¦b³o¤@³¹ùرN¦V¦U¦ì¤¶²Ð ( µù¤@ ) ¦b Win32 §@·~¨t²Î¤¤¡A³Ì²³æªº²Õ¦X»y¨¥µ{¦¡¡A¦P®É½m²ß¦p¦ó¥H MASM32 v7.0 ²ÕĶ³sµ²¡A¥H¤Î§Q¥Î Soft-ICE ¸ü¤Jµ{¦¡°£¿ù ( ©ÎªÌ¥Î OllyDebug °£¿ù ) ³o¤T¶µ¤u§@¡C
¨ÌºD¨Ò¡Aµ{¦¡±Ð¾Çªº²Ä¤@Óµ{¦¡¡A¶È¦b¿Ã¹õ¤WÅã¥Ü¤@Ó¦r¦ê¡A¤p¤ì°¸¤]¤£·Q¨Ò¥~¡A©Ò¥H²Ä¤@ӥβզX»y¨¥©Ò¼¶¼gªº Win32 µ{¦¡¤]¬O¦p¦¹¡C¥¦¶È¶ÈÅã¥Ü¤@Óµøµ¡¡A¼ÐÃD¼g¡y³Ì²³æªºµ{¦¡¡z¡Aµøµ¡¤º¤å¼g¡y³o¬O¦b Win32 §@·~¨t²Î¡A¥Î²Õ¦X»y¨¥¼gªºµ{¦¡¡C¡z¡A¨Ã¥B¦³¤@Ó¡y½T©w¡z«ö¶s¡A·í¨Ï¥ÎªÌ«ö¤U³oÓ«ö¶s¥i¥Hµ²§ôµ{¦¡¡C¥¦¨S¦³²o¯A¤Ó¦h Win32 ½ÆÂøªº¨t²Î¡A¬Æ¦Ü³s³Ì°ò¥»ªº°T®§¶Ç»¼¤]³£¨S¦³¡A³Ì¾A¦X§@¬° Win32 ²Õ¦X»y¨¥¤Jªùªºµ{¦¡¡C³oÓµ{¦¡¡A¤p¤ì°¸¦W¤§¬° message.asm¡A¨ä°õ¦æµ²ªG¦p¤U¡G
¤W±¬O¦b Win 98 SE ªº°õ¦æµe±¡A¦Ü©ó XP/Vista ¤]³£Ãþ¦ü¡AŪªÌ¥i¥H¸Õ¸Õ¡Cmessage.asm ªºì©l½X¦p¤U¡G
1 2 3 4
5 6 7 8
9
10 11 12 13
14 15 16 17
18 19 |
OPTION CASEMAP:NONE
.386
.MODEL FLAT,STDCALL
INCLUDE WINDOWS.INC
INCLUDE KERNEL32.INC
INCLUDE USER32.INC
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
;***************************************************************************************************
.DATA
szTitle DB "³Ì²³æªºµ{¦¡",0
szMessage DB "³o¬O¦b Win32 §@·~¨t²Î¡A¥Î²Õ¦X»y¨¥¼gªºµ{¦¡¡C",0
;***************************************************************************************************
.CODE
start: INVOKE MessageBox,NULL,ADDR szMessage,ADDR szTitle,MB_OK
INVOKE ExitProcess,NULL
;***************************************************************************************************
END start |
¬Ý°_¨Ó¥u¦³ 19 ¦æ¡A¦ü¥G«Ü²³æ¡A¨º¬O¦]¬°¦³³\¦h©w¸q³£¤wÅn¬A¦b¥]§tÀÉ ( *.INC ÀÉ ) ¤¤¤F¡C©³¤U¤p¤ì°¸±N¤ÀªR³o¨Çµ{¦¡½X¡C
²Ä¤@¦æ¬O§i¶D²ÕĶ¾¹¡AML.EXE¡A¨Ï¥Î§ÚÌ©Ò©w¸qªºÅܼƦWºÙ¡B¼Ð°O¦WºÙ¡BWin32 API ¦WºÙµ¥µ¥¬O°Ï¤À¤j¤p¼gªº¡A¤]´N¬O»¡ message »P MESSAGE ¥Nªí¨âÓ¤£¦Pªº¦r¦ê¦W¡C°²¦p±z¤£¦bì©lµ{¦¡¤¤¼g³o¤@¦æ¡A¦b²ÕĶ®É¤U /Cp °Ñ¼Æ¤]¬O¤@¼Ëªº¡C¦]¬°©Ò¦³ªº Win32 µ{¦¡³£·|©I¥s Win32 API¡A¦Ó Win 32 API ¤j¤p¼g¤£¦Pªº¦r¥Àµø¬°¤£¦PªºÅܼơA©Ò¥H¥²¶·¦³³o¤@¦æ¡A³o¤@ÂI©M DOS ¤¤¼¶¼gµ{¦¡¤£¤À¤j¤p¼g¬O¤£¤@¼Ëªº¡Aªì¾ÇªÌ±o¤p¤ß¡C
²Ä¤G¦æ¬O«Å§i¥i¥H¨Ï¥Î 80386 «ü¥O¶°¡A¦]¬°§Ú̪ºµ{¦¡±N¦b Win32 ¨t²Î¤W°õ¦æ¡A¦]¬° Win32 ¨t²Î¥²¶·¦b 80386 ¥H¤Wªº CPU ¤~¯à°õ¦æ¡A¦Ó¥Bn¥Î 32 ¦ì¤¸ªº©w§}¤è¦¡ ( §Y flat mode )¡A©Ò¥H¡y.386¡z³o¤@¦æ¬O¥²nªº¡C
²Ä¤T¦æ¬O«ü©w°O¾ÐÅé¼Ò¦¡¥H¤Î©I¥s¨ó©w ( calling convention )¡C¥ý»¡°O¾ÐÅé¼Ò¦¡¡C¦b DOS ®É¥N¡A°O¾ÐÅé¬O¥H 16 ¦ì¤¸©w§}¤è¦¡©w§}¡A¤À¬°°Ï¬q»P°¾²¾¦ì§}¡A¨CӰϬq¤£±o¶W¹L 64 KB¡A¦ý¦b Win32 §@·~¨t²ÎùØ¡A°O¾ÐÅé¬O¥H 32 ¦ì¤¸¤è¦¡©w§}¡A³Ì¦h¥i¹F 4GB¡A¦p¦¹¤jªº°O¾ÐÅ餣¦A»Ýn¡A¤]¨S¦³¥²n¤À¦¨°Ï¬q»P°¾²¾¦ì§}ªº©w§}¤è¦¡¡A±z¥i¥H§â°O¾ÐÅé¦ì§}¥þ³£¬Ý¦¨¬O¤@ӫܤjªº¡y°Ï¬q¡z¡A¥Ñ 00 ¨ì 4GB ¦¨ª½½u±Æ¦C¡AºÙ¤§¬°¡yflat¡z¼Ò¦¡ ( ¥©Z¼Ò¦¡ ) ( µù¤G )¡C¦b Win32 §@·~¨t²Î¤¤¡A±z¤]¥u¯à¥Î³oºØ¼Ò¦¡¡C¦b Win32 ¨t²Îªº FLAT ¼Ò¦¡¤§¤U¡A·íµ{¦¡³Q¸ü¤J°õ¦æ®É¡A§@·~¨t²Î·|¤À°t¤@Ó 4GB ªº°O¾ÐÅéªÅ¶¡µ¹µ{¦¡¨Ï¥Î¡A§Ú̪ºµ{¦¡¥u¯à¦b³o 4GB ªºªÅ¶¡°õ¦æ¡A¤]¨S¦³¿ìªk¬Ý¨ì¨ä¥Lµ{¦¡ªº°O¾ÐÅ餺®e¡A°O¾ÐÅ骺¤À°t¡BºÞ²z¥þ³¡³£¥Ñ§@·~¨t²Î½Õ«×«ü´§¡A©Ò¥H·í¬YÓµ{¦¡·í±¼¡A¨Ã¤£¼vÅT¨ä¥Lµ{¦¡¡C§Ú̦A¤]¨S¦³¿ìªk¡A¤]¨S¦³¥²n¥hÃö¤ß¨ä¥Lµ{¦¡ªº°O¾ÐÅ餺®e¡A¥un±Mª`©ó¦Û¤vµ{¦¡ªº 4GB ¤º§Y¥i¡C
©I¥s¨ó©w¬O«ü¥Dµ{¦¡©I¥s°Æµ{¦¡®É¡An¦p¦ó§â°Ñ¼Æ¶Çµ¹°Æµ{¦¡¡A¥Dµ{¦¡»P°Æµ{¦¡¥²¶·¤@P¡A§_«h©Ò±oµ²ªG«K¨S¦³·N¸q¡C¦b DOS ùØ©I¥s¤¤Â_¬O¨Ï¥Î¼È¦s¾¹¶Ç»¼°Ñ¼Æ¨ÃµL©Ò¿×©I¥s¨ó©w¡A¦ý¬O¦b Win32 ùØ©I¥s Win32 API¡A«o¬O¨Ï¥Î°ïÅ|¶Ç»¼°Ñ¼Æ¡A¦Ó¦b¤¤¡B°ª¶¥»y¨¥ùØ©I¥s°Æµ{¦¡±`¥H¤@¦æ§¹¦¨¡A¨Ò¦p C/C¡Ï¡Ï ¤¤©I¥s MessageBox »yªk¦p¤U¡G
MessageBox ( NULL,szMessage,szTitle,MB_OK )
©I¥s¨ó©w¬O«ün¨M©w¦b³Ì¥kÃäÁÙ¬O³Ì¥ªÃ䪺°Ñ¼Æ¥ý±À¤J°ïÅ|¡B¬O¥Ñ¥Dµ{¦¡ÁÙ¬O°Æµ{¦¡²M°£°ïÅ|¡B¬O§_¤¹³\¤£©T©wӼƪº°Ñ¼Æµ¥µ¥¡C©³¤U´XºØ¬O±`¨£ªº©I¥s¨ó©w¡G
©I¥s¨ó©w | STDCALL | C | BASIC |
³Ì¥ý±À¤J°ïÅ|ªº°Ñ¼Æ | ¥k | ¥k | ¥ª |
¥Ñ½Öt³d²M°£°ïÅ| | °Æµ{¦¡ | ¥Dµ{¦¡ | °Æµ{¦¡ |
¬O§_¤¹³\¤£©wӼƪº°Ñ¼Æ | ¬O | ¬O | §_ |
¨ä¥LÁÙ¦³¤@¨Ç©I¥s¨ó©w¡A¦p PASCAL¡BFORTRAN µ¥µ¥¡A¤£¹L¦b Win32 ùإΤ£µÛ¡A©Ò¥H¨S¦³¤¶²Ð¡C¦b Win32 ²Õ¦X»y¨¥¤¤¦]¬°¤j¶q©I¥s Win32 API µ{¦¡¡A¦Ó Win32 API ¬O¥Î STDCALL ¤è¦¡¶Ç»¼°Ñ¼Æ¡A©Ò¥H§Ṳ́]±o«Å§i¥H STDCALL ¤è¦¡¶Ç»¼°Ñ¼Æ¡A¨Ã¥B¤]¥u¯à¥H STDCALL ¤è¦¡©I¥s Win32 API¡C¦p¤Wªí©Ò¥Ü¡A¥H STDCALL ©I¥s¨ó©w²ÕĶ®É¡A¬O§i¶D²ÕĶ¾¹³Ì¥kÃ䪺°Ñ¼Æ³Ì¥ý±À¤J°ïÅ|¡AµM«á¬O¥kÃä²Ä¤GӰѼƱÀ¤J°ïÅ|¡K¡K²Ä¤@ӰѼƬO³Ì«á±À¤J°ïÅ|¡C
³o«e¤T¦æ¡A±z¥i¥H¬Ý¦¨¬O¥²¶·¥B¤£¤Ó·|§ó°Êªºµ{¦¡½X¡C
²Ä¥|¦æ¨ì²Ä¤K¦æ¬O§âµ{¦¡©Ò©I¥s Win32 API ©Ò»ÝnªºÅܼƩw¸q¤Îµ{¦¡®w§t¬A¶i¨Ó¡C¦b DOS ¤¤¡ADOS ´£¨Ñ¤F³\¦h¤¤Â_ªA°Èµ{¦¡¨Ñ¨Ï¥ÎªÌ©I¥s¡F¬Û¦P¦a¡A¦b Win 32 ¨t²Î¤¤¡AWindows ¤]´£¨Ñ¤F³\¦h±j¤jªº°Æµ{¦¡¡A¤]´N¬O Win32 API¡A¨ÑÀ³¥Îµ{¦¡©I¥s¡C»P DOS ¤£¦Pªº¬O DOS ¤¤Â_ªA°Èµ{¦¡©ñ¦b°O¾ÐÅ餤¡A¦Ó Win32 API ¬O¥]§t¦b°ÊºAµ{¦¡®w¤º¡A³o¨Ç°ÊºAµ{¦¡®w¬O©ñ¦b C:\WINDOWS\SYSTEM ¤l¥Ø¿ýùتº DDL ÀÉ ( ³Ì«nªº¤TÓ¬O KERNEL32.DLL¡BGDI32.DLL ©M USER32.DLL ) ¡A·íÀ³¥Îµ{¦¡©I¥s®É¡A¤~¥h³oÓ¤l¥Ø¿ý§ä¨ì¸ÓÀÉ´O¤J°õ¦æ¡A¤£¹³ DOS ªº¤¤Â_ªA°Èµ{¦¡¥u»Ýn¥Î CPU «ü¥O INT ´N¥i¥H¤F¡C
°ÊºAµ{¦¡®wªº¨ç¼Æ©w¸q³£©ñ¦b¬Û¹ïÀ³¦P¥DÀɦWªº¥]§tÀɤº¡A·N«ä¬O KERNEL32.DLL ªº¨ç¼Æ©w¸q©ñ¦b KERNEL32.INC ¥]§tÀɤº¡AUSER32.DLL ªº¨ç¼Æ©w¸q©ñ¦b KUSER32.INC ¥]§tÀɤº¡Cµ{¦¡ªº²Ä 4 ¨ì²Ä 8 ¦æ´N¬O«ü©w©Ò¥Î¨ìªº¥]§tÀÉ»Pµ{¦¡®w¡C¦Ü©ón¥[¤J¨º¤@Ó¥]§tÀɩε{¦¡®w¥²¶·µøµ{¦¡©Ò¥Î¨ìªº Win32 API ¦Ó©w¡A¥i¥H¬d API ¤â¥U¡C¤£¹L¤@¯ë¦³Ó³W«h¡A¦pªG±z©I¥sªº API ¬O¦b KERNEL32.DLL Àɮפº¡A¨º´N´N¥²¶·¥]§t KERNEL32.INC¡A¥H¤Îµ{¦¡®w KERNEL32.LIB¡Cµ{¦¡®wªº¥]§tÀɨèS¦³¥]§tµ²ºcÅé¡B±`¼Æµ¥©w¸q¡A³o¨Ç©w¸q¬O¥]§t¦b WINDOWS.INC Àɮפº¡A©Ò¥Hì©lµ{¦¡¤]n¥]§t WINDOWS.INC ÀÉ¡C
²Ä¤Q¦æ¬Oµù¸Ñ¡A²Õ¦X»y¨¥µù¸Ñ§¡¥H¡y;¡z¶}©l¡A²ÕĶ¾¹·|©¿²¤¡y;¡z¥H«áªº¤å¦r¡C¦³®Éµù¸Ñ¤Óªø¡A¥²¶·¨Ï¥Î¦n´X¦æ¤å¦r®É¡A¥i¥H¥Î COMMENT ¨Ó·í¦¨µù¸Ñ¡C
²Ä 11 ¦æ¨ì²Ä 13 ¦æ¬O©w¸q¸ê®Æ¡y¬q¡z¡A§Ú§â³oÓ¡y¬q¡z¥H¤Þ¸¹¬A°_¨Ó¬O¦]¬°¥¦©M¦b DOS ¼Ò¦¡¤Uªº°Ï¬q·N¸q¤£¦P¡A¦b DOS ¤¤¤@Ó¬q¥u¦³ 64KB ªº¤j¤p¡A¦Ó¦b Win32 ¤¤¤@ӰϬq´N¦³ 4GB ªºªø«×¡A¦Ó³o 4GB ªº¤j¤p¦A¤À¦¨¸ê®Æ¬q»Pµ{¦¡½X¬q¡C¦b MASM 6.0 ¥H«áªºª©¥»¥i¥H¥Î²³æªº¤èªk¥h©w¸q°Ï¬q¡A¥¦¬Ù²¤¤F°Ï¬q¦W¡A¦Ó¥u§i¶D²ÕĶ¾¹³o¬O°ïÅ|°Ï¬q¡B¸ê®Æ°Ï¬q©Î¬Oµ{¦¡½X°Ï¬q¡A¥Ñ²ÕĶ¾¹¤º©w°Ï¬q¦WºÙ¡C
²³æ©w¸q°Ï¬qªº¤èªk´N¬O¦b¤@¦æªº³Ì«e±¼g¡y.¡zªí¥Ü³o¬O¤@ӰϬq¶}©l¡A°Ï¬qªºµ²§ô¨ÃµL°²«ü¥O¡A¦ý¬O¤@ӰϬqªº¶}©l´N¬O«e¤@°Ï¬qªºµ²§ô¡A¦]¦¹¤£·|·d²V¡C±`¥Îªº°Ï¬q¦³¤U±¥|ºØ¡G
.DATA ¡÷ ¸ê®Æ°Ï¬q .CONST ¡÷ ¸ê®Æ°Ï¬q¡A¦ý¬O¥u¯àÀx¦s±`¼Æ¡A¤]´N¬O¦¹°Ï¬q¤ºªº¸ê®Æ¤£¯à§ó§ï .DATA? ¡÷ ÅܼƨS¦³ªì©lȪº¸ê®Æ°Ï¬q .CODE ¡÷ µ{¦¡½X°Ï¬q
¡y.data¡z¬O¸ê®Æ°Ï¬q¥B¦¹°Ï¬q¤ºªºÅܼơB¦r¦ê³£¬O¤w¸g¦³ªì©lȪº¡C¡y.data?¡z©Ò¶}©lªº°Ï¬q¬O¥¼¦³ªì©lȪº¸ê®Æ°Ï¬q¡C¡y.code¡z¶}©lªº°Ï¬q´N¬Oµ{¦¡½X°Ï¬q¡C¦¹³B¤p¤ì°¸©w¸q¤F¨âÓ¦r¦ê¡A³o¨âÓ¦r¦ê³£¦³¤º®e¤F¡A©Ò¥H©ñ¦b¡y.data¡z°Ï¬q¤º¡C³o¨Ç°Ï¬q¬O²ÕĶ¾¹¤ºªº«O¯d¦r¡A¨Ã¤£¬OÅܼơA¦]¦¹¤j¤p¼g¤£¨ü¡yOPTION CASEMAP:NONE¡zªº¼vÅT¡C¦¹¥~¡A¹³°²«ü¥O ( ¨Ò¦p INVOKE¡Baddr¡Boffset µ¥µ¥ )¡B80x86 «ü¥O¶° ( ¨Ò¦p mov¡Bpush¡Bdiv µ¥µ¥ )¡K³£¤£¨ü¡yOPTION CASEMAP:NONE¡zªº¼vÅT¡A¥ç§Y¤j¤p¼g¨S¦³°Ï§O¡C
¦b Win32 ²Õ¦X»y¨¥ùØ¡A©Ò¦³¦³Ãö¦ì§}ªº¼È¦s¾¹¡A¨Ò¦p ESI¡BEDI¡BEBP µ¥³£¬O 32 ¦ì¤¸ªø¡A¦Ó¥B 232=4GB¡A©Ò¥H³o¨Ç¼È¦s¾¹³£¯à©w§}¨ì 4GB ªº¤j¤p¡A¦]¦¹¤£»Ýn¦A¹³ DOS ®É¥N¡A¥h§â¦ì§}ªí¥Ü¦¨°Ï¬q»P°¾²¾ªº¤è¦¡¤F¡C¨º»ò°Ï¬q¼È¦s¾¹¬O¤£¬O¯uªº¨S¥Î¤F©O¡H·íµM¤£¬O¡A«OÅ@¼Ò¦¡ùتº°Ï¬q¼È¦s¾¹¥t¦³¨ä·N¸q¡A¨Ã«D¤T¨¥¨â»y¥i¥H¤¶²Ð±o§¹ªº¡A¦pªG¶Ã§ï³o¨Ç¼È¦s¾¹ªº¸Ü¡A«Ü®e©ö´N³y¦¨·í¾÷¡AWindows ·|¦Û°Ê¦bµ{¦¡¸ü¤J°õ¦æ®É¡A´N·|§â³o¨Çȳ]©w¦n¡A¨Ï¥ÎªÌªºµ{¦¡¤£¯à¥hק復¡C©Ò¥H¦b Win32 ²Õ¦X»y¨¥ùØ¡A§ÚÌ¥i¥H¤£¥²¥h¦b·N°Ï¬q¼È¦s¾¹ªº¼ÆÈ¡A·íµM°²¦p±z·Q²`¤J¬ã¨sªº¸Ü¡A´N¥t·í§O½×¤F¡C
²Ä 15 ¦æ¬Oµ{¦¡½X°Ï¬q¶}©l¡C¦A¤U¤@¦æ¡A¦³¤@ӼаO¡Astart:¡A©M¦b DOS ®ÉÔ¤@¼Ë¡A¦bµ{¦¡ªº³Ì«á¤@¦æ¦³¤@Ó END °²«ü¥O¡Aªí¥Ü¾ãÓì©l¾×¨ì¦¹µ²§ô¡AEND «á±©Ò±µªº¼Ð°Oªí¥Ü³oÓµ{¦¡ªº¶i¤JÂI¡A´«¥y¸Ü»¡¡A³oÓµ{¦¡¬O±q²Ä 16 ¦æ¶}©l°õ¦æªº¡C
²Ä¤@Ó«ü¥O¬O INVOKE¡A³o¬O¤@Ó°²«ü¥O¡A¥¦©Ò¥Nªíªº·N¸q¬O©I¥s°Æµ{¦¡¡A¥ý¬Ý¬Ý¥¦ªº»yªk¡G
INVOKE °Æµ{¦¡¦W, °Ñ¼Æ1, °Ñ¼Æ2, °Ñ¼Æ3, ¡K¡K
INVOKE «á±±µ¤Wn©I¥sªº°Æµ{¦¡¦WºÙ¡A¦Ó°Æµ{¦¡©Ò»Ýnªº°Ñ¼Æ«h¬O±µ¦b°Æµ{¦¡¤§«á¡A°Æµ{¦¡»P°Ñ¼Æ¤§¶¡¥H¡y,¡z¤À¹j¡A°Ñ¼Æ»P°Ñ¼Æ¤§¶¡¤]¥Î¡y,¡z¤À¹j¡C°²¦p°Ñ¼Æ¤Ó¦h¦Ó¤@¦æ®e¯Ç¤£¤U®É¡A¥i¥H¥Î¡y\¡zªí¥Ü¤U¤@¦æ¬O±µµÛ³o¤@¦æ¤§«á¡C³oùئ³Ó°ÝÃD²£¥Í¤F¡A¥H«e¦b DOS ©I¥s¤¤Â_®É¡A¬O§Q¥Î¼È¦s¾¹¶Ç»¼°Ñ¼Æ¡A¨Ò¦p
mov dx,offset string ;¡÷DX¬°¶Ç»¼ªº°Ñ¼Æ
mov ah,9
int 21h
¦Ó INVOKE ©Ò»Ýªº°Ñ¼Æ¦s¦b¨º¸Ì©O¡Hì¨Ó±µ¦b°Æµ{¦¡¦WºÙ«á±ªº°Ñ¼Æ1¡B°Ñ¼Æ2¡K¡K³£·|³Q²ÕĶ¦¨ push «ü¥O¡AµM«á¥þ³¡³Q±À¤J°ïÅ|¤º¡A¦Ó°Æµ{¦¡«h¨ì°ïÅ|¥h§ä¨ì©Ò»Ýnªº°Ñ¼Æ¡C³o¨Ç°Ê§@¥þ³¡¥Ñ²ÕĶ¾¹¦Û°Ê§@¦n¡Aµ{¦¡³]p®v©Ò»Ýn°µªº´N¬O¬d Win32 API °Ñ¦Ò¤â¥U¤¤¡A³oÓ API ¥Î¨ì¨º¨Ç°Ñ¼Æ¡A¥H¤Î°Ñ¼Æ©Ò¥Nªíªº·N¸q©M¶¶§Ç¡C(µù¤T)
ML.EXE ²ÕĶ®É¡A©Ò±À¤J°ïÅ|ªº¶¶§Ç¬O¨Ì¾Úµ{¦¡²Ä 3 ¦æ¡Amodel¡Aªº©w¸q¡A¦pªG¬O STDCALL ªº¸Ü¡A¬O³Ì¥kÃ䪺ÅܼƳ̥ý³Q±À¤J°ïÅ|¡A³Ì¥ªÃ䪺ÅܼƳ̫á³Q±À¤J°ïÅ|¡C©Ò¥H²Ä 16 ¦æ¨ä¹ê¬O©³¤U¤¦æµ{¦¡ªºÂ²¼g¡C
push MB_OK push addr szTitle ;¨ä¹ê°Ñ¼Æ¦³ addr °²«ü¥O®É¡A¨Ã«D½¦¨ push addr szTitle ©Î push addr szMessage ;push addr szTitle ³o¼Ë²³æ¡A½Ð°Ñ¦Òµù¤ push NULL call MessageBox
MessgaeBox ( µù¥|) ³oÓ API ·|¦Û°Ê¨ì°ïÅ|¸Ì¥h§ä¥X©Ò»Ý°Ñ¼Æ¡C
¦¹³B INVOKE ©Ò©I¥sªº°Æµ{¦¡¡AMessageBox¡A¦b¾ãÓì©lµ{¦¡¤¤¨Ã¥¼©w¸q¡A¨º¥¦¨ì©³¦b¨ºùØ©O¡Hì¨Ó¦b USER32.INC ùؤw¸g¦³©w¸q¤F¡A±z¦pªG¶}±Ò USE32.INC¡A¥i¥H§ä¨ì¡G
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD MessageBox equ <MessageBoxA>
³o¨â¦æ¡A´N¬O©w¸q MessageBox¡A¸Ô²Ó±¡§Î½Ð¬Ýµù¤T»Pµù¤C¡C³o¤]´N¬O¦b Win32 ¼¶¼g²Õ¦X»y¨¥¥²¶·§â¥]§tÀÉÅn¬A¶i¨Óªºì¦]¡C·í²ÕĶ¾¹²ÕĶ®É¡A¥¦¥i¥Hª¾¹D³o¬O¡y¥~³¡¡z°Æµ{¦¡¡A¦Ó¦b¥ØªºÀɤ¤°O¿ý°_¨Ó¡Aµ¥³sµ²¾¹§â¥ØªºÀÉ»Pµ{¦¡®w³sµ²®É¡A¦]¬°µ{¦¡®w¦s¦³ *.DLL ªº¸ê®Æ¡A©Ò¥H§â³o¨Ç¸ê®Æ©M¥ØªºÀɤñ¹ï´Nª¾¹D©I¥sªº API ¦s©ó¦ó³B¡AÀ³¸Ó¦b°õ¦æ®É«ç¼Ë³s±µ¡C
MessageBox ÅU¦W«ä¸q¡A¬O¥Î¨Ó§â¦r¦ê¦L¦bµøµ¡ªº API¡A¦³Ãö¥¦°Ñ¼Æªº·N¸q¡A¥i¥H¬d Win32 API ¤â¥U¦p¤U¡G
int MessageBox( HWND hWnd, // handle of owner window LPCTSTR lpText, // address of text in message box LPCTSTR lpCaption, // address of title of message box UINT uType // style of message box );
¦b¤p¬A©·¤ºªºªí¥Ü MessageBox API ©Ò»Ýªº¥|ӰѼơA¨ä°Ñ¼Æ¦WºÙ¬O hWnd¡BlpText¡BlpCaption¡BuType¡A¦Ó³o¥|ӰѼƪº¸ê®Æ«¬ºA¬O HWND¡BLPCTSTR¡BUINT¡A©Ò¿×¸ê®Æ«¬ºA´N¬O¹³ DB¡BDW¡BDD ³o¼Ë©w¸qÅܼƪºªø«×¡A¥¦Ì©M DB¡BDW¡BDD ¤£¦Pªº¬O¥¦Ì©w¸q¦b WINDOWS.INC ùئӲÕĶ¾¹¤£»{±o¡A³o¤]´N¬On§â WINDOWS.INC ¥]§t¶i¨Óªºì¦]¡CHWND¡BLPCTSTR¡BUINT ªºªø«×§¡¬°Âù¦r²Õ ( 4 Ӧ줸²Õ¡A¨ä¹ê©Ò¦³ªº API °Ñ¼Æªºªø«×³£¬OÂù¦r²Õ )¡A¤§©Ò¥H©w¸q³o´XÓ·sªº¸ê®Æ«¬ºA¬O¬°¤F¥iŪ©Ê ( ¦ý¦³®É§Úı±o¼W¥[¤F½ÆÂø©Ê )¡A¨Ò¦p¬Ý¨£ HWND ´Nª¾¹D³o¬Oµøµ¡¥N½X¡A¬Ý¨ì LPCTSTR¡A´Nª¾¹D³o¬O«ü¦V¦r¦ê©Ò¦b¦ì§}ªº«ü¼Ð¡C©³¤U¬O³o¥|ӰѼƩҪí¥Üªº·N¸q¡G
uType | ¼ÆÈ | ·N¸q |
©³¤Uªº uType ·|Åã¥Ü¤£¦Pªº«ö¶s | ||
MB_OK | 0h | ¥uÅã¥Ü¡y½T©w¡z«ö¶s |
MB_OKCANCEL | 1h | Åã¥Ü¡y½T©w¡z»P¡y¨ú®ø¡z¨âÓ«ö¶s |
MB_ABORTRETRYIGNORE | 2h | Åã¥Ü¡y²×¤î¡z¡B¡y«¸Õ¡z¡B¡y²¤¹L¡z¤TÓ«ö¶s |
MB_YESNOCANCEL | 3h | Åã¥Ü¡y¬O¡z¡B¡y§_¡z¡B¡y¨ú®ø¡z¤TÓ«ö¶s |
MB_YESNO | 4h | Åã¥Ü¡y¬O¡z¡B¡y§_¡z¨âÓ«ö¶s |
MB_RETRYCANCEL | 5h | Åã¥Ü¡y«¸Õ¡z¡B¡y¨ú®ø¡z¨âÓ«ö¶s |
MB_CANCELTRYCONTINUE | 6h | Åã¥Ü¡y¨ú®ø¡z¡B¡y«¸Õ¡z¡B¡yÄ~Äò¡z¤TÓ«ö¶s |
MB_HELP | 4000h | Åã¥Ü¡y½T©w¡z¡B¡y»¡©ú¡z¨âÓ«ö¶s¡A¦pªG¨Ï¥ÎªÌ«ö¤U¡y»¡©ú¡z«ö¶s¡A¨t²Î·|µo¥X WM_HELP °T®§µ¹¤÷µ{¦¡¡C¦³Ãö°T®§¡A°Ñ¦Ò²Ä¤G³¹¡C |
©³¤Uªº uType ·|¦bµøµ¡ªº¥ªÃäÅ㤣¦Pªº¹Ï¥Ü | ||
MB_ICONSTOP | 10h | ·|Åã¥Ü¹Ï¥Ü |
MB_ICONERROR | 10h | ¦P MB_ICONSTOP |
MB_ICONHAND | 10h | ¦P MB_ICONSTOP |
MB_ICONQUESTION | 20h | ·|Åã¥Ü¹Ï¥Ü¡A¦ý·L³n«Øij¾¨¶q¤£n¨Ï¥Î |
MB_ICONEXCLAMATION | 30h | ·|Åã¥Ü¹Ï¥Ü |
MB_ICONWARNING | 30h | ¦P MB_ICONEXCLAMATION |
MB_ICONINFORMATION | 40h | ·|Åã¥Ü¹Ï¥Ü |
MB_ICONASTERISK | 40h | ¦P MB_ICONINFORMATION |
©³¤Uªº uType ¨M©wþ¤@Ó¬O¤º©wªº«ö¶s | ||
MB_DEFBUTTON1 | 0h | ²Ä¤@Ó«ö¶s¬°¤º©w«ö¶s¡A¤º©w«ö¶sÃäÃä·|¥Hµê½u®Ø®Ø³ò¦í¡A·í¨Ï¥ÎªÌ«ö¤UÁä½L¤Wªº¡yEnter¡zÁä¡A´N¬Û·í¨Ï¥ÎªÌ¥H·Æ¹«ÂI¿ï¤º©w«ö¶s¤@¼Ë¡A¨ã¦³¬Û¦Pªº®ÄªG |
MB_DEFBUTTON2 | 100h | ²Ä¤GÓ«ö¶s¬°¤º©w«ö¶s |
MB_DEFBUTTON3 | 200h | ²Ä¤TÓ«ö¶s¬°¤º©w«ö¶s |
MB_DEFBUTTON4 | 300h | ²Ä¥|Ó«ö¶s¬°¤º©w«ö¶s |
©³¤Uªº uType ¨M©w MessageBox µøµ¡¥X²{«á¡A¨Ï¥ÎªÌ¯à§_Ä~Äò¤u§@ | ||
MB_APPLMODAL | 0h | ¦pªG MessageBox ¬O¬YÓµ{¦¡ªº¤lµøµ¡¡A¨º»ò¨Ï¥ÎªÌ¤@©wn«ö¤U MessageBox ©Ò²£¥Íªºµøµ¡¤¤ªº¥ô¤@«ö¶s¡A¤~¯à¤Á´«¨ì¤÷µøµ¡¡F¦ý¥i¥H¤Á´«¨ì¨ä¥Lµøµ¡Ä~Äò¤u§@¡C¦pªG¨S¦³«ü©w MB_SYSTEMMODAL¡A¤]¨S¦³«ü©w MB_TASKMOOAL¡A«h MB_APPLMODAL ¬°¹w³]È |
MB_SYSTEMMODAL | 1000h | ¦¹ºX¼Ð·|¨Ï¹ï¸Ü²°¥X²{¦b³Ì«e±¡A§Y¨Ï¥H·Æ¹«ÂI¿ï¨ä¥Lµøµ¡¡A¤]¤´¦b³Ì«e±¡C³q±`¥Î¨Ó³qª¾«ÜÄY«ªº¿ù»~¡C |
MB_TASKMODAL | 2000h | |
¨ä¥L | ||
MB_SETFOREGROUND | 10000h | ¨t²Î©I¥s SetForegroundWindow¡A¨Ï MessageBox ²£¥Íªºµøµ¡¦b³Ì«e±¡C |
MB_DEFAULT_DESKTOP_ONLY | 20000h | |
MB_TOPMOST | 40000h | ²£¥Íªºµøµ¡¨ã¦³ WS_EX_TOPMOST ©µ¦ù·®æ |
MB_RIGHT | 80000h | ¼ÐÃD¡Bµøµ¡¤º¤å¦r¾a¥k¹ï»ô |
MB_RTLREADING | 100000h | ¼ÐÃD¡Bµøµ¡¤º¤å¦r¥Ñ¥k¦Ü¥ª±Æ¦C¡A¥Î¦bªü©Ô§B¤å©Î§Æ§B¨Ó¤å |
MB_SERVICE_NOTIFICATION | 200000h |
²Å¸¹ | ¼ÆÈ | ·N¸q |
IDOK | 1h | «ö¤U¡y½T©w¡z«ö¶s |
IDCANCEL | 2h | «ö¤U¡y¨ú®ø¡z«ö¶s¡C¦pªGµøµ¡¤¤¦³¡y¨ú®ø¡z«ö¶s¡A«ö¤UÁä½Lªº Esc Áä¡A¤]¯àÃö³¬µøµ¡¡A¨Ãªð¦^ IDCANCEL¡F¦pªG¨S¦³¡y¨ú®ø¡z«ö¶s¡AEsc Áä´N¨S¦³§@¥Î¡C |
IDABORT | 3h | «ö¤U¡y²×¤î¡z«ö¶s |
IDRETRY | 4h | «ö¤U¡y«¸Õ¡z«ö¶s |
IDIGNORE | 5h | «ö¤U¡y©¿²¤¡z«ö¶s |
IDYES | 6h | «ö¤U¡y¬O¡z«ö¶s |
IDNO | 7h | «ö¤U¡y§_¡z«ö¶s |
IDCONTINUE | 0Bh | «ö¤U¡yÄ~Äò¡z«ö¶s |
Win32 API ªº¶Ç¦^ȧ¡¦s©ñ¦b EAX ¼È¦s¾¹ùØ¡C
¬°¤Fn¨ú±o¨âÓ¦r¦êªº°_©l¦ì§}¡A¦b¦r¦ê«e¥[¤W addr °²«ü¥O¡Aªí¥Ü¨ú±o¦ì§}¤§·N¡Caddr ©M¥H«eªº offset «Ü¬Û¦ü¡A®t§O¦b addr ¤£¯à¦V«e¤Þ¥Î¡A·N«ä¬O±z¥²¶·¥ý©w¸qÅܼƤ~¯à¦bµ{¦¡«á±¨ú±o¸ÓÅܼƦì§}¡A¤£¯à¦bµ{¦¡«á±©w¸qÅܼƦӦb©w¸q«e¨Ï¥Î addr¡A¦Ó offset «h¥i¥H¡Caddr ¤£¯à§âÅܼƦì§}¶Çµ¹¨ä¥LÅܼƩμȦs¾¹¡A¨Ò¦p
mov si,addr string
³o¼Ë¼g¬O¤£¦Xªkªº¡A¦ý¬O offset «o¥i¥H¡Caddr ¤@¯ë³£¬O°t¦X INVOKE °²«ü¥O¥Îªº¡C(µù¤)
¤F¸Ñ¤Wz¤§«á¡AINVOKE °²«ü¥O´N¤£Ãø¤F¸Ñ¤F¡AINVOKE ´N¦n¹³©I¥s¤@ӰƵ{¦¡ (API)¡A¦Ó³oӰƵ{¦¡©Ò»Ýnªº°Ñ¼Æ¡A´N±µ¦b°Æµ{¦¡ªº«á±¡A³o¼Ë¥Î INVOKE ©I¥s¤ñ¥Î call ©I¥s¦Ü¤Ö¦³¤@ÂI¦n³B¡A¨º´N¬O INVOKE ·|À°§ÚÌÀˬd±À¤J°ïÅ|ùتº°Ñ¼ÆӼƬO§_¥¿½T¡A°²¦p°Ñ¼Æ¼Æ¥Ø©Î«¬ºA¤£¥¿½Tªº¸Ü¡A¦b²ÕĶ¶¥¬q´N·|²£¥Í¿ù»~°T®§¡C¦Ó¨Ï¥Î call ©I¥s«h¤£·|²£¥Í¿ù»~¡A¦ý¬O¦b°õ¦æ®É¡A«Ü®e©ö¤Þ°_·í¾÷¡C
µ{¦¡²Ä 13 ¦æ¤]¬O INVOKE¡A©Ò©I¥sªº¬O ExitProcess¡A³o¤]¬O¤@Ó Win32 API¡AÅU¦W«ä¸q¡A¨ä¥\¯à¬Oµ²§ôµ{¦¡ªº¡A¬d Win32 API ¤â¥U¡G
VOID ExitProcess( UINT uExitCode // exit code for all threads );
±oª¾°Ñ¼Æ¥u¦³¤@Ó¡A§âªð¦^½X¶Çµ¹§@·~¨t²Î¡C
§â¤Wzì©lµ{¦¡¥Î¤å®Ñ³B²z³nÅé¦s¦¨ MESSAGE.ASM Àɮ׫á¡A«ö¤U¡y¶}©l¡z¡÷¡yµ{¦¡¶°¡z¡÷¡yMS-DOS ¼Ò¦¡¡zªº´£¥Ü²Å¸¹¤U¿é¤J¡G
H:\HomePage\SOURCE>ml message.asm [Enter]
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: message.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/SUBSYSTEM:WINDOWS
"message.obj"
"/OUT:message.exe"
H:\MASM32ASM>
´N¯à²ÕĶ»P³sµ²¤F¡C°²¦p¨S¦³¿ìªk¥¿½T±o¨ì MESSAGE.EXE ªº¸Ü¡AÀˬd¤@¤U±zªºÀô¹Ò¬O§_¥¿½T¡A¦b DOS ´£¥Ü¸¹¿é¤J
H:\HomePage\SOURCE>set [Enter] TMP=C:\WINDOWS\TEMP TEMP=C:\WINDOWS\TEMP PROMPT=$p$g winbootdir=C:\WINDOWS COMSPEC=C:\WINDOWS\COMMAND.COM windir=C:\WINDOWS INCLUDE=C:\masm32\INCLUDE LIB=C:\masm32\LIB PATH=C:\MASM32\BIN;C:\WINDOWS;C:\WINDOWS\COMMAND ML=/coff /link /SUBSYSTEM:WINDOWS
°²¦p¨S¦³¥X²{Ãþ¦ü¥Õ¦â¤å¦rªº¸Ü¡A¨º¥i¯à¥²¶·±z¦Û¤v³]©wÀô¹Ò¤F¡A¤èªk¤]«Ü²³æ¡Aª½±µ¦b DOS ´£¥Ü¸¹¿é¤J
H:\HomePage\SOURCE>path C:\masm32\BIN;%path% [Enter] H:\HomePage\SOURCE>set include=C:\masm32\INCLUDE [Enter] H:\HomePage\SOURCE>set lib=C:\masm32\LIB [Enter] H:\HomePage\SOURCE>set ml=/coff /link /SUBSYSTEM:WINDOWS [Enter]
¥|¦æ«ü¥O¡A¦¹³B¬O°²³]±z¦w¸Ëªº MASM32 ¦b¡yC:\masm32¡z¡C¦A°õ¦æ ML.EXE ¤@¦¸¸Õ¸Õ¡A°²¦p¤@¤Á¥¿±`¡A±z¥i¥H±o¨ì¤@Ó MESSAGE.EXE ÀɮסA¥¦¬O¤@Ó¤£§é¤£¦©ªº Win32 ¥i°õ¦æÀÉ¡A¦pn°õ¦æ¥¦¡A´N¦b DOS ´£¥Ü²Å¸¹¤U¿é¤J message §Y¥i¬Ý¨ì¼u¥X¤@Óµøµ¡¡A¤W±ªº°T®§´N¬O§ÚÌ©Ò¼gªºµ{¦¡¤º®e¡I
¥H«e¥Î DEBUG ©Î SYMDEB ®É¡An¸ü¤J°£¿ùªºµ{¦¡ª½±µ±µ¦b DEBUG ©Î SYMDEB ¤§«á¡A¦ý¬O Soft-ICE µLªk³o¼Ë¸ü¤J¡A¨ºn¦p¦óÆ[¹î MESSAGE.EXE °õ¦æ±¡§Î©O¡H½Ð·Ó¤U±¤èªk¸Õ¸Õ¡G
¿ï¨ú¥Ñ¡y¶}©l¡z¡÷¡yµ{¦¡¶°¡z¡÷¡yNuMega SoftICE¡z¡÷¡ySymbol Loader¡z¡A°õ¦æ Symbol Loader¡AµM«á¦b¨ä¿ï³æ¤º¿ï¾Ü¡yFile¡z¡÷¡yOpen Modules...¡z¶}±Ò¿ï¾ÜÀɮתº¹ï¸Ü²°¡A¦p¤U¹Ï¡G
========================= H:\HomePage\SOURCE\MESSAGE.exe - loaded successfully
µM«á¥Ñ¿ï³æ¤º¡A¿ï¾Ü¡yModule¡z¡÷¡yLoad¡z¡ASoft-ICE ·|¥X²{¨S¦³²Å¸¹ÀÉ ( µù¤» ) ªº°T®§¡A°Ý±z¬O§_Ä~Äò¸ü¤J¡A¦p¤U¹Ï¡G
°£¿ùµe±¬O¤@¶ô¶Â©³¥Õ¦rªºªø¤è§Î°Ï°ì¡A¨ä¤¤ÁÙ³Q¤À³Î¦¨¦n´X¶ô¡A³Ì¤U±¨º¤@¶ôÀ³¸Ó¬O¡y©R¥Oµøµ¡¡z(command window)¡A¥i¥Hµ¹¨Ï¥ÎªÌ¿é¤J©R¥O¡C¦b©R¥Oµøµ¡¤W±¬O¡yµ{¦¡½Xµøµ¡¡z(code window)¡A²{¦bÁÙ¨S¦³Åã¥Ün°£¿ùµ{¦¡ªº¤º®e¡C¦n¡A§ÚÌ«ö¤U F8 Áä ( F8 Á䪺¥\¥Î¡A±z¤]¥i¥H¦b©R¥Oµøµ¡¿é¤J¡yt¡z«ü¥O¦A«ö Enter Áä¡Aµ²ªG¬O¬Û¦Pªº¡C³oÓ t ªº·N«ä´N¬O³æ¨B°lÂÜ¡A©M¦b DEBUG/SYMDEB ¬Û¦P )¡A±z·|µo²{µ{¦¡½Xµøµ¡ªº¤º®e§ïÅܤF¡AÅܦ¨ MESSAGE.EXE ªº¤º®e¡A¨Ã¥B°ª«G«×¥ú´Î²¾¨ì¦ì§} 00401002 ³B¡G
017F:00401000 6A00 PUSH 00 017F:00401002 6800304000 PUSH 00403000 017F:00401007 680D304000 PUSH 0040300D 017F:0040100C 6A00 PUSH 00 017F:0040100E E80D000000 CALL 00401020 017F:00401013 6A00 PUSH 00 017F:00401015 E800000000 CALL 0040101A 017F:0040101A FF2500204000 JMP [00402000] 017F:00401020 FF2508204000 JMP [00402008]
À˵ø³o¤@¬qµ{¦¡½X¡A¥Ñ 017F:00401000 ¨ì 0040100C ³sÄò¥|Ó push «ü¥O¡A´N¬O§â MessageBox ©Ò»Ýªº°Ñ¼Æ±À¨ì°ïÅ|¤¤¡AµM«á MessageBox ¦A¥Ñ°ïÅ|¤¤¥h¨ú¥X¡C¦ì§} 0040100E ªº call ´N¬O call MessageBox¡A³o¥|Ó push «ü¥O»P call «ü¥O¥i¥H¬Ý§@¬O INVOKE °²«ü¥O¹B§@ªºµ²ªG¡C00401013 ¨ì 00401015 ³o¨â¦æ«ü¥O©M¤W±¤@¼Ë¡A¬O§â ExitProcess ©Ò»Ý¤§°Ñ¼Æ±À¤J°ïÅ|¡A¥H¤Î©I¥s ExitProcess API¡C
¨C·í±z¨C¿é¤J¤@Ó F8 Áä®É¡A°ª«G«×ªº¥ú´Î°õ¦æ¸Ó¦æ«ü¥O¨Ã²¾°Ê¨ì¤U¤@Ó±Nn°õ¦æªº«ü¥O³B¡A°£¤F¶i¤J Soft¡ÐICE ªº²Ä¤@Ó F8¡C
·í±z°lÂܨì 017F:0040100E ³B¡A³o¬O Win32 API MessageBox¡A¥i¥H«ö F10 ©Î¿é¤J¡yp¡ÏEnter Áä¡z ªí¥Ü¤£°lÂܰƵ{¦¡¤º³¡¡A§â°Æµ{¦¡·í¦¨¤@Ó«ü¥O°õ¦æ¡A´N¹³ SYMDEB ùتº¡yp¡z«ü¥O¤@¼Ë¡A¦ý¬O°²¦p±zn°lÂÜ MessageBox ¤ºªº¸ê®Æ¥i¥H«ö F8 ÁäÄ~Äò°lÂÜ¡C
¤p¤ì°¸¬°¤F§ó¸Ô²Ó¤F¸Ñ INVOKE °²«ü¥O¡A«ö¤U F8 °lÂÜ MessageBox ùتºµ{¦¡½X¡A·í±z«ö¤U F8 Áä®É¡Aµo²{¥ú´Î¸õ¨ì¦ì§} 00401020 ³B¡A±N°õ¦æ JMP [00402008] ³o¤@¦æ«ü¥O¡A·í±z¦A«ö¤U F8 Áä¡Aµ{¦¡·|¸õ¨ì¡A¾ãÓµe±·|Åܦ¨¤U¹Ï¡G
017F:BFF541BA 55 PUSH EBP 017F:BFF541BB 8BEC MOV EBP,ESP 017F:BFF541BD 6A00 PUSH 00 017F:BFF541BF FF7514 PUSH DWORD PTR [EBP+14] 017F:BFF541C2 FF7510 PUSH DWORD PTR [EBP+10] 017F:BFF541C5 FF750C PUSH DWORD PTR [EBP+0C] 017F:BFF541C8 FF7508 PUSH DWORD PTR [EBP+08] 017F:BFF541CB E84CECFFFF CALL BFF52E1C 017F:BFF541D0 5D POP EBP 017F:BFF541D1 C21000 RET 0010
µo²{ MessgaeBox º¥ý§â EBP ¼È¦s¾¹¦s¤J°ïÅ|¡AµM«á§â EBP «ü¦V°ïÅ|³»ºÝ¡A¥H EBP ¥h°ïÅ|§ä¥X°Ñ¼ÆȨӡC¦ý¬O MessageBox °Æµ{¦¡ ( À³¸Ó»¡ API ¤Ó½ÆÂø¡A¤£©öÆ[¹î°ïÅ|ª¬ºA¡Aµù¤C¦³¥t¤@Ó²³æªº¨Ò¤l¡C )
¤F¸Ñ¤F INVOKE °²«ü¥O«á¡A§Ú·Q¥H«á¤j·§¤£»Ýn¶O¨Æ¥h°lÂÜ Win API ªA°Èµ{¦¡¡A¬Ý¨ì¬O Win API ª½±µ«ö¤U F10 Áä°õ¦æ§¹²¦´N¥i¥H¤F¡C¨ä¹ê Soft-ICE ¥i¥H§â API ¦WºÙÅã¥Ü¥X¨Ó¡A¤èªk¬Oקï winice.dat Àɮ׫á¥b¬q¡A§â©Ò¦³ªº¡y;EXP=¡K¡K¡z«e±ªº¡y;¡z¥h±¼¡A«·s¶}¾÷¡A¦A¥H¬Û¦P¤èªk¸ü¤J MESSAGE.EXE ´N·|¬Ý¨ì¤U±ªºµ{¦¡½X¡G
017F:00401000 6A00 PUSH 00 017F:00401002 6800304000 PUSH 00403000 017F:00401007 680D304000 PUSH 0040300D 017F:0040100C 6A00 PUSH 00 017F:0040100E E80D000000 CALL USER32!MessageBoxA 017F:00401013 6A00 PUSH 00 017F:00401015 E800000000 CALL KERNEL32!ExitProcess
³o¼Ë¹ï©ó°£¿ù©Î°lÂܳ£«Ü¤è«K¡A¤£¬O¶Ü¡H
¦pªG±z·Qªð¦^ Win 9x §@·~¨t²Î¡A¥i¥H«ö Ctrl-D¡ASoft-ICE ·|§â±±¨îÅv¥æÁÙµ¹Win 9x §@·~¨t²Î¡A¦ý¬O Soft-ICE ¤´µMÁÙ¦b°O¾ÐÅ餺¡A±z¥i¥HÀH®É«ö¤U Ctrl-D ¥s¥X Soft-ICE¡C¦Ü©ó Soft-ICE §ó¸Ô²Óªº¥Îªk½Ð°Ñ¦Ò¹q¸£¤Wªº»¡©ú¡C
·íµ{¦¡³]p®v·Q¥Î OllyDebug °£¿ù MESSAGE.EXE ®É¡A¥ý°õ¦æ OLLYDBG.EXE µ{¦¡¡AµM«á¦b OllyDebug µøµ¡ªº¿ï³æùØ¡A¿ï¾Ü¡yFile¡z¡÷¡yOpen¡z¡AµM«á¦b¼u¥Xªº¹ï¸Ü²°¤¤¡A¤Á´«¨ì MESSAGE.EXE ©Ò¦bªº¤l¥Ø¿ý¡A¦A¿ï¾Ü MESSAGE.EXE¡A´N¥X²{¹³¤U±ªºµe±¡G
±z¥i¥H§â·Æ¹«´å¼Ð²¾¨ì·Qק諸¼È¦s¾¹¤W¡A¹ï³oӼȦs¾¹§Ö«ö¨â¦¸·Æ¹«¥ªÁä¡C
±z¥i¥H²¾°Ê·Æ¹«´å¼Ð©Î«öÁä½Lªº¦V¤W¡B¦V¤UÁä²¾°Ê¦ì©ó¤Ï²ÕĶ°Ïªº¦Ç¦â¥ú´Î ( ¤W¹Ïªº¦Ç¦â¥ú´Î¦b¦ì§} 00401000 ³B ) ¨ì±z·Q³]©wªº¤¤Â_ÂI¦ì§}¡AµM«á«öÁä½Lªº F2 Áä¤@¦¸¡A¦b¤Ï²ÕĶ°Ïµ{¦¡½X¦ì§}³B·|Åܦ¨¬õ©³¶Â¦r¡Aªí¥Ü¦¹³B¤w¸g³]©w¦n¤¤Â_ÂI¡C
Yn²¾°£¤¤Â_ÂI¡A«h¨Ï¦Ç¦â¥ú´Î²¾¨ìn²¾°£ªº¤¤Â_ÂI³B¡A¦A«ö¤@¦¸ F2 Áä§Y¥i¡C
F7 ©M F8 ³£¬O°lÂܵ{¦¡¡A¤£¹L F7 ¹J¨ì°Æµ{¦¡©Î LOOP¡BREP MOVS µ¥«ü¥O®É¤´·|¤@¨B¤@¨B¥h°lÂÜ¡F¦Ó F8 ¹J¨ì°Æµ{¦¡©Î Win32 API «hª½±µ§â¾ãӰƵ{¦¡©Î Win32 API °õ¦æ§¹²¦¡A¹J¨ì LOOP¡BREP WOVS µ¥«ü¥O¤]¬Oª½±µ°õ¦æ§¹²¦¡C
«ö¤U F9¡A¥i¨Ïµ{¦¡°õ¦æ¨ìµ²§ô¡A©Î¨ì¤¤Â_ÂI¬°¤î¡C
Ãö³¬µ{¦¡·|µ²§ôì°£¿ù¤¤ªºµ{¦¡¡AY«ö¤U Ctrl¡ÐF2¡AOllyDebug ·|¦ÛµwºÐ«·s¸ü¤Jèµ²§ôªºµ{¦¡¡FY«ö¤U Alt¡ÐF2¡AOllyDebug ¤£·|¦A¸ü¤Jµ{¦¡¡A©ó¬O¤u§@°ÏÅܦ¨ªÅ¥Õ¡C¨Æ¹ê¤W¡A¦b OllyDebug ¤@¶}©l°õ¦æ«á¡A©|¥¼¸ü¤Jn°£¿ùªºµ{¦¡«e¡AY«ö¤U Ctrl¡ÐF2¡AOllyDebug ·|¦Û°Ê¸ü¤J¤W¦¸°£¿ùªºµ{¦¡¡C
OllyDebug ¤ä´©ì©l½X°£¿ù¡A¬O¤@Ó¦b RING 3 «Ü¤£¿ùªº°£¿ù¾¹¡Cn¦b OllyDebug Æ[¹î¨ìì©l½X¡A¥²¶·§âì©l½Xªº²Å¸¹¸ê®Æ¼g¤J EXE ÀÉùØ¡A¦b²ÕĶ®É¥²¶·¤U¹F¡y/Zi¡z°Ñ¼Æ¡G
E:\HomePage\SOURCE>ml /Zi message.asm [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: message.asm Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "message.obj" /DEBUG "/OUT:message.exe" E:\HomePage\SOURCE>
µM«á¦A¥H¥¿±`¤è¦¡°õ¦æ OllyDebug¡A¸ü¤J message.exe §Y¥i¬Ý¨ìì©l½X¤F¡A´N¹³¤U±ªº¹Ï¤ù¡G
µù¤@¡G¨ä¹ê¤p¤ì°¸¦Û¤v¤]¥¿¾Ç²ß Win32 ²Õ¦X»y¨¥¡A©Ò¥H°²¦p¦³¤£¥¿½Tªº¦a¤è¡AÁٽФj®a¨Ó«H§iª¾¡C
µù¤G¡G¦pªG±z´¿¾Ç¹L C/C++¡A¦Ó¥B´¿¼g¹L DOS µ{¦¡¡A¥i¯à´¿¬Ý¹L TINY¡BSMALL¡BCOMPACK¡BMEDIUM¡BLARGE¡BHUGE µ¥¼Ò¦¡¡C¦b¤p¤ì°¸©Ò¼gªº DOS µ{¦¡¤¤±`±`§âµ{¦¡½X¬q¡B¸ê®Æ¬q¡B°ïÅ|¬q¶°¤¤©ó 64KB ¤º¡AµM«á»s§@¦¨ *.COM ÀÉ¡A¹³³oºØ¼Ò¦¡ºÙ¤§¬° TINY ¼Ò¦¡(·L¤p¼Ò¦¡)¡CSMALL ¼Ò¦¡¬O¸ê®Æ¬q©Mµ{¦¡½X¬q¤À§O¦b¤£¦Pªº°Ï¬q¡CCOMPACK ¼Ò¦¡«h¬O¥u¦³¤@Óµ{¦¡½X°Ï¬q¡A¦Ó¸ê®Æ¬q¥i¥H¦³¦n´XÓ¡CMEDIUM ¼Ò¦¡«h¬O¥u¦³¤@Ó¸ê®Æ¬q¡A¦Óµ{¦¡½X°Ï¬q¥i¥H¦³¦n´XÓ¡CLARGE ¼Ò¦¡«h¬Oµ{¦¡½X°Ï¬q©M¸ê®Æ¬q³£¥i¥H¦³¦n´XÓ¡CHUGE ¼Ò¦¡«h¬Oµ{¦¡½X°Ï¬q©M¸ê®Æ¬q³£¥i¥H¦³¦n´XÓ¡A¨Ã¥B¦³¥²nªº¸Ü¡A¨ä¬YÓÅܼƪø«×¥i¥H¶W¹L 64KB¡C
µù¤T¡G¼¶¼g Win32 ¨t²Îªºµ{¦¡¡A¦pªGn©I¥s°Æµ{¦¡¡A¤£½×¬O¦¹°Æµ{¦¡¬O¦bì©lÀɤ¤©Î¬O¥~³¡°Æµ{¦¡¡Aì©lµ{¦¡¥²¶·¥ý«Å§i°Æµ{¦¡¡A³oÂI©M¦b DOS ªº±¡§Î¤£¦P ( ¦pªG°Æµ{¦¡¦b call/INVOKE ©I¥s¤§«e¡A´N¤£¶·¥ý«Å§i )¡Cì¦]¬O¦b Win32 ¨t²Îùتºµ{¦¡·|¥Î¨ì Win32 API¡A¦Ó¨ä©Ò»Ý°Ñ¼Æ¬O©ñ¦b°ïÅ|ùØ¡A©Ò¥H¥²¶·ª¾¹D°Æµ{¦¡»Ýn´XӰѼơAÅý²ÕĶ¾¹¦n¦b°ïÅ|¤¤ªÅ¥X¤@¨ÇªÅ¶¡¡A®e¯Ç³o¨Ç°Ñ¼Æ¡C«Å§i°Æµ{¦¡»Ýnªº°Ñ¼Æ¡AºÙ¬°¡y«Å§i¨ç¼Æ쫬¡z¡C³oÂI©M C/C++ «Ü¹³¡A¦b C/C++ ùØ¡A¨Ï¥Î°Æµ{¦¡ ( C/C++ ºÙ¬°¨ç¦¡©Î¨ç¼Æ ) ®É¡A¤]³£n¨Æ¥ý«Å§i¡C
¦b Win32 ²Õ¦X»y¨¥¤¤«Å§i°Æµ{¦¡ì«¬ªº¤èªk¬O¥Î PROTO ¡A¤@¯ë PROTO ³£¬O©ñ¦bì©lµ{¦¡ªº³Ì«e±¡A¦Ü¤Ö¦b©I¥s°Æµ{¦¡¤§«e¡CPROTO ¬O¤@Ó MASM ªº°²«ü¥O¡A¨ä»yªk¦p¤U¡F
°Æµ{¦¡¦WºÙ PROTO [¦ì²¾] [µ{¦¡»y¨¥] [[°Ñ¼Æ¤@]:¸ê®Æ«¬ºA,] [[°Ñ¼Æ¤G]:¸ê®Æ«¬ºA,] ¡K¡K
¤W¦¡¤¤ªº¦ì²¾¥i¥H¥Î NEAR¡BFAR¡K¡Kµ¥¡Aªí¥Ü°Æµ{¦¡¶ZÂ÷©I¥sªÌ¦h»·¡A¬O§_¬O¦b¦P¤@ӰϬqµ¥µ¥¡A¦ý¬O¦b Win32 ùØ¡A°O¾ÐÅé¼Ò¦¡³£¬O FLAT ¼Ò¦¡¡A©Ò¥H¦b Win32 ²Õ¦X»y¨¥ùØ¡A³oӿﶵ¬OµL¥Îªº¡Cµ{¦¡»y¨¥¥i¥Î C¡BPASCAL¡BSTDCALL¡A¨ä·N¸q©M .MODEL ¬Û¦P¡A°²¦p³oӿﶵ¬Ù²¤ªº¸Ü¡A´N±Ä¨ú .MODEL ©Ò©w¸qªº¤è¦¡¡A¦b Win32 ²Õ¦X»y¨¥¨Ó»¡¡AÀ³¸Ón¨Ï¥Î STDCALL¡A¦Ó¥B¦b .MODEL ©w¸q§Y¥i¡C°Æµ{¦¡©Ò»Ýªº°Ñ¼Æ¦C¦b³Ì«á±¡A¹ï Win32 ²Õ¦X»y¨¥¨Ó»¡¡A°Ñ¼Æªº¸ê®Æ«¬ºA³£¬OÂù¦r²Õ¡A³o¬O¦]¬°n±À¤J°ïÅ|¡A°ïÅ|¤¤ªº¨C¤@µ§¸ê®Æ³£¬O 32 ¦ì¤¸ªø¡A¦Ó°Ñ¼Æ¦WºÙ³£¥i¥H¬Ù²¤¡A¦]¬°²ÕĶ¾¹¥u»Ýª¾¹D±À¤J°ïÅ|ªº°Ñ¼ÆӼơA¦Ü©ó°Ñ¼Æ¦WºÙ¬O¤£«nªº¡A¦pªG¤£¬O¬°¤F¥iŪ©Êªº¸Ü¬O¥i¥H¬Ù²¤ªº¡C
¦b message.asm ì©lµ{¦¡ùبèS¦³«Å§i MessageBox ³oÓ Win32 API¡A¦ý¬O¦b USER32.INC ùئ³¤@¦æ´N¬O©w¸q MessageBoxA ªº¨ç¼Æ쫬¡F
MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORD
©Ò¥HÁöµMì©lµ{¦¡¨Ã¨S¦³«Å§i MessageBox¡A¦ý¬O¥un§â USER32.INC ¥]§t¶i¨Ó´N¥i¥H¤F¡C¦Ü©ó MessageBox ©M MessageBoxA ªºÃö«Y½Ð°Ñ¦Òµù¥|¡C
·íµM°£¤F©I¥s Win32 API ¤§¥~¡A¤]¥i¥H©I¥s¦Û¤vªº°Æµ{¦¡¡A°²¦pn©I¥s¦Û¤vªº°Æµ{¦¡¡A¨º»ò°£¤F¤@¶}©l´Nn¥Î PROTO «Å§i°Æµ{¦¡¤§¥~¡AÁÙn¦Û¤v¥Î PROC/ENDP ¨Ó¼¶¼g°Æµ{¦¡¡A§_«h¦b API ¨S¦³¦Ó±z¤S¤£¦Û¤v¼¶¼g¡A³o¼ËµLªk»s¦¨ *.EXE ÀÉ¡C¦b MASM 6.x ¤§«á¡A PROC ¤w¸g°µ¤F¤@¨Ç×¥¿¡A¥¦ªº»yªk¦p¤U¡F
°Æµ{¦¡¦W PROC [¦ì²¾][µ{¦¡»y¨¥][¨Ï¥ÎÅv][USES ¼È¦s¾¹][°Ñ¼Æ¤@:¸ê®Æ«¬ºA,]¡K¡K °Æµ{¦¡¦W ENDP
°Æµ{¦¡¦W¥i¥H¥ô·N¨ú¡A¥un²Å¦X©R¦W³W«h¨Ã¥B PROC ©M ENDP ¤@P§Y¥i¡C¦ì²¾¡Bµ{¦¡»y¨¥¡B°Ñ¼Æ©M PROTO ·N¸q¬Û¦P¡A¦Ó¥B¦b PROTO «Å§i®É©M¦b PROC °²«ü¥O«ü©wªº¿ï¶µ¤]À³¸Ón¤@P¡C¨Ï¥ÎÅv¥i¥H¥Î PUBLIC¡BPRIVATE¡BEXPORT ¤TºØ¡APUBLIC ¬Oªí¥Ü©Ò¦³ªº¼Ò²Õ³£¥i¥H¨Ï¥Î¡A°²¦p¦b PROC ¨S¦³«ü©ú®É¡A²ÕĶ¾¹·|±Ä¥Î³oºØ¤è¦¡¡CPRIVATE ¬Oªí¥Ü¥u¦³¥»¼Ò²Õ¯à°÷¨Ï¥Î¡CEXPORT ¬O«ü¦pªGn½s¼g *.DLL ÀÉ®ÉÅý¦¹°Æµ{¦¡¯à°÷Â^¨ú¥X¨Ó¡CUSES ¤§«á±µ¤Wªº¼È¦s¾¹¬Oªí¥Ü²ÕĶ¾¹·|¦b°Æµ{¦¡Ä¶¶}©l¦Û°Ê¦w´¡ push «ü¥O¨Ï¼È¦s¾¹±À¤J°ïÅ|¡A¦b ENDP «ü¥O«e¥Î pop ¨ú¦^¼È¦s¾¹¡A³o¬OÅé¶Kµ{¦¡³]p®vªº¤@ºØ³]p¡A¦ý¦³®É¤£¦p¦Û¤v¥Î pushad ©M popad ³o¨âÓ 80386 «ü¥O¦Û¤v«O¦s¼È¦s¾¹¡CENDP °²«ü¥O¬Oªí¥Ü°Æµ{¦¡µ²§ô¡C
¦b¼¶¼g Win32 ²Õ¦X»y¨¥®É¡A¦pªGn©I¥s°Æµ{¦¡¡AÀ³¸Ón¦bµ{¦¡¤@¶}©l¨Ï¥Î PROTO «Å§i¨ç¦¡ì«¬¡A¨Ã¥B§â¸Ó°Æµ{¦¡ªº©Ò¥Î¨ìªº°Ñ¼Æ¦b PROTO «á±¡A¨Ã¥B¥Î PROC ªí¬O°Æµ{¦¡¶}©l¡A¦P®É¤]§â©Ò¨Ï¥Î¨ìªº°Ñ¼Æ¦C¦b PROC «á±¡AµM«á¦b©I¥s®É¾¨¶q¥Î INVOKE ¦Ó¤£n¥Î call¡C³o¼Ëªº¸Ü¡A¦pªG©I¥s®É°Ñ¼Æªº¼Æ¥Ø©M«Å§i®É¤£¤@¼Ë®É¡A²ÕĶ¾¹·|²£¥Í¿ù»~¡A¦Ü©ó±À¤J¦h¤ÖӰѼƨì°ïÅ|¥H¤Îµ²§ô°Æµ{¦¡®É±Ë±ó¦h¤Öªº°ïÅ|¸ê®Æ¡A³£¥Ñ²ÕĶ¾¹¦Û°Êpºâ¡A¤£¥Îµ{¦¡³]pªÌ¾Þ¤ß¡C°²¦p±z·Q¥Î call¡A·íµM¤]¥i¥H¡A¦ý¬O¥²¶·¦Û¦æª`·N°ïÅ|¬O§_¿ù»~¡A§_«h«Ü®e©ö·í¾÷¡Cµù¤C¦³¤@Ó¨Ò¤l»¡©ú PROTO¡BPROC¡BINVOKE ªºÃö«Y¡A¥H¤Î°ïÅ|¾Þ§@¡C
µù¥|¡G°²¦p±z¥h¬d Win32 API ¤â¥U¡A¥i¯à·|¬d¨ì MessageBoxA ©Î MessageBoxW¡A¦ý¬O´N§ä¤£¨ì MessageBox¡A¨ä¹ê MessgaeBoxA ¬O ANSI ª©¥»ªº¡AMessageBoxW ¬O UNICODE ª©¥»ªº¡A¦b Win 9x ¨t²Î¤¤¥u¤ä´© ANSI ª©¥»¡ANT/XP ¤ä´© ANSI ¤Î UNICODE¡A©Ò¥H¦b user32.inc ùØ°½°½§â MessgaeBox ©w¸q¦¨ MessgaeBoxA¡C±z¥i¥H¥Î¥ô¦ó¤å®Ñ³B²zµ{¦¡¶}±Ò user32.inc ÀɮסA¥i¥H§ä¨ì³o¤@¦æ¡F
MessageBox equ <MessageBoxA>
µù¤¡G¦³Ãö addr »P offset ªº¤£¦P¡A¨ä¹ê¬O©M°Ï°ìÅܼƻP¥þ°ìÅܼƦ³Ãö¡A½Ð°Ñ¦Ò²Ä¤T³¹¦³Ãö addr »P offset ªº»¡©ú¡C
ML /Zi /Cp /coff MESSAGE.ASM
¨º´N·|»s°µ¥X§t¦³²Å¸¹ªº MESSAGE.EXE¡AÁöµM³o¼Ëªº°µªk·|¨Ï±o MESSAGE.EXE ÀÉ®×Åܤj¤@¨Ç¡A¦ý¬O·í Soft-ICE ¸ü¤J®É¤£·|¥X²{³oÓ¿ù»~°T®§¡A¦Ó¥B¥i¥H¬Ý¨£ì©l½X¡A¨Ã¥B¥i¥H¥Îì©l½X¨Ó°£¿ù¡A·íµ{¦¡¸û¬°½ÆÂø®É¤ñ¸û¤è«K¡C¨ä¥Lªº ML °Ñ¼Æ¥i¥H¥Î
ML /help | more
¨ÓÆ[¹î¡C
µù¤C¡G¦b message.asm ùØ©I¥s¤F MessageBox API¡A¦ý¬O§Ṳ́£©öÆ[¹î¨ì¨ä°ïÅ|¹B§@±¡§Î¡C¬°¤F¸Ô²ÓÆ[¹îÆ[¹î°ïÅ|ªº¹B§@¥H¤Î PROC¡BINVOKE µ¥°²«ü¥O·t¦aùØ©Ò°µªº¨Æ¡A¤p¤ì°¸¥t¥~¼g¤F¤@Ó²³æªºµ{¦¡¨Ó»¡©ú¡C³oÓµ{¦¡·|©I¥s¤@Ó addition °Æµ{¦¡¡Aaddition °Æµ{¦¡ªº¥\¥Î¬O¥Î¨Ó¨D¤TӰѼƪº©M«á¦s©ó EAX ¼È¦s¾¹¡A¦Aªð¦^¥Dµ{¦¡¡Aì©lµ{¦¡¦p¤U¡G
.386 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE INCLUDE WINDOWS.INC INCLUDE KERNEL32.INC INCLUDELIB KERNEL32.LIB .DATA a1 DWORD 20h a2 DWORD 100h a3 DWORD 40000h .DATA? sum DWORD ? .CODE addition PROC para1:DWORD,para2:DWORD,para3:DWORD mov eax,para1 add eax,para2 add eax,para3 ret addition ENDP start: INVOKE addition, a1, a2, a3 mov sum,eax INVOKE ExitProcess,0 END start
²ÕĶ¡B³sµ²¦n«á¡A¥Î Soft-ICE ¸ü¤J¡A¦A«ö¤U¤@¦¸ F8 Áä¡AÆ[¹îµ{¦¡½X¦p¤U¡G
0187:00401000 55 PUSH EBP 0187:00401001 8BEC MOV EBP,ESP 0187:00401003 8B4508 MOV EAX,[EBP+08] 0187:00401006 03450C ADD EAX,[EBP+0C] 0187:00401009 034510 ADD EAX,[EBP+10] 0187:0040100C C9 LEAVE 0187:0040100D C20C00 RET 0C 0187:00401010 FF3508304000 PUSH DWPRD PTR [00403008] 0187:00401016 FF3504304000 PUSH DWPRD PTR [00403004] 0187:0040101C FF3500304000 PUSH DWPRD PTR [00403000] 0187:00401022 E809FFFFFF CALL 00401000 0187:00401027 A30C304000 MOV [0040300C],EAX 0187:0040102C 6A00 PUSH 00 0187:0040102E E801000000 CALL KERNEL32!ExitProcess
¤Wzµ{¦¡½X¤¤¾ï¦âªº³¡¥÷¬O addition °Æµ{¦¡¡AÂŦ⪺³¡¥÷¬O INVOKE °²«ü¥O³Q²ÕĶ«áªºµ²ªG¡C¥i¥H«Ü©úÅã¬Ý¥X¨Ó¡A²ÕĶ¾¹®Ú¾Ú INVOKE addition «á±ªº°Ñ¼Æ¦C¡A²ÕĶ¦¨¤TÓ push «ü¥O ( ª`·N³Ì¥kÃ䪺°Ñ¼Æ¥ý³Q±À¤J°ïÅ| )¡C¦b addition °Æµ{¦¡¤¤¡A²ÕĶ¾¹·|¦Û°Ê¥[¤W¤T¦æ¨Ãקï RET «ü¥O¡F
PUSH EBP MOV EBP,ESP ¡K¡K¡K¡K LEAVE RET 0C
«e¨â¦æ¬O¬°¤F¡A·í»Ýn°Ñ¼Æ®É´N§Q¥Î EBP ¼È¦s¾¹¦Û°ïÅ|¤¤¨ú¥X¡CEBP ©M BP ¼È¦s¾¹³£¬O¥i¥H§Q¥Î¼È¦s¾¹©w§}¨ú¥X°ïÅ|¬q ( SS ) ªº¼ÆÈ¡C³oÂI©M¥H«e¦b DOS ²Õ¦X»y¨¥¤¤¥Î BX¡BSI ©w§}¨ú¥X¸ê®Æ¬q ( DS ) ªº¼ÆÈ¡A©M¥Î DI ©w§}¨ú¥XÃB¥~¬q ( ES ) ªº¼ÆȬOÃþ¦üªº¡C³Ì«á¨â¦æ¬O¬°¤F¦Û°Æµ{¦¡ªð¦^¥Dµ{¦¡®É¡A¯à©ß±ó°Ñ¼Æ¸ê®Æ¥H¤Î«ì´_¥¿½Tªº EBP¡C©³¤U§ÚÌ¥ý¨Ó¬Ý¬Ý Soft-ICE ªº¼È¦s¾¹µøµ¡¡G
EAX=00401010 EBX=00000000 ECX=8196BF28 EDX=8196BF68 ESI=8196BF08 EDI=00000000 EBP=0063FF78 ESP=0063FE38 EIP=00401016 CS=0187 DS=018F SS=018F ES=018F FS=43CF GS=0000
¦A¦b Soft-ICE ³Ì¤U±ªºµøµ¡¿é¤J¡yd ds:402FF0¡z¡AÆ[¹î DATA °Ï¬qªº¸ê®Æ¡G
0187:00402FF0 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 0187:00403000 20 00 00 00 00 01 00 00-00 00 04 00 00 00 00 00
¾ï¦âªº¬O a1 ÅܼơA¦ì§}¦b 018F:00403000¡A²HÂŦ⪺¬O a2 ÅܼơA¦ì§}¦b018F:00403004¡A²H¶À¦âªº¬O a3 ÅܼơA¦ì§}¦b018F:00403008¡A¦b¦ì§}018F:0040300C ªº¬O sum ÅܼơF³o¨Ç¦ì§}¥i¥H¦b¤W±¥H Soft¡ÐICE ¤Ï²ÕĶ®É¡APUSH ¤TÓÅܼƪº¦ì§}¬Ý¥X¨Ó¡C³o®ÉÔ Soft-ICE ¥¿n°õ¦æ
0187:00401016 FF3504304000 PUSH DWPRD PTR [00403004]
³o¤@¦æ¡A¦ý©|¥¼°õ¦æ¡C³o¤@¦æ¨Ã¤£¬Oµ{¦¡ªº²Ä¤@¦æ¡A³o¬O¦]¬°¤@¶}©l§ÚÌ´¿¸g«ö¤U¤@¦¸ F8 Áä¡A©Ò¥H¨ä¹êµ{¦¡¤w¸g°õ¦æ¹L push a3 ¤F¡A´«¥y¸Ü»¡¡Aa3 ¤w³Q±À¤J°ïÅ|¤F¡A±z¥i¥H¨£¨ì°ïÅ|ªº±¡§Î¬O¤U¹Ïªº¹Ï¤@¡A40000h ¤w¸g¦b°ïÅ|ùؤF¡C¦Ó³Ì¥ªÃ䪺¥Õ¦â¼Æ¦r¡A0063FE24 ¨ì 0063FE3C¡A¬O°ïÅ|¦ì§}¡A¶À¦âªº¤T¨¤§Î½b¸¹»P ESP ¬O²{¦b ESP ©Ò«üªº¦ì§}¡A¦Ó³Ì¤W±ªº¤@¦æ¥Î¥Õ¦âªí¥Üªº«ü¥O¬O±Nn°õ¦æªº«ü¥O¡C©³¤U¤p¤ì°¸¥H¹Ï§Î»¡©ú°ïÅ|ÅܤƱ¡§Î¡F
¦A³sÄò«ö¨â¦¸ F8 «á¡A°ïÅ|±¡§ÎÅܦ¨¹Ï¤T¡A³o®ÉÔ¤w¸g§â addition ©Ò»Ýªº¤TӰѼƱÀ¤J°ïÅ|ùؤF¡C¦A«ö¤@¦¸ F8 Áä¡A©I¥s¦ì©ó 00401000 ªº addition °Æµ{¦¡¡A¦P®É§â¥Dµ{¦¡¤U¤@Ó±N°õ¦æ«ü¥Oªº¦ì§}¡A00401027¡A±À¤J°ïÅ|Àx¦s¡A¦p¹Ï¥|¡C¦A«ö¤U¤@¦¸ F8 Áä¡A°õ¦æ°Æµ{¦¡ªº²Ä¤@Ó«ü¥O¡A§âì¨Óªº EBP ±À¤J°ïÅ|Àx¦s°_¨Ó¡A¦p¹Ï¤¡C¦A«ö¤@¦¸ F8 Áä¡A¨Ï EBP «ü¦V°ïÅ|³»¡A¤@ª½¨ì°Æµ{¦¡µ²§ô«e¡AEBP ¤§È³£¬O 63FE28¡A¦p¹Ï¤»¡C
¥Ñ¤W±ªº¨Ò¤l¥i¥H¬Ý¨ì¡A¥Dµ{¦¡¥ý§â°Ñ¼Æ¥Ñ¥k¦Ü¥ª±À¤J°ïÅ|¡A±µµÛ°õ¦æ call «ü¥O®É§âªð¦^¦ì§}±À¤J°ïÅ|¡A¨Ã¥H EBP ·í§@«ü¼Ð¦s¨ú°Ñ¼Æ¡F¦pªG°Æµ{¦¡»Ýn¥Î¨ì°Ï°ìÅܼƮɡA¤]·|¦b³o¶ô°ïÅ|¤¤«Ø¥ß°Ï°ìÅܼơC³o¶ô°ïÅ|¥i»¡¬O°Æµ{¦¡»P¥Dµ{¦¡·¾³qªº¾ô¼Ù¡A¤]¬O°Æµ{¦¡¦s¨ú¸ê®Æ©Ò¦b¡A³o¶ô°ïÅ|ºÙ¬°¡y°ïÅ|®Ø¡z( stack frame )¡C¤W¹Ï¤¤ªº 63FE38 ¨ì 63FE28 §Y¬°°ïÅ|®Ø¡C¦b Win32 ùر¡A°Æµ{¦¡ªº²Ä¤@ӰѼƥH [EBP¡Ï08H] ªí¥Ü¡B²Ä¤GӰѼƥH [EBP¡Ï0CH] ªí¥Ü¡B²Ä¤TӰѼƥH [EBP¡Ï10H] ªí¥Ü¡K¡K¡F¦Óªð¦^¦ì§}«hÀx¦s¦b [EBP¡Ï04H] ¤§³B¡C
LEAVE «ü¥O¬O 80X86 CPU «ü¥O¶°ªº¤@Ó«ü¥O¡A¥¦¥ý¨Ï ESP ¼È¦s¾¹³]©w¬° EBP ¤§È¡AµM«á¦A¼u¥X¤@Ó°ïÅ|¼ÆȦs©ó EBP¡C±`¥Î©óªð¦^¥Dµ{¦¡®É§â ESP ¤§È³]©w¬°¥¿½TÈ¡C¦b°Æµ{¦¡¤¤¡AESP ¤§È¤£¤@©w¬O«ü¦V±z©Ò¹w´Áªº¦ì§}¡A¦]¬°±`¦³¤¤Â_µo¥Í¡A·|¨Ï ESP Ȥ£½T©w¡A¦ý¬O¦pªG¦b°Æµ{¦¡¤@¶}©l³]©w EBP È¡A¨º EBP ¤£·|§ïÅÜ¡C©Ò¥H Win32 ¨t²Î±`§Q¥Î LEAVE «ü¥O¦bªð¦^¥Dµ{¦¡®É§â ESP ¤§È³]©w¬°¥¿½TÈ¡C¦b Win32 ¨t²Î¤¤¡A¤@Ó°ïÅ|¼ÆȪø«×¬°¤@ÓÂù¦r²Õ ( 32 Ӧ줸 )¡C
¦b 16 ¦ì¤¸ªº DOS ¨t²Î¤¤¡A¤]¥i¥H¨Ï¥Î LEAVE «ü¥O¡A³o®É¨Ï SP ¼È¦s¾¹¤§È³]¬° BP ¤§È¡AµM«á¦A¼u¥X¤@Ó°ïÅ|¼ÆȦs©ó BP¡C©Ò¤£¦Pªº¬O¡A¦b 16 ¦ì¤¸ªº¨t²ÎùØ¡A°ïÅ|¤@Ó¼ÆȪø«×¬°¤@Ó¦r²Õ ( 16 Ӧ줸 )¡C
RET «ü¥O¤]¬O¤@Ó 80X86 CPU «ü¥O¶°ªº¤@Ó«ü¥O¡A°²¦p n ¬°¹s¥i¥H¶È¼g¡yRET¡z¡A¨º´N¬O¨ú¥X¤@Ó°ïÅ|ªº¸ê®Æ¡A¦s©ó IP ©Î EIP¡Aµø Win32 ©Î DOS ¨t²Î¦Ó©w¡C°²¦p¦³ n È¡A¨º»ò¥ý¨ú¥X¤@Ó°ïÅ|ªº¸ê®Æ¡A¦s©ó IP ©Î EIP¡AµM«á¦A¨Ï SP ©Î ESP ¤§È¥[¤W n¡A©ß±ó°ïÅ|¤W n Ӧ줸²Õªº¸ê®Æ¡A³o¨Ç¸ê®Æ¤]´N¬O©I¥s°Æµ{¦¡®É¦s©ó°ïÅ|ªº°Ñ¼Æ¡C¤@¯ë¦Ó¨¥¡An ȳq±`¥Ñ²ÕĶ¾¹³]©w¡A¼gµ{¦¡®É¡A¥i¥H©¿²¤¦Ó¥u¼g¡yRET¡z§Y¥i¡C