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

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 

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

    • Disney Speedstorm v1.11.2 +2 Jailed Cheats [ Unlimited Nitro ]
      Modded/Hacked App: Disney Speedstorm By Gameloft
      Bundle ID: com.gameloft.disneyspeedstorm
      iTunes Store Link: https://apps.apple.com/us/app/disney-speedstorm/id6449708682?uo=4


      Hack Features:
      - Unlimited Nitro -> Will not decrease.
      - Instant Nitro Max


      Jailbreak required hack(s): [Mod Menu Hack] Disney Speedstorm v1.5.0 +2 Cheats [ Unlimited Nitro ] - 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/
      • 77 replies
    • Disney Speedstorm v1.11.2 +2 Cheats [ Unlimited Nitro ]
      Modded/Hacked App: Disney Speedstorm By Gameloft
      Bundle ID: com.gameloft.disneyspeedstorm
      iTunes Store Link: https://apps.apple.com/us/app/disney-speedstorm/id6449708682?uo=4


      Hack Features:
      - Unlimited Nitro -> Will not decrease.
      - Instant Nitro Max


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Disney Speedstorm v1.5.0 +2 Jailed Cheats [ Unlimited Nitro ] - 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/
        • Like
      • 69 replies
    • EGGCRYPTO ( エグリプト 世界に一体だけのモンスターを育成して戦うRPG ) v1.97.2 +1 Jailed Cheat [ Auto Win ]
      Modded/Hacked App: エグリプト 世界に一体だけのモンスターを育成して戦うRPG By Kyuzan Inc.
      Bundle ID: com.kyuzan.eggrypto
      iTunes Store Link: https://apps.apple.com/jp/app/%E3%82%A8%E3%82%B0%E3%83%AA%E3%83%97%E3%83%88-%E4%B8%96%E7%95%8C%E3%81%AB%E4%B8%80%E4%BD%93%E3%81%A0%E3%81%91%E3%81%AE%E3%83%A2%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%BC%E3%82%92%E8%82%B2%E6%88%90%E3%81%97%E3%81%A6%E6%88%A6%E3%81%86rpg/id1450911855?uo=4

       


      🤩 Hack Features

      - Auto Win
      • 9 replies
    • Lamar - Idle Vlogger v226.0.1 +2 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Lamar - Idle Vlogger By Advant Limited
      Bundle ID: com.advant.lamar
      iTunes Store Link: https://apps.apple.com/us/app/lamar-idle-vlogger/id1595314851
       

      Hack Features:
      - Unlimited Cash -> Will increase instead of decrease.
      - Unlimited Gold -> Spend some.


      Jailbreak required hack(s): [Mod Menu Hack] Lamar - Idle Vlogger v151.07.05 +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/
        • Informative
        • Like
      • 86 replies
    • Lamar - Idle Vlogger v226.0.1 +2 Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Lamar - Idle Vlogger By Advant Limited
      Bundle ID: com.advant.lamar
      iTunes Store Link: https://apps.apple.com/us/app/lamar-idle-vlogger/id1595314851
       

      Hack Features:
      - Unlimited Cash -> Will increase instead of decrease.
      - Unlimited Gold -> Spend some.


      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/
        • Like
      • 41 replies
    • Combat Master Mobile v0.24.71 +2 Jailed Cheats [ No Recoil ]
      Modded/Hacked App: Combat Master Mobile By Alfa Bravo Inc.
      Bundle ID: com.AlfaBravo.CombatMaster
      iTunes Store Link: https://apps.apple.com/us/app/combat-master-mobile/id1598639131
       

      Hack Features:
      - No Recoil
      - Instant Reload


      Jailbreak required hack(s): https://iosgods.com/topic/171228-combat-master-mobile-v08381-2-cheats-no-recoil/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
        • Agree
      • 99 replies
    • Combat Master Mobile v0.24.71 +2 Cheats [ No Recoil ]
      Modded/Hacked App: Combat Master Mobile By Alfa Bravo Inc.
      Bundle ID: com.AlfaBravo.CombatMaster
      iTunes Store Link: https://apps.apple.com/us/app/combat-master-mobile/id1598639131
       

      Hack Features:
      - No Recoil
      - Instant Reload


      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/
        • Informative
        • Winner
        • Like
      • 113 replies
    • EGGCRYPTO ( エグリプト 世界に一体だけのモンスターを育成して戦うRPG ) v1.97.2 +1 Cheat [ Auto Win ]
      Modded/Hacked App: エグリプト 世界に一体だけのモンスターを育成して戦うRPG By Kyuzan Inc.
      Bundle ID: com.kyuzan.eggrypto
      iTunes Store Link: https://apps.apple.com/jp/app/%E3%82%A8%E3%82%B0%E3%83%AA%E3%83%97%E3%83%88-%E4%B8%96%E7%95%8C%E3%81%AB%E4%B8%80%E4%BD%93%E3%81%A0%E3%81%91%E3%81%AE%E3%83%A2%E3%83%B3%E3%82%B9%E3%82%BF%E3%83%BC%E3%82%92%E8%82%B2%E6%88%90%E3%81%97%E3%81%A6%E6%88%A6%E3%81%86rpg/id1450911855?uo=4

       
       

      🤩 Hack Features

      - Auto WIn
        • Like
      • 8 replies
    • AFK Magic TD v0.25.0 +3 Jailed Cheats [ Damage + More ]
      Modded/Hacked App: AFK Magic TD By ARIZONA, INC.
      Bundle ID: com.arizonags.afktd
      iTunes Store Link: https://apps.apple.com/gb/app/afk-magic-td/id6479079201?uo=4


      Hack Features:
      - God Mode
      - Damage Mulitplier
      - No Skill Consumption -> Charge skill first.


      Jailbreak required hack(s): [Mod Menu Hack] AFK Magic TD v0.16.1 +3 Cheats [ Damage + More ] - 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/
      • 13 replies
    • AFK Magic TD v0.25.0 +3 Cheats [ Damage + More ]
      Modded/Hacked App: AFK Magic TD By ARIZONA, INC.
      Bundle ID: com.arizonags.afktd
      iTunes Store Link: https://apps.apple.com/gb/app/afk-magic-td/id6479079201?uo=4


      Hack Features:
      - God Mode
      - Damage Multiplier
      - No Skill Consumption -> Charge skill first.


      Non-Jailbroken & No Jailbreak required hack(s): [IPA Mod Menu] AFK Magic TD v0.16.1 +3 Jailed Cheats [ Damage + More ] - 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/
        • Like
      • 17 replies
    • Backpack Brawl v0.33.2 +1++ Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Backpack Brawl By 1986 GAMES SIA
      Bundle ID: com.rapidfiregames.backpackbrawl
      iTunes Store Link: https://apps.apple.com/us/app/backpack-brawl/id6479175676?uo=4


      Hack Features:
      - Unlimited Currencies -> Earn some.


      Jailbreak required hack(s): [Mod Menu Hack] Backpack Brawl v0.14.0 +1++ 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/
        • Haha
        • Winner
        • Like
      • 57 replies
    • Backpack Brawl v0.33.2 +1++ Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Backpack Brawl By 1986 GAMES SIA
      Bundle ID: com.rapidfiregames.backpackbrawl
      iTunes Store Link: https://apps.apple.com/us/app/backpack-brawl/id6479175676?uo=4


      Hack Features:
      - Unlimited Currencies -> Earn some.


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Backpack Brawl v0.14.0 +1++ 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/
        • Like
      • 47 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