;_________________________________________________________________________________________________ ; ; ; Heinz - Volker Viehof ; Assembler Test - , Demo - und Beispieldateien ; Erzeug Fenster und Button , fängt WM_MESSAGE ab ;_________________________________________________________________________________________________ .386 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD RegisterWinClass PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD MsgLoop PROTO :DWORD Static PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD ;_________________________________________________________________________________________________ ; ; Daten (initialisiert) ; ;_________________________________________________________________________________________________ .data fehler db "Hexadezimalwert : ",0 db "Fehlernummer :",0 hexvalues db "0123456789ABCDEF" description db "Handle :,Message :,wParam :,lParam :,time :,cursorpos. :#" szCaption db"HVV Assembler Fenster Demo",0 szClassName db"My_Class",0 szText7 db "--Test--",0 szText10 db "Heinz - Volker Viehof ",10,13,"Test - und DemoSoftware",0 btnClass db "BUTTON",0 btnClass3 db "STATIC" ;_________________________________________________________________________________________________ ; ; nicht initialisierte Daten ; ;_________________________________________________________________________________________________ .data? hInstance dd ? hIcon dd ? hCursor dd ? hWnd dd ? hbutt dd ? hSelf dd ? myPointer dd ? puffer db 1000 dup (?) kommas dd ? lesezeiger dd ? merker db ? ;_________________________________________________________________________________________________ ; ; Programm (Hauptteil) ; ;_________________________________________________________________________________________________ .code start: call Init call Main invoke ExitProcess,eax ;_________________________________________________________________________________________________ ; ; Subroutinen ; ;_________________________________________________________________________________________________ Init proc invoke GetModuleHandle, NULL mov hInstance, eax invoke LoadIcon,hInstance,IDI_APPLICATION mov hIcon, eax invoke LoadCursor,NULL,IDC_ARROW mov hCursor, eax ret Init endp Main proc LOCAL Wwd:DWORD,Wht:DWORD,Wtx:DWORD,Wty:DWORD mov Wtx,10 ;x koordinate oben links mov Wty,10 ;y koordinate oben links mov Wwd,280 ;+x= unten rechts mov Wht,200+100 ;+y= unten rechts invoke RegisterWinClass,ADDR WndProc,ADDR szClassName,hIcon,hCursor,COLOR_BTNFACE+3 invoke CreateWindowEx,WS_EX_CONTEXTHELP,ADDR szClassName,ADDR szCaption, WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,hInstance,NULL mov hWnd,eax invoke Static,ADDR szText10,hWnd,40,20,180,40,500 invoke PushButton,ADDR szText7,hWnd,40,80,180,25,600 mov hSelf,eax invoke ShowWindow,hWnd, SW_SHOWNORMAL invoke UpdateWindow,hWnd invoke MsgLoop,0 ;hSelf ret Main endp m2m MACRO M1, M2 push M2 pop M1 ENDM ;_________________________________________________________________________________________________ ; ; andere Unterprogramme ; ;_________________________________________________________________________________________________ RegisterWinClass proc lpWndProc:DWORD,lpClassName:DWORD,Icon:DWORD,Cursor:DWORD, bColor:DWORD LOCAL wc:WNDCLASSEX mov wc.cbSize, sizeof WNDCLASSEX mov wc.style, CS_BYTEALIGNCLIENT or CS_BYTEALIGNWINDOW m2m wc.lpfnWndProc, lpWndProc mov wc.cbClsExtra, NULL mov wc.cbWndExtra, NULL m2m wc.hInstance, hInstance m2m wc.hbrBackground, bColor mov wc.lpszMenuName, NULL m2m wc.lpszClassName, lpClassName m2m wc.hIcon, Icon m2m wc.hCursor, Cursor m2m wc.hIconSm, Icon invoke RegisterClassEx,ADDR wc ret RegisterWinClass endp ;_________________________________________________________________________________________________ ; ; Message Loop ;_________________________________________________________________________________________________ MsgLoop proc hMSG:DWORD LOCAL msg:MSG StartLoop: call analyse_init invoke GetMessage,ADDR msg,0,0,0 .if eax == 0 jmp ExitLoop .endif invoke GetMessage,ADDR msg,hMSG,0,0 ;.if eax == WM_COMMAND .if msg.wParam != 0200h ;.if msg.lParam == 1h .if msg.message == 0201h call sound .endif ;.endif mov eax,msg.hwnd call analyse_main mov eax,msg.message call analyse_main mov eax,msg.wParam call analyse_main mov eax,msg.lParam call analyse_main mov eax,msg.time call analyse_main ;mov eax,msg.pt ;call analyse_main mov edi,dword ptr[myPointer] mov al,0 stosb call Display .endif invoke DispatchMessage ,ADDR msg jmp StartLoop ExitLoop: mov eax, msg.wParam ret MsgLoop endp ;_________________________________________________________________________________________________ WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD .if uMsg == WM_DESTROY invoke PostQuitMessage,NULL mov eax, 0 ret .endif invoke DefWindowProc,hWin,uMsg,wParam,lParam ret WndProc endp ;_________________________________________________________________________________________________ PushButton proc lpText:DWORD,hParent:DWORD, a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,ID:DWORD invoke CreateWindowEx,0, ADDR btnClass,lpText, WS_CHILD or WS_VISIBLE or BS_PUSHBUTTON or BS_NOTIFY, a,b,wd,ht,hParent,ID, hInstance,NULL ret PushButton endp ;_________________________________________________________________________________________________ ; ; transfer , hexchange und Display ; ;_________________________________________________________________________________________________ analyse_init proc mov dword ptr[myPointer],offset puffer mov dword ptr[lesezeiger],offset description mov byte ptr[merker],0 mov byte ptr[kommas],0 ret analyse_init endp analyse_main proc push eax call transfer pop eax call hexchange ret analyse_main endp transfer proc mov edi,dword ptr[myPointer] mov esi,dword ptr[lesezeiger] T1: lodsb .if al == "," inc byte ptr[kommas] mov dword ptr[myPointer],edi mov dword ptr[lesezeiger],esi ret .elseif al == "#" mov dword ptr[myPointer],edi mov dword ptr[lesezeiger],esi mov byte ptr[merker],1 ret .endif stosb jmp T1 transfer endp hexchange proc push eax rol eax,4 mov ecx ,8 cld mov edi ,dword ptr[myPointer] X1: push eax and eax ,0fh mov ebx ,eax mov al ,byte ptr[ebx+offset hexvalues] stosb pop eax rol eax,4 loop X1 mov al,10 stosb mov al,13 stosb mov dword ptr[myPointer],edi pop eax ret hexchange endp Display proc invoke Static,ADDR puffer,hWnd,40,120,180,100,501 invoke UpdateWindow,hWnd ret Display endp sound proc invoke Beep ,1000,50 ret sound endp ;_________________________________________________________________________________________________ Static proc lpText:DWORD,hParent:DWORD, a:DWORD,b:DWORD,wd:DWORD,ht:DWORD,ID:DWORD invoke CreateWindowEx,WS_EX_STATICEDGE, ADDR btnClass3,lpText, WS_CHILD or WS_VISIBLE, a,b,wd,ht,hParent,ID, hInstance,NULL ret Static endp end start