HTML5¼¼Êõ

CoreCLRÔ´Âë̽Ë÷(Ò») ObjectÊÇʲô - q303248153(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-01-06 11:04 ÎÒÒªÆÀÂÛ( )

ÕâÀïÎÒ¶¨ÒåÁËMyClassºÍMyStructÀàÐÍ£¬ÏÈ¿´Console.WriteLine(myClass) ÕâÀï°ÑµÚÒ»¸ö²ÎÊýÉèÖõ½rcx²¢ÇÒµ÷ÓÃConsole.WriteLineº¯Êý£¬ÎªÊ²Ã´ÊÇrcxÇë¿´²é¿´²Î¿¼Á´½ÓÖжÔfastcallµÄ½éÉÜ rbp + 0x50 = 0x1fc8fde110 Ìøµ½

ÕâÀïÎÒ¶¨ÒåÁË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µÄ´úÂ룬Èç¹ûÓÐÎóÇëÔÚÁôÑÔÖÐÖ¸³ö
½ÓÏÂÀ´ÓÐʱ¼äÎÒ½«»á×ÅÖØÔĶÁºÍ½éÉÜÕâЩÄÚÈÝ

¾´ÇëÆÚ´ý


¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ÉýѶÍþADO.NETÔöÇ¿×é¼þ£¨Ô´Â룩£ºË͸øϲ»¶Ô­ÉúADO.NETµÄÄã - sheng.chao

    ÉýѶÍþADO.NETÔöÇ¿×é¼þ£¨Ô´Â룩£ºË͸øϲ»¶Ô­ÉúADO.NETµÄÄã - sheng.c

    2016-12-20 11:01

  • html5 Sortable.js ÍÏקÅÅÐòÔ´Âë·ÖÎö - qq281113270

    html5 Sortable.js ÍÏקÅÅÐòÔ´Âë·ÖÎö - qq281113270

    2016-11-04 15:00

  • MVCϵÁСª¡ªMVCÔ´Âëѧϰ£º´òÔì×Ô¼ºµÄMVC¿ò¼Ü£¨Èý£º×Ô¶¨Òå·ÓɹæÔò£© - ÀÁµÃ°²·Ö

    MVCϵÁСª¡ªMVCÔ´Âëѧϰ£º´òÔì×Ô¼ºµÄMVC¿ò¼Ü£¨Èý£º×Ô¶¨Òå·ÓɹæÔò£©

    2016-11-03 18:00

  • MVCϵÁСª¡ªMVCÔ´Âëѧϰ£º´òÔì×Ô¼ºµÄMVC¿ò¼Ü£¨¶þ£º¸½Ô´Â룩 - ÀÁµÃ°²·Ö

    MVCϵÁСª¡ªMVCÔ´Âëѧϰ£º´òÔì×Ô¼ºµÄMVC¿ò¼Ü£¨¶þ£º¸½Ô´Â룩 - ÀÁµÃ°²

    2016-10-31 15:00

ÍøÓѵãÆÀ
Í