Accueil > > > FENÊTRE WIDOWS (NASM)
FENÊTRE WIDOWS (NASM)
Information sur la source
Description
Encor un coup de pousse pour les programmer sous nasm. Je sais qu'il y a déjà un exemple mais celui si un peu différents : pur assembleur
En plus il y a une petite gestion des erreures!
TRAX
Source
- [EXTERN MessageBoxA]
- [import MessageBoxA user32.dll]
-
- [EXTERN ExitProcess]
- [import ExitProcess kernel32.dll]
- [EXTERN CreateWindowExA]
- [import CreateWindowExA user32.dll]
- [extern GetModuleHandleA]
- [import GetModuleHandleA kernel32.dll]
- [extern GetCommandLineA]
- [import GetCommandLineA kernel32.dll]
- [EXTERN RegisterClassExA]
- [import RegisterClassExA user32.dll]
- [EXTERN ShowWindow]
- [import ShowWindow user32.dll]
- [EXTERN LoadIconA]
- [import LoadIconA user32.dll]
- [EXTERN LoadCursorA]
- [import LoadCursorA user32.dll]
- [EXTERN DefWindowProcA]
- [import DefWindowProcA user32.dll]
- [EXTERN PostQuitMessage]
- [import PostQuitMessage user32.dll]
- [EXTERN TranslateMessage]
- [import TranslateMessage user32.dll]
- [EXTERN DispatchMessageA]
- [import DispatchMessageA user32.dll]
- [EXTERN GetMessageA]
- [import GetMessageA user32.dll]
- [EXTERN CreateFontIndirectA]
- [import CreateFontIndirectA gdi32.dll]
- [EXTERN DeleteObject]
- [import DeleteObject gdi32.dll]
- [EXTERN PostMessageA]
- [import PostMessageA user32.dll]
- ;_______________________________________________
-
- [SECTION CODE USE32 CLASS=CODE]
-
- ..start:
-
- push dword 00h ; null
- call [GetModuleHandleA]
- mov dword [instance], eax
-
- Call [GetCommandLineA]
- mov dword [commandline], eax
-
- push dword 0Ah ; SW_SHOW
- push dword eax
- push dword 00h ; null
- push dword [instance]
- call WinMain
-
- push dword eax
- call [ExitProcess]
-
-
- ;************************************************
- ;* winMain *
- ;************************************************
- ;%define hInstance ebp+8
- ;%define hPrevInstance ebp+12
- ;%define lpCmdLine ebp+16
- ;%define nCmdShow ebp+20
-
- WinMain:
- enter 0,0
- mov dword [winclass+0], 30h ; 48(d)
- mov dword [winclass+4], 03h ; CS_HREDRAW | CS_VREDRAW
- mov dword [winclass+8], WinProc
- mov dword [winclass+12], 0
- mov dword [winclass+16], 0
- mov eax, dword [instance]
- mov dword [winclass+20], eax
-
- push word 0
- push word 101
- mov eax, dword [instance]
- push dword eax
- call [LoadIconA]
- mov dword [winclass+24], eax
- mov dword [winclass+44], eax
-
- push dword 07F00h ; IDC_ARROW
- push dword 00h ; NULL
- call [LoadCursorA]
- mov dword [winclass+28], eax
-
- mov dword [winclass+32], 10h ; background COLOR_BTNFACE+1
- mov dword [winclass+36], 00h ; (MenuName)
- mov dword [winclass+40], nomclass
-
- push dword winclass
- call [RegisterClassExA]
-
- cmp eax,0
- jne RegisterOk
-
- push dword 00h
- push dword message1
- push dword message2
- push dword 00h
- call [MessageBoxA]
-
- push word 00h
- call [ExitProcess]
-
-
-
- RegisterOk:
-
- mov dword [atom], eax
-
- push dword 00h ; null
- mov eax, dword [instance]
- push dword eax
- push dword 00h ; null
- push dword 00h ; null
- push dword 500 ; Wigth
- push dword 500 ; Height
- push dword 20 ; Left
- push dword 20 ; Top
- push dword 00CF0000h ; WS_TILEDWINDOW
- push dword nom
- push dword nomclass
- push dword 00h ; WS_EX_LEFT
- call [CreateWindowExA]
-
- cmp eax , 0
- jne CreateWindowOk
-
-
- push dword 00h
- push dword message1
- push dword message3
- push dword 00h
- call [MessageBoxA]
-
- push word 00h
- call [ExitProcess]
-
-
- CreateWindowOk:
-
- mov dword [handle], eax
-
- push dword 5h ; SW_SHOW
- push dword [handle]
- call [ShowWindow]
-
- BoucleMessages:
-
- push dword 0
- push dword 0
- push dword [handle]
- push dword msg1
- call [GetMessageA]
-
- cmp eax, 12h ; WM_QUIT
- je FinBoucle
-
- cmp eax, -1
- jne GetMEssageOk
-
-
- push dword 00h
- push dword message1
- push dword message4
- push dword 00h
- call [MessageBoxA]
-
- push word 00h
- call [ExitProcess]
-
- GetMEssageOk:
-
- push dword msg1
- call [TranslateMessage]
- push dword msg1
- call [DispatchMessageA]
-
- jmp BoucleMessages
-
- FinBoucle:
- mov eax, dword [msg1+8] ; ????????????????????????? wParam
-
- Fin:
- leave
- ret 16
-
- ;*********************************************
- ;* WindowProc *
- ;*********************************************
- %define hwnd ebp+8
- %define uMsg ebp+12
- %define wParam ebp+16
- %define lParam ebp+20
-
- WinProc:
- enter 0,0
- mov eax,[uMsg]
-
- cmp eax,01b
- je near Create
- cmp eax,10b
- je near Destroy
-
- Defaut:
- push dword [lParam]
- push dword [wParam]
- push dword [uMsg]]
- push dword [hwnd]
- call [DefWindowProcA]
-
- Fin2:
- leave
- ret 16
-
- Create: ;**************************************
- push dword FontStandard
- call [CreateFontIndirectA]
- mov dword [hFontStandard], eax
-
- jmp Fin2
-
- Destroy: ;*************************************
- push dword [hFontStandard]
- call [DeleteObject]
- jmp Fin2
- ;_______________________________________________
-
-
- ; Procedures et fonctions secondaires
- ;_______________________________________________
-
- ;Procedure qui assigne une font standard à un contrôle
- ; Param : Handle du contrôle dans eax
-
- SetFontStandard:
- push dword 01b
- push dword [hFontStandard]
- push dword 30h
- push dword eax
- call [PostMessageA]
- ret
- ;_______________________________________________
-
-
- [SECTION DATA USE32 CLASS=DATA]
-
- ; Données
- ;_______________________________________________
- instance resd 1
- commandline resd 1
- winclass resd 12
- atom resd 1
- handle resd 1
- msg1 resd 9
- nomclass db "WindowClass01",0
- nom db "premiere fenetre window",0
- message1 db "Erreur !",0
- message2 db "Première erreur !",0
- message3 db "Deuxsième erreur !",0
- message4 db "Bye !",0
-
-
- FontStandard dd 10
- resd 6
- db "MS sans Serif",0
-
- hFontStandard resd 1
- ;_______________________________________________
-
[EXTERN MessageBoxA]
[import MessageBoxA user32.dll]
[EXTERN ExitProcess]
[import ExitProcess kernel32.dll]
[EXTERN CreateWindowExA]
[import CreateWindowExA user32.dll]
[extern GetModuleHandleA]
[import GetModuleHandleA kernel32.dll]
[extern GetCommandLineA]
[import GetCommandLineA kernel32.dll]
[EXTERN RegisterClassExA]
[import RegisterClassExA user32.dll]
[EXTERN ShowWindow]
[import ShowWindow user32.dll]
[EXTERN LoadIconA]
[import LoadIconA user32.dll]
[EXTERN LoadCursorA]
[import LoadCursorA user32.dll]
[EXTERN DefWindowProcA]
[import DefWindowProcA user32.dll]
[EXTERN PostQuitMessage]
[import PostQuitMessage user32.dll]
[EXTERN TranslateMessage]
[import TranslateMessage user32.dll]
[EXTERN DispatchMessageA]
[import DispatchMessageA user32.dll]
[EXTERN GetMessageA]
[import GetMessageA user32.dll]
[EXTERN CreateFontIndirectA]
[import CreateFontIndirectA gdi32.dll]
[EXTERN DeleteObject]
[import DeleteObject gdi32.dll]
[EXTERN PostMessageA]
[import PostMessageA user32.dll]
;_______________________________________________
[SECTION CODE USE32 CLASS=CODE]
..start:
push dword 00h ; null
call [GetModuleHandleA]
mov dword [instance], eax
Call [GetCommandLineA]
mov dword [commandline], eax
push dword 0Ah ; SW_SHOW
push dword eax
push dword 00h ; null
push dword [instance]
call WinMain
push dword eax
call [ExitProcess]
;************************************************
;* winMain *
;************************************************
;%define hInstance ebp+8
;%define hPrevInstance ebp+12
;%define lpCmdLine ebp+16
;%define nCmdShow ebp+20
WinMain:
enter 0,0
mov dword [winclass+0], 30h ; 48(d)
mov dword [winclass+4], 03h ; CS_HREDRAW | CS_VREDRAW
mov dword [winclass+8], WinProc
mov dword [winclass+12], 0
mov dword [winclass+16], 0
mov eax, dword [instance]
mov dword [winclass+20], eax
push word 0
push word 101
mov eax, dword [instance]
push dword eax
call [LoadIconA]
mov dword [winclass+24], eax
mov dword [winclass+44], eax
push dword 07F00h ; IDC_ARROW
push dword 00h ; NULL
call [LoadCursorA]
mov dword [winclass+28], eax
mov dword [winclass+32], 10h ; background COLOR_BTNFACE+1
mov dword [winclass+36], 00h ; (MenuName)
mov dword [winclass+40], nomclass
push dword winclass
call [RegisterClassExA]
cmp eax,0
jne RegisterOk
push dword 00h
push dword message1
push dword message2
push dword 00h
call [MessageBoxA]
push word 00h
call [ExitProcess]
RegisterOk:
mov dword [atom], eax
push dword 00h ; null
mov eax, dword [instance]
push dword eax
push dword 00h ; null
push dword 00h ; null
push dword 500 ; Wigth
push dword 500 ; Height
push dword 20 ; Left
push dword 20 ; Top
push dword 00CF0000h ; WS_TILEDWINDOW
push dword nom
push dword nomclass
push dword 00h ; WS_EX_LEFT
call [CreateWindowExA]
cmp eax , 0
jne CreateWindowOk
push dword 00h
push dword message1
push dword message3
push dword 00h
call [MessageBoxA]
push word 00h
call [ExitProcess]
CreateWindowOk:
mov dword [handle], eax
push dword 5h ; SW_SHOW
push dword [handle]
call [ShowWindow]
BoucleMessages:
push dword 0
push dword 0
push dword [handle]
push dword msg1
call [GetMessageA]
cmp eax, 12h ; WM_QUIT
je FinBoucle
cmp eax, -1
jne GetMEssageOk
push dword 00h
push dword message1
push dword message4
push dword 00h
call [MessageBoxA]
push word 00h
call [ExitProcess]
GetMEssageOk:
push dword msg1
call [TranslateMessage]
push dword msg1
call [DispatchMessageA]
jmp BoucleMessages
FinBoucle:
mov eax, dword [msg1+8] ; ????????????????????????? wParam
Fin:
leave
ret 16
;*********************************************
;* WindowProc *
;*********************************************
%define hwnd ebp+8
%define uMsg ebp+12
%define wParam ebp+16
%define lParam ebp+20
WinProc:
enter 0,0
mov eax,[uMsg]
cmp eax,01b
je near Create
cmp eax,10b
je near Destroy
Defaut:
push dword [lParam]
push dword [wParam]
push dword [uMsg]]
push dword [hwnd]
call [DefWindowProcA]
Fin2:
leave
ret 16
Create: ;**************************************
push dword FontStandard
call [CreateFontIndirectA]
mov dword [hFontStandard], eax
jmp Fin2
Destroy: ;*************************************
push dword [hFontStandard]
call [DeleteObject]
jmp Fin2
;_______________________________________________
; Procedures et fonctions secondaires
;_______________________________________________
;Procedure qui assigne une font standard à un contrôle
; Param : Handle du contrôle dans eax
SetFontStandard:
push dword 01b
push dword [hFontStandard]
push dword 30h
push dword eax
call [PostMessageA]
ret
;_______________________________________________
[SECTION DATA USE32 CLASS=DATA]
; Données
;_______________________________________________
instance resd 1
commandline resd 1
winclass resd 12
atom resd 1
handle resd 1
msg1 resd 9
nomclass db "WindowClass01",0
nom db "premiere fenetre window",0
message1 db "Erreur !",0
message2 db "Première erreur !",0
message3 db "Deuxsième erreur !",0
message4 db "Bye !",0
FontStandard dd 10
resd 6
db "MS sans Serif",0
hFontStandard resd 1
;_______________________________________________
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
[FRAMEWORK 4] LES TASKS ET LE THREAD UI[FRAMEWORK 4] LES TASKS ET LE THREAD UI par fathi
Je viens de passer quelques temps au TechDay's et j'ai pu voir pas mal de session intéressante. Par contre une chose m'a un peu étonné lors de certaines de ces sessions qui abordaient les améliorations du framework .NET (donc le 4.5) : en gros, bea...
Cliquez pour lire la suite de l'article par fathi WORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBEWORKFLOW FOUNDATION 3 A UN PIED DANS LA TOMBE par JeremyJeanson
Depuis déjà un an, je conseille vivement les utilisateurs de Workflow Foundation 3 à migrer vers la version 4. L'information qui va suivre ne devrait donc pas trop prendre au dépourvu les personnes qui m'ont suivi. Je profite de ce poste, pour faire le re...
Cliquez pour lire la suite de l'article par JeremyJeanson TECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PCTECHDAYS PARIS 2012 : NOUVELLES TENDANCES DU POSTE DE TRAVAIL - BRING YOUR OWN PC par ROMELARD Fabrice
Speakers: Thierry Rapatout, Antoine Petit et Xavier Trebbia Cette session entre dans le cadre des RDV Décideurs des TechDays 2012, elle est liée à la consumérisation de l'IT et la mise en place du "DeskTop as a Service" dans de plus en ...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLETECHDAYS PARIS 2012 : SYSTEM CENTER SERVICE MANAGER 2012 VUE D'ENSEMBLE par ROMELARD Fabrice
Speakers: Julien Marechal, Gautier Confiant, Sébastien MEYER La session débute par le positionnement de la solution System Center par rapport aux concepts d'organisation ITIL. Le portail du catalogue de se...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2012 : PLEINIèRE SECOND JOURTECHDAYS PARIS 2012 : PLEINIèRE SECOND JOUR par ROMELARD Fabrice
Après une première journée dédiée aux développeurs, cette seconde journée est dédiée au monde des entreprises et de ses applications. Ainsi, cette pleinière est dédiée à faire un 360 de l'évolution des applications Business aux demandes ac...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V7.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|