update minhook

1
This commit is contained in:
恍兮惚兮 2024-03-21 21:15:40 +08:00
parent eb123790e6
commit 3cdc17bfaa
14 changed files with 558 additions and 61 deletions

View File

@ -20,3 +20,7 @@ trim_trailing_whitespace = true
# UTF-8 with BOM # UTF-8 with BOM
[*.{c,h,def,txt}] [*.{c,h,def,txt}]
charset=utf-8-bom charset=utf-8-bom
# C/C++ code formatting
[*.{c,h}]
cpp_space_pointer_reference_alignment = right

View File

@ -24,7 +24,7 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(minhook LANGUAGES C) project(minhook LANGUAGES C)
@ -55,8 +55,8 @@ endif()
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
set(RESOURCES set(RESOURCES
"dll_resources/minhook.rc" "dll_resources/MinHook.rc"
"dll_resources/minhook.def" "dll_resources/MinHook.def"
) )
endif() endif()
@ -81,7 +81,7 @@ if(WIN32)
set_target_properties(minhook PROPERTIES DEBUG_POSTFIX ".x32d") set_target_properties(minhook PROPERTIES DEBUG_POSTFIX ".x32d")
set_target_properties(minhook PROPERTIES RELEASE_POSTFIX ".x32") set_target_properties(minhook PROPERTIES RELEASE_POSTFIX ".x32")
set_target_properties(minhook PROPERTIES RELWITHDEBINFO_POSTFIX ".x32") set_target_properties(minhook PROPERTIES RELWITHDEBINFO_POSTFIX ".x32")
set_target_properties(minhook PROPERTIES MINSIZEREL_POSTFIX ".x64") set_target_properties(minhook PROPERTIES MINSIZEREL_POSTFIX ".x32")
endif() endif()
else() else()
set_target_properties(minhook PROPERTIES PREFIX "lib") set_target_properties(minhook PROPERTIES PREFIX "lib")

View File

@ -17,7 +17,7 @@ all: MinHook.dll libMinHook.dll.a libMinHook.a
libMinHook.a: $(OBJS) libMinHook.a: $(OBJS)
$(AR) r $@ $^ $(AR) r $@ $^
libMinHook.dll.a: MinHook.dll dll_resources/MinHook.def libMinHook.dll.a: MinHook.dll dll_resources/MinHook.def
$(DLLTOOL) --dllname MinHook.dll --def dll_resources/MinHook.def --output-lib $@ $(DLLTOOL) --dllname MinHook.dll --input-def dll_resources/MinHook.def --output-lib $@
MinHook.dll: $(OBJS) dll_resources/MinHook.res dll_resources/MinHook.def MinHook.dll: $(OBJS) dll_resources/MinHook.res dll_resources/MinHook.def
$(CCLD) -o $@ -shared $(LDFLAGS) $^ $(CCLD) -o $@ -shared $(LDFLAGS) $^

View File

@ -120,7 +120,6 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<CompileAs>CompileAsC</CompileAs>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile> </ClCompile>

View File

@ -120,7 +120,6 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<CompileAs>CompileAsC</CompileAs>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile> </ClCompile>

View File

@ -120,7 +120,6 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<CompileAs>CompileAsC</CompileAs>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile> </ClCompile>

View File

@ -120,7 +120,6 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat> <DebugInformationFormat>None</DebugInformationFormat>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion> <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<CompileAs>CompileAsC</CompileAs>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile> </ClCompile>

View File

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{027FAC75-3FDB-4044-8DD0-BC297BD4C461}</ProjectGuid>
<RootNamespace>MinHook</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)bin\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName).x86</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName).x86</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName).x64</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName).x64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MINHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
</ClCompile>
<Link>
<ModuleDefinitionFile>$(SolutionDir)..\..\dll_resources\MinHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>$(SolutionDir)lib\$(Configuration)\libMinHook.x86.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;MINHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
</ClCompile>
<Link>
<ModuleDefinitionFile>$(SolutionDir)..\..\dll_resources\MinHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalDependencies>$(SolutionDir)lib\$(Configuration)\libMinHook.x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MINHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<ModuleDefinitionFile>$(SolutionDir)..\..\dll_resources\MinHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>$(SolutionDir)lib\$(Configuration)\libMinHook.x86.lib;%(AdditionalDependencies)</AdditionalDependencies>
<NoEntryPoint>true</NoEntryPoint>
<MergeSections>.CRT=.text</MergeSections>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;MINHOOK_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<ModuleDefinitionFile>$(SolutionDir)..\..\dll_resources\MinHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>false</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalDependencies>$(SolutionDir)lib\$(Configuration)\libMinHook.x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
<NoEntryPoint>true</NoEntryPoint>
<MergeSections>.CRT=.text</MergeSections>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="..\..\dll_resources\MinHook.def" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\dll_resources\MinHook.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,41 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libMinHook", "libMinHook.vcxproj", "{F142A341-5EE0-442D-A15F-98AE9B48DBAE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MinHook", "MinHook.vcxproj", "{027FAC75-3FDB-4044-8DD0-BC297BD4C461}"
ProjectSection(ProjectDependencies) = postProject
{F142A341-5EE0-442D-A15F-98AE9B48DBAE} = {F142A341-5EE0-442D-A15F-98AE9B48DBAE}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.ActiveCfg = Debug|Win32
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|Win32.Build.0 = Debug|Win32
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.ActiveCfg = Debug|x64
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Debug|x64.Build.0 = Debug|x64
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.ActiveCfg = Release|Win32
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|Win32.Build.0 = Release|Win32
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.ActiveCfg = Release|x64
{F142A341-5EE0-442D-A15F-98AE9B48DBAE}.Release|x64.Build.0 = Release|x64
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.ActiveCfg = Debug|Win32
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|Win32.Build.0 = Debug|Win32
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.ActiveCfg = Debug|x64
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Debug|x64.Build.0 = Debug|x64
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.ActiveCfg = Release|Win32
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|Win32.Build.0 = Release|Win32
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.ActiveCfg = Release|x64
{027FAC75-3FDB-4044-8DD0-BC297BD4C461}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,174 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F142A341-5EE0-442D-A15F-98AE9B48DBAE}</ProjectGuid>
<RootNamespace>libMinHook</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)lib\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)lib\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)lib\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)lib\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\$(ProjectName)\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName).x86</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectName).x86</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName).x64</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName).x64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Lib />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;STRICT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
</ClCompile>
<Lib />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<WholeProgramOptimization>true</WholeProgramOptimization>
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
</ClCompile>
<Lib />
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>MinSpace</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;STRICT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>None</DebugInformationFormat>
<WholeProgramOptimization>true</WholeProgramOptimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
</ClCompile>
<Lib />
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\buffer.c" />
<ClCompile Include="..\..\src\HDE\hde32.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\HDE\hde64.c">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\hook.c" />
<ClCompile Include="..\..\src\trampoline.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\MinHook.h" />
<ClInclude Include="..\..\src\buffer.h" />
<ClInclude Include="..\..\src\HDE\hde32.h" />
<ClInclude Include="..\..\src\HDE\hde64.h" />
<ClInclude Include="..\..\src\HDE\pstdint.h" />
<ClInclude Include="..\..\src\HDE\table32.h" />
<ClInclude Include="..\..\src\HDE\table64.h" />
<ClInclude Include="..\..\src\trampoline.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\src\buffer.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\hook.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\trampoline.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\HDE\hde32.c">
<Filter>HDE</Filter>
</ClCompile>
<ClCompile Include="..\..\src\HDE\hde64.c">
<Filter>HDE</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\trampoline.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\buffer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\include\MinHook.h" />
<ClInclude Include="..\..\src\HDE\hde32.h">
<Filter>HDE</Filter>
</ClInclude>
<ClInclude Include="..\..\src\HDE\hde64.h">
<Filter>HDE</Filter>
</ClInclude>
<ClInclude Include="..\..\src\HDE\pstdint.h">
<Filter>HDE</Filter>
</ClInclude>
<ClInclude Include="..\..\src\HDE\table32.h">
<Filter>HDE</Filter>
</ClInclude>
<ClInclude Include="..\..\src\HDE\table64.h">
<Filter>HDE</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{9d24b740-be2e-4cfd-b9a4-340a50946ee9}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{76381bc7-2863-4cc5-aede-926ec2c506e4}</UniqueIdentifier>
</Filter>
<Filter Include="HDE">
<UniqueIdentifier>{56ddb326-6179-430d-ae19-e13bfd767bfa}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -195,7 +195,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
} }
for (; ht != table_end; ht += 2) for (; ht != table_end; ht += 2)
if (*ht++ == opcode) { if (*ht++ == opcode) {
if (*ht++ & pref && !((*ht << m_reg) & 0x80)) if ((*ht++ & pref) && !((*ht << m_reg) & 0x80))
goto error_operand; goto error_operand;
else else
break; break;
@ -246,6 +246,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
disp_size = 2; disp_size = 2;
if (!(pref & PRE_67)) if (!(pref & PRE_67))
disp_size <<= 1; disp_size <<= 1;
break;
} }
if (m_mod != 3 && m_rm == 4) { if (m_mod != 3 && m_rm == 4) {
@ -271,6 +272,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
case 4: case 4:
hs->flags |= F_DISP32; hs->flags |= F_DISP32;
hs->disp.disp32 = *(uint32_t *)p; hs->disp.disp32 = *(uint32_t *)p;
break;
} }
p += disp_size; p += disp_size;
} else if (pref & PRE_LOCK) } else if (pref & PRE_LOCK)

View File

@ -140,7 +140,7 @@ static PHOOK_ENTRY AddHookEntry()
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
static void DeleteHookEntry(UINT pos) static VOID DeleteHookEntry(UINT pos)
{ {
if (pos < g_hooks.size - 1) if (pos < g_hooks.size - 1)
g_hooks.pItems[pos] = g_hooks.pItems[g_hooks.size - 1]; g_hooks.pItems[pos] = g_hooks.pItems[g_hooks.size - 1];
@ -196,7 +196,7 @@ static DWORD_PTR FindNewIP(PHOOK_ENTRY pHook, DWORD_PTR ip)
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
static void ProcessThreadIPs(HANDLE hThread, UINT pos, UINT action) static VOID ProcessThreadIPs(HANDLE hThread, UINT pos, UINT action)
{ {
// If the thread suspended in the overwritten area, // If the thread suspended in the overwritten area,
// move IP to the proper address. // move IP to the proper address.
@ -260,8 +260,11 @@ static void ProcessThreadIPs(HANDLE hThread, UINT pos, UINT action)
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
static VOID EnumerateThreads(PFROZEN_THREADS pThreads) static BOOL EnumerateThreads(PFROZEN_THREADS pThreads)
{ {
LPDWORD p;
BOOL succeeded = FALSE;
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0); HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hSnapshot != INVALID_HANDLE_VALUE) if (hSnapshot != INVALID_HANDLE_VALUE)
{ {
@ -269,6 +272,7 @@ static VOID EnumerateThreads(PFROZEN_THREADS pThreads)
te.dwSize = sizeof(THREADENTRY32); te.dwSize = sizeof(THREADENTRY32);
if (Thread32First(hSnapshot, &te)) if (Thread32First(hSnapshot, &te))
{ {
succeeded = TRUE;
do do
{ {
if (te.dwSize >= (FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(DWORD)) if (te.dwSize >= (FIELD_OFFSET(THREADENTRY32, th32OwnerProcessID) + sizeof(DWORD))
@ -281,16 +285,22 @@ static VOID EnumerateThreads(PFROZEN_THREADS pThreads)
pThreads->pItems pThreads->pItems
= (LPDWORD)HeapAlloc(g_hHeap, 0, pThreads->capacity * sizeof(DWORD)); = (LPDWORD)HeapAlloc(g_hHeap, 0, pThreads->capacity * sizeof(DWORD));
if (pThreads->pItems == NULL) if (pThreads->pItems == NULL)
{
succeeded = FALSE;
break; break;
}
} }
else if (pThreads->size >= pThreads->capacity) else if (pThreads->size >= pThreads->capacity)
{ {
LPDWORD p = (LPDWORD)HeapReAlloc(
g_hHeap, 0, pThreads->pItems, (pThreads->capacity * 2) * sizeof(DWORD));
if (p == NULL)
break;
pThreads->capacity *= 2; pThreads->capacity *= 2;
p = (LPDWORD)HeapReAlloc(
g_hHeap, 0, pThreads->pItems, pThreads->capacity * sizeof(DWORD));
if (p == NULL)
{
succeeded = FALSE;
break;
}
pThreads->pItems = p; pThreads->pItems = p;
} }
pThreads->pItems[pThreads->size++] = te.th32ThreadID; pThreads->pItems[pThreads->size++] = te.th32ThreadID;
@ -298,20 +308,35 @@ static VOID EnumerateThreads(PFROZEN_THREADS pThreads)
te.dwSize = sizeof(THREADENTRY32); te.dwSize = sizeof(THREADENTRY32);
} while (Thread32Next(hSnapshot, &te)); } while (Thread32Next(hSnapshot, &te));
if (succeeded && GetLastError() != ERROR_NO_MORE_FILES)
succeeded = FALSE;
if (!succeeded && pThreads->pItems != NULL)
{
HeapFree(g_hHeap, 0, pThreads->pItems);
pThreads->pItems = NULL;
}
} }
CloseHandle(hSnapshot); CloseHandle(hSnapshot);
} }
return succeeded;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
static VOID Freeze(PFROZEN_THREADS pThreads, UINT pos, UINT action) static MH_STATUS Freeze(PFROZEN_THREADS pThreads, UINT pos, UINT action)
{ {
MH_STATUS status = MH_OK;
pThreads->pItems = NULL; pThreads->pItems = NULL;
pThreads->capacity = 0; pThreads->capacity = 0;
pThreads->size = 0; pThreads->size = 0;
EnumerateThreads(pThreads); if (!EnumerateThreads(pThreads))
{
if (pThreads->pItems != NULL) status = MH_ERROR_MEMORY_ALLOC;
}
else if (pThreads->pItems != NULL)
{ {
UINT i; UINT i;
for (i = 0; i < pThreads->size; ++i) for (i = 0; i < pThreads->size; ++i)
@ -325,6 +350,8 @@ static VOID Freeze(PFROZEN_THREADS pThreads, UINT pos, UINT action)
} }
} }
} }
return status;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -414,19 +441,21 @@ static MH_STATUS EnableAllHooksLL(BOOL enable)
if (first != INVALID_HOOK_POS) if (first != INVALID_HOOK_POS)
{ {
FROZEN_THREADS threads; FROZEN_THREADS threads;
Freeze(&threads, ALL_HOOKS_POS, enable ? ACTION_ENABLE : ACTION_DISABLE); status = Freeze(&threads, ALL_HOOKS_POS, enable ? ACTION_ENABLE : ACTION_DISABLE);
if (status == MH_OK)
for (i = first; i < g_hooks.size; ++i)
{ {
if (g_hooks.pItems[i].isEnabled != enable) for (i = first; i < g_hooks.size; ++i)
{ {
status = EnableHookLL(i, enable); if (g_hooks.pItems[i].isEnabled != enable)
if (status != MH_OK) {
break; status = EnableHookLL(i, enable);
if (status != MH_OK)
break;
}
} }
}
Unfreeze(&threads); Unfreeze(&threads);
}
} }
return status; return status;
@ -644,11 +673,13 @@ MH_STATUS WINAPI MH_RemoveHook(LPVOID pTarget)
if (g_hooks.pItems[pos].isEnabled) if (g_hooks.pItems[pos].isEnabled)
{ {
FROZEN_THREADS threads; FROZEN_THREADS threads;
Freeze(&threads, pos, ACTION_DISABLE); status = Freeze(&threads, pos, ACTION_DISABLE);
if (status == MH_OK)
{
status = EnableHookLL(pos, FALSE);
status = EnableHookLL(pos, FALSE); Unfreeze(&threads);
}
Unfreeze(&threads);
} }
if (status == MH_OK) if (status == MH_OK)
@ -687,17 +718,19 @@ static MH_STATUS EnableHook(LPVOID pTarget, BOOL enable)
} }
else else
{ {
FROZEN_THREADS threads;
UINT pos = FindHookEntry(pTarget); UINT pos = FindHookEntry(pTarget);
if (pos != INVALID_HOOK_POS) if (pos != INVALID_HOOK_POS)
{ {
if (g_hooks.pItems[pos].isEnabled != enable) if (g_hooks.pItems[pos].isEnabled != enable)
{ {
Freeze(&threads, pos, ACTION_ENABLE); FROZEN_THREADS threads;
status = Freeze(&threads, pos, ACTION_ENABLE);
if (status == MH_OK)
{
status = EnableHookLL(pos, enable);
status = EnableHookLL(pos, enable); Unfreeze(&threads);
}
Unfreeze(&threads);
} }
else else
{ {
@ -804,20 +837,22 @@ MH_STATUS WINAPI MH_ApplyQueued(VOID)
if (first != INVALID_HOOK_POS) if (first != INVALID_HOOK_POS)
{ {
FROZEN_THREADS threads; FROZEN_THREADS threads;
Freeze(&threads, ALL_HOOKS_POS, ACTION_APPLY_QUEUED); status = Freeze(&threads, ALL_HOOKS_POS, ACTION_APPLY_QUEUED);
if (status == MH_OK)
for (i = first; i < g_hooks.size; ++i)
{ {
PHOOK_ENTRY pHook = &g_hooks.pItems[i]; for (i = first; i < g_hooks.size; ++i)
if (pHook->isEnabled != pHook->queueEnable)
{ {
status = EnableHookLL(i, pHook->queueEnable); PHOOK_ENTRY pHook = &g_hooks.pItems[i];
if (status != MH_OK) if (pHook->isEnabled != pHook->queueEnable)
break; {
status = EnableHookLL(i, pHook->queueEnable);
if (status != MH_OK)
break;
}
} }
}
Unfreeze(&threads); Unfreeze(&threads);
}
} }
} }
else else
@ -846,7 +881,7 @@ MH_STATUS WINAPI MH_CreateHookApiEx(
if (pTarget == NULL) if (pTarget == NULL)
return MH_ERROR_FUNCTION_NOT_FOUND; return MH_ERROR_FUNCTION_NOT_FOUND;
if(ppTarget != NULL) if (ppTarget != NULL)
*ppTarget = pTarget; *ppTarget = pTarget;
return MH_CreateHook(pTarget, pDetour, ppOriginal); return MH_CreateHook(pTarget, pDetour, ppOriginal);
@ -856,11 +891,11 @@ MH_STATUS WINAPI MH_CreateHookApiEx(
MH_STATUS WINAPI MH_CreateHookApi( MH_STATUS WINAPI MH_CreateHookApi(
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal) LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal)
{ {
return MH_CreateHookApiEx(pszModule, pszProcName, pDetour, ppOriginal, NULL); return MH_CreateHookApiEx(pszModule, pszProcName, pDetour, ppOriginal, NULL);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
const char * WINAPI MH_StatusToString(MH_STATUS status) const char *WINAPI MH_StatusToString(MH_STATUS status)
{ {
#define MH_ST2STR(x) \ #define MH_ST2STR(x) \
case x: \ case x: \

View File

@ -28,7 +28,8 @@
#include <windows.h> #include <windows.h>
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(MINHOOK_DISABLE_INTRINSICS)
#define ALLOW_INTRINSICS
#include <intrin.h> #include <intrin.h>
#endif #endif
@ -152,7 +153,7 @@ BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
PUINT32 pRelAddr; PUINT32 pRelAddr;
// Avoid using memcpy to reduce the footprint. // Avoid using memcpy to reduce the footprint.
#ifndef _MSC_VER #ifndef ALLOW_INTRINSICS
memcpy(instBuf, (LPBYTE)pOldInst, copySize); memcpy(instBuf, (LPBYTE)pOldInst, copySize);
#else #else
__movsb(instBuf, (LPBYTE)pOldInst, copySize); __movsb(instBuf, (LPBYTE)pOldInst, copySize);
@ -208,7 +209,7 @@ BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
pCopySrc = &jmp; pCopySrc = &jmp;
copySize = sizeof(jmp); copySize = sizeof(jmp);
// Exit the function If it is not in the branch // Exit the function if it is not in the branch.
finished = (pOldInst >= jmpDest); finished = (pOldInst >= jmpDest);
} }
} }
@ -277,15 +278,14 @@ BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
ct->nIP++; ct->nIP++;
// Avoid using memcpy to reduce the footprint. // Avoid using memcpy to reduce the footprint.
#ifndef _MSC_VER #ifndef ALLOW_INTRINSICS
memcpy((LPBYTE)ct->pTrampoline + newPos, pCopySrc, copySize); memcpy((LPBYTE)ct->pTrampoline + newPos, pCopySrc, copySize);
#else #else
__movsb((LPBYTE)ct->pTrampoline + newPos, pCopySrc, copySize); __movsb((LPBYTE)ct->pTrampoline + newPos, (LPBYTE)pCopySrc, copySize);
#endif #endif
newPos += copySize; newPos += copySize;
oldPos += hs.len; oldPos += hs.len;
} } while (!finished);
while (!finished);
// Is there enough place for a long jump? // Is there enough place for a long jump?
if (oldPos < sizeof(JMP_REL) if (oldPos < sizeof(JMP_REL)