Getting the Mod Working

To get the mod working properly, you will need to install the GTA VC Android APK:

Download gtavc.apk

Make sure to enable installation from unknown sources in your Android settings before installing.

Also make sure after installing of app your app should have access to permissions/Files and media/Allow management of all files -> enabled

Vice City Mod – Starter Template

Requirements:
Here’s a starter template to get you working fast:

This C++ mod example hooks into Vice City’s HUD functions using AML. You can build upon this to create your own features!

Download Basic Template:

Download JNI

The jni folder must be placed inside your NDK project directory.

How to Compile Your Mod:

Use the following commands inside your NDK project folder to build your mod:


ndk-build clean
ndk-build
    

This will compile your code into a shared library (.so) which you can then load using AML.

Where to Place the .so File:

Once your mod is compiled, you’ll get a shared library file (e.g. libYourMod.so).

Place this file in the following folder on your Android device:


/storage/emulated/0/data/com.rockstargames.gtavc/mods
    

Note: Some file managers show /storage/emulated/0/ as just Internal Storage/.

The mods folder may need to be created manually if it doesn’t already exist.

Use ZArchiver



#include <mod/amlmod.h>                // Includes the AML (Android Mod Loader) API header to interface with the modding framework.
#include <mod/logger.h>                 // Includes logging utilities to log messages to AML logs (useful for debugging).
#include <mod/config.h>                 // Includes configuration tools for reading/writing mod config files.
#include <stdlib.h>                     // Standard C library for general-purpose functions (e.g., memory allocation, process control).
#include <sys/stat.h>                   // Includes functions for working with file information (e.g., file attributes).
#include <fstream>                      // Includes C++ file stream handling for reading/writing files.
#include <stdint.h>                     // Defines fixed-width integer types (e.g., uint32_t, uintptr_t).
#include <dlfcn.h>                      // Provides functions to handle dynamic loading of shared libraries (like dlopen, dlsym).
#include <string.h>                     // Includes string manipulation functions (e.g., memcpy, strcmp).

// Comments specifying dependencies (helpful for other developers).
// libR1.so - another mod or component required
// libGTASA.so - San Andreas version of the game, mentioned likely for context or comparison

// Registering mod with AML using macro provided by AML framework
MYMODCFG(MEGAMIND.VCMOD, ViceCityMod, 1.0, MEGAMIND)
// Arguments:
// - Internal mod ID
// - Mod name
// - Mod version
// - Author name

// Global variable: handle for the GTA VC shared library
void* hGTAVC = nullptr;                // `hGTAVC` will store the handle to the loaded libGTAVC.so so we can access its symbols

// Global variable: base memory address for libGTAVC.so in the process
uintptr_t pGTAVC = 0;                  // `pGTAVC` holds the base address of the GTA VC library for offset-based modifications

// Hook declaration for the function: CHud::SetBigMessage
// This will override the original SetBigMessage function in-game
DECL_HOOKv(SetBigMessage, unsigned short* text , unsigned short style)
{
    // Define a custom message string using UTF-16 literal (char16_t)
    char16_t myString[] = u"MEGAMIND";

    // Call the original SetBigMessage but replace the message text with "MEGAMIND"
    SetBigMessage(reinterpret_cast<unsigned short*>(myString), 1);
}

// Hook declaration for the function: CHud::SetHelpMessage
// This will override the in-game help message function
DECL_HOOKv(SetHelpMessage, unsigned short* text, bool flag1, bool flag2, bool flag3)
{
    // Define a UTF-16 string "MEGAMIND" to display instead of original help message
    char16_t myString2[] = u"MEGAMIND";

    // Call the original SetHelpMessage but with custom message and custom flags
     SetHelpMessage(reinterpret_cast<unsigned short*>(myString2), true, false, false);

}

// The main entry point called by AML when the mod is loaded
extern "C" void OnModLoad()
{
    // Fetch base address of libGTAVC.so using AML API
    pGTAVC = aml->GetLib("libGTAVC.so");

    // Fetch handle to libGTAVC.so (for symbol hooking via dlsym-like API)
    hGTAVC = aml->GetLibHandle("libGTAVC.so");

    // If the library was found and loaded successfully
    if (pGTAVC && hGTAVC)
    {
        // Hook into CHud::SetBigMessage in the game's HUD system
        // _ZN4CHud13SetBigMessageEPtt is the mangled C++ name (symbol)
        HOOKSYM(SetBigMessage, hGTAVC, "_ZN4CHud13SetBigMessageEPtt");

        // Hook into CHud::SetHelpMessage function
        // _ZN4CHud14SetHelpMessageEPtbbb is the mangled symbol for the method
        HOOKSYM(SetHelpMessage, hGTAVC, "_ZN4CHud14SetHelpMessageEPtbbb");
    }
}

Go Back