Getting method's arguments when ILRewriting

Oct 7, 2016 at 9:52 AM
Hi all,

I am working on a profiler/tracer for .NET, which is designed to built distributed tracing without the need to actually change the code of the profilee.
Doing so, I started out with rewriting the IL of methods I am interested in. To add meaning to the traces, I need to gather not only a reference of the object on which the instrumented method has been called, but also references to all the parameters that have been passed to that method.
So far I intercept the JIT of the methods, rewrite their IL to call my tracing methods on enter and exit and pass the called object as a parameter.
For the arguments of the method, I'm a little stuck.
I think the only information I really need in the first place is the number of arguments passed to the method, so that I can ldarg.N them in IL.
Does anyone have an example on that?

Thanks in advance!

Dec 19, 2016 at 7:55 AM
Hi again,

ich actually managed to get the arguments some time ago by parsing the signature of the method. Sorry for not updating the question (althoigh nobody read it apparently :-) ).
Marked as answer by kristofberger on 12/18/2016 at 11:55 PM
Jan 25 at 5:21 PM

How can we get the arguments passed to any .Net function as i'm also working on the tracer functionality. It looks like COR_PRF_FUNCTION_ARGUMENT_INFO is the approach, but not sure or any examples?