Jump to content

Can a you set a value to a function pointer inside a hook?


PixelYT

6 posts in this topic

Recommended Posts

Posted

Let's say I found this method and I wanna change the value to 0:

private int ReloadDuration(); // 0x2347C82

I would just do it by hooking it and returning 0 like this:

int (*old_ReloadDuration)(void *instance);
int ReloadDuration(void *instance)
{
  if(instance != NULL)
  {
   return 0; 
  }
  return old_ReloadDuration(instance);
}
// MShookfunction whatever lol

 

But can I do it by making a function pointer and changing the value of it inside a hook and how would I do it?

Would I do it like this?

int (*ReloadDuration)(void *instance) = (int (*)(void *))getAbsoluteAddress(targetLibName, 0xOFFSET); // Function pointer for int ReloadDuration

void (*old_FixedUpdate)(void *instance);
void FixedUpdate(void *instance)
{
 if(instance != NULL)
 {
  int Reloadtime = ReloadDuration(instance); // Declare a variable to our function pointer and call it ReloadTime
   int ReloadTime = 0; // Set the value to 0
 }
  old_FixedUpdate(instance);
}
// MSHookfunction of Fixedupdate, whatever

 

@Ted2 you or anyone can help me please?

Posted

No, in programming you have getters and setters;

int getCoins() {
	return coins
}

void setCoins(int newValue) {
	coins = new_value
}

As you can see, to one of those functions you can pass a new value (SET). The other one just returns a variable (GET).

Function pointers are not any different, because the function pointer is that function and so, they work the same.

 

If for some reason you don't want to hook it, then I recommend opening the binary in IDA, go to the ReloadDuration method, and see which variable(s) is being used here (0x<some_value>. I assume this is an Unity game, so on top of the class ReloadDuration is in, you'll find a list of variables. See which one of them is inside ReloadDuration.

You can then change these variables in the FixedUpdate method, like so:

*(int*)((uint64_t)instance + 0x<variable_code> = 0;

 

Posted
8 hours ago, Ted2 said:

No, in programming you have getters and setters;


int getCoins() {
	return coins
}

void setCoins(int newValue) {
	coins = new_value
}

As you can see, to one of those functions you can pass a new value (SET). The other one just returns a variable (GET).

Function pointers are not any different, because the function pointer is that function and so, they work the same.

 

If for some reason you don't want to hook it, then I recommend opening the binary in IDA, go to the ReloadDuration method, and see which variable(s) is being used here (0x<some_value>. I assume this is an Unity game, so on top of the class ReloadDuration is in, you'll find a list of variables. See which one of them is inside ReloadDuration.

You can then change these variables in the FixedUpdate method, like so:


*(int*)((uint64_t)instance + 0x<variable_code> = 0;

 

Okay, I don't have a problem with hooking, it's just that I wanted to know if it was possible to set a value to a function inside a hook, but other than that, I have no problem patching or hooking the function.

Posted

@Ted2 I just have one more quick question, that i'll ask here, I already asked on another site, but didn't receive a good response. So there was one class called IAPManager or something like that, and inside it there were many useful functions that if called, would buy you whatever it is supposed to, but inside that class there was no Update/LateUpdate/FixedUpdate method (I know in some cases they can be renamed, but I looked and that wasn't the case), so would I hook Start or Awake and call those functions through a function pointer? Which one works, or does neither work?

Posted
19 minutes ago, PixelYT said:

@Ted2 I just have one more quick question, that i'll ask here, I already asked on another site, but didn't receive a good response. So there was one class called IAPManager or something like that, and inside it there were many useful functions that if called, would buy you whatever it is supposed to, but inside that class there was no Update/LateUpdate/FixedUpdate method (I know in some cases they can be renamed, but I looked and that wasn't the case), so would I hook Start or Awake and call those functions through a function pointer? Which one works, or does neither work?

https://docs.unity3d.com/Manual/ExecutionOrder.html

This is a great graph that tells you what and when they're being executed.

So I don't think any of those two will work.

 

It's possible other classes have an instance of this IAPManager class, and handle it there.

But without more info, I can't really answer.

Posted
2 hours ago, Ted2 said:

https://docs.unity3d.com/Manual/ExecutionOrder.html

This is a great graph that tells you what and when they're being executed.

So I don't think any of those two will work.

 

It's possible other classes have an instance of this IAPManager class, and handle it there.

But without more info, I can't really answer.

Alright thanks for the help

Archived

This topic is now archived and is closed to further replies.

  • Our picks

    • Rise & Loot: Idle Hero RPG v1.1.2 [ +15 Cheats ] Currency Max
      Modded/Hacked App: Rise & Loot: Idle Hero RPG By Ngoc Minh Le
      Bundle ID: com.riseloop.idlerpg
      App Store Link: https://apps.apple.com/us/app/rise-loot-idle-hero-rpg/id6821365929?uo=4

      🤩 Hack Features

      - Never Die
      - One Hit Kill
      ===== VIP =====
      - Skip Ads
      - Add Currency
      - Max Damage
      - Multi Attack x5
      - Always Exotic Loot
      - Sale Value x1000
      - Money Multiplier
      - Free Shopping / Not IAP
      - Battle Speed x3
      - Unlock All Realms
      - God Roll Gear
      - Best Card Picks
      - Daily Reward Always Ready
      • 0 replies
    • Rise & Loot: Idle Hero RPG v1.1.2 [ +15 Jailed ] Currency Max
      Modded/Hacked App: Rise & Loot: Idle Hero RPG By Ngoc Minh Le
      Bundle ID: com.riseloop.idlerpg
      App Store Link: https://apps.apple.com/us/app/rise-loot-idle-hero-rpg/id6821365929?uo=4

      🤩 Hack Features

      - Never Die
      - One Hit Kill
      ===== VIP =====
      - Skip Ads
      - Add Currency
      - Max Damage
      - Multi Attack x5
      - Always Exotic Loot
      - Sale Value x1000
      - Money Multiplier
      - Free Shopping / Not IAP
      - Battle Speed x3
      - Unlock All Realms
      - God Roll Gear
      - Best Card Picks
      - Daily Reward Always Ready
      • 0 replies
    • Stick Fight: Evolution v1.0.6 [ +22 Cheats ] Currency Max
      Modded/Hacked App: Stick Fight: Evolution By Ngoc Minh Le
      Bundle ID: com.min001.stickman.warrior.evolution.age
      App Store Link: https://apps.apple.com/us/app/stick-fight-evolution/id6747939675?uo=4

      🤩 Hack Features

      - Add Currency
      - Never Die
      - Max Damage
      ===== VIP =====
      - Auto Win
      - Skip Ads
      - Game Speed
      - Unlimited Battle Food
      - Cheat Panel +15
      • 0 replies
    • Stick Fight: Evolution v1.0.6 [ +22 Jailed ] Currency Max
      Modded/Hacked App: Stick Fight: Evolution By Ngoc Minh Le
      Bundle ID: com.min001.stickman.warrior.evolution.age
      App Store Link: https://apps.apple.com/us/app/stick-fight-evolution/id6747939675?uo=4

      🤩 Hack Features

      - Add Currency
      - Never Die
      - Max Damage
      ===== VIP =====
      - Auto Win
      - Skip Ads
      - Game Speed
      - Unlimited Battle Food
      - Cheat Panel +15
      • 0 replies
    • Geometry Cannon : Idle Defense v1.4.4 [ +7 Cheats ] Currency Max
      Modded/Hacked App: Geometry Cannon : Idle Defense By SUPERBOX. Inc
      Bundle ID: com.superbox.ios.idledefense
      App Store Link: https://apps.apple.com/us/app/geometry-cannon-idle-defense/id6742388718?uo=4
       

      🤩 Hack Features

      - Gold Pass
      - Silver Pass
      - Add Currency
      - Never Die
      - Max Damage
      - Kill All Enemies
      - Game Speed
      • 0 replies
    • Geometry Cannon : Idle Defense v1.4.4 [ +7 Jailed ] Currency Max
      Modded/Hacked App: Geometry Cannon : Idle Defense By SUPERBOX. Inc
      Bundle ID: com.superbox.ios.idledefense
      App Store Link: https://apps.apple.com/us/app/geometry-cannon-idle-defense/id6742388718?uo=4

      🤩 Hack Features

      - Gold Pass
      - Silver Pass
      - Add Currency
      - Never Die
      - Max Damage
      - Kill All Enemies
      - Game Speed
      • 0 replies
    • Neon Castle: Idle TD RPG v1.0 [ +4 Cheats ] Currency Max
      Modded/Hacked App: Neon Castle: Idle TD RPG By Mert Can Diker
      Bundle ID: com.medu.neon.castledefense.idlerpg.ios
      App Store Link: https://apps.apple.com/us/app/neon-castle-idle-td-rpg/id6748567934?uo=4

      🤩 Hack Features

      - Add Currency
      - Never Die
      - Max Damage
      - Kill All Enemies
      • 0 replies
    • Neon Castle: Idle TD RPG v1.0 [ +4 Jailed ] Currency Max
      Modded/Hacked App: Neon Castle: Idle TD RPG By Mert Can Diker
      Bundle ID: com.medu.neon.castledefense.idlerpg.ios
      App Store Link: https://apps.apple.com/us/app/neon-castle-idle-td-rpg/id6748567934?uo=4

      🤩 Hack Features

      - Add Currency
      - Never Die
      - Max Damage
      - Kill All Enemies
      • 0 replies
    • Endless Defense: Idle Tower v0.2.13 [ +4 Cheats ] Currency Max
      Modded/Hacked App: Endless Defense: Idle Tower By MAD PIXEL GAMES LTD
      Bundle ID: battle.castle.clash.wave
      App Store Link: https://apps.apple.com/us/app/endless-defense-idle-tower/id6740865987?uo=4

      🤩 Hack Features

      - Ads No
      - Add Currency
      - Never Die
      - Max Damage
      • 0 replies
    • Endless Defense: Idle Tower v0.2.13 [ +4 Jailed ] Currency Max
      Modded/Hacked App: Endless Defense: Idle Tower By MAD PIXEL GAMES LTD
      Bundle ID: battle.castle.clash.wave
      App Store Link: https://apps.apple.com/us/app/endless-defense-idle-tower/id6740865987?uo=4
       

      🤩 Hack Features

      - Ads No
      - Add Currency
      - Never Die
      - Max Damage
      • 0 replies
    • Fishing Inc: Legendary Catch +10 Jailed Cheats [ Unlimited Money ]
      Modded/Hacked App: Fishing Inc: Legendary Catch By Snapbreak Games AB
      Bundle ID: com.snapbreak.fishinginc
      App Store Link: https://apps.apple.com/us/app/fishing-inc-legendary-catch/id6770534658?uo=4

       


      🤩 Hack Features

      - Freeze Gold
      - Unlimited Gold -> Will increase instead of decrease.
      - Freeze Casts
      - One-Click Catch
      - Always Perfect Catch
      - Unlock All Fish
      - Complete All Achievements
      - Trigger Kraken Event
      -- No Ads
      -- Deluxe Bundle Purchased
      • 2 replies
    • Grave Dividend +10 Jailed Cheats [ Damage & Defence ]
      Modded/Hacked App: Grave Dividend By ByteBrew IT LLC
      Bundle ID: com.bytebrewit.gravedividend
      App Store Link: https://apps.apple.com/us/app/grave-dividend/id6797710902?uo=4

       


      🤩 Hack Features

      - Damage Multiplier
      - Defence Multiplier
      - God Mode
      - Move Speed Multiplier
      - Freeze Enemies
      - Freeze Currencies
      - Unlimited Currencies
      - Unlimited Currencies v2 -> Will increase instead of decrease.
      - Kill All Enemies
      -- No Ads
      • 1 reply
×
  • 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