flat assembler
Message board for the users of flat assembler.

Index > Windows > wsprintf messes up ESP

Author
Thread Post new topic Reply to topic
proveren



Joined: 24 Jul 2004
Posts: 68
Location: Bulgaria
proveren 11 Aug 2004, 06:45
I am having a problem with calling the win32 function wsprintf. After the call esp is having an incorrect value. So what I do is:
_esp dd ?
.
.
.
mov [_esp],esp
invoke wsprintf,....... (I always have the correct number of parameters)
mov esp,[_esp]

This definitely not a good programming habit. How can I solve the problem in another way? In the reference there is a note that the function uses some strange calling convention. Do you have some ideas?
Post 11 Aug 2004, 06:45
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 11 Aug 2004, 06:52
wsprintf have C calling convention. That means that you have to fix the stack pointer yourself after return. Actually "add esp, sizeOfArguments" is the standard method of doing so. Also in FASM there is "ccall" macro that counts the arguments passed and fixes the stack pointer for you. See it in "include/macro/ccall.inc" from fasmw package.

Regards.
Post 11 Aug 2004, 06:52
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 11 Aug 2004, 08:23
Maybe this is what I should do with *my* problem:
http://board.flatassembler.net/topic.php?t=2026
Could stdcall, comcall, ccall,... help instead of invoke?
Post 11 Aug 2004, 08:23
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
proveren



Joined: 24 Jul 2004
Posts: 68
Location: Bulgaria
proveren 11 Aug 2004, 08:44
Yes, thanks John, I understood many things just by looking at the included macros.
Post 11 Aug 2004, 08:44
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.