Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a67c32c
Remove SourceHook from core
Kenzzer Aug 17, 2025
a90d0e0
Remove CDetour
Kenzzer Aug 17, 2025
34dde0c
Add guard rails around Recalls
Kenzzer Aug 17, 2025
8a1d1cc
Fix compilation
Kenzzer Aug 17, 2025
e6fe961
Strip sourcehook from bintools
Kenzzer Aug 17, 2025
f8f9d1d
Strip sourcehook from clientprefs
Kenzzer Aug 17, 2025
e5f8fbd
Strip sourcehook from PGSQL
Kenzzer Aug 17, 2025
c7beadf
Strip sourcehook from SQLite
Kenzzer Aug 17, 2025
d47c9ba
Strip sourcehook from Regex
Kenzzer Aug 17, 2025
1902b21
Strip sourcehook from Updater
Kenzzer Aug 17, 2025
230d767
Re-enable compilation for GeoIP & Curl
Kenzzer Aug 17, 2025
d2c9271
Strip sourcehook from SDKHooks
Kenzzer Aug 18, 2025
256effc
Remove Safetyhook(CDetour)
Kenzzer Aug 18, 2025
00ac976
Strip sourcehook from SDKTools Part 1
Kenzzer Aug 18, 2025
4593848
Strip sourcehook from SDKTools
Kenzzer Aug 19, 2025
ed5d81d
Remove unnecessary includes to SDKTools
Kenzzer Aug 19, 2025
9eb326f
Blow up dhooks
Kenzzer Aug 19, 2025
6aa5b6a
Begin re-impl of dhooks
Kenzzer Sep 18, 2025
caab97a
Implement basic callback logic
Kenzzer Sep 18, 2025
73c0861
Add recall support
Kenzzer Sep 19, 2025
4dd68c6
Implem DHookReturn
Kenzzer Sep 19, 2025
3feb150
Finish DHookParam implem
Kenzzer Sep 19, 2025
c4151d3
Move dhookparam/return natives to its own file
Kenzzer Sep 19, 2025
980dd3b
Add gamedata parser
Kenzzer Sep 28, 2025
6cc99d4
use the new khook functions
Kenzzer Feb 1, 2026
f63cee6
Add/update dhook handles
Kenzzer Feb 1, 2026
13b9f7d
Reconcile with master rebase
Kenzzer Feb 1, 2026
637dfdb
Progress towards DynamicDetour
Kenzzer Feb 3, 2026
80e5140
Start work on DynamicDetour.Enable
Kenzzer Feb 5, 2026
217aef8
Finalise DynamicDetour natives
Kenzzer Feb 7, 2026
080b851
Define remaining undefined symbols
Kenzzer Feb 21, 2026
52d5e24
Add missing functions to bintools
Kenzzer Feb 24, 2026
322b566
Strip SourceHook from topmenus
Kenzzer Feb 24, 2026
6e7ce2d
Fix dhooks loading
Kenzzer Feb 24, 2026
333ccb5
Strip SourceHook from game.tf2
Kenzzer Feb 25, 2026
673456d
Update metamod dependency for CI
Kenzzer Feb 26, 2026
c4c8d40
Fix invalid hook name on CSS/CSGO
Kenzzer Feb 26, 2026
d2f38d0
Fix initialising order
Kenzzer Feb 25, 2026
a5b4d96
Fix wrong vtable offset calculation in bintools
Kenzzer Mar 1, 2026
e3be9ca
Default init addr to nullptr
Kenzzer Mar 1, 2026
f970d6f
Fix SDKHooks not fireing
Kenzzer Mar 1, 2026
817c605
Enable dhooks natives
Kenzzer Mar 1, 2026
2a9556f
Fix this ptr crash in Dynamic Detour & make call original
Kenzzer Mar 1, 2026
b94eb48
Update hl2sdk-manifests
Kenzzer Mar 7, 2026
89445c5
Start implementing DynamicHook natives
Kenzzer Mar 7, 2026
48dcbfe
Limit dhooks compilation to linux x64 for now
Kenzzer Mar 7, 2026
d6c0317
Fix var name error in PlayerManager.cpp
Kenzzer Mar 7, 2026
674aa7e
Remove detour callbacks on dynamicdetour deletion
Kenzzer Mar 7, 2026
d421a22
Finalise DynamicHook natives
Kenzzer Mar 7, 2026
23f56f4
DHooks: Add support for void return on System V x64
Kenzzer Mar 9, 2026
ac4ad97
DHooks: Allow registration of DynamicHooks
Kenzzer Mar 9, 2026
aee6631
DHooks: Add automatic virtual hook cleanup
Kenzzer Mar 9, 2026
3024bfa
DHooks: Skip some unnecessary steps in hook cleanup
Kenzzer Mar 9, 2026
d81207f
Make checkout-deps update submodules if they exist
Kenzzer Mar 11, 2026
2759a59
Update with latest khook changes
Kenzzer Mar 11, 2026
11ad1e1
Make mock compile against khook branch of metamod
Kenzzer Mar 11, 2026
2b0843a
Correct hook function name for pre-orangebox games
Kenzzer Mar 11, 2026
9d1f2f9
Correct SDKHooks::Hook_GetGameDescription
Kenzzer Mar 11, 2026
fda2087
Strip remaining of sourcehook
Kenzzer Mar 12, 2026
9bf818f
Fix compilation for l4d2 & csgo
Kenzzer Mar 12, 2026
a086f60
Fix incorrect dhook callback removal
Kenzzer Mar 14, 2026
92b10b4
Push int64 Address under dhook callbacks
Kenzzer Mar 15, 2026
bf99e26
Fix DHookReturnParam handle leaking
Kenzzer Apr 11, 2026
d0d342a
Fix invalid DHookParam.IsNull
Kenzzer Apr 11, 2026
160f0da
Remove global hook destroyal logic from SDKHooks
Kenzzer Apr 11, 2026
0130fae
Fixup FireOutput detour for windows
Kenzzer Apr 11, 2026
6332514
Upload artifacts of release
Kenzzer Apr 11, 2026
ef3a114
DHooks: Feature dtor hook cleanup
Kenzzer Apr 12, 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
1 change: 1 addition & 0 deletions .github/workflows/mocktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
name: Clone metamod-source
with:
repository: alliedmodders/metamod-source
ref: k/sourcehook_alternative
submodules: recursive
path: metamod-source

Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
DEPENDENCIES_FOLDER: dependencies
DEPENDENCIES_ROOT: ${{ github.workspace }}/dependencies
MYSQL_VERSION: '5.7'
MMSOURCE_VERSION: '1.12'
MMSOURCE_VERSION: '2.0'
steps:
- uses: actions/checkout@v6
with:
Expand Down Expand Up @@ -96,3 +96,9 @@ jobs:
cd build
python ../configure.py --enable-optimize --sdks=${{ join(fromJSON(env.SDKS)) }} --targets=${{ env.ARCH }} --mms-path=${{ env.DEPENDENCIES_ROOT }}/mmsource-${{ env.MMSOURCE_VERSION }} --hl2sdk-root=${{ env.DEPENDENCIES_ROOT }} --mysql-path=${{ env.DEPENDENCIES_ROOT }}/mysql-${{ env.MYSQL_VERSION }} --mysql64-path=${{ env.DEPENDENCIES_ROOT }}/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 @@ -55,7 +55,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 @@ -128,7 +127,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 @@ -499,6 +498,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 @@ -517,29 +521,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 @@ -588,16 +576,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 @@ -666,10 +644,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
17 changes: 8 additions & 9 deletions bridge/include/IScriptManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@

#include <sp_vm_api.h>
#include <IPluginSys.h>
#include <sh_vector.h>
#include <sh_string.h>
#include <vector>
#include <string>

namespace SourceMod {

using namespace SourceHook;
using namespace SourcePawn;

class IChangeableForward;
Expand All @@ -47,8 +46,8 @@ enum LibraryAction

struct AutoConfig
{
SourceHook::String autocfg;
SourceHook::String folder;
std::string autocfg;
std::string folder;
bool create;
};

Expand Down Expand Up @@ -82,8 +81,8 @@ class IScriptManager
virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0;
virtual bool UnloadPlugin(IPlugin *plugin) = 0;
virtual const CVector<SMPlugin *> *ListPlugins() = 0;
virtual void FreePluginList(const CVector<SMPlugin *> *list) = 0;
virtual const std::vector<SMPlugin *> *ListPlugins() = 0;
virtual void FreePluginList(const std::vector<SMPlugin *> *list) = 0;
virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0;
};

Expand All @@ -98,13 +97,13 @@ class AutoPluginList
{
scripts_->FreePluginList(list_);
}
const CVector<SMPlugin *> *operator ->()
const std::vector<SMPlugin *> *operator ->()
{
return list_;
}
private:
IScriptManager *scripts_;
const CVector<SMPlugin *> *list_;
const std::vector<SMPlugin *> *list_;
};

} // namespace SourceMod
Expand Down
2 changes: 1 addition & 1 deletion core/ConCmdManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void RegisterInPlugin(CmdHook *hook)

void ConCmdManager::AddToCmdList(ConCmdInfo *info)
{
List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
auto iter = m_CmdList.begin();
ConCmdInfo *pInfo;
bool inserted = false;
const char *orig = NULL;
Expand Down
10 changes: 4 additions & 6 deletions core/ConCmdManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@
#include "sm_globals.h"
#include "sourcemm_api.h"
#include <IForwardSys.h>
#include <sh_list.h>
#include <sh_string.h>
#include <list>
#include <string>
#include <IRootConsoleMenu.h>
#include <IAdminSystem.h>
#include "concmd_cleaner.h"
#include "GameHooks.h"
#include <sm_namehashset.h>

using namespace SourceHook;

struct CmdHook;
struct ConCmdInfo;

Expand Down Expand Up @@ -137,7 +135,7 @@ struct ConCmdInfo
};
};

typedef List<ConCmdInfo *> ConCmdList;
typedef std::list<ConCmdInfo *> ConCmdList;

class ConCmdManager :
public SMGlobalClass,
Expand Down Expand Up @@ -180,7 +178,7 @@ class ConCmdManager :
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
ConCmdInfo *FindInTrie(const char *name);
public:
inline const List<ConCmdInfo *> & GetCommandList()
inline const std::list<ConCmdInfo *> & GetCommandList()
{
return m_CmdList;
}
Expand Down
34 changes: 21 additions & 13 deletions core/ConVarManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "ConVarManager.h"
#include "HalfLife2.h"
#include "sm_stringutil.h"
#include <sh_vector.h>
#include <vector>
#include <sm_namehashset.h>
#include "logic_bridge.h"
#include "sourcemod.h"
Expand All @@ -40,7 +40,7 @@
ConVarManager g_ConVarManager;

const ParamType CONVARCHANGE_PARAMS[] = {Param_Cell, Param_String, Param_String};
typedef List<const ConVar *> ConVarList;
typedef std::list<const ConVar *> ConVarList;
NameHashSet<ConVarInfo *, ConVarInfo::ConVarPolicy> convar_cache;

enum {
Expand Down Expand Up @@ -114,7 +114,7 @@ void ConVarManager::OnSourceModAllInitialized()

void ConVarManager::OnSourceModShutdown()
{
List<ConVarInfo *>::iterator iter = m_ConVars.begin();
auto iter = m_ConVars.begin();
HandleSecurity sec(NULL, g_pCoreIdent);

/* Iterate list of ConVarInfo structures, remove every one of them */
Expand Down Expand Up @@ -217,7 +217,7 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
}

/* Clear any references to this plugin as the convar creator */
for (List<ConVarInfo *>::iterator iter = m_ConVars.begin(); iter != m_ConVars.end(); ++iter)
for (auto iter = m_ConVars.begin(); iter != m_ConVars.end(); ++iter)
{
ConVarInfo *pInfo = (*iter);

Expand All @@ -230,7 +230,7 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
const IPluginRuntime * pRuntime = plugin->GetRuntime();

/* Remove convar queries for this plugin that haven't returned results yet */
for (List<ConVarQuery>::iterator iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
for (auto iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
{
ConVarQuery &query = (*iter);
if (query.pCallback->GetParentRuntime() == pRuntime)
Expand All @@ -246,7 +246,7 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
void ConVarManager::OnClientDisconnected(int client)
{
/* Remove convar queries for this client that haven't returned results yet */
for (List<ConVarQuery>::iterator iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
for (auto iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
{
ConVarQuery &query = (*iter);
if (query.client == client)
Expand Down Expand Up @@ -311,7 +311,6 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename();

ConVarList *pConVarList;
ConVarList::iterator iter;

/* If no convar list... */
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
Expand All @@ -327,7 +326,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs
}

/* Iterate convar list and display/reset each one */
for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
for (auto iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
{
/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
if (!wantReset)
Expand Down Expand Up @@ -599,10 +598,18 @@ void ConVarManager::AddConVarToPluginList(IPlugin *plugin, const ConVar *pConVar
pConVarList = new ConVarList();
plugin->SetProperty("ConVarList", pConVarList);
}
else if (pConVarList->find(pConVar) != pConVarList->end())
else
{
/* If convar is already in list, then don't add it */
return;
auto iterS = pConVarList->begin();
while (iterS != pConVarList->end() && (*iterS) != pConVar)
{
iterS++;
}
if (iterS != pConVarList->end())
{
return;
}
}

/* Insert convar into list which is sorted alphabetically */
Expand Down Expand Up @@ -678,9 +685,9 @@ void ConVarManager::OnClientQueryFinished(QueryCvarCookie_t cookie,
{
IPluginFunction *pCallback = NULL;
cell_t value = 0;
List<ConVarQuery>::iterator iter;

for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end(); iter++)
auto iter = m_ConVarQueries.begin();
for (; iter != m_ConVarQueries.end(); iter++)
{
ConVarQuery &query = (*iter);
if (query.cookie == cookie)
Expand Down Expand Up @@ -712,7 +719,8 @@ void ConVarManager::OnClientQueryFinished(QueryCvarCookie_t cookie,
pCallback->PushCell(value);
pCallback->Execute(&ret);

m_ConVarQueries.erase(iter);
if (iter != m_ConVarQueries.end())
m_ConVarQueries.erase(iter);
}
}
#endif
Expand Down
Loading
Loading