flat assembler
Message board for the users of flat assembler.

Index > Windows > Writing string to buffer

Author
Thread Post new topic Reply to topic
denial



Joined: 12 Sep 2004
Posts: 98
denial 19 Oct 2004, 19:31
Hi,

I wanted to write a string constant into an empty buffer:

Code:
'my string'    


and my buffer:

Code:
buffer rb 15    


now i wanted to use the following code to perform the operation:

Code:
cinvoke wsprintf,buffer,'%s','my string'    


I thought I could do it that way, but it doesn't work.
The error message: Value out of range.
I'm a newbie, so can somebody help me? Confused

Regards
denial
Post 19 Oct 2004, 19:31
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 19 Oct 2004, 19:54
It's too easy.
Code:
include '%fasminc%/win32ax.inc'
buffer rb 32
.code

  start:
        invoke wsprintf,buffer,'%s',"Hi! I'm the example program!"
        invoke  MessageBox,HWND_DESKTOP,buffer,"Win32 Assembly",MB_OK
        invoke  ExitProcess,0

.end start    


Tomorrow, i will send a simple how use wsprintf with all formats
Post 19 Oct 2004, 19:54
View user's profile Send private message Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial 19 Oct 2004, 22:30
thank you very much, it was really too easy. i'm a fool Very Happy Rolling Eyes
Post 19 Oct 2004, 22:30
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 20 Oct 2004, 03:38
Post 20 Oct 2004, 03:38
View user's profile Send private message Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial 20 Oct 2004, 10:50
Mhmm I've got another question... is it possible to increase the declared byte size of the buffer dynamicaly? Maybe there's something like malloc() in C?
Post 20 Oct 2004, 10:50
View user's profile Send private message Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 20 Oct 2004, 11:09
HeapAlloc and HeapReAlloc?
Post 20 Oct 2004, 11:09
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial 20 Oct 2004, 11:45
I searched about HeapAlloc/HeapReAlloc, however if I'm not wrong, couldn't find an example.
Maybe you could give me one? Smile
Post 20 Oct 2004, 11:45
View user's profile Send private message Reply with quote
polygon7



Joined: 14 Aug 2003
Posts: 62
Location: Poznan, Poland
polygon7 21 Oct 2004, 18:29
denial wrote:
I searched about HeapAlloc/HeapReAlloc, however if I'm not wrong, couldn't find an example.
Maybe you could give me one? Smile


You could try:
Code:
src          dd ?

invoke  LocalAlloc,LMEM_FIXED,255
;255 is a number of allocated bytes
mov [src],eax
;[src] - pointer to allocated memmory

invoke        LocalFree,src
;freeing memmory    

_________________
best regards
p7
Post 21 Oct 2004, 18:29
View user's profile Send private message Visit poster's website Reply with quote
denial



Joined: 12 Sep 2004
Posts: 98
denial 21 Oct 2004, 20:03
Thank you for your answer. It helps me alot Smile
Post 21 Oct 2004, 20:03
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.