// main.h
#include "includes.h"
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
typedef long(__stdcall* EndScene)(LPDIRECT3DDEVICE9);
static EndScene oEndScene = NULL;
typedef long(__stdcall* Reset)(LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
static Reset oReset = NULL;
typedef long(__stdcall* PresentScene)(IDirect3DDevice9*, const RECT*, const RECT*, HWND, const RGNDATA*);
static PresentScene oPresent = NULL;
static WNDPROC oWndProc = NULL;
void InitImGui(LPDIRECT3DDEVICE9 pDevice, HWND window)
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF(("C:\\Windows\\Fonts\\Arial.ttf"), 20, NULL, io.Fonts->GetGlyphRangesCyrillic());
io.ConfigFlags = ImGuiConfigFlags_NoMouseCursorChange;
ImGui_ImplWin32_Init(window);
ImGui_ImplDX9_Init(pDevice);
// renderer::SetupStyle();
}
LRESULT CALLBACK hkWindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam)
{
if (ImGui_ImplWin32_WndProcHandler(hwnd, uMsg, wParam, lParam) > 0)
return 1L;
return ::CallWindowProcA(oWndProc, hwnd, uMsg, wParam, lParam);
}
long __stdcall hkPresent(IDirect3DDevice9* pDevice, const RECT* pSourceRect, const RECT* pDestRect, HWND hDestWindowOverride, const RGNDATA* pDirtyRegion)
{
if (!renderer::init) {
D3DDEVICE_CREATION_PARAMETERS params;
pDevice->GetCreationParameters(¶ms);
oWndProc = (WNDPROC)::SetWindowLongPtr((HWND)params.hFocusWindow, GWLP_WNDPROC, (LONG)hkWindowProc);
InitImGui(pDevice, params.hFocusWindow);
renderer::init = true;
}
// Unhook
if (GetAsyncKeyState(VK_END)) {
kiero::shutdown();
}
// Open Menu
if (GetAsyncKeyState(VK_HOME) & 1) {
renderer::Enabled = !renderer::Enabled;
}
if (renderer::Enabled) {
ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
auto flags = ImGuiConfigFlags_NoMouseCursorChange | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;
static int ttab = 0;
ImGui::Begin("DarwinTap", nullptr, flags);
if (ImGui::Button(u8"Аимбот", ImVec2(100.f, 0.f))) {
ttab = 1;
}
ImGui::SameLine(0.f, 2.f);
if (ImGui::Button(u8"Визуалы", ImVec2(100.f, 0.f))) {
ttab = 2;
}
ImGui::SameLine(0.f, 2.f);
if (ImGui::Button(u8"Другое", ImVec2(100.f, 0.f))) {
ttab = 3;
}
ImGui::SameLine(0.f, 2.f);
if (ImGui::Button(u8"Цвета", ImVec2(100.f, 0.f))) {
ttab = 4;
}
ImGui::End();
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
}
return oPresent(pDevice, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
}
long __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice) {
if (!renderer::init)
{
D3DDEVICE_CREATION_PARAMETERS params;
pDevice->GetCreationParameters(¶ms);
oWndProc = (WNDPROC)::SetWindowLongPtr((HWND)params.hFocusWindow, GWLP_WNDPROC, (LONG)hkWindowProc);
InitImGui(pDevice, params.hFocusWindow);
renderer::init = true;
}
// Unhook
if (GetAsyncKeyState(VK_END)) {
kiero::shutdown();
}
// Open Menu
if (GetAsyncKeyState(VK_HOME) & 1) {
renderer::Enabled = !renderer::Enabled;
}
if (renderer::Enabled) {
ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
auto flags = ImGuiConfigFlags_NoMouseCursorChange | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_AlwaysAutoResize;
static int ttab = 0;
ImGui::Begin("DarwinTap", nullptr, flags);
if (ImGui::Button(u8"Аимбот", ImVec2(100.f, 0.f))) {
ttab = 1;
}
ImGui::SameLine(0.f, 2.f);
if (ImGui::Button(u8"Визуалы", ImVec2(100.f, 0.f))) {
ttab = 2;
}
ImGui::SameLine(0.f, 2.f);
if (ImGui::Button(u8"Другое", ImVec2(100.f, 0.f))) {
ttab = 3;
}
ImGui::SameLine(0.f, 2.f);
if (ImGui::Button(u8"Цвета", ImVec2(100.f, 0.f))) {
ttab = 4;
}
ImGui::End();
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
}
return oEndScene(pDevice);
}
long __stdcall hkReset(LPDIRECT3DDEVICE9 pDevice, D3DPRESENT_PARAMETERS* pPresentationParameters)
{
ImGui_ImplDX9_InvalidateDeviceObjects();
long result = oReset(pDevice, pPresentationParameters);
ImGui_ImplDX9_CreateDeviceObjects();
return result;
}
int mainThread()
{
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
{
kiero::bind(17, (void**)&oPresent, hkPresent);
//kiero::bind(42, (void**)&oEndScene, hkEndScene);
kiero::bind(16, (void**)&oReset, hkReset);
}
return 0;
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, LPVOID)
{
switch(fdwReason){
case DLL_PROCESS_ATTACH: {
DisableThreadLibraryCalls(hInstance);
CloseHandle(CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)mainThread, NULL, 0, NULL));
break;
}
case DLL_PROCESS_DETACH: {
renderer::init = false;
kiero::shutdown();
ImGui_ImplWin32_Shutdown();
ImGui_ImplDX9_Shutdown();
ImGui::DestroyContext();
break;
}
}
return TRUE;
}