«e±¤Q³¹¤¶²Ðªº³£¬O¥Î MASM64 SDK ¨Ó²ÕĶì©lµ{¦¡¡A¤]´N¬O¨Ï¥Î·L³nªº ML64.EXE ²ÕĶ¾¹·f°t¥ý¶i hutch-- ©Ò¶}µoªº¥¨¶°¡B¥]§tÀɨӻs§@µ{¦¡¡C±q³o¤@³¹¶}©l¡A±N¨Ï¥Î UASM ¨Ó»s§@µ{¦¡¡C¦b¥Á°ê 100 ¦~«e«á¡]¦è¤¸ 2011 ¦~«e«á¡^¡A¤p¤ì°¸¤w¶}©l¾Ç²ß¦b Win64 ¨t²Î¤U¼¶¼g²Õ¦X»y¨¥µ{¦¡¡A¨º®É MASM64 SDK ©|¥¼ÄÀ¥X¡A¤p¤ì°¸¬O§Q¥Î UASM ªº«e¨¡AJWASM¡A²ÕĶ¾¹·f°t WinInc ¥]§tÀɨӼ¶¼g²Õ¦X»y¨¥µ{¦¡¡C¦]¦¹¹ï©ó¼¶¼g 64 ¦ì¤¸ªºµ{¦¡¦Ó¨¥¡AUASM ºâ¬O¡u±Ò»X¡vªº²ÕĶ¾¹¡A¤p¤ì°¸³Î±Ë¤£¤U¡A©Ò¥H¥²¶·n¤¶²Ð UASM¡C
UASM ¥i»¡¬O©R¹B¦h¦ß¡A¥Ñ©ó¥¦ªºì¥Í¤½¥q¡A¥[®³¤jªº Watcom ³nÅ餽¥q³Q Powersoft ¤½¥q¦¬ÁÊ¡APowersoft ¤½¥q¤S³Q Sybase ¤½¥q¦¬ÁÊ¡A¤@«×°±¤î¶}µo¡C©¯¦n«á¨Ó Sybase ¤½¥q±N¨äì©l½X¶}©ñÄÀ¥X¡A¦A¥Ñ Japheth¡BHabran¡BBranislav Habus¡BJohn Hankinson µ¥¥ý¶i«ùÄò§V¤O¡A¤~¦³¤F UASM¡C¡]¨£²Ä¹s³¹¡^
¤£½×¦p¦ó¡AUASM Á`ºâ¬O¼õ¤F¹L¨Ó¡C©³¤U¶}©l¤¶²Ð UASM ªº¥Îªk¡C
º¥ý¡A¥ýÀˬd¬O§_¤w§¹¦¨¤U±ªº¶µ¥Ø¡G
¦pªG§Aªº¦w¸Ë¥Ø¿ý»P¤W±¤£¦P¡A¤]¨S¦³Ãö«Y¡A¦ý¬O©³¤U´Nnקï¬Û¹ïÀ³ªº¥Ø¿ý¦WºÙ¤F¡C¦]¬°²ÕĶ»P³sµ²³£n¨Ï¥Î¨ì UASM64.EXE »P LINK.EXE¡A¦Ó¥Bì©l½Xn¦³¥]§tÀɤζפJµ{¦¡®w¡A³o¨Ç³£¦b¤£¦Pªº¤l¥Ø¿ý¡C¨C¦¸²ÕĶ¨Ã³sµ²®É¡A³£n¥ý¶i¦æ©³¤Uªº³]©w¡G
SET INCLUDE=C:\UASM\Include SET LIB=E:\MASM32\lib64 SET PATH=C:\UASM;C:\UASM\bin64;%PATH% SET LINK=/SUBSYSTEM:WINDOWS /DEBUG
¦pªG¨C¦¸²ÕĶ³£«·s³]©w·j´M¸ô®|«Ü³Â·Ð¡A¤£¦p»s§@¤@ӧ妸ÀÉ¡]batch file¡^¡C§å¦¸ÀÉ°ÆÀɦW¬O BAT¡AÅU¦W«ä¸q¡A¥¦¥u¶·«Ø¥ß¤@¦¸«á¡A´N¯à¤@¦¸³B²z³\¦h«ü¥O¡C
³oӧ妸ÀÉ¡A¥i¥H©R¦W¬°¡uUASM.BAT¡v¡A±N©³¤Uªº¤å¦r¥Î¡u°O¨Æ¥»¡v¿é¤J«á¡A¦s¤J¡uC:\USER\±b¸¹\UASM.BAT¡v¸Ì±¡CÀx¦s®Éªº½s½X¥i¥Î¡uUTF-8¡v©Î¡uANSI¡v¡CUASM.BAT ªº¤º®e¦p¤U¡G
1 2 3 4
5 6 7 8
9 10 11 12 |
SET INCLUDE=C:\UASM\Include
SET LIB=C:\UASM\lib64
SET PATH=C:\UASM;C:\UASM\bin64;%PATH%
E:
CD E:\HOMEPAGE\SOURCE\WIN64
@ECHO OFF
IF "%1"=="C" SET LINK=/SUBSYSTEM:CONSOLE /DEBUG
IF "%1"=="c" SET LINK=/SUBSYSTEM:CONSOLE /DEBUG
IF "%1"=="W" SET LINK=/SUBSYSTEM:WINDOWS /DEBUG
IF "%1"=="w" SET LINK=/SUBSYSTEM:WINDOWS /DEBUG
IF "%1"=="" SET LINK=/SUBSYSTEM:WINDOWS /DEBUG
SET LINK |
©¹«á¦pªGn²ÕĶì©lµ{¦¡®É¡A¶i¤J¡u©R¥O´£¥Ü¦r¤¸¡v¥ý°õ¦æ¡uUASM.BAT¡v¡A´N¯à§¹¦¨«ez³]©w¡C°£¦¹¤§¥~¡AUASM.BAT ÁÙ·s¼W¤F¤@¶µ¥\¯à¡C¦pªG¦b©R¥O´£¥Ü¦r¤¸¤¤¡A¿é¤J¡uUASM C¡v¡]C ªº¤j¤p¼g¤£©ë¡^¡A¥i²ÕĶ±±¨î»Oµ{¦¡¡F¦pªG¿é¤J¡uUASM W¡v©Î¨S¦³¿ï¶µ¡A¨º»ò´N·|²ÕĶ¦¨µøµ¡µ{¦¡¡C
§å¦¸Àɤ]¥i¥H¦³¿ï¶µ¡A¥H¡u%1¡v¡B¡u%2¡v¡B¡u%3¡v¡K¡K¥Nªí²Ä¤@Ó¡B²Ä¤GÓ¡B²Ä¤TÓ¡K¡K¿ï¶µ¡C¦]¦¹¡uIF "%1"=="C" SET LINK=/SUBSYSTEM:CONSOLE /DEBUG¡vªº·N«ä´N¬O¡A¦pªG²Ä¤@ӿﶵ¬O C¡A´N³]©w¡uLINK=/SUBSYSTEM:CONSOLE /DEBUG¡v¡C
UASM ªº²ÕĶ¾¹¬O UASM64.EXE¡A²ÕĶ Win64 µ{¦¡®É¡A¥²¶·¦b©R¥O´£¥Ü¦r¤¸¤¤¡A°õ¦æ UASM64.EXE¡AÁÙ¥²¶·¿é¤J¾A·íªº¿ï¶µ¡C¦b¤¶²Ð³o¨Ç¿ï¶µ¤§«e¡An¥ý»¡»¡³o¨Ç¿ï¶µ¦@³q¤§³B¡G
§A¥i¥H¦b¡u©R¥O´£¥Ü¦r¤¸¡v¿é¤J¡uUASM64 -h¡v©Î¡uUASM64 -?¡v¡AUASM ·|Åã¥Ü¥X©Ò¦³¿ï¶µªºÂ²³æ´yz¡A¤]¥i¥H¦b¶}±Ò¡uC:\UASM\JWasm.chm¡v»¡©úÀɾ\Ū¸Ô²Ó»¡©ú¡C¾¨ºÞ UASM ¥\¯à±j¤j¡A¦ý¬O¥¦µLªk²ÕĶ¦¨¥\«á¡Aª½±µ©I¥s³sµ²¾¹¡A¦]¦¹±o¦Û¦æ³sµ²¡A©Ò¥H¨S¦³¡u-link¡v³oӰѼơC
¨Ï¥Î¡u-Fl¡v¿ï¶µ¡]¨ä¤¤ªº¡ul¡v¬O¤p¼gªº¡uL¡v¡^¡A¥i¥H¨Ï UASM64.EXE «Ø¥ß¦CªíÀÉ¡C¨ä«áªº¡u[=file_name]¡v¥i¥H¬Ù²¤¡A¦pªG¬Ù²¤¡A¦CªíÀɪº¥DÀɦW´N¬Oì©lµ{¦¡ªº¥DÀɦW¡A°ÆÀɦW¬O¡uLST¡v¡C¦pªG¡u[=file_name]¡v¨S¦³¬Ù²¤¡A¦ý¥u¼g¥DÀɦW¡AUASM64.EXE ·|¦Û°Ê¥[¤W°ÆÀɦW¡uLST¡v¡F¦pªG¡u[=file_name]¡v¼g¥X¤F§¹¾ãªºÀɦW¡A¨º»ò¦CªíÀÉ´N¥Î³oÓ¦WºÙ¡C
¨Ï¥Î¡u-Zi¡v¿ï¶µ¡A¥i¥H¦b©Ò«Ø¥ßªº¥ØªºÀɤ¤¡]¥]§t OMF ¥H¤Î COFF ®æ¦¡ªº¥ØªºÀÉ¡^¡A¥[¤W¨Ï¥ÎªÌ¦bì©lµ{¦¡ùةҨϥΪº²Å¸¹¸ê®Æ¡A³o²Å¸¹¸ê®Æ¯àÅý°£¿ù¾¹¦b°£¿ù®ÉÅã¥Ü²Å¸¹¦WºÙ¡A¨Ò¦pÅܼƦWºÙ©Î±`¼Æ¦WºÙ¡A¦Ó¤£¬O¥uÅã¥Ü¦ì§}¦Ó¤w¡A³oªº½T¬O¤@¤j¶i¨B¡C¦ý³sµ²¾¹¤]¥²¶·n°t¦X¤~¦æ¡ALINK.EXE ¥²¶·¤U¹F¡u/DEBUG¡v¿ï¶µ¡A´N¯à¹Fªº¦¹¥Øªº¡C
¯à¥Îì©lµ{¦¡²Å¸¹°£¿ùªº°£¿ù¾¹¥²¶·²Å¦X CodeView V4 ªº¼Ð·Ç¡A¦³«Ü¦h°£¿ùµ{¦¡³£¥i¨Ï¥Î¡A¨Ò¦p¹³ WinDbg¡BOllyDbg¡Bx64dbg µ¥³£¥i¥H¡C
¡u-Zi¡v«á±ÁÙ¥i¥H¿ï¾Ü¡A0¡B1¡B2¡B3¡B5¡B8 ¤»ºØ¼Æ¦rªº¨ä¤¤¤@ºØ¡C0 ªí¥Ü¥u¦³¥þ°ìÅܼƷ|³Q¼g¤J¥ØªºÀÉùØ¡F1 ªí¥Ü¥þ°ìÅܼƩM°Ï°ìÅܼƳ£·|¼g¤J¥ØªºÀÉ¡F2 ªí¥Ü¥þ°ìÅܼơB°Ï°ìÅܼƥH¤Î¨Ï¥ÎªÌ©w¸qªº²Å¸¹³£·|¼g¤J¡A³o¬O¤º©wÈ¡F3 ªí¥Ü¥H EQU ©w¸qªº±`¼Æ¤]·|³Q¼g¤J¥ØªºÀÉ¡F5 »P 8 ¤À§O¥Nªí¤ä´© CodeView ²Ä 5 ª©»P²Ä 8 ª©¡C
¡u-win64¡v·|¨Ï UASM »s³y¥X 64 ¦ì¤¸ COFF ®æ¦¡ªº¥ØªºÀÉ¡A¶i¤@¨B³sµ²«á´N¯à²£¥Í PE¡Ï ®æ¦¡ªº¥i°õ¦æÀÉ¡A¦¹ºØ¥i°õ¦æÀɬO Win64 ªºì¥Íµ{¦¡¡C´«¥y¸Ü»¡¡A¦pªGn»s³y¥X Win64 ¨t²Î¤¤ªº¥i°õ¦æÀÉ¡A´N¥²¶·¨Ï¥Î³oӰѼơC³oӰѼƷ|¦Û°Ê±Ò¥Î
.X64 .MODEL FLAT,FASTCALL OPTION WIN64:0
¡u.MODEL FLAT,FASTCALL¡v©M¡uOPTION WIN64:0¡v³£¬O UASM64.EXE ªº°²«ü¥O¡An¼g¦bì©lµ{¦¡ùر¡Aµy«á¦A¸ÑÄÀ¡C
§ÚÌ¥é·Ó²Ä¤C³¹ªº SPLWND.ASM ¼¶¼g¥Ñ UASM64.EXE ²ÕĶªºª©¥»¡AºÙ¤§¬°¡uUASM ª©ªº SPLWND¡v¡A¨äì©lµ{¦¡¦p¤U¡C¦b¤å®Ñ³B²z¾¹¤¤±N¨ä¿é¤J«á¡AÀx¦s¦b¡uE:\HomePage\SOURCE\Win64\SPLWND\SPLWND_U.ASM¡v¡C
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
37 38 39 40
41 42 43 44
45 46 47 48
49 50 51 52
53 54 55 56
57 58 59 60
61 62 63 64
65 66 67 68
69 70 71 72
73 74 75 76
77 78 79 80
81 82 83 84
85 86 87 88
89 |
;²ÕĶ»P³sµ²¡G
;SET INCLUDE=C:\UASM\INCLUDE;
;SET LIB=E:\masm32\lib64
;SET PATH=C:\UASM;C:\UASM\bin64;%PATH%
;SET LINK=/SUBSYSTEM:WINDOWS
;uasm64 -win64 splwnd_u.asm
OPTION CASEMAP:NONE
OPTION WIN64:3
INCLUDE WINDOWS.INC
INCLUDELIB GDI32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
;***************************************************************************************************
.DATA
hInstance HINSTANCE ? ;¼Ò²Õ¥N½X
hwnd HWND ? ;µøµ¡¥N½X
CommandLine LPSTR ? ;©R¥O¦C¦ì§}
wc WNDCLASSEX <>
msg MSG <>
rect RECT <>
ps PAINTSTRUCT <>
szClassName DB "SimpleWndClass",0 ;µøµ¡Ãþ§O¦WºÙ
szAppName DB "²³æªºµøµ¡",0
sYouPress DB "§A«ö¤U¤F Áä¡C"
;***************************************************************************************************
.CODE
;---------------------------------------------------------------------------------------------------
WndProc PROC hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.switch uMsg
.case WM_PAINT
invoke BeginPaint,hWnd,ADDR ps
invoke GetClientRect,hWnd,ADDR rect
invoke DrawText,ps.hdc,ADDR sYouPress,SIZEOF sYouPress,ADDR rect,\
DT_SINGLELINE or DT_CENTER or DT_VCENTER
invoke EndPaint,hWnd,ADDR ps
.case WM_CHAR
mov rax,wParam
mov [sYouPress+8],al
invoke InvalidateRect,hWnd,0,1
.case WM_DESTROY
invoke PostQuitMessage,0
.default
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endsw
xor rax,rax
ret
WndProc ENDP
;---------------------------------------------------------------------------------------------------
main PROC
invoke GetModuleHandle,0 ;¨ú±o¼Ò²Õ¥N½X
mov hInstance,rax
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
lea rdx,WndProc
mov wc.lpfnWndProc,rdx
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
mov wc.hInstance,rax
invoke LoadIcon,NULL,IDI_APPLICATION ;¨ú±o¹Ï¥Ü¥N½X
mov wc.hIcon,rax ;¦s¤J¹Ï¥Ü¥N½X
mov wc.hIconSm,rax ;¦s¤J¤p¹Ï¥Ü¥N½X
invoke LoadCursor,NULL,IDC_ARROW ;¨ú±o´å¼Ð¥N½X
mov wc.hCursor,rax ;¦s¤J´å¼Ð¥N½X
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,0
lea rdx,szClassName
mov wc.lpszClassName,rdx
invoke RegisterClassEx,ADDR wc ;µù¥Uµøµ¡Ãþ§O
invoke CreateWindowEx,0,ADDR szClassName,ADDR szAppName,WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,hInstance,0
mov hwnd,rax
invoke ShowWindow,hwnd,SW_SHOWNORMAL
invoke UpdateWindow,hwnd
.while TRUE
invoke GetMessage,ADDR msg,0,0,0
.break .if rax==0
invoke TranslateMessage,ADDR msg
invoke DispatchMessage,ADDR msg
.endw
invoke ExitProcess,0 ;µ{¦¡µ²§ô
main ENDP
;***************************************************************************************************
END main |
¶}±Ò¡u©R¥O´£¥Ü¦r¤¸¡v¤§«á¡A¨Ì·Ó©³¤U¹Lµ{²ÕĶ¨Ã³sµ²¡C¶À¦â¦r¬O¨Ï¥ÎªÌ¥²¶·¦Û¦æ¿é¤Jªº«ü¥O¡A¨C¿é¤J§¹¤@¦æ¥²¶·«ö¡uEnter¡vÁä¡A¹q¸£¤~·|°õ¦æ³o¹D©R¥O¡C
Microsoft Windows [ª©¥» 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\wanker>uasm [Enter] ¡÷°õ¦æ UASM.BAT §å¦¸ÀÉ¡A¬Ù¤F³\¦h¥´¦r¿é¤J C:\Users\wanker>SET INCLUDE=C:\UASM\Include C:\Users\wanker>SET LIB=C:\UASM\lib64 C:\Users\wanker>SET PATH=C:\UASM;C:\UASM\bin64;C:\Windows\system32;C:\Windows;C: \Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Fi les (x86)\UltraEdit-32 C:\Users\wanker>E: E:\>CD E:\HOMEPAGE\SOURCE\WIN64 LINK=/SUBSYSTEM:WINDOWS /DEBUG ¡÷¨ì¦¹ UASM.BAT ¤w°õ¦æ§¹²¦ E:\HomePage\SOURCE\Win64>cd SPLWND [Enter] ¡÷³]©w SPLWND_U.ASM ©Ò¦b¤l¥Ø¿ý¬°·í«e¥Ø¿ý E:\HomePage\SOURCE\Win64\SPLWND>uasm64 -win64 -Zi SPLWND_U.ASM [Enter] ¡÷²ÕĶ UASM v2.56, Oct 27 2022, Masm-compatible assembler. Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved. Source code is available under the Sybase Open Watcom Public License. SPLWND_U.ASM: 89 lines, 3 passes, 143 ms, 0 warnings, 0 errors ¡÷¨S¦³¿ù»~¡A¦¨¥\²ÕĶ§¹¦¨ E:\HomePage\SOURCE\Win64\SPLWND>link SPLWND_U.OBJ [Enter] ¡÷³sµ² Microsoft (R) Incremental Linker Version 14.25.28614.0 Copyright (C) Microsoft Corporation. All rights reserved. /SUBSYSTEM:WINDOWS /DEBUG ¡÷¨S¦³°T®§¡Aªí¥Ü SPLWND_U.EXE ¦¨¥\»s§@¦n¤F E:\HomePage\SOURCE\Win64\SPLWND>
¤W±²ÕĶ¹Lµ{ªºµe±ÃC¦â¡A¬O«ö©R¥O´£¥Ü¦r¤¸¤¤ªº¹ê»ÚÃC¦â¡C©Î³\¦³¤H¤w¸gµo²{¡AUASM64.EXE ªº°T®§¬O±m¦âªº¡C¤ñ¸û«nªº¬O¾í¦â»P¬õ¦âªºÄµ§i»P¿ù»~°T®§¡A¦pªG³£¬O 0¡A´N¥Nªí²ÕĶ¦¨¥\¡C
©³¤U¤p¤ì°¸·Q½Í½Í¤@¨Ç¸gÅç¡A¦³Ãö©ó¦b©R¥O´£¥Ü¦r¤¸©Ò¿é¤J«ü¥Oªº¤j¤p¼g°ÝÃD¡C
Windows §@·~¨t²Î¤¤¡A©R¥O´£¥Ü¦r¤¸ªº«ü¥O¤jP¥i¤À¬°¨âºØ¡G①¤º³¡«ü¥O»P②¥~³¡«ü¥O¡C©Ò¿×¤º³¡«ü¥O¬O«ü©R¥O´£¥Ü¦r¤¸¥»¨´£¨Ñªº¡A¨Ò¦p¡uCD¡v¡B¡uSET¡vµ¥¡F¿é¤J¤º³¡«ü¥O®É¡A¤£°Ï¤À¤j¤p¼g¡A·N«ä´N¬O»¡¿é¤J¡uCD¡v¡B¡uCd¡v¡B¡ucd¡v³£¬O¤@¼Ëªº¡C¥~³¡«ü¥O¬O«üÀx¦s¦b¹q¸£ºÏºÐ¾÷¤Wªº¥i°õ¦æÀÉ¡A¨Ò¦p¡uUASM64.EXE¡v¡B¡uLINK.EXE¡vµ¥¡F°õ¦æ³o¨Ç¥i°õ¦æÀÉ¡A´N¬Û·í°õ¦æ¥~³¡«ü¥O¡A¥u»Ý¦b©R¥O´£¥Ü¦r¤¸¿é¤J¥DÀɦW§Y¥i¡A¤£»Ýn§âªþÀɦW¡]´N¬O¡uEXE¡v¡^¤]¼g¥X¨Ó¡A¤]¤£°Ï¤À¤j¤p¼g¡Cµ²½×´N¬O¡A¦b©R¥O´£¥Ü¦r¤¸ªº«ü¥O¤£°Ï¤À¤j¤p¼g¡C
¦b©R¥O´£¥Ü¦r¤¸¤¤¡A°£¤F«ü¥O¤£°Ï¤À¤j¤p¼g¡AÀɮצWºÙ¤]¤£°Ï¤À¤j¤p¼g¡A¦]¦¹¡uSPLWND_U.ASM¡v©M¡usplwnd_u.asm¡v¬O¤@¼Ëªº¡C¦pªG§AµwºÐ D:\ ¤¤¦³ SPLWND_U.ASM ÀɮסAE:\ ¤¤¦³ splwnd_u.asm ÀɮסA±N¡uD:\SPLWND_U.ASM¡v«þ¨©¨ì¡uE:\¡v¡A©R¥O´£¥Ü¦r¤¸´N·|µo¥Xĵ§i°T®§¡A°Ý¡u½T©wn½Æ¼g¶Ü¡H¡v¡C¥Ñ¦¹¥i¨£¡A©R¥O´£¥Ü¦r¤¸§â¬Û¦P¦r¥À¦ý¤£¦P¤j¤p¼gªºÀɮסAµø¬°¦P¤@ÓÀɮסC¥t¥~¡AÁöµMÀɦW¤£°Ï¤À¤j¤p¼g¡A¦ý¬O·í«Ø¥ßÀɮ׮ɡA¨t²Î·|¥H¨Ï¥ÎªÌ¿é¤Jªº¤j¤p¼g¡A·|¦p¹ê«Ø¥ß¡A¤]·|¦p¹êÅã¥Ü¡C¤£¶È©R¥O´£¥Ü¦r¤¸¤¤¦p¦¹¡A¦b Windows §@·~¨t²ÎªºÀɮ׺޲zû©Î¨ä¥Lµ{¦¡¤]¬O³o¼Ë¡C
©R¥O´£¥Ü¦r¤¸ªº«ü¥O»PÀɮצWºÙ³£¤£°Ï¤À¤j¼g¤p¡A¨º»ò¤°»ò®ÉÔ·|°Ï¤À¤j¤p¼g©O¡H©R¥O´£¥Ü¦r¤¸¤¤ªº«ü¥O¡A¤£½×¬O¤º³¡«ü¥OÁÙ¬O¥~³¡«ü¥O¡A¦pªG«ü¥O¦³¿ï¶µ¡A³o¨Ç¿ï¶µ¤¤¡A¦³¨Ç¬O°Ï¤À¤j¤p¼g¡A¨Ò¦p UASM64.EXE ªº¡u-win64¡v¡BML64.EXE ªº¡u/Fl¡vµ¥¡C¤]¦³¤£°Ï¤À¤j¤p¼gªº¿ï¶µ¡A¨Ò¦p LINK.EXE ªº¡u/SUBSYSTEM:WINDOWS¡v¡C¨Æ¹ê¤W¡A³o¨Ç¿ï¶µ¬O¨Ì¾Ú³o¨Çµ{¦¡³Ìªìªº³]p¡A¦Ó¨M©w¬O§_°Ï¤À¤j¤p¼g¡C
¤ñ¸û¾A¥Î©ó UASM »P MASM64 SDK ªºì©lµ{¦¡¡GSPLWND_U.ASM »P SPLWND¡A§A·|µo²{¨âªÌ´X¥G¤@¼Ë¡A®t§O¦b©ó©³¤Uªº¤T³B¡A¨Æ¹ê¤W¡A¨ä¥Lªºì©lµ{¦¡¥Î MASM64 SDK ²ÕĶ»P¥Î UASM ²ÕĶ¡Aì©lµ{¦¡ªº¼gªk¤£¦P¤§³B¤]¬O³o¤T³B¡G
©³¤U³v¶µ¨Ó¤ÀªR¡C
①¡G¡uOPTION CASEMAP:NONE¡v¬O¥Î¨Ó³]©wì©lµ{¦¡¤¤¡A¨Ï¥ÎªÌ©w¸qªº¦WºÙ¡A¨Ò¦pÅܼƦWºÙ¡B°Æµ{¦¡¦WºÙ¡K¡Kµ¥¬O°Ï§O¤j¤p¼gªº¡C¦]¬° Windows µ{¦¡¥²©w·|©I¥s Windows API¡A³o¨Ç¨ç¦¡¦WºÙ³£°Ï¤À¤j¤p¼g¡A©Ò¥H¤£ºÞ¥ÎþÓ²ÕĶ¾¹¡A³£¥²¶·n¦³³o¤@¦æ¡A®t§O¬O MASM64 SDK ª©ªºì©lµ{¦¡¤w¼g¦b¡umasm64rt.inc¡v¸Ì±¤F¡AUASM ª©ªºì©lµ{¦¡¥²¶·¦Û¦æ¥[¤J¡C
¦¹¥~¡A¦b¶i¤J°Æµ{¦¡ÁÙ¥²¶·³]©w¤@¨Ç¯S©Ê¡A³o¶µ¤u§@¬O¥Î¡uOPTION WIN64¡v¹F¦¨¡C
OPTION ¥»¬O ML64.EXE ªº°²«ü¥O¡A¦ý UASM ¦bì¨Óªº¡uOPTION¡v°ò¦¤W²K¥[¤F¡uWIN64:n¡v¿ï¶µ¡A©Ò¥H UASM64.EXE ¥i¥Î¡uOPTION WIN64:n¡v¡A¦ý ML64.EXE ¤£¯à¨Ï¥Î¡C¥¦ªº»yªk¬O¡G
OPTION WIN64:n
¨ä¤¤ n ¥u¦³ 0¡ã3 ¦ì¤¸¨Ï¥Î¡A¨£¤Uªí¡G
¤@¯ë¦Ó¨¥¡A¼¶¼g 64 ¦ì¤¸ªº Windows µ{¦¡³q±`§â²Ä¹s¡B¤@¦ì¤¸³]©w°ß¤@§Y¥i¡A¦p¤U¡G
OPTION WIN64:3
¦³Ãö¼v¤l±±¶¡»P°Ñ¼Æ©Ò»Ýªº°ïÅ|ªÅ¶¡¡A½Ð¤À§O°Ñ¾\²Ä¤G³¹ªº¡ux64 ©I¥sºD¨Ò¡v»P¡u¦b°ïÅ|¤¤«O¯d°Ñ¼ÆªÅ¶¡»P¹ï»ô¸`ªºÃä¬Éªºµ¦²¤¡v¡C¦b 64 ¦ì¤¸ªºµwÅ餤¡A¦s¨úªº°O¾ÐÅé¦ì§}¦pªG¥H¤Q¤»¶i¦ìªí¥Ü¡A¦Ó¥B¦ì§}ªºÓ¦ì¼Æ¬°¹s¡A¦s¨ú³t«×¸û§Ö¡C°ò©ó¤Wzì¦]¡A°²¦p§â°Ï°ìÅܼƦw±Æ¦b¸`ªºÃä¬É¤W¡]¸`¬O«ü 16 Ӧ줸²Õ¡A^¤å¬O paragraphs¡^¡A «K¯à¼W¶i®Ä²v¡C
¦pªG¤£¦bì©lµ{¦¡¼g¤W¡uOPTION WIN64:n¡v¡A¤]¥i¥H¦b²ÕĶ®É©ó©R¥O´£¥Ü¦r¤¸¿é¤J¡uuasm64 -win64 ì©lµ{¦¡¡v¹F¦¨¡C¦ý¦b©R¥O´£¥Ü¦r¤¸¿é¤J¡u-win64¡v¿ï¶µ¡A¥u¯à¨Ï¥Î¹w³]È¡A¤£¦p¦bì©lµ{¦¡¤¤¼g¤W¡uOPTION WIN64:n¡v¤ñ¸û¦³¼u©Ê¡C¥t¥~¡An²ÕĶ 64 ¦ì¤¸ªº Windows µ{¦¡¡A©R¥O´£¥Ü¦r¤¸¿é¤J¡uuasm64 -win64¡v¤¤ªº¡u-win64¡v¤£¥i¬Ù²¤¡A§_«h·|µoºÙ¿ù»~¡C
②¡G¦]¬°»P UASM ·f°tªº WinInc ¥]§tÀɤ¤¡A¨Ã¨S¦³¦Û°Ê¥]§t¶×¤Jµ{¦¡®w¡A¦]¦¹¥²¶·¦bì©lµ{¦¡¤¤¡A¥H¡uINCLUDELIB¡v°²«ü¥O±N¾A·íªº¶×¤Jµ{¦¡®w¤Þ¤J¡C
n¤Þ¤Jþ¤@ӶפJµ{¦¡®w¡A¨ä¹ê¤£Ãø¨M©w¡C¦bì©lµ{¦¡¤¤¡A¦pªG©I¥s¬YÓ Windows API ®É¡A¥i¦bºô»Úºô¸ô¤W¬d¾\¸Ó API ªº¡u³W®æ»Ý¨D¡v¡]Requirements¡^¤¤¡A»ÝnþÓµ{¦¡®w¡]Library¡^¡A¥H¡uINCLUDELIB¡v°²«ü¥O¤Þ¤J§Y¥i¡C
¨Ò¦p¦bµ{¦¡¤¤©I¥s¤F BeginPaint¡A¨º»òn¤Þ¤JþӶפJµ{¦¡®w©O¡H¥i¥H¦b Google ¤¤¿é¤J¡uBeginPaint¡v¡AµM«á§ä¨ì Microsoft | Learn ¤¤ªº»¡©ú¡CµM«á±²°Ê¨ì¡u³W®æ»Ý¨D¡v©Î¡uRequirements¡v¡A¥H¬õ¦â®Ø®Ø¦íªº´N¬On¤Þ¤Jªºµ{¦¡®w¡A¦p¤U¹Ï¡G
③¡GUASM64.EXE ª½±µ´N¤ä´© invoke »P±ø¥ó±±¨î¬yµ{«ü¥O³oÃþ°ª¶¥»yªk¡A³o¬O UASM64.EXE ³Ì¤jªºÀu¶Õ¡A³o¨Ç«ü¥O³£¬O°²«ü¥O¡C
invoke °²«ü¥Oªº»yªk©M MASM64 SDK ¬Û¦P¡A½Ð°Ñ¾\²Ä¤»³¹¡C¦ý¬O UASM ªº invoke °²«ü¥Oªº°Ñ¼Æ¦C¤£¯à¨Ï¥Î¦r¦ê¡C
±ø¥ó±±¨î¬yµ{«ü¥O¥]§t¡u.switch/.case/.default/.endsw¡v¡B¡u.if/.elseif/.else/.endif¡v¡B¡u.while/.break .if/.endw¡v¡B¡u.repaet/.break .if/.until¡vµ¥¡C³o¨Ç±ø¥ó±±¨î¬yµ{ªº»yªk©M MASM64 SDK ´X¥G¤@¼Ë¡A½Ð°Ñ¾\²Ä¤C³¹¡A®t§O¦b©ó§PÂ_¦¡¤¤ªºÅÞ¿è¹Bºâ¤l¸û¬°ª½Æ[¡C¦b UASM ¤¤ªºÅÞ¿è¹Bºâ¤l¡A< ªí¥Ü¤p©ó¡B> ªí¥Ü¤j©ó¡B<> ªí¥Ü¤£µ¥©ó¡C
④¡G¦]¬° UASM ¤ä´© END °²«ü¥O¤§«á¼g¤Wµ{¦¡ªº¶i¤JÂI¡A©Ò¥H³q±` UASM ª©ªºì©lµ{¦¡³Ì«á¤@¦æ¬O
END ¶i¤JÂI
¤]¦]¬°¦³³o¤@¦æ¡A©Ò¥H¦b³sµ²®É´N¤£»Ý«ü©w /ENTRY ¿ï¶µ¡C
©³¤U¤¶²Ð¥t¤@Ó¨Ò¤l¡ARNDRECT.ASM¡C³oÓµ{¦¡¯à¦b¤u§@°Ï¤¤Åã¥Ü¤£©T©wÃC¦âÀH¾÷¤j¤pªºªø¤è§Î¡]ªø¤è§Î¤]¥s¯x§Î¡^¡C©³¤U¥ý¤¶²Ð RNDRECT.ASM ¨Ï¥Î¨ìªº·s«ü¥O¡B·sªº Windows API »P·§©À¡A¦A¦C¥X§¹¾ãªºì©lµ{¦¡¡C
RDRAND «ü¥O·|Åý CPU ²£¥Í¤@Ӷüơ]¤]¥sÀH¾÷¼Æ¡^¡A¦s¤J±µ©ó¨ä«áªº¥Øªº¹Bºâ¤¸ùر¡A¨ä»yªk¦p¤U¡G
RDRAND ¥Øªº¹Bºâ¤¸
¥Øªº¹Bºâ¤¸¥i¥H¬O 16 ¦ì¤¸¡B32¦ì¤¸¡B64 ¦ì¤¸ªº¼È¦s¾¹¡ACPU ·|¨Ì¾Ú¤£¦Pªø«×ªº¼È¦s¾¹¡A¦Ó¥Í¦¨¤£¦P¤j¤pªº¶Ã¼Æ¡C·í°õ¦æ§¹ RDRAND «ü¥O¤§«á¡A¦pªG¦¨¥\²£¥Í¶Ã¼Æ¨Ã¦s¤J¥Øªº¹Bºâ¤¸ùر¡A¨º»ò CPU ·|³]©w¶i¦ìºX¼Ð¡F¦pªG¥¢±Ñ¡A«h²M°£¶i¦ìºX¼Ð¡C
¦ý¨Ã¤£¬O©Ò¦³ªº CPU ³£¤ä´© RDRAND «ü¥O¡A¦]¦¹¦b¨Ï¥Î RDRAND ¤§«en¥ý½T©w CPU ¬O§_¤ä´©¸Ó«ü¥O¡C½T©wªº¤èªk«Ü²³æ¡A¥ý§â RAX ³]¬°¤@¡AµM«á°õ¦æ CPUID «ü¥O¡A°õ¦æ CPUID §¹²¦«á¡A¦pªG RCX ªº²Ä 30 ¦ì¤¸¬°¤@¡Aªí¥Ü¦¹ CPU ¤ä´© RDRAND «ü¥O¡FY¬°¹sªí¥Ü¤£¤ä´©¡C
RDSEED «ü¥O¬O²£¥Í¤@Ӷüƺؤl¡AµM«á¥i¥H±N³oӶüƺؤl±Ò°Ê¥t¤@Ó°°ÀH¾÷¼Æ¥Í¦¨¾¹¡]pseudorandom number generator¡^¡A¥H±o¨ì¶Ã¼Æ¡CRDSEED ªº»yªk¬O¡G
RDSEED ¥Øªº¹Bºâ¤¸
¥Øªº¹Bºâ¤¸¥i¥H¬O 16 ¦ì¤¸¡B32¦ì¤¸¡B64 ¦ì¤¸ªº¼È¦s¾¹¡ACPU ·|¨Ì¾Ú¤£¦Pªø«×ªº¼È¦s¾¹¡A¦Ó¥Í¦¨¤£¦P¤j¤pªº¶Ã¼ÆºØ¤l¡C°õ¦æ§¹ RDSEED «ü¥O¤§«á¡A¦pªG¦¨¥\²£¥Í¶Ã¼ÆºØ¤l¨Ã¦s¤J¥Øªº¹Bºâ¤¸ùØ¡A¨º»ò CPU ·|³]©w¶i¦ìºX¼Ð¡F¦pªG¥¢±Ñ¡A«h²M°£¶i¦ìºX¼Ð¡C
¨Ã¤£¬O©Ò¦³ªº CPU ³£¤ä´© RDSEED «ü¥O¡A¦]¦¹¦b¨Ï¥Î RDSEED ¤§«en¥ý½T©w CPU ¬O§_¤ä´©¸Ó«ü¥O¡C½T©wªº¤èªk¬O¥ý§â RAX ³]¬°¤C¡A±µµÛ°õ¦æ CPUID «ü¥O¡A°õ¦æ§¹ CPUID «á¡A¦pªG RBX ªº²Ä 18 ¦ì¤¸¬°¤@¡Aªí¥Ü¦¹ CPU ¤ä´© RDSEED «ü¥O¡FY¬°¹sªí¥Ü¤£¤ä´©¡C
RDRAND »P RDSEED «Ü¬Û¹³¡An¿ï¾Ü¨Ï¥ÎþÓ«ü¥O¡A¨Ì¾Ú¿é¥Xªº¥Øªº¹Bºâ¤¸n¥Î©ó¤°»ò¥Øªº¡C¦pªG§Æ±æ¥Øªº¹Bºâ¤¸¬O°°ÀH¾÷¼Æ¥Í¦¨¾¹¡]PRNG¡^ªºªì©lÈ¡A¨º´N¥Î RDSEED¡C¦Ó¨ä¥L¥Øªº¡A´N¨Ï¥Î RDRAND¡C
CPUID ¬O¡uCPU Identification¡vªº·N«ä¡A´N¬OÀò±o CPU ªº¦WºÙ¤Î¯S©Ê¡CnÀò¨úªº¦WºÙ©Î¯S©Ê¡A¥Ñ EAX ¨M©w¡A¥²¶·¬d¾\ CPU ¤â¥U¡C¨Ì¾Ú¤â¥U¤Wªº¬ö¸ü¡A³]©w¦n EAX ¼È¦s¾¹¡A¦A°õ¦æ CPUID¡ACPU ·|±N¦WºÙ©Î¯S©Ê©ñ¦b¬Y¨Ç¼È¦s¾¹¶Ç¦^¨Ó¡C¦¹³B¶ÈÁ| EAX ¬°¹sªº¨Ò¤l¡A¦p¹Ln¸Ô²Ó¸ê®Æ¡A½Ð¦Û¦æ¬d¾\¤â¥U¡C
·í EAX µ¥©ó 0 ¦A°õ¦æ CPUID «á¡A¦pªG¬O^¯Sº¸ªº CPU¡ACPUID ·|¶Ç¦^¨âµ§¸ê®Æ¡A²Ä¤@µ§¸ê®Æ¬O¦s©ñ¦b EAX¡A¬O CPUID ©Ò¯à±µ¨ü EAX ªº³Ì¤jÈ¡A²Ä¤Gµ§¸ê®Æ¦s©ñ¦b EBX¡BEDX¡BECX ¦@ 96 ¦ì¤¸¡A¦X°_¨Ó¥Nªí¡uGenuineIntel¡v¦r¦ê¡Aªí¥Ü»s³y¼t°Óªº¦WºÙ¦r¦ê¡C¦pªG¬O¶W·Lªº CPU¡ACPUID ·|¶Ç¦^ªº EAX ¬O°ò¥»¥\¯àªº³Ì¤jÈ¡A¶W·Lªº CPU ÁÙ¦³ÂX¥R¥\¯à¡F¥t¥~ EBX¡BEDX¡BECX ¤]¬Oªí¥Ü»s³y¼t°Óªº¦WºÙ¦r¦ê¡A¬O¡uAuthenticAMD¡v¦r¦ê¡C
¹ï©ó CPU ¬O§_¦³¤ä´© RDRAND ¤Î RDSEED «ü¥O¡A^¯Sº¸¤Î¶W·LªºÀË´ú¤è¦¡³£¬Û¦P¡C¦´Á CPU ªº CPUID «ü¥O¥i¯à¤£¤ä´©ÀË´ú RDRAND »P RDSEED «ü¥O¡A¦ý¨º¨Ç CPU ³£¬O¦è¤¸ 2010 ¦~¥Í²£ªº¡A²{¦b¤j·§¤£¦h¤F¡C
¥ý»¡ BT¡ABT ¬O bit test¡A¥i½Ķ¬°¡u¦ì¤¸´ú¸Õ¡v¡A¥ç§Y´ú¸Õ¬YӦ줸¬O¹sÁÙ¬O¤@¡C¥¦ªº»yªk¬O¡G
BT r/m16,r16 BT r/m32,r32 BT r/m64,r64 BT r/m16,imm8 BT r/m32,imm8 BT r/m64,imm8
r/m16¡Br/m32¡Br/m64 ¨Ì§Ç¥Nªí 16 ¦ì¤¸¡B32¦ì¤¸¡B64 ¦ì¤¸ªº¼È¦s¾¹©Î°O¾ÐÅéÅܼơFr16¡Br32¡Br64 ¨Ì§Ç¥Nªí 16 ¦ì¤¸¡B32¦ì¤¸¡B64 ¦ì¤¸ªº¼È¦s¾¹¡Fimm8 ¬O¥Nªí¤K¦ì¤¸ªº±`¼Æ¡]¥ß§YÈ¡^¡CBT «ü¥O·|§â²Ä¤@Ó¹Bºâ¤¸¤¤ªº¬YӦ줸½Æ»s¨ì¶i¦ìºX¼Ð¡]ÁY¼g¬O CF¡^¤¤¡Aº¸«áµ{¦¡¯àÂǥѶi¦ìºX¼Ð§PÂ_¸Ó¦ì¤¸¬O¹sÁÙ¬O¤@¡A¦Ü©ó¬O²Ä¤@Ó¹Bºâ¤¸ªºþ¤@Ӧ줸«h¥Ñ¨ä«áªº¥ß§YÈ¡]imm8¡^¨M©w¡C¨Ò¦p©³¤Uªº¨Ò¤l¡G
mov eax,1101b ;1101b¡×13¡A¨ä¤¤ªº b ¥Nªí¤G¶i¦ì
bt eax,2
EAX ¦³ 32 Ӧ줸¡A³Ì§C¦ì¤¸¬O³Ì¥kÃ䪺¦ì¤¸¡A¨ä¦WºÙ¬O²Ä¹sӦ줸¡A¥Ñ¤W±µ{¦¡½X±oª¾¨äȬ°¤@¡F³Ì°ª¦ì¤¸¬O³Ì¥ªÃ䪺¦ì¤¸¡AºÙ¬°²Ä 31 Ӧ줸¡A¤W±ªºµ{¦¡½X¨Sªí¥Ü¥X¨Ó¡CEAX ªº²Ä¤GӦ줸¬O 1¡A¬G°õ¦æ§¹¡ubt eax,2¡v¤§«á¡A¶i¦ìºX¼Ð¬° 1¡C
²Ä¤GÓ¹Bºâ¤¸¦pªG¬O¤KӦ줸ªøªº¥ß§YÈ¡A¨ä³Ì¤j¬O 255¡A¥i¯à·|¶W¹L²Ä¤@Ó¹Bºâ¤¸ªº¦ì¤¸²ÕӼơC°²¦p¶W¹Lªº¸Ü¡A¨º»ò´N°£¥H²Ä¤@Ó¹Bºâ¤¸ªº¦ì¤¸Ó¼Æ¡A¨ú¨ä¾l¼Æ¡A§@¬°·sªº¥ß§YÈ¡A¦A¶i¦æ¦ì¤¸´ú¸Õ¡C¨Ò¦p
mov eax,1110 0001 1111 0011b ;1110 0001 1111 0011b¡×57843
bt eax,227
EAX ¥u¦³ 32 Ӧ줸¡AµLªk´ú¸Õ²Ä 227 Ӧ줸¬O¹sÁÙ¬O¤@¡A©Ò¥H¶i¦æ 227 °£¥H 32 ªº¹Bºâ¡A©Ò±o¾l¼Æ¬O 3¡C¬G¡uBT EAX,227¡v¸ò¡uBT EAX,3¡v¬O¤@¼Ëªºµ²ªG¡A°õ¦æ«á¡A¶i¦ìºX¼Ð¬°¹s¡C
BTR ¬O¡ubit test and reset¡v¡ABTS ¬O¡ubit test and set¡v¡A³o¨âÓ«ü¥Oªº»yªk¤Î¹Bºâ¹Lµ{´X¥G³£»P BT ¤@¼Ë¡C®t§O¶È¦b©ó BTR ³Ì«á·|±N«ü©wªº¦ì¤¸«¸m¡]¥ç§Y³]¬°¹s¡^¡ABTS ³Ì«á·|³]©w«ü©wªº¦ì¤¸¡]¥ç§Y±N¸Ó¦ì¤¸³]¬°¤@¡^¡C
BTC ¬O¡ubit test and complement¡v¡A¥¦ªº»yªk¤Î¹Bºâ¹Lµ{¤]´X¥G³£»P BT ¤@¼Ë¡C®t§O¶È¦b©ó BTC ³Ì«á·|±N«ü©wªº¦ì¤¸¤Ï¸m¡C¥ç§Y¦pªGì¥ý«ü©wªº¦ì¤¸¬O¤@¡A¨º´N§ï¬°¹s¡F¦pªGì¥ý«ü©wªº¦ì¤¸¬O¹s¡A¨º´N§ï¬°¤@¡C
BSF ¬O¡ubit scan forward¡vªº·N«ä¡A¬O»¡©¹«e±½´y§ä¨ì¤@¡C¥ý¬Ý¬Ý BSF «ü¥Oªº»yªk¡G
BSF ¥Øªº¹Bºâ¤¸,¨Ó·½¹Bºâ¤¸
¥Øªº¹Bºâ¤¸¥u¯à¬O 16 ¦ì¤¸¡B32¦ì¤¸¡B64 ¦ì¤¸ªº¼È¦s¾¹¡F¨Ó·½¹Bºâ¤¸¥i¥H¬O¼È¦s¾¹©Î°O¾ÐÅéÅܼơA¨äªø«×¥²¶·©M¥Øªº¹Bºâ¤¸¤@P¡CBSF «ü¥O·|±q¨Ó·½¹Bºâ¤¸ªº²Ä¹s¦ì¤¸¶}©l¡A©¹°ª¦ì¤¸³B±½´y¡A§ä¨ì¦ì¤¸¤§È¬°¤@®É°±¤î¡A±N¦¹¦ì¤¸½s¸¹¡]¦b¨Ó·½¹Bºâ¤¸¤¤¬O²Ä´XӦ줸¡^°O¿ý¨ì¥Øªº¹Bºâ¤¸¤¤¡C¦pªG¨Ó·½¹Bºâ¤¸¬°¹s¡A´N§ä¤£¨ì¦ì¤¸È¬°¤@¡A¨º»ò¥Øªº¹Bºâ¤¸¤§ÈµL·N¸q¡A¦P®É¹sȺX¼Ð³Q³]¬°¤@¡F¦pªG¦³§ä¨ì¤@¡A¹sȺX¼Ð³Q²M°£¡C¶i¦ìºX¼Ð¡B·¸¦ìºX¼Ð¡B²Å¸¹ºX¼Ð³£µL·N¸q¡C
BSR ¬O¡ubit scan reverse¡vªº·N«ä¡A¥¦ªº»yªk¡B¹Bºâ¤è¦¡¡BºX¼Ð³]©w¸ò BSF ´X¥G¤@¼Ë¡A®t§O¦b©ó BSR ¬O¥Ñ³Ì°ª¦ì¤¸¶}©l±½´y¡C¬Ý©³¤Uªº¨Ò¤l¡G
mov ax,0100 0011 1111 0100b bsf bx,ax bsr cx,ax
¥Ñ AX ªº²Ä¹s¦ì¤¸¶}©l©¹°ª¦ì¤¸±½´y¡A²Ä¤@¦¸¤@¥X²{©ó²Ä¤G¦ì¤¸¡A¬G BX ¬° 2¡C¥Ñ AX ªº²Ä 15 ¦ì¤¸¶}©l©¹²Ä¹s¦ì¤¸±½´y¡A²Ä¤@¦¸¤@¥X²{©ó²Ä 14 ¦ì¤¸¡A¬G CX ¬° 14¡]CX¡×000DH¡^¡C
PeekMessage API ·|Àˬdµ{¦¡°T®§¦î¦C¡A¦pªG¦³°T®§ªº¸Ü´N©ñ¤J«ü©wªº MSG µ²ºcÅ餤¡A¨Ã¦^¶Ç«D¹sÈ¡F¦pªG¨S¦³°T®§¦^¶Ç¹sÈ¡CPeekMessage ªºì«¬¬O¡G
invoke PeekMessage,\ lpMsg,\ ; pointer to structure for message hWnd,\ ; handle to window wMsgFilterMin,\ ; first message wMsgFilterMax,\ ; last message wRemoveMsg ; removal flags
PeekMessage ªº¥Î³~¸ò GetMessage «Ü¬Û¹³¡A´N³s«e±¥|ӰѼƳ£¤@¼Ë¡G
è¤~´£¹L¡APeekMessage ¸ò GetMessage «Ü¬Û¹³¡A°Ï§O¦b©ó·í°T®§¦î¦C¸Ì¦³°T®§ªº®ÉÔ¡APeekMessage ¨ú¦^°T®§¡A¨Ã¦b RAX ¤¤¦^¶Ç«D¹sÈ¡F¨S¦³°T®§ªº®ÉÔª½±µªð¦^¡A¨Ã¦b RAX ¤¤¦^¶Ç¹sÈ¡A¤£¹³ GetMessage ·|°½°½ªº±N±±¨îÅv¥æµ¹ Windows §Q¥Î¡C
©Ò¥H¦b PeekMessage ¦^¶Ç«D¹sȪº®ÉÔ¡Aµ{¦¡Àˬd°T®§¬O§_¬O WM_QUIT¡A¦pªG¬Oªº¸Ü¡A´Nnµ²§ô°T®§°j°é¡F¦pªG¤£¬Oªº¸Ü¡A´N¥Î¼Ð·Ç¬yµ{³B²z°T®§¡F¦^¶Ç¹sȪº®ÉÔ¡Aªí¥Ü¬OªÅ¶¢®É¶¡¡Aµ{¦¡´N¥i¥H°µ¨ä¥L¤u§@¤F¡A¦ý´¡¤J°µ¨ä¥L¤u§@ªº®ÉÔ¡A°õ¦æ®É¶¡¤£¯à¹Lªø¡A¤£µM·|¼vÅT¥¿±`ªº°T®§³B²z¡A¨Ïµøµ¡ªº¤ÏÀ³Åܱo¿ð¶w¡C
¦pªGÀ³¥Îµ{¦¡·Q§Q¥ÎªÅ¶¢®É¶¡¡A¤]´N¬O»¡§Y¨Ï°T®§¦î¦CùبS¦³°T®§ªº®ÉÔ§ï§@¨ä¥L¨Æ¡A¦Ó¤£¬OÅý GetMessage «ý¤â¥æ¥XÄÝ©óÀ³¥Îµ{¦¡ªº CPU ®É¶¡¡A¨º»ò´N¤£n©I¥s GetMessage¡A§ï¥Î PeekMessage¡A°T®§°j°é¥i¥H¬O¹³¤U¦Cªº¼Ë¤l¡G
.while TRUE
invoke PeekMessage,ADDR msg,0,0,0,PM_REMOVE
.if rax
cmp msg.message,WM_QUIT
je quit
invoke TranslateMessage,ADDR msg
invoke DispatchMessage,ADDR msg
.else
;¶X¨S¦³°T®§ªº®ÉÔ¡A°µ¨ä¥L¨Æªºµ{¦¡½X¼g¦b³o¸Ì
.endif
.endw
CreateSolidBrush ¬O¥Î¨Ó«Ø¥ßÅÞ¿èµe¨ê¡AÅÞ¿èµe¨ê¥i¥H¥Î¨Ó¶îº¡¯x§Î¡B¶ê§Îµ¥¤º³¡°Ï°ì¡CCreateSolidBrush ªº»yªk¬O
invoke CreateSolidBrush,\
crColor ; brush color value
crColor ¬O 32 ¦ì¤¸ªø¼ÆÈ¡A¦ý¥u¦³ 0¡ã23 ¦ì¤¸¦³¥Î¡A¨ä¤¤ 0¡ã7 ¦ì¤¸¥Nªí¬õ¦â±j«×¡A8¡ã15 ¦ì¤¸¥Nªíºñ¦â±j«×¡A16¡ã23 ¦ì¤¸¥NªíÂŦâ±j«×¡C¥i¥H¥Î
00BBGGRR
ªí¥Ü¡C³o¤Tì¦âªº±j«×¡A³£¥H 8 Ӧ줸ªí¥Ü¡A¨CºØÃC¦â±j«×½d³ò¦b 0¡ã255 ¤§¶¡¡A¥H¤Q¤»¶i¦ìªí¥Ü¦b 0¡ãFF ¤§¶¡¡C¨Æ¹ê¤W¡A¥H³o¼Ëªí¥Üªº¸ê®ÆÃþ«¬¡A¦b Windows ¤¤ºÙ¬° COLORREF¡A¦³ÂIÃþ¦üµøµ¡¥N½X¥Î¸ê®ÆÃþ«¬ HWND ªí¥Ü¡C¦pªG crColor ¬O 0FFH ´N¥Nªí¬õ¦â¡A¦pªG crColor ¬O 0FFFFH ´N¥Nªí¶À¦â¡K¡K¡C
¦pªG¥¢±Ñ¡A¦^¶ÇȬO¹s¡F¦pªG¦¨¥\«Ø¥ßÅÞ¿èµe¨ê¡A¦^¶ÇȬOÅÞ¿èµe¨ê¥N½X¡C¤@¯ë¦Ó¨¥¡AÀ³¥Îµ{¦¡·|§âÅÞ¿èµe¨ê¥N½X«O¦s°_¨Ó¡A¦pªG¤£¥Î®É¡A´NÀ³¸Ó§R°£¡Cn§R°£ÅÞ¿èµe¨ê¡A¥i¥H©I¥s DeleteObject¡C
ȱo¤@´£ªº¬O¡Aµe¨ê¦³¨âºØÃþ«¬¡GÅÞ¿èµe¨ê©M¹êÅéµe¨ê¡CÅÞ¿èµe¨ê¬OÀ³¥Îµ{¦¡¥Î¨Ó¶îº¡¬YӧΪ¬¤º³¡°Ï°ìªº¹Ï®×¡A¥]§tÃC¦â¡B¯¾²z¡B³z©ú«×µ¥¡C¹êÅéµe¨ê«h¬O³]³ÆÅX°Êµ{¦¡®Ú¾ÚÀ³¥Îµ{¦¡ªºÅÞ¿èµe¨ê©w¸q©Ò«Ø¥ßªº¦ì¤¸¹Ï¡C
DeleteObject ¥i¥H¥Î¨Ó§R°£¹Ï§Îª«¥ó¡A¥]§tÅÞ¿èµeµ§¡BÅÞ¿èµe¨ê¡BÅÞ¿è¦r§Î¡B¦ì¤¸¹Ï¡B°Ï°ì¥H¤Î½Õ¦â½L¡A¥HÄÀ©ñ¨t²Î¸ê·½¡C·í«ü©wªº¹Ï§Îª«¥ó§R°£«á¡A¨ä¹Ï§Îª«¥ó¥N½X´N¤£¯à¦A¨Ï¥Î¤F¡C
invoke DeleteObject,\
hObject ; handle to graphic object
hObject ¬On§R°£ªº¹Ï§Îª«¥ó¥N½X¡C¦pªG¦¨¥\§R°£¹Ï§Îª«¥ó¡A¦^¶ÇȬ°«D¹s¡F¤Ï¤§¦^¶ÇȬ°¹s¡C
FillRect ¥Î«ü©wªºµe¨ê±N¤@¶ô¯x§Î°Ï°ì¶ñº¡¡A¨ä쫬¬O¡G
invoke FillRect,\ hDC,\ ; handle to device context lprc,\ ; pointer to structure with rectangle hbr ; handle to brush
¦pªG¦¨¥\°õ¦æ FillRect¡A¦^¶ÇȬ°«D¹sÈ¡A¤Ï¤§¦^¶ÇȬ°¹s¡CFillRect ¦b¯x§Î°Ï°ì¶î¦â®É¡A¤WÃä¤Î¥ªÃ䪺Ãä½u·|¤W¦â¡A¦ý¬O¤UÃä¤Î¥kÃ䪺Ãä½u¤£·|¤W¦â¡C
RNDRECT.ASM »P MS¡ÐDOS 2.00 §@·~¨t²Î©Òªþªº BASIC µ{¦¡¡AART.BAS¡A«Ü¬Û¦ü¡C¨âªÌ³£¦b¹q¸£¿Ã¹õ¤W¡AÀH¾÷¥X²{¤£¦Pªº¯x§Î¡C
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
17 18 19 20
21 22 23 24
25 26 27 28
29 30 31 32
33 34 35 36
37 38 39 40
41 42 43 44
45 46 47 48
49 50 51 52
53 54 55 56
57 58 59 60
61 62 63 64
65 66 67 68
69 70 71 72
73 74 75 76
77 78 79 80
81 82 83 84
85 86 87 88
89 90 91 92
93 94 95 96
97 98 99 100
101 102 103 104
105 106 107 108
109 110 111 112
113 114 115 116
117 118 119 120
121 122 123 124
125 126 127 128
129 130 131 132
133 134 135 136
137 138 139 140
141 142 143 144
145 146 147 148
149 150 151 152
153 154 155 |
;RNDRECT.ASM¡G¦b¿Ã¹õ¤WÅã¥Ü¤@µøµ¡¡A§Q¥Î°T®§¦î¦C¤ºµL°T®§ªºªÅ¶¢®É¶¡¡A
;©óµøµ¡¤ºÀH¾÷ø»s¥X¯x§Î¡C²ÕĶ¤è¦¡¦p¤U¡G
;SET INCLUDE=C:\UASM\Include
;SET LIB=C:\UASM\lib64
;SET PATH=C:\UASM;C:\UASM\bin64;
;SET LINK=/SUBSYSTEM:WINDOWS
;UASM64 -win64 RNDRECT.ASM
;LINK RNDRECT.OBJ
OPTION CASEMAP:NONE
OPTION WIN64:3
INCLUDE WINDOWS.INC
INCLUDELIB GDI32.LIB
INCLUDELIB KERNEL32.LIB
INCLUDELIB USER32.LIB
;*******************************************************************************
.CONST
szClassName DB "RNDRECT",0 ;µøµ¡Ãþ§O¦WºÙ
szAppName DB "¯x§Î",0
szErr DB "¿ù»~",0
szErrMsg0 DB "CPU¤£¤ä´©¡C",0
szErrMsg1 DB "µù¥Uµøµ¡Ãþ§O¥¢±Ñ¡C",0
;*******************************************************************************
.DATA
hInstance HINSTANCE ? ;¼Ò²Õ¥N½X
hWnd HWND ? ;µøµ¡¥N½X
iWidth DD ? ;¤u§@°Ï¼e«×
iHeight DD ? ;¤u§@°Ï°ª«×
;*******************************************************************************
.CODE
;-------------------------------------------------------------------------------
;check_rdrand¥Î¨ÓÀˬdCPU¬O§_¤ä´©RDRAND¡A¦pªG¤ä´©¦^¶ÇȬ°1¡F¤£¤ä´©¦^¶ÇȬ°0
check_rdrand PROC
;¦´ÁªºCPU¤£¤ä´©RDRAND«ü¥O¡A©Ò¥H¦b¨Ï¥Î«en¥ý¶i¦æÀË´ú¡G§âEAX¼È¦s¾¹³]¬°1¨Ã°õ¦æ
;CPUID«ü¥O¡A¦pªG¤ä´©RDRANDªº¸Ü¡AECX¼È¦s¾¹ªº²Ä30¦ì¤¸¦ì·|³QCPU³]¬°1¡C
mov rax,1
cpuid
bt ecx,30 ;±NECXªº²Ä30¦ì¤¸²¾¦ÜCF
mov rax,1
jc support ;¦pªGCF¡×1¡A«h¸õÅD¦Üsupport¼Ð°O³B
xor rax,rax
support: ret
check_rdrand ENDP
;-------------------------------------------------------------------------------
WndProc PROC hwnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.switch uMsg
.case WM_SIZE
mov r10,lParam
mov r11,lParam
and r10,0ffffh
shr r11,10h
mov iWidth,r10d
mov iHeight,r11d
.case WM_DESTROY
invoke PostQuitMessage,0
.default
invoke DefWindowProc,hwnd,uMsg,wParam,lParam
ret
.endsw
xor rax,rax
ret
WndProc ENDP
;-------------------------------------------------------------------------------
;»s³y¤@¶Ã¼Æ¡A¥B¤p©órange¡AµM«á¦s©óEAX«áªð¦^
get_rnd PROC range:DWORD
mov ecx,30
bsr eax,range ;¥H¤G¶i¦ìªí¥Ürange¡A³Ì°ª¦ì¤¸¬°1ªº¦b²ÄEAX¦ì¤¸
mov r11d,7fffffffh ;¨Ï²Å¸¹¦ì¤¸¬°0
sub ecx,eax ;ECX¡×R11Dªº²Å¸¹¦ì¤¸n¥k²¾¦h¤Ö¦¸
sar r11d,cl ;°õ¦æ¥k²¾CL¦¸
retry: rdrand eax
and eax,r11d
cmp eax,range
ja retry
ret
get_rnd ENDP
;-------------------------------------------------------------------------------
;µe¥X¶îº¡ÃC¦âªº¯x§Î¡A¯x§Îªº¤j¤p¡BÃC¦â¡B¦ì¸m³£¬OÀH¾÷ªº
DrawRect PROC hwnd:HWND
LOCAL hBrush:HBRUSH,hdc:HDC,rect:RECT
cmp iWidth,0
jz quit
cmp iHeight,0
jz quit
invoke get_rnd,iWidth ;¯x§Î¥ª¤W¨¤X®y¼Ð
mov rect.left,eax
invoke get_rnd,iHeight ;¯x§Î¥ª¤W¨¤Y®y¼Ð
mov rect.top,eax
invoke get_rnd,iWidth ;¯x§Î¥k¤U¨¤X®y¼Ð
mov rect.right,eax
invoke get_rnd,iHeight ;¯x§Î¥k¤U¨¤Y®y¼Ð
mov rect.bottom,eax
rdrand rcx
and rcx,0ffffffh ;ÃC¦â¤]¬OÀH¾÷¥Í¦¨ªº
invoke CreateSolidBrush,ecx
mov hBrush,rax
invoke GetDC,hwnd
mov hdc,rax
invoke FillRect,hdc,ADDR rect,hBrush
invoke ReleaseDC,hwnd,hdc
invoke DeleteObject,hBrush
quit: ret
DrawRect ENDP
;-------------------------------------------------------------------------------
main PROC
LOCAL wc:WNDCLASSEX,msg:MSG
call check_rdrand ;ÀˬdCPU¬O§_¤ä´©RDRAND
lea rdx,szErrMsg0
or rax,rax ;YRAX¡×0¡A¤£¤ä´©¡A¸õ¦Üerror:³B
jz error
invoke GetModuleHandle,0 ;¨ú±o¼Ò²Õ¥N½X
mov hInstance,rax
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
lea rdx,WndProc
mov wc.lpfnWndProc,rdx
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
mov wc.hInstance,rax
invoke LoadIcon,NULL,IDI_APPLICATION ;¨ú±o¹Ï¥Ü¥N½X
mov wc.hIcon,rax ;¦s¤J¹Ï¥Ü¥N½X
mov wc.hIconSm,rax ;¦s¤J¤p¹Ï¥Ü¥N½X
invoke LoadCursor,NULL,IDC_ARROW ;¨ú±o´å¼Ð¥N½X
mov wc.hCursor,rax ;¦s¤J´å¼Ð¥N½X
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,0
lea rdx,szClassName
mov wc.lpszClassName,rdx
invoke RegisterClassEx,ADDR wc ;µù¥Uµøµ¡Ãþ§O
lea edx,szErrMsg1
.if rax==0
error: invoke MessageBox,0,rdx,OFFSET szErr,MB_ICONERROR or MB_OK
jmp quit
.endif
invoke CreateWindowEx,0,ADDR szClassName,ADDR szAppName,WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,0,0,hInstance,0
mov hWnd,rax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke PeekMessage,ADDR msg,0,0,0,PM_REMOVE
.if rax
cmp msg.message,WM_QUIT
je quit
invoke TranslateMessage,ADDR msg
invoke DispatchMessage,ADDR msg
.else
invoke DrawRect,hWnd
.endif
.endw
quit: invoke ExitProcess,0 ;µ{¦¡µ²§ô
main ENDP
;*******************************************************************************
END main |
«e±¤jP¤w»¡©ú¹L RNDRECT.ASM ¤º®e¤F¡A©³¤U¨Ó»¡»¡´XÓ³¡¤À¡C
RNDRECT n¦b¤u§@°Ï¤º²£¥Í¤@¯x§Î¡A¯x§Îªº¦ì¸m¡A¤]´N¬O¥ª¤W¨¤»P¥k¤U¨¤ªº®y¼Ð¡A¬OÀH¾÷²£¥Íªº¡A¨º»ò¨äªø»P¼e¤]·|¬OÀH¾÷ªº¡C¦Ó x86 «ü¥O¤¤¡ARDRAND «ü¥O´N¯à²£¥Í¤@ӶüơC¦]¦¹ get_rnd °Æµ{¦¡¬OÂÇ¥Ñ RDRAND «ü¥O²£¥Í¶Ã¼Æ¡AµM«á±N¦¹¶Ã¼Æ¦s©ó EAX ¤º¶Ç¦^µ¹¥Dµ{¦¡¡C
¦ý¬O EAX ³Ì¤j¥i¹F¥|¤Q¤G»õ¡Aµøµ¡ªº¤u§@°Ï¤j¤p¸ò¿Ã¹õ¤j¤p¦³Ãö¡A¦Ó²{¦bªº¿Ã¹õªø©Î¼eªº¹³¯À¡]¥i¥H§â¹³¯À¬Ý¦¨¬OÂI¡^³£¦b¤@¸U¥H¤º¡A¥H¤p¤ì°¸ªº¹q¸£¿Ã¹õ¨Ó»¡¡A¿Ã¹õ¤j¤p¬O 1920¡Ñ1080¡A´Nºâ¦A¹L¤Q¦~¡A¤]¤£·|¦h¥X¦h¤Ö¡C¦]¦¹§Ú̧Ʊæ¥Ñ get_rnd ©ÒÀò±oªº¶Ã¼Æ¦b¤@©w½d³ò¤º¡C©Ò¥HÅý get_rnd ²K¥[¤@ӰѼơA¦¹°Ñ¼Æ¨î¦s©ó EAX ¤ºªº¶Ã¼Æn¤p©ó©Îµ¥©ó¦¹°Ñ¼Æ¡C
¨º¸Ó¦p¦ó¿ì¨ì©O¡H¤p¤ì°¸ªº·Qªk¬O§â°Ñ¼Æµø¬°¤G¶i¦ì¼Æ¡A¦b³o 32 ¦ì¤¸¤¤¡A¥Ñ³Ì°ª¦ì¤¸¡]¤]´N¬O²Ä 31 ¦ì¤¸¡^¶}©l¦V§C¦ì¤¸¡A·j´M¦bþ¤@Ӧ줸º¥ý¥X²{¤@¡A°O¿ý¨ä½s¸¹¡CÁ|¨Ò¨Ó»¡¡A°²³]°Ñ¼Æ¬O 1424¡A´«ºâ¦¨¤G¶i¦ì¬O¡u0000 0000 0000 0000 0000 0101 1001 0000¡v¡A«Ü©úÅã¡A¦b²Ä 10 ¦ì¤¸¡]¥H¬õ¦âªí¥Ü¡^¶}©l¥X²{¤@¡C§Q¥Î BSR ´N¯à¨D¥Xþ¤@Ӧ줸½s¸¹¶}©l¥X²{¤@¡C
±µ¤U¨Ó´N¬O§â¤ñ¥X²{¤@ªº³Ì°ª¦ì¤¸ÁÙn°ªªº©Ò¦³¦ì¤¸¡A³£Åܦ¨¹s¡A³o¼Ë´N¯à¹F¨ì¥Øªº¡C¨Ò¦p¦b³oÓ¨Ò¤l¡A´N¬OÅý EAX »P¡u0000 0000 0000 0000 0000 0111 1111 1111¡v°µ AND ¹Bºâ¡A´N¯à±N²Ä 11¡ã31 ¦ì¤¸³£Åܦ¨¹s¡C²{¦bªº°ÝÃDÅܦ¨¡u«ç»òpºâ¥X¡@0000 0000 0000 0000 0000 0111 1111 1111¡v¡C
§Q¥Î SHR ©Î SAR «ü¥O¡A¥i¥H±N 7FFF FFFF FFFF FFFFH ¦ì²¾¼Æ¦¸¡A´NÅܦ¨¤G¶i¦ìªº¡u0000 0111 1111 1111¡v¡]´«ºâ¦¨¤Q¤»¶i¦ì¬O 7FFH¡^¡Cn¦ì²¾´X¦¸¡AÀ³¸Ó¬On¥ÎÁ`¦@ 31 ¦ì¤¸´î¥h¥X²{¶}©l¥X²{¤@ªº¨ºÓ¦ì¤¸½s¸¹¡A¦ý¦]¬°¬O±N 7FFF FFFF FFFF FFFFH ¦ì²¾¡A²Ä 31 ¦ì¤¸¤w¸g¬O¹s¤F¡A©Ò¥HÀ³¸Ó´î¥h¤@¦¸¡A¬Gn¦ì²¾ªº¦¸¼Æ¬O 30 ´î¥h¥X²{³Ì°ª¦ì¤¸¬O¤@ªº¨ºÓ¦ì¤¸½s¸¹¡C
³Ì«á§â¥Ñ RDRAND »s³y¥X¨Óªº¶Ã¼Æ»P 7FFH °µ AND ¹Bºâ¡A¨äµ²ªG¤´¥i¯à¤j©ó range¡A¦]¦¹ÁÙ»Ýn°µ¤ñ¸û¡C¦pªG¤j©ó´N±o«·s¥Ñ RDRAND »s³y·sªº¶Ã¼Æ¶}©l¡A«·s¦A¨Ó¤@¹M¡A¦ý³oºØ¾÷²v¤w¸g¤p¤F³\¦h¡C
³o¬q get_rnd °Æµ{¦¡¦bì©lµ{¦¡ªº²Ä 65¡ã77 ¦æ¡C
¹Ï§Îª«¥ó¤]¥iºÙ¬° GDI ª«¥ó¡A¥]§t¤Fµeµ§¡Bµe¨ê¡B¦r§Î¡B¦ì¤¸¹Ï¡B°Ï°ì¥H¤Î½Õ¦â½Lµ¥µ¥¡Cµeµ§¥Î¨Óø»s½u±ø¡Bµe¨ê¨Ó¶îº¡°Ï°ì¡B¦r§Î¨Óø»s¤å¦r¡C³o¨Ç¹Ï§Îª«¥óªº¨Ï¥Î¤èªk¤jP¨BÆJ¦p¤U¡G
³o¬q¹Lµ{³q±`¬Oµo¥Í¦b³B²z WM_PAINT °T®§®É¡A¦b©I¥s BeginPaunt ¤§«á¡A©M©I¥s EndPaint ¤§«e¡C¦pªGn¦b¨ä¥L°T®§¤¤Ã¸»s¹Ï§Î¡A¨º»ò¥i¥H¦b©I¥s GetDC ¤§«á¡A¶i¦æ¤W±ªº¥|Ó¨BÆJø»s¹Ï§Î¡AµM«á©I¥s ReleaseDC µ²§ôø»s¡C
RNDRECT §Q¥Î¨S¦³°T®§¶Ç¤Jµøµ¡¨ç¦¡ªºªÅ¶¢®É¶¡Ã¸»sÀH¾÷¯x§Î¡A¥unµ{¦¡ÁÙ¨Sµ²§ô¡A´N¯à¤@ª½Ã¸»s¹Ï§Î¡CÁÙ¦³¤@ºØ¤èªk¤]¥i¥H¹F¨ìµ{¦¡¨Sµ²§ô´N¯à¤@ª½Ã¸»s¹Ï§Îªº®ÄªG¡A¨º´N¬O«Ø¥ßp®É¾¹¡A¦ý¬O³o¬O¤U¤@³¹ªº¥DÃD¡C