Hello, modders and users!
I can't understand, why my mod don't change anything.
I try remod 10+ times. Change update offset for another, but this not help. I try use only method with Vector3, but game crashes.
Game: Constellation Eleven.
float randomgems; class Bounty;
int count; (in questasteroids) class QuestAsteroids;
float timer; (time to complete mission)
I can't understand, why my mod don't change anything.
I try remod 10+ times. Change update offset for another, but this not help. I try use only method with Vector3, but game crashes.
Game: Constellation Eleven.
float randomgems; class Bounty;
int count; (in questasteroids) class QuestAsteroids;
float timer; (time to complete mission)
C++:
#include <list>
#include <vector>
#include <string.h>
#include <pthread.h>
#include <thread>
#include <cstring>
#include <jni.h>
#include <unistd.h>
#include <fstream>
#include <iostream>
#include <dlfcn.h>
#include "Includes/Logger.h"
#include "Includes/obfuscate.h"
#include "Includes/Utils.h"
#include "KittyMemory/MemoryPatch.h"
#include "Menu/Setup.h"
#include "Substrate/SubstrateHook.h"
#include "Substrate/CydiaSubstrate.h"
//Target lib here
#define targetLibName OBFUSCATE("libil2cpp.so")
#include "Includes/Macros.h"
struct Vector3 {
int x, y, z;
};
bool CrystallToogle = false;
bool CrystallToogle1 = false;
bool CrystallToogle2 = false;
bool BCTrace = false;
int sliderValue = 1, level = 0;
void *instanceBtn;
// Hooking examples. Assuming you know how to write hook
void (*old_BountyCrystall)(void *instance);
void NewBountyCrystall(void *instance) {
instanceBtn = instance;
if (instance != NULL) {
if (CrystallToogle) {
*(float *) ((uint64_t) instance + 0x20) = 999999.0f;
}
}
old_BountyCrystall(instance);
}
void (*old_BountyCrystall1)(void *instance);
void NewBountyCrystall1(void *instance) {
instanceBtn = instance;
if (instance != NULL) {
if (CrystallToogle1) {
*(float *) ((uint64_t) instance + 0x38) = 9999.0f;
}
}
old_BountyCrystall1(instance);
}
void (*old_BountyCrystall2)(void *instance);
void NewBountyCrystall2(void *instance) {
instanceBtn = instance;
if (instance != NULL) {
if (CrystallToogle2) {
*(int *) ((uint64_t) instance + 0x18) = 1;
}
}
old_BountyCrystall2(instance);
}
/*void (*old_BountyCrystal)(void *instance, float _level, Vector3* _pos, float _count);
void Newbounty(void *instance, float _level, Vector3* _pos, float _count) {
instanceBtn = instance;
if (instance != NULL) {
if (BCTrace) {
Vector3 v3 = {1,2,3};
old_BountyCrystal(instance, 5.0f, &v3, 1000.0f);
}
}
old_BountyCrystal(instance, _level, _pos, _count);
}
*/
// we will run our hacks in a new thread so our while loop doesn't block process main thread
void *hack_thread(void *) {
LOGI(OBFUSCATE("pthread created"));
//Check if target lib is loaded
do {
sleep(1);
} while (!isLibraryLoaded(targetLibName));
//Anti-lib rename
/*
do {
sleep(1);
} while (!isLibraryLoaded("libYOURNAME.so"));*/
LOGI(OBFUSCATE("%s has been loaded"), (const char *) targetLibName);
#if defined(__aarch64__) //To compile this code for arm64 lib only. Do not worry about greyed out highlighting code, it still works
#else //To compile this code for armv7 lib only.
MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0x252138), (void *) NewBountyCrystall, (void **) &old_BountyCrystall);
MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0x2B3618), (void *) NewBountyCrystall1, (void **) &old_BountyCrystall1);
MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0x2B5E94), (void *) NewBountyCrystall2, (void **) &old_BountyCrystall2);
//MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0x252138), (void *) Newbounty, (void **) &old_BountyCrystal);
LOGI(OBFUSCATE("Done"));
#endif
//Anti-leech
/*if (!iconValid || !initValid || !settingsValid) {
//Bad function to make it crash
sleep(5);
int *p = 0;
*p = 0;
}*/
return NULL;
}
// Do not change or translate the first text unless you know what you are doing
// Assigning feature numbers is optional. Without it, it will automatically count for you, starting from 0
// Assigned feature numbers can be like any numbers 1,3,200,10... instead in order 0,1,2,3,4,5...
// ButtonLink, Category, RichTextView and RichWebView is not counted. They can't have feature number assigned
// Toggle, ButtonOnOff and Checkbox can be switched on by default, if you add True_. Example: CheckBox_True_The Check Box
// To learn HTML, go to this page: https://www.w3schools.com/
jobjectArray GetFeatureList(JNIEnv *env, jobject context) {
jobjectArray ret;
const char *features[] = {
OBFUSCATE("Category_Hacks"), //Not counted
OBFUSCATE("Toggle_Crystall Bounty Hack"),
OBFUSCATE("Toggle_Timer Go to dist"),
OBFUSCATE("Toggle_Count Asteroids")
// OBFUSCATE("Toggle_Bounty Titan")
};
//Now you dont have to manually update the number everytime;
int Total_Feature = (sizeof features / sizeof features[0]);
ret = (jobjectArray)
env->NewObjectArray(Total_Feature, env->FindClass(OBFUSCATE("java/lang/String")),
env->NewStringUTF(""));
for (int i = 0; i < Total_Feature; i++)
env->SetObjectArrayElement(ret, i, env->NewStringUTF(features[i]));
return (ret);
}
void Changes(JNIEnv *env, jclass clazz, jobject obj,
jint featNum, jstring featName, jint value,
jboolean boolean, jstring str) {
LOGD(OBFUSCATE("Feature name: %d - %s | Value: = %d | Bool: = %d | Text: = %s"), featNum,
env->GetStringUTFChars(featName, 0), value,
boolean, str != NULL ? env->GetStringUTFChars(str, 0) : "");
//BE CAREFUL NOT TO ACCIDENTLY REMOVE break;
switch (featNum) {
case 0:
CrystallToogle = !CrystallToogle;
break;
case 1:
CrystallToogle1 = boolean;
break;
case 2:
CrystallToogle2 = boolean;
break;
// case 3:
// BCTrace=!BCTrace;
//break;
}
}
__attribute__((constructor))
void lib_main() {
// Create a new thread so it does not block the main thread, means the game would not freeze
pthread_t ptid;
pthread_create(&ptid, NULL, hack_thread, NULL);
}
int RegisterMenu(JNIEnv *env) {
JNINativeMethod methods[] = {
{OBFUSCATE("Icon"), OBFUSCATE("()Ljava/lang/String;"), reinterpret_cast<void *>(Icon)},
{OBFUSCATE("IconWebViewData"), OBFUSCATE("()Ljava/lang/String;"), reinterpret_cast<void *>(IconWebViewData)},
{OBFUSCATE("IsGameLibLoaded"), OBFUSCATE("()Z"), reinterpret_cast<void *>(isGameLibLoaded)},
{OBFUSCATE("Init"), OBFUSCATE("(Landroid/content/Context;Landroid/widget/TextView;Landroid/widget/TextView;)V"), reinterpret_cast<void *>(Init)},
{OBFUSCATE("SettingsList"), OBFUSCATE("()[Ljava/lang/String;"), reinterpret_cast<void *>(SettingsList)},
{OBFUSCATE("GetFeatureList"), OBFUSCATE("()[Ljava/lang/String;"), reinterpret_cast<void *>(GetFeatureList)},
};
jclass clazz = env->FindClass(OBFUSCATE("com/android/support/Menu"));
if (!clazz)
return JNI_ERR;
if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) != 0)
return JNI_ERR;
return JNI_OK;
}
int RegisterPreferences(JNIEnv *env) {
JNINativeMethod methods[] = {
{OBFUSCATE("Changes"), OBFUSCATE("(Landroid/content/Context;ILjava/lang/String;IZLjava/lang/String;)V"), reinterpret_cast<void *>(Changes)},
};
jclass clazz = env->FindClass(OBFUSCATE("com/android/support/Preferences"));
if (!clazz)
return JNI_ERR;
if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) != 0)
return JNI_ERR;
return JNI_OK;
}
int RegisterMain(JNIEnv *env) {
JNINativeMethod methods[] = {
{OBFUSCATE("CheckOverlayPermission"), OBFUSCATE("(Landroid/content/Context;)V"), reinterpret_cast<void *>(CheckOverlayPermission)},
};
jclass clazz = env->FindClass(OBFUSCATE("com/android/support/Main"));
if (!clazz)
return JNI_ERR;
if (env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])) != 0)
return JNI_ERR;
return JNI_OK;
}
extern "C"
JNIEXPORT jint JNICALL
JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
vm->GetEnv((void **) &env, JNI_VERSION_1_6);
if (RegisterMenu(env) != 0)
return JNI_ERR;
if (RegisterPreferences(env) != 0)
return JNI_ERR;
if (RegisterMain(env) != 0)
return JNI_ERR;
return JNI_VERSION_1_6;
}