簡體   English   中英

GetProcessDEPPolicy錯誤87

[英]GetProcessDEPPolicy error 87

當我嘗試檢查某個進程是否正在使用數據執行保護(DEP)時,出現錯誤87(INVALID_PARAMETER)。 我檢查了我的代碼,這似乎還可以,但是不幸的是我仍然遇到相同的錯誤。

碼:

BOOL var = true;
DWORD dwPolicy;

HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, false, 3624);
if (hProc == NULL) {
    cout << "Can't open Process because of the error " << GetLastError() << endl;
}

if (GetProcessDEPPolicy(hProc, &dwPolicy, 0) != FALSE) {
    if (dwPolicy == PROCESS_DEP_ENABLE) {
        cout << "For try.exe process data execution prevention is enabled" << endl;

    }
    else if (dwPolicy == NULL) {
        cout << "For try.exe process data execution prevention is disabled" << endl;
    }
    else {
        cout << "Data is thrunked and we can't change DEP value in future" << endl;
    }
}
else {
    cout << "There was an error with discovering DEP in try.exe process because of "<<GetLastError() << endl;
}

編譯並執行后,我得到:

There was an error with discovering DEP in try.exe process because of 87

在文檔中,定義了GetProcessDEPPolicy函數:

BOOL WINAPI GetProcessDEPPolicy(
  _In_  HANDLE  hProcess,
  _Out_ LPDWORD lpFlags,
  _Out_ PBOOL   lpPermanent
);

請注意,最后一個參數是out參數,它不是可選參數,但是您要傳遞0 aka NULL 該電話應為:

BOOL permanent = FALSE;
if (GetProcessDEPPolicy(hProc, &dwPolicy, &permanent) != FALSE) {

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM