summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework/ModLoading/Rewriters/ArchitectureAssemblyRewriter.cs
blob: cc8302161277f28cab30bf5b8356a4c554cd6cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Mono.Cecil;
using StardewModdingAPI.Framework.ModLoading.Framework;

namespace StardewModdingAPI.Framework.ModLoading.Rewriters
{
    /// <summary>Removes the 32-bit-only from loaded assemblies.</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 &= ~ModuleAttributes.Required32Bit;
                this.MarkRewritten();
                return true;
            }

            return false;
        }

    }
}