1

I need to allocate in Special address. How can I force free parts of the memory to be allocated in the process ?

ZwFreeVirtualMemory(0,(LPVOID*)&(ImageBase),&(SizeOfImage),MEM_RELEASE );
1
  • 1
    This question appears to be off-topic because it is about a primarily malware-specific development technique, of unmapping the original process entirely in order to replace it with a new one. – peter ferrie Jun 2 '14 at 15:31
1

You could do that by attaching a debugger to the process and call the function from within the debugger. But, as this would invalidate all pointers from your application into that force-free'd area, your application would crash as soon as it tries to dereference one of that pointers.

The only way to make sure you can allocate a specific memory location is allocating it as soon as possible in your program, before anything else takes it away.

Please, when you post, tell us a bit more about what you want to do and why you want to do it. There's generally no good reason to allocate a specific address in virtual memory, but there might be reasons to have a map for a specific physical address if there's hardware at that address.

So i assume your question is an X-Y Problem, and your real question is "How can i allocate a chunk of virtual memory that maps to a certain physical address". But without any context, it's impossible to know how to help you.

1
  • in need this work in my program and i cant doing in another process. – user2522767 Jun 2 '14 at 9:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.