Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- #include <strsafe.h>
- #include <tlhelp32.h>
- DWORD PlayerNoKBAddress = 0x00850CF2;
- DWORD PlayerNoKBRet = 0x00850CFA;
- DWORD MissGmodeAddress = 0x008500A5;
- DWORD MissGmodeRet = 0x008500AB;
- DWORD MissGmodeOpcode = 0x00850CF2;
- int MissRound = 0;
- void __cdecl DebugPrintA(__in_z __format_string LPCSTR lpcszFormat, ...)
- {
- va_list pArguments;
- char szDebugBuffer[1024];
- va_start(pArguments, lpcszFormat);
- if (SUCCEEDED(StringCchVPrintfA(szDebugBuffer, _countof(szDebugBuffer), lpcszFormat, pArguments)))
- OutputDebugStringA(szDebugBuffer);
- va_end(pArguments);
- }
- __declspec(naked) void Do7Miss()
- {
- __asm{
- inc [MissRound]
- cmp [MissRound], 7 // NUMBER OF MISS
- ja StopMiss
- xor eax,eax
- jmp dword ptr ds:[MissGmodeOpcode] //main address opcode
- StopMiss:
- mov [MissRound], 0
- jmp dword ptr ds:[MissGmodeRet]//bottom address
- }
- }
- __declspec(naked) void DoNoKB()
- {
- __asm{
- pushad
- mov [ebp+c],0
- mov [ebp+10],0
- popad
- jmp dword ptr ds:[PlayerNoKBRet]
- }
- }
- BOOL WINAPI EnableHax()
- {
- DEBUG_EVENT DebugEvent;
- HANDLE hThread;
- CONTEXT Context;
- for(;;) {
- WaitForDebugEvent(&DebugEvent, INFINITE);
- switch(DebugEvent.dwDebugEventCode) {
- case EXCEPTION_DEBUG_EVENT:
- if(DebugEvent.u.Exception.ExceptionRecord.ExceptionCode == EXCEPTION_SINGLE_STEP ){//EXCEPTION_BREAKPOINT) {
- if(DebugEvent.u.Exception.ExceptionRecord.ExceptionAddress == PlayerNoKBAddress) {
- if(hThread = OpenThread(THREAD_ALL_ACCESS, false, DebugEvent.dwThreadId)) {
- DebugPrintA("NoKB Exception caught on thread %04X", DebugEvent.dwThreadId);
- SuspendThread(hThread);
- Context.ContextFlags = CONTEXT_FULL;
- GetThreadContext(hThread, &Context);
- Context.Eip = (DWORD)&DoNoKB;
- SetThreadContext(hThread, &Context);
- ResumeThread(hThread);
- CloseHandle(hThread);
- }
- }
- else if(DebugEvent.u.Exception.ExceptionRecord.ExceptionAddress == MissGmodeAddress){
- if(hThread = OpenThread(THREAD_ALL_ACCESS, false, DebugEvent.dwThreadId)) {
- DebugPrintA("Godmode Exception caught on thread %04X", DebugEvent.dwThreadId);
- SuspendThread(hThread);
- Context.ContextFlags = CONTEXT_FULL;
- GetThreadContext(hThread, &Context);
- Context.Eip = (DWORD)&Do7Miss;
- SetThreadContext(hThread, &Context);
- ResumeThread(hThread);
- CloseHandle(hThread);
- }
- }
- }
- ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, DBG_CONTINUE);
- break;
- default:
- ContinueDebugEvent(DebugEvent.dwProcessId, DebugEvent.dwThreadId, DBG_EXCEPTION_NOT_HANDLED);
- }
- }
- }
- BOOL WINAPI SetDRs()
- {
- while (TRUE){
- HANDLE hSnapshot;
- THREADENTRY32 Te32;
- Te32.dwSize = sizeof(THREADENTRY32);
- hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, GetCurrentProcessId())
- if (hSnapshot != INVALID_HANDLE_VALUE)
- {
- if (Thread32First(hSnapshot, &Te32))
- {
- do
- {
- if (Te32.th32OwnerProcessID == GetCurrentProcessId())
- {
- CONTEXT Context;
- Context.ContextFlags = CONTEXT_DEBUG_REGISTERS;
- HANDLE hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, Te32.th32ThreadID);
- GetThreadContext(hThread, &Context);
- Context.Dr0 = PlayerNoKBAddress;
- Context.Dr1 = MissGmodeAddress;
- Context.Dr7 |= 1;
- SetThreadContext(hThread, &Context);
- //DebugPrintA("Set Context on Thread->%04X", Te32.th32ThreadID);
- }
- } while (Thread32Next(hSnapshot, &Te32));
- }
- }
- }
- }
- BOOL APIENTRY DllMain(__in HMODULE hInsDll, __in DWORD fwdReason, __reserved void* lpReserved)
- {
- switch (fwdReason)
- {
- case DLL_PROCESS_ATTACH:
- DisableThreadLibraryCalls(hInsDll);
- CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)SetDRs, NULL, 0, NULL);
- CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)EnableHax, NULL, 0, NULL);
- break;
- }
- return TRUE;
- }
Add Comment
Please, Sign In to add comment