@@ -35,17 +35,10 @@ float m_flMouseSampleTime;
35
35
36
36
void Error (char * text)
37
37
{
38
- MessageBox (0 , text, " ERROR" , 16 );
38
+ MessageBoxA (0 , text, " ERROR" , 16 );
39
39
ExitProcess (0 );
40
40
}
41
41
42
- void UpdateConsole ()
43
- {
44
- system (" cls" );
45
- printf (" Set \" m_rawinput 2\" in game for it to take effect.\n " );
46
- printf (" Use DELETE button to unhook and shutdown RawInput2.\n " );
47
- }
48
-
49
42
bool GetRawMouseAccumulators (int & accumX, int & accumY, double frame_split)
50
43
{
51
44
static int * m_mouseRawAccumX = (int *)((uintptr_t )g_InputSystem + 0x119C );
@@ -203,7 +196,15 @@ void __fastcall Hooked_IN_SetSampleTime(void* thisptr, void* edx, float frametim
203
196
oIn_SetSampleTime (thisptr, frametime);
204
197
}
205
198
206
- DWORD InjectionEntryPoint ()
199
+ BOOL IsProcessRunning (DWORD processID)
200
+ {
201
+ HANDLE process = OpenProcess (SYNCHRONIZE, FALSE , processID);
202
+ DWORD ret = WaitForSingleObject (process, 0 );
203
+ CloseHandle (process);
204
+ return ret == WAIT_TIMEOUT;
205
+ }
206
+
207
+ DWORD InjectionEntryPoint (DWORD processID)
207
208
{
208
209
LoadLibraryA (" VCRUNTIME140.dll" );
209
210
@@ -221,7 +222,7 @@ DWORD InjectionEntryPoint()
221
222
ConMsg = (ConMsgFn)(uintptr_t )GetProcAddress ((HMODULE)tier, " ?ConMsg@@YAXPBDZZ" );
222
223
Plat_FloatTime = (Plat_FloatTimeFn)(uintptr_t )GetProcAddress ((HMODULE)tier, " Plat_FloatTime" );
223
224
224
- // ConMsg("Plat_FloatTime: %.5f\n", plat_floattime ());
225
+ // ConMsg("Plat_FloatTime: %.5f\n", Plat_FloatTime ());
225
226
226
227
DetourTransactionBegin ();
227
228
DetourUpdateThread (GetCurrentThread ());
@@ -232,9 +233,10 @@ DWORD InjectionEntryPoint()
232
233
DetourAttach (&(PVOID&)oIn_SetSampleTime, Hooked_IN_SetSampleTime);
233
234
DetourTransactionCommit ();
234
235
235
- while (!(GetAsyncKeyState (VK_DELETE) & 0x8000 ))
236
+ while (IsProcessRunning (processID))
237
+ // while(FindWindowA(NULL, "CS:S RawInput2") != 0)
236
238
{
237
- Sleep (100 );
239
+ Sleep (1000 );
238
240
}
239
241
240
242
DetourTransactionBegin ();
@@ -251,7 +253,7 @@ DWORD InjectionEntryPoint()
251
253
}
252
254
253
255
// Credits: https://www.ired.team/offensive-security/code-injection-process-injection/pe-injection-executing-pes-inside-remote-processes
254
- void PEInjector (DWORD processID, DWORD Func ())
256
+ void PEInjector (DWORD processID, DWORD Func (DWORD ))
255
257
{
256
258
// Get current image's base address
257
259
PVOID imageBase = GetModuleHandle (NULL );
@@ -297,7 +299,7 @@ void PEInjector(DWORD processID, DWORD Func())
297
299
WriteProcessMemory (targetProcess, targetImage, localImage, ntHeader->OptionalHeader .SizeOfImage , NULL );
298
300
299
301
// Start the injected PE inside the target process
300
- CreateRemoteThread (targetProcess, NULL , 0 , (LPTHREAD_START_ROUTINE)((DWORD_PTR)Func + deltaImageBase), NULL , 0 , NULL );
302
+ CreateRemoteThread (targetProcess, NULL , 0 , (LPTHREAD_START_ROUTINE)((DWORD_PTR)Func + deltaImageBase), (LPVOID) GetCurrentProcessId () , 0 , NULL );
301
303
}
302
304
303
305
// Сredits: https://github.com/alkatrazbhop/BunnyhopAPE
@@ -333,10 +335,12 @@ int main()
333
335
if (!strstr (cmdLine, " -insecure" ))
334
336
Error (" -insecure key is missing!" );
335
337
336
- UpdateConsole ();
338
+ system (" cls" );
339
+ printf (" Set \" m_rawinput 2\" in game for it to take effect.\n " );
337
340
338
341
PEInjector (processID, InjectionEntryPoint);
339
342
340
- while (!(GetAsyncKeyState (VK_DELETE) & 0x8000 )) {}
343
+
344
+ while (_getch () != VK_RETURN) {}
341
345
return false ;
342
346
}
0 commit comments