Raised This Month: $ Target: $400
 0% 

General hamsandwich questions


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 06-21-2009 , 03:28   Re: General hamsandwich questions
Reply With Quote #7

Quote:
Originally Posted by jim_yang View Post
vtable only contains virtual member function pointers, all of your provided functions are non virtual member function, they
don't exist in CBasePlayer's Obj's vtable.
calling function is simple if you know its real address, prototype and calling conventions. here is an example to call
CBasePlayer::DropPlayerItem(const char *szItem), I use it to instead "engclient_cmd" method to force a player drop an item.
Code:
void CallDllDropPlayerItem(edict_t *pEdict, const char *szWeapon)
{
    HMODULE handle = GetModuleHandle("mp.dll");
    unsigned long baseaddr = (unsigned long)handle;
    void *g_CBasePlayer_DropPlayerItem = (void *)(baseaddr + 0xB3DB0);
    CBasePlayer *pPlayer = (CBasePlayer *)pEdict->pvPrivateData;
    __asm
    {
        PUSH    szItem;     //push param into stack
        MOV     ECX, pPlayer; //push "this" to ecx
        CALL    [g_CBasePlayer_DropPlayerItem]; //call function
    }
}
To get the real address and prototype, you need to disassemble the gamedll. "mp.dll" here for windows.
Then find the function address you want to call.
By this way, you can call all the functions you list above. Hooking them is another story.
To get virtual offsets, here is a tut:
http://wiki.alliedmods.net/Finding_Virtual_Offsets
Thank you. So hamsandwich has nothing to do with this. I will deepen my knowledge in this area.

(And that was a nice example. I also don't like to use engclient_cmd)
__________________
joaquimandrade is offline
 



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 15:33.


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