If you call ICorProfilerInfo::GetModuleMetaData with dwOpenFlags =
ofWrite and riid = IID_IMetaDataEmit, it should give you back a
writeable metadata interface. You should be then able to create a new
tokens through it on the fly.

As you can see from many comments and names in the related code, this
functionality was also used to implement the prototype of
Edit'n'Continue (not part of Rotor), so it should be powerful enough for
your needs.

-Jan

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Mikunov, Aleksandr [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, August 15, 2002 4:40 PM
To: Jan Kotas; '[EMAIL PROTECTED]';
'[EMAIL PROTECTED]'
Subject: [Dotnet-sscli] Rotor instrumentation - II


Hi Jan,

Once again thank you for the answer.

I keep working on this stuff making some good progress and I recently
found that the ICorProfilerInfo::SetILFunctionBody function has some
limitations. As far as I know, since the local variables signature
should be declared in the StandAloneSig table ( 0x11000000 token ),
we're not able to use local variables in the new function:

.method public ... NewFunction( ... )
{
 .maxstack 10
 .locals init ( ... )
 ...
}

Is this correct?

I found one solution - not to use local variables at all.
Is there any other workaround?


Thanks.
Alex

 

-----Original Message-----
From: Jan Kotas
To: Mikunov, Aleksandr; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: 7/19/02 3:25 PM
Subject: RE: [Dotnet-sscli] Rotor instrumentation

Both the method renaming and stub interceptors you have described could
be workable with enough effort. But as you have discovered they will
require a very profound changes across the execution engine to fix all
interactions, especially the security stack walk.

A problem similar to yours has been solved for the profiling interfaces
in the execution engine. The profilers often want to modify the method
prolog and epilog to insert customized probes. The architects of the
execution engine decided that the best way to achieve this is to allow
profilers to modify the IL code of the method - check
ICorProfilerInfo::SetILFunctionBody(). Simple and powerful interface.

So I would probably implement what your are looking for by changing the
IL of the method, although you think this being the hard way. As
developer of large software projects I know more than well how important
is to keep the interface between my feature and the rest of the world
simple and to don't scatter my feature all over the place.

If you believe the rehashing of the IL is too hard, you could try to
create a special callback from the JIT to provide a custom IL for prolog
and epilog. The good places to insert these callbacks is when the lock
is entered/leaved for synchronized methods - look for CORINFO_FLG_SYNCH
in clr\src\fjit\fjit.cpp. A bit of code shuffling in the fjit is
necessary to get the main JIT loop to be called once for the prolog, the
method body and the epilog.

-Jan

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Mikunov, Aleksandr [mailto:[EMAIL PROTECTED]] 
Sent: Friday, July 19, 2002 11:10 AM
To: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]'
Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]';
'[EMAIL PROTECTED]'
Subject: [Dotnet-sscli] Rotor instrumentation



The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.  

Reply via email to