What is an array header in .NET.

I saw a little representation of the array in memory with the Windbg and SOS plugins.

Here is C #:

class myobj{
  public int[] arr;
}
class Program{
  static void Main(string[] args){
    myobj o = new myobj();
    o.arr = new int[7];
    o.arr[0] = 0xFFFFFF;
    o.arr[1] = 0xFFFFFF;
    o.arr[2] = 0xFFFFFF;
    o.arr[3] = 0xFFFFFF;
    o.arr[4] = 0xFFFFFF;
  }
}

I break in the finale of Main, and I observe:

    0:000> !clrstack -l
OS Thread Id: 0xc3c (0)
ESP       EIP     
0015f0cc 0043d1cf test.Program.Main(System.String[])
    LOCALS:
        0x0015f0d8 = 0x018a2f58
0:000> !do 0x018a2f58
Name: test.myobj
MethodTable: 0026309c
EEClass: 00261380
Size: 12(0xc) bytes
 (C:\Users\admin\Documents\Visual Studio 2008\Projects\test\test\bin\Debug\test.exe)
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
01324530  4000001        4       System.Int32[]  0 instance 018a2f64 tab
0:000> dd 018a2f64
018a2f64  01324530 00000007 00ffffff 00ffffff
018a2f74  00ffffff 00ffffff 00ffffff 00000000
018a2f84  00000000 00000000 00000000 00000000

I see that the header contains the size of the array (00000007), but my question is: what is the value 01324530?

Thank!

+5
source share
3 answers

The value 01324530 is a table of methods. This is how .NET implements virtual methods - each method is a pointer to a function.

Notice that the value of the array is in pointer 018a2f64. I see that you dumped memory with dd. If you did not know this, you can also dump the array with the command! Da:

!da 018a2f64
+5

- , .Net 1.0.

, .

0

What does MT mean on this line?

      MT    Field   Offset                 Type VT     Attr    Value Name
01324530  4000001        4       System.Int32[]  0 instance 018a2f64 tab

I guess this means the same, as it is the same number.

(Based on Andrew's comment, this means a table of methods.)

0
source

All Articles