Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
5c660d4
Remove SourceHook from core
Kenzzer Aug 17, 2025
5b328cd
Remove CDetour
Kenzzer Aug 17, 2025
8eaf645
Add guard rails around Recalls
Kenzzer Aug 17, 2025
dd12e08
Fix compilation
Kenzzer Aug 17, 2025
6600e40
Strip sourcehook from bintools
Kenzzer Aug 17, 2025
2830daf
Strip sourcehook from clientprefs
Kenzzer Aug 17, 2025
a7a0007
Strip sourcehook from PGSQL
Kenzzer Aug 17, 2025
17b6dc8
Strip sourcehook from SQLite
Kenzzer Aug 17, 2025
103d355
Strip sourcehook from Regex
Kenzzer Aug 17, 2025
b3d7fd9
Strip sourcehook from Updater
Kenzzer Aug 17, 2025
18117b6
Re-enable compilation for GeoIP & Curl
Kenzzer Aug 17, 2025
b04d9e0
Strip sourcehook from SDKHooks
Kenzzer Aug 18, 2025
b667ca6
Remove Safetyhook(CDetour)
Kenzzer Aug 18, 2025
c023952
Strip sourcehook from SDKTools Part 1
Kenzzer Aug 18, 2025
0a00d23
Strip sourcehook from SDKTools
Kenzzer Aug 19, 2025
90c3a34
Remove unnecessary includes to SDKTools
Kenzzer Aug 19, 2025
288b9c0
Blow up dhooks
Kenzzer Aug 19, 2025
04bd672
Begin re-impl of dhooks
Kenzzer Sep 18, 2025
8326ec2
Implement basic callback logic
Kenzzer Sep 18, 2025
697921f
Add recall support
Kenzzer Sep 19, 2025
5ec93f9
Implem DHookReturn
Kenzzer Sep 19, 2025
827bf59
Finish DHookParam implem
Kenzzer Sep 19, 2025
5560224
Move dhookparam/return natives to its own file
Kenzzer Sep 19, 2025
c5a8538
Add gamedata parser
Kenzzer Sep 28, 2025
66e162c
use the new khook functions
Kenzzer Feb 1, 2026
a89655b
Add/update dhook handles
Kenzzer Feb 1, 2026
fb3e6e5
Reconcile with master rebase
Kenzzer Feb 1, 2026
312f58e
Progress towards DynamicDetour
Kenzzer Feb 3, 2026
77b2755
Start work on DynamicDetour.Enable
Kenzzer Feb 5, 2026
2119f5c
Finalise DynamicDetour natives
Kenzzer Feb 7, 2026
1004410
Define remaining undefined symbols
Kenzzer Feb 21, 2026
f56054c
Add missing functions to bintools
Kenzzer Feb 24, 2026
7397b78
Strip SourceHook from topmenus
Kenzzer Feb 24, 2026
f74ed35
Fix dhooks loading
Kenzzer Feb 24, 2026
fc0f87b
Strip SourceHook from game.tf2
Kenzzer Feb 25, 2026
3af6b0d
Update metamod dependency for CI
Kenzzer Feb 26, 2026
0b9206c
Fix invalid hook name on CSS/CSGO
Kenzzer Feb 26, 2026
f3abc9c
Fix initialising order
Kenzzer Feb 25, 2026
dac62af
Fix wrong vtable offset calculation in bintools
Kenzzer Mar 1, 2026
49d22ad
Default init addr to nullptr
Kenzzer Mar 1, 2026
940533b
Fix SDKHooks not fireing
Kenzzer Mar 1, 2026
e1df48a
Enable dhooks natives
Kenzzer Mar 1, 2026
39270d2
Fix this ptr crash in Dynamic Detour & make call original
Kenzzer Mar 1, 2026
9b13a7f
Start implementing DynamicHook natives
Kenzzer Mar 7, 2026
7f753cb
Limit dhooks compilation to linux x64 for now
Kenzzer Mar 7, 2026
7dd8ca8
Fix var name error in PlayerManager.cpp
Kenzzer Mar 7, 2026
07d1f54
Remove detour callbacks on dynamicdetour deletion
Kenzzer Mar 7, 2026
d0cf015
Finalise DynamicHook natives
Kenzzer Mar 7, 2026
e5fe730
DHooks: Add support for void return on System V x64
Kenzzer Mar 9, 2026
a5497d0
DHooks: Allow registration of DynamicHooks
Kenzzer Mar 9, 2026
463ea5e
DHooks: Add automatic virtual hook cleanup
Kenzzer Mar 9, 2026
5361cd8
DHooks: Skip some unnecessary steps in hook cleanup
Kenzzer Mar 9, 2026
306bc82
Make checkout-deps update submodules if they exist
Kenzzer Mar 11, 2026
a638744
Update with latest khook changes
Kenzzer Mar 11, 2026
c06ba64
Make mock compile against khook branch of metamod
Kenzzer Mar 11, 2026
4caabb1
Correct hook function name for pre-orangebox games
Kenzzer Mar 11, 2026
4356902
Correct SDKHooks::Hook_GetGameDescription
Kenzzer Mar 11, 2026
cff4b0a
Strip remaining of sourcehook
Kenzzer Mar 12, 2026
245b400
Fix compilation for l4d2 & csgo
Kenzzer Mar 12, 2026
3e74773
Fix incorrect dhook callback removal
Kenzzer Mar 14, 2026
64f0079
Push int64 Address under dhook callbacks
Kenzzer Mar 15, 2026
56544a4
Fix DHookReturnParam handle leaking
Kenzzer Apr 11, 2026
c81b0ab
Fix invalid DHookParam.IsNull
Kenzzer Apr 11, 2026
ed98d30
Remove global hook destroyal logic from SDKHooks
Kenzzer Apr 11, 2026
c7483b5
Fixup FireOutput detour for windows
Kenzzer Apr 11, 2026
0ddf9e4
Upload artifacts of release
Kenzzer Apr 11, 2026
8fa1e51
DHooks: Feature dtor hook cleanup
Kenzzer Apr 12, 2026
84ad792
Update sdktools gamedata
Kenzzer May 6, 2026
51d3ef7
Remove more instances of SourceHook::List
Kenzzer May 6, 2026
b2c40a2
Adapt code to latest khook changes
Kenzzer Jun 21, 2026
ccb6860
Adapt code to latest khook changes
Kenzzer Jun 21, 2026
4a2e554
Fix up DHooks, SDKHooks & SDKTools on KHook (#2492)
Mikusch Jun 24, 2026
980a63c
Fix crash reading return value in superseded callbacks (#2496)
Mikusch Jul 1, 2026
8d7a691
Fix wrong read of Address this pointer (#2499)
Mikusch Jul 4, 2026
e0443ea
Add CGameRules cleanup
Kenzzer Jul 5, 2026
020dc1e
DHooks: Hook CWorld::~CWorld for gamerules hook cleanup
Kenzzer Jul 5, 2026
b17e00b
Remove unnecessary context
Kenzzer Jul 5, 2026
2d763a2
Remove dhooks bandaid from master rebase
Kenzzer Jul 5, 2026
bc43ca6
Update dhooks.inc
Kenzzer Jul 5, 2026
ee8e444
DHooks: Add DHookAddEntityListener/DHookRemoveEntityListener
Kenzzer Jul 6, 2026
3f59a93
Make sdkhooks synchronous
Kenzzer Jul 10, 2026
be702bc
Fix crash under DHookParam_GetParamObjectPtrString
Kenzzer Jul 11, 2026
dca592f
DHooks: Fix outdated globals::cell_to_ptr def
Kenzzer Jul 11, 2026
77ec55f
Fix crash when a vtable hook only sets a pre or post callback
Mikusch Jul 13, 2026
6b189d8
Remove unnecessary hook for css/csgo
Kenzzer Jul 13, 2026
76d0d1a
Fix "no active hook" false report (#2507)
Mikusch Jul 13, 2026
1fc8960
Refactor sdkhooks callback loops (#2513)
Mikusch Aug 3, 2026
5f97261
Make use of std::unique_ptr for hooks list
Kenzzer Aug 3, 2026
7d663a2
Correct KeyValuesFromAddress from rebase
Kenzzer Aug 3, 2026
274f4f9
Correct PlayerManager::OnNetworkIDValidated from rebase
Kenzzer Aug 3, 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
193 changes: 97 additions & 96 deletions .github/workflows/mocktest.yml
Original file line number Diff line number Diff line change
@@ -1,96 +1,97 @@
name: hl2sdk-mock tests
on:
push:
branches:
- master
- '[0-9]+.[0-9]+-dev'
pull_request:
branches:
- master
- '[0-9]+.[0-9]+-dev'
jobs:
mock:
runs-on: ubuntu-latest
container:
image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
steps:
- uses: actions/checkout@v7
name: Clone sourcemod
with:
submodules: recursive
path: sourcemod

- uses: actions/checkout@v7
name: Clone metamod-source
with:
repository: alliedmodders/metamod-source
submodules: recursive
path: metamod-source

- uses: actions/checkout@v7
name: Clone hl2sdk-mock
with:
repository: alliedmodders/hl2sdk-mock
submodules: recursive
path: hl2sdk-mock

- name: Build MetaMod:Source
working-directory: metamod-source
run: |
python3 configure.py --enable-optimize --sdks=mock --targets=x86_64
ambuild objdir

- name: Build SourceMod
working-directory: sourcemod
run: |
python3 configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86_64
ambuild objdir

- name: Build hl2sdk-mock
working-directory: hl2sdk-mock
run: |
python3 configure.py --enable-optimize --targets=x86_64
ambuild objdir

- name: Setup gamedir
working-directory: hl2sdk-mock
shell: bash
run: |
mkdir ../gamedir
./build_gamedir.sh ../gamedir ../metamod-source/objdir/package
./build_gamedir.sh ../gamedir ../sourcemod/objdir/package

- name: Compile testsuite
working-directory: hl2sdk-mock
shell: bash
run: |
mkdir ../gamedir/addons/sourcemod/plugins/optional

for f in ../sourcemod/plugins/testsuite/mock/*.sp; do
echo "Compiling $(basename $f)"
../gamedir/addons/sourcemod/scripting/spcomp64 -i ../gamedir/addons/sourcemod/scripting/include -o "../gamedir/addons/sourcemod/plugins/optional/$(basename $f .sp).smx" -E "$f"
done

- name: Test
working-directory: hl2sdk-mock
shell: bash
run: |
for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do
echo "==================================="
echo "Running $(basename $f)..."
echo "==================================="
timeout 60 ./objdir/dist/x86_64/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 |
{
failed=0
while IFS= read -r line; do
echo "$line"
if [[ "$line" == *"FAIL"* ]]; then
failed=1
fi
done
if [ "$failed" = "1" ]; then
echo "$(basename $f) failed."
exit 1
fi
}
done
name: hl2sdk-mock tests
on:
push:
branches:
- master
- '[0-9]+.[0-9]+-dev'
pull_request:
branches:
- master
- '[0-9]+.[0-9]+-dev'
jobs:
mock:
runs-on: ubuntu-latest
container:
image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
steps:
- uses: actions/checkout@v7
name: Clone sourcemod
with:
submodules: recursive
path: sourcemod

- uses: actions/checkout@v7
name: Clone metamod-source
with:
repository: alliedmodders/metamod-source
ref: k/sourcehook_alternative
submodules: recursive
path: metamod-source

- uses: actions/checkout@v7
name: Clone hl2sdk-mock
with:
repository: alliedmodders/hl2sdk-mock
submodules: recursive
path: hl2sdk-mock

- name: Build MetaMod:Source
working-directory: metamod-source
run: |
python3 configure.py --enable-optimize --sdks=mock --targets=x86_64
ambuild objdir

- name: Build SourceMod
working-directory: sourcemod
run: |
python3 configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86_64
ambuild objdir

- name: Build hl2sdk-mock
working-directory: hl2sdk-mock
run: |
python3 configure.py --enable-optimize --targets=x86_64
ambuild objdir

- name: Setup gamedir
working-directory: hl2sdk-mock
shell: bash
run: |
mkdir ../gamedir
./build_gamedir.sh ../gamedir ../metamod-source/objdir/package
./build_gamedir.sh ../gamedir ../sourcemod/objdir/package

- name: Compile testsuite
working-directory: hl2sdk-mock
shell: bash
run: |
mkdir ../gamedir/addons/sourcemod/plugins/optional

for f in ../sourcemod/plugins/testsuite/mock/*.sp; do
echo "Compiling $(basename $f)"
../gamedir/addons/sourcemod/scripting/spcomp64 -i ../gamedir/addons/sourcemod/scripting/include -o "../gamedir/addons/sourcemod/plugins/optional/$(basename $f .sp).smx" -E "$f"
done

- name: Test
working-directory: hl2sdk-mock
shell: bash
run: |
for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do
echo "==================================="
echo "Running $(basename $f)..."
echo "==================================="
timeout 60 ./objdir/dist/x86_64/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 |
{
failed=0
while IFS= read -r line; do
echo "$line"
if [[ "$line" == *"FAIL"* ]]; then
failed=1
fi
done
if [ "$failed" = "1" ]; then
echo "$(basename $f) failed."
exit 1
fi
}
done
8 changes: 7 additions & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
SDKS: '["episode1","css","tf2","l4d2","csgo","dods"]'
ARCH: x86,x86_64
MYSQL_VERSION: '5.7'
MMSOURCE_VERSION: '1.12'
MMSOURCE_VERSION: '2.0'
steps:
- uses: actions/checkout@v7
with:
Expand Down Expand Up @@ -81,3 +81,9 @@ jobs:
'--mysql-path=${{ steps.path_helper.outputs.dependencies }}/mysql-${{ env.MYSQL_VERSION }}' \
'--mysql64-path=${{ steps.path_helper.outputs.dependencies }}/mysql-${{ env.MYSQL_VERSION }}-x86_64'
ambuild

- name: Upload artifact
uses: actions/upload-artifact@v7
with:
path: sourcemod/build/package
name: ${{ matrix.os_short }}-${{ matrix.compiler_cc }}
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
[submodule "hl2sdk-manifests"]
path = hl2sdk-manifests
url = https://github.com/alliedmodders/hl2sdk-manifests.git
[submodule "public/safetyhook"]
path = public/safetyhook
url = https://github.com/alliedmodders/safetyhook
[submodule "core/logic/libaddrz"]
path = core/logic/libaddrz
url = https://github.com/dvander/libaddrz.git
38 changes: 8 additions & 30 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class SMConfig(object):
self.target_archs = set()
self.enable_asan = getattr(builder.options, 'enable_asan', False)
self.asan_libs = {}
self.libsafetyhook = {}

if builder.options.targets:
target_archs = builder.options.targets.split(',')
Expand Down Expand Up @@ -127,7 +126,7 @@ class SMConfig(object):
if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12')
self.mms_root = ResolveEnvPath('MMSOURCE200', 'mmsource-2.0')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE', 'metamod-source')
if not self.mms_root:
Expand Down Expand Up @@ -516,6 +515,11 @@ class SMConfig(object):
os.path.join(builder.sourcePath, 'public', 'amtl', 'amtl'),
os.path.join(builder.sourcePath, 'public', 'amtl'),
]

compiler.cxxincludes += [
os.path.join(self.mms_root, 'core'),
os.path.join(self.mms_root, 'third_party', 'khook', 'include'),
]
return compiler

def ExtLibrary(self, context, compiler, name):
Expand All @@ -534,29 +538,13 @@ class SMConfig(object):
compiler = binary.compiler
SetArchFlags(compiler)

compiler.cxxincludes += [
os.path.join(self.mms_root, 'core'),
os.path.join(self.mms_root, 'core', 'sourcehook'),
]

for other_sdk in self.sdk_manifests:
compiler.defines += ['SE_{}={}'.format(other_sdk['define'], other_sdk['code'])]

SdkHelpers.configureCxx(context, binary, sdk)

return binary

def AddCDetour(self, binary):
public_path = os.path.join(builder.sourcePath, 'public')
binary.sources += [ os.path.join(public_path, 'CDetour', 'detours.cpp') ]
binary.compiler.cxxincludes += [ os.path.join(public_path, 'safetyhook', 'include') ]

for task in self.libsafetyhook:
if task.target.arch == binary.compiler.target.arch:
binary.compiler.linkflags += [task.binary]
return
raise Exception('No suitable build of safetyhook was found.')

def HL2Library(self, context, compiler, name, sdk):
binary = self.Library(context, compiler, name)
self.ConfigureForExtension(context, binary.compiler)
Expand Down Expand Up @@ -609,16 +597,6 @@ if SM.use_auto_versioning():
{ 'SM': SM }
)

class SafetyHookShim(object):
def __init__(self):
self.all_targets = {}
self.libsafetyhook = {}

SafetyHook = SafetyHookShim()
SafetyHook.all_targets = SM.all_targets
builder.Build('public/safetyhook/AMBuilder', {'SafetyHook': SafetyHook })
SM.libsafetyhook = SafetyHook.libsafetyhook

class SPRoot(object):
def __init__(self):
self.generated_headers = SM.generated_headers
Expand Down Expand Up @@ -681,10 +659,10 @@ else:
'extensions/bintools/AMBuilder',
'extensions/clientprefs/AMBuilder',
'extensions/curl/AMBuilder',
'extensions/cstrike/AMBuilder',
#'extensions/cstrike/AMBuilder',
'extensions/dhooks/AMBuilder',
'extensions/geoip/AMBuilder',
'extensions/mysql/AMBuilder',
#'extensions/mysql/AMBuilder',
'extensions/pgsql/AMBuilder',
'extensions/regex/AMBuilder',
'extensions/sdkhooks/AMBuilder',
Expand Down
11 changes: 5 additions & 6 deletions bridge/include/IExtensionBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@

#include <sp_vm_api.h>
#include <IExtensionSys.h>
#include <sh_vector.h>
#include <vector>

struct edict_t;

namespace SourceMod {

using namespace SourceHook;
using namespace SourcePawn;
class SMPlugin;

Expand All @@ -51,8 +50,8 @@ class IExtensionSys : public IExtensionManager
virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0;
virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0;
virtual const CVector<IExtension *> *ListExtensions() = 0;
virtual void FreeExtensionList(const CVector<IExtension *> *list) = 0;
virtual const std::vector<IExtension *> *ListExtensions() = 0;
virtual void FreeExtensionList(const std::vector<IExtension *> *list) = 0;
virtual void CallOnCoreMapEnd() = 0;
};

Expand All @@ -67,13 +66,13 @@ class AutoExtensionList
{
extensions_->FreeExtensionList(list_);
}
const CVector<IExtension *> *operator ->()
const std::vector<IExtension *> *operator ->()
{
return list_;
}
private:
IExtensionSys *extensions_;
const CVector<IExtension *> *list_;
const std::vector<IExtension *> *list_;
};

} // namespace SourceMod
Expand Down
Loading
Loading