Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Credit : Midz - VHB
- //Blog : http://midz-vhb.blogspot.com
- //Base : D3D Menu Base.
- #include <Windows.h>
- #include <cstdio>
- #include "lib\d3d9.h"
- #include "lib\d3dx9.h"
- #pragma comment(lib,"lib\\d3d9.lib")
- #pragma comment(lib,"lib\\d3dx9.lib")
- #include "lib\detours.h"
- #pragma comment(lib,"detours.lib")
- typedef HRESULT(WINAPI* tDIP)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount); // Define Type of data : DrawIndexPrimitive
- tDIP oDIP; //Declare oDIP
- HRESULT WINAPI nDIP(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount) //Hook Function
- {
- LPDIRECT3DVERTEXBUFFER9 Data_Stream; // Declare Data Stream with LPDIRECT3D
- UINT Offset = 0;
- UINT Stride = 0;
- if (pDevice->GetStreamSource(0, &Data_Stream, &Offset, &Stride)) Data_Stream->Release(); //GetStream put into DataStream, Offset, Stride and Release Data_Stream
- // Note if you're not release data, memory will be larger.
- if (Stride == 20) pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
- return oDIP(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
- }
- boolean bCompare(const BYTE* pData, const BYTE* bMask, const char* szMask)
- {
- for (; *szMask; ++szMask, ++pData, ++bMask)
- if (*szMask == 'x' && *pData != *bMask ) return 0;
- return (*szMask) == NULL;
- }
- DWORD FindPattern(DWORD dwAddress, DWORD dwLen, BYTE *bMask, char * szMask)
- {
- for (DWORD i = 0; i<dwLen; i++)
- if (bCompare((BYTE*)(dwAddress + i), bMask, szMask )) return (DWORD)(dwAddress + i);
- return 0;
- }
- void D3D_Hook(void)
- {
- DWORD DIP = 82;
- DWORD *vTable = NULL;
- DWORD hD3D = 0;
- do
- {
- hD3D = (DWORD)GetModuleHandleA("d3d9.dll");
- Sleep(10);
- } while (!hD3D);
- DWORD adr = FindPattern(hD3D, 0x128000, (PBYTE)"\xC7\x06\x00\x00\x00\x00\x89\x86\x00\x00\x00\x00\x89\x86", "xx????xx????xx");
- if (adr)
- memcpy(&vTable, (void *)(adr + 2), 4);
- oDIP = (tDIP)DetourFunction((PBYTE)vTable[DIP], (PBYTE)nDIP); //Hook DIP
- }
- BOOL APIENTRY DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved )
- {
- DisableThreadLibraryCalls(hDll);
- if (dwReason == DLL_PROCESS_ATTACH)
- CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)D3D_Hook, NULL, NULL, NULL);
- return TRUE;
- }
Add Comment
Please, Sign In to add comment