Skip to content
Guest Big Announcement

MSHOOKFUNCTION usage

Featured Replies

With great content of this website, I am able to do more, and got some tiny result, today, please allow me to ask something in a little bit advance

 

IDA  section

__text:009791B4             ; =============== S U B R O U T I N E =======================================
__text:009791B4
__text:009791B4             ; Attributes: bp-based frame
__text:009791B4
__text:009791B4             _Unit_get_GarrisonAttack_m3286393770    ; DATA XREF: __const:02694614o

 

my tweak.xm on the specific function.  

float (*orig_GarrisonAttack)(void *self);

static float GarrisonAttack(void *self) {
    NSLog(@"[tweak] --- >>> original attack %f",orig_GarrisonAttack(self));
    if(ishookEnabled(@"attack")){
        return 999999;
    }
    else
    {
        return orig_GarrisonAttack(self);
    }
}

at ctr%		
MSHookFunction(MSFindSymbol(NULL, "_Unit_get_GarrisonAttack_m3286393770"),(void*)GarrisonAttack, (void**)&orig_GarrisonAttack);

My questions

1. How do I know its return type from IDA? using float and work is purely by luck, I don't know, maybe int will also work?

2. can I print the original result of the function?  like I want to know what is the value of _Unit_get_GarrisonAttack_m3286393770, can I just NSlog orig_GarrisonAttack(self)?

3. cont with 2, I did try to do this and nothing show up, perhaps I code it wrong?

NSLog(@"[tweak] --- >>> original attack %f",orig_GarrisonAttack(self));

4. Lastly (sorry), is it possible to return the number base on the original method's result? (don't want to get god power as it looked so easy to get caught)

e.g. take return value and x10 as new value

static float GarrisonAttack(void *self) {
        return orig_GarrisonAttack(self)*10;
}

 

really appreciate in advance

Create an account or sign in to comment

Featured Content

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.