Guest User

Untitled

a guest
Jun 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.87 KB | None | 0 0
  1. #include <windows.h>
  2. #include <stdio.h>
  3. #include <strsafe.h>
  4. #include <tlhelp32.h>
  5.  
  6. DWORD PlayerNoKBAddress = 0x00850CF2;
  7. DWORD PlayerNoKBRet = 0x00850CFA;
  8.  
  9. DWORD MissGmodeAddress = 0x008500A5;
  10. DWORD MissGmodeRet = 0x008500AB;
  11. DWORD MissGmodeOpcode = 0x00850CF2;
  12. int MissRound = 0;
  13.  
  14. void __cdecl DebugPrintA(__in_z __format_string LPCSTR lpcszFormat, ...)
  15. {
  16. va_list pArguments;
  17. char szDebugBuffer[1024];
  18. va_start(pArguments, lpcszFormat);
  19. if (SUCCEEDED(StringCchVPrintfA(szDebugBuffer, _countof(szDebugBuffer), lpcszFormat, pArguments)))
  20. OutputDebugStringA(szDebugBuffer);
  21. va_end(pArguments);
  22. }
  23.  
  24. __declspec(naked) void Do7Miss()
  25. {
  26. __asm{
  27. inc [MissRound]
  28. cmp [MissRound], 7 // NUMBER OF MISS
  29. ja StopMiss
  30. xor eax,eax
  31. jmp dword ptr ds:[MissGmodeOpcode] //main address opcode
  32.  
  33. StopMiss:
  34. mov [MissRound], 0
  35. jmp dword ptr ds:[MissGmodeRet]//bottom address
  36. }
  37. }
  38.  
  39. __declspec(naked) void DoNoKB()
  40. {
  41. __asm{
  42. pushad
  43. mov [ebp+c],0
  44. mov [ebp+10],0
  45. popad
  46. jmp dword ptr ds:[PlayerNoKBRet]
  47. }
  48. }
  49.  
  50.  
  51. BOOL WINAPI EnableHax()
  52. {
  53. DEBUG_EVENT DebugEvent;
  54. HANDLE hThread;
  55. CONTEXT Context;
  56. for(;;) {
  57. WaitForDebugEvent(&DebugEvent, INFINITE);
  58. switch(DebugEvent.dwDebugEventCode) {
  59. case EXCEPTION_DEBUG_EVENT:
  60. if(DebugEvent.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_SINGLE_STEP ){//EXCEPTION_BREAKPOINT) {
  61. if(DebugEvent.u.Exception.ExceptionRecord.ExceptionAddress == PlayerNoKBAddress) {
  62. if(hThread = OpenThread(THREAD_ALL_ACCESS, false, DebugEvent.dwThreadId)) {
  63. DebugPrintA("NoKB Exception caught on thread %04X", DebugEvent.dwThreadId);
  64. SuspendThread(hThread);
  65. Context.ContextFlags = CONTEXT_FULL;
  66. GetThreadContext(hThread, &Context);
  67. Context.Eip = (DWORD)&DoNoKB;
  68. SetThreadContext(hThread, &Context);
  69. ResumeThread(hThread);
  70. CloseHandle(hThread);
  71. }
  72. }
  73. else if(DebugEvent.u.Exception.ExceptionRecord.ExceptionAddress == MissGmodeAddress){
  74. if(hThread = OpenThread(THREAD_ALL_ACCESS, false, DebugEvent.dwThreadId)) {
  75. DebugPrintA("Godmode Exception caught on thread %04X", DebugEvent.dwThreadId);
  76. SuspendThread(hThread);
  77. Context.ContextFlags = CONTEXT_FULL;
  78. GetThreadContext(hThread, &Context);
  79. Context.Eip = (DWORD)&Do7Miss;
  80. SetThreadContext(hThread, &Context);
  81. ResumeThread(hThread);
  82. CloseHandle(hThread);
  83. }
  84. }
  85.  
  86. }
  87. ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, DBG_CONTINUE);
  88. break;
  89. default:
  90. ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
  91. }
  92. }
  93. }
  94.  
  95. BOOL WINAPI SetDRs()
  96. {
  97. while (TRUE){
  98. HANDLE hSnapshot;
  99. THREADENTRY32 Te32;
  100. Te32.dwSize = sizeof(THREADENTRY32);
  101.  
  102. hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, GetCurrentProcessId())
  103. if (hSnapshot != INVALID_HANDLE_VALUE)
  104. {
  105. if (Thread32First(hSnapshot, &Te32))
  106. {
  107. do
  108. {
  109. if (Te32.th32OwnerProcessID == GetCurrentProcessId())
  110. {
  111. CONTEXT Context;
  112. Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;
  113. HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, Te32.th32ThreadID);
  114. GetThreadContext(hThread, &Context);
  115. Context.Dr0 = PlayerNoKBAddress;
  116. Context.Dr1 = MissGmodeAddress;
  117. Context.Dr7 |= 1;
  118. SetThreadContext(hThread, &Context);
  119. //DebugPrintA("Set Context on Thread->%04X", Te32.th32ThreadID);
  120. }
  121. } while (Thread32Next(hSnapshot, &Te32));
  122. }
  123. }
  124. }
  125. }
  126.  
  127. BOOL APIENTRY DllMain(__in HMODULE hInsDll, __in DWORD fwdReason, __reserved void* lpReserved)
  128. {
  129. switch (fwdReason)
  130. {
  131. case DLL_PROCESS_ATTACH:
  132. DisableThreadLibraryCalls(hInsDll);
  133. CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)SetDRs, NULL, 0, NULL);
  134. CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)EnableHax, NULL, 0, NULL);
  135. break;
  136.  
  137. }
  138. return TRUE;
  139. }
Add Comment
Please, Sign In to add comment