-
Автор темы
- #1
Меню рисуется, но абсолютно не кликается/не работают элементы/не двигается/не расширяется
C++:
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
static EndScene oEndScene = NULL;
static WNDPROC oWndProc;
static HWND window = NULL;
void InitImGui(LPDIRECT3DDEVICE9 pDevice)
{
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontFromFileTTF("C:\\Windows\Fonts\Verdana.ttf", 25, NULL, io.Fonts->GetGlyphRangesCyrillic());
io.ConfigFlags = ImGuiConfigFlags_NoMouseCursorChange;
ImGui_ImplWin32_Init(window);
ImGui_ImplDX9_Init(pDevice);
}
typedef long(__stdcall* EndScene)(LPDIRECT3DDEVICE9);
bool imgui_init = false;
bool menu_show = false;
long __stdcall hkEndScene(LPDIRECT3DDEVICE9 pDevice)
{
if (!imgui_init)
{
InitImGui(pDevice);
imgui_init = true;
}
if (GetAsyncKeyState(VK_END)) {
kiero::shutdown();
return 0;
}
if (GetAsyncKeyState(VK_INSERT) & 1)
{
menu_show = !menu_show;
}
if (menu_show) {
ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
ImGui::Begin("ImGui Window");
ImGui::Checkbox("test checkbox", &test_checkbox);
ImGui::SliderInt("test slider", &test_slider, -1337, 1337);
ImGui::End();
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
}
return oEndScene(pDevice);
}
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 CALLBACK EnumWindowsCallback(HWND handle, LPARAM lParam)
{
DWORD wndProcId;
GetWindowThreadProcessId(handle, &wndProcId);
if (GetCurrentProcessId() != wndProcId)
return TRUE; // skip to next window
window = handle;
return FALSE; // window found abort search
}
HWND GetProcessWindow()
{
window = NULL;
EnumWindows(EnumWindowsCallback, NULL);
return window;
}
DWORD WINAPI kThread(LPVOID lpReserved)
{
bool attached = false;
do
{
if (kiero::init(kiero::RenderType::D3D9) == kiero::Status::Success)
{
kiero::bind(42, (void**)&oEndScene, hkEndScene);
do
window = GetProcessWindow();
while (window == NULL);
oWndProc = (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)WndProc);
attached = true;
}
} while (!attached);
return TRUE;
}