#include <Windows.h>
#include "ImGui/imgui.h"
#include "ImGui/imgui_impl_dx9.h"
// Оффсеты из sezzyaep/CS2-OFFSETS (проверено для v1.0.0)
#define ASPECT_RATIO_ADDR 0x4D3A8C // CViewSetup::flAspectRatio
#define VIEW_SETUP_PTR 0x00B5F69C
bool enabled = true;
float aspectRatio = 21.0f;
struct ViewSetup {
float flAspectRatio;
};
typedef struct {
ViewSetup* pViewSetup;
} CameraStruct;
void SetupMenu() {
ImGui::Begin("Aspect Ratio Changer", &enabled);
ImGui::SliderFloat("Aspect Ratio", &aspectRatio, 4.0f, 25.0f);
ImGui::End();
}
DWORD __stdcall HackThread(HMODULE hmod) {
LPDIRECT3DDEVICE9 pd3dDevice = nullptr;
while (!pd3dDevice) pd3dDevice = reinterpret_cast<LPDIRECT3DDEVICE9>(GetModuleHandleA("shadercache"))->lpVtbl->GetDevice;
ImGui_ImplDX9_Init(pd3dDevice);
CameraStruct* camera = (CameraStruct*)(GetClientState() + VIEW_SETUP_PTR);
while (true) {
if (GetAsyncKeyState(VK_INSERT) & 1)
enabled = !enabled;
if (pd3dDevice->TestCooperativeLevel() != D3DERR_DEVICELOST) {
ImGui_ImplDX9_NewFrame();
ImGui::NewFrame();
SetupMenu();
if (camera && camera->pViewSetup) {
if (enabled)
*(float*)((DWORD)camera->pViewSetup + ASPECT_RATIO_ADDR) = aspectRatio;
}
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
}
}
}
BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, LPVOID reserved) {
if (reason == DLL_PROCESS_ATTACH)
CreateThread(NULL, 0, HackThread, hmod, 0, NULL);
return TRUE;
}