I want to use the windows api call GetWriteWatch()
. This method takes an void*
array that I allocated on the stack like that: void* lpAddresses[PAGE_COUNT];
The problem now is, that PAGE_COUNT
needs to be large and this leads to a stackoverflow.
How do I write this to allocate the memory on the heap?
I tried:
void* lpAddresses = ::operator new[](PAGE_COUNT);
void* lpAddresses = ::operator new(PAGE_COUNT);
void* lpAddresses = malloc(PAGE_COUNT*sizeof(void*));
but that results in an error code from GetWriteWatch()
The version on the stack that works:
ULONG_PTR lpdwCount = PAGE_COUNT;
void *lpAddresses[PAGE_COUNT];
ULONG lpdwGranularity;
UINT result = GetWriteWatch(WRITE_WATCH_FLAG_RESET, m_rawMemory.as_void, m_alloc_size, lpAddresses, &lpdwCount, &lpdwGranularity);
Thanks