Jump to content

Simplified MSHookMemory Usage [ARM64 Only]


23 posts in this topic

Recommended Posts

Updated (edited)

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
Posted
1 minute ago, Joka said:

How is this Tools?

It's a .h file, which is a tool to patch memory ? idk LUL
Both sections fine for me

Posted

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

Posted (edited)
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
Posted (edited)
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
Posted

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.

Posted
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 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Our picks

    • Bloons TD 6 v49.0 +24 MEGA Jailed Cheats
      Modded/Hacked App: Bloons TD 6 By Ninja Kiwi Limited
      Bundle ID: com.ninjakiwi.bloonstd6
      iTunes Store Link: https://apps.apple.com/us/app/bloons-td-6/id1118115766?uo=4


      Hack Features:
      - Place Tower Anywhere<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Multiple God Towers<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- God Mode<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Infinite Cash<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Infinite Monkey Money<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Infinite Powers<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Unlock All Heroes<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Unlock All Knowledges<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Unlock All Towers<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Unlock All Upgrades<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Can Unlock Map (Click any locked map)<br style="background-color:#1e1f25;color:rgba(255,255,255,0.81);font-size:14px;">- Bypass Tutorial (Place one tower and quit the game)


      Jailbreak required hack(s): 
      • 1,437 replies
    • Bloons TD 6 v49.0 +24 MEGA Cheats
      Modded/Hacked App: Bloons TD 6 By Ninja Kiwi Limited
      Bundle ID: com.ninjakiwi.bloonstd6
      iTunes Store Link: https://apps.apple.com/us/app/bloons-td-6/id1118115766?uo=4


      Hack Features:
      - God Mode -updated- Clear Bloons -new
      - Auto Win Game -new
      - Set Round -new
      - Restart Game -new
      - Add Cash - new
      - Place towers anywhere
      - Multiple God Towers
      - Infinite Cash
      - Infinite Monkey Money
      - Infinite Powers
      - Unlock all Heros
      - Unlock all Knoledge
      - Unlock all towers
      - Unlock all upgrades 
      - Can unlock map (click locked map)
      - Skip tutorial (load the games first tutorial then exit app and start it. should skip tutorial) -new
      • 1,769 replies
    • Power Slap v7.2.5 +2++ Jailed Cheats [ Unlimited Everything ]
      Modded/Hacked App: Power Slap By Rollic Games Oyun Yazilim ve Pazarlama Anonim Sirketi
      Bundle ID: com.uncosoft.powerslap
      iTunes Store Link: https://apps.apple.com/us/app/power-slap/id6449244841?uo=4


      Hack Features:
      - Unlimited Everything -> Will increase instead of decrease.
      - Pro Pass Unlocked


      Jailbreak required hack(s): [Mod Menu Hack] Power Slap v0.4.1 +4 Cheats [ Damage & Defence ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 158 replies
    • Episode: Reality Stars v1.22 +2++ Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Episode: Reality Stars By Episode Interactive, LLC
      Bundle ID: com.sodeepilabs.glamsquad
      App Store Link: https://apps.apple.com/ph/app/episode-reality-stars/id1604253094?uo=4


      Hack Features:
      - Unlimited Currencies -> Head into Settings and toggle the License button. Press on Hero to add 99K currencies.
      - Time Cheat Menu -> Head into Settings and toggle the Terms of Service button. Toggle to your liking.
      • 88 replies
    • Episode: Reality Stars v1.22 +2++ Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Episode: Reality Stars By Episode Interactive, LLC
      Bundle ID: com.sodeepilabs.glamsquad
      App Store Link: https://apps.apple.com/ph/app/episode-reality-stars/id1604253094?uo=4


      Hack Features:
      - Unlimited Currencies -> Head into Settings and toggle the License button. Press on Hero to add 99K currencies.
      - Time Cheat Menu -> Head into Settings and toggle the Terms of Service button. Toggle to your liking.
      • 33 replies
    • Love Sick: Stories & Choices v1.116.1 +2 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Love Sick: Stories & Choices By SVEG MASHA, OOO
      Bundle ID: com.swagmasha.genres
      iTunes Store Link: https://apps.apple.com/us/app/love-sick-stories-choices/id1450264153?uo=4


      Hack Features:
      - Unlimited Keys -> Spend some.
      - Unlimited Diamonds -> Spend some.


      Jailbreak required hack(s): [Mod Menu Hack] Love Sick: Stories & Choices ( All Versions ) +2 Cheats [ Unlimited Currencies ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 68 replies
    • Love Sick: Stories & Choices v1.116.1 +2 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Love Sick: Stories & Choices By SVEG MASHA, OOO
      Bundle ID: com.swagmasha.genres
      iTunes Store Link: https://apps.apple.com/us/app/love-sick-stories-choices/id1450264153?uo=4


      Hack Features:
      - Unlimited Keys -> Spend some.
      - Unlimited Diamonds -> Spend some.


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Love Sick: Stories & Choices v1.107.0 +2 Jailed Cheats [ Unlimited Currencies ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 20 replies
    • Power Slap v7.2.5 +2++ Cheats [ Unlimited Everything ]
      Modded/Hacked App: Power Slap By Rollic Games Oyun Yazilim ve Pazarlama Anonim Sirketi
      Bundle ID: com.uncosoft.powerslap
      iTunes Store Link: https://apps.apple.com/us/app/power-slap/id6449244841?uo=4


      Hack Features:
      - Unlimited Everything -> Will increase instead of decrease.
      - Pro Pass Unlocked


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Power Slap v0.4.1 +2 Jailed Cheats [ Unlimited Currencies ] - Free Non-Jailbroken IPA Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 112 replies
    • League of Dreamers - My Story v2.1.3 +3 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: League of Dreamers - My Story By Story Inc. Company
      Bundle ID: com.storyincorporate.leagueofdreamers
      iTunes Store Link: https://apps.apple.com/us/app/league-of-dreamers-my-story/id1591679538
       

      Hack Features:
      - 666 Gems -> Earn some then restart the game.
      - 666 Keys -> Earn some then restart the game.
      - Free In-App Purchases -> Allows free in-app purchases.


      Jailbreak required hack(s): [Mod Menu Hack] League of Dreamers - My Story v1.54 +3 Cheats [ Unlimited Currencies ] - Free Jailbroken Cydia Cheats - iOSGods
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 167 replies
    • League of Dreamers - My Story v2.1.3 +3 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: League of Dreamers - My Story By Story Inc. Company
      Bundle ID: com.storyincorporate.leagueofdreamers
      iTunes Store Link: https://apps.apple.com/us/app/league-of-dreamers-my-story/id1591679538
       

      Hack Features:
      - 666 Gems -> Earn some then restart the game.
      - 666 Keys -> Earn some then restart the game.
      - Free In-App Purchases


      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/
      • 78 replies
    • Bud Farm: Munchie Match v1.55.2 +12 [Game Breaking]
      Modded/Hacked App: Bud Farm: Munchie Match By LDRLY (Technologies) Inc
      Bundle ID: com.LDRLY.budmatch
      iTunes Store Link: https://apps.apple.com/us/app/bud-farm-munchie-match/id1594712929?uo=4


      Mod Requirements:
      - Non-Jailbroken/Jailed or Jailbroken iPhone/iPad/iPod Touch.
      - Sideloadly / Cydia Impactor or alternatives.
      - A Computer Running Windows/macOS/Linux with iTunes installed.


      Hack Features:
      - No Ads
      - Win Level (Settings > Music Toggle)
      - Freeze Lives
      - Infinite Coins
      - Infinite Cash
      - Freeze Moves
      - Freeze Powerups
      - Infinite Boosters
      - Infinite Stars
      - Always Win if Lost
      - Reward Always Available


      Jailbreak required hack(s): https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/


      • 75 replies
    • Bud Farm: Munchie Match v1.55.2 +12 [Game Breaking]
      Modded/Hacked App: Bud Farm: Munchie Match By LDRLY (Technologies) Inc
      Bundle ID: com.LDRLY.budmatch
      iTunes Store Link: https://apps.apple.com/us/app/bud-farm-munchie-match/id1594712929?uo=4


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


      Hack Features:
      - No Ads
      - Win Level
      - Freeze Lives
      - Infinite Coins
      - Infinite Cash
      - Freeze Moves
      - Freeze Powerups
      - Infinite Boosters
      - Infinite Stars
      - Always Win if Lost
      - Upgrade without Decorations
      - Reward Always Available


      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/


      • 72 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