Asebbly MessageBox program

  assembly, windows

Having a simple MessageBox program like that:

NULL          EQU 0                             ; Constants
MB_DEFBUTTON1 EQU 0
MB_DEFBUTTON2 EQU 100h
IDNO          EQU 7
MB_YESNO      EQU 4

extern [email protected]                          ; Import external symbols
extern [email protected]                           ; Windows API functions, decorated

global Start                                    ; Export symbols. The entry point

section .data                                   ; Initialized data segment
 MessageBoxText    db "Do you want to exit?", 0
 MessageBoxCaption db "MessageBox 32", 0

section .text                                   ; Code segment
Start:
 push  MB_YESNO | MB_DEFBUTTON2                 ; 4th parameter. 2 constants ORed together
 push  MessageBoxCaption                        ; 3rd parameter
 push  MessageBoxText                           ; 2nd parameter
 push  NULL                                     ; 1st parameter
 call  [email protected]

 cmp   EAX, IDNO                                ; Check the return value for "No"
 je    Start

 push  NULL

 call  [email protected]

My question is – shouldn’t we add appropriate value to the esp reg after calling the MessageBoxA to restore the stack to it’s previous state? If so when calling push MessageBoxCaption how much have to be added to the esp register (4?).

Source: Windows Questions

LEAVE A COMMENT