#define WALLHACK 1
#define WALLHACK_CAR 1
#include <intrin.h>
#pragma intrinsic(_ReturnAddress)
rtdhook_vmt* hook;
rtdhook_call* hook2;
HRESULT __stdcall IDirect3DDevice9__DrawIndexedPrimitive(IDirect3DDevice9* self, D3DPRIMITIVETYPE type, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
{
bool calledToRenderSkin = reinterpret_cast<uintptr_t>(_ReturnAddress()) == 0x761142;
#if WALLHACK
HRESULT result;
if (calledToRenderSkin)
{
self->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
result = reinterpret_cast<decltype(IDirect3DDevice9__DrawIndexedPrimitive)*>(hook->getOriginalMethod(82))
(self, D3DPT_LINESTRIP,
BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
self->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
}
else
result = reinterpret_cast<decltype(IDirect3DDevice9__DrawIndexedPrimitive)*>(hook->getOriginalMethod(82))
(self, type,
BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
return result;
#else
return reinterpret_cast<decltype(IDirect3DDevice9__DrawIndexedPrimitive)*>(hook->getOriginalMethod(82))
(self, (calledToRenderSkin ? D3DPT_LINELIST : type),
BaseVertexIndex, MinVertexIndex, NumVertices, startIndex, primCount);
#endif
}
int __cdecl Render__Obj(void* a1, void* a2, void* a3, char a4, void* a5)
{
auto pD3DDevice = *reinterpret_cast<IDirect3DDevice9**>(0xC97C28);
pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
#if WALLHACK_CAR
pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
#endif
auto ret = reinterpret_cast<decltype(Render__Obj)*>(hook2->getHookedFunctionAddress())
(a1, a2, a3, a4, a5);
#if WALLHACK_CAR
pD3DDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE);
#endif
pD3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
return ret;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD fdwReason, LPVOID lpReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
std::thread([&]
{
while (*reinterpret_cast<uintptr_t*>(0x00C8D4C0) != 9) {}
std::this_thread::sleep_for(std::chrono::milliseconds(8000));
hook = new rtdhook_vmt(*reinterpret_cast<uintptr_t*>(0xC97C28));
hook->install(82, &IDirect3DDevice9__DrawIndexedPrimitive);
hook2 = new rtdhook_call(0x005D9EEB, &Render__Obj);
hook2->install();
}
).detach();
return TRUE;
}