flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Teehee 14 Jan 2010, 18:07
with no API (VirtualAlloc, HeapAlloc, etc).
_________________ Sorry if bad english. |
|||
![]() |
|
baldr 14 Jan 2010, 19:22
Be more specific on that. Where are you supposed to get memory to allocate from? Some uninitialized section + custom allocator?
|
|||
![]() |
|
Teehee 14 Jan 2010, 19:41
But and in the runtime? Or my app must separete a space anyway (like you shown, r22)? (I dont think so, bc if you use a HeapAlloc you dont need separete space)
baldr, I need to read some strings (file paths (unknow quantity)), And I'd like to alloc some space to store them. But I'd like to alloc the exactly size of the strings to don't spend memory. |
|||
![]() |
|
Borsuc 14 Jan 2010, 23:35
I think the stack is the only option you have without APIs. So you'll have to use the stack for it.
Define a big stack reserve (this does not allocate memory, it only reserves address space -- make it as big as you need to, you can't have larger buffer than this!), then everytime you "touch" a 4K memory page on the stack it allocates it -- this means if you put something or access that particular stack reserved page, it gets allocated. so conclusion: small stack commit size, big stack reserve size. Other than that, what's wrong with HeapAlloc? |
|||
![]() |
|
LocoDelAssembly 15 Jan 2010, 00:16
Quote:
Or using VirtualAlloc and then implementing the heap over the returned memory (which can also reserve memory space without actually occupying it in memory nor in swap file). Teehee, also note that Windows can't allocate less than 4KB (or the page size of the system) even with HeapAlloc. Of course, HeapAlloc will use those 4KB chunks to allocate as much as possible so a single HeapAlloc of, say, 16 bytes won't deplete the entire 4KB chunk. |
|||
![]() |
|
Teehee 15 Jan 2010, 09:08
Quote: Other than that, what's wrong with HeapAlloc? Nothing. I just want to know how to do that manually ![]() Thanks for tips guys. PS: Everything that goes in 'data section' is in heap space, right? |
|||
![]() |
|
ManOfSteel 15 Jan 2010, 11:46
No. Everything that is reserved (rb, rw, rd, etc.) will not be part of the .exe, but everything that is defined (db, dw, dd, etc.) will be.
Also, from the manual: Quote: heap directive chooses the size of heap for Portable Executable, value of heap reserve size should follow, optionally value of heap commit separated with comma can follow. When no heap is defined, it is set by default to size of 65536 bytes, when size of heap commit is unspecified, it is by default set to zero. |
|||
![]() |
|
baldr 15 Jan 2010, 19:32
ManOfSteel,
Not exactly. Everything uninitialized (rb/db ?) before last initialized item in section still appears in PE .Exe file, only trailing uninitialized items don't (remember file alignment though). _____ Teehee, Windows creates standard heap for process (even if you specify 0/0 as heap commit/reserve); you may use GetProcessHeap() to obtain it's handle. This heap (and any you create yourself) resides outside any sections. From where those paths are coming? HeapAlloc() / lstrlen() / HeapReAlloc() can be quite effective. _____ Borsuc, Stack allocation has one drawback: the technique Windows uses to commit stack pages (guard pages) requires them to be touched sequentially when allocated. |
|||
![]() |
|
ManOfSteel 15 Jan 2010, 21:18
baldr wrote: only trailing uninitialized items don't Yes, that's more precise and correct than what I said and it's exactly what I meant. I was thinking of r22's post when I posted my reply. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.