[Mono-dev] Unity - patching methods

pardeike andreas at pardeike.net
Sat Jan 21 12:46:17 UTC 2017

I am trying to replace methods during runtime. Lots of existing ways do this
simply inserting a jump at assembler level from the original to the new
I want to do this too but with the new method being a DynamicMethod (or a 
delegate to it).

I did solve the IL part of it but testing it with a game (RimWorld) that
uses Unity 
I find it crashes when I try my code with more than one method. I am no
in when mono jitts its methods and vaguely know about trampolines and it
like the memory area that you get with GetFunctionPtr() does change compared 
to when I write a jump to it into the original and that changed assembler
me all sort of crashes. Interestingly, the other method using exactly the
same way 
to patch it works.

So any pointers, ideas or suggestions welcome. I am in general an
developer but just not familiar with the specific area. I can read c# and c
tried to understand the mono repository code and will continue to do so. I
it would be nice to ask in parallel here.


PS: my (not complete project) is here: https://github.com/pardeike/Harmony

View this message in context: http://mono.1490590.n4.nabble.com/Unity-patching-methods-tp4669765.html
Sent from the Mono - Dev mailing list archive at Nabble.com.

More information about the Mono-devel-list mailing list