Function with variable number of parameters

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

Previous topic - Next topic

Vortex

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.


.386
.model flat,stdcall
option casemap:none

include    \GeneSys\include\windows.inc
include    \GeneSys\include\kernel32.inc
include    \GeneSys\include\GeneSys.inc

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

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

.data

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

.data?

buffer  db 100 dup(?)

.code

start:

    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]

Vortex

Here is another optimized version of the wsprintf simulator.

PBrennick

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

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

Vortex

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