flat assembler
Message board for the users of flat assembler.
Index
> Windows > a question(too hard to explain in little amount of words...) |
Author |
|
coconut 13 Jul 2004, 04:28
most APIs that return a string actually return a pointer to a string buffer, probably eax. example:
Code: format pe gui 4.0 entry start include '%FASMINC%\win32a.inc' _hello db 'hello world',0 start: mov eax, _hello invoke MessageBox,0,eax,eax,0 invoke ExitProcess ;; section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ ExitProcess,'ExitProcess' import user,\ MessageBox,'MessageBoxA' any APIs like MessageBoxA that work with a pointer to a string buffer will take the returning buffer pointed at by eax. havent played with GetSystemMetrics myself but try maybe: Code: invoke GetSystemMetrics, 1 mov [buff], eax ;return value/string buffer invoke MessageBox,0,buff,buff,0 to format/process the string buffer you may have to play with various APIs like wsprintf, or perhaps search the boards for different string macros |
|||
13 Jul 2004, 04:28 |
|
wolf 13 Jul 2004, 10:55
Perhaps you mean sth. like this:
Code: section '.code' code readable writeable executable start: syscall GetSystemMetrics,SM_CXFULLSCREEN stdcall dwtoa,eax,Buffer syscall MessageBox,0,eax,Title,0 syscall ExitProcess,0 proc dwtoa,value,buff enterproc mov eax,[value] mov ecx,10 mov edi,[buff] add edi,14 mov byte[edi+1],0 .loop: xor edx,edx test eax,eax je .finish div ecx add dl,'0' mov byte[edi],dl dec edi jmp .loop .finish: inc edi mov eax,edi endproc Title db 'function result is:',0 Buffer rb 16 wolf |
|||
13 Jul 2004, 10:55 |
|
coconut 03 Aug 2004, 02:46
wolf, nice example on dwtoa. however it gives wierd results with negative numbers, was it meant to handle them?
|
|||
03 Aug 2004, 02:46 |
|
VitalOne 03 Aug 2004, 03:43
You can also use wsprintf API, like this
Code: invoke wsprintf,string_buffer,"%d",eax |
|||
03 Aug 2004, 03:43 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.