#include "includes.h"
#include "visual.h"
#include "memory.h"
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
Present oPresent;
HWND window = NULL;
WNDPROC oWndProc;
ID3D11Device* pDevice = NULL;
ID3D11DeviceContext* pContext = NULL;
ID3D11RenderTargetView* mainRenderTargetView;
void InitImGui()
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags = ImGuiConfigFlags_NoMouseCursorChange;
ImGui_ImplWin32_Init(window);
ImGui_ImplDX11_Init(pDevice, pContext);
}
LRESULT __stdcall WndProc(const HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
if (true && ImGui_ImplWin32_WndProcHandler(hWnd, uMsg, wParam, lParam))
return true;
return CallWindowProc(oWndProc, hWnd, uMsg, wParam, lParam);
}
bool init = false;
bool isMenu = true;
bool ESP = false;
bool ThirdPerson = false;
float boxwidht = 0.5f;
int boxthickness = 2;
HRESULT __stdcall hkPresent(IDXGISwapChain* pSwapChain, UINT SyncInterval, UINT Flags)
{
if (!init)
{
if (SUCCEEDED(pSwapChain->GetDevice(__uuidof(ID3D11Device), (void**)& pDevice)))
{
pDevice->GetImmediateContext(&pContext);
DXGI_SWAP_CHAIN_DESC sd;
pSwapChain->GetDesc(&sd);
window = sd.OutputWindow;
ID3D11Texture2D* pBackBuffer;
pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)& pBackBuffer);
pDevice->CreateRenderTargetView(pBackBuffer, NULL, &mainRenderTargetView);
pBackBuffer->Release();
oWndProc = (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)WndProc);
InitImGui();
init = true;
}
else
return oPresent(pSwapChain, SyncInterval, Flags);
}
if (GetAsyncKeyState(VK_INSERT) & 1)
isMenu = !isMenu;
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
DWORD BaseAddress = (DWORD)GetModuleHandleA("client.dll");
if (!BaseAddress)
MessageBoxA(0, "client.dll not found", "Error", 0);
ImGui::Begin("My Cheat");
ImGui::Checkbox("ESP", &ESP);
ImGui::Checkbox("Third Person", &ThirdPerson);\
ImGui::Text("BaseAddress: 0x%p", (void*)BaseAddress);
ImGui::Text("BaseAddress: %llu", BaseAddress); // для 64-битных
ImGui::Text("BaseAddress: %u", (unsigned int)BaseAddress); // для 32-битных
ImGui::End();
//-allow_third_party_software
if (ESP)
{
V::PlayerESP();
uintptr_t entList = *(uintptr_t*)(BaseAddress + O::offsets::client_dll::dwEntityList);
if (entList)
{
uintptr_t lplr = *(uintptr_t*)(BaseAddress + O::offsets::client_dll::dwViewAngles);
for (int i = 0; i < 64; ++i) {
const auto list_entry = mem.Read<uintptr_t>(entList + 0x10 + 0x8 * (i >> 9));
if (!list_entry)
continue;
const auto controller = mem.Read<uintptr_t>(list_entry + 0x78 * (i & 0x1FF));
if (!controller)
continue;
const auto pawn_handle = mem.Read<uintptr_t>(controller + O::offsets::CCSPlayerController::m_hPlayerPawn);
const auto pawn_list_entry = mem.Read<uintptr_t>(entList + 0x10 + 0x8 * static_cast<uintptr_t>((pawn_handle & 0x7FFF) >> 9));
if (!pawn_list_entry)
continue;
auto pawn = mem.Read<uintptr_t>(pawn_list_entry + 0x78 * static_cast<uintptr_t>(pawn_handle & 0x1FF));
if (!pawn || pawn == lplr)
continue;
C_CSPlayerPawn player;
player.address = pawn;
int entityHp123 = mem.Read<int>(pawn + O::offsets::C_BaseEntity::m_iHealth);
ImGui::Text("HP: %d", entityHp123);
}
}
}
if (ThirdPerson)
{
uintptr_t lplr = *(uintptr_t*)(BaseAddress + O::offsets::client_dll::dwViewAngles);
if (lplr && IsBadReadPtr((void*)lplr, sizeof(uintptr_t)) == 0) // проверка валидности
{
uintptr_t observerModeAddr = lplr + O::offsets::CPlayer_ObserverServices::m_iObserverMode;
if (!IsBadWritePtr((void*)observerModeAddr, sizeof(int)))
{
*(int*)observerModeAddr = 1;
}
}
}
ImGui::Render();
pContext->OMSetRenderTargets(1, &mainRenderTargetView, NULL);
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
return oPresent(pSwapChain, SyncInterval, Flags);
}
DWORD WINAPI MainThread(LPVOID lpReserved)
{
bool init_hook = false;
do
{
if (kiero::init(kiero::RenderType::D3D11) == kiero::Status::Success)
{
kiero::bind(8, (void**)&oPresent, hkPresent);
init_hook = true;
}
} while (!init_hook);
return TRUE;
}
BOOL WINAPI DllMain(HMODULE hMod, DWORD dwReason, LPVOID lpReserved)
{
switch (dwReason)
{
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hMod);
CreateThread(nullptr, 0, MainThread, hMod, 0, nullptr);
break;
case DLL_PROCESS_DETACH:
kiero::shutdown();
break;
}
return TRUE;
}