flat assembler
Message board for the users of flat assembler.

Index > Main > clear string

Author
Thread Post new topic Reply to topic
jacko221



Joined: 12 Nov 2005
Posts: 22
jacko221 14 Oct 2006, 14:15
Is there anyway to clear a string/buffer in my code?
For example if i define:
buffer db ?
and it gets filled with data in my code... but later i want to clear it.
How would i go about doing such a thing?
All help is appreciated Smile
Thanks, Jack
Post 14 Oct 2006, 14:15
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20451
Location: In your JS exploiting you and your system
revolution 14 Oct 2006, 14:39
jacko221 wrote:
i want to clear it.
How would i go about doing such a thing?
like this:
Code:
mov [buffer],0    
But, are you sure you want a string buffer to be one byte long? Perhaps you want:
Code:
buffer rb 1024    
Then you can use something like this to clear it:
Code:
mov edi,buffer
mov ecx,1024/4
xor eax,eax
rep stosd    


Last edited by revolution on 14 Oct 2006, 14:54; edited 1 time in total
Post 14 Oct 2006, 14:39
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Oct 2006, 14:45
if you mean filling with zeroes, it's:
Code:
cld
mov edi, buffer
mov ecx, size_of_buffer
mov al, 0
rep stosb    
Post 14 Oct 2006, 14:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 14 Oct 2006, 17:09
Both vid and revolution are correct, however I will point out, you need to ensure that ES and DS are in the same segment/selector as the buffer, otherwise you'll put them zeros into space you may not want them to go.
Post 14 Oct 2006, 17:09
View user's profile Send private message Reply with quote
jacko221



Joined: 12 Nov 2005
Posts: 22
jacko221 15 Oct 2006, 03:32
thanks for all your help Very Happy
Post 15 Oct 2006, 03:32
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.