flat assembler
Message board for the users of flat assembler.

Index > Windows > VirtualAlloc trouble

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
windwakr



Joined: 30 Jun 2004
Posts: 827
Location: Michigan, USA
windwakr
Neat.


Description:
Filesize: 4.59 KB
Viewed: 913 Time(s)

bigallocation.PNG



_________________
----> * <---- My star, won HERE
Post 21 Dec 2009, 02:14
View user's profile Send private message Reply with quote
sinsi



Joined: 10 Aug 2007
Posts: 709
Location: Adelaide
sinsi
64-bit
Image
Post 21 Dec 2009, 02:37
View user's profile Send private message Reply with quote
blacky



Joined: 06 Apr 2006
Posts: 32
Location: JA
blacky
heh that snippet should probably free it too before exiting.
(i know by default the system will free the memory, just saying)
Post 24 Dec 2009, 02:59
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17664
Location: In your JS exploiting you and your system
revolution
blacky: Sure. But it is just simple test. Not worth the extra effort IMO.
Post 24 Dec 2009, 03:15
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
As Borsuc already said, (Local|Global)Alloc functions are implemented on top of HeapAlloc for default process heap. Both of them don't compact or whatever in case of allocation failure. Indeed LocalAlloc(LMEM_FIXED,...) almost immediately calls HeapAlloc(BaseHeap,...) and returns pointer it get (SetLastError(ERROR_NOT_ENOUGH_MEMORY) if NULL). XP x86-32 SP3.

Heap functions are useful because you can discard entire private heap with single HeapDestroy(), no matter how complex is your data structure stored inside.

GlobalAlloc has some logic around GMEM_SHARE, this is probably for interprocess communication (DDE, clipboard?).
Post 24 Dec 2009, 10:06
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3170
Location: Denmark
f0dder
Local/GlobalAlloc are indeed implemented on top of HeapAlloc, but use an undocumented allocation flag. Generally, don't bother with local/globalalloc in new code but use heapalloc, you'll save a few instruction cycles...

However, when dealing with things where MSDN explicitly specifies you should use local/globalalloc memory (clipboard, createstreamonhglobal), do stick with them - that little magic flag does make the allocation a slight bit different. Last time I dug into the issue (XP SP2, I think - but it's been enough years that it could have been Win2000) the local/globalalloc functions caused some 4 or 8 bytes of information to be prepended to the allocated memory.
Post 25 Dec 2009, 14:46
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3

< 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.