branch update for HEAD-2003050101
[reactos.git] / ntoskrnl / io / device.c
index 40551eb..57fde3f 100644 (file)
@@ -627,7 +627,6 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
 {
    PDEVICE_OBJECT CreatedDeviceObject;
    OBJECT_ATTRIBUTES ObjectAttributes;
-   HANDLE DeviceHandle;
    NTSTATUS Status;
    
    assert_irql(PASSIVE_LEVEL);
@@ -637,6 +636,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
    assert(sizeof(CreatedDeviceObject->Dpc) == 32);
    assert(sizeof(CreatedDeviceObject->DeviceLock) == 16);
    assert(sizeof(DEVICE_OBJECT) == 184);
+   assert(sizeof(DEVICE_OBJECT) == 0xB8);
 
    if (DeviceName != NULL)
      {
@@ -660,7 +660,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
    if (DeviceName != NULL)
      {
        InitializeObjectAttributes(&ObjectAttributes,DeviceName,0,NULL,NULL);
-       Status = ObCreateObject(&DeviceHandle,
+       Status = ObCreateObject(NULL,
                                0,
                                &ObjectAttributes,
                                IoDeviceObjectType,
@@ -668,7 +668,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
      }
    else
      {
-       Status = ObCreateObject(&DeviceHandle,
+       Status = ObCreateObject(NULL,
                                0,
                                NULL,
                                IoDeviceObjectType,
@@ -704,7 +704,10 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
      }
   
   CreatedDeviceObject->Type = DeviceType;
-  CreatedDeviceObject->Size = sizeof (*CreatedDeviceObject);
+   /* W32 (ntfs) expects CreatedDeviceObject->Size to cover even 'DeviceExtensionSize'.
+    * Undocumented by W32!
+    */
+  CreatedDeviceObject->Size = sizeof (DEVICE_OBJECT) + DeviceExtensionSize;
   CreatedDeviceObject->ReferenceCount = 0;     /* or 1? it is floating unused this way */
   CreatedDeviceObject->DriverObject = DriverObject;
   CreatedDeviceObject->CurrentIrp = NULL;
@@ -737,6 +740,13 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
                    DeviceExtensionSize);
     }
 
+#ifdef LIBCAPTIVE
+  /* Magic value expected by ntfs.sys NT5.1sp1 _NtfsInitializeIrpContext()
+   */
+  if (DeviceExtensionSize>=0x2A)
+    *(USHORT *)(((UCHAR *)CreatedDeviceObject->DeviceExtension)+0x28)=0x0701;
+#endif /* LIBCAPTIVE */
+
   CreatedDeviceObject->AttachedDevice = NULL;
   CreatedDeviceObject->DeviceType = DeviceType;
   CreatedDeviceObject->StackSize = 1;