Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
d0664a8
Remove SourceHook from core
Kenzzer Aug 17, 2025
b588c68
Remove CDetour
Kenzzer Aug 17, 2025
a71be66
Add guard rails around Recalls
Kenzzer Aug 17, 2025
0046842
Fix compilation
Kenzzer Aug 17, 2025
baa471b
Strip sourcehook from bintools
Kenzzer Aug 17, 2025
24bc3e3
Strip sourcehook from clientprefs
Kenzzer Aug 17, 2025
24c2f16
Strip sourcehook from PGSQL
Kenzzer Aug 17, 2025
a272529
Strip sourcehook from SQLite
Kenzzer Aug 17, 2025
b4b3753
Strip sourcehook from Regex
Kenzzer Aug 17, 2025
a377ba8
Strip sourcehook from Updater
Kenzzer Aug 17, 2025
e37950a
Re-enable compilation for GeoIP & Curl
Kenzzer Aug 17, 2025
51fd546
Strip sourcehook from SDKHooks
Kenzzer Aug 18, 2025
b485ff5
Remove Safetyhook(CDetour)
Kenzzer Aug 18, 2025
7238320
Strip sourcehook from SDKTools Part 1
Kenzzer Aug 18, 2025
363c231
Strip sourcehook from SDKTools
Kenzzer Aug 19, 2025
dbb5c81
Remove unnecessary includes to SDKTools
Kenzzer Aug 19, 2025
25dd83c
Blow up dhooks
Kenzzer Aug 19, 2025
67c850c
Begin re-impl of dhooks
Kenzzer Sep 18, 2025
f9f1cad
Implement basic callback logic
Kenzzer Sep 18, 2025
dee1f2d
Add recall support
Kenzzer Sep 19, 2025
54f5d8a
Implem DHookReturn
Kenzzer Sep 19, 2025
147ca23
Finish DHookParam implem
Kenzzer Sep 19, 2025
d3a685b
Move dhookparam/return natives to its own file
Kenzzer Sep 19, 2025
c9be6a8
Add gamedata parser
Kenzzer Sep 28, 2025
40144ec
use the new khook functions
Kenzzer Feb 1, 2026
d67e684
Add/update dhook handles
Kenzzer Feb 1, 2026
e9fde4e
Reconcile with master rebase
Kenzzer Feb 1, 2026
e3f578f
Progress towards DynamicDetour
Kenzzer Feb 3, 2026
2bd38d8
Start work on DynamicDetour.Enable
Kenzzer Feb 5, 2026
0e14e16
Finalise DynamicDetour natives
Kenzzer Feb 7, 2026
c15f6ce
Define remaining undefined symbols
Kenzzer Feb 21, 2026
84f4d5a
Add missing functions to bintools
Kenzzer Feb 24, 2026
3442c5b
Strip SourceHook from topmenus
Kenzzer Feb 24, 2026
30a358a
Fix dhooks loading
Kenzzer Feb 24, 2026
a1651ae
Strip SourceHook from game.tf2
Kenzzer Feb 25, 2026
1ff9de0
Update metamod dependency for CI
Kenzzer Feb 26, 2026
9e24ed7
Fix invalid hook name on CSS/CSGO
Kenzzer Feb 26, 2026
5b8e112
Fix initialising order
Kenzzer Feb 25, 2026
b8cdcb6
Fix wrong vtable offset calculation in bintools
Kenzzer Mar 1, 2026
09bbd38
Default init addr to nullptr
Kenzzer Mar 1, 2026
80cf2a6
Fix SDKHooks not fireing
Kenzzer Mar 1, 2026
c4313c7
Enable dhooks natives
Kenzzer Mar 1, 2026
8414644
Fix this ptr crash in Dynamic Detour & make call original
Kenzzer Mar 1, 2026
26a91ca
Update hl2sdk-manifests
Kenzzer Mar 7, 2026
33bed17
Start implementing DynamicHook natives
Kenzzer Mar 7, 2026
63c0702
Limit dhooks compilation to linux x64 for now
Kenzzer Mar 7, 2026
0d4cda3
Fix var name error in PlayerManager.cpp
Kenzzer Mar 7, 2026
2dc1122
Remove detour callbacks on dynamicdetour deletion
Kenzzer Mar 7, 2026
87c8a63
Finalise DynamicHook natives
Kenzzer Mar 7, 2026
7e8bdca
DHooks: Add support for void return on System V x64
Kenzzer Mar 9, 2026
e3e6dd0
DHooks: Allow registration of DynamicHooks
Kenzzer Mar 9, 2026
a4d9bfb
DHooks: Add automatic virtual hook cleanup
Kenzzer Mar 9, 2026
d2452fc
DHooks: Skip some unnecessary steps in hook cleanup
Kenzzer Mar 9, 2026
07ee724
Make checkout-deps update submodules if they exist
Kenzzer Mar 11, 2026
d52399a
Update with latest khook changes
Kenzzer Mar 11, 2026
d9fe3b4
Make mock compile against khook branch of metamod
Kenzzer Mar 11, 2026
9177d4e
Correct hook function name for pre-orangebox games
Kenzzer Mar 11, 2026
32698d4
Correct SDKHooks::Hook_GetGameDescription
Kenzzer Mar 11, 2026
0ff0e5d
Strip remaining of sourcehook
Kenzzer Mar 12, 2026
cf9eae4
Fix compilation for l4d2 & csgo
Kenzzer Mar 12, 2026
e7e7f7e
Fix incorrect dhook callback removal
Kenzzer Mar 14, 2026
c348db4
Push int64 Address under dhook callbacks
Kenzzer Mar 15, 2026
0a8a04e
Fix DHookReturnParam handle leaking
Kenzzer Apr 11, 2026
94a424a
Fix invalid DHookParam.IsNull
Kenzzer Apr 11, 2026
e3fff3a
Remove global hook destroyal logic from SDKHooks
Kenzzer Apr 11, 2026
9abedf7
Fixup FireOutput detour for windows
Kenzzer Apr 11, 2026
fbd42c3
Upload artifacts of release
Kenzzer Apr 11, 2026
c6fba84
DHooks: Feature dtor hook cleanup
Kenzzer Apr 12, 2026
b97d0d6
Update sdktools gamedata
Kenzzer May 6, 2026
bf8950c
Remove more instances of SourceHook::List
Kenzzer May 6, 2026
871a86b
Adapt code to latest khook changes
Kenzzer Jun 21, 2026
cf52bc8
Adapt code to latest khook changes
Kenzzer Jun 21, 2026
bdf281c
Fix up DHooks, SDKHooks & SDKTools on KHook (#2492)
Mikusch Jun 24, 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@v6
name: Clone sourcemod
with:
submodules: recursive
path: sourcemod

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

- uses: actions/checkout@v6
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@v6
name: Clone sourcemod
with:
submodules: recursive
path: sourcemod

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

- uses: actions/checkout@v6
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@v6
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 @@ -506,6 +505,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 @@ -524,29 +528,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 @@ -600,16 +588,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 @@ -672,10 +650,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