Skip to content

Commit

Permalink
feat: gamedata support (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxime1907 authored and xen-000 committed Oct 16, 2023
1 parent b618dcf commit b8d2866
Show file tree
Hide file tree
Showing 23 changed files with 748 additions and 231 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ bld/
[Bb]in/
[Oo]bj/
.vs/
*.vcxproj.user
*.vcxproj.user
.vscode
3 changes: 2 additions & 1 deletion AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ for sdk_name in MMSPlugin.sdks:
'src/cs2_sdk/interfaces/cs2_interfaces.cpp',
'src/cs2_sdk/interfaces/centitysystem.cpp',
'src/ctimer.cpp',
'src/playermanager.cpp'
'src/playermanager.cpp',
'src/gameconfig.cpp',
]

if sdk_name in ['dota', 'cs2']:
Expand Down
1 change: 1 addition & 0 deletions CS2Fixes.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<ClCompile Include="src\cvars.cpp" />
<ClCompile Include="src\detours.cpp" />
<ClCompile Include="src\events.cpp" />
<ClCompile Include="src\gameconfig.cpp" />
<ClCompile Include="src\mempatch.cpp" />
<ClCompile Include="src\patches.cpp" />
<ClCompile Include="src\playermanager.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions CS2Fixes.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
<ClCompile Include="src\events.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\gameconfig.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\mempatch.h">
Expand Down
2 changes: 2 additions & 0 deletions PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ with open(os.path.join(builder.buildPath, 'pdblog.txt'), 'wt') as fp:
# Add CS2Fixes-specific files
builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name, 'data'))
configs_folder = builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name, 'configs'))
gamedata_folder = builder.AddFolder(os.path.join('addons', MMSPlugin.plugin_name, 'gamedata'))
builder.AddCopy(os.path.join(builder.sourcePath, 'configs', 'admins.cfg'), configs_folder)
builder.AddCopy(os.path.join('gamedata', 'cs2fixes.games.txt'), gamedata_folder)
246 changes: 246 additions & 0 deletions gamedata/cs2fixes.games.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
"Games"
{
"csgo"
{
"Signatures"
{
// Logging
"Msg"
{
"library" "tier0"
"windows" "@Msg"
"linux" "@Msg"
}
"ConDMsg"
{
"library" "tier0"
"windows" "@ConDMsg"
"linux" "@ConDMsg"
}
"DevMsg"
{
"library" "tier0"
"windows" "@DevMsg"
"linux" "@DevMsg"
}
"Warning"
{
"library" "tier0"
"windows" "@Warning"
"linux" "@Warning"
}
"DevWarning"
{
"library" "tier0"
"windows" "@DevWarning"
"linux" "@DevWarning"
}
"LoggingSystem_Log"
{
"library" "tier0"
"windows" "@LoggingSystem_Log"
"linux" "@LoggingSystem_Log"
}
"LoggingSystem_LogDirect"
{
"library" "tier0"
"windows" "@LoggingSystem_LogDirect"
"linux" "@LoggingSystem_LogDirect"
}
"LoggingSystem_LogAssert"
{
"library" "tier0"
"windows" "@LoggingSystem_LogAssert"
"linux" "@LoggingSystem_LogAssert"
}

// String: "\"Console<0>\" say \"%s\"\n"
"Host_Say"
{
"library" "server"
"windows" "\x44\x89\x4C\x24\x2A\x44\x88\x44\x24\x2A\x55\x53\x56\x57\x41\x54\x41\x55"
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xFF\x41\x56\x41\x55\x41\x54\x4D\x89\xC4"
}
// Called from Host_Say
"UTIL_SayTextFilter"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x2A\x55\x56\x57\x48\x8D\x6C\x24\x2A\x48\x81\xEC\x2A\x2A\x2A\x2A\x49\x8B\xD8"
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xD7\x31\xD2\x41\x56\x4C\x8D\x75\x98"
}
// Called from Host_Say
"UTIL_SayText2Filter"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x2A\x55\x56\x57\x48\x8D\x6C\x24\x2A\x48\x81\xEC\x2A\x2A\x2A\x2A\x41\x0F\xB6\xF8"
"linux" "\x55\x48\x89\xE5\x41\x57\x4C\x8D\xBD\x2A\x2A\x2A\x2A\x41\x56\x4D\x89\xC6\x41\x55\x4D\x89\xCD"
}
// String: "<unconnected>"
"UTIL_ClientPrintAll"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x81\xEC\x70\x01\x2A\x2A\x8B\xE9"
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xD7\x41\x56\x49\x89\xF6\x41\x55\x41\x89\xFD"
}
// String: "Console command too long"
"ClientPrint"
{
"library" "server"
"windows" "\x48\x85\xC9\x0F\x84\x2A\x2A\x2A\x2A\x48\x8B\xC4\x48\x89\x58\x18"
"linux" "\x55\x48\x89\xE5\x41\x57\x49\x89\xCF\x41\x56\x49\x89\xD6\x41\x55\x41\x89\xF5\x41\x54\x4C\x8D\xA5\xA0\xFE\xFF\xFF"
}
"NetworkStateChanged"
{
"library" "server"
"windows" "\x4C\x8B\xC9\x48\x8B\x09\x48\x85\xC9\x74\x2A\x48\x8B\x41\x10"
"linux" "\x4C\x8B\x07\x4D\x85\xC0\x74\x2A\x49\x8B\x40\x10"
}
"StateChanged"
{
"library" "server"
"windows" "\x48\x89\x54\x24\x10\x55\x53\x57\x41\x55"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x55\x41\x54\x53\x89\xD3"
}
"VoiceShouldHear"
{
"library" "engine"
"windows" "\x48\x89\x5C\x24\x10\x44\x88\x4C\x24\x20\x44\x88\x44\x24\x18"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x89\xD7\x41\x56\x49\x89\xF6\x41\x55\x41\x54\x49\x89\xFC\x53\x48\x83\xEC\x28"
}
"IsHearingClient"
{
"library" "engine"
"windows" "\x40\x53\x48\x83\xEC\x20\x48\x8B\xD9\x3B\x91\xB8"
"linux" "\x55\x48\x89\xE5\x41\x55\x41\x54\x53\x48\x89\xFB\x48\x83\xEC\x08\x3B\xB7\xC8"
}
// String: "Playing sound on non-networked entity %s"
"CSoundEmitterSystem_EmitSound"
{
"library" "server"
"windows" "\x48\x8B\xC4\x4C\x89\x40\x18\x55\x57"
"linux" "\x48\xB8\x2A\x2A\x2A\x2A\xFF\xFF\xFF\xFF\x55\x48\x89\xE5\x41\x57\x41\x89\xF7"
}
// String: "hammerUniqueId"
"CBaseEntity_Spawn"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x10\x48\x89\x74\x24\x18\x57\x48\x83\xEC\x30\x48\x8B\xF2"
"linux" "\x55\x48\x89\xE5\x41\x56\x41\x55\x41\x54\x49\x89\xF4\x53\x48\x89\xFB\x48\x83\xEC\x10\xE8\x2A\x2A\x2A\x2A"
}
// Is the 4th function in the CCSWeaponBase vtable
"CCSWeaponBase_Spawn"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x18\x48\x89\x74\x24\x20\x57\x48\x83\xEC\x30\x48\x8B\xDA\x48\x8B\xE9\xE8\x2A\x2A\x2A\x2A"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x4C\x8D\x75\xC0\x41\x55\x49\x89\xFD\x41\x54\x49\x89\xF4"
}
// idk a good way to find this again, i just brute forced the vtable. offset is 133 on CTriggerPush
"TriggerPush_Touch"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x10\x48\x89\x7C\x24\x18\x55\x48\x8D\xAC\x24\x60\xE0\xFF\xFF"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x55\x49\x89\xF5\x41\x54\x49\x89\xFC\x53\x48\x81\xEC\x28\x20\x2A\x2A\xE8"
}
// this is called in CTriggerPush::Touch, using IDA pseudocode look in an `if ( ( v & 0x80 ) != 0 )` and then `if ( v > 0.0 ) SetGroundEntity()`
"SetGroundEntity"
{
"library" "server"
"windows" "\x48\x89\x5C\x24\x10\x48\x89\x6C\x24\x18\x48\x89\x7C\x24\x20\x41\x56\x48\x83\xEC\x20\x0F\xB6\x81\xC0\x02\x2A\x2A\x48"
"linux" "\x55\x48\x89\xE5\x41\x57\x41\x56\x41\x55\x49\x89\xF5\x41\x54\x49\x89\xFC\x53\x48\x83\xEC\x08\x0F\xB6\x87\xA8\x05\x2A\x2A\x83"
}
// Check vauff's pin in #scripting
"ServerMovementUnlock"
{
"library" "server"
"windows" "\x76\x2A\xF2\x0F\x10\x57\x2A\xF3\x0F\x10\x2A\x2A\x0F\x28\xCA\xF3\x0F\x59\xC0"
"linux" "\x0F\x87\x2A\x2A\x2A\x2A\x49\x8B\x7C\x24\x2A\xE8\x2A\x2A\x2A\x2A\x66\x0F\xEF\xED\x66\x0F\xD6\x85\x2A\x2A\x2A\x2A"
}
// Check vauff's pin in #scripting
"ClientMovementUnlock"
{
"library" "client"
"windows" "\x76\x2A\xF2\x0F\x10\x57\x2A\xF3\x0F\x10\x2A\x2A\x0F\x28\xCA\xF3\x0F\x59\xC0"
"linux" "\x0F\x87\x2A\x2A\x2A\x2A\x49\x8B\x7C\x24\x2A\xE8\x2A\x2A\x2A\x2A\x66\x0F\xEF\xED\x66\x0F\xD6\x85\x2A\x2A\x2A\x2A"
}
// Check tilgep's pin in #scripting
"VScriptEnable"
{
"library" "vscript"
"windows" "\xBE\x01\x2A\x2A\x2A\x2B\xD6\x74\x2A\x3B\xD6"
"linux" "\x83\xFE\x01\x0F\x84\x2A\x2A\x2A\x2A\x83"
}
// String: "Noise removal", there should be 3 customermachine checks
"HammerNoCustomerMachine"
{
"library" "hammer"
"windows" "\xFF\x15\x2A\x2A\x2A\x2A\x84\xC0\x0F\x85\x2A\x2A\x2A\x2A\xB9"
"linux" ""
}
// String: "player_jump", then find 42C80000h or in pseudocode "*(a2 + 68) = 1120403456;", changing from 100 to 145
"CheckJumpButtonWater"
{
"library" "server"
"windows" "\xC8\x42\xEB\x2A\x48\x8B\x4B\x30"
"linux" "\xC8\x42\x66\x0F\xEF\xE4\x41\x0F\x2F\x65"
}
// String: "CCSPlayerPawnBase::SwitchTeam", just keep in mind this is actually CCSPlayerController::SwitchTeam
"CCSPlayerController_SwitchTeam"
{
"library" "server"
"windows" "\x40\x56\x57\x48\x81\xEC\x2A\x2A\x2A\x2A\x48\x8B\xF9\x8B\xF2\x8B\xCA"
"linux" "\x55\x48\x89\xE5\x41\x55\x49\x89\xFD\x89\xF7"
}
}
"Offsets"
{
"GameEntitySystem"
{
"windows" "88"
"linux" "80"
}
"Teleport"
{
"windows" "148"
"linux" "147"
}
"CollisionRulesChanged"
{
"windows" "173"
"linux" "172"
}
}
"Patches"
{
// Server
"ServerMovementUnlock"
{
"windows" "\xEB"
"linux" "\x90\x90\x90\x90\x90\x90"
}
"VScriptEnable"
{
"windows" "\xBE\x02"
"linux" "\x83\xFE\x02"
}
"FixWaterFloorJump"
{
"windows" "\x11\x43"
"linux" "\x11\x43"
}

// Client
"ClientMovementUnlock"
{
"windows" "\xEB"
"linux" "\x90\x90\x90\x90\x90\x90"
}

// Hammer
"HammerNoCustomerMachine"
{
"windows" "\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"linux" ""
}
}
}
}
19 changes: 10 additions & 9 deletions src/addresses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
#include "tier0/memdbgon.h"


#define RESOLVE_SIG(module, sig, variable) variable = (decltype(variable))module->FindSignature((uint8*)sig)
#define RESOLVE_SIG(gameConfig, name, variable) \
variable = (decltype(variable))gameConfig->ResolveSignature(name)

void addresses::Initialize()
void addresses::Initialize(CGameConfig *g_GameConfig)
{
modules::engine = new CModule(ROOTBIN, "engine2");
modules::tier0 = new CModule(ROOTBIN, "tier0");
Expand All @@ -44,10 +45,10 @@ void addresses::Initialize()
modules::hammer = new CModule(ROOTBIN, "tools/hammer");
#endif

RESOLVE_SIG(modules::server, sigs::NetworkStateChanged, addresses::NetworkStateChanged);
RESOLVE_SIG(modules::server, sigs::StateChanged, addresses::StateChanged);
RESOLVE_SIG(modules::server, sigs::UTIL_ClientPrintAll, addresses::UTIL_ClientPrintAll);
RESOLVE_SIG(modules::server, sigs::ClientPrint, addresses::ClientPrint);
RESOLVE_SIG(modules::server, sigs::SetGroundEntity, addresses::SetGroundEntity);
RESOLVE_SIG(modules::server, sigs::CCSPlayerController_SwitchTeam, addresses::CCSPlayerController_SwitchTeam);
}
RESOLVE_SIG(g_GameConfig, "NetworkStateChanged", addresses::NetworkStateChanged);
RESOLVE_SIG(g_GameConfig, "StateChanged", addresses::StateChanged);
RESOLVE_SIG(g_GameConfig, "UTIL_ClientPrintAll", addresses::UTIL_ClientPrintAll);
RESOLVE_SIG(g_GameConfig, "ClientPrint", addresses::ClientPrint);
RESOLVE_SIG(g_GameConfig, "SetGroundEntity", addresses::SetGroundEntity);
RESOLVE_SIG(g_GameConfig, "CCSPlayerController_SwitchTeam", addresses::CCSPlayerController_SwitchTeam);
}
Loading

0 comments on commit b8d2866

Please sign in to comment.