AsianHackz
Welcome to AsianHackz | Game Hacking

Register now to gain access to all of our features.Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Share
View previous topicGo downView next topic
avatar
ArtixxxHackz
Members
Members
Posts : 13
Reputation : 0
Join date : 2014-12-16

default [Source Code] Hook Graphics Driver Wallhack

on Mon Jul 31, 2017 4:21 am
Code:
 if ( D3DHookFunc1.Stride==40 ////   ///Support for other games, the need to modify the model ID
   ||  D3DHookFunc1.Stride==44
   ||  D3DHookFunc1.Stride==36
   ||  D3DHookFunc1.Stride==32
   || D3DHookFunc1.Stride==64)


[ltr] if (D3DHookFunc2.Stride==40 || D3DHookFunc2.Stride==44 || D3DHookFunc2.Stride==36 || D3DHookFunc2.Stride==32 || D3DHookFunc2.Stride==64) ///Modified model ID[/ltr]



[ltr][You must be registered and logged in to see this link.] <Windows.h>
[You must be registered and logged in to see this link.] "stdafx.h"
[You must be registered and logged in to see this link.] "d3d9types.h"
[You must be registered and logged in to see this link.] "d3dumddi.h"
[You must be registered and logged in to see this link.] "d3d9.h"

typedef HRESULT APIENTRY _OpenAdapter(D3DDDIARG_OPENADAPTER *pAdapterData);
HRESULT APIENTRY WarpDdiCreateDevice(
HANDLE hAdapter,
D3DDDIARG_CREATEDEVICE *pDeviceData);
void HookThread();

typedef struct _D3D_HookFunc
{
PFND3DDDI_DRAWINDEXEDPRIMITIVE DrawIndexedPrimitive;
PFND3DDDI_SETRENDERSTATE SetRenderState;
PFND3DDDI_SETSTREAMSOURCE SetStreamSource;
PFND3DDDI_CREATEQUERY CreateQuery;
DWORD Stride;

}D3D_HookFunc;


BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL,NULL,(LPTHREAD_START_ROUTINE)&HookThread,NULL,0,NULL);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}






void *DetourFunction(BYTE *src, const BYTE *dst, const int len)
{
BYTE *jmp = (BYTE*)VirtualAlloc(0,len+5,MEM_COMMIT,64);
//BYTE *jmp = (BYTE*)malloc(len+5);
DWORD dwBack;

VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
memcpy(jmp, src, len);
jmp += len;
jmp[0] = 0xE9;
*(DWORD*)(jmp+1) = (DWORD)(src+len - jmp) - 5;
src[0] = 0xE9;
*(DWORD*)(src+1) = (DWORD)(dst - src) - 5;
for (int i=5; i<len; i++) src[i]=0x90;
VirtualProtect(src, len, dwBack, &dwBack);
return (jmp-len);

}

_OpenAdapter *OldOpenAdapter;

PFND3DDDI_CREATEDEVICE DdiCreateDevice = NULL;
PFND3DDDI_PRESENT DdiPresent = NULL;
//PFND3DDDI_PRESENT1 DdiPresent1= NULL;
PFND3DDDI_LOCK DdiLock = NULL;
PFND3DDDI_CREATERESOURCE DdiCreateResource = NULL;
//PFND3DDDI_CREATERESOURCE2 DdiCreateResource2 = NULL;
PFND3DDDI_UNLOCK DdiUnlock = NULL;
PFND3DDDI_BLT DdiBlt = NULL;


HRESULT APIENTRY WarpOpenAdapter(D3DDDIARG_OPENADAPTER *pAdapterData)
{

HRESULT ret = OldOpenAdapter(pAdapterData);

if (ret == S_OK && pAdapterData->pAdapterFuncs->pfnCreateDevice)
{
DdiCreateDevice = pAdapterData->pAdapterFuncs->pfnCreateDevice;
pAdapterData->pAdapterFuncs->pfnCreateDevice = WarpDdiCreateDevice;
}
return ret;
}



BOOL DetourOpenAdapter()

{
PVOID OpenAdapter;

OpenAdapter = (PVOID)GetProcAddress(GetModuleHandleA("nvd3dum.dll"), "OpenAdapter");
if (OpenAdapter == NULL)
{
OpenAdapter = (PVOID)GetProcAddress(GetModuleHandleA("aticfx32.dll"), "OpenAdapter");
}

if (OpenAdapter)
{

OldOpenAdapter=(_OpenAdapter *)DetourFunction(( PBYTE )OpenAdapter,( PBYTE ) &WarpOpenAdapter,9);


}

return OpenAdapter != NULL;
}



D3DDDI_DEVICEFUNCS* pDeviceFuncs;
HRESULT WINAPI nDrawIndexedPrimitive(PVOID pDevice, D3DDDIARG_DRAWINDEXEDPRIMITIVE* pDrawIndexedPrimitive);
DWORD NewStride=0;
DWORD fangwei1;
DWORD fangwei2=500;


void HookThread()
{
BOOL IsHook;
IsHook=FALSE;
while (IsHook==FALSE)
{
IsHook=DetourOpenAdapter();
}
while (TRUE)
{
if (GetAsyncKeyState (VK_F2)&1)
{
NewStride++;
fangwei1=fangwei1+500;
fangwei2=fangwei2+500;
Sleep(100);
}
if (GetAsyncKeyState (VK_F3)&1)
{
NewStride--;
fangwei1=fangwei1-500;
fangwei2=fangwei2-500;
Sleep(100);
}
if (GetAsyncKeyState (VK_F4)&1)
{
char str[256];
itoa(NewStride,str,10);
MessageBoxA(0,str,0,0);

}

Sleep(100);
}


}




D3D_HookFunc D3DHookFunc1={};
D3D_HookFunc D3DHookFunc2={};



HRESULT WINAPI nSetStreamSource1(PVOID pDevice, D3DDDIARG_SETSTREAMSOURCE* pSetStreamSource)
{
if (pSetStreamSource->Stream==0)
{
D3DHookFunc1.Stride=pSetStreamSource->Stride;
}

return D3DHookFunc1.SetStreamSource(pDevice,pSetStreamSource);
}


HRESULT WINAPI nDrawIndexedPrimitive1(PVOID pDevice, D3DDDIARG_DRAWINDEXEDPRIMITIVE* pDrawIndexedPrimitive)
{
D3DDDIARG_RENDERSTATE tmp;
tmp.State=D3DDDIRS_ZENABLE;
tmp.Value=0;

if ( D3DHookFunc1.Stride==40 //// ///Modified model ID
|| D3DHookFunc1.Stride==44
|| D3DHookFunc1.Stride==36
|| D3DHookFunc1.Stride==32
|| D3DHookFunc1.Stride==64)

{

tmp.State=D3DDDIRS_ZENABLE;
tmp.Value=0;
D3DHookFunc1.SetRenderState(pDevice,&tmp);
D3DHookFunc1.DrawIndexedPrimitive( pDevice, pDrawIndexedPrimitive);


tmp.State=D3DDDIRS_ZENABLE;
tmp.Value=1;
D3DHookFunc1.SetRenderState(pDevice,&tmp);



}


return D3DHookFunc1.DrawIndexedPrimitive( pDevice, pDrawIndexedPrimitive);

}

HRESULT WINAPI nCreateQuery1(PVOID pDevice, D3DDDIARG_CREATEQUERY* pCreateQuery)
{
if (pCreateQuery->QueryType==D3DDDIQUERYTYPE_OCCLUSION)
{
pCreateQuery->QueryType=D3DDDIQUERYTYPE_TIMESTAMP;
}



return D3DHookFunc1.CreateQuery(pDevice,pCreateQuery);
}


HRESULT WINAPI nSetStreamSource2(PVOID pDevice, D3DDDIARG_SETSTREAMSOURCE* pSetStreamSource)
{
if (pSetStreamSource->Stream==0)
{
D3DHookFunc2.Stride=pSetStreamSource->Stride;
}
return D3DHookFunc2.SetStreamSource(pDevice,pSetStreamSource);
}

HRESULT WINAPI nDrawIndexedPrimitive2(PVOID pDevice, D3DDDIARG_DRAWINDEXEDPRIMITIVE* pDrawIndexedPrimitive)
{
D3DDDIARG_RENDERSTATE tmp;
D3DDDIARG_SETMATERIAL Material;

if (D3DHookFunc2.Stride==40 || D3DHookFunc2.Stride==44 || D3DHookFunc2.Stride==36 || D3DHookFunc2.Stride==32 || D3DHookFunc2.Stride==64) ///Modified model ID

{
tmp.State=D3DDDIRS_ZENABLE;
tmp.Value=0;
D3DHookFunc2.SetRenderState(pDevice,&tmp);
D3DHookFunc2.DrawIndexedPrimitive( pDevice, pDrawIndexedPrimitive);


tmp.State=D3DDDIRS_ZENABLE;
tmp.Value=1;
D3DHookFunc2.SetRenderState(pDevice,&tmp);
}


return D3DHookFunc2.DrawIndexedPrimitive( pDevice, pDrawIndexedPrimitive);

}


HRESULT WINAPI nCreateQuery2(PVOID pDevice, D3DDDIARG_CREATEQUERY* pCreateQuery)
{
if (pCreateQuery->QueryType==D3DDDIQUERYTYPE_OCCLUSION)
{
pCreateQuery->QueryType=D3DDDIQUERYTYPE_TIMESTAMP;
}


return D3DHookFunc2.CreateQuery(pDevice,pCreateQuery);
}



HRESULT APIENTRY WarpDdiCreateDevice(
HANDLE hAdapter,
D3DDDIARG_CREATEDEVICE *pDeviceData)
{
// DdiCreateDevice must not be NULL if this path hit
HRESULT ret = DdiCreateDevice(hAdapter, pDeviceData);




if (pDeviceData->pDeviceFuncs->pfnDrawIndexedPrimitive!=NULL)
{
if (D3DHookFunc1.DrawIndexedPrimitive==NULL && D3DHookFunc2.SetRenderState!=pDeviceData->pDeviceFuncs->pfnSetRenderState)
{

D3DHookFunc1.DrawIndexedPrimitive=pDeviceData->pDeviceFuncs->pfnDrawIndexedPrimitive;
D3DHookFunc1.SetRenderState=pDeviceData->pDeviceFuncs->pfnSetRenderState;
D3DHookFunc1.SetStreamSource=pDeviceData->pDeviceFuncs->pfnSetStreamSource;
D3DHookFunc1.CreateQuery=pDeviceData->pDeviceFuncs->pfnCreateQuery;

pDeviceData->pDeviceFuncs->pfnDrawIndexedPrimitive=(PFND3DDDI_DRAWINDEXEDPRIMITIVE)nDrawIndexedPrimitive1;
pDeviceData->pDeviceFuncs->pfnSetStreamSource=(PFND3DDDI_SETSTREAMSOURCE)nSetStreamSource1;
pDeviceData->pDeviceFuncs->pfnCreateQuery=(PFND3DDDI_CREATEQUERY)nCreateQuery1;

}

if (D3DHookFunc2.DrawIndexedPrimitive==NULL && D3DHookFunc1.SetRenderState!=pDeviceData->pDeviceFuncs->pfnSetRenderState )
{

D3DHookFunc2.DrawIndexedPrimitive=pDeviceData->pDeviceFuncs->pfnDrawIndexedPrimitive;
D3DHookFunc2.SetRenderState=pDeviceData->pDeviceFuncs->pfnSetRenderState;
D3DHookFunc2.SetStreamSource=pDeviceData->pDeviceFuncs->pfnSetStreamSource;
D3DHookFunc2.CreateQuery=pDeviceData->pDeviceFuncs->pfnCreateQuery;
pDeviceData->pDeviceFuncs->pfnDrawIndexedPrimitive=(PFND3DDDI_DRAWINDEXEDPRIMITIVE)nDrawIndexedPrimitive2;
pDeviceData->pDeviceFuncs->pfnSetStreamSource=(PFND3DDDI_SETSTREAMSOURCE)nSetStreamSource2;
pDeviceData->pDeviceFuncs->pfnCreateQuery=(PFND3DDDI_CREATEQUERY)nCreateQuery2;
}

}


return ret;
}

























[You must be registered and logged in to see this link.] DLLEXPORT_API extern "C" _declspec(dllexport)
DLLEXPORT_API void SXF()
{

}[/ltr]
View previous topicBack to topView next topic
Permissions in this forum:
You cannot reply to topics in this forum