Jump to content

Simplified MSHookMemory Usage [ARM64 Only]


Ted2

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
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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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

    • ONE PIECE トレジャークルーズ [OP TREASURE CRUISE Japan] v14.0.2 +5
      Modded/Hacked App: ONE PIECE トレジャークルーズ By Bandai Namco Entertainment Inc.
      Bundle ID: jp.co.bandainamcogames.NBGI0199
      iTunes Store Link: https://apps.apple.com/jp/app/one-piece-%E3%83%88%E3%83%AC%E3%82%B8%E3%83%A3%E3%83%BC%E3%82%AF%E3%83%AB%E3%83%BC%E3%82%BA/id824116884?uo=4


      Hack Features:
      - Go over Character Box Capacity
      - Auto Win
      - God Mode
      - Skill Available after 1 Turn
      - High Damage Hits
      • 73 replies
    • Global ONE PIECE TREASURE CRUISE v14.0.2 +5
      App Name: ONE PIECE TREASURE CRUISE By Bandai Namco Entertainment Inc. v12.1.2
      Bundle ID: jp.co.bandainamcogames.BNGI0218
      Requires: iOS 10.0 or later.
      Price: Free
      iTunes URL: https://apps.apple.com/us/app/one-piece-treasure-cruise/id943690848

      Hack Features:

      - Auto Win

      - God Mode

      - Skill Available after 1 Turn

      - High Damage Hits

      - Go over Character Box Capacity
      • 234 replies
    • Toram Online v4.0.38 - [ Custom Move Speed & More ]
      Modded/Hacked App: Toram Online By ASOBIMO,Inc.
      Bundle ID: com.asobimo.toramonline
      iTunes Store Link: https://itunes.apple.com/us/app/toram-online/id988683886?mt=8&uo=4&at=1010lce4
       

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


      Hack Features:
      - Custom Move Speed
      - God Mode 
      - Fast Attack Speed
      - Fast Cast Speed
      - Always Critical Chance
      - Never Miss Hit 
      - Mobs/Bosses Can't Avoid & Guard 
      - Quick Draw
      - Armor Break
      - Magic Wall - Stun + Full Map Hack 
      • 2,449 replies
    • [Free] Asphalt 8: Airborne Hack v7.8.0 +4 Cheats
      Modded/Hacked App: Asphalt 8: Airborne by Gameloft
      Bundle ID: com.gameloft.asphalt8
      iTunes Store Link: https://apps.apple.com/us/app/asphalt-8-airborne/id610391947


      Hack Features:
      - Unlimited Nitro Use / Nitro Doesn't Decrease
      - No Car Crash / No Wrecks
      - Anti-Ban -> Does not mean you can abuse the hack.
      - No Rank Required to do Mastery Missions

      This hack only works on x64 or ARM64 iDevices: iPhone 5s, 6, 6 Plus, 6s, 6s Plus, 7, 7 Plus, 8, 8 Plus, X, iPod Touch 6G, iPad Air, Air 2, Pro & iPad Mini 2, 3, 4 and later. 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.

      ViP version of this hack with more features: https://iosgods.com/topic/39095-vip-asphalt-8-airborne-v321-13-cheats/
      Non-Jailbroken version of this hack: https://iosgods.com/topic/38140-hack-asphalt-8-airborne-v310-4-cheats-for-jailed-idevices-ios-10/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 8,809 replies
    • [Hack] Asphalt 8: Airborne v7.8.0 +3 Cheats for Jailed iDevices! [ iOS 18 ]
      Modded/Hacked App: Asphalt 8: Airborne By Gameloft
      Bundle ID: com.gameloft.asphalt8
      iTunes Link: https://itunes.apple.com/us/app/asphalt-8-airborne/id610391947

      Hack Features:
      - Unlimited Nitro Use. Use Unlimited Nitro!
      - No Car Crash/Wreck
      - All Cars Unlocked
      - Unlimited Coins -> Coins will still decrease and go negative after buying and turning the hack off. Caused issues after uninstalling the hack. Removed.
      - Free Store - Buy any item for free which cost coins Patched. Removed.
      This hack only works on x64 or ARM64 iDevices: iPhone 5s, 6, 6 Plus, 6s, 6s Plus, 7, 7 Plus, 8, 8 Plus, X, SE, iPod Touch 6G, iPad Air, Air 2, Pro & iPad Mini 2, 3, 4 and later.

      Jailbroken version of this hack: https://iosgods.com/topic/23005-free-asphalt-8-airborne-hack-v321-4-cheats/
      • 682 replies
    • [ViP] Asphalt 8: Airborne v7.8.0 +13 Cheats!
      Modded/Hacked App: Asphalt 8: Airborne By Gameloft
      Bundle ID: com.gameloft.asphalt8
      iTunes Link: https://itunes.apple.com/us/app/asphalt-8-airborne/id610391947


      Hack Features:
      - Unlimited Nitro Use / Nitro Doesn't Decrease
      - 0 Coin Cost to buy Decals
      - All Seasons Unlocked
      - Tag Season Unlocked
      - Coins Hack (Enter your own amount in settings)
      - 0 Cost to Apply ProKits
      - Free Store (only works with coins. Blue tokens cost is server sided)
      - Mastery Unlocked at any Level (choose the amount of stars you want in settings to unlock early)
      - Anti-Ban -> Does not mean you can abuse the hack.
      - No Rank Required to do Mastery Missions
      - All Cars Unlocked
      - No Speed Limit
      - No Car Crash
       
      Free Version of this hack: https://iosgods.com/topic/23005-updated-asphalt-8-airborne-hack-v260-13-cheats/
      ViP No-Jailbreak Version of this Hack: https://iosgods.com/forum/78-vip-non-jailbroken-hacks-cheats/
      For more fun, check out the Club(s): https://iosgods.com/clubs/
      • 2,120 replies
    • Amikin Survival: Anime RPG v0.4.0 +3 Jailed Cheats [ Durability / Split / Level ]
      Modded/Hacked App: Amikin Survival: Anime RPG By HELIO LTD
      Bundle ID: com.heliogames.amikin.survival
      iTunes Store Link: https://apps.apple.com/us/app/amikin-survival-anime-rpg/id6478102304?uo=4


      Hack Features:
      - Unlimited Weapon Durability
      - Split Hack
      - Max Level -> Earn some XP.


      Jailbreak required hack(s): [Mod Menu Hack] Amikin Survival: Anime RPG v0.2.3 +6 Cheats [ God Mode ] - 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/
      • 161 replies
    • Amikin Survival: Anime RPG v0.4.0 +6 Cheats [ God Mode  ]
      Modded/Hacked App: Amikin Survival: Anime RPG By HELIO LTD
      Bundle ID: com.heliogames.amikin.survival
      iTunes Store Link: https://apps.apple.com/us/app/amikin-survival-anime-rpg/id6478102304?uo=4


      Hack Features:
      - God Mode
      - Pet God Mode
      - Unlimited Weapon Durability
      - Split Hack
      - Speed Multiplier
      - Max Level -> Earn some XP.


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Amikin Survival: Anime RPG v0.2.3 +3 Jailed Cheats [ Durability / Split / Level ] - 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/
      • 52 replies
    • Idle Ghost Girl: AFK RPG v1.02.012 +2 Jailed Cheats [ God & O-HK ]
      Modded/Hacked App: Idle Ghost Girl: AFK RPG By Ndolphin Connect
      Bundle ID: com.nadadigital.idleghostgirl
      iTunes Store Link: https://apps.apple.com/us/app/idle-ghost-girl-afk-rpg/id6446347964?uo=4


      Hack Features:
      - God Mode
      - One-Hit Kill


      Jailbreak required hack(s): [Mod Menu Hack] Idle Ghost Girl: AFK RPG v1.02.008 +2 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/
      • 19 replies
    • Grow Shooter : Survivor RPG v1.0.23 +2 Jailed Cheats [ Unlimited Currencies ]
      Modded/Hacked App: Grow Shooter : Survivor RPG By DongSik Moon
      Bundle ID: com.eastmoon.growshooterlive
      iTunes Store Link: https://apps.apple.com/us/app/grow-shooter-survivor-rpg/id6480362458?uo=4


      Hack Features:
      - Unlimited Coins -> Will not decrease.
      - Unlimited Rubies -> Will not decrease.


      Jailbreak required hack(s): [Mod Menu Hack] Grow Shooter : Survivor RPG v1.0.10 +4 Cheats [ Damage ] - 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/
      • 32 replies
    • Grow Shooter : Survivor RPG v1.0.23 +4 Cheats [ Damage ]
      Modded/Hacked App: Grow Shooter : Survivor RPG By DongSik Moon
      Bundle ID: com.eastmoon.growshooterlive
      iTunes Store Link: https://apps.apple.com/us/app/grow-shooter-survivor-rpg/id6480362458?uo=4


      Hack Features:
      - Damage Multiplier
      - Move Speed Multiplier
      - Unlimited Coins -> Will not decrease.
      - Unlimited Rubies -> Will not decrease.


      Non-Jailbroken & No Jailbreak required hack(s): [Non-Jailbroken Hack] Grow Shooter : Survivor RPG v1.0.10 +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/
      • 48 replies
    • Idle Outpost: Business Game v0.14.83 +1++ Jailed Cheat [ Free Shopping ]
      Modded/Hacked App: Idle Outpost: Business Game By AppQuantum Publishing Ltd
      Bundle ID: com.rockbite.zombieoutpost
      iTunes Store Link: https://apps.apple.com/us/app/idle-outpost-business-game/id6463128982?uo=4


      Hack Features:
      - Free Shopping -> Currencies will go negative.


      Jailbreak required hack(s): [Mod Menu Hack] Idle Outpost: Business Game v0.14.53 +1++ Cheat [ Free Shopping ] - 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/
      • 26 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