[NTOSKRNL]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 28 Jan 2014 23:40:27 +0000 (23:40 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Tue, 28 Jan 2014 23:40:27 +0000 (23:40 +0000)
- Implement FsRtlRegisterFileSystemFilterCallbacks
- Fix returned ResultLength value in NtQuerySystemInformation
- Create \FileSystems\Filters folder in IopCreateRootDirectories, used by Windows fltmgr

svn path=/trunk/; revision=61874

reactos/ntoskrnl/ex/sysinfo.c
reactos/ntoskrnl/fsrtl/fastio.c
reactos/ntoskrnl/io/iomgr/iomgr.c

index f441dff..f8195b0 100644 (file)
@@ -1654,7 +1654,7 @@ SSI_DEF(SystemExtendServiceTableInformation)
     /* Check who is calling */
     if (PreviousMode != KernelMode)
     {
-        static const UNICODE_STRING Win32kName = 
+        static const UNICODE_STRING Win32kName =
             RTL_CONSTANT_STRING(L"\\SystemRoot\\System32\\win32k.sys");
 
         /* Make sure we can load drivers */
@@ -1663,7 +1663,7 @@ SSI_DEF(SystemExtendServiceTableInformation)
             /* FIXME: We can't, fail */
             return STATUS_PRIVILEGE_NOT_HELD;
         }
-        
+
         _SEH2_TRY
         {
             /* Probe and copy the unicode string */
@@ -1684,7 +1684,7 @@ SSI_DEF(SystemExtendServiceTableInformation)
             _SEH2_YIELD(return _SEH2_GetExceptionCode());
         }
         _SEH2_END;
-        
+
         /* Recursively call the function, so that we are from kernel mode */
         return ZwSetSystemInformation(SystemExtendServiceTableInformation,
                                       (PVOID)&Win32kName,
@@ -1956,51 +1956,51 @@ CallQS [] =
     SI_QX(SystemPerformanceInformation),
     SI_QX(SystemTimeOfDayInformation),
     SI_QX(SystemPathInformation), /* should be SI_XX */
-    SI_QX(SystemProcessInformation),
-    SI_QX(SystemCallCountInformation),
-    SI_QX(SystemDeviceInformation),
-    SI_QX(SystemProcessorPerformanceInformation),
-    SI_QS(SystemFlagsInformation),
+    SI_QX(SystemProcessInformation),  // aka SystemProcessesAndThreadsInformation
+    SI_QX(SystemCallCountInformation), // aka SystemCallCounts
+    SI_QX(SystemDeviceInformation), // aka SystemConfigurationInformation
+    SI_QX(SystemProcessorPerformanceInformation), // aka SystemProcessorTimes
+    SI_QS(SystemFlagsInformation), // aka SystemGlobalFlag
     SI_QX(SystemCallTimeInformation), /* should be SI_XX */
     SI_QX(SystemModuleInformation),
-    SI_QX(SystemLocksInformation),
+    SI_QX(SystemLocksInformation), // aka SystemLockInformation
     SI_QX(SystemStackTraceInformation), /* should be SI_XX */
     SI_QX(SystemPagedPoolInformation), /* should be SI_XX */
     SI_QX(SystemNonPagedPoolInformation), /* should be SI_XX */
     SI_QX(SystemHandleInformation),
     SI_QX(SystemObjectInformation),
-    SI_QX(SystemPageFileInformation),
-    SI_QX(SystemVdmInstemulInformation),
+    SI_QX(SystemPageFileInformation), // aka SystemPagefileInformation
+    SI_QX(SystemVdmInstemulInformation), // aka SystemInstructionEmulationCounts
     SI_QX(SystemVdmBopInformation), /* it should be SI_XX */
-    SI_QS(SystemFileCacheInformation),
+    SI_QS(SystemFileCacheInformation), // aka SystemCacheInformation
     SI_QX(SystemPoolTagInformation),
-    SI_QX(SystemInterruptInformation),
-    SI_QS(SystemDpcBehaviourInformation),
+    SI_QX(SystemInterruptInformation), // aka SystemProcessorStatistics
+    SI_QS(SystemDpcBehaviourInformation), // aka SystemDpcInformation
     SI_QX(SystemFullMemoryInformation), /* it should be SI_XX */
-    SI_XS(SystemLoadGdiDriverInformation),
-    SI_XS(SystemUnloadGdiDriverInformation),
-    SI_QS(SystemTimeAdjustmentInformation),
+    SI_XS(SystemLoadGdiDriverInformation), // correct: SystemLoadImage
+    SI_XS(SystemUnloadGdiDriverInformation), // correct: SystemUnloadImage
+    SI_QS(SystemTimeAdjustmentInformation), // aka SystemTimeAdjustment
     SI_QX(SystemSummaryMemoryInformation), /* it should be SI_XX */
     SI_QX(SystemNextEventIdInformation), /* it should be SI_XX */
-    SI_QX(SystemEventIdsInformation), /* it should be SI_XX */
+    SI_QX(SystemEventIdsInformation), /* it should be SI_XX */ // SystemPerformanceTraceInformation
     SI_QX(SystemCrashDumpInformation),
     SI_QX(SystemExceptionInformation),
     SI_QX(SystemCrashDumpStateInformation),
     SI_QX(SystemKernelDebuggerInformation),
     SI_QX(SystemContextSwitchInformation),
     SI_QS(SystemRegistryQuotaInformation),
-    SI_XS(SystemExtendServiceTableInformation),
+    SI_XS(SystemExtendServiceTableInformation), // correct: SystemLoadAndCallImage
     SI_XS(SystemPrioritySeperation),
     SI_QX(SystemPlugPlayBusInformation), /* it should be SI_XX */
     SI_QX(SystemDockInformation), /* it should be SI_XX */
-    SI_QX(SystemPowerInformation), /* it should be SI_XX */
+    SI_QX(SystemPowerInformation), /* it should be SI_XX */ // SystemPowerInformationNative? SystemInvalidInfoClass2
     SI_QX(SystemProcessorSpeedInformation), /* it should be SI_XX */
-    SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */
+    SI_QS(SystemCurrentTimeZoneInformation), /* it should be SI_QX */ // aka SystemTimeZoneInformation
     SI_QX(SystemLookasideInformation),
     SI_XS(SystemSetTimeSlipEvent),
     SI_XS(SystemCreateSession),
     SI_XS(SystemDeleteSession),
-    SI_QX(SystemInvalidInfoClass4), /* it should be SI_XX */
+    SI_QX(SystemInvalidInfoClass4), /* it should be SI_XX */ // SystemSessionInformation?
     SI_QX(SystemRangeStartInformation),
     SI_QS(SystemVerifierInformation),
     SI_XS(SystemAddVerifier),
@@ -2021,7 +2021,7 @@ NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
                          OUT PULONG UnsafeResultLength)
 {
     KPROCESSOR_MODE PreviousMode;
-    ULONG ResultLength;
+    ULONG ResultLength = 0;
     NTSTATUS FStatus = STATUS_NOT_IMPLEMENTED;
 
     PAGED_CODE();
@@ -2038,8 +2038,11 @@ NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInformationClass,
                 ProbeForWriteUlong(UnsafeResultLength);
         }
 
+        if (UnsafeResultLength)
+            *UnsafeResultLength = 0;
+
         /*
-         * Check the request is valid.
+         * Check if the request is valid.
          */
         if (SystemInformationClass >= MAX_SYSTEM_INFO_CLASS)
         {
index aad368e..174c8bc 100644 (file)
@@ -1802,7 +1802,7 @@ FsRtlAcquireFileForModWriteEx(IN PFILE_OBJECT FileObject,
         Exclusive = TRUE;
         ResourceToAcquire = FcbHeader->Resource;
     }
-    else if (!FcbHeader->PagingIoResource || 
+    else if (!FcbHeader->PagingIoResource ||
              (FcbHeader->Flags & FSRTL_FLAG_ACQUIRE_MAIN_RSRC_SH))
     {
         /* Acquire main resource shared if flag is specified or
@@ -1942,9 +1942,35 @@ FsRtlReleaseFileForModWrite(IN PFILE_OBJECT FileObject,
  *--*/
 NTSTATUS
 NTAPI
-FsRtlRegisterFileSystemFilterCallbacks(IN PDRIVER_OBJECT FilterDriverObject,
-                                       IN PFS_FILTER_CALLBACKS Callbacks)
+FsRtlRegisterFileSystemFilterCallbacks(
+    PDRIVER_OBJECT FilterDriverObject,
+    PFS_FILTER_CALLBACKS Callbacks)
 {
-    UNIMPLEMENTED;
-    return STATUS_NOT_IMPLEMENTED;
+    PFS_FILTER_CALLBACKS NewCallbacks;
+    PEXTENDED_DRIVER_EXTENSION DriverExtension;
+    PAGED_CODE();
+
+    /* Verify parameters */
+    if ((FilterDriverObject == NULL) || (Callbacks == NULL))
+    {
+        return STATUS_INVALID_PARAMETER;
+    }
+
+    /* Allocate a buffer for a copy of the callbacks */
+    NewCallbacks = ExAllocatePoolWithTag(NonPagedPool,
+                                         Callbacks->SizeOfFsFilterCallbacks,
+                                         'gmSF');
+    if (NewCallbacks == NULL)
+    {
+        return STATUS_INSUFFICIENT_RESOURCES;
+    }
+
+    /* Copy the callbacks */
+    RtlCopyMemory(NewCallbacks, Callbacks, Callbacks->SizeOfFsFilterCallbacks);
+
+    /* Set the callbacks in the driver extension */
+    DriverExtension = (PEXTENDED_DRIVER_EXTENSION)FilterDriverObject->DriverExtension;
+    DriverExtension->FsFilterCallbacks = NewCallbacks;
+
+    return STATUS_SUCCESS;
 }
index fe86ac9..b1d4a13 100644 (file)
@@ -110,7 +110,7 @@ IopInitLookasideLists(VOID)
                                     IOC_TAG1,
                                     32,
                                     &ExSystemLookasideListHead);
-    
+
     /* Initialize the Lookaside List for Large IRPs */
     ExInitializeSystemLookasideList(&IoLargeIrpLookaside,
                                     NonPagedPool,
@@ -137,11 +137,11 @@ IopInitLookasideLists(VOID)
                                     &ExSystemLookasideListHead);
 
     /* Allocate the global lookaside list buffer */
-    CurrentList = ExAllocatePoolWithTag(NonPagedPool, 
+    CurrentList = ExAllocatePoolWithTag(NonPagedPool,
                                         4 * KeNumberProcessors *
                                         sizeof(GENERAL_LOOKASIDE),
                                         TAG_IO);
-    
+
     /* Loop all processors */
     for (i = 0; i < KeNumberProcessors; i++)
     {
@@ -165,13 +165,13 @@ IopInitLookasideLists(VOID)
                                             &ExSystemLookasideListHead);
             Prcb->PPLookasideList[LookasideCompletionList].P = CurrentList;
             CurrentList++;
-            
+
         }
         else
         {
             Prcb->PPLookasideList[LookasideCompletionList].P = &IoCompletionPacketLookaside;
         }
-        
+
         /* Set the Large IRP List */
         Prcb->PPLookasideList[LookasideLargeIrpList].L = &IoLargeIrpLookaside;
         if (CurrentList)
@@ -185,7 +185,7 @@ IopInitLookasideLists(VOID)
                                             &ExSystemLookasideListHead);
             Prcb->PPLookasideList[LookasideLargeIrpList].P = CurrentList;
             CurrentList++;
-            
+
         }
         else
         {
@@ -205,7 +205,7 @@ IopInitLookasideLists(VOID)
                                             &ExSystemLookasideListHead);
             Prcb->PPLookasideList[LookasideSmallIrpList].P = CurrentList;
             CurrentList++;
-            
+
         }
         else
         {
@@ -223,10 +223,10 @@ IopInitLookasideLists(VOID)
                                             TAG_MDL,
                                             128,
                                             &ExSystemLookasideListHead);
-            
+
             Prcb->PPLookasideList[LookasideMdlList].P = CurrentList;
             CurrentList++;
-            
+
         }
         else
         {
@@ -332,6 +332,7 @@ IopCreateRootDirectories()
     OBJECT_ATTRIBUTES ObjectAttributes;
     UNICODE_STRING DirName;
     HANDLE Handle;
+    NTSTATUS Status;
 
     /* Create the '\Driver' object directory */
     RtlInitUnicodeString(&DirName, L"\\Driver");
@@ -340,9 +341,14 @@ IopCreateRootDirectories()
                                OBJ_PERMANENT,
                                NULL,
                                NULL);
-    if (!NT_SUCCESS(NtCreateDirectoryObject(&Handle,
-                                            DIRECTORY_ALL_ACCESS,
-                                            &ObjectAttributes))) return FALSE;
+    Status = NtCreateDirectoryObject(&Handle,
+                                     DIRECTORY_ALL_ACCESS,
+                                     &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to create \\Driver directory: 0x%lx\n", Status);
+        return FALSE;
+    }
     NtClose(Handle);
 
     /* Create the '\FileSystem' object directory */
@@ -352,9 +358,31 @@ IopCreateRootDirectories()
                                OBJ_PERMANENT,
                                NULL,
                                NULL);
-    if (!NT_SUCCESS(NtCreateDirectoryObject(&Handle,
-                                            DIRECTORY_ALL_ACCESS,
-                                            &ObjectAttributes))) return FALSE;
+    Status = NtCreateDirectoryObject(&Handle,
+                                     DIRECTORY_ALL_ACCESS,
+                                     &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to create \\FileSystem directory: 0x%lx\n", Status);
+        return FALSE;
+    }
+    NtClose(Handle);
+
+    /* Create the '\FileSystem' object directory */
+    RtlInitUnicodeString(&DirName, L"\\FileSystem\\Filters");
+    InitializeObjectAttributes(&ObjectAttributes,
+                               &DirName,
+                               OBJ_PERMANENT,
+                               NULL,
+                               NULL);
+    Status = NtCreateDirectoryObject(&Handle,
+                                     DIRECTORY_ALL_ACCESS,
+                                     &ObjectAttributes);
+    if (!NT_SUCCESS(Status))
+    {
+        DPRINT1("Failed to create \\FileSystem\\Filters directory: 0x%lx\n", Status);
+        return FALSE;
+    }
     NtClose(Handle);
 
     /* Return success */