flat assembler
Message board for the users of flat assembler.

Index > Windows > Very Long Strings (RB) in fasm?

Author
Thread Post new topic Reply to topic
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 28 May 2010, 06:38
i need to declare a very long string (rb), cause in some cases i need to get the list of all files in a specific directory like \windows\system32 but the variable cant hold this much data

is there anyway to fix this?
Code:
Buffer rb 429496    


maybe there is something (like SetLength function in delphi) to increase the string dynamically?
Post 28 May 2010, 06:38
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 28 May 2010, 07:06
Nameless,

Allocate memory dynamically, reallocate if it's not big enough. BTW, Buffer rb 429496 compiles just fine. Probably you've meant Buffer rb 4'294'967'295? Wink
Post 28 May 2010, 07:06
View user's profile Send private message Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 28 May 2010, 11:12
yea it compiles fine, and works fine too
but when the directory have lots of files it doesn't, either crashing or not showing all files

how can i do that Dynamic Memory Allocation? APIs? functions?
Post 28 May 2010, 11:12
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 28 May 2010, 12:40
VirtualAlloc
HeapAlloc (<=4Mb)
Post 28 May 2010, 12:40
View user's profile Send private message Visit poster's website Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 29 May 2010, 01:52
and the variable declaration is the same?
Code:
Buffer rb 429496
    


or

Code:
Buffer db 128 dup(?)   
    
Post 29 May 2010, 01:52
View user's profile Send private message Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 29 May 2010, 02:19
They return pointer to memory...
Code:
; I need this much memory
nSize dd 4096

; I am pointer to memory
pBlock dd NULL

; Get pointer to memory
invoke GlobalAlloc,GPTR,[nSize]
mov [pBlock],eax

; Release pointer to memory
invoke GlobalFree,[pBlock]
    
Post 29 May 2010, 02:19
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 29 May 2010, 07:45
bitshifter,

While using GlobalXxx() is not considered as a deadly sin (on occasions you must use it, e.g. in clipboard operations), better practice is to avoid the unneeded overhead and resource consumption — use HeapXxx() (or VirtualXxx() if you need memory in bulk).
Post 29 May 2010, 07:45
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.