New D3D Hook & Wireframe Example

Posts 1–15 of 26 · Page 1 of 2
New D3D Hook & Wireframe Example
Made it about 30min ago, not the same hook i used in the hack i released.
I left out one Include and moved two variables down so you can't just C&P.

All the debugging and the hook was coded by me.
I had a look online and couldn't find this one.

Two downsides..
-Im a win7 user so the byte pattern is for win7, xp users will need add their own pattern.
-If you're one of those who can't inject a dll without getting a message, even if it contains no functions,
i included my dll patcher.
One file is a patcher only, the other also injects.

If you create a hack and want to release it, put the patcher in the folder with the dll and run it.
The dll should be good to release now.

Do the same for the other file besides click the inject button then run CF.

 
Source
Code:
#include <Windows.h>

#pragma region D3D Stuff Here

void Derp()
{ 
	IDirect3DVertexBuffer9* pStreamData = NULL;
              UINT pOffsetInBytes , pStride;
              pDevice->GetStreamSource(0,&pStreamData,&pOffsetInBytes,&pStride);

	if (pStride == 24 || pStride == 28)//Wireframe Example
	{
                  pDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
	}
}

#pragma endregion

#pragma region Mem Scanner/Detour/Hook
bool Compare(const BYTE* pData, const BYTE* bMaskara, const char* szMaskara)
{
	for(;*szMaskara;++szMaskara,++pData,++bMaskara)
		if(*szMaskara=='x' && *pData!=*bMaskara ) 
			return false;
	return (*szMaskara) == NULL;
}
DWORD FindPattern(DWORD dwAddress,DWORD dwLen,BYTE *bMask,char * szMask)
{
	 for (DWORD x = 0; x < dwLen; x++)
		if( Compare( ( BYTE * )( dwAddress + x ), bMask, szMask ) )  
		return ( DWORD )( dwAddress + x );
	return 0;
}
void Detour(BYTE *pAddress, DWORD dwJumpTo, DWORD dwLen)
{
    DWORD dwOldProtect, dwBkup, dwRelAddr;
    VirtualProtect(pAddress, dwLen, PAGE_EXECUTE_READWRITE, &dwOldProtect);
    dwRelAddr = (DWORD) (dwJumpTo - (DWORD) pAddress) - 5;
    *pAddress = 0xE9;
    *((DWORD *)(pAddress + 1)) = dwRelAddr;
    for(DWORD x = 0x5; x < dwLen; x++) *(pAddress + x) = 0x90;
    VirtualProtect(pAddress, dwLen, dwOldProtect, &dwBkup);    
}
__declspec( naked )VOID MidHook()
{
	__asm
	{
		MOV EDI,[EBP+10h]
		MOV EAX, DWORD PTR SS:[EBP + 8]
		MOV DWORD PTR DS:[pDevice], EAX
		CALL Derp
		CMP EDI,20h
		JMP NxtInst
	}
}
#pragma endregion

#pragma region Storage
LPDIRECT3DDEVICE9 pDevice;
DWORD NxtInst;
#pragma endregion

#pragma region Find Address

DWORD GetD3D()
{
	//No Windows 8 or xp byte pattern. I dont have access to those OS...
    DWORD hD3D = (DWORD)GetModuleHandle("d3d9");
  	//Windows 7 Scan d3d9.dll+EEFA
	DWORD DIPD3D9;
	if ((DIPD3D9 = FindPattern(hD3D,0x128000,( PBYTE )"\x8B\x7D\x10\x83\xFF\x20","xxxxxx")))
	{
       NxtInst = DIPD3D9 + 6;
       return DIPD3D9;
	}
  return 0;
}

#pragma endregion

#pragma region DllMain/Thread

void Hooker()
{
	while (GetModuleHandle("d3d9") == NULL)
	Sleep(10);
	DWORD DIPD3D9;
	if (DIPD3D9 = GetD3D()) Detour((PBYTE)DIPD3D9, (DWORD)MidHook, 6);
}

BOOL WINAPI DllMain(HMODULE dHandle, DWORD nReason, LPVOID Reserved)
{
	if(nReason == DLL_PROCESS_ATTACH)
	{
		DisableThreadLibraryCalls(dHandle);
		CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)Hooker, NULL, NULL, NULL);
	}
	return TRUE;
}

#pragma endregion


 
A CFNA wtf Screenshot


Virus Total
Jotti

I'm not a D3D pro nor a C++ one, so if you see something wrong or noobish, dont scream at me
InjPch_mpgh.net.zip46 KB · 848 downloads Clean
THANKS FOR SHARE
Approved .
@Pingo i can give you access to XP OS if you wanna search for XP
Quote Originally Posted by bandi12 View Post
@Pingo i can give you access to XP OS if you wanna search for XP
I PMed you my email
6 errors in the code!
1 IntelliSense: идентификатор "IDirect3DVertexBuffer9" не определен c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 7 2 WallHack
2 IntelliSense: идентификатор "pStreamData" не определен c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 7 26 WallHack
3 IntelliSense: идентификатор "D3DRS_FILLMODE" не определен c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 13 43 WallHack
4 IntelliSense: идентификатор "D3DFILL_WIREFRAME" не определен c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 13 58 WallHack
5 IntelliSense: идентификатор "LPDIRECT3DDEVICE9" не определен c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 59 1 WallHack
6 IntelliSense: аргумент типа "const char *" несовместим с параметром типа "LPCWSTR" c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 68 41 WallHack
Need to Include the D3D9.dll and D3Dx9.dll like :

#include <d3d9.h>
#include <d3dx9.h>

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

and you have to Include the Dicetx in your Project in the libory ....
1 IntelliSense: не удается открыть источник файл "d3dx9.h" c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 3 1 WallHack
Quote Originally Posted by -Dreamer- View Post
1 IntelliSense: не удается открыть источник файл "d3dx9.h" c:\users\singatulin\documents\visual studio 2010\projects\wallhack\wallhack\dllmain.cpp 3 1 WallHack
do you have got directx sdk installed?
Is this scrambled source still "undetected"?
thanks for this...
Works fine .
But I prefer my own hook.
Good to learn from!
Thanks
can someone help me to make this work with Windows 8? I tried this but the game crashed:

Code:
//win7
//if ((DIPD3D9 = FindPattern(hD3D,0x128000,( PBYTE )"\x8B\x7D\x10\x83\xFF\x20","xxxxxx")))

//win8
if ((DIPD3D9 = FindPattern(hD3D,0x128000,( PBYTE )"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86","xx????xx????xx")))
{
       NxtInst = DIPD3D9 + 6;
       return DIPD3D9;
}
Posts 1–15 of 26 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us