Jump to content
Tuts 4 You

How to get the real method from MethodTyPar


CodeExplorer

Recommended Posts

Posted
tablesinfo[0x2B].Name = "MethodTyPar";

tablesinfo[0x2B].names = new String[] { "Number", "Method", "Bound", "Name" };

tablesinfo[0x2B].type = Types.MethodTyPar;

tablesinfo[0x2B].ctypes = new Types[] { Types.UInt16, Types.Method, Types.TypeDefOrRef, Types.String };

How to get the real method from MethodTyPar ? Used for methods with generic parameters.

Seems that I should get it from "Method" but how?

Posted (edited)

You're reading some old ass code. MD Table 2Bh is MethodSpec and it has two columns, not four, see here.


 


The MethodSpec.Method column is an index into the Method or MemberRef table (I.e. it's a MethodDefOrRef coded token). Which table this is depends on the low N number of bits. Since it's a MethodDefOrRef coded token, only 1 bit is used (i.e,. N = 1). If the coded token is 10h, then we have 10h & 1 == 0, so it's table Method. Index is 10h >> N (N = 1) which is index 8. 11h = index 8 in MemberRef table.


 


You can see what I do in dnlib here. Follow the call to readerModule.ResolveMethodDefOrRef().


Edited by 0xd4d
  • Like 3
Posted

Thank you 0xd4d


It worked!


 


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...