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

    • LAST CLOUDIA Cheats v5.13.3 +5
      Modded/Hacked App: LAST CLOUDIA By AIDIS Inc.
      Bundle ID: com.aidis.lastcloudiaen
      iTunes Store Link: https://apps.apple.com/us/app/last-cloudia/id1473588527?uo=4


      Hack Features:
      - God Mode
      - Infinite MP
      - Infinite SP
      - Infinite Ether


      Non-Jailbroken & No Jailbreak required hack(s): https://iosgods.com/topic/147069-last-cloudia-v1160-jailed-cheats-1/


      iOS Hack Download Link: https://iosgods.com/topic/147068-last-cloudia-cheats-all-versions-1/
      • 472 replies
    • Mr Autofire Cheats v3.8.0 +3 [ God Mode & More ]
      Modded/Hacked App: Mr Autofire By Lightheart Entertainment Oy
      Bundle ID: games.lightheart.mrautofire
      iTunes Store Link: https://apps.apple.com/us/app/mr-autofire/id1483457500?uo=4

       

      📌 Mod Requirements

      - Jailbroken iPhone or iPad.
      - iGameGod / Filza / iMazing.
      - Cydia Substrate, ElleKit, Substitute or libhooker depending on your jailbreak (from Sileo, Cydia or Zebra).

       

      🤩 Hack Features

      - God Mode 
      - One Hit Kill
      - Free Store

       

      Non-Jailbroken Hack: https://iosgods.com/topic/134805-mr-autofire-v380-jailed-cheats-1/

       

      ⬇️ iOS Hack Download Link: https://iosgods.com/topic/134788-mr-autofire-cheats-v380-3-god-mode-more/
        • Like
      • 630 replies
    • Dragon City - Breed & Battle! Cheats v25.4.3 +4
      Modded/Hacked App: Dragon City - Breed & Battle! By Socialpoint
      Bundle ID: es.socialpoint.dragoncity
      iTunes Store Link: https://apps.apple.com/us/app/dragon-city-breed-battle/id561941526?uo=4


      Hack Features:
      - One Hit Kill
      - God Mode 
      - Auto-Battle Unlocked

      This hack is using the new iOSGods Auto Updater. The hack will automatically update itself to the current app version you have installed on your iDevice.
      Note:
      Everything is linked with enemies, please use it carefully

      This hack works on the latest x64 or ARM64 & ARM64e iDevices: iPhone 5s, 6, 6 Plus, 6s, 6s Plus, 7, 7 Plus, 8, 8 Plus, X, Xr, Xs, Xs Max, 11, 11 Pro, 11 Pro Max, 12, 12 Pro, 12 Pro Max, 12 Mini, 13, 13 Pro, 13 Pro Max, 13 Mini, 14, 14 Plus, 14 Pro, 14 Pro Max, SE, iPod Touch 6G, 7G, iPad Air, Air 2, iPad Pro & iPad Mini 2, 3, 4, 5, 6 and later.


      iOS Hack Download Link: https://iosgods.com/topic/129371-dragon-city-mobile-cheats-auto-updating-3-god-mode-one-hit-kill/
        • Informative
        • Agree
        • Haha
        • Thanks
        • Winner
        • Like
      • 2,161 replies
    • Angry Birds 2 Cheats v3.27.5 +1 [ Infinite Currencies ]
      Modded/Hacked App: Angry Birds 2 By Rovio Entertainment Oyj
      Bundle ID: com.rovio.baba
      iTunes Store Link: https://apps.apple.com/us/app/angry-birds-2/id880047117?uo=4


      Hack Features:
      - Infinite Currencies ( Spend some/ Get some )


      Non-Jailbroken & No Jailbreak required hack(s):  https://iosgods.com/topic/70081-angry-birds-2-v2600-jailed-cheats-2/


      Hack Download Link: https://iosgods.com/topic/72039-angry-birds-2-cheats-v2600-1-infinite-currencies/
      • 1,945 replies
    • Pal Go: Tower Defense TD v0.3.42 [+7 Cheats]
      Modded/Hacked App: Pal Go: Tower Defense TD By Playwind Ltd
      Bundle ID: com.playwindgames.freedefender
      iTunes Store Link: https://apps.apple.com/us/app/pal-go-tower-defense-td/id6479316663?uo=4


       

      🚀 Hack Features

      - [VIP] Freeze Currency (Currency will not decrease when used)

      - [VIP] Currency Always Enough (Buy even when you don't have enough currency)

      - [Free] Higher Recruit Energy (Gives 500 Recruit Energy Every Wave)

      - [Free] Always Can Drag Hero

      - [Free] Skip Ads

      - [Free] No Attack Cooldown

      - [Free] Global Speed Multiplier (Enable Inside Battle)

       

      Warning


      Do not use on main account. There is a chance of ban. Not responsible for any bans.

       


      🍏 For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/forum/79-no-jailbreak-section/
      🤖 Modded Android APK(s): https://iosgods.com/forum/68-android-section/
      • 27 replies
    • Pal Go: Tower Defense TD v0.3.42 [+7 Jailed Cheats]
      Modded/Hacked App: Pal Go: Tower Defense TD By Playwind Ltd
      Bundle ID: com.playwindgames.freedefender
      iTunes Store Link: https://apps.apple.com/us/app/pal-go-tower-defense-td/id6479316663?uo=4


       

      Hack Features

      - [VIP] Freeze Currency (Currency will not decrease when used)

      - [VIP] Currency Always Enough (Buy even when you don't have enough currency)

      - [Free] Higher Recruit Energy (Gives 500 Recruit Energy Every Wave)

      - [Free] Always Can Drag Hero

      - [Free] Skip Ads

      - [Free] No Attack Cooldown

      - [Free] Global Speed Multiplier (Enable Inside Battle)

       

      Warning


      Do not use on main account. There is a chance of ban. Not responsible for any bans.

       

      Jailbreak required iOS hacks: https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APKs: https://iosgods.com/forum/68-android-section/
      • 47 replies
    • 20 Minutes Till Dawn v6.3.755 [ +12+++ Cheats ] Coins Freeze
      Modded/Hacked App: 20 Minutes Till Dawn By QI YU SG. PTE. LTD.
      Bundle ID: com.flanne.erabit.20minutes.tilldawn.shooting.roguelike.iap.ios
      iTunes Store Link: https://apps.apple.com/us/app/20-minutes-till-dawn/id1635123906?uo=4


      Hack Features:
      - Coins Freeze 

      - Hero Unlocked 

      - Guns Unlocked 

      - Never Die 

      - Ammo Max 

      - No Reload 

      - Rune Unlocked

      - Rune LvL Max

      - Pickup Range [ Linked Rune ] Just Equip

      - DMG Easy Kill [ Linked Rune ] Just Equip

      - Skill CD [ Linked Rune ] Just Equip

      - HP Drop [ Linked Rune ] Just Equip

      - Knockback [ Linked Rune ] Just Equip

      + More Read Status Rune


      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
      • 27 replies
    • 20 Minutes Till Dawn v6.3.755 [ +12+++ Jailed ] Coins Freeze
      Modded/Hacked App: 20 Minutes Till Dawn By QI YU SG. PTE. LTD.
      Bundle ID: com.flanne.erabit.20minutes.tilldawn.shooting.roguelike.iap.ios
      iTunes Store Link: https://apps.apple.com/us/app/20-minutes-till-dawn/id1635123906?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:

      - Coins Freeze 

      - Hero Unlocked 

      - Guns Unlocked 

      - Never Die 

      - Ammo Max 

      - No Reload 

      - Rune Unlocked

      - Rune LvL Max

      - Pickup Range [ Linked Rune ] Just Equip

      - DMG Easy Kill [ Linked Rune ] Just Equip

      - Skill CD [ Linked Rune ] Just Equip

      - HP Drop [ Linked Rune ] Just Equip

      - Knockback [ Linked Rune ] Just Equip

      + More Read Status Rune

       
      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/


      iOS Hack Download IPA Link:

      Hidden Content

      Download via the iOSGods App
      • 13 replies
    • Hello Town: Merge & Succeed v2.0 [ +3 Cheats ] Currency Max
      Modded/Hacked App: Hello Town By Springcomes Co., Ltd.
      Bundle ID: com.spcomes.hellotown
      iTunes Store Link: https://apps.apple.com/us/app/hello-town/id6737850281?uo=4


      Hack Features

      - Diamonds
      - Gold
      - Energy Freeze



      For Non-Jailbroken & No Jailbreak required hacks: https://iosgods.com/forum/79-no-jailbreak-section/
      Modded Android APK(s): https://iosgods.com/forum/68-android-section/
        • Thanks
      • 5 replies
    • Hello Town: Merge & Succeed v2.0 [ +3 Jailed ] Currency Max
      Modded/Hacked App: Hello Town By Springcomes Co., Ltd.
      Bundle ID: com.spcomes.hellotown
      iTunes Store Link: https://apps.apple.com/us/app/hello-town/id6737850281?uo=4

       

      Hack Features

      - Diamonds
      - Gold
      - Energy Freeze



      Jailbreak required iOS hacks: https://iosgods.com/forum/5-game-cheats-hack-requests/
      Modded Android APKs: https://iosgods.com/forum/68-android-section/
      • 9 replies
    • Disney Solitaire v0.44.0 [ +7 Cheats ] Auto Win
      Modded/Hacked App: Disney Solitaire By SuperPlay LTD
      Bundle ID: com.superplaystudios.disneysolitairedreams
      iTunes Store Link: https://apps.apple.com/ph/app/disney-solitaire/id6475757306?uo=4
       

      🤩 Hack Features

      - Coins [ Win Match ]

      - Task [ No Need Star ]

      - Stars

      - Undo

      - Wild Card

      - Free Ticket

      - Auto Win
      • 2 replies
    • Disney Solitaire v0.44.0 [ +7 Jailed ] Auto Win
      Modded/Hacked App: Disney Solitaire By SuperPlay LTD
      Bundle ID: com.superplaystudios.disneysolitairedreams
      iTunes Store Link: https://apps.apple.com/ph/app/disney-solitaire/id6475757306?uo=4


      🤩 Hack Features

      - Coins [ Win Match ]

      - Task [ No Need Star ]

      - Stars

      - Undo

      - Wild Card

      - Free Ticket

      - Auto Win
      • 3 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