Code:
#include "DirectX.h"
#include "Menu.h"
bool Font = false;
oReset pReset;
oPresent pPresent;
cDirectx Directx;
VOID cDirectx::DrawTri(LPDIRECT3DDEVICE9 dev, INT x, INT y, INT w, INT h, DWORD Color)
{
D3DRECT BarRect = {x, y, x + w, y + h};
dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Color, 0, 0);
}
VOID cDirectx::Texto(INT x, INT y, DWORD color, DWORD Flags, LPD3DXFONT g_pFont, CONST CHAR *fmt, ...)
{
RECT FontPos = { x, y, x, y };
CHAR buf[256] = {'\0'};
va_list va_alist;
va_start(va_alist, fmt);
vsprintf_s(buf, fmt, va_alist);
va_end(va_alist);
g_pFont->DrawText(NULL, buf, -1, &FontPos, Flags, color);
}
HRESULT WINAPI Reset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters)
{
__asm NOP;
Directx.pFont->OnLostDevice();
Directx.WarningFont->OnLostDevice();
HRESULT hRet = pReset(pDevice, pPresentationParameters);
if(SUCCEEDED(hRet))
{
Directx.pFont->OnResetDevice();
Directx.WarningFont->OnResetDevice();
}
return hRet;
}
HRESULT WINAPI Present(LPDIRECT3DDEVICE9 pDevice, CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
__asm PUSHAD;
if(Directx.pFont)
{
Directx.pFont->Release();
Directx.pFont = 0;
Directx.WarningFont->Release();
Directx.WarningFont = 0;
Font = false;
}
if(!Font)
{
D3DXCreateFont(pDevice, 15, 0, 350, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx.pFont);
D3DXCreateFont(pDevice, 30, 0, 350, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial", &Directx.WarningFont);
Font = true;
}
Base.RenderFrame(pDevice);
Base.Funcoes(pDevice);
__asm POPAD;
return pPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
VOID cDirectx::Hook(VOID)
{
while( !GetModuleHandleA( "ClientFX.fxd" ) )
Sleep( 100 );
DWORD *Device = ***( DWORD **** ) DeviceGaming;
pReset = ( oReset ) DetourCreate( ( BYTE * ) Device[16] , ( BYTE *) Reset, 16);
pPresent = ( oPresent ) DetourCreate( ( BYTE * ) Device[17] , ( BYTE *) Present, 10);
}
Base.CPP
Code:
#include "Files.h"
#include "Base.h"
#include "Menu.h"
#include "DirectX.h"
#include "Itens.h"
INT frame;
//Posição do Menu.
INT menux = 50;
INT menuy = 45;
VOID cBase::RenderFrame(LPDIRECT3DDEVICE9 pDevice)
{
if(Mvisible)
{
if(colorborder == 0)
{
cBase::DrawBox(menux, menuy, Mxofs + 20, 20, TBlack, Red, pDevice);
cBase::DrawBox(menux, menuy + 25, Mxofs + 20, frame, TBlack, Red, pDevice);
} else if(colorborder == 1) {
cBase::DrawBox(menux, menuy, Mxofs + 20, 20, TBlack, Green, pDevice);
cBase::DrawBox(menux, menuy + 25, Mxofs + 20, frame, TBlack, Green, pDevice);
} else if(colorborder == 2) {
cBase::DrawBox(menux, menuy, Mxofs + 20, 20, TBlack, Blue, pDevice);
cBase::DrawBox(menux, menuy + 25, Mxofs + 20, frame, TBlack, Blue, pDevice);
} else if(colorborder == 3) {
cBase::DrawBox(menux, menuy, Mxofs + 20, 20, TBlack, Black, pDevice);
cBase::DrawBox(menux, menuy + 25, Mxofs + 20, frame, TBlack, Black, pDevice);
}
Directx.Texto(menux + ((Mxofs + 20) / 2), menuy + 3, Green, TCenter, Directx.pFont, "Test");
}
Menu.MenuShow(menux + 10, menuy + 35, Directx.pFont);
Menu.MenuNav();
if(Mmax == 0)
Menu.RenderMenu();
Base.MoveMenu(pDevice);
}
VOID cBase::FillRGB(INT x, INT y, INT w, INT h, D3DCOLOR color, LPDIRECT3DDEVICE9 pDevice)
{
D3DRECT rec = {x, y, x + w, y + h};
pDevice->Clear(1, &rec, D3DCLEAR_TARGET, color, 0, 0);
}
VOID cBase::DrawLine(INT x1, INT y1, INT x2, INT y2, D3DCOLOR color, LPDIRECT3DDEVICE9 pDevice)
{
CONST DWORD D3D_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE;
struct Vertex
{
FLOAT x, y, z, rhw;
DWORD dwColor;
FLOAT u, v;
} V[2] = {
{(FLOAT)(x1), (FLOAT)(y1), 0.0f, 1.0f, color, 0.0f, 0.0f},
{(FLOAT)(x2), (FLOAT)(y2), 0.0f, 1.0f, color, 0.0f, 0.0f},
};
pDevice->SetFVF(D3D_FVF);
pDevice->SetTexture(0, NULL);
pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 2, V, sizeof(Vertex));
}
VOID cBase::DrawBorder(INT x, INT y, INT w, INT h, INT px, D3DCOLOR BorderColor, LPDIRECT3DDEVICE9 pDevice)
{
FillRGB(x, (y + h - px), w, px, BorderColor, pDevice);
FillRGB(x, y, px, h, BorderColor, pDevice);
FillRGB(x, y, w, px, BorderColor, pDevice);
FillRGB((x + w - px), y, px, h, BorderColor, pDevice);
}
VOID cBase::DrawBox(INT X, INT Y, INT W, INT H, D3DCOLOR Color, D3DCOLOR BorderColor, LPDIRECT3DDEVICE9 pDevice) {
DrawBorder(X, Y, W, H, 2, BorderColor, pDevice);
CONST DWORD D3D_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE;
struct Vertex
{
FLOAT X, Y, W, H;
D3DCOLOR Color;
} V[4] = {
{(FLOAT)X, (FLOAT)(Y + H), 0.0F, 0.0F, Color},
{(FLOAT)X, (FLOAT)Y, 0.0F, 0.0F, Color},
{(FLOAT)(X + W), (FLOAT)(Y + H), 0.0F, 0.0F, Color},
{(FLOAT)(X + W), (FLOAT)Y, 0.0F, 0.0F, Color}
};
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, D3DZB_TRUE);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
pDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
pDevice->SetRenderState(D3DRS_FOGENABLE, D3DZB_FALSE);
pDevice->SetFVF(D3D_FVF);
pDevice->SetTexture(0, NULL);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, V, sizeof(Vertex));
}
VOID cBase::MoveMenu(LPDIRECT3DDEVICE9 pDevice)
{
if(movemenu)
{
POINT myCursor;
GetCursorPos(&myCursor);
menux = myCursor.x;
menuy = myCursor.y;
}
}
VOID cBase::CrossHair(LPDIRECT3DDEVICE9 pDevice, D3DCOLOR Color)
{
D3DVIEWPORT9 Viewport;
pDevice->GetViewport(&Viewport);
DWORD ScreenX = Viewport.Width / 2 - 1;
DWORD ScreenY = Viewport.Height / 2 - 1;
D3DRECT rec1 = {ScreenX - 15, ScreenY, ScreenX + 15, ScreenY + 2};
D3DRECT rec2 = {ScreenX, ScreenY - 15, ScreenX + 2, ScreenY + 15};
pDevice->Clear(1, &rec1, D3DCLEAR_TARGET, Color, 0, 0);
pDevice->Clear(1, &rec2, D3DCLEAR_TARGET, Color, 0, 0);
}
bool cBase::IsGameReadyForHook(VOID)
{
if ((GetModuleHandleA(/*d3d9.dll*/Descriptografa("‘`‘f[‘™™"))) &&
(GetModuleHandleA(/*ClientFX.fxd*/Descriptografa("p™–’›¡s…[“¥‘"))) &&
(GetModuleHandleA(/*CShell.dll*/Descriptografa("p€•’™™[‘™™"))))
return true;
return false;
}
DWORD WINAPI dwMainThread(LPVOID)
{
while(!Base.IsGameReadyForHook())
Sleep(100);
Directx.Hook();
return 0;
}
INT WINAPI DllMain(HMODULE hDll, DWORD dwReason, LPVOID lpReserved)
{
DisableThreadLibraryCalls(hDll);
if(dwReason == DLL_PROCESS_ATTACH)
{
CreateThread( 0, 0, ( LPTHREAD_START_ROUTINE )dwMainThread, 0, 0, 0 );
}
return 1;
}