使用反汇编.NET对象布局结构布局、对象、结构、反汇编

2023-09-03 20:39:11 作者:ミ糯米〞飯團o○

我希望看到的对象布局结构,并想使用在Visual Studio中拆卸。 以下是我的code:

I am interested in seeing the object layout structure, and am trying to use a disassembly in visual studio. Following is my code:

class myclass
{
  public int m_a;
}

myclass myc = new myclass();
myc.m_a = 23;
//I am setting a breakpoint after this line

我在地址栏中打开内存1窗口,键入MYC。我得到了以下细节诠释输出窗口(用于Windows XP的32位PC采用英特尔编译器):

I opened Memory1 window, and type myc in the Address field. I get the following details int the output window (used Windows XP PC 32bit with Intel compiler):

    0x0148B7BC  1c 93 a7 00 17 00 00 00 00 00 00 00 00 00 00 00 00 00 00

似乎有其在对象数据,它通过4个字节增加对象大小的前面加一个附加的指针00a7931c。我的困惑是,文件说,对象大小是增加8个字节由于每个对象头。可有人请点我到其他的4个字节?

It appears that there is an additional pointer 00a7931c which is added in front of the object data, which increases the object size by 4 bytes. My confusion is that documentation says that object size is increase by 8 bytes due to header per object. Can someone please point me to where the other 4 bytes are?

推荐答案

从Advanced净调试 - CLR对象的内部结构:

这是对象的CLR的内部结构是:

An object’s CLR internal structure is:

[DWORD:的SyncBlock] [DWORD:方法表指针] [DWORD:引用类型的指针] ... [数值类型字段值] ...

[DWORD: SyncBlock][DWORD: MethodTable Pointer][DWORD: Reference type pointer]…[Value of Value Type field]…

对象标题:的[DWORD:的SyncBlock]   的对象指针:的[DWORD:方法表指针] [DWORD:引用类型的指针] ... [数值类型字段值] ...

Object Header: [DWORD: SyncBlock] Object Pointer: [DWORD: MethodTable Pointer][DWORD: Reference type pointer]…[Value of Value Type field]…

每一个对象是$ P $由ObjHeader pceded(在负偏移)。该ObjHeader的索引到的SyncBlock。

Every Object is preceded by an ObjHeader (at a negative offset). The ObjHeader has an index to a SyncBlock.