Hi,
wie kann ich die Parameter, die an mein MASM32-Programm übergeben wurden, auslesen?
Vielen Dank für jede Antwort!
Parameter an Masm32-Programm übergeben
Moderatoren: crack, Krüsty, Marwin
- crack
- Administrator
- Beiträge: 280
- Registriert: Dienstag 21. Dezember 2004, 15:02
- Wohnort: 53783 Eitorf
- Kontaktdaten:
Hm, zum Austesten hab ich hier mal'n Beispiel 'zusammengeschustert' 
.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,:DWORD
RegisterWinClass PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
Static PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
MsgLoop PROTO :DWORD,:DWORD
.data
szClassName db "My_Class",0
slStatic db "STATIC",0
btnClass db "BUTTON",0
szEnde db "--Ende--",0
szCaption db "Kommandozeile : ",0
.data?
hInstance dd ?
hIcon dd ?
hCursor dd ?
hWnd dd ?
hEnde dd ?
.code
start:
call Main
invoke ExitProcess,eax
;-----------------------------------------------------------------
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,360 ;+x= unten rechts
mov Wht,160 ;+y= unten rechts
invoke RegisterWinClass,ADDR WndProc,ADDR szClassName,hIcon,hCursor,COLOR_BTNFACE+1
invoke CreateWindowEx,WS_EX_TOOLWINDOW,ADDR szClassName,ADDR szCaption, WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,hInstance,NULL
mov hWnd,eax
invoke PushButton,ADDR szEnde,hWnd,100,100,80,24,720
mov hEnde,eax
invoke GetCommandLine
invoke Static,eax,20,10,320,80,hWnd,730
invoke ShowWindow,hWnd, SW_SHOWNORMAL
invoke UpdateWindow,hWnd
invoke MsgLoop,0,hEnde
invoke ExitProcess,eax
ret
Main endp
;---------------------------------------------------------------
m2m MACRO M1, M2
push M2
pop M1
ENDM
;---------------------------------------------------------------
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 or CS_NOCLOSE
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
MsgLoop proc hMSG:DWORD,hENDE:DWORD
LOCAL msg:MSG
StartLoop:
invoke GetMessage,ADDR msg,0,0,0
.if eax == 0
jmp ExitLoop
.elseif msg.message == 0201h
mov ecx,hENDE
.if msg.hwnd == ecx
jmp ExitLoop
.endif
.endif
invoke UpdateWindow ,hWnd
invoke DispatchMessage ,ADDR msg
jmp StartLoop
ExitLoop:
mov eax, msg.wParam
ret
MsgLoop endp
WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD,hDOIT:DWORD
LOCAL msg:MSG
.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
Static proc szMsg:DWORD,a:DWORD,b:DWORD,
wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR slStatic,szMsg,
WS_VISIBLE or WS_CHILDWINDOW or SS_LEFT, \
a,b,wd,ht,hParent,ID,hInstance,NULL
ret
Static endp
end start
.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,:DWORD
RegisterWinClass PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD
Static PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
PushButton PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
MsgLoop PROTO :DWORD,:DWORD
.data
szClassName db "My_Class",0
slStatic db "STATIC",0
btnClass db "BUTTON",0
szEnde db "--Ende--",0
szCaption db "Kommandozeile : ",0
.data?
hInstance dd ?
hIcon dd ?
hCursor dd ?
hWnd dd ?
hEnde dd ?
.code
start:
call Main
invoke ExitProcess,eax
;-----------------------------------------------------------------
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,360 ;+x= unten rechts
mov Wht,160 ;+y= unten rechts
invoke RegisterWinClass,ADDR WndProc,ADDR szClassName,hIcon,hCursor,COLOR_BTNFACE+1
invoke CreateWindowEx,WS_EX_TOOLWINDOW,ADDR szClassName,ADDR szCaption, WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,hInstance,NULL
mov hWnd,eax
invoke PushButton,ADDR szEnde,hWnd,100,100,80,24,720
mov hEnde,eax
invoke GetCommandLine
invoke Static,eax,20,10,320,80,hWnd,730
invoke ShowWindow,hWnd, SW_SHOWNORMAL
invoke UpdateWindow,hWnd
invoke MsgLoop,0,hEnde
invoke ExitProcess,eax
ret
Main endp
;---------------------------------------------------------------
m2m MACRO M1, M2
push M2
pop M1
ENDM
;---------------------------------------------------------------
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 or CS_NOCLOSE
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
MsgLoop proc hMSG:DWORD,hENDE:DWORD
LOCAL msg:MSG
StartLoop:
invoke GetMessage,ADDR msg,0,0,0
.if eax == 0
jmp ExitLoop
.elseif msg.message == 0201h
mov ecx,hENDE
.if msg.hwnd == ecx
jmp ExitLoop
.endif
.endif
invoke UpdateWindow ,hWnd
invoke DispatchMessage ,ADDR msg
jmp StartLoop
ExitLoop:
mov eax, msg.wParam
ret
MsgLoop endp
WndProc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD,hDOIT:DWORD
LOCAL msg:MSG
.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
Static proc szMsg:DWORD,a:DWORD,b:DWORD,
wd:DWORD,ht:DWORD,hParent:DWORD,ID:DWORD
invoke CreateWindowEx,WS_EX_CLIENTEDGE,ADDR slStatic,szMsg,
WS_VISIBLE or WS_CHILDWINDOW or SS_LEFT, \
a,b,wd,ht,hParent,ID,hInstance,NULL
ret
Static endp
end start
mit freundlichen grüssen,
with best regards,
crack
with best regards,
crack