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

It's not work with Mhook_Unhook #2

Open
RelicOfTesla opened this issue Sep 19, 2014 · 2 comments
Open

It's not work with Mhook_Unhook #2

RelicOfTesla opened this issue Sep 19, 2014 · 2 comments

Comments

@RelicOfTesla
Copy link

Only hook one api, and call the Mhook_Unhook to restore it, It's bad to TrampolineGet return NULL.

@RelicOfTesla RelicOfTesla changed the title it's now work with Mhook_Unhook It's not work with Mhook_Unhook Sep 19, 2014
@RelicOfTesla
Copy link
Author

@poizan42 @martona This problem is only after merge e58a58c (Merge branch 'fix-remove-max-limit-patch' )
When I switch to efa4d7e (remove @poizan42 change), IT'S OK.
My OS is win7 x64,( but build in x86 mode)
//////////////////

#include <mhook-lib/mhook.h>

int (WINAPI* OldMessageBoxA)(
__in_opt HWND hWnd,
__in_opt LPCSTR lpText,
__in_opt LPCSTR lpCaption,
__in UINT uType) = MessageBoxA;

int WINAPI NewMessageBoxA(
__in_opt HWND hWnd,
__in_opt LPCSTR lpText,
__in_opt LPCSTR lpCaption,
__in UINT uType)
{
return 0;
}

int _tmain(int argc, _TCHAR* argv[])
{
Mhook_SetHook((void**)&OldMessageBoxA, NewMessageBoxA);
Mhook_Unhook((void**)&OldMessageBoxA);
MessageBoxA(0, 0, 0, 0);

return 0;

}

@gmmybu
Copy link

gmmybu commented Dec 18, 2015

In function Mhook_SetHook, *ppSystemFunction is assigned to pTrampoline->codeTrampoline.
In Mhook_Unhook, *ppSystemFunction is passed to TrampolineGet, by comparing with pCurrent->pHookFunction to get owned pTrampoline.

In my test, unhook always return FALSE because TrampolineGet always return NULL.

This bug can be fixed by modifying function TrampolineGet pCurrent->pHookFunction to pCurrent->codeTrampoline

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