Common (Windows): uses RtlOpenCurrentUser directly

This commit is contained in:
李通洲
2026-03-22 19:52:41 +08:00
parent f188e9518d
commit 4fb7860a8e
2 changed files with 6 additions and 17 deletions
+3 -2
View File
@@ -1231,8 +1231,9 @@ NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(
_Out_ PULONG ResultLength
);
NTSYSAPI NTSTATUS NTAPI RtlFormatCurrentUserKeyPath(
_Out_ PUNICODE_STRING CurrentUserKeyPath
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(
_In_ ACCESS_MASK DesiredAccess,
_Out_ PHANDLE CurrentUserKey
);
typedef struct _KEY_VALUE_PARTIAL_INFORMATION
+3 -15
View File
@@ -42,27 +42,15 @@ HANDLE ffRegGetRootKeyHandle(HKEY hKey)
switch ((uintptr_t) hKey)
{
case (uintptr_t) HKEY_CURRENT_USER: {
UNICODE_STRING path = {};
NTSTATUS status = RtlFormatCurrentUserKeyPath(&path);
NTSTATUS status = RtlOpenCurrentUser(KEY_READ, &result);
if (!NT_SUCCESS(status))
{
FF_DEBUG("RtlFormatCurrentUserKeyPath() failed: %s", ffDebugNtStatus(status));
FF_DEBUG("RtlOpenCurrentUser() failed: %s", ffDebugNtStatus(status));
return NULL;
}
status = NtOpenKey(&result, KEY_READ, &(OBJECT_ATTRIBUTES) {
.Length = sizeof(OBJECT_ATTRIBUTES),
.RootDirectory = NULL,
.ObjectName = &path,
});
if (!NT_SUCCESS(status))
{
FF_DEBUG("NtOpenKey(%ls) failed: %s (0x%08lx)", path.Buffer, ffDebugNtStatus(status), status);
RtlFreeUnicodeString(&path);
return NULL;
}
RtlFreeUnicodeString(&path);
break;
}
case (uintptr_t) HKEY_LOCAL_MACHINE: {
UNICODE_STRING path = RTL_CONSTANT_STRING(L"\\Registry\\Machine");
NTSTATUS status = NtOpenKey(&result, KEY_READ, &(OBJECT_ATTRIBUTES) {