flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Need macro proc without stack restoration

Author
Thread Post new topic Reply to topic
twgt



Joined: 23 Jan 2007
Posts: 8
twgt
Hi all.
Sorry for my english Smile

I need a macro 'proc ... endp', but without restoring stack.
I creating dll with export, but program, whitch use this dll is call functions in c-convention.
Code:
call My_exported_func
add esp,4 ; for 1 arg
    


Standart proc macro create code
Quote:

My_exported_func:
push ebp
mov ebp,esp
;my code
leave
retn 4


I need 'ret' instead 'retn 4'. How do this(not using manual define my_exported_func:)?
Thanks.
Post 29 Dec 2007, 08:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
Use this:
Code:
proc My_exported_func c param1, param2
...
ret
endp    

The 'c' in there tells it that you a making a cdecl complying proc.
Post 29 Dec 2007, 08:33
View user's profile Send private message Visit poster's website Reply with quote
twgt



Joined: 23 Jan 2007
Posts: 8
twgt
Thanks!
Post 29 Dec 2007, 08:36
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

I need 'ret' instead 'retn 4'. How do this(not using manual define my_exported_func:)?


Apart of revolution's solution that suits better to your needs you can use retn to skip the automatic generation of leave/retn args*4. This is because proc macro defines a macro called "ret" that produces the aforementioned instructions sequence, that is why ret does not map to retn when you are inside a proc. Note that since the macros are case sensitive using "Ret", "rEt", "RET", etc, also skips the "ret" macro.
Post 29 Dec 2007, 16:23
View user's profile Send private message Reply with quote
twgt



Joined: 23 Jan 2007
Posts: 8
twgt
Thanks LocoDelAssembly, I remember this advice.
Post 30 Dec 2007, 10:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17278
Location: In your JS exploiting you and your system
revolution
Be careful where you use what LocoDelAssembly suggested. Using it like that does not restore the stack from locals, the saved registers or ebp!
Post 30 Dec 2007, 10:51
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-2020, Tomasz Grysztar.

Powered by rwasa.