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 › Combat Arms Hacks & Cheats › Combat Arms Hack Coding / Programming / Source Code › Simple Assembly Hooking

PostSimple Assembly Hooking

Posts 1–8 of 8 · Page 1 of 1
GN
gnm
Simple Assembly Hooking
Hey guys, first post, just releasing my personal code for assembly hooking, hope you guys put it to good use.

Source:
Code:
typedef struct
{
	BOOL hooked;
	INT_PTR origAddress;
	INT_PTR hookAddress;
	BYTE origAsm[6];
	BYTE hookedAsm[6];
} HOOK;

BOOL HookFunction( HOOK* hook )
{
	if( hook->hooked )
		return TRUE;

	DWORD oldProtection;
	DWORD numBytes;

	if( *(INT_PTR*)(hook->hookedAsm + 1) == 0 )
	{
		hook->hookedAsm[0] = 0xe9; // jmp
		hook->hookedAsm[5] = 0xc3; // retn

		INT_PTR relativeAddress = hook->hookAddress - hook->origAddress - 5;
		*(INT_PTR*)(hook->hookedAsm + 1) = relativeAddress;
	}

	VirtualProtect( (LPVOID)hook->origAddress, 6, PAGE_READWRITE, &oldProtection );

	if( !ReadProcessMemory( GetCurrentProcess(), (LPVOID)hook->origAddress, hook->origAsm, 6, &numBytes ) || numBytes != 6 )
		return FALSE;

	numBytes = 0;

	if( !WriteProcessMemory( GetCurrentProcess(), (LPVOID)hook->origAddress, hook->hookedAsm, 6, &numBytes ) || numBytes != 6 )
		return FALSE;

	VirtualProtect( (LPVOID)hook->origAddress, 6, oldProtection, NULL );

	hook->hooked = TRUE;

	return TRUE;
}

BOOL UnhookFunction( HOOK* hook )
{
	if( !hook->hooked )
		return TRUE;

	DWORD oldProtection;
	DWORD numBytes;

	VirtualProtect( (LPVOID)hook->origAddress, 6, PAGE_READWRITE, &oldProtection );

	if( !WriteProcessMemory( GetCurrentProcess(), (LPVOID)hook->origAddress, hook->origAsm, 6, &numBytes ) || numBytes != 6 )
		return FALSE;

	VirtualProtect( (LPVOID)hook->origAddress, 6, oldProtection, NULL );

	hook->hooked = FALSE;

	return TRUE;
}
Example usage:
Code:
static HOOK hkLoadLibraryA;

extern "C" HMODULE WINAPI LoadLibraryAHook( LPCSTR lpLibFileName )
{
	UnhookFunction( &hkLoadLibraryA );
	HMODULE returned = LoadLibraryA( lpLibFileName );
	HookFunction( &hkLoadLibraryA );

	// Own code goes here

	return returned;
}

void Hook()
{
	hkLoadLibraryA.origAddress = (INT_PTR)LoadLibraryA;
	hkLoadLibraryA.hookAddress = (INT_PTR)LoadLibraryAHook;
	HookFunction( &hkLoadLibraryA );
}
#1 · edited 15y ago · 15y ago
C0
c0ke187
IM PRETTY SURE...

That HackShield Blocks RPM and WPM so you may have to change that to memcpy()
#2 · 15y ago
GN
gnm
Do you know if they've disabled ntdll functions? These?
#3 · 15y ago
.::SCHiM::.
.::SCHiM::.
Quote Originally Posted by gnm View Post
Do you know if they've disabled ntdll functions? These?
yes, hackshield hooks zwOpenProcess(), zwReadProcessMemory(), zwWriteProcessMemory(), zwVirtualAllocEx(), psCreateSystemThread(), psCreateThread(), zwImpersonateThread().

I'm sure about those, there are probably more. The result is that you can't use their userland versions either, since they are actually these functions but exported through ntdll.dll and ntoskrnl.exe.
#4 · 15y ago
DE
DeadLinez
Yah, they hook those, switch em over to memcpy()
#5 · 15y ago
speedforyou
speedforyou
hmmm this just gave me a idea
#6 · 15y ago
GN
gnm
So that pretty much means no threads. Which means I'll have to hook IDirect3DDevice9::EndScene, do all my calculations and rendering, then call the real IDirect3DDevice9::EndScene.
#7 · edited 15y ago · 15y ago
KI
kibbles18
@gnm
can you help me with my code for a hook?
#8 · 15y ago
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

  • CF:Simple D3d HookBy Hungry in CrossFire Hacks & Cheats
    9Last post 16y ago
  • Most simple d3d hookBy Lyoto Machida in C++/C Programming
    4Last post 15y ago
  • Hooking in assembly.By Void in Assembly
    12Last post 13y ago
  • Simple Combat Arms Public HookBy [NIG]Ady[GA] in Combat Arms Hacks & Cheats
    8Last post 16y ago
  • Simple Hook V1By MugNuf in Combat Arms Hacks & Cheats
    17Last post 16y ago

Tags for this Thread

None