Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
Fix lockup logic
Browse files Browse the repository at this point in the history
Harmony seems to be locking the file anyway during PatchAll, which causes a questionable state where the patcher cannot find the target method.
  • Loading branch information
misandrie committed May 24, 2024
1 parent ed3b7a6 commit 15528cd
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Marsey/Misc/FileHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static void LoadAssemblies(string[]? path = null, bool pipe = false, stri
foreach (string file in files)
{
MarseyLogger.Log(MarseyLogger.LogType.DEBG, $"Loading assembly from {file}");
LoadExactAssembly(file);
LoadExactAssembly(file, pipe);
}
}

Expand All @@ -112,15 +112,24 @@ public static List<string> GetFilesFromPipe(string name)
/// Loads an assembly from the specified file path and initializes it.
/// </summary>
/// <param name="file">The file path of the assembly to load.</param>
public static void LoadExactAssembly(string file)
/// <param name="lockup">Load from the dll directly instead of reading from file</param>
public static void LoadExactAssembly(string file, bool lockup = false)
{
Redial.Disable(); // Disable any AssemblyLoad callbacks found

try
{
byte[] assemblyData = File.ReadAllBytes(file);
Assembly assembly = Assembly.Load(assemblyData);
AssemblyInitializer.Initialize(assembly, file);
if (lockup)
{
Assembly assembly = Assembly.LoadFrom(file);
AssemblyInitializer.Initialize(assembly, assembly.Location);
}
else
{
byte[] assemblyData = File.ReadAllBytes(file);
Assembly assembly = Assembly.Load(assemblyData);
AssemblyInitializer.Initialize(assembly, file);
}
}
catch (FileNotFoundException)
{
Expand Down

0 comments on commit 15528cd

Please sign in to comment.