static PDRIVER_OBJECT RegistryDriverObject;
static UNICODE_STRING RegistryPath;
+typedef NTSTATUS(*IOOPENDRIVERREGISTRYKEY)(PDRIVER_OBJECT, DRIVER_REGKEY_TYPE, ACCESS_MASK, ULONG, PHANDLE);
+
+static IOOPENDRIVERREGISTRYKEY __IoOpenDriverRegistryKey;
+
static FORCEINLINE PVOID
__RegistryAllocate(
IN ULONG Length
IN PUNICODE_STRING Path
)
{
+ UNICODE_STRING Unicode;
+ PVOID Func;
NTSTATUS status;
ASSERT3P(RegistryPath.Buffer, ==, NULL);
ASSERT3P(RegistryDriverObject, ==, NULL);
RegistryDriverObject = DriverObject;
+ ASSERT3P(__IoOpenDriverRegistryKey, ==, NULL);
+ RtlInitUnicodeString(&Unicode, L"IoOpenDriverRegistryKey");
+
+ Func = MmGetSystemRoutineAddress(&Unicode);
+ if (Func != NULL)
+ __IoOpenDriverRegistryKey = (IOOPENDRIVERREGISTRYKEY)Func;
+
return STATUS_SUCCESS;
fail1:
VOID
)
{
+ __IoOpenDriverRegistryKey = NULL;
+
RegistryDriverObject = NULL;
RtlFreeUnicodeString(&RegistryPath);
OUT PHANDLE Key
)
{
-#ifdef VERIFIER_REG_ISOLATION
- return IoOpenDriverRegistryKey(RegistryDriverObject,
- DriverRegKeyParameters,
- DesiredAccess,
- 0,
- Key);
-#else
HANDLE ServiceKey;
NTSTATUS status;
+ if (__IoOpenDriverRegistryKey != NULL) {
+ status = __IoOpenDriverRegistryKey(RegistryDriverObject,
+ DriverRegKeyParameters,
+ DesiredAccess,
+ 0,
+ Key);
+ if (!NT_SUCCESS(status))
+ goto fail1;
+
+ goto done;
+ }
+
status = RegistryOpenKey(NULL, &RegistryPath, DesiredAccess, &ServiceKey);
if (!NT_SUCCESS(status))
- goto fail1;
+ goto fail2;
status = RegistryOpenSubKey(ServiceKey, "Parameters", DesiredAccess, Key);
if (!NT_SUCCESS(status))
- goto fail2;
+ goto fail3;
RegistryCloseKey(ServiceKey);
+done:
return STATUS_SUCCESS;
-fail2:
- Error("fail2\n");
+fail3:
+ Error("fail3\n");
RegistryCloseKey(ServiceKey);
+fail2:
+ Error("fail2\n");
+
fail1:
Error("fail1 %08x\n", status);
return status;
-#endif
}
NTSTATUS