Skip to content

Commit 54be1c3

Browse files
ZivDeroMetadorius
andcommitted
Relative instruction fixup (#19)
Co-authored-by: Kerbiter <crabiter@vivaldi.net>
1 parent 4e43375 commit 54be1c3

107 files changed

Lines changed: 152686 additions & 14 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Release/**
22
Debug/**
3+
tests/obj/**
4+
tests/bin/**
5+
external/lib/**
36

47
.vs/**
58
.vscode/settings.json

Debugger.vcxproj

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,13 @@
6262
</Midl>
6363
<ClCompile>
6464
<Optimization>Disabled</Optimization>
65-
<AdditionalIncludeDirectories>
66-
</AdditionalIncludeDirectories>
67-
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
65+
<AdditionalIncludeDirectories>$(ProjectDir)external\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
66+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;NOMINMAX;ZYDIS_STATIC_BUILD;ZYCORE_STATIC_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
6867
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
6968
<PrecompiledHeaderOutputFile>.\Debug\Syringe.pch</PrecompiledHeaderOutputFile>
7069
<AssemblerListingLocation>$(IntDir)\%(RelativeDir)</AssemblerListingLocation>
7170
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
7271
<WarningLevel>Level4</WarningLevel>
73-
<CallingConvention>StdCall</CallingConvention>
7472
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
7573
<AdditionalOptions>/Zc:threadSafeInit- /Zc:throwingNew /Gw %(AdditionalOptions)</AdditionalOptions>
7674
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
@@ -97,6 +95,7 @@
9795
<OptimizeReferences>true</OptimizeReferences>
9896
<EnableCOMDATFolding>true</EnableCOMDATFolding>
9997
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;comctl32.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
98+
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
10099
</Link>
101100
<Bscmake>
102101
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -110,21 +109,21 @@
110109
</Midl>
111110
<ClCompile>
112111
<Optimization>Full</Optimization>
113-
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;NOMINMAX;ZYDIS_STATIC_BUILD;ZYCORE_STATIC_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114113
<StringPooling>true</StringPooling>
115114
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
116115
<PrecompiledHeaderOutputFile>.\Release\Syringe.pch</PrecompiledHeaderOutputFile>
117116
<AssemblerListingLocation>$(IntDir)\%(RelativeDir)</AssemblerListingLocation>
118117
<ObjectFileName>$(IntDir)\%(RelativeDir)</ObjectFileName>
119118
<WarningLevel>Level4</WarningLevel>
120-
<CallingConvention>StdCall</CallingConvention>
121119
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
122120
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
123121
<AdditionalOptions>/Zc:threadSafeInit- /Zc:throwingNew /Gw %(AdditionalOptions)</AdditionalOptions>
124122
<RuntimeTypeInfo>false</RuntimeTypeInfo>
125123
<LanguageStandard>stdcpp20</LanguageStandard>
126124
<BufferSecurityCheck>false</BufferSecurityCheck>
127125
<ConformanceMode>true</ConformanceMode>
126+
<AdditionalIncludeDirectories>$(ProjectDir)external\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
128127
</ClCompile>
129128
<ResourceCompile>
130129
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -140,6 +139,7 @@
140139
<OptimizeReferences>true</OptimizeReferences>
141140
<EnableCOMDATFolding>true</EnableCOMDATFolding>
142141
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;comctl32.lib;dbghelp.lib;%(AdditionalDependencies)</AdditionalDependencies>
142+
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
143143
</Link>
144144
<Bscmake>
145145
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -172,6 +172,11 @@
172172
<ItemGroup>
173173
<Manifest Include="Syringe.exe.manifest" />
174174
</ItemGroup>
175+
<ItemGroup>
176+
<ProjectReference Include="external\Zydis.vcxproj">
177+
<Project>{B2C3D4E5-2345-6789-ABCD-EF2345678901}</Project>
178+
</ProjectReference>
179+
</ItemGroup>
175180
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
176181
<ImportGroup Label="ExtensionTargets">
177182
</ImportGroup>

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ This fork extends and modernizes the original **Syringe** while maintaining comp
55

66
# License
77

8-
The **entire program** is licensed under **LGPLv3**.
8+
The **SyringeEx code in this repository** is licensed under **LGPLv3**.
99
See [`LICENSE`](LICENSE) for details.
1010

1111
The file **[`Syringe.h`](Syringe.h)** is explicitly designated as an **API header**, and may be used under the LGPLv3 interface rules.
1212

13+
This repository also vendors **[Zydis 5.0.0](https://zydis.re/)** and **[Zycore-C 1.5.2](https://github.com/zyantific/zycore-c)** under the **MIT License**.
14+
1315
# Background
1416

1517
Syringe was originally created by **Patrick "pd" Dinklage**, based partially on work by **Jan Newger**, and later maintained by contributors from the **Ares** project.
@@ -110,6 +112,7 @@ void YourDLL::SomeLoadCode()
110112

111113
- `ESPModification` - Adds an ability for DLLs to modify the stack pointer (ESP) across hooks to be able to exit on addresses with a different stack depth than the hook entry point
112114
- `ZFPreservation` - Indicates that the Zero Flag (ZF) is preserved after hook execution, allowing to hook on conditional instructions
115+
- `ReladdrInstructionFixup` - Indicates that relative address instructions (JMP, CALL, Jcc) in overwritten code are properly relocated when copied to trampolines, preventing crashes from stale offsets
113116

114117
## Adding New API Features
115118

Syringe.sln

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.25920.0
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.5.11709.299 stable
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Syringe", "Debugger.vcxproj", "{DC2E7848-31D1-43EA-90D5-A5F1FB28E8AC}"
77
EndProject
8+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tests", "Tests.vcxproj", "{A1B2C3D4-1234-5678-9ABC-DEF012345678}"
9+
EndProject
10+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zydis", "external\Zydis.vcxproj", "{B2C3D4E5-2345-6789-ABCD-EF2345678901}"
11+
EndProject
812
Global
913
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1014
Debug|Any CPU = Debug|Any CPU
@@ -25,6 +29,27 @@ Global
2529
{DC2E7848-31D1-43EA-90D5-A5F1FB28E8AC}.Release|Mixed Platforms.Build.0 = Release|Win32
2630
{DC2E7848-31D1-43EA-90D5-A5F1FB28E8AC}.Release|Win32.ActiveCfg = Release|Win32
2731
{DC2E7848-31D1-43EA-90D5-A5F1FB28E8AC}.Release|Win32.Build.0 = Release|Win32
32+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Any CPU.ActiveCfg = Release|Win32
33+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Any CPU.Build.0 = Release|Win32
34+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Mixed Platforms.ActiveCfg = Release|Win32
35+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Mixed Platforms.Build.0 = Release|Win32
36+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Win32.ActiveCfg = Release|Win32
37+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Win32.Build.0 = Release|Win32
38+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Any CPU.ActiveCfg = Release|Win32
39+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Mixed Platforms.ActiveCfg = Release|Win32
40+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Mixed Platforms.Build.0 = Release|Win32
41+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Win32.ActiveCfg = Release|Win32
42+
{A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Win32.Build.0 = Release|Win32
43+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Debug|Any CPU.ActiveCfg = Debug|Win32
44+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
45+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Debug|Mixed Platforms.Build.0 = Debug|Win32
46+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Debug|Win32.ActiveCfg = Debug|Win32
47+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Debug|Win32.Build.0 = Debug|Win32
48+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Release|Any CPU.ActiveCfg = Release|Win32
49+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Release|Mixed Platforms.ActiveCfg = Release|Win32
50+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Release|Mixed Platforms.Build.0 = Release|Win32
51+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Release|Win32.ActiveCfg = Release|Win32
52+
{B2C3D4E5-2345-6789-ABCD-EF2345678901}.Release|Win32.Build.0 = Release|Win32
2853
EndGlobalSection
2954
GlobalSection(SolutionProperties) = preSolution
3055
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)