ÓÑÇéÌáʾ£ºÈç¹û±¾ÍøÒ³´ò¿ªÌ«Âý»òÏÔʾ²»ÍêÕû£¬Çë³¢ÊÔÊó±êÓÒ¼ü¡°Ë¢Ð¡±±¾ÍøÒ³£¡ÔĶÁ¹ý³Ì·¢ÏÖÈκδíÎóÇë¸æËßÎÒÃÇ£¬Ð»Ð»£¡£¡ ±¨¸æ´íÎó
ÒÀÒÀС˵ ·µ»Ø±¾ÊéĿ¼ ÎÒµÄÊé¼Ü ÎÒµÄÊéÇ© TXTÈ«±¾ÏÂÔØ ½øÈëÊé°É ¼ÓÈëÊéÇ©

windows»·¾³ÏÂ32λ»ã±àÓïÑÔ³ÌÐòÉè¼Æ-µÚ7²¿·Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡



¡¡¡¡


µÚ3Õ¡¡Ê¹ÓÃMASM


3¡£4¡¡Ê¹ÓÃ×Ó³ÌÐò

¡¡¡¡¡¡¡¡
µ±³ÌÐòÖÐÏàͬ¹¦ÄܵÄÒ»¶Î´úÂëÓõñȽÏƵ·±Ê±£¬¿ÉÒÔ½«Ëü·ÖÀë³öÀ´Ð´³ÉÒ»¸ö×Ó³ÌÐò£¬ÔÚÖ÷³ÌÐòÖÐÓÃcallÖ¸ÁîÀ´µ÷ÓÃËü¡£ÕâÑù¿ÉÒÔ²»ÓÃÖظ´Ð´ÏàͬµÄ´úÂ룬¶øÓÃcallÖ¸Áî¾Í¿ÉÒÔÍê³É¶à´ÎͬÑùµÄ¹¤×÷ÁË¡£Win32»ã±àÖеÄ×Ó³ÌÐòÒ²²ÉÓöÑÕ»À´´«µÝ²ÎÊý£¬ÕâÑù¾Í¿ÉÒÔÓÃinvokeαָÁîÀ´½øÐе÷ÓúÍÓï·¨¼ì²é¹¤×÷¡£

3¡£4¡£1¡¡¡¡×Ó³ÌÐòµÄ¶¨Òå

×Ó³ÌÐòµÄ¶¨Ò巽ʽÈçÏÂËùʾ¡£

×Ó³ÌÐòÃû¡¡¡¡proc¡¡£§¾àÀ룧£§ÓïÑÔÀàÐÍ£§£§¿ÉÊÓÇøÓò£§£§USES¡¡¼Ä´æÆ÷ÁÐ±í£§£§£»²ÎÊý£ºÀàÐÍ£§¡£¡£¡££§VARARG£§

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡local¡¡¾Ö²¿±äÁ¿Áбí

¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Ö¸Áî

¡¡

×Ó³ÌÐòÃû¡¡¡¡endp

procºÍendpαָÁÒåÁË×Ó³ÌÐò¿ªÊ¼ºÍ½áÊøµÄλÖ㬡¡procºóÃæ¸úµÄ²ÎÊýÊÇ×Ó³ÌÐòµÄÊôÐÔºÍÊäÈë²ÎÊý¡£×Ó³ÌÐòµÄÊôÐÔÓУº

¡ñ¡¡¡¡¡¡¾àÀ롪¡ª¿ÉÒÔÊÇNEAR£¬FAR£¬NEAR16£¬NEAR32£¬FAR16»òFAR32£¬Win32ÖÐÖ»ÓÐÒ»¸öƽ̹µÄ¶Î£¬ÎÞËùν¾àÀ룬ËùÒÔ¶Ô¾àÀëµÄ¶¨ÒåÍùÍùºöÂÔ¡£

¡ñ¡¡¡¡¡¡ÓïÑÔÀàÐÍ¡ª¡ª±íʾ²ÎÊýµÄʹÓ÷½Ê½ºÍ¶ÑջƽºâµÄ·½Ê½£¬¿ÉÒÔÊÇStdCall£¬C£¬SysCall£¬BASIC¡¢FORTRANºÍPASCAL£¬Èç¹ûºöÂÔ£¬ÔòʹÓóÌÐòÍ·²¿¡¡¡£model¶¨ÒåµÄÖµ¡£

¡ñ¡¡¡¡¡¡¿ÉÊÓÇøÓò¡ª¡ª¿ÉÒÔÊÇPRIVATE£¬PUBLICºÍEXPORT¡£PRIVATE±íʾ×Ó³ÌÐòÖ»¶Ô±¾Ä£¿é¿É¼û£»PUBLIC±íʾ¶ÔËùÓеÄÄ£¿é¿É¼û£¨ÔÚ×îºó±àÒëÁ´½ÓÍê³ÉµÄ¡¡¡£exeÎļþÖУ©£»EXPORT±íʾÊǵ¼³öµÄº¯Êý£¬µ±±àдDLLµÄʱºòÒª½«Ä³¸öº¯Êýµ¼³öµÄʱºò¿ÉÒÔÕâÑùʹÓá£Ä¬ÈϵÄÉèÖÃÊÇPUBLIC¡£

¡ñ¡¡¡¡¡¡USES¼Ä´æÆ÷ÁÐ±í¡ª¡ª±íʾÓɱàÒëÆ÷ÔÚ×Ó³ÌÐòÖ¸Áʼǰ×Ô¶¯°²ÅÅpushÕâЩ¼Ä´æÆ÷µÄÖ¸Á²¢ÇÒÔÚretÇ°×Ô¶¯°²ÅÅpopÖ¸ÁÓÃÓÚ±£´æÖ´Ðл·¾³£¬µ«±ÊÕßÈÏΪ²»Èç×Ô¼ºÔÚ¿ªÍ·ºÍ½áβÓÃpushadºÍpopadÖ¸ÁîÒ»´Î±£´æºÍ»Ö¸´ËùÓмĴæÆ÷À´µÃ·½±ã¡£

¡ñ¡¡¡¡¡¡²ÎÊýºÍÀàÐÍ¡ª¡ª²ÎÊýÖ¸²ÎÊýµÄÃû³Æ£¬ÔÚ¶¨Òå²ÎÊýÃûµÄʱºò²»ÄܸúÈ«¾Ö±äÁ¿ºÍ×Ó³ÌÐòÖеľֲ¿±äÁ¿ÖØÃû¡£¶ÔÓÚÀàÐÍ£¬ÓÉÓÚWin32ÖеIJÎÊýÀàÐÍÖ»ÓÐ32루dword£©Ò»ÖÖÀàÐÍ£¬ËùÒÔ¿ÉÒÔÊ¡ÂÔ¡£ÔÚ²ÎÊý¶¨ÒåµÄ×îºó»¹¿ÉÒÔ¸úVARARG£¬±íʾÔÚÒÑÈ·¶¨µÄ²ÎÊýºó»¹¿ÉÒÔ¸ú¶à¸öÊýÁ¿²»È·¶¨µÄ²ÎÊý£¬ÔÚWin32»ã±àÖÐΩһʹÓÃVARARGµÄAPI¾ÍÊÇwsprintf£¬ÀàËÆÓÚCÓïÑÔÖеÄprintf£¬Æä²ÎÊýµÄ¸öÊýÈ¡¾öÓÚÒªÏÔʾµÄ×Ö·û´®ÖÐÖ¸¶¨µÄ±äÁ¿¸öÊý¡£

Íê³ÉÁ˶¨ÒåÖ®ºó£¬¿ÉÒÔÓÃinvokeαָÁîÀ´µ÷ÓÃ×Ó³ÌÐò£¬µ±invokeαָÁîλÓÚ×Ó³ÌÐò´úÂë֮ǰµÄʱºò£¬´¦Àíµ½invokeÓï¾äµÄʱºò±àÒëÆ÷»¹Ã»ÓÐɨÃèµ½×Ó³ÌÐò¶¨ÒåÐÅÏ¢µÄ¼Ç¼£¬ËùÒÔ»áÓÐÒÔÏ´íÎóÐÅÏ¢£º

error¡¡A2006£º¡¡undefined¡¡symbol¡¡£º¡¡_ProcWinMain

Õâ²¢²»ÊÇ˵×Ó³ÌÐòµÄ±àдÓдíÎ󣬶øÊÇinvokeαָÁîÎÞ·¨µÃÖª×Ó³ÌÐòµÄ¶¨ÒåÇé¿ö£¬ËùÒÔÎÞ·¨½øÐвÎÊýµÄ¼ì²â¡£ÔÚÕâÖÖÇé¿öÏ£¬ÎªÁËÈÃinvokeÖ¸ÁîÄÜÕý³£Ê¹Ó㬱ØÐëÔÚ³ÌÐòµÄÍ·²¿ÓÃprotoα²Ù×÷¶¨Òå×Ó³ÌÐòµÄÐÅÏ¢£¬¡°ÌáÇ°¡±¸æËßinvokeÓï¾ä¹ØÓÚ×Ó³ÌÐòµÄÐÅÏ¢£¬protoµÄÓ÷¨¼û3¡£2¡£2½Ú¡£µ±È»£¬Èç¹û×Ó³ÌÐò¶¨ÒåÔÚÇ°µÄ»°£¬ÓÃprotoµÄ¶¨Òå¾Í¿ÉÒÔÊ¡ÂÔÁË¡£

ÓÉÓÚ³ÌÐòµÄµ÷ÊÔ¹ý³ÌÖпÉÄܳ£³£¶ÔһЩ×Ó³ÌÐòµÄ²ÎÊý¸öÊý½øÐе÷Õû£¬ÎªÁËʹËüÃDZ£³ÖÒ»Ö£¬¾ÍÐèҪͬʱÐÞ¸ÄprocÓï¾äºÍprotoÓï¾ä¡£ÔÚдԴ³ÌÐòµÄʱºòÓÐÒâʶµØ°Ñ×Ó³ÌÐòµÄλÖÃÌáµ½invokeÓï¾äµÄÇ°Ã棬ʡÂÔµôprotoÓï¾ä£¬¿ÉÒÔ¼ò»¯³ÌÐòºÍ±ÜÃâ³ö´í¡£

3¡£4¡£2¡¡¡¡²ÎÊý´«µÝºÍ¶Ñջƽºâ

Á˽âÁË×Ó³ÌÐòµÄ¶¨Òå·½·¨ºó£¬ÈÃÎÒÃǼÌÐøÉîÈëÁ˽â×Ó³ÌÐòµÄʹÓÃϸ½Ú¡£ÔÚµ÷ÓÃ×Ó³ÌÐòʱ£¬²ÎÊýµÄ´«µÝÊÇͨ¹ý¶ÑÕ»½øÐеģ¬Ò²¾ÍÊÇ˵£¬µ÷ÓÃÕß°ÑÒª´«µÝ¸ø×Ó³ÌÐòµÄ²ÎÊýѹÈë¶ÑÕ»£¬×Ó³ÌÐòÔÚ¶ÑÕ»ÖÐÈ¡³öÏàÓ¦µÄÖµÔÙʹÓ㬱ÈÈ磬Èç¹ûÒªµ÷Óãº

SubRouting£¨Var1£»Var2£»Var3£©

¾­¹ý±àÒëºóµÄ×îÖÕ´úÂë¿ÉÄÜÊÇ£¨×¢ÒâÖ»ÊÇ¡°¿ÉÄÜ¡±£©£º

push¡¡¡¡Var3

push¡¡¡¡Var2

push¡¡¡¡Var1

call¡¡¡¡SubRouting

add¡¡¡¡¡¡esp£»12

Ò²¾ÍÊÇ˵£¬µ÷ÓÃÕßÊ×ÏȰѲÎÊýѹÈë¶ÑÕ»£¬È»ºóµ÷ÓÃ×Ó³ÌÐò£¬ÔÚÍê³Éºó£¬ÓÉÓÚ¶ÑÕ»ÖÐÏÈǰѹÈëµÄÊý²»ÔÙÓÐÓ㬵÷ÓÃÕß»òÕß±»µ÷ÓÃÕß±ØÐëÓÐÒ»·½°Ñ¶ÑÕ»Ö¸ÕëÐÞÕýµ½µ÷ÓÃÇ°µÄ״̬£¬¼´¶ÑÕ»µÄƽºâ¡£²ÎÊýÊÇ×îÓұߵÄÏÈÈë¶ÑÕ»»¹ÊÇ×î×ó±ßµÄÏÈÈë¶ÑÕ»¡¢»¹ÓÐÓɵ÷ÓÃÕß»¹ÊDZ»µ÷ÓÃÕßÀ´ÐÞÕý¶ÑÕ»¶¼±ØÐëÓиöÔ¼¶¨£¬²»È»¾Í»á²úÉú´íÎóµÄ½á¹û£¬Õâ¾ÍÊÇÔÚÉÏÊöÎÄ×ÖÖÐʹÓá°¿ÉÄÜ¡±ÕâÁ½¸ö×ÖµÄÔ­Òò¡£¸÷ÖÖÓïÑÔÖе÷ÓÃ×Ó³ÌÐòµÄÔ¼¶¨ÊDz»Í¬µÄ£¬ËùÒÔÔÚprocÒÔ¼°protoÓï¾äµÄÓïÑÔÊôÐÔÖÐÈ·¶¨ÓïÑÔÀàÐͺ󣬱àÒëÆ÷²Å¿ÉÄܽ«invokeαָÁî·­Òë³ÉÕýÈ·µÄÑù×Ó£¬²»Í¬ÓïÑԵIJ»Í¬µãÈç±í3¡£4Ëùʾ¡£

±í3¡£4¡¡¡¡²»Í¬ÓïÑÔµ÷Ó÷½Ê½µÄ²î±ð

C¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡SysCall¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡StdCall¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡BASIC¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡FORTRAN¡¡¡¡¡¡¡¡¡¡¡¡PASCAL
¡¡
×îÏÈÈëÕ»²ÎÊý
¡¡ÓÒ
¡¡ÓÒ
¡¡ÓÒ
¡¡×ó
¡¡×ó
¡¡×ó
¡¡
Çå³ý¶ÑÕ»Õß
¡¡µ÷ÓÃÕß
¡¡×Ó³ÌÐò
¡¡×Ó³ÌÐò
¡¡×Ó³ÌÐò
¡¡×Ó³ÌÐò
¡¡×Ó³ÌÐò
¡¡
ÔÊÐíʹÓÃVARARG
¡¡ÊÇ
¡¡ÊÇ
¡¡ÊÇ×¢
¡¡·ñ
¡¡·ñ
¡¡·ñ
¡¡

×¢£ºVARARG¡¡±íʾ²ÎÊýµÄ¸öÊý¿ÉÒÔÊDz»È·¶¨µÄ£¬Èçwsprintfº¯Êý£¬±¾±íÖÐÌØÊâµÄµØ·½ÊÇStdCall¡¡µÄ¶ÑÕ»Çå³ýƽʱÊÇÓÉ×Ó³ÌÐòÍê³ÉµÄ£¬µ«Ê¹ÓÃVARARG¡¡Ê±ÊÇÓɵ÷ÓÃÕßÇå³ýµÄ¡£

ΪÁËÁ˽â±àÒëÆ÷¶Ô²»Í¬ÀàÐÍ×Ó³ÌÐòµÄ´¦Àí·½Ê½£¬ÏÈÀ´¿´Ò»¶ÎÔ´³ÌÐò£º

£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·

Sub1¡¡¡¡¡¡¡¡proc¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡C¡¡_Var1£»_Var2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡eax£»_Var1

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ebx£»_Var2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ret

Sub1¡¡¡¡¡¡¡¡endp

£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·

Sub2¡¡¡¡¡¡¡¡proc¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡PASCAL¡¡_Var1£»_Var2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡eax£»_Var1

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ebx£»_Var2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ret

Sub2¡¡¡¡¡¡¡¡endp

£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·

Sub3¡¡¡¡¡¡¡¡proc¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_Var1£»_Var2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡eax£»_Var1

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ebx£»_Var2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ret

b3¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡endp

£»¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·¡·

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub1£»1£»2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub2£»1£»2

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡invoke¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub3£»1£»2

±àÒëºóÔÙ½øÐз´»ã±à£¬¿´±àÒëÆ÷ÊÇÈçºÎת»»´¦Àí²»Í¬ÀàÐ͵Ä×Ó³ÌÐòµÄ£º

£»¡¡ÕâÀïÊÇSub1¡¡£­¡¡CÀàÐÍ

£º00401000¡¡55¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡ebp

£º00401001¡¡8BEC¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡ebp£»¡¡esp

£º00401003¡¡8B4508¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡eax£»¡¡dword¡¡ptr¡¡£§ebp£«08£§

£º00401006¡¡8B5D0C¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡ebx£»¡¡dword¡¡ptr¡¡£§ebp£«0C£§

£º00401009¡¡C9¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡leave

£º0040100A¡¡C3¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ret

£»¡¡ÕâÀïÊÇSub2¡¡£­¡¡PASCALÀàÐÍ

£º0040100B¡¡55¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡ebp

£º0040100C¡¡8BEC¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡ebp£»¡¡esp

£º0040100E¡¡8B450C¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡eax£»¡¡dword¡¡ptr¡¡£§ebp£«0C£§

£º00401011¡¡8B5D08¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡ebx£»¡¡dword¡¡ptr¡¡£§ebp£«08£§

£º00401014¡¡C9¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡leave

£º00401015¡¡C20800¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ret¡¡0008

£»¡¡ÕâÀïÊÇSub3¡¡¡ª¡¡StdCallÀàÐÍ

£º00401018¡¡55¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡ebp

£º00401019¡¡8BEC¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡ebp£»¡¡esp

£º0040101B¡¡8B4508¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡eax£»¡¡dword¡¡ptr¡¡£§ebp£«08£§

£º0040101E¡¡8B5D0C¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mov¡¡ebx£»¡¡dword¡¡ptr¡¡£§ebp£«0C£§

£º00401021¡¡C9¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡leave

£º00401022¡¡C20800¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ret¡¡0008

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡­

£»¡¡ÕâÀïÊÇinvoke¡¡Sub1£»1£»2¡¡¡ª¡¡CÀàÐÍ

£º00401025¡¡6A02¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡00000002

£º00401027¡¡6A01¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡00000001

£º00401029¡¡E8D2FFFFFF¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡call¡¡00401000

£º0040102E¡¡83C408¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡add¡¡esp£»¡¡00000008

£»¡¡ÕâÀïÊÇinvoke¡¡Sub2£»1£»2¡¡¡ª¡¡PASCALÀàÐÍ

£º00401031¡¡6A01¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡00000001

£º00401033¡¡6A02¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡00000002

£º00401035¡¡E8D1FFFFFF¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡call¡¡0040100B

£»¡¡ÕâÀïÊÇinvoke¡¡Sub3£»1£»2¡¡¡ª¡¡StdCallÀàÐÍ

£º0040103A¡¡6A02¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡00000002

£º0040103C¡¡6A01¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡push¡¡00000001

£º0040103E¡¡E8D5FFFFFF¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡call¡¡00401018

¿ÉÒÔÇå³þµØ¿´µ½£¬ÔÚ²ÎÊýÈëջ˳ÐòÉÏ£¬CÀàÐͺÍStdCallÀàÐÍÊÇÏÈ°ÑÓұߵIJÎÊýÏÈѹÈë¶ÑÕ»£¬¶øPASCALÀàÐÍÊÇÏÈ°Ñ×ó±ßµÄ²ÎÊýѹÈë¶ÑÕ»¡£ÔÚ¶ÑջƽºâÉÏ£¬CÀàÐÍÊÇÔÚµ÷ÓÃÕßÔÚʹÓÃcallÖ¸ÁîÍê³Éºó£¬×ÔÐÐÓÃadd¡¡esp£»8Ö¸Áî°Ñ8¸ö×ֽڵIJÎÊý¿Õ¼äÇå³ý£¬¶øPASCALºÍStdCallµÄµ÷ÓÃÕßÔò²»¹ÜÕâ¸öÊÂÇ飬¶ÑջƽºâµÄÊÂÇéÊÇÓÉ×Ó³ÌÐòÓÃret¡¡8À´ÊµÏֵģ¬retÖ¸ÁîºóÃæ¼ÓÒ»¸ö²Ù×÷Êý±íʾÔÚretºó°Ñ¶ÑÕ»Ö¸Õëesp¼ÓÉϲÙ×÷Êý£¬Íê³ÉµÄÊÇͬÑùµÄ¹¦ÄÜ¡£

Win32Ô¼¶¨µÄÀàÐÍÊÇStdCall£¬ËùÒÔÔÚ³ÌÐòÖе÷ÓÃ×Ó³ÌÐò»òϵͳAPIºó£¬²»±Ø×Ô¼ºÀ´Æ½ºâ¶ÑÕ»£¬ÃâÈ¥Á˺ܶàÂé·³¡£

´æÈ¡²ÎÊýºÍ¾Ö²¿±äÁ¿¶¼ÊÇͨ¹ý¶ÑÕ»À´¶¨ÒåµÄ£¬ËùÒÔ²ÎÊýµÄ´æÈ¡Ò²ÊÇͨ¹ýebp×öÖ¸ÕëÀ´Íê³ÉµÄ¡£ÔÚ̽ÌÖ¾Ö²¿±äÁ¿µÄʱºò£¬ÒѾ­¾ÍûÓвÎÊýµÄÇé¿öÏÂebpÖ¸ÕëºÍ¾Ö²¿±äÁ¿µÄ¶ÔÓ¦¹Øϵ×öÁË·ÖÎö£¬ÏÖÔÚÀ´·ÖÎöÒ»ÏÂebpÖ¸ÕëºÍ²ÎÊýÖ®¼äµÄ¶ÔÓ¦¹Øϵ£¬×¢Ò⣬ÕâÀïÊÇÒÔWin32ÖеÄStdCallΪÀý£¬²»Í¬µÄÓïÑÔÀàÐÍ£¬Ö¸ÕëµÄ˳Ðò¿ÉÄÜÊDz»Í¬µÄ¡£

¼Ù¶¨ÔÚÒ»¸ö×Ó³ÌÐòÖÐÓÐÁ½¸ö²ÎÊý£¬Ö÷³ÌÐòµ÷ÓÃʱÔÚ¡¡push¡¡µÚÒ»¸ö²ÎÊýÇ°µÄ¶ÑÕ»Ö¸ÕëespΪX£¬ÄÇôѹÈëÁ½¸ö²ÎÊýºóµÄespΪX¡­8£¬³ÌÐò¿ªÊ¼Ö´ÐÐcallÖ¸ÁcallÖ¸Áî°Ñ·µ»ØµØַѹÈë¶ÑÕ»£¬ÕâʱºòepsΪX¡­C£¬½ÓÏÂÈ¥ÊÇ×Ó³ÌÐòÖÐÓÃpush¡¡ebpÀ´±£´æebpµÄÖµ£¬esp±äΪX¡­10£¬ÔÙÖ´ÐÐÒ»¾ämov¡¡ebp£»esp£¬¾Í¿ÉÒÔ¿ªÊ¼ÓÃebp´æÈ¡²ÎÊýºÍ¾Ö²¿±äÁ¿ÁË£¬Í¼3¡£4˵Ã÷ÁËÕâ¸ö¹ý³Ì¡£


ͼ3¡£4¡¡¡¡ebpÖ¸Õë¡¢²ÎÊýºÍ¾Ö²¿±äÁ¿µÄ¹Øϵ

ÔÚÔ´³ÌÐòÖУ¬ÓÉÓÚ²ÎÊý¡¢¾Ö²¿±äÁ¿ºÍebpµÄ¹ØϵÊÇÓɱàÒëÆ÷×Ô¶¯Î¬»¤µÄ£¬ËùÒÔ¶ÁÕß²»±Ø¹ØÐÄËüÃǵľßÌå¹Øϵ£¬µ«µ½ÁËÓÃSoft¡­ICEµÈ¹¤¾ßÀ´·ÖÎöÆäËûÈí¼þµÄʱºò£¬Óöµ½µ÷ÓÃ×Ó³ÌÐòµÄʱºòÒ»¶¨ÒªÏÈ¿´Çå³þËüÃÇÖ®¼äµÄÀàÐͲî±ð¡£

ÔÚ×Ó³ÌÐòÖÐʹÓòÎÊý£¬¿ÉÒÔʹÓÃÓë´æÈ¡¾Ö²¿±äÁ¿Í¬ÑùµÄ·½·¨£¬ÒòΪÕâÁ½ÕߵĹ¹ÔìÔ­Àí¼¸ºõһģһÑù£¬ËùÒÔ£¬ÔÚ×Ó³ÌÐòÖÐÓÐinvokeÓï¾äʱ£¬Èç¹ûÒªÓõ½ÊäÈë²ÎÊýµÄµØÖ·µ±×öinvokeµÄ²ÎÊý£¬Í¬ÑùÒª×ñÑ­¾Ö²¿±äÁ¿µÄʹÓ÷½Ê½£¬²»ÄÜÓÃoffsetα²Ù×÷·û£¬Ö»ÄÜÓÃaddrÀ´Íê³É¡£Í¬Ñù£¬ËùÓжԾֲ¿±äÁ¿Ê¹ÓõÄÏÞÖƼ¸ºõ¶¼¿ÉÒÔÊÊÓÃÓÚ²ÎÊý¡£



¡¡
À´Ô´£ºµç×Ó¹¤Òµ³ö°æÉç¡¡×÷ÕߣºÂÞÔƱò¡¡ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
ÉÏÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡»ØÊéÄ¿¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ÏÂÒ»Ò³¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡


µÚ3Õ¡¡Ê¹ÓÃMASM


3¡£5¡¡¸ß¡¡¼¶¡¡Óï¡¡·¨£¨1£©

¡¡¡¡¡¡¡¡
ÒÔÇ°¸ß¼¶ÓïÑԺͻã±àµÄ×î´ó²î±ð¾ÍÊÇÌõ¼þ²âÊÔ¡¢·ÖÖ§ºÍÑ­»·µÈ¸ß¼¶Óï·¨¡£¸ß¼¶ÓïÑÔÖУ¬³ÌÐòÔ±¿ÉÒÔ·½±ãµØÓÃÀàËÆÓÚif£¬case£¬loopºÍwhileµÈÓï¾äÀ´¹¹³É³ÌÐòµÄ½á¹¹Á÷³Ì£¬²»½öÌõÀíÇå³þ¡¢Ò»Ä¿ÁËÈ»£¬¶øÇÒά»¤ÐÔÏ൱ºÃ¡£¶ø»ã±à³ÌÐòÔ±ÄØ£¿Ö»ÄÜÔÚcmpÖ¸ÁîºóÃæ½Ê¾¡ÄÔÖ­µØÏ뾿¾¹Óü¸Ê®ÖÖÌøתÓï¾äÖеÄÄÄÒ»ÖÖ£¬ÕâÀï¾ÍÄÜÁгö½üÈýÊ®¸öÌõ¼þÌøתָÁîÀ´£ºja£¬jae£¬jb£¬jbe£¬jc£¬je£¬jg£¬jge£¬jl£¬jle£¬jna£¬jnae£¬jnb£¬jnbe£¬jnc£¬jne£¬jng£¬jnge£¬jnl£¬jnle£¬jno£¬jnp£¬jns£¬jnz£¬jo£¬jp£¬jpe£¬jpoºÍjzµÈ¡£ËäÈ»ÆäÖеĺܶàÖ¸ÁîÎÒÃÇÒ»±²×ÓÒ²²»»áÓõ½£¬µ«¾ÍÊÇÕâЩָÁîºÍһЩloop£¬loopnzÒÔ¼°±»loopÉæ¼°µÄecxµÈ¼Ä´æÆ÷¾À²øÔÚÒ»Æð£¬Ê¹ÔÚ»ã±àÖÐÊéд½á¹¹ÇåÎú¡¢¿É¶ÁÐԺõĴúÂë±äµÃÏ൱À§ÄÑ£¬ÕâÒ²ÊǺܶàÈËÊÓ»ã±àΪη;µÄÒ»¸öÔ­Òò¡£

ÏÖÔÚºÃÁË£¬MASMÖÐÐÂÒýÈëÁËһϵÁеÄαָÁÉæ¼°Ìõ¼þ²âÊÔ¡¢·ÖÖ§ºÍÑ­»·Óï¾ä£¬ÀûÓÃËüÃÇ£¬»ã±àÓïÑÔÓÐÁ˺͸߼¶ÓïÑÔÒ»ÑùµÄ½á¹¹£¬ÅäºÏ¶Ô¾Ö²¿±äÁ¿ºÍµ÷ÓòÎÊýµÈ¸ß¼¶ÓïÑÔÖг£¼ûÔªËصÄÖ§³Ö£¬ÎªÊ¹ÓÃWin32»ã±à±àд´ó¹æÄ£µÄÓ¦ÓóÌÐòµì¶¨ÁË»ù´¡¡£

3¡£5¡£1¡¡¡¡Ìõ¼þ²âÊÔÓï¾ä

Ôڸ߼¶ÓïÑÔÖУ¬ËùÓеķÖÖ§ºÍÑ­»·Óï¾äÊ×ÏÈÒªÉæ¼°Ìõ¼þ²âÊÔ£¬Ò²¾ÍÊÇÉæ¼°Ò»¸ö±í´ïʽµÄ½á¹ûÊÇ¡°Õ桱»¹ÊÇ¡°¼Ù¡±µÄÎÊÌ⣬±í´ïʽÖÐÍùÍùÓÐÓÃÀ´×ö±È½ÏºÍ¼ÆËãµÄ²Ù×÷·û£¬MASMÒ²²»ÀýÍ⣬Õâ¾ÍÊÇÌõ¼þ²âÊÔÓï¾ä¡£

MASMÌõ¼þ²âÊԵĻù±¾±í´ïʽÊÇ£º

¼Ä´æÆ÷»ò±äÁ¿¡¡¡¡²Ù×÷·û¡¡²Ù×÷Êý

Á½¸öÒÔÉϵıí´ïʽ¿
·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨0£© ²È£¨0£©
δÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
ÎÂÜ°Ìáʾ£º ο´Ð¡ËµµÄͬʱ·¢±íÆÀÂÛ£¬Ëµ³ö×Ô¼ºµÄ¿´·¨ºÍÆäËüС»ï°éÃÇ·ÖÏíÒ²²»´íŶ£¡·¢±íÊéÆÀ»¹¿ÉÒÔ»ñµÃ»ý·ÖºÍ¾­Ñé½±Àø£¬ÈÏÕæдԭ´´ÊéÆÀ ±»²ÉÄÉΪ¾«ÆÀ¿ÉÒÔ»ñµÃ´óÁ¿½ð±Ò¡¢»ý·ÖºÍ¾­Ñé½±ÀøŶ£¡