Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <pthread.h>
- #include "KittyMemory/MemoryPatch.h"
- #include "Logger.h"
- // fancy struct for patches
- struct My_Patches {
- // let's assume we have patches for these functions for whatever game
- // like show in miniMap boolean function
- MemoryPatch isUnlimatedGold;
- MemoryPatch isUnlimatedGems;
- // etc...
- }patches;
- // we will run our patches in a new thread so "sleep" doesn't block process main thread
- void *my_test_thread(void *) {
- LOGD("I have been loaded...");
- // loop until our target library is found
- ProcMap il2cppMap;
- do {
- il2cppMap = KittyMemory::getLibraryMap("libil2cpp.so");
- sleep(1);
- } while(!il2cppMap.isValid());
- // now here we do our stuff
- // let's say our patches are meant for an arm library
- // http://shell-storm.org/online/Online-Assembler-and-Disassembler/
- /*
- * mov r0, #1
- * bx lr
- */
- // address = 0x6A6144
- // bytes len = 8
- patches.isUnlimatedGems = MemoryPatch("libil2cpp.so", 0x59DD98,"\x01\x08\xa0\xe3\x1e\xff\x2f\xe1", 8);
- patches.isUnlimatedGold = MemoryPatch("libil2cpp.so", 0x72E9F0,"\x01\x08\xa0\xe3\x1e\xff\x2f\xe1", 8);
- LOGD("===== New Patch Entry =====");
- LOGD("Patch Address: %p", (void *)patches.isUnlimatedGems.get_TargetAddress());
- LOGD("Patch Size: %zu", patches.isUnlimatedGems.get_PatchSize());
- LOGD("Current Bytes: %s", patches.isUnlimatedGems.ToHexString().c_str());
- // modify & print bytes
- if (patches.isUnlimatedGems.Modify()) {
- LOGD("Unlimated Gems has been modified successfully");
- LOGD("Current Bytes: %s", patches.isUnlimatedGems.ToHexString().c_str());
- }
- // restore & print bytes
- if (patches.isUnlimatedGems.Restore()) {
- LOGD("Unlimated Gems has been restored successfully");
- LOGD("Current Bytes: %s", patches.isUnlimatedGems.ToHexString().c_str());
- }
- LOGD("===========================");
- LOGD("===== New Patch Entry =====");
- LOGD("Patch Address: %p", (void *)patches.isUnlimatedGold.get_TargetAddress());
- LOGD("Patch Size: %zu", patches.isUnlimatedGold.get_PatchSize());
- LOGD("Current Bytes: %s", patches.isUnlimatedGold.ToHexString().c_str());
- if (patches.isUnlimatedGold.Modify()) {
- LOGD("Unlimated Gold has been modified successfully");
- LOGD("Current Bytes: %s", patches.isUnlimatedGold.ToHexString().c_str());
- }
- // restore & print bytes
- if (patches.isUnlimatedGold.Restore()) {
- LOGD("Unlimated Gold has been restored successfully");
- LOGD("Current Bytes: %s", patches.isUnlimatedGold.ToHexString().c_str());
- }
- LOGD("===========================");
- return NULL;
- }
- __attribute__((constructor))
- void initializer() {
- pthread_t ptid;
- pthread_create(&ptid, NULL, my_test_thread, NULL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement