Most simple d3d hook

Posts 1–5 of 5 · Page 1 of 1
Most simple d3d hook
Can someone give me the most simple d3d hook posssible?
Like, for a game that doesnt even have anti cheat?

Just want to learn it..
btw its me @whit .. ive been perm'ad on all my accounts
but try this

Code:
DWORD * vTable = ***(DWORD****) Device Pointer;
pFunction = (oFunction) DetourCreate(( BYTE* ) vTable[whatever], ( BYTE* )HookFunction, DETOUR_TYPE_JMP );
Quote Originally Posted by shadow9231 View Post
btw its me @whit .. ive been perm'ad on all my accounts
but try this

Code:
DWORD * vTable = ***(DWORD****) Device Pointer;
pFunction = (oFunction) DetourCreate(( BYTE* ) vTable[whatever], ( BYTE* )HookFunction, DETOUR_TYPE_JMP );
Thanks, Since you're banned, Can someone else explain a litle bit more?
btw why you permbaneed ?
d3d hook
I think this should work :
Code:
#include <windows.h>
#include <detours.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <cstdio>

#pragma comment (lib,"detours.lib")
#pragma comment (lib,"d3d9.lib")
#pragma comment (lib,"d3dx9.lib")

using namespace std;

typedef HRESULT (WINAPI* EndSceneType)(LPDIRECT3DDEVICE9);
EndSceneType EndScene_orig = NULL;


bool bDataCompare(const BYTE* pData,const BYTE* bMask,const char* szMask)
{
	for(;*szMask;++szMask,++pData,++bMask)
		if(*szMask == 'x' && *pData != *bMask)
			return false;
	return (*szMask) == NULL;
}

DWORD dwFindPattern(DWORD dwAddress,DWORD dwLen, BYTE *bMask,char * szMask)
{
	for(DWORD i = 0; i < dwLen; i++)
		if(bDataCompare((BYTE*)(dwAddress+i),bMask,szMask))
			return (DWORD)(dwAddress + i);
	return 0;
}


HRESULT WINAPI EndSceneDetour(LPDIRECT3DDEVICE9 pDevice)
{
	return EndScene_orig(pDevice);
}

int initHook(void)
{
	DWORD *vTable;
	HMODULE hMod;

	do{
		hMod = GetModuleHandleA("d3d9.dll");
		Sleep(50);
	}while(!hMod);

	DWORD addy = dwFindPattern((DWORD)hMod,0x128000,(PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86","xx????xx????xx");
	if(addy)
	{
		memcpy(&vTable,(void *)(addy +0x2),4);
		EndScene_orig = (EndSceneType)DetourFunction((PBYTE)vTable[42],(PBYTE)EndSceneDetour);
	}
	return true;
}

BOOL APIENTRY DllMain(HINSTANCE module,DWORD reason,LPVOID reserved)
{
	switch(reason)
	{
		case DLL_PROCESS_ATTACH:
			CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)initHook,NULL,NULL,NULL);
			break;
		case DLL_PROCESS_DETACH:
			break;
	}
	return TRUE;
}
Also MSDetours 1.5 is required ( i'll upload it as attachment)

And here the two Virus Scans :

VirusTotal - Free Online Virus, Malware and URL Scannerⓘ

MSDetours15.zip - Jottis Malwarescannerⓘ
MSDetours15.zipattachment deleted · 59 downloads before removal
You can try mid hook but must knowledgeable with asm.
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us