.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc ;*
include demo.imp
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\msvcrt.lib
cinvoke EQU <invoke> ;* The scanner skips a line when it detects the symbols ;*
.data
template db 'Computer name : %s',0
caption db 'Hello',0
nSize dd MAX_COMPUTERNAME_LENGTH+1
.data?
temp db 256 dup(?)
computername db MAX_COMPUTERNAME_LENGTH+1 dup(?)
.code
start:
invoke GetComputerName,ADDR computername,ADDR nSize
cinvoke sprintf,ADDR temp,ADDR template,ADDR computername ; The scanner should be instructed
; with the cinvoke statement
; to process C functions
invoke MessageBox,0,ADDR temp,ADDR caption,MB_ICONINFORMATION
invoke ExitProcess,0
END start
This one is example from External Scanner for Fasm by vortex,
template db 'Computer name : %s',0
so, when i change this s to something else msg does show my computer name, its only work with s.
whats is this s exactly? and how you know that you need to put s?
MSDN is your friend...
From the MSDN article on sprintf:
Quote from: MSDN-sprintf
The sprintf function formats and stores a series of characters and values in buffer. Each argument (if any) is converted and output according to the corresponding format specification in format. The format consists of ordinary characters and has the same form and function as the format argument for printf.
And the format specifications for the printf function family can be found here (http://msdn2.microsoft.com/en-us/library/56e442dc(VS.80).aspx), it is linked to from the MSDN article on sprintf.
Hope this helps, Ehtyar.
[edit]
Most coders will use wsprintfA instead, as it is exported from user32 and will not require you to link directly to the crt.
[/edit]