ÕâÀïÎÒ¶¨ÒåÁËMyClassºÍMyStructÀàÐÍ£¬ÏÈ¿´Console.WriteLine(myClass)
ÕâÀï°ÑµÚÒ»¸ö²ÎÊýÉèÖõ½rcx²¢ÇÒµ÷ÓÃConsole.WriteLineº¯Êý£¬ÎªÊ²Ã´ÊÇrcxÇë¿´²é¿´²Î¿¼Á´½ÓÖжÔfastcallµÄ½éÉÜ
rbp + 0x50 = 0x1fc8fde110
Ìøµ½ÄÚ´æÖÐÒÔºó¿ÉÒÔ¿´µ½Ñ¡ÖеÄÕâ8byteÊÇÖ¸Ïò¶ÔÏóµÄÖ¸Õ룬ÈÃÎÒÃǼÌÐøÌøµ½0x1fcad88390
ÕâÀïÎÒÃÇ¿ÉÒÔ¿´µ½MyClassʵÀýµÄÕæÃæÄ¿ÁË£¬Ñ¡ÖеÄ8byteÊÇÖ¸ÏòMethodTableµÄÖ¸Õë
ºóÃæ·Ö±ðÊÇÖ¸ÏòStringMemberµÄÖ¸ÕëºÍIntMemberµÄÄÚÈÝ
ÔÚÕâÀïObjHeaderÖеÄͬ²½Ë÷Òý¿éÖµÊÇ0£¬ÕâÊÇÕý³£µÄ£¬Î¢ÈíÔÚ´úÂëÖÐÓÐ×¢ÊÍThis is often zero
ÕâÀïÊÇStringMemberÖ¸ÏòµÄÄÚÈÝ£¬·Ö±ðÊÇÖ¸ÏòMethodTableµÄÖ¸Õ룬×Ö·û´®³¤¶ÈºÍ×Ö·û´®ÄÚÈÝ
ÕâÀïÊÇMyClassµÄMethodTable£¬m_BaseSizeÊÇ32
ÓÐÐËȤµÄ¿ÉÒÔÈ¥ºÍMethodTableµÄ³ÉÔ±Ò»Ò»¶ÔÕÕ£¬ÕâÀïÎҾͲ»¸úÏÂÈ¥ÁË
ÈÃÎÒÃÇÔÙ¿´ÏÂstructÊÇÔõô´¦ÀíµÄ
¿ÉÒÔ¿´µ½Ö»ÊǼòµ¥µÄ°ÑÖµ¸´ÖƵ½Á˶ÑÕ»¿Õ¼äÖУ¨rbpÊǵ±Ç°frameµÄ¶ÑÕ»»ù´¡µØÖ·)
ÈÃÎÒÃÇÔÙÀ´¿´ÏÂConsole.WriteLine¶ÔÓÚstructÊÇÔõô´¦ÀíµÄ£¬ÕâÀïµÄ´¦ÀíÏ൱ÓÐȤ
ÒòΪÐèҪװÏ䣬Ê×ÏÈ»áÒªÀ´Ò»¸öÏä×Ó£¬Ïä×Ó·ÅÔÚÁËrbp+30h
°ÑMyStructÖеÄÖµ¸´ÖƵ½ÁËÏä×ÓÖУ¬rax+8µÄ8ÊÇ°ÑÖµ¸´ÖƵ½MethodTableÖ®ºó
¸´Öƺ󣬽ÓÏÂÀ´°ÑÕâ¸öÏä×Ó´«¸øConsole.WriteLine¾ÍºÍMyClassÒ»ÑùÁË
ÁíÍâÔÙ¸½Ò»ÕÅʵ¼Ê²é¿´ComponentSizeµÄͼ
²Êµ°¿´ÍêÁË.NetÖжÔObjectµÄ¶¨Ò壬ÈÃÎÒÃÇÔÙ¿´ÏÂPythonÖжÓObjectµÄ¶¨Òå
Ô´´úÂë: https://github.com/python/cpython/blob/master/Include/object.h
_object { _object *_ob_prev; // HeapÖеĺóÒ»¸ö¶ÔÏó #endif Py_ssize_t ob_refcnt; // ÒýÓüÆÊý struct _typeobject *ob_type; // Ö¸ÏòÀàÐÍÐÅÏ¢ } PyObject;
¶¨Òå²»Ò»Ñù£¬µ«ÊÇ×÷Óû¹ÊÇÀàËƵÄ
²Î¿¼
https://en.wikipedia.org/wiki/X86_calling_conventions
https://github.com/dotnet/coreclr/blob/master/src/vm/object.inl
https://github.com/dotnet/coreclr/blob/master/src/vm/object.h
https://github.com/dotnet/coreclr/blob/master/src/vm/object.cpp
https://github.com/dotnet/coreclr/blob/master/src/vm/syncblk.h
https://github.com/dotnet/coreclr/blob/master/src/vm/syncblk.cpp
https://github.com/dotnet/coreclr/blob/master/src/vm/methodtable.inl
https://github.com/dotnet/coreclr/blob/master/src/vm/methodtable.h
https://github.com/dotnet/coreclr/blob/master/src/vm/methodtable.cpp
https://github.com/dotnet/coreclr/blob/master/src/vm/class.h
https://github.com/dotnet/coreclr/blob/master/src/inc/daccess.h
https://github.com/dotnet/coreclr/blob/master/src/debug/daccess/dacfn.cpp
ÒòΪÊǸտªÊ¼ÔĶÁcoreclrµÄ´úÂ룬Èç¹ûÓÐÎóÇëÔÚÁôÑÔÖÐÖ¸³ö
½ÓÏÂÀ´ÓÐʱ¼äÎÒ½«»á×ÅÖØÔĶÁºÍ½éÉÜÕâЩÄÚÈÝ
¾´ÇëÆÚ´ý
¡¡