Windows: RDR DeviceObject Characteristics
[openafs.git] / src / WINNT / afsrdr / kernel / fs / AFSInit.cpp
index bbc662a..25e11b0 100644 (file)
@@ -68,8 +68,7 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
 {
 
     NTSTATUS ntStatus = STATUS_SUCCESS;
-    AFSDeviceExt    *pDeviceExt;
-    ULONG ulTimeIncrement = 0;
+    AFSDeviceExt    *pDeviceExt = NULL;
     UNICODE_STRING uniSymLinkName;
     UNICODE_STRING uniDeviceName;
     ULONG ulIndex = 0;
@@ -108,6 +107,8 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
 
         AFSReadServerName();
 
+        AFSReadMountRootName();
+
         RtlZeroMemory( &sysVersion,
                        sizeof( RTL_OSVERSIONINFOW));
 
@@ -175,14 +176,6 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
             ntStatus = STATUS_SUCCESS;
         }
 
-        //
-        // Initialize the debug log and dump file interface
-        //
-
-        AFSInitializeDbgLog();
-
-        AFSInitializeDumpFile();
-
 #if DBG
 
         if( BooleanFlagOn( AFSDebugFlags, AFS_DBG_FLAG_BREAK_ON_ENTRY))
@@ -212,6 +205,14 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
         }
 
         //
+        // Initialize the debug log and dump file interface
+        //
+
+        AFSInitializeDbgLog();
+
+        AFSInitializeDumpFile();
+
+        //
         // Setup the registry string
         //
 
@@ -259,7 +260,7 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
                                          sizeof( AFSDeviceExt),
                                          &uniDeviceName,
                                          FILE_DEVICE_NETWORK_FILE_SYSTEM,
-                                         0,
+                                         FILE_DEVICE_SECURE_OPEN | FILE_REMOTE_DEVICE,
                                          FALSE,
                                          &SDDL_DEVOBJ_SYS_ALL_ADM_RWX_WORLD_RWX_RES_RWX,
                                          (LPCGUID)&GUID_SD_AFS_REDIRECTOR_CONTROL_OBJECT,
@@ -420,6 +421,23 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
         AFSSysProcess = PsGetCurrentProcessId();
 
         //
+        // Initialize the worker Queues and their syncrhonization structures
+        //
+
+        KeInitializeEvent( &pDeviceExt->Specific.Control.WorkerQueueHasItems,
+                           SynchronizationEvent,
+                           FALSE);
+
+        ExInitializeResourceLite( &pDeviceExt->Specific.Control.QueueLock);
+
+        KeInitializeEvent( &pDeviceExt->Specific.Control.IOWorkerQueueHasItems,
+                           SynchronizationEvent,
+                           FALSE);
+
+        ExInitializeResourceLite( &pDeviceExt->Specific.Control.IOQueueLock);
+
+
+        //
         // Register for shutdown notification
         //
 
@@ -453,7 +471,12 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
         AFSInitServerStrings();
 
         //
-        // Register the call back for process creation and tear down
+        // Register the call back for process creation and tear down.
+        // On Vista SP1 and above, PsSetCreateProcessNotifyRoutineEx
+        // will be used.  This function returns STATUS_ACCESS_DENIED
+        // if there is a signing error.  In that case, the AFSProcessNotifyEx
+        // routine has not been registered and we can fallback to the
+        // Windows 2000 interface and AFSProcessNotify.
         //
 
         RtlInitUnicodeString( &uniPsSetCreateProcessNotifyRoutineEx,
@@ -461,19 +484,24 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
 
         pPsSetCreateProcessNotifyRoutineEx = (PsSetCreateProcessNotifyRoutineEx_t)MmGetSystemRoutineAddress(&uniPsSetCreateProcessNotifyRoutineEx);
 
+        ntStatus = STATUS_ACCESS_DENIED;
+
         if ( pPsSetCreateProcessNotifyRoutineEx)
         {
 
-            pPsSetCreateProcessNotifyRoutineEx( AFSProcessNotifyEx,
-                                                FALSE);
+            ntStatus = pPsSetCreateProcessNotifyRoutineEx( AFSProcessNotifyEx,
+                                                           FALSE);
         }
-        else
+
+        if ( ntStatus == STATUS_ACCESS_DENIED)
         {
 
-            PsSetCreateProcessNotifyRoutine( AFSProcessNotify,
-                                             FALSE);
+            ntStatus = PsSetCreateProcessNotifyRoutine( AFSProcessNotify,
+                                                        FALSE);
         }
 
+        ntStatus = STATUS_SUCCESS;
+
 try_exit:
 
         if( !NT_SUCCESS( ntStatus))
@@ -510,12 +538,14 @@ try_exit:
             ExDeleteResourceLite( &AFSDbgLogLock);
         }
     }
-    __except( AFSExceptionFilter( GetExceptionCode(), GetExceptionInformation()) )
+    __except( AFSExceptionFilter( __FUNCTION__, GetExceptionCode(), GetExceptionInformation()) )
     {
 
-        AFSDbgLogMsg( 0,
+        AFSDbgTrace(( 0,
                       0,
-                      "EXCEPTION - AFSRedirFs DriverEntry\n");
+                      "EXCEPTION - AFSRedirFs DriverEntry\n"));
+
+        AFSDumpTraceFilesFnc();
     }
 
     return ntStatus;