summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs
diff options
context:
space:
mode:
authorChase Warrington <spacechase0.and.cat@gmail.com>2021-08-29 15:48:28 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2021-09-01 19:35:18 -0400
commitec5fbb06113b29342e6d4b213144f4dc3e358b03 (patch)
tree2a0d1677b4b94380a67a194e3e2041fd892b80c9 /src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs
parent9316fe303827cb31f38f4a5bb068f8fa0190ac5e (diff)
downloadSMAPI-ec5fbb06113b29342e6d4b213144f4dc3e358b03.tar.gz
SMAPI-ec5fbb06113b29342e6d4b213144f4dc3e358b03.tar.bz2
SMAPI-ec5fbb06113b29342e6d4b213144f4dc3e358b03.zip
Rewrite 32-bit assemblies for 64-bit
Diffstat (limited to 'src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs')
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs
new file mode 100644
index 00000000..216c042a
--- /dev/null
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs
@@ -0,0 +1,34 @@
+using System;
+using HarmonyLib;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+using StardewModdingAPI.Framework.ModLoading.Framework;
+using StardewModdingAPI.Framework.ModLoading.RewriteFacades;
+
+namespace StardewModdingAPI.Framework.ModLoading.Rewriters
+{
+ /// <summary>Rewrites Harmony 1.x assembly references to work with Harmony 2.x.</summary>
+ internal class ArchitectureAssemblyRewriter : BaseInstructionHandler
+ {
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Construct an instance.</summary>
+ public ArchitectureAssemblyRewriter()
+ : base(defaultPhrase: "32-bit architecture") { }
+
+
+ /// <inheritdoc />
+ public override bool Handle( ModuleDefinition module )
+ {
+ if ( module.Attributes.HasFlag( ModuleAttributes.Required32Bit ) )
+ {
+ module.Attributes = module.Attributes & ~ModuleAttributes.Required32Bit;
+ this.MarkRewritten();
+ return true;
+ }
+ return false;
+ }
+
+ }
+}