1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| NTSTATUS KernelReg(PUNICODE_STRING RegistryPath) { NTSTATUS status = STATUS_SUCCESS; HANDLE hRegKey = NULL; OBJECT_ATTRIBUTES RegAttribute = { 0 }; ULONG KeyOp = 0;
PVOID KeyInfo = ExAllocatePool2(POOL_FLAG_NON_PAGED, 0x1000, 'kcaH'); if (KeyInfo == NULL) { DbgPrint("Allocate Mem Failed\n"); return status; } RtlZeroMemory(KeyInfo, 0x1000); UNICODE_STRING regKeyName = { 0 }; RtlInitUnicodeString(®KeyName, L"ImagePath");
InitializeObjectAttributes(&RegAttribute, RegistryPath, OBJ_CASE_INSENSITIVE, NULL, NULL); status = ZwOpenKey(&hRegKey, KEY_ALL_ACCESS, &RegAttribute); if (!NT_SUCCESS(status)) { DbgPrint("Open Reg Key Failed\n"); return status; } status = ZwQueryValueKey(hRegKey, ®KeyName, KeyValuePartialInformation, KeyInfo, 0x1000 - 1, &KeyOp); if (!NT_SUCCESS(status)) { DbgPrint("Read Reg Key Failed\n"); ZwClose(hRegKey); ExFreePool(KeyInfo); return status; } PKEY_VALUE_PARTIAL_INFORMATION tempinfo = (PKEY_VALUE_PARTIAL_INFORMATION)KeyInfo; PWCHAR tempName = (PWCHAR)(tempinfo->Data); DbgPrint("reg: %wZ, key: %wZ, Value: %ws\n", RegistryPath,regKeyName, tempName);
ZwClose(hRegKey); ExFreePool(KeyInfo); return status; }
|