Advertisement
Francois284Modz

Untitled

Jan 18th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.81 KB | None | 0 0
  1. #include <pthread.h>
  2. #include "KittyMemory/MemoryPatch.h"
  3. #include "Logger.h"
  4.  
  5. // fancy struct for patches
  6.  struct My_Patches {
  7.      // let's assume we have patches for these functions for whatever game
  8.      // like show in miniMap boolean function
  9.      MemoryPatch isUnlimatedGold;
  10.      MemoryPatch isUnlimatedGems;
  11.    
  12.      // etc...
  13.  }patches;
  14.  
  15.  
  16. // we will run our patches in a new thread so "sleep" doesn't block process main thread
  17. void *my_test_thread(void *) {
  18.     LOGD("I have been loaded...");
  19.    
  20.     // loop until our target library is found
  21.     ProcMap il2cppMap;
  22.     do {
  23.         il2cppMap = KittyMemory::getLibraryMap("libil2cpp.so");
  24.         sleep(1);
  25.     } while(!il2cppMap.isValid());
  26.    
  27.    
  28.  
  29.     // now here we do our stuff
  30.     // let's say our patches are meant for an arm library
  31.  
  32.     // http://shell-storm.org/online/Online-Assembler-and-Disassembler/
  33.     /*
  34.     * mov r0, #1
  35.     * bx lr
  36.     */
  37.     // address = 0x6A6144
  38.     // bytes len = 8
  39.     patches.isUnlimatedGems = MemoryPatch("libil2cpp.so", 0x59DD98,"\x01\x08\xa0\xe3\x1e\xff\x2f\xe1", 8);
  40.     patches.isUnlimatedGold = MemoryPatch("libil2cpp.so", 0x72E9F0,"\x01\x08\xa0\xe3\x1e\xff\x2f\xe1", 8);
  41.  
  42.  
  43.     LOGD("===== New Patch Entry =====");
  44.     LOGD("Patch Address: %p", (void *)patches.isUnlimatedGems.get_TargetAddress());
  45.     LOGD("Patch Size: %zu", patches.isUnlimatedGems.get_PatchSize());
  46.     LOGD("Current Bytes: %s", patches.isUnlimatedGems.ToHexString().c_str());
  47.  
  48.     // modify & print bytes
  49.     if (patches.isUnlimatedGems.Modify()) {
  50.         LOGD("Unlimated Gems has been modified successfully");
  51.         LOGD("Current Bytes: %s", patches.isUnlimatedGems.ToHexString().c_str());
  52.     }
  53.     // restore & print bytes
  54.     if (patches.isUnlimatedGems.Restore()) {
  55.         LOGD("Unlimated Gems has been restored successfully");
  56.         LOGD("Current Bytes: %s", patches.isUnlimatedGems.ToHexString().c_str());
  57.     }
  58.     LOGD("===========================");
  59.  
  60.     LOGD("===== New Patch Entry =====");
  61.     LOGD("Patch Address: %p", (void *)patches.isUnlimatedGold.get_TargetAddress());
  62.     LOGD("Patch Size: %zu", patches.isUnlimatedGold.get_PatchSize());
  63.     LOGD("Current Bytes: %s", patches.isUnlimatedGold.ToHexString().c_str());
  64.  
  65.  
  66.         if (patches.isUnlimatedGold.Modify()) {
  67.         LOGD("Unlimated Gold has been modified successfully");
  68.         LOGD("Current Bytes: %s", patches.isUnlimatedGold.ToHexString().c_str());
  69.     }
  70.     // restore & print bytes
  71.     if (patches.isUnlimatedGold.Restore()) {
  72.         LOGD("Unlimated Gold has been restored successfully");
  73.         LOGD("Current Bytes: %s", patches.isUnlimatedGold.ToHexString().c_str());
  74.     }
  75.     LOGD("===========================");
  76.  
  77.     return NULL;
  78. }
  79.  
  80. __attribute__((constructor))
  81. void initializer() {
  82.     pthread_t ptid;
  83.     pthread_create(&ptid, NULL, my_test_thread, NULL);
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement