Recreate DCE'd method for use with DLL injection

25 Views Asked by At

I'm writing a mod for a game using DLL injection (specifically Unity Doorstop). My mod uses an external package not specifically meant for DLL injection, in this case it's MoonSharp.

I have a problem where the game's System.dll file seems to have been rid of the setter for System.Collection.Generic.LinkedListNode.Value, as inspecting the DLL in ILSpy shows only a getter. I suspect Dead Code Elimination since every spec I've been able to read (and my own inspection of my system's System.dll) shows that a setter exists. MoonSharp's code unfortunately makes use of this setter, which throws a MethodNotFound exception on the call site. I've been able to replicate this outside of MoonSharp so I know it's not the lib's fault.

I haven't been able to replace the game's System.dll file successfully since my project only seems to output a reference assembly with no function bodies. I'm not terribly familiar with C# in general, so my question is as follows: is there a way around this situation? My non-educated guesses are:

  • defining the setter out-of-source, but this sounds impossible since LinkedListNode is sealed and its item member (which Value accesses) is marked internal.
  • rewriting LinkedListNode entirely and somehow making everything use that instead of System.Collection.Generic.LinkedListNode

Any ideas?

0

There are 0 best solutions below