Skip to content

Commit

Permalink
add HvppNtStatusToErrorCode()/HvppErrorCodeToNtStatus()
Browse files Browse the repository at this point in the history
  • Loading branch information
wbenny committed Oct 31, 2019
1 parent b839eff commit c7cba16
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
23 changes: 18 additions & 5 deletions src/hvpp/hvpp/hvpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ using namespace hvpp;
#define vcpu_ ((vcpu_t*)Vcpu)
#define ept_ ((ept_t*)Ept)

extern "C" {

static
NTSTATUS
NTAPI
ErrorCodeToNtStatus(
HvppErrorCodeToNtStatus(
error_code_t error
)
{
Expand All @@ -34,6 +31,22 @@ ErrorCodeToNtStatus(
: STATUS_UNSUCCESSFUL;
}

error_code_t
NTAPI
HvppNtStatusToErrorCode(
NTSTATUS Status
)
{
if (!NT_SUCCESS(Status))
{
return make_error_code_t(std::errc::operation_not_supported);
}

return {};
}

extern "C" {

//////////////////////////////////////////////////////////////////////////
// ept.h
//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -273,7 +286,7 @@ HvppStart(
// Start the hypervisor.
//

return ErrorCodeToNtStatus(hypervisor::start(*c_exit_handler));
return HvppErrorCodeToNtStatus(hypervisor::start(*c_exit_handler));
}

VOID
Expand Down
19 changes: 4 additions & 15 deletions src/hvpp/hvpp/lib/win32/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,11 @@ namespace driver
void* end_address = nullptr;
}

static
NTSTATUS
NTAPI
ErrorCodeToNtStatus(
HvppErrorCodeToNtStatus(
error_code_t error
)
{
//
// TODO: Something meaningful...
//
return !error
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL;
}

);

NTSTATUS
NTAPI
Expand Down Expand Up @@ -130,7 +120,7 @@ DriverDispatch(
//
// Complete the I/O request.
//
Irp->IoStatus.Status = ErrorCodeToNtStatus(err);
Irp->IoStatus.Status = HvppErrorCodeToNtStatus(err);
Irp->IoStatus.Information = BytesTransferred;

IoCompleteRequest(Irp, IO_NO_INCREMENT);
Expand Down Expand Up @@ -170,7 +160,6 @@ DriverEntry(
UNREFERENCED_PARAMETER(RegistryPath);

GlobalDriverObject = DriverObject;

DriverObject->MajorFunction[IRP_MJ_CREATE] = &DriverDispatch;
DriverObject->MajorFunction[IRP_MJ_CLOSE] = &DriverDispatch;
DriverObject->MajorFunction[IRP_MJ_READ] = &DriverDispatch;
Expand All @@ -188,5 +177,5 @@ DriverEntry(
//
DriverObject->DriverUnload = &DriverUnload;

return ErrorCodeToNtStatus(err);
return HvppErrorCodeToNtStatus(err);
}

0 comments on commit c7cba16

Please sign in to comment.