Changeset 49150 in vbox for trunk/src/VBox/HostDrivers/Support
- Timestamp:
- Oct 17, 2013 7:22:02 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/win/SUPLib-win.cpp
r44528 r49150 38 38 #endif 39 39 40 #include <Windows.h> 40 #define USE_NT_DEVICE_IO_CONTROL_FILE 41 #ifdef USE_NT_DEVICE_IO_CONTROL_FILE 42 # include <iprt/nt/nt-and-windows.h> 43 #else 44 # include <Windows.h> 45 #endif 41 46 42 47 #include <VBox/sup.h> … … 75 80 static int suplibOsStartService(void); 76 81 static int suplibOsStopService(void); 82 #ifdef USE_NT_DEVICE_IO_CONTROL_FILE 83 static int suplibConvertNtStatus(NTSTATUS rcNt); 84 #else 77 85 static int suplibConvertWin32Err(int); 86 #endif 78 87 79 88 … … 496 505 PSUPREQHDR pHdr = (PSUPREQHDR)pvReq; 497 506 Assert(cbReq == RT_MAX(pHdr->cbIn, pHdr->cbOut)); 507 # ifdef USE_NT_DEVICE_IO_CONTROL_FILE 508 IO_STATUS_BLOCK Ios; 509 Ios.Status = -1; 510 Ios.Information = 0; 511 NTSTATUS rcNt = NtDeviceIoControlFile((HANDLE)pThis->hDevice, NULL /*hEvent*/, NULL /*pfnApc*/, NULL /*pvApcCtx*/, &Ios, 512 (ULONG)uFunction, 513 pvReq /*pvInput */, pHdr->cbIn /* cbInput */, 514 pvReq /*pvOutput*/, pHdr->cbOut /* cbOutput */); 515 if (NT_SUCCESS(rcNt)) 516 { 517 if (NT_SUCCESS(Ios.Status)) 518 return VINF_SUCCESS; 519 rcNt = Ios.Status; 520 } 521 return suplibConvertNtStatus(rcNt); 522 523 # else 498 524 DWORD cbReturned = (ULONG)pHdr->cbOut; 499 525 if (DeviceIoControl((HANDLE)pThis->hDevice, uFunction, pvReq, pHdr->cbIn, pvReq, cbReturned, &cbReturned, NULL)) 500 526 return 0; 501 527 return suplibConvertWin32Err(GetLastError()); 528 # endif 502 529 } 503 530 … … 508 535 * Issue device I/O control. 509 536 */ 537 # ifdef USE_NT_DEVICE_IO_CONTROL_FILE 538 IO_STATUS_BLOCK Ios; 539 Ios.Status = -1; 540 Ios.Information = 0; 541 NTSTATUS rcNt = NtDeviceIoControlFile((HANDLE)pThis->hDevice, NULL /*hEvent*/, NULL /*pfnApc*/, NULL /*pvApcCtx*/, &Ios, 542 (ULONG)uFunction, 543 (PVOID)idCpu /*pvInput */, 0 /* cbInput */, 544 NULL /*pvOutput*/, 0 /* cbOutput */); 545 if (NT_SUCCESS(rcNt)) 546 { 547 if (NT_SUCCESS(Ios.Status)) 548 return VINF_SUCCESS; 549 rcNt = Ios.Status; 550 } 551 return suplibConvertNtStatus(rcNt); 552 # else 510 553 DWORD cbReturned = 0; 511 554 if (DeviceIoControl((HANDLE)pThis->hDevice, uFunction, NULL, 0, (LPVOID)idCpu, 0, &cbReturned, NULL)) 512 555 return VINF_SUCCESS; 513 556 return suplibConvertWin32Err(GetLastError()); 557 # endif 514 558 } 515 559 … … 521 565 if (*ppvPages) 522 566 return VINF_SUCCESS; 523 return suplibConvertWin32Err(GetLastError());567 return RTErrConvertFromWin32(GetLastError()); 524 568 } 525 569 … … 530 574 if (VirtualFree(pvPages, 0, MEM_RELEASE)) 531 575 return VINF_SUCCESS; 532 return suplibConvertWin32Err(GetLastError()); 533 } 534 535 576 return RTErrConvertFromWin32(GetLastError()); 577 } 578 579 580 # ifndef USE_NT_DEVICE_IO_CONTROL_FILE 536 581 /** 537 582 * Converts a supdrv win32 error code to an IPRT status code. … … 585 630 return RTErrConvertFromWin32(rc); 586 631 } 632 # else 633 /** 634 * Reverse of VBoxDrvNtErr2NtStatus 635 * returns VBox status code. 636 * @param rcNt NT status code. 637 */ 638 static int suplibConvertNtStatus(NTSTATUS rcNt) 639 { 640 switch (rcNt) 641 { 642 case STATUS_SUCCESS: return VINF_SUCCESS; 643 case STATUS_NOT_SUPPORTED: return VERR_GENERAL_FAILURE; 644 case STATUS_INVALID_PARAMETER: return VERR_INVALID_PARAMETER; 645 case STATUS_UNKNOWN_REVISION: return VERR_INVALID_MAGIC; 646 case STATUS_INVALID_HANDLE: return VERR_INVALID_HANDLE; 647 case STATUS_INVALID_ADDRESS: return VERR_INVALID_POINTER; 648 case STATUS_NOT_LOCKED: return VERR_LOCK_FAILED; 649 case STATUS_IMAGE_ALREADY_LOADED: return VERR_ALREADY_LOADED; 650 case STATUS_ACCESS_DENIED: return VERR_PERMISSION_DENIED; 651 case STATUS_REVISION_MISMATCH: return VERR_VERSION_MISMATCH; 652 } 653 654 /* Fall back on IPRT for the rest. */ 655 return RTErrConvertFromNtStatus(rcNt); 656 } 657 # endif 587 658 588 659 #endif /* !IN_SUP_HARDENED_R3 */
Note:
See TracChangeset
for help on using the changeset viewer.