Dinput8.dll kullanarak tuş gönderme
1 2 3 4 5 |
void HookDInput(void); DWORD FindDInputKeyPtr(void); DWORD FindModule(LPTSTR pModuleName); void SendDInputKeys(DWORD DIKey); void SendZKey(void); |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
#include "stdafx.h" #include "Dinput.h" #include <TlHelp32.h> DWORD DInputMod; DWORD DINPUT_K_1; DWORD DINPUT_K_2; DWORD DINPUT_K_3; DWORD DINPUT_K_4; DWORD DINPUT_K_5; DWORD DINPUT_K_6; DWORD DINPUT_K_7; DWORD DINPUT_K_8; DWORD DINPUT_K_TAB; DWORD DINPUT_K_Q; DWORD DINPUT_K_W; DWORD DINPUT_K_E; DWORD DINPUT_K_R; DWORD DINPUT_K_T; DWORD DINPUT_K_Y; DWORD DINPUT_K_U; DWORD DINPUT_K_I; DWORD DINPUT_K_O; DWORD DINPUT_K_P; DWORD DINPUT_K_A; DWORD DINPUT_K_S; DWORD DINPUT_K_D; DWORD DINPUT_K_F; DWORD DINPUT_K_G; DWORD DINPUT_K_H; DWORD DINPUT_K_J; DWORD DINPUT_K_K; DWORD DINPUT_K_L; DWORD DINPUT_K_Z; DWORD DINPUT_K_X; DWORD DINPUT_K_C; DWORD DINPUT_K_V; DWORD DINPUT_K_B; DWORD DINPUT_K_N; DWORD DINPUT_K_M; DWORD DINPUT_K_F1; DWORD DINPUT_K_F2; DWORD DINPUT_K_F3; DWORD DINPUT_K_F4; DWORD DINPUT_K_F5; DWORD DINPUT_K_F6; DWORD DINPUT_K_F7; DWORD DINPUT_K_F8; BYTE MemReadByte(DWORD paddy) { BYTE retval; __asm { mov ebx,[paddy] xor eax,eax mov al,BYTE PTR DS:[ebx] mov retval,al } return retval; } void MemWriteByte(DWORD paddy, BYTE pval){__asm { mov ebx, paddy xor eax, eax mov al, pval mov BYTE PTR DS : [ebx], al }}; DWORD MemReadDWord(DWORD paddy) { DWORD retval; __asm { mov ebx,[paddy] xor eax,eax mov eax,DWORD PTR DS:[ebx] mov retval,eax } return retval; }; DWORD FindModule(char *pModuleName) { HANDLE hSnapshot; BOOL ret; MODULEENTRY32 lpme; lpme.dwSize = sizeof(MODULEENTRY32); hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0); ret = Module32First(hSnapshot, &lpme); while (ret) { ret = Module32Next(hSnapshot, &lpme); if (lstrcmpi(lpme.szModule, pModuleName) == 0) { return (DWORD)lpme.hModule; break; } } return 0; } void HookDInput() { DWORD DIKeyPtr; DInputMod = FindModule("dinput8.dll"); if (DInputMod == 0) { MessageBoxA(0, "DInput8 not loaded!", "", 0); TerminateProcess(GetCurrentProcess(), 0); } DIKeyPtr = FindDInputKeyPtr(); if (DIKeyPtr != 0) { DINPUT_K_1 = DIKeyPtr + 2; DINPUT_K_2 = DIKeyPtr + 3; DINPUT_K_3 = DIKeyPtr + 4; DINPUT_K_4 = DIKeyPtr + 5; DINPUT_K_5 = DIKeyPtr + 6; DINPUT_K_6 = DIKeyPtr + 7; DINPUT_K_7 = DIKeyPtr + 8; DINPUT_K_8 = DIKeyPtr + 9; DINPUT_K_TAB = DIKeyPtr + 15; DINPUT_K_Q = DIKeyPtr + 16; DINPUT_K_W = DIKeyPtr + 17; DINPUT_K_E = DIKeyPtr + 18; DINPUT_K_R = DIKeyPtr + 19; DINPUT_K_T = DIKeyPtr + 20; DINPUT_K_Y = DIKeyPtr + 21; DINPUT_K_U = DIKeyPtr + 22; DINPUT_K_I = DIKeyPtr + 23; DINPUT_K_O = DIKeyPtr + 24; DINPUT_K_P = DIKeyPtr + 25; DINPUT_K_A = DIKeyPtr + 30; DINPUT_K_S = DIKeyPtr + 31; DINPUT_K_D = DIKeyPtr + 32; DINPUT_K_F = DIKeyPtr + 33; DINPUT_K_G = DIKeyPtr + 34; DINPUT_K_H = DIKeyPtr + 35; DINPUT_K_J = DIKeyPtr + 36; DINPUT_K_K = DIKeyPtr + 37; DINPUT_K_L = DIKeyPtr + 38; DINPUT_K_Z = DIKeyPtr + 44; DINPUT_K_X = DIKeyPtr + 45; DINPUT_K_C = DIKeyPtr + 46; DINPUT_K_V = DIKeyPtr + 47; DINPUT_K_B = DIKeyPtr + 48; DINPUT_K_N = DIKeyPtr + 49; DINPUT_K_M = DIKeyPtr + 50; DINPUT_K_F1 = DIKeyPtr + 59; DINPUT_K_F2 = DIKeyPtr + 60; DINPUT_K_F3 = DIKeyPtr + 61; DINPUT_K_F4 = DIKeyPtr + 62; DINPUT_K_F5 = DIKeyPtr + 63; DINPUT_K_F6 = DIKeyPtr + 64; DINPUT_K_F7 = DIKeyPtr + 65; DINPUT_K_F8 = DIKeyPtr + 66; } } DWORD FindDInputKeyPtr() { DWORD i; DWORD retd; retd = 0; for (i = (DInputMod); i <= (DInputMod + 0x3a0000); i++) { if (MemReadByte(i) == 0x57 && MemReadByte(i + 1) == 0x6a && MemReadByte(i + 2) == 0x40 && MemReadByte(i + 3) == 0x33 && MemReadByte(i + 4) == 0xc0 && MemReadByte(i + 5) == 0x59 && MemReadByte(i + 6) == 0xbf) { retd = MemReadDWord(i + 7); break; } } return (DWORD)retd; } void SendDInputKeys(DWORD DIKey) { DWORD pSleepTime; pSleepTime = 50; MemWriteByte(DIKey, 128); Sleep(pSleepTime); MemWriteByte(DIKey, 0); } void SendZKey() { SendDInputKeys(DINPUT_K_Z); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
#include "stdafx.h" #include "Dinput.h" void d8hookthread() { while (1) { if (GetAsyncKeyState(VK_F11)) { SendZKey(); } Sleep(100); } } BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: HookDInput(); CreateThread(0, 0, (LPTHREAD_START_ROUTINE)d8hookthr ead, 0, 0, 0); } } |