pardeike / Harmony

A library for patching, replacing and decorating .NET and Mono methods during runtime
https://www.patreon.com/pardeike
MIT License
5.16k stars 486 forks source link

Double assembly after patching #516

Closed deltaone closed 1 year ago

deltaone commented 1 year ago
  1. Load target assembly through Assembly.Load(File.ReadAllBytes(targetPath));
  2. Apply PatchAll()
  3. We get two same loaded assembly: one unpatched loaded from memory and one patched loaded from disk

How to patch assembly loaded from memory ? As workaround - i rename assembly on disk and apply path, then patch apply on assembly loaded from memory ...

THX!

pardeike commented 1 year ago

Harmony does not load any assemblies. This must be an oversight on your side.

deltaone commented 1 year ago

Look in code ...

/// !!! HERE !!!
Assembly game = Assembly.Load(File.ReadAllBytes(Path.Combine(AssemblyFolder, "target.exe")));
//Assembly game = Assembly.LoadFile(Path.Combine(AssemblyFolder, "target.exe"));

double.zip

pardeike commented 1 year ago

How is this related to Harmony. The code you posted is not part of Harmony. Please use the official discord for support questions and leave GitHub Issues for bugs in the library.

deltaone commented 1 year ago

https://github.com/pardeike/Harmony/files/11060796/double.zip