-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <windows.h> | ||
#include <hook.h> // <MaxHook.h> | ||
|
||
void MHOOK_CALLBACK onEnter(MHInvocationContext* ctx) { | ||
printf("Called Beep(%d, %d);\n", mhook_get_parameter(ctx, 0), mhook_get_parameter(ctx, 1)); | ||
printf("Return address => 0x%p\n", mhook_get_return_address(ctx)); | ||
} | ||
|
||
void MHOOK_CALLBACK onLeave(MHInvocationContext* ctx) { | ||
mhook_replace_return_value(ctx, 1337); | ||
printf("Leave\n"); | ||
} | ||
|
||
int main() { | ||
mhook_init(); | ||
unsigned long long hookId = mhook_add(Beep, onEnter, onLeave); | ||
if (hookId > 0) { | ||
int ret = Beep(100, 1000); | ||
if (mhook_remove(hookId)) | ||
printf("Hook removed\n"); | ||
printf("Beep return: %d\n", ret); | ||
// This won't be triggered by the hook | ||
Beep(100, 1000); | ||
} | ||
mhook_deinit(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters