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
[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA[MIX10] KEYNOTE DEUXIèME JOURNéE - INTERNET EXPLORER 9, HTML5, VISUAL STUDIO 2010, ODATA par cyril
Le deuxième keynote du mix fut très riche en contenu. Internet Explorer 9 Juste un après le lancement de Internet Explorer 8, Microsoft a dévoilé les nouveautés de Internet Explorer 9. Désormais, IE supportera HTML5, SVG et CSS3. L'élément ...
Cliquez pour lire la suite de l'article par cyril CERTIFICATIONS BETA .NET 4CERTIFICATIONS BETA .NET 4 par KooKiz
Les inscriptions pour les certifications beta .NET 4 ont commencé. L'inscription est offerte pour les examens suivants : - 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 - 71-515, TS: Web Applications Development with...
Cliquez pour lire la suite de l'article par KooKiz [MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2[MIX 2010] - MICROSOFT TRANSLATOR TECHNOLOGY PREVIEW V2 par redo
J'imagine que la plupart d'entre vous connaissent bien et utilisent le service de traduction de Google, mais connaissez-vous celui de Microsoft . Microsoft Translator ? Effectivement, Microsoft nous annoncé le lancement version 2 de la Technologie Preview...
Cliquez pour lire la suite de l'article par redo LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010!LANCEMENT EN PREVIEW DE CYCLONE LORS DES TECHDAYS 2010! par MPOWARE
Toutes les vidéos de ce lancement sont en ligne!
Partie I - Intro
http://www.youtube.com/watch?v=LkQzTQ8T6CA
Partie II - Démo 1
http://www.youtube.com/watch?v=drAhYQ7lqvo
Partie III - Démo 2
http://www.youtube.com/watch?v=c8KM_1Gqybc...
Cliquez pour lire la suite de l'article par MPOWARE
Forum
RE : ASSEMBLEURRE : ASSEMBLEUR par ghuysmans99
Cliquez pour lire la suite par ghuysmans99 RE : ASSEMBLEURRE : ASSEMBLEUR par ghuysmans99
Cliquez pour lire la suite par ghuysmans99 ASSEMBLEURASSEMBLEUR par solleil
Cliquez pour lire la suite par solleil
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|