![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, Is there a way to force the ReJit of a method? One of the demos that I do in my 'Rooting the CLR' presentation is to do real time MSIL patching. The problem is that I need to apply the 'patches' before the JIT has occurred, unless (hence my question) I am able to dynamically either: - ReJit a method - Mark a method as not Jitted (whereby it is Jitted the next time that method is invoked) Looking at the symbols of a CLR dll (can't remember the name now) I know that there is a internal way to do this on the CLR (after all (if I remember correctly) that is one of the methods available to the GC to reclaim memory). Thanks, Dinis Cruz Owasp .Net Project www.owasp.net |
#3
| |||
| |||
|
|
I don't know how you "patch" the methods, but I have used MethodRental class from System.Reflection.Emit. It has JitImmediate and JitOnDemand methods to recompile methods. Laura. "Dinis Cruz" <dinis.cruz (AT) owasp (DOT) net> ha scritto nel messaggio news:%23qqAogAZGHA.3752 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello, Is there a way to force the ReJit of a method? One of the demos that I do in my 'Rooting the CLR' presentation is to do real time MSIL patching. The problem is that I need to apply the 'patches' before the JIT has occurred, unless (hence my question) I am able to dynamically either: - ReJit a method - Mark a method as not Jitted (whereby it is Jitted the next time that method is invoked) Looking at the symbols of a CLR dll (can't remember the name now) I know that there is a internal way to do this on the CLR (after all (if I remember correctly) that is one of the methods available to the GC to reclaim memory). Thanks, Dinis Cruz Owasp .Net Project www.owasp.net |
#4
| |||
| |||
|
|
Hello Laura, There are two types of patches that I do in my demos (both using direct memory writes (after unlocking the relevant memory pages)). 1) Unmanaged patch - Re-Writing Assembly code directly on the method's code. Used for example to patch the CLR so that you can load 'corrupted Strong Named Assemblies' 2) MSIL patch - Re-Write MSIL on .Net methods. If you know the exact location of the method this is a simple case of replacing the existing MSIL code with the new one (although at the moment I am limited to the size of the original MSIL code (there are some guys who did a very interesting research on 'self healing code' which had a solution for this problem)) Regarding JitImmediate and JitOnDemand, I have not looked at them, but I don't think they will allow me to do what I want to do (which is to patch managed methods that are already loaded in memory) Best Regards Dinis Cruz Owasp .Net Project www.owasp.net Laura T. wrote: I don't know how you "patch" the methods, but I have used MethodRental class from System.Reflection.Emit. It has JitImmediate and JitOnDemand methods to recompile methods. Laura. "Dinis Cruz" <dinis.cruz (AT) owasp (DOT) net> ha scritto nel messaggio news:%23qqAogAZGHA.3752 (AT) TK2MSFTNGP03 (DOT) phx.gbl... Hello, Is there a way to force the ReJit of a method? One of the demos that I do in my 'Rooting the CLR' presentation is to do real time MSIL patching. The problem is that I need to apply the 'patches' before the JIT has occurred, unless (hence my question) I am able to dynamically either: - ReJit a method - Mark a method as not Jitted (whereby it is Jitted the next time that method is invoked) Looking at the symbols of a CLR dll (can't remember the name now) I know that there is a internal way to do this on the CLR (after all (if I remember correctly) that is one of the methods available to the GC to reclaim memory). Thanks, Dinis Cruz Owasp .Net Project www.owasp.net |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Use ICorProfilerInfo::SetFunctionReJIT(). -John http://www.iunknown.com |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |