#include <android/log.h>
#include <unistd.h>
#include <thread>
#include <limits>
#include <string>
#include <iostream>
#include <cstring>
#include <Struct/main.h>
#include <xdl.h>
#include <KittyUtils.h>
#include <KittyMemory/KittyMemory.h>
#include <KittyMemory/MemoryPatch.h>
#include <KittyMemory/KittyScanner.h>
#include <KittyMemory/KittyUtils.h>
#include <KittyMemory.h>
#include <Il2Cpp.h>
#include <SubstrateHook.h>
#include <CydiaSubstrate.h>
#include "Chams.h"
#include "Struct/gui.hpp"
#include "Struct/DrawMenu.h"
#include "FireWall.h"
#include "Zygisk_GoluYT.hpp"
#include "Golu-YT.h"
#include "GoluYT/Tools/Call_Tools.h"
#include "GoluYT/Font.h"
#include "GoluYT/CN.h"
#include "GoluYT/Icon.h"
#include "GoluYT/Iconcpp.h"
using Zygisk_GoluYT::AKG;
using Zygisk_GoluYT::GoluSingh366;
using Zygisk_GoluYT::GoluYT_Hack;
void hack();
void writeLog(const std::string& logMessage, const std::string& filename = "/storage/emulated/0/Android/data/com.dualspace.multispace.androidx/files/log.txt");

#define ICON_FA_CHECK_CIRCLE "\xef\x81\x98"	// U+f058
#define ICON_FA_CROSSHAIRS "\xef\x81\x9b"	// U+f05b
JavaVM *jvm;
JNIEnv *genv;
//extern JavaVM* jvm;
//extern JNIEnv* genv;

class MyModule : public Zygisk_GoluYT::ModuleBase {
 public:
  void onLoad(AKG *api, JNIEnv *env) override {
    this->api_ = api;
    this->env_ = env;
    genv = env;
   // gEnv = env;

  }

  void preAppSpecialize(GoluSingh366 *args) override {
    static constexpr const char *packages[] = {
        "com.dts.freefireth"
    };
    const char *process = env_->GetStringUTFChars(args->nice_name, nullptr);
    for (const auto *package: packages) {
      is_game_ = (strcmp(process, package) == 0);
      if (is_game_) {
        break;
      }
    }
    env_->ReleaseStringUTFChars(args->nice_name, process);
  }

  void postAppSpecialize(const GoluSingh366 *args) override {
    if (is_game_) {
       genv->GetJavaVM(&jvm);
     //  genv->GetJavaVM(&gJvm);
      std::thread{hack}.detach();
    }
  }

 private:
  AKG *api_ = nullptr;
  JNIEnv *env_ = nullptr;
  bool is_game_ = false;
};


uintptr_t il2cpp_base = 0;
void *getRealAddr(ulong offset) {
    return reinterpret_cast<void*>(il2cpp_base + offset);
};





void (*OpenURL)(String *url);
//inline static bool g_IsSetup = false;
//inline int prevWidth, prevHeight;
bool WORTERSYPORNO; 
bool GoluSingh366;
#include "imgui.h"
#include <cmath>

/*

// Rainbow wheel with animated rotation
void DrawRotatingColorWheel(ImVec2 center, float radius, float time) {
    ImDrawList* draw_list = ImGui::GetWindowDrawList();
    const int num_segments = 60;
    for (int i = 0; i < num_segments; ++i) {
        float start_angle = (2.0f * IM_PI * i) / num_segments + time;
        float end_angle = (2.0f * IM_PI * (i + 1)) / num_segments + time;
        ImVec2 p1(center.x + cosf(start_angle) * radius, center.y + sinf(start_angle) * radius);
        ImVec2 p2(center.x + cosf(end_angle) * radius, center.y + sinf(end_angle) * radius);
        float hue = (float)i / num_segments;
        ImU32 color = ImColor::HSV(hue, 1.0f, 1.0f);
        draw_list->AddTriangleFilled(center, p1, p2, color);
    }
}*/

// Custom switch with proper rounded edges and bigger rainbow knob

   
   // apne switch ki jagah ye switch lagao
   //DrawCustomSwitch("SPEED HACK", OBFUSCATE("SPEED HACK"), &Speed, ImGui::GetTime());

#include "imgui.h"

// --- Helper function for toggle switch ---
bool ToggleButton(const char* label, bool* v)
{
    ImVec2 p = ImGui::GetCursorScreenPos();
    ImDrawList* draw_list = ImGui::GetWindowDrawList();
    float height = ImGui::GetFrameHeight();
    float width = height * 2.10f;
    float radius = height * 0.50f;

    ImGui::InvisibleButton(label, ImVec2(width, height));
    if (ImGui::IsItemClicked())
        *v = !*v;

    ImU32 col_bg = *v ? IM_COL32(0, 200, 0, 255) : IM_COL32(150, 150, 150, 255);
    ImU32 col_circle = IM_COL32(255, 255, 255, 255);

    draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height), col_bg, height * 0.5f);
    draw_list->AddCircleFilled(ImVec2(p.x + radius + (*v ? width - height : 0), p.y + radius), radius - 1.5f, col_circle);

    return *v;
}

// 🔘 Custom Toggle Switch Function


  


bool clearMousePos = true;
bool initImGui = false;

void SetupImgui() {
    IMGUI_CHECKVERSION();
    
    ImGui::CreateContext();
    ImGui_ImplAndroid_Init(nullptr);
    ImGuiIO& io = ImGui::GetIO();
    ImGuiStyle* style = &ImGui::GetStyle();
    io.Fonts->AddFontFromMemoryTTF((void *)BaiduZY_data, BaiduZY_size, 35.0f, NULL, io.Fonts->GetGlyphRangesChineseFull());
    //io.DisplaySize = ImVec2((float)g_GlWidth, (float)g_GlHeight);

    ImGui_ImplOpenGL3_Init("#version 300 es");
    ImFontConfig font_cfg;
    font_cfg.SizePixels = 22.0f;
    io.Fonts->AddFontDefault(&font_cfg);

    ImVec4 whiteColor(1.0f, 1.0f, 1.0f, 1.0f);
    style->WindowTitleAlign = ImVec2(0.5f,0.5f);

  //  ImGui::StyleColorsLight();
    ImGui::StyleColorsDark();//   Màu Xanh Nước Biển

    ImFontConfig CustomFont;
    CustomFont.FontDataOwnedByAtlas = false;
    font_cfg.SizePixels = 22.0f;
    static const ImWchar vietnamese_chars[] = {
        0x0020, 0x00FF, // Basic Latin + Latin Supplement
        0x0102, 0x0103, // Â, â
        0x0110, 0x0111, // Đ, đ
        0x0128, 0x0129, // Ĩ, ĩ
        0x0168, 0x0169, // Ũ, ũ
        0x01A0, 0x01A1, // Ơ, ơ
        0x01AF, 0x01B0, // Ư, ư
        0x1EA0, 0x1EF9, // Vietnamese specific characters
        0 // null-terminated list
    };
    ImGui::GetStyle().ScaleAllSizes(3.0f);
}



//bool clearMousePos = true;
bool ImGuiOK = false;
//bool initImGui = false;
//bool rainbow = false;
inline EGLBoolean (*old_eglSwapBuffers)(EGLDisplay dpy, EGLSurface surface);
inline EGLBoolean hook_eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) {
    
        eglQuerySurface(dpy, surface, EGL_WIDTH, &g_GlWidth);
    eglQuerySurface(dpy, surface, EGL_HEIGHT, &g_GlHeight);
    
    

    if (!g_IsSetup) {
        prevWidth = g_GlWidth;
        prevHeight = g_GlHeight;
        SetupImgui();
        
        g_IsSetup = true;
    }
    
	ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle* style = &ImGui::GetStyle();
ImVec4* colors = style->Colors;
	
	
	

// 🖤 Normal UI Styling

// ===== Borders & Rounding =====
style->WindowBorderSize = 0.0f;  
style->FrameBorderSize  = 0.0f;  
style->FrameRounding    = 10.0f;
style->WindowRounding   = 12.0f;

// ===== Background Colors =====
// ===== Pure Black Theme (Light Black Variations) =====
ImVec4 blackBg    = ImColor(15, 15, 15, 240);  // Main window background
ImVec4 blackChild = ImColor(20, 20, 20, 250);  // Child windows
ImVec4 blackPopup = ImColor(25, 25, 25, 255);  // Popup background

style->Colors[ImGuiCol_WindowBg] = blackBg;
style->Colors[ImGuiCol_ChildBg]  = blackChild;
style->Colors[ImGuiCol_PopupBg]  = blackPopup;

// ===== Text =====
style->Colors[ImGuiCol_Text]         = ImColor(255, 255, 255, 255); // White text
style->Colors[ImGuiCol_TextDisabled] = ImColor(150, 150, 150, 200); // Grey for disabled

// ===== Title Bar =====
style->Colors[ImGuiCol_TitleBg]          = ImColor(20, 20, 20, 255); // Dark black
style->Colors[ImGuiCol_TitleBgCollapsed] = ImColor(15, 15, 15, 200); // Transparent black
style->Colors[ImGuiCol_TitleBgActive]    = ImColor(30, 30, 30, 255); // Slightly lighter black

// ===== Scrollbar & Frame Adjustments =====
style->ScrollbarSize = 0.0f;                     // Hide scrollbars
style->WindowMenuButtonPosition = ImGuiDir_None; // Hide menu button
style->WindowPadding = ImVec2(10, 10);
style->FramePadding  = ImVec2(6, 4);
style->ItemSpacing   = ImVec2(6, 6);

// ===== Buttons =====
style->Colors[ImGuiCol_Button]        = ImColor(35, 35, 35, 255);  // Normal
style->Colors[ImGuiCol_ButtonHovered] = ImColor(50, 50, 50, 255);  // Hover
style->Colors[ImGuiCol_ButtonActive]  = ImColor(70, 70, 70, 255);  // Pressed

// ===== Frames =====
style->Colors[ImGuiCol_FrameBg]        = ImColor(25, 25, 25, 220);
style->Colors[ImGuiCol_FrameBgHovered] = ImColor(40, 40, 40, 240);
style->Colors[ImGuiCol_FrameBgActive]  = ImColor(60, 60, 60, 255);



ImGui::PopStyleColor();
ImGui::PopStyleVar();

    ImGui_ImplOpenGL3_NewFrame();
    ImGui_ImplAndroid_NewFrame(g_GlWidth, g_GlHeight);
    ImGui::NewFrame();
	if (ImGuiOK) {
	    int touchCount = (((int (*)())(Class_Input__get_touchCount))());
    if (touchCount > 0) {
        UnityEngine_Touch_Fields touch = ((UnityEngine_Touch_Fields(*)(int))(Class_Input__GetTouch))(0);
        float reverseY = io.DisplaySize.y - touch.m_Position.fields.y;
        switch (touch.m_Phase) {
            case TouchPhase::Began:
            case TouchPhase::Stationary:
                io.MousePos = ImVec2(touch.m_Position.fields.x, reverseY);
                io.MouseDown[0] = true;
                break;
            case TouchPhase::Ended:
            case TouchPhase::Canceled:
                io.MouseDown[0] = false;
                clearMousePos = true;
                break;
            case TouchPhase::Moved:
                io.MousePos = ImVec2(touch.m_Position.fields.x, reverseY);
                break;
            default:
                break;
        }
    }
	}
	//DrawESP(g_GlWidth, g_GlHeight);  
	
    ExpireDate exp;
    exp.setExpirationDate(17,9,2025);//d,m,y
    if (exp.isExpired()) {
    //ImGui::SetNextWindowSize(ImVec2(glWidth/3.5, glHeight/1.5), ImGuiCond_FirstUseEver);
    ImGui::Begin(OBFUSCATE("MODS MENU EXPIRED PLEASE JOIN TELEGRAM️"));

  ImGui::Text(OBFUSCATE("HAXX-CKER PRO EXPIRED"));
    OpenURL(Il2CppString::Create("https://t.me/+wz_-pIChD_5kZjll"));
}
    
    DrawESP(g_GlWidth, g_GlHeight);
static float isRed = 0.0f, isGreen = 0.01f, isBlue = 0.0f;
const float speed = 0.05f;  // Speed increase







// 🌟 State variables (toggles)
static int tabIndex = 0;            // 0 = Aimbot, 1 = Player, 2 = Draw
static bool showMainUI = true;
static bool showFloatingBtn = false;

ImVec2 panelSize = ImVec2(500, 615);

// --- Floating emoji button ---
if (showFloatingBtn)
{
    ImGui::SetNextWindowBgAlpha(0.0f); // transparent
    ImGui::SetNextWindowPos(ImVec2(20, 20), ImGuiCond_Always);
    ImGui::Begin("FloatingButton", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize );
    if (ImGui::Button("🗿", ImVec2(50, 50)))
    {
        showMainUI = true;      // show main UI
        showFloatingBtn = false; // hide floating button
    }
    ImGui::End();
}

// --- Main window ---
if (showMainUI)
{
    ImGui::SetNextWindowSize(panelSize, ImGuiCond_Always);
    if (ImGui::Begin("HIMANSHU X MOD V15",
                     nullptr,
                     ImGuiWindowFlags_NoResize |
                     ImGuiWindowFlags_NoCollapse |
                     ImGuiWindowFlags_NoTitleBar))
    {
        // --- HEADER ---
        ImGui::Dummy(ImVec2(0, 5));
        ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("HAXX-CKER PRO BY @DARKAYU7").x) * 0.5f);
        ImGui::Text("HIMANSHU X MOD V15");
        ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("FREEFIRE 1.175.X 64 BIT").x) * 0.5f);
        ImGui::Text("FREEFIRE 1.175.X 64 BIT");
        ImGui::Dummy(ImVec2(0, 10));

        // --- STATUS & SELLER ---
        ImGui::Text("STATUS:");   
        ImGui::SameLine(170);  
        ImGui::TextColored(ImVec4(0.0f, 1.0f, 0.33f, 1.0f), "INJECTED");  

        ImGui::Text("KEY:");   
        ImGui::SameLine(170);  
        ImGui::TextColored(ImVec4(1.0f, 0.2f, 0.2f, 1.0f), "FREE ");  

        ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("ALL FEATURE").x) * 0.5f);  
        ImGui::Text("ALL FEATURE");  
        ImGui::Dummy(ImVec2(0, 5));  

        // --- ESP / AIMBOT Toggles ---
        ImGui::Text("ENABLE FUNCTIONS"); ImGui::SameLine(400); ToggleButton("##esp", &Enable);  
        
ImGui::Text("ENABLE AIMBOT"); ImGui::SameLine(400); ToggleButton("##esp", &Aimbot); 

				if (Aimbot) {  
          //  Aimbot = true;  
            AimWhen2 = true;  
            AimWhen3 = true;  
            Fov_Aim = 600.0f;  
        } else {
          //  Aimbot = false;
            AimWhen2 = false;
            AimWhen3 = false;
            Fov_Aim = 0.0f;
        }
		
/*
ImGui::Text("ENABLE AIM FIRE"); ImGui::SameLine(400); ToggleButton("##esp", &AimWhen2); 
ImGui::Text("ENABLE AIM LOCK"); ImGui::SameLine(400); ToggleButton("##esp", &AimVisible); 
ImGui::Text("ENABLE AIM VISIBLE"); ImGui::SameLine(400); ToggleButton("##esp", &AimWhen3); 
		*/
		// extra code by @darkayu7
		
      //   ImGui::Text("ENABLE ESP"); ImGui::SameLine(400); ToggleButton("##esp", &Enable);
        ImGui::Text("ESP LINE"); ImGui::SameLine(400); ToggleButton("##espLine", &Config.ESP.Line);
        ImGui::Text("ESP BOX"); ImGui::SameLine(400); ToggleButton("##espBox", &box);
		ImGui::Text("ESP HEALTH"); ImGui::SameLine(400); ToggleButton("##espHealth", &Config.ESP.Target);
        ImGui::Text("ESP DISTANCE"); ImGui::SameLine(400); ToggleButton("##espDistance", &Config.ESP.Health);
        // --- BUTTONS ---
        float buttonWidth = 100.0f;
        float buttonHeight = 50.0f;
        float padding = 10.0f;

        // HIDE button - left
        if (ImGui::Button("HIDE", ImVec2(buttonWidth, buttonHeight)))
        {
            showMainUI = false;
            showFloatingBtn = true;
        }

        // CLOSE button - right
        float windowWidth = ImGui::GetWindowWidth();
        ImGui::SameLine(windowWidth - buttonWidth - padding);
        if (ImGui::Button("CLOSE", ImVec2(buttonWidth, buttonHeight)))
        {
            showMainUI = false;
            showFloatingBtn = true;
        }

        ImGui::Dummy(ImVec2(0, 10));
        ImGui::End();
    }
}




	
	
   ImGui::Render();
    
    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
    return old_eglSwapBuffers(dpy, surface);

}


typedef unsigned long DWORD;
static uintptr_t libBase;
inline void hack_injec();
inline void StartGUI() {
    void *ptr_eglSwapBuffer = DobbySymbolResolver("/system/lib/libEGL.so", "eglSwapBuffers");
    if (NULL != ptr_eglSwapBuffer) {
        DobbyHook((void *)ptr_eglSwapBuffer, (void*)hook_eglSwapBuffers, (void**)&old_eglSwapBuffers);
            LOGD("Gui Started");
			hack_injec();
        }
    }

bool libLoaded = false;

DWORD findLibrary(const char *library) {
    char filename[0xFF] = {0},
            buffer[1024] = {0};
    FILE *fp = NULL;
    DWORD address = 0;

    sprintf(filename, OBFUSCATE("/proc/self/maps"));

    fp = fopen(filename, OBFUSCATE("rt"));
    if (fp == NULL) {
        perror(OBFUSCATE("fopen"));
        goto done;
    }

    while (fgets(buffer, sizeof(buffer), fp)) {
        if (strstr(buffer, library)) {
            address = (DWORD) strtoul(buffer, NULL, 16);
            goto done;
        }
    }

    done:

    if (fp) {
        fclose(fp);
    }

    return address;
}

DWORD getAbsoluteAddress(const char *libraryName, DWORD relativeAddr) {
    libBase = findLibrary(libraryName);
    if (libBase == 0)
        return 0;
    return (reinterpret_cast<DWORD>(libBase + relativeAddr));
}
ProcMap unityMap, anogsMap, il2cppMap;
using KittyScanner::RegisterNativeFn;



    
    
void hack() {
     LOGD("Inject Ok");
    //std::thread thread_hack(hack_thread, getpid());
    //thread_hack.detach();
    
}
uintptr_t get_symbol_addr_in_pid(pid_t pid, const char* libname, uintptr_t offset_in_lib) {
    char maps_path[64];
    snprintf(maps_path, sizeof(maps_path), "/proc/%d/maps", pid);

    FILE* fp = fopen(maps_path, "r");
    if (!fp) return 0;

    char line[512];
    uintptr_t base = 0;

    while (fgets(line, sizeof(line), fp)) {
        if (strstr(line, libname)) {
            sscanf(line, "%lx-%*lx", &base);
            break;
        }
    }
    fclose(fp);

    if (base == 0) return 0;
    return base + offset_in_lib;
}

pid_t get_pid_by_name(const char* process_name) {
    DIR* proc_dir = opendir("/proc");
    if (!proc_dir) return -1;

    struct dirent* entry;
    while ((entry = readdir(proc_dir)) != NULL) {
        if (entry->d_type != DT_DIR) continue;

        pid_t pid = atoi(entry->d_name);
        if (pid <= 0) continue;

        char cmdline_path[256];
        snprintf(cmdline_path, sizeof(cmdline_path), "/proc/%d/cmdline", pid);

        FILE* fp = fopen(cmdline_path, "r");
        if (!fp) continue;

        char cmdline[256];
        fgets(cmdline, sizeof(cmdline), fp);
        fclose(fp);

        if (strstr(cmdline, process_name)) {
            closedir(proc_dir);
            return pid;
        }
    }

    closedir(proc_dir);
    return -1;
}

#include <cstdio>

void writeLog(const std::string& logMessage, const std::string& filename) {
    FILE* file = fopen(filename.c_str(), "a");  // Open in append mode
    if (file) {
        fprintf(file, "%s\n", logMessage.c_str());
        fclose(file);
    } else {
        // Can't use cerr either; log to logcat or do nothing
        // You can use __android_log_print instead if needed
    }
}

bool is_current_process(const char* target_name) {
    char cmdline_path[64];
    snprintf(cmdline_path, sizeof(cmdline_path), "/proc/%d/cmdline", getpid());

    FILE* fp = fopen(cmdline_path, "r");
    if (!fp) return false;

    char cmdline[256] = {0};
    fgets(cmdline, sizeof(cmdline), fp);
    fclose(fp);

    return strcmp(cmdline, target_name) == 0;
}

void hack_injec() {
	while (!unityMap.isValid()) {
        unityMap = KittyMemory::getLibraryBaseMap("libunity.so");
		anogsMap = KittyMemory::getLibraryBaseMap("libanogs.so");
		il2cppMap = KittyMemory::getLibraryBaseMap("libil2cpp.so");
		
        sleep(6);
	}
    
 sleep(5);
    Il2CppAttach();
	
	if (mlovinit()) {
        setShader("_AlphaMask");
        LogShaders();
        Wallhack();
    }
    
    
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("GarenaMSDK"), OBFUSCATE("GarenaMSDKMgr"), OBFUSCATE("IsPlatformInstalled"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("System.dll"), OBFUSCATE("System.Net"), OBFUSCATE("WebProxy"), OBFUSCATE("IsBypassed"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("System.dll"), OBFUSCATE("System.Net"), OBFUSCATE("IWebProxy"), OBFUSCATE("IsBypassed"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("System.dll"), OBFUSCATE("System.Net"), OBFUSCATE("WebProxy"), OBFUSCATE(".ctor"), 0), (void *) &_FixGame, (void **) &FixGame);
   
     DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("System.dll"), OBFUSCATE("System.Net"), OBFUSCATE("WebProxy"), OBFUSCATE("CheckBypassList"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW"), OBFUSCATE("EventLogger"), OBFUSCATE("LogReportCheatInHistory"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW"), OBFUSCATE("EventLogger"), OBFUSCATE("LogReportCheat"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW"), OBFUSCATE("MobileReplayManager"), OBFUSCATE("GetGameTimeMS"), 0), (void *) &_FixGame, (void **) &FixGame);
   
     DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW"), OBFUSCATE("CreditPunishManager"), OBFUSCATE("ShowPunishWindow"), 0), (void *) &_FixGame, (void **) &FixGame);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("SceneGraphicsQuality"), OBFUSCATE("SetGraphicsQuality"), 0), (void *) _BypassESP, (void **) &BypassESP);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("UnityEngine.CoreModule.dll"), OBFUSCATE("UnityEngine"), OBFUSCATE("Screen"), OBFUSCATE("SetResolution"), 0), (void *) _BypassESP, (void **) &BypassESP);
  
  
  DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("Player"), OBFUSCATE("UpdateBehavior"), 2), (void *) _LateUpdate, (void **) &LateUpdate);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("Player"), OBFUSCATE("IsFoldWingGliding"), 0), (void *) _IsFoldWingGliding, (void **)& IsFoldWingGliding);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW"), OBFUSCATE("GameConfig") , OBFUSCATE("get_ResetGuest"), 0), (void *) ResetGuest, (void **) &_ResetGuest);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("UnityEngine.CoreModule.dll"), OBFUSCATE("UnityEngine"), OBFUSCATE("AndroidJNI"), OBFUSCATE("IsInstanceOf"), 2), (void *) &_Bypass, (void **) &Bypass);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("mscorlib.dll"), OBFUSCATE("System"), OBFUSCATE("SerializableAttribute"), OBFUSCATE(".ctor"), 0), (void *) &_FixGame, (void **) &FixGame);
  
  
      DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("UnityEngine.CoreModule.dll"), OBFUSCATE("UnityEngine"), OBFUSCATE("QualitySettings"), OBFUSCATE("GetQualityLevel"), 0), (void *) _BypassESP, (void **) &BypassESP);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("SceneGraphicsQuality"), OBFUSCATE("SetGraphicsQuality"), 0), (void *) _BypassESP, (void **) &BypassESP);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("GCommon"), OBFUSCATE("PlatformUtility_Android"), OBFUSCATE("IsPackageInstalled"), 0), (void *) _Set_Aim, (void **) &Set_Aim);
    DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("GCommon"), OBFUSCATE("PlatformUtility_Android"), OBFUSCATE("CheckFileExists"), 0), (void *) _Set_Aim, (void **) &Set_Aim);
 OpenURL = (void (*)(String *))Il2CppGetMethodOffset("UnityEngine.CoreModule.dll","UnityEngine","Application","OpenURL",1);
ImGuiOK = true;


}


void hack_thread(pid_t pid) {
	
	StartGUI();
	while(pid == -1){pid = get_pid_by_name("com.dts.freefireth");} 
	remote_inject(pid);
	writeLog(to_string(pid));
    
}
__attribute__((constructor))
void lib_main()
{
    std::thread thread_hack(hack_thread, get_pid_by_name("com.dts.freefireth"));
    thread_hack.detach();
}
//REGISTER_Zygisk_GoluYT_MODULE( by GoluYT)


