flat assembler
Message board for the users of flat assembler.

Index > Windows > pass arguments by stack

Author
Thread Post new topic Reply to topic
dadius



Joined: 31 Jul 2011
Posts: 2
dadius 31 Jul 2011, 20:53
hello i have my function

proc aFunction, FileName:BYTE, FileName2:BYTE, ParameterCount:DWORD, ...

do somthing

endp


the ... defines a variable length of parameter when i call function now i do as:


stdcall dword CallFunction, arg1, arg2, 2, param1, param2

instead of passing it this way is there a way to define proc function that i can pass arguments on stack reverse order like:

push param2
push param1
..
call function

thx for help
Post 31 Jul 2011, 20:53
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 31 Jul 2011, 21:51
Hi, welcome to the board

Is that what you really want? "stdcall dword [func]" and "invoke func", already push the parameters in reverse order (and of course procedures/functions defined with the "proc" macro do expect such order in the stack)
Post 31 Jul 2011, 21:51
View user's profile Send private message Reply with quote
dadius



Joined: 31 Jul 2011
Posts: 2
dadius 31 Jul 2011, 22:34
my problem is i have big code in which i already pushed arguments in nearly all functions i wanna make it compatible
Post 31 Jul 2011, 22:34
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 31 Jul 2011, 23:59
dadius, but have you pushed them in reverse order? If that is the case you are good already ("proc" **needs** arguments in reverse order).
Post 31 Jul 2011, 23:59
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20621
Location: In your JS exploiting you and your system
revolution 01 Aug 2011, 06:30
The current macros proc and stdcall are designed to work with each other. The order of pushes is reversed by stdcall, and the order of reading by proc matches the order in memory that stdcall produces. Use like this:
Code:
include 'win32ax.inc'
proc Func, p1, p2

;...

stdcall Func, fname1, fname2    
However there is a problem with variable number of parameters. stdcall does not support a variable number of parameters. For that you should be using ccall and c based procs. Use like this:
Code:
include 'win32ax.inc'
proc aFunction c, FileName:BYTE, FileName2:BYTE, ParameterCount:DWORD, ...

;...

ccall aFunction, fname1, fname2, SomeCount, ...    
Post 01 Aug 2011, 06:30
View user's profile Send private message Visit poster's website 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.