Solved How to hook this function to repeat itself?

Status
Not open for further replies.

nyc709

Platinian
Mar 23, 2021
14
7
3
30
Earth
Can somebody help me hook this function to repeat itself. Like I'm doing attack multiplier to hit the enemy multiple times.


[Address(RVA = "0x1639E4C", Offset = "0x1639E4C", VA = "0x101639E4C")]
public void SendAttackToEnemy(List<int> moblist, int skill, int card, int flag)

Code:
#import "Menu.h"

#include <substrate.h>

#import <mach-o/dyld.h>



uint64_t getRealOffset(uint64_t offset){

return _dyld_get_image_vmaddr_slide(0)+offset;

}

int (*org_SendAttackToEnemy)(void*, int moblist, int skill, int card, int flag);

int SendAttackToEnemy(void* this_, int moblist, int skill, int card, int flag) {

return org_SendAttackToEnemy(this_, moblist, skill, card, flag) * 20;

}

%ctor {

MSHookFunction((void *)getRealOffset(0x101639E4C), (void *)SendAttackToEnemy, (void **)&org_SendAttackToEnemy);

}








Kindly correct my code cause it's not working. planning to repeat the function 20 times.
 

nyc709

Platinian
Mar 23, 2021
14
7
3
30
Earth
Use loop...?
Sorry bro, i’m not sure what loop is, i only rely on the tutorials i found here and other sites like basic hooking, unlinking methods, function pointers, etc. But i didnt find any tutorial for repeating a function.
 

Yaskashije

PMT Elite Modder
Staff member
Modding-Team
Sep 9, 2018
4,384
850,239
1,213
Minkowski Space
Sorry bro, i’m not sure what loop is, i only rely on the tutorials i found here and other sites like basic hooking, unlinking methods, function pointers, etc. But i didnt find any tutorial for repeating a function.
If you don't know what a loop is, you really need to learn C++ programming.
All these tutorials you found give you the basic info to get you started (since the way that stuff works is not trivial), but the rest is up to the programmer himself.
After all, a hook consists on replacing an ingame function with one you coded yourself; and making a tutorial for every possible case one could encounter is something absurdly unpractical.
 
  • Like
Reactions: Sevol

Tiahh

Solid & Active Platinian
Jan 12, 2018
79
46
18
37
You can try to hook an update. Then calling the function with a function pointer this will make an infinite loop everytime "Update" gets called it will call the function pointer.
 
Status
Not open for further replies.