Raised This Month: $12 Target: $400
 3% 

Solved How to hook MessageBegin with chooker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kaido Ren
Junior Member
Join Date: Jul 2017
Old 07-28-2017 , 07:12   How to hook MessageBegin with chooker
Reply With Quote #1

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?

Last edited by Kaido Ren; 07-29-2017 at 04:06.
Kaido Ren is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-28-2017 , 11:29   Re: How to hook MessageBegin with chooker
Reply With Quote #2

(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.
__________________
Arkshine is offline
Kaido Ren
Junior Member
Join Date: Jul 2017
Old 07-28-2017 , 11:35   Re: How to hook MessageBegin with chooker
Reply With Quote #3

Arkshine, could you tell, how to find the right address?
Kaido Ren is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 07-28-2017 , 12:19   Re: How to hook MessageBegin with chooker
Reply With Quote #4

Isn't "&g_engfuncs.pfnMessageBegin" a pointer to the pointer?
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Kaido Ren
Junior Member
Join Date: Jul 2017
Old 07-28-2017 , 12:51   Re: How to hook MessageBegin with chooker
Reply With Quote #5

And how will be correct?
Kaido Ren is offline
Kaido Ren
Junior Member
Join Date: Jul 2017
Old 07-29-2017 , 04:05   Re: How to hook MessageBegin with chooker
Reply With Quote #6

problem solved:
PHP Code:
g_messageBeginOriginalHandle = (Func_MessageBegin)g_engfuncs.pfnMessageBegin

Last edited by Kaido Ren; 07-29-2017 at 04:05.
Kaido Ren is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:19.


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