Re: Force Rejit of a method

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



IMO you cannot jit a method with is already loaded you first have to unload
the assembly where the code belongs to and then reload it with
assembly.load.


"Dinis Cruz" <dinis.cruz@xxxxxxxxx> schrieb im Newsbeitrag
news:444D45C6.20506@xxxxxxxxxxxx
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@xxxxxxxxx> ha scritto nel messaggio
news:%23qqAogAZGHA.3752@xxxxxxxxxxxxxxxxxxxxxxx
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





.



Relevant Pages

  • Re: Force Rejit of a method
    ... memory writes ). ... Unmanaged patch - Re-Writing Assembly code directly on the method's ... MSIL patch - Re-Write MSIL on .Net methods. ... One of the demos that I do in my 'Rooting the CLR' presentation is to do ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Salamander .NET Linker Tool 2.0 Released
    ... > Link assemblies together, compile MSIL to native code, deploy without ... > Framework installation, stop reverse engineering, all in one. ... > assemblies together into a single file, ...
    (microsoft.public.dotnet.framework)
  • Re: Steps Involved in transforming the code to MSIL
    ... The CLR loads, verifies, JIT compiles MSIL and runs native code in a particular app-domain. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Managed, Unmanaged, Native Concepts Questions?
    ... //code and members ... Class A code is MSIL executed by the CLR ... Class B is a native type (because it does not use new language ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Steps Involved in transforming the code to MSIL
    ... involved by CLR to convert the code to MSIL. ... Find great Windows Forms articles in Windows Forms Tips and Tricks ...
    (microsoft.public.dotnet.framework.windowsforms)