Synchronize up to trunk's revision r57784.
[reactos.git] / drivers / filters / mountmgr / mountmgr.c
index 44ef916..229a00a 100644 (file)
 /* FIXME */
 GUID MountedDevicesGuid = {0x53F5630D, 0xB6BF, 0x11D0, {0x94, 0xF2, 0x00, 0xA0, 0xC9, 0x1E, 0xFB, 0x8B}};
 
+PDEVICE_OBJECT gdeviceObject;
 KEVENT UnloadEvent;
 LONG Unloading;
 
-PWSTR Cunc = L"\\??\\C:";
+static const WCHAR Cunc[] = L"\\??\\C:";
 
 /*
  * TODO:
@@ -131,7 +132,7 @@ CreateNewDriveLetterName(OUT PUNICODE_STRING DriveLetter,
                          IN UCHAR Letter,
                          IN PMOUNTDEV_UNIQUE_ID UniqueId OPTIONAL)
 {
-    NTSTATUS Status;
+    NTSTATUS Status = STATUS_UNSUCCESSFUL;
 
     /* Allocate a big enough buffer to contain the symbolic link */
     DriveLetter->MaximumLength = sizeof(DosDevices.Buffer) + 3 * sizeof(WCHAR);
@@ -240,7 +241,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
     /* The associate FO can't have a file name */
     if (FileObject->FileName.Length)
     {
-        ObfDereferenceObject(FileObject);
+        ObDereferenceObject(FileObject);
         return STATUS_OBJECT_NAME_NOT_FOUND;
     }
 
@@ -275,12 +276,12 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
                                                 &IoStatusBlock);
             if (!Irp)
             {
-                ObfDereferenceObject(DeviceObject);
-                ObfDereferenceObject(FileObject);
+                ObDereferenceObject(DeviceObject);
+                ObDereferenceObject(FileObject);
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
-            Status = IofCallDriver(DeviceObject, Irp);
+            Status = IoCallDriver(DeviceObject, Irp);
             if (Status == STATUS_PENDING)
             {
                 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -322,12 +323,12 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
                                                 &IoStatusBlock);
             if (!Irp)
             {
-                ObfDereferenceObject(DeviceObject);
-                ObfDereferenceObject(FileObject);
+                ObDereferenceObject(DeviceObject);
+                ObDereferenceObject(FileObject);
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
-            Status = IofCallDriver(DeviceObject, Irp);
+            Status = IoCallDriver(DeviceObject, Irp);
             if (Status == STATUS_PENDING)
             {
                 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -361,12 +362,12 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
                                                     &IoStatusBlock);
                 if (!Irp)
                 {
-                    ObfDereferenceObject(DeviceObject);
-                    ObfDereferenceObject(FileObject);
+                    ObDereferenceObject(DeviceObject);
+                    ObDereferenceObject(FileObject);
                     return STATUS_INSUFFICIENT_RESOURCES;
                 }
 
-                Status = IofCallDriver(DeviceObject, Irp);
+                Status = IoCallDriver(DeviceObject, Irp);
                 if (Status == STATUS_PENDING)
                 {
                     KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -392,8 +393,8 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
         Name = AllocatePool(sizeof(MOUNTDEV_NAME));
         if (!Name)
         {
-            ObfDereferenceObject(DeviceObject);
-            ObfDereferenceObject(FileObject);
+            ObDereferenceObject(DeviceObject);
+            ObDereferenceObject(FileObject);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
@@ -419,7 +420,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
         Stack = IoGetNextIrpStackLocation(Irp);
         Stack->FileObject = FileObject;
 
-        Status = IofCallDriver(DeviceObject, Irp);
+        Status = IoCallDriver(DeviceObject, Irp);
         if (Status == STATUS_PENDING)
         {
             KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -437,8 +438,8 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
             Name = AllocatePool(Size);
             if (!Name)
             {
-                ObfDereferenceObject(DeviceObject);
-                ObfDereferenceObject(FileObject);
+                ObDereferenceObject(DeviceObject);
+                ObDereferenceObject(FileObject);
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
@@ -464,7 +465,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
             Stack = IoGetNextIrpStackLocation(Irp);
             Stack->FileObject = FileObject;
 
-            Status = IofCallDriver(DeviceObject, Irp);
+            Status = IoCallDriver(DeviceObject, Irp);
             if (Status == STATUS_PENDING)
             {
                 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -524,15 +525,15 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
         if (!Irp)
         {
             FreePool(Id);
-            ObfDereferenceObject(DeviceObject);
-            ObfDereferenceObject(FileObject);
+            ObDereferenceObject(DeviceObject);
+            ObDereferenceObject(FileObject);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
         Stack = IoGetNextIrpStackLocation(Irp);
         Stack->FileObject = FileObject;
 
-        Status = IofCallDriver(DeviceObject, Irp);
+        Status = IoCallDriver(DeviceObject, Irp);
         if (Status == STATUS_PENDING)
         {
             KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -550,8 +551,8 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
             Id = AllocatePool(Size);
             if (!Id)
             {
-                ObfDereferenceObject(DeviceObject);
-                ObfDereferenceObject(FileObject);
+                ObDereferenceObject(DeviceObject);
+                ObDereferenceObject(FileObject);
                 return STATUS_INSUFFICIENT_RESOURCES;
             }
 
@@ -577,7 +578,7 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
             Stack = IoGetNextIrpStackLocation(Irp);
             Stack->FileObject = FileObject;
 
-            Status = IofCallDriver(DeviceObject, Irp);
+            Status = IoCallDriver(DeviceObject, Irp);
             if (Status == STATUS_PENDING)
             {
                 KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -622,15 +623,15 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
                                             &IoStatusBlock);
         if (!Irp)
         {
-            ObfDereferenceObject(DeviceObject);
-            ObfDereferenceObject(FileObject);
+            ObDereferenceObject(DeviceObject);
+            ObDereferenceObject(FileObject);
             return STATUS_INSUFFICIENT_RESOURCES;
         }
 
         Stack = IoGetNextIrpStackLocation(Irp);
         Stack->FileObject = FileObject;
 
-        Status = IofCallDriver(DeviceObject, Irp);
+        Status = IoCallDriver(DeviceObject, Irp);
         if (Status == STATUS_PENDING)
         {
             KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
@@ -640,8 +641,8 @@ QueryDeviceInformation(IN PUNICODE_STRING SymbolicName,
         *HasGuid = NT_SUCCESS(Status);
     }
 
-    ObfDereferenceObject(DeviceObject);
-    ObfDereferenceObject(FileObject);
+    ObDereferenceObject(DeviceObject);
+    ObDereferenceObject(FileObject);
     return Status;
 }
 
@@ -907,7 +908,7 @@ MountMgrUnload(IN struct _DRIVER_OBJECT *DriverObject)
 /*
  * @implemented
  */
-ULONG
+BOOLEAN
 MountmgrReadNoAutoMount(IN PUNICODE_STRING RegistryPath)
 {
     NTSTATUS Status;
@@ -931,10 +932,10 @@ MountmgrReadNoAutoMount(IN PUNICODE_STRING RegistryPath)
                                     NULL);
     if (!NT_SUCCESS(Status))
     {
-        return Default;
+        return (Default != 0);
     }
 
-    return Result;
+    return (Result != 0);
 }
 
 /*
@@ -1009,7 +1010,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
 
             if (RtlEqualUnicodeString(&(DeviceInformation->SymbolicName), &(CurrentDevice->SymbolicName), TRUE))
             {
-                break;            
+                break;
             }
         }
 
@@ -1054,7 +1055,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
     /* If it's OK, set it and save its letter (if any) */
     if (SuggestedLinkName.Buffer && IsDriveLetter(&SuggestedLinkName))
     {
-        DeviceInformation->SuggestedDriveLetter = SuggestedLinkName.Buffer[LETTER_POSITION];
+        DeviceInformation->SuggestedDriveLetter = (UCHAR)SuggestedLinkName.Buffer[LETTER_POSITION];
     }
 
     /* Acquire driver exclusively */
@@ -1069,7 +1070,7 @@ MountMgrMountedDeviceArrival(IN PDEVICE_EXTENSION DeviceExtension,
 
         if (RtlEqualUnicodeString(&(DeviceInformation->DeviceName), &TargetDeviceName, TRUE))
         {
-            break;            
+            break;
         }
     }
 
@@ -1683,6 +1684,7 @@ MountMgrCreateClose(IN PDEVICE_OBJECT DeviceObject,
  * @implemented
  */
 VOID
+NTAPI
 MountMgrCancel(IN PDEVICE_OBJECT DeviceObject,
                IN PIRP Irp)
 {
@@ -1692,7 +1694,7 @@ MountMgrCancel(IN PDEVICE_OBJECT DeviceObject,
 
     Irp->IoStatus.Information = 0;
     Irp->IoStatus.Status = STATUS_CANCELLED;
-    IofCompleteRequest(Irp, IO_NO_INCREMENT);
+    IoCompleteRequest(Irp, IO_NO_INCREMENT);
 }
 
 /*