Skip to content

Commit

Permalink
Make single link node pool unlimited
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNormalnij committed Jan 26, 2025
1 parent bf689fd commit 39ace26
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,7 @@ void CMultiplayerSA::InitHooks()

InitHooks_CrashFixHacks();
InitHooks_DeviceSelection();
InitHooks_SingleLinkNode();

// Init our 1.3 hooks.
Init_13();
Expand Down
1 change: 1 addition & 0 deletions Client/multiplayer_sa/CMultiplayerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CMultiplayerSA : public CMultiplayer
void InitHooks_ObjectStreamerOptimization();
void InitHooks_Postprocess();
void InitHooks_DeviceSelection();
void InitHooks_SingleLinkNode();
CRemoteDataStorage* CreateRemoteDataStorage();
void DestroyRemoteDataStorage(CRemoteDataStorage* pData);
void AddRemoteDataStorage(CPlayerPed* pPed, CRemoteDataStorage* pData);
Expand Down
58 changes: 58 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA_SingleLinkNode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*****************************************************************************
*
* PROJECT: Multi Theft Auto
* LICENSE: See LICENSE in the top level directory
* FILE: multiplayer_sa/CMultiplayerSA_SingleLinkNode.cpp
* PORPOISE: Unlimites the SingleLinkNode pool
*
* Multi Theft Auto is available from https://www.multitheftauto.com/
*
*****************************************************************************/

#include "StdInc.h"

constexpr std::size_t NODE_POOL_CAPACITY = 90000;
constexpr std::size_t NODE_POOL_SIZE_BYTES = NODE_POOL_CAPACITY * 8;

constexpr std::uint32_t HOOKPOS_SingleLinkNodeConstructor = 0x5522A0;
constexpr std::size_t HOOKSIZE_SingleLinkNodeConstructor = 5;
static void _declspec(naked) HOOK_SingleLinkNodeConstructor()
{
_asm {
push 0x8
call malloc
add esp, 4
pop edi
pop esi
ret
}
}

constexpr std::uint32_t HOOKPOS_SingleLinkNodeDestructor = 0x552396;
constexpr std::size_t HOOKSIZE_SingleLinkNodeDestructor = 5;
static const std::uint32_t CONTINUE_SingleLinkNodeDestructor = 0x55239B;
static void _declspec(naked) HOOK_SingleLinkNodeDestructor()
{
_asm {
mov eax, [esp+0x4] ; Node to delete
mov edx, [ecx] ; Pool objects array
cmp edx, eax
ja out_of_pool
add edx, NODE_POOL_SIZE_BYTES ; Pool end
cmp edx, eax
jb out_of_pool
push ebx ; original
jmp CONTINUE_SingleLinkNodeDestructor
out_of_pool:
push eax
call free
pop eax
retn
}
}

void CMultiplayerSA::InitHooks_SingleLinkNode()
{
EZHookInstall(SingleLinkNodeConstructor);
EZHookInstall(SingleLinkNodeDestructor);
}

0 comments on commit 39ace26

Please sign in to comment.