Function with variable number of parameters

Started by Vortex, December 08, 2008, 10:33:42 AM

Previous topic - Next topic


Here is a function to simulate partially wsprintf. The purpose is to concatenate multiple strings into a single string copied to a destination buffer. The only accepted format specification is the symbol %. This is enough to concatenate strings.

.model flat,stdcall
option casemap:none

include    \GeneSys\include\
include    \GeneSys\include\
include    \GeneSys\include\

includelib \GeneSys\lib\kernel32.lib
includelib \GeneSys\lib\user32.lib
includelib \GeneSys\lib\GeneSys.lib

wsp PROTO C buffer:DWORD,format:DWORD,args:VARARG


format1 db 'This is a % % to % %',0
str1    db 'wsp',0
str2    db 'demo',0
str3    db 'concatenate',0
str4    db 'strings.',0


buffer  db 100 dup(?)



    invoke   wsp,ADDR buffer,ADDR format1,\
             ADDR str1,ADDR str2,ADDR str3,ADDR str4
    invoke   ConsoleOut,ADDR buffer
    invoke   ExitProcess,0

END start

Result :

This is a wsp demo to concatenate strings.

The wsp function retuns the size of the final string copied to the buffer.

[attachment deleted by admin]


Here is another optimized version of the wsprintf simulator.


Thank you my friend. We must talk about the project.

The GeneSys Project is available from:
The Repository or My crappy website


Hi Paul,

I sent you three personal messages. Did you receive them my friend?

If you cannot access me via PM, here is my email address : vortex_1 at hotmail dot com