-
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.
Modernized modloader, make it actually replace patched assemblies
- Loading branch information
1 parent
b398807
commit e5f7c07
Showing
8 changed files
with
90 additions
and
32 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-18.3 KB
modloader/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3/.signature.p7s
Binary file not shown.
Binary file removed
BIN
-6.54 MB
...erenceAssemblies.net35.1.0.3/Microsoft.NETFramework.ReferenceAssemblies.net35.1.0.3.nupkg
Binary file not shown.
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" /> | ||
</packageSources> | ||
</configuration> |
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,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Reflection; | ||
using Mono.Cecil; | ||
|
||
namespace modloader | ||
{ | ||
public static class Patcher | ||
{ | ||
public static IEnumerable<string> TargetDLLs => GetDLLs(); | ||
|
||
public static IEnumerable<string> GetDLLs() | ||
{ | ||
string codeBase = Assembly.GetExecutingAssembly().CodeBase; | ||
UriBuilder uri = new UriBuilder(codeBase); | ||
string path = Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)), "replace"); | ||
|
||
if (Directory.Exists(path)) | ||
{ | ||
foreach (string assembly in Directory.GetFiles(path, "*.dll", SearchOption.TopDirectoryOnly)) | ||
{ | ||
Console.WriteLine("Found Assembly replacement at " + assembly); | ||
string fileName = Path.GetFileName(assembly); | ||
yield return fileName; | ||
} | ||
} | ||
} | ||
|
||
// Patches the assemblies | ||
public static void Patch(ref AssemblyDefinition assembly) | ||
{ | ||
Console.WriteLine("Replacing " + assembly.FullName); | ||
|
||
string codeBase = Assembly.GetExecutingAssembly().CodeBase; | ||
UriBuilder uri = new UriBuilder(codeBase); | ||
string path = Path.Combine(Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)), "replace"); | ||
if (Directory.Exists(path)) | ||
{ | ||
assembly = AssemblyDefinition.ReadAssembly(Path.Combine(path, assembly.Name.Name + ".dll")); | ||
} | ||
else | ||
{ | ||
Console.WriteLine("Replacment path is gone??? No game Assembles will be patched!"); | ||
} | ||
} | ||
} | ||
} |
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net35</TargetFramework> | ||
<AssemblyName>modloader</AssemblyName> | ||
<Description>My first plugin</Description> | ||
<Version>1.0.0</Version> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<LangVersion>latest</LangVersion> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BepInEx.Analyzers" Version="1.*" PrivateAssets="all" /> | ||
<PackageReference Include="BepInEx.Core" Version="5.*" /> | ||
<PackageReference Include="BepInEx.PluginInfoProps" Version="1.*" /> | ||
<PackageReference Include="UnityEngine.Modules" Version="5.3.4" IncludeAssets="compile" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'"> | ||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2" PrivateAssets="all" /> | ||
</ItemGroup> | ||
</Project> |
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 |
---|---|---|
@@ -1,16 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Doorstop", "Doorstop\Doorstop.csproj", "{ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}" | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.002.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "modloader", "modloader.csproj", "{E4FAB302-FC55-4F05-81DE-B43652B4AA13}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ED48B984-7FF8-4BED-9C31-9110F3FB3A4B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E4FAB302-FC55-4F05-81DE-B43652B4AA13}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {1F587C02-7DCD-4A3A-8F81-A54ABCCB9808} | ||
EndGlobalSection | ||
EndGlobal |