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

question about chooker hook __cdecl function


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2013 , 17:51   Re: question about chooker hook __cdecl function
Reply With Quote #11

You can call any functions you want. Just a matter to get a signature/symbol/header.
__________________
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-02-2013 , 18:19   Re: question about chooker hook __cdecl function
Reply With Quote #12

Arkshine,help me please.

can you give an example?



PHP Code:
#include "amxxmodule.h"
#include "chooker.h"

CHooker  HookerClass;
CHooker*    Hooker = &HookerClass;

typedef void ( *Func_RadiusDamage )( Vectorentvars_tentvars_tfloatfloatintint  );
Func_RadiusDamage RadiusDamage_Addr NULL;

bool hookRadiusDamage();
void RadiusDamage_HookVector vecSrcentvars_t *pevInflictorentvars_t *pevAttackerfloat flDamagefloat flRadiusint iClassIgnoreint bitsDamageType );


void RadiusDamage_HookVector vecSrcentvars_t *pevInflictorentvars_t *pevAttackerfloat flDamagefloat flRadiusint iClassIgnoreint bitsDamageType 
{
    
GET_ORIG_FUNCfunc );

    if( 
func->Restore() )
    {
        
RadiusDamage_AddrvecSrcpevInflictorpevAttackerflDamageflRadiusiClassIgnorebitsDamageType );

        
func->Patch();
    }

    
printf"\n\t\tHook RadiusDamage.\n" );
}

bool hookRadiusDamage()
{
    
#ifdef _WIN32 
        
RadiusDamage_Addr Hooker->MemorySearchFunc_RadiusDamage>( "0xD9,*,*,*,0xD8,*,*,*,*,*,0x56,0x8B,0xF1,0x8B,0x4C,*,*,0xDF,*,0x25,*,*,*,*,0x8B", ( void* )gpGlobalsFALSE );
    
#else
        
RadiusDamage_Addr Hooker->MemorySearchFunc_RadiusDamage>( "RadiusDamage__12CBaseMonsterP9entvars_sT1fii", ( void* )gpGlobalsTRUE );
    
#endif

    
return Hooker->CreateHook( ( void* )RadiusDamage_Addr, ( void* )RadiusDamage_HookTRUE ) ? true false;
}

void OnMetaAttach()
{
    
bool result hookRadiusDamage();
    
    
printf" %s.\n\n"result "Loaded with success" "Failed to create hook" );


__________________

Last edited by Bos93; 04-02-2013 at 18:22.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2013 , 18:47   Re: question about chooker hook __cdecl function
Reply With Quote #13

You don't explain what is your problem.
__________________
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-02-2013 , 18:56   Re: question about chooker hook __cdecl function
Reply With Quote #14

1>..\meta_api.cpp(55): error C2664: void (Vector,entvars_t,entvars_t,float,float,int,i nt): can not convert parameter 3 from "entvars_t *" in "entvars_t"
1>..\meta_api.cpp(55): error C2664: void (Vector,entvars_t,entvars_t,float,float,int,i nt): can not convert parameter 2 from "float" in "entvars_t"
1>..\meta_api.cpp(55): error C2664: void (Vector,entvars_t,entvars_t,float,float,int,i nt): can not convert parameter 1 from "float" in "Vector"


PHP Code:
    if( func->Restore() )
    {
        
RadiusDamage_AddrvecSrcpevInflictorpevAttackerflDamageflRadiusiClassIgnorebitsDamageType ); //line 55

        
func->Patch();
    } 
__________________

Last edited by Bos93; 04-02-2013 at 18:58.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-02-2013 , 19:01   Re: question about chooker hook __cdecl function
Reply With Quote #15

Seriously ?

Look at your header and your typedef and the error is really easy to understand.
__________________
Arkshine is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 04-02-2013 , 21:53   Re: question about chooker hook __cdecl function
Reply With Quote #16

The function type to be hooked should use the same prototype as the hook

Code:
typedef void ( *Func_RadiusDamage )( Vector, entvars_t*, entvars_t*, float, float, int, int  );

__________________

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
Old 04-03-2013, 06:47
Bos93
This message has been deleted by Bos93.
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-03-2013 , 06:52   Re: question about chooker hook __cdecl function
Reply With Quote #17

Why are posting right away instead of searching FIRST ?
Why do you never give details ?

Do you test windows/linux ? If windows, did you check if signature is right at least ?
__________________
Arkshine is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-03-2013 , 07:02   Re: question about chooker hook __cdecl function
Reply With Quote #18

Solved

Not the correct signature
__________________

Last edited by Bos93; 04-03-2013 at 09:29.
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
Old 04-03-2013, 07:43
Bos93
This message has been deleted by Bos93.
Reply



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 04:49.


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