[Mono-dev] Unity - patching methods
pardeike
andreas at pardeike.net
Sat Jan 21 12:46:17 UTC 2017
Hi,
I am trying to replace methods during runtime. Lots of existing ways do this
by
simply inserting a jump at assembler level from the original to the new
method.
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
expert
in when mono jitts its methods and vaguely know about trampolines and it
looks
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
gives
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
experienced
developer but just not familiar with the specific area. I can read c# and c
and
tried to understand the mono repository code and will continue to do so. I
though
it would be nice to ask in parallel here.
Thanks,
Andreas
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