π Cpatch NoDelay
I made this tutorial so i desided to share something i learn ^^
Credits to my partner @kevin..
CPatch.h
CPatch.cpp
stdafx.h
stdafx.cpp
targetver.h
Main.cpp
Credits to my partner @kevin..
CPatch.h
Code:
#include "stdafx.h" /*stdafx is where we have our defualt headers, if you don't have or use stdafx then add you includes: #include <headers> here*/ #pragma once class cPatch { private: DWORD ADR; BYTE OFF_BYTES[255]; BYTE ON_BYTES[255]; int SIZE; enum PATCHSTATUS { NORMAL, PATCHED, }; int STATUS; void* memcpy_s(void* pvAddress, const void* pvBuffer, size_t stLen); public: cPatch(DWORD pAdr,BYTE* pByte,int pSize); void Patch(); void Restore(); };
CPatch.cpp
Code:
#include "CPatch.h" void* cPatch::memcpy_s(void *pvAddress, const void *pvBuffer, size_t stLen) { MEMORY_BASIC_INFORMATION mbi; VirtualQuery( ( void* )pvAddress, &mbi, sizeof( mbi ) ); VirtualProtect( mbi.BaseAddress, mbi.RegionSize, PAGE_EXECUTE_READWRITE, &mbi.Protect ); void* pvRetn = memcpy( ( void* )pvAddress, ( void* )pvBuffer, stLen ); VirtualProtect( mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &mbi.Protect ); FlushInstructionCache( GetCurrentProcess( ), ( void* )pvAddress, stLen ); return pvRetn; } cPatch::cPatch(DWORD pAdr,BYTE* pByte,int pSize) { STATUS = NORMAL; SIZE = pSize; ADR = pAdr; for(int i = 0; i < pSize; i++) { OFF_BYTES[i] = 0x00; ON_BYTES[i] = pByte[i]; } } void cPatch::Patch() { if( STATUS==NORMAL ) { BYTE *pOFF_BYTES = (BYTE*)ADR; for( int i = 0; i < SIZE; i++ ) { OFF_BYTES[i] = pOFF_BYTES[i]; } memcpy_s((void*)ADR,(const void*)ON_BYTES,SIZE); STATUS=PATCHED; } } void cPatch::Restore() { if(STATUS==PATCHED) { memcpy_s((void*)ADR,(const void*)OFF_BYTES,SIZE); STATUS=NORMAL; } }
stdafx.h
Code:
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> // TODO: reference additional headers your program requires here
stdafx.cpp
Code:
// stdafx.cpp : source file that includes just the standard includes // arttest.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
targetver.h
Code:
#pragma once // Including SDKDDKVer.h defines the highest available Windows platform. // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. #include <SDKDDKVer.h>
Main.cpp
Code:
#include "stdafx.h
"#include <windows.h>
#include "CPatch.h"
#define ADR_Playerpointer 0x00
#define ADR_Serverpointer 0x00
#define ADR_NoDelay 0x00
BYTE NOP[8] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
cPatch cNodelay(ADR_NoDelay, NOP, 2);
DWORD *ongame = (DWORD*)ADR_Playerpointer;
DWORD *outgame = (DWORD*)ADR_Serverpointer;
void NoDelay()
{
if (GetAsyncKeyState(VK_LBUTTON))
{
cNodelay.Patch();
}
else
{
cNodelay.Restore();
}
}
void HackThread()
{
for (;;)
{
if (*ongame)
{
NoDelay()
}
if (*outgame)
{
}
Sleep(200);
}
}
BOOL __stdcall DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
MessageBoxA(NULL, " Coderz ", "Made By", MB_OK);
}
return TRUE;
}

