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
#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
[IMG]http://i203.photobucke*****m/albums/aa29/Baxter_esa/screen_zpsce46b09c.png[/IMG]
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
