Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
db16bb9
Switch to Metamod KHook development branch
Vauff Apr 18, 2025
022936d
fix includes, some definitely wrong messing around with api
Vauff Apr 18, 2025
32027b4
first khook theoretically working
Vauff Apr 18, 2025
e507b6e
Finish migration of main virtual hooks
Vauff Apr 20, 2025
03b959e
fix building docker container
Vauff Apr 23, 2025
a5c05dd
fix build errors
Vauff Apr 23, 2025
1a0c145
fix more build errors
Vauff Apr 23, 2025
e9825a7
update khook include path
Vauff Apr 29, 2025
7db7c33
Fix VTable hooks
Vauff Apr 29, 2025
8c8d52f
Migrate EntWatch virtual hooks
Vauff May 1, 2025
c8059eb
Merge branch 'main' into khook
Vauff Jan 14, 2026
9f81a40
Merge branch 'main' into khook
Vauff Mar 11, 2026
8a1f258
various fixes & remove/add some todo's
Vauff Mar 11, 2026
644af85
more fixes
Vauff Mar 11, 2026
1a6664b
"fix" another calloriginal
Vauff Mar 17, 2026
597273f
Merge branch 'main' into khook
Vauff Mar 19, 2026
2e79ae1
Fix EntWatch crashes
Vauff Apr 9, 2026
f1c4dca
Re-enable GoToIntermission hook
Vauff Apr 11, 2026
cac7bca
Fix PostEventAbstract crash
Vauff Apr 11, 2026
9d19b9b
Merge branch 'main' into khook
Vauff May 23, 2026
c1b3be7
Migrate detour system to KHook
Vauff Jun 1, 2026
9481893
fix TakeDamage crash
Vauff Jun 1, 2026
ebe7aeb
Fix template deduction for windows compilation (#449)
Kenzzer Jun 8, 2026
ef70947
Merge branch 'main' into khook
Vauff Jul 15, 2026
338985f
fix bad copy paste
Vauff Jul 15, 2026
56aeaf8
Replace our signature lookup with KHook's implementation
Vauff Jul 16, 2026
1682e40
Merge branch 'main' into khook
Vauff Sep 9, 2026
c4e2c95
switch back to metamod master branch
Vauff Sep 9, 2026
cd02e27
Remove wildcard converter now that KHook supports singles
Vauff Sep 9, 2026
75ed954
Address automatic review findings
Vauff Sep 9, 2026
8b0c794
Merge branch 'dev' into khook
Vauff Sep 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ const char *PLUGIN_FULL_VERSION = \"{version}\";
cxx.cxxincludes += [
os.path.join(context.currentSourcePath),
os.path.join(mms_core_path),
os.path.join(mms_core_path, 'sourcehook'),
os.path.join(self.mms_root, 'third_party', 'khook', 'include'),
]

for other_sdk in self.sdk_manifests:
Expand Down
7 changes: 0 additions & 7 deletions AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,16 @@ for sdk_target in MMSPlugin.sdk_targets:
os.path.join(builder.sourcePath, 'src', 'utils'),
os.path.join(builder.sourcePath, 'public'),
os.path.join(builder.sourcePath, 'sdk', 'thirdparty', 'protobuf-3.21.8', 'src'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'include'),
]

target_folder = 'Debug' if builder.options.debug else 'Release'

if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += [
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', target_folder, 'libfunchook.a'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', target_folder, 'libdistorm.a'),
os.path.join(builder.sourcePath, 'sdk', 'lib', 'linux64', 'release', 'libprotobuf.a'),
]
binary.sources += ['src/utils/plat_unix.cpp']
elif binary.compiler.target.platform == 'windows':
binary.compiler.postlink += [
os.path.join('psapi.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', target_folder, 'funchook.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', target_folder, 'distorm.lib'),
os.path.join(builder.sourcePath, 'sdk', 'lib' ,'public', 'win64', '2015', 'libprotobuf.lib'),
os.path.join(builder.sourcePath, 'sdk', 'lib', 'public', 'win64', 'steam_api64.lib')
]
Expand Down
21 changes: 10 additions & 11 deletions CS2Fixes.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>cs2fixes</TargetName>
<LibraryPath>sdk\lib\public\win64;vendor/funchook/lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
<LibraryPath>sdk\lib\public\win64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
<OutDir>$(SolutionDir)/package/addons/cs2fixes/bin/win64/</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>cs2fixes</TargetName>
<LibraryPath>sdk\lib\public\win64;vendor/funchook/lib;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
<LibraryPath>sdk\lib\public\win64;$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64)</LibraryPath>
<OutDir>$(SolutionDir)/package/addons/cs2fixes/bin/win64/</OutDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
Expand Down Expand Up @@ -119,12 +119,12 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>__STDC_LIMIT_MACROS;X64BITS;WIN32;COMPILER_MSVC;COMPILER_MSVC64;_CRT_NO_VA_START_VALIDATION;_ITERATOR_DEBUG_LEVEL=0;_DEBUG;CS2Fixes_EXPORTS;_WINDOWS;_USRDLL;META_IS_SOURCE2;SUBHOOK_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>__STDC_LIMIT_MACROS;X64BITS;WIN32;COMPILER_MSVC;COMPILER_MSVC64;_CRT_NO_VA_START_VALIDATION;_ITERATOR_DEBUG_LEVEL=0;_DEBUG;CS2Fixes_EXPORTS;_WINDOWS;_USRDLL;META_IS_SOURCE2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>build/cs2fixes.cs2/windows-x86_64;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;minhook/include;$(MMSOURCE112)/core;$(MMSOURCE112)/core/sourcehook;$(MMSOURCE_DEV)/core;$(MMSOURCE_DEV)/core/sourcehook;vendor/subhook;vendor/funchook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>build/cs2fixes.cs2/windows-x86_64;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;$(MMSOURCE112)/core;$(MMSOURCE112)/third_party/khook/include;$(MMSOURCE_DEV)/core;$(MMSOURCE_DEV)/third_party/khook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
Expand All @@ -133,8 +133,8 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>interfaces.lib;mathlib.lib;tier0.lib;tier1.lib;psapi.lib;funchook.lib;distorm.lib;steam_api64.lib;vendor/protobuf-lib/Debug/libprotobufd.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>sdk/lib/public/win64;vendor/funchook/lib/Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>interfaces.lib;mathlib.lib;tier0.lib;tier1.lib;psapi.lib;steam_api64.lib;vendor/protobuf-lib/Debug/libprotobufd.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>sdk/lib/public/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ShowProgress>
</ShowProgress>
</Link>
Expand All @@ -145,12 +145,12 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>__STDC_LIMIT_MACROS;X64BITS;WIN32;COMPILER_MSVC;COMPILER_MSVC64;_CRT_NO_VA_START_VALIDATION;_ITERATOR_DEBUG_LEVEL=0;NDEBUG;_WINDOWS;CS2Fixes_EXPORTS;_USRDLL;META_IS_SOURCE2;SUBHOOK_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>__STDC_LIMIT_MACROS;X64BITS;WIN32;COMPILER_MSVC;COMPILER_MSVC64;_CRT_NO_VA_START_VALIDATION;_ITERATOR_DEBUG_LEVEL=0;NDEBUG;_WINDOWS;CS2Fixes_EXPORTS;_USRDLL;META_IS_SOURCE2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>Default</ConformanceMode>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>build/cs2fixes.cs2/windows-x86_64;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;minhook/include;$(MMSOURCE112)/core;$(MMSOURCE112)/core/sourcehook;$(MMSOURCE_DEV)/core;$(MMSOURCE_DEV)/core/sourcehook;vendor/subhook;vendor/funchook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>build/cs2fixes.cs2/windows-x86_64;src/utils;src/cs2_sdk;sdk/public;sdk/public/tier0;sdk/game/shared;sdk/game/server;sdk/public/tier1;sdk/public/mathlib;$(MMSOURCE112)/core;$(MMSOURCE112)/third_party/khook/include;$(MMSOURCE_DEV)/core;$(MMSOURCE_DEV)/third_party/khook/include;sdk/public/entity2;sdk/public/game/server;sdk/thirdparty/protobuf-3.21.8/src;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<UndefinePreprocessorDefinitions>%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
Expand All @@ -161,8 +161,8 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>interfaces.lib;mathlib.lib;tier0.lib;tier1.lib;psapi.lib;funchook.lib;distorm.lib;steam_api64.lib;vendor/protobuf-lib/Release/libprotobuf.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>sdk/lib/public/win64;vendor/funchook/lib/Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>interfaces.lib;mathlib.lib;tier0.lib;tier1.lib;psapi.lib;steam_api64.lib;vendor/protobuf-lib/Release/libprotobuf.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>sdk/lib/public/win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ShowProgress>
</ShowProgress>
</Link>
Expand Down Expand Up @@ -269,7 +269,6 @@
<ClInclude Include="src\cs2_sdk\schema.h" />
<ClInclude Include="src\cs2_sdk\entityio.h" />
<ClInclude Include="src\cs2_sdk\cchecktransmitinfo.h" />
<ClInclude Include="src\cdetour.h" />
<ClInclude Include="src\ctimer.h" />
<ClInclude Include="src\customio.h" />
<ClInclude Include="src\detours.h" />
Expand Down
3 changes: 0 additions & 3 deletions CS2Fixes.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,6 @@
<ClInclude Include="src\commands.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\cdetour.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\ctimer.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ghcr.io/source2ze/build-containers:steamrt3

WORKDIR /app

RUN git clone https://github.com/alliedmodders/metamod-source
RUN git clone --recurse-submodules https://github.com/alliedmodders/metamod-source
RUN git config --global --add safe.directory /app

COPY ./docker-entrypoint.sh ./
Expand Down
4 changes: 2 additions & 2 deletions cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ cs2f_idle_kick_min_players 0 // Minimum amount of connected clients to kick id
cs2f_idle_kick_admins 1 // Whether to kick idle players with ADMFLAG_GENERIC
// Button watch
cs2f_enable_button_watch 0 // INCOMPATIBLE WITH CS#. Whether to enable button watch or not.
cs2f_enable_button_watch 0 // Whether to enable button watch or not.
// EntWatch Settings
entwatch_enable 0 // INCOMPATIBLE WITH CS#. Whether to enable EntWatch features
entwatch_enable 0 // Whether to enable EntWatch features
entwatch_auto_filter 1 // Whether to automatically block non-item holders from triggering uses
entwatch_clantag 1 // Whether to set item holder's clantag and set 9999 score
entwatch_clantag_colour_mode 1 // Whether to set item clantag colours (0=No colour, 1=Use item colour, 2=Use entwatch_clantag_colour value)
Expand Down
3 changes: 2 additions & 1 deletion src/addresses.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023-2026 Source2ZE
Expand Down Expand Up @@ -79,6 +79,7 @@ bool addresses::Initialize(CGameConfig* g_GameConfig)
RESOLVE_SIG(g_GameConfig, "CCSPlayer_WeaponServices_EquipWeapon", addresses::CCSPlayer_WeaponServices_EquipWeapon);
RESOLVE_SIG(g_GameConfig, "GetSpawnGroups", addresses::GetSpawnGroups);
RESOLVE_SIG(g_GameConfig, "CBasePlayerPawn_SnapViewAngles", addresses::CBasePlayerPawn_SnapViewAngles);
RESOLVE_SIG(g_GameConfig, "CBaseEntity_TakeDamageOld", addresses::CBaseEntity_TakeDamageOld);

return InitializeBanMap(g_GameConfig);
}
Expand Down
4 changes: 3 additions & 1 deletion src/addresses.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* =============================================================================
* CS2Fixes
* Copyright (C) 2023-2026 Source2ZE
Expand Down Expand Up @@ -61,6 +61,7 @@ class CBasePlayerWeapon;
class CSpawnGroupMgrGameSystem;
struct EmitSound_t;
struct StartSoundEventInfo;
struct CTakeDamageResult;

// Can't be forward-declared, can't include cgamerules.h.. just define it here
struct CGcBanInformation_t
Expand Down Expand Up @@ -105,6 +106,7 @@ namespace addresses
inline void(FASTCALL* CCSPlayer_WeaponServices_EquipWeapon)(CCSPlayer_WeaponServices* pWeaponServices, CBasePlayerWeapon* pPlayerWeapon);
inline void(FASTCALL* GetSpawnGroups)(CSpawnGroupMgrGameSystem* pSpawnGroupMgr, CUtlVector<SpawnGroupHandle_t>* pList);
inline void(FASTCALL* CBasePlayerPawn_SnapViewAngles)(CBasePlayerPawn* pPawn, QAngle* pAngles);
inline int64(FASTCALL* CBaseEntity_TakeDamageOld)(CBaseEntity* pThis, CTakeDamageInfo* pInfo, CTakeDamageResult* pResult);

inline CVScriptFunction<void, CBaseEntity, float> SetGravityScale;
inline CVScriptFunction<void, CBaseEntity, const char*> ScriptSetEntityName;
Expand Down
23 changes: 3 additions & 20 deletions src/buttonwatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,11 @@
#include "entity/clogiccase.h"
#include "entity/cpointviewcontrol.h"

CConVar<bool> g_cvarEnableButtonWatch(
"cs2f_enable_button_watch", FCVAR_NONE, "INCOMPATIBLE WITH CS#. Whether to enable button watch or not.", false,
[](CConVar<bool>* cvar, CSplitScreenSlot slot, const bool* new_val, const bool* old_val) {
if (!(*new_val) || !SetupFireOutputInternalDetour())
{
mapIOFunctions.erase("buttonwatch");
cvar->Set(false);
}
else if (!IsButtonWatchEnabled())
mapIOFunctions["buttonwatch"] = ButtonWatch;
});
CConVar<bool> g_cvarEnableButtonWatch("cs2f_enable_button_watch", FCVAR_NONE, "Whether to enable button watch or not.", false);

CON_COMMAND_CHAT_FLAGS(bw, "- Toggle button watch display", ADMFLAG_GENERIC)
{
if (!IsButtonWatchEnabled())
if (!g_cvarEnableButtonWatch.Get())
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Button watch is disabled on this server.");
return;
Expand Down Expand Up @@ -84,17 +74,10 @@ CON_COMMAND_CHAT_FLAGS(bw, "- Toggle button watch display", ADMFLAG_GENERIC)
}
}

bool IsButtonWatchEnabled()
{
return std::any_of(mapIOFunctions.begin(), mapIOFunctions.end(), [](const auto& p) {
return p.first == "buttonwatch";
});
}

std::map<int, bool> mapRecentEnts;
void ButtonWatch(const CEntityIOOutput* pThis, CEntityInstance* pActivator, CEntityInstance* pCaller, const CVariant* value, float flDelay)
{
if (!IsButtonWatchEnabled() || !GetGlobals() || V_stricmp(pThis->m_pDesc->m_pName, "OnPressed") || !pActivator || !((CBaseEntity*)pActivator)->IsPawn() || !pCaller || mapRecentEnts.contains(pCaller->GetEntityIndex().Get()))
if (!GetGlobals() || V_stricmp(pThis->m_pDesc->m_pName, "OnPressed") || !pActivator || !((CBaseEntity*)pActivator)->IsPawn() || !pCaller || mapRecentEnts.contains(pCaller->GetEntityIndex().Get()))
return;

CCSPlayerController* ccsPlayer = CCSPlayerController::FromPawn(static_cast<CCSPlayerPawn*>(pActivator));
Expand Down
3 changes: 2 additions & 1 deletion src/buttonwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
#pragma once
#include "detours.h"

bool IsButtonWatchEnabled();
extern CConVar<bool> g_cvarEnableButtonWatch;

void ButtonWatch(const CEntityIOOutput* pThis, CEntityInstance* pActivator, CEntityInstance* pCaller, const CVariant* value, float flDelay);
153 changes: 0 additions & 153 deletions src/cdetour.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/cs2_sdk/entity/cbaseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class CBaseEntity : public CEntityInstance

void TakeDamage(CTakeDamageInfo& info)
{
Detour_CBaseEntity_TakeDamageOld(this, &info, 0);
addresses::CBaseEntity_TakeDamageOld(this, &info, 0);
}

void Teleport(const Vector* pPosition, const QAngle* pAngles, const Vector* pVelocity)
Expand Down
Loading