aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/shared/exploit_fixes
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-20 13:24:07 +0000
committerGitHub <noreply@github.com>2023-12-20 14:24:07 +0100
commit0438b5c8cfa99ac01c7e142d959aa40f88f1cc70 (patch)
treebbfdded20f8686cf188dba148db4b6c1b1211872 /NorthstarDLL/shared/exploit_fixes
parent210dab2b0e5c686829bafdc857d2910f6b216b85 (diff)
downloadNorthstarLauncher-0438b5c8cfa99ac01c7e142d959aa40f88f1cc70.tar.gz
NorthstarLauncher-0438b5c8cfa99ac01c7e142d959aa40f88f1cc70.zip
Cherry pick "remove unnecessary namespaces" from primedev (#618)v1.21.2-rc2
Cherry-picks the removal of unnecessary namespaces from `primedev` https://github.com/F1F7Y/NorthstarPrime/ Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'NorthstarDLL/shared/exploit_fixes')
-rw-r--r--NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp24
-rw-r--r--NorthstarDLL/shared/exploit_fixes/ns_limits.cpp56
-rw-r--r--NorthstarDLL/shared/exploit_fixes/ns_limits.h12
3 files changed, 46 insertions, 46 deletions
diff --git a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
index 8821a40d..8064d5ac 100644
--- a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
+++ b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
@@ -84,7 +84,7 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10
};
auto msg = (NET_SetConVar*)pMsg;
- bool bIsServerFrame = Tier0::ThreadInServerFrameThread();
+ bool bIsServerFrame = ThreadInServerFrameThread();
std::string BLOCK_PREFIX =
std::string {"NET_SetConVar ("} + (bIsServerFrame ? "server" : "client") + "): Blocked dangerous/invalid msg: ";
@@ -118,7 +118,7 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10
if (!nameValid || !valValid)
return BLOCKED_INFO("Missing null terminators");
- ConVar* pVar = R2::g_pCVar->FindVar(entry->name);
+ ConVar* pVar = g_pCVar->FindVar(entry->name);
if (pVar)
{
@@ -263,19 +263,19 @@ bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D
{
// somewhat temp, store the modname here, since we don't have a proper ptr in engine to it rn
int iSize = strlen(pModName);
- R2::g_pModName = new char[iSize + 1];
- strcpy(R2::g_pModName, pModName);
+ g_pModName = new char[iSize + 1];
+ strcpy(g_pModName, pModName);
if (g_pVanillaCompatibility->GetVanillaCompatibility())
return false;
- return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !Tier0::CommandLine()->CheckParm("-norestrictservercommands");
+ return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !CommandLine()->CheckParm("-norestrictservercommands");
}
// ratelimit stringcmds, and prevent remote clients from calling commands that they shouldn't
// clang-format off
AUTOHOOK(CGameClient__ExecuteStringCommand, engine.dll + 0x1022E0,
-bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommandString))
+bool, __fastcall, (CBaseClient* self, uint32_t unknown, const char* pCommandString))
// clang-format on
{
if (Cvar_ns_should_log_all_clientcommands->GetBool())
@@ -283,7 +283,7 @@ bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommand
if (!g_pServerLimits->CheckStringCommandLimits(self))
{
- R2::CBaseClient__Disconnect(self, 1, "Sent too many stringcmd commands");
+ CBaseClient__Disconnect(self, 1, "Sent too many stringcmd commands");
return false;
}
@@ -292,10 +292,10 @@ bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommand
memset(commandBuf, 0, sizeof(commandBuf));
CCommand tempCommand = *(CCommand*)&commandBuf;
- if (!R2::CCommand__Tokenize(tempCommand, pCommandString, R2::cmd_source_t::kCommandSrcCode) || !tempCommand.ArgC())
+ if (!CCommand__Tokenize(tempCommand, pCommandString, cmd_source_t::kCommandSrcCode) || !tempCommand.ArgC())
return false;
- ConCommand* command = R2::g_pCVar->FindCommand(tempCommand.Arg(0));
+ ConCommand* command = g_pCVar->FindCommand(tempCommand.Arg(0));
// if the command doesn't exist pass it on to ExecuteStringCommand for script clientcommands and stuff
if (command && !command->IsFlagSet(FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS))
@@ -304,7 +304,7 @@ bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommand
if (IsDedicatedServer())
return false;
- if (strcmp(self->m_UID, R2::g_pLocalPlayerUserID))
+ if (strcmp(self->m_UID, g_pLocalPlayerUserID))
return false;
}
@@ -355,7 +355,7 @@ void, __fastcall, (void* self))
bWasWritingStringTableSuccessful = true;
CBaseClient__SendServerInfo(self);
if (!bWasWritingStringTableSuccessful)
- R2::CBaseClient__Disconnect(
+ CBaseClient__Disconnect(
self, 1, "Overflowed CNetworkStringTableContainer::WriteBaselines, try restarting your client and reconnecting");
}
@@ -457,5 +457,5 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerExploitFixes, ConVar, (CModule module))
Cvar_ns_should_log_all_clientcommands =
new ConVar("ns_should_log_all_clientcommands", "0", FCVAR_NONE, "Whether to log all clientcommands");
- Cvar_sv_cheats = R2::g_pCVar->FindVar("sv_cheats");
+ Cvar_sv_cheats = g_pCVar->FindVar("sv_cheats");
}
diff --git a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
index c9085cb0..bd855ee4 100644
--- a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
+++ b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
@@ -19,47 +19,47 @@ void ServerLimitsManager::RunFrame(double flCurrentTime, float flFrameTime)
if (Cvar_sv_antispeedhack_enable->GetBool())
{
// for each player, set their usercmd processing budget for the frame to the last frametime for the server
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
{
- R2::CBaseClient* player = &R2::g_pClientArray[i];
+ CBaseClient* player = &g_pClientArray[i];
if (m_PlayerLimitData.find(player) != m_PlayerLimitData.end())
{
PlayerLimitData* pLimitData = &g_pServerLimits->m_PlayerLimitData[player];
- if (pLimitData->flFrameUserCmdBudget < R2::g_pGlobals->m_flTickInterval * Cvar_sv_antispeedhack_maxtickbudget->GetFloat())
+ if (pLimitData->flFrameUserCmdBudget < g_pGlobals->m_flTickInterval * Cvar_sv_antispeedhack_maxtickbudget->GetFloat())
{
pLimitData->flFrameUserCmdBudget += g_pServerLimits->Cvar_sv_antispeedhack_budgetincreasemultiplier->GetFloat() *
- fmax(flFrameTime, R2::g_pGlobals->m_flFrameTime * CEngineServer__GetTimescale());
+ fmax(flFrameTime, g_pGlobals->m_flFrameTime * CEngineServer__GetTimescale());
}
}
}
}
}
-void ServerLimitsManager::AddPlayer(R2::CBaseClient* player)
+void ServerLimitsManager::AddPlayer(CBaseClient* player)
{
PlayerLimitData limitData;
limitData.flFrameUserCmdBudget =
- R2::g_pGlobals->m_flTickInterval * CEngineServer__GetTimescale() * Cvar_sv_antispeedhack_maxtickbudget->GetFloat();
+ g_pGlobals->m_flTickInterval * CEngineServer__GetTimescale() * Cvar_sv_antispeedhack_maxtickbudget->GetFloat();
m_PlayerLimitData.insert(std::make_pair(player, limitData));
}
-void ServerLimitsManager::RemovePlayer(R2::CBaseClient* player)
+void ServerLimitsManager::RemovePlayer(CBaseClient* player)
{
if (m_PlayerLimitData.find(player) != m_PlayerLimitData.end())
m_PlayerLimitData.erase(player);
}
-bool ServerLimitsManager::CheckStringCommandLimits(R2::CBaseClient* player)
+bool ServerLimitsManager::CheckStringCommandLimits(CBaseClient* player)
{
if (CVar_sv_quota_stringcmdspersecond->GetInt() != -1)
{
// note: this isn't super perfect, legit clients can trigger it in lobby if they try, mostly good enough tho imo
- if (Tier0::Plat_FloatTime() - m_PlayerLimitData[player].lastClientCommandQuotaStart >= 1.0)
+ if (Plat_FloatTime() - m_PlayerLimitData[player].lastClientCommandQuotaStart >= 1.0)
{
// reset quota
- m_PlayerLimitData[player].lastClientCommandQuotaStart = Tier0::Plat_FloatTime();
+ m_PlayerLimitData[player].lastClientCommandQuotaStart = Plat_FloatTime();
m_PlayerLimitData[player].numClientCommandsInQuota = 0;
}
@@ -74,11 +74,11 @@ bool ServerLimitsManager::CheckStringCommandLimits(R2::CBaseClient* player)
return true;
}
-bool ServerLimitsManager::CheckChatLimits(R2::CBaseClient* player)
+bool ServerLimitsManager::CheckChatLimits(CBaseClient* player)
{
- if (Tier0::Plat_FloatTime() - m_PlayerLimitData[player].lastSayTextLimitStart >= 1.0)
+ if (Plat_FloatTime() - m_PlayerLimitData[player].lastSayTextLimitStart >= 1.0)
{
- m_PlayerLimitData[player].lastSayTextLimitStart = Tier0::Plat_FloatTime();
+ m_PlayerLimitData[player].lastSayTextLimitStart = Plat_FloatTime();
m_PlayerLimitData[player].sayTextLimitCount = 0;
}
@@ -100,14 +100,14 @@ char, __fastcall, (void* self, void* buf))
NETCHANLIMIT_KICK
};
- double startTime = Tier0::Plat_FloatTime();
+ double startTime = Plat_FloatTime();
char ret = CNetChan__ProcessMessages(self, buf);
// check processing limits, unless we're in a level transition
- if (R2::g_pHostState->m_iCurrentState == R2::HostState_t::HS_RUN && Tier0::ThreadInServerFrameThread())
+ if (g_pHostState->m_iCurrentState == HostState_t::HS_RUN && ThreadInServerFrameThread())
{
// player that sent the message
- R2::CBaseClient* sender = *(R2::CBaseClient**)((char*)self + 368);
+ CBaseClient* sender = *(CBaseClient**)((char*)self + 368);
// if no sender, return
// relatively certain this is fine?
@@ -121,7 +121,7 @@ char, __fastcall, (void* self, void* buf))
g_pServerLimits->m_PlayerLimitData[sender].lastNetChanProcessingLimitStart = startTime;
g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime = 0.0;
}
- g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime += (Tier0::Plat_FloatTime() * 1000) - (startTime * 1000);
+ g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime += (Plat_FloatTime() * 1000) - (startTime * 1000);
if (g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime >=
g_pServerLimits->Cvar_net_chan_limit_msec_per_sec->GetInt())
@@ -133,9 +133,9 @@ char, __fastcall, (void* self, void* buf))
g_pServerLimits->Cvar_net_chan_limit_msec_per_sec->GetInt());
// never kick local player
- if (g_pServerLimits->Cvar_net_chan_limit_mode->GetInt() != NETCHANLIMIT_WARN && strcmp(R2::g_pLocalPlayerUserID, sender->m_UID))
+ if (g_pServerLimits->Cvar_net_chan_limit_mode->GetInt() != NETCHANLIMIT_WARN && strcmp(g_pLocalPlayerUserID, sender->m_UID))
{
- R2::CBaseClient__Disconnect(sender, 1, "Exceeded net channel processing limit");
+ CBaseClient__Disconnect(sender, 1, "Exceeded net channel processing limit");
return false;
}
}
@@ -144,12 +144,12 @@ char, __fastcall, (void* self, void* buf))
return ret;
}
-bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packet)
+bool ServerLimitsManager::CheckConnectionlessPacketLimits(netpacket_t* packet)
{
- static const ConVar* Cvar_net_data_block_enabled = R2::g_pCVar->FindVar("net_data_block_enabled");
+ static const ConVar* Cvar_net_data_block_enabled = g_pCVar->FindVar("net_data_block_enabled");
// don't ratelimit datablock packets as long as datablock is enabled
- if (packet->adr.type == R2::NA_IP &&
+ if (packet->adr.type == NA_IP &&
(!(packet->data[4] == 'N' && Cvar_net_data_block_enabled->GetBool()) || !Cvar_net_data_block_enabled->GetBool()))
{
// bad lookup: optimise later tm
@@ -169,12 +169,12 @@ bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packe
memcpy(sendData->ip, packet->adr.ip, 16);
}
- if (Tier0::Plat_FloatTime() < sendData->timeoutEnd)
+ if (Plat_FloatTime() < sendData->timeoutEnd)
return false;
- if (Tier0::Plat_FloatTime() - sendData->lastQuotaStart >= 1.0)
+ if (Plat_FloatTime() - sendData->lastQuotaStart >= 1.0)
{
- sendData->lastQuotaStart = Tier0::Plat_FloatTime();
+ sendData->lastQuotaStart = Plat_FloatTime();
sendData->packetCount = 0;
}
@@ -188,7 +188,7 @@ bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packe
packet->data[4]);
// timeout for a minute
- sendData->timeoutEnd = Tier0::Plat_FloatTime() + 60.0;
+ sendData->timeoutEnd = Plat_FloatTime() + 60.0;
return false;
}
}
@@ -232,12 +232,12 @@ struct alignas(4) SV_CUserCmd
// clang-format off
AUTOHOOK(CPlayerMove__RunCommand, server.dll + 0x5B8100,
-void, __fastcall, (void* self, R2::CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4))
+void, __fastcall, (void* self, CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4))
// clang-format on
{
if (g_pServerLimits->Cvar_sv_antispeedhack_enable->GetBool())
{
- R2::CBaseClient* pClient = &R2::g_pClientArray[player->m_nPlayerIndex - 1];
+ CBaseClient* pClient = &g_pClientArray[player->m_nPlayerIndex - 1];
if (g_pServerLimits->m_PlayerLimitData.find(pClient) != g_pServerLimits->m_PlayerLimitData.end())
{
diff --git a/NorthstarDLL/shared/exploit_fixes/ns_limits.h b/NorthstarDLL/shared/exploit_fixes/ns_limits.h
index d1f7f2ed..a2cc431f 100644
--- a/NorthstarDLL/shared/exploit_fixes/ns_limits.h
+++ b/NorthstarDLL/shared/exploit_fixes/ns_limits.h
@@ -37,16 +37,16 @@ class ServerLimitsManager
ConVar* Cvar_sv_antispeedhack_maxtickbudget;
ConVar* Cvar_sv_antispeedhack_budgetincreasemultiplier;
- std::unordered_map<R2::CBaseClient*, PlayerLimitData> m_PlayerLimitData;
+ std::unordered_map<CBaseClient*, PlayerLimitData> m_PlayerLimitData;
std::vector<UnconnectedPlayerLimitData> m_UnconnectedPlayerLimitData;
public:
void RunFrame(double flCurrentTime, float flFrameTime);
- void AddPlayer(R2::CBaseClient* player);
- void RemovePlayer(R2::CBaseClient* player);
- bool CheckStringCommandLimits(R2::CBaseClient* player);
- bool CheckChatLimits(R2::CBaseClient* player);
- bool CheckConnectionlessPacketLimits(R2::netpacket_t* packet);
+ void AddPlayer(CBaseClient* player);
+ void RemovePlayer(CBaseClient* player);
+ bool CheckStringCommandLimits(CBaseClient* player);
+ bool CheckChatLimits(CBaseClient* player);
+ bool CheckConnectionlessPacketLimits(netpacket_t* packet);
};
extern ServerLimitsManager* g_pServerLimits;