summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs6
-rw-r--r--src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs7
-rw-r--r--src/SMAPI/Framework/SCore.cs15
3 files changed, 22 insertions, 6 deletions
diff --git a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs
index be0c18ce..2636aae0 100644
--- a/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs
+++ b/src/SMAPI.Toolkit/Framework/LowLevelEnvironmentUtility.cs
@@ -90,10 +90,10 @@ namespace StardewModdingAPI.Toolkit.Framework
}
/// <summary>Get whether an executable is 64-bit.</summary>
- /// <param name="executablePath">The absolute path to the executable file.</param>
- public static bool Is64BitAssembly(string executablePath)
+ /// <param name="path">The absolute path to the assembly file.</param>
+ public static bool Is64BitAssembly(string path)
{
- return AssemblyName.GetAssemblyName(executablePath).ProcessorArchitecture != ProcessorArchitecture.X86;
+ return AssemblyName.GetAssemblyName(path).ProcessorArchitecture != ProcessorArchitecture.X86;
}
diff --git a/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs b/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs
index 62bd13cd..6de79a85 100644
--- a/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs
+++ b/src/SMAPI.Toolkit/Utilities/EnvironmentUtility.cs
@@ -46,5 +46,12 @@ namespace StardewModdingAPI.Toolkit.Utilities
{
return LowLevelEnvironmentUtility.GetExecutableName(platform.ToString());
}
+
+ /// <summary>Get whether an executable is 64-bit.</summary>
+ /// <param name="path">The absolute path to the assembly file.</param>
+ public static bool Is64BitAssembly(string path)
+ {
+ return LowLevelEnvironmentUtility.Is64BitAssembly(path);
+ }
}
}
diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs
index 5fb4aa03..dff0fc55 100644
--- a/src/SMAPI/Framework/SCore.cs
+++ b/src/SMAPI/Framework/SCore.cs
@@ -1704,12 +1704,21 @@ namespace StardewModdingAPI.Framework
// load as mod
else
{
+ // get mod info
IManifest manifest = mod.Manifest;
+ string assemblyPath = Path.Combine(mod.DirectoryPath, manifest.EntryDll);
+
+ // assert 64-bit
+#if SMAPI_FOR_WINDOWS_64BIT_HACK
+ if (!EnvironmentUtility.Is64BitAssembly(assemblyPath))
+ {
+ errorReasonPhrase = "it needs to be updated for 64-bit mode.";
+ failReason = ModFailReason.LoadFailed;
+ return false;
+ }
+#endif
// load mod
- string assemblyPath = manifest?.EntryDll != null
- ? Path.Combine(mod.DirectoryPath, manifest.EntryDll)
- : null;
Assembly modAssembly;
try
{