Raised This Month: $32 Target: $400
 8% 

About CommitSuicide


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Yeah=}
Member
Join Date: Apr 2010
Location: Ural, Russia
Old 04-27-2012 , 06:04   About CommitSuicide
Reply With Quote #1

Hello, I have a question with very strange behaviour of code. So, I have a function that causes a crash:

Code:
void CPlugin::FireGameEvent( IGameEvent *event )
{
    std::string name = event->GetName();

    g_SMAPI->ConPrint( ( name + " Just called\n" ).c_str( ) );

    if( name == "player_say" )
    {
        std::string msg = event->GetString( "text" );

        edict_t* pEdict = DrUtils::GetPEdictFromUserId( event->GetInt( "userid" ) );

        if( pEdict != nullptr )
        {
            CBasePlayer* pBase = reinterpret_cast< CBasePlayer* >( pEdict->GetUnknown( )->GetBaseEntity( ) );

            if( pBase != nullptr )
            {
                CommitSuicide( pBase );
            }
            else
            {
                g_SMAPI->ConPrint( "Culd not get CBasePlayer\n" );
            }
        }
        else
        {
            g_SMAPI->ConPrint( "Could not get edict_t" );
        }
    }
}
When I comment this line
Code:
std::string msg = event->GetString( "text" );
it works, however I think that problem is not in this line because then I tried to comment this line
Code:
CommitSuicide( pBase );
and it worked ok. WTF I'm doing wrong?
PS. Code of CommitSuicide

Code:
CommitSuicide( CBaseEntity* pEntity  )
        {
            void **this_ptr = *(void ***)&pEntity;
            void **vtable = *(void ***)pEntity;
            void *func = vtable[433]; 

            union {    CBaseEntity *(EmptyClass::*mfpnew)( );
            void *addr;    } u;     u.addr = func;

            (reinterpret_cast<EmptyClass*>(this_ptr)->*u.mfpnew)( );
        }

Last edited by Yeah=}; 04-27-2012 at 06:05.
Yeah=} 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 18:42.


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