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 › Hacking › General Hacking › 5 byte code jump crashing when in a injected dll

5 byte code jump crashing when in a injected dll

Posts 1–2 of 2 · Page 1 of 1
AN
Anddos
5 byte code jump crashing when in a injected dll
heres my code

Code:
#include "stdafx.h"
#include <stdio.h>

DWORD HookFunction(LPCSTR lpModule, LPCSTR lpFuncName, LPVOID lpFunction, unsigned char *lpBackup);
BOOL UnHookFunction(LPCSTR lpModule, LPCSTR lpFuncName, unsigned char *lpBackup);
int MyMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
BYTE hook[6];

BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
					 )
{
	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		LoadLibrary("user32.dll");
		HookFunction("user32.dll", "MessageBoxA", MyMessageBoxA, hook);
	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}

int MyMessageBoxA(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType)
{
        UnHookFunction("user32.dll", "MessageBoxA", hook);
		char msg[32];
		sprintf(msg, "HOOKED!!\n\n%s", lpText);
		int x = MessageBox(hWnd, msg, lpCaption, uType);
		HookFunction("user32.dll", "MessageBoxA", MyMessageBoxA, hook);
		return x;
}

DWORD HookFunction(LPCSTR lpModule, LPCSTR lpFuncName, LPVOID lpFunction, unsigned char *lpBackup)
{
	DWORD dwAddr = (DWORD)GetProcAddress(GetModuleHandle(lpModule), lpFuncName);

        BYTE jmp[6] = { 0xe9,   //jmp
			            0x00, 
						0x00, 
						0x00, 
						0x00, //address
						0xc3
		};      //retn

	
		ReadProcessMemory(GetCurrentProcess(), (LPVOID)dwAddr, lpBackup, 6, 0); //GetCurrentProcess()
		DWORD dwCalc = ((DWORD)lpFunction - dwAddr - 5);        //((to)-(from)-5)
		memcpy(&jmp[1], &dwCalc, 4);    //build the jmp
		WriteProcessMemory(GetCurrentProcess(), (LPVOID)dwAddr, jmp, 6, 0); //GetCurrentProcess()
		return dwAddr;
}

BOOL UnHookFunction(LPCSTR lpModule, LPCSTR lpFuncName, unsigned char *lpBackup)
{
	DWORD dwAddr = (DWORD)GetProcAddress(GetModuleHandle(lpModule), lpFuncName);
		if (WriteProcessMemory(GetCurrentProcess(), (LPVOID)dwAddr, lpBackup, 6, 0)) 
			return TRUE;

		return FALSE;

}
this is in a dll which is injected in to my msgbox app , it hooks it once then crashs , does anyone know why?, i have another 1 which hooks by imports but was hopeing to get this version fixed to work in a injected dll
thanks
#1 · 16y ago
CR
cruizrisner
again, wrong section
#2 · 16y ago
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

  • Warrock crashes when using this code in my D3D hack...By k2hacker in C++/C Programming
    0Last post 18y ago
  • Game crashes when I inject anything into itBy djcynz in Call of Duty Modern Warfare 2 Help
    6Last post 16y ago
  • Why crossfire game crashed when i play with any program hackBy goergemamdoh in CrossFire Hacks & Cheats
    2Last post 17y ago
  • CUE crash when attach to warrockBy TheRedEye in WarRock - International Hacks
    2Last post 19y ago
  • Crash when debuggingBy Koekenbakker in WarRock - International Hacks
    6Last post 18y ago

Tags for this Thread

None