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

    • Hello Kitty Friends Match v1.0.11 +1 Jailed Cheat [ Auto Win ]
      Modded/Hacked App: Hello Kitty Friends Match By LINE Games
      Bundle ID: com.linegames.hkfm
      App Store Link: https://apps.apple.com/us/app/hello-kitty-friends-match/id6742533643?uo=4

       
       

      🤩 Hack Features

      - Auto Win -> Move a block.
      • 8 replies
    • Hello Kitty Friends Match v1.0.11 +1 Cheat [ Auto Win ]
      Modded/Hacked App: Hello Kitty Friends Match By LINE Games
      Bundle ID: com.linegames.hkfm
      App Store Link: https://apps.apple.com/us/app/hello-kitty-friends-match/id6742533643?uo=4

       
       

      🤩 Hack Features

      - Auto Win -> Move a block.
      • 4 replies
    • Hunt Royale: Action RPG Battle v3.12.1 +3 Jailed Cheats [ Damage & Defence ]
      Modded/Hacked App: Hunt Royale: Action RPG Battle By BoomBit, Inc.
      Bundle ID: com.hunt.royale
      iTunes Store Link: https://apps.apple.com/us/app/hunt-royale-action-rpg-battle/id1537379121?uo=4

       
       

      🚀 Hack Features

      - Dumb Enemies

      VIP
      - Damage Multiplier
      - Defence Multiplier
      • 143 replies
    • Hunt Royale: Action RPG Battle v3.12.1 +3 Cheats [ Damage & Defence ]
      Modded/Hacked App: Hunt Royale: Action RPG Battle By BoomBit, Inc.
      Bundle ID: com.hunt.royale
      iTunes Store Link: https://apps.apple.com/us/app/hunt-royale-action-rpg-battle/id1537379121?uo=4

       


      🚀 Hack Features

      - Dumb Enemies

      VIP
      - Damage Multiplier
      - Defence Multiplier
      • 24 replies
    • Grand War: Rome Strategy Games v2.2.4 +5 Jailed Cheats [ Damage & Defence ]
      Modded/Hacked App: Grand War: Rome Strategy Games By HangZhouCaiLingTechnology.Co., Limited
      Bundle ID: com.rome.caesar.war.strategy.conqueror.games.2021
      iTunes Store Link: https://apps.apple.com/us/app/grand-war-rome-strategy-games/id1593989305?uo=4

       


      🤩 Hack Features

      - Damage Multiplier
      - Defence Multiplier
      - Unlimited Silver
      - Unlimited Gold
      - Unlimited Medals
      • 40 replies
    • Loot Heroes v1.9.2 +28 Jailed Cheats [ Unlimited Everything ]
      Modded/Hacked App: Loot Heroes: Fantasy RPG Games By BoomBit, Inc.
      Bundle ID: com.bbp.lootheroes
      iTunes Store Link: https://apps.apple.com/us/app/loot-heroes-fantasy-rpg-games/id6642699678?uo=4


      Hack Features:
      - Freeze Everything -> Currencies, Hero Cards, Hero Skill Points will all freeze.
      - God Mode -> Traps still cause damage.
      - One-Hit Kill
      - No Attack Delay
      - All Critical Hits
      - All Heroes Unlocked
      - All Skins Unlocked
      - No Skill Cooldown
      - Nickname Edit Unlocked
      - No Nickname Filter
      - No Guild Name Filter
      - No Dash Cooldown
      - Unlimited Boosters
      - Auto Play
      - No Camp Upgrade Cost
      - Unlimited Bolts
      - No Ads

      VIP
      - Unlimited Everything -> Currencies, Hero Cards, Hero Skill Points will all increase instead of decrease.
      - Currency Modifier -> Earn or spend some.
      - Unlimited Hero Cards -> Earn some.
      - Unlimited Hero Skill Points -> Earn some.
      - Trophy Modifier -> Earn or lose some to stick to the leaderboard.
      - Guild Score Modifier -> Earn some.
      - Unlimited Event Score -> Earn some.
      - Max Hero Mastery Level
      - Auto Win
      - Battle Pass Unlocked
      - VIP Enabled
      • 153 replies
    • Loot Heroes v1.9.2 +28 Cheats [ Unlimited Everything ]
      Modded/Hacked App: Loot Heroes By BoomBit, Inc.
      Bundle ID: com.bbp.lootheroes
      iTunes Store Link: https://apps.apple.com/us/app/loot-heroes/id6642699678?uo=4


      Hack Features:
      - Freeze Everything -> Currencies, Hero Cards, Hero Skill Points will all freeze.
      - God Mode -> Traps still cause damage.
      - One-Hit Kill
      - No Attack Delay
      - All Critical Hits
      - All Heroes Unlocked
      - All Skins Unlocked
      - No Skill Cooldown
      - Nickname Edit Unlocked
      - No Nickname Filter
      - No Guild Name Filter
      - No Dash Cooldown
      - Unlimited Boosters
      - Auto Play
      - No Camp Upgrade Cost
      - Unlimited Bolts
      - No Ads

      VIP
      - Unlimited Everything -> Currencies, Hero Cards, Hero Skill Points will all increase instead of decrease.
      - Currency Modifier -> Earn or spend some.
      - Unlimited Hero Cards -> Earn some.
      - Unlimited Hero Skill Points -> Earn some.
      - Trophy Modifier -> Earn or lose some to stick to the leaderboard.
      - Guild Score Modifier -> Earn some.
      - Unlimited Event Score -> Earn some.
      - Max Hero Mastery Level
      - Auto Win
      - Battle Pass Unlocked
      - VIP Enabled
      • 309 replies
    • Grand War: Rome Strategy Games v2.2.4 +5 Cheats [ Damage & Defence ]
      Modded/Hacked App: Grand War: Rome Strategy Games By HangZhouCaiLingTechnology.Co., Limited
      Bundle ID: com.rome.caesar.war.strategy.conqueror.games.2021
      iTunes Store Link: https://apps.apple.com/us/app/grand-war-rome-strategy-games/id1593989305?uo=4

       


      🤩 Hack Features

      - Damage Multiplier
      - Defence Multiplier
      - Unlimited Silver
      - Unlimited Gold
      - Unlimited Medals
      • 64 replies
    • DREDGE v1.5.16 +3 Jailed Cheats [ Unlocked ]
      Modded/Hacked App: DREDGE By Black Salt Games Limited
      Bundle ID: com.blacksaltgames.dredge
      iTunes Store Link: https://apps.apple.com/us/app/dredge/id6526463862?uo=4

       
       

      🤩 Hack Features

      - Full Game & All DLC Unlocked
      - Sell Value Multiplier
      - All Cabin Items Unlocked -> Head into Settings > Controls and toggle the Reset All Controls button.
      • 80 replies
    • DREDGE v1.5.16 +3 Cheats [ Unlocked ]
      Modded/Hacked App: DREDGE By Black Salt Games Limited
      Bundle ID: com.blacksaltgames.dredge
      iTunes Store Link: https://apps.apple.com/us/app/dredge/id6526463862?uo=4

       
       

      🤩 Hack Features

      - Full Game & All DLC Unlocked
      - Sell Value Multiplier
      - All Cabin Items Unlocked -> Head into Settings > Controls and toggle the Reset All Controls button.
      • 27 replies
    • Amikin Village: Magic Sim RPG v1.1.0 +5 Jailed Cheats [ Damage + More ]
      Modded/Hacked App: Amikin Village: Magic Sim RPG By HELIO LTD
      Bundle ID: com.heliogames.amikin.survival
      App Store Link: https://apps.apple.com/us/app/amikin-village-magic-sim-rpg/id6478102304?uo=4

       


      🤩 Hack Features

      - Damage Multiplier
      - God Mode
      - Speed Multiplier
      - Unlimited Weapon Durability
      - Split Hack
      • 326 replies
    • Amikin Village: Magic Sim RPG v1.1.0 +5 Cheats [ Damage + More ]
      Modded/Hacked App: Amikin Village: Magic Sim RPG By HELIO LTD
      Bundle ID: com.heliogames.amikin.survival
      App Store Link: https://apps.apple.com/us/app/amikin-village-magic-sim-rpg/id6478102304?uo=4

       
       

      🤩 Hack Features

      - Damage Multiplier
      - God Mode
      - Speed Multiplier
      - Unlimited Weapon Durability
      - Split Hack
      • 111 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