-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "../../Shared-ASI/Interface.h" | ||
#include "../../Shared-ASI/Common.h" | ||
|
||
SPI_PLUGINSIDE_SUPPORT(L"LE2HotReload", L"1.0.0", L"ME3Tweaks", SPI_GAME_LE2, SPI_VERSION_LATEST); | ||
SPI_PLUGINSIDE_PRELOAD; | ||
SPI_PLUGINSIDE_ASYNCATTACH; | ||
|
||
/** | ||
* \brief Patches a segment of process memory. | ||
* \param address The address to start the overwrite of patch data to | ||
* \param patch The patch data | ||
* \param patchSize The size of patch | ||
* \return true if patched, false otherwise | ||
*/ | ||
bool PatchMemory(void* address, const void* patch, const SIZE_T patchSize) | ||
{ | ||
//make the memory we're going to patch writeable | ||
DWORD oldProtect; | ||
if (!VirtualProtect(address, patchSize, PAGE_EXECUTE_READWRITE, &oldProtect)) | ||
return false; | ||
|
||
//overwrite with our patch | ||
memcpy(address, patch, patchSize); | ||
|
||
//restore the memory's old protection level | ||
VirtualProtect(address, patchSize, oldProtect, &oldProtect); | ||
FlushInstructionCache(GetCurrentProcess(), address, patchSize); | ||
return true; | ||
} | ||
|
||
void* PatchOffset; | ||
const BYTE patchData[] = { 0x03 }; | ||
SPI_IMPLEMENT_ATTACH | ||
{ | ||
//Common::OpenConsole(); | ||
INIT_FIND_PATTERN(PatchOffset, "01 ff 15 97 41 f0 00 48 89 06 48 83 f8"); | ||
if (PatchOffset != nullptr) | ||
{ | ||
PatchMemory(PatchOffset, patchData , 1); | ||
writeln("Patched for hot reload at %p", PatchOffset); | ||
} else | ||
{ | ||
writeln("Failed to patch for hot reload"); | ||
} | ||
} | ||
|
||
|
||
SPI_IMPLEMENT_DETACH | ||
{ | ||
return true; | ||
} | ||
|
||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID) { | ||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<Keyword>Win32Proj</Keyword> | ||
<ProjectGuid>{D56CAF33-BA78-4541-98EE-02BCD292EECF}</ProjectGuid> | ||
<RootNamespace>SeqActLog Enabler</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
<ProjectName>LE2HotReload</ProjectName> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>DynamicLibrary</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v143</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
<TargetExt>.asi</TargetExt> | ||
<TargetName>LE2HotReload</TargetName> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
<TargetExt>.asi</TargetExt> | ||
<TargetName>LE2HotReload</TargetName> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>ASI_DEBUG;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>false</ConformanceMode> | ||
<LanguageStandard>stdcpp17</LanguageStandard> | ||
<LanguageStandard_C>stdc17</LanguageStandard_C> | ||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions> | ||
<MultiProcessorCompilation>true</MultiProcessorCompilation> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<WarningLevel>Level3</WarningLevel> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>false</ConformanceMode> | ||
<LanguageStandard>stdcpp17</LanguageStandard> | ||
<LanguageStandard_C>stdc17</LanguageStandard_C> | ||
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions> | ||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="LE2HotReload.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="HookPrototypes.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |