#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");



// ⬇⬇ Iske neeche paste karo
void DrawTopOverlayRainbow(const char* text)
{
    ImDrawList* draw = ImGui::GetForegroundDrawList();
    ImVec2 screen = ImGui::GetIO().DisplaySize;

    ImVec2 ts = ImGui::CalcTextSize(text);
    float posX = (screen.x - ts.x) * 0.5f;
    float posY = 15.0f;

    ImVec2 p0 = ImVec2(posX - 10, posY - 5);
    ImVec2 p1 = ImVec2(posX + ts.x + 10, posY + ts.y + 5);
    draw->AddRectFilled(p0, p1, IM_COL32(0, 0, 0, 180), 6.0f);
    draw->AddRect(p0, p1, IM_COL32(255, 255, 255, 120), 6.0f);

    static float rainbowSpeed = 0.0015f;
    static float hue = 0.0f;
    hue += rainbowSpeed * ImGui::GetIO().DeltaTime * 60.0f;
    if (hue > 1.0f) hue = 0.0f;

    ImColor rainbowColor = ImColor::HSV(hue, 1.0f, 1.0f);

    draw->AddText(ImVec2(posX+1, posY+1), IM_COL32(0,0,0,200), text);
    draw->AddText(ImVec2(posX, posY), rainbowColor, text);
}














#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);
};


// Simple neon style toggle switch
void CustomToggleSwitch(const char* label, bool* v)
{
    ImVec2 p = ImGui::GetCursorScreenPos();
    float height = ImGui::GetFrameHeight();
    float width = height * 1.8f;
    float radius = height * 0.5f;

    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    // Toggle background
    draw_list->AddRectFilled(p, ImVec2(p.x + width, p.y + height),
        *v ? IM_COL32(0, 255, 0, 200) : IM_COL32(60, 60, 60, 200),
        height * 0.5f);

    // Toggle circle
    float circle_x = *v ? (p.x + width - radius) : (p.x + radius);
    draw_list->AddCircleFilled(ImVec2(circle_x, p.y + radius),
        radius * 0.8f, IM_COL32(255, 255, 255, 255));

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

    // Label text
    ImGui::SameLine();
    ImGui::TextUnformatted(label);
}


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
void DrawCustomSwitch(const char* id, const char* label, bool* state, float time) {
    ImVec2 size = ImVec2(160, 70); // Switch size
    ImVec2 pos = ImGui::GetCursorScreenPos();
    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    // Perfect rounded corner (pill shape)
    float rounding = size.y / 2.0f;

    // Background
    ImU32 bg_color = *state ? IM_COL32(0, 200, 0, 255) : IM_COL32(120, 120, 120, 255);
    ImU32 border_color = IM_COL32(0, 255, 0, 255);
    draw_list->AddRectFilled(pos, ImVec2(pos.x + size.x, pos.y + size.y), bg_color, rounding);
    draw_list->AddRect(pos, ImVec2(pos.x + size.x, pos.y + size.y), border_color, rounding, 0, 3.0f);

    // Knob position
    float knob_offset = *state ? (pos.x + size.x - 60) : (pos.x + 10);
    ImVec2 knob_center = ImVec2(knob_offset + 25, pos.y + size.y / 2);

    // Black circle background
    draw_list->AddCircleFilled(knob_center, 22, IM_COL32(0, 0, 0, 255)); // Slightly bigger

    // Rotating rainbow wheel (bigger)
    DrawRotatingColorWheel(knob_center, 26, time);

    // ON/OFF text (black)
    const char* onoff_text = *state ? "ON" : "OFF";
    ImVec2 text_size = ImGui::CalcTextSize(onoff_text);
    ImVec2 text_pos = *state
        ? ImVec2(pos.x + 10, pos.y + size.y / 2 - text_size.y / 2)
        : ImVec2(pos.x + size.x - text_size.x - 10, pos.y + size.y / 2 - text_size.y / 2);
    draw_list->AddText(text_pos, IM_COL32(0, 0, 0, 255), onoff_text);

    // Clickable button area
    ImGui::SetCursorScreenPos(pos);
    if (ImGui::InvisibleButton(id, size)) {
        *state = !*state;
    }

    // Label (right side)
    ImVec2 label_pos = ImVec2(pos.x + size.x + 10, pos.y + size.y / 2 - ImGui::CalcTextSize(label).y / 2);
    draw_list->AddText(label_pos, IM_COL32(0, 255, 255, 255), label);

    ImGui::Dummy(ImVec2(size.x + 100, size.y));
}
   
   // apne switch ki jagah ye switch lagao
   //DrawCustomSwitch("SPEED HACK", OBFUSCATE("SPEED HACK"), &Speed, ImGui::GetTime());

#include "imgui.h"

// 🔘 Full Animated Custom Toggle Switch (Black Border)
void CustomToggleSwitch_Animated(const char* label, bool* v)
{
    ImVec2 p = ImGui::GetCursorScreenPos();
    ImDrawList* draw_list = ImGui::GetWindowDrawList();

    float height = 50.0f;
    float width = 130.0f;
    float radius = height * 0.50f;

    // Invisible button for click detection
    ImGui::InvisibleButton(label, ImVec2(width, height));
    if (ImGui::IsItemClicked())
        *v = !*v;

    // Animation position
    ImGuiID id = ImGui::GetID(label);
    float animPos = ImGui::GetStateStorage()->GetFloat(id, *v ? 1.0f : 0.0f);
    animPos = ImLerp(animPos, *v ? 1.0f : 0.0f, ImGui::GetIO().DeltaTime * 8.0f);
    ImGui::GetStateStorage()->SetFloat(id, animPos);

    // Interpolated background color:
    ImU32 bg_col = ImGui::GetColorU32(ImLerp(
        ImVec4(0.6f, 0.6f, 0.6f, 1.0f),                // grey
        ImVec4(132.0f / 255.0f, 230.0f / 255.0f, 147.0f / 255.0f, 1.0f), // light green
        animPos
    ));

    ImVec2 bg_min = p;
    ImVec2 bg_max = ImVec2(p.x + width, p.y + height);

    // Background
    draw_list->AddRectFilled(bg_min, bg_max, bg_col, radius);

    // Border (pure black)
    draw_list->AddRect(bg_min, bg_max, IM_COL32(0, 0, 0, 255), radius, 0, 2.0f);

    // Toggle circle
    float circle_x = p.x + ImLerp(radius, width - radius, animPos);
    draw_list->AddCircleFilled(ImVec2(circle_x, p.y + radius), radius - 4, IM_COL32(255, 255, 255, 255));

    // Circle shadow
    draw_list->AddCircleFilled(ImVec2(circle_x, p.y + radius), radius - 4, IM_COL32(0, 0, 0, 50));

    ImGui::SameLine();
    ImGui::Text("%s [%s]", label, *v ? "ON" : "OFF");
}

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;
    }
    
    

    ImGuiIO &io = ImGui::GetIO();
	//Darkness();
	// Thiết lập màu chủ đề
	ImVec4* colors = ImGui::GetStyle().Colors;
/*
	colors[ImGuiCol_Text]                   = ImVec4(0.86f, 0.86f, 0.86f, 1.00f); // Màu chữ
	colors[ImGuiCol_TextDisabled]           = ImVec4(0.60f, 0.60f, 0.60f, 1.00f); // Màu chữ vô hiệu hóa
	colors[ImGuiCol_WindowBg]               = ImVec4(0.16f, 0.16f, 0.16f, 0.95f); // Màu nền cửa sổ
	colors[ImGuiCol_ChildBg]                = ImVec4(0.18f, 0.18f, 0.18f, 0.58f); // Màu nền bên trong Child window
	colors[ImGuiCol_PopupBg]                = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); // Màu nền của Popup window
	colors[ImGuiCol_Border]                 = ImVec4(0.08f, 0.08f, 0.08f, 0.40f); // Màu đường viền
	colors[ImGuiCol_BorderShadow]           = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); // Màu bóng đổ đường viền
	colors[ImGuiCol_FrameBg]                = ImVec4(0.27f, 0.27f, 0.27f, 0.54f); // Màu nền Frame
	colors[ImGuiCol_FrameBgHovered]         = ImVec4(0.47f, 0.47f, 0.47f, 0.40f); // Màu nền Frame khi hover
	colors[ImGuiCol_FrameBgActive]          = ImVec4(0.40f, 0.40f, 0.40f, 0.67f); // Màu nền Frame khi active
	colors[ImGuiCol_TitleBg]                = ImVec4(0.04f, 0.04f, 0.04f, 1.00f); // Màu nền tiêu đề cửa sổ
	colors[ImGuiCol_TitleBgActive]          = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); // Màu nền tiêu đề cửa sổ khi active
	colors[ImGuiCol_TitleBgCollapsed]       = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); // Màu nền tiêu đề cửa sổ khi bị thu gọn
	colors[ImGuiCol_MenuBarBg]              = ImVec4(0.14f, 0.14f, 0.14f, 1.00f); // Màu nền của MenuBar
	colors[ImGuiCol_ScrollbarBg]            = ImVec4(0.02f, 0.02f, 0.02f, 0.53f); // Màu nền của thanh cuộn
	colors[ImGuiCol_ScrollbarGrab]          = ImVec4(0.31f, 0.31f, 0.31f, 1.00f); // Màu của cần cẩu thanh cuộn
	colors[ImGuiCol_ScrollbarGrabHovered]   = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); // Màu của cần cẩu thanh cuộn khi hover
	colors[ImGuiCol_ScrollbarGrabActive]    = ImVec4(0.51f, 0.51f, 0.51f, 1.00f); // Màu của cần cẩu thanh cuộn khi active
	colors[ImGuiCol_CheckMark]              = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // Màu của dấu check
	colors[ImGuiCol_SliderGrab]             = ImVec4(0.24f, 0.52f, 0.88f, 1.00f); // Màu của cần cẩu thanh trượt
	colors[ImGuiCol_SliderGrabActive]       = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // Màu của cần cẩu thanh trượt khi active
	colors[ImGuiCol_Button]                 = ImVec4(0.26f, 0.59f, 0.98f, 0.40f); // Màu của nút
	colors[ImGuiCol_ButtonHovered]          = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // Màu của nút khi hover
	colors[ImGuiCol_ButtonActive]           = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); // Màu của nút khi active
	colors[ImGuiCol_Header]                 = ImVec4(0.26f, 0.59f, 0.98f, 0.31f); // Màu của tiêu đề
	colors[ImGuiCol_HeaderHovered]          = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); // Màu của tiêu đề khi hover
	colors[ImGuiCol_HeaderActive]           = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // Màu của tiêu đề khi active
	colors[ImGuiCol_Separator]              = ImVec4(0.43f, 0.43f, 0.50f, 0.50f); // Màu của dấu phân cách
	colors[ImGuiCol_SeparatorHovered]       = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); // Màu của dấu phân cách khi hover
	colors[ImGuiCol_SeparatorActive]        = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); // Màu của dấu phân cách khi active
	colors[ImGuiCol_ResizeGrip]             = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); // Màu của khớp co giãn
	colors[ImGuiCol_ResizeGripHovered]      = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); // Màu của khớp co giãn khi hover
	colors[ImGuiCol_ResizeGripActive]       = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); // Màu của khớp co giãn khi active
	colors[ImGuiCol_Tab]                    = ImVec4(0.18f, 0.18f, 0.18f, 0.86f); // Màu của tab
	colors[ImGuiCol_TabHovered]             = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); // Màu của tab khi hover
	colors[ImGuiCol_TabActive]              = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); // Màu của tab khi active
	colors[ImGuiCol_TabUnfocused]           = ImVec4(0.06f, 0.06f, 0.06f, 0.97f); // Màu của tab khi không focus
	colors[ImGuiCol_TabUnfocusedActive]     = ImVec4(0.13f, 0.13f, 0.13f, 1.00f); // Màu của tab khi không focus nhưng active
	colors[ImGuiCol_PlotLines]              = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); // Màu của đồ thị dạng line
	colors[ImGuiCol_PlotLinesHovered]       = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); // Màu của đồ thị dạng line khi hover
	colors[ImGuiCol_PlotHistogram]          = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); // Màu của đồ thị dạng histogram
	colors[ImGuiCol_PlotHistogramHovered]   = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); // Màu của đồ thị dạng histogram khi hover
	colors[ImGuiCol_TextSelectedBg]         = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); // Màu nền khi chọn văn bản
	colors[ImGuiCol_DragDropTarget]         = ImVec4(0.41f, 0.41f, 0.41f, 1.00f); // Màu của Drag and Drop target
	colors[ImGuiCol_NavHighlight]           = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); // Màu highlight trong navigation
	colors[ImGuiCol_NavWindowingHighlight]  = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); // Màu highlight trong navigation khi windowing
	colors[ImGuiCol_NavWindowingDimBg]      = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); // Màu nền khi windowing
	colors[ImGuiCol_ModalWindowDimBg]       = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); // Màu nền khi modal window
	
	*/
	// Create Context
ImGui::CreateContext();
//ImGuiIO& io = ImGui::GetIO();
ImGuiStyle* style = &ImGui::GetStyle();

// Base Dark Theme
ImGui::StyleColorsDark(style);

// ===== Shape, Padding, Border =====
style->WindowRounding   = 12.0f;             // Rounded windows
style->FrameRounding    = 10.0f;             // Rounded frames
style->FramePadding     = ImVec2(5, 4);      // Padding inside widgets
style->FrameBorderSize  = 0.0f;              // No frame border
style->WindowBorderSize = 0.0f;              // No window border
style->WindowTitleAlign = ImVec2(0.5f, 0.5f);
style->ScrollbarSize    = 18.0f;             // Bigger scrollbar
style->ScrollbarRounding= 0.0f;
style->ButtonTextAlign  = ImVec2(0.5f, 0.5f);

// ===== Colors =====
//ImVec4* colors = style->Colors;

// 🖤 Backgrounds
colors[ImGuiCol_WindowBg]     = ImColor(20, 20, 40, 200);   // Semi-transparent deep blue
colors[ImGuiCol_ChildBg]      = ImVec4(0.08f, 0.08f, 0.1f, 0.85f);
colors[ImGuiCol_PopupBg]      = ImColor(15, 15, 20, 200);

// ✨ Text
colors[ImGuiCol_Text]         = ImColor(255, 255, 255, 220);
colors[ImGuiCol_TextDisabled] = ImVec4(0.6f, 0.6f, 0.7f, 0.9f);

// 🔥 Solid Top Title Bar
colors[ImGuiCol_TitleBg]          = ImColor(25, 25, 50, 255);
colors[ImGuiCol_TitleBgActive]    = ImColor(35, 35, 70, 255);
colors[ImGuiCol_TitleBgCollapsed] = ImColor(20, 20, 40, 255);

// 🟢 Neon Borders
colors[ImGuiCol_Border]       = ImColor(0, 255, 0, 255);
colors[ImGuiCol_BorderShadow] = ImColor(0, 255, 0, 255);

// Keep original useful highlights
colors[ImGuiCol_Button]            = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
colors[ImGuiCol_ButtonHovered]     = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_ButtonActive]      = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
colors[ImGuiCol_Header]            = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
colors[ImGuiCol_HeaderHovered]     = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
colors[ImGuiCol_HeaderActive]      = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_CheckMark]         = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
colors[ImGuiCol_SliderGrab]        = ImVec4(0.24f, 0.52f, 0.88f, 1.00f);
colors[ImGuiCol_SliderGrabActive]  = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);


// ----------------------
// Button with red border
// ----------------------
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); // बॉर्डर enable
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(1.00f, 0.00f, 0.00f, 1.00f)); // लाल रंग


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(16,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️"));

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


/*
if (isGreen == 0.01f && isBlue == 0.0f) {
    isRed += speed;
}

if (isRed > 0.99f && isBlue == 0.0f) {
    isRed = 1.0f;
    isGreen += speed;
}

if (isGreen > 0.99f && isBlue == 0.0f) {
    isGreen = 1.0f;
    isRed -= speed;
}

if (isRed < 0.01f && isGreen == 1.0f) {
    isRed = 0.0f;
    isBlue += speed;
}

if (isBlue > 0.99f && isRed == 0.0f) {
    isBlue = 1.0f;
    isGreen -= speed;
}

if (isGreen < 0.01f && isBlue == 1.0f) {
    isGreen = 0.0f;
    isRed += speed;
}

if (isRed > 0.99f && isGreen == 0.0f) {
    isRed = 1.0f;
    isBlue -= speed;
}

if (isBlue < 0.01f && isGreen == 0.0f) {
    isBlue = 0.0f;
    isRed -= speed;
    if (isRed < 0.01f) isGreen = 0.01f;
}*/

//ImGui::PushStyleColor(ImGuiCol_Border, ImColor(isRed, isBlue, isGreen, 1.0f).Value);

  //  ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
// 🔹 Title bar colors set karo


    
// 🔹 Screen width ke hisaab se top-center position
// 🌈 Animated Rainbow Text Example
DrawTopOverlayRainbow("PAPA BHUVI");
// 🔹 Main menu window
ImGui::SetNextWindowSize(ImVec2(650, 450), ImGuiCond_Once);
if (ImGui::Begin(OBFUSCATE("|| BHUVI OFFCIAL V1 ||"), 0, ImGuiWindowFlags_NoBringToFrontOnFocus)) {

	   
	   
	   
// Animated and unique gradient with dynamic particles
ImDrawList* draw = ImGui::GetWindowDrawList();
ImVec2 pos = ImGui::GetWindowPos();
ImVec2 size = ImGui::GetWindowSize();
static float t = 0.0f;
t = ImGui::GetTime(); // time-based animation

// Dynamic shifting colors for gradient corners
ImU32 colorTL = IM_COL32(
    int(128 + 127 * sinf(t * 1.1f)),    // Red
    int(128 + 127 * sinf(t * 1.3f)),    // Green
    int(128 + 127 * sinf(t * 1.5f)),    // Blue
    255);

ImU32 colorTR = IM_COL32(
    int(128 + 127 * sinf(t * 1.2f + 1)), 
    int(128 + 127 * sinf(t * 1.4f + 1)), 
    int(128 + 127 * sinf(t * 1.6f + 1)), 
    255);

ImU32 colorBR = IM_COL32(
    int(128 + 127 * sinf(t * 1.3f + 2)), 
    int(128 + 127 * sinf(t * 1.5f + 2)), 
    int(128 + 127 * sinf(t * 1.7f + 2)), 
    255);

ImU32 colorBL = IM_COL32(
    int(128 + 127 * sinf(t * 1.4f + 3)), 
    int(128 + 127 * sinf(t * 1.6f + 3)), 
    int(128 + 127 * sinf(t * 1.8f + 3)), 
    255);

// Draw the animated gradient rectangle
draw->AddRectFilledMultiColor(
    pos,
    ImVec2(pos.x + size.x, pos.y + size.y),
    colorTL, colorTR, colorBR, colorBL);

// Particle system with smooth motion and pulsating effect
struct Particle {
    ImVec2 pos;
    ImVec2 vel;
    float baseRadius;
    float phase;
};

static Particle particles[100];
static bool initialized = false;
if (!initialized) {
    for (int i = 0; i < 100; ++i) {
        particles[i].pos = ImVec2(pos.x + rand() % (int)size.x, pos.y + rand() % (int)size.y);
        particles[i].vel = ImVec2((rand() % 100 - 50) / 50.0f, (rand() % 100 - 50) / 50.0f);
        particles[i].baseRadius = 1.0f + (rand() % 3);
        particles[i].phase = (rand() % 100) / 100.0f * 3.14f * 2;
    }
    initialized = true;
}

for (int i = 0; i < 100; ++i) {
    Particle& p = particles[i];

    // Move particle
    p.pos.x += p.vel.x;
    p.pos.y += p.vel.y;

    // Wrap around edges
    if (p.pos.x < pos.x) p.pos.x = pos.x + size.x;
    if (p.pos.x > pos.x + size.x) p.pos.x = pos.x;
    if (p.pos.y < pos.y) p.pos.y = pos.y + size.y;
    if (p.pos.y > pos.y + size.y) p.pos.y = pos.y;

    // Pulsating effect
    float radius = p.baseRadius + sinf(t * 3.0f + p.phase) * 0.5f;

    // Smooth color change
    ImU32 color = IM_COL32(
        int(128 + 127 * sinf(t * 2.0f + p.phase)),
        int(128 + 127 * sinf(t * 2.5f + p.phase)),
        int(128 + 127 * sinf(t * 3.0f + p.phase)),
        150);

    // Draw glowing circle
    draw->AddCircleFilled(p.pos, radius, color, 12);
}
        
  
	
   static int tab = 1;
   
       // Tab Buttons
    ImGui::PushStyleColor(ImGuiCol_Border, IM_COL32(0, 0, 0, 0));
    if (ImGui::Button("AIM !!", ImVec2(140, 50)))
        tab = 1;
    ImGui::SameLine();

    if (ImGui::Button("ESP !!", ImVec2(140, 50)))
        tab = 2;
    ImGui::SameLine();

    if (ImGui::Button("EXTRA !!", ImVec2(140, 50)))
        tab = 3;
    ImGui::PopStyleColor();

	
	
	ImVec4 red = ImVec4(255, 255, 255, 255);  // Warna merah untuk ON
        ImVec4 blue = ImVec4(255, 255, 255, 255); // Warna putih untuk OFF

		if (tab == 1) {
			
        ImGui::Text("AIM");
        ImGui::Checkbox(OBFUSCATE("ACTIVE FUNCTION"), &Enable);
        ImGui::Checkbox(OBFUSCATE("AIMBOT"), &Aimbot);
        ImGui::Checkbox(OBFUSCATE("AIM VISIBLE"), &AimWhen2);
        ImGui::Checkbox(OBFUSCATE("AIM SILENT"), &AimSilent);
        ImGui::Checkbox(OBFUSCATE("DOUBLE GUN"), &DoubleGun);
        ImGui::Checkbox(OBFUSCATE("FAST SWITCH"), &fastswitch);
        ImGui::SliderFloat(OBFUSCATE("AIM FOV"), &Fov_Aim, 0.0f, 660.0f, "%.f");
    }
    if (tab == 2) {
        ImGui::Text("ESP");
        ImGui::Checkbox(OBFUSCATE("ESP LINE"), &Config.ESP.Line);
        ImGui::Checkbox(OBFUSCATE("ESP NAME"), &Config.ESP.Health);
        ImGui::Checkbox(OBFUSCATE("ESP BOX"), &box);
        ImGui::Checkbox(OBFUSCATE("ESP HEALTH"), &Config.ESP.Target);
        ImGui::Separator();
        ImGui::Checkbox(OBFUSCATE("SPEED RUN"), &isSpeedSafe);
        ImGui::Checkbox(OBFUSCATE("RESET GUEST"), &Reset);
    }
    if (tab == 3) {
        ImGui::Text("CHAMS");
        ImGui::Checkbox(OBFUSCATE("WIREFRAME"), &wireframe);
        ImGui::SliderFloat(OBFUSCATE("RED"), &r, 0.0f, 255.0f);
        ImGui::SliderFloat(OBFUSCATE("GREEN"), &g, 0.0f, 255.0f);
        ImGui::SliderFloat(OBFUSCATE("BLUE"), &b, 0.0f, 255.0f);
    }

//  if (resetGuest) {
       
        ImGui::Spacing();
        ImGui::Spacing();
        ImGui::Spacing();
        
        // **🔥 WARNA CUSTOM ESP**
        
        
	
	
		
ImGui::End();
    ImGui::Render();
    
    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
    return old_eglSwapBuffers(dpy, surface);
}


static int (*LEBIPIGPEEP)(...);
//static int _LEBIPIGPEEP(void* GLDLCOBLGNF)


}


//	if (Speedrun)
	//{
	//	return 1;
	//}
	//return LEBIPIGPEEP(GLDLCOBLGNF);
//}


/*
bool (*IsFoldWingGliding)(void *_CrazyMod);
bool _IsFoldWingGliding(void *_CrazyMod)
{
	if (_CrazyMod != NULL && Speedrun)
	{
		return true;
	}
	return IsFoldWingGliding(_CrazyMod);
}*
bool (*GJCHEHNJIAD)(void *_CrazyMod);
bool _GJCHEHNJIAD(void *_CrazyMod)
{
	if (_CrazyMod != NULL && Awm)
	{
		return false;
	}
	return GJCHEHNJIAD(_CrazyMod);
}
*/
float (*GetSpeedScaleBySpeedType)(void *instance);

float _GetSpeedScaleBySpeedType(void *instance) {
   
 
 if (instance != nullptr) {
        switch (isSpeed) {
            case 0: return GetSpeedScaleBySpeedType(instance);            
            case 1: return 2.4f;
            case 2: return 2.5f;
            case 3: return 2.6f;
            case 4: return 2.7f;
            case 5: return 2.8f;
            case 6: return 2.9f;
            case 7: return 3.0f;
            case 8: return 3.1f;
            case 9: return 3.2f;
   
            default: return GetSpeedScaleBySpeedType(instance);
        }
  
    }
    return GetSpeedScaleBySpeedType(instance);
}


float (*GetWeaponRunSpeedScale)(void *instance);

float _GetWeaponRunSpeedScale(void *instance) {
 
 
    if (instance != nullptr) {
        switch (isSpeed) {
            case 0: return GetWeaponRunSpeedScale(instance);            
            case 1: return 2.4f;
            case 2: return 2.5f;
            case 3: return 2.6f;
            case 4: return 2.7f;
            case 5: return 2.8f;
            case 6: return 2.9f;
            case 7: return 3.0f;
            case 8: return 3.1f;
            case 9: return 3.2f;
            default: return GetWeaponRunSpeedScale(instance);
        }
 
    }
    return GetWeaponRunSpeedScale(instance);
}
bool (*SpeedFix)();

bool _SpeedFix() {
    return true;
}

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("OJOHLBJEIJO"), 2), (void *) hook_mrAimSilent, (void **)&orig_mrSilentAim);
DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("PlayerAttributes"), OBFUSCATE("GetDashSpeedScale"), 0), (void *) _GetWeaponRunSpeedScale, (void **)& GetWeaponRunSpeedScale);
     DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("PlayerAttributes"), OBFUSCATE("GetDashSpeedScale"), 0), (void *) _GetWeaponRunSpeedScale, (void **)& GetWeaponRunSpeedScale);
     
   DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("Player"), OBFUSCATE("UpdateRotation"), 2), (void *) hook_mrAimSilent, (void **)&orig_mrSilentAim);
   DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("Player"), OBFUSCATE("IsFoldWingGliding"), 0), (void *) _SpeedFix, (void **)& SpeedFix);
   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("message"), OBFUSCATE("ProtoUtil"), OBFUSCATE("MappingFromPhysXState"), 1), (void *) _SpeedFix, (void **)& SpeedFix);
      DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("message"), OBFUSCATE("ProtoUtil"), OBFUSCATE("MappingFromPhysXState"), 1), (void *) _GetSpeedScaleBySpeedType, (void **)& GetSpeedScaleBySpeedType);
   DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("message"), OBFUSCATE("ProtoUtil"), OBFUSCATE("MappingFromPhysXState"), 1), (void *) _MappingFromPhysXState, (void **)& MappingFromPhysXState);
   DobbyHook(Il2CppGetMethodOffset(OBFUSCATE("Assembly-CSharp.dll"), OBFUSCATE("COW.GamePlay"), OBFUSCATE("Player"), OBFUSCATE("OJOHLBJEIJO"), 2), (void *) hook_mrAimSilent, (void **)&orig_mrSilentAim);
  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)


