Changeset 44979 in vbox for trunk/src/VBox
- Timestamp:
- Mar 11, 2013 12:10:18 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84199
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win-legacy.cpp
r32474 r44979 1 /* $Id$ */ 1 2 /** @file 2 *3 3 * VBoxGuest-win-legacy - Windows NT4 specifics. 4 * 5 * Copyright (C) 2010 Oracle Corporation 4 */ 5 6 /* 7 * Copyright (C) 2010-2013 Oracle Corporation 6 8 * 7 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 41 43 *******************************************************************************/ 42 44 RT_C_DECLS_BEGIN 43 NTSTATUS vboxguestwinnt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath); 44 static NTSTATUS vboxguestwinnt4FindPCIDevice(PULONG pBusNumber, PPCI_SLOT_NUMBER pSlotNumber); 45 static NTSTATUS vbgdNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber); 45 46 RT_C_DECLS_END 46 47 47 48 #ifdef ALLOC_PRAGMA 48 # pragma alloc_text (INIT, vboxguestwinnt4CreateDevice)49 # pragma alloc_text (INIT, vboxguestwinnt4FindPCIDevice)49 # pragma alloc_text(INIT, vbgdNt4CreateDevice) 50 # pragma alloc_text(INIT, vbgdNt4FindPciDevice) 50 51 #endif 51 52 … … 56 57 * @returns NT status code. 57 58 * 58 * @param pDrvObj59 * @param pDevObj60 * @param pRegPath61 */ 62 NTSTATUS vb oxguestwinnt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)59 * @param pDrvObj The driver object. 60 * @param pDevObj Unused. NULL. Dunno why it's here, makes no sense. 61 * @param pRegPath The driver registry path. 62 */ 63 NTSTATUS vbgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath) 63 64 { 64 int vrc = VINF_SUCCESS; 65 NTSTATUS rc = STATUS_SUCCESS; 66 67 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: pDrvObj=%p, pDevObj=%p, pRegPath=%p\n", 68 pDrvObj, pDevObj, pRegPath)); 65 Log(("VBoxGuest::vbgdNt4CreateDevice: pDrvObj=%p, pDevObj=%p, pRegPath=%p\n", pDrvObj, pDevObj, pRegPath)); 69 66 70 67 /* 71 68 * Find our virtual PCI device 72 69 */ 73 ULONG uBusNumber, uSlotNumber; 74 rc = vboxguestwinnt4FindPCIDevice(&uBusNumber, (PCI_SLOT_NUMBER*)&uSlotNumber); 70 ULONG uBusNumber; 71 PCI_SLOT_NUMBER SlotNumber; 72 NTSTATUS rc = vbgdNt4FindPciDevice(&uBusNumber, &SlotNumber); 75 73 if (NT_ERROR(rc)) 76 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Device not found!\n")); 77 78 bool fSymbolicLinkCreated = false; 79 UNICODE_STRING szDosName; 74 { 75 Log(("VBoxGuest::vbgdNt4CreateDevice: Device not found!\n")); 76 return rc; 77 } 78 79 /* 80 * Create device. 81 */ 82 UNICODE_STRING szDevName; 83 RtlInitUnicodeString(&szDevName, VBOXGUEST_DEVICE_NAME_NT); 80 84 PDEVICE_OBJECT pDeviceObject = NULL; 85 rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXT), &szDevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject); 81 86 if (NT_SUCCESS(rc)) 82 87 { 83 /* 84 * Create device. 85 */ 86 UNICODE_STRING szDevName; 87 RtlInitUnicodeString(&szDevName, VBOXGUEST_DEVICE_NAME_NT); 88 rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXT), &szDevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject); 88 Log(("VBoxGuest::vbgdNt4CreateDevice: Device created\n")); 89 90 UNICODE_STRING DosName; 91 RtlInitUnicodeString(&DosName, VBOXGUEST_DEVICE_NAME_DOS); 92 rc = IoCreateSymbolicLink(&DosName, &szDevName); 89 93 if (NT_SUCCESS(rc)) 90 94 { 91 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Device created\n")); 92 93 RtlInitUnicodeString(&szDosName, VBOXGUEST_DEVICE_NAME_DOS); 94 rc = IoCreateSymbolicLink(&szDosName, &szDevName); 95 Log(("VBoxGuest::vbgdNt4CreateDevice: Symlink created\n")); 96 97 /* 98 * Setup the device extension. 99 */ 100 Log(("VBoxGuest::vbgdNt4CreateDevice: Setting up device extension ...\n")); 101 102 PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pDeviceObject->DeviceExtension; 103 RtlZeroMemory(pDevExt, sizeof(VBOXGUESTDEVEXT)); 104 105 Log(("VBoxGuest::vbgdNt4CreateDevice: Device extension created\n")); 106 107 /* Store a reference to ourself. */ 108 pDevExt->win.s.pDeviceObject = pDeviceObject; 109 110 /* Store bus and slot number we've queried before. */ 111 pDevExt->win.s.busNumber = uBusNumber; 112 pDevExt->win.s.slotNumber = SlotNumber.u.AsULONG; 113 114 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 115 rc = hlpRegisterBugCheckCallback(pDevExt); 116 #endif 117 118 /* Do the actual VBox init ... */ 95 119 if (NT_SUCCESS(rc)) 96 120 { 97 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Symlink created\n")); 98 fSymbolicLinkCreated = true; 121 rc = vboxguestwinInit(pDrvObj, pDeviceObject, pRegPath); 122 if (NT_SUCCESS(rc)) 123 { 124 Log(("VBoxGuest::vbgdNt4CreateDevice: Returning rc = 0x%x (succcess)\n", rc)); 125 return rc; 126 } 127 128 /* bail out */ 99 129 } 100 else 101 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc)); 130 IoDeleteSymbolicLink(&DosName); 102 131 } 103 132 else 104 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc)); 133 Log(("VBoxGuest::vbgdNt4CreateDevice: IoCreateSymbolicLink failed with rc = %#x\n", rc)); 134 IoDeleteDevice(pDeviceObject); 105 135 } 106 107 /* 108 * Setup the device extension. 109 */ 110 PVBOXGUESTDEVEXT pDevExt = NULL; 111 if (NT_SUCCESS(rc)) 112 { 113 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Setting up device extension ...\n")); 114 115 pDevExt = (PVBOXGUESTDEVEXT)pDeviceObject->DeviceExtension; 116 RtlZeroMemory(pDevExt, sizeof(VBOXGUESTDEVEXT)); 117 } 118 119 if (NT_SUCCESS(rc) && pDevExt) 120 { 121 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Device extension created\n")); 122 123 /* Store a reference to ourself. */ 124 pDevExt->win.s.pDeviceObject = pDeviceObject; 125 126 /* Store bus and slot number we've queried before. */ 127 pDevExt->win.s.busNumber = uBusNumber; 128 pDevExt->win.s.slotNumber = uSlotNumber; 129 130 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 131 rc = hlpRegisterBugCheckCallback(pDevExt); 132 #endif 133 } 134 135 /* Do the actual VBox init ... */ 136 if (NT_SUCCESS(rc)) 137 rc = vboxguestwinInit(pDrvObj, pDeviceObject, pRegPath); 138 139 /* Clean up in case of errors. */ 140 if (NT_ERROR(rc)) 141 { 142 if (fSymbolicLinkCreated && szDosName.Length > 0) 143 IoDeleteSymbolicLink(&szDosName); 144 if (pDeviceObject) 145 IoDeleteDevice(pDeviceObject); 146 } 147 148 Log(("VBoxGuest::vboxguestwinnt4CreateDevice: Returning rc = 0x%x\n", rc)); 136 else 137 Log(("VBoxGuest::vbgdNt4CreateDevice: IoCreateDevice failed with rc = %#x\n", rc)); 138 Log(("VBoxGuest::vbgdNt4CreateDevice: Returning rc = 0x%x\n", rc)); 149 139 return rc; 150 140 } … … 156 146 * @returns NT status code. 157 147 * 158 * @param pBusNumber 159 * @param pSlotNumber 160 * 161 */ 162 static NTSTATUS vboxguestwinnt4FindPCIDevice(PULONG pBusNumber, PPCI_SLOT_NUMBER pSlotNumber) 148 * @param pulBusNumber Where to return the bus number on success. 149 * @param pSlotNumber Where to return the slot number on success. 150 */ 151 static NTSTATUS vbgdNt4FindPciDevice(PULONG pulBusNumber, PPCI_SLOT_NUMBER pSlotNumber) 163 152 { 164 NTSTATUS rc; 165 166 ULONG busNumber; 167 ULONG deviceNumber; 168 ULONG functionNumber; 169 PCI_SLOT_NUMBER slotNumber; 170 PCI_COMMON_CONFIG pciData; 171 172 Log(("VBoxGuest::vboxguestwinnt4FindPCIDevice\n")); 173 174 rc = STATUS_DEVICE_DOES_NOT_EXIST; 175 slotNumber.u.AsULONG = 0; 153 Log(("VBoxGuest::vbgdNt4FindPciDevice\n")); 154 155 PCI_SLOT_NUMBER SlotNumber; 156 SlotNumber.u.AsULONG = 0; 176 157 177 158 /* Scan each bus. */ 178 for ( busNumber = 0; busNumber < PCI_MAX_BUSES; busNumber++)159 for (ULONG ulBusNumber = 0; ulBusNumber < PCI_MAX_BUSES; ulBusNumber++) 179 160 { 180 161 /* Scan each device. */ 181 for ( deviceNumber = 0; deviceNumber < PCI_MAX_DEVICES; deviceNumber++)162 for (ULONG deviceNumber = 0; deviceNumber < PCI_MAX_DEVICES; deviceNumber++) 182 163 { 183 slotNumber.u.bits.DeviceNumber = deviceNumber;164 SlotNumber.u.bits.DeviceNumber = deviceNumber; 184 165 185 166 /* Scan each function (not really required...). */ 186 for ( functionNumber = 0; functionNumber < PCI_MAX_FUNCTION; functionNumber++)167 for (ULONG functionNumber = 0; functionNumber < PCI_MAX_FUNCTION; functionNumber++) 187 168 { 188 slotNumber.u.bits.FunctionNumber = functionNumber;169 SlotNumber.u.bits.FunctionNumber = functionNumber; 189 170 190 171 /* Have a look at what's in this slot. */ 191 if (!HalGetBusData(PCIConfiguration, busNumber, slotNumber.u.AsULONG,192 &pciData, sizeof(ULONG)))172 PCI_COMMON_CONFIG PciData; 173 if (!HalGetBusData(PCIConfiguration, ulBusNumber, SlotNumber.u.AsULONG, &PciData, sizeof(ULONG))) 193 174 { 194 175 /* No such bus, we're done with it. */ … … 197 178 } 198 179 199 if (pciData.VendorID == PCI_INVALID_VENDORID) 200 { 180 if (PciData.VendorID == PCI_INVALID_VENDORID) 201 181 /* We have to proceed to the next function. */ 202 182 continue; 203 }204 183 205 184 /* Check if it's another device. */ 206 if ((pciData.VendorID != VMMDEV_VENDORID) || 207 (pciData.DeviceID != VMMDEV_DEVICEID)) 208 { 185 if ( PciData.VendorID != VMMDEV_VENDORID 186 || PciData.DeviceID != VMMDEV_DEVICEID) 209 187 continue; 210 }211 188 212 189 /* Hooray, we've found it! */ 213 Log(("VBoxGuest::vb oxguestwinnt4FindPCIDevice: Device found!\n"));214 215 *p BusNumber = busNumber;216 *pSlotNumber = slotNumber;217 r c =STATUS_SUCCESS;190 Log(("VBoxGuest::vbgdNt4FindPciDevice: Device found!\n")); 191 192 *pulBusNumber = ulBusNumber; 193 *pSlotNumber = SlotNumber; 194 return STATUS_SUCCESS; 218 195 } 219 196 } 220 197 } 221 198 222 return rc;199 return STATUS_DEVICE_DOES_NOT_EXIST; 223 200 } 224 201 -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r44529 r44979 162 162 pDrvObj->MajorFunction[IRP_MJ_WRITE] = vboxguestwinNotSupportedStub; 163 163 #ifdef TARGET_NT4 164 rc = vb oxguestwinnt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);164 rc = vbgdNt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath); 165 165 #else 166 166 pDrvObj->MajorFunction[IRP_MJ_PNP] = vboxguestwinPnP; -
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.h
r44529 r44979 163 163 RT_C_DECLS_BEGIN 164 164 #ifdef TARGET_NT4 165 NTSTATUS vb oxguestwinnt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath);165 NTSTATUS vbgdNt4CreateDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath); 166 166 NTSTATUS vboxguestwinInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath); 167 167 #else
Note:
See TracChangeset
for help on using the changeset viewer.