MCPcopy Create free account
hub / github.com/NullTerminatorr/NullHook / call_kernel_function

Method call_kernel_function

KernelCheatYT/hook.cpp:11–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9DeleteObjectApp_t NtGdiDeleteObjectApp = NULL;
10
11bool nullhook::call_kernel_function(void* kernel_function_address)
12{
13 if (!kernel_function_address)
14 return false;
15 //NtQueryCompositionSurfaceStatistics
16 PVOID* function = reinterpret_cast<PVOID*>(get_system_module_export("\\SystemRoot\\System32\\drivers\\dxgkrnl.sys",
17 "NtDxgkGetTrackedWorkloadStatistics"));
18
19 if (!function)
20 return false;
21
22 BYTE orig[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
23
24 BYTE shell_code[] = { 0x48, 0xB8 }; // mov rax, xxx
25 BYTE shell_code_end[] = { 0xFF, 0xE0 }; //jmp rax
26
27 RtlSecureZeroMemory(&orig, sizeof(orig));
28 memcpy((PVOID)((ULONG_PTR)orig), &shell_code, sizeof(shell_code));
29 uintptr_t hook_address = reinterpret_cast<uintptr_t>(kernel_function_address);
30 memcpy((PVOID)((ULONG_PTR)orig + sizeof(shell_code)), &hook_address, sizeof(void*));
31 memcpy((PVOID)((ULONG_PTR)orig + sizeof(shell_code) + sizeof(void*)), &shell_code_end, sizeof(shell_code_end));
32
33 write_to_read_only_memory(function, &orig, sizeof(orig));
34
35 GdiSelectBrush = (GdiSelectBrush_t)get_system_module_export(L"win32kfull.sys", "NtGdiSelectBrush");
36 NtGdiCreateSolidBrush = (NtGdiCreateSolidBrush_t)get_system_module_export(L"win32kfull.sys", "NtGdiCreateSolidBrush");
37 NtGdiPatBlt = (PatBlt_t)get_system_module_export(L"win32kfull.sys", "NtGdiPatBlt");
38 NtUserGetDC = (NtUserGetDC_t)get_system_module_export(L"win32kbase.sys", "NtUserGetDC");
39 NtUserReleaseDC = (ReleaseDC_t)get_system_module_export(L"win32kbase.sys", "NtUserReleaseDC");
40 NtGdiDeleteObjectApp = (DeleteObjectApp_t)get_system_module_export(L"win32kbase.sys", "NtGdiDeleteObjectApp");
41
42 return true;
43}
44
45NTSTATUS nullhook::hook_handler(PVOID called_param)
46{

Callers

nothing calls this directly

Calls 2

get_system_module_exportFunction · 0.85

Tested by

no test coverage detected