Code:
#include "stdafx.h"
#include "Menu.h"
#include "Hook.h"
//////////////////////////////////
#define LTClientEXE 0x45263 //
//////////////////////////////////
INT PosX = 30;
INT PosY = 70;
//Menu
CHAR MenuTitle[25] = { "Teste D3D Menu :) " }; // Titulo do Menu aqui, Menu Title.
CHAR Timestruct[25] = { "hh':'mm':'ss tt" }; // Estrutura Relogio.
CHAR TimeString[25];
INT MenuSelection;
BOOL Menu = TRUE;
BOOL bFont;
//Menu Variables
INT FPS;
INT Cross;
INT movemenu;
INT bFPS;
INT quantdehacks = 3; // Quantidade de hacks que tem na base, deve mudar sempre o valor ao adicionar ou retirar alguma função.
void ComandoPush(const char* cmd)
{
_asm
{
PUSH cmd
MOV EAX, LTClientEXE
CALL EAX
ADD ESP, 0x4
}
}
HRESULT WINAPI hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *a)
{
Directx_Font->OnLostDevice();
HRESULT hTorna = oReset(pDevice, a);
if(SUCCEEDED(hTorna))
Directx_Font->OnResetDevice();
return hTorna;
}
HRESULT WINAPI hkPresent(LPDIRECT3DDEVICE9 pDevice, CONST RECT *a, CONST RECT *b, HWND c, CONST RGNDATA *d)
{
if(Directx_Font) {
Directx_Font->Release();
Directx_Font = NULL;
bFont = FALSE;
}
if(!bFont) {
D3DXCreateFont(pDevice, 14, 0, FW_NORMAL, 1, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx_Font);
bFont = TRUE;
}
if(GetAsyncKeyState(VK_INSERT)&1) Menu = !Menu;
if(Menu && Directx_Font) {
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
GetTimeFormat(NULL, NULL, NULL, NULL, Timestruct, 15);
DrawBox(PosX - 10, PosY - 22, 162, 20, Black, Green, pDevice);//Draw box do titulo.
DrawBorder(PosX - 10, PosY - 22, 162, 20, 1, Green, pDevice);//Borda da box do titulo.
DrawText(pDevice, PosX , PosY - 20, Yellow, MenuTitle);// Titulo do hack. MenuTitle declaração, então deve mudar la em cima.
sprintf_s(TimeString, "%s", Timestruct);// Relogio.
DrawText(pDevice, PosX + 100, PosY - 20, Yellow, TimeString);// Texto do Relogio.
DrawBox(PosX - 10, PosY, 162, 70, Black, Green, pDevice);//Draw Box Principal //Cada vez que for adicionar uma nova função aumente o INT h (50) em 20 em 20 por exemplo, 50 + 20 = 70, 70 + 20 = 100, Espero que intenda.
DrawBorder(PosX - 10, PosY, 162, 70, 1, Green, pDevice);//Borda da box principal.
DrawText(pDevice, PosX, PosY + 10, White, "Show FPS");
if(FPS == 1) DrawText(pDevice, PosX + 120, PosY + 10, Green, "ON");
if(FPS == 0) DrawText(pDevice, PosX + 120, PosY + 10, Red, "OFF");
DrawText(pDevice, PosX, PosY + 30, White, "CrossHair");
if(Cross == 1) DrawText(pDevice, PosX + 120, PosY + 30, Green, "ON");
if(Cross == 0) DrawText(pDevice, PosX + 120, PosY + 30, Red, "OFF");
DrawText(pDevice, PosX, PosY + 50, White, "Mover Menu");
if(movemenu == 1) DrawText(pDevice, PosX + 120, PosY + 50, Green, "ON");
if(movemenu == 0) DrawText(pDevice, PosX + 120, PosY + 50, Red, "OFF");
//Cada função que for adicionar Sempre aumente a INT Y de cada uma em 20 para ficar ajustado. Espero que intenda.
if(GetAsyncKeyState(VK_UP)&1) {
MenuSelection--;
if(MenuSelection < 0) MenuSelection = quantdehacks - 1;
}
if(GetAsyncKeyState(VK_DOWN)&1) {
MenuSelection++;
if(MenuSelection > quantdehacks - 1) MenuSelection = 0;
}
if(GetAsyncKeyState(VK_RIGHT)&1) {
switch(MenuSelection) {
case 0:
FPS++; if(FPS > 1) FPS = 1; break;// case do FPS.
case 1:
Cross++; if(Cross > 1) Cross =1; break;// case do CrossHair.
case 2:
movemenu++; if(movemenu > 1) movemenu =1; break;// Sempre adicionar um novo a cada nova função adicionada.
default:
break;
}
}
if(GetAsyncKeyState(VK_LEFT)&1) {
switch(MenuSelection) {
case 0:
FPS--; if(FPS < 0) FPS = 0; break;
case 1:
Cross--; if(Cross <0) Cross = 0; break;
case 2:
movemenu--; if(movemenu > 0) movemenu =0; break;// Sempre adicionar um novo a cada nova função adicionada.
default:
break;
}
}
for(INT x = 0; x < quantdehacks + 1; x++) {
if(MenuSelection == x)
CurrentOption(pDevice, PosX - 9, PosY + 10 + 20 * x, 15, 158, Red);// Opção de seleção/Current Option.
}
}
if(Cross) CrossHair(pDevice, Red);
if(FPS && !bFPS) {
ComandoPush("ShowFPS 1");
bFPS = 1;
} else if(!FPS && bFPS) {
ComandoPush("ShowFPS 0");
bFPS = 0;
}
if(movemenu) {
POINT myCursor;
GetCursorPos(&myCursor);
PosX = myCursor.x;
PosY = myCursor.y;
}
return oPresent(pDevice, a, b, c, d);
}
DWORD WINAPI Hook(LPVOID lpArgs)
{
DWORD dwD3D9 = 0;
while(!dwD3D9) {
Sleep(100);
dwD3D9 = (DWORD)GetModuleHandle("d3d9.dll");
}
DWORD dwVTable[1] = {0};
CreateDevice(dwVTable);
oReset = (tReset) DetourCreate((PBYTE) dwVTable[0], (PBYTE) &hkReset, 5);
oPresent = (tPresent)DetourCreate((PBYTE) dwVTable[1], (PBYTE) &hkPresent, 5);
return FALSE;
}
Code:
#include "stdafx.h"
BOOL Pointer = 0xE9;
typedef HRESULT(WINAPI *tReset)(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *a);
tReset oReset;
typedef HRESULT(WINAPI *tPresent)(LPDIRECT3DDEVICE9 pDevice, CONST RECT *a, CONST RECT *b, HWND c, CONST RGNDATA *d);
tPresent oPresent;
VOID CreateDevice(DWORD *dwVTable)
{
LPDIRECT3D9 pD3d9;
LPDIRECT3DDEVICE9 pD3DDevice;
pD3d9 = Direct3DCreate9(D3D_SDK_VERSION);
if(pD3d9 == NULL)
return;
D3DPRESENT_PARAMETERS pPresentParms;
ZeroMemory(&pPresentParms, sizeof(pPresentParms));
pPresentParms.Windowed = TRUE;
pPresentParms.BackBufferFormat = D3DFMT_UNKNOWN;
pPresentParms.SwapEffect = D3DSWAPEFFECT_DISCARD;
if(FAILED(pD3d9->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, GetDesktopWindow(), D3DCREATE_SOFTWARE_VERTEXPROCESSING, &pPresentParms, &pD3DDevice)))
return;
DWORD *dwTable = (DWORD *)pD3DDevice;
dwTable = (DWORD *) dwTable[0];
dwVTable[0] = dwTable[16];
dwVTable[1] = dwTable[17];
}
VOID *DetourCreate(BYTE *src, CONST BYTE *dst, CONST INT len)
{
BYTE *jmp = (BYTE *)malloc(len + 5);
DWORD dwback;
VirtualProtect(src, len, PAGE_READWRITE, &dwback);
memcpy(jmp, src, len);
jmp += len;
jmp[0] = Pointer;
*(DWORD *)(jmp + 1) = (DWORD)(src + len - jmp) - 5;
src[0] = Pointer;
*(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);
}