[CoD4] COPY PASTE INSIDE K?

Posts 111 of 11 · Page 1 of 1
[CoD4] COPY PASTE INSIDE K?
Bored, have fun
Did not test the toggles ingame yet, they worked fine before I added toggles.
I know GetAsyncKeyState is not the way to go, its just a quick edit of this old code(that me and couch made when 1.7 patch was first released)

dectected

main.cpp:
Code:
#include <windows.h>
#include "patch.h"

bool bWallHack=false;
bool bNoRecoil=false;
bool bXHair=false;
bool bNameTags=false;

unsigned char *playerFlag = (unsigned char*)0x00445480;
unsigned char xwallhackpatch[2] = { 0x6a, 0x12 }; // push 12, patched
unsigned char owallhackpatch[2];// copy unpatched

unsigned long *fireRecoil = (unsigned long*)0x00457D2E;
unsigned char oRecoilPatch[5];

unsigned long *xHair = (unsigned long*)0x00430B50;
unsigned char oXHairPatch[10];

unsigned long *xTeamcheck = (unsigned long*)0x0042E1AC; //Orig 0x0F 0x85 0xCE 0x00 0x00 0x00
unsigned long *xVisible = (unsigned long*)0x0042E1CE; //Orig 0x74 0x25
unsigned char oTeamCheckPatch[6] = { 0x0F, 0x85, 0xCE, 0x00, 0x00, 0x00 };
unsigned char oVisiblePatch[2] = { 0x74, 0x25 };

void doWallhack(void)
{
	unsigned long orig;
	if(bWallHack==false)
	{
		VirtualProtect(playerFlag, sizeof(xwallhackpatch), PAGE_EXECUTE_READWRITE, &orig);
		memcpy(playerFlag, &xwallhackpatch, sizeof(xwallhackpatch));
		VirtualProtect(playerFlag, sizeof(xwallhackpatch), orig, &orig);
		bWallHack=true;
	}
	else
	{
		VirtualProtect(playerFlag, sizeof(owallhackpatch), PAGE_EXECUTE_READWRITE, &orig);
		memcpy(playerFlag, &owallhackpatch, sizeof(owallhackpatch));
		VirtualProtect(playerFlag, sizeof(owallhackpatch), orig, &orig);
		bWallHack=false;
	}
}

// recoil offset + patch

void doNoRecoil(void)
{
	unsigned long orig;
	if(bNoRecoil==false)
	{
		writeNOP(fireRecoil, 5);
		bNoRecoil=true;
	}
	else
	{
		VirtualProtect(fireRecoil, sizeof(oRecoilPatch), PAGE_EXECUTE_READWRITE, &orig);
		memcpy(fireRecoil, &oRecoilPatch, sizeof(oRecoilPatch));
		VirtualProtect(fireRecoil, sizeof(oRecoilPatch), orig, &orig);
		bNoRecoil=false;
	}
}

// xhair offset + patch

void doXHair(void)
{
	unsigned long orig;
	if(bXHair==false)
	{
		writeNOP(xHair, 10); // nop padding to prevent overwriting bytes
		changeBYTEPTR(0xB8, xHair); //mov eax,
		changeDWORDPTR(0x1, (unsigned long*)(xHair + 1)); // 1
		changeBYTEPTR(0xC3, (unsigned long*)(xHair + 6)); //ret
		bXHair=true;
	}
	else
	{
		VirtualProtect(xHair, sizeof(oXHairPatch), PAGE_EXECUTE_READWRITE, &orig);
		memcpy(xHair, &oXHairPatch, sizeof(oXHairPatch));
		VirtualProtect(xHair, sizeof(oXHairPatch), orig, &orig);
		bXHair=false;
	}
}

void doNametags(void)
{
	unsigned long orig;
	if(bNameTags==false)
	{
		writeNOP(xTeamcheck, 6);
		writeNOP(xVisible, 2);
		bNameTags=true;
	}
	else
	{
		VirtualProtect(xTeamcheck, sizeof(oTeamCheckPatch), PAGE_EXECUTE_READWRITE, &orig);
		memcpy(xTeamcheck, &oTeamCheckPatch, sizeof(oTeamCheckPatch));
		VirtualProtect(xTeamcheck, sizeof(oTeamCheckPatch), orig, &orig);
		VirtualProtect(xVisible, sizeof(oVisiblePatch), PAGE_EXECUTE_READWRITE, &orig);
		memcpy(xVisible, &oVisiblePatch, sizeof(oVisiblePatch));
		VirtualProtect(xVisible, sizeof(oVisiblePatch), orig, &orig);
		bNameTags=false;
	}
}

void InitBackups(void)
{
	unsigned long orig;
	VirtualProtect(playerFlag, sizeof(owallhackpatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(owallhackpatch, playerFlag, sizeof(owallhackpatch));
	VirtualProtect(playerFlag, sizeof(owallhackpatch), orig, &orig);

	VirtualProtect(fireRecoil, sizeof(oRecoilPatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(oRecoilPatch, fireRecoil, sizeof(oRecoilPatch));
	VirtualProtect(fireRecoil, sizeof(oRecoilPatch), orig, &orig);

	VirtualProtect(xHair, sizeof(oXHairPatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(oXHairPatch, xHair, sizeof(oXHairPatch));
	VirtualProtect(xHair, sizeof(oXHairPatch), orig, &orig);
}

void DisableAll(void)
{
	unsigned long orig;
	//wallhack
	VirtualProtect(playerFlag, sizeof(owallhackpatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(playerFlag, &owallhackpatch, sizeof(owallhackpatch));
	VirtualProtect(playerFlag, sizeof(owallhackpatch), orig, &orig);
	bWallHack=false;
	
	//recoil
	VirtualProtect(fireRecoil, sizeof(oRecoilPatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(fireRecoil, &oRecoilPatch, sizeof(oRecoilPatch));
	VirtualProtect(fireRecoil, sizeof(oRecoilPatch), orig, &orig);
	bNoRecoil=false;

	//crosshair
	VirtualProtect(xHair, sizeof(oXHairPatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(xHair, &oXHairPatch, sizeof(oXHairPatch));
	VirtualProtect(xHair, sizeof(oXHairPatch), orig, &orig);
	bXHair=false;

	//nametags
	VirtualProtect(xTeamcheck, sizeof(oTeamCheckPatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(xTeamcheck, &oTeamCheckPatch, sizeof(oTeamCheckPatch));
	VirtualProtect(xTeamcheck, sizeof(oTeamCheckPatch), orig, &orig);
	VirtualProtect(xVisible, sizeof(oVisiblePatch), PAGE_EXECUTE_READWRITE, &orig);
	memcpy(xVisible, &oVisiblePatch, sizeof(oVisiblePatch));
	VirtualProtect(xVisible, sizeof(oVisiblePatch), orig, &orig);

}

void HackThread(void)
{
	InitBackups();
	while(1)
	{
		if(GetAsyncKeyState(VK_NUMPAD0)&1) // Panic key
		{
			DisableAll();
		}
		if(GetAsyncKeyState(VK_NUMPAD1)&1)
		{
			doWallhack();
		}
		if(GetAsyncKeyState(VK_NUMPAD2)&1)
		{
			doNametags();
		}
		if(GetAsyncKeyState(VK_NUMPAD3)&1)
		{
			doNoRecoil();
		}
		if(GetAsyncKeyState(VK_NUMPAD4)&1)
		{
			doXHair();
		}
		Sleep(1);
	}
}

BOOL __stdcall DllMain(HMODULE hinst, DWORD reason, void *useless)
{
	DisableThreadLibraryCalls(hinst);
	if(reason == 1)
	{
		CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
	}
	return TRUE;
}
patch.cpp:
Code:
#include <windows.h>
/* Thanks NightGhost for the patch util's */

void writeNOP(unsigned long *orig, int len)
{
	int i = 0;
	unsigned long back;
	VirtualProtect((void*)orig, len, PAGE_READWRITE, &back);
	while(i < len) {
		*(unsigned char*)(orig + i) = 0x90;
		i++;
	}
	VirtualProtect((void*)orig, len, back, &back);
}

void changeDWORDPTR(unsigned long dest, unsigned long *orig)
{
	unsigned long back;
	VirtualProtect((void*)orig, 4, PAGE_READWRITE, &back);
	*(unsigned long*)(orig) = (unsigned long)(dest);
	VirtualProtect((void*)orig, 4, back, &back);
}

void changeBYTEPTR(unsigned char dest, unsigned long *orig)
{
	unsigned long back;
	VirtualProtect((void*)orig, 4, PAGE_READWRITE, &back);
	*(unsigned char*)(orig) = (unsigned char)(dest);
	VirtualProtect((void*)orig, 4, back, &back);
}
patch.h:
Code:
#ifndef _PATCH_H
#define _PATCH_H

void writeNOP(unsigned long *orig, int len);
void changeDWORDPTR(unsigned long dest, unsigned long *orig);
void changeBYTEPTR(unsigned char dest, unsigned long *orig);

#endif // _PATCH_H
Credits: Hell_Demon, Couch, NightGhost
I dont play COD4, but does detected mean patched. Just wondering because I was gonna post:

OMG DOESNT WORK
who cares, this is the c++ section and the source is to learn from, not to whine that the hack is detected when u copy and paste it
I dont whine. I imitate choobs. (It's how I am.)
What does detected mean? Someone explain because my degenerate mind cannot comprehend such high levels of vocabulary
Quote Originally Posted by Lolland View Post
I dont whine. I imitate choobs. (It's how I am.)
What does detected mean? Someone explain because my degenerate mind cannot comprehend such high levels of vocabulary
Your kidding right? Oh and thanks for the code code HD. This will be nice to look at.
really nice code i can learn alot from it. btw try posting tuts about how to find the recoil or
w/e address u think its hard to find. for example how do u find the wall address to write a wallhack for it?
Quote Originally Posted by Matrix_NEO006 View Post
really nice code i can learn alot from it. btw try posting tuts about how to find the recoil or
w/e address u think its hard to find. for example how do u find the wall address to write a wallhack for it?
I leeched it like all other coders do =D
J/K, download the engine's SDK, check for strings(I believe the recoil one was something like cg_firerecoil), search for it with olly, start looking at the function, find out(by testing/etc) which one controls spread, then nop it out for nospread ^^
Quote Originally Posted by Hell_Demon View Post
I
download the engine's SDK
what?? wth is engines sdk
Quote Originally Posted by Matrix_NEO006 View Post
what?? wth is engines sdk
What engine does CoD4 use? starts with Q :P now go and look up the engine ^^
Quote Originally Posted by Hell_Demon View Post
What engine does CoD4 use? starts with Q :P now go and look up the engine ^^
Quake obviously...
Posts 111 of 11 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?