From ea771008f7028cdb72c553b5679d61067c8d160e Mon Sep 17 00:00:00 2001 From: gggaa2152 <60614405+gggaa2152@users.noreply.github.com> Date: Mon, 6 Apr 2026 02:51:05 +0800 Subject: [PATCH] Update main.cpp --- main.cpp | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/main.cpp b/main.cpp index 638aade84..1e699ba87 100644 --- a/main.cpp +++ b/main.cpp @@ -1,44 +1,40 @@ #include #include #include -#include // 必须包含,修复 sleep 报错 +#include #include #include #include -#include #include "dobby.h" #include "imgui.h" #include "imgui_impl_android.h" #include "imgui_impl_opengl3.h" -#define TAG "JKMenu_Core" +#define TAG "JKMenu_SGame" #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) static bool g_Initialized = false; -static bool g_VulkanMode = false; - typedef EGLBoolean (*eglSwapBuffers_t)(EGLDisplay, EGLSurface); static eglSwapBuffers_t old_eglSwapBuffers = nullptr; -// 简单的 ImGui 菜单界面 void DrawJKMenu() { if (!ImGui::GetCurrentContext()) return; - ImGui::SetNextWindowSize(ImVec2(400, 300), ImGuiCond_FirstUseEver); - ImGui::Begin("JKMenu - Version 1.0", nullptr, ImGuiWindowFlags_AlwaysAutoResize); - ImGui::Text("Render: %s", g_VulkanMode ? "Vulkan (Limited Support)" : "GLES 3.0 (Active)"); + ImGui::Begin("JKMenu for SGame", nullptr, ImGuiWindowFlags_AlwaysAutoResize); + ImGui::Text("Build Date: 2026-04-06"); ImGui::Separator(); - if (ImGui::Button("Log Test")) { LOGI("ImGui Button Clicked!"); } + static bool hack_enabled = false; + ImGui::Checkbox("功能开关示例", &hack_enabled); ImGui::End(); } -// OpenGL 渲染 Hook EGLBoolean hook_eglSwapBuffers(EGLDisplay dpy, EGLSurface surf) { if (!g_Initialized) { ImGui::CreateContext(); ImGui_ImplAndroid_Init(nullptr); ImGui_ImplOpenGL3_Init("#version 300 es"); g_Initialized = true; + LOGI("ImGui Initialized in SGame process."); } ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplAndroid_NewFrame(); @@ -50,20 +46,13 @@ EGLBoolean hook_eglSwapBuffers(EGLDisplay dpy, EGLSurface surf) { } void* init_thread(void*) { - LOGI("JKMenu init_thread started..."); - sleep(5); // 等待游戏完全进入 - - // 探测 Vulkan 驱动 - if (dlopen("vulkan.adreno.so", RTLD_NOLOAD)) { - g_VulkanMode = true; - LOGI("Detected Vulkan. Switch to Compatibility Mode if menu is invisible."); - } - - // 挂载 EGL Hook (libEGL.so 在 Android 兼容模式下必用) + // 王者荣耀启动较慢,建议延迟 10 秒等待渲染库加载完毕 + sleep(10); + void* egl_addr = DobbySymbolResolver("libEGL.so", "eglSwapBuffers"); if (egl_addr) { DobbyHook(egl_addr, (void*)hook_eglSwapBuffers, (void**)&old_eglSwapBuffers); - LOGI("GLES Hooked successfully."); + LOGI("Hook eglSwapBuffers Success!"); } return nullptr; }