#include "cInclude.h"
#include <TlHelp32.h>
const int menuSizeX = 500;
const int menuSizeY = 350;
const int menuItems = 5;
const int menuSizeGeneralButtons = (menuSizeX / menuItems);
// Menu vars
int menuSelectItem = 1;
static bool wh_functions_on = false;
DWORD getModuleBaseAddress(DWORD pid, const char* name)
{
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pid);
MODULEENTRY32 mEntry;
mEntry.dwSize = sizeof(MODULEENTRY32);
do
{
if (!strcmp(mEntry.szModule, name))
{
CloseHandle(snapshot);
return (DWORD)mEntry.modBaseAddr;
}
} while (Module32Next(snapshot, &mEntry));
}
bool Create = false;
HRESULT APIENTRY myPresent(IDirect3DDevice9 * m_pDevice, CONST RECT* pSourceRect, CONST RECT* pDestRect, HWND hDestWindowOverride, CONST RGNDATA* pDirtyRegion)
{
if (Create == false)
{
ImGui_Init(hWnd, m_pDevice);
Create = true;
}
else
{
ImGui_NewFrame();
if (bShowWindow) {
DWORD dwFlag = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_ShowBorders | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize;
ImGui::Begin("\t\t\t\t\t\t\t\t\tR[O]SHEN CS:GO", NULL, ImVec2(menuSizeX, menuSizeY), 1.0f, dwFlag);
{
// Menu
if (ImGui::Button(u8"Visual", ImVec2(menuSizeGeneralButtons-10, 30))) {
}
ImGui::SameLine();
if (ImGui::Button(u8"Aim", ImVec2(menuSizeGeneralButtons - 10, 30))) {
}
ImGui::SameLine();
if (ImGui::Button(u8"ESP", ImVec2(menuSizeGeneralButtons - 10, 30))) {
}
ImGui::SameLine();
if (ImGui::Button(u8"SkinChanger", ImVec2(menuSizeGeneralButtons - 10, 30))) {
}
ImGui::SameLine();
if (ImGui::Button(u8"Other", ImVec2(menuSizeGeneralButtons - 10, 30))) {
}
}
ImGui::End();
}
ImGui::Render();
}
return oPresent->GetTrampoline()(m_pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
HRESULT APIENTRY myReset(IDirect3DDevice9* m_pDevice, D3DPRESENT_PARAMETERS *pPresentationParameters)
{
if (!Create)
return m_pDevice->Reset(pPresentationParameters);
ImGui_InvalidateDeviceObjects();
auto result = oReset->GetTrampoline()(m_pDevice, pPresentationParameters);
ImGui_CreateDeviceObjects();
return result;
}
bool Init()
{
bool bResult = false;
HMODULE hD3d9 = NULL;
if (hD3d9 = GetModuleHandleA("d3d9.dll"))
{
using oDirect3DCreate9Ex = HRESULT(WINAPI*)(UINT, IDirect3D9Ex**);
oDirect3DCreate9Ex pDirect3DCreate9Ex = (oDirect3DCreate9Ex)GetProcAddress(hD3d9, "Direct3DCreate9Ex");
if (pDirect3DCreate9Ex)
{
HRESULT hr = D3D_OK;
LPDIRECT3D9EX d3d9ex = nullptr;
if (SUCCEEDED(hr = pDirect3DCreate9Ex(D3D_SDK_VERSION, &d3d9ex)))
{
D3DPRESENT_PARAMETERS dp;
ZeroMemory(&dp, sizeof(dp));
dp.Windowed = 1;
dp.SwapEffect = D3DSWAPEFFECT_FLIP;
dp.BackBufferFormat = D3DFMT_A8R8G8B8;
dp.BackBufferCount = 1;
dp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
IDirect3DDevice9Ex *mDevice = nullptr;
if (SUCCEEDED(hr = d3d9ex->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_NULLREF, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &dp, NULL, &mDevice)))
{
bResult = true;
PVOID* vtbl = *reinterpret_cast<PVOID**>(mDevice);
auto& pContext = cContext::GetInstance();
pContext.ApplyDetour<PresentFn>(static_cast<PresentFn>(vtbl[17]), reinterpret_cast<PresentFn>(myPresent), &oPresent);
pContext.ApplyDetour<ResetFn>(static_cast<ResetFn>(vtbl[16]), reinterpret_cast<ResetFn>(myReset), &oReset);
mDevice->Release();
}
d3d9ex->Release();
}
}
}
return bResult;
}
unsigned WINAPI GUIDX(LPVOID lpParam)
{
// "Counter-Strike: Global Offensive" -- normal
// D3D9 Test
hWnd = FindWindowA(NULL, "D3D9 Test");
if (hWnd) {
m_pWindowProc = (WNDPROC)SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR)myWndProc);
}
while (!Init())
Sleep(200);
return 0L;
}
BOOL APIENTRY DllMain(
_In_ HINSTANCE hinstDLL,
_In_ DWORD fdwReason,
_In_ LPVOID lpvReserved) {
DisableThreadLibraryCalls(hinstDLL);
switch (fdwReason) {
case DLL_PROCESS_ATTACH: {
_beginthreadex(NULL, NULL, GUIDX, NULL, NULL, NULL);
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
SetWindowLongPtr(hWnd, GWL_WNDPROC, (LONG_PTR)m_pWindowProc);
break;
}
return TRUE;
}