diff --git a/src/hvpp/hvpp/hvpp.cpp b/src/hvpp/hvpp/hvpp.cpp index 14556a6..d95e89d 100644 --- a/src/hvpp/hvpp/hvpp.cpp +++ b/src/hvpp/hvpp/hvpp.cpp @@ -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 ) { @@ -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 ////////////////////////////////////////////////////////////////////////// @@ -273,7 +286,7 @@ HvppStart( // Start the hypervisor. // - return ErrorCodeToNtStatus(hypervisor::start(*c_exit_handler)); + return HvppErrorCodeToNtStatus(hypervisor::start(*c_exit_handler)); } VOID diff --git a/src/hvpp/hvpp/lib/win32/driver.cpp b/src/hvpp/hvpp/lib/win32/driver.cpp index f2e9bef..dbd1e36 100644 --- a/src/hvpp/hvpp/lib/win32/driver.cpp +++ b/src/hvpp/hvpp/lib/win32/driver.cpp @@ -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 @@ -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); @@ -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; @@ -188,5 +177,5 @@ DriverEntry( // DriverObject->DriverUnload = &DriverUnload; - return ErrorCodeToNtStatus(err); + return HvppErrorCodeToNtStatus(err); }