Jump to content

Simplified MSHookMemory Usage [ARM64 Only]


23 posts in this topic

Recommended Posts

While MSHookMemory is great, I hate I have to do this:

const uint8_t hack[] = {
    0x00, 0x00, 0x80, 0x52, // mov w0, #0
    0xc0, 0x03, 0x5f, 0xd6, // ret
};

 

 

So I wrote some code which won't need you to do that:

#include <substrate.h>
#include <mach-o/dyld.h>

#define ASLR_BIAS _dyld_get_image_vmaddr_slide(0)

uint64_t getRealOffset(uint64_t offset){
	return ASLR_BIAS + offset;
}

// main func
void inject(uint64_t offset, uint64_t hackedHex) {

    hackedHex = CFSwapInt32(hackedHex);        

    MSHookMemory((void *)getRealOffset(offset), (void *)&hackedHex, sizeof(hackedHex));
}

 

How to import this code to your project?

You have two options:

1. Copy & paste the code from above under your "imports"

2. Download this file & paste it in /var/theos/includes & write this on top of tweak.xm:

#include <inject.h>

 

Usage of the function:

//parameters it takes
inject(0xIDAOffset, 0xHackedHex);

//actual usage on a offset
inject(0x100299DC4, 0xC0035FD6);

 

 

Bugs to be fixed:

1. If you wanna write a hex more than 4 bytes, it won't work the way you think, example:

inject(0x100299DC0, 0x20008052C0035FD6);

/*

	This will write C0035FD620008052 instead of what you entered due the CFSwapInt32

/*

NOTE:  I'm no pro at this kinda stuff (dealing with memory), so if there's anything just mention it ^^

 

Credits

- Saurik

- topics from https://stackoverflow.com/   which helped me understand several things

- Me for this simplified version

Updated by Joey
  • Like 3
  • Winner 3
  • Informative 1
Link to comment
https://iosgods.com/topic/90873-simplified-mshookmemory-usage-arm64-only/
Share on other sites

17 minutes ago, TheArmKing said:

is it possible to make the hackedHex param a stirng, make it an array of strings which gets split at every 2nd character and add a 0x to each of them

Yeah I tried that, but couldn’t get something like it to work. I’ve tried multiple things, this is the only one that worked. Will look into an alternative another time. C/C++ isn’t the most user friendly when it comes to arrays it seems 

Updated by Joey
26 minutes ago, Joey said:

Yeah I tried that, but couldn’t get something like it to work. I’ve tried multiple things, this is the only one that worked. Will look into an alternative another time. C/C++ isn’t the most user friendly when it comes to arrays it seems 

something like this maybe?
 

// Convert long long to string
// Convert string to char array
// loop through char array to make strings of 2 characters or 1 byte, like c00fe3d4 becomes c0 0f e3 d4
// c0 gets converted to int
// the int gets converted to uint8
// the uint8 gets appeneded to aa uint8 array
// copied this from stackexchange 
char str[256];
sprintf(str, "%lld", hackedHex);
printf("%s\n", str); 

for (int x=0; x<str.length; x++ ) { //dk if this is how C works
  if(x%2==0){
    char a = str[x]
  }
  if(x%2==1){
    char b = str[x]
    // do something that combines char a and b to a string
    // then convert to int
    // then to uint
    // then append to array
}


 

Updated by TheArmKing
added some bs

I don't know why people prefer integers type for this purpose which forces you to deal with endianness.

I just simplified yours too.

void inject(uint64_t offset, const void *bytes, size_t bytes_len) {
	 MSHookMemory((void *)getRealOffset(offset), bytes, bytes_len);
}

Usage:

//offset & bytes literal & bytes length
/* 
mov w0, #1
ret 
*/
inject(0x100299DC4, "\x20\x00\x80\x52\xC0\x03\x5F\xD6", 8);

You can write as many bytes as you want with this.

5 hours ago, CyberCat said:

I don't know why people prefer integers type for this purpose which forces you to deal with endianness.

I just simplified yours too.


void inject(uint64_t offset, const void *bytes, size_t bytes_len) {
	 MSHookMemory((void *)getRealOffset(offset), bytes, bytes_len);
}

Usage:


//offset & bytes literal & bytes length
/* 
mov w0, #1
ret 
*/
inject(0x100299DC4, "\x20\x00\x80\x52\xC0\x03\x5F\xD6", 8);

You can write as many bytes as you want with this.

The thing is, I hate to have to write it like that ^, it’s almost the same as the original now :p 

7 hours ago, TheArmKing said:

something like this maybe?
 


// Convert long long to string
// Convert string to char array
// loop through char array to make strings of 2 characters or 1 byte, like c00fe3d4 becomes c0 0f e3 d4
// c0 gets converted to int
// the int gets converted to uint8
// the uint8 gets appeneded to aa uint8 array

// copied this from stackexchange 
char str[256];
sprintf(str, "%lld", hackedHex);
printf("%s\n", str); 

for (int x=0; x<str.length; x++ ) { //dk if this is how C works
  if(x%2==0){
    char a = str[x]
  }
  if(x%2==1){
    char b = str[x]
    // do something that combines char a and b to a string
    // then convert to int
    // then to uint
    // then append to array
}


 

possibly, but I think there must be a simpler solution 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below. For more information, please read our Posting Guidelines.
Reply to this topic... Posting Guidelines

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Our picks

    • Lucky Defense! Cheats v1.4.10 +2
      Modded/Hacked App: Lucky Defense! By Crater Co., Ltd.
      Bundle ID: com.percent.ios.luckydefense
      iTunes Store Link: https://apps.apple.com/us/app/lucky-defense/id6482291732?uo=4


      Hack Features:
      - Free Spawn
      - Unlimited Spawn
      - Free In-Game Upgrade


      iOS Hack Download Link: https://iosgods.com/topic/183406-lucky-defense-cheats-v121-3/
      • 164 replies
    • Hero Assemble : Epic Idle RPG Cheats v1.10.02 +5
      Modded/Hacked App: Hero Assemble : Epic Idle RPG By cookapps
      Bundle ID: com.cookapps.heroassemble
      iTunes Store Link: https://apps.apple.com/us/app/hero-assemble-epic-idle-rpg/id6478940653?uo=4


      Mod Requirements:
      - Jailbroken iPhone/iPad/iPod Touch.
      - iGameGod / Filza / iMazing or any other file managers for iOS.
      - Cydia Substrate, ElleKit, Substitute or libhooker depending on your jailbreak.
      - PreferenceLoader (from Cydia, Sileo or Zebra).


      Hack Features:
      - Damage Multiplier
      - Defense Multiplier
      - Loot Multiplier
      - Jailbreak Detection Removed


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/


      iOS Hack Download Link:

      Hidden Content
      Download Hack







      Installation Instructions:
      STEP 1: Download the .deb Cydia hack file from the link above. Use Safari/Google Chrome or other iOS browsers to download.
      STEP 2: Once the file has downloaded, tap on it and then you will be prompted on whether you want to open the deb with iGameGod or copy it to Filza.
      STEP 3: If necessary, tap on the downloaded file, and then, you will need to press 'Install' from the options on your screen.
      STEP 4: Let iGameGod/Filza finish the cheat installation. Make sure it successfully installs, otherwise see the note below.
      STEP 5: If the hack is a Mod Menu — which is usually the case nowadays — the cheat features can be toggled in-game. Some cheats have options that can be enabled from your iDevice settings.
      STEP 6: Turn on the features you want and play the game. You may need to follow further instructions inside the hack's popup in-game.

       

      NOTE: If you have any questions or problems, read our Troubleshooting topic & Frequently Asked Questions & Answers topic. If you still haven't found a solution, post your issue down below and we'll do our best to help! If the hack does work for you, please post your feedback below and help out other fellow members that are encountering issues.


      Credits:
      - AlyssaX64


      Cheat Video/Screenshots:

      N/A
      • 132 replies
    • The Crown Saga: Pi’s Adventure Cheats v1.0.13 +6
      Modded/Hacked App: The Crown Saga: Pi’s Adventure By SuperPlanet corp.
      Bundle ID: com.superplanet.crown
      iTunes Store Link: https://apps.apple.com/us/app/the-crown-saga-pis-adventure/id6636483923?uo=4


      Hack Features:
      - Multiply Attack
      - Multiply Defense
      - God Mode
      - Instant Skills
      - Infinite MP
      - Custom Move Speed


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/forum/79-no-jailbreak-section/
       


      iOS Hack Download Link: https://iosgods.com/topic/188573-the-crown-saga-pi%E2%80%99s-adventure-cheats-v107-6/
      • 42 replies
    • Super Stylist Fashion Makeover Cheats v3.5.3 +1
      Modded/Hacked App: Super Stylist Fashion Makeover By CRAZY STYLE LTD
      Bundle ID: com.babyeducationtoys.fashionstyle
      iTunes Store Link: https://apps.apple.com/us/app/super-stylist-fashion-makeover/id1441648201?uo=4


      Hack Features:
      - Free Store (not iAP)


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/topic/112404-super-stylist-fashion-makeover-v352-jailed-cheats-1/


      iOS Hack Download Link: https://iosgods.com/topic/190368-super-stylist-fashion-makeover-cheats-v352-1/
      • 0 replies
    • Toca Boca World Modded v1.101.0 +1
      Modded/Hacked App: Toca Boca World By Toca Boca AB
      Bundle ID: com.tocaboca.tocalifeworld
      iTunes Store Link: https://apps.apple.com/us/app/toca-boca-world/id1208138685?uo=4


      Mod Requirements:
      - Jailbroken iPhone/iPad/iPod Touch.
      - iFile / Filza / iFunBox / iTools or any other file managers for iOS.
      - Cydia Substrate (from Cydia).
      - PreferenceLoader (from Cydia).


      Hack Features:
      - Everything Purchased


      Non-Jailbroken & No Jailbreak required hack(s): 


      Hack Download Link:

      Hidden Content

      Download Hack








      Installation Instructions:
      STEP 1: Download the .deb Cydia hack file from the link above.
      STEP 2: Copy the file over to your iDevice using any of the file managers mentioned above or skip this step if you're downloading from your iDevice.
      STEP 3: Using iFile or Filza, browse to where you saved the downloaded .deb file and tap on it.
      STEP 4: Once you tap on the file, you will then need to press on 'Installer' or 'Install' from the options on your screen.
      STEP 5: Let iFile / Filza finish the cheat installation. Make sure it successfully installs, otherwise see the note below.
      STEP 6: Now open your iDevice settings and scroll down until you see the settings for this cheat and tap on it. If the hack is a Mod Menu, the cheat features can be toggled in-game.
      STEP 7: Turn on the features you want and play the game. You may need to follow further instructions inside the hack's popup in-game.

       

      NOTE: If you have any questions or problems, read our Troubleshooting topic & Frequently Asked Questions topic. If you still haven't found a solution, post your issue down below and we'll do our best to help! If the hack does work for you, post your feedback below and help out other fellow members that are encountering issues.


      Credits:
      - @Laxus


      Cheat Video/Screenshots:

      N/A

       
        • Thanks
      • 1,347 replies
    • Disney Magic Kingdoms Cheats v10.0.0 +1
      Modded/Hacked App: Disney Magic Kingdoms By Gameloft
      Bundle ID: com.gameloft.disneykingdom
      iTunes Store Link: https://apps.apple.com/us/app/disney-magic-kingdoms/id731592936?uo=4


      Hack Features:
      - Free Store ( not Free iAP )
      * Will let you purchase even you don't have enough


      iOS Hack Download Link: https://iosgods.com/topic/147877-disney-magic-kingdoms-cheats-v610-1/
      • 373 replies
    • Cooking Diary Restaurant Game v2.35.2 Jailed Cheats +3
      Modded/Hacked App: Cooking Diary® Restaurant Game by MyTona Pte Ltd
      Bundle ID: com.mytonallc.cookingdiary
      iTunes Store Link: https://apps.apple.com/us/app/cooking-diary-restaurant-game/id1214763610?uo=4&at=1010lce4


      Hack Features:
      - Infinite Currencies (Get some)
      - Freeze Boosters


      iOS Hack Download Link: https://iosgods.com/topic/110310-arm64-cooking-diary-restaurant-game-v1160-3/
      • 652 replies
    • SimCity BuildIt Cheats v1.60.1 +1 [ Infinite Currencies ]
      Modded/Hacked App: SimCity BuildIt By EA Swiss Sarl
      Bundle ID: com.ea.simcitymobile.bv
      iTunes Store Link: https://apps.apple.com/us/app/simcity-buildit/id913292932?uo=4


      Hack Features:
      - Infinite Currencies


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/topic/124792-arm64-simcity-buildit-v1412-jailed-cheats-1/


      iOS Hack Download Link: https://iosgods.com/topic/157687-simcity-buildit-cheats-v1415-1/
      • 605 replies
    • Family Island — Farm game v2024206.0.64579 Jailed Cheats +1
      Modded/Hacked App: Family Island™ — Farm game by Melsoft
      Bundle ID: com.MelsoftGames.FamilyIsland
      iTunes Store Link: https://apps.apple.com/us/app/family-island-farm-game/id1464689103?uo=4&at=1010lce4


      Hack Features:
      - Cheat Engine Enabled


      iOS Hack Download Link: https://iosgods.com/topic/115337-arm64-family-island-%E2%80%94-farm-game-v20190824862-jailed-cheats-1/
      • 2,232 replies
    • Demon Squad: Idle RPG Cheats v1.66 +2
      Modded/Hacked App: Demon Squad: Idle RPG By SuperPlanet corp.
      Bundle ID: com.superplanet.demonsquad
      iTunes Store Link: https://apps.apple.com/us/app/demon-squad-idle-rpg/id6504470907?uo=4


      Hack Features:
      - Multiply Attack
      - Multiply Defense


      iOS Hack Download Link: https://iosgods.com/topic/185576-demon-squad-idle-rpg-cheats-v139-2/
      • 74 replies
    • RPG AVABEL ONLINE Cheats v11.12.3 - [ God Mode & More ]
      Modded/Hacked App: RPG AVABEL ONLINE By ASOBIMO,Inc.
      Bundle ID: com.asobimo.AvabelOnline
      iTunes Store Link: https://itunes.apple.com/us/app/rpg-avabel-online/id606800657
       

      Mod Requirements:
      - Jailbroken iPhone/iPad/iPod Touch.
      - iFile / Filza / iFunBox / iTools or any other file managers for iOS.
      - Cydia Substrate (from Cydia).
      - PreferenceLoader (from Cydia).


      Hack Features:
      - God Mode 
      - Cast Speed Multiplier
      - Charge Speed Multiplier
      - Approach Speed Multiplier
      - No Roll CoolDown
      - No Skills CoolDown

      This hack is an In-Game Mod Menu (iGMM). In order to activate the Mod Menu, tap on the iOSGods button found inside the app. This hack works on the latest x64 or ARM64 iDevices: iPhone 5s, 6, 6 Plus, 6s, 6s Plus, 7, 7 Plus, 8, 8 Plus, X, Xr, Xs, Xs Max, SE, iPod Touch 6G, iPad Air, Air 2, Pro & iPad Mini 2, 3, 4 and later.
      • 2,134 replies
    • Zooba: Zoo Battle Royale Game Cheats v4.64.0 +2
      Modded/Hacked App: Zooba: Zoo Battle Royale Game by Wildlife Studios Limited
      Bundle ID: com.fungames.battleroyale
      iTunes Store Link: https://apps.apple.com/us/app/zooba-zoo-battle-royale-game/id1459402952?uo=4&at=1010lce4


      Hack Features:
      - Map Hacks
      - Allow Shoot In Water


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/topic/131134-arm64-zooba-zoo-battle-royale-game-v220-jailed-cheats-1/


      iOS Hack Download Link: https://iosgods.com/topic/131104-arm64-zooba-zoo-battle-royale-game-cheats-all-versions-1/
      • 1,172 replies
×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines