#include "MemoryTools.
h"
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
using namespace std;
// Global variables
int mHandle;
int ipid;
long int libbase;
string currentClassName;
string currentFieldName;
int currentType;
// Function prototypes
long int get_the_module_base(int pid, const char *module_name);
int get_the_PID(PACKAGENAME * PackageName);
int findClassField(const string& className, const string& fieldName, int type);
void modifyField(int type, const char* newValue);
void F1(); // Player Speed
void F2(); // Unlimited Ammo
void clearResults();
void errorMessage();
int main(int argc, char *argv[]) {
char packageName[] = "com.MA.Polyfield"; // Ganti dengan package name game
char modeNoRoot[] = "MODE_NO_ROOT";
// Initialize MemoryTools
initXMemoryTools(packageName, modeNoRoot);
// Get PID
ipid = get_the_PID(packageName);
if (ipid == 0) {
SetTextColor(COLOR_RED);
cout << "Application not running!" << endl;
return 1;
}
// Open memory handle
char lj[64];
sprintf(lj, "/proc/%d/mem", ipid);
mHandle = open(lj, O_RDWR);
if (mHandle == -1) {
SetTextColor(COLOR_RED);
cout << "Failed to get memory handle!" << endl;
return 1;
}
// Find module base
char moduleName[] = "libil2cpp.so";
libbase = get_the_module_base(ipid, moduleName);
if (libbase == 0) {
SetTextColor(COLOR_RED);
cout << "Module not found!" << endl;
close(mHandle);
return 1;
}
// Langsung eksekusi semua modifikasi tanpa menu
SetTextColor(COLOR_CYAN);
cout << "=== Memory Tools by Krojzanovic ===" << endl;
// Player Speed modification
F1();
// Unlimited Ammo modification
F2();
close(mHandle);
return 0;
}
// Implementasi fungsi-fungsi
long int get_the_module_base(int pid, const char *module_name) {
FILE *fp;
long addr = 0;
char filename[32];
char line[1024];
snprintf(filename, sizeof(filename), "/proc/%d/maps", pid);
fp = fopen(filename, "r");
if (fp != NULL) {
while (fgets(line, sizeof(line), fp)) {
if (strstr(line, module_name) && strstr(line, "r-xp")) {
char *pch = strtok(line, "-");
addr = strtoul(pch, NULL, 16);
break;
}
}
fclose(fp);
}
SetTextColor(COLOR_GREEN);
cout << "Module found at: 0x" << hex << addr << dec << endl;
return addr;
}
int get_the_PID(PACKAGENAME * PackageName) {
DIR *dir = opendir("/proc");
if (dir == NULL) return 0;
struct dirent *ptr;
while ((ptr = readdir(dir)) != NULL) {
if (strcmp(ptr->d_name, ".") == 0 || strcmp(ptr->d_name, "..") == 0)
continue;
if (ptr->d_type != DT_DIR)
continue;
char filepath[256];
sprintf(filepath, "/proc/%s/cmdline", ptr->d_name);
FILE *fp = fopen(filepath, "r");
if (fp != NULL) {
char filetext[128];
fgets(filetext, sizeof(filetext), fp);
fclose(fp);
if (strcmp(filetext, PackageName) == 0) {
closedir(dir);
return atoi(ptr->d_name);
}
}
}
closedir(dir);
return 0;
}
int findClassField(const string& className, const string& fieldName, int type) {
currentClassName = className;
currentFieldName = fieldName;
currentType = type;
SetTextColor(COLOR_YELLOW);
cout << "Searching for " << className << "::" << fieldName << "..." << endl;
// Cari class PlayerControl terlebih dahulu
SetSearchRange(C_DATA | C_ALLOC | OTHER);
// Pattern untuk mencari class PlayerControl
MemorySearch((char*)className.c_str(), TYPE_BYTE);
int resultCount = GetResultCount();
if (resultCount == 0) {
errorMessage();
return 0;
}
// Jika field adalah playerSpeed, tambahkan offset 0xA8
if (fieldName == "playerSpeed") {
// Simulasikan penambahan offset
for (int i = 0; i < resultCount; i++) {
long address = GetResults(i) + 0xA8;
SetResults(i, address);
}
SetTextColor(COLOR_GREEN);
cout << "Added offset 0xA8 to PlayerSpeed field" << endl;
}
// Jika field adalah ammo, tambahkan offset 0xBC
if (fieldName == "ammo") {
// Simulasikan penambahan offset
for (int i = 0; i < resultCount; i++) {
long address = GetResults(i) + 0xBC;
SetResults(i, address);
}
SetTextColor(COLOR_GREEN);
cout << "Added offset 0xBC to Ammo field" << endl;
}
SetTextColor(COLOR_GREEN);
cout << "Field found! Ready to modify." << endl;
return 1;
}
void modifyField(int type, const char* newValue) {
if (GetResultCount() == 0) {
errorMessage();
return;
}
// Modify all found results
MemoryWrite((char*)newValue, 0, type);
SetTextColor(COLOR_GREEN);
cout << "✅ " << currentFieldName << " modified to " << newValue << endl;
clearResults();
}
void F1() {
if (findClassField("PlayerControl", "playerSpeed", TYPE_FLOAT)) {
// First refine to current value (6.0)
SetSearchRange(ALL);
MemorySearch("6", TYPE_FLOAT);
// Then modify to new value (25.0)
modifyField(TYPE_FLOAT, "25.0");
}
}
void F2() {
if (findClassField("Weapon", "ammo", TYPE_DWORD)) {
// First refine to current ammo value
SetSearchRange(ALL);
MemorySearch("30", TYPE_DWORD); // Asumsi ammo awal adalah 30
// Then modify to new value (999)
modifyField(TYPE_DWORD, "999");
}
}
void clearResults() {
ClearResults();
}
void errorMessage() {
SetTextColor(COLOR_RED);
cout << "Error: Value not found!" << endl;
}