gpt4 book ai didi

c++ - GetProcessDEPPolicy 错误 87

转载 作者:行者123 更新时间:2023-11-28 00:02:20 26 4
gpt4 key购买 nike

当我尝试检查某个进程是否正在使用数据执行保护 (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
);

请注意,最后一个参数是一个输出参数,它不是可选的,但您传递的是 0,也就是 NULL。调用应该是:

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

关于c++ - GetProcessDEPPolicy 错误 87,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37889449/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com