parsing method byte codes

Can anyone give me some hints about my question below

The following delegate returns the further following byte codes (read on):

Func<TestClass, bool> function;

function = delegate(TestClass test)

{

return test.Name.Contains("my");

};

0

2

111

1

0

0

6

114

91

0

0

112

111

33

0

0

10

10

43

0

6

42

I found that code 111 is a callvirt, fine...and i also noticed that there are always 4 codes after a callvirt. I assume these represent information about the function being called at the callvirt op. If this is the case, how do i use these codes to derive the correct function being called



Answer this question

parsing method byte codes

  • DuckJones

    What follows is an encoded method token. Have you read the ECMA CLI spec so you know what a token is and how to decode encoded ones Once you do that you can use it to look up the target method.



  • Karthikeyan S

    Shortly after I posted this thread, I came across the CLI spec. I haven't gotten through all I need to figure this out, but I'm working on it. Thanks for your guidance.


  • Dale N

    If you're using .NET Framework 2.0 you can call Module.ResolveMethod once the token has been decoded.



  • Paul_Holliday

    Are there any .NET Framework constructs to decode the token, or is that normally a "roll your own" thing Forgive my ignorance...I've never messed around in this low of a level before.
  • reader25

    alright, so after reading the CLI docs, I now understand that the following would mean I have to look into the 6th row of the metadata table represented by the 1 to determine what method this callvirt op is referencing.

    111

    1

    0

    0

    6

    Question, now, is what .NET constructs can I use to access this information


  • parsing method byte codes