私は Windows 7 、64ビットアプリケーションに取り組んでいます。
大きなページの割り当てが成功した後、VirtualProtect を使用して PAGE_GUARD 保護フラグを最初の大きなページに設定しようとしています。これは私が使用しているコードです:
unsigned long long memSize = 1024*1024*1024;
char* data = (char*)VirtualAlloc(NULL, memSize, MEM_RESERVE|MEM_COMMIT|MEM_LARGE_PAGES, PAGE_READWRITE);
//make the first large page in the allocated buffer be a guard page
DWORD oldProtect;
SIZE_T pageSize = GetLargePageMinimum();
LPVOID startPtr = data;
bool res = VirtualProtect(startPtr, pageSize, PAGE_READWRITE | PAGE_GUARD, &oldProtect);
GetLastError() はエラー 487 を返します - 「無効なアドレスにアクセスしようとしています。」
通常のページ (4KB) に PAGE_GUARD 保護を割り当てて設定している間、すべてが正常に機能しています。
大規模ページに対するガード保護はサポートされていますか? もしそうなら、私のコードの何が問題なのですか?
前もって感謝します。