Originally posted by funkylunch
that still doesn't explain when it would be better to use virtual alloc. Is virtual alloc pointless?
It wouldnt be better to use VirtualAlloc unless you needed to allocate a block of memory that you dont want to accomodate in the heap (such as a large block of memory that you dont want to burden your heap with)....or if you need to allocate a block at a specific point in your usermode address space

I imagine that when you call LoadLibrary to load a dll at runtime, there might be a call to VirtualAlloc to reserve some memory for that image within your address space before the contents of the dll are loaded into memory......that might be the case - I havent sat there with a debugger to test it, but it gives you an idea as to it's uses. Look out for some of the earlier books by Jeff Prosise such as Advanced windows...that will give you a good look at this type of stuff