Skip to content

Commit e07c120

Browse files
Kenzzerbottiger1
andauthored
CDetour safetyhook (#2162)
* Add safetyhook, remove libudis86 Co-authored-by: bottiger1 <55270538+bottiger1@users.noreply.github.com> * Add modified CDetour Co-authored-by: bottiger1 <55270538+bottiger1@users.noreply.github.com> * Add CDetour [Safetyhook] to build script * Re-enable loader/core/corelogic, and fix new C++20 error * Reenable all extensions (except dhooks) * Make cstrike compile against new CDetour * Remove unused variable in sdktools output? * Make sdktools compile against new cdetour * Downgrade to C++17 * remove auto * fix compilation on linux * Re-enable dhooks * Re-authorise old compilers * Fix invalid downgrade of std::optional * readd libudis86 for dhooks only --------- Co-authored-by: Kenzzer <kenzzer@users.noreply.github.com> Co-authored-by: bottiger1 <55270538+bottiger1@users.noreply.github.com>
1 parent e373480 commit e07c120

30 files changed

+71521
-332
lines changed

AMBuildScript

+10
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,16 @@ class SMConfig(object):
520520

521521
return binary
522522

523+
def AddCDetour(self, binary):
524+
public_path = os.path.join(builder.sourcePath, 'public')
525+
binary.sources += [
526+
os.path.join(public_path, 'CDetour', 'detours.cpp'),
527+
os.path.join(public_path, 'safetyhook', 'safetyhook.cpp'),
528+
os.path.join(public_path, 'safetyhook', 'Zydis.c')
529+
]
530+
binary.compiler.cxxincludes += [ os.path.join(public_path, 'safetyhook') ]
531+
binary.compiler.includes += [ os.path.join(public_path, 'safetyhook') ]
532+
523533
def HL2Library(self, context, compiler, name, sdk):
524534
binary = self.Library(context, compiler, name)
525535
self.ConfigureForExtension(context, binary.compiler)

core/logic/ExtensionSys.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@ void CExtension::AddDependency(const IfaceInfo *pInfo)
395395
}
396396
}
397397

398-
bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
399-
{
400-
return (i1.iface == i2.iface) && (i1.owner == i2.owner);
401-
}
402-
403398
void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
404399
{
405400
IfaceInfo info;

core/logic/ShareSys.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace SourceMod
5959

6060
struct IfaceInfo
6161
{
62-
bool operator ==(const IfaceInfo &info)
62+
bool operator ==(const IfaceInfo &info) const
6363
{
6464
return (info.iface == iface && info.owner == owner);
6565
}

extensions/cstrike/AMBuilder

+3-9
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ project.sources += [
99
'timeleft.cpp',
1010
'forwards.cpp',
1111
'util_cstrike.cpp',
12-
'../../public/smsdk_ext.cpp',
13-
'../../public/CDetour/detours.cpp',
14-
'../../public/asm/asm.c',
15-
'../../public/libudis86/decode.c',
16-
'../../public/libudis86/itab.c',
17-
'../../public/libudis86/syn-att.c',
18-
'../../public/libudis86/syn-intel.c',
19-
'../../public/libudis86/syn.c',
20-
'../../public/libudis86/udis86.c',
12+
'../../public/smsdk_ext.cpp'
2113
]
2214

2315
for sdk_name in ['css', 'csgo']:
@@ -34,6 +26,8 @@ for sdk_name in ['css', 'csgo']:
3426

3527
cxx.defines += ['HAVE_STRING_H']
3628
binary = SM.HL2ExtConfig(project, builder, cxx, 'game.cstrike.ext.' + sdk['extension'], sdk)
29+
SM.AddCDetour(binary)
30+
3731
if sdk_name == 'csgo':
3832
compiler = binary.compiler
3933
compiler.cxxincludes += [os.path.join(sdk['path'], 'public', 'steam')]

extensions/dhooks/AMBuilder

+12-7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ for cxx in builder.targets:
1919
binary.compiler.cxxincludes += [
2020
os.path.join(SM.mms_root, 'core'),
2121
os.path.join(SM.mms_root, 'core', 'sourcehook'),
22+
os.path.join(builder.sourcePath, 'extensions', 'dhooks'),
2223
os.path.join(builder.sourcePath, 'public', 'jit'),
2324
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
2425
os.path.join(builder.sourcePath, 'sourcepawn', 'include'),
@@ -27,6 +28,10 @@ for cxx in builder.targets:
2728
os.path.join(builder.sourcePath, 'extensions', 'dhooks', 'DynamicHooks'),
2829
]
2930

31+
binary.compiler.includes += [
32+
os.path.join(builder.sourcePath, 'extensions', 'dhooks')
33+
]
34+
3035
binary.sources += [
3136
'extension.cpp',
3237
'listeners.cpp',
@@ -36,13 +41,13 @@ for cxx in builder.targets:
3641
'util.cpp',
3742
'dynhooks_sourcepawn.cpp',
3843
'../../public/smsdk_ext.cpp',
39-
'../../public/asm/asm.c',
40-
'../../public/libudis86/decode.c',
41-
'../../public/libudis86/itab.c',
42-
'../../public/libudis86/syn-att.c',
43-
'../../public/libudis86/syn-intel.c',
44-
'../../public/libudis86/syn.c',
45-
'../../public/libudis86/udis86.c',
44+
'asm/asm.c',
45+
'libudis86/decode.c',
46+
'libudis86/itab.c',
47+
'libudis86/syn-att.c',
48+
'libudis86/syn-intel.c',
49+
'libudis86/syn.c',
50+
'libudis86/udis86.c',
4651
'../../sourcepawn/vm/x86/assembler-x86.cpp',
4752
]
4853

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

extensions/sdktools/AMBuilder

+7-13
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@ project.sources += [
2424
'hooks.cpp',
2525
'gamerulesnatives.cpp',
2626
'vstringtable.cpp',
27-
'../../public/smsdk_ext.cpp',
28-
'../../public/CDetour/detours.cpp',
29-
'../../public/asm/asm.c',
30-
'../../public/libudis86/decode.c',
31-
'../../public/libudis86/itab.c',
32-
'../../public/libudis86/syn-att.c',
33-
'../../public/libudis86/syn-intel.c',
34-
'../../public/libudis86/syn.c',
35-
'../../public/libudis86/udis86.c',
27+
'../../public/smsdk_ext.cpp'
3628
]
3729

3830
for sdk_name in SM.sdks:
@@ -45,18 +37,20 @@ for sdk_name in SM.sdks:
4537
continue
4638

4739
binary = SM.HL2ExtConfig(project, builder, cxx, 'sdktools.ext.' + sdk['extension'], sdk)
40+
SM.AddCDetour(binary)
41+
4842
binary.compiler.cxxincludes += [
4943
os.path.join(builder.sourcePath, 'public', 'jit'),
5044
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
5145
]
5246

5347
if sdk['name'] in ('episode1', 'darkm'):
54-
binary.compiler.cxxincludes += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game_shared')]
55-
binary.compiler.cxxincludes += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'dlls')]
48+
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'game_shared')]
49+
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'dlls')]
5650
else:
5751
binary.compiler.cxxincludes += [
58-
os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'shared'),
59-
os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'server'),
52+
os.path.join(sdk['path'], 'game', 'shared'),
53+
os.path.join(sdk['path'], 'game', 'server'),
6054
]
6155

6256
#binary.sources += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'server', 'variant_t.cpp')]

extensions/sdktools/output.h

-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class EntityOutputManager : public IPluginsListener
128128

129129
int HookCount;
130130

131-
patch_t info_restore;
132131
void *info_address;
133132
void *info_callback;
134133
};

extensions/tf2/AMBuilder

+2-9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if 'tf2' in SM.sdks:
88
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
99
continue
1010
binary = SM.HL2Library(builder, cxx, 'game.tf2.ext.' + sdk['extension'], sdk)
11+
SM.AddCDetour(binary)
1112
binary.sources += [
1213
'extension.cpp',
1314
'natives.cpp',
@@ -18,15 +19,7 @@ if 'tf2' in SM.sdks:
1819
'teleporter.cpp',
1920
'gameplayrules.cpp',
2021
'conditions.cpp',
21-
'../../public/smsdk_ext.cpp',
22-
'../../public/CDetour/detours.cpp',
23-
'../../public/asm/asm.c',
24-
'../../public/libudis86/decode.c',
25-
'../../public/libudis86/itab.c',
26-
'../../public/libudis86/syn-att.c',
27-
'../../public/libudis86/syn-intel.c',
28-
'../../public/libudis86/syn.c',
29-
'../../public/libudis86/udis86.c',
22+
'../../public/smsdk_ext.cpp'
3023
]
3124
binary.compiler.defines += ['HAVE_STRING_H']
3225
SM.extensions += [builder.Add(binary)]

0 commit comments

Comments
 (0)