Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
644ce22
First draft of dynamic detours using Ayuto's DynamicHooks library
peace-maker Dec 12, 2016
f897c54
Cleanup detour structures properly on unload
peace-maker Dec 12, 2016
5906744
Switch to sp::MacroAssembler instead of AsmJit
peace-maker Dec 13, 2016
fd5d3ba
Fix new - free mismatch
peace-maker Dec 13, 2016
8addcc5
Add detour test plugin
peace-maker Dec 13, 2016
3d2f7a3
Use AMTL instead of the stdlib in DynamicHooks
peace-maker Dec 13, 2016
23ab2a2
Don't use std::list at all in DynamicHooks
peace-maker Dec 14, 2016
1a2040e
Fix overriding return value
peace-maker Dec 14, 2016
cf800c7
Save this pointer on windows after calling original function
peace-maker Dec 14, 2016
a918586
Fix compilation
peace-maker Jan 21, 2018
eb67ad6
Fix not clearing return address cache after use
peace-maker Jan 21, 2018
5a8c67e
Add support for custom calling convention passing arguments in registers
peace-maker Jan 23, 2018
ef76f5a
Fix assert when the pre-hook was fired, but the post hook was skipped
peace-maker Jan 23, 2018
6048b17
Update visual studio project files
peace-maker Jan 23, 2018
76e0492
Fix saving arguments in custom registers in combination with argument…
peace-maker Jan 23, 2018
eeec7a1
Fix passing this pointer to callback even if the detour was setup to …
peace-maker Jan 23, 2018
2afaea0
Document the new natives in the include file
peace-maker Jan 23, 2018
2529711
Mark new natives as optional if extension is optional
peace-maker Jan 23, 2018
4f1803f
Add support to define function signatures in gamedata
peace-maker Jan 25, 2018
3456c00
Fix linux build
peace-maker Jan 27, 2018
e815bec
More linux fixes
peace-maker Jan 27, 2018
b3f04f9
Fix linux build with clang
peace-maker Apr 17, 2018
8b58d7e
Fix detouring |thiscall| on linux
peace-maker Apr 17, 2018
42c8341
Fix crash when accessing invalid argument index
peace-maker Apr 17, 2018
efc3889
Fix not using passed alignment value for argument sizes
peace-maker Apr 17, 2018
58fe5c0
Merge branch 'master' into dynhooks
peace-maker Apr 19, 2018
b235230
Update version to track detour support
peace-maker Apr 19, 2018
3d75d9b
Fix typos in "Functions" section parsing
peace-maker Apr 21, 2018
925ba99
Remove optional callback parameter from DHookCreateFromConf
peace-maker Apr 21, 2018
2f9af2c
Fix build against SourceMod 1.9
peace-maker Apr 21, 2018
df4bd84
Cleanup detour callback MRES return value handling
peace-maker Apr 21, 2018
f87369c
Ignore build directory in .hgignore
peace-maker Apr 21, 2018
196b31d
Fix saving arguments in wrong order when parsing "Functions" section …
peace-maker Apr 21, 2018
5ca8c1f
Fix signed - unsigned comparison warning
peace-maker Apr 21, 2018
df59f1a
Fix changing return value of detoured function
peace-maker Apr 22, 2018
ff15e80
Bump version
peace-maker Apr 22, 2018
18bf863
Fix linux build
peace-maker Apr 22, 2018
0975105
Don't call sourcepawn detour callbacks from threads other than the ma…
peace-maker May 2, 2018
0a70c03
Fix defining virtual hooks in gamedata "Functions" section
peace-maker May 20, 2018
5dc2e66
Bump version
peace-maker May 20, 2018
eb724f4
Fix |thiscall| on linux for functions with arguments
peace-maker Jun 2, 2018
040475e
Bump version
peace-maker Jun 6, 2018
ba0eb28
Fix skipping plugin callbacks on plugin unload
peace-maker Aug 7, 2018
b1babf3
Fix adding arguments multiple times when reloading a gamedata file
peace-maker Aug 7, 2018
94a9064
Improve error message on bad detour argument setup
peace-maker Aug 7, 2018
3f8f721
Bump version
peace-maker Aug 7, 2018
b91d708
Fix detour of functions returning a float
peace-maker Aug 18, 2018
af24cae
Bump version
peace-maker Aug 28, 2018
36bf7d0
Fix crash on unaligned SSE instructions
peace-maker Oct 5, 2018
e71fd49
Fix crash when trying to decode NULL this pointer
peace-maker Oct 5, 2018
0df334a
Bump version
peace-maker Nov 21, 2018
5857b0a
Fix compilation against SourceMod 1.10
peace-maker May 6, 2019
38bf922
Add support for the "fastcall" calling convention
peace-maker Jun 20, 2019
4d17d2f
Fix changing of charptr and vectorptr returns and parameters
peace-maker Aug 3, 2019
2243c68
Bump version
peace-maker Aug 3, 2019
9830fe9
Merge branch 'master' into dynhooks
peace-maker Aug 19, 2019
b7000ba
Bump version
peace-maker Aug 19, 2019
2adea32
Add |this|-ptr save and restore from pre to post hooks on linux
peace-maker Nov 1, 2019
32f8f4b
Fix parsing of platform specific sections in "Functions" gamedata
peace-maker Apr 21, 2020
96f653c
Bump version to 2.2.0-detours10
peace-maker Apr 21, 2020
17cea91
Translate .hgignore to .gitignore
peace-maker May 14, 2020
f96100a
Fix recursive calls when the ESP register is reused #3
peace-maker May 14, 2020
ff0eed4
Fix skipping and overriding return values of recursive calls #3
peace-maker May 15, 2020
6d8aba4
Bump version to 2.2.0-detours11
peace-maker May 26, 2020
e58d77e
Fix linux build and malloc / delete mismatch
peace-maker May 28, 2020
d8f3997
Fix typo preventing "odtor" argument flag parsing in gamedata
peace-maker May 29, 2020
aa408c2
Bump version to 2.2.0-detours12
peace-maker May 29, 2020
aa3be5c
Fix parsing of multiple argument flags in gamedata
peace-maker May 30, 2020
9d24417
Bump version to 2.2.0-detours13
peace-maker May 30, 2020
568ada2
Fix regression crash with post-only detours #3
peace-maker Jun 4, 2020
86bfea5
Include sdktools.inc in include file #4
peace-maker Jun 5, 2020
ac44af9
Fix trying to call hook removal callback on unloaded plugin
peace-maker Jun 7, 2020
b492c66
Bump version to 2.2.0-detours14
peace-maker Jun 9, 2020
370ab37
More regression fixes for post-only detours #3
peace-maker Jun 9, 2020
d01af6a
Bump version to 2.2.0-detours14a
peace-maker Jun 9, 2020
9b9454b
Fix regression when unloading plugins with entity vhooks on mapchange
peace-maker Jun 17, 2020
5fe46a3
Add methodmap API
peace-maker Oct 14, 2020
3b86e32
Save all arguments before calling the original function
peace-maker Oct 15, 2020
2ccd565
Print nicer error message on wrong callback signature
peace-maker Oct 15, 2020
c9a648a
Fix the saving and restoring part..
peace-maker Oct 16, 2020
947a520
Update to AMBuild 2.2
peace-maker Oct 16, 2020
136b7ba
Merge pull request #8 from peace-maker/saveargs_post
peace-maker Oct 17, 2020
3eb418b
Bump version to 2.2.0-detours15
peace-maker Oct 17, 2020
e5d5e9a
Fix INVALID_HOOK_ID using incorrect value
FortyTwoFortyTwo Oct 19, 2020
aca054f
Fix crash on server shutdown
peace-maker Oct 21, 2020
87e8034
Add README
peace-maker Oct 21, 2020
a323ffc
Switch to std::vector and std::string
peace-maker Oct 28, 2020
29ca496
Move sourcemod to sourcemod_files to avoid build conflicts with the s…
Nov 14, 2020
6fa1016
Avoid reference to GameData methodmap
peace-maker Nov 16, 2020
b9a1585
Enable frame pointer on linux
peace-maker Jan 28, 2021
19d6b32
Bump version to v2.2.0-detours16
peace-maker Jan 28, 2021
a5e0321
Statically link libstdc++
peace-maker Jan 28, 2021
574576c
Fix assigning nullptr to std::string
peace-maker Jan 28, 2021
1d7dcbe
allow to set cbasentity return to nullptr
arthurdead Feb 27, 2021
4f93cd9
Add hexadecimal support to gamedata argument size parsing
peace-maker Mar 11, 2021
314f926
Fix SourceHook contextstack mismatch on MRES_Supercede
peace-maker May 1, 2021
fb3cc73
Print mprotect error message on failure
peace-maker Jun 23, 2021
83c6ad5
Avoid using the glibc heap for the trampoline
peace-maker Jun 23, 2021
ef295b4
Fix DHookIsNullParam checking wrong parameter #15
peace-maker Jun 24, 2021
d4e3c37
Fix mismatching new[] + delete[]
peace-maker Jun 28, 2021
98bb4e5
Bump version to 2.2.0-detours17
peace-maker Jun 30, 2021
008a2fd
Add native to get address of pointer parameters (#24)
Natanel-Shitrit Jul 26, 2021
1314f2d
Fix error reporting on invalid entity (#25)
FortyTwoFortyTwo Aug 25, 2021
25b4b29
Announce merge into SourceMod
peace-maker Nov 17, 2021
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
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Binaries
*.dll
*.dylib
*.exe
*.so

# Files generated by Visual Studio
*.aps
*.ipch
*.ncb
*.opensdf
*.opendb
*.sdf
*.suo
*.user
*.cachefile
*.VC.db
*.VC.VC.opendb

# Build directories
CrazyDebug/
Debug/
Release/
build*/

# Files generated by Mac OS X Finder
(^|/)\.DS_Store

# Files generated by Windows Explorer
(^|/)[dD]esktop\.ini
(^|/)[tT]humbs\.db
26 changes: 0 additions & 26 deletions .hgignore

This file was deleted.

78 changes: 58 additions & 20 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class DHooksConfig(object):
if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
self.mms_root = ResolveEnvPath('MMSOURCE11', 'mmsource-1.11')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE11', 'metamod-1.11')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE10', 'mmsource-1.10')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE10', 'metamod-1.10')
if not self.mms_root:
Expand All @@ -67,7 +71,15 @@ class DHooksConfig(object):
if builder.options.sm_path:
self.sm_root = builder.options.sm_path
else:
self.sm_root = ResolveEnvPath('SOURCEMOD18', 'sourcemod-1.8')
self.sm_root = ResolveEnvPath('SOURCEMOD111', 'sourcemod-1.11')
if not self.sm_root:
self.sm_root = ResolveEnvPath('SOURCEMOD110', 'sourcemod-1.10')
if not self.sm_root:
self.sm_root = ResolveEnvPath('SOURCEMOD19', 'sourcemod-1.9')
if not self.sm_root:
self.sm_root = ResolveEnvPath('SOURCEMOD18', 'sourcemod-1.8')
if not self.sm_root:
self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod')

if not self.sm_root or not os.path.isdir(self.sm_root):
raise Exception('Could not find a source copy of Sourcemod')
Expand All @@ -76,7 +88,9 @@ class DHooksConfig(object):
def configure(self):
builder.AddConfigureFile('push.txt')

cxx = builder.DetectCompilers()
cxx = builder.DetectCxx(target_arch='x86')

builder.cxx = cxx

if cxx.like('gcc'):
cxx.defines += [
Expand All @@ -103,11 +117,11 @@ class DHooksConfig(object):
'-Wno-invalid-offsetof',
]
cxx.cxxflags += [
'-std=c++11',
'-std=c++14',
]

have_gcc = cxx.vendor == 'gcc'
have_clang = cxx.vendor == 'clang'
have_gcc = cxx.family == 'gcc'
have_clang = cxx.family == 'clang'
if cxx.version >= 'clang-3.6':
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
if have_clang or (have_gcc and cxx.version >= '4'):
Expand All @@ -121,7 +135,7 @@ class DHooksConfig(object):
cxx.cflags += ['-Wno-unused-result']
if have_clang:
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
if (builder.target_platform == 'mac' and cxx.version >= '5.1') or cxx.version >= '3.4':
if (cxx.target.platform == 'mac' and cxx.version >= '5.1') or cxx.version >= '3.4':
cxx.cxxflags += ['-Wno-deprecated-register']
else:
cxx.cxxflags += ['-Wno-deprecated']
Expand All @@ -137,7 +151,7 @@ class DHooksConfig(object):

if have_gcc:
cxx.cflags += ['-mfpmath=sse']
elif cxx.vendor == 'msvc':
elif cxx.family == 'msvc':
if builder.options.debug == '1':
cxx.cflags += ['/MTd']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
Expand Down Expand Up @@ -192,18 +206,22 @@ class DHooksConfig(object):
cxx.cflags += ['/d2Zi+']

# This needs to be after our optimization flags which could otherwise disable it.
if cxx.vendor == 'msvc':
if cxx.family == 'msvc':
# Don't omit the frame pointer.
cxx.cflags += ['/Oy-']
elif cxx.like('gcc'):
# Don't omit the frame pointer.
cxx.cflags += ['-fno-omit-frame-pointer']

# Platform-specifics
if builder.target_platform == 'linux':
if cxx.target.platform == 'linux':
cxx.defines += ['_LINUX', 'POSIX']
if cxx.vendor == 'gcc':
if cxx.family == 'gcc':
cxx.linkflags += ['-static-libgcc']
elif cxx.vendor == 'clang':
elif cxx.family == 'clang':
cxx.linkflags += ['-lgcc_eh']
elif builder.target_platform == 'mac':
cxx.linkflags += ['-static-libstdc++']
elif cxx.target.platform == 'mac':
cxx.defines += ['OSX', '_OSX', 'POSIX']
cxx.cflags += ['-mmacosx-version-min=10.5']
cxx.linkflags += [
Expand All @@ -213,18 +231,18 @@ class DHooksConfig(object):
'-stdlib=libstdc++',
]
cxx.cxxflags += ['-stdlib=libstdc++']
elif builder.target_platform == 'windows':
elif cxx.target.platform == 'windows':
cxx.defines += ['WIN32', '_WINDOWS']

if cxx.vendor == 'gcc' or cxx.vendor == 'clang':
if cxx.family == 'gcc' or cxx.family == 'clang':
cxx.cxxflags += ['-fno-rtti']
elif cxx.vendor == 'msvc':
elif cxx.family == 'msvc':
cxx.cxxflags += ['/GR-']

cxx.defines += ['META_NO_HL2SDK']

def IncludeSDKs(self, builder):
builder.compiler.cxxincludes += [
builder.cxx.cxxincludes += [
os.path.join(builder.currentSourcePath),
os.path.join(builder.currentSourcePath, 'sdk'),
os.path.join(self.mms_root, 'core'),
Expand All @@ -238,8 +256,9 @@ class DHooksConfig(object):
os.path.join(self.sm_root, 'sourcepawn', 'include'),
os.path.join(self.sm_root, 'sourcepawn', 'vm'),
os.path.join(self.sm_root, 'sourcepawn', 'vm', 'x86'),
os.path.join(self.sm_root, 'public', 'amtl', 'include'),
os.path.join(self.sm_root, 'public', 'amtl', 'include'),
os.path.join(self.sm_root, 'public', 'amtl', 'amtl'),
os.path.join(builder.currentSourcePath, 'DynamicHooks'),
]


Expand All @@ -248,16 +267,35 @@ DHooks.detectSDKs()
DHooks.configure()
DHooks.IncludeSDKs(builder)

program = builder.compiler.Library('dhooks.ext')
program = builder.cxx.Library('dhooks.ext')

program.sources += [
'extension.cpp',
'listeners.cpp',
'natives.cpp',
'signatures.cpp',
'vhook.cpp',
'util.cpp',
'dynhooks_sourcepawn.cpp',
]

# DynamicHooks
program.sources += [
os.path.join('DynamicHooks', 'asm.cpp'),
os.path.join('DynamicHooks', 'hook.cpp'),
os.path.join('DynamicHooks', 'manager.cpp'),
os.path.join('DynamicHooks', 'registers.cpp'),
os.path.join('DynamicHooks', 'utilities.cpp'),
os.path.join('DynamicHooks', 'conventions', 'x86MsCdecl.cpp'),
os.path.join('DynamicHooks', 'conventions', 'x86MsStdcall.cpp'),
os.path.join('DynamicHooks', 'conventions', 'x86MsFastcall.cpp'),
]

if builder.cxx.target.platform == 'windows':
program.sources += [os.path.join('DynamicHooks', 'conventions', 'x86MsThiscall.cpp')]
else:
program.sources += [os.path.join('DynamicHooks', 'conventions', 'x86GccThiscall.cpp')]

program.sources += [os.path.join(DHooks.sm_root, 'public', 'smsdk_ext.cpp')]

if os.path.isfile(os.path.join(DHooks.sm_root, 'sourcepawn', 'vm', 'x86', 'assembler-x86.cpp')):
Expand All @@ -269,4 +307,4 @@ else:

DHooks.task = builder.Add(program)

builder.RunScript('buildbot/PackageScript', { 'DHooks': DHooks })
builder.Build('buildbot/PackageScript', { 'DHooks': DHooks })
Loading