Tutorial How to Create Zygisk MOD Menu

Yunana24

PMT Elite Modder
Original poster
Staff member
Modding-Team
Sep 16, 2018
5,947
588,023
1,213
Narukami Ooyashiro
This is a tutorial about how to create Zygisk Mod Menu for Unity games. It is useful for games that has some custom protections or integrity checks.
It is only recommended for modders that already have the basic knowledge.

Requirements: Rooted device with Zygisk enabled, or just grab the VPhonegaga App posted over here(searchable) by @AndnixSH to be easier.
Last tested on: VPhonegaga 3.4.0 + Magisk v26.1

Instructions:
1. Clone the repo, Github Repository: GitHub - fedes1to/Zygisk-ImGui-Menu: A template for an ImGui menu using Zygisk
(Project base credits goes to the rightfully repo owner @fedes1to)
Note: You can also get the project base codes in this thread below
2. To generate the module zip package: Run gradle task :module:assembleRelease to compile, it will be generated in the current {ProjectDirectory}/out folder.
3. To install it, you need to install by selecting the package in Magisk App.

A. What you should know/do:
1) hook.cpp
> Edit package name; #define GamePackageName "com.example.game"
> Pointers and Hook functions are called in hack_thread function. Initializing the menu is called after that by hooking the egLSwapBuffers. (leave it as is if you are unsure)
2) menu.h
> DrawMenu function is responsible to create or watch the components of the mod menu.
3) functions.h
> This is where you would write your hooks, you can call HOOK, PATCH functions directly.
4) Obfuscate function is already integrated, at Include/obfuscate.h. Be sure to utilize it.

B. What you might be also interested:
1) To change module properties such as name, version, you need to edit module.gradle accordingly.
2) It is generating four ABIs by default, add abiFilters into build.gradle based on your needs accordingly.
For example (only for ARM64):
Code:
release {
    ndk {
        abiFilters  'arm64-v8a'
        }
    }
}
Note: Be sure to create the module based on the architecture(s) you want to support.
3) Mod Menu is created with IMGUI, you can refer to imgui.h for more menu components.

C. End to End Example - Adding God Mode & Damage Multiplier Features
Note: This is just an example code snippet. Please don't treat it as a bible, make changes as you deemed necessary.

1) Edit package name
Inside hook.cpp, edit the package name:
C++:
#define GamePackageName "com.platinmods.yunana" // example
2) We have to write the logic such as declaring the variables, creating the hook functions and calling them as well
Inside functions.h
C++:
// Declaring variables
bool isGodMode; int damageMultiplier = 1;

// Creating the hook functions
void (*old_ApplyDamagePlayer)(void* instance);
void ApplyDamagePlayer(void instance) {
    if (instance != NULL) {
        if (isGodMode) {
            return;
        }
    }
    return old_ApplyDamagePlayer(instance);
}
void (*old_ApplyDamageEnemy)(void* instance, int damage);
void ApplyDamageEnemy(void instance, int damage) {
    if (instance != NULL) {
        damage *= damageMultiplier;
    }
    return old_ApplyDamageEnemy(instance, damage);
}

// Calling the hooks constructed above
void Hooks() {
    // HOOK are automatically obfuscated, refer to macros defined in Misc.h
    HOOK("0xOFFSET_1", ApplyDamagePlayer, old_ApplyDamagePlayer);
    HOOK("0xOFFSET_2", ApplyDamageEnemy, old_ApplyDamageEnemy);
}
3) Now, let's create the menu components
Inside menu.h:
C++:
void DrawMenu()
{
    static ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
    {
        Begin(OBFUSCATE("Platinmods.com")); // Header
        ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_FittingPolicyResizeDown;
        if (BeginTabBar(OBFUSCATE("Main Tab"), tab_bar_flags)) {
            if (BeginTabItem(BFUSCATE("Tab Items"))) {
                TextUnformatted(OBFUSCATE("Damage Multiplier:")); // just plain text

                SliderInt(OBFUSCATE("Damage Multiplier"), &damageMultiplier, 1, 100, OBFUSCATE("%d"), 0); // min = 1, max = 100
                Checkbox(OBFUSCATE("God Mode"), &isGodMode);
                EndTabItem();
            }
            EndTabBar();
        }
        Patches(); // <-This is entry point of patching functions, navigate to it and you will understand :)
        End();
    }
}
4) Run gradle task :module:assembleRelease to compile. Grab the module package.zip from {ProjectDirectory}/out folder
5) Install the module package.zip with Magisk App. Reboot the device and launch the target game.

D. Extras
1) You might be facing initialization error complaining about Unsupported Java. This is because the Java version on your machine is not compatible with the gradle version used in the project. However, we can fix this easily. Special thanks to @Mika Cybertron
> When open original projects it will give you this error.
1691065565616.png

> Click on "Unsupported Java" and it will give you the solution how to fix it (in blue text)
1691065632702.png

> Then just click that blue text and wait for the process to complete.
> Easy way to build the module
>Select Build Variant to change type build like from "debug to release" then click "Make Project" in Menu "Build > Make Project" to compile/build your zygisk module
Note: No need to change "Active ABI"
1691065749513.png

> Sample Output
1691065781559.png


2) Project complaints about CMake cannot be found
Special thanks to @Keiran98 for this finding
1691073018127.png

> Install the required CMake version
1691073115698.png



Lastly, as mentioned in the text above, you can get the base project codes from the Github repo or using the links I provided below:
Hidden content
** You must be signed up and reply to the thread or click 'Like' under this post before you can see the hidden links contained here. **
If you still facing issues revealing the hidden links, please read this.
 
Last edited:

fedesito

Platinian
Jun 11, 2023
6
5
3
25
no
i realised kinda late that my stuff was here lol, anyways good tutorial ill just link it in the github issues page if anyone asks for anything thats explained here lol
 
  • Like
Reactions: Del3646999