Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Getting class objects using ICoreprofiler

$
0
0

Hi, 

I am trying to get the parent class object of the called function using ICoreprofilerCallback/ICoreprofilerInfo2 APIs.

What i want to do is

So my parent class

public class TestManagedClass{

public int somevalue;

public SecondDotNetClass cls;

......

public void MyFunction(some args);

}

I am using ICoreprofiler and getting the call back when the the function 'MyFunction' being called with functionId,clientdata,frameinfo and argument info.

Once i am here, i call GetFunctionInfo2 and get the class id. Now what i want to do is get this information and pass it on to the manged layer and pass some kind of pointer there so that i can do something like this.

IntPtr p = (IntPtr)Ptr;
        GCHandle handle2 = (GCHandle)p;
        TestManagedClass objOfInterest= (handle2.Target as TestManagedClass);

I am looking at GetBoxClassLayout or GetClassLayout kind of methods so that i can extract the GCHandle or something similar to it, with which i can get the managed object back. Does any of these sound reasonable ? Or do i have to hook to some other call back so that i can map the class id to GCHandle? 

Thank in advance for your advice!


itsgPhere


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>