flat assembler
Message board for the users of flat assembler.
Index
> Windows > Dynamic Memory Allocation |
Author |
|
revolution 27 Feb 2009, 08:34
LocalAlloc, LocalFree
VirtualAlloc, VirtualFree HeapAlloc, HeapFree. |
|||
27 Feb 2009, 08:34 |
|
FlitTear 27 Feb 2009, 08:42
Oh, thank you very much. I'll try those.
|
|||
27 Feb 2009, 08:42 |
|
Picnic 27 Feb 2009, 08:59
Hi FlitTear,
Here is a small example -written on the fly- using VirtualAlloc, maybe it helps. Code: ; Allocate virtual memory format PE GUI 4.0 include 'win32ax.inc' MEMSIZE = 256 .data MemArea dd ? .code main: mov eax, MEMSIZE invoke VirtualAlloc, 0, eax, MEM_COMMIT + MEM_RESERVE, PAGE_READWRITE test eax, eax je exit mov [MemArea], eax ; code invoke VirtualFree, [MemArea], 0, MEM_RELEASE exit: invoke ExitProcess, 0 .end main |
|||
27 Feb 2009, 08:59 |
|
revolution 27 Feb 2009, 09:20
thimis wrote:
Win32 docs for VirtualAlloc wrote: dwSize |
|||
27 Feb 2009, 09:20 |
|
sinsi 27 Feb 2009, 09:52
For dynamic memory (re)allocation, use the 'Heapxxx' functions - there's even HeapReAlloc (never used the heap functions myself).
|
|||
27 Feb 2009, 09:52 |
|
Picnic 27 Feb 2009, 09:53
Thanks for pointing that out revolution!
|
|||
27 Feb 2009, 09:53 |
|
iic2 27 Feb 2009, 14:18
You'll also find years of study about dynamic memory here. ..
http://f0dder.reteam.org/ click > [ARTICLES] |
|||
27 Feb 2009, 14:18 |
|
FlitTear 27 Feb 2009, 16:02
Thanks for all your replies.
I think i'm going to use the VirtulAlloc base on the link given by iic2. It says their that heapalloc failed on 9x and i might run the prog on 98 |
|||
27 Feb 2009, 16:02 |
|
comrade 28 Feb 2009, 10:34
That is bad advice then.
There is nothing wrong with using HeapAlloc on 9x. If you plan on using VirtualAlloc, you will be committing a full page even though you might only want to allocate ten bytes. |
|||
28 Feb 2009, 10:34 |
|
iic2 01 Mar 2009, 10:12
You read f0dder site wrong, but at lease you are learning when, where and why. It takes time to catch on to ASM and when you do you'll never turn back.
f0dder recommend HeapAlloc above all else. Fact is, 99% of all he say is correct. He came from the from the stone age with many others around this ASM world. Just be glad that they are willing to share all of that experience with us youngster. I use HeapAlloc where it's needed but VirtualAlloc proved to work for me and did something special. I been off of ASM for a while. I forgot what ... but it did WIN on my 2-4 k data block ... They both are API and best of all you are not stuck to using only one API and the cost to use it is still only one dword in size per API to include in any program and the speed is about the same. Here's a test result preformed by another great coder known as MichaelW. Silently search this forum and Google for a few days and learn it all. It took me years of spare time to make up my mind and we all still ask the same question and f0dder will tell us again and again so don't feel shy. Code: At start 684 168 After 16 calls to GlobalAlloc 1720 1260 After 16 calls to GlobalFree 696 172 After 16 calls to HeapAlloc 824 1260 After 16 calls to HeapFree 696 172 After 16 calls to VirtualAlloc 696 1196 After 16 calls to VirtualFree 696 172 BTW: Dump 9x when it comes to today's projects. It's an NT world now. 9x just like DOS is DEAD but old school still love it like me. XP SP2 buck up my entire 9x-XP project with DEP. Who knows what's next in this NT world... 9x is a waste of time other than for a personal tool that rules if you catch the clue. I still love Windows 95 |
|||
01 Mar 2009, 10:12 |
|
FlitTear 05 Mar 2009, 02:39
I'm taking back what i said about using VirtualAlloc.
Actually i can't think of how will i use those extra bytes 'cause i only need 120b. I've thought about link list that can delete a block in between and can also sort the list but i think it will take time for me code it (I'm still new to ASM). Also my deadline is next week. So I used the HeapAlloc for simple management of X numbers of 120b. |
|||
05 Mar 2009, 02:39 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.