Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › MultiPlayer Game Hacks & Cheats › CrossFire Hacks & Cheats › CrossFire Hack Coding / Programming / Source Code › A simple Hooking class

A simple Hooking class

Posts 1–14 of 14 · Page 1 of 1
25
258456
A simple Hooking class
So lately many people have been asking how to hook and Fallen is going to write a tutorial soon, but i just wanted to release a part of my hooking class. It's very simple and contains only the most basic type of hook which is the jmp hook and i threw in a function to NOP addies as well. Again it's very simple, but i made it to give you guys that want to learn how to hook a simple idea of how the idea works.

Here is the class:
Code:
class Hook
{
public:
	void NOP(DWORD* dwaddress, DWORD dwlen);
	void JMP(DWORD* dwaddress, DWORD* dwyouraddress, DWORD dwlen);
	
};

void Hook::NOP(DWORD* dwaddress, DWORD dwlen)
{
		DWORD dwOldProtect;
		VirtualProtect((void*)dwaddress, dwlen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
		BYTE *pAddie = (BYTE*)dwaddress;
		*pAddie = 0x90;
		
		for(DWORD i = 0x1; i < dwlen; i++)
				*(pAddie + i) = 0x90;
			
		VirtualProtect((void*)dwaddress, dwlen, dwOldProtect, NULL);
}

void Hook::JMP(DWORD* dwaddress, DWORD* dwyouraddress, DWORD dwlen)
{
	DWORD dwOldProtect;
	DWORD dwRealAddie = (DWORD)dwyouraddress - (DWORD)dwaddress  - 5;
	VirtualProtect((void*)dwaddress, dwlen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
	
	BYTE* pAddie = (BYTE*)dwaddress;
	*pAddie = 0xE9;
	pAddie++;
	dwaddress = (DWORD*)pAddie;
	*dwaddress = dwRealAddie;
	
	for(DWORD i = 0x4; i < dwlen; i++)
		*(pAddie + i) = 0x90;
	
	VirtualProtect((void*)dwaddress, dwlen, dwOldProtect, NULL);
}
To implement it you simply declare a variable of type Hook and then use the functions like so:
Code:
Hook hook;
hook.NOP((DWORD*)(address), (how_many_bytes_to_nop));
hook.JMP((DWORD*)(address), (DWORD*)(your function), (how many bytes));
Note that in order to use the JMP method you need to do it in a spot with atleast 5 bytes because the JMP is 0xE9 (1-byte) then the address of your function which is 4 bytes.

This isn't really a tutorial it's just some source code for you guys to study and learn from. Again it's very simple but you can combine it with other methods and it's very useful. Hope you learned something.
#1 · edited 14y ago · 14y ago
~F
~FALLEN~
Quote Originally Posted by 258456 View Post
So lately many people have been asking how to hook and Fallen is going to write a tutorial soon, but i just wanted to release a part of my hooking class. It's very simple and contains only the most basic type of hook which is the jmp hook and i threw in a function to NOP addies as well. Again it's very simple, but i made it to give you guys that want to learn how to hook a simple idea of how the idea works.

Here is the class:
Code:
class Hook
{
public:
	void NOP(DWORD* dwaddress, DWORD dwlen);
	void JMP(DWORD* dwaddress, DWORD* dwyouraddress, DWORD dwlen);
	
};

void Hook::NOP(DWORD* dwaddress, DWORD dwlen)
{
		DWORD dwOldProtect;
		VirtualProtect((void*)dwaddress, dwlen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
		BYTE *pAddie = (BYTE*)dwaddress;
		*pAddie = 0x90;
		
		for(DWORD i = 0x1; i < dwlen; i++)
				*(pAddie + i) = 0x90;
			
		VirtualProtect((void*)dwaddress, dwlen, dwOldProtect, NULL);
}

void Hook::JMP(DWORD* dwaddress, DWORD* dwyouraddress, DWORD dwlen)
{
	DWORD dwOldProtect;
	DWORD dwRealAddie = (DWORD)dwyouraddress - (DWORD)dwaddress  - 5;
	VirtualProtect((void*)dwaddress, dwlen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
	
	BYTE* pAddie = (BYTE*)dwaddress;
	*pAddie = 0xE9;
	pAddie++;
	dwaddress = (DWORD*)pAddie;
	*dwaddress = dwRealAddie;
	
	for(DWORD i = 0x4; i < dwlen; i++)
		*(pAddie + i) = 0x90;
	
	VirtualProtect((void*)dwaddress, dwlen, dwOldProtect, NULL);
}
To implement it you simply declare a variable of type Hook and then use the functions like so:
Code:
Hook hook;
hook.NOP((DWORD*)(address), (how_many_bytes_to_nop));
hook.JMP((DWORD*)(address), (DWORD*)(your function), (how many bytes));
Note that in order to use the JMP method you need to do it in a spot with atleast 5 bytes because the JMP is 0xE9 (1-byte) then the address of your function which is 4 bytes.

This isn't really a tutorial it's just some source code for you guys to study and learn from. Again it's very simple but you can combine it with other methods and it's very useful. Hope you learned something.
Good job man, I'll pm you my msn if you want to chat ( idk if you're on it yet or not lolz ) and heres a few tips btw
when you do the class instead of Hook hook; do Hook* hook = new Hook( ); Hook->Function( );
Second I would suggest saving the opcodes you overwrite and executing them before you execute your code ( just because then you don't need to rewrite them yourself ) other than that, It's a pretty good tutorial for your first time. Looking forward to seeing more of your work.
#2 · 14y ago
25
258456
Quote Originally Posted by ~FALLEN~ View Post
Good job man, I'll pm you my msn if you want to chat ( idk if you're on it yet or not lolz ) and heres a few tips btw
when you do the class instead of Hook hook; do Hook* hook = new Hook( ); Hook->Function( );
Second I would suggest saving the opcodes you overwrite and executing them before you execute your code ( just because then you don't need to rewrite them yourself ) other than that, It's a pretty good tutorial for your first time. Looking forward to seeing more of your work.
Thanks bro. Lol, i was tempted to use the free store but then i was like naw i am to lazy to use delete so i will just release it like this, haha. If you really wanna boost your self confidence by using "elite" syntax you can also do this:

Code:
Hook *hook = new Hook;
(*hook).NOP();
#3 · 14y ago
kmanev073
kmanev073
wont it get patched why did you relese it ?
#4 · 14y ago
giniyat101
giniyat101
nice work @258456
Quote Originally Posted by kmanev073 View Post
wont it get patched why did you relese it ?
because it is patched
#5 · 14y ago
Swag
Swag
Nice!
Good job
#6 · 14y ago
SY
Syn0tix
Quote Originally Posted by ~FALLEN~ View Post
Good job man, I'll pm you my msn if you want to chat ( idk if you're on it yet or not lolz ) and heres a few tips btw
when you do the class instead of Hook hook; do Hook* hook = new Hook( ); Hook->Function( );
Second I would suggest saving the opcodes you overwrite and executing them before you execute your code ( just because then you don't need to rewrite them yourself ) other than that, It's a pretty good tutorial for your first time. Looking forward to seeing more of your work.
sory @~FALLEN~ , but why is this "good job" ?
i´m working with PUSHAD & POPAD stuff.. more effective than this (why the hell nop's? > makes game laggy)
#7 · 14y ago
~F
~FALLEN~
Quote Originally Posted by Syn0tix View Post
sory @~FALLEN~ , but why is this "good job" ?
i´m working with PUSHAD & POPAD stuff.. more effective than this (why the hell nop's? > makes game laggy)
LOL okay... Let me explain this in dumb terms so even the noobs can laugh at you. pushad preserves the general registers on the stack popad pops the general registers pushfd pushes the eflags register onto the stack and popfd will pop the registers into eflags again. So now that I have introduced that, here is a few tips.
1. calling convention (32 bit conventions) ex. __thiscall __stdcall __cdecl __fastcall
now i'm sure the people actually reading this are asking, well whats the difference?

well one of the main differences is how they operate. ex. (calling wise) and two, how the arguments are used ( left to right vs right to left )

__stdcall:
push arguments
call function
( automatic cleanup from "callee" )

__cdecl:
push arguments
call function
add esp, arguments * 4 ( pops function arguments off the stack ) ( clean up from "caller" )

__thiscall:
mov ecx, this pointer*
push arguments*
call function

__fastcall: pretty much the same as __thiscall but with edx too.

these are just short descriptions of the calling conventions, theres much more behind them.

note* this can interchange

the reason he nops ( no operation ) is so he doesn't corrupt the stack. ( A BIG NO NO ) because if you don't nop you get a bunch of unintended commands in the function -> corrupt reason why? tried to preform an unsupported operation. this is why you replace the original operations in your function ( or save them and jump to them before you jump to your code ) pushad / popfd is so you dont interfere with the registers while you execute your code.. same with pushfd and popfd ( for the eflags ) try subfunction hooking and you would probably understand it better. anyways you're wrong, and once again learn wtf you're talking about before you try to correct / claim someone elses work. especially if they're better than you. bye now

by the way nopping doesn't make a game laggy, that's just you're p.o.s code.
#8 · edited 14y ago · 14y ago
25
258456
Quote Originally Posted by ~FALLEN~ View Post
LOL okay... Let me explain this in dumb terms so even the noobs can laugh at you. pushad preserves the general registers on the stack popad pops the general registers pushfd pushes the eflags register onto the stack and popfd will pop the registers into eflags again. So now that I have introduced that, here is a few tips.
1. calling convention (32 bit conventions) ex. __thiscall __stdcall __cdecl __fastcall
now i'm sure the people actually reading this are asking, well whats the difference?

well one of the main differences is how they operate. ex. (calling wise) and two, how the arguments are used ( left to right vs right to left )

__stdcall:
push arguments
call function
( automatic cleanup from "callee" )

__cdecl:
push arguments
call function
add esp, arguments * 4 ( pops function arguments off the stack ) ( clean up from "caller" )

__thiscall:
mov ecx, this pointer*
push arguments*
call function

__fastcall: pretty much the same as __thiscall but with edx too.

these are just short descriptions of the calling conventions, theres much more behind them.

note* this can interchange

the reason he nops ( no operation ) is so he doesn't corrupt the stack. ( A BIG NO NO ) because if you don't nop you get a bunch of unintended commands in the function -> corrupt reason why? tried to preform an unsupported operation. this is why you replace the original operations in your function ( or save them and jump to them before you jump to your code ) pushad / popfd is so you dont interfere with the registers while you execute your code.. same with pushfd and popfd ( for the eflags ) try subfunction hooking and you would probably understand it better. anyways you're wrong, and once again learn wtf you're talking about before you try to correct / claim someone elses work. especially if they're better than you. bye now

by the way nopping doesn't make a game laggy, that's just you're p.o.s code.

Thanks for saving me the time to reply to Syntoix. He always hatin cuz he jelly that he can't make a d3d menu. He has to use vb lol.
#9 · 14y ago
giniyat101
giniyat101
i agree with @~FALLEN~
naked function and pushad , pushfd etc is not the best idea
in my opinion, the best idea for mid hook (for example) is to make a function that (sry bad english):
1- allocates some memory
2- adds code that fixes the stack
3- jumps to the modified function
4- writes an alternate header to the real function instead of the modified one
5- jumps back to next executable line of the real function
and the function would return a pointer to the alternate header ofc

i have made a function which makes all of this.. really easy and i can access all function parameters
and easily can declare local variables inside the function itself, not global variables outside it

another advantage : i can make chams easily, while you have to work hard to get it working using your method..

and i see nops could be useless in one case:
if you jump back AFTER them, while if you jump back after the modified bytes , they are needed
but i prefer them because they make the function more readable while debugging

@258456
you made a mistake
Code:
for(DWORD i = 0x4; i < dwlen; i++)
do you mean 0x5?
#10 · edited 14y ago · 14y ago
25
258456
Quote Originally Posted by giniyat101 View Post
i agree with @~FALLEN~
naked function and pushad , pushfd etc is not the best idea
in my opinion, the best idea for mid hook (for example) is to make a function that (sry bad english):
1- allocates some memory
2- adds code that fixes the stack
3- jumps to the modified function
4- writes an alternate header to the real function instead of the modified one
5- jumps back to next executable line of the real function
and the function would return a pointer to the alternate header ofc

i have made a function which makes all of this.. really easy and i can access all function parameters
and easily can declare local variables inside the function itself, not global variables outside it

another advantage : i can make chams easily, while you have to work hard to get it working using your method..

and i see nops could be useless in one case:
if you jump back AFTER them, while if you jump back after the modified bytes , they are needed
but i prefer them because they make the function more readable while debugging

@258456
you made a mistake
Code:
for(DWORD i = 0x4; i < dwlen; i++)
do you mean 0x5?
Well, i made it with 0x5 and it would nop the wrong bytes so i made it 0x4 and it worked.
#11 · 14y ago
giniyat101
giniyat101
Quote Originally Posted by 258456 View Post
Well, i made it with 0x5 and it would nop the wrong bytes so i made it 0x4 and it worked.
my bad..
i checked again and i see u increased the pointer by 1.. so the first nop is pointer + 4
good job
#12 · 14y ago
Zacherl
Zacherl
If you want to make your hook generic, you have to use some kind of length disassembler to avoid some opcodes to get corrupted
#13 · 14y ago
25
258456
Quote Originally Posted by giniyat101 View Post
my bad..
i checked again and i see u increased the pointer by 1.. so the first nop is pointer + 4
good job
thank you sir
#14 · 14y ago
Posts 1–14 of 14 · Page 1 of 1

Post a Reply

Similar Threads

  • Simple Hook V1By MugNuf in Combat Arms Hacks & Cheats
    17Last post 16y ago
  • [Source]Simple menu classBy Void in C++/C Programming
    44Last post 15y ago
  • Simple MemoryMgr ClassBy CodeDemon in Combat Arms Hack Coding / Programming / Source Code
    21Last post 15y ago
  • CF:Simple D3d HookBy Hungry in CrossFire Hacks & Cheats
    9Last post 16y ago
  • Simple Combat Arms Public HookBy [NIG]Ady[GA] in Combat Arms Hacks & Cheats
    8Last post 16y ago

Tags for this Thread

None