Questions tagged [virtualalloc]
64 questions
1
vote
1 answer
Function Pointers in VS-2010 ( + Virtual Alloc call)
As an experiment i am trying to write the following program which allows me to generate code during runtime. i.e. i do the following:
1. Fill a buffer with op-codes of the instructions i want to execute.
2. Declare a function-pointer and make it…

TheCodeArtist
- 21,479
- 4
- 69
- 130
1
vote
1 answer
How to (temporary) release memory from VirtualAlloc?
When using VirtualAlloc I can (ab)use the following property to simplify memory management.
Actual physical pages are not allocated unless/until the virtual addresses are actually accessed.
I run the following code to allocate the block.
type
…

Johan
- 74,508
- 24
- 191
- 319
1
vote
2 answers
Getting the lowest free virtual memory address in windows
Title says it pretty much all : is there a way to get the lowest free virtual memory address under windows ? I should add that I am interested by this information at the beginning of the program (before any dynamic memory allocation has been…

Norswap
- 11,740
- 12
- 47
- 60
1
vote
1 answer
the order of VirtualAlloc appears to matter (c++)
I am having some odd behavior when using virtualalloc. I'm in c++, Visual Studio 2010.
I have two things I want to allocate, and I'm using VirtualAlloc (I have my reasons, irrelevant to the question)
1 - Space to hold a buffer of x86 assembly code
2…

Without Me It Just Aweso
- 4,593
- 10
- 35
- 53
1
vote
1 answer
What is difference between BaseAddress and AllocationBase and between AllocationProtect and Protect in _MEMORY_BASIC_INFORMATION structure?
_MEMORY_BASIC_INFORMATION contains fields, that describe address space. I want to know what is the difference between BaseAddress and AllocationBase. BaseAddress is the base address of region, and what is AllocationBase?
Also, I want to know…

OSProgrammer
- 11
- 3
1
vote
1 answer
Write to process memory in c#
I want to write an offset to some address of process memory, but I cannot allocate memory or change the memory address type to be "writable". so I cannot write any offset or value to my process memory. I am not sure, but I think my process memory is…

Hemi Sh
- 21
- 1
- 2
1
vote
1 answer
Using VirtualQueryEx to enumerate modules at remote process doesn't return all modules
I am trying to get a list of DLLs that a given process is using, I am trying to achieve that through VirtualQueryEx. My problem is that it return to me just a partial list of DLLs and not all of them (i can see the list using Process Explorer or…

Hanan
- 1,169
- 3
- 23
- 40
1
vote
1 answer
VirtualAlloc failing on certain configurations of hdd
For some reason on my application when running on some configuration of hard disk (RAID, random partitions, through a separate IDE controller, not on the operating systems partition), VirtualAlloc returns null with the GetLastError code of…

Stowelly
- 1,260
- 2
- 12
- 31
0
votes
3 answers
New/delete[] and VirtualAlloc
#include
#include
using namespace std;
int main(void)
{
unsigned char* pFoo = new unsigned char[1000];
pFoo = (unsigned char*)VirtualAlloc(NULL, 1000, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
VirtualFree(pFoo, 0,…

replicant
- 329
- 3
- 13
0
votes
0 answers
Win32 application wired memory usage
I have write an win32 application using flutter 3.0.5. It uses some third party library and shared library also written by me.
Currently I found there is wired memory usage.
Once the application start up, it would take around 150MB memory. If I do…

user1896561
- 23
- 5
0
votes
0 answers
What's the difference between VirtualAlloc() vs CreateFileMappingW(INVALID_HANDLE_VALUE) + MapViewOfFileEx()
I'm trying to understand the difference between two ways of reserving virtual memory on Windows.
VOID * AllocateSome( SIZE_T cbSize, VOID * lpDesiredAddress )
{
HANDLE handle;
VOID * pv;
// lpDesiredAddress may be NULL.
// First:
…

Tim Williams
- 1
- 2
0
votes
1 answer
Reserving and Committing memory if needed
What are the downsides of using VirtualAlloc for arrays, reserving large chunk of address space, and committing pages when they are needed?
For example if I know max cap for my array, I can reserve address space for it, using VirtualAlloc, and…

Heorhiy
- 190
- 2
- 14
0
votes
0 answers
VirtualAlloc in specific memory range (Windows, x64)
I am trying to allocate a memory region with a specified maximum absolute distance from a given base address.
For example, let's say the base address is 0x007FFFFFFF400000 and I want to allocate a block of memory with size size that is reachable…

navix1337
- 47
- 4
0
votes
1 answer
Marshal.AllocHGlobal instead of VirtualAlloc from kernel32.dll on dotnet core 6
I have some legacy unmanaged code (unsafe, intptr) which uses VirtualAlloc method from kernel32.dll many times in order to allocate unmanaged intptrs.
This code is in a project which was upgraded from .net framework to .net 6 (core).
When I publish…

Hadar
- 1
- 2
0
votes
0 answers
Using page protection to surface pointer/iterator invalidation bugs
Context: A container class we are writing does not guarantee pointer/iterator stability over a certain operation, because the operation has to reallocate in rare circumstances. The danger is that users inadvertently write code that assumes…

Max Langhof
- 23,383
- 5
- 39
- 72