AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   Solved How to hook MessageBegin with chooker (https://forums.alliedmods.net/showthread.php?t=299856)

Kaido Ren 07-28-2017 07:12

How to hook MessageBegin with chooker
 
Hello. I'm trying to hook function pfnMessageBegin with chooker by Arkshine:
PHP Code:

void MessageBegin(int msg_destint msg_type, const float *pOriginedict_t *ed) {
    
printf(__FUNCTION__"\n");

    if (
g_messageBeginHook->Restore()) {
        
g_messageBeginOriginalHandle(msg_destmsg_typepOrigined);
        
g_messageBeginHook->Patch();
    }
}

bool hook_func(void) {
#ifdef WIN32
    
g_messageBeginOriginalHandle g_hooker->MemorySearch<Func_MessageBegin>((char *)&g_engfuncs.pfnMessageBegin, (void *)gpGlobalsFALSE);
#else
    
void *sym_ptr = (void *)&g_engfuncs.pfnMessageBegin;

    while (*(
unsigned short *)sym_ptr == 0x25ff) {
        
sym_ptr = **(void ***)((char *)sym_ptr 2);
    }

    
g_messageBeginOriginalHandle = (Func_MessageBegin)sym_ptr;
#endif

    
g_messageBeginHook g_hooker->CreateHook(g_messageBeginOriginalHandle, (void *)MessageBeginTRUE);

    return 
g_messageBeginHook true false;


But the handler is not called, but the hook is happening. What am I doing wrong? :oops:

Arkshine 07-28-2017 11:29

Re: How to hook MessageBegin with chooker
 
(Brief note: CHooker has been made by Joropito).

I don't know about your problem. If you the hook is created successfully, then you hook at the wrong address.

Kaido Ren 07-28-2017 11:35

Re: How to hook MessageBegin with chooker
 
Arkshine, could you tell, how to find the right address?

joropito 07-28-2017 12:19

Re: How to hook MessageBegin with chooker
 
Isn't "&g_engfuncs.pfnMessageBegin" a pointer to the pointer?

Kaido Ren 07-28-2017 12:51

Re: How to hook MessageBegin with chooker
 
And how will be correct?:oops:

Kaido Ren 07-29-2017 04:05

Re: How to hook MessageBegin with chooker
 
problem solved:
PHP Code:

g_messageBeginOriginalHandle = (Func_MessageBegin)g_engfuncs.pfnMessageBegin

:D


All times are GMT -4. The time now is 17:31.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.