Try fixing server crashes

This commit is contained in:
Maurice Heumann 2021-05-04 19:59:47 +02:00
parent 62f4b39688
commit edf1d41639
2 changed files with 41 additions and 0 deletions

View File

@ -14,6 +14,29 @@ namespace security
reinterpret_cast<void(*)(int, int, int)>(0x140536A60)(localclient, index1, index2);
}
}
void remap_cached_entities(game::mp::cachedSnapshot_t& snapshot)
{
static bool printed = false;
if(snapshot.num_clients > 1200 && !printed)
{
printed = true;
printf("Too many entities (%d)... remapping!\n", snapshot.num_clients);
}
snapshot.num_clients = std::min(snapshot.num_clients, 1200);
}
void remap_cached_entities_stub(utils::hook::assembler& a)
{
a.pushad64();
a.mov(rcx, rbx);
a.call_aligned(remap_cached_entities);
a.popad64();
a.jmp(0x14044DE51);
}
}
class component final : public component_interface
@ -25,6 +48,9 @@ namespace security
// Patch vulnerability in PlayerCards_SetCachedPlayerData
utils::hook::call(0x1401BB909, set_cached_playerdata_stub);
// Patch entity overflow
utils::hook::jump(0x14044DE3A, assemble(remap_cached_entities_stub), true);
}
};
}

View File

@ -1267,6 +1267,21 @@ namespace game
namespace mp
{
struct cachedSnapshot_t
{
int archivedFrame;
int time;
int num_entities;
int first_entity;
int num_clients;
int first_client;
int num_agents;
int first_agent;
unsigned int scriptableCount;
unsigned int scriptableFirstIndex;
int usesDelta;
};
struct gclient_s
{
char __pad0[20708];