Skip to content

Commit

Permalink
CDetour safetyhook (#2162)
Browse files Browse the repository at this point in the history
* Add safetyhook, remove libudis86

Co-authored-by: bottiger1 <[email protected]>

* Add modified CDetour

Co-authored-by: bottiger1 <[email protected]>

* 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 <[email protected]>
Co-authored-by: bottiger1 <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent e373480 commit e07c120
Show file tree
Hide file tree
Showing 30 changed files with 71,521 additions and 332 deletions.
10 changes: 10 additions & 0 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,16 @@ class SMConfig(object):

return binary

def AddCDetour(self, binary):
public_path = os.path.join(builder.sourcePath, 'public')
binary.sources += [
os.path.join(public_path, 'CDetour', 'detours.cpp'),
os.path.join(public_path, 'safetyhook', 'safetyhook.cpp'),
os.path.join(public_path, 'safetyhook', 'Zydis.c')
]
binary.compiler.cxxincludes += [ os.path.join(public_path, 'safetyhook') ]
binary.compiler.includes += [ os.path.join(public_path, 'safetyhook') ]

def HL2Library(self, context, compiler, name, sdk):
binary = self.Library(context, compiler, name)
self.ConfigureForExtension(context, binary.compiler)
Expand Down
5 changes: 0 additions & 5 deletions core/logic/ExtensionSys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,6 @@ void CExtension::AddDependency(const IfaceInfo *pInfo)
}
}

bool operator ==(const IfaceInfo &i1, const IfaceInfo &i2)
{
return (i1.iface == i2.iface) && (i1.owner == i2.owner);
}

void CExtension::AddChildDependent(CExtension *pOther, SMInterface *iface)
{
IfaceInfo info;
Expand Down
2 changes: 1 addition & 1 deletion core/logic/ShareSys.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ namespace SourceMod

struct IfaceInfo
{
bool operator ==(const IfaceInfo &info)
bool operator ==(const IfaceInfo &info) const
{
return (info.iface == iface && info.owner == owner);
}
Expand Down
12 changes: 3 additions & 9 deletions extensions/cstrike/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ project.sources += [
'timeleft.cpp',
'forwards.cpp',
'util_cstrike.cpp',
'../../public/smsdk_ext.cpp',
'../../public/CDetour/detours.cpp',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
'../../public/smsdk_ext.cpp'
]

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

cxx.defines += ['HAVE_STRING_H']
binary = SM.HL2ExtConfig(project, builder, cxx, 'game.cstrike.ext.' + sdk['extension'], sdk)
SM.AddCDetour(binary)

if sdk_name == 'csgo':
compiler = binary.compiler
compiler.cxxincludes += [os.path.join(sdk['path'], 'public', 'steam')]
Expand Down
19 changes: 12 additions & 7 deletions extensions/dhooks/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ for cxx in builder.targets:
binary.compiler.cxxincludes += [
os.path.join(SM.mms_root, 'core'),
os.path.join(SM.mms_root, 'core', 'sourcehook'),
os.path.join(builder.sourcePath, 'extensions', 'dhooks'),
os.path.join(builder.sourcePath, 'public', 'jit'),
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
os.path.join(builder.sourcePath, 'sourcepawn', 'include'),
Expand All @@ -27,6 +28,10 @@ for cxx in builder.targets:
os.path.join(builder.sourcePath, 'extensions', 'dhooks', 'DynamicHooks'),
]

binary.compiler.includes += [
os.path.join(builder.sourcePath, 'extensions', 'dhooks')
]

binary.sources += [
'extension.cpp',
'listeners.cpp',
Expand All @@ -36,13 +41,13 @@ for cxx in builder.targets:
'util.cpp',
'dynhooks_sourcepawn.cpp',
'../../public/smsdk_ext.cpp',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
'asm/asm.c',
'libudis86/decode.c',
'libudis86/itab.c',
'libudis86/syn-att.c',
'libudis86/syn-intel.c',
'libudis86/syn.c',
'libudis86/udis86.c',
'../../sourcepawn/vm/x86/assembler-x86.cpp',
]

Expand Down
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.
File renamed without changes.
20 changes: 7 additions & 13 deletions extensions/sdktools/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ project.sources += [
'hooks.cpp',
'gamerulesnatives.cpp',
'vstringtable.cpp',
'../../public/smsdk_ext.cpp',
'../../public/CDetour/detours.cpp',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
'../../public/smsdk_ext.cpp'
]

for sdk_name in SM.sdks:
Expand All @@ -45,18 +37,20 @@ for sdk_name in SM.sdks:
continue

binary = SM.HL2ExtConfig(project, builder, cxx, 'sdktools.ext.' + sdk['extension'], sdk)
SM.AddCDetour(binary)

binary.compiler.cxxincludes += [
os.path.join(builder.sourcePath, 'public', 'jit'),
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
]

if sdk['name'] in ('episode1', 'darkm'):
binary.compiler.cxxincludes += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game_shared')]
binary.compiler.cxxincludes += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'dlls')]
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'game_shared')]
binary.compiler.cxxincludes += [os.path.join(sdk['path'], 'dlls')]
else:
binary.compiler.cxxincludes += [
os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'shared'),
os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'server'),
os.path.join(sdk['path'], 'game', 'shared'),
os.path.join(sdk['path'], 'game', 'server'),
]

#binary.sources += [os.path.join(builder.options.hl2sdk_root, sdk['path'], 'game', 'server', 'variant_t.cpp')]
Expand Down
1 change: 0 additions & 1 deletion extensions/sdktools/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class EntityOutputManager : public IPluginsListener

int HookCount;

patch_t info_restore;
void *info_address;
void *info_callback;
};
Expand Down
11 changes: 2 additions & 9 deletions extensions/tf2/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ if 'tf2' in SM.sdks:
if not cxx.target.arch in sdk['platforms'][cxx.target.platform]:
continue
binary = SM.HL2Library(builder, cxx, 'game.tf2.ext.' + sdk['extension'], sdk)
SM.AddCDetour(binary)
binary.sources += [
'extension.cpp',
'natives.cpp',
Expand All @@ -18,15 +19,7 @@ if 'tf2' in SM.sdks:
'teleporter.cpp',
'gameplayrules.cpp',
'conditions.cpp',
'../../public/smsdk_ext.cpp',
'../../public/CDetour/detours.cpp',
'../../public/asm/asm.c',
'../../public/libudis86/decode.c',
'../../public/libudis86/itab.c',
'../../public/libudis86/syn-att.c',
'../../public/libudis86/syn-intel.c',
'../../public/libudis86/syn.c',
'../../public/libudis86/udis86.c',
'../../public/smsdk_ext.cpp'
]
binary.compiler.defines += ['HAVE_STRING_H']
SM.extensions += [builder.Add(binary)]
Loading

0 comments on commit e07c120

Please sign in to comment.