- Yasaklandı
- #1
Onaylı Üye
C++:
C++:
/*
Bu Main.cpp'dir
-
*/
#include "main.h" //less important stuff & helper funcs here
typedef HRESULT(APIENTRY *SetStreamSource_t)(IDirect3DDevice9*, UINT, IDirect3DVertexBuffer9*, UINT, UINT);
HRESULT APIENTRY SetStreamSource_hook(IDirect3DDevice9*, UINT, IDirect3DVertexBuffer9*, UINT, UINT);
SetStreamSource_t SetStreamSource_orig = 0;
typedef HRESULT(APIENTRY *SetTexture_t)(IDirect3DDevice9*, DWORD, IDirect3DBaseTexture9 *);
HRESULT APIENTRY SetTexture_hook(IDirect3DDevice9*, DWORD, IDirect3DBaseTexture9 *);
SetTexture_t SetTexture_orig = 0;
typedef HRESULT(APIENTRY* Present_t) (IDirect3DDevice9*, const RECT *, const RECT *, HWND, const RGNDATA *);
HRESULT APIENTRY Present_hook(IDirect3DDevice9*, const RECT *, const RECT *, HWND, const RGNDATA *);
Present_t Present_orig = 0;
typedef HRESULT(APIENTRY *Reset_t)(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
HRESULT APIENTRY Reset_hook(IDirect3DDevice9*, D3DPRESENT_PARAMETERS*);
Reset_t Reset_orig = 0;
typedef HRESULT(APIENTRY *GetRenderTargetData_t)(IDirect3DDevice9*, IDirect3DSurface9 *pRenderTarget, IDirect3DSurface9 *pDestSurface);
GetRenderTargetData_t oGetRenderTargetData = 0;
typedef HRESULT(APIENTRY *CreateOffscreenPlainSurface_t)(IDirect3DDevice9*, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle);
CreateOffscreenPlainSurface_t oCreateOffscreenPlainSurface = 0;
//==========================================================================================================================
HRESULT APIENTRY hkGetRenderTargetData(LPDIRECT3DDEVICE9 pDevice, IDirect3DSurface9 *pRenderTarget, IDirect3DSurface9 *pDestSurface)
{
//called
screenshot_taken = true;
//temp disable visuals (it is too late to do this, screens are still dirty)
//wallhack = 0;
//nograss = 0;
//nofog = 0;
//Log("pRenderTarget == %d && pDestSurface == %d", pRenderTarget, pDestSurface);
return oGetRenderTargetData(pDevice, pRenderTarget, pDestSurface);
}
//==========================================================================================================================
HRESULT APIENTRY hkCreateOffscreenPlainSurface(LPDIRECT3DDEVICE9 pDevice, UINT Width, UINT Height, D3DFORMAT Format, D3DPOOL Pool, IDirect3DSurface9 **ppSurface, HANDLE *pSharedHandle)
{
//temp disable visuals (it is too late to do this, screens are still dirty)
//wallhack = 0;
//nograss = 0;
//nofog = 0;
screenshot_taken = true;
//prevent local screenshot (is screenshot still uploaded to gm?)
Width = 1;
Height = 1;
//Log("Width == %d && Height == %d && Format == %d && Pool == %d", Width, Height, Format, Pool);
Log("Screenshot blocked.");
return oCreateOffscreenPlainSurface(pDevice, Width, Height, Format, Pool, ppSurface, pSharedHandle);
}
//==========================================================================================================================
HRESULT APIENTRY SetStreamSource_hook(LPDIRECT3DDEVICE9 pDevice, UINT StreamNumber, IDirect3DVertexBuffer9* pStreamData, UINT OffsetInBytes, UINT sStride)
{
if (StreamNumber == 0)
Stride = sStride;
return SetStreamSource_orig(pDevice, StreamNumber, pStreamData, OffsetInBytes, sStride);
}
//==========================================================================================================================
HRESULT APIENTRY SetTexture_hook(LPDIRECT3DDEVICE9 pDevice, DWORD Sampler, IDirect3DBaseTexture9 *pTexture)
{
if (InitOnce)
{
InitOnce = false;
//get viewport
pDevice->GetViewport(&Viewport);
ScreenCX = (float)Viewport.Width / 2.0f;
ScreenCY = (float)Viewport.Height / 2.0f;
//GenerateTexture(pDevice, &Red, D3DCOLOR_ARGB(255, 255, 0, 0));
//GenerateTexture(pDevice, &Green, D3DCOLOR_RGBA(0, 255, 0, 255));
//GenerateTexture(pDevice, &Blue, D3DCOLOR_ARGB(255, 0, 0, 255));
//GenerateTexture(pDevice, &Yellow, D3DCOLOR_ARGB(255, 255, 255, 0));
LoadCfg();
}
//get vSize
if (SUCCEEDED(pDevice->GetVertexShader(&vShader)))
if (vShader != NULL)
if (SUCCEEDED(vShader->GetFunction(NULL, &vSize)))
if (vShader != NULL) { vShader->Release(); vShader = NULL; }
//model rec sample
//Stride == 36 && pSize == 1724 && vSize == 1952 //legs
//Stride == 36 && pSize == 1848 && vSize == 2300 //chest
//Stride == 44 && pSize == 2272 && vSize == 2300 //hair
//Stride == 36 && numElements == 5 && decl->Type == 2 && pSize == 412 && vSize == 1436 //weapons on ground
//Stride == 24 && numElements == 6 && decl->Type == 2 && vSize == 1436 //stupid door1
//Stride == 36 && numElements == 5 && decl->Type == 2 && vSize == 1436 //stupid door2
if (wallhack>0)
{
pDevice->SetRenderState(D3DRS_DEPTHBIAS, 0);
if ((vSize == 2300 || vSize == 900 ||
vSize == 1952 || vSize == 640) || (Stride == 36 && vSize == 1436)|| (Stride == 48 && vSize == 1436))
{
if (wallhack == 2 && vSize != 1436)
{
float sColor[4] = { 0.0f, 1.0f, 0.0f, 1.0f };//green
pDevice->SetPixelShaderConstantF(0, sColor, 1);
//SetTexture_orig(pDevice, 0, Red);
//SetTexture_orig(pDevice, 1, Red);
}
//if (wallhack == 2 && Stride == 36 && vSize == 1436)//weapons on ground
//{
//float sColorr[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
//pDevice->SetPixelShaderConstantF(0, sColorr, 4);
//}
float bias = 1000.0f;
float bias_float = static_cast<float>(-bias);
bias_float /= 10000.0f;
pDevice->SetRenderState(D3DRS_DEPTHBIAS, *(DWORD*)&bias_float);
}
}
//worldtoscreen weapons in hand
if (aimbot == 1 || esp > 0)
{
if ((Stride == 48 && vSize > 1328) || (vSize == 2300 || vSize == 1952 || vSize == 1552))//1040crap,1328crap
AddWeapons(pDevice);
}
//no grass by mtsagossi
if (nograss == 1)
{
pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
if (vSize == 1660 || vSize == 1704)//grass
{
pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT);
}
}
if (nofog == 1)
{
if (Stride == 48 || vSize == 2300 || vSize == 1952 || vSize == 1552)
{
D3DXMATRIX matLegs;
D3DXMatrixScaling(&matLegs, 0.0f, 0.0f, 0.0f);
pDevice->SetVertexShaderConstantF(20, matLegs, 1);//legs
D3DXMATRIX matChest;
D3DXMatrixScaling(&matChest, 0.0f, 0.0f, 0.0f);
pDevice->SetVertexShaderConstantF(25, matChest, 1);//chest
}
}
/*
//logger
if (GetAsyncKeyState('O') & 1) //-
countnum--;
if (GetAsyncKeyState('P') & 1) //+
countnum++;
if (countnum == vSize / 100)//vdesc.Size / 100000)
if (GetAsyncKeyState('I') & 1) //log
Log("Stride == %d && vSize == %d", Stride, vSize);
if (countnum == vSize / 100)//vdesc.Size / 100000)
{
//SetTexture_orig(pDevice, 0, Yellow);
//SetTexture_orig(pDevice, 1, Yellow);
//return D3D_OK; //delete texture
//pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT);
}
*/
return SetTexture_orig(pDevice, Sampler, pTexture);
}
//==========================================================================================================================
HRESULT APIENTRY Present_hook(IDirect3DDevice9* pDevice, const RECT *pSourceRect, const RECT *pDestRect, HWND hDestWindowOverride, const RGNDATA *pDirtyRegion)
{
if (GetAsyncKeyState(VK_ESCAPE) & 1||GetAsyncKeyState(VK_INSERT))
{
//get viewport
pDevice->GetViewport(&Viewport);
ScreenCX = (float)Viewport.Width / 2.0f;
ScreenCY = (float)Viewport.Height / 2.0f;
}
//create font
if (Font == NULL)
D3DXCreateFont(pDevice, 14, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Italic"), &Font);
if (ShowMenu)
//draw background
DrawBox(pDevice, 71.0f, 86.0f, 200.0f, 160.0f, D3DCOLOR_ARGB(120, 30, 200, 200));//180 = up/down, 200 = left/right
if (Font)
DrawMenu(pDevice);
if (screenshot_taken && Font)
DrawCenteredString(Font, (int)Viewport.Width/2, (int)Viewport.Height/2, D3DCOLOR_ARGB(255, 255, 255, 255), "Someone reported you. Screenshot blocked. (gmcomplaint.jpg)");
static DWORD lastTime = timeGetTime();
DWORD timePassed = timeGetTime() - lastTime;
if (timePassed>2000)
{
screenshot_taken = false;
lastTime = timeGetTime();
}
//Shift|RMouse|LMouse|Ctrl|Alt|Space|X|C
if (aimkey == 0) Daimkey = 0;
if (aimkey == 1) Daimkey = VK_SHIFT;
if (aimkey == 2) Daimkey = VK_RBUTTON;
if (aimkey == 3) Daimkey = VK_LBUTTON;
if (aimkey == 4) Daimkey = VK_CONTROL;
if (aimkey == 5) Daimkey = VK_MENU;
if (aimkey == 6) Daimkey = VK_SPACE;
if (aimkey == 7) Daimkey = 0x58; //X
if (aimkey == 8) Daimkey = 0x43; //C
//do esp
if (esp > 0 && WeaponEspInfo.size() != NULL)
{
for (unsigned int i = 0; i < WeaponEspInfo.size(); i++)
{
//box esp
if (WeaponEspInfo[i].pOutX > 1.0f && WeaponEspInfo[i].pOutY > 1.0f && (float)WeaponEspInfo[i].RealDistance > 4.0f)
DrawCornerBox(pDevice, (int)WeaponEspInfo[i].pOutX, (int)WeaponEspInfo[i].pOutY + 20, 20, 30, 1, D3DCOLOR_ARGB(255, 255, 255, 255));
//line esp
if (WeaponEspInfo[i].pOutX > 1.0f && WeaponEspInfo[i].pOutY > 1.0f && (float)WeaponEspInfo[i].RealDistance > 4.0f)//&& (float)WeaponEspInfo[i].vSizeod == 1952)//long range weapon
DrawLine(pDevice, (int)WeaponEspInfo[i].pOutX, (int)WeaponEspInfo[i].pOutY, ScreenCX, ScreenCY * ((float)esp * 0.2f), 20, D3DCOLOR_ARGB(255, 255, 255, 255), 1);//0.1up, 1.0middle, 2.0down
//else if (WeaponEspInfo[i].pOutX > 1.0f && WeaponEspInfo[i].pOutY > 1.0f && (float)WeaponEspInfo[i].RealDistance > 4.0f && (float)WeaponEspInfo[i].vSizeod != 1952)//short/mid range weapon
//DrawLine(pDevice, (int)WeaponEspInfo[i].pOutX, (int)WeaponEspInfo[i].pOutY, ScreenCX, ScreenCY * ((float)esp * 0.2f), 20, D3DCOLOR_ARGB(255, 0, 255, 0), 1);//0.1up, 1.0middle, 2.0down
//distance esp
if (WeaponEspInfo[i].pOutX > 1.0f && WeaponEspInfo[i].pOutY > 1.0f && (float)WeaponEspInfo[i].RealDistance > 200.0f)
DrawCenteredString(Font, (int)WeaponEspInfo[i].pOutX, (int)WeaponEspInfo[i].pOutY - 20.0f, D3DCOLOR_ARGB(255, 255, 255, 255), "%.f", (float)WeaponEspInfo[i].RealDistance);
else if (WeaponEspInfo[i].pOutX > 1.0f && WeaponEspInfo[i].pOutY > 1.0f && (float)WeaponEspInfo[i].RealDistance > 4.0f && (float)WeaponEspInfo[i].RealDistance <= 200.0f)
DrawCenteredString(Font, (int)WeaponEspInfo[i].pOutX, (int)WeaponEspInfo[i].pOutY - 20.0f, D3DCOLOR_ARGB(255, 255, 255, 0), "%.f", (float)WeaponEspInfo[i].RealDistance);
//text esp
//if (WeaponEspInfo[i].pOutX > 1.0f && WeaponEspInfo[i].pOutY > 1.0f && (float)WeaponEspInfo[i].distance > 4.0f)
//DrawString(Font, (int)WeaponEspInfo[i].pOutX, (int)WeaponEspInfo[i].pOutY, D3DCOLOR_ARGB(255, 255, 255, 255), "o");
}
}
//do aim
if (aimbot == 1 && WeaponEspInfo.size() != NULL)
{
UINT BestTarget = -1;
DOUBLE fClosestPos = 99999;
for (unsigned int i = 0; i < WeaponEspInfo.size(); i++)
{
//aimfov
float radiusx = (aimfov*5.0f) * (ScreenCX / 100.0f);
float radiusy = (aimfov*5.0f) * (ScreenCY / 100.0f);
if (aimfov == 0)
{
radiusx = 5.0f * (ScreenCX / 100.0f);
radiusy = 5.0f * (ScreenCY / 100.0f);
}
//get crosshairdistance
WeaponEspInfo[i].CrosshairDistance = GetDistance(WeaponEspInfo[i].pOutX, WeaponEspInfo[i].pOutY, ScreenCX, ScreenCY);
//if in fov
if (WeaponEspInfo[i].pOutX >= ScreenCX - radiusx && WeaponEspInfo[i].pOutX <= ScreenCX + radiusx && WeaponEspInfo[i].pOutY >= ScreenCY - radiusy && WeaponEspInfo[i].pOutY <= ScreenCY + radiusy)
//get closest/nearest target to crosshair
if (WeaponEspInfo[i].CrosshairDistance < fClosestPos)
{
fClosestPos = WeaponEspInfo[i].CrosshairDistance;
BestTarget = i;
}
}
//if nearest target to crosshair
if (BestTarget != -1 && WeaponEspInfo[BestTarget].RealDistance > 4.0f)//do not aim at self
{
double DistX = WeaponEspInfo[BestTarget].pOutX - ScreenCX;
double DistY = WeaponEspInfo[BestTarget].pOutY - ScreenCY;
DistX /= (0.5f + (float)aimsens*0.5f);
DistY /= (0.5f + (float)aimsens*0.5f);
//aim
if (GetAsyncKeyState(Daimkey) & 0x8000)
mouse_event(MOUSEEVENTF_MOVE, (float)DistX, (float)DistY, 0, NULL);
//autoshoot on
if ((!GetAsyncKeyState(VK_LBUTTON) && (autoshoot == 1) && (GetAsyncKeyState(Daimkey) & 0x8000))) //
{
if (autoshoot == 1 && !IsPressed)
{
IsPressed = true;
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
}
}
}
}
WeaponEspInfo.clear();
//autoshoot off
if (autoshoot == 1 && IsPressed)
{
if (timeGetTime() - astime >= asdelay)
{
IsPressed = false;
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
astime = timeGetTime();
}
}
/*
//draw logger
if (Font && countnum != 0)
{
char szString[255];
sprintf_s(szString, "countnum = %d", countnum);
DrawString(Font, 219, 99, D3DCOLOR_ARGB(255, 0, 0, 0), (char*)&szString[0]);
DrawString(Font, 221, 101, D3DCOLOR_ARGB(255, 0, 0, 0), (char*)&szString[0]);
DrawString(Font, 220, 100, D3DCOLOR_ARGB(255, 255, 255, 255), (char*)&szString[0]);
DrawString(Font, 220, 110, D3DCOLOR_ARGB(255, 255, 255, 255), "hold P to +");
DrawString(Font, 220, 120, D3DCOLOR_ARGB(255, 255, 255, 255), "hold O to -");
}
*/
return Present_orig(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
//==========================================================================================================================
HRESULT APIENTRY Reset_hook(IDirect3DDevice9* pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters)
{
if (Font)
Font->OnLostDevice();
HRESULT ResetReturn = Reset_orig(pDevice, pPresentationParameters);
if (SUCCEEDED(ResetReturn))
{
if (Font)
Font->OnResetDevice();
InitOnce = true;
}
return ResetReturn;
}
//==========================================================================================================================
HANDLE(WINAPI *Real_CreateFile)(LPCWSTR lpFileName,DWORD dwDesiredAccess,DWORD dwShareMode,LPSECURITY_ATTRIBUTES lpSecurityAttributes,DWORD dwCreationDisposition,DWORD dwFlagsAndAttributes,HANDLE hTemplateFile) = CreateFileW;
HANDLE WINAPI Routed_CreateFile(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
{
char buffer[500];
wcstombs(buffer, lpFileName, 500);
if (strcmp(buffer + strlen(buffer) - 4, ".jpg") == 0)//find gm_complaint_x.jpg
{
Log("buffer == %s", buffer);//log jpg
}
return Real_CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
}
//==========================================================================================================================
DWORD WINAPI RosD3D(__in LPVOID lpParameter)
{
HMODULE dDll = NULL;
while (!dDll)
{
dDll = GetModuleHandleA("d3d9.dll");
Sleep(100);
}
CloseHandle(dDll);
IDirect3D9* d3d = NULL;
IDirect3DDevice9* d3ddev = NULL;
HWND tmpWnd = CreateWindowA("BUTTON", "RosD3D", WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, NULL, NULL, Hand, NULL);
if (tmpWnd == NULL)
{
//Log("[DirectX] Failed to create temp window");
return 0;
}
d3d = Direct3DCreate9(D3D_SDK_VERSION);
if (d3d == NULL)
{
DestroyWindow(tmpWnd);
//Log("[DirectX] Failed to create temp Direct3D interface");
return 0;
}
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = tmpWnd;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
HRESULT result = d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, tmpWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
if (result != D3D_OK)
{
d3d->Release();
DestroyWindow(tmpWnd);
//Log("[DirectX] Failed to create temp Direct3D device");
return 0;
}
// We have the device, so walk the vtable to get the address of all the dx functions in d3d9.dll
#if defined _M_X64
DWORD64* dVtable = (DWORD64*)d3ddev;
dVtable = (DWORD64*)dVtable[0];
#elif defined _M_IX86
DWORD* dVtable = (DWORD*)d3ddev;
dVtable = (DWORD*)dVtable[0]; // == *d3ddev
#endif
//Log("[DirectX] dVtable: %x", dVtable);
//for(int i = 0; i < 95; i++)
//{
//Log("[DirectX] vtable[%i]: %x, pointer at %x", i, dVtable[i], &dVtable[i]);
//}
// Detour functions x86 & x64
if (MH_Initialize() != MH_OK) { return 1; }
if (MH_CreateHook((DWORD_PTR*)dVtable[17], &Present_hook, reinterpret_cast<void**>(&Present_orig)) != MH_OK) { return 1; }
if (MH_EnableHook((DWORD_PTR*)dVtable[17]) != MH_OK) { return 1; }
if (MH_CreateHook((DWORD_PTR*)dVtable[100], &SetStreamSource_hook, reinterpret_cast<void**>(&SetStreamSource_orig)) != MH_OK) { return 1; }
if (MH_EnableHook((DWORD_PTR*)dVtable[100]) != MH_OK) { return 1; }
if (MH_CreateHook((DWORD_PTR*)dVtable[65], &SetTexture_hook, reinterpret_cast<void**>(&SetTexture_orig)) != MH_OK) { return 1; }
if (MH_EnableHook((DWORD_PTR*)dVtable[65]) != MH_OK) { return 1; }
if (MH_CreateHook((DWORD_PTR*)dVtable[16], &Reset_hook, reinterpret_cast<void**>(&Reset_orig)) != MH_OK) { return 1; }
if (MH_EnableHook((DWORD_PTR*)dVtable[16]) != MH_OK) { return 1; }
if (MH_CreateHook((DWORD_PTR*)dVtable[32], &hkGetRenderTargetData, reinterpret_cast<void**>(&oGetRenderTargetData)) != MH_OK) { return 1; }
if (MH_EnableHook((DWORD_PTR*)dVtable[32]) != MH_OK) { return 1; }
if (MH_CreateHook((DWORD_PTR*)dVtable[36], &hkCreateOffscreenPlainSurface, reinterpret_cast<void**>(&oCreateOffscreenPlainSurface)) != MH_OK) { return 1; }
if (MH_EnableHook((DWORD_PTR*)dVtable[36]) != MH_OK) { return 1; }
HMODULE modd = LoadLibrary(TEXT("Kernel32.dll"));
void* ptrr = GetProcAddress(modd, "CreateFileW");
MH_CreateHook(ptrr, Routed_CreateFile, reinterpret_cast<void**>(&Real_CreateFile));
MH_EnableHook(ptrr);
//Log("[Detours] Detours attached\n");
d3ddev->Release();
d3d->Release();
DestroyWindow(tmpWnd);
return 1;
}
//==========================================================================================================================
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
Hand = hModule;
DisableThreadLibraryCalls(hModule); //Kapat *********.Com
GetModuleFileNameA(hModule, dlldir, 512);
for (int i = (int)strlen(dlldir); i > 0; i--)
{
if (dlldir[i] == '\\')
{
dlldir[i + 1] = 0;
break;
}
}
CreateThread(0, 0, RosD3D, 0, 0, 0); //Hook Burda *********.Com
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
break;
}
return TRUE;
}
C++:
#include <windows.h>
#include <fstream>
#include <string>
#include <vector>
#include <d3d9.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "winmm.lib")
//dx sdk *********.Com Ömer Karakurt Main.h'dir buda
#include "DXSDK\d3dx9.h"
#if defined _M_X64
#pragma comment(lib, "DXSDK/x64/d3dx9.lib")
#elif defined _M_IX86
#pragma comment(lib, "DXSDK/x86/d3dx9.lib")
#endif
//DX Includes
//#include <DirectXMath.h>
//using namespace DirectX;
#include "MinHook/include/MinHook.h" //detour
using namespace std;
#pragma warning (disable: 4244) //
#pragma warning (disable: 4996)
#define _CRT_SECURE_NO_DEPRECATE
//==========================================================================================================================
HMODULE Hand;
LPDIRECT3DDEVICE9 pDevice;
UINT Stride;
D3DVIEWPORT9 Viewport; //use this Viewport
float ScreenCX;
float ScreenCY;
LPD3DXFONT Font; //font
IDirect3DVertexShader9* vShader;
UINT vSize;
D3DVERTEXBUFFER_DESC vdesc;
bool InitOnce = true;
LPDIRECT3DTEXTURE9 Red, Green, Blue, Yellow;
int countnum = 0;
static BOOL screenshot_taken = FALSE;
//==========================================================================================================================
//features
//visuals
int wallhack = 1; //wallhack
int esp = 10; //esp
int nograss = 1; //nograss
int nofog = 1; //nofog
//aimbot settings
int aimbot = 1;
int aimkey = 2;
DWORD Daimkey = VK_RBUTTON; //aimkey
int aimsens = 1; //aim sensitivity, makes aim smoother
int aimfov = 3; //aim field of view in %
int aimheight = 3; //aim height value, high value aims higher
//autoshoot settings
int autoshoot = 0;
unsigned int asdelay = 49; //use x-999 (shoot for xx millisecs, looks more legit)
bool IsPressed = false; //
DWORD astime = timeGetTime(); //autoshoot timer
//==========================================================================================================================
// getdir & log
char dlldir[320];
char* GetDirFile(char *name)
{
static char pldir[320];
strcpy_s(pldir, dlldir);
strcat_s(pldir, name);
return pldir;
}
void Log(const char *fmt, ...)
{
if (!fmt) return;
char text[4096];
va_list ap;
va_start(ap, fmt);
vsprintf_s(text, fmt, ap);
va_end(ap);
ofstream logfile(GetDirFile("log.txt"), ios::app);
if (logfile.is_open() && text) logfile << text << endl;
logfile.close();
}
//==========================================================================================================================
// Parameters:
//
// float4 CameraPos;
// float4 FogInfo;
// float4 PointLightAttr[5];
// float4 ShadowLightAttr[5];
// row_major float4x4 texTrans0;
// row_major float4x4 world;
// row_major float4x4 wvp;
//
//
// Registers:
//
// Name Reg Size
// --------------- ----- ----
// PointLightAttr c0 5
// world c5 4
// ShadowLightAttr c9 4
// wvp c13 4
// texTrans0 c17 3
// FogInfo c20 1
// CameraPos c21 1
//calc distance
float GetDistance(float Xx, float Yy, float xX, float yY)
{
return sqrt((yY - Yy) * (yY - Yy) + (xX - Xx) * (xX - Xx));
}
struct WeaponEspInfo_t
{
float pOutX, pOutY, RealDistance, vSizeod;
float CrosshairDistance;
};
std::vector<WeaponEspInfo_t>WeaponEspInfo;
//w2s for weapons
void AddWeapons(LPDIRECT3DDEVICE9 Device)
{
D3DXMATRIX matrix;
Device->GetVertexShaderConstantF(13, matrix, 4);
D3DXVECTOR3 pOut, pIn(0, (float)aimheight, 0);
float distance = pIn.x * matrix._14 + pIn.y * matrix._24 + pIn.z * matrix._34 + matrix._44;
D3DXVec3TransformCoord(&pOut, &pIn, &matrix);
pOut.x = Viewport.X + (1.0f + pOut.x) *Viewport.Width / 2.0f;
pOut.y = Viewport.Y + (1.0f - pOut.y) *Viewport.Height / 2.0f;
WeaponEspInfo_t pWeaponEspInfo = { static_cast<float>(pOut.x), static_cast<float>(pOut.y), static_cast<float>(distance*0.1f), static_cast<float>(vSize) };
WeaponEspInfo.push_back(pWeaponEspInfo);
}
//==========================================================================================================================
IDirect3DPixelShader9* oldsShader;
void DrawBox(IDirect3DDevice9 *pDevice, float x, float y, float w, float h, D3DCOLOR Color)
{
struct Vertex
{
float x, y, z, ht;
DWORD Color;
}
V[4] = { { x, y + h, 0.0f, 0.0f, Color },{ x, y, 0.0f, 0.01f, Color },
{ x + w, y + h, 0.0f, 0.0f, Color },{ x + w, y, 0.0f, 0.0f, Color } };
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
pDevice->GetPixelShader(&oldsShader);
pDevice->SetTexture(0, Blue);
pDevice->SetPixelShader(0);
// mix texture color
pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
// mix texture alpha
pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
//pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
//pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
//pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
pDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, V, sizeof(Vertex));
pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
pDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
pDevice->SetPixelShader(oldsShader);
}
void DrawP(LPDIRECT3DDEVICE9 Device, int baseX, int baseY, int baseW, int baseH, D3DCOLOR Cor)
{
D3DRECT BarRect = { baseX, baseY, baseX + baseW, baseY + baseH };
Device->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, Cor, 0, 0);
}
void DrawCornerBox(LPDIRECT3DDEVICE9 Device, int x, int y, int w, int h, int borderPx, DWORD borderColor)
{
DrawP(Device, x - (w / 2), (y - h + borderPx), w / 3, borderPx, borderColor); //bottom
DrawP(Device, x - (w / 2) + w - w / 3, (y - h + borderPx), w / 3, borderPx, borderColor); //bottom
DrawP(Device, x - (w / 2), (y - h + borderPx), borderPx, w / 3, borderColor); //left
DrawP(Device, x - (w / 2), (y - h + borderPx) + h - w / 3, borderPx, w / 3, borderColor); //left
DrawP(Device, x - (w / 2), y, w / 3, borderPx, borderColor); //top
DrawP(Device, x - (w / 2) + w - w / 3, y, w / 3, borderPx, borderColor); //top
DrawP(Device, (x + w - borderPx) - (w / 2), (y - h + borderPx), borderPx, w / 3, borderColor);//right
DrawP(Device, (x + w - borderPx) - (w / 2), (y - h + borderPx) + h - w / 3, borderPx, w / 3, borderColor);//right
}
HRESULT DrawString(LPD3DXFONT Font, INT X, INT Y, DWORD dColor, CONST PCHAR cString, ...)
{
HRESULT hRet;
CHAR buf[512] = { NULL };
va_list ArgumentList;
va_start(ArgumentList, cString);
_vsnprintf_s(buf, sizeof(buf), sizeof(buf) - strlen(buf), cString, ArgumentList);
va_end(ArgumentList);
RECT rc[2];
SetRect(&rc[0], X, Y, X, 0);
SetRect(&rc[1], X, Y, X + 50, 50);
hRet = D3D_OK;
if (SUCCEEDED(hRet))
{
Font->DrawTextA(NULL, buf, -1, &rc[0], DT_NOCLIP, 0xFF000000);
hRet = Font->DrawTextA(NULL, buf, -1, &rc[1], DT_NOCLIP, dColor);
}
return hRet;
}
HRESULT DrawCenteredString(LPD3DXFONT Font, INT X, INT Y, DWORD dColor, CONST PCHAR cString, ...)
{
HRESULT hRet;
CHAR buf[512] = { NULL };
va_list ArgumentList;
va_start(ArgumentList, cString);
_vsnprintf_s(buf, sizeof(buf), sizeof(buf) - strlen(buf), cString, ArgumentList);
va_end(ArgumentList);
RECT rc[2];
SetRect(&rc[0], X, Y, X, 0);
SetRect(&rc[1], X, Y, X + 2, 2);
hRet = D3D_OK;
if (SUCCEEDED(hRet))
{
Font->DrawTextA(NULL, buf, -1, &rc[0], DT_NOCLIP | DT_CENTER, 0xFF000000);
hRet = Font->DrawTextA(NULL, buf, -1, &rc[1], DT_NOCLIP | DT_CENTER, dColor);
}
return hRet;
}
HRESULT GenerateTexture(IDirect3DDevice9 *pDevice, IDirect3DTexture9 **ppD3Dtex, DWORD colour32)
{
if (FAILED(pDevice->CreateTexture(8, 8, 1, 0, D3DFMT_A4R4G4B4, D3DPOOL_MANAGED, ppD3Dtex, NULL)))
return E_FAIL;
WORD colour16 = ((WORD)((colour32 >> 28) & 0xF) << 12)
| (WORD)(((colour32 >> 20) & 0xF) << 8)
| (WORD)(((colour32 >> 12) & 0xF) << 4)
| (WORD)(((colour32 >> 4) & 0xF) << 0);
D3DLOCKED_RECT d3dlr;
(*ppD3Dtex)->LockRect(0, &d3dlr, 0, 0);
WORD *pDst16 = (WORD*)d3dlr.pBits;
for (int xy = 0; xy < 8 * 8; xy++)
*pDst16++ = colour16;
(*ppD3Dtex)->UnlockRect(0);
return S_OK;
}
class D3DTLVERTEX
{
public:
FLOAT X, Y, X2, Y2;
DWORD Color;
};
IDirect3DPixelShader9* oldlShader;
void DrawLine(IDirect3DDevice9* pDevice, float X, float Y, float X2, float Y2, float Width, D3DCOLOR Color, bool AntiAliased)
{
D3DTLVERTEX qV[2] = {
{ (float)X , (float)Y, 0.0f, 1.0f, Color },
{ (float)X2 , (float)Y2 , 0.0f, 1.0f, Color },
};
const DWORD D3DFVF_TL = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
pDevice->SetFVF(D3DFVF_TL);
pDevice->GetPixelShader(&oldlShader);
//pDevice->SetTexture(0, Yellow);
pDevice->SetTexture(0, NULL);
pDevice->SetPixelShader(0);
pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
pDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
pDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, (AntiAliased ? TRUE : FALSE));
pDevice->DrawPrimitiveUP(D3DPT_LINELIST, 2, qV, sizeof(D3DTLVERTEX));
pDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, FALSE);
pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
pDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE);
pDevice->SetPixelShader(oldlShader);
}
//==========================================================================================================================
void SaveCfg()
{
ofstream fout;
fout.open(GetDirFile("rosd3d.ini"), ios::trunc);
fout << "wallhack " << wallhack << endl;
fout << "esp " << esp << endl;
fout << "aimbot " << aimbot << endl;
fout << "aimkey " << aimkey << endl;
fout << "aimsens " << aimsens << endl;
fout << "aimfov " << aimfov << endl;
fout << "aimheight " << aimheight << endl;
fout << "autoshoot " << autoshoot << endl;
fout << "nograss " << nograss << endl;
fout << "nofog " << nofog << endl;
fout.close();
}
void LoadCfg()
{
ifstream fin;
string Word = "";
fin.open(GetDirFile("rosd3d.ini"), ifstream::in);
fin >> Word >> wallhack;
fin >> Word >> esp;
fin >> Word >> aimbot;
fin >> Word >> aimkey;
fin >> Word >> aimsens;
fin >> Word >> aimfov;
fin >> Word >> aimheight;
fin >> Word >> autoshoot;
fin >> Word >> nograss;
fin >> Word >> nofog;
fin.close();
}
//==========================================================================================================================
// menu stuff
int menuselect = 0;
int Current = true;
int PosX = 30;
int PosY = 27;
int ShowMenu = false; //off by default
POINT Pos;
//LPD3DXFONT Font; //font
int CheckTab(int x, int y, int w, int h)
{
if (ShowMenu)
{
GetCursorPos(&Pos);
ScreenToClient(GetForegroundWindow(), &Pos);
if (Pos.x > x && Pos.x < x + w && Pos.y > y && Pos.y < y + h)
{
if (GetAsyncKeyState(VK_LBUTTON) & 1)
{
//return 1; //disabled mouse selection in menu
}
return 2;
}
}
return 0;
}
void WriteText(int x, int y, DWORD color, char *text)
{
RECT rect;
SetRect(&rect, x, y, x, y);
Font->DrawText(0, text, -1, &rect, DT_NOCLIP | DT_LEFT, color);
}
void lWriteText(int x, int y, DWORD color, char *text)
{
RECT rect;
SetRect(&rect, x, y, x, y);
Font->DrawText(0, text, -1, &rect, DT_NOCLIP | DT_RIGHT, color);
}
void Category(LPDIRECT3DDEVICE9 pDevice, char *text)
{
if (ShowMenu)
{
int Check = CheckTab(PosX + 44, (PosY + 51) + (Current * 15), 190, 10);
DWORD ColorText;
ColorText = D3DCOLOR_ARGB(255, 255, 0, 255);
if (Check == 2)
ColorText = D3DCOLOR_ARGB(255, 255, 255, 255);
if (menuselect == Current)
ColorText = D3DCOLOR_ARGB(255, 255, 255, 255);
WriteText(PosX + 44, PosY + 50 + (Current * 15) - 1, ColorText, text);
lWriteText(PosX + 236, PosY + 50 + (Current * 15) - 1, ColorText, "[-]");
Current++;
}
}
void AddItem(LPDIRECT3DDEVICE9 pDevice, char *text, int &var, char **opt, int MaxValue)
{
if (ShowMenu)
{
int Check = CheckTab(PosX + 44, (PosY + 51) + (Current * 15), 190, 10);
DWORD ColorText;
if (var)
{
//DrawBox(pDevice, PosX+44, PosY+51 + (Current * 15), 10, 10, Green);
ColorText = D3DCOLOR_ARGB(255, 0, 255, 0);
}
if (var == 0)
{
//DrawBox(pDevice, PosX+44, PosY+51 + (Current * 15), 10, 10, Red);
ColorText = D3DCOLOR_ARGB(255, 255, 0, 0);
}
if (Check == 1)
{
var++;
if (var > MaxValue)
var = 0;
}
if (Check == 2)
ColorText = D3DCOLOR_ARGB(255, 255, 255, 255);
if (menuselect == Current)
{
static int lasttick_right = GetTickCount64();
static int lasttick_left = GetTickCount64();
if (GetAsyncKeyState(VK_RIGHT) && GetTickCount64() - lasttick_right > 100)
{
lasttick_right = GetTickCount64();
var++;
if (var > MaxValue)
var = 0;
}
else if (GetAsyncKeyState(VK_LEFT) && GetTickCount64() - lasttick_left > 100)
{
lasttick_left = GetTickCount64();
var--;
if (var < 0)
var = MaxValue;
}
}
if (menuselect == Current)
ColorText = D3DCOLOR_ARGB(255, 255, 255, 255);
WriteText(PosX + 44, PosY + 50 + (Current * 15) - 1, D3DCOLOR_ARGB(255, 50, 50, 50), text);
WriteText(PosX + 45, PosY + 51 + (Current * 15) - 1, ColorText, text);
lWriteText(PosX + 236, PosY + 50 + (Current * 15) - 1, D3DCOLOR_ARGB(255, 100, 100, 100), opt[var]);
lWriteText(PosX + 237, PosY + 51 + (Current * 15) - 1, ColorText, opt[var]);
Current++;
}
}
//==========================================================================================================================
// menu part
char *opt_OnOff[] = { "[OFF]", "[On]" };
char *opt_WhChams[] = { "[OFF]", "[On]", "[Color]" };
char *opt_ZeroTen[] = { "[0]", "[1]", "[2]", "[3]", "[4]", "[5]", "[6]", "[7]", "[8]", "[9]", "[10]" };
char *opt_Keys[] = { "[OFF]", "[Shift]", "[RMouse]", "[LMouse]", "[Ctrl]", "[Alt]", "[Space]", "[X]", "[C]" };
char *opt_aimfov[] = { "[0]", "[5%]", "[10%]", "[15%]", "[20%]", "[25%]", "[30%]", "[35%]", "[40%]", "[45%]" };
char *opt_autoshoot[] = { "[OFF]", "[OnKeyDown]" };
void DrawMenu(LPDIRECT3DDEVICE9 pDevice)
{
static int lasttick_insert = GetTickCount64();
if (GetAsyncKeyState(VK_INSERT) && GetTickCount64() - lasttick_insert > 100)
{
lasttick_insert = GetTickCount64();
ShowMenu = !ShowMenu;
//save settings
SaveCfg();
}
if (ShowMenu)
{
static int lasttick_up = GetTickCount64();
if (GetAsyncKeyState(VK_UP) && GetTickCount64() - lasttick_up > 75)
{
lasttick_up = GetTickCount64();
menuselect--;
}
static int lasttick_down = GetTickCount64();
if (GetAsyncKeyState(VK_DOWN) && GetTickCount64() - lasttick_down > 75)
{
lasttick_down = GetTickCount64();
menuselect++;
}
Current = 1;
AddItem(pDevice, " Wallhack", wallhack, opt_WhChams, 2);
AddItem(pDevice, " Esp", esp, opt_ZeroTen, 10);
AddItem(pDevice, " Aimbot", aimbot, opt_OnOff, 1);
AddItem(pDevice, " Aimkey", aimkey, opt_Keys, 8);
AddItem(pDevice, " Aimsens", aimsens, opt_ZeroTen, 10);
AddItem(pDevice, " Aimfov", aimfov, opt_aimfov, 9);
AddItem(pDevice, " Aimheight", aimheight, opt_ZeroTen, 5);
AddItem(pDevice, " Autoshoot", autoshoot, opt_autoshoot, 1);
AddItem(pDevice, " No Grass", nograss, opt_OnOff, 1);
AddItem(pDevice, " No Fog", nofog, opt_OnOff, 1);
if (menuselect >= Current)
menuselect = 1;
if (menuselect < 1)
menuselect = 10;//Current;
}
}
//=====================================================================================================================