iscalibar
Messages postés15Date d'inscriptionvendredi 22 juin 2007StatutMembreDernière intervention27 mars 2009
-
26 déc. 2007 à 23:04
ToutEnMasm
Messages postés587Date d'inscriptionjeudi 28 novembre 2002StatutMembreDernière intervention13 décembre 2022
-
27 déc. 2007 à 20:24
Bonjour, j'ai un petit probleme, j'ai ecris un program pour le compilateur masm32 qui ne fai que afficher une fenetre, mai malheureusement ça marche pa, voila le code:
----------------------------------------------------
.386p
.model flat, stdcall
progName db 'Ich Bin HStein',0
szMainClass db 'ASMWINDOW',0
marchtitle db 'Box',0
marchbody db 'Ich marche bien',0
.CODE
start:
push 0
call [mailto:GetModuleHandleA@4 GetModuleHandleA@4]
mov [hInst],eax
WndProc proc
push ebp
mov ebp,esp
push ebx
push esi
push edi
cmp dword ptr [ebp+0ch],WM_DESTROY
je wmdestroy
cmp dword ptr [ebp+0ch],WM_CREATE
je wmcreate
push dword ptr [ebp+014h]
push dword ptr [ebp+010h]
push dword ptr [ebp+0ch]
push dword ptr [ebp+08h]
call [mailto:DefWindowProcA@16 DefWindowProcA@16]
jmp finish
wmcreate:
mov eax,0
jmp finish
wmdestroy:
push 0
call [mailto:PostQuitMessage@4 PostQuitMessage@4]
xor eax,eax
finish:
pop edi
pop esi
pop ebx
pop ebp
ret 16
WndProc endp
end start
----------------------------------
la fenetre ne s'affiche pa ,aide moi a trouver le probleme et la solution svp
iscalibar
Messages postés15Date d'inscriptionvendredi 22 juin 2007StatutMembreDernière intervention27 mars 2009 27 déc. 2007 à 11:42
Ben, mon code est extrait d'un example, ben voila le code source de l'example (ben je sais qu'il y a une erreur mai je ne la voi pa, je veu seuelement savoir ou est l'erreur), voila le code source de l'example:
-------------------------------------------------------
.386P
; Flat memory model
.MODEL FLAT, stdcall
; Constants
; The message arrives when the window is closed
WM_DESTROY equ 2
; The message arrives when the window is created
WM_CREATE equ 1
; The message arrives if the left mouse button is clicked
; somewhere in the window area
WM_LBUTTONDOWN equ 201h
; The message arrives if the right mouse button is clicked
; somewhere in the window area
WM_RBUTTONDOWN equ 204h
; Window properties
CS_VREDRAW equ 1h
CS_HREDRAW equ 2h
CS_GLOBALCLASS equ 4000h
WS_OVERLAPPEDWINDOW equ 000CF0000H
Style equ CS_HREDRAW+CS_VREDRAW+CS_GLOBALCLASS
; Standard icon identifier
IDI_APPLICATION equ 32512
; Cursor identifier
IDC_CROSS equ 32515
; Normal mode of displaying the window
SW_SHOWNORMAL equ 1
; Prototypes of external procedures
EXTERN MessageBoxA@16:NEAR
EXTERN CreateWindowExA@48:NEAR
EXTERN DefWindowProcA@16:NEAR
EXTERN DispatchMessageA@4:NEAR
EXTERN ExitProcess@4:NEAR
EXTERN GetMessageA@16:NEAR
EXTERN GetModuleHandleA@4:NEAR
EXTERN LoadCursorA@8:NEAR
EXTERN LoadIconA@8:NEAR
EXTERN PostQuitMessage@4:NEAR
EXTERN RegisterClassA@4:NEAR
EXTERN ShowWindow@8:NEAR
EXTERN TranslateMessage@4:NEAR
EXTERN UpdateWindow@4:NEAR
; Directives for linking libraries
includelib .c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
;------------------------------------------
; Structures
; Message structure
MSGSTRUCT STRUC
MSHWND DD ? ; Identifier of the window
; that received the message
MSMESSAGE DD ? ; Message identifier
MSWPARAM DD ? ; Auxiliary information about the message
MSLPARAM DD ? ; Auxiliary information about the message
MSTIME DD ? ; Time of sending the message
MSPT DD ? ; Cursor position at the time of sending
; the message
MSGSTRUCT ENDS
;------------
WNDCLASS STRUC
CLSSTYLE DD ? ; Window style
CLWNDPROC DD ? ; Pointer to the window procedure
CLSCEXTRA DD ? ; Information on auxiliary bytes for
; this structure
CLWNDEXTRA DD ? ; Information on auxiliary bytes for the window
CLSHINSTANCE DD ? ; Application descriptor
CLSHICON DD ? ; Window icon descriptor
CLSHCURSOR DD ? ; Window cursor descriptor
CLBKGROUND DD ? ; Window brush descriptor
CLMENUNAME DD ? ; Menu identifier
CLNAME DD ? ; Specifies the window class name
WNDCLASS ENDS
; Data segment
_DATA SEGMENT
NEWHWND DD 0
MSG MSGSTRUCT <?>
WC WNDCLASS <?>
HINST DD 0 ; Here, the application descriptor is stored
TITLENAME DB 'Simple example of a 32-bit application', 0
CLASSNAME DB 'CLASS32', 0
CAP DB 'Message', 0
MES1 DB 'You have clicked the left mouse button', 0
MES2 DB 'Exit. Bye!', 0
_DATA ENDS
; Code segment
_TEXT SEGMENT
START:
; Get application descriptor
PUSH 0
CALL GetModuleHandleA@4 ;
MOV [HINST], EAX
REG_CLASS:
; Fill window structure
; Style
MOV [WC.CLSSTYLE], style
; Message-handling procedure
MOV [WC.CLWNDPROC], OFFSET WNDPROC
MOV [WC.CLSCEXTRA], 0
MOV [WC.CLWNDEXTRA], 0
MOV EAX, [HINST]
MOV [WC.CLSHINSTANCE], EAX
;----------Window icon
PUSH IDI_APPLICATION
PUSH 0
CALL LoadIconA@8
MOV [WC.CLSHICON], EAX
;----------Window cursor
PUSH IDC_CROSS
PUSH 0
CALL LoadCursorA@8
MOV [WC.CLSHCURSOR], EAX
;-----------
MOV [WC.CLBKGROUND], 17 ; Window color
MOV DWORD PTR [WC.CLMENUNAME], 0
MOV DWORD PTR [WC.CLNAME], OFFSET CLASSNAME
PUSH OFFSET WC
CALL RegisterClassA@4
; Create a window of the registered class
PUSH 0
PUSH [HINST]
PUSH 0
PUSH 0
PUSH 400 ; DY - Window height
PUSH 400 ; DX - Window width
PUSH 100 ; Y - Coordinate of the window's top left corner
PUSH 100 ; X - Coordinate of the window's top left corner
PUSH WS_OVERLAPPEDWINDOW
PUSH OFFSET TITLENAME ; Window name
PUSH OFFSET CLASSNAME ; Class name
PUSH 0
CALL CreateWindowExA@48
; Check for errors
CMP EAX, 0
JZ _ERR
MOV [NEWHWND], EAX ; Window descriptor
;---------------------
PUSH SW_SHOWNORMAL
PUSH [NEWHWND]
CALL ShowWindow@8 ; Display the newly created window
;-------------------------
PUSH [NEWHWND]
CALL UpdateWindow@4 ; Redraw the visible part of the window
; WM_PAINT message
; Message-handling loop
MSG_LOOP:
PUSH 0
PUSH 0
PUSH 0
PUSH OFFSET MSG
CALL GetMessageA@16
CMP EAX, 0
JE END_LOOP
PUSH OFFSET MSG
CALL TranslateMessage@4
PUSH OFFSET MSG
CALL DispatchMessageA@4
JMP MSG_LOOP
END_LOOP:
; Exit the program (close the process)
PUSH [MSG.MSWPARAM]
CALL ExitProcess@4
_ERR:
JMP END_LOOP
;------------------------------------------
; Window procedure
; Position of parameters in the stack
; [EBP+014H] LPARAM
; [EBP+10H] WAPARAM
; [EBP+0CH] MES
; [EBP+8] HWND
WNDPROC PROC
PUSH EBP
MOV EBP, ESP
PUSH EBX
PUSH ESI
PUSH EDI
CMP DWORD PTR [EBP+0CH], WM_DESTROY
JE WMDESTROY
CMP DWORD PTR [EBP+0CH], WM_CREATE
JE WMCREATE
CMP DWORD PTR [EBP+0CH], WM_LBUTTONDOWN ; Left button
JE LBUTTON
CMP DWORD PTR [EBP+0CH], WM_RBUTTONDOWN ; Right button
JE RBUTTON
JMP DEFWNDPROC
; Clicking the right mouse button closes the window
RBUTTON:
JMP WMDESTROY
; Clicking the left mouse button
LBUTTON:
; Displaying the message
PUSH 0 ; MB_OK
PUSH OFFSET CAP
PUSH OFFSET MES1
PUSH DWORD PTR [EBP+08H]
CALL MessageBoxA@16
MOV EAX, 0
JMP FINISH
WMCREATE:
MOV EAX, 0
JMP FINISH
DEFWNDPROC:
PUSH DWORD PTR [EBP+14H]
PUSH DWORD PTR [EBP+10H]
PUSH DWORD PTR [EBP+0CH]
PUSH DWORD PTR [EBP+08H]
CALL DefWindowProcA@16
JMP FINISH
WMDESTROY:
PUSH 0 ; MB_OK
PUSH OFFSET CAP
PUSH OFFSET MES2
PUSH DWORD PTR [EBP+08H] ; Window descriptor
CALL MessageBoxA@16
PUSH 0
CALL PostQuitMessage@4 ; WM_QUIT message
MOV EAX, 0
FINISH:
POP EDI
POP ESI
POP EBX
POP EBP
RET 16
WNDPROC ENDP
_TEXT ENDS
END START
------------------------------------
j'aimerai bien que quelqu'un m'aide a trouver l'erreur car on peu pa apprendre si on connais pa nos erreur.
iscalibar
Messages postés15Date d'inscriptionvendredi 22 juin 2007StatutMembreDernière intervention27 mars 2009 27 déc. 2007 à 11:42
Ben, mon code est extrait d'un example, ben voila le code source de l'example (ben je sais qu'il y a une erreur mai je ne la voi pa, je veu seuelement savoir ou est l'erreur), voila le code source de l'example:
-------------------------------------------------------
.386P
; Flat memory model
.MODEL FLAT, stdcall
; Constants
; The message arrives when the window is closed
WM_DESTROY equ 2
; The message arrives when the window is created
WM_CREATE equ 1
; The message arrives if the left mouse button is clicked
; somewhere in the window area
WM_LBUTTONDOWN equ 201h
; The message arrives if the right mouse button is clicked
; somewhere in the window area
WM_RBUTTONDOWN equ 204h
; Window properties
CS_VREDRAW equ 1h
CS_HREDRAW equ 2h
CS_GLOBALCLASS equ 4000h
WS_OVERLAPPEDWINDOW equ 000CF0000H
Style equ CS_HREDRAW+CS_VREDRAW+CS_GLOBALCLASS
; Standard icon identifier
IDI_APPLICATION equ 32512
; Cursor identifier
IDC_CROSS equ 32515
; Normal mode of displaying the window
SW_SHOWNORMAL equ 1
; Prototypes of external procedures
EXTERN MessageBoxA@16:NEAR
EXTERN CreateWindowExA@48:NEAR
EXTERN DefWindowProcA@16:NEAR
EXTERN DispatchMessageA@4:NEAR
EXTERN ExitProcess@4:NEAR
EXTERN GetMessageA@16:NEAR
EXTERN GetModuleHandleA@4:NEAR
EXTERN LoadCursorA@8:NEAR
EXTERN LoadIconA@8:NEAR
EXTERN PostQuitMessage@4:NEAR
EXTERN RegisterClassA@4:NEAR
EXTERN ShowWindow@8:NEAR
EXTERN TranslateMessage@4:NEAR
EXTERN UpdateWindow@4:NEAR
; Directives for linking libraries
includelib .c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
;------------------------------------------
; Structures
; Message structure
MSGSTRUCT STRUC
MSHWND DD ? ; Identifier of the window
; that received the message
MSMESSAGE DD ? ; Message identifier
MSWPARAM DD ? ; Auxiliary information about the message
MSLPARAM DD ? ; Auxiliary information about the message
MSTIME DD ? ; Time of sending the message
MSPT DD ? ; Cursor position at the time of sending
; the message
MSGSTRUCT ENDS
;------------
WNDCLASS STRUC
CLSSTYLE DD ? ; Window style
CLWNDPROC DD ? ; Pointer to the window procedure
CLSCEXTRA DD ? ; Information on auxiliary bytes for
; this structure
CLWNDEXTRA DD ? ; Information on auxiliary bytes for the window
CLSHINSTANCE DD ? ; Application descriptor
CLSHICON DD ? ; Window icon descriptor
CLSHCURSOR DD ? ; Window cursor descriptor
CLBKGROUND DD ? ; Window brush descriptor
CLMENUNAME DD ? ; Menu identifier
CLNAME DD ? ; Specifies the window class name
WNDCLASS ENDS
; Data segment
_DATA SEGMENT
NEWHWND DD 0
MSG MSGSTRUCT <?>
WC WNDCLASS <?>
HINST DD 0 ; Here, the application descriptor is stored
TITLENAME DB 'Simple example of a 32-bit application', 0
CLASSNAME DB 'CLASS32', 0
CAP DB 'Message', 0
MES1 DB 'You have clicked the left mouse button', 0
MES2 DB 'Exit. Bye!', 0
_DATA ENDS
; Code segment
_TEXT SEGMENT
START:
; Get application descriptor
PUSH 0
CALL GetModuleHandleA@4 ;
MOV [HINST], EAX
REG_CLASS:
; Fill window structure
; Style
MOV [WC.CLSSTYLE], style
; Message-handling procedure
MOV [WC.CLWNDPROC], OFFSET WNDPROC
MOV [WC.CLSCEXTRA], 0
MOV [WC.CLWNDEXTRA], 0
MOV EAX, [HINST]
MOV [WC.CLSHINSTANCE], EAX
;----------Window icon
PUSH IDI_APPLICATION
PUSH 0
CALL LoadIconA@8
MOV [WC.CLSHICON], EAX
;----------Window cursor
PUSH IDC_CROSS
PUSH 0
CALL LoadCursorA@8
MOV [WC.CLSHCURSOR], EAX
;-----------
MOV [WC.CLBKGROUND], 17 ; Window color
MOV DWORD PTR [WC.CLMENUNAME], 0
MOV DWORD PTR [WC.CLNAME], OFFSET CLASSNAME
PUSH OFFSET WC
CALL RegisterClassA@4
; Create a window of the registered class
PUSH 0
PUSH [HINST]
PUSH 0
PUSH 0
PUSH 400 ; DY - Window height
PUSH 400 ; DX - Window width
PUSH 100 ; Y - Coordinate of the window's top left corner
PUSH 100 ; X - Coordinate of the window's top left corner
PUSH WS_OVERLAPPEDWINDOW
PUSH OFFSET TITLENAME ; Window name
PUSH OFFSET CLASSNAME ; Class name
PUSH 0
CALL CreateWindowExA@48
; Check for errors
CMP EAX, 0
JZ _ERR
MOV [NEWHWND], EAX ; Window descriptor
;---------------------
PUSH SW_SHOWNORMAL
PUSH [NEWHWND]
CALL ShowWindow@8 ; Display the newly created window
;-------------------------
PUSH [NEWHWND]
CALL UpdateWindow@4 ; Redraw the visible part of the window
; WM_PAINT message
; Message-handling loop
MSG_LOOP:
PUSH 0
PUSH 0
PUSH 0
PUSH OFFSET MSG
CALL GetMessageA@16
CMP EAX, 0
JE END_LOOP
PUSH OFFSET MSG
CALL TranslateMessage@4
PUSH OFFSET MSG
CALL DispatchMessageA@4
JMP MSG_LOOP
END_LOOP:
; Exit the program (close the process)
PUSH [MSG.MSWPARAM]
CALL ExitProcess@4
_ERR:
JMP END_LOOP
;------------------------------------------
; Window procedure
; Position of parameters in the stack
; [EBP+014H] LPARAM
; [EBP+10H] WAPARAM
; [EBP+0CH] MES
; [EBP+8] HWND
WNDPROC PROC
PUSH EBP
MOV EBP, ESP
PUSH EBX
PUSH ESI
PUSH EDI
CMP DWORD PTR [EBP+0CH], WM_DESTROY
JE WMDESTROY
CMP DWORD PTR [EBP+0CH], WM_CREATE
JE WMCREATE
CMP DWORD PTR [EBP+0CH], WM_LBUTTONDOWN ; Left button
JE LBUTTON
CMP DWORD PTR [EBP+0CH], WM_RBUTTONDOWN ; Right button
JE RBUTTON
JMP DEFWNDPROC
; Clicking the right mouse button closes the window
RBUTTON:
JMP WMDESTROY
; Clicking the left mouse button
LBUTTON:
; Displaying the message
PUSH 0 ; MB_OK
PUSH OFFSET CAP
PUSH OFFSET MES1
PUSH DWORD PTR [EBP+08H]
CALL MessageBoxA@16
MOV EAX, 0
JMP FINISH
WMCREATE:
MOV EAX, 0
JMP FINISH
DEFWNDPROC:
PUSH DWORD PTR [EBP+14H]
PUSH DWORD PTR [EBP+10H]
PUSH DWORD PTR [EBP+0CH]
PUSH DWORD PTR [EBP+08H]
CALL DefWindowProcA@16
JMP FINISH
WMDESTROY:
PUSH 0 ; MB_OK
PUSH OFFSET CAP
PUSH OFFSET MES2
PUSH DWORD PTR [EBP+08H] ; Window descriptor
CALL MessageBoxA@16
PUSH 0
CALL PostQuitMessage@4 ; WM_QUIT message
MOV EAX, 0
FINISH:
POP EDI
POP ESI
POP EBX
POP EBP
RET 16
WNDPROC ENDP
_TEXT ENDS
END START
------------------------------------
j'aimerai bien que quelqu'un m'aide a trouver l'erreur car on peu pa apprendre si on connais pa nos erreur.
ToutEnMasm
Messages postés587Date d'inscriptionjeudi 28 novembre 2002StatutMembreDernière intervention13 décembre 20223 27 déc. 2007 à 14:36
J'insiste,il ne sert à rien que je te trouve ton erreur .On peut utiliser un debugger mais on peut aussi :
Comparer et trouver.
ça doit être suffisant
<hr />
; #########################################################################
;
; GENERIC.ASM is a roadmap around a standard 32 bit
iscalibar
Messages postés15Date d'inscriptionvendredi 22 juin 2007StatutMembreDernière intervention27 mars 2009 27 déc. 2007 à 19:31
J'ai une question tres précise, ou est la faute??? ben a celui qui peu m'aider a trouver la faute merci bien de m'aider sinon merci bien de ne pa ecrir n'importe quel commentaire, et merçi
ToutEnMasm
Messages postés587Date d'inscriptionjeudi 28 novembre 2002StatutMembreDernière intervention13 décembre 20223 27 déc. 2007 à 20:24
J'ai un peu plus de connaissance en assembleur que vous (voir mon site) et je ne me permet pas de mettre "n'importe quel commentaire"
Un exemple de masm32 sur la création d'une fenêtre est une référence,ce n'est pas "n'importe quoi".