: ,    Windows : ,    Windows
: ,    Windows  
 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 
 • 




: , Windows

Windows

: ..

.-923:

2001.

1. Windows.

2. Windows-

3.

4. Windows

5.

Windows , , C/C++, Pascal. ? , ! . . , , : , , : , , - ! , . , . , . Windows- ? :

;

. , , ;

;

, , , ;

, , , , . , , . , , . , . , .

1. Windows.

Windows :

(API), (GUI, Graphic User Interface). , . . , , ;

Windows , .

Windows- , . Windows-. Windows- , Windows. , , Windows-, .

Windows :

;

;

.

Windows- . , () Windows. . . . , . , , , . , Windows-, , .

Windows- .data . code. Windows- . Windows , . def. 2 . er , .

2. Windows-

<1> ; Win32

<2> .386

<3> locals ;

<4> .model flat, STDCALL ; flat

<5> ;STDCALL - ( ),

<6> ;

<7> include windowA.inc ;

; Win32

<8> ; Win32 (ASCII):

<9> extrn GetModuleHandleA:PROC

<10> extrn GetVersionExA:PROC

<11> extrn GetCommandLineA:PROC

<12> extrn GetEnvironmentStringsA:PROC

<13> extrn GetEnvironmentStringsA:PROC

<14> extrn GetStartupInfoA:PROC

<15> extrn LoadIconA:PROC

<16> extrn LoadCursorA:PROC

<17> extrn GetStockObject:PROC

<18> extrn RegisterClassExA:PROC

<19> extrn CreateWindowExA:PROC

<20> extrn ShowWindow:PROC

<21> extrn UpdateWindow:PROC

<22> extrn GetMessageA:PROC

<23> extrn TranslateMessage:PROC

<24> extrn DispatchMessageA:PROC

<25> extrn ExitProcess:PROC

<26> extrn PostQuitMessage:PROC

<27> extrn DefWindowProcA:PROC

<28> extrn PlaySoundA:PROC

<29> extrn ReleaseDC:PROC

<30> extrn TextOutA:PROC

<31> extrn GetDC:PROC

<32> extrn BeginPaint:PROC

<33> extrn EndPaint:PROC

<34> ; ,

<35> public WindowProc

<36> .data

<37> hwnd dd 0

<38> hInst dd 0

<39> hdc dd 0

<40> ;lpVersionInformation OSVERSIONINFO <?>

<41> wcl WNDCLASSEX <?>

<42> message MSG <?>

<43> ps PAINTSTRUCT <?>

<44> szClassName db ' Win32 ',0

<45> szTitleName db ' Win32 '.0

<46> MesWindow db '

?'

<47> MesWindowLen= $-MesWindow

<48> playFileCreate db 'create.wav',0

<49> playFilePaint db 'paint.wav',0

<50> playFileDestroy db 'destroy.wav',0

<51> . code

<52> start proc near

<53> ; :

<54> ;

<55> ; ,

<56> :

<57> ; BOOL GetVersionEx(LPOSVERSIONINFO lpVersionInformation)

<58> ; push offset lpVersionInformation

<59> ; call GetVersionExA

<60> ; Windows

<61> ; LPTSTR GetCommandLine(VOID) -

<62> ; call GetCommandLineA :

<63> ; LPVOID GetEnvironmentStrings (VOID) -

;

<64> ; call GetEnvironmentStringsA ;

<65> ; VOIDGetStartupInfo(LPSTARTUPINFO lpStartupInfo) ;

; STARTUPINFO

<66> ; push offset lpStartupInfo

<67> ; call GetStartupInfoA

<68> ; HMODULE GetModuleHandleA (LPCTSTR lpModuleName)

<69> push NULL ;0->GetModuleHandle

<70> call GetModuleHandleA ; ,

<71> mov hInst, eax ;no .

<72> ; hInst

<73> ;

<74> WinMain:

<75>; ATOM RegisterClassEx(CONST WNDCLASSEX *lpWndClassEx),

<76> ; *lpWndClassEx - WndClassEx

<77> ; WndClassEx

<78> mov wcl.cbSize,typeWNDCLASSEX -.

: wcl.cbCIZE

<79> mov wcl.style,CS_HREDRAW+CS_VREDRAW

<80> mov wcl.pfnWndProg,offsetWindowProg ;

<81> mov wcl.cbCisExtra,0

<82> mov wcl.cbWndExtra,0

<83> mov eax,hInst

<84> mov ; hInstance wcl

<85> mov wcl.hInstance, eax

<86> ; HICON LoadIcon (HINSTANCE hInstance, LPCTSTR lpIconName)

<87> push IDI_APPLICATION ,-

<88> push 0 ;NULL

<89> LoadIconA

<90> mov wcl.hIcon, eax ,- hIcon I

; wcl

<91> ; HCURSOR LoadCursorA (HINSTANCE hInstance, LPCTSTR M ;lpCursorName)

<92> push IDC_ARROW ,- -

<93> push 0

<94> ll LoadCursorA

<95> mov wcl.hCursor,eax ; hCursor

; wc1

<96> ; -

<97> ; HGDIOBJ GetStockObject(int fnObject)

<98> push WHITE_BRUSH

<99> GetStockObject

<100> mov wcl.hbrBackground, eax

<101> mov dword ptrwcl.lpszMenuName, 0 ;

<102> mov dwordptrwcl.lpszClassName,offsetszC1assName;

; ࠠ

<103> mov wcl.hIconSm, 0

<104> ; - RegisterClassExA (&wndclass)

<105> push offset wcl

<106> RegisterClassExA

<107> test ax, ;

<108> jz end_cyc1_msg ;

<109> ; :

<110> ; HWND CreateWindowExA(DWORDdwExStyle,

LPCTSTR1pClassName,

<111> ; LPCTSTR 1pW1ndowName, DWORD dwStyle, int x, int , int nWidth,

|;int nHeight,

<112> ; HWND hWndParent, HMENU hMenu, HANDLE hInstance, LPVOID

;lpParam)

<113> push 0 ;lpParam

<114> push hInst ;hInstance

<115> push NULL ;menu

<116> push NULL ;parent hwnd

<117> push CW_USEDEFAULT ;

<118> push CW_USEDEFAULT ;

<119> push CW_USEDEFAULT ;

;

<120> push CW_USEDEFAULT ;

<121> push WS_OVERLAPPEDWINDOW ;

<122> push offset szTitleName ;

<123> push offset szClassName ;

<124> push NULL

<125> ll CreateWindowExA

<126> mov hwnd,eax ;-

<127> ; :

<128> ; BOOL ShowWindow( HWND hWnd, int nCmdShow )

<129> push SW_SHOWNORMAL

<130> push hwnd

<131> call ShowWindow

<132> ;

<133> ; BOOL UpdateWindow( HWND hWnd )

<134> push hwnd

<135> call UpdateWindow

<136> ; :

<137> ; BOOL GetMessageA( LPMSG lpMsg, HWND hWnd,

<138> ; UINTwMsgFilterMin,UINTwMsgFilterMax)

<139> cycl_msg:

<140> push 0

<141> push 0

<142> push NULL

<143> push offset message

<144> cal 1 GetMessageA

<145> cmp , 0

<146> je end_cycl_msg

<147> ;

<148> ; BOOL Trans1ateMessage( CONST MSG *lpMsg )

<149> push offset message

<150> call TranslateMessage

<151> ;

<152> ; LONG D1spatchMessage( CONST MSG *lpmsg )

<153> push offset message

<154> call DispatchMessageA

<155> jmp cycl_msg

<156> end_cycl_msg:

<157>

<158> ;

<159> ; VOID ExitProcess( UINT uExitCode )

<160> push NULL

<161> call ExitProcess

<162> start endp

<163> ; - - - - - - - - - - - - --WindowProc-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

<164> WindowProc proc

<165> argP0nwnd:DWORD, PPmes:DWORD, @@wparam:DWORD, @@lparam:DWORD

<166> uses ebx, edi, es1 ;

<167> local @@hdc:DWORD

<168> cmp @@mes, WM_DESTROY

<169> je wmdestroy

<170> cmp @@mes, WM_CREATE

<171> je wmcreate

<172> cmp @@mes, WM_PAINT

<173> je wmpaint

<174> jmp default

<175> wmcreate:

<176> ;

<177> ; BOOL PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD

;fdwSound )

<178> push SND_SYNC+SND_FILENAME

<179> push NULL

<180> push offset playFileCreate

<181> call PlaySoundA

<182> mov eax, ; - 0

<183> jmp exit_wndproc

<184> wmpaint:

<185> push SND_SYNC+SND_FILENAME

<186> push NULL

<187> push offset playFIilePaint

<188> call P1aySoundA

<189>; HDC BeginPaint(HWND nwnd,LPPAINTSTRUCT;LPpAINT)

<190> push offset ps

<191> push @@hwnd

<192> call BeginPaint

<193> mov @@hdc,eax

<194> ; BOOL TextOut( HDC hdc. int nXStart, int

:nYStart.

<195> ; LPCTSTR lpString, int cbString )

<196> push MesWindowLen

<197> push offset MesWindow

<198> push 100

<199> push 10

<200> push @@hdc

<201> call TextOutA

<202> :ocoooecBOOLEndPaint( HWNDhWnd, CONSTPAINTSTRUCT*lpPai <203> push offset ps

<204> push @@hdc

<205> call EndPaint

<206> mov ,0; -0

<207> jmp exit_wndproc

<208> wmdestroy:

<209> push SND_SYNC+SND_FILENAME

<210> push NULL

<211> push offset playFileDestroy

<212> call PlaySoundA

<213> ; W_QUI

<214> ; VOID PostQuitMessage( int nExitCode )

<215> push 0

<216> call PostQuitMessage

<217> mov eax, ; - 0

<218> jmp exit_wndproc

<219> default:

<220> ;

<221>; LRESULTDefWindowProc( HWND hWnd, UINTMsg,

<222> ; WPARAMwParam,LPARAMlParam)

<223> push @@lparam

<224> push @@wparam

<225> push @@mes

<226> push @@nwnd

<227> call DefWindowProcA

<228> jmp exit_wndproc

<229> ;... ... ...

<230> exit_wndproc:

<231> ret

<232> WindowProc endp

<233> end start

3.

Windows Assembler , .

32- , Create Window.

Window.

1 . . WS_OVERLAPPED.

2 . . WS_POPUP.

3 . . . WS_CHILD.

, Windows .

:

.

; , , .

/ / . WND, , . , . HWND "" USER, , . , USER, .1.

- , . :

USER , . USER , hWndChild hWndNext- , "" USER.

Tab ( ), ( hWndNext) . , hWndChild hWndNext Z- . Z- ( ). ;

Z-, hWndNext .


..1 , USER.

, , , , ().

desktop-. Z-. , . Desktop- , , . (- .) "" Windows.

Desktop- .. ( ) WS_POPUP WS_CLIPCHILDREN. WS_DESKTOP. desktop- USER HWndDesktop. , desktop-, HWND, , HWndDesktop. HWndDesktop, API- GetDesktopWindow().

Windows

/. Windows . , , . /, . -, , .

- , , . , WS_POPUP TrackPopupMenu(), . WM_COMMAND, . , . / , , , , , .

WS_CHILD. WS_CHILD HWND WND , . , . , , .. . , ws_child-okhb hWndOwner , hWndParenfc, . Presentati

on Manager WS_CHILD WS_POPUP. hWndPa-rent, hWndOwner. , , . Presentation Manager hWndParent hWndOw-ner HWND.

, , , -. , , . - , , , . , , / HWND , .

, Windows . SDK , , /. Presentation Manager OS/2 , -. Windows .

CreateWindow() HWND , Windows? CreateWindow() . WS_CHILD, hWndParent . , WS_OVERLAPPED WS_POPUP, hWndParent HWND, . WS_OVERLAPPED WS_POPUP HWND desktop- (HWndDes

ktop).

3. Windows

p386; i 386

jumps;

; , ;

model flat,STDCALL; 32- ; STDCALL,

UNICODE = 0

include win32.inc;,

; some 32-bit constants and structures

L equ <LARGE>; LARGE, , 32-, L

Define the external functions we will be linking to

;

extrn BeginPaint:PROC; Windows

extrn CreateWindowExA:PROC

extrn DefWindowProcA:PROC

extrn DispatchMessageA:PROC

extrn EndPaint:PROC

extrn ExitProcess:PROC

extrn GetMessageA:PROC

extrn GetModuleHandleA:PROC

extrn GetStockObject:PROC

extrn InvalidateRect:PROC

extrn LoadCursorA:PROC

extrn LoadIconA:PROC

extrn MessageBeep:PROC

extrn MessageBoxA:PROC

extrn PostQuitMessage:PROC

extrn RegisterClassA:PROC

extrn ShowWindow:PROC

extrn SetWindowPos:PROC

extrn TextOutA:PROC

extrn TranslateMessage:PROC

extrn UpdateWindow:PROC

extrn FindFirstFileA:PROC

.data; ,

newhwnd dd 0

lppaint PAINTSTRUCT <?>

msg MSGSTRUCT <?>

wc WNDCLASS <?>

hInst dd 0

szTitleName db ' ',0

szTitleName1 db ' -923',0 ;' Win32 '.0

szClassName db 'ASMCLASS32',0 ;' Win32

Buffer db ' !',0

new1hwnd dd 0

MSG_L EQU 14

.code

start:

push L 0

call GetModuleHandleA ; get hmod (in eax)

mov [hInst], eax ; hInstance is same as HMODULE

; in the Win32 world

reg_class:

;

; initialize the WndClass structure ; WndClass

;

mov [wc.clsStyle], CS_HREDRAW + CS_VREDRAW + CS_GLOBALCLASS; ;

mov [wc.clsLpfnWndProc], offset WndProc;

mov [wc.clsCbClsExtra], 0

mov [wc.clsCbWndExtra], 0

mov eax, [hInst]

mov [wc.clsHInstance], eax ;

push L IDI_APPLICATION;

push L 0

call LoadIconA

mov [wc.clsHIcon], eax

push L IDC_ARROW

push L 0

call LoadCursorA

mov [wc.clsHCursor], eax

mov [wc.clsHbrBackground], COLOR_WINDOW + 1

mov dword ptr [wc.clsLpszMenuName], 0

mov dword ptr [wc.clsLpszClassName], offset szClassName

push offset wc

call RegisterClassA

push L 0 ; lpParam

push [hInst] ; hInstance

push L 0 ; menu

push L 0 ; parent hwnd

push L CW_USEDEFAULT ; height

push L CW_USEDEFAULT ; width

push L CW_USEDEFAULT ; y

push L CW_USEDEFAULT ; x

push L WS_OVERLAPPEDWINDOW ; Style

push offset szTitleName ; Title string

push offset szClassName ; Class name;

push L 0 ; extra style

call CreateWindowExA

mov [newhwnd], eax

push L SW_SHOWNORMAL

push [newhwnd]

call ShowWindow

push [newhwnd]

call UpdateWindow

push L 0 ; lpParam

push [hInst] ; hInstance

push L 0 ; menu

push L [newhwnd] ; parent hwnd

push L CW_USEDEFAULT ; height

push L CW_USEDEFAULT ; width

push L CW_USEDEFAULT ; y

push L CW_USEDEFAULT ; x

push L WS_OVERLAPPEDWINDOW ; Style

push offset szTitleName1 ; Title string

push offset szClassName ; Class name

push L 0 ; extra style

call CreateWindowExA

mov [new1hwnd], eax

push L SW_SHOWNORMAL

push [new1hwnd]

call ShowWindow

push [new1hwnd]

call UpdateWindow

msg_loop:

push L 0

push L 0

push L 0

push offset msg

call GetMessageA

cmp ax, 0

je end_loop

push offset msg

call TranslateMessage

push offset msg

call DispatchMessageA

jmp msg_loop

end_loop:

push [msg.msWPARAM]

call ExitProcess

; we never get to here

;

;-----------------------------------------------------------------------------

WndProc proc uses ebx edi esi, hwnd:DWORD, wmsg:DWORD,\

wparam:DWORD, lparam:DWORD

;

; WARNING: Win32 requires that EBX, EDI, and ESI be preserved! We comply

; with this by listing those regs after the 'uses' statement in the 'proc'

; line. This allows the Assembler to save them for us.

;

LOCAL hDC:DWORD

cmp [wmsg], WM_DESTROY

je wmdestroy

cmp [wmsg], WM_SIZE

je wmsize

cmp [wmsg], WM_CREATE

je wmcreate

cmp [wmsg],WM_PAINT

je wmpaint

jmp defwndproc

wmcreate:

mov eax, 0

jmp finish

defwndproc:

push [lparam]

push [wparam]

push [wmsg]

push [hwnd]

call DefWindowProcA

jmp finish

wmdestroy:

push L 0

call PostQuitMessage

mov eax, 0

jmp finish

wmsize:

mov eax, 0

jmp finish

wmpaint:

push offset lppaint

push [hwnd]

call BeginPaint

mov [hDC],eax

push L 17

; push ecx

push offset Buffer

push L 5

push L 5

push [hDC]

call TextOutA

push offset lppaint

push [hwnd]

call EndPaint

mov eax,0

jmp finish

finish:

ret

WndProc endp

;-----------------------------------------------------------------------------

public WndProc

end start

1. Turbo Assembler / .. . : , 1995.

2. . Windows ( Win32 API Windows

NT 3.5 Windows 95) . . .: Π Channel Trading Ltd, 1995.

3. .. Assembler. DOS, Windows Unix. . : . 1999.



      ©2010