Jump to content
Tuts 4 You

Getting Table Lenght with dnlib ???


CodeExplorer

Recommended Posts

CodeExplorer
Posted

How to get Tables length with dnlib??
Fallowing tables:
0x1B000000 TypeSpec
0x01000000 TypeRef
0x02000000 TypeDef
0x0A000000 MemberRef
0x04000000 Field
0x06000000 Method
0x2B000000 MethodTyPar
0x70000000 String
0x11000000 StandAloneSig
 

CodeExplorer
Posted

I got it:
 

        private uint GetTableLength(uint table)
        {
            if (table==0) return 0;
            if (Program.module==null) return 0;
            
            TablesStream tablesStream = Program.module.Metadata.TablesStream;
            if (tablesStream==null) return 0;
            
            if ((table&0xFFFFFF)==0)
                table = table>>24;
            
            //MDTable mdtable = tablesStream.Get((Table)0x2B);
            
            if (table==0x1B)
                return tablesStream.TypeSpecTable.Rows;
            else if (table==0x01)
                return tablesStream.TypeRefTable.Rows;
            else if (table==0x02)
                return tablesStream.TypeDefTable.Rows;
            else if (table==0x0A)
                return tablesStream.MemberRefTable.Rows;
            else if (table==0x04)
                return tablesStream.FieldTable.Rows;
            else if (table==0x06)
                return tablesStream.MethodTable.Rows;
            else if (table==0x2B)
                return tablesStream.MethodSpecTable.Rows;
            else if (table==0x70)  // string
                return Program.module.USStream.StreamLength;
            else if (table==0x11)
                return tablesStream.StandAloneSigTable.Rows;
            
            return 0;
            
        }

 

  • Like 2

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...