¦b DOS §@·~¨t²Îùتº²Õ¦X»y¨¥±Ð¾Ç¤¤¡A¤p¤ì°¸´¿¦b²Ä¤Q³¹¤¶²Ð¤F»s§@µ{¦¡®w ( ©Î½¦¨¨ç¦¡®w¡A^¤å¬O library ) ªº¤èªk¡A³oºØµ{¦¡®w¬O¦b³sµ²¹Lµ{¤¤¡A¥Ñ³sµ²¾¹¦bµ{¦¡®wùØ´M§än©I¥sªº°Æµ{¦¡¡A±µµÛ§â³oӰƵ{¦¡¾ã¬q¦a´O¤J¥Dµ{¦¡¦Ó²£¥Í¥i°õ¦æÀÉ¡C¹³³oºØª½±µ§â°Æµ{¦¡ªºµ{¦¡½X¼g¤J¨ì¥i°õ¦æÀɤ¤ªº³sµ²¤è¦¡ºÙ¬°ÀRºA³sµ²¡A¦Ó³Q³sµ²ªºµ{¦¡®wºÙ¬°ÀRºAµ{¦¡®w¡C·íÀRºA³sµ²µ{¦¡®w³Q´¡¤J¥Dµ{¦¡«á¡A§Y¨ÏÀRºA³sµ²µ{¦¡®w³Q§R±¼¡A¥Dµ{¦¡¤´¯à¥¿±`°õ¦æ¡C
ÀRºA³sµ²ªº¯ÊÂI¤j¬ù¦³¨âÓ¡G²Ä¤@Ó¬OÀRºA³sµ²·|¦û¾Ú¤ñ¸û¦hªºµwºÐªÅ¶¡©Î°O¾ÐÅé¡A°²¦p¦³ 100 Óµ{¦¡n©I¥s¬Y¤@¬q°Æµ{¦¡¡A¨º»ò´N¦³ 100 Ó¬Û¦Pªº°Æµ{¦¡·|³Q¼g¤J¤£¦Pªºµ{¦¡¤¤¡A¥ç§Y¦bµwºÐ¾÷ùØ´N«½Æ¤F³o 100 ӰƵ{¦¡¡C²Ä¤GÓ¯ÊÂI¬OºûÅ@¤Wªº¤£«K¡A¦pªGµo²{¬Y¬q°Æµ{¦¡ªºµ{¦¡½X¿ù»~©ÎªÌn§ó·sª©¥»¡A¨º»ò¥u¯à§â©Ò¦³©I¥s³o¬q°Æµ{¦¡ªº¥Dµ{¦¡«·s²ÕĶ¡B³sµ²¤~¯à×¥¿¿ù»~¡A°²¦p¦³¤@Óµ{¦¡¿òº|¤F¡A¨º»ò³oÓ¿òº|ªº¥Dµ{¦¡ÁÙ¬O·|¨Ï¥Îª©©Î¿ù»~ªº°Æµ{¦¡¡C
¨º»ò¡AWindows §@·~¨t²Î¦³¨S¦³¤èªk§ï¶i³o¨âÓ¯ÊÂI©O¡Hµª®×·íµM¬OªÖ©wªº¡A§_«h´N¤£·|¦³³o¤@³¹¤F¡CWindows ±Ä¥Î°ÊºA³sµ²ªº¤è¦¡©I¥s°Æµ{¦¡¡A¦Ó§â³o¨Ç°Æµ{¦¡¶°¦X°_¨Ó©Ò¦¨ªºµ{¦¡®w´N¥s°µ°ÊºA³sµ²µ{¦¡®w ( dynamic-link library¡AÁY¼g¬° DLL )¡A°ÊºA³sµ²µ{¦¡®wªº°ÆÀɦW³q±`¬O DLL¡A¦ý¬O¤]¦³¥H EXE¡BOCX µ¥¬°°ÆÀɦWªº°ÊºA³sµ²µ{¦¡®w¡C¥H³oºØ¤è¦¡©Ò²£¥Íªº¥Dµ{¦¡¦b³sµ²¶¥¬q¡A¨Ã¤£·|´O¤J°Æµ{¦¡ªºµ{¦¡½X¡A¦Ó¶È¶È§â°Æµ{¦¡©Ò¦bªºµ{¦¡®w ( °ÆÀɦW¬° DLL ) ¤Î°Æµ{¦¡¬ÛÃö°T®§ ( ¦p°Æµ{¦¡¦WºÙµ¥µ¥ ) ´¡¤Jµ{¦¡ùØ¡A¦Ó³o¨Ç³Q´¡¤J¸ê®Æ¬O¥Ñ°ÆÀɦW¬° LIB ªº¶×¤Jµ{¦¡®w´£¨Ñ¡C
¨Æ¹ê¤W¡AWindows §@·~¨t²Î´N¬O¥Ñ³\¦hªº°ÊºA³sµ²µ{¦¡®w©Ò²Õ¦¨ªº¡A¨Ò¦p³Ì¥Dnªº¤TӰʺA³sµ²µ{¦¡®w¡G
¡@¡@1.USER32.DLL ¤¤ªº°Æµ{¦¡¡A¥Dn¬O±±¨î¨Ï¥ÎªÌ¬É±
¡@¡@2.GDI32.DLL ¤¤ªº°Æµ{¦¡¡A¥Dnt³d¹Ï§ÎªºÅã¥Ü¡B¾Þ§@
¡@¡@3.KERNEL32.DLL ¤¤ªº°Æµ{¦¡¡A¥Dn³B²z°O¾ÐÅéºÞ²z©M¤u§@½Õ«×
·í¥Dµ{¦¡³Q°õ¦æ®É¡A§@·~¨t²Î¤~·|§â©Ò»Ýn¥Î¨ì°ÊºA³sµ²µ{¦¡®w¸ü¤J¦Ü°O¾ÐÅé¡A¦pªG³oӰʺA³sµ²µ{¦¡®w¤w¸g¸ü¤J°O¾ÐÅé¤F¡A§@·~¨t²Î±N·|§â³oӰƵ{¦¡ªºµ{¦¡½X¬M®g¨ì¥Dµ{¦¡©Ò¦b°O¾ÐÅéªÅ¶¡¡A©Ò¥H¦b¹êÅé°O¾ÐÅ餤ÁÙ¬O¶È«O¦s¤@¥÷µ{¦¡½X¡C¦]¬°°ÊºA³sµ²µ{¦¡®wªºµ{¦¡½X¦ì§}¬O¬M®g¦Ü¥Dµ{¦¡ªº¦ì§}ªÅ¶¡¡A©Ò¥HºÙ¬°¡y°ÊºA¡z¡C°²¦p¨t²Î§ä¤£µÛ°ÊºA³sµ²µ{¦¡®w¡A¨º»òµ{¦¡´NµLªk°õ¦æ¡C
°ÊºA³sµ²µ{¦¡®w¥i¥H¬Ý¦¨¬O¤@¨Ç°Æµ{¦¡ªº¶°¦X ( ¤£¹L¤]¦³¨Ò¥~¡A¤]¦³¨Ç¬O¬Y¨Ç¸ê·½ªº¶°¦X )¡A¤@¯ë¦Ó¨¥¡A³o¨Ç°Æµ{¦¡¬O³Q¨ä¥Lµ{¦¡©Ò©I¥s¡A©Ò¥H¤£»Ýn«Ø¥ßµøµ¡¡A¤]¤£»Ýn°T®§°j°é©Î²×µ²µøµ¡ªºµ{¦¡½X¡C¨CӰʺA³sµ²µ{¦¡®w³£·|¦³¤@ÓºÙ¬°¡y¶i¤J¡þÂ÷¶}°Æµ{¦¡¡zªº°Æµ{¦¡¡A¥¦ªº¦WºÙ¥i¥H¥ô·Nq©w¡A¥un²Å¦X©R¦W³W«h§Y¥i¡C¡y¶i¤J¡þÂ÷¶}°Æµ{¦¡¡z¨Ã¤£¹³°ÊºA³sµ²®wùتº¨ä¥L°Æµ{¦¡¤@¼Ëµ¹¨ä¥Lµ{¦¡©I¥s¡A¦Ó¬O§@·~¨t²Î¸ü¤J©Î¨ø¸ü°ÊºA³sµ²µ{¦¡®w®É¡A¥Ñ§@·~¨t²Î©I¥s¡AÅý§@·~¨t²Î¦³¾÷·|°µ¤@¨Ç¨Æ«e³B²z©Î¬OÂ÷¶}®É§@¤@¨Ç²M°£°Ê§@¥Îªº¡C¡y¶i¤J¡þÂ÷¶}°Æµ{¦¡¡z¦³©T©wªº®æ¦¡¡A°²¦p¤£»Ýn°µ³o¨Ç°Ê§@ªº¸Ü¡A¡y¶i¤J¡þÂ÷¶}°Æµ{¦¡¡z¤]¥i¥H¥u¬O§â TRUE ¦s¤J EAX ùØ¡AµM«á§â TRUE ·í¦¨ªð¦^È´N¸õÂ÷¡C¾ãӰʺA³sµ²µ{¦¡®wªº¼Ë¤l¹³©³¤U³o¼Ë¡G
.386 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE ;°²¦p»Ýn¥Î¨ì¥]§tÀÉ¡A¨º»ò¥i¥H¦b¦¹³B©w¸q INCLUDE WINDOWS.INC INCLUDE USER32.INC INCLUDE KERNEL32.INC INCLUDELIB USER32.LIB INCLUDELIB KERNEL32.LIB ;********************************************************************* .DATA? ;¦¹³B©w¸q¥¼ªì©l¤ÆªºÅÜ¼Æ ;********************************************************************* .CODE ;--------------------------------------------------------------------- ;¶i¤J¡þÂ÷¶}°Æµ{¦¡ªº¶i¤JÂI DLLEntry PROC hInstance,dwReason,dwReserved mov eax,dwReason .IF eax==DLL_PROCESS_ATTACH ;«O¦shInstance ;ªì©l¤Æ°ÊºA³sµ²µ{¦¡®w»Ýnªº¦UºØ¸ê·½ .IF ;ªì©l¤Æ¦¨¥\ mov eax,TRUE .ELSE mov eax,FALSE .ENDIF .ELSEIF eax==DLL_THREAD_ATTACH ;ÄÀ©ñ°ÊºA³sµ²µ{¦¡®w¨Ï¥Îªº¸ê·½ .ELSEIF eax==DLL_THREAD_DETACH ;¬°·sªº°õ¦æºü¤À°t¸ê·½ .ELSEIF eax==DLL_PROCESS_DETACH ;¬°°õ¦æºüÄÀ©ñ¸ê·½ .ENDIF DLLEntry ENDP ;¶i¤J¡þÂ÷¶}°Æµ{¦¡µ²§ô ;--------------------------------------------------------------------- SubRoutine1 PROC Param1,Param2 ;¦¹³B¬°²Ä¤@ӰƵ{¦¡ªº°Ñ¼Æ ;¦¹³B¬°²Ä¤@ӰƵ{¦¡ªºµ{¦¡½X ret SubRoutine1 ENDP ;--------------------------------------------------------------------- SubRoutine2 PROC ParamA,ParamB ;¦¹³B¬°²Ä¤GӰƵ{¦¡ªº°Ñ¼Æ ;¦¹³B¬°²Ä¤GӰƵ{¦¡ªºµ{¦¡½X ret SubRoutine2 ENDP ;--------------------------------------------------------------------- SubRoutine3 PROC ParamX,ParamY ;¦¹³B¬°²Ä¤TӰƵ{¦¡ªº°Ñ¼Æ ;¦¹³B¬°²Ä¤TӰƵ{¦¡ªºµ{¦¡½X ret SubRoutine3 ENDP ;********************************************************************* END DLLEntry
¤W±ªº³oÓ¨Ò¤l¡A¡y¶i¤J¡þÂ÷¶}°Æµ{¦¡¡z¦W¦r¬O¡yDLLEntry¡z¡A¹ï©ón°µ¨Æ«e³B²z©Î²M²z°Ê§@ªº°ÊºA³sµ²µ{¦¡®w¡A¤À§O¥Ñ¤£¦Pªº±ø¥ó°µ³B²z¡A´N¬O¹³¤W±ªº¡yDLLEntry¡z°Æµ{¦¡©Òªí¥Üªº¡C§@·~¨t²Î·|¶Ç¨Ó¤Tªº°Ñ¼Æ¡A¤À§O¬O hInstance¡BdwReason ¤Î dwReserved¡ChInstance ¬O°ÊºA³sµ²µ{¦¡®wªº¼Ò²Õ¥N½X¡A³oÓ¼Ò²Õ¥N½X»P¥Dµ{¦¡ªº¼Ò²Õ¥N½X¤£¦P¡A©Ò¥HµLªk¥H GetModuleHandle ¨ú±o¡CdwReason ªí¥Ü¦]¬°þ¤@ºØì¦]¦Ó¨Ï±o§@·~¨t²Î¸ü¤J°ÊºA³sµ²µ{¦¡®w¡A§ÚÌ¥i¦b¦¹³B°µ«e¸m³B²z©Î¬O²M°£°Ê§@¡AdwReason ¥i¤À¬°¥|ºØì¦]¡G
DLL_PROCESS_ATTACH¡Gªí¥Ü°ÊºA³sµ²µ{¦¡®wè³Q¬M®g¨ì¥Dµ{¦¡ªº¦ì§}ªÅ¶¡¡A§ÚÌ¥i¥H¦b¦¹°µ¤@¨Çµ{¦¡®w¸ü¤J®Éªºªì©l¤Æ¤u§@¡A¦pªG¦¨¥\«hªð¦^ TRUE¡F§_«hªð¦^ FALSE¡Aªí¥Üµ{¦¡®wµLªk¥¿±`¤u§@¡C·í¨Ï¥ÎªÌ¨Ï¥Î·Æ¹«¡A¦b®à±¤WÂùÀ»¬Y¤@Óµ{¦¡ªº¹Ï¥Ü®É¡AWindows §@·~¨t²Î·|¬°¸Óµ{¦¡«Ø¥ß¦ì§}ªÅ¶¡¡A±µµÛ§â³oµ{¦¡¥H¤Î©Ò»Ýªº°ÊºA³sµ²µ{¦¡®w¸ü¤J¶iè«Ø¥ßªº¦ì§}ªÅ¶¡¡AµM«á¨t²Î·|¬°³oÓµ{¦¡«Ø¥ß¥D°õ¦æºü¡A¦A¥Ñ³oÓ¥D°õ¦æºü©I¥s¨C¤@ӰʺA³sµ²µ{¦¡®wªº¶i¤J¡þÂ÷¶}°Æµ{¦¡¡A¦¹®É dwReason °Ñ¼Æ´N¬O DLL_PROCESS_ATTACH¡C¥un¦³¤@ӰʺA³sµ²µ{¦¡®wªº¶Ç¦^ȬO FALSE¡A¨º»ò¨t²Î·|²×¤îµ{¦¡Ä~Äò°õ¦æ¡C
DLL_PROCESS_DETACH¡Gªí¥Üµ{¦¡®w³Q¨ø¸ü®É¡A¨t²Î·|¥H DLL_PROCESS_DETACH ¬° dwReason °Ñ¼Æ¤§È¡A©I¥s°ÊºA³sµ²µ{¦¡®wªº¶i¤J¡þÂ÷¶}°Æµ{¦¡¡A¥i¥H¦b¦¹°µ¤@¨Ç²M°£ªº°Ê§@¡C¦Ûµ{¦¡®w¸ü¤J¨ì¨ø¸üªº¹Lµ{¤¤¡ADLL_PROCESS_ATTACH ©M DLL_PROCESS_DETACH °T®§¥uµo¥Í¤@¦¸¡C
DLL_THREAD_ATTACH¡G·í¥Dµ{¦¡«Ø¥ß¤F·sªº°õ¦æºü®É¡A¨t²Î·|¥H DLL_THREAD_ATTACH ¬°°Ñ¼Æ©I¥s°ÊºA³sµ²°Æµ{¦¡¡A¥H¨Ïµ{¦¡¦³¾÷·|§@ªì©l¤Æ°õ¦æºüªº¤u§@¡C
DLL_THREAD_DETACH¡G·í¥Dµ{¦¡²×¤î°õ¦æºü®É¡A¨t²Î·|¥H DLL_THREAD_DETACH ¬°°Ñ¼Æ©I¥s°ÊºA³sµ²°Æµ{¦¡¡C¦pªG¨S¦³«Ø¥ß°õ¦æºü¡ADLL_THREAD_ATTACH¡BDLL_THREAD_DETACH ´N¤£·|µo¥Í¡C
°ÊºA³sµ²µ{¦¡®w ( DLL ÀÉ ) ªº®æ¦¡»Pµøµ¡¥i°õ¦æÀÉ ( EXE ÀÉ ) ¤@¼Ë¡A³£¬O 32 ¦ì¤¸µøµ¡ªº¥i°õ¦æÀÉ¡A¤]´N¬O PE ®æ¦¡ ( portable executable )¡A©Ò¥H DLL Àɤ]¹³ EXE Àɤ@¼Ë¡A¥i¥H¥]§tµ{¦¡½X¡B¸ê®Æ©M¸ê·½¡A¦ý¬O DLL ÀÉ»P EXE ÀÉÁÙ¬O¦³¤£¦Pªº¦a¤è¡A¨º´N¬O DLL Àɤ¤§t¦³¤@ÓºÙ¬°¶×¥Xªí³æªºªí®æ¡A¥u¦³¦b³oÓªí®æ¤¤©Ò¦C¥Xªº°Æµ{¦¡¤~¯à¬°¨ä¥Lµ{¦¡©Ò©I¥s¡C¨º»òn«ç»ò¼Ë°µ¡A¦b DLL Àɤ¤ªº°Æµ{¦¡¤~¯à³Q¥~³¡µ{¦¡©I¥s©O¡Hµª®×¬O¥Ñ¼Ò²Õ©w¸qÀɤ¤©w¸q¡C
¼Ò²Õ©w¸qÀÉ ( Module-Definition File ) ªº°ÆÀɦW¬O DEF¡A¥¦¬O¦b³sµ²¶¥¬q¡A¥Î¨Ó«ü©w°ÊºA³sµ²µ{¦¡®w¤¤ªºþ¨Ç°Æµ{¦¡¥i¥H¬°¥~³¡¥Dµ{¦¡©Ò©I¥s¡A¨Ã¥Ñ³sµ²¾¹³sµ²¼g¤J¨ì¶×¥Xªí³æùØ¡CDEF Àɪº®æ¦¡¬O¥Ñ´XÓ¬q¸¨²Õ¦¨¡A¨CÓ¬q¸¨³£¬O¥Ñ¤@ÓÃöÁä¦r¶}©l¡A³o¨ÇÃöÁä¦r¦³ LIBRARY¡BEXPORT¡BSECTIONS µ¥µ¥¡CDEF Àɤ]¥i¥H¥[¤Jµù¸Ñ¡A»P²Õ¦X»y¨¥ì©l½X¬Û¦P¡A¡y;¡z¤§«á´N¬Oµù¸Ñ¡C¨ä¥LÁÙ¦³³\¦hÃöÁä¦r¡A½Ð°Ñ¦Ò·L³nªº MSDN ºô¯¸¡C©³¤U¬O´XÓ¦b¼Ò²Õ©w¸qÀɤ¤±`¨£ªºÃöÁä¦r¡G
LIBRARY ÃöÁä¦rªº»yªk¬O¡G
LIBRARY [library][BASE=address]
«ü©w¤F LIBRARY «á¡A·|¨Ï LINK.EXE «Ø¥ß DLL.LINK ÀÉ¡Clibrary ÁÙ¥i¥H«ü©w LINK.EXE ¿é¥Xªº°ÊºA³sµ²µ{¦¡®wªº¥DÀɦW¡CBASE ¬O«ü©w¸ü¤J DLL ®Éªº¦ì§}¡A¦p¤£¯S§O«ü©w BASE¡A¨t²Î·|¨Ï°ÊºA³sµ²µ{¦¡®w¬M®g¨ì¦ì§} 10000000H ³B¡A±z¥i¥H¥Ñ OllyDebug ¤¤°lÂܸոլݡC³Ì«á¡ALIBRARY ¬q¸¨¥²¶·©ñ¦b DEF Àɪº³Ì«e±¡C
EXPORTS ÃöÁä¦r¶}©lªº¬q¸¨«ü©w¤Fþ¨Ç°Æµ{¦¡¥i¥H³Q¨ä¥Lµ{¦¡©I¥s¡A³oÓ¬q¸¨¬O¥Ñ¤@өΦhÓ±Ôz²Õ¦¨¡A¨CÓ±Ôz®æ¦¡¦p¤U¡G
entryname[=internalname] [@ordinal [NONAME]] [PRIVATE] [DATA]
¤¤¬A¸¹ ( [ ] ) ¤ºªºÄݩʬO¥i¥H¬Ù²¤ªº¡Centryname ¬O±zn¶×¥Xªº°Æµ{¦¡¦WºÙ¡A³o¬O¥²nªºÄÝ©Ê¡Cinternalname ¬O°Æµ{¦¡¤º³¡ªº¦WºÙ¡A¥ç§Yì©l½X¤¤°Æµ{¦¡ªº¦W¦r¡A¦pªG«á±ªº¡y=internalname¡z¬Ù²¤¡Aªí¥Ü©I¥s®É©Ò¨Ï¥Î¦WºÙ»Pì©l½X¤¤ªº°Æµ{¦¡¦WºÙ¬Û¦P¡F´«¥y¸Ü»¡¡Aì©l½X¤¤°Æµ{¦¡ªº¦WºÙ¤]¥i¥H¸ò©I¥s®Éªº¦WºÙ¤£¦P¡A³o®É±z´N±o¥H internalname ¨Ó«ü©wì©l½Xªº¦WºÙ¡A¥H entryname ¨Ó«ü©w©I¥s®É©Ò¨Ï¥Îªº¦WºÙ¡C¨Ò¦p¡A¦pªGì©l½X¤¤°Æµ{¦¡¦W¬° ubcd_add¡A¦ý¬O±z§Æ±æ±N¥¦·í°µ UBCD_ADDS ¨Ó©I¥s¡A´N¥i¥H«ü©w¡G
EXPORTS UBCD_ADDS=ubcd_add
§Ç¼Æ¡Aordinal¡A¬O¦b¡©@¡ª¤§«áªºªü©Ô§B¼Æ¦r¡A¥i¥H©I¥s§Ç¼Æ¥N´À°Æµ{¦¡¦WºÙ¡A¦pªG¥[¤W¡yNONAME¡zªí¥Ü¥u¥Î§Ç¼Æ¶×¥X¡A³o¼Ëªº¸Ü¨S¦³°Æµ{¦¡¦WºÙ¡An«ç»ò¤~¯à©I¥s©O¡H¤èªk¥u¦³¤@Ó¡A¨º´N¬O¨Ï¥Î¡y°õ¦æ®É°ÊºA³sµ²¡z¤è¦¡©I¥s¡A¦Ó¦b¨Ï¥Î GetProcAddr ¨ú±o°Æµ{¦¡¦ì§}®É¡A¨Ï¥Î§Ç¼Æ§@¬°°Ñ¼Æ¡A¸Ô±¡½Ð°Ñ¦Ò°õ¦æ®É°ÊºA³sµ² DLL ¡CPRIVATE ¬O«ü¤£§â entryname ©ñ¤J¶×¤Jµ{¦¡®wùØ¡CDATA ªí¥Ü entryname ¬OÅܼƦӫD°Æµ{¦¡¡C
SECTIONS ÃöÁä¦r¶}©lªº¬q¸¨¡A¥i¥H¬O¥Ñ¤@өΦhÓ±Ôz²Õ¦¨¡A¨ä¨CÓ±Ôzªº»yªk¦p¤U¡G
.section_name specifier
.section_name ¬O°Ï¬q¦WºÙ¡Aspecifier ¥i¥H¬O EXECUTE¡BREAD¡BSHARED ©Î WRITE¡CSection ¬O°Ï¬qªº·N«ä¡A¦b Win32 ²Õ¦X»y¨¥ªº section »P DOS ¤¤ segment ¥Nªíµ{¦¡½X¡B¸ê®Æ¡B°ïÅ|·N¸qªº¤£¦P¡AÁöµM¨âªÌ³£Ä¶¦¨°Ï¬q¡C¦b Win32 ²Õ¦X»y¨¥ùØ¡Asection ¬Oªí¥Ü¬O§_¥iŪ¡B¥i¼g¤§·N¡C°²¦p¬YӰϬqn³]¬°¥iŪ¥B¥i¼g¡A«h¤¤¶¡¥HªÅ¥Õ¤À¹j¡C¦¹¥~¤]¥i¥H¦b³sµ²¾¹ªº°Ñ¼Æ¤¤«ü©w¡C
VERSION ¡Aªí¥Üª©¥»¸¹½X¡A¨ä®æ¦¡¦p¤U¡G
VERSION major [. minor]
Major ¬O¥Dnª©¥»¡Aminor ¬O¦¸nª©¥»¡A¨âªÌ³£¬O¤Q¶i¦ìªº¼ÆÈ¡A¥Ñ 0 ¨ì 65535¡C¦pªG¬Ù²¤¡A¤º©wȬO 0.0¡C
Á¿¤F³o»ò¬\ÀêµL¨ýªº²z½×¡A¦pªG¤£¹ê»Ú¾Þ§@¤@µf¡AµS¦p¯È¤W½Í§L¡A²@µL·N¸q¡A©³¤U¤p¤ì°¸´Nºt¥Ü»s§@°ÊºA³sµ²µ{¦¡®wªº¹Lµ{¡C©³¤U¤p¤ì°¸§âªþ¿ý¤Tªº¤j¼Æªº¥[ªk»P¼ªk»s§@¦¨°ÊºA³sµ²µ{¦¡®w¬°¨Ò¡A»¡©ú¨ä»s§@¨BÆJ¡C
º¥ý¡A¨Ì·Ó¤Wz®æ¦¡¡A¼¶¼g©³¤U¤j¼Æ¥[ªk»P¤j¼Æ¼ªk°Æµ{¦¡¡A¨Ã¨Ì·Ó¤Wz®æ¦¡¦s¦¨ UBCDDLL.ASM¡G
.586 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE ;¥]§tÀÉ»P¶×¤Jµ{¦¡®w INCLUDE KERNEL32.INC INCLUDELIB KERNEL32.LIB TRUE EQU 1 GMEM_SHARE EQU 2000h GMEM_FIXED EQU 0h GMEM_ZEROINIT EQU 40h GPTR EQU GMEM_FIXED OR GMEM_ZEROINIT ;******************************************************************************* .CODE ;------------------------------------------------------------------------------- ;¶i¤J¡þÂ÷¶}°Æµ{¦¡ DLLEntry PROC hInstDLL,dwReason,dwReserved mov eax,TRUE ;¤£»Ý¨Æ«e³B²z©Î¨Æ«á²M²z¡A¬G¶Èªð¦^TRUE ret DLLEntry ENDP ;------------------------------------------------------------------------------- ubcd_add PROC USES ebx edx esi edi lpLow1,lpLow2,lpSum,n1,n2 ;pºâ¨â«D»E¶°BCD¼Æ¤§©M ;¿é¤J¡GlpLow1¡G³Q¥[¼Æ³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§} ; lpLow2¡G¥[¼Æ³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§} ; lpSum¡G©M³Ì§C¦ì§} ; n1¡G³Q¥[¼Æ¦ì¼Æ ; n2¡G¥[¼Æ¦ì¼Æ ;¿é¥X¡GEAX¡G¬°©M©ÒÀx¦sªº¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§} ; ECX¡G©Mªºªø«×¡A§Y¦ì¼Æ ; EBX¡BEDX¡BESI¡BEDI§¡³Q«O¦s°_¨Ó mov esi,lpLow1 ;ESI=³Q¥[¼Æ³Ì§C¦ì§} mov ebx,lpLow2 ;EBX=¥[¼Æ³Ì§C¦ì§} mov eax,n1 cmp eax,n2 ;¤ñ¸û³Q¥[¼Æ»P¥[¼Æ¨º¤@Ó¦ì¼Æ¤j jae u_a0 xchg eax,n2 ;Y¥[¼Æ¦ì¼Æ¤j¡A«h¨Ï³Q¥[¼Æ»P¥[¼Æ¥æ´«³Ì§C¦ì§} xchg esi,ebx ;(ESI»PEBX)¡A¦P®É¤]¥æ´«¦ì¼Æ(n1¡Nn2) mov n1,eax mov lpLow2,esi mov lpLow1,ebx ;¶}©l¬Û¥[®É¡AESI«ü¦V¨â¼Æ¦ì¼Æ¸û¤jªÌªº¦ì§}¡An1¬°¨ä¦ì¼Æ u_a0: sub eax,n2 mov n1,eax ;n1¡×«Å|³¡¥÷ªº¦ì¼Æ mov edi,lpSum ;pºâ«Å|³¡¥÷¡A¨Ò¦p ; 987654 ;+ 912 ;--------- ; 988566 ;³Q¥[¼Æ¡B¥[¼Æ³£¦³Ó¦ì¡B¤Q¦ì¡B¦Ê¦ì¼Æ¡A©Ò¥H¬O«Å|ªº³¡¥÷¡C clc sub eax,eax u_a1: lodsb ;¨ú±o¥[¼Æ¤¤ªº¤@¦ì add al,ah ;¥[¤W¶i¦ìªº¼Æ cbw add al,[ebx] aaa ;¥[ªk½Õ¾ã¡AY¦³¶i¦ì¡A·|¦s¦bAHùØ stosb ;¦s¤J©M¤º inc ebx dec n2 jnz u_a1 cmp n1,0 jz u_a3 ;°²¦p³Q¥[¼Æ»P¥[¼Æ¦ì¼Æ¬Û¦P®É¡An1·|µ¥©ó¹s ;pºâ¥u¦³¸û¤j¦ì¼Æ³¡¥÷¡A¥H¤W±¬°¨Ò¡A§Ypºâ ; 987654 ;+ 000912 ;--------- ; 988566 ;987+000ªº³¡¥÷ u_a2: lodsb add al,ah ;AH¡×pºâ«Å|³¡¥÷«áªº¶i¦ì cbw aaa stosb dec n1 jnz u_a2 ;³B²z³Ì¤j¦ì¼Æ¶i¦ì u_a3: sub al,al ;¨ÏALµ¥©ó¹s add al,ah ;AH¡×¶i¦ì¡A¥[¤W¶i¦ì or al,al jz u_a4 stosb u_a4: mov ecx,edi mov eax,lpSum sub ecx,eax ret ubcd_add ENDP ;------------------------------------------------------------------------------- ubcd_mul PROC USES ebx edx esi edi lpLow1,lpLow2,Product,n1,n2 ;pºâ¨â«D»E¶°BCD¾ã¼Æ¤§¼¿n ;¿é¤J¡GlpLow1¡G³Q¼¼Æ³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§} ; lpLow2¡G¼¼Æ(multiplier)³Ì§C¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§} ; Product¡G¼¿n³Ì§C¦ì§} ; n1¡G³Q¼¼Æ¦ì¼Æ ; n2¡G¼¼Æ¦ì¼Æ ;¿é¥X¡GEAX¡G¬°¼¿n©ÒÀx¦s¦ì§}¡A¥H¥¼»E¶°BCD¤è¦¡Àx¦s¡A¤j¦ì¼Æ¦b°ª¦ì§} ; ECX¡G¼¿nªº¦ì¼Æ ; EBX¡BEDX¡BESI¡BEDI§¡³Q«O¦s°_¨Ó ;ì²z¡G¼¿n¦ì¼Æ¡AnProduct¡A¥i¯à¬O(n1¡Ïn2)©Î(n1¡Ïn2¡Ð1)¡A¥ý°²³]nProduct¡×(n1¡Ïn2)¡A³Ì«á¦A ;¡@¡@¡@½Õ¾ã¡C§@ª½¦¡¼ªk»Ýn°t¸m°O¾ÐÅé§@¬°¼È¦s°Ï¡A©Ò°t¸m°O¾ÐÅ骺¤j¤p¬° ;¡@¡@¡@SizeTemp¡×¼¿n¦ì¼Æ¡Ñ(¼¼Æ¦ì¼Æ¡Ï1)Ӧ줸²Õ ;¡@¡@¡@¥H987654*912=900740448¬°¨Ò¡AnProduct¬°9¡A¶·°t¸m°O¾ÐÅé(9¡Ñ3¡Ï9)Ӧ줸²Õ¡C ; 987654 ³Q¼¼Æ¡A¦s©ó©Ò°t¸m°O¾ÐÅé¦ì§}ªº0¡ã(SizeTemp-1)³B¡A¤]¬O¼¿n©Ò¦s©ñ³B¡A¦@¦³n1¦ì¼Æ ; x 912 ¼¼Æ¡A¦s©ó©Ò°t¸m°O¾ÐÅé¦ì§}ªºLARGEST¡ã(SizeTemp+3FH)³B¡A¦@¦³n2¦ì¼Æ¡A¦¹¨Òn2=3 ; ---------- ; zz1975308 ¼È¦s°Ï¡A¥Ñ©Ò°t¸m°O¾ÐÅé¦ì§}ªº(LARFEST+40H)³B¶}©l¡A¹ï¨C¤@¦ì¼¼Æ¦Ó¨¥ ; z0987654z ¡A§¡¦û¾Ún1+n2¦ì¼Æ¡A¦¹¨Òn1+n2¦@9¦ì¼Æ¡A¼¿n¤]¬O9¦ì¼Æ ; 8888886zz ; ---------- ; 900740448 ;³Q¼¼Æ·|³Q¤T¦ì¼¼Æ¼¤T¦¸¡A¨C¤@¦¸³£¥i¤À¦¨¤T³¡¥÷¡G³Ì¥kÃän¶ñ¤J0¡A¬Û¼¡A°µ¥ªÃä¤]n¶ñ¤J0 ;©³¤Uªº°Ï°ìÅܼơAlpHi1,lpHi2,nProduct¤À§Oªí¥Ü³Q¼¼Æ³Ì°ª¦ì§}¡B¼¼Æ³Ì°ª¦ì§}¡B¼¿n¦ì¼Æ LOCAL lpHi1,lpHi2,nProduct:DWORD LOCAL lpTemp:DWORD ;°t¸m°O¾ÐÅé¦ì§} clc mov ecx,n1 ;pºâ¼¿n¦ì¼Æ¡A¨Ã¦s©ónProduct mov eax,n2 ;¼¼Æ¦ì¼Æ add ecx,eax ;ECX¡×¼¿n¦ì¼Æ mov nProduct,ecx inc eax ;¼¼Æ¦ì¼Æ¡Ï1 sub edx,edx mul ecx ;EAX¡×¼¿n¦ì¼Æ¡Ñ(¼¼Æ¦ì¼Æ¡Ï1) INVOKE GlobalAlloc,GMEM_SHARE or GPTR,eax mov lpTemp,eax mov eax,lpLow1 ;pºâ³Q¼¼Æ¡B¼¼Æ³Ì¤j¦ì¼Æ©Ò¦b¦ì§}¡A mov ebx,lpLow2 ;¨Ã¦s©ólpHi1¡BlpHi2 add eax,n1 add ebx,n2 mov lpHi1,eax mov lpHi2,ebx ;²Ä¤@¶¥¬q¡A³B²z¨C¤@¦ì¼¼Æ¥h¼³Q¼¼Æ mov edi,lpTemp ;EDI«ü¦V¼È¦s°Ï(¦s©ñ¨C¤@¦ì¼¼Æ¬Û¼«áªºµ²ªG) mov esi,lpLow2 ;¨C¦¸pºâ¼¼Æ¤@¦ì¼Æ¼³Q¼¼Æµ²ªG¤§°j°é¶}©l m1: sub eax,eax ;²M°£EAX¡NEDX¨Ï©¹«áªºAAM¡NAAA«ü¥O¯à¥¿½T¹Bºâ mov edx,eax mov ecx,esi ;¤p¦ì¼Æªº¶ñ¹s³¡¤À¡AECX¬°¶ñ¹sªºÓ¼Æ sub ecx,lpLow2 mov ebx,lpLow1 ;pºâ¼¼Æ¨C¦ì¼Æ¼³Q¼¼Æ³¡¤À push ecx jcxz m3 m2: stosb loop m2 m3: mov al,[ebx] ;BX«ü¦V³Q¼¼Æ mul BYTE PTR [esi] aam add al,dh ;¥[¤W«e¤@¦¸ªº¶i¦ì aaa mov dh,ah ;¶i¦ì¦s©óDH stosb inc ebx cmp ebx,lpHi1 jne m3 mov [edi],dh ;³B²z¶i¦ì³¡¤À inc edi pop eax ;³B²z¤j¦ì¼Æ¶ñ¹s³¡¤À mov ecx,nProduct sub ebx,lpLow1 sub ecx,eax sub ecx,ebx dec ecx ;ECX¬°¶ñ¹sªºÓ¼Æ jcxz m5 m4: mov BYTE PTR [edi],0 inc edi loop m4 m5: inc esi ;«ü¦V¼¼Æªº¤U¤@¦ì cmp esi,lpHi2 ;Àˬd¼¼Æ¬O§_³£¤wºâ§¹ jne m1 ;²Ä¤G¶¥¬q¡A³B²z¦b¼È¦s°Ï¤¤¨C¤@¦ì¼¼Æ¼¿n¤§©M mov edi,Product mov ecx,nProduct xor eax,eax inc ecx rep stosb ;²M°£¼¿nªº©U§£¸ê®Æ mov esi,Product ;ESI=¼¿n¦ì§} mov ebx,lpTemp ;EBX¬°¼È¦s°Ï¦ì§} mov edx,nProduct m6: INVOKE ubcd_add,esi,ebx,esi,edx,edx ;ESI=ESI+EBX add ebx,edx dec n2 ;n2=¼¼Æ¦ì¼Æ¡A§Yn¬Û¥[¦¸¼Æ jnz m6 INVOKE GlobalFree,lpTemp mov eax,Product mov ecx,nProduct cmp BYTE PTR [eax+ecx-1],0 ;Àˬd³Ì°ª¦ì¼Æ¬O§_¬°¹s jnz m7 dec ecx ;Y¨S¦³¶i¦ì¡A«h¼¿n¦ì¼Æ´î¤@ m7: ret ubcd_mul ENDP ;******************************************************************************* END DLLEntry
²Ä¤G¨B¡A¼¶¼g©³¤Uªº UBCDDLL.DEF ÀÉ¡G
EXPORTS UBCD_ADDS=ubcd_add UBCD_MULS=ubcd_mul
¦¹³B¤p¤ì°¸¥H UBCD_ADDS¡BUBCD_MULS ¨ú¥Nì¥ýªº°Æµ{¦¡ ubcd_add¡Bubcd_mul ¦WºÙ¡C
²Ä¤T¨B¡A±Ò°Ê¡y©R¥O´£¥Ü¦r¤¸¡z¡A°õ¦æ²ÕĶ¡B³sµ²¦Ó²£¥Í¤TÓÀɮסAUBCDDLL.DLL¡BUBCDDLL.LIB ¤Î UBCDDLL.EXP¡C¶}±Ò XP ªº©R¥O´£¥Ü¦r¤¸¡A¿é¤J¤U¦C«ü¥O¡G(¡uml /c¡v¤¤ªº¡u/c¡v¬O«ü¥Ü ML.EXE ¥u²ÕĶ¤£³sµ² )
E:\HomePage\SOURCE\Win32\DLL>ml /c ubcddll.asm [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: ubcddll.asm E:\HomePage\SOURCE\Win32\DLL>link /DLL /SUBSYSTEM:WINDOWS /DEF:ubcddll.def ubcddll.obj [Enter] Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. Creating library ubcddll.lib and object ubcddll.exp E:\HomePage\SOURCE\Win32\DLL>
²Ä¥|¨B¡A¤]¬O³Ì«á¤@¨B¡A¬°è«Ø¥ß¦nªº°ÊºA³sµ²µ{¦¡®w¼¶¼g¥]§tÀÉ ( INC ÀÉ ) ¤Î»¡©ú¡A¦b³oÓ¨Ò¤lùØ¡A¥]§tÀÉ¡AUDCDDLL.INC¡A¤º®e¦p¤U¡G
UBCD_ADDS PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD UBCD_MULS PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
¦pªG·Q§â¦Û¤vªº³Ç§@µo§Gµ¹¨ä¥L¦P¦n¨Ï¥Î¡AÀ³¸Ón¥]§t INC ÀÉ¡BDLL ÀÉ¡BLIB Àɤλ¡©úÀÉ¡C»¡©úÀÉ¥i¥Î¯Â¤å¦r®æ¦¡¡AÀx¦s¦¨ TXT ÀÉ¡A©Î¬O HTML ®æ¦¡¡C¦p¯àªþ¤Wì©l½X¡AÅý¤j®aÆ[¼¯±zªºµ{¦¡¡A¤]¬O¤£¿ù¡C
¤p¤ì°¸¤w§¹¦¨¤@ӰʺA³sµ²®w¡A©³¤U´N¨Ó¥Ü½d¦p¦ó¨Ï¥Î¥¦¡C©³¤U³oÓµ{¦¡¡ATEST.ASM¡A°õ¦æ«á·|¦b®à±¤W¥X²{¤@Ó¹ï¸Ü²°¡A¥i¥H°µ«Ü¤j¦ì¼Æªº¥[ªk¤Î¼ªk¡A¥¦·|©I¥s°ÊºA³sµ²µ{¦¡®w¡AUBCDDLL.DLL¡A¹ê²{¤j¦ì¼Æªº¥[ªk¤Î¼ªk¡C¨äì©l½X¦p¤U¡G
;¦¹µ{¦¡½X¬O¬°¤F´ú¸Õ°ÊºA³sµ²µ{¦¡®w¦Ó»s§@ªº¡A¥]§t¨âÓµ{¦¡¡Apºâ¤j¦ì¾ã¼Æªº¥[ªk»Ppºâ¤j¦ì¾ã¼Æªº¼ªk .586 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE INCLUDE WINDOWS.INC INCLUDE USER32.INC INCLUDE KERNEL32.INC INCLUDELIB USER32.LIB INCLUDELIB KERNEL32.LIB INCLUDE UBCDDLL.INC ;¤p¤ì°¸»s§@ªºUBCDDLL.INC¥]§tÀÉ INCLUDELIB UBCDDLL.LIB ;¤p¤ì°¸»s§@ªºUBCDDLL.DLL°ÊºA³sµ²µ{¦¡®w IDC_CALC EQU 2001 IDC_EXIT EQU 2002 IDC_N1 EQU 2003 IDC_N2 EQU 2004 IDC_ANSWER EQU 2005 IDC_OP EQU 2006 MAX_DIGIT EQU 20 ;******************************************************************************* .DATA hInstance HINSTANCE ? index DWORD ? ;³Q¿ï©wªº¹Bºâ¤l¡G¥[ªk¡G0¡A¼ªk¡G1 szDlgName BYTE 'AddNMul',0 szAdd BYTE '¡Ï',0 szMul BYTE '¡Ñ',0 ubcdN1 BYTE MAX_DIGIT+1 DUP (?) ubcdN2 BYTE MAX_DIGIT+1 DUP (?) buffer BYTE 2*MAX_DIGIT+1 DUP (?) nN1 DWORD ? nN2 DWORD ? szAnswer BYTE '=' answer BYTE 2*MAX_DIGIT+1 DUP (?) ;******************************************************************************* .CODE ;------------------------------------------------------------------------------- get_number PROC USES esi edi hDia:HANDLE,ID:DWORD,adrOperand:DWORD LOCAL szuBcd[MAX_DIGIT+2]:BYTE LOCAL nBcd:DWORD INVOKE GetDlgItemText,hDia,ID,ADDR szuBcd,MAX_DIGIT+1 mov nBcd,eax mov ecx,eax jecxz no_n lea esi,szuBcd mov edi,adrOperand add esi,ecx dec esi clc next: mov al,[esi] and al,0fh dec esi stosb loop next mov eax,ecx stosb mov eax,nBcd no_n: ret get_number ENDP ;------------------------------------------------------------------------------- DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL hOperator:HANDLE .IF uMsg==WM_INITDIALOG ;¸ü¤J¹Ï¥Ü INVOKE LoadIcon,hInstance,OFFSET szDlgName INVOKE SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax ;§â¥[¡B¼ªk¹Bºâ¤l¥[¤J½Æ¦X®ØùØ INVOKE GetDlgItem,hDlg,IDC_OP mov hOperator,eax INVOKE SendMessage,hOperator,CB_ADDSTRING,NULL,OFFSET szAdd INVOKE SendMessage,hOperator,CB_ADDSTRING,NULL,OFFSET szMul ;³]©w½s¿è®Ø³Ì¦h¿é¤J¦ì¼Æ INVOKE GetDlgItem,hDlg,IDC_N1 INVOKE SendMessage,eax,EM_SETLIMITTEXT,MAX_DIGIT,NULL INVOKE GetDlgItem,hDlg,IDC_N2 INVOKE SendMessage,eax,EM_SETLIMITTEXT,MAX_DIGIT,NULL .ELSEIF uMsg==WM_COMMAND mov edx,wParam mov eax,wParam shr edx,10h ;EDX=³qª¾½X and eax,0ffffh ;EAX=±±¨î¤¸¥óÃѧO½X .IF dx==BN_CLICKED .IF ax==IDC_EXIT jmp exit .ELSEIF ax==IDC_CALC INVOKE get_number,hDlg,IDC_N1,OFFSET ubcdN1 mov nN1,eax or eax,eax jz no_input INVOKE get_number,hDlg,IDC_N2,OFFSET ubcdN2 mov nN2,eax or eax,eax jz no_input .IF index==0 INVOKE UBCD_ADDS,OFFSET ubcdN1,OFFSET ubcdN2,OFFSET buffer,nN1,nN2 ;©I¥sUDCDDLL.DLLùتºubcd_add°Æµ{¦¡ .ELSEIF index==1 INVOKE UBCD_MULS,OFFSET ubcdN1,OFFSET ubcdN2,OFFSET buffer,nN1,nN2 ;©I¥sUDCDDLL.DLLùتºubcd_mul°Æµ{¦¡ .ELSE jmp no_input .ENDIF mov edx,OFFSET buffer mov edi,OFFSET answer add edx,ecx dec edx @@: mov al,[edx] or al,'0' dec edx stosb dec ecx jnz @b mov al,cl stosb INVOKE SetDlgItemText,hDlg,IDC_ANSWER,OFFSET szAnswer .ENDIF .ELSEIF dx==CBN_SELENDOK INVOKE SendDlgItemMessage,hDlg,IDC_OP,CB_GETCURSEL,0,0 mov index,eax .ENDIF no_input: .ELSEIF uMsg==WM_CLOSE exit: INVOKE EndDialog,hDlg,NULL ;¨ä¥L°T®§ .ELSE mov eax,FALSE ret .ENDIF mov eax,TRUE ret DlgProc ENDP ;------------------------------------------------------------------------------- start: INVOKE GetModuleHandle,NULL mov hInstance,eax INVOKE DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL INVOKE ExitProcess,eax ;******************************************************************************* END start
§â¥¦¦s¦¨ TEST.ASM ÀÉ¡CµM«á¼¶¼g¸ê·½´yzÀÉ¡ATEST.RC¡G
#include "c:\masm32\include\resource.h" #define IDC_CALC 2001 #define IDC_EXIT 2002 #define IDC_N1 2003 #define IDC_N2 2004 #define IDC_ANSWER 2005 #define IDC_OP 2006 AddNMul ICON exclamation01.ico AddNMul DIALOG 6, 15, 185, 90 STYLE DS_MODALFRAME|WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU CAPTION "pºâ¤j¾ã¼Æ¥[ªk»P¼ªk" FONT 8,"MS Sans Serif" { EDITTEXT IDC_N1, 5, 13, 70, 12,WS_TABSTOP|ES_NUMBER|ES_RIGHT|ES_AUTOHSCROLL COMBOBOX IDC_OP, 77, 13, 28, 40,CBS_DROPDOWNLIST|WS_VSCROLL EDITTEXT IDC_N2, 105, 13, 70, 12,WS_TABSTOP|ES_NUMBER|ES_RIGHT|ES_AUTOHSCROLL LTEXT "=",IDC_ANSWER, 5, 30,160, 12 DEFPUSHBUTTON "pºâ",IDC_CALC,10, 55, 80, 20 PUSHBUTTON "Â÷¶}",IDC_EXIT,95, 55, 80, 20 }
¹³¥H«e²ÕĶ¡B³sµ²µ{¦¡¤@¼Ë¡A§â¹Ï¥ÜÀÉ ( exclamation01.ico )¡Bì©l½X ( TEST.ASM ) ©M¸ê·½´yzÀÉ ( TEST.RC ) ©ñ¦b¦P¤@¸ê®Æ§¨ùØ¡A¦b©R¥O´£¥Ü¦r¤¸¤¤¡A¤U¹F¤U¦C«ü¥O¡G
E:\HomePage\SOURCE\DLL>rc test.rc [Enter] E:\HomePage\SOURCE\DLL>ml test.asm /link test.res [Enter] Microsoft (R) Macro Assembler Version 6.14.8444 Copyright (C) Microsoft Corp 1981-1997. All rights reserved. Assembling: test.asm Microsoft (R) Incremental Linker Version 5.12.8078 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /SUBSYSTEM:WINDOWS "test.obj" /DEBUG "/OUT:test.exe" "test.res" E:\HomePage\SOURCE\DLL>test [Enter] ¡÷°õ¦æ¡I
¤U¹Ï¬O°õ¦æ®Éªºµe±¡A±z¥i¥H¦b¨âÓ½s¿è®ØùØ¿é¤Jªü©Ô§B¼Æ¦r¡A¦b½Æ¦X®Ø¤¤¿ï¨ú¥[ªk©Î´îªk¹Bºâ¤l¡A«ö¤U¡ypºâ¡z«ö¶s±o¨ìµ²ªG¡C
¦b TEST.ASM ùØ¡Aµ{¦¡³B²z¤F¨âÓ±±¨î¤¸¥óªº³qª¾½X¡A¤@Ó¬O BN_CLICKED¡A¥t¤@Ó¬O CBN_SELENDOK ¡C·í¨Ï¥ÎªÌ«ö¤U¥ô¦ó¤@Ó«ö¶s®É¡A¨t²Î·|µo¥X BN_CLICKED ³qª¾½Xµ¹µ{¦¡¡AµM«á¦b¥hÀˬd¬Oþ¤@Ó«ö¶s³Q«ö¤U¡A¦pªG¬O IDC_EXIT ³Q«ö¤U¡A«hÂ÷¶}µ{¦¡¡F¦pªG¬O IDC_CALC ³Q«ö¤U¡A«hpºâµ²ªG¡C·í¨Ï¥ÎªÌ¿ï©w½Æ¦X®Ø²M³æ¤ºªº¿ï¶µ®É¡A¨t²Îµo¥X CBN_SELENDOK ³qª¾½X¡Aµ{¦¡n¨ú±o¨Ï¥ÎªÌ¿ï¾Ü¥[ªkÁÙ¬O¼ªk¡C³o¬qµ{¦¡³£¦b³B²z WM_COMMAND °T®§¤¤¹ê§@¥X¨Ó¤F¡C
¨Æ¹ê¤W¡A©I¥s DLL Àɤ¤ªº°Æµ{¦¡¡A¦³¨âºØ¤è¦¡¡A²Ä¤@ºØ¤è¦¡´N¬O«ez©Ò¨Ï¥Îªº¤è¦¡¡AºÙ¬°¡y¸ü¤J®É°ÊºA³sµ²¡z ( load-time dynamic linking¡A¤S¥s·t¥Ü©Ê³sµ² )¡F²Ä¤GºØ¤è¦¡«hºÙ¬°¡y°õ¦æ®É°ÊºA³sµ² ¡z( Run-Time Dynamic Linking¡A¤S¥s©ú½T©Ê³sµ² )¡C°õ¦æ®É°ÊºA¸ü¤J DLL¡A¤£»Ýn«ü©w¥]§tÀɤζפJµ{¦¡®w¡A¨º»ò«ç»òª¾¹Dn¸ü¤Jþ¤@Óµ{¦¡®w©O¡Hì¨Ó²Ä¤@Ó¨BÆJ±o¦bì©l½X¤¤©I¥s LoadLibrary ©Î LoadLibraryEx API¡A¥Ñµ{¦¡¦Û¤v¸ü¤J DLL¡C°²¦p¸ü¤J¦¨¥\¡A²Ä¤GÓ¨BÆJ¬O©I¥s GetProcAddress Àò±o°ÊºAµ{¦¡®w¤¤°Æµ{¦¡ªº¦ì§}¡C²Ä¤TÓ¨BÆJ¡A·ín©I¥s¸Ó°Æµ{¦¡®É¡A¥i¥Î 80x86 ªº push «ü¥O§â°Ñ¼Æ±À¤J°ïÅ|¡A¦A¥Î call «ü¥O©I¥s¸Ó°Æµ{¦¡ªº¦ì§}¡C³Ì«á¡A¦pªG¤£¦A»Ýn°ÊºA³sµ²µ{¦¡®w®É ( ¨Ò¦pµ{¦¡µ²§ô®É )¡A©I¥s FreeLibrary ¨ø¸ü¦¹µ{¦¡®w¡C©³¤U¥ý¬Ý¬Ý©Ò¥Î¨ìªº API¡C
LoadLibrary 쫬¬O
HINSTANCE LoadLibrary( LPCTSTR lpLibFileName // address of filename of executable module );
°Ñ¼Æ lpLibFileName ¬O«ü¦V *.DLL ©Î *.EXE ÀɮצWºÙ©Ò¦bªº¦r¦ê¦ì§}¡A°²¦p¦¹¦r¦ê¥]§t¸ô®|¡A¶·¥H¡y\¡z¤À¹j¨CÓ¤l¥Ø¿ý¦W¦r¡A³Ì«á³oÓ¦r¦ê¥H 0 µ²§À¡C¦pªGÀɦW¥u¦C¥X¥DÀɦW¡A·|¦Û°Ê¥[¤W¡y.DLL¡z¡A¦ý¸U¤@°ÊºA³sµ²µ{¦¡®w¯uªº¨S¦³°ÆÀɦW¡A¨º»ò´Nn¦bÀɦW«á¥[¤W¡y.¡zªí¥Üµ²§À¨S°ÆÀɦW¡C¦pªG¨S¦³¸ô®|¦WºÙ¡ALoadLibrary ·|¨Ì¤U±¶¶§Ç·j´M DLL ÀÉ¡G
°²¦p LoadLibrary ¦¨¥\¦a§ä¨ì¨Ã¸ü¤J DLL ÀÉ¡AEAX ¤¤·|¶Ç¦^¼Ò²Õ¥N½X¡F¦pªG¥¢±Ñ¡AEAX ·|¶Ç¦^ NULL¡C
HINSTANCE LoadLibraryEx( LPCTSTR lpLibFileName, // points to name of executable module HANDLE hFile, // reserved, must be NULL DWORD dwFlags // entry-point execution flag );
LoadLibraryEx ªº²Ä¤@ӰѼƻP LoadLibrary ¬Û¦P¡ChFile ³Q«O¯dµ¹¥H«á¨Ï¥Î¡A¥²¶·¬° NULL¡C°Ñ¼Æ dwFlags ¬O¥Î¨Ó¸ü¤J°ÊºA³sµ²µ{¦¡®w¤§«áµo¥Íªº°Ê§@¡A¥i¥H¬O¤U±´X¶µ
LoadLibraryEx ¦pªG¦¨¥\ªº¸ü¤J DLL ÀÉ¡A·|¶Ç¦^¼Ò²Õ¥N½X¡F¦pªG¥¢±Ñ¡AEAX ·|¶Ç¦^ NULL¡C
GetProcAddress ¬O¥Î¨Ó¨ú±o°ÊºA³sµ²µ{¦¡®w¤¤¬YӶץX°Æµ{¦¡©ÎÅܼƪº¦ì§}¡A¨ä쫬¦p¤U¡G
FARPROC GetProcAddress( HMODULE hModule, // handle to DLL module LPCSTR lpProcName // name of function );
°Ñ¼Æ¡AhModule¡A¬O°ÊºA³sµ²µ{¦¡®wªº¼Ò²Õ¥N½X¡A¤]´N¬O LoadLibrary ©Î LoadLibraryEx ªº¶Ç¦^È¡ClpProcName ¬O¬YӰƵ{¦¡©ÎÅܼƪº¦WºÙ¡A¶·¥H¹s¬°µ²§À¡A¨ä¦r¥À«÷ªk¤Î¤j¤p¼g¬O¨Ì¾Ú¼Ò²Õ©w¸qÀɤ¤ EXPORT ¬q¸¨¤¤©Ò´yzªº¡AlpProcName ¤]¥i¥H¬O§Ç¼Æ¡C¦pªG GetProcAddress °õ¦æ¦¨¥\¡A·|¶Ç¦^ DLL ªº°Æµ{¦¡¶i¤JÂI¦ì§}¡F¦pªG¥¢±Ñ«h¶Ç¦^ NULL¡CµM«á§Ú̧â³oÓ¶i¤JÂIªº¦ì§}°O¿ý¦b¬YÓÅܼÆùØ¡A¨Ò¦p lpProc ÅܼơA·í¥Dµ{¦¡n©I¥s°ÊºA³sµ²µ{¦¡®w¤¤ªº°Æµ{¦¡®É¡A´N¥H¤U±¤è¦¡©I¥s°Æµ{¦¡¡G
push °Ñ¼Æ¤@ push °Ñ¼Æ¤G ¡K¡K call lpProc
¦pªGn¨Ï¥Î INVOKE °²«ü¥O©I¥sªº¸Ü¡A±o¨Æ¥ý«Å§i¡A¥i¥H§Q¥Î¨â¦¸ TYPEDEF °²«ü¥O¡G
UBCD_PROTO TYPEDEF PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD UBCD_PROC TYPEDEF PTR UBCD_PROTO
²Ä¤@¥y¬O¥Î¨Ó«Å§i¤Ó°Ñ¼Æªºì«¬©w¸q¦¨ UBCD_PROTO¡A²Ä¤G¥y¦A§â UBCD_PROC «ü©w¬° UBCD_PROTO ªº«ü¼Ð¡A±µµÛ´N¥i¥H¦b¸ê®Æ¬q©w¸q°Æµ{¦¡¦ì§}¡A¦pn©I¥s®É¡A´N¥i¥Î INVOKE ©I¥s¤F¡C¤j·§ªºµ{¦¡½X¦p¤U¡G
.DATA lpMulProc UBCD_PROC ? ¡K¡K¡K¡K .CDOE ¡K¡K¡K¡K INVOKE GetProcAddress,hModule,OFFSET szBigMul .IF eax mov lpMulProc,eax ¡K¡K¡K¡K INVOKE lpMulProc,OFFSET ubcdN1,OFFSET ubcdN2,OFFSET buffer,nN1,nN2
FreeLibrary ªºì«¬¬O
BOOL FreeLibrary( HMODULE hLibModule // handle to loaded library module );
hLibModele ¬O°ÊºA³sµ²µ{¦¡®wªº¼Ò²Õ¥N½X¡A¥ç§Y©I¥s LoadLibrary «áªº¶Ç¦^È¡C·íµ{¦¡µ²§ô©Î¤£¦A©I¥s DLL ®É¡A´N¥i¥H§â¥¦±q¦Û¤vªº°O¾ÐÅé¦ì§}ªÅ¶¡¨ø¸ü¡A´N¥i¥H©I¥s FreeLibrary¡C
·í¨Ï¥Î¡y°õ¦æ®É°ÊºA³sµ²¡z¤è¦¡©I¥s°ÊºA³sµ²µ{¦¡®w¤¤ªº°Æµ{¦¡®É¡A³£À³¸ÓÀˬd LoadLibrary¡BGetProcAddress ¬O§_¦¨¥\ªº¥¿½T°õ¦æ¡A¨Ã¶Ç¦^¥¿½TÈ¡F§_«h¶Ç¦^ NULL ¦Ó¤£Àˬd¡A«Ü®e©ö³y¦¨¿ù»~¡C¦]¬°¦pªG¸ü¤J°ÊºA³sµ²µ{¦¡®w¿ù»~©Î¨ú±o°Æµ{¦¡¦ì§}¿ù»~¡A³£·|¤Þµoµ{¦¡¸õ¨ì¿ù»~¦ì§}°õ¦æ¡A¥²©w¤Þµoµ{¦¡²×¤î¡C¥¿¦]¬°¦³¾÷·|Àˬd°ÊºA³sµ²µ{¦¡®w©Î¨ä¤¤ªº°Æµ{¦¡¬O§_¥¿½T¡A©Ò¥H§Y¨Ï§ä¤£¨ì°ÊºA³sµ²µ{¦¡®w©Î°Æµ{¦¡¡A¤]¤£P¨Ï¥Dµ{¦¡§¹¥þ¤£¯à°õ¦æ¡A§ÚÌ¥i¥H¤p¤ßªº¼¶¼g¯Ê¤Ö¦³Ãö¸Ó°ÊºA³sµ²µ{¦¡®wªº¥\¯à¡A¦Ó¤£·|¼vÅT¨ìªº¥\¯à¤´¯à°õ¦æ¡C
©³¤Uªº TEST2.ASM ¬O§Q¥Î¡y°õ¦æ®É°ÊºA³sµ²¡z©I¥s DLL¡Aì©l½X¦p¤U¡G
.586 .MODEL FLAT,STDCALL OPTION CASEMAP:NONE INCLUDE WINDOWS.INC INCLUDE USER32.INC INCLUDE KERNEL32.INC INCLUDELIB USER32.LIB INCLUDELIB KERNEL32.LIB IDC_CALC EQU 2001 IDC_EXIT EQU 2002 IDC_N1 EQU 2003 IDC_N2 EQU 2004 IDC_ANSWER EQU 2005 IDC_OP EQU 2006 MAX_DIGIT EQU 40 ;¥ipºâ40¦ì¼Æªº¥[ªk©Î¼ªk ;©³¤U¨â¦æ¥i¥H¦b©I¥s DLL °Æµ{¦¡®É¨Ï¥Î INVOKE¡A¤£¹L¦¹µ{¦¡¤¤¤p¤ì°¸¥Î call ©I¥s¤j¼Æ¥[ªk¡A¥Î INVOKE ©I¥s¼ªk UBCD_PROTO TYPEDEF PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD UBCD_PROC TYPEDEF PTR UBCD_PROTO ;******************************************************************************* .CONST szUBCDDLL BYTE 'UBCDDLL.DLL',0 ;©w¸q DLL ÀɦW¥H¤Î°Æµ{¦¡¦WºÙ szBigAdd BYTE 'UBCD_ADDS',0 ;©w¸q°Æµ{¦¡¦WºÙ¡A¦]¬°¦b¼Ò²Õ©w¸qÀÉ¡A¥HUBCD_ADDS¥N szBigMul BYTE 'UBCD_MULS',0 ;´Àubcd_add¡F¥HUBCD_MULS¥N´Àubcd_mul szDlgName BYTE 'AddNMul',0 szAdd BYTE '¡Ï',0 szMul BYTE '¡Ñ',0 szDllLoadFail BYTE 'UBCDDLL.DLL¸ü¤J¥¢±Ñ¡I',0dh,0ah,'¬Y¨Ç¥\¯àµLªk°õ¦æ¡C',0 szAddFail BYTE '¥[ªk¥\¯à¥¢®Ä',0 szMulFail BYTE '¼ªk¥\¯à¥¢®Ä',0 ;******************************************************************************* .DATA hInstance HINSTANCE ? hModule HANDLE 0 ;°ÊºA³sµ²µ{¦¡®w(UBCDDLL.DLL)ªº¼Ò²Õ¥N½X lpAddProc DWORD ? ;UBCD_ADDS°Æµ{¦¡¶i¤JÂI¦ì§} lpMulProc UBCD_PROC ? ;UBCD_MULS°Æµ{¦¡¶i¤JÂI¦ì§} index DWORD ? ;³Q¿ï©wªº¹Bºâ¤l¡G¥[ªk¡G¡Ï¡A¼ªk¡G¡Ñ ubcdN1 BYTE MAX_DIGIT+1 DUP (?) ubcdN2 BYTE MAX_DIGIT+1 DUP (?) buffer BYTE 2*MAX_DIGIT+1 DUP (?) nN1 DWORD ? nN2 DWORD ? szAnswer BYTE '=' answer BYTE 2*MAX_DIGIT+1 DUP (?) ;******************************************************************************* .CODE ;------------------------------------------------------------------------------- get_number PROC USES esi edi hDia:HANDLE,ID:DWORD,adrOperand:DWORD LOCAL szuBcd[MAX_DIGIT+2]:BYTE LOCAL nBcd:DWORD INVOKE GetDlgItemText,hDia,ID,ADDR szuBcd,MAX_DIGIT+1 mov nBcd,eax mov ecx,eax jecxz no_n lea esi,szuBcd mov edi,adrOperand add esi,ecx dec esi clc next: mov al,[esi] and al,0fh dec esi stosb loop next mov eax,ecx stosb mov eax,nBcd no_n: ret get_number ENDP ;------------------------------------------------------------------------------- DlgProc PROC hDlg:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL hOperator:HANDLE .IF uMsg==WM_INITDIALOG ;¸ü¤J¹Ï¥Ü INVOKE LoadIcon,hInstance,OFFSET szDlgName INVOKE SendMessage,hDlg,WM_SETICON,ICON_SMALL,eax ;³]©w½s¿è®Ø³Ì¦h¿é¤J¦ì¼Æ INVOKE GetDlgItem,hDlg,IDC_N1 INVOKE SendMessage,eax,EM_SETLIMITTEXT,MAX_DIGIT,NULL INVOKE GetDlgItem,hDlg,IDC_N2 INVOKE SendMessage,eax,EM_SETLIMITTEXT,MAX_DIGIT,NULL ;¨ú±o´_¦X®Ø¥N½X INVOKE GetDlgItem,hDlg,IDC_OP mov hOperator,eax ;¨Ï¡ypºâ¡z«ö¶s¥¢®Ä INVOKE GetDlgItem,hDlg,IDC_CALC INVOKE EnableWindow,eax,FALSE ;¸ü¤JUBCDDLL.DLLÀÉ INVOKE LoadLibrary,OFFSET szUBCDDLL .IF eax mov hModule,eax INVOKE GetProcAddress,eax,OFFSET szBigAdd .IF eax mov lpAddProc,eax INVOKE SendMessage,hOperator,CB_ADDSTRING,NULL,OFFSET szAdd ;§â¥[ªk¹Bºâ¤l¥[¤J½Æ¦X®ØùØ INVOKE GetDlgItem,hDlg,IDC_CALC ;¨Ï¡ypºâ¡z«ö¶s¥¿±` INVOKE EnableWindow,eax,TRUE .ELSE INVOKE MessageBox,hDlg,OFFSET szAddFail,NULL,MB_OK or MB_ICONWARNING .ENDIF INVOKE GetProcAddress,hModule,OFFSET szBigMul .IF eax mov lpMulProc,eax INVOKE SendMessage,hOperator,CB_ADDSTRING,NULL,OFFSET szMul ;§â¥[ªk¹Bºâ¤l¥[¤J½Æ¦X®ØùØ INVOKE GetDlgItem,hDlg,IDC_CALC ;¨Ï¡ypºâ¡z«ö¶s¥¿±` INVOKE EnableWindow,eax,TRUE .ELSE INVOKE MessageBox,hDlg,OFFSET szMulFail,NULL,MB_OK or MB_ICONWARNING .ENDIF .ELSE INVOKE MessageBox,hDlg,OFFSET szDllLoadFail,NULL,MB_OK or MB_ICONWARNING .ENDIF .ELSEIF uMsg==WM_COMMAND mov edx,wParam mov eax,wParam shr edx,10h ;EDX=³qª¾½X and eax,0ffffh ;EAX=±±¨î¤¸¥óÃѧO½X .IF dx==BN_CLICKED .IF ax==IDC_EXIT jmp exit .ELSEIF ax==IDC_CALC INVOKE get_number,hDlg,IDC_N1,OFFSET ubcdN1 mov nN1,eax or eax,eax jz no_input INVOKE get_number,hDlg,IDC_N2,OFFSET ubcdN2 mov nN2,eax or eax,eax jz no_input .IF WORD PTR index==0cfa1h ;0cfa1h='¡Ï' push nN2 push nN1 push OFFSET buffer push OFFSET ubcdN2 push OFFSET ubcdN1 call lpAddProc .ELSEIF WORD PTR index==0d1a1h ;0d1a1h='¡Ñ' INVOKE lpMulProc,OFFSET ubcdN1,OFFSET ubcdN2,OFFSET buffer,nN1,nN2 .ELSE jmp no_input .ENDIF mov edx,OFFSET buffer mov edi,OFFSET answer add edx,ecx dec edx @@: mov al,[edx] or al,'0' dec edx stosb dec ecx jnz @b mov al,cl stosb INVOKE SetDlgItemText,hDlg,IDC_ANSWER,OFFSET szAnswer .ENDIF .ELSEIF dx==CBN_SELENDOK INVOKE SendDlgItemMessage,hDlg,IDC_OP,CB_GETCURSEL,0,0 INVOKE SendDlgItemMessage,hDlg,IDC_OP,CB_GETLBTEXT,eax,OFFSET index .ENDIF no_input: .ELSEIF uMsg==WM_CLOSE exit: .IF hModule INVOKE FreeLibrary,hModule .ENDIF INVOKE EndDialog,hDlg,NULL ;¨ä¥L°T®§ .ELSE mov eax,FALSE ret .ENDIF mov eax,TRUE ret DlgProc ENDP ;------------------------------------------------------------------------------- start: INVOKE GetModuleHandle,NULL mov hInstance,eax INVOKE DialogBoxParam,hInstance,OFFSET szDlgName,NULL,OFFSET DlgProc,NULL INVOKE ExitProcess,eax ;******************************************************************************* END start
±µµÛ¦b¡y©R¥O´£¥Ü¦r¤¸¡z¤¤¡A¿é¤J¡G
E:\HomePage\SOURCE\DLL>ml test2.asm /link test.res [Enter]
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.
Assembling: test2.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/SUBSYSTEM:WINDOWS
"test2.obj" /DEBUG
"/OUT:test2.exe"
"test.res"
E:\HomePage\SOURCE\DLL>
¦]¬°¬O°õ¦æ®É¤~°ÊºAªº³sµ² ubcddll.dll µ{¦¡®w¡A©Ò¥H³sµ²®É¤£»Ýn¶×¤Jµ{¦¡®w´£¨Ñ¸ê®Æ¡A¬Gì©lµ{¦¡¤¤¤]¤£»Ýn§t¤J¥]§tÀÉ¡A©Ò¥H§â
INCLUDE UBCDDLL.INC ;¤p¤ì°¸»s§@ªºUBCDDLL.INC¥]§tÀÉ INCLUDELIB UBCDDLL.LIB ;¤p¤ì°¸»s§@ªºUBCDDLL.DLL°ÊºA³sµ²µ{¦¡®w
¨â¦æµ¹§R±¼¤F¡A°h¤@¨B¨Ó»¡¡A§Y¨ÏºÏºÐùØ¡A¨S¡yUBCDDLL.INC¡z©M¡yUBCDDLL.LIB¡z¤]¨SÃö«Y¡C¦ý¬O¥²¶·¦b¸ê®Æ¬qùئۦæ©w¸q°ÊºA³sµ²µ{¦¡®wªºÀɦW¥H¤Î°Æµ{¦¡¦WºÙ¡G
szUBCDDLL BYTE 'UBCDDLL.DLL',0 szBigAdd BYTE 'UBCD_ADDS',0 szBigMul BYTE 'UBCD_MULS',0
·íµ{¦¡¥H LoadLibrary ¸ü¤J UBCDDLL.DLL «á¡A¤p¤ì°¸Àˬd¤F¶Ç¦^ȬO§_¬° NULL¡A¦pªG¬Oªº¸Ü¡A·|¦b¿Ã¹õ¤W¥X²{
¦ý¤£·|²×¤îµ{¦¡¡AÁÙ¬O¯à¿é¤J¼Æ¦r¡C°²¦p±z§â UBCDDLL.DEF ¤¤ªº¶×¥X°Æµ{¦¡§R°£¤@Ó¡AÅܦ¨¡G
EXPORTS UBCD_MULS=ubcd_mul
¨Ì«eªk²ÕĶ³sµ²«á¡A°õ¦æ TEST.EXE¡A·|¥X²{¤U±ªº¹ï¸Ü²°¡A·í«ö¤U½T©w«á¡Aµ{¦¡¥ß§Y²×¤î¡C
¦ý¬O¦pªG°õ¦æ TEST2.EXE¡A¤]·|¥X²{¤@Ó¹ï¸Ü²°¡A¦p¤U¹Ï¥ª¡A§i¶D¨Ï¥ÎªÌ¡A¶È¶È¥[ªk¥¢®Ä¡A«ö¤U½T©w«á¡Aµ{¦¡¤´Ä~Äò°õ¦æ¡A¼ªk¥\¯àÁÙ¬O¦³®Ä¡A¦p¤U¹Ï¥k¡C
¡@
¦b TEST2.ASM ùØ¡A¦]¬°¥²¶·¦Ò¼{¥|ºØ±¡§Î¡G¥i¯à¥[ªk¥\¯à¥¢®Ä¦Ó¼ªk¥\¯à¥¿±`¡A¤]¥i¯à¤Ï¹L¨Ó¼ªk¥\¯à¥¢®Ä¦Ó¥[ªk¥\¯à¥¿±`¡A©Î¨âªÌ³£¥¿±`©Î³£¥¢®Ä¡C©Ò¥H¤p¤ì°¸¤£¬O¥HÀˬd index ¤§¼ÆȨӧPÂ_¨Ï¥ÎªÌ¿ï¾Ü¥[ªkÁÙ¬O¼ªk¡A¦Ó¬OÀˬd¡y¦r¤¸¡z¬°¡y¡Ï¡zªí¥Ü¨Ï¥ÎªÌ¿ï¾Ü¥[ªk¹Bºâ¡A¡y¡Ñ¡zªí¥Ü¼ªk¹Bºâ¡C±ý¨ú±o¨Ï¥ÎªÌ¦b½Æ¦X®Ø¤¤ªº½s¿è®Ø©Ò¿ï©wªº¤º®e¦r¦ê¤èªk¬O¡A¦b³B²z CBN_SELENDOK ³qª¾½Xªº®ÉÔ¡A¥ýÀò±o¨Ï¥ÎªÌ¿ï©wªº¶µ¥Ø¯Á¤Þ ( ¤]´N¬O¨Ï¥ÎªÌ¿ï©w¤F²M³æ¤ºªº²Ä´XÓ¶µ¥Ø ( ¥Ñ¹s¶}©l ) )¡A¦A¥Ñ¦¹¶µ¥Ø¯Á¤Þ¶Ç¦^¦r¦ê¡A¤èªk¦p¤U¡G
.ELSEIF dx==CBN_SELENDOK INVOKE SendDlgItemMessage,hDlg,IDC_OP,CB_GETCURSEL,0,0 INVOKE SendDlgItemMessage,hDlg,IDC_OP,CB_GETLBTEXT,eax,OFFSET index
©Ò¥H¦b TEST2.ASM ùتº index¡A¨ä¹ê¬O¤@ÓÂù¦ì¤¸²Õªº¦r¦ê¡A¥Nªí¡y¡Ï¡z©Î¡y¡Ñ¡z¡A³oÂI»P TEST.ASM ¤£¦P¡C
°²¦p±z±qºô»Úºô¸ô¤W¤U¸ü¤F¤@ӰʺA³sµ²µ{¦¡®w¡A·QÆ[¹î¥¦¦³þ¨Ç°Æµ{¦¡¥i¥H³Q¥Dµ{¦¡©I¥s¡A¥i¥H¨Ï¥Î DUMPBIN.EXE¡C¥¦¬O¤@Ó¤G¶i¦ìÀɮ׶ɦL¤u¨ã¡A¥i¥HÆ[¹î COFF ®æ¦¡ªº¥ØªºÀÉ¡BCOFF ª«¥óªº¼Ð·Çµ{¦¡®w¡B¥i°õ¦æÀÉ¡A©M°ÊºA³sµ²µ{¦¡®w (DLL)¡CDUMPBIN.EXE ¥i¥H¦b MASM32\BIN ¤l¥Ø¿ýùاä¨ì¡C
DUMPBIN ¥u¯à¦b¡y©R¥O´£¥Ü¦r¤¸¡z¤¤°õ¦æ¡A¨ä¥Îªk¬O¡G
DUMPBIN ¿ï¶µ ÀɦW
¤W¦¡¤¤ªº¡y¿ï¶µ¡z¥i¥H¤£¥u¨Ï¥Î¤@Ó¡A¨C¤@ӿﶵ³£¥H¡y/¡z©Î¡y-¡z¶}©l¡A°²¦pn¬d¬Ý DLL ÀÉùرþ¨Ç°Æµ{¦¡¥i¥H³Q©I¥s¡A¥i¥H¥Î¡y/exports¡z¿ï¶µ¡C©³¤Uªº¨Ò¤l¬O¬d¬Ý UBCDDLL.DLL ùئ³þ¨Ç°Æµ{¦¡¥i¨Ñ¨ä¥Lµ{¦¡©I¥s¡G
E:\HomePage\SOURCE\DLL>c:\masm32\bin\dumpbin /exports ubcddll.dll [Enter]
E:\HomePage\SOURCE\DLL>Microsoft (R) COFF Binary File Dumper Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file ubcddll.dll
File Type: DLL
Section contains the following exports for ubcddll.dll
0 characteristics
4C95C7A6 time date stamp Sun Sep 19 16:19:50 2010
0.00 version
1 ordinal base
2 number of functions
2 number of names
ordinal hint RVA name
1 0 0000100C UBCD_ADDS
2 1 00001074 UBCD_MULS
Summary
1000 .rdata
1000 .reloc
1000 .text
E:\HomePage\SOURCE\DLL>
¤W±ªº¡yordinal hint RVA name¡zªí®æ¤¤ªº¡yname¡zÄæ¦ì§i¶D§Ú̳oÓ DLL ÀÉ®×¥]§t¤Fþ¨Ç°Æµ{¦¡¡C¡yRVA¡z¬O¡yRelative Virtual Address¡zªºÁY¼g¡A¥ç§Y¬Û¹ïµêÀÀ¦ì§}¡A±q 1000H ¶}©l¡A¦]¬° UBCDDLL.ASM ªº DLLEntry ¥Î¥h¤F 0CH ¦ì¤¸²Õ¡A¬G UBCD_ADDS ¬O±q 100CH ¶}©l¡C¦Ó DLLEntry ¤£³Q¨ä¥Lµ{¦¡©I¥s¡A¨Ã¨S¦³¦C¦b¼Ò²Õ©w¸qÀɪº¡yEXPORTS¡z¬q¸¨¤º¡A©Ò¥H¦¹³B¤£·|³Q¦C¥X¨Ó¡C¡yhint¡z¬O°Æµ{¦¡¦b name Äæ¦ìªº¦ì¸m¡A¥Ñ¹s¶}©l»¼¼W¡C¡yordinal¡z¬O§Ç¸¹¡A¥i¥H¦b¼Ò²Õ©w¸qÀɪº¡yEXPORTS¡z¬q¸¨¤ºªº¶µ¥Ø¤¤«ü©w¡A¤]¥i¥H¤£«ü©w¡A¥i¥H¥H§Ç¸¹¥N´À°Æµ{¦¡¦WºÙ¨Ó©I¥s°Æµ{¦¡¡C
°²¦p±z·Q¬Ý¬Ýµ{¦¡©I¥s¤Fþ¨Ç°Æµ{¦¡¡A¤]¥i¥H¥Î DUMPBIN¡A¦¹®É¨Ï¥Î¡y/IMPORTS¡z¿ï¶µ¡C©³¤U¬O¹î¬Ý TEST.EXE ©I¥s¤Fþ¨Ç°Æµ{¦¡¡A¦Ó³o¨Ç°Æµ{¦¡¤S¥]§t¦bþ¨Ç°ÊºA³sµ²µ{¦¡®wùØ¡C
E:\HomePage\SOURCE\DLL>c:\masm32\bin\dumpbin /imports test.exe [Enter]
E:\HomePage\SOURCE\DLL>Microsoft (R) COFF Binary File Dumper Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
Dump of file test.exe
File Type: EXECUTABLE IMAGE
Section contains the following imports:
USER32.dll
40513C Import Address Table
405084 Import Name Table
0 time date stamp
0 Index of first forwarder reference
19B LoadIconA
100 GetDlgItem
210 SendMessageA
228 SetDlgItemTextA
B8 EndDialog
20B SendDlgItemMessageA
102 GetDlgItemTextA
92 DialogBoxParamA
KERNEL32.dll
405108 Import Address Table
405050 Import Name Table
0 time date stamp
0 Index of first forwarder reference
75 ExitProcess
111 GetModuleHandleA
ubcddll.dll
40518C Import Address Table
4050D4 Import Name Table
0 time date stamp
0 Index of first forwarder reference
1 UBCD_MULS
0 UBCD_ADDS
Summary
1000 .data
1000 .idata
1000 .rdata
1000 .reloc
1000 .rsrc
2000 .text
E:\HomePage\SOURCE\DLL>