================ @@ -1,9 +1,76 @@ -#include <stdio.h> -#include <stdint.h> - -int main (int argc, char const *argv[]) -{ - const char* stringdata = "hello world; I like to write text in const char pointers"; - uint8_t bytedata[] = {0xAA,0xBB,0xCC,0xDD,0xEE,0xFF,0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99}; - return 0; // break here +#include <cstdint> +#include <cstdio> +#include <cstdlib> +#include <cstring> +#include <initializer_list> +#include <iostream> + +#ifdef _WIN32 +#include "Windows.h" + +int getpagesize() { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + return system_info.dwPageSize; +} + +char *allocate_memory_with_holes() { + int pagesize = getpagesize(); + void *mem = VirtualAlloc(nullptr, 5 * pagesize, MEM_RESERVE, PAGE_NOACCESS); + if (!mem) { + std::cerr << std::system_category().message(GetLastError()) << std::endl; + exit(1); + } + char *bytes = static_cast<char *>(mem); + for (int page : {0, 2, 4}) { + if (!VirtualAlloc(bytes + page * pagesize, pagesize, MEM_COMMIT, ---------------- DavidSpickett wrote:
So `PAGE_NOACCESS` allocates them but they are inaccessible (even to debug APIs?), then `PAGE_READWRITE` makes pages 0, 2 and 4 accessible. 1 and 3 are the gaps, correct? https://github.com/llvm/llvm-project/pull/104193 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits