Help HOOK D3D after loading the game

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • ► You must register to download attachments!
Swift Games Accounts
Sep 9, 2012
Can anybody tell me how Fleep inject DLL into the game and HOOK D3D after loading the game in this video? (Time 5:50)
Interested C++ code

You do not have permission to view link Log in or register now.

This code does not do this:

bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved)
	if(dwReason == DLL_PROCESS_ATTACH)
			HMODULE hMod = LoadLibrary("d3d9.dll");		
			oDirect3DCreate9 = (tDirect3DCreate9)DetourFunc(
				(BYTE*)GetProcAddress(hMod, "Direct3DCreate9"),
			return true;
		return false;

void *DetourFunc(BYTE *src, const BYTE *dst, const int len)
	BYTE *jmp = (BYTE*)malloc(len+5);
	DWORD dwback;

	VirtualProtect(src, len, PAGE_READWRITE, &dwback);

	memcpy(jmp, src, len);	jmp += len;
	jmp[0] = 0xE9;
	*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;

	src[0] = 0xE9;
	*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;

	VirtualProtect(src, len, dwback, &dwback);

	return (jmp-len);

bool RetourFunc(BYTE *src, BYTE *restore, const int len)
	DWORD dwback;
	if(!VirtualProtect(src, len, PAGE_READWRITE, &dwback))	{ return false; }
	if(!memcpy(src, restore, len))							{ return false; }

	restore[0] = 0xE9;
	*(DWORD*)(restore+1) = (DWORD)(src - restore) - 5;

	if(!VirtualProtect(src, len, dwback, &dwback))			{ return false; }
	return true;
Last edited:


Kim Kong Trasher
Legacy Donator
Dank Tier VIP
Jul 19, 2012
Mankei Iland
you need to detour EndScene()
Not necessarily. It's quite fun to see people going on and on for ages about hooking endscene whereas actually Present gets called after Endscene, when the data is presented to the backbuffer, making it a bit safer place to draw. But I guess it has turned into more of a personal choice.