>>102449401
Ok my bad, I did make a mistake, if I use MEM_RESERVE it won't commit memory. The problem is that I can't allocate more than I can commit, so if I try 4 gigs, it won't work, and it's probably related to the fact I have 16gb of ram, it doesn't make a difference with PAGE_NOACCESS or not.
So I guess if you use VirtualAlloc and try to allocated 64gb, it won't work on my PC.
You are 100% correct.
However I just tested address sanitizer and it didn't work.
This is my monkey code (I would have used getline if it was C++, you need to type "1")
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
int main(int argc, char**argv)
{
int size = 4 * 1024 * 1024 *1024ULL;
if(argc == 2)
{
size = atoi(argv[1]);
}
printf("start\n");
int t;
scanf("%d",&t);
//void*ptr = malloc(size);
char* ptr = (char*) VirtualAlloc(NULL,size ,MEM_RESERVE ,PAGE_READWRITE);
int d = GetLastError ();//errno;
ptr[0] = '0';
printf("%p|%c|%lu\n",ptr,ptr[0], d);
scanf("%d",&t);
//free(ptr);
VirtualFree(ptr, 0, MEM_RELEASE);
d = GetLastError ();
printf("Done %lu\n", d);
scanf("%d",&t);
return 0;
}
cl /O2 /fsanitize=address test.c test