1
0
forked from gcdsfh/PMDT
Files
PMDT/main.cpp
T
2026-05-03 14:19:19 +08:00

133 lines
5.2 KiB
C++
Executable File

#include <android_native_app_glue.h>
#include <EGL/egl.h>
#include "imgui/imgui.h"
#include "imgui/imgui_impl_android.h"
#include "imgui/imgui_impl_opengl3.h"
#include "font.h"
#include <dobby.h>
#include <fstream>
#include <vector>
#include <array>
#include <cstddef>
#include <sstream>
#include "structures/data/SDK.hpp"
using namespace SDK;
bool initImGui=false;
bool =true;
int screenWidth=2400,screenHeight=1080,glWidth,glHeight,gWidth,gHeight;
float density=-1;
uintptr_t UE4;
android_app*g_App=0;
static char s[64];
#include "refs.h"
#include "menu.h"
EGLBoolean (*orig_eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
EGLBoolean _eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) {
eglQuerySurface(dpy, surface, EGL_WIDTH, &glWidth);
eglQuerySurface(dpy, surface, EGL_HEIGHT, &glHeight);
if (glWidth <= 0 || glHeight <= 0)
return eglSwapBuffers(dpy, surface);
if (!g_App)
return eglSwapBuffers(dpy, surface);
screenWidth = ANativeWindow_getWidth(g_App->window);
screenHeight = ANativeWindow_getHeight(g_App->window);
density = AConfiguration_getDensity(g_App->config);
if (!initImGui) {
LoadLanguageSetting();
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.IniFilename = NULL;
ImGui::StyleColorsLight();//黑紫主题
ImGui_ImplAndroid_Init();
ImGui_ImplOpenGL3_Init("#version 300 es");
ImFontConfig font_cfg;
font_cfg.SizePixels = 22.0f;
io.Fonts->AddFontFromMemoryTTF((void*)Custom_data, Custom_size, 29.0f,
nullptr, io.Fonts->GetGlyphRangesChineseFull());
static const ImWchar diamondRange[] = { 0x25C6, 0x25C6, 0 };
ImFontConfig cfgMerge;
cfgMerge.MergeMode = true;
io.Fonts->AddFontFromMemoryTTF((void*)Custom_data, Custom_size, 29.0f,
&cfgMerge, diamondRange);
io.Fonts->Build();
io.Fonts->AddFontDefault(&font_cfg);
ImGuiStyle *style = &ImGui::GetStyle();
style->Alpha = 0.8;
style->GrabMinSize = 13.0f; // 设置滑块宽度
style->ScrollbarRounding = 2.0f; // 设置滚动条圆角
style->ScrollbarSize = 15.0f; // 设置滚动条宽度
style->WindowPadding = ImVec2(4, 9); // 设置窗口内容区域与窗口边界的内边距,这里是上下4,左右9单位
style->WindowRounding = 5.0f; // 设置窗口边角的圆角半径为5单位
style->FramePadding = ImVec2(3, 3); // 设置表单控件(如按钮)内容区域与边界的内边距
style->FrameRounding = 2.0f; // 设置表单控件边角的圆角半径为2单位
style->ItemSpacing = ImVec2(8, 4); // 设置控件之间的水平和垂直间距
style->ItemInnerSpacing = ImVec2(1, 10); // 设置控件内部元素之间的间距
style->CellPadding = ImVec2(5, 5); // 设置表格单元格的内边距
style->IndentSpacing = 23.0f; // 设置列表项缩进的间距
style->TouchExtraPadding = ImVec2(0, 0); // 设置触摸屏额外的内边距(这里设置为0,可能意味着不增加额外的触摸区域)
style->ButtonTextAlign = ImVec2(0.50f, 0.50f); // 设置按钮文本的对齐方式(水平和垂直居中)
style->DisplayWindowPadding = ImVec2(22, 22); // 设置显示窗口内容区域与窗口边界的内边距
style->DisplaySafeAreaPadding = ImVec2(4, 4); // 设置显示安全区域的内边距(避免内容被屏幕边缘裁剪)
style->AntiAliasedLines = true; // 启用抗锯齿线
style->CurveTessellationTol = 1.f; // 设置曲线细分公差
style->TabBorderSize = 0.001f; // 设置标签页边框的大小(这里设置为0,意味着没有边框)
style->WindowTitleAlign = ImVec2(0.5, 0.5); // 设置标题居中
ImGui::GetStyle().ScaleAllSizes(1.0f);
initImGui = true;
const ImWchar icons_ranges[]={0xf000,0xf3ff,0};
ImFontConfig icons_config;
ImFontConfig CustomFont;
CustomFont.FontDataOwnedByAtlas=false;
icons_config.MergeMode=true;
icons_config.PixelSnapH=true;
icons_config.OversampleH=2.5;
icons_config.OversampleV=2.5;
io.ConfigWindowsMoveFromTitleBarOnly=true;
}
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplAndroid_NewFrame(glWidth,glHeight);
ImGui::NewFrame();
DrawESP(ImGui::GetBackgroundDrawList(),glWidth, glHeight);
ImGuiIO & io = ImGui::GetIO();
();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
return orig_eglSwapBuffers(dpy,surface);
}
int32_t(*orig_onInputEvent)(struct android_app*app,AInputEvent*inputEvent);
int32_t onInputEvent(struct android_app*app,AInputEvent*inputEvent){
ImGui_ImplAndroid_HandleInputEvent(inputEvent,{(float)screenWidth/(float)glWidth,(float)screenHeight/(float)glHeight});
return orig_onInputEvent(app,inputEvent);
}
extern "C"{
void android_main(struct android_app*state){
app_dummy();
}
}
void*main_thread(void*){
UE4=get_Module_Base("libUE4.so");
while(!UE4){
UE4=get_Module_Base("libUE4.so");
sleep(1.5);
}
while(!g_App){
g_App=*(android_app**)(UE4+0x4249CA4);
sleep(1.5);
}
orig_onInputEvent=decltype(orig_onInputEvent)(g_App->onInputEvent);
g_App->onInputEvent=onInputEvent;
FName::GNames=GetGNames();
UObject::GUObjectArray=(FUObjectArray*)(UE4+0x454dd28);
DobbyHook((void*)DobbySymbolResolver(("/system/lib/libEGL.so"),("eglSwapBuffers")),(void*)_eglSwapBuffers,(void**)&orig_eglSwapBuffers);
DobbyHook((void*)(UE4 + 0xc5ebbc), (void*)gm, (void**)&ogm);
return 0;
}
__attribute__((constructor))void _init(){
pthread_t pid;
pthread_create(&pid,0,main_thread,0);
}