Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Question) Are multiple hooks at the same address allowed? #26

Closed
chayleaf opened this issue Apr 4, 2018 · 2 comments
Closed

(Question) Are multiple hooks at the same address allowed? #26

chayleaf opened this issue Apr 4, 2018 · 2 comments

Comments

@chayleaf
Copy link

chayleaf commented Apr 4, 2018

something like

void log(const char *text);
void hooked();
typedef void(*hooked_t)(void);

hooked_t origin1;
void replacement1() {
   log("hook 1 works");
   origin1();
}

hooked_t origin2;
void replacement2() {
   log("hook 2 works");
   origin2();
}

ZzHookReplace(
	&hooked,
	&replacement2,
	&origin2
);

ZzHookReplace(
	&hooked,
	&replacement1,
	&origin1
);

hooked();

/* 
 * log now contains:
 * hook 1 works
 * hook 2 works
 */
@jmpews
Copy link
Owner

jmpews commented Apr 9, 2018

sorry, No. but you can call replacement2 in replacement1

@chayleaf
Copy link
Author

chayleaf commented Apr 9, 2018

Ok, thanks for the answer. I'm making a modification api for a C++ game, and I want multiple mods that hook the same function to be compatible. In this case I will write my own wrapper that will use updated addresses (I suppose you can do

void log(const char *text);
void hooked();
typedef void(*hooked_t)(void);

hooked_t origin1;
void replacement1() {
   log("hook 1 works");
   origin1();
}

hooked_t origin2;
void replacement2() {
   log("hook 2 works");
   origin2();
}

ZzHookReplace(
	&hooked,
	&replacement2,
	&origin2
);

ZzHookReplace(
	&replacement2,
	&replacement1,
	&origin1
);

hooked();

/* 
 * log now contains:
 * hook 1 works
 * hook 2 works
 */

)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants