├── hookloader.sln ├── hookloader ├── hookloader.vcxproj ├── hookloader.vcxproj.filters ├── hookloader.vcxproj.user └── main.cpp └── test ├── dllmain.cpp ├── test.vcxproj ├── test.vcxproj.filters └── test.vcxproj.user /hookloader.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2036 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hookloader", "hookloader\hookloader.vcxproj", "{A7564738-5C68-4C53-98CD-AD75171C3BD6}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcxproj", "{6526AB07-6ABE-4F7B-9C9B-2F512A61D232}" 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 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Debug|x64.ActiveCfg = Debug|x64 19 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Debug|x64.Build.0 = Debug|x64 20 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Debug|x86.ActiveCfg = Debug|Win32 21 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Debug|x86.Build.0 = Debug|Win32 22 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Release|x64.ActiveCfg = Release|x64 23 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Release|x64.Build.0 = Release|x64 24 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Release|x86.ActiveCfg = Release|Win32 25 | {A7564738-5C68-4C53-98CD-AD75171C3BD6}.Release|x86.Build.0 = Release|Win32 26 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Debug|x64.ActiveCfg = Debug|x64 27 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Debug|x64.Build.0 = Debug|x64 28 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Debug|x86.ActiveCfg = Debug|Win32 29 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Debug|x86.Build.0 = Debug|Win32 30 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Release|x64.ActiveCfg = Release|x64 31 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Release|x64.Build.0 = Release|x64 32 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Release|x86.ActiveCfg = Release|Win32 33 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {930116A9-2169-4338-B8D3-A8BD13BB9EAC} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /hookloader/hookloader.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 | 23 | 24 | 25 | 15.0 26 | {a7564738-5c68-4c53-98cd-ad75171c3bd6} 27 | Win32Proj 28 | hookloader 29 | 10.0 30 | 31 | 32 | 33 | Application 34 | true 35 | v142 36 | Unicode 37 | 38 | 39 | Application 40 | false 41 | v142 42 | true 43 | Unicode 44 | 45 | 46 | Application 47 | true 48 | v142 49 | Unicode 50 | 51 | 52 | Application 53 | false 54 | v142 55 | true 56 | Unicode 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | true 78 | $(SolutionDir)x86\dbg\bin\ 79 | $(SolutionDir)x86\dbg\tmp\ 80 | 81 | 82 | true 83 | $(SolutionDir)x64\dbg\bin\ 84 | $(SolutionDir)x64\dbg\tmp\ 85 | 86 | 87 | false 88 | $(SolutionDir)x86\release\bin\ 89 | $(SolutionDir)x86\release\tmp\ 90 | 91 | 92 | false 93 | $(SolutionDir)x64\release\bin\ 94 | $(SolutionDir)x64\release\tmp\ 95 | 96 | 97 | 98 | NotUsing 99 | Level3 100 | Disabled 101 | true 102 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 103 | true 104 | 105 | 106 | 107 | Console 108 | true 109 | 110 | 111 | 112 | 113 | NotUsing 114 | Level3 115 | Disabled 116 | true 117 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 118 | true 119 | 120 | 121 | 122 | Console 123 | true 124 | 125 | 126 | 127 | 128 | NotUsing 129 | Level3 130 | MaxSpeed 131 | true 132 | true 133 | true 134 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | 139 | Console 140 | true 141 | true 142 | true 143 | 144 | 145 | 146 | 147 | NotUsing 148 | Level3 149 | MaxSpeed 150 | true 151 | true 152 | true 153 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 154 | true 155 | 156 | 157 | 158 | Console 159 | true 160 | true 161 | true 162 | 163 | 164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /hookloader/hookloader.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 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /hookloader/hookloader.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /hookloader/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) { 7 | wchar_t* dllPath = argv[1]; 8 | 9 | if (GetFileAttributes(dllPath) == INVALID_FILE_ATTRIBUTES) { 10 | cout << "[ FAILED ] DLL file does not exist." << endl; 11 | system("pause"); 12 | return EXIT_FAILURE; 13 | } 14 | 15 | HWND hwnd = FindWindowW(L"UnrealWindow", NULL); //Game window classname 16 | if (hwnd == NULL) { 17 | cout << "[ FAILED ] Could not find target window." << endl; 18 | system("pause"); 19 | return EXIT_FAILURE; 20 | } 21 | 22 | // Getting the thread of the window and the PID 23 | DWORD pid = NULL; 24 | DWORD tid = GetWindowThreadProcessId(hwnd, &pid); 25 | if (tid == NULL) { 26 | cout << "[ FAILED ] Could not get thread ID of the target window." << endl; 27 | system("pause"); 28 | return EXIT_FAILURE; 29 | } 30 | 31 | // Loading DLL 32 | HMODULE dll = LoadLibraryEx(dllPath, NULL, DONT_RESOLVE_DLL_REFERENCES); //Loading dll from params 33 | if (dll == NULL) { 34 | cout << "[ FAILED ] The DLL could not be found." << endl; 35 | system("pause"); 36 | return EXIT_FAILURE; 37 | } 38 | 39 | // Getting exported function address 40 | HOOKPROC addr = (HOOKPROC)GetProcAddress(dll, "NextHook"); //export see dllmain.cpp "C" __declspec(dllexport) int NextHook(int code, WPARAM wParam, LPARAM lParam) 41 | if (addr == NULL) { 42 | cout << "[ FAILED ] The function was not found." << endl; 43 | system("pause"); 44 | return EXIT_FAILURE; 45 | } 46 | 47 | // Setting the hook in the hook chain 48 | HHOOK handle = SetWindowsHookEx(WH_GETMESSAGE, addr, dll, tid); // Or WH_KEYBOARD if you prefer to trigger the hook manually 49 | if (handle == NULL) { 50 | cout << "[ FAILED ] Couldn't set the hook with SetWindowsHookEx." << endl; 51 | system("pause"); 52 | return EXIT_FAILURE; 53 | } 54 | 55 | // Triggering the hook 56 | PostThreadMessage(tid, WM_NULL, NULL, NULL); 57 | 58 | // Waiting for user input to remove the hook 59 | cout << "[ OK ] Hook set and triggered." << endl; 60 | cout << "[ >> ] Press any key to unhook (This will unload the DLL)." << endl; 61 | system("pause > nul"); 62 | 63 | // Unhooking 64 | BOOL unhook = UnhookWindowsHookEx(handle); 65 | if (unhook == FALSE) { 66 | cout << "[ FAILED ] Could not remove the hook." << endl; 67 | system("pause"); 68 | return EXIT_FAILURE; 69 | } 70 | 71 | cout << "[ OK ] Done. Press any key to exit." << endl; 72 | system("pause > nul"); 73 | return EXIT_SUCCESS; 74 | } 75 | -------------------------------------------------------------------------------- /test/dllmain.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cMiraka/SetWindowsHookEx-Injector/3b4228c45f77a9255caa34020c7f8d9b02943a23/test/dllmain.cpp -------------------------------------------------------------------------------- /test/test.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 | 15.0 23 | {6526AB07-6ABE-4F7B-9C9B-2F512A61D232} 24 | Win32Proj 25 | test 26 | 10.0 27 | test 28 | 29 | 30 | 31 | DynamicLibrary 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | DynamicLibrary 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | DynamicLibrary 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | DynamicLibrary 51 | false 52 | v142 53 | true 54 | NotSet 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | false 76 | $(SolutionDir)x64\release\bin\ 77 | $(SolutionDir)x64\release\bin\ 78 | 79 | 80 | true 81 | $(SolutionDir)x86\dbg\bin\ 82 | $(SolutionDir)x86\dbg\tmp\ 83 | 84 | 85 | true 86 | $(SolutionDir)x64\dbg\bin\ 87 | $(SolutionDir)x64\dbg\tmp\ 88 | 89 | 90 | false 91 | $(SolutionDir)x86\release\bin\ 92 | $(SolutionDir)x86\release\tmp\ 93 | 94 | 95 | 96 | NotUsing 97 | Level3 98 | MaxSpeed 99 | true 100 | true 101 | true 102 | NDEBUG;TEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 103 | true 104 | 105 | 106 | 107 | Windows 108 | true 109 | true 110 | true 111 | 112 | 113 | 114 | 115 | NotUsing 116 | Level3 117 | Disabled 118 | true 119 | WIN32;_DEBUG;TEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 120 | true 121 | 122 | 123 | 124 | Windows 125 | true 126 | 127 | 128 | 129 | 130 | NotUsing 131 | Level3 132 | Disabled 133 | true 134 | _DEBUG;TEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 135 | true 136 | 137 | 138 | 139 | Windows 140 | true 141 | 142 | 143 | 144 | 145 | NotUsing 146 | Level3 147 | MaxSpeed 148 | true 149 | true 150 | true 151 | WIN32;NDEBUG;TEST_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) 152 | true 153 | 154 | 155 | 156 | Windows 157 | true 158 | true 159 | true 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | -------------------------------------------------------------------------------- /test/test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 6 | h;hh;hpp;hxx;hm;inl;inc;xsd 7 | 8 | 9 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 10 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 11 | 12 | 13 | 14 | 15 | Header Files\Source Files 16 | 17 | 18 | -------------------------------------------------------------------------------- /test/test.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | --------------------------------------------------------------------------------