/q crashing / crashing every time I want to exit game.

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
So this thing for some reason when I hook into the RakClient in SA-MP (0.3.DL), it works but everytime I want to exit or I exit the game. I kinda get a crash popup but I don't really crash, like when I /q it says your game has crashed but I leave as "leaving/quit" in the server rather than "crashed".
What can be the fix of this? Also if I'm not mistaken s0biet used to have a issue like this before and it was fixed but I cannot find it.

Code:
  g_SAMP = (DWORD)GetModuleHandle("samp.dll");

   
    bool initSampRak = false;
    while (true)
    {
        if (!initSampRak)
        {
            if (memcmp_safe((uint8_t*)g_SAMP + 0xBABE, hex_to_bin(SAMP037_CMP), 10))
            {
                samp037 = true;
            }
            else samp037 = false;

            if (samp037)
            {
                // same sht just like for 037 diff structs etc
            }
            else
            {
                g_stSAMP = stGetSampInfo();

                if (isBadPtr_writeAny(g_stSAMP, sizeof(stSAMP)))
                {
                    MessageBox(0, "stSamp BadPtr", "INIT ERR", 0);
                    continue;
                }

                if (isBadPtr_writeAny(g_stSAMP->pPools, sizeof(stSAMPPools)))
                {
                    MessageBox(0, "stSamp->pPools BadPtr", "INIT ERR", 0);
                    continue;
                }

                g_Chat = stGetSampChatInfo();
                if (isBadPtr_writeAny(g_Chat, sizeof(stChatInfo)))
                {
                    MessageBox(0, "g_Chat BadPtr", "INIT ERR", 0);
                    continue;
                }

                g_Input = stGetInputInfo();
                if (isBadPtr_writeAny(g_Input, sizeof(stInputInfo)))
                {
                    MessageBox(0, "g_Input BadPtr", "INIT ERR", 0);
                    continue;
                }

                if (g_stSAMP->pRakClientInterface == NULL)
                {
                    MessageBox(0, "RakClient == NULL", "INIT ERR", 0);
                    continue;
                }

                g_RakClient = new RakClient(g_stSAMP->pRakClientInterface);
                g_stSAMP->pRakClientInterface = new HookedRakClientInterface();
            }

            initSampRak = true;
        }
 

0x32789

Expert
Joined
May 26, 2014
Messages
849
Reaction score
51
Location
LongForgotten <-> 0x32789
Mayb bcs u don kill thread?
While(!initraksanp)

Yep, I don't. Is this the reason why it gives out a crash exception every time?
A normal while(loop) doesn't crash, like it'd die with the process...
And it's while(true) as after DLL Main it's called on another thread to do the hack stuff, without rak shit it's all good.
 
Joined
Feb 18, 2005
Messages
2,963
Reaction score
267
C++:
g_RakClient = new RakClient(g_stSAMP->pRakClientInterface);
g_stSAMP->pRakClientInterface = new HookedRakClientInterface();

You need to restore this pointer, before sa-mp calls 'delete' on it, so it can call the right destructor, mod_sa does it by hooking CNetGame destructor.
 
Top