flat assembler
Message board for the users of flat assembler.

Index > Windows > ESP substraction and Windows Dialogs

Author
Thread Post new topic Reply to topic
Uwar



Joined: 09 Oct 2009
Posts: 11
Uwar 09 Oct 2009, 12:31
Why following codes works vary?
IncorrectWindowBorder:
Code:
 start:
    push  ebp
    mov   ebp, esp
    sub   esp, 0x0A

    push  dword 0x00000000
    push  sz_caption
    push  sz_msg
    push  dword 0x00000000
    call  [user32.MessageBoxA]
    
    push  0x00000000 ; return winmain result
    call  [kernel32.ExitProcess]
    

CorrectWindowBorder

Code:
 start:
    push  ebp
    mov   ebp, esp
    ;sub   esp, 0x0A why esp substraction (for local vars) changes msgBox?

    push  dword 0x00000000
    push  sz_caption
    push  sz_msg
    push  dword 0x00000000
    call  [user32.MessageBoxA]
    
    push  0x00000000 ; return winmain result
    call  [kernel32.ExitProcess]
    
Post 09 Oct 2009, 12:31
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20453
Location: In your JS exploiting you and your system
revolution 09 Oct 2009, 12:45
You should always subtract a value that is a multiple of 4. The stack needs to be kept dword aligned.
Post 09 Oct 2009, 12:45
View user's profile Send private message Visit poster's website Reply with quote
Uwar



Joined: 09 Oct 2009
Posts: 11
Uwar 09 Oct 2009, 12:52
Thanks a lot I thought that must be aligned to the word.
Post 09 Oct 2009, 12:52
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.