mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-10 00:15:57 +01:00
Update main.cpp
This commit is contained in:
parent
66b9fb5d0d
commit
87e6c9f2c6
59
main.cpp
59
main.cpp
@ -6,6 +6,8 @@
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// 核心库包含
|
||||
#include "dobby.h"
|
||||
@ -34,27 +36,27 @@ void DrawImGuiMenu() {
|
||||
if (!g_ShowMenu) return;
|
||||
|
||||
ImGui::SetNextWindowSize(ImVec2(400, 350), ImGuiCond_FirstUseEver);
|
||||
ImGui::Begin("JKMenu - SGame Final Debug", &g_ShowMenu);
|
||||
ImGui::Begin("JKMenu - SGame Multi-Hook", &g_ShowMenu);
|
||||
|
||||
ImGui::Text("Device: OnePlus Pad Pro 2");
|
||||
ImGui::Text("Status: Rendering...");
|
||||
ImGui::Text("Target: com.tencent.tmgp.sgame");
|
||||
ImGui::Text("Screen: %dx%d", g_Width, g_Height);
|
||||
ImGui::Separator();
|
||||
|
||||
static float f = 0.0f;
|
||||
ImGui::SliderFloat("测试滑块", &f, 0.0f, 1.0f);
|
||||
static float f = 0.5f;
|
||||
ImGui::SliderFloat("Menu Scale", &f, 0.1f, 2.0f);
|
||||
|
||||
if (ImGui::Button("隐藏菜单")) {
|
||||
if (ImGui::Button("Hide Menu")) {
|
||||
g_ShowMenu = false;
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// 统一渲染入口
|
||||
// 核心渲染执行器
|
||||
void PerformRender(EGLDisplay dpy, EGLSurface surface) {
|
||||
if (!g_Initialized) {
|
||||
LOGI("Hooked Swap triggered! Initializing ImGui...");
|
||||
LOGI("SUCCESS! A Hooked Render function was triggered.");
|
||||
|
||||
eglQuerySurface(dpy, surface, EGL_WIDTH, &g_Width);
|
||||
eglQuerySurface(dpy, surface, EGL_HEIGHT, &g_Height);
|
||||
@ -67,7 +69,7 @@ void PerformRender(EGLDisplay dpy, EGLSurface surface) {
|
||||
|
||||
if (ImGui_ImplOpenGL3_Init("#version 300 es")) {
|
||||
g_Initialized = true;
|
||||
LOGI("ImGui Renderer Initialized: %dx%d", g_Width, g_Height);
|
||||
LOGI("ImGui Initialized: %dx%d", g_Width, g_Height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,40 +82,47 @@ void PerformRender(EGLDisplay dpy, EGLSurface surface) {
|
||||
}
|
||||
}
|
||||
|
||||
// Hook 后的 eglSwapBuffers
|
||||
EGLBoolean hooked_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) {
|
||||
// Hook 回调函数 (通用)
|
||||
EGLBoolean hooked_universal_swap(EGLDisplay dpy, EGLSurface surface) {
|
||||
PerformRender(dpy, surface);
|
||||
return orig_eglSwapBuffers(dpy, surface);
|
||||
}
|
||||
|
||||
// 尝试 Hook 王者荣耀内部可能使用的其它渲染函数名
|
||||
// 动态全量 Hook 逻辑
|
||||
void* hack_thread(void*) {
|
||||
LOGI("SO Loaded! Searching for render symbols...");
|
||||
|
||||
// 等待更久一点,确保 libGLESv2/libEGL 加载完全
|
||||
LOGI("SO Loaded! Waiting for engine to settle...");
|
||||
sleep(10);
|
||||
|
||||
// 尝试多个可能的 Hook 点
|
||||
const char* symbols[] = {"eglSwapBuffers", "nw_main_swap_buffers"};
|
||||
// 王者荣耀/金铲铲等腾讯游戏可能使用的渲染函数候选名单
|
||||
const char* symbol_list[] = {
|
||||
"eglSwapBuffers", // 标准 EGL
|
||||
"nw_main_swap_buffers", // 腾讯常用渲染 Hook 点
|
||||
"GameCanvas_SwapBuffers", // 部分引擎私有实现
|
||||
"_Z22nw_main_swap_buffersP10EGLDisplayP10EGLSurface" // 混淆后的符号名
|
||||
};
|
||||
|
||||
void* target = nullptr;
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
target = DobbySymbolResolver("libEGL.so", symbols[i]);
|
||||
if (!target) target = DobbySymbolResolver("libGLESv2.so", symbols[i]);
|
||||
if (!target) target = dlsym(RTLD_DEFAULT, symbols[i]);
|
||||
for (const char* sym : symbol_list) {
|
||||
// 尝试从不同的库寻找
|
||||
target = DobbySymbolResolver("libEGL.so", sym);
|
||||
if (!target) target = DobbySymbolResolver("libGLESv2.so", sym);
|
||||
if (!target) target = DobbySymbolResolver("libunity.so", sym); // 针对 Unity 游戏
|
||||
if (!target) target = dlsym(RTLD_DEFAULT, sym);
|
||||
|
||||
if (target) {
|
||||
LOGI("Found target %s at: %p", symbols[i], target);
|
||||
DobbyHook(target, (dobby_dummy_func_t)hooked_eglSwapBuffers, (dobby_dummy_func_t*)&orig_eglSwapBuffers);
|
||||
LOGI("Found potential render target: %s at %p", sym, target);
|
||||
DobbyHook(target, (dobby_dummy_func_t)hooked_universal_swap, (dobby_dummy_func_t*)&orig_eglSwapBuffers);
|
||||
if (orig_eglSwapBuffers) {
|
||||
LOGI("Hooked %s Successfully!", symbols[i]);
|
||||
// 如果 Hook 成功一个点,可以根据需要决定是否继续搜
|
||||
LOGI("Successfully hooked: %s", sym);
|
||||
// 只要成功 Hook 到了一个,通常就不需要再 Hook 其他的了
|
||||
// 但如果游戏有多个渲染管线,可以继续
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!orig_eglSwapBuffers) {
|
||||
LOGE("Failed to hook any render function. Checking if Vulkan is used...");
|
||||
LOGE("CRITICAL: Failed to find ANY render function. Game might be using Vulkan.");
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user