I'm making a mod for Imgui. I initially tried it on LGL for testing – it worked. I moved the hooks and calls to Imgui – but it stopped working. What should I do? Code:
What did I do wrong? The menu appears, but the mod doesn't work.
C++:
#include "../Include/KittyMemory/MemoryPatch.h"
#include "../Include/ImGui.h"
#include "../Include/RemapTools.h"
#include "../Include/Drawing.h"
#include "../Include/Unity.h"
#define targetLibName OBFUSCATE("libil2cpp.so")
#include "../Include/Macros.h"
#include "../Include/And64InlineHook/And64InlineHook.hpp"
void InitStyle()
{
ImGui::StyleColorsDark();
auto& Style = ImGui::GetStyle();
}
bool main_show = true;
bool is_AB = true;
bool is_AA = false;
bool is_V = false;
bool is_M = false;
/*bool testfunc = false;
bool isCash, Health;void *instanceBtn;*/
bool isCash = false;
void* CashInstance = nullptr;
void (*old_ctor)(void* instance);
void ctor(void* instance) {
CashInstance = instance;
old_ctor(instance);
}
void (*addcash)(void *);
void (*old_Update)(void* instance);
void Update(void* instance) {
if (instance && isCash) {
//*(int*)((uintptr_t)instance + 0x2C) = 99999;
addcash(instance);
}
old_Update(instance);
}
void DrawMenu() {
if (main_show) {
ImGui::SetNextWindowSize(ImVec2(950.000f, 640.000f), ImGuiCond_Once);
ImGui::Begin("ZailoxWare", &main_show, 2);
ImGui::SetCursorPos({30.000f, 60.000f});
if (ImGui::Button("AimBot", ImVec2(200.000f, 100.000f))) {
is_AB = true;
is_AA = false;
is_V = false;
is_M = false;
}
ImGui::SetCursorPos({260.000f, 60.000f});
if (ImGui::Button("AntiAim", ImVec2(200.000f, 100.000f))) {
is_AB = false;
is_AA = true;
is_V = false;
is_M = false;
}
ImGui::SetCursorPos({490.000f, 60.000f});
if (ImGui::Button("Visuals", ImVec2(200.000f, 100.000f))) {
is_AB = false;
is_AA = false;
is_V = true;
is_M = false;
}
ImGui::SetCursorPos({720.000f, 60.000f});
if (ImGui::Button("Misc", ImVec2(200.000f, 100.000f))) {
is_AB = false;
is_AA = false;
is_V = false;
is_M = true;
}
if(is_AB) {
ImGui::SetCursorPos({30.000f, 190.000f});
ImGui::Checkbox("Infinite cash", &isCash);
}
if(isCash) {
ImGui::SetCursorPos({30.000f, 250.000f});
ImGui::Text("Cash enanled!!");
}
ImGui::End();
}
}
void *thread(void *) {
LOGI(OBFUSCATE("Main Thread Loaded: %d"), gettid());
initModMenu((void *)DrawMenu);
//Hooks, Patches and Pointers here
//Example:
/*DobbyHook(getAbsoluteAddress("libIl2cpp.so", 0xA20768), Update, old_Update);
SetSelfie = (void (*)(void *, Quaternion)) getAbsoluteAddress("libIl2cpp.so", );
Cash = (void (*)(void *, int))getAbsoluteAddress("libil2cpp.so", 0xA23424);
A64HookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0xA23420), (void *)Update, (void **) &old_Update);
*/
#if defined(__aarch64__)
addcash = (void(*)(void *)) getAbsoluteAddress(targetLibName, 0x916214);
DobbyHook((void *)getAbsoluteAddress(targetLibName, 0x919B64), (void *)ctor, (void **)&old_ctor);
DobbyHook((void *)getAbsoluteAddress(targetLibName, 0x91502C), (void *)Update, (void **)&old_Update); //I also tried A64 and Hook_lib - same thing
#else
// ARMv7/x86, : MSHookFunction(...)
#endif
LOGI("Main thread done");
pthread_exit(0);
}
// Call anything from JNI_OnLoad here
extern "C" {
// JNI Support
JavaVM *jvm = nullptr;
JNIEnv *env = nullptr;
__attribute__((visibility ("default")))
jint loadJNI(JavaVM *vm) {
jvm = vm;
vm->AttachCurrentThread(&env, nullptr);
LOGI("loadJNI(): Initialized");
return JNI_VERSION_1_6;
}
}
__attribute__((constructor))
void init() {
LOGI("Loaded Mod Menu");
pthread_t t;
pthread_create(&t, nullptr, thread, nullptr);
//Don't leave any traces, remap the loader lib as well
RemapTools::RemapLibrary("libLoader.so");
}
What did I do wrong? The menu appears, but the mod doesn't work.