// Wallhack.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <Windows.h>
#include "d3d9.h"
#include "detours.h"
#include "stdio.h"
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "detours.lib")
bool StartDll=1;
bool WallHack=1;
typedef HRESULT(WINAPI* DrawIndexedPrimitive_)(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount);
DrawIndexedPrimitive_ pDrawIndexedPrimitive;
HRESULT WINAPI nDrawIndexedPrimitive(LPDIRECT3DDEVICE9 pDevice, D3DPRIMITIVETYPE Type, INT BaseVertexIndex, UINT MinIndex,UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
{
IDirect3DVertexBuffer9* pStreamData = NULL;
UINT iOffsetInBytes,iStride;
pDevice->GetStreamSource(0,&pStreamData,&iOffsetInBytes,&iStride);
if ( iStride == 40 &&WallHack==1)
{
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_ZFUNC,D3DCMP_NEVER);
}
return pDrawIndexedPrimitive(pDevice, Type, BaseVertexIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
}
int StartHack ();
BOOL APIENTRY DllMain( HANDLE hModule,DWORD ul_reason_for_call, LPVOID lpReserved )
{
if (StartDll)
{
StartDll=0;
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)StartHack, NULL, NULL, NULL);
}
return TRUE;
}
int StartHack ()
{
char s[1000];
DWORD offsetBase=0x4FE571A0;
for(;; Sleep(500))
{
offsetBase=(DWORD)GetModuleHandle ("d3d9.dll");
if (offsetBase)
break;
}
DWORD a[2];
a[0]=offsetBase+0x88840;
sprintf (s,"[Noobshooter] Module d3d9 =%08X,Offset FuncHook =%08X",offsetBase,a[0]);
OutputDebugString (s);
pDrawIndexedPrimitive = (DrawIndexedPrimitive_)DetourFunction((PBYTE)a[0],(PBYTE)nDrawIndexedPrimitive);
for (;;Sleep (500))
{
if (GetAsyncKeyState (VK_F9)!=0)
{
Beep (2000,200);
Wallhack=1;
}
if (GetAsyncKeyState (VK_F10)!=0)
{
Beep (3000,200);
WallHack=0;
}
}
return 1;
}


