Solved HOOK D3D after loading the game

Hexui Undetected CSGO Cheats PUBG Accounts

Nytlenc

Newbie
Full Member
Sep 9, 2012
9
242
0
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

https://www.youtube.com/watch?v=FZDcZ84xxzo

This code does not do this:

C++:
bool WINAPI DllMain(HMODULE hDll, DWORD dwReason, PVOID pvReserved)
{
	if(dwReason == DLL_PROCESS_ATTACH)
		{
			DisableThreadLibraryCalls(hDll);
			HMODULE hMod = LoadLibrary("d3d9.dll");		
	
			oDirect3DCreate9 = (tDirect3DCreate9)DetourFunc(
				(BYTE*)GetProcAddress(hMod, "Direct3DCreate9"),
				(BYTE*)hkDirect3DCreate9, 
				5);
	
			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:

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
19,938
76
You need to hook something else than createdevice. Present or endscene for example.
 

c5

Kim Kong Trasher
Dank Tier VIP
Dank Tier Donator
Jul 19, 2012
1,187
19,938
76
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.
 

Nytlenc

Newbie
Full Member
Sep 9, 2012
9
242
0
Thank you guys. You helped a lot. I'll try it and I will write about the result
 
Community Mods