分配的堆栈空间是否可能CreateThread
干扰 的使用VirtualAlloc
?我找不到任何讨论或文档来准确解释允许分配堆栈空间的位置......
以下更准确地说明了我的问题:
uint8_t *baseA = (uint8_t*)VirtualAlloc(NULL,1,MEM_RESERVE,PAGE_NOACCESS);
// Create a thread with the default stack size
HANDLE hThread = CreateThread(NULL,0,SomeThreadProc,NULL,NULL,NULL);
// Possibly create even more threads here.
// Can this ever fail in the absence of other allocators? It doesn't here...
uint8_t *baseB = (uint8_t*)VirtualAlloc(NULL,1,MEM_RESERVE,PAGE_NOACCESS);
// Furthermore, in this test, baseB-baseA == 65536 (unless the debugger did something),
// so nothing appeared between baseA and baseB... not even enough space for the
// full 64kb of wastage, as baseA points to 4096 bytes by itself
如果它确实使用了 的一些类似物VirtualAlloc
,有没有办法改变 Windows 在给定进程中分配堆栈空间的方式?