flat assembler
Message board for the users of flat assembler.
Index
> Windows > wsprintf/wvsprintf |
Author |
|
pete 21 Apr 2009, 06:46
Well, just a guess: if using wvsprintf, no c-calling conventions are needed; they are needed only for wsprintf!
|
|||
21 Apr 2009, 06:46 |
|
revolution 21 Apr 2009, 07:37
The third argument must a be a pointer to a list of pointers.
TFM wrote: int wvsprintf( Code: varargs dw TstStr ... invoke wvsprintf,Output,FmtStr,varargs |
|||
21 Apr 2009, 07:37 |
|
pete 21 Apr 2009, 07:45
That doesn't work either, revolution. It seems FASM has a problem importing the wsprintf function from user32... When debugging the application with ollydbg, the jump to wsprintf won't work.
|
|||
21 Apr 2009, 07:45 |
|
revolution 21 Apr 2009, 08:01
You have two libraries. Use this:
Code: library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'api\kernel32.inc' include 'api\user32.inc' |
|||
21 Apr 2009, 08:01 |
|
pete 21 Apr 2009, 08:17
Yep this works now!
|
|||
21 Apr 2009, 08:17 |
|
booter 22 Apr 2009, 03:03
revolution wrote: You have two libraries. Use this: It took me some time to get what you meant Who could imagin that Code: library x,'X', y,'Y' may be not the same as Code: library x,'X' library y,'Y' Should it be considered a bug in FASM "include" ? |
|||
22 Apr 2009, 03:03 |
|
revolution 22 Apr 2009, 05:31
It is a gotcha. The macros need to be treated with caution when trying to use them in different ways than the original intention.
|
|||
22 Apr 2009, 05:31 |
|
booter 23 Apr 2009, 05:37
This is the final version of my test program.
Code: ; Demonstration of wvsprintf ; Pablic Domain. ; Output: ;Started<ABC abcd1234 ;12345 ABC>Ended format PE console use32 entry start include '%fasminc%\win32ax.inc' section '.data' data readable writeable StdOutHdl dd 0 TstStr db "ABC",0 TstHex dd 0ABCD1234h TstDec dd 12345 EOL db 10,13,0 macro WriteFmt formatstr,[arg] { common push eax size@args = 4 if ~ arg eq reverse pushd arg size@args = size@args+4 common end if mov eax,esp pushd eax stdcall WriteFmtLst,formatstr,eax if size@args add esp,size@args end if pop eax } section '.code' code readable executable start: invoke GetStdHandle, STD_OUTPUT_HANDLE mov [StdOutHdl],eax stdcall WriteStdOut,"Started" WriteFmt "<%s %x%s%u %s>",TstStr,[TstHex],EOL,[TstDec],TstStr stdcall WriteStdOut,"Ended" invoke ExitProcess,0 proc WriteFmtLst fmtstr:DWORD,alist:DWORD local strbuf[1024]:BYTE stdcall [wvsprintf],addr strbuf,[fmtstr],[alist] stdcall WriteStdOut,addr strbuf ret endp proc WriteStdOut lpStr:DWORD local OutLen:DWORD invoke lstrlen,[lpStr] invoke WriteFile, [StdOutHdl],[lpStr],eax,addr OutLen,NULL ret endp section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',user32,'USER32.DLL' include '%fasminc%\api\kernel32.inc' include '%fasminc%\api\user32.inc' |
|||
23 Apr 2009, 05:37 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.