Changeset 44989 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Mar 11, 2013 2:40:02 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-win.cpp
r44988 r44989 28 28 #include <VBox/log.h> 29 29 #include <VBox/VBoxGuestLib.h> 30 #include <iprt/string.h> 30 31 31 32 /* … … 206 207 * Create device. 207 208 */ 209 UNICODE_STRING DevName; 210 RtlInitUnicodeString(&DevName, VBOXGUEST_DEVICE_NAME_NT); 208 211 PDEVICE_OBJECT pDeviceObject = NULL; 209 PVBOXGUESTDEVEXTWIN pDevExt = NULL; 210 UNICODE_STRING devName; 211 UNICODE_STRING win32Name; 212 RtlInitUnicodeString(&devName, VBOXGUEST_DEVICE_NAME_NT); 213 rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), &devName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject); 212 rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), &DevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject); 214 213 if (NT_SUCCESS(rc)) 215 214 { … … 217 216 * Create symbolic link (DOS devices). 218 217 */ 219 RtlInitUnicodeString(&win32Name, VBOXGUEST_DEVICE_NAME_DOS); 220 rc = IoCreateSymbolicLink(&win32Name, &devName); 218 UNICODE_STRING DosName; 219 RtlInitUnicodeString(&DosName, VBOXGUEST_DEVICE_NAME_DOS); 220 rc = IoCreateSymbolicLink(&DosName, &DevName); 221 221 if (NT_SUCCESS(rc)) 222 222 { … … 224 224 * Setup the device extension. 225 225 */ 226 pDevExt = (PVBOXGUESTDEVEXTWIN)pDeviceObject->DeviceExtension;227 R tlZeroMemory(pDevExt, sizeof(VBOXGUESTDEVEXT));226 PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDeviceObject->DeviceExtension; 227 RT_ZERO(*pDevExt); 228 228 229 229 KeInitializeSpinLock(&pDevExt->MouseEventAccessLock); … … 234 234 235 235 pDevExt->pNextLowerDriver = IoAttachDeviceToDeviceStack(pDeviceObject, pDevObj); 236 if (pDevExt->pNextLowerDriver == NULL) 236 if (pDevExt->pNextLowerDriver != NULL) 237 { 238 /* 239 * If we reached this point we're fine with the basic driver setup, 240 * so continue to init our own things. 241 */ 242 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION 243 vbgdNtBugCheckCallback(pDevExt); /* Ignore failure! */ 244 #endif 245 if (NT_SUCCESS(rc)) 246 { 247 /* VBoxGuestPower is pageable; ensure we are not called at elevated IRQL */ 248 pDeviceObject->Flags |= DO_POWER_PAGABLE; 249 250 /* Driver is ready now. */ 251 pDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; 252 Log(("VBoxGuest::vbgdNtGuestAddDevice: returning with rc = 0x%x (success)\n", rc)); 253 return rc; 254 } 255 256 IoDetachDevice(pDevExt->pNextLowerDriver); 257 } 258 else 237 259 { 238 260 Log(("VBoxGuest::vbgdNtGuestAddDevice: IoAttachDeviceToDeviceStack did not give a nextLowerDriver!\n")); 239 261 rc = STATUS_DEVICE_NOT_CONNECTED; 240 262 } 263 264 /* bail out */ 265 IoDeleteSymbolicLink(&DosName); 241 266 } 242 267 else 243 268 Log(("VBoxGuest::vbgdNtGuestAddDevice: IoCreateSymbolicLink failed with rc=%#x!\n", rc)); 269 IoDeleteDevice(pDeviceObject); 244 270 } 245 271 else 246 272 Log(("VBoxGuest::vbgdNtGuestAddDevice: IoCreateDevice failed with rc=%#x!\n", rc)); 247 248 if (NT_SUCCESS(rc))249 {250 /*251 * If we reached this point we're fine with the basic driver setup,252 * so continue to init our own things.253 */254 #ifdef VBOX_WITH_GUEST_BUGCHECK_DETECTION255 vbgdNtBugCheckCallback(pDevExt); /* Ignore failure! */256 #endif257 /* VBoxGuestPower is pageable; ensure we are not called at elevated IRQL */258 pDeviceObject->Flags |= DO_POWER_PAGABLE;259 260 /* Driver is ready now. */261 pDeviceObject->Flags &= ~DO_DEVICE_INITIALIZING;262 }263 264 /* Cleanup on error. */265 if (NT_ERROR(rc))266 {267 if (pDevExt)268 {269 if (pDevExt->pNextLowerDriver)270 IoDetachDevice(pDevExt->pNextLowerDriver);271 }272 IoDeleteSymbolicLink(&win32Name);273 if (pDeviceObject)274 IoDeleteDevice(pDeviceObject);275 }276 277 273 Log(("VBoxGuest::vbgdNtGuestAddDevice: returning with rc = 0x%x\n", rc)); 278 274 return rc; … … 810 806 if ( vrc == VERR_NOT_SUPPORTED 811 807 || vrc == VERR_INVALID_PARAMETER) 812 {813 808 Status = STATUS_INVALID_PARAMETER; 814 }815 809 else if (vrc == VERR_OUT_OF_RANGE) 816 810 Status = STATUS_INVALID_BUFFER_SIZE;
Note:
See TracChangeset
for help on using the changeset viewer.