[MOUNTMGR]
[reactos.git] / reactos / drivers / filters / mountmgr / notify.c
index 2b2acbc..4e148f2 100644 (file)
@@ -75,15 +75,15 @@ SendOnlineNotification(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);
     }
 
 Cleanup:
-    ObfDereferenceObject(DeviceObject);
-    ObfDereferenceObject(FileObject);
+    ObDereferenceObject(DeviceObject);
+    ObDereferenceObject(FileObject);
 
     return;
 }
@@ -107,7 +107,7 @@ SendOnlineNotificationWorker(IN PVOID Parameter)
     /* First, send the notification */
     SendOnlineNotification(&(WorkItem->SymbolicName));
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
     /* If there are no notifications running any longer, reset event */
     if (--DeviceExtension->OnlineNotificationCount == 0)
     {
@@ -120,7 +120,7 @@ SendOnlineNotificationWorker(IN PVOID Parameter)
         /* Queue a new one for execution */
         Head = RemoveHeadList(&(DeviceExtension->OnlineNotificationListHead));
         NewWorkItem = CONTAINING_RECORD(Head, ONLINE_NOTIFICATION_WORK_ITEM, List);
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
         NewWorkItem->List.Blink = NULL;
         NewWorkItem->List.Flink = NULL;
         ExQueueWorkItem((PWORK_QUEUE_ITEM)NewWorkItem, DelayedWorkQueue);
@@ -129,7 +129,7 @@ SendOnlineNotificationWorker(IN PVOID Parameter)
     {
         /* Mark it's over */
         DeviceExtension->OnlineNotificationWorkerActive = 0;
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
     }
 
     FreePool(WorkItem->SymbolicName.Buffer);
@@ -171,14 +171,14 @@ PostOnlineNotification(IN PDEVICE_EXTENSION DeviceExtension,
     RtlCopyMemory(WorkItem->SymbolicName.Buffer, SymbolicName->Buffer, SymbolicName->Length);
     WorkItem->SymbolicName.Buffer[SymbolicName->Length / sizeof(WCHAR)] = UNICODE_NULL;
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
     DeviceExtension->OnlineNotificationCount++;
 
     /* If no worker are active */
     if (DeviceExtension->OnlineNotificationWorkerActive == 0)
     {
         /* Queue that one for execution */
-        DeviceExtension->OnlineNotificationWorkerActive == 1;
+        DeviceExtension->OnlineNotificationWorkerActive = 1;
         ExQueueWorkItem((PWORK_QUEUE_ITEM)WorkItem, DelayedWorkQueue);
     }
     else
@@ -187,7 +187,7 @@ PostOnlineNotification(IN PDEVICE_EXTENSION DeviceExtension,
         InsertTailList(&(DeviceExtension->OnlineNotificationListHead), &(WorkItem->List));
     }
 
-    KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+    KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
     return;
 }
@@ -202,13 +202,13 @@ WaitForOnlinesToComplete(IN PDEVICE_EXTENSION DeviceExtension)
 
     KeInitializeEvent(&(DeviceExtension->OnlineNotificationEvent), NotificationEvent, FALSE);
 
-    OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+    KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
 
     /* Just wait all the worker are done */
     if (DeviceExtension->OnlineNotificationCount != 1)
     {
         DeviceExtension->OnlineNotificationCount--;
-        KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+        KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 
         KeWaitForSingleObject(&(DeviceExtension->OnlineNotificationEvent),
                               Executive,
@@ -216,11 +216,11 @@ WaitForOnlinesToComplete(IN PDEVICE_EXTENSION DeviceExtension)
                               FALSE,
                               NULL);
 
-        OldIrql = KfAcquireSpinLock(&(DeviceExtension->WorkerLock));
+        KeAcquireSpinLock(&(DeviceExtension->WorkerLock), &OldIrql);
         DeviceExtension->OnlineNotificationCount++;
     }
 
-    KfReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
+    KeReleaseSpinLock(&(DeviceExtension->WorkerLock), OldIrql);
 }
 
 /*
@@ -301,7 +301,7 @@ RegisterForTargetDeviceNotification(IN PDEVICE_EXTENSION DeviceExtension,
         DeviceInformation->TargetDeviceNotificationEntry = NULL;
     }
 
-    ObfDereferenceObject(FileObject);
+    ObDereferenceObject(FileObject);
 
     return;
 }
@@ -341,7 +341,7 @@ MountMgrNotify(IN PDEVICE_EXTENSION DeviceExtension)
         *((PULONG)Irp->AssociatedIrp.SystemBuffer) = DeviceExtension->EpicNumber;
         Irp->IoStatus.Information = sizeof(DeviceExtension->EpicNumber);
 
-        IofCompleteRequest(Irp, IO_NO_INCREMENT);
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
     }
 }
 
@@ -412,8 +412,8 @@ MountMgrNotifyNameChange(IN PDEVICE_EXTENSION DeviceExtension,
                                         &IoStatusBlock);
     if (!Irp)
     {
-        ObfDereferenceObject(DeviceObject);
-        ObfDereferenceObject(FileObject);
+        ObDereferenceObject(DeviceObject);
+        ObDereferenceObject(FileObject);
     }
 
     Stack = IoGetNextIrpStackLocation(Irp);
@@ -428,15 +428,15 @@ MountMgrNotifyNameChange(IN PDEVICE_EXTENSION DeviceExtension,
     Stack->FileObject = FileObject;
 
     /* And call driver */
-    Status = IofCallDriver(DeviceObject, Irp);
+    Status = IoCallDriver(DeviceObject, Irp);
     if (Status == STATUS_PENDING)
     {
         KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
         Status = IoStatusBlock.Status;
     }
 
-    ObfDereferenceObject(DeviceObject);
-    ObfDereferenceObject(FileObject);
+    ObDereferenceObject(DeviceObject);
+    ObDereferenceObject(FileObject);
 
     if (!NT_SUCCESS(Status))
     {
@@ -466,7 +466,7 @@ MountMgrNotifyNameChange(IN PDEVICE_EXTENSION DeviceExtension,
                                            &DeviceNotification,
                                            NULL, NULL);
 
-    ObfDereferenceObject(DeviceObject);
+    ObDereferenceObject(DeviceObject);
 
     return;
 }
@@ -477,7 +477,7 @@ MountMgrNotifyNameChange(IN PDEVICE_EXTENSION DeviceExtension,
 VOID
 RemoveWorkItem(IN PUNIQUE_ID_WORK_ITEM WorkItem)
 {
-    PDEVICE_EXTENSION DeviceExtension;
+    PDEVICE_EXTENSION DeviceExtension = WorkItem->DeviceExtension;
 
     KeWaitForSingleObject(&(DeviceExtension->DeviceLock), Executive, KernelMode, FALSE, NULL);
 
@@ -511,6 +511,8 @@ UniqueIdChangeNotifyWorker(IN PDEVICE_OBJECT DeviceObject,
     PMOUNTDEV_UNIQUE_ID OldUniqueId, NewUniqueId;
     PMOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY_OUTPUT UniqueIdChange;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
+
     /* Validate worker */
     if (!NT_SUCCESS(WorkItem->Irp->IoStatus.Status))
     {
@@ -567,6 +569,9 @@ UniqueIdChangeNotifyCompletion(IN PDEVICE_OBJECT DeviceObject,
 {
     PUNIQUE_ID_WORK_ITEM WorkItem = Context;
 
+    UNREFERENCED_PARAMETER(DeviceObject);
+    UNREFERENCED_PARAMETER(Irp);
+
     /* Simply queue the work item */
     IoQueueWorkItem(WorkItem->WorkItem,
                     UniqueIdChangeNotifyWorker,
@@ -605,12 +610,12 @@ IssueUniqueIdChangeNotifyWorker(IN PUNIQUE_ID_WORK_ITEM WorkItem,
 
     /* Initialize the IRP */
     Irp = WorkItem->Irp;
-    IoInitializeIrp(Irp, IoSizeOfIrp(WorkItem->StackSize), WorkItem->StackSize);
+    IoInitializeIrp(Irp, IoSizeOfIrp(WorkItem->StackSize), (CCHAR)WorkItem->StackSize);
 
     if (InterlockedExchange((PLONG)&(WorkItem->Event), 0) != 0)
     {
-        ObfDereferenceObject(FileObject);
-        ObfDereferenceObject(DeviceObject);
+        ObDereferenceObject(FileObject);
+        ObDereferenceObject(DeviceObject);
         RemoveWorkItem(WorkItem);
         return;
     }
@@ -634,16 +639,16 @@ IssueUniqueIdChangeNotifyWorker(IN PUNIQUE_ID_WORK_ITEM WorkItem,
                                       TRUE, TRUE, TRUE);
     if (!NT_SUCCESS(Status))
     {
-        ObfDereferenceObject(FileObject);
-        ObfDereferenceObject(DeviceObject);
+        ObDereferenceObject(FileObject);
+        ObDereferenceObject(DeviceObject);
         RemoveWorkItem(WorkItem);
         return;
     }
 
     /* Call the driver */
-    IofCallDriver(DeviceObject, Irp);
-    ObfDereferenceObject(FileObject);
-    ObfDereferenceObject(DeviceObject);
+    IoCallDriver(DeviceObject, Irp);
+    ObDereferenceObject(FileObject);
+    ObDereferenceObject(DeviceObject);
 }
 
 /*
@@ -673,13 +678,13 @@ IssueUniqueIdChangeNotify(IN PDEVICE_EXTENSION DeviceExtension,
     /* And then, get attached device */
     DeviceObject = IoGetAttachedDeviceReference(FileObject->DeviceObject);
 
-    ObfDereferenceObject(FileObject);
+    ObDereferenceObject(FileObject);
 
     /* Allocate a work item */
     WorkItem = AllocatePool(sizeof(UNIQUE_ID_WORK_ITEM));
     if (!WorkItem)
     {
-        ObfDereferenceObject(DeviceObject);
+        ObDereferenceObject(DeviceObject);
         return;
     }
 
@@ -687,7 +692,7 @@ IssueUniqueIdChangeNotify(IN PDEVICE_EXTENSION DeviceExtension,
     WorkItem->WorkItem = IoAllocateWorkItem(DeviceExtension->DeviceObject);
     if (!WorkItem->WorkItem)
     {
-        ObfDereferenceObject(DeviceObject);
+        ObDereferenceObject(DeviceObject);
         goto Cleanup;
     }
 
@@ -696,7 +701,7 @@ IssueUniqueIdChangeNotify(IN PDEVICE_EXTENSION DeviceExtension,
     /* Already provide the IRP */
     WorkItem->Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
 
-    ObfDereferenceObject(DeviceObject);
+    ObDereferenceObject(DeviceObject);
 
     if (!WorkItem->Irp)
     {