summaryrefslogtreecommitdiff
path: root/filesys/miniFilter/MetadataManager
diff options
context:
space:
mode:
Diffstat (limited to 'filesys/miniFilter/MetadataManager')
-rw-r--r--filesys/miniFilter/MetadataManager/MetadataManager.sln14
-rw-r--r--filesys/miniFilter/MetadataManager/MetadataManagerInit.c255
-rw-r--r--filesys/miniFilter/MetadataManager/fmm.infbin2406 -> 8292 bytes
-rw-r--r--filesys/miniFilter/MetadataManager/fmm.vcxproj38
4 files changed, 236 insertions, 71 deletions
diff --git a/filesys/miniFilter/MetadataManager/MetadataManager.sln b/filesys/miniFilter/MetadataManager/MetadataManager.sln
index 9d47fdd5..4eac8251 100644
--- a/filesys/miniFilter/MetadataManager/MetadataManager.sln
+++ b/filesys/miniFilter/MetadataManager/MetadataManager.sln
@@ -1,4 +1,4 @@
-
+
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0
@@ -7,16 +7,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmm", "fmm.vcxproj", "{D3B7
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
+ Debug|ARM64 = Debug|ARM64
+ Release|ARM64 = Release|ARM64
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Debug|Win32.ActiveCfg = Debug|Win32
- {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Debug|Win32.Build.0 = Debug|Win32
- {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Release|Win32.ActiveCfg = Release|Win32
- {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Release|Win32.Build.0 = Release|Win32
+ {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Debug|ARM64.Build.0 = Debug|ARM64
+ {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Release|ARM64.ActiveCfg = Release|ARM64
+ {D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Release|ARM64.Build.0 = Release|ARM64
{D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Debug|x64.ActiveCfg = Debug|x64
{D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Debug|x64.Build.0 = Debug|x64
{D3B738B6-46C9-4572-A81F-C47F95D39A7B}.Release|x64.ActiveCfg = Release|x64
diff --git a/filesys/miniFilter/MetadataManager/MetadataManagerInit.c b/filesys/miniFilter/MetadataManager/MetadataManagerInit.c
index 222159f7..dbedd3a8 100644
--- a/filesys/miniFilter/MetadataManager/MetadataManagerInit.c
+++ b/filesys/miniFilter/MetadataManager/MetadataManagerInit.c
@@ -86,8 +86,31 @@ FmmInstanceTeardownComplete (
#if DBG
+typedef
+NTSTATUS
+(*PFN_IoOpenDriverRegistryKey) (
+ PDRIVER_OBJECT DriverObject,
+ DRIVER_REGKEY_TYPE RegKeyType,
+ ACCESS_MASK DesiredAccess,
+ ULONG Flags,
+ PHANDLE DriverRegKey
+ );
+
+PFN_IoOpenDriverRegistryKey
+FmmGetIoOpenDriverRegistryKey (
+ VOID
+ );
+
+NTSTATUS
+FmmOpenServiceParametersKey (
+ _In_ PDRIVER_OBJECT DriverObject,
+ _In_ PUNICODE_STRING ServiceRegistryPath,
+ _Out_ PHANDLE ServiceParametersKey
+ );
+
VOID
FmmInitializeDebugLevel (
+ _In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
);
@@ -101,6 +124,8 @@ FmmInitializeDebugLevel (
#pragma alloc_text(INIT, DriverEntry)
#if DBG
+#pragma alloc_text(INIT, FmmGetIoOpenDriverRegistryKey)
+#pragma alloc_text(INIT, FmmOpenServiceParametersKey)
#pragma alloc_text(INIT, FmmInitializeDebugLevel)
#endif
@@ -115,11 +140,11 @@ FmmInitializeDebugLevel (
//
// If we need to verify that the metadata file is indeed open whenever
-// a create suceeds on the volume, then we need to monitor all creates
+// a create suceeds on the volume, then we need to monitor all creates
// not just DASD creates.
-// If that is not the case, then we are better off telling filter manager
-// to show us only DASD creates. That way we can avoid the performance
+// If that is not the case, then we are better off telling filter manager
+// to show us only DASD creates. That way we can avoid the performance
// penalty of being called for all creates when we only have use for DASD
// creates.
//
@@ -241,7 +266,7 @@ Return Value:
//
// Default to NonPagedPoolNx for non paged pool allocations where supported.
//
-
+
ExInitializeDriverRuntime( DrvRtPoolNxOptIn );
@@ -253,7 +278,7 @@ Return Value:
// Initialize global debug level
//
- FmmInitializeDebugLevel( RegistryPath );
+ FmmInitializeDebugLevel( DriverObject, RegistryPath );
#else
@@ -299,8 +324,147 @@ Return Value:
#if DBG
+PFN_IoOpenDriverRegistryKey
+FmmGetIoOpenDriverRegistryKey (
+ VOID
+ )
+{
+ static PFN_IoOpenDriverRegistryKey pIoOpenDriverRegistryKey = NULL;
+ UNICODE_STRING FunctionName = {0};
+
+ if (pIoOpenDriverRegistryKey == NULL) {
+
+ RtlInitUnicodeString(&FunctionName, L"IoOpenDriverRegistryKey");
+
+ pIoOpenDriverRegistryKey = (PFN_IoOpenDriverRegistryKey)MmGetSystemRoutineAddress(&FunctionName);
+ }
+
+ return pIoOpenDriverRegistryKey;
+}
+
+NTSTATUS
+FmmOpenServiceParametersKey (
+ _In_ PDRIVER_OBJECT DriverObject,
+ _In_ PUNICODE_STRING ServiceRegistryPath,
+ _Out_ PHANDLE ServiceParametersKey
+ )
+/*++
+
+Routine Description:
+
+ This routine opens the service parameters key, using the isolation-compliant
+ APIs when possible.
+
+Arguments:
+
+ DriverObject - Pointer to driver object created by the system to
+ represent this driver.
+
+ RegistryPath - The path key passed to the driver during DriverEntry.
+
+ ServiceParametersKey - Returns a handle to the service parameters subkey.
+
+Return Value:
+
+ STATUS_SUCCESS if the function completes successfully. Otherwise a valid
+ NTSTATUS code is returned.
+
+--*/
+{
+ NTSTATUS status;
+ PFN_IoOpenDriverRegistryKey pIoOpenDriverRegistryKey;
+ UNICODE_STRING Subkey;
+ HANDLE ParametersKey = NULL;
+ HANDLE ServiceRegKey = NULL;
+ OBJECT_ATTRIBUTES Attributes;
+
+ //
+ // Open the parameters key to read values from the INF, using the API to
+ // open the key if possible
+ //
+
+ pIoOpenDriverRegistryKey = FmmGetIoOpenDriverRegistryKey();
+
+ if (pIoOpenDriverRegistryKey != NULL) {
+
+ //
+ // Open the parameters key using the API
+ //
+
+ status = pIoOpenDriverRegistryKey( DriverObject,
+ DriverRegKeyParameters,
+ KEY_READ,
+ 0,
+ &ParametersKey );
+
+ if (!NT_SUCCESS( status )) {
+
+ goto cleanup;
+ }
+
+ } else {
+
+ //
+ // Open specified service root key
+ //
+
+ InitializeObjectAttributes( &Attributes,
+ ServiceRegistryPath,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ NULL,
+ NULL );
+
+ status = ZwOpenKey( &ServiceRegKey,
+ KEY_READ,
+ &Attributes );
+
+ if (!NT_SUCCESS( status )) {
+
+ goto cleanup;
+ }
+
+ //
+ // Open the parameters key relative to service key path
+ //
+
+ RtlInitUnicodeString( &Subkey, L"Parameters" );
+
+ InitializeObjectAttributes( &Attributes,
+ &Subkey,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ ServiceRegKey,
+ NULL );
+
+ status = ZwOpenKey( &ParametersKey,
+ KEY_READ,
+ &Attributes );
+
+ if (!NT_SUCCESS( status )) {
+
+ goto cleanup;
+ }
+ }
+
+ //
+ // Return value to caller
+ //
+
+ *ServiceParametersKey = ParametersKey;
+
+cleanup:
+
+ if (ServiceRegKey != NULL) {
+
+ ZwClose( ServiceRegKey );
+ }
+
+ return status;
+
+}
+
VOID
FmmInitializeDebugLevel (
+ _In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
/*++
@@ -313,6 +477,9 @@ Routine Description:
Arguments:
+ DriverObject - Pointer to driver object created by the system to
+ represent this driver.
+
RegistryPath - The path key passed to the driver during DriverEntry.
Return Value:
@@ -321,8 +488,7 @@ Return Value:
--*/
{
- OBJECT_ATTRIBUTES attributes;
- HANDLE driverRegKey;
+ HANDLE driverRegKey = NULL;
NTSTATUS status;
ULONG resultLength;
UNICODE_STRING valueName;
@@ -331,47 +497,46 @@ Return Value:
Globals.DebugLevel = DEBUG_TRACE_ERROR;
//
- // Open the desired registry key
+ // Open service parameters key to query values from.
//
- InitializeObjectAttributes( &attributes,
- RegistryPath,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- NULL,
- NULL );
+ status = FmmOpenServiceParametersKey( DriverObject,
+ RegistryPath,
+ &driverRegKey );
- status = ZwOpenKey( &driverRegKey,
- KEY_READ,
- &attributes );
+ if (!NT_SUCCESS( status )) {
- if (NT_SUCCESS( status )) {
+ driverRegKey = NULL;
+ goto cleanup;
+ }
- //
- // Read the DebugFlags value from the registry.
- //
+ //
+ // Read the DebugFlags value from the registry.
+ //
- RtlInitUnicodeString( &valueName, L"DebugLevel" );
+ RtlInitUnicodeString( &valueName, L"DebugLevel" );
- status = ZwQueryValueKey( driverRegKey,
- &valueName,
- KeyValuePartialInformation,
- buffer,
- sizeof(buffer),
- &resultLength );
+ status = ZwQueryValueKey( driverRegKey,
+ &valueName,
+ KeyValuePartialInformation,
+ buffer,
+ sizeof(buffer),
+ &resultLength );
- if (NT_SUCCESS( status )) {
+ if (NT_SUCCESS( status )) {
- Globals.DebugLevel = *((PULONG) &(((PKEY_VALUE_PARTIAL_INFORMATION) buffer)->Data));
- }
-
- //
- // Close the registry entry
- //
-
- ZwClose( driverRegKey );
-
+ Globals.DebugLevel = *((PULONG) &(((PKEY_VALUE_PARTIAL_INFORMATION) buffer)->Data));
}
+cleanup:
+
+ //
+ // Close the registry entry
+ //
+
+ if (driverRegKey != NULL) {
+ ZwClose( driverRegKey );
+ }
}
#endif
@@ -678,22 +843,22 @@ FmmInstanceSetupCleanup:
}
//
- // If this is an automatic attachment (mount, load, etc) and we are not
- // attaching to this volume because we do not support attaching to this
- // volume, then simply return STATUS_FLT_DO_NOT_ATTACH. If we return
- // anything else fltmgr logs an event log indicating failure to attach.
- // Since this failure to attach is not really an error, we do not want
+ // If this is an automatic attachment (mount, load, etc) and we are not
+ // attaching to this volume because we do not support attaching to this
+ // volume, then simply return STATUS_FLT_DO_NOT_ATTACH. If we return
+ // anything else fltmgr logs an event log indicating failure to attach.
+ // Since this failure to attach is not really an error, we do not want
// this failure to be logged as an error in the event log. For all other
// error codes besides the ones we consider "normal", if is ok for fltmgr
// to actually log the failure to attach.
//
- // If this is a manual attach attempt that we have failed then we want to
- // give the user a clear indication of why the attachment failed. Hence in
+ // If this is a manual attach attempt that we have failed then we want to
+ // give the user a clear indication of why the attachment failed. Hence in
// this case, we will not override the error status with STATUS_FLT_DO_NOT_ATTACH
// irrespective of the cause of the failure to attach
//
- if (status == STATUS_NOT_SUPPORTED &&
+ if (status == STATUS_NOT_SUPPORTED &&
!FlagOn( Flags, FLTFL_INSTANCE_SETUP_MANUAL_ATTACHMENT )) {
status = STATUS_FLT_DO_NOT_ATTACH;
diff --git a/filesys/miniFilter/MetadataManager/fmm.inf b/filesys/miniFilter/MetadataManager/fmm.inf
index 5c39ed06..ad231a8c 100644
--- a/filesys/miniFilter/MetadataManager/fmm.inf
+++ b/filesys/miniFilter/MetadataManager/fmm.inf
Binary files differ
diff --git a/filesys/miniFilter/MetadataManager/fmm.vcxproj b/filesys/miniFilter/MetadataManager/fmm.vcxproj
index c4814d15..f46e09ce 100644
--- a/filesys/miniFilter/MetadataManager/fmm.vcxproj
+++ b/filesys/miniFilter/MetadataManager/fmm.vcxproj
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
+ <ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
+ <Platform>ARM64</Platform>
</ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
+ <ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
- <Platform>Win32</Platform>
+ <Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
@@ -22,7 +22,7 @@
<ProjectGuid>{D3B738B6-46C9-4572-A81F-C47F95D39A7B}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
- <Platform Condition="'$(Platform)' == ''">Win32</Platform>
+ <Platform Condition="'$(Platform)' == ''">x64</Platform>
<SampleGuid>{8C639D05-4938-4C61-BB91-F227CEE05488}</SampleGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@@ -34,23 +34,23 @@
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
</PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>True</UseDebugLibraries>
+ <UseDebugLibraries>False</UseDebugLibraries>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
<DriverType>WDM</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
</PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetVersion>Windows10</TargetVersion>
- <UseDebugLibraries>False</UseDebugLibraries>
+ <UseDebugLibraries>True</UseDebugLibraries>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
<DriverType>WDM</DriverType>
<PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset>
<ConfigurationType>Driver</ConfigurationType>
</PropertyGroup>
- <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<TargetVersion>Windows10</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
<DriverTargetPlatform>Universal</DriverTargetPlatform>
@@ -65,26 +65,26 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
- <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ItemGroup Label="WrappedTaskItems" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>fmm</TargetName>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<TargetName>fmm</TargetName>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>fmm</TargetName>
</PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<TargetName>fmm</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@@ -108,7 +108,7 @@
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
</DriverSign>
</ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
<WarningLevel>Level4</WarningLevel>
@@ -129,7 +129,7 @@
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
</DriverSign>
</ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
<WarningLevel>Level4</WarningLevel>
@@ -150,7 +150,7 @@
<FileDigestAlgorithm>sha256</FileDigestAlgorithm>
</DriverSign>
</ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<TreatWarningAsError>true</TreatWarningAsError>
<WarningLevel>Level4</WarningLevel>