Solved HOOK D3D after loading the game

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat

Nytlenc

Newbie
Full Member
Sep 9, 2012
10
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
12,638
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
12,638
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
10
242
0
Thank you guys. You helped a lot. I'll try it and I will write about the result
 
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods