Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
085d21b
Remove SourceHook from core
Kenzzer Aug 17, 2025
74835a5
Remove CDetour
Kenzzer Aug 17, 2025
81f4691
Add guard rails around Recalls
Kenzzer Aug 17, 2025
e718084
Fix compilation
Kenzzer Aug 17, 2025
779f916
Strip sourcehook from bintools
Kenzzer Aug 17, 2025
d56db1e
Strip sourcehook from clientprefs
Kenzzer Aug 17, 2025
303005f
Strip sourcehook from PGSQL
Kenzzer Aug 17, 2025
731bd25
Strip sourcehook from SQLite
Kenzzer Aug 17, 2025
dae4849
Strip sourcehook from Regex
Kenzzer Aug 17, 2025
ed2b7fc
Strip sourcehook from Updater
Kenzzer Aug 17, 2025
e334219
Re-enable compilation for GeoIP & Curl
Kenzzer Aug 17, 2025
a73e9e5
Strip sourcehook from SDKHooks
Kenzzer Aug 18, 2025
bf2e96c
Remove Safetyhook(CDetour)
Kenzzer Aug 18, 2025
d3e1c53
Strip sourcehook from SDKTools Part 1
Kenzzer Aug 18, 2025
b98c142
Strip sourcehook from SDKTools
Kenzzer Aug 19, 2025
bbf2386
Remove unnecessary includes to SDKTools
Kenzzer Aug 19, 2025
335af20
Blow up dhooks
Kenzzer Aug 19, 2025
2911708
Begin re-impl of dhooks
Kenzzer Sep 18, 2025
dd5d841
Implement basic callback logic
Kenzzer Sep 18, 2025
620e277
Add recall support
Kenzzer Sep 19, 2025
f2e907c
Implem DHookReturn
Kenzzer Sep 19, 2025
7693df5
Finish DHookParam implem
Kenzzer Sep 19, 2025
73c6da6
Move dhookparam/return natives to its own file
Kenzzer Sep 19, 2025
b74d5a5
Add gamedata parser
Kenzzer Sep 28, 2025
d1d0d6d
use the new khook functions
Kenzzer Feb 1, 2026
e8ca8a9
Add/update dhook handles
Kenzzer Feb 1, 2026
5da4834
Reconcile with master rebase
Kenzzer Feb 1, 2026
a63e9c2
Progress towards DynamicDetour
Kenzzer Feb 3, 2026
f3a063b
Start work on DynamicDetour.Enable
Kenzzer Feb 5, 2026
c2e3ca8
Finalise DynamicDetour natives
Kenzzer Feb 7, 2026
334032e
Define remaining undefined symbols
Kenzzer Feb 21, 2026
53f24fa
Add missing functions to bintools
Kenzzer Feb 24, 2026
d9edbad
Strip SourceHook from topmenus
Kenzzer Feb 24, 2026
3daba6d
Fix dhooks loading
Kenzzer Feb 24, 2026
66d911e
Strip SourceHook from game.tf2
Kenzzer Feb 25, 2026
45c23e4
Update metamod dependency for CI
Kenzzer Feb 26, 2026
d9645cc
Fix invalid hook name on CSS/CSGO
Kenzzer Feb 26, 2026
c423cd6
Fix initialising order
Kenzzer Feb 25, 2026
1be4605
Fix wrong vtable offset calculation in bintools
Kenzzer Mar 1, 2026
623e363
Default init addr to nullptr
Kenzzer Mar 1, 2026
e988ca3
Fix SDKHooks not fireing
Kenzzer Mar 1, 2026
4351b5d
Enable dhooks natives
Kenzzer Mar 1, 2026
de08651
Fix this ptr crash in Dynamic Detour & make call original
Kenzzer Mar 1, 2026
aa2d9a8
Update hl2sdk-manifests
Kenzzer Mar 7, 2026
8b21876
Start implementing DynamicHook natives
Kenzzer Mar 7, 2026
801862a
Limit dhooks compilation to linux x64 for now
Kenzzer Mar 7, 2026
09e5ec0
Fix var name error in PlayerManager.cpp
Kenzzer Mar 7, 2026
11224ec
Remove detour callbacks on dynamicdetour deletion
Kenzzer Mar 7, 2026
1041a1c
Finalise DynamicHook natives
Kenzzer Mar 7, 2026
fa796a7
DHooks: Add support for void return on System V x64
Kenzzer Mar 9, 2026
0ce856c
DHooks: Allow registration of DynamicHooks
Kenzzer Mar 9, 2026
c2c001d
DHooks: Add automatic virtual hook cleanup
Kenzzer Mar 9, 2026
eaeb3c3
DHooks: Skip some unnecessary steps in hook cleanup
Kenzzer Mar 9, 2026
98920e2
Make checkout-deps update submodules if they exist
Kenzzer Mar 11, 2026
b1dafb5
Update with latest khook changes
Kenzzer Mar 11, 2026
40d3587
Make mock compile against khook branch of metamod
Kenzzer Mar 11, 2026
27c042d
Correct hook function name for pre-orangebox games
Kenzzer Mar 11, 2026
63ae09b
Correct SDKHooks::Hook_GetGameDescription
Kenzzer Mar 11, 2026
e08e055
Strip remaining of sourcehook
Kenzzer Mar 12, 2026
a444735
Fix compilation for l4d2 & csgo
Kenzzer Mar 12, 2026
ea97fef
Fix incorrect dhook callback removal
Kenzzer Mar 14, 2026
604ae06
Push int64 Address under dhook callbacks
Kenzzer Mar 15, 2026
c99f6de
Fix DHookReturnParam handle leaking
Kenzzer Apr 11, 2026
67c4482
Fix invalid DHookParam.IsNull
Kenzzer Apr 11, 2026
dbc76a7
Remove global hook destroyal logic from SDKHooks
Kenzzer Apr 11, 2026
19ffd9e
Fixup FireOutput detour for windows
Kenzzer Apr 11, 2026
57d2d4f
Upload artifacts of release
Kenzzer Apr 11, 2026
8af2f4f
DHooks: Feature dtor hook cleanup
Kenzzer Apr 12, 2026
ff8cc50
Update sdktools gamedata
Kenzzer May 6, 2026
9e63d38
Remove more instances of SourceHook::List
Kenzzer May 6, 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 @@ -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 @@ -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