- Timestamp:
- Jun 15, 2011 4:38:56 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r37226 r37474 26 26 #include <VBox/VBoxGuestLib.h> 27 27 28 #include <VBoxGuestInternal.h>29 30 #ifdef TARGET_NT431 28 /* 32 29 * XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist 33 30 * on NT4, so... The same for ExAllocatePool. 34 31 */ 35 #undef ExAllocatePool 36 #undef ExFreePool 32 #ifdef TARGET_NT4 33 # undef ExAllocatePool 34 # undef ExFreePool 37 35 #endif 38 36 39 37 /******************************************************************************* 40 * Defined Constants And Macros * 41 *******************************************************************************/ 42 43 44 /******************************************************************************* 45 * Entry Points * 38 * Internal Functions * 46 39 *******************************************************************************/ 47 40 RT_C_DECLS_BEGIN … … 55 48 static NTSTATUS vboxguestwinShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp); 56 49 static NTSTATUS vboxguestwinNotSupportedStub(PDEVICE_OBJECT pDevObj, PIRP pIrp); 57 RT_C_DECLS_END58 59 60 /*******************************************************************************61 * Internal Functions *62 *******************************************************************************/63 RT_C_DECLS_BEGIN64 50 #ifdef DEBUG 65 static voidvboxguestwinDoTests(void);51 static void vboxguestwinDoTests(void); 66 52 #endif 67 53 RT_C_DECLS_END … … 544 530 * @param pDrvObj Driver object. 545 531 */ 546 void vboxguestwinUnload(PDRIVER_OBJECT pDrvObj)532 static void vboxguestwinUnload(PDRIVER_OBJECT pDrvObj) 547 533 { 548 534 Log(("VBoxGuest::vboxguestwinGuestUnload\n")); … … 579 565 * @param pIrp Request packet. 580 566 */ 581 NTSTATUS vboxguestwinCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)567 static NTSTATUS vboxguestwinCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp) 582 568 { 583 569 /** @todo AssertPtrReturn(pIrp); */ … … 648 634 * @param pIrp Request packet. 649 635 */ 650 NTSTATUS vboxguestwinClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)636 static NTSTATUS vboxguestwinClose(PDEVICE_OBJECT pDevObj, PIRP pIrp) 651 637 { 652 638 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension; … … 679 665 * @param pIrp Request packet. 680 666 */ 681 NTSTATUS vboxguestwinIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)682 { 683 NTSTATUS Status= STATUS_SUCCESS;684 PVBOXGUESTDEVEXT pDevExt= (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension;685 PIO_STACK_LOCATION pStack= IoGetCurrentIrpStackLocation(pIrp);686 unsigned int uCmd= (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;687 688 char *pBuf= (char *)pIrp->AssociatedIrp.SystemBuffer; /* All requests are buffered. */689 size_t cbData= pStack->Parameters.DeviceIoControl.InputBufferLength;690 unsigned cbOut= 0;667 static NTSTATUS vboxguestwinIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 668 { 669 NTSTATUS Status = STATUS_SUCCESS; 670 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension; 671 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 672 unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode; 673 674 char *pBuf = (char *)pIrp->AssociatedIrp.SystemBuffer; /* All requests are buffered. */ 675 size_t cbData = pStack->Parameters.DeviceIoControl.InputBufferLength; 676 unsigned cbOut = 0; 691 677 692 678 /* Do we have a file object associated?*/ 693 PFILE_OBJECT pFileObj = pStack->FileObject;694 PVBOXGUESTSESSION pSession = NULL;679 PFILE_OBJECT pFileObj = pStack->FileObject; 680 PVBOXGUESTSESSION pSession = NULL; 695 681 if (pFileObj) /* ... then we might have a session object as well! */ 696 682 pSession = (PVBOXGUESTSESSION)pFileObj->FsContext; … … 701 687 /* We don't have a session associated with the file object? So this seems 702 688 * to be a kernel call then. */ 689 /** @todo r=bird: What on earth is this supposed to be? Each kernel session 690 * shall have its own context of course, no hacks, pleeease. */ 703 691 if (pSession == NULL) 704 692 { … … 758 746 */ 759 747 size_t cbDataReturned; 760 int vrc = VBoxGuestCommonIOCtl(uCmd, pDevExt, pSession, (void*)pBuf, cbData, &cbDataReturned);748 int vrc = VBoxGuestCommonIOCtl(uCmd, pDevExt, pSession, pBuf, cbData, &cbDataReturned); 761 749 762 750 Log(("VBoxGuest::vboxguestwinGuestDeviceControl: rc=%Rrc, pBuf=0x%p, cbData=%u, cbDataReturned=%u\n", … … 797 785 } 798 786 799 /* we do not want to allow some IOCTLs to be originated from user mode, 800 * this is why we have a separate vboxguestwinInternalIOCtl for internal IOCTLs */ 801 NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 802 { 803 NTSTATUS Status = STATUS_SUCCESS; 804 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension; 805 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 806 unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode; 807 BOOLEAN fProcessed = FALSE; 808 unsigned Info = 0; 787 /** 788 * Internal Device I/O Control entry point. 789 * 790 * We do not want to allow some IOCTLs to be originated from user mode, this is 791 * why we have a different entry point for internal IOCTLs. 792 * 793 * @param pDevObj Device object. 794 * @param pIrp Request packet. 795 * 796 * @todo r=bird: This is no need for this extra function for the purpose of 797 * securing an IOCTL from user space access. VBoxGuestCommonIOCtl 798 * has a way to do this already, see VBOXGUEST_IOCTL_GETVMMDEVPORT. 799 */ 800 static NTSTATUS vboxguestwinInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp) 801 { 802 NTSTATUS Status = STATUS_SUCCESS; 803 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDevObj->DeviceExtension; 804 PIO_STACK_LOCATION pStack = IoGetCurrentIrpStackLocation(pIrp); 805 unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode; 806 bool fProcessed = false; 807 unsigned Info = 0; 809 808 810 809 switch (uCmd) … … 1265 1264 } 1266 1265 1267 1268 1266 #ifdef DEBUG 1269 /** A quick implementation of AtomicTestAndClear for uint32_t and multiple 1270 * bits. 1267 1268 /** 1269 * A quick implementation of AtomicTestAndClear for uint32_t and multiple bits. 1271 1270 */ 1272 1271 static uint32_t vboxugestwinAtomicBitsTestAndClear(void *pu32Bits, uint32_t u32Mask) … … 1317 1316 vboxguestwinTestAtomicTestAndClearBitsU32(0x22, 0x23, 0x22); 1318 1317 } 1319 #endif 1318 1319 #endif /* DEBUG */ 1320
Note:
See TracChangeset
for help on using the changeset viewer.