flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > how do stdcall and invoke work ?

Author
Thread Post new topic Reply to topic
wisepenguin



Joined: 30 Mar 2005
Posts: 129
wisepenguin
how does the invoke macro allow

invoke MessageBox,HWND_DESKTOP,"some text in quotes", "and more",MB_OK

im new to assembly and dont understand the stack, and what to do in a standard call function.
i have read about how they use the stack and whether the caller clears the stack but do not understand what to do.

i also dont understand how the invoke macro can use text, as i have usually had a global string variable and "push string_var_name" then call the function

is it possible to set a string variables contents aswell but not in the declaration ?

in data section
mystring db "this is my string", 0

is it possible to do
mystring rb 16 ; 16 bytes buffer

then mystring = "this is my string"
or something similar ?
Post 21 Apr 2005, 15:14
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
only simple calls can't be used with params

Code:
invoke strlen,szString
    


equal to:

Code:
push szString
call [lstrlen]
    


if you want to use string you must operate with him address

Code:
szString db "test",0
...
push szString
call [lstrlen]
    


Quote:

in data section
mystring db "this is my string", 0

is it possible to do
mystring rb 16 ; 16 bytes buffer


yes, it is possible, you can use lstrcpy function (copy string to a buffer)

Code:
.data section
anotherstring db "this is my string",0
...
.idata section
mystring rb 16
...
.code section
invoke lstrcpy,mystring,anotherstring
    


after this, you have mystring="this is my string"


Last edited by Vasilev Vjacheslav on 25 Apr 2005, 11:09; edited 1 time in total
Post 25 Apr 2005, 10:36
View user's profile Send private message Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Vjacheslav, any call macroses (stdcall, invoke, cinvoke, etc.) can be used without parameters. They are macroses, so you can check, whether there are any parameters passed, and if it isn't, make only appropriate call.
In fasm package stdcall (or invoke - I don't remember exactly) doesn't work without params, but you can easily fix it by yourself.
Best regards.
Post 25 Apr 2005, 10:48
View user's profile Send private message Reply with quote
Vasilev Vjacheslav



Joined: 11 Aug 2004
Posts: 392
Vasilev Vjacheslav
yes, you right
Post 25 Apr 2005, 11:12
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.