├── .gitattributes ├── .gitignore ├── KernelHack.sln ├── KernelHack ├── CallStack-Spoofer.h ├── Callbacks.cpp ├── Callbacks.h ├── Comm.cpp ├── Comm.hpp ├── Debug │ ├── KernelHack.Build.CppClean.log │ ├── KernelHack.log │ └── KernelHack.tlog │ │ ├── KernelHack.lastbuildstate │ │ └── unsuccessfulbuild ├── I8042Interface.cpp ├── I8042Interface.h ├── Imports.h ├── Includes.h ├── KernelHack.inf ├── KernelHack.vcxproj ├── KernelHack.vcxproj.filters ├── KernelHack.vcxproj.user ├── Mapper.cpp ├── Mapper.hpp ├── Memory.cpp ├── Memory.hpp ├── NativeEnums.h ├── NativeStructs.h ├── NativeStructs10.h ├── NativeStructs7.h ├── NativeStructs8.h ├── NativeStructs81.h ├── Offsets.cpp ├── Offsets.hpp ├── Process.cpp ├── Process.hpp ├── Utils.cpp ├── Utils.hpp ├── entry.cpp ├── hde │ ├── hde.h │ ├── hde32.c │ ├── hde32.h │ ├── hde64.c │ ├── hde64.h │ ├── kstdint.h │ ├── table32.h │ └── table64.h ├── skCrypter.h └── x64 │ ├── Debug │ ├── Callbacks.obj │ ├── Comm.obj │ ├── I8042Interface.obj │ ├── KernelHack.Build.CppClean.log │ ├── KernelHack.log │ ├── KernelHack.sys.recipe │ ├── KernelHack.tlog │ │ ├── CL.command.1.tlog │ │ ├── CL.read.1.tlog │ │ ├── CL.write.1.tlog │ │ ├── KernelHack.lastbuildstate │ │ ├── link.command.1.tlog │ │ ├── link.read.1.tlog │ │ └── link.write.1.tlog │ ├── Mapper.obj │ ├── Memory.obj │ ├── Offsets.obj │ ├── Process.obj │ ├── Utils.obj │ ├── entry.obj │ ├── hde32.obj │ ├── hde64.obj │ ├── vc143.pdb │ └── vcpkg.applocal.log │ └── Release │ ├── KernelHack.Build.CppClean.log │ ├── KernelHack.log │ ├── KernelHack.sys.recipe │ ├── KernelHack.tlog │ └── KernelHack.lastbuildstate │ └── vcpkg.applocal.log ├── LICENSE.txt ├── README.md ├── Usermode ├── Debug │ ├── Usermode.Build.CppClean.log │ ├── Usermode.exe.recipe │ ├── Usermode.log │ ├── Usermode.tlog │ │ └── Usermode.lastbuildstate │ ├── Usermode.vcxproj.FileListAbsolute.txt │ └── vcpkg.applocal.log ├── UmComm.cpp ├── UmComm.h ├── Usermode.vcxproj ├── Usermode.vcxproj.filters ├── Usermode.vcxproj.user ├── Utils.h ├── main.cpp ├── ntdll.h └── x64 │ ├── Debug │ ├── CodeAnalysisResultManifest.txt │ ├── Usermode.Build.CppClean.log │ ├── Usermode.exe.recipe │ ├── Usermode.log │ ├── Usermode.tlog │ │ └── Usermode.lastbuildstate │ ├── Usermode.vcxproj.FileListAbsolute.txt │ └── vcpkg.applocal.log │ └── Release │ ├── Usermode.Build.CppClean.log │ ├── Usermode.exe.recipe │ ├── Usermode.log │ ├── Usermode.tlog │ └── Usermode.lastbuildstate │ └── Usermode.vcxproj.FileListAbsolute.txt ├── install.bat └── x64 ├── Debug ├── KernelHack.pdb ├── KernelHack.sys ├── KernelHack │ └── KernelHack.sys ├── Msgbox.dll ├── Usermode.exe └── getmemory.exe └── Release ├── KernelHack.sys ├── KernelHack └── KernelHack.sys └── Usermode.exe /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。 3 | ################################################################################ 4 | 5 | /.vs/KernelHack 6 | -------------------------------------------------------------------------------- /KernelHack.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32929.386 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "KernelHack", "KernelHack\KernelHack.vcxproj", "{1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Usermode", "Usermode\Usermode.vcxproj", "{A6F58EEE-0E0D-4A80-9355-E446107CCC4D}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Debug|x64.ActiveCfg = Debug|x64 19 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Debug|x64.Build.0 = Debug|x64 20 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Debug|x64.Deploy.0 = Debug|x64 21 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Debug|x86.ActiveCfg = Debug|Win32 22 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Debug|x86.Build.0 = Debug|Win32 23 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Debug|x86.Deploy.0 = Debug|Win32 24 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Release|x64.ActiveCfg = Release|x64 25 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Release|x64.Build.0 = Release|x64 26 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Release|x64.Deploy.0 = Release|x64 27 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Release|x86.ActiveCfg = Release|Win32 28 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Release|x86.Build.0 = Release|Win32 29 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7}.Release|x86.Deploy.0 = Release|Win32 30 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Debug|x64.ActiveCfg = Debug|x64 31 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Debug|x64.Build.0 = Debug|x64 32 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Debug|x86.ActiveCfg = Debug|Win32 33 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Debug|x86.Build.0 = Debug|Win32 34 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Release|x64.ActiveCfg = Release|x64 35 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Release|x64.Build.0 = Release|x64 36 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Release|x86.ActiveCfg = Release|Win32 37 | {A6F58EEE-0E0D-4A80-9355-E446107CCC4D}.Release|x86.Build.0 = Release|Win32 38 | EndGlobalSection 39 | GlobalSection(SolutionProperties) = preSolution 40 | HideSolutionNode = FALSE 41 | EndGlobalSection 42 | GlobalSection(ExtensibilityGlobals) = postSolution 43 | SolutionGuid = {C42C8C5A-79EC-4CE4-9B61-6239866053FB} 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /KernelHack/CallStack-Spoofer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifdef _KERNEL_MODE 3 | #include 4 | #include 5 | //#include 6 | #else 7 | #include 8 | #include 9 | #endif 10 | #include 11 | 12 | /* 13 | * Copyright 2022 Barracudach 14 | * 15 | * Licensed under the Apache License, Version 2.0 (the "License"); 16 | * you may not use this file except in compliance with the License. 17 | * You may obtain a copy of the License at 18 | * 19 | * http://www.apache.org/licenses/LICENSE-2.0 20 | * 21 | * Unless required by applicable law or agreed to in writing, software 22 | * distributed under the License is distributed on an "AS IS" BASIS, 23 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 | * See the License for the specific language governing permissions and 25 | * limitations under the License. 26 | */ 27 | 28 | // === FAQ === documentation is available at https://github.com/Barracudach 29 | //Supports 2 modes: kernelmode and usermode(x64) 30 | //For kernel- disable Control Flow Guard (CFG) /guard:cf 31 | //usermode c++17 and above 32 | //kernelmode c++14 and above 33 | 34 | 35 | 36 | #define SPOOF_FUNC CallSpoofer::SpoofFunction spoof(_AddressOfReturnAddress()); 37 | #define SPOOF_FUNC_EX(x) CallSpoofer::SpoofFunction spoof(_AddressOfReturnAddress(), (x)); 38 | #ifdef _KERNEL_MODE 39 | #define SPOOF_CALL(ret_type,name) (CallSpoofer::SafeCall>(name)) 40 | #else 41 | #define SPOOF_CALL(name) (CallSpoofer::SafeCall(name)) 42 | #endif 43 | 44 | 45 | #define MAX_FUNC_BUFFERED 100 46 | #define SHELLCODE_GENERATOR_SIZE 500 47 | 48 | namespace CallSpoofer 49 | { 50 | #ifdef _KERNEL_MODE 51 | typedef unsigned __int64 uintptr_t, size_t; 52 | #pragma region std::forward 53 | template 54 | struct remove_reference { 55 | using type = _Ty; 56 | using _Const_thru_ref_type = const _Ty; 57 | }; 58 | template 59 | using remove_reference_t = typename remove_reference<_Ty>::type; 60 | 61 | template 62 | constexpr bool is_lvalue_reference_v = false; // determine whether type argument is an lvalue reference 63 | 64 | template 65 | constexpr bool is_lvalue_reference_v<_Ty&> = true; 66 | 67 | template 68 | constexpr _Ty&& forward( 69 | remove_reference_t<_Ty>& _Arg) noexcept { // forward an lvalue as either an lvalue or an rvalue 70 | return static_cast<_Ty&&>(_Arg); 71 | } 72 | 73 | template 74 | constexpr _Ty&& forward(remove_reference_t<_Ty>&& _Arg) noexcept { // forward an rvalue as an rvalue 75 | static_assert(!is_lvalue_reference_v<_Ty>, "bad forward call"); 76 | return static_cast<_Ty&&>(_Arg); 77 | } 78 | #pragma endregion 79 | 80 | #else 81 | using namespace std; 82 | #endif 83 | 84 | } 85 | 86 | 87 | namespace CallSpoofer 88 | { 89 | class SpoofFunction 90 | { 91 | public: 92 | uintptr_t temp = 0; 93 | const uintptr_t xor_key = 0xff11ff22ff33ff44; 94 | void* ret_addr_in_stack = 0; 95 | 96 | SpoofFunction(void* addr) :ret_addr_in_stack(addr) 97 | { 98 | temp = *(uintptr_t*)ret_addr_in_stack; 99 | temp ^= xor_key; 100 | *(uintptr_t*)ret_addr_in_stack = __readmsr(0xC0000082); 101 | } 102 | SpoofFunction(void* addr, uintptr_t fake_addr) :ret_addr_in_stack(addr) 103 | { 104 | temp = *(uintptr_t*)ret_addr_in_stack; 105 | temp ^= xor_key; 106 | *(uintptr_t*)ret_addr_in_stack = fake_addr; 107 | } 108 | ~SpoofFunction() 109 | { 110 | temp ^= xor_key; 111 | *(uintptr_t*)ret_addr_in_stack = temp; 112 | } 113 | }; 114 | 115 | #ifdef _KERNEL_MODE 116 | __forceinline PVOID LocateShellCode(PVOID func, size_t size = 500) 117 | { 118 | void* addr = ExAllocatePoolWithTag(NonPagedPool, size, 'TAGE'); 119 | if (!addr) 120 | return nullptr; 121 | return memcpy(addr, func, size); 122 | } 123 | #else 124 | __forceinline PVOID LocateShellCode(PVOID func, size_t size = SHELLCODE_GENERATOR_SIZE) 125 | { 126 | void* addr = VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 127 | if (!addr) 128 | return nullptr; 129 | return memcpy(addr, func, size); 130 | } 131 | #endif 132 | 133 | #ifdef _KERNEL_MODE 134 | template 135 | RetType 136 | #else 137 | template 138 | typename std::invoke_result::type 139 | #endif 140 | __declspec(safebuffers)ShellCodeGenerator(Func f, Args&... args) 141 | { 142 | #ifdef _KERNEL_MODE 143 | using this_func_type = decltype(ShellCodeGenerator); 144 | using return_type = RetType; 145 | #else 146 | using this_func_type = decltype(ShellCodeGenerator); 147 | using return_type = typename std::invoke_result::type; 148 | #endif 149 | const uintptr_t xor_key = 0xff00ff00ff00ff00; 150 | void* ret_addr_in_stack = _AddressOfReturnAddress(); 151 | uintptr_t temp = *(uintptr_t*)ret_addr_in_stack; 152 | temp ^= xor_key; 153 | *(uintptr_t*)ret_addr_in_stack = 0; 154 | 155 | if constexpr (std::is_same::value) 156 | { 157 | f(args...); 158 | temp ^= xor_key; 159 | *(uintptr_t*)ret_addr_in_stack = temp; 160 | } 161 | else 162 | { 163 | return_type&& ret = f(args...); 164 | temp ^= xor_key; 165 | *(uintptr_t*)ret_addr_in_stack = temp; 166 | return ret; 167 | } 168 | } 169 | 170 | 171 | 172 | #ifdef _KERNEL_MODE 173 | template 174 | #else 175 | template 176 | #endif 177 | class SafeCall 178 | { 179 | 180 | Func* funcPtr; 181 | 182 | public: 183 | SafeCall(Func* func) :funcPtr(func) {} 184 | 185 | 186 | template 187 | __forceinline decltype(auto) operator()(Args&&... args) 188 | { 189 | SPOOF_FUNC; 190 | 191 | #ifdef _KERNEL_MODE 192 | using return_type = RetType; 193 | using p_shell_code_generator_type = decltype(&ShellCodeGenerator); 194 | PVOID self_addr = static_cast(&ShellCodeGenerator); 195 | #else 196 | using return_type = typename std::invoke_result::type; 197 | using p_shell_code_generator_type = decltype(&ShellCodeGenerator); 198 | p_shell_code_generator_type self_addr = static_cast(&ShellCodeGenerator); 199 | #endif 200 | 201 | p_shell_code_generator_type p_shellcode{}; 202 | 203 | static size_t count{}; 204 | static p_shell_code_generator_type orig_generator[MAX_FUNC_BUFFERED]{}; 205 | static p_shell_code_generator_type alloc_generator[MAX_FUNC_BUFFERED]{}; 206 | 207 | unsigned index{}; 208 | while (orig_generator[index]) 209 | { 210 | if (orig_generator[index] == self_addr) 211 | { 212 | #ifdef _KERNEL_MODE 213 | //DbgPrint("Found allocated generator"); 214 | #else 215 | //std::cout << "Found allocated generator" << std::endl; 216 | #endif 217 | 218 | p_shellcode = alloc_generator[index]; 219 | break; 220 | } 221 | index++; 222 | } 223 | 224 | if (!p_shellcode) 225 | { 226 | #ifdef _KERNEL_MODE 227 | //DbgPrint("Alloc generator"); 228 | #else 229 | //std::cout << "Alloc generator" << std::endl; 230 | #endif 231 | 232 | p_shellcode = reinterpret_cast( LocateShellCode(self_addr)); 233 | orig_generator[count] = self_addr; 234 | alloc_generator[count] = p_shellcode; 235 | count++; 236 | } 237 | 238 | if (!p_shellcode) 239 | { 240 | //DbgPrint("!p_shellcode"); 241 | } 242 | 243 | return p_shellcode(funcPtr, args...); 244 | } 245 | }; 246 | } 247 | -------------------------------------------------------------------------------- /KernelHack/Callbacks.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #include "Callbacks.h" 13 | -------------------------------------------------------------------------------- /KernelHack/Callbacks.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include 14 | 15 | namespace Callbacks 16 | { 17 | typedef struct _NOTIFICATION_CALLBACKS { 18 | ULONG_PTR PspCreateProcessNotifyRoutine; 19 | ULONG_PTR PspCreateThreadNotifyRoutine; 20 | ULONG_PTR PspLoadImageNotifyRoutine; 21 | ULONG_PTR KeBugCheckCallbackHead; 22 | ULONG_PTR KeBugCheckReasonCallbackHead; 23 | ULONG_PTR CmCallbackListHead; 24 | ULONG_PTR IopNotifyShutdownQueueHead; 25 | ULONG_PTR IopNotifyLastChanceShutdownQueueHead; 26 | ULONG_PTR ObProcessCallbackHead; 27 | ULONG_PTR ObThreadCallbackHead; 28 | ULONG_PTR ObDesktopCallbackHead; 29 | ULONG_PTR SeFileSystemNotifyRoutinesHead; 30 | ULONG_PTR SeFileSystemNotifyRoutinesExHead; 31 | ULONG_PTR PopRegisteredPowerSettingCallbacks; 32 | ULONG_PTR RtlpDebugPrintCallbackList; 33 | ULONG_PTR IopFsNotifyChangeQueueHead; 34 | ULONG_PTR IopDiskFileSystemQueueHead; 35 | ULONG_PTR IopCdRomFileSystemQueueHead; 36 | ULONG_PTR IopTapeFileSystemQueueHead; 37 | ULONG_PTR IopNetworkFileSystemQueueHead; 38 | ULONG_PTR DbgkLmdCallbacks; 39 | ULONG_PTR PsAltSystemCallHandlers; 40 | ULONG_PTR CiCallbacks; 41 | ULONG_PTR ExpHostListHead; 42 | ULONG_PTR ExpCallbackListHead; 43 | ULONG_PTR PoCoalescingCallbacks; 44 | ULONG_PTR PspPicoProviderRoutines; 45 | ULONG_PTR KiNmiCallbackListHead; 46 | ULONG_PTR PspSiloMonitorList; 47 | ULONG_PTR EmpCallbackListHead; 48 | } NOTIFICATION_CALLBACKS, * PNOTIFICATION_CALLBACKS; 49 | }; 50 | 51 | -------------------------------------------------------------------------------- /KernelHack/Comm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/Comm.cpp -------------------------------------------------------------------------------- /KernelHack/Comm.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include "Includes.h" 14 | 15 | namespace Comm 16 | { 17 | enum OPERATION 18 | { 19 | ReadMem = 0x801, 20 | WriteMem, 21 | AllocMem, 22 | ProtectMem, 23 | ModuleBase, 24 | CodeInject, 25 | }; 26 | 27 | #pragma pack(8) 28 | typedef struct _REQUEST { 29 | ULONG Operation; 30 | PVOID Instruction; 31 | } REQUEST, * PREQUEST; 32 | 33 | typedef struct _COPY_MEMORY { 34 | ULONG ProcessId; 35 | PVOID Destination; 36 | PVOID Source; 37 | SIZE_T Size; 38 | } COPY_MEMORY, * PCOPY_MEMORY; 39 | 40 | typedef struct _ALLOC_MEMORY { 41 | ULONG ProcessId; 42 | PVOID Base; 43 | SIZE_T Size; 44 | } ALLOC_MEMORY, * PALLOC_MEMORY; 45 | 46 | typedef struct _MODULE_BASE { 47 | ULONG ProcessId; 48 | PCHAR ModuleName; 49 | PVOID PBase; 50 | } MODULE_BASE, * PMODULE_BASE; 51 | 52 | typedef struct _CODE_INJECT { 53 | ULONG ProcessId; 54 | PBYTE Shellcode; 55 | SIZE_T Size; 56 | } CODE_INJECT, * PCODE_INJECT; 57 | 58 | #pragma pack() 59 | 60 | void RequestHandler(PREQUEST Request); 61 | 62 | namespace DeviceIoControl { 63 | NTSTATUS DispatchIoCtrl(PDEVICE_OBJECT pDeviceObj, PIRP pIrp); 64 | BOOLEAN Initialize(PDRIVER_OBJECT DriverObject); 65 | BOOLEAN Unload(PDRIVER_OBJECT DriverObject); 66 | } 67 | 68 | namespace BoundCallback { 69 | BOUND_CALLBACK_STATUS CallbackFunc(); 70 | BOOLEAN Initialize(); 71 | BOOLEAN Unload(); 72 | } 73 | 74 | namespace RegistryCallback 75 | { 76 | NTSTATUS RegistryCallback( 77 | PVOID CallbackContext, 78 | PVOID Argument1, 79 | PVOID Argument2); 80 | BOOLEAN Initialize(); 81 | BOOLEAN Unload(); 82 | } 83 | 84 | namespace IrpHijack { 85 | NTSTATUS DetourDeviceControl( 86 | PDEVICE_OBJECT DeviceObject, 87 | PIRP Irp); 88 | BOOLEAN Initialize(); 89 | BOOLEAN Unload(); 90 | } 91 | }; 92 | 93 | -------------------------------------------------------------------------------- /KernelHack/Debug/KernelHack.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | e:\project\vsproject\kernelhack\kernelhack\debug\vc142.pdb 2 | e:\project\vsproject\kernelhack\kernelhack\debug\utils.obj 3 | e:\project\vsproject\kernelhack\kernelhack\debug\process.obj 4 | e:\project\vsproject\kernelhack\kernelhack\debug\offsets.obj 5 | e:\project\vsproject\kernelhack\kernelhack\debug\memory.obj 6 | e:\project\vsproject\kernelhack\kernelhack\debug\entry.obj 7 | e:\project\vsproject\kernelhack\kernelhack\debug\callbacks.obj 8 | e:\project\vsproject\kernelhack\kernelhack\debug\kernelhack.tlog\cl.command.1.tlog 9 | e:\project\vsproject\kernelhack\kernelhack\debug\kernelhack.tlog\cl.read.1.tlog 10 | e:\project\vsproject\kernelhack\kernelhack\debug\kernelhack.tlog\cl.write.1.tlog 11 | -------------------------------------------------------------------------------- /KernelHack/Debug/KernelHack.log: -------------------------------------------------------------------------------- 1 |  Building 'KernelHack' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform. 2 | Callbacks.cpp 3 | Comm.cpp 4 | E:\project\VSProject\KernelHack\KernelHack\Comm.cpp(57,4): error C2065: “PKTRAP_FRAME”: 未声明的标识符 5 | E:\project\VSProject\KernelHack\KernelHack\Comm.cpp(57,17): error C2146: 语法错误: 缺少“;”(在标识符“trap_frame”的前面) 6 | E:\project\VSProject\KernelHack\KernelHack\Comm.cpp(57,17): error C2065: “trap_frame”: 未声明的标识符 7 | E:\project\VSProject\KernelHack\KernelHack\Comm.cpp(57,31): error C2065: “PKTRAP_FRAME”: 未声明的标识符 8 | E:\project\VSProject\KernelHack\KernelHack\Comm.cpp(58,29): error C2065: “trap_frame”: 未声明的标识符 9 | E:\project\VSProject\KernelHack\KernelHack\Comm.cpp(59,4): error C2065: “trap_frame”: 未声明的标识符 10 | entry.cpp 11 | Mapper.cpp 12 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(32,97): error C2664: “PVOID TranslateRaw(PBYTE,PIMAGE_NT_HEADERS,DWORD)”: 无法将参数 2 从“const PIMAGE_NT_HEADERS64”转换为“PIMAGE_NT_HEADERS” 13 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(32,83): message : 与指向的类型无关;强制转换要求 reinterpret_cast、C 样式强制转换或函数样式强制转换 14 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(16,7): message : 参见“TranslateRaw”的声明 15 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(33,23): error C3536: “importDescriptor”: 初始化之前无法使用 16 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(38,91): error C2660: “TranslateRaw”: 函数不接受 2 个参数 17 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(16,7): message : 参见“TranslateRaw”的声明 18 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(45,85): error C2665: “Utils::GetModuleBase”: 3 个重载中没有一个可以转换所有参数类型 19 | E:\project\VSProject\KernelHack\KernelHack\Utils.hpp(10,8): message : 可能是“PVOID Utils::GetModuleBase(PCHAR,SIZE_T *)” 20 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(45,85): message : 尝试匹配参数列表“(PCHAR, size_t *)”时 21 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(50,3): error C2660: “TranslateRaw”: 函数不接受 2 个参数 22 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(16,7): message : 参见“TranslateRaw”的声明 23 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(52,132): error C2664: “PVOID TranslateRaw(PBYTE,PIMAGE_NT_HEADERS,DWORD)”: 无法将参数 2 从“const PIMAGE_NT_HEADERS64”转换为“PIMAGE_NT_HEADERS” 24 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(52,78): message : 与指向的类型无关;强制转换要求 reinterpret_cast、C 样式强制转换或函数样式强制转换 25 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(16,7): message : 参见“TranslateRaw”的声明 26 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(53,102): error C3536: “importByName”: 初始化之前无法使用 27 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(53,108): error C2660: “RtlFindExportedRoutineByName”: 函数不接受 1 个参数 28 | E:\project\VSProject\KernelHack\KernelHack\Imports.h(232,1): message : 参见“RtlFindExportedRoutineByName”的声明 29 | E:\project\VSProject\KernelHack\KernelHack\Mapper.cpp(172,18): warning C4244: “初始化”: 从“LONGLONG”转换到“SIZE_T”,可能丢失数据 30 | Memory.cpp 31 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(124,19): error C3861: “MiGetPxeOffset”: 找不到标识符 32 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(125,19): error C3861: “MiGetPpeOffset”: 找不到标识符 33 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(126,19): error C3861: “MiGetPdeOffset”: 找不到标识符 34 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(127,19): error C3861: “MiGetPteOffset”: 找不到标识符 35 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(302,32): warning C4244: “初始化”: 从“ULONG64”转换到“uintptr_t”,可能丢失数据 36 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(311,51): warning C4244: “=”: 从“ULONG64”转换到“uintptr_t”,可能丢失数据 37 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(325,30): warning C4244: “初始化”: 从“ULONG64”转换到“uintptr_t”,可能丢失数据 38 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(376,25): warning C4244: “=”: 从“ULONG64”转换到“uintptr_t”,可能丢失数据 39 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(380,29): warning C4244: “=”: 从“ULONG64”转换到“uintptr_t”,可能丢失数据 40 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(384,37): warning C4244: “=”: 从“ULONG64”转换到“uintptr_t”,可能丢失数据 41 | E:\project\VSProject\KernelHack\KernelHack\Memory.cpp(406,20): warning C4018: “<”: 有符号/无符号不匹配 42 | Offsets.cpp 43 | Process.cpp 44 | E:\project\VSProject\KernelHack\KernelHack\Process.cpp(32,41): warning C4100: “Process”: 未引用的形参 45 | Utils.cpp 46 | 正在生成代码... 47 | -------------------------------------------------------------------------------- /KernelHack/Debug/KernelHack.tlog/KernelHack.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=WindowsKernelModeDriver10.0:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:TargetPlatformVersion=10.0.19041.0:VcpkgTriplet=x86-windows: 2 | Debug|Win32|E:\project\VSProject\KernelHack\| 3 | -------------------------------------------------------------------------------- /KernelHack/Debug/KernelHack.tlog/unsuccessfulbuild: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/Debug/KernelHack.tlog/unsuccessfulbuild -------------------------------------------------------------------------------- /KernelHack/I8042Interface.cpp: -------------------------------------------------------------------------------- 1 | #include "I8042Interface.h" 2 | #include "Imports.h" 3 | #include "Offsets.hpp" 4 | #include "Utils.hpp" 5 | 6 | 7 | namespace I8042Interface 8 | { 9 | PDEVICE_OBJECT I8042DeviceObject; 10 | } 11 | 12 | BOOLEAN I8042Interface::InitializeI8042Interface() 13 | { 14 | PDRIVER_OBJECT i8042; 15 | UNICODE_STRING i8042prt = RTL_CONSTANT_STRING(L"\\Driver\\i8042prt"); 16 | NTSTATUS status = ObReferenceObjectByName(&i8042prt, OBJ_CASE_INSENSITIVE, NULL, 0, *IoDriverObjectType, KernelMode, NULL, (PVOID*)&i8042); 17 | if (!NT_SUCCESS(status)) { 18 | return FALSE; 19 | } 20 | ObDereferenceObject(i8042); 21 | I8042DeviceObject = i8042->DeviceObject; 22 | if (!I8042DeviceObject) { 23 | return FALSE; 24 | } 25 | if (I8042DeviceObject->NextDevice) { 26 | I8042DeviceObject = I8042DeviceObject->NextDevice; 27 | } 28 | return TRUE; 29 | } 30 | 31 | BOOLEAN I8042Interface::I8xWriteDataToKeyboardQueue(PVOID KeyboardExtension, IN PKEYBOARD_INPUT_DATA InputData) 32 | { 33 | typedef BOOLEAN(*pfnI8xWriteDataToKeyboardQueue)(PVOID KeyboardExtension, PKEYBOARD_INPUT_DATA InputData); 34 | if (Offsets::I8xWriteDataToKeyboardQueue.Address) { 35 | return ((pfnI8xWriteDataToKeyboardQueue)Offsets::I8xWriteDataToKeyboardQueue.Address)(KeyboardExtension, InputData); 36 | } 37 | return FALSE; 38 | } 39 | 40 | void I8042Interface::Test() 41 | { 42 | 43 | //do test 44 | 45 | //00 00 5b 00 02 00 00 00-00 00 00 00 00 00 00 00 //Win make 46 | //00 00 5b 00 03 00 00 00-00 00 00 00 00 00 00 00 //Win release 47 | 48 | //00 00 1e 00 00 00 00 00-00 00 00 00 00 00 00 00 //A make 49 | //00 00 1e 00 01 00 00 00-00 00 00 00 00 00 00 00 //A release 50 | 51 | KEYBOARD_INPUT_DATA data1 = { 52 | 0x0000, 53 | 0x005b, 54 | 0x0002, 55 | 0x0000, 56 | 0x00000000, 57 | }; 58 | 59 | KEYBOARD_INPUT_DATA data2 = { 60 | 0x0000, 61 | 0x005b, 62 | 0x0003, 63 | 0x0000, 64 | 0x00000000, 65 | }; 66 | 67 | //I8042Interface::I8042DeviceObject = (PDEVICE_OBJECT)0xffffa606d8ef03e0; 68 | 69 | if (I8042Interface::InitializeI8042Interface()) 70 | { 71 | DbgPrint("[*] I8042DeviceObject = %p\n", I8042Interface::I8042DeviceObject); 72 | 73 | for (size_t i = 0; i < 10; i++) 74 | { 75 | DbgPrint("[*] Calling I8xWriteDataToKeyboardQueue\n"); 76 | I8042Interface::I8xWriteDataToKeyboardQueue(I8042Interface::I8042DeviceObject->DeviceExtension, &data1); 77 | KeInsertQueueDpc((PRKDPC)((char*)I8042Interface::I8042DeviceObject->DeviceExtension + 0x2E0), 78 | I8042Interface::I8042DeviceObject->CurrentIrp, NULL); 79 | 80 | I8042Interface::I8xWriteDataToKeyboardQueue(I8042Interface::I8042DeviceObject->DeviceExtension, &data2); 81 | KeInsertQueueDpc((PRKDPC)((char*)I8042Interface::I8042DeviceObject->DeviceExtension + 0x2E0), 82 | I8042Interface::I8042DeviceObject->CurrentIrp, NULL); 83 | 84 | Utils::Sleep(100); 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /KernelHack/I8042Interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | namespace I8042Interface 8 | { 9 | //typedef struct _KEYBOARD_INPUT_DATA { 10 | // USHORT UnitId; 11 | // USHORT MakeCode; 12 | // USHORT Flags; 13 | // USHORT Reserved; 14 | // ULONG ExtraInformation; 15 | //} KEYBOARD_INPUT_DATA, * PKEYBOARD_INPUT_DATA; 16 | 17 | extern PDEVICE_OBJECT I8042DeviceObject; 18 | 19 | BOOLEAN InitializeI8042Interface(); 20 | 21 | BOOLEAN I8xWriteDataToKeyboardQueue(PVOID KeyboardExtension, IN PKEYBOARD_INPUT_DATA InputData); 22 | 23 | void Test(); 24 | } 25 | -------------------------------------------------------------------------------- /KernelHack/Imports.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include "NativeEnums.h" 14 | #include "NativeStructs.h" 15 | 16 | 17 | EXTERN_C_START 18 | 19 | NTSYSAPI 20 | NTSTATUS 21 | NTAPI 22 | ZwQuerySystemInformation( 23 | IN SYSTEM_INFORMATION_CLASS SystemInformationClass, 24 | OUT PVOID SystemInformation, 25 | IN ULONG SystemInformationLength, 26 | OUT PULONG ReturnLength OPTIONAL 27 | ); 28 | 29 | NTSYSAPI 30 | NTSTATUS 31 | NTAPI 32 | ZwSetSystemInformation( 33 | IN SYSTEM_INFORMATION_CLASS SystemInformationClass, 34 | IN PVOID SystemInformation, 35 | IN ULONG SystemInformationLength 36 | ); 37 | 38 | NTSYSAPI 39 | NTSTATUS 40 | NTAPI 41 | ZwQueryInformationProcess( 42 | IN HANDLE ProcessHandle, 43 | IN PROCESSINFOCLASS ProcessInformationClass, 44 | OUT PVOID ProcessInformation, 45 | IN ULONG ProcessInformationLength, 46 | IN PULONG ReturnLength 47 | ); 48 | 49 | NTSYSAPI 50 | NTSTATUS 51 | NTAPI 52 | ZwQueryInformationThread( 53 | IN HANDLE ThreadHandle, 54 | IN THREADINFOCLASS ThreadInformationClass, 55 | OUT PVOID ThreadInformation, 56 | IN ULONG ThreadInformationLength, 57 | OUT PULONG ReturnLength OPTIONAL 58 | ); 59 | 60 | /* 61 | NTSYSAPI 62 | NTSTATUS 63 | NTAPI 64 | ZwQueryVirtualMemory( 65 | IN HANDLE ProcessHandle, 66 | IN PVOID BaseAddress, 67 | IN MEMORY_INFORMATION_CLASS MemoryInformationClass, 68 | OUT PVOID MemoryInformation, 69 | IN SIZE_T MemoryInformationLength, 70 | OUT PSIZE_T ReturnLength 71 | ); 72 | */ 73 | NTSTATUS 74 | NTAPI 75 | ZwCreateThreadEx( 76 | OUT PHANDLE hThread, 77 | IN ACCESS_MASK DesiredAccess, 78 | IN PVOID ObjectAttributes, 79 | IN HANDLE ProcessHandle, 80 | IN PVOID lpStartAddress, 81 | IN PVOID lpParameter, 82 | IN ULONG Flags, 83 | IN SIZE_T StackZeroBits, 84 | IN SIZE_T SizeOfStackCommit, 85 | IN SIZE_T SizeOfStackReserve, 86 | IN PNT_PROC_THREAD_ATTRIBUTE_LIST AttributeList 87 | ); 88 | 89 | NTSTATUS 90 | NTAPI 91 | ZwTerminateThread( 92 | IN HANDLE ThreadHandle, 93 | IN NTSTATUS ExitStatus 94 | ); 95 | 96 | 97 | 98 | NTKERNELAPI 99 | NTSTATUS 100 | NTAPI 101 | MmCopyVirtualMemory( 102 | IN PEPROCESS FromProcess, 103 | IN PVOID FromAddress, 104 | IN PEPROCESS ToProcess, 105 | OUT PVOID ToAddress, 106 | IN SIZE_T BufferSize, 107 | IN KPROCESSOR_MODE PreviousMode, 108 | OUT PSIZE_T NumberOfBytesCopied 109 | ); 110 | 111 | NTKERNELAPI 112 | PPEB 113 | NTAPI 114 | PsGetProcessPeb(IN PEPROCESS Process); 115 | 116 | NTKERNELAPI 117 | PVOID 118 | NTAPI 119 | PsGetThreadTeb(IN PETHREAD Thread); 120 | 121 | NTKERNELAPI 122 | PVOID 123 | NTAPI 124 | PsGetProcessWow64Process(IN PEPROCESS Process); 125 | 126 | NTKERNELAPI 127 | PVOID 128 | NTAPI 129 | PsGetCurrentProcessWow64Process(); 130 | 131 | NTKERNELAPI 132 | BOOLEAN 133 | NTAPI 134 | KeTestAlertThread(IN KPROCESSOR_MODE AlertMode); 135 | 136 | NTKERNELAPI 137 | BOOLEAN 138 | NTAPI 139 | PsIsProtectedProcess(IN PEPROCESS Process); 140 | 141 | typedef VOID(NTAPI* PKNORMAL_ROUTINE)( 142 | PVOID NormalContext, 143 | PVOID SystemArgument1, 144 | PVOID SystemArgument2 145 | ); 146 | 147 | typedef VOID(NTAPI* PKKERNEL_ROUTINE)( 148 | PRKAPC Apc, 149 | PKNORMAL_ROUTINE* NormalRoutine, 150 | PVOID* NormalContext, 151 | PVOID* SystemArgument1, 152 | PVOID* SystemArgument2 153 | ); 154 | 155 | typedef VOID(NTAPI* PKRUNDOWN_ROUTINE)(PRKAPC Apc); 156 | 157 | NTKERNELAPI 158 | VOID 159 | NTAPI 160 | KeInitializeApc( 161 | IN PKAPC Apc, 162 | IN PKTHREAD Thread, 163 | IN KAPC_ENVIRONMENT ApcStateIndex, 164 | IN PKKERNEL_ROUTINE KernelRoutine, 165 | IN PKRUNDOWN_ROUTINE RundownRoutine, 166 | IN PKNORMAL_ROUTINE NormalRoutine, 167 | IN KPROCESSOR_MODE ApcMode, 168 | IN PVOID NormalContext 169 | ); 170 | 171 | NTKERNELAPI 172 | BOOLEAN 173 | NTAPI 174 | KeInsertQueueApc( 175 | PKAPC Apc, 176 | PVOID SystemArgument1, 177 | PVOID SystemArgument2, 178 | KPRIORITY Increment 179 | ); 180 | 181 | NTSYSAPI 182 | PIMAGE_NT_HEADERS 183 | NTAPI 184 | RtlImageNtHeader(PVOID Base); 185 | 186 | NTSYSAPI 187 | PVOID 188 | NTAPI 189 | RtlImageDirectoryEntryToData( 190 | PVOID ImageBase, 191 | BOOLEAN MappedAsImage, 192 | USHORT DirectoryEntry, 193 | PULONG Size 194 | ); 195 | 196 | 197 | typedef BOOLEAN(*EX_ENUMERATE_HANDLE_ROUTINE)( 198 | #if !defined(_WIN7_) 199 | IN PHANDLE_TABLE HandleTable, 200 | #endif 201 | IN PHANDLE_TABLE_ENTRY HandleTableEntry, 202 | IN HANDLE Handle, 203 | IN PVOID EnumParameter 204 | ); 205 | 206 | NTKERNELAPI 207 | BOOLEAN 208 | ExEnumHandleTable( 209 | IN PHANDLE_TABLE HandleTable, 210 | IN EX_ENUMERATE_HANDLE_ROUTINE EnumHandleProcedure, 211 | IN PVOID EnumParameter, 212 | OUT PHANDLE Handle 213 | ); 214 | 215 | NTKERNELAPI 216 | VOID 217 | FASTCALL 218 | ExfUnblockPushLock( 219 | IN OUT PEX_PUSH_LOCK PushLock, 220 | IN OUT PVOID WaitBlock 221 | ); 222 | 223 | NTKERNELAPI 224 | PCHAR 225 | PsGetProcessImageFileName( 226 | __in PEPROCESS Process 227 | ); 228 | 229 | NTSYSAPI 230 | NTSTATUS 231 | NTAPI 232 | NtTraceControl( 233 | _In_ ULONG FunctionCode, 234 | _In_reads_bytes_opt_(InBufferLen) PVOID InBuffer, 235 | _In_ ULONG InBufferLen, 236 | _Out_writes_bytes_opt_(OutBufferLen) PVOID OutBuffer, 237 | _In_ ULONG OutBufferLen, 238 | _Out_ PULONG ReturnLength); 239 | 240 | 241 | NTKERNELAPI 242 | PVOID 243 | NTAPI 244 | RtlFindExportedRoutineByName( 245 | PVOID ImageBase, 246 | PCCH RoutineNam); 247 | 248 | 249 | NTKERNELAPI 250 | PVOID 251 | NTAPI 252 | PsGetCurrentThreadWin32Thread(); 253 | 254 | 255 | NTSYSAPI 256 | NTSTATUS 257 | NTAPI 258 | ZwGetNextThread( 259 | __in HANDLE ProcessHandle, 260 | __in HANDLE ThreadHandle, 261 | __in ACCESS_MASK DesiredAccess, 262 | __in ULONG HandleAttributes, 263 | __in ULONG Flags, 264 | __out PHANDLE NewThreadHandle); 265 | 266 | NTKERNELAPI 267 | PVOID 268 | NTAPI 269 | PsGetThreadWin32Thread( 270 | _In_ PETHREAD Thread 271 | ); 272 | 273 | NTKERNELAPI 274 | VOID 275 | PsSetThreadWin32Thread( 276 | IN OUT PETHREAD Thread, 277 | IN PVOID Win32Thread, 278 | IN PVOID PrevWin32Thread 279 | ); 280 | 281 | NTKERNELAPI 282 | VOID 283 | MmUnlockPagedPool( 284 | IN PVOID Address, 285 | IN SIZE_T Size 286 | ); 287 | 288 | NTKERNELAPI 289 | PVOID 290 | PsGetProcessSectionBaseAddress( 291 | __in PEPROCESS Process 292 | ); 293 | 294 | extern POBJECT_TYPE* IoDriverObjectType; 295 | 296 | NTKERNELAPI 297 | NTSTATUS 298 | ObReferenceObjectByName( 299 | IN PUNICODE_STRING ObjectName, 300 | IN ULONG Attributes, 301 | IN PACCESS_STATE PassedAccessState OPTIONAL, 302 | IN ACCESS_MASK DesiredAccess OPTIONAL, 303 | IN POBJECT_TYPE ObjectType, 304 | IN KPROCESSOR_MODE AccessMode, 305 | IN OUT PVOID ParseContext OPTIONAL, 306 | OUT PVOID* Object 307 | ); 308 | 309 | EXTERN_C_END -------------------------------------------------------------------------------- /KernelHack/Includes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | //#include 7 | #include 8 | #include 9 | #include 10 | 11 | -------------------------------------------------------------------------------- /KernelHack/KernelHack.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; KernelHack.inf 3 | ; 4 | 5 | [Version] 6 | Signature="$WINDOWS NT$" 7 | Class=System 8 | ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} 9 | Provider=%ManufacturerName% 10 | DriverVer= 11 | CatalogFile=KernelHack.cat 12 | PnpLockDown=1 13 | 14 | [DestinationDirs] 15 | DefaultDestDir = 12 16 | 17 | 18 | [SourceDisksNames] 19 | 1 = %DiskName%,,,"" 20 | 21 | [SourceDisksFiles] 22 | 23 | 24 | [Manufacturer] 25 | %ManufacturerName%=Standard,NT$ARCH$ 26 | 27 | [Standard.NT$ARCH$] 28 | 29 | 30 | [Strings] 31 | ManufacturerName="" ;TODO: Replace with your manufacturer name 32 | ClassName="" 33 | DiskName="KernelHack Source Disk" 34 | -------------------------------------------------------------------------------- /KernelHack/KernelHack.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {1DB89EDB-7AC2-4D33-85A1-03BFADF436A7} 23 | {dd38f7fc-d7bd-488b-9242-7d8754cde80d} 24 | v4.5 25 | 12.0 26 | Debug 27 | Win32 28 | KernelHack 29 | $(LatestTargetPlatformVersion) 30 | 31 | 32 | 33 | Windows10 34 | true 35 | WindowsKernelModeDriver10.0 36 | Driver 37 | WDM 38 | false 39 | 1 40 | 41 | 42 | Windows10 43 | false 44 | WindowsKernelModeDriver10.0 45 | Driver 46 | WDM 47 | false 48 | 1 49 | 50 | 51 | Windows10 52 | true 53 | WindowsKernelModeDriver10.0 54 | Driver 55 | WDM 56 | false 57 | 1 58 | 59 | 60 | Windows10 61 | false 62 | WindowsKernelModeDriver10.0 63 | Driver 64 | WDM 65 | false 66 | 1 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | DbgengKernelDebugger 78 | false 79 | 80 | 81 | DbgengKernelDebugger 82 | false 83 | 84 | 85 | DbgengKernelDebugger 86 | 87 | 88 | DbgengKernelDebugger 89 | 90 | 91 | 92 | false 93 | false 94 | Default 95 | 96 | 97 | DriverEntry 98 | 99 | 100 | 101 | 102 | false 103 | false 104 | Default 105 | Custom 106 | 107 | 108 | DriverEntry 109 | 110 | 111 | 112 | 113 | false 114 | false 115 | Default 116 | 117 | 118 | DriverEntry 119 | 120 | 121 | 122 | 123 | false 124 | false 125 | Default 126 | Custom 127 | 128 | 129 | DriverEntry 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /KernelHack/KernelHack.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {73fc1256-a689-41c2-bf80-cd0443ed364b} 10 | 11 | 12 | {456b3b89-8db1-4ed2-8688-bf2e5c49ffd3} 13 | 14 | 15 | {568dc788-6e61-43e7-b0ae-2e7088a9772f} 16 | 17 | 18 | {1812d213-ca68-439c-9c08-ae4bf88d1428} 19 | 20 | 21 | {8465f0bb-6844-43d8-967f-dcc1771b0cbb} 22 | 23 | 24 | {4a421927-4ce1-4f06-8adb-a4a9f1947e8e} 25 | 26 | 27 | {54df836e-03c1-4425-97b6-d60c149519d7} 28 | 29 | 30 | {652824d0-60f1-49a6-8edf-b0384ced0fd2} 31 | 32 | 33 | {df5b61d8-8c9b-4d36-ba95-c2001d331f3b} 34 | 35 | 36 | {82646748-16e7-4387-85d1-b7ad7b4339e9} 37 | 38 | 39 | 40 | 41 | Source Files 42 | 43 | 44 | Memory 45 | 46 | 47 | Comm 48 | 49 | 50 | Utils 51 | 52 | 53 | Process 54 | 55 | 56 | Mapper 57 | 58 | 59 | Offsets 60 | 61 | 62 | Callbacks 63 | 64 | 65 | hde 66 | 67 | 68 | hde 69 | 70 | 71 | KbdMouse 72 | 73 | 74 | 75 | 76 | Memory 77 | 78 | 79 | Comm 80 | 81 | 82 | Utils 83 | 84 | 85 | General 86 | 87 | 88 | General 89 | 90 | 91 | General 92 | 93 | 94 | General 95 | 96 | 97 | Process 98 | 99 | 100 | Mapper 101 | 102 | 103 | Offsets 104 | 105 | 106 | Callbacks 107 | 108 | 109 | hde 110 | 111 | 112 | hde 113 | 114 | 115 | hde 116 | 117 | 118 | hde 119 | 120 | 121 | hde 122 | 123 | 124 | hde 125 | 126 | 127 | General 128 | 129 | 130 | General 131 | 132 | 133 | KbdMouse 134 | 135 | 136 | -------------------------------------------------------------------------------- /KernelHack/KernelHack.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Off 5 | win10x64 6 | 7 | 8 | Off 9 | win10x64 10 | 11 | 12 | Off 13 | win10x64 14 | DbgengKernelDebugger 15 | 16 | 17 | Off 18 | win10x64 19 | 20 | -------------------------------------------------------------------------------- /KernelHack/Mapper.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/Mapper.cpp -------------------------------------------------------------------------------- /KernelHack/Mapper.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #include "Includes.h" 13 | 14 | namespace Mapper 15 | { 16 | BOOLEAN ResolveImports(uintptr_t imageBase); 17 | 18 | void ResolveRelocations(uintptr_t imageBase, uintptr_t newBase, uintptr_t delta); 19 | 20 | NTSTATUS MapDriver(PVOID data, SIZE_T size); 21 | 22 | NTSTATUS MapDriverFromFile(PUNICODE_STRING FilePath); 23 | } -------------------------------------------------------------------------------- /KernelHack/Memory.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/Memory.cpp -------------------------------------------------------------------------------- /KernelHack/Memory.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include "Includes.h" 14 | #include "NativeStructs.h" 15 | 16 | namespace Memory 17 | { 18 | VOID InitializePageBase(); 19 | 20 | PMMPTE GetPxeAddress(ULONG64 va); 21 | 22 | PMMPTE GetPpeAddress(ULONG64 va); 23 | 24 | PMMPTE GetPdeAddress(ULONG64 va); 25 | 26 | PMMPTE GetPteAddress(ULONG64 va); 27 | 28 | NTSTATUS ReadPhysicalMemory( 29 | PHYSICAL_ADDRESS PhysicalAddress, 30 | PVOID lpBuffer, 31 | SIZE_T Size); 32 | 33 | NTSTATUS WritePhysicalMemory( 34 | PHYSICAL_ADDRESS PhysicalAddress, 35 | PVOID lpBuffer, 36 | SIZE_T Size); 37 | 38 | ULONG64 GetProcessDirbase( 39 | PEPROCESS Process); 40 | 41 | PHYSICAL_ADDRESS TranslateLinearAddress( 42 | ULONG64 Dirbase, 43 | ULONG64 VirtualAddress); 44 | 45 | NTSTATUS ReadVirtualMemory( 46 | ULONG64 Dirbase, 47 | PVOID VirtualAddress, 48 | PVOID buffer, 49 | SIZE_T size); 50 | 51 | NTSTATUS WriteVirtualMemory( 52 | ULONG64 Dirbase, 53 | PVOID VirtualAddress, 54 | PVOID buffer, 55 | SIZE_T size); 56 | 57 | NTSTATUS ReadProcessMemory( 58 | PEPROCESS Process, 59 | PVOID VirtualAddress, 60 | PVOID lpBuffer, 61 | SIZE_T Size); 62 | 63 | NTSTATUS WriteProcessMemory( 64 | PEPROCESS Process, 65 | PVOID VirtualAddress, 66 | PVOID lpBuffer, 67 | SIZE_T Size); 68 | 69 | NTSTATUS MmAllocateCopyRemove( 70 | PVOID SrcPtr, 71 | ULONG DataSize, 72 | PPHYSICAL_ADDRESS PhysPtr); 73 | 74 | PVOID AllocateMemoryInSystemSpace( 75 | SIZE_T Size); 76 | 77 | PVOID MmAllocateIndependentPages( 78 | SIZE_T NumberOfBytes, 79 | ULONG Node); 80 | 81 | BOOLEAN MmSetPageProtection( 82 | PVOID VirtualAddress, 83 | SIZE_T NumberOfBytes, 84 | ULONG NewProtect); 85 | 86 | PHYSICAL_ADDRESS SafeMmGetPhysicalAddress( 87 | PVOID VirtualAddress); 88 | 89 | BOOLEAN ClearPFN( 90 | PMDL mdl); 91 | 92 | NTSTATUS CleanPiDDBCache( 93 | PDRIVER_OBJECT DriverObject); 94 | 95 | NTSTATUS CleanBigPoolAllocation( 96 | PVOID AllocationAddress); 97 | 98 | BOOLEAN WriteToReadOnly( 99 | PVOID destination, 100 | PVOID buffer, 101 | ULONG size); 102 | 103 | BOOLEAN SetExecutePage( 104 | ULONG64 VirtualAddress, 105 | SIZE_T size); 106 | 107 | }; 108 | -------------------------------------------------------------------------------- /KernelHack/NativeEnums.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | typedef enum _MEMORY_INFORMATION_CLASS_EX 4 | { 5 | MemoryBasicInformationEx = 0, 6 | MemoryWorkingSetInformation = 1, 7 | MemoryMappedFilenameInformation = 2, 8 | MemoryRegionInformation = 3, 9 | MemoryWorkingSetExInformation = 4, 10 | } MEMORY_INFORMATION_CLASS_EX; 11 | 12 | typedef enum _PS_PROTECTED_SIGNER 13 | { 14 | PsProtectedSignerNone = 0, 15 | PsProtectedSignerAuthenticode = 1, 16 | PsProtectedSignerCodeGen = 2, 17 | PsProtectedSignerAntimalware = 3, 18 | PsProtectedSignerLsa = 4, 19 | PsProtectedSignerWindows = 5, 20 | PsProtectedSignerWinTcb = 6, 21 | PsProtectedSignerMax = 7 22 | } PS_PROTECTED_SIGNER; 23 | 24 | typedef enum _PS_PROTECTED_TYPE 25 | { 26 | PsProtectedTypeNone = 0, 27 | PsProtectedTypeProtectedLight = 1, 28 | PsProtectedTypeProtected = 2, 29 | PsProtectedTypeMax = 3 30 | } PS_PROTECTED_TYPE; 31 | 32 | typedef enum _SYSTEM_INFORMATION_CLASS 33 | { 34 | SystemBasicInformation = 0x0, 35 | SystemProcessorInformation = 0x1, 36 | SystemPerformanceInformation = 0x2, 37 | SystemTimeOfDayInformation = 0x3, 38 | SystemPathInformation = 0x4, 39 | SystemProcessInformation = 0x5, 40 | SystemCallCountInformation = 0x6, 41 | SystemDeviceInformation = 0x7, 42 | SystemProcessorPerformanceInformation = 0x8, 43 | SystemFlagsInformation = 0x9, 44 | SystemCallTimeInformation = 0xa, 45 | SystemModuleInformation = 0xb, 46 | SystemLocksInformation = 0xc, 47 | SystemStackTraceInformation = 0xd, 48 | SystemPagedPoolInformation = 0xe, 49 | SystemNonPagedPoolInformation = 0xf, 50 | SystemHandleInformation = 0x10, 51 | SystemObjectInformation = 0x11, 52 | SystemPageFileInformation = 0x12, 53 | SystemVdmInstemulInformation = 0x13, 54 | SystemVdmBopInformation = 0x14, 55 | SystemFileCacheInformation = 0x15, 56 | SystemPoolTagInformation = 0x16, 57 | SystemInterruptInformation = 0x17, 58 | SystemDpcBehaviorInformation = 0x18, 59 | SystemFullMemoryInformation = 0x19, 60 | SystemLoadGdiDriverInformation = 0x1a, 61 | SystemUnloadGdiDriverInformation = 0x1b, 62 | SystemTimeAdjustmentInformation = 0x1c, 63 | SystemSummaryMemoryInformation = 0x1d, 64 | SystemMirrorMemoryInformation = 0x1e, 65 | SystemPerformanceTraceInformation = 0x1f, 66 | SystemObsolete0 = 0x20, 67 | SystemExceptionInformation = 0x21, 68 | SystemCrashDumpStateInformation = 0x22, 69 | SystemKernelDebuggerInformation = 0x23, 70 | SystemContextSwitchInformation = 0x24, 71 | SystemRegistryQuotaInformation = 0x25, 72 | SystemExtendServiceTableInformation = 0x26, 73 | SystemPrioritySeperation = 0x27, 74 | SystemVerifierAddDriverInformation = 0x28, 75 | SystemVerifierRemoveDriverInformation = 0x29, 76 | SystemProcessorIdleInformation = 0x2a, 77 | SystemLegacyDriverInformation = 0x2b, 78 | SystemCurrentTimeZoneInformation = 0x2c, 79 | SystemLookasideInformation = 0x2d, 80 | SystemTimeSlipNotification = 0x2e, 81 | SystemSessionCreate = 0x2f, 82 | SystemSessionDetach = 0x30, 83 | SystemSessionInformation = 0x31, 84 | SystemRangeStartInformation = 0x32, 85 | SystemVerifierInformation = 0x33, 86 | SystemVerifierThunkExtend = 0x34, 87 | SystemSessionProcessInformation = 0x35, 88 | SystemLoadGdiDriverInSystemSpace = 0x36, 89 | SystemNumaProcessorMap = 0x37, 90 | SystemPrefetcherInformation = 0x38, 91 | SystemExtendedProcessInformation = 0x39, 92 | SystemRecommendedSharedDataAlignment = 0x3a, 93 | SystemComPlusPackage = 0x3b, 94 | SystemNumaAvailableMemory = 0x3c, 95 | SystemProcessorPowerInformation = 0x3d, 96 | SystemEmulationBasicInformation = 0x3e, 97 | SystemEmulationProcessorInformation = 0x3f, 98 | SystemExtendedHandleInformation = 0x40, 99 | SystemLostDelayedWriteInformation = 0x41, 100 | SystemBigPoolInformation = 0x42, 101 | SystemSessionPoolTagInformation = 0x43, 102 | SystemSessionMappedViewInformation = 0x44, 103 | SystemHotpatchInformation = 0x45, 104 | SystemObjectSecurityMode = 0x46, 105 | SystemWatchdogTimerHandler = 0x47, 106 | SystemWatchdogTimerInformation = 0x48, 107 | SystemLogicalProcessorInformation = 0x49, 108 | SystemWow64SharedInformationObsolete = 0x4a, 109 | SystemRegisterFirmwareTableInformationHandler = 0x4b, 110 | SystemFirmwareTableInformation = 0x4c, 111 | SystemModuleInformationEx = 0x4d, 112 | SystemVerifierTriageInformation = 0x4e, 113 | SystemSuperfetchInformation = 0x4f, 114 | SystemMemoryListInformation = 0x50, 115 | SystemFileCacheInformationEx = 0x51, 116 | SystemThreadPriorityClientIdInformation = 0x52, 117 | SystemProcessorIdleCycleTimeInformation = 0x53, 118 | SystemVerifierCancellationInformation = 0x54, 119 | SystemProcessorPowerInformationEx = 0x55, 120 | SystemRefTraceInformation = 0x56, 121 | SystemSpecialPoolInformation = 0x57, 122 | SystemProcessIdInformation = 0x58, 123 | SystemErrorPortInformation = 0x59, 124 | SystemBootEnvironmentInformation = 0x5a, 125 | SystemHypervisorInformation = 0x5b, 126 | SystemVerifierInformationEx = 0x5c, 127 | SystemTimeZoneInformation = 0x5d, 128 | SystemImageFileExecutionOptionsInformation = 0x5e, 129 | SystemCoverageInformation = 0x5f, 130 | SystemPrefetchPatchInformation = 0x60, 131 | SystemVerifierFaultsInformation = 0x61, 132 | SystemSystemPartitionInformation = 0x62, 133 | SystemSystemDiskInformation = 0x63, 134 | SystemProcessorPerformanceDistribution = 0x64, 135 | SystemNumaProximityNodeInformation = 0x65, 136 | SystemDynamicTimeZoneInformation = 0x66, 137 | SystemCodeIntegrityInformation = 0x67, 138 | SystemProcessorMicrocodeUpdateInformation = 0x68, 139 | SystemProcessorBrandString = 0x69, 140 | SystemVirtualAddressInformation = 0x6a, 141 | SystemLogicalProcessorAndGroupInformation = 0x6b, 142 | SystemProcessorCycleTimeInformation = 0x6c, 143 | SystemStoreInformation = 0x6d, 144 | SystemRegistryAppendString = 0x6e, 145 | SystemAitSamplingValue = 0x6f, 146 | SystemVhdBootInformation = 0x70, 147 | SystemCpuQuotaInformation = 0x71, 148 | SystemNativeBasicInformation = 0x72, 149 | SystemErrorPortTimeouts = 0x73, 150 | SystemLowPriorityIoInformation = 0x74, 151 | SystemBootEntropyInformation = 0x75, 152 | SystemVerifierCountersInformation = 0x76, 153 | SystemPagedPoolInformationEx = 0x77, 154 | SystemSystemPtesInformationEx = 0x78, 155 | SystemNodeDistanceInformation = 0x79, 156 | SystemAcpiAuditInformation = 0x7a, 157 | SystemBasicPerformanceInformation = 0x7b, 158 | SystemQueryPerformanceCounterInformation = 0x7c, 159 | SystemSessionBigPoolInformation = 0x7d, 160 | SystemBootGraphicsInformation = 0x7e, 161 | SystemScrubPhysicalMemoryInformation = 0x7f, 162 | SystemBadPageInformation = 0x80, 163 | SystemProcessorProfileControlArea = 0x81, 164 | SystemCombinePhysicalMemoryInformation = 0x82, 165 | SystemEntropyInterruptTimingInformation = 0x83, 166 | SystemConsoleInformation = 0x84, 167 | SystemPlatformBinaryInformation = 0x85, 168 | SystemThrottleNotificationInformation = 0x86, 169 | SystemHypervisorProcessorCountInformation = 0x87, 170 | SystemDeviceDataInformation = 0x88, 171 | SystemDeviceDataEnumerationInformation = 0x89, 172 | SystemMemoryTopologyInformation = 0x8a, 173 | SystemMemoryChannelInformation = 0x8b, 174 | SystemBootLogoInformation = 0x8c, 175 | SystemProcessorPerformanceInformationEx = 0x8d, 176 | SystemSpare0 = 0x8e, 177 | SystemSecureBootPolicyInformation = 0x8f, 178 | SystemPageFileInformationEx = 0x90, 179 | SystemSecureBootInformation = 0x91, 180 | SystemEntropyInterruptTimingRawInformation = 0x92, 181 | SystemPortableWorkspaceEfiLauncherInformation = 0x93, 182 | SystemFullProcessInformation = 0x94, 183 | SystemKernelDebuggerInformationEx = 0x95, 184 | SystemBootMetadataInformation = 0x96, 185 | SystemSoftRebootInformation = 0x97, 186 | SystemElamCertificateInformation = 0x98, 187 | SystemOfflineDumpConfigInformation = 0x99, 188 | SystemProcessorFeaturesInformation = 0x9a, 189 | SystemRegistryReconciliationInformation = 0x9b, 190 | MaxSystemInfoClass = 0x9c, 191 | } SYSTEM_INFORMATION_CLASS; 192 | 193 | typedef enum _PROCESS_INFORMATION_CLASS { 194 | ProcessMemoryPriority, 195 | ProcessMemoryExhaustionInfo, 196 | ProcessAppMemoryInfo, 197 | ProcessInPrivateInfo, 198 | ProcessPowerThrottling, 199 | ProcessReservedValue1, // Used to be for ProcessActivityThrottlePolicyInfo 200 | ProcessTelemetryCoverageInfo, 201 | ProcessProtectionLevelInfo, 202 | ProcessLeapSecondInfo, 203 | ProcessInformationClassMax 204 | } PROCESS_INFORMATION_CLASS; 205 | 206 | typedef enum _KAPC_ENVIRONMENT 207 | { 208 | OriginalApcEnvironment, 209 | AttachedApcEnvironment, 210 | CurrentApcEnvironment, 211 | InsertApcEnvironment 212 | } KAPC_ENVIRONMENT, *PKAPC_ENVIRONMENT; 213 | 214 | typedef enum _MI_VAD_TYPE 215 | { 216 | VadNone, 217 | VadDevicePhysicalMemory, 218 | VadImageMap, 219 | VadAwe, 220 | VadWriteWatch, 221 | VadLargePages, 222 | VadRotatePhysical, 223 | VadLargePageSection 224 | } MI_VAD_TYPE, *PMI_VAD_TYPE; 225 | 226 | typedef enum _MMSYSTEM_PTE_POOL_TYPE 227 | { 228 | SystemPteSpace, 229 | NonPagedPoolExpansion, 230 | MaximumPtePoolTypes 231 | } MMSYSTEM_PTE_POOL_TYPE; -------------------------------------------------------------------------------- /KernelHack/NativeStructs10.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 4 | // Native structures W10 technical preview x64, build 9841 5 | // 6 | #pragma warning(disable : 4214 4201) 7 | #pragma pack(push, 1) 8 | 9 | typedef struct _MM_AVL_NODE // Size=24 10 | { 11 | struct _MM_AVL_NODE * LeftChild; // Size=8 Offset=0 12 | struct _MM_AVL_NODE * RightChild; // Size=8 Offset=8 13 | 14 | union ___unnamed1666 // Size=8 15 | { 16 | struct 17 | { 18 | __int64 Balance : 2; // Size=8 Offset=0 BitOffset=0 BitCount=2 19 | }; 20 | struct _MM_AVL_NODE * Parent; // Size=8 Offset=0 21 | } u1; 22 | } MM_AVL_NODE, *PMM_AVL_NODE, *PMMADDRESS_NODE; 23 | 24 | typedef struct _RTL_AVL_TREE // Size=8 25 | { 26 | PMM_AVL_NODE BalancedRoot; 27 | void * NodeHint; 28 | unsigned __int64 NumberGenericTableElements; 29 | } RTL_AVL_TREE, *PRTL_AVL_TREE, MM_AVL_TABLE, *PMM_AVL_TABLE; 30 | 31 | union _EX_PUSH_LOCK // Size=8 32 | { 33 | struct 34 | { 35 | unsigned __int64 Locked : 1; // Size=8 Offset=0 BitOffset=0 BitCount=1 36 | unsigned __int64 Waiting : 1; // Size=8 Offset=0 BitOffset=1 BitCount=1 37 | unsigned __int64 Waking : 1; // Size=8 Offset=0 BitOffset=2 BitCount=1 38 | unsigned __int64 MultipleShared : 1; // Size=8 Offset=0 BitOffset=3 BitCount=1 39 | unsigned __int64 Shared : 60; // Size=8 Offset=0 BitOffset=4 BitCount=60 40 | }; 41 | unsigned __int64 Value; // Size=8 Offset=0 42 | void * Ptr; // Size=8 Offset=0 43 | }; 44 | 45 | struct _MMVAD_FLAGS // Size=4 46 | { 47 | unsigned long VadType: 3; // Size=4 Offset=0 BitOffset=0 BitCount=3 48 | unsigned long Protection: 5; // Size=4 Offset=0 BitOffset=3 BitCount=5 49 | unsigned long PreferredNode: 6; // Size=4 Offset=0 BitOffset=8 BitCount=6 50 | unsigned long NoChange: 1; // Size=4 Offset=0 BitOffset=14 BitCount=1 51 | unsigned long PrivateMemory: 1; // Size=4 Offset=0 BitOffset=15 BitCount=1 52 | unsigned long Teb: 1; // Size=4 Offset=0 BitOffset=16 BitCount=1 53 | unsigned long PrivateFixup: 1; // Size=4 Offset=0 BitOffset=17 BitCount=1 54 | unsigned long ManySubsections: 1; // Size=4 Offset=0 BitOffset=18 BitCount=1 55 | unsigned long Spare: 12; // Size=4 Offset=0 BitOffset=19 BitCount=12 56 | unsigned long DeleteInProgress: 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 57 | }; 58 | struct _MMVAD_FLAGS1 // Size=4 59 | { 60 | unsigned long CommitCharge : 31; // Size=4 Offset=0 BitOffset=0 BitCount=31 61 | unsigned long MemCommit : 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 62 | }; 63 | 64 | struct _MMVAD_FLAGS2 // Size=4 65 | { 66 | unsigned long FileOffset : 24; // Size=4 Offset=0 BitOffset=0 BitCount=24 67 | unsigned long Large : 1; // Size=4 Offset=0 BitOffset=24 BitCount=1 68 | unsigned long TrimBehind : 1; // Size=4 Offset=0 BitOffset=25 BitCount=1 69 | unsigned long Inherit : 1; // Size=4 Offset=0 BitOffset=26 BitCount=1 70 | unsigned long CopyOnWrite : 1; // Size=4 Offset=0 BitOffset=27 BitCount=1 71 | unsigned long NoValidationNeeded : 1; // Size=4 Offset=0 BitOffset=28 BitCount=1 72 | unsigned long Spare : 3; // Size=4 Offset=0 BitOffset=29 BitCount=3 73 | }; 74 | 75 | struct _MI_VAD_SEQUENTIAL_INFO // Size=8 76 | { 77 | unsigned __int64 Length : 12; // Size=8 Offset=0 BitOffset=0 BitCount=12 78 | unsigned __int64 Vpn : 52; // Size=8 Offset=0 BitOffset=12 BitCount=52 79 | }; 80 | 81 | union ___unnamed1951 // Size=4 82 | { 83 | unsigned long LongFlags; // Size=4 Offset=0 84 | struct _MMVAD_FLAGS VadFlags; // Size=4 Offset=0 85 | }; 86 | 87 | union ___unnamed1952 // Size=4 88 | { 89 | unsigned long LongFlags1; // Size=4 Offset=0 90 | struct _MMVAD_FLAGS1 VadFlags1; // Size=4 Offset=0 91 | }; 92 | 93 | union ___unnamed2047 // Size=4 94 | { 95 | unsigned long LongFlags2; // Size=4 Offset=0 96 | struct _MMVAD_FLAGS2 VadFlags2; // Size=4 Offset=0 97 | }; 98 | 99 | union ___unnamed2048 // Size=8 100 | { 101 | struct _MI_VAD_SEQUENTIAL_INFO SequentialVa; // Size=8 Offset=0 102 | struct _MMEXTEND_INFO * ExtendedInfo; // Size=8 Offset=0 103 | }; 104 | 105 | typedef struct _MMVAD_SHORT // Size=64 106 | { 107 | union 108 | { 109 | struct _RTL_BALANCED_NODE VadNode; // Size=24 Offset=0 110 | struct _MMVAD_SHORT * NextVad; // Size=8 Offset=0 111 | }; 112 | unsigned long StartingVpn; // Size=4 Offset=24 113 | unsigned long EndingVpn; // Size=4 Offset=28 114 | unsigned char StartingVpnHigh; // Size=1 Offset=32 115 | unsigned char EndingVpnHigh; // Size=1 Offset=33 116 | unsigned char CommitChargeHigh; // Size=1 Offset=34 117 | unsigned char SpareNT64VadUChar; // Size=1 Offset=35 118 | long ReferenceCount; // Size=4 Offset=36 119 | union _EX_PUSH_LOCK PushLock; // Size=8 Offset=40 120 | union ___unnamed1951 u; // Size=4 Offset=48 121 | union ___unnamed1952 u1; // Size=4 Offset=52 122 | struct _MI_VAD_EVENT_BLOCK * EventList; // Size=8 Offset=56 123 | } MMVAD_SHORT, *PMMVAD_SHORT; 124 | 125 | 126 | typedef struct _MMVAD // Size=128 127 | { 128 | struct _MMVAD_SHORT Core; // Size=64 Offset=0 129 | union ___unnamed2047 u2; // Size=4 Offset=64 130 | unsigned long pad0; // Size=4 Offset=68 131 | struct _SUBSECTION * Subsection; // Size=8 Offset=72 132 | struct _MMPTE * FirstPrototypePte; // Size=8 Offset=80 133 | struct _MMPTE * LastContiguousPte; // Size=8 Offset=88 134 | struct _LIST_ENTRY ViewLinks; // Size=16 Offset=96 135 | struct _EPROCESS * VadsProcess; // Size=8 Offset=112 136 | union ___unnamed2048 u4; // Size=8 Offset=120 137 | struct _FILE_OBJECT * FileObject; // Size=8 Offset=128 138 | } MMVAD, *PMMVAD; 139 | #pragma pack(pop) 140 | 141 | typedef struct _HANDLE_TABLE 142 | { 143 | ULONG NextHandleNeedingPool; 144 | long ExtraInfoPages; 145 | LONG_PTR TableCode; 146 | PEPROCESS QuotaProcess; 147 | LIST_ENTRY HandleTableList; 148 | ULONG UniqueProcessId; 149 | ULONG Flags; 150 | EX_PUSH_LOCK HandleContentionEvent; 151 | EX_PUSH_LOCK HandleTableLock; 152 | // More fields here... 153 | } HANDLE_TABLE, *PHANDLE_TABLE; 154 | 155 | typedef struct _API_SET_VALUE_ENTRY_10 156 | { 157 | ULONG Flags; 158 | ULONG NameOffset; 159 | ULONG NameLength; 160 | ULONG ValueOffset; 161 | ULONG ValueLength; 162 | } API_SET_VALUE_ENTRY_10, *PAPI_SET_VALUE_ENTRY_10; 163 | 164 | typedef struct _API_SET_VALUE_ARRAY_10 165 | { 166 | ULONG Flags; 167 | ULONG NameOffset; 168 | ULONG Unk; 169 | ULONG NameLength; 170 | ULONG DataOffset; 171 | ULONG Count; 172 | } API_SET_VALUE_ARRAY_10, *PAPI_SET_VALUE_ARRAY_10; 173 | 174 | typedef struct _API_SET_NAMESPACE_ENTRY_10 175 | { 176 | ULONG Limit; 177 | ULONG Size; 178 | } API_SET_NAMESPACE_ENTRY_10, *PAPI_SET_NAMESPACE_ENTRY_10; 179 | 180 | typedef struct _API_SET_NAMESPACE_ARRAY_10 181 | { 182 | ULONG Version; 183 | ULONG Size; 184 | ULONG Flags; 185 | ULONG Count; 186 | ULONG Start; 187 | ULONG End; 188 | ULONG Unk[2]; 189 | } API_SET_NAMESPACE_ARRAY_10, *PAPI_SET_NAMESPACE_ARRAY_10; 190 | 191 | #pragma warning(default : 4214 4201) 192 | 193 | #define GET_VAD_ROOT(Table) Table->BalancedRoot -------------------------------------------------------------------------------- /KernelHack/NativeStructs7.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 4 | // Native structures W7 x64 SP1 5 | // 6 | #pragma warning(disable : 4214 4201) 7 | 8 | struct _MMVAD_FLAGS // Size=8 9 | { 10 | unsigned __int64 CommitCharge: 51; // Size=8 Offset=0 BitOffset=0 BitCount=51 11 | unsigned __int64 NoChange: 1; // Size=8 Offset=0 BitOffset=51 BitCount=1 12 | unsigned __int64 VadType: 3; // Size=8 Offset=0 BitOffset=52 BitCount=3 13 | unsigned __int64 MemCommit: 1; // Size=8 Offset=0 BitOffset=55 BitCount=1 14 | unsigned __int64 Protection: 5; // Size=8 Offset=0 BitOffset=56 BitCount=5 15 | unsigned __int64 Spare: 2; // Size=8 Offset=0 BitOffset=61 BitCount=2 16 | unsigned __int64 PrivateMemory: 1; // Size=8 Offset=0 BitOffset=63 BitCount=1 17 | }; 18 | 19 | struct _MMVAD_FLAGS3 // Size=8 20 | { 21 | unsigned __int64 PreferredNode: 6; // Size=8 Offset=0 BitOffset=0 BitCount=6 22 | unsigned __int64 Teb: 1; // Size=8 Offset=0 BitOffset=6 BitCount=1 23 | unsigned __int64 Spare: 1; // Size=8 Offset=0 BitOffset=7 BitCount=1 24 | unsigned __int64 SequentialAccess: 1; // Size=8 Offset=0 BitOffset=8 BitCount=1 25 | unsigned __int64 LastSequentialTrim: 15; // Size=8 Offset=0 BitOffset=9 BitCount=15 26 | unsigned __int64 Spare2: 8; // Size=8 Offset=0 BitOffset=24 BitCount=8 27 | unsigned __int64 LargePageCreating: 1; // Size=8 Offset=0 BitOffset=32 BitCount=1 28 | unsigned __int64 Spare3: 31; // Size=8 Offset=0 BitOffset=33 BitCount=31 29 | }; 30 | 31 | struct _MMVAD_FLAGS2 // Size=4 32 | { 33 | unsigned int FileOffset: 24; // Size=4 Offset=0 BitOffset=0 BitCount=24 34 | unsigned int SecNoChange: 1; // Size=4 Offset=0 BitOffset=24 BitCount=1 35 | unsigned int OneSecured: 1; // Size=4 Offset=0 BitOffset=25 BitCount=1 36 | unsigned int MultipleSecured: 1; // Size=4 Offset=0 BitOffset=26 BitCount=1 37 | unsigned int Spare: 1; // Size=4 Offset=0 BitOffset=27 BitCount=1 38 | unsigned int LongVad: 1; // Size=4 Offset=0 BitOffset=28 BitCount=1 39 | unsigned int ExtendableFile: 1; // Size=4 Offset=0 BitOffset=29 BitCount=1 40 | unsigned int Inherit: 1; // Size=4 Offset=0 BitOffset=30 BitCount=1 41 | unsigned int CopyOnWrite: 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 42 | }; 43 | 44 | struct _MMSECURE_FLAGS // Size=4 45 | { 46 | unsigned long ReadOnly: 1; // Size=4 Offset=0 BitOffset=0 BitCount=1 47 | unsigned long NoWrite: 1; // Size=4 Offset=0 BitOffset=1 BitCount=1 48 | unsigned long Spare: 10; // Size=4 Offset=0 BitOffset=2 BitCount=10 49 | }; 50 | 51 | union ___unnamed710 // Size=8 52 | { 53 | struct 54 | { 55 | __int64 Balance: 2; // Size=8 Offset=0 BitOffset=0 BitCount=2 56 | }; 57 | struct _MMADDRESS_NODE * Parent; // Size=8 Offset=0 58 | }; 59 | 60 | union ___unnamed712 // Size=8 61 | { 62 | unsigned __int64 LongFlags; // Size=8 Offset=0 63 | struct _MMVAD_FLAGS VadFlags; // Size=8 Offset=0 64 | }; 65 | union ___unnamed713 // Size=8 66 | { 67 | unsigned __int64 LongFlags3; // Size=8 Offset=0 68 | struct _MMVAD_FLAGS3 VadFlags3; // Size=8 Offset=0 69 | }; 70 | 71 | union ___unnamed715 // Size=4 72 | { 73 | unsigned long LongFlags2; // Size=4 Offset=0 74 | struct _MMVAD_FLAGS2 VadFlags2; // Size=4 Offset=0 75 | }; 76 | 77 | union ___unnamed1322 // Size=8 78 | { 79 | struct _MMSECURE_FLAGS Flags; // Size=4 Offset=0 80 | void * StartVa; // Size=8 Offset=0 81 | }; 82 | 83 | struct _MMADDRESS_LIST // Size=16 84 | { 85 | union ___unnamed1322 u1; // Size=8 Offset=0 86 | void * EndVa; // Size=8 Offset=8 87 | }; 88 | 89 | union ___unnamed1319 // Size=16 90 | { 91 | struct _LIST_ENTRY List; // Size=16 Offset=0 92 | struct _MMADDRESS_LIST Secured; // Size=16 Offset=0 93 | }; 94 | 95 | union ___unnamed1320 // Size=8 96 | { 97 | struct _MMBANKED_SECTION * Banked; // Size=8 Offset=0 98 | struct _MMEXTEND_INFO * ExtendedInfo; // Size=8 Offset=0 99 | }; 100 | 101 | typedef struct _MMADDRESS_NODE // Size=40 102 | { 103 | union ___unnamed710 u1; 104 | struct _MMADDRESS_NODE * LeftChild; // Size=8 Offset=8 105 | struct _MMADDRESS_NODE * RightChild; // Size=8 Offset=16 106 | unsigned __int64 StartingVpn; // Size=8 Offset=24 107 | unsigned __int64 EndingVpn; // Size=8 Offset=32 108 | 109 | } MMADDRESS_NODE, *PMMADDRESS_NODE, *PMM_AVL_NODE; 110 | 111 | typedef struct _MM_AVL_TABLE // Size=64 112 | { 113 | struct _MMADDRESS_NODE BalancedRoot; // Size=40 Offset=0 114 | struct 115 | { 116 | unsigned __int64 DepthOfTree: 5; // Size=8 Offset=40 BitOffset=0 BitCount=5 117 | unsigned __int64 Unused: 3; // Size=8 Offset=40 BitOffset=5 BitCount=3 118 | unsigned __int64 NumberGenericTableElements: 56; // Size=8 Offset=40 BitOffset=8 BitCount=56 119 | }; 120 | void * NodeHint; // Size=8 Offset=48 121 | void * NodeFreeHint; // Size=8 Offset=56 122 | 123 | } MM_AVL_TABLE, *PMM_AVL_TABLE; 124 | 125 | typedef struct _MMVAD_SHORT // Size=64 126 | { 127 | union ___unnamed710 u1; // Size=8 Offset=0 128 | struct _MMVAD * LeftChild; // Size=8 Offset=8 129 | struct _MMVAD * RightChild; // Size=8 Offset=16 130 | unsigned __int64 StartingVpn; // Size=8 Offset=24 131 | unsigned __int64 EndingVpn; // Size=8 Offset=32 132 | union ___unnamed712 u; // Size=8 Offset=40 133 | void * PushLock; // Size=8 Offset=48 134 | union ___unnamed713 u5; // Size=8 Offset=56 135 | } MMVAD_SHORT, *PMMVAD_SHORT; 136 | 137 | typedef struct _MMVAD // Size=120 138 | { 139 | MMVAD_SHORT vadShort; 140 | union ___unnamed715 u2; // Size=4 Offset=64 141 | unsigned long pad0; // Size=4 Offset=68 142 | struct _SUBSECTION * Subsection; // Size=8 Offset=72 143 | struct _MMPTE * FirstPrototypePte; // Size=8 Offset=80 144 | struct _MMPTE * LastContiguousPte; // Size=8 Offset=88 145 | struct _LIST_ENTRY ViewLinks; // Size=16 Offset=96 146 | struct _EPROCESS * VadsProcess; // Size=8 Offset=112 147 | } MMVAD, *PMMVAD; 148 | 149 | typedef struct _MMVAD_LONG // Size=144 150 | { 151 | MMVAD vad; 152 | union ___unnamed1319 u3; // Size=16 Offset=120 153 | union ___unnamed1320 u4; // Size=8 Offset=136 154 | } MMVAD_LONG, *PMMVAD_LONG; 155 | 156 | typedef struct _HANDLE_TABLE 157 | { 158 | ULONG_PTR TableCode; 159 | struct _EPROCESS *QuotaProcess; 160 | HANDLE UniqueProcessId; 161 | void* HandleLock; 162 | struct _LIST_ENTRY HandleTableList; 163 | EX_PUSH_LOCK HandleContentionEvent; 164 | struct _HANDLE_TRACE_DEBUG_INFO *DebugInfo; 165 | int ExtraInfoPages; 166 | ULONG Flags; 167 | ULONG FirstFreeHandle; 168 | struct _HANDLE_TABLE_ENTRY *LastFreeHandleEntry; 169 | ULONG HandleCount; 170 | ULONG NextHandleNeedingPool; 171 | // More fields here... 172 | } HANDLE_TABLE, *PHANDLE_TABLE; 173 | 174 | #pragma warning(default : 4214 4201) 175 | 176 | #define GET_VAD_ROOT(Table) &Table->BalancedRoot -------------------------------------------------------------------------------- /KernelHack/NativeStructs8.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 4 | // Native structures W8 x64 5 | // 6 | #pragma warning(disable : 4214 4201) 7 | 8 | struct _MMVAD_FLAGS // Size=4 9 | { 10 | unsigned long VadType: 3; // Size=4 Offset=0 BitOffset=0 BitCount=3 11 | unsigned long Protection: 5; // Size=4 Offset=0 BitOffset=3 BitCount=5 12 | unsigned long PreferredNode: 6; // Size=4 Offset=0 BitOffset=8 BitCount=6 13 | unsigned long NoChange: 1; // Size=4 Offset=0 BitOffset=14 BitCount=1 14 | unsigned long PrivateMemory: 1; // Size=4 Offset=0 BitOffset=15 BitCount=1 15 | unsigned long Teb: 1; // Size=4 Offset=0 BitOffset=16 BitCount=1 16 | unsigned long PrivateFixup: 1; // Size=4 Offset=0 BitOffset=17 BitCount=1 17 | unsigned long Spare: 13; // Size=4 Offset=0 BitOffset=18 BitCount=13 18 | unsigned long DeleteInProgress: 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 19 | }; 20 | 21 | struct _MMVAD_FLAGS1 // Size=4 22 | { 23 | unsigned long CommitCharge: 31; // Size=4 Offset=0 BitOffset=0 BitCount=31 24 | unsigned long MemCommit: 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 25 | }; 26 | 27 | struct _MMVAD_FLAGS2 // Size=4 28 | { 29 | unsigned long FileOffset: 24; // Size=4 Offset=0 BitOffset=0 BitCount=24 30 | unsigned long Large: 1; // Size=4 Offset=0 BitOffset=24 BitCount=1 31 | unsigned long TrimBehind: 1; // Size=4 Offset=0 BitOffset=25 BitCount=1 32 | unsigned long Inherit: 1; // Size=4 Offset=0 BitOffset=26 BitCount=1 33 | unsigned long CopyOnWrite: 1; // Size=4 Offset=0 BitOffset=27 BitCount=1 34 | unsigned long NoValidationNeeded: 1; // Size=4 Offset=0 BitOffset=28 BitCount=1 35 | unsigned long Spare: 3; // Size=4 Offset=0 BitOffset=29 BitCount=3 36 | }; 37 | 38 | struct _MMVAD_FLAGS3 // Size=8 39 | { 40 | unsigned __int64 PreferredNode: 6; // Size=8 Offset=0 BitOffset=0 BitCount=6 41 | unsigned __int64 Teb: 1; // Size=8 Offset=0 BitOffset=6 BitCount=1 42 | unsigned __int64 Spare: 1; // Size=8 Offset=0 BitOffset=7 BitCount=1 43 | unsigned __int64 SequentialAccess: 1; // Size=8 Offset=0 BitOffset=8 BitCount=1 44 | unsigned __int64 LastSequentialTrim: 15; // Size=8 Offset=0 BitOffset=9 BitCount=15 45 | unsigned __int64 Spare2: 8; // Size=8 Offset=0 BitOffset=24 BitCount=8 46 | unsigned __int64 LargePageCreating: 1; // Size=8 Offset=0 BitOffset=32 BitCount=1 47 | unsigned __int64 Spare3: 31; // Size=8 Offset=0 BitOffset=33 BitCount=31 48 | }; 49 | 50 | struct _MMSECURE_FLAGS // Size=4 51 | { 52 | unsigned long ReadOnly: 1; // Size=4 Offset=0 BitOffset=0 BitCount=1 53 | unsigned long NoWrite: 1; // Size=4 Offset=0 BitOffset=1 BitCount=1 54 | unsigned long Spare: 10; // Size=4 Offset=0 BitOffset=2 BitCount=10 55 | }; 56 | 57 | struct _MI_VAD_SEQUENTIAL_INFO // Size=8 58 | { 59 | unsigned __int64 Length: 12; // Size=8 Offset=0 BitOffset=0 BitCount=12 60 | unsigned __int64 Vpn: 52; // Size=8 Offset=0 BitOffset=12 BitCount=52 61 | }; 62 | 63 | union ___unnamed1666 // Size=8 64 | { 65 | struct 66 | { 67 | __int64 Balance: 2; // Size=8 Offset=0 BitOffset=0 BitCount=2 68 | }; 69 | struct _MM_AVL_NODE * Parent; // Size=8 Offset=0 70 | }; 71 | 72 | union ___unnamed1784 // Size=4 73 | { 74 | unsigned long LongFlags; // Size=4 Offset=0 75 | struct _MMVAD_FLAGS VadFlags; // Size=4 Offset=0 76 | }; 77 | union ___unnamed1785 // Size=4 78 | { 79 | unsigned long LongFlags1; // Size=4 Offset=0 80 | struct _MMVAD_FLAGS1 VadFlags1; // Size=4 Offset=0 81 | }; 82 | 83 | union ___unnamed1883 // Size=4 84 | { 85 | unsigned long LongFlags2; // Size=4 Offset=0 86 | struct _MMVAD_FLAGS2 VadFlags2; // Size=4 Offset=0 87 | }; 88 | 89 | union ___unnamed1885 // Size=8 90 | { 91 | struct _MI_VAD_SEQUENTIAL_INFO SequentialVa; // Size=8 Offset=0 92 | struct _MMEXTEND_INFO * ExtendedInfo; // Size=8 Offset=0 93 | }; 94 | 95 | typedef struct _MM_AVL_NODE // Size=24 96 | { 97 | union ___unnamed1666 u1; // Size=8 Offset=0 98 | struct _MM_AVL_NODE * LeftChild; // Size=8 Offset=8 99 | struct _MM_AVL_NODE * RightChild; // Size=8 Offset=16 100 | } MM_AVL_NODE, *PMM_AVL_NODE, *PMMADDRESS_NODE; 101 | 102 | typedef struct _MM_AVL_TABLE // Size=48 103 | { 104 | struct _MM_AVL_NODE BalancedRoot; // Size=24 Offset=0 105 | struct 106 | { 107 | unsigned __int64 DepthOfTree: 5; // Size=8 Offset=24 BitOffset=0 BitCount=5 108 | unsigned __int64 TableType: 3; // Size=8 Offset=24 BitOffset=5 BitCount=3 109 | unsigned __int64 NumberGenericTableElements: 56; // Size=8 Offset=24 BitOffset=8 BitCount=56 110 | }; 111 | void * NodeHint; // Size=8 Offset=32 112 | void * NodeFreeHint; // Size=8 Offset=40 113 | } MM_AVL_TABLE, *PMM_AVL_TABLE; 114 | 115 | typedef struct _MMVAD_SHORT // Size=64 116 | { 117 | struct _MM_AVL_NODE VadNode; // Size=24 Offset=0 118 | unsigned long StartingVpn; // Size=4 Offset=24 119 | unsigned long EndingVpn; // Size=4 Offset=28 120 | void * PushLock; // Size=8 Offset=32 121 | union ___unnamed1784 u; // Size=4 Offset=40 122 | union ___unnamed1785 u1; // Size=4 Offset=44 123 | struct _MI_VAD_EVENT_BLOCK * EventList; // Size=8 Offset=48 124 | long ReferenceCount; // Size=4 Offset=56 125 | } MMVAD_SHORT, *PMMVAD_SHORT; 126 | 127 | typedef struct _MMVAD // Size=128 128 | { 129 | struct _MMVAD_SHORT Core; // Size=64 Offset=0 130 | union ___unnamed1883 u2; // Size=4 Offset=64 131 | struct _SUBSECTION * Subsection; // Size=8 Offset=72 132 | struct _MMPTE * FirstPrototypePte; // Size=8 Offset=80 133 | struct _MMPTE * LastContiguousPte; // Size=8 Offset=88 134 | struct _LIST_ENTRY ViewLinks; // Size=16 Offset=96 135 | struct _EPROCESS * VadsProcess; // Size=8 Offset=112 136 | union ___unnamed1885 u4; // Size=8 Offset=120 137 | } MMVAD, *PMMVAD; 138 | 139 | typedef struct _HANDLE_TABLE 140 | { 141 | ULONG NextHandleNeedingPool; 142 | long ExtraInfoPages; 143 | ULONG_PTR TableCode; 144 | struct _EPROCESS * QuotaProcess; 145 | LIST_ENTRY HandleTableList; 146 | ULONG UniqueProcessId; 147 | ULONG Flags; 148 | EX_PUSH_LOCK HandleContentionEvent; 149 | EX_PUSH_LOCK HandleTableLock; 150 | // More fields here... 151 | } HANDLE_TABLE, *PHANDLE_TABLE; 152 | 153 | #pragma warning(default : 4214 4201) 154 | 155 | #define GET_VAD_ROOT(Table) (Table->BalancedRoot.RightChild) -------------------------------------------------------------------------------- /KernelHack/NativeStructs81.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // 4 | // Native structures W8.1 x64 5 | // 6 | #pragma warning(disable : 4214 4201) 7 | #pragma pack(push, 1) 8 | 9 | typedef struct _MM_AVL_NODE // Size=24 10 | { 11 | struct _MM_AVL_NODE * LeftChild; // Size=8 Offset=0 12 | struct _MM_AVL_NODE * RightChild; // Size=8 Offset=8 13 | 14 | union ___unnamed1666 // Size=8 15 | { 16 | struct 17 | { 18 | __int64 Balance : 2; // Size=8 Offset=0 BitOffset=0 BitCount=2 19 | }; 20 | struct _MM_AVL_NODE * Parent; // Size=8 Offset=0 21 | } u1; 22 | } MM_AVL_NODE, *PMM_AVL_NODE, *PMMADDRESS_NODE; 23 | 24 | typedef struct _RTL_AVL_TREE // Size=8 25 | { 26 | PMM_AVL_NODE BalancedRoot; // Size=8 Offset=0 27 | void * NodeHint; // Size=8 Offset=1504 28 | unsigned __int64 NumberGenericTableElements; // Size=8 Offset=1512 29 | } RTL_AVL_TREE, *PRTL_AVL_TREE, *PMM_AVL_TABLE; 30 | 31 | union _EX_PUSH_LOCK // Size=8 32 | { 33 | struct 34 | { 35 | unsigned __int64 Locked : 1; // Size=8 Offset=0 BitOffset=0 BitCount=1 36 | unsigned __int64 Waiting : 1; // Size=8 Offset=0 BitOffset=1 BitCount=1 37 | unsigned __int64 Waking : 1; // Size=8 Offset=0 BitOffset=2 BitCount=1 38 | unsigned __int64 MultipleShared : 1; // Size=8 Offset=0 BitOffset=3 BitCount=1 39 | unsigned __int64 Shared : 60; // Size=8 Offset=0 BitOffset=4 BitCount=60 40 | }; 41 | unsigned __int64 Value; // Size=8 Offset=0 42 | void * Ptr; // Size=8 Offset=0 43 | }; 44 | 45 | struct _MMVAD_FLAGS // Size=4 46 | { 47 | unsigned long VadType : 3; // Size=4 Offset=0 BitOffset=0 BitCount=3 48 | unsigned long Protection : 5; // Size=4 Offset=0 BitOffset=3 BitCount=5 49 | unsigned long PreferredNode : 6; // Size=4 Offset=0 BitOffset=8 BitCount=6 50 | unsigned long NoChange : 1; // Size=4 Offset=0 BitOffset=14 BitCount=1 51 | unsigned long PrivateMemory : 1; // Size=4 Offset=0 BitOffset=15 BitCount=1 52 | unsigned long Teb : 1; // Size=4 Offset=0 BitOffset=16 BitCount=1 53 | unsigned long PrivateFixup : 1; // Size=4 Offset=0 BitOffset=17 BitCount=1 54 | unsigned long Spare : 13; // Size=4 Offset=0 BitOffset=18 BitCount=13 55 | unsigned long DeleteInProgress : 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 56 | }; 57 | struct _MMVAD_FLAGS1 // Size=4 58 | { 59 | unsigned long CommitCharge : 31; // Size=4 Offset=0 BitOffset=0 BitCount=31 60 | unsigned long MemCommit : 1; // Size=4 Offset=0 BitOffset=31 BitCount=1 61 | }; 62 | 63 | struct _MMVAD_FLAGS2 // Size=4 64 | { 65 | unsigned long FileOffset : 24; // Size=4 Offset=0 BitOffset=0 BitCount=24 66 | unsigned long Large : 1; // Size=4 Offset=0 BitOffset=24 BitCount=1 67 | unsigned long TrimBehind : 1; // Size=4 Offset=0 BitOffset=25 BitCount=1 68 | unsigned long Inherit : 1; // Size=4 Offset=0 BitOffset=26 BitCount=1 69 | unsigned long CopyOnWrite : 1; // Size=4 Offset=0 BitOffset=27 BitCount=1 70 | unsigned long NoValidationNeeded : 1; // Size=4 Offset=0 BitOffset=28 BitCount=1 71 | unsigned long Spare : 3; // Size=4 Offset=0 BitOffset=29 BitCount=3 72 | }; 73 | 74 | struct _MI_VAD_SEQUENTIAL_INFO // Size=8 75 | { 76 | unsigned __int64 Length : 12; // Size=8 Offset=0 BitOffset=0 BitCount=12 77 | unsigned __int64 Vpn : 52; // Size=8 Offset=0 BitOffset=12 BitCount=52 78 | }; 79 | 80 | union ___unnamed1859 // Size=4 81 | { 82 | unsigned long LongFlags; // Size=4 Offset=0 83 | struct _MMVAD_FLAGS VadFlags; // Size=4 Offset=0 84 | }; 85 | union ___unnamed1860 // Size=4 86 | { 87 | unsigned long LongFlags1; // Size=4 Offset=0 88 | struct _MMVAD_FLAGS1 VadFlags1; // Size=4 Offset=0 89 | }; 90 | 91 | union ___unnamed1956 // Size=4 92 | { 93 | unsigned long LongFlags2; // Size=4 Offset=0 94 | struct _MMVAD_FLAGS2 VadFlags2; // Size=4 Offset=0 95 | }; 96 | 97 | union ___unnamed1957 // Size=8 98 | { 99 | struct _MI_VAD_SEQUENTIAL_INFO SequentialVa; // Size=8 Offset=0 100 | struct _MMEXTEND_INFO * ExtendedInfo; // Size=8 Offset=0 101 | }; 102 | 103 | typedef struct _MMVAD_SHORT // Size=64 104 | { 105 | union 106 | { 107 | struct _MM_AVL_NODE VadNode; // Size=24 Offset=0 108 | struct _MMVAD_SHORT * NextVad; // Size=8 Offset=0 109 | }; 110 | unsigned long StartingVpn; // Size=4 Offset=24 111 | unsigned long EndingVpn; // Size=4 Offset=28 112 | unsigned char StartingVpnHigh; // Size=1 Offset=32 113 | unsigned char EndingVpnHigh; // Size=1 Offset=33 114 | unsigned char CommitChargeHigh; // Size=1 Offset=34 115 | unsigned char LargeImageBias; // Size=1 Offset=35 116 | long ReferenceCount; // Size=4 Offset=36 117 | union _EX_PUSH_LOCK PushLock; // Size=8 Offset=40 118 | union ___unnamed1859 u; // Size=4 Offset=48 119 | union ___unnamed1860 u1; // Size=4 Offset=52 120 | struct _MI_VAD_EVENT_BLOCK * EventList; // Size=8 Offset=56 121 | } MMVAD_SHORT, *PMMVAD_SHORT; 122 | 123 | typedef struct _MMVAD // Size=128 124 | { 125 | struct _MMVAD_SHORT Core; // Size=64 Offset=0 126 | union ___unnamed1956 u2; // Size=4 Offset=64 127 | unsigned long pad0; // Size=4 Offset=68 128 | struct _SUBSECTION * Subsection; // Size=8 Offset=72 129 | struct _MMPTE * FirstPrototypePte; // Size=8 Offset=80 130 | struct _MMPTE * LastContiguousPte; // Size=8 Offset=88 131 | struct _LIST_ENTRY ViewLinks; // Size=16 Offset=96 132 | struct _EPROCESS * VadsProcess; // Size=8 Offset=112 133 | union ___unnamed1957 u4; // Size=8 Offset=120 134 | } MMVAD, *PMMVAD; 135 | #pragma pack(pop) 136 | 137 | typedef struct _HANDLE_TABLE 138 | { 139 | ULONG NextHandleNeedingPool; 140 | long ExtraInfoPages; 141 | LONG_PTR TableCode; 142 | struct _EPROCESS * QuotaProcess; 143 | LIST_ENTRY HandleTableList; 144 | ULONG UniqueProcessId; 145 | ULONG Flags; 146 | EX_PUSH_LOCK HandleContentionEvent; 147 | EX_PUSH_LOCK HandleTableLock; 148 | // More fields here... 149 | } HANDLE_TABLE, *PHANDLE_TABLE; 150 | 151 | #pragma warning(default : 4214 4201) 152 | 153 | #define GET_VAD_ROOT(Table) Table->BalancedRoot -------------------------------------------------------------------------------- /KernelHack/Offsets.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #include "Offsets.hpp" 13 | #include "Utils.hpp" 14 | #include "hde/hde.h" 15 | #include "skCrypter.h" 16 | 17 | namespace Offsets 18 | { 19 | OFFSETINFO CmCallbackListHead; 20 | OFFSETINFO PoolBigPageTable; 21 | OFFSETINFO PiDDBLock; 22 | OFFSETINFO PiDDBCacheTable; 23 | OFFSETINFO KeSuspendThread; 24 | OFFSETINFO KeResumeThread; 25 | OFFSETINFO PspNotifyEnableMask; 26 | OFFSETINFO MmSetPageProtection; 27 | OFFSETINFO I8xWriteDataToKeyboardQueue; 28 | } 29 | 30 | BOOLEAN Offsets::UpdateOffsetInfo(POFFSETINFO OffsetInfo) 31 | { 32 | ULONG64 found = 0; 33 | 34 | if (OffsetInfo->Mask) 35 | { 36 | found = Utils::FindPatternImage( 37 | OffsetInfo->Module, 38 | OffsetInfo->Section, 39 | OffsetInfo->Pattern, 40 | OffsetInfo->Mask) + OffsetInfo->Offset; //OPCODE of call/mov/... 41 | } 42 | else 43 | { 44 | found = Utils::FindPatternImage( 45 | OffsetInfo->Module, 46 | OffsetInfo->Section, 47 | OffsetInfo->Pattern) + OffsetInfo->Offset; 48 | } 49 | //KdPrint(("found = %llX\n", found)); 50 | if (found == OffsetInfo->Offset) 51 | return FALSE; 52 | 53 | hde64s dasm; 54 | if (hde64_disasm((PVOID)found, &dasm) < 4) 55 | return FALSE; 56 | 57 | OffsetInfo->Address = *(PLONG)(found + dasm.len - 4) + (found + dasm.len); 58 | return TRUE; 59 | } 60 | 61 | BOOLEAN Offsets::Initialize() 62 | { 63 | NTSTATUS status = STATUS_SUCCESS; 64 | RTL_OSVERSIONINFOEXW verInfo = { 0 }; 65 | 66 | verInfo.dwOSVersionInfoSize = sizeof(verInfo); 67 | status = RtlGetVersion((PRTL_OSVERSIONINFOW)&verInfo); 68 | //DbgPrint("%d\n", verInfo.dwBuildNumber); //19044 69 | 70 | //7600 0 71 | //7601 0 72 | //9200 0 73 | //9600 0 74 | //10240 1 75 | //10586 1 76 | //14393 1 77 | //15063 1 78 | //16299 1 79 | //17134 1 80 | //17763 1 81 | //18362 1 82 | //18363 1 83 | //19041 1 84 | //19042 1 85 | //19043 1 86 | //19044 1 87 | //22000 1 88 | //22621 1 89 | //22622 0 90 | //22623 0 91 | //25217 0 92 | //25267 0 93 | //25276 0 94 | //25300 0 95 | //25330 0 96 | 97 | //General Pattern 98 | if (verInfo.dwBuildNumber >= 10240) 99 | { 100 | CmCallbackListHead.Module = skCrypt("ntoskrnl.exe"); 101 | CmCallbackListHead.Section = skCrypt("PAGE"); 102 | CmCallbackListHead.InFunction = skCrypt("CmUnRegisterCallback"); 103 | CmCallbackListHead.Pattern = skCrypt("48 8D 0D ? ? ? ? E8 ? ? ? ? 48 8B F8 48 89 44 24 ? 48 85 C0"); //Win10-Win11 104 | CmCallbackListHead.Mask = 0; 105 | CmCallbackListHead.Offset = 0x0; 106 | 107 | PiDDBLock.Module = skCrypt("ntoskrnl.exe"); 108 | PiDDBLock.Section = skCrypt("PAGE"); 109 | PiDDBLock.InFunction = skCrypt("PpCheckInDriverDatabase"); 110 | PiDDBLock.Pattern = skCrypt("B2 01 48 8D 0D ? ? ? ? E8 ? ? ? ? 4C 8B 8C 24"); //10240-19044 111 | PiDDBLock.Mask = 0; 112 | PiDDBLock.Offset = 0x2; 113 | 114 | PiDDBCacheTable.Module = skCrypt("ntoskrnl.exe"); 115 | PiDDBCacheTable.Section = skCrypt("PAGE"); 116 | PiDDBCacheTable.InFunction = skCrypt("PiUpdateDriverDBCache"); 117 | PiDDBCacheTable.Pattern = skCrypt("48 8D 0D ? ? ? ? E8 ? ? ? ? 48 8D 1D ? ? ? ? 48 85 C0 0F"); //Win10-Win11 118 | PiDDBCacheTable.Mask = 0; 119 | PiDDBCacheTable.Offset = 0x0; 120 | 121 | KeSuspendThread.Module = skCrypt("ntoskrnl.exe"); 122 | KeSuspendThread.Section = skCrypt("PAGE"); 123 | KeSuspendThread.InFunction = skCrypt("PsSuspendThread"); 124 | KeSuspendThread.Pattern = skCrypt("A8 01 0F 85 ? ? ? ? 48 8B ? E8 ? ? ? ? 89 44 24"); //Win7,Win10-Win11 125 | KeSuspendThread.Mask = 0; 126 | KeSuspendThread.Offset = 0xB; 127 | 128 | PspNotifyEnableMask.Module = skCrypt("ntoskrnl.exe"); 129 | PspNotifyEnableMask.Section = skCrypt("PAGE"); 130 | PspNotifyEnableMask.InFunction = skCrypt("PsSetLoadImageNotifyRoutineEx"); 131 | PspNotifyEnableMask.Pattern = skCrypt("8B 05 ? ? ? ? A8 01 75 09 F0 0F BA 2D"); //Win7,Win10-Win11 132 | PspNotifyEnableMask.Mask = 0; 133 | PspNotifyEnableMask.Offset = 0x0; 134 | 135 | MmSetPageProtection.Module = skCrypt("ntoskrnl.exe"); 136 | MmSetPageProtection.Section = skCrypt("PAGE"); 137 | MmSetPageProtection.InFunction = skCrypt("MmAllocateIsrStack"); 138 | MmSetPageProtection.Pattern = skCrypt("41 ?? ?? ?? ?? ?? 48 ?? ?? ?? ?? ?? E8 ?? ?? ?? ?? 84 C0 74 ?? 48 81 EB ?? ?? ?? ?? EB"); 139 | MmSetPageProtection.Mask = 0; 140 | MmSetPageProtection.Offset = 0xC; 141 | 142 | I8xWriteDataToKeyboardQueue.Module = skCrypt("i8042prt.sys"); 143 | I8xWriteDataToKeyboardQueue.Section = skCrypt(".text"); 144 | I8xWriteDataToKeyboardQueue.InFunction = skCrypt("I8xQueueCurrentKeyboardInput"); 145 | I8xWriteDataToKeyboardQueue.Pattern = skCrypt("39 73 ?? 0F ?? ?? ?? ?? ?? 48 8D ?? ?? ?? ?? ?? 48 8B CB E8 ?? ?? ?? ?? 84 C0 75 ??"); 146 | I8xWriteDataToKeyboardQueue.Mask = 0; 147 | I8xWriteDataToKeyboardQueue.Offset = 0x13; 148 | } 149 | 150 | //PoolBigPageTable 151 | if (verInfo.dwBuildNumber >= 10240 && verInfo.dwBuildNumber < 19041) 152 | { 153 | PoolBigPageTable.Module = skCrypt("ntoskrnl.exe"); 154 | PoolBigPageTable.Section = skCrypt(".text"); 155 | PoolBigPageTable.InFunction = skCrypt("ExGetBigPoolInfo"); 156 | PoolBigPageTable.Pattern = skCrypt("83 ? 01 75 10 48 8B 15 ? ? ? ? 48 8B ? ? ? ? ? EB ? 48"); 157 | PoolBigPageTable.Mask = 0; 158 | PoolBigPageTable.Offset = 0x5; 159 | } 160 | else if (verInfo.dwBuildNumber >= 19041) 161 | { 162 | PoolBigPageTable.Module = skCrypt("ntoskrnl.exe"); 163 | PoolBigPageTable.Section = skCrypt(".text"); 164 | PoolBigPageTable.InFunction = skCrypt("ExProtectPoolEx"); 165 | PoolBigPageTable.Pattern = skCrypt("48 C1 E8 ?? 48 33 D8 E8 ?? ?? ?? ?? 4C ?? ?? ?? ?? ?? ?? 4C ?? ?? ?? ?? ?? ?? 0F B6 F8"); 166 | PoolBigPageTable.Mask = 0; 167 | PoolBigPageTable.Offset = 0x13; 168 | } 169 | 170 | //PiDDBLock 171 | if (verInfo.dwBuildNumber > 19044 && verInfo.dwBuildNumber < 22621) 172 | { 173 | PiDDBLock.Module = skCrypt("ntoskrnl.exe"); 174 | PiDDBLock.Section = skCrypt("PAGE"); 175 | PiDDBLock.InFunction = skCrypt("PpCheckInDriverDatabase"); 176 | PiDDBLock.Pattern = skCrypt("B2 01 48 8D 0D ? ? ? ? E8 ? ? ? ? 4C 8B 4C 24"); 177 | PiDDBLock.Mask = 0; 178 | PiDDBLock.Offset = 0x2; 179 | } 180 | else if (verInfo.dwBuildNumber >= 22621) 181 | { 182 | PiDDBLock.Module = skCrypt("ntoskrnl.exe"); 183 | PiDDBLock.Section = skCrypt("PAGE"); 184 | PiDDBLock.InFunction = skCrypt("PpReleaseBootDDB"); 185 | PiDDBLock.Pattern = skCrypt("48 8D 0D ?? ?? ?? ?? B2 01 66 FF 88 ?? ?? ?? ?? 90 E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? 48 85 C9"); 186 | PiDDBLock.Mask = 0; 187 | PiDDBLock.Offset = 0x0; 188 | } 189 | 190 | //KeResumeThread 191 | if (verInfo.dwBuildNumber >= 10240 && verInfo.dwBuildNumber < 14393) 192 | { 193 | 194 | } 195 | else if (verInfo.dwBuildNumber >= 14393 && verInfo.dwBuildNumber < 18362) 196 | { 197 | KeResumeThread.Module = skCrypt("ntoskrnl.exe"); 198 | KeResumeThread.Section = skCrypt("PAGE"); 199 | KeResumeThread.InFunction = skCrypt("PsResumeProcess"); 200 | KeResumeThread.Pattern = skCrypt("48 8B ? E8 ? ? ? ? 48 8B ? 48 8B ? E8 ? ? ? ? EB ? BB ? ? ? ? EB"); 201 | KeResumeThread.Mask = 0; 202 | KeResumeThread.Offset = 0x3; 203 | } 204 | else if (verInfo.dwBuildNumber >= 18362 && verInfo.dwBuildNumber < 22000) 205 | { 206 | KeResumeThread.Module = skCrypt("ntoskrnl.exe"); 207 | KeResumeThread.Section = skCrypt("PAGE"); 208 | KeResumeThread.InFunction = skCrypt("PsResumeProcess"); 209 | KeResumeThread.Pattern = skCrypt("48 8B C8 E8 ? ? ? ? 48 8B D7 48 8B CE"); 210 | KeResumeThread.Mask = 0; 211 | KeResumeThread.Offset = 0x3; 212 | } 213 | else if (verInfo.dwBuildNumber >= 22000) 214 | { 215 | KeResumeThread.Module = skCrypt("ntoskrnl.exe"); 216 | KeResumeThread.Section = skCrypt(".text"); 217 | KeResumeThread.InFunction = skCrypt("PsResumeProcess"); 218 | KeResumeThread.Pattern = skCrypt("48 8B C8 E8 ? ? ? ? 48 8B D7 48 8B CE"); 219 | KeResumeThread.Mask = 0; 220 | KeResumeThread.Offset = 0x3; 221 | } 222 | 223 | UpdateOffsetInfo(&CmCallbackListHead); 224 | KdPrint(("CmCallbackListHead = %llX\n", CmCallbackListHead.Address)); 225 | 226 | UpdateOffsetInfo(&PiDDBLock); 227 | KdPrint(("PiDDBLock = %llX\n", PiDDBLock.Address)); 228 | 229 | UpdateOffsetInfo(&PiDDBCacheTable); 230 | KdPrint(("PiDDBCacheTable = %llX\n", PiDDBCacheTable.Address)); 231 | 232 | UpdateOffsetInfo(&PoolBigPageTable); 233 | KdPrint(("PoolBigPageTable = %llX\n", PoolBigPageTable.Address)); 234 | 235 | UpdateOffsetInfo(&KeSuspendThread); 236 | KdPrint(("KeSuspendThread = %llX\n", KeSuspendThread.Address)); 237 | 238 | UpdateOffsetInfo(&KeResumeThread); 239 | KdPrint(("KeResumeThread = %llX\n", KeResumeThread.Address)); 240 | 241 | UpdateOffsetInfo(&PspNotifyEnableMask); 242 | KdPrint(("PspNotifyEnableMask = %llX\n", PspNotifyEnableMask.Address)); 243 | 244 | UpdateOffsetInfo(&MmSetPageProtection); 245 | KdPrint(("MmSetPageProtection = %llX\n", MmSetPageProtection.Address)); 246 | 247 | UpdateOffsetInfo(&I8xWriteDataToKeyboardQueue); 248 | KdPrint(("I8xWriteDataToKeyboardQueue = %llX\n", I8xWriteDataToKeyboardQueue.Address)); 249 | 250 | return TRUE; 251 | } 252 | -------------------------------------------------------------------------------- /KernelHack/Offsets.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include "Includes.h" 14 | 15 | namespace Offsets 16 | { 17 | typedef struct _OFFSETINFO 18 | { 19 | PCHAR Module; 20 | PCHAR Section; 21 | PCHAR InFunction; 22 | PCHAR Pattern; 23 | PCHAR Mask; 24 | ULONG64 Offset; 25 | ULONG64 Address; 26 | }OFFSETINFO, * POFFSETINFO; 27 | 28 | extern OFFSETINFO CmCallbackListHead; 29 | extern OFFSETINFO PoolBigPageTable; 30 | extern OFFSETINFO PiDDBLock; 31 | extern OFFSETINFO PiDDBCacheTable; 32 | extern OFFSETINFO KeSuspendThread; 33 | extern OFFSETINFO KeResumeThread; 34 | extern OFFSETINFO PspNotifyEnableMask; 35 | extern OFFSETINFO MmSetPageProtection; 36 | extern OFFSETINFO I8xWriteDataToKeyboardQueue; 37 | 38 | BOOLEAN UpdateOffsetInfo(POFFSETINFO OffsetInfo); 39 | 40 | BOOLEAN Initialize(); 41 | } -------------------------------------------------------------------------------- /KernelHack/Process.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/Process.cpp -------------------------------------------------------------------------------- /KernelHack/Process.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include "Includes.h" 14 | 15 | namespace Process 16 | { 17 | void AttachProcess( 18 | PEPROCESS NewProcess); 19 | 20 | void DetachProcess(); 21 | 22 | NTSTATUS ReadVirtualMemory( 23 | PEPROCESS Process, 24 | PVOID Destination, 25 | PVOID Source, 26 | SIZE_T Size); 27 | 28 | NTSTATUS WriteVirtualMemory( 29 | PEPROCESS Process, 30 | PVOID Destination, 31 | PVOID Source, 32 | SIZE_T Size); 33 | 34 | NTSTATUS AllocateVirtualMemory( 35 | PEPROCESS Process, 36 | PVOID* BaseAddress, 37 | SIZE_T* Size, 38 | DWORD fProtect); 39 | 40 | NTSTATUS FreeVirtualMemory( 41 | PEPROCESS Process, 42 | PVOID* BaseAddress, 43 | SIZE_T* Size); 44 | 45 | NTSTATUS SafeAllocateExecuteMemory( 46 | PEPROCESS Process, 47 | PVOID* BaseAddress, 48 | SIZE_T* Size); 49 | 50 | PVOID GetModuleBase( 51 | PCHAR ModuleName); 52 | 53 | PVOID GetModuleBase( 54 | PEPROCESS Process, 55 | PCHAR ModuleName); 56 | 57 | PVOID ProtectProcess( 58 | PEPROCESS Process); 59 | 60 | PETHREAD GetProcessMainThread( 61 | PEPROCESS Process); 62 | 63 | KTRAP_FRAME GetThreadTrapFrame( 64 | PETHREAD Thread); 65 | 66 | void SetThreadTrapFrame( 67 | PETHREAD Thread, KTRAP_FRAME TrapFrame); 68 | 69 | BOOLEAN InjectShellcode( 70 | PEPROCESS Process, 71 | PBYTE Shellcode, 72 | SIZE_T Size); 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /KernelHack/Utils.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/Utils.cpp -------------------------------------------------------------------------------- /KernelHack/Utils.hpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #pragma once 13 | #include "Includes.h" 14 | #include "NativeStructs.h" 15 | 16 | namespace Utils 17 | { 18 | PVOID GetModuleBase( 19 | PCHAR szModuleName); 20 | 21 | PVOID GetModuleBase( 22 | PCHAR szModuleName, 23 | SIZE_T* size); 24 | 25 | PVOID GetModuleBase( 26 | PCHAR szModuleName, 27 | SIZE_T* size, 28 | BOOLEAN CaseInSensitive); 29 | 30 | PVOID GetModuleBaseEx( 31 | PCHAR szModuleName); 32 | 33 | PVOID GetModuleBaseEx( 34 | PCHAR szModuleName, 35 | SIZE_T* size); 36 | 37 | PVOID GetProcAddress( 38 | PVOID ModuleBase, 39 | PCHAR szFuncName); 40 | 41 | BOOLEAN RtlCaptureAnsiString( 42 | PUNICODE_STRING, 43 | PCSZ, 44 | BOOLEAN); 45 | 46 | ULONG GetActiveProcessLinksOffset(); 47 | 48 | HANDLE GetProcessIdByName( 49 | PCHAR szName); 50 | 51 | PEPROCESS GetProcessByProcessId( 52 | HANDLE pid); 53 | 54 | PEPROCESS GetProcessByProcessIdEx( 55 | HANDLE pid); 56 | 57 | PVOID GetProcessBaseAddress( 58 | HANDLE pid); 59 | 60 | PEPROCESS GetProcessByName( 61 | PCHAR szName); 62 | 63 | PETHREAD GetProcessMainThread( 64 | PEPROCESS Process); 65 | 66 | ULONG64 FindPattern( 67 | ULONG64 base, 68 | SIZE_T size, 69 | PCHAR pattern, 70 | PCHAR mask); 71 | 72 | ULONG64 FindPatternImage( 73 | PCHAR module, 74 | PCHAR section, 75 | PCHAR pattern, 76 | PCHAR mask); 77 | 78 | ULONG64 FindPattern( 79 | ULONG64 base, 80 | SIZE_T size, 81 | PCHAR pattern); 82 | 83 | ULONG64 FindPatternImage( 84 | PCHAR module, 85 | PCHAR section, 86 | PCHAR pattern); 87 | 88 | ULONG64 GetImageSectionByName( 89 | ULONG64 imageBase, 90 | PCHAR sectionName, 91 | SIZE_T* sizeOut); 92 | 93 | PSERVICE_DESCRIPTOR_TABLE 94 | GetKeServiceDescriptorTableShadow(); 95 | 96 | PVOID GetServiceFunctionByIndex( 97 | PSYSTEM_SERVICE_TABLE, 98 | ULONG ServiceId); 99 | 100 | VOID Sleep( 101 | ULONG Milliseconds); 102 | 103 | NTSTATUS SafeCmRegisterCallback( 104 | PEX_CALLBACK_FUNCTION Function, 105 | PVOID Context, 106 | PLARGE_INTEGER Cookie); 107 | 108 | NTSTATUS SafeCmUnRegisterCallback( 109 | LARGE_INTEGER Cookie); 110 | 111 | PDRIVER_OBJECT GetDriverObjectByName( 112 | PWCHAR DriverName); 113 | 114 | #pragma warning(disable:4127) 115 | template T __ROL__(T value, int count) 116 | { 117 | const unsigned int nbits = sizeof(T) * 8; 118 | if (count > 0) 119 | { 120 | count %= nbits; 121 | T high = value >> (nbits - count); 122 | if (T(-1) < 0) // This will be a signed val. 123 | high &= ~((T(-1) << count)); 124 | value <<= count; 125 | value |= high; 126 | } 127 | else 128 | { 129 | count = -count % nbits; 130 | T low = value << (nbits - count); 131 | value >>= count; 132 | value |= low; 133 | } 134 | return value; 135 | } 136 | }; 137 | -------------------------------------------------------------------------------- /KernelHack/entry.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | GPL 10 | 11 | --*/ 12 | #include "Includes.h" 13 | #include "Memory.hpp" 14 | #include "Utils.hpp" 15 | #include "Comm.hpp" 16 | #include "Mapper.hpp" 17 | #include "Offsets.hpp" 18 | #include "Process.hpp" 19 | #include "I8042Interface.h" 20 | #include "skCrypter.h" 21 | 22 | 23 | NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) 24 | { 25 | UNREFERENCED_PARAMETER(RegistryPath); 26 | NTSTATUS status = STATUS_SUCCESS; 27 | DbgPrint(skCrypt("DriverObject = %p\n"), DriverObject); 28 | 29 | if (Offsets::Initialize() == FALSE) { 30 | DbgPrint(skCrypt("Unsupport System!!!\n")); 31 | return STATUS_UNSUCCESSFUL; 32 | } 33 | 34 | DbgPrint("res - %p\n", Utils::GetProcessByName("dwm.exe")); 35 | 36 | if (DriverObject) { 37 | DriverObject->DriverUnload = [](PDRIVER_OBJECT DriverObject)-> VOID { 38 | UNREFERENCED_PARAMETER(DriverObject); 39 | //Comm::RegistryCallback::Unload(); 40 | //Comm::DeviceIoControl::Unload(DriverObject); 41 | Comm::IrpHijack::Unload(); 42 | }; 43 | 44 | //Comm::RegistryCallback::Initialize(); 45 | //Comm::DeviceIoControl::Initialize(DriverObject); 46 | Comm::IrpHijack::Initialize(); 47 | return STATUS_SUCCESS; 48 | 49 | //PLDR_DATA_TABLE_ENTRY LdrData = (PLDR_DATA_TABLE_ENTRY)DriverObject->DriverSection; 50 | //status = Mapper::MapDriverFromFile(&LdrData->FullDllName); 51 | //LdrData->BaseDllName.Length = 0; 52 | //Memory::CleanPiDDBCache(DriverObject); 53 | //return STATUS_UNSUCCESSFUL; 54 | } 55 | else { 56 | //Comm::RegistryCallback::Initialize(); 57 | //Comm::BonudCallback::Initialize(); 58 | Comm::IrpHijack::Initialize(); 59 | } 60 | 61 | return status; 62 | } 63 | -------------------------------------------------------------------------------- /KernelHack/hde/hde.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_AMD64_) 4 | #include "hde64.h" 5 | typedef hde64s hdes; 6 | #define hde_disasm hde64_disasm 7 | #elif defined(_X86_) 8 | #include "hde32.h" 9 | typedef hde32s hdes; 10 | #define hde_disasm hde32_disasm 11 | #else 12 | #error Unsupported architecture 13 | #endif 14 | -------------------------------------------------------------------------------- /KernelHack/hde/hde32.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 32 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include "hde32.h" 11 | #include "table32.h" 12 | 13 | #ifdef _MSC_VER 14 | #pragma warning(disable:4701) 15 | #endif 16 | 17 | unsigned int hde32_disasm(const void *code, hde32s *hs) 18 | { 19 | uint8_t x, c, *p = (uint8_t*)code, cflags, opcode, pref = 0; 20 | uint8_t* ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0; 21 | 22 | memset(hs, 0, sizeof(hde32s)); 23 | 24 | for (x = 16; x; x--) 25 | switch (c = *p++) { 26 | case 0xf3: 27 | hs->p_rep = c; 28 | pref |= PRE_F3; 29 | break; 30 | case 0xf2: 31 | hs->p_rep = c; 32 | pref |= PRE_F2; 33 | break; 34 | case 0xf0: 35 | hs->p_lock = c; 36 | pref |= PRE_LOCK; 37 | break; 38 | case 0x26: case 0x2e: case 0x36: 39 | case 0x3e: case 0x64: case 0x65: 40 | hs->p_seg = c; 41 | pref |= PRE_SEG; 42 | break; 43 | case 0x66: 44 | hs->p_66 = c; 45 | pref |= PRE_66; 46 | break; 47 | case 0x67: 48 | hs->p_67 = c; 49 | pref |= PRE_67; 50 | break; 51 | default: 52 | goto pref_done; 53 | } 54 | pref_done: 55 | 56 | hs->flags = (uint32_t)pref << 23; 57 | 58 | if (!pref) 59 | pref |= PRE_NONE; 60 | 61 | if ((hs->opcode = c) == 0x0f) { 62 | hs->opcode2 = c = *p++; 63 | ht += DELTA_OPCODES; 64 | } else if (c >= 0xa0 && c <= 0xa3) { 65 | if (pref & PRE_67) 66 | pref |= PRE_66; 67 | else 68 | pref &= ~PRE_66; 69 | } 70 | 71 | opcode = c; 72 | cflags = ht[ht[opcode / 4] + (opcode % 4)]; 73 | 74 | if (cflags == C_ERROR) { 75 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 76 | cflags = 0; 77 | if ((opcode & -3) == 0x24) 78 | cflags++; 79 | } 80 | 81 | x = 0; 82 | if (cflags & C_GROUP) { 83 | uint16_t t; 84 | t = *(uint16_t*)(ht + (cflags & 0x7f)); 85 | cflags = (uint8_t)t; 86 | x = (uint8_t)(t >> 8); 87 | } 88 | 89 | if (hs->opcode2) { 90 | ht = hde32_table + DELTA_PREFIXES; 91 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref) 92 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 93 | } 94 | 95 | if (cflags & C_MODRM) { 96 | hs->flags |= F_MODRM; 97 | hs->modrm = c = *p++; 98 | hs->modrm_mod = m_mod = c >> 6; 99 | hs->modrm_rm = m_rm = c & 7; 100 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3; 101 | 102 | if (x && ((x << m_reg) & 0x80)) 103 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 104 | 105 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) { 106 | uint8_t t = opcode - 0xd9; 107 | if (m_mod == 3) { 108 | ht = hde32_table + DELTA_FPU_MODRM + t*8; 109 | t = ht[m_reg] << m_rm; 110 | } else { 111 | ht = hde32_table + DELTA_FPU_REG; 112 | t = ht[t] << m_reg; 113 | } 114 | if (t & 0x80) 115 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 116 | } 117 | 118 | if (pref & PRE_LOCK) { 119 | if (m_mod == 3) { 120 | hs->flags |= F_ERROR | F_ERROR_LOCK; 121 | } else { 122 | uint8_t* table_end, op = opcode; 123 | if (hs->opcode2) { 124 | ht = hde32_table + DELTA_OP2_LOCK_OK; 125 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK; 126 | } else { 127 | ht = hde32_table + DELTA_OP_LOCK_OK; 128 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK; 129 | op &= -2; 130 | } 131 | for (; ht != table_end; ht++) 132 | if (*ht++ == op) { 133 | if (!((*ht << m_reg) & 0x80)) 134 | goto no_lock_error; 135 | else 136 | break; 137 | } 138 | hs->flags |= F_ERROR | F_ERROR_LOCK; 139 | no_lock_error: 140 | ; 141 | } 142 | } 143 | 144 | if (hs->opcode2) { 145 | switch (opcode) { 146 | case 0x20: case 0x22: 147 | m_mod = 3; 148 | if (m_reg > 4 || m_reg == 1) 149 | goto error_operand; 150 | else 151 | goto no_error_operand; 152 | case 0x21: case 0x23: 153 | m_mod = 3; 154 | if (m_reg == 4 || m_reg == 5) 155 | goto error_operand; 156 | else 157 | goto no_error_operand; 158 | } 159 | } else { 160 | switch (opcode) { 161 | case 0x8c: 162 | if (m_reg > 5) 163 | goto error_operand; 164 | else 165 | goto no_error_operand; 166 | case 0x8e: 167 | if (m_reg == 1 || m_reg > 5) 168 | goto error_operand; 169 | else 170 | goto no_error_operand; 171 | } 172 | } 173 | 174 | if (m_mod == 3) { 175 | uint8_t* table_end; 176 | if (hs->opcode2) { 177 | ht = hde32_table + DELTA_OP2_ONLY_MEM; 178 | table_end = ht + sizeof(hde32_table) - DELTA_OP2_ONLY_MEM; 179 | } else { 180 | ht = hde32_table + DELTA_OP_ONLY_MEM; 181 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM; 182 | } 183 | for (; ht != table_end; ht += 2) 184 | if (*ht++ == opcode) { 185 | if ((*ht++ & pref) && !((*ht << m_reg) & 0x80)) 186 | goto error_operand; 187 | else 188 | break; 189 | } 190 | goto no_error_operand; 191 | } else if (hs->opcode2) { 192 | switch (opcode) { 193 | case 0x50: case 0xd7: case 0xf7: 194 | if (pref & (PRE_NONE | PRE_66)) 195 | goto error_operand; 196 | break; 197 | case 0xd6: 198 | if (pref & (PRE_F2 | PRE_F3)) 199 | goto error_operand; 200 | break; 201 | case 0xc5: 202 | goto error_operand; 203 | } 204 | goto no_error_operand; 205 | } else 206 | goto no_error_operand; 207 | 208 | error_operand: 209 | hs->flags |= F_ERROR | F_ERROR_OPERAND; 210 | no_error_operand: 211 | 212 | c = *p++; 213 | if (m_reg <= 1) { 214 | if (opcode == 0xf6) 215 | cflags |= C_IMM8; 216 | else if (opcode == 0xf7) 217 | cflags |= C_IMM_P66; 218 | } 219 | 220 | switch (m_mod) { 221 | case 0: 222 | if (pref & PRE_67) { 223 | if (m_rm == 6) 224 | disp_size = 2; 225 | } else 226 | if (m_rm == 5) 227 | disp_size = 4; 228 | break; 229 | case 1: 230 | disp_size = 1; 231 | break; 232 | case 2: 233 | disp_size = 2; 234 | if (!(pref & PRE_67)) 235 | disp_size <<= 1; 236 | break; 237 | } 238 | 239 | if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) { 240 | hs->flags |= F_SIB; 241 | p++; 242 | hs->sib = c; 243 | hs->sib_scale = c >> 6; 244 | hs->sib_index = (c & 0x3f) >> 3; 245 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1)) 246 | disp_size = 4; 247 | } 248 | 249 | p--; 250 | switch (disp_size) { 251 | case 1: 252 | hs->flags |= F_DISP8; 253 | hs->disp.disp8 = *p; 254 | break; 255 | case 2: 256 | hs->flags |= F_DISP16; 257 | hs->disp.disp16 = *(uint16_t*)p; 258 | break; 259 | case 4: 260 | hs->flags |= F_DISP32; 261 | hs->disp.disp32 = *(uint32_t*)p; 262 | break; 263 | } 264 | p += disp_size; 265 | } else if (pref & PRE_LOCK) 266 | hs->flags |= F_ERROR | F_ERROR_LOCK; 267 | 268 | if (cflags & C_IMM_P66) { 269 | if (cflags & C_REL32) { 270 | if (pref & PRE_66) { 271 | hs->flags |= F_IMM16 | F_RELATIVE; 272 | hs->imm.imm16 = *(uint16_t*)p; 273 | p += 2; 274 | goto disasm_done; 275 | } 276 | goto rel32_ok; 277 | } 278 | if (pref & PRE_66) { 279 | hs->flags |= F_IMM16; 280 | hs->imm.imm16 = *(uint16_t*)p; 281 | p += 2; 282 | } else { 283 | hs->flags |= F_IMM32; 284 | hs->imm.imm32 = *(uint32_t*)p; 285 | p += 4; 286 | } 287 | } 288 | 289 | if (cflags & C_IMM16) { 290 | if (hs->flags & F_IMM32) { 291 | hs->flags |= F_IMM16; 292 | hs->disp.disp16 = *(uint16_t*)p; 293 | } else if (hs->flags & F_IMM16) { 294 | hs->flags |= F_2IMM16; 295 | hs->disp.disp16 = *(uint16_t*)p; 296 | } else { 297 | hs->flags |= F_IMM16; 298 | hs->imm.imm16 = *(uint16_t*)p; 299 | } 300 | p += 2; 301 | } 302 | if (cflags & C_IMM8) { 303 | hs->flags |= F_IMM8; 304 | hs->imm.imm8 = *p++; 305 | } 306 | 307 | if (cflags & C_REL32) { 308 | rel32_ok: 309 | hs->flags |= F_IMM32 | F_RELATIVE; 310 | hs->imm.imm32 = *(uint32_t*)p; 311 | p += 4; 312 | } else if (cflags & C_REL8) { 313 | hs->flags |= F_IMM8 | F_RELATIVE; 314 | hs->imm.imm8 = *p++; 315 | } 316 | 317 | disasm_done: 318 | 319 | if ((hs->len = (uint8_t)(p-(uint8_t*)code)) > 15) { 320 | hs->flags |= F_ERROR | F_ERROR_LENGTH; 321 | hs->len = 15; 322 | } 323 | 324 | return (unsigned int)hs->len; 325 | } 326 | -------------------------------------------------------------------------------- /KernelHack/hde/hde32.h: -------------------------------------------------------------------------------- 1 | #ifndef _HDE32_H_ 2 | #define _HDE32_H_ 3 | 4 | #include "kstdint.h" 5 | 6 | #define F_MODRM 0x00000001 7 | #define F_SIB 0x00000002 8 | #define F_IMM8 0x00000004 9 | #define F_IMM16 0x00000008 10 | #define F_IMM32 0x00000010 11 | #define F_DISP8 0x00000020 12 | #define F_DISP16 0x00000040 13 | #define F_DISP32 0x00000080 14 | #define F_RELATIVE 0x00000100 15 | #define F_2IMM16 0x00000800 16 | #define F_ERROR 0x00001000 17 | #define F_ERROR_OPCODE 0x00002000 18 | #define F_ERROR_LENGTH 0x00004000 19 | #define F_ERROR_LOCK 0x00008000 20 | #define F_ERROR_OPERAND 0x00010000 21 | #define F_PREFIX_REPNZ 0x01000000 22 | #define F_PREFIX_REPX 0x02000000 23 | #define F_PREFIX_REP 0x03000000 24 | #define F_PREFIX_66 0x04000000 25 | #define F_PREFIX_67 0x08000000 26 | #define F_PREFIX_LOCK 0x10000000 27 | #define F_PREFIX_SEG 0x20000000 28 | #define F_PREFIX_ANY 0x3f000000 29 | 30 | #define PREFIX_SEGMENT_CS 0x2e 31 | #define PREFIX_SEGMENT_SS 0x36 32 | #define PREFIX_SEGMENT_DS 0x3e 33 | #define PREFIX_SEGMENT_ES 0x26 34 | #define PREFIX_SEGMENT_FS 0x64 35 | #define PREFIX_SEGMENT_GS 0x65 36 | #define PREFIX_LOCK 0xf0 37 | #define PREFIX_REPNZ 0xf2 38 | #define PREFIX_REPX 0xf3 39 | #define PREFIX_OPERAND_SIZE 0x66 40 | #define PREFIX_ADDRESS_SIZE 0x67 41 | 42 | #pragma pack(push,1) 43 | 44 | typedef struct { 45 | uint8_t len; 46 | uint8_t p_rep; 47 | uint8_t p_lock; 48 | uint8_t p_seg; 49 | uint8_t p_66; 50 | uint8_t p_67; 51 | uint8_t opcode; 52 | uint8_t opcode2; 53 | uint8_t modrm; 54 | uint8_t modrm_mod; 55 | uint8_t modrm_reg; 56 | uint8_t modrm_rm; 57 | uint8_t sib; 58 | uint8_t sib_scale; 59 | uint8_t sib_index; 60 | uint8_t sib_base; 61 | union { 62 | uint8_t imm8; 63 | uint16_t imm16; 64 | uint32_t imm32; 65 | } imm; 66 | union { 67 | uint8_t disp8; 68 | uint16_t disp16; 69 | uint32_t disp32; 70 | } disp; 71 | uint32_t flags; 72 | } hde32s; 73 | 74 | #pragma pack(pop) 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | 80 | /* __cdecl */ 81 | unsigned int hde32_disasm(const void *code, hde32s *hs); 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif 86 | 87 | #endif /* _HDE32_H_ */ 88 | -------------------------------------------------------------------------------- /KernelHack/hde/hde64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Hacker Disassembler Engine 64 C 3 | * Copyright (c) 2008-2009, Vyacheslav Patkov. 4 | * All rights reserved. 5 | * 6 | */ 7 | 8 | #include 9 | 10 | #include "hde64.h" 11 | #include "table64.h" 12 | 13 | unsigned int hde64_disasm(const void *code, hde64s *hs) 14 | { 15 | uint8_t x = 0, c = 0, *p = (uint8_t *)code, cflags, opcode, pref = 0; 16 | uint8_t *ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0; 17 | uint8_t op64 = 0; 18 | 19 | memset(hs, 0, sizeof(hde64s)); 20 | 21 | for (x = 16; x; x--) 22 | switch (c = *p++) { 23 | case 0xf3: 24 | hs->p_rep = c; 25 | pref |= PRE_F3; 26 | break; 27 | case 0xf2: 28 | hs->p_rep = c; 29 | pref |= PRE_F2; 30 | break; 31 | case 0xf0: 32 | hs->p_lock = c; 33 | pref |= PRE_LOCK; 34 | break; 35 | case 0x26: case 0x2e: case 0x36: 36 | case 0x3e: case 0x64: case 0x65: 37 | hs->p_seg = c; 38 | pref |= PRE_SEG; 39 | break; 40 | case 0x66: 41 | hs->p_66 = c; 42 | pref |= PRE_66; 43 | break; 44 | case 0x67: 45 | hs->p_67 = c; 46 | pref |= PRE_67; 47 | break; 48 | default: 49 | goto pref_done; 50 | } 51 | pref_done: 52 | 53 | hs->flags = (uint32_t)pref << 23; 54 | 55 | if (!pref) 56 | pref |= PRE_NONE; 57 | 58 | if ((c & 0xf0) == 0x40) { 59 | hs->flags |= F_PREFIX_REX; 60 | hs->rex_w = (c & 0xf) >> 3; 61 | if (hs->rex_w && (*p & 0xf8) == 0xb8) 62 | op64++; 63 | hs->rex_r = (c & 7) >> 2; 64 | hs->rex_x = (c & 3) >> 1; 65 | hs->rex_b = c & 1; 66 | if (((c = *p++) & 0xf0) == 0x40) { 67 | opcode = c; 68 | goto error_opcode; 69 | } 70 | } 71 | 72 | if ((hs->opcode = c) == 0x0f) { 73 | hs->opcode2 = c = *p++; 74 | ht += DELTA_OPCODES; 75 | } else if (c >= 0xa0 && c <= 0xa3) { 76 | op64++; 77 | if (pref & PRE_67) 78 | pref |= PRE_66; 79 | else 80 | pref &= ~PRE_66; 81 | } 82 | 83 | opcode = c; 84 | cflags = ht[ht[opcode / 4] + (opcode % 4)]; 85 | 86 | if (cflags == C_ERROR) { 87 | error_opcode: 88 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 89 | cflags = 0; 90 | if ((opcode & -3) == 0x24) 91 | cflags++; 92 | } 93 | 94 | x = 0; 95 | if (cflags & C_GROUP) { 96 | uint16_t t; 97 | t = *(uint16_t *)(ht + (cflags & 0x7f)); 98 | cflags = (uint8_t)t; 99 | x = (uint8_t)(t >> 8); 100 | } 101 | 102 | if (hs->opcode2) { 103 | ht = hde64_table + DELTA_PREFIXES; 104 | if (ht[ht[opcode / 4] + (opcode % 4)] & pref) 105 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 106 | } 107 | 108 | if (cflags & C_MODRM) { 109 | hs->flags |= F_MODRM; 110 | hs->modrm = c = *p++; 111 | hs->modrm_mod = m_mod = c >> 6; 112 | hs->modrm_rm = m_rm = c & 7; 113 | hs->modrm_reg = m_reg = (c & 0x3f) >> 3; 114 | 115 | if (x && ((x << m_reg) & 0x80)) 116 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 117 | 118 | if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) { 119 | uint8_t t = opcode - 0xd9; 120 | if (m_mod == 3) { 121 | ht = hde64_table + DELTA_FPU_MODRM + t*8; 122 | t = ht[m_reg] << m_rm; 123 | } else { 124 | ht = hde64_table + DELTA_FPU_REG; 125 | t = ht[t] << m_reg; 126 | } 127 | if (t & 0x80) 128 | hs->flags |= F_ERROR | F_ERROR_OPCODE; 129 | } 130 | 131 | if (pref & PRE_LOCK) { 132 | if (m_mod == 3) { 133 | hs->flags |= F_ERROR | F_ERROR_LOCK; 134 | } else { 135 | uint8_t *table_end, op = opcode; 136 | if (hs->opcode2) { 137 | ht = hde64_table + DELTA_OP2_LOCK_OK; 138 | table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK; 139 | } else { 140 | ht = hde64_table + DELTA_OP_LOCK_OK; 141 | table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK; 142 | op &= -2; 143 | } 144 | for (; ht != table_end; ht++) 145 | if (*ht++ == op) { 146 | if (!((*ht << m_reg) & 0x80)) 147 | goto no_lock_error; 148 | else 149 | break; 150 | } 151 | hs->flags |= F_ERROR | F_ERROR_LOCK; 152 | no_lock_error: 153 | ; 154 | } 155 | } 156 | 157 | if (hs->opcode2) { 158 | switch (opcode) { 159 | case 0x20: case 0x22: 160 | m_mod = 3; 161 | if (m_reg > 4 || m_reg == 1) 162 | goto error_operand; 163 | else 164 | goto no_error_operand; 165 | case 0x21: case 0x23: 166 | m_mod = 3; 167 | if (m_reg == 4 || m_reg == 5) 168 | goto error_operand; 169 | else 170 | goto no_error_operand; 171 | } 172 | } else { 173 | switch (opcode) { 174 | case 0x8c: 175 | if (m_reg > 5) 176 | goto error_operand; 177 | else 178 | goto no_error_operand; 179 | case 0x8e: 180 | if (m_reg == 1 || m_reg > 5) 181 | goto error_operand; 182 | else 183 | goto no_error_operand; 184 | } 185 | } 186 | 187 | if (m_mod == 3) { 188 | uint8_t *table_end; 189 | if (hs->opcode2) { 190 | ht = hde64_table + DELTA_OP2_ONLY_MEM; 191 | table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM; 192 | } else { 193 | ht = hde64_table + DELTA_OP_ONLY_MEM; 194 | table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM; 195 | } 196 | for (; ht != table_end; ht += 2) 197 | if (*ht++ == opcode) { 198 | if (*ht++ & pref && !((*ht << m_reg) & 0x80)) 199 | goto error_operand; 200 | else 201 | break; 202 | } 203 | goto no_error_operand; 204 | } else if (hs->opcode2) { 205 | switch (opcode) { 206 | case 0x50: case 0xd7: case 0xf7: 207 | if (pref & (PRE_NONE | PRE_66)) 208 | goto error_operand; 209 | break; 210 | case 0xd6: 211 | if (pref & (PRE_F2 | PRE_F3)) 212 | goto error_operand; 213 | break; 214 | case 0xc5: 215 | goto error_operand; 216 | } 217 | goto no_error_operand; 218 | } else 219 | goto no_error_operand; 220 | 221 | error_operand: 222 | hs->flags |= F_ERROR | F_ERROR_OPERAND; 223 | no_error_operand: 224 | 225 | c = *p++; 226 | if (m_reg <= 1) { 227 | if (opcode == 0xf6) 228 | cflags |= C_IMM8; 229 | else if (opcode == 0xf7) 230 | cflags |= C_IMM_P66; 231 | } 232 | 233 | switch (m_mod) { 234 | case 0: 235 | if (pref & PRE_67) { 236 | if (m_rm == 6) 237 | disp_size = 2; 238 | } else 239 | if (m_rm == 5) 240 | disp_size = 4; 241 | break; 242 | case 1: 243 | disp_size = 1; 244 | break; 245 | case 2: 246 | disp_size = 2; 247 | if (!(pref & PRE_67)) 248 | disp_size <<= 1; 249 | } 250 | 251 | if (m_mod != 3 && m_rm == 4) { 252 | hs->flags |= F_SIB; 253 | p++; 254 | hs->sib = c; 255 | hs->sib_scale = c >> 6; 256 | hs->sib_index = (c & 0x3f) >> 3; 257 | if ((hs->sib_base = c & 7) == 5 && !(m_mod & 1)) 258 | disp_size = 4; 259 | } 260 | 261 | p--; 262 | switch (disp_size) { 263 | case 1: 264 | hs->flags |= F_DISP8; 265 | hs->disp.disp8 = *p; 266 | break; 267 | case 2: 268 | hs->flags |= F_DISP16; 269 | hs->disp.disp16 = *(uint16_t *)p; 270 | break; 271 | case 4: 272 | hs->flags |= F_DISP32; 273 | hs->disp.disp32 = *(uint32_t *)p; 274 | } 275 | p += disp_size; 276 | } else if (pref & PRE_LOCK) 277 | hs->flags |= F_ERROR | F_ERROR_LOCK; 278 | 279 | if (cflags & C_IMM_P66) { 280 | if (cflags & C_REL32) { 281 | if (pref & PRE_66) { 282 | hs->flags |= F_IMM16 | F_RELATIVE; 283 | hs->imm.imm16 = *(uint16_t *)p; 284 | p += 2; 285 | goto disasm_done; 286 | } 287 | goto rel32_ok; 288 | } 289 | if (op64) { 290 | hs->flags |= F_IMM64; 291 | hs->imm.imm64 = *(uint64_t *)p; 292 | p += 8; 293 | } else if (!(pref & PRE_66)) { 294 | hs->flags |= F_IMM32; 295 | hs->imm.imm32 = *(uint32_t *)p; 296 | p += 4; 297 | } else 298 | goto imm16_ok; 299 | } 300 | 301 | 302 | if (cflags & C_IMM16) { 303 | imm16_ok: 304 | hs->flags |= F_IMM16; 305 | hs->imm.imm16 = *(uint16_t *)p; 306 | p += 2; 307 | } 308 | if (cflags & C_IMM8) { 309 | hs->flags |= F_IMM8; 310 | hs->imm.imm8 = *p++; 311 | } 312 | 313 | if (cflags & C_REL32) { 314 | rel32_ok: 315 | hs->flags |= F_IMM32 | F_RELATIVE; 316 | hs->imm.imm32 = *(uint32_t *)p; 317 | p += 4; 318 | } else if (cflags & C_REL8) { 319 | hs->flags |= F_IMM8 | F_RELATIVE; 320 | hs->imm.imm8 = *p++; 321 | } 322 | 323 | disasm_done: 324 | 325 | if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) { 326 | hs->flags |= F_ERROR | F_ERROR_LENGTH; 327 | hs->len = 15; 328 | } 329 | 330 | return (unsigned int)hs->len; 331 | } 332 | -------------------------------------------------------------------------------- /KernelHack/hde/hde64.h: -------------------------------------------------------------------------------- 1 | #ifndef _HDE64_H_ 2 | #define _HDE64_H_ 3 | 4 | /* stdint.h - C99 standard header 5 | * http://en.wikipedia.org/wiki/stdint.h 6 | * 7 | * if your compiler doesn't contain "stdint.h" header (for 8 | * example, Microsoft Visual C++), you can download file: 9 | * http://www.azillionmonkeys.com/qed/pstdint.h 10 | * and change next line to: 11 | * #include "pstdint.h" 12 | */ 13 | #include "kstdint.h" 14 | 15 | #define F_MODRM 0x00000001 16 | #define F_SIB 0x00000002 17 | #define F_IMM8 0x00000004 18 | #define F_IMM16 0x00000008 19 | #define F_IMM32 0x00000010 20 | #define F_IMM64 0x00000020 21 | #define F_DISP8 0x00000040 22 | #define F_DISP16 0x00000080 23 | #define F_DISP32 0x00000100 24 | #define F_RELATIVE 0x00000200 25 | #define F_ERROR 0x00001000 26 | #define F_ERROR_OPCODE 0x00002000 27 | #define F_ERROR_LENGTH 0x00004000 28 | #define F_ERROR_LOCK 0x00008000 29 | #define F_ERROR_OPERAND 0x00010000 30 | #define F_PREFIX_REPNZ 0x01000000 31 | #define F_PREFIX_REPX 0x02000000 32 | #define F_PREFIX_REP 0x03000000 33 | #define F_PREFIX_66 0x04000000 34 | #define F_PREFIX_67 0x08000000 35 | #define F_PREFIX_LOCK 0x10000000 36 | #define F_PREFIX_SEG 0x20000000 37 | #define F_PREFIX_REX 0x40000000 38 | #define F_PREFIX_ANY 0x7f000000 39 | 40 | #define PREFIX_SEGMENT_CS 0x2e 41 | #define PREFIX_SEGMENT_SS 0x36 42 | #define PREFIX_SEGMENT_DS 0x3e 43 | #define PREFIX_SEGMENT_ES 0x26 44 | #define PREFIX_SEGMENT_FS 0x64 45 | #define PREFIX_SEGMENT_GS 0x65 46 | #define PREFIX_LOCK 0xf0 47 | #define PREFIX_REPNZ 0xf2 48 | #define PREFIX_REPX 0xf3 49 | #define PREFIX_OPERAND_SIZE 0x66 50 | #define PREFIX_ADDRESS_SIZE 0x67 51 | 52 | #pragma pack(push,1) 53 | 54 | typedef struct { 55 | uint8_t len; 56 | uint8_t p_rep; 57 | uint8_t p_lock; 58 | uint8_t p_seg; 59 | uint8_t p_66; 60 | uint8_t p_67; 61 | uint8_t rex; 62 | uint8_t rex_w; 63 | uint8_t rex_r; 64 | uint8_t rex_x; 65 | uint8_t rex_b; 66 | uint8_t opcode; 67 | uint8_t opcode2; 68 | uint8_t modrm; 69 | uint8_t modrm_mod; 70 | uint8_t modrm_reg; 71 | uint8_t modrm_rm; 72 | uint8_t sib; 73 | uint8_t sib_scale; 74 | uint8_t sib_index; 75 | uint8_t sib_base; 76 | union { 77 | uint8_t imm8; 78 | uint16_t imm16; 79 | uint32_t imm32; 80 | uint64_t imm64; 81 | } imm; 82 | union { 83 | uint8_t disp8; 84 | uint16_t disp16; 85 | uint32_t disp32; 86 | } disp; 87 | uint32_t flags; 88 | } hde64s; 89 | 90 | #pragma pack(pop) 91 | 92 | #ifdef __cplusplus 93 | extern "C" { 94 | #endif 95 | 96 | /* __cdecl */ 97 | unsigned int hde64_disasm(const void *code, hde64s *hs); 98 | 99 | #ifdef __cplusplus 100 | } 101 | #endif 102 | 103 | #endif /* _HDE64_H_ */ 104 | -------------------------------------------------------------------------------- /KernelHack/hde/kstdint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef _STDINT 3 | #define _STDINT 4 | 5 | typedef signed char int8_t; 6 | typedef short int16_t; 7 | typedef int int32_t; 8 | typedef long long int64_t; 9 | typedef unsigned char uint8_t; 10 | typedef unsigned short uint16_t; 11 | typedef unsigned int uint32_t; 12 | typedef unsigned long long uint64_t; 13 | 14 | typedef signed char int_least8_t; 15 | typedef short int_least16_t; 16 | typedef int int_least32_t; 17 | typedef long long int_least64_t; 18 | typedef unsigned char uint_least8_t; 19 | typedef unsigned short uint_least16_t; 20 | typedef unsigned int uint_least32_t; 21 | typedef unsigned long long uint_least64_t; 22 | 23 | typedef signed char int_fast8_t; 24 | typedef int int_fast16_t; 25 | typedef int int_fast32_t; 26 | typedef long long int_fast64_t; 27 | typedef unsigned char uint_fast8_t; 28 | typedef unsigned int uint_fast16_t; 29 | typedef unsigned int uint_fast32_t; 30 | typedef unsigned long long uint_fast64_t; 31 | 32 | typedef long long intmax_t; 33 | typedef unsigned long long uintmax_t; 34 | 35 | // These macros must exactly match those in the Windows SDK's intsafe.h. 36 | #define INT8_MIN (-127i8 - 1) 37 | #define INT16_MIN (-32767i16 - 1) 38 | #define INT32_MIN (-2147483647i32 - 1) 39 | #define INT64_MIN (-9223372036854775807i64 - 1) 40 | #define INT8_MAX 127i8 41 | #define INT16_MAX 32767i16 42 | #define INT32_MAX 2147483647i32 43 | #define INT64_MAX 9223372036854775807i64 44 | #define UINT8_MAX 0xffui8 45 | #define UINT16_MAX 0xffffui16 46 | #define UINT32_MAX 0xffffffffui32 47 | #define UINT64_MAX 0xffffffffffffffffui64 48 | 49 | #define INT_LEAST8_MIN INT8_MIN 50 | #define INT_LEAST16_MIN INT16_MIN 51 | #define INT_LEAST32_MIN INT32_MIN 52 | #define INT_LEAST64_MIN INT64_MIN 53 | #define INT_LEAST8_MAX INT8_MAX 54 | #define INT_LEAST16_MAX INT16_MAX 55 | #define INT_LEAST32_MAX INT32_MAX 56 | #define INT_LEAST64_MAX INT64_MAX 57 | #define UINT_LEAST8_MAX UINT8_MAX 58 | #define UINT_LEAST16_MAX UINT16_MAX 59 | #define UINT_LEAST32_MAX UINT32_MAX 60 | #define UINT_LEAST64_MAX UINT64_MAX 61 | 62 | #define INT_FAST8_MIN INT8_MIN 63 | #define INT_FAST16_MIN INT32_MIN 64 | #define INT_FAST32_MIN INT32_MIN 65 | #define INT_FAST64_MIN INT64_MIN 66 | #define INT_FAST8_MAX INT8_MAX 67 | #define INT_FAST16_MAX INT32_MAX 68 | #define INT_FAST32_MAX INT32_MAX 69 | #define INT_FAST64_MAX INT64_MAX 70 | #define UINT_FAST8_MAX UINT8_MAX 71 | #define UINT_FAST16_MAX UINT32_MAX 72 | #define UINT_FAST32_MAX UINT32_MAX 73 | #define UINT_FAST64_MAX UINT64_MAX 74 | 75 | #ifdef _WIN64 76 | #define INTPTR_MIN INT64_MIN 77 | #define INTPTR_MAX INT64_MAX 78 | #define UINTPTR_MAX UINT64_MAX 79 | #else 80 | #define INTPTR_MIN INT32_MIN 81 | #define INTPTR_MAX INT32_MAX 82 | #define UINTPTR_MAX UINT32_MAX 83 | #endif 84 | 85 | #define INTMAX_MIN INT64_MIN 86 | #define INTMAX_MAX INT64_MAX 87 | #define UINTMAX_MAX UINT64_MAX 88 | 89 | #define PTRDIFF_MIN INTPTR_MIN 90 | #define PTRDIFF_MAX INTPTR_MAX 91 | 92 | #ifndef SIZE_MAX 93 | // SIZE_MAX definition must match exactly with limits.h for modules support. 94 | #ifdef _WIN64 95 | #define SIZE_MAX 0xffffffffffffffffui64 96 | #else 97 | #define SIZE_MAX 0xffffffffui32 98 | #endif 99 | #endif 100 | 101 | #define SIG_ATOMIC_MIN INT32_MIN 102 | #define SIG_ATOMIC_MAX INT32_MAX 103 | 104 | #define WCHAR_MIN 0x0000 105 | #define WCHAR_MAX 0xffff 106 | 107 | #define WINT_MIN 0x0000 108 | #define WINT_MAX 0xffff 109 | 110 | #define INT8_C(x) (x) 111 | #define INT16_C(x) (x) 112 | #define INT32_C(x) (x) 113 | #define INT64_C(x) (x ## LL) 114 | 115 | #define UINT8_C(x) (x) 116 | #define UINT16_C(x) (x) 117 | #define UINT32_C(x) (x ## U) 118 | #define UINT64_C(x) (x ## ULL) 119 | 120 | #define INTMAX_C(x) INT64_C(x) 121 | #define UINTMAX_C(x) UINT64_C(x) 122 | 123 | #endif // #ifndef _STDINT 124 | -------------------------------------------------------------------------------- /KernelHack/hde/table32.h: -------------------------------------------------------------------------------- 1 | #define C_NONE 0x00 2 | #define C_MODRM 0x01 3 | #define C_IMM8 0x02 4 | #define C_IMM16 0x04 5 | #define C_IMM_P66 0x10 6 | #define C_REL8 0x20 7 | #define C_REL32 0x40 8 | #define C_GROUP 0x80 9 | #define C_ERROR 0xff 10 | 11 | #define PRE_ANY 0x00 12 | #define PRE_NONE 0x01 13 | #define PRE_F2 0x02 14 | #define PRE_F3 0x04 15 | #define PRE_66 0x08 16 | #define PRE_67 0x10 17 | #define PRE_LOCK 0x20 18 | #define PRE_SEG 0x40 19 | #define PRE_ALL 0xff 20 | 21 | #define DELTA_OPCODES 0x4a 22 | #define DELTA_FPU_REG 0xf1 23 | #define DELTA_FPU_MODRM 0xf8 24 | #define DELTA_PREFIXES 0x130 25 | #define DELTA_OP_LOCK_OK 0x1a1 26 | #define DELTA_OP2_LOCK_OK 0x1b9 27 | #define DELTA_OP_ONLY_MEM 0x1cb 28 | #define DELTA_OP2_ONLY_MEM 0x1da 29 | 30 | unsigned char hde32_table[] = { 31 | 0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3,0xa8,0xa3, 32 | 0xa8,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xac,0xaa,0xb2,0xaa,0x9f,0x9f, 33 | 0x9f,0x9f,0xb5,0xa3,0xa3,0xa4,0xaa,0xaa,0xba,0xaa,0x96,0xaa,0xa8,0xaa,0xc3, 34 | 0xc3,0x96,0x96,0xb7,0xae,0xd6,0xbd,0xa3,0xc5,0xa3,0xa3,0x9f,0xc3,0x9c,0xaa, 35 | 0xaa,0xac,0xaa,0xbf,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0x90, 36 | 0x82,0x7d,0x97,0x59,0x59,0x59,0x59,0x59,0x7f,0x59,0x59,0x60,0x7d,0x7f,0x7f, 37 | 0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x9a,0x88,0x7d, 38 | 0x59,0x50,0x50,0x50,0x50,0x59,0x59,0x59,0x59,0x61,0x94,0x61,0x9e,0x59,0x59, 39 | 0x85,0x59,0x92,0xa3,0x60,0x60,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59,0x59, 40 | 0x59,0x59,0x9f,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xcc,0x01,0xbc,0x03,0xf0, 41 | 0x10,0x10,0x10,0x10,0x50,0x50,0x50,0x50,0x14,0x20,0x20,0x20,0x20,0x01,0x01, 42 | 0x01,0x01,0xc4,0x02,0x10,0x00,0x00,0x00,0x00,0x01,0x01,0xc0,0xc2,0x10,0x11, 43 | 0x02,0x03,0x11,0x03,0x03,0x04,0x00,0x00,0x14,0x00,0x02,0x00,0x00,0xc6,0xc8, 44 | 0x02,0x02,0x02,0x02,0x00,0x00,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xca, 45 | 0x01,0x01,0x01,0x00,0x06,0x00,0x04,0x00,0xc0,0xc2,0x01,0x01,0x03,0x01,0xff, 46 | 0xff,0x01,0x00,0x03,0xc4,0xc4,0xc6,0x03,0x01,0x01,0x01,0xff,0x03,0x03,0x03, 47 | 0xc8,0x40,0x00,0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00, 48 | 0x00,0x00,0x00,0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00, 49 | 0x00,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 50 | 0x00,0xff,0xff,0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 51 | 0x7f,0x00,0x00,0xff,0x4a,0x4a,0x4a,0x4a,0x4b,0x52,0x4a,0x4a,0x4a,0x4a,0x4f, 52 | 0x4c,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x55,0x45,0x40,0x4a,0x4a,0x4a, 53 | 0x45,0x59,0x4d,0x46,0x4a,0x5d,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a,0x4a, 54 | 0x4a,0x4a,0x4a,0x4a,0x4a,0x61,0x63,0x67,0x4e,0x4a,0x4a,0x6b,0x6d,0x4a,0x4a, 55 | 0x45,0x6d,0x4a,0x4a,0x44,0x45,0x4a,0x4a,0x00,0x00,0x00,0x02,0x0d,0x06,0x06, 56 | 0x06,0x06,0x0e,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x00,0x06,0x06,0x02,0x06, 57 | 0x00,0x0a,0x0a,0x07,0x07,0x06,0x02,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04, 58 | 0x04,0x04,0x00,0x00,0x00,0x0e,0x05,0x06,0x06,0x06,0x01,0x06,0x00,0x00,0x08, 59 | 0x00,0x10,0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01, 60 | 0x86,0x00,0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba, 61 | 0xf8,0xbb,0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00, 62 | 0xc4,0xff,0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00, 63 | 0x13,0x09,0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07, 64 | 0xb2,0xff,0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf, 65 | 0xe7,0x08,0x00,0xf0,0x02,0x00 66 | }; 67 | -------------------------------------------------------------------------------- /KernelHack/hde/table64.h: -------------------------------------------------------------------------------- 1 | #define C_NONE 0x00 2 | #define C_MODRM 0x01 3 | #define C_IMM8 0x02 4 | #define C_IMM16 0x04 5 | #define C_IMM_P66 0x10 6 | #define C_REL8 0x20 7 | #define C_REL32 0x40 8 | #define C_GROUP 0x80 9 | #define C_ERROR 0xff 10 | 11 | #define PRE_ANY 0x00 12 | #define PRE_NONE 0x01 13 | #define PRE_F2 0x02 14 | #define PRE_F3 0x04 15 | #define PRE_66 0x08 16 | #define PRE_67 0x10 17 | #define PRE_LOCK 0x20 18 | #define PRE_SEG 0x40 19 | #define PRE_ALL 0xff 20 | 21 | #define DELTA_OPCODES 0x4a 22 | #define DELTA_FPU_REG 0xfd 23 | #define DELTA_FPU_MODRM 0x104 24 | #define DELTA_PREFIXES 0x13c 25 | #define DELTA_OP_LOCK_OK 0x1ae 26 | #define DELTA_OP2_LOCK_OK 0x1c6 27 | #define DELTA_OP_ONLY_MEM 0x1d8 28 | #define DELTA_OP2_ONLY_MEM 0x1e7 29 | 30 | unsigned char hde64_table[] = { 31 | 0xa5,0xaa,0xa5,0xb8,0xa5,0xaa,0xa5,0xaa,0xa5,0xb8,0xa5,0xb8,0xa5,0xb8,0xa5, 32 | 0xb8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xac,0xc0,0xcc,0xc0,0xa1,0xa1, 33 | 0xa1,0xa1,0xb1,0xa5,0xa5,0xa6,0xc0,0xc0,0xd7,0xda,0xe0,0xc0,0xe4,0xc0,0xea, 34 | 0xea,0xe0,0xe0,0x98,0xc8,0xee,0xf1,0xa5,0xd3,0xa5,0xa5,0xa1,0xea,0x9e,0xc0, 35 | 0xc0,0xc2,0xc0,0xe6,0x03,0x7f,0x11,0x7f,0x01,0x7f,0x01,0x3f,0x01,0x01,0xab, 36 | 0x8b,0x90,0x64,0x5b,0x5b,0x5b,0x5b,0x5b,0x92,0x5b,0x5b,0x76,0x90,0x92,0x92, 37 | 0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x6a,0x73,0x90, 38 | 0x5b,0x52,0x52,0x52,0x52,0x5b,0x5b,0x5b,0x5b,0x77,0x7c,0x77,0x85,0x5b,0x5b, 39 | 0x70,0x5b,0x7a,0xaf,0x76,0x76,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b,0x5b, 40 | 0x5b,0x5b,0x86,0x01,0x03,0x01,0x04,0x03,0xd5,0x03,0xd5,0x03,0xcc,0x01,0xbc, 41 | 0x03,0xf0,0x03,0x03,0x04,0x00,0x50,0x50,0x50,0x50,0xff,0x20,0x20,0x20,0x20, 42 | 0x01,0x01,0x01,0x01,0xc4,0x02,0x10,0xff,0xff,0xff,0x01,0x00,0x03,0x11,0xff, 43 | 0x03,0xc4,0xc6,0xc8,0x02,0x10,0x00,0xff,0xcc,0x01,0x01,0x01,0x00,0x00,0x00, 44 | 0x00,0x01,0x01,0x03,0x01,0xff,0xff,0xc0,0xc2,0x10,0x11,0x02,0x03,0x01,0x01, 45 | 0x01,0xff,0xff,0xff,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0xff,0xff,0x10, 46 | 0x10,0x10,0x10,0x02,0x10,0x00,0x00,0xc6,0xc8,0x02,0x02,0x02,0x02,0x06,0x00, 47 | 0x04,0x00,0x02,0xff,0x00,0xc0,0xc2,0x01,0x01,0x03,0x03,0x03,0xca,0x40,0x00, 48 | 0x0a,0x00,0x04,0x00,0x00,0x00,0x00,0x7f,0x00,0x33,0x01,0x00,0x00,0x00,0x00, 49 | 0x00,0x00,0xff,0xbf,0xff,0xff,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0xff,0x00, 50 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff, 51 | 0x00,0x00,0x00,0xbf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,0x00,0x00, 52 | 0xff,0x40,0x40,0x40,0x40,0x41,0x49,0x40,0x40,0x40,0x40,0x4c,0x42,0x40,0x40, 53 | 0x40,0x40,0x40,0x40,0x40,0x40,0x4f,0x44,0x53,0x40,0x40,0x40,0x44,0x57,0x43, 54 | 0x5c,0x40,0x60,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40, 55 | 0x40,0x40,0x64,0x66,0x6e,0x6b,0x40,0x40,0x6a,0x46,0x40,0x40,0x44,0x46,0x40, 56 | 0x40,0x5b,0x44,0x40,0x40,0x00,0x00,0x00,0x00,0x06,0x06,0x06,0x06,0x01,0x06, 57 | 0x06,0x02,0x06,0x06,0x00,0x06,0x00,0x0a,0x0a,0x00,0x00,0x00,0x02,0x07,0x07, 58 | 0x06,0x02,0x0d,0x06,0x06,0x06,0x0e,0x05,0x05,0x02,0x02,0x00,0x00,0x04,0x04, 59 | 0x04,0x04,0x05,0x06,0x06,0x06,0x00,0x00,0x00,0x0e,0x00,0x00,0x08,0x00,0x10, 60 | 0x00,0x18,0x00,0x20,0x00,0x28,0x00,0x30,0x00,0x80,0x01,0x82,0x01,0x86,0x00, 61 | 0xf6,0xcf,0xfe,0x3f,0xab,0x00,0xb0,0x00,0xb1,0x00,0xb3,0x00,0xba,0xf8,0xbb, 62 | 0x00,0xc0,0x00,0xc1,0x00,0xc7,0xbf,0x62,0xff,0x00,0x8d,0xff,0x00,0xc4,0xff, 63 | 0x00,0xc5,0xff,0x00,0xff,0xff,0xeb,0x01,0xff,0x0e,0x12,0x08,0x00,0x13,0x09, 64 | 0x00,0x16,0x08,0x00,0x17,0x09,0x00,0x2b,0x09,0x00,0xae,0xff,0x07,0xb2,0xff, 65 | 0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,0xe7,0x08, 66 | 0x00,0xf0,0x02,0x00 67 | }; 68 | -------------------------------------------------------------------------------- /KernelHack/skCrypter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /*____________________________________________________________________________________________________________ 4 | 5 | Original Author: skadro 6 | Github: https://github.com/skadro-official 7 | License: See end of file 8 | 9 | skCrypter 10 | Compile-time, Usermode + Kernelmode, safe and lightweight string crypter library for C++11+ 11 | 12 | *Not removing this part is appreciated* 13 | ____________________________________________________________________________________________________________*/ 14 | 15 | #ifdef _KERNEL_MODE 16 | namespace std 17 | { 18 | // STRUCT TEMPLATE remove_reference 19 | template 20 | struct remove_reference { 21 | using type = _Ty; 22 | }; 23 | 24 | template 25 | struct remove_reference<_Ty&> { 26 | using type = _Ty; 27 | }; 28 | 29 | template 30 | struct remove_reference<_Ty&&> { 31 | using type = _Ty; 32 | }; 33 | 34 | template 35 | using remove_reference_t = typename remove_reference<_Ty>::type; 36 | 37 | // STRUCT TEMPLATE remove_const 38 | template 39 | struct remove_const { // remove top-level const qualifier 40 | using type = _Ty; 41 | }; 42 | 43 | template 44 | struct remove_const { 45 | using type = _Ty; 46 | }; 47 | 48 | template 49 | using remove_const_t = typename remove_const<_Ty>::type; 50 | } 51 | #else 52 | #include 53 | #endif 54 | 55 | namespace skc 56 | { 57 | template 58 | using clean_type = typename std::remove_const_t>; 59 | 60 | template 61 | class skCrypter 62 | { 63 | public: 64 | __forceinline constexpr skCrypter(T* data) 65 | { 66 | crypt(data); 67 | } 68 | 69 | __forceinline T* get() 70 | { 71 | return _storage; 72 | } 73 | 74 | __forceinline int size() // (w)char count 75 | { 76 | return _size; 77 | } 78 | 79 | __forceinline char key() 80 | { 81 | return _key1; 82 | } 83 | 84 | __forceinline T* encrypt() 85 | { 86 | if (!isEncrypted()) 87 | crypt(_storage); 88 | 89 | return _storage; 90 | } 91 | 92 | __forceinline T* decrypt() 93 | { 94 | if (isEncrypted()) 95 | crypt(_storage); 96 | 97 | return _storage; 98 | } 99 | 100 | __forceinline bool isEncrypted() 101 | { 102 | return _storage[_size - 1] != 0; 103 | } 104 | 105 | __forceinline void clear() // set full storage to 0 106 | { 107 | for (int i = 0; i < _size; i++) 108 | { 109 | _storage[i] = 0; 110 | } 111 | } 112 | 113 | __forceinline operator T* () 114 | { 115 | decrypt(); 116 | 117 | return _storage; 118 | } 119 | 120 | private: 121 | __forceinline constexpr void crypt(T* data) 122 | { 123 | for (int i = 0; i < _size; i++) 124 | { 125 | _storage[i] = data[i] ^ (_key1 + i % (1 + _key2)); 126 | } 127 | } 128 | 129 | T _storage[_size]{}; 130 | }; 131 | } 132 | 133 | #define skCrypt(str) skCrypt_key(str, __TIME__[4], __TIME__[7]) 134 | #define skCrypt_key(str, key1, key2) []() { \ 135 | constexpr static auto crypted = skc::skCrypter \ 136 | >((skc::clean_type*)str); \ 137 | return crypted; }() 138 | 139 | /*________________________________________________________________________________ 140 | 141 | MIT License 142 | 143 | Copyright (c) 2020 skadro 144 | 145 | Permission is hereby granted, free of charge, to any person obtaining a copy 146 | of this software and associated documentation files (the "Software"), to deal 147 | in the Software without restriction, including without limitation the rights 148 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 149 | copies of the Software, and to permit persons to whom the Software is 150 | furnished to do so, subject to the following conditions: 151 | 152 | The above copyright notice and this permission notice shall be included in all 153 | copies or substantial portions of the Software. 154 | 155 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 156 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 157 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 158 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 159 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 160 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 161 | SOFTWARE. 162 | 163 | ________________________________________________________________________________*/ 164 | -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Callbacks.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Callbacks.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Comm.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Comm.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/I8042Interface.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/I8042Interface.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\callbacks.obj 2 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\comm.obj 3 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\entry.obj 4 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\hde32.obj 5 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\hde64.obj 6 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\i8042interface.obj 7 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\mapper.obj 8 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\memory.obj 9 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\offsets.obj 10 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\process.obj 11 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\vc143.pdb 12 | e:\project\codeproject\visualstudio\kernelhack\kernelhack\x64\debug\kernelhack.tlog\cl.command.1.tlog 13 | -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.log: -------------------------------------------------------------------------------- 1 |  Building 'KernelHack' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform. 2 | Callbacks.cpp 3 | Comm.cpp 4 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\CallStack-Spoofer.h(118,16): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 5 | entry.cpp 6 | 正在生成代码... 7 | 正在编译... 8 | hde32.c 9 | hde64.c 10 | 正在生成代码... 11 | 正在编译... 12 | I8042Interface.cpp 13 | Mapper.cpp 14 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Mapper.cpp(106,30): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 15 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Mapper.cpp(119,40): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 16 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Mapper.cpp(184,17): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 17 | Memory.cpp 18 | Offsets.cpp 19 | Process.cpp 20 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Process.cpp(404,17): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 21 | Utils.cpp 22 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(27,74): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 23 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(56,74): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 24 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(86,74): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 25 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(280,63): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 26 | 正在生成代码... 27 | KernelHack.vcxproj -> E:\Project\CodeProject\VisualStudio\KernelHack\x64\Debug\KernelHack.sys 28 | Inf2Cat task was skipped as there were no inf files to process 29 | 30 | -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.sys.recipe: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E:\Project\CodeProject\VisualStudio\KernelHack\x64\Debug\KernelHack.sys 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/CL.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/KernelHack.tlog/CL.command.1.tlog -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/CL.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/KernelHack.tlog/CL.read.1.tlog -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/CL.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/KernelHack.tlog/CL.write.1.tlog -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/KernelHack.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=WindowsKernelModeDriver10.0:VCToolArchitecture=Native64Bit:VCToolsVersion=14.35.32215:TargetPlatformVersion=10.0.22621.0:VcpkgTriplet=x64-windows: 2 | Debug|x64|E:\Project\CodeProject\VisualStudio\KernelHack\| 3 | -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/link.command.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/KernelHack.tlog/link.command.1.tlog -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/link.read.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/KernelHack.tlog/link.read.1.tlog -------------------------------------------------------------------------------- /KernelHack/x64/Debug/KernelHack.tlog/link.write.1.tlog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/KernelHack.tlog/link.write.1.tlog -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Mapper.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Mapper.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Memory.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Memory.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Offsets.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Offsets.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Process.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Process.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/Utils.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/Utils.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/entry.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/entry.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/hde32.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/hde32.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/hde64.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/hde64.obj -------------------------------------------------------------------------------- /KernelHack/x64/Debug/vc143.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/KernelHack/x64/Debug/vc143.pdb -------------------------------------------------------------------------------- /KernelHack/x64/Debug/vcpkg.applocal.log: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /KernelHack/x64/Release/KernelHack.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | e:\project\codeproject\visualstudio\kernelhack\x64\release\kernelhack.sys 2 | -------------------------------------------------------------------------------- /KernelHack/x64/Release/KernelHack.log: -------------------------------------------------------------------------------- 1 |  Building 'KernelHack' with toolset 'WindowsKernelModeDriver10.0' and the 'Desktop' target platform. 2 | Callbacks.cpp 3 | Comm.cpp 4 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\CallStack-Spoofer.h(118,16): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 5 | entry.cpp 6 | 正在生成代码... 7 | 正在编译... 8 | hde32.c 9 | hde64.c 10 | 正在生成代码... 11 | 正在编译... 12 | I8042Interface.cpp 13 | Mapper.cpp 14 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Mapper.cpp(106,30): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 15 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Mapper.cpp(119,40): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 16 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Mapper.cpp(184,17): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 17 | Memory.cpp 18 | Offsets.cpp 19 | Process.cpp 20 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Process.cpp(404,17): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 21 | Utils.cpp 22 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(27,74): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 23 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(56,74): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 24 | E:\Project\CodeProject\VisualStudio\KernelHack\KernelHack\Utils.cpp(86,74): warning C4996: 'ExAllocatePoolWithTag': ExAllocatePoolWithTag is deprecated, use ExAllocatePool2. 25 | 正在生成代码... 26 | KernelHack.vcxproj -> E:\Project\CodeProject\VisualStudio\KernelHack\x64\Release\KernelHack.sys 27 | Inf2Cat task was skipped as there were no inf files to process 28 | 29 | -------------------------------------------------------------------------------- /KernelHack/x64/Release/KernelHack.sys.recipe: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E:\Project\CodeProject\VisualStudio\KernelHack\x64\Release\KernelHack.sys 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /KernelHack/x64/Release/KernelHack.tlog/KernelHack.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=WindowsKernelModeDriver10.0:VCToolArchitecture=Native64Bit:VCToolsVersion=14.35.32215:TargetPlatformVersion=10.0.22621.0:VcpkgTriplet=x64-windows: 2 | Release|x64|E:\Project\CodeProject\VisualStudio\KernelHack\| 3 | -------------------------------------------------------------------------------- /KernelHack/x64/Release/vcpkg.applocal.log: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KernelHack 2 | ### This source code is copy and modify from other source code... 3 | 4 | 5 | # Credit 6 | HackerDisassemblerEngine 7 | 8 | https://github.com/DarthTon/Blackbone 9 | 10 | https://unknowncheats.me/ 11 | 12 | https://github.com/armvirus/CosMapper 13 | 14 | https://github.com/skadro-official/skCrypter 15 | 16 | https://github.com/Barracudach/CallStack-Spoofer 17 | 18 | etc. 19 | 20 | ### The above rankings are in no particular order 21 | 22 | 23 | # Notice 24 | ### This source code is full of bugs and most of functions only tested on Windows 10 x64 19044. 25 | ### Loading on other versions of the Windows operating system may trigger BSOD. 26 | -------------------------------------------------------------------------------- /Usermode/Debug/Usermode.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | e:\project\vsproject\kernelhack\usermode\debug\vc142.pdb 2 | e:\project\vsproject\kernelhack\usermode\debug\vc142.idb 3 | e:\project\vsproject\kernelhack\usermode\debug\umcomm.obj 4 | e:\project\vsproject\kernelhack\usermode\debug\main.obj 5 | e:\project\vsproject\kernelhack\usermode\debug\usermode.ilk 6 | e:\project\vsproject\kernelhack\debug\usermode.exe 7 | e:\project\vsproject\kernelhack\debug\usermode.pdb 8 | e:\project\vsproject\kernelhack\usermode\debug\usermode.tlog\cl.command.1.tlog 9 | e:\project\vsproject\kernelhack\usermode\debug\usermode.tlog\cl.read.1.tlog 10 | e:\project\vsproject\kernelhack\usermode\debug\usermode.tlog\cl.write.1.tlog 11 | e:\project\vsproject\kernelhack\usermode\debug\usermode.tlog\link.command.1.tlog 12 | e:\project\vsproject\kernelhack\usermode\debug\usermode.tlog\link.read.1.tlog 13 | e:\project\vsproject\kernelhack\usermode\debug\usermode.tlog\link.write.1.tlog 14 | -------------------------------------------------------------------------------- /Usermode/Debug/Usermode.exe.recipe: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E:\project\VSProject\KernelHack\Debug\Usermode.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Usermode/Debug/Usermode.log: -------------------------------------------------------------------------------- 1 |  UmComm.cpp 2 | Usermode.vcxproj -> E:\project\VSProject\KernelHack\Debug\Usermode.exe 3 | -------------------------------------------------------------------------------- /Usermode/Debug/Usermode.tlog/Usermode.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:TargetPlatformVersion=10.0.19041.0: 2 | Debug|Win32|E:\project\VSProject\KernelHack\| 3 | -------------------------------------------------------------------------------- /Usermode/Debug/Usermode.vcxproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/Usermode/Debug/Usermode.vcxproj.FileListAbsolute.txt -------------------------------------------------------------------------------- /Usermode/Debug/vcpkg.applocal.log: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /Usermode/UmComm.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | MIT 10 | 11 | --*/ 12 | #pragma once 13 | #include "UmComm.h" 14 | 15 | namespace Comm { 16 | namespace DeviceIoControl { 17 | HANDLE hDevice; 18 | } 19 | namespace RegistryCallback { 20 | UNICODE_STRING SubKeyName; 21 | UNICODE_STRING ValueName; 22 | OBJECT_ATTRIBUTES ObjectAttributes; 23 | } 24 | namespace HijackIrp { 25 | HANDLE hDevice; 26 | } 27 | } 28 | 29 | bool Comm::DeviceIoControl::Initialize() 30 | { 31 | hDevice = CreateFile("\\\\.\\DeviceI0C0ntr0l", GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 32 | if (hDevice == INVALID_HANDLE_VALUE) { 33 | return false; 34 | } 35 | return true; 36 | } 37 | 38 | void Comm::DeviceIoControl::Request(PREQUEST req) 39 | { 40 | ULONG retLen; 41 | ::DeviceIoControl(hDevice, 0x9909099, &req, sizeof(req), NULL, 0, &retLen, NULL); 42 | } 43 | 44 | #ifndef _WIN64 45 | void Comm::BonudCallback::Request(PREQUEST req) 46 | { 47 | __asm { 48 | mov eax, req 49 | bound di, dword ptr[ebp] 50 | } 51 | } 52 | #endif 53 | 54 | bool Comm::RegistryCallback::Initialize() { 55 | HMODULE hNtdll = GetModuleHandle("ntdll.dll"); 56 | if (!hNtdll) { 57 | return false; 58 | } 59 | RtlInitUnicodeString(&SubKeyName, L"\\registry\\machine\\Software\\Policies\\Microsoft\\Windows\\Safer\\CodeIdentifiers"); 60 | RtlInitUnicodeString(&ValueName, L"P4ssw0rd"); 61 | InitializeObjectAttributes(&ObjectAttributes, &SubKeyName, OBJ_CASE_INSENSITIVE, NULL, NULL); 62 | return true; 63 | } 64 | 65 | void Comm::RegistryCallback::Request(PREQUEST req) 66 | { 67 | NTSTATUS status = 0; 68 | HANDLE KeyHandle; 69 | 70 | status = NtOpenKey(&KeyHandle, KEY_SET_VALUE, &ObjectAttributes); 71 | if (NT_SUCCESS(status)) { 72 | NtSetValueKey(KeyHandle, &ValueName, 0, REG_QWORD, &req, sizeof uintptr_t); 73 | NtClose(KeyHandle); 74 | } 75 | } 76 | 77 | bool Comm::HijackIrp::Initialize() 78 | { 79 | hDevice = CreateFile("\\\\.\\PciControl", GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 80 | if (hDevice == INVALID_HANDLE_VALUE) { 81 | return false; 82 | } 83 | return true; 84 | } 85 | 86 | void Comm::HijackIrp::Request(PREQUEST req) 87 | { 88 | ULONG retLen; 89 | ::DeviceIoControl(hDevice, 0x9909099, &req, sizeof(req), NULL, 0, &retLen, NULL); 90 | } 91 | 92 | -------------------------------------------------------------------------------- /Usermode/UmComm.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | MIT 10 | 11 | --*/ 12 | #include 13 | #include "ntdll.h" 14 | 15 | namespace Comm 16 | { 17 | enum OPERATION 18 | { 19 | ReadMem = 0x801, 20 | WriteMem, 21 | AllocMem, 22 | ProtectMem, 23 | ModuleBase, 24 | CodeInject, 25 | DllInject, 26 | }; 27 | 28 | #pragma pack(8) 29 | typedef struct _REQUEST { 30 | ULONG Operation; 31 | PVOID Instruction; 32 | } REQUEST, * PREQUEST; 33 | 34 | typedef struct _COPY_MEMORY { 35 | ULONG ProcessId; 36 | PVOID Destination; 37 | PVOID Source; 38 | SIZE_T Size; 39 | } COPY_MEMORY, * PCOPY_MEMORY; 40 | 41 | typedef struct _ALLOC_MEMORY { 42 | ULONG ProcessId; 43 | PVOID Base; 44 | SIZE_T Size; 45 | } ALLOC_MEMORY, * PALLOC_MEMORY; 46 | 47 | typedef struct _MODULE_BASE { 48 | ULONG ProcessId; 49 | LPCSTR ModuleName; 50 | PVOID PBase; 51 | } MODULE_BASE, * PMODULE_BASE; 52 | 53 | typedef struct _CODE_INJECT { 54 | ULONG ProcessId; 55 | PBYTE Shellcode; 56 | SIZE_T Size; 57 | } CODE_INJECT, * PCODE_INJECT; 58 | 59 | typedef struct _DLL_INJECT { 60 | ULONG ProcessId; 61 | LPCSTR DllPath; 62 | } DLL_INJECT, * PDLL_INJECT; 63 | #pragma pack() 64 | 65 | namespace DeviceIoControl 66 | { 67 | bool Initialize(); 68 | void Request(PREQUEST req); 69 | } 70 | 71 | namespace BoundCallback 72 | { 73 | void Request(PREQUEST req); 74 | } 75 | 76 | namespace RegistryCallback 77 | { 78 | bool Initialize(); 79 | void Request(PREQUEST req); 80 | } 81 | 82 | namespace HijackIrp 83 | { 84 | bool Initialize(); 85 | void Request(PREQUEST req); 86 | } 87 | } -------------------------------------------------------------------------------- /Usermode/Usermode.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {a6f58eee-0e0d-4a80-9355-e446107ccc4d} 25 | Usermode 26 | 10.0 27 | 28 | 29 | 30 | Application 31 | true 32 | v143 33 | MultiByte 34 | 35 | 36 | Application 37 | false 38 | v143 39 | true 40 | MultiByte 41 | 42 | 43 | Application 44 | true 45 | v143 46 | MultiByte 47 | 48 | 49 | Application 50 | false 51 | v143 52 | true 53 | MultiByte 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | true 82 | 83 | 84 | false 85 | 86 | 87 | 88 | Level3 89 | true 90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_LEAN_AND_MEAN 91 | true 92 | MultiThreadedDebug 93 | 94 | 95 | Console 96 | true 97 | RequireAdministrator 98 | 99 | 100 | 101 | 102 | Level3 103 | true 104 | true 105 | true 106 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_LEAN_AND_MEAN 107 | true 108 | MultiThreaded 109 | 110 | 111 | Console 112 | true 113 | true 114 | true 115 | RequireAdministrator 116 | 117 | 118 | 119 | 120 | Level3 121 | true 122 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_LEAN_AND_MEAN 123 | true 124 | MultiThreadedDebug 125 | 126 | 127 | Console 128 | true 129 | RequireAdministrator 130 | 131 | 132 | 133 | 134 | Level3 135 | true 136 | true 137 | true 138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_LEAN_AND_MEAN 139 | true 140 | MultiThreaded 141 | 142 | 143 | Console 144 | true 145 | true 146 | true 147 | RequireAdministrator 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /Usermode/Usermode.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 10 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 11 | 12 | 13 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 14 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | UmComm 23 | 24 | 25 | 26 | 27 | UmComm 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /Usermode/Usermode.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | WindowsLocalDebugger 5 | 6 | -------------------------------------------------------------------------------- /Usermode/Utils.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | MIT 10 | 11 | --*/ 12 | #pragma once 13 | #include 14 | #include 15 | 16 | DWORD GetProcessIdByProcessName(const CHAR ProcessName[MAX_PATH]) 17 | { 18 | HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 19 | if (hProcessSnap == INVALID_HANDLE_VALUE) 20 | { 21 | return FALSE; 22 | } 23 | PROCESSENTRY32 pe32; 24 | ZeroMemory(&pe32, sizeof(pe32)); 25 | pe32.dwSize = sizeof(pe32); 26 | if (!Process32First(hProcessSnap, &pe32)) 27 | { 28 | CloseHandle(hProcessSnap); 29 | return FALSE; 30 | } 31 | do { 32 | if (!strcmp(pe32.szExeFile, ProcessName)) 33 | { 34 | return pe32.th32ProcessID; 35 | } 36 | } while (Process32Next(hProcessSnap, &pe32)); 37 | return FALSE; 38 | } -------------------------------------------------------------------------------- /Usermode/main.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Copyright (c) 2020-2025, Rog. All rights reserved. 4 | 5 | Author: 6 | Rog 7 | 8 | License: 9 | MIT 10 | 11 | --*/ 12 | #include 13 | #include 14 | #include "UmComm.h" 15 | #include "Utils.h" 16 | 17 | void test_get_module_base(int pid) 18 | { 19 | Comm::MODULE_BASE Data = { 0 }; 20 | Comm::REQUEST req = { 0 }; 21 | uintptr_t Base; 22 | 23 | Data.ProcessId = pid; 24 | Data.ModuleName = "RainbowSix.exe"; 25 | Data.PBase = &Base; 26 | 27 | req.Operation = Comm::ModuleBase; 28 | req.Instruction = &Data; 29 | 30 | Comm::RegistryCallback::Request(&req); 31 | 32 | printf("Buffer = %llX\n", Base); 33 | } 34 | 35 | void test_read_memory() 36 | { 37 | Comm::COPY_MEMORY Data = { 0 }; 38 | Comm::REQUEST req = { 0 }; 39 | 40 | ULONG64 Buffer = 0; 41 | 42 | Data.ProcessId = 4904; 43 | Data.Source = (PVOID)0x210C176F6B0; 44 | Data.Destination = &Buffer; 45 | Data.Size = sizeof(Buffer); 46 | 47 | req.Operation = Comm::ReadMem; 48 | req.Instruction = &Data; 49 | 50 | [&]()->void { 51 | SIZE_T number = 1000000; 52 | ULONG64 now = GetTickCount64(); 53 | for (SIZE_T i = 0; i < number; i++) { 54 | //Comm::RegistryCallback::Request(&req); 55 | Comm::HijackIrp::Request(&req); 56 | //Comm::DeviceIoControl::Request(&req); 57 | } 58 | printf("Read %lld times cost = %lfs\n", 59 | number, 60 | (double)(GetTickCount64() - now) / 1000); 61 | }(); 62 | 63 | printf("Buffer = %llX\n", Buffer); 64 | } 65 | 66 | void test_code_inject() 67 | { 68 | Comm::CODE_INJECT Data = { 0 }; 69 | Comm::REQUEST req = { 0 }; 70 | req.Operation = Comm::CodeInject; 71 | req.Instruction = &Data; 72 | 73 | BYTE Shellcode[] = { 74 | 0x50,0x51,0x52,0x53, //push rax,rcx,rdx,rbx 75 | 0x6A,0xFF, //Dummy for rsp 76 | 0x55,0x56,0x57, //push rbp,rsi,rdi 77 | 0x41,0x50,0x41,0x51,0x41,0x52,0x41,0x53,0x41,0x54,0x41,0x55,0x41,0x56,0x41,0x57, 78 | 79 | 0xB9,0x00,0x00,0x00,0x00, //mov ecx, 0 80 | 0xBA,0x00,0x00,0x00,0x00, //mov edx, 0 81 | 0x41,0xB8,0x00,0x00,0x00,0x00, //mov r8d, 0 82 | 0x41,0xB9,0x01,0x00,0x00,0x00, //mov r9d, 1 83 | 0x48,0xB8,0x10,0xAC,0x1C,0x9E,0xFA,0x7F,0x00,0x00, //mov rax, 84 | 0xFF,0xD0, //call rax 85 | 86 | 0x41,0x5F,0x41,0x5E,0x41,0x5D,0x41,0x5C,0x41,0x5B,0x41,0x5A,0x41,0x59,0x41,0x58, 87 | 0x5F,0x5E,0x5D,0x5B,0x5B,0x5A,0x59,0x58, //pop rdi,rsi,rbp,rbx,rbx,rdx,rcx,rax 88 | 0xC3 //ret 89 | }; 90 | 91 | HMODULE user32 = LoadLibrary("user32.dll"); 92 | if (!user32) return; 93 | *(PULONG64)(Shellcode + 49) = (ULONG64)GetProcAddress(user32, "MessageBoxA"); 94 | 95 | //Data.ProcessId = GetProcessIdByProcessName("notepad.exe"); 96 | Data.ProcessId = GetProcessIdByProcessName("Ke64v1.4.exe"); 97 | Data.Shellcode = Shellcode; 98 | Data.Size = sizeof(Shellcode); 99 | 100 | Comm::RegistryCallback::Request(&req); 101 | } 102 | 103 | int main(void) 104 | { 105 | //Comm::RegistryCallback::Initialize(); 106 | Comm::HijackIrp::Initialize(); 107 | //Comm::DeviceIoControl::Initialize(); 108 | //test_get_module_base(GetProcessIdByProcessName("RainbowSix.exe")); 109 | test_read_memory(); 110 | //test_code_inject(); 111 | 112 | getchar(); 113 | return 0; 114 | } 115 | -------------------------------------------------------------------------------- /Usermode/x64/Debug/CodeAnalysisResultManifest.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/Usermode/x64/Debug/CodeAnalysisResultManifest.txt -------------------------------------------------------------------------------- /Usermode/x64/Debug/Usermode.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\vc143.pdb 2 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\vc143.idb 3 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\umcomm.obj 4 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\main.obj 5 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.ilk 6 | e:\project\codeproject\visualstudio\kernelhack\x64\debug\usermode.exe 7 | e:\project\codeproject\visualstudio\kernelhack\x64\debug\usermode.pdb 8 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.tlog\cl.command.1.tlog 9 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.tlog\cl.read.1.tlog 10 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.tlog\cl.write.1.tlog 11 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.tlog\link.command.1.tlog 12 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.tlog\link.read.1.tlog 13 | e:\project\codeproject\visualstudio\kernelhack\usermode\x64\debug\usermode.tlog\link.write.1.tlog 14 | -------------------------------------------------------------------------------- /Usermode/x64/Debug/Usermode.exe.recipe: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E:\Project\CodeProject\VisualStudio\KernelHack\x64\Debug\Usermode.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Usermode/x64/Debug/Usermode.log: -------------------------------------------------------------------------------- 1 |  main.cpp 2 | UmComm.cpp 3 | 正在生成代码... 4 | Usermode.vcxproj -> E:\Project\CodeProject\VisualStudio\KernelHack\x64\Debug\Usermode.exe 5 | -------------------------------------------------------------------------------- /Usermode/x64/Debug/Usermode.tlog/Usermode.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.35.32215:TargetPlatformVersion=10.0.22621.0:VcpkgTriplet=x64-windows: 2 | Debug|x64|E:\Project\CodeProject\VisualStudio\KernelHack\| 3 | -------------------------------------------------------------------------------- /Usermode/x64/Debug/Usermode.vcxproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/Usermode/x64/Debug/Usermode.vcxproj.FileListAbsolute.txt -------------------------------------------------------------------------------- /Usermode/x64/Debug/vcpkg.applocal.log: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /Usermode/x64/Release/Usermode.Build.CppClean.log: -------------------------------------------------------------------------------- 1 | e:\project\vsproject\kernelhack\usermode\x64\release\vc142.pdb 2 | e:\project\vsproject\kernelhack\usermode\x64\release\umcomm.obj 3 | e:\project\vsproject\kernelhack\usermode\x64\release\main.obj 4 | e:\project\vsproject\kernelhack\x64\release\usermode.exe 5 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.ipdb 6 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.iobj 7 | e:\project\vsproject\kernelhack\x64\release\usermode.pdb 8 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.tlog\cl.command.1.tlog 9 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.tlog\cl.read.1.tlog 10 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.tlog\cl.write.1.tlog 11 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.tlog\link.command.1.tlog 12 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.tlog\link.read.1.tlog 13 | e:\project\vsproject\kernelhack\usermode\x64\release\usermode.tlog\link.write.1.tlog 14 | -------------------------------------------------------------------------------- /Usermode/x64/Release/Usermode.exe.recipe: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | E:\project\VSProject\KernelHack\x64\Release\Usermode.exe 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Usermode/x64/Release/Usermode.log: -------------------------------------------------------------------------------- 1 |  main.cpp 2 | UmComm.cpp 3 | 正在生成代码 4 | Previous IPDB not found, fall back to full compilation. 5 | All 9 functions were compiled because no usable IPDB/IOBJ from previous compilation was found. 6 | 已完成代码的生成 7 | Usermode.vcxproj -> E:\project\VSProject\KernelHack\x64\Release\Usermode.exe 8 | -------------------------------------------------------------------------------- /Usermode/x64/Release/Usermode.tlog/Usermode.lastbuildstate: -------------------------------------------------------------------------------- 1 | PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:VCServicingVersionMFC=14.29.30136:TargetPlatformVersion=10.0.19041.0: 2 | Release|x64|E:\project\VSProject\KernelHack\| 3 | -------------------------------------------------------------------------------- /Usermode/x64/Release/Usermode.vcxproj.FileListAbsolute.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/Usermode/x64/Release/Usermode.vcxproj.FileListAbsolute.txt -------------------------------------------------------------------------------- /install.bat: -------------------------------------------------------------------------------- 1 | copy "%~dp0KernelHack.sys" "C:\KernelHack.sys" 2 | sc create KernelHack binPath= "\??\c:\KernelHack.sys" type= "kernel" start= "demand" 3 | sc start KernelHack 4 | sc delete KernelHack 5 | -------------------------------------------------------------------------------- /x64/Debug/KernelHack.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Debug/KernelHack.pdb -------------------------------------------------------------------------------- /x64/Debug/KernelHack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Debug/KernelHack.sys -------------------------------------------------------------------------------- /x64/Debug/KernelHack/KernelHack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Debug/KernelHack/KernelHack.sys -------------------------------------------------------------------------------- /x64/Debug/Msgbox.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Debug/Msgbox.dll -------------------------------------------------------------------------------- /x64/Debug/Usermode.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Debug/Usermode.exe -------------------------------------------------------------------------------- /x64/Debug/getmemory.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Debug/getmemory.exe -------------------------------------------------------------------------------- /x64/Release/KernelHack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Release/KernelHack.sys -------------------------------------------------------------------------------- /x64/Release/KernelHack/KernelHack.sys: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Release/KernelHack/KernelHack.sys -------------------------------------------------------------------------------- /x64/Release/Usermode.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rogxo/KernelHack/835786642dea53296dff52c096ea9abce1e28e9a/x64/Release/Usermode.exe --------------------------------------------------------------------------------