summaryrefslogtreecommitdiff
path: root/filesys/miniFilter/ctx
diff options
context:
space:
mode:
authorzlockard <[email protected]>2023-07-31 17:28:46 -0700
committerzlockard <[email protected]>2023-07-31 17:28:46 -0700
commitb45ffd69a7205e46bbdd5d415ac591f9446fb04f (patch)
tree7969a2e29e471670f49cc931f9b0bafb36f1e590 /filesys/miniFilter/ctx
parent713297235bc1de929404221824b88c6b4228376b (diff)
Update file system filter samples to use isolated state locations
Diffstat (limited to 'filesys/miniFilter/ctx')
-rw-r--r--filesys/miniFilter/ctx/CtxInit.c98
-rw-r--r--filesys/miniFilter/ctx/ctx.infbin5004 -> 7776 bytes
2 files changed, 72 insertions, 26 deletions
diff --git a/filesys/miniFilter/ctx/CtxInit.c b/filesys/miniFilter/ctx/CtxInit.c
index 2654b9f9..fbb2d99c 100644
--- a/filesys/miniFilter/ctx/CtxInit.c
+++ b/filesys/miniFilter/ctx/CtxInit.c
@@ -80,6 +80,7 @@ CtxInstanceTeardownComplete (
VOID
CtxInitializeDebugLevel (
+ _In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
);
@@ -217,7 +218,7 @@ Return Value:
//
// Default to NonPagedPoolNx for non paged pool allocations where supported.
//
-
+
ExInitializeDriverRuntime( DrvRtPoolNxOptIn );
RtlZeroMemory( &Globals, sizeof( Globals ) );
@@ -228,7 +229,7 @@ Return Value:
// Initialize global debug level
//
- CtxInitializeDebugLevel( RegistryPath );
+ CtxInitializeDebugLevel( DriverObject, RegistryPath );
#else
@@ -276,6 +277,7 @@ Return Value:
VOID
CtxInitializeDebugLevel (
+ _In_ PDRIVER_OBJECT DriverObject,
_In_ PUNICODE_STRING RegistryPath
)
/*++
@@ -288,6 +290,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:
@@ -297,7 +302,8 @@ Return Value:
--*/
{
OBJECT_ATTRIBUTES attributes;
- HANDLE driverRegKey;
+ OSVERSIONINFOW versionInfo;
+ HANDLE driverRegKey = NULL;
NTSTATUS status;
ULONG resultLength;
UNICODE_STRING valueName;
@@ -305,48 +311,88 @@ Return Value:
Globals.DebugLevel = DEBUG_TRACE_ERROR;
+ RtlZeroMemory( &versionInfo, sizeof( versionInfo ) );
+
+ //
+ // Determine the OS version being run.
+ //
+
+ versionInfo.dwOSVersionInfoSize = sizeof( versionInfo );
+
+ status = RtlGetVersion( &versionInfo );
+
+ if (!NT_SUCCESS( status )) {
+
+ goto cleanup;
+ }
+
//
// Open the desired registry key
//
- InitializeObjectAttributes( &attributes,
- RegistryPath,
- OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
- NULL,
- NULL );
+ if (versionInfo.dwBuildNumber >= 25900) {
+ //
+ // Open the Parameters key for the service.
+ //
- status = ZwOpenKey( &driverRegKey,
- KEY_READ,
- &attributes );
+ status = IoOpenDriverRegistryKey( DriverObject,
+ DriverRegKeyParameters,
+ KEY_READ,
+ 0,
+ &driverRegKey );
- if (NT_SUCCESS( status )) {
+ if (!NT_SUCCESS( status )) {
+ goto cleanup;
+ }
+ } else {
//
- // Read the DebugFlags value from the registry.
+ // Open legacy registry key.
//
- RtlInitUnicodeString( &valueName, L"DebugLevel" );
+ InitializeObjectAttributes( &attributes,
+ RegistryPath,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
+ NULL,
+ NULL );
- status = ZwQueryValueKey( driverRegKey,
- &valueName,
- KeyValuePartialInformation,
- buffer,
- sizeof(buffer),
- &resultLength );
+ status = ZwOpenKey( &driverRegKey,
+ KEY_READ,
+ &attributes );
- if (NT_SUCCESS( status )) {
+ if (!NT_SUCCESS( status )) {
- Globals.DebugLevel = *((PULONG) &(((PKEY_VALUE_PARTIAL_INFORMATION) buffer)->Data));
+ goto cleanup;
}
+ }
- //
- // Close the registry entry
- //
+ //
+ // Read the DebugFlags value from the registry.
+ //
- ZwClose( driverRegKey );
+ RtlInitUnicodeString( &valueName, L"DebugLevel" );
+ status = ZwQueryValueKey( driverRegKey,
+ &valueName,
+ KeyValuePartialInformation,
+ buffer,
+ sizeof(buffer),
+ &resultLength );
+
+ if (NT_SUCCESS( status )) {
+
+ Globals.DebugLevel = *((PULONG) &(((PKEY_VALUE_PARTIAL_INFORMATION) buffer)->Data));
}
+cleanup:
+
+ //
+ // Close the registry entry
+ //
+
+ if (driverRegKey != NULL) {
+ ZwClose( driverRegKey );
+ }
}
#endif
diff --git a/filesys/miniFilter/ctx/ctx.inf b/filesys/miniFilter/ctx/ctx.inf
index 39e935af..1f3a833e 100644
--- a/filesys/miniFilter/ctx/ctx.inf
+++ b/filesys/miniFilter/ctx/ctx.inf
Binary files differ