[VCDROM] Implement the virtual CD-ROM class driver.
[reactos.git] / ntoskrnl / config / cmwraprs.c
index a3948b9..0f5e47d 100644 (file)
@@ -82,9 +82,13 @@ CmpFileRead(IN PHHIVE RegistryHive,
     IO_STATUS_BLOCK IoStatusBlock;
     NTSTATUS Status;
 
+    /* Just return success if no file is associated with this hive */
+    if (HiveHandle == NULL)
+        return TRUE;
+
     _FileOffset.QuadPart = *FileOffset;
-    Status = ZwReadFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
-                       Buffer, (ULONG)BufferLength, &_FileOffset, 0);
+    Status = ZwReadFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
+                        Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
     return NT_SUCCESS(Status) ? TRUE : FALSE;
 }
 
@@ -102,9 +106,17 @@ CmpFileWrite(IN PHHIVE RegistryHive,
     IO_STATUS_BLOCK IoStatusBlock;
     NTSTATUS Status;
 
+    /* Just return success if no file is associated with this hive */
+    if (HiveHandle == NULL)
+        return TRUE;
+
+    /* Don't do anything if we're not supposed to */
+    if (CmpNoWrite)
+        return TRUE;
+
     _FileOffset.QuadPart = *FileOffset;
-    Status = ZwWriteFile(HiveHandle, 0, 0, 0, &IoStatusBlock,
-                       Buffer, (ULONG)BufferLength, &_FileOffset, 0);
+    Status = ZwWriteFile(HiveHandle, NULL, NULL, NULL, &IoStatusBlock,
+                         Buffer, (ULONG)BufferLength, &_FileOffset, NULL);
     return NT_SUCCESS(Status) ? TRUE : FALSE;
 }
 
@@ -122,6 +134,10 @@ CmpFileSetSize(IN PHHIVE RegistryHive,
     IO_STATUS_BLOCK IoStatusBlock;
     NTSTATUS Status;
 
+    /* Just return success if no file is associated with this hive */
+    if (HiveHandle == NULL)
+        return TRUE;
+
     EndOfFileInfo.EndOfFile.QuadPart = FileSize;
     Status = ZwSetInformationFile(HiveHandle,
                                   &IoStatusBlock,
@@ -153,6 +169,14 @@ CmpFileFlush(IN PHHIVE RegistryHive,
     IO_STATUS_BLOCK IoStatusBlock;
     NTSTATUS Status;
 
+    /* Just return success if no file is associated with this hive */
+    if (HiveHandle == NULL)
+        return TRUE;
+
+    /* Don't do anything if we're not supposed to */
+    if (CmpNoWrite)
+        return TRUE;
+
     Status = ZwFlushBuffersFile(HiveHandle, &IoStatusBlock);
     return NT_SUCCESS(Status) ? TRUE : FALSE;
 }