gpt4 book ai didi

C++ Detours 3.0 Express on MVS 2012 错误 "identifier not found"

转载 作者:搜寻专家 更新时间:2023-10-31 01:49:49 24 4
gpt4 key购买 nike

我的编译器:Microsoft Visual Studio 2012。
我的代码在 detours 2.1 上可以正常运行,但我不能再用我的编译器编译它(模块对 SAFESEH 图像不安全。)。我需要使用像 MVS2005 这样的旧编译器,但我不想这样做。

所以我需要更新我的代码并使用 detours 3.0。

编辑了一些东西,出现了 4 个错误。

error C3861: 'DetourFunction': identifier not found
error C3861: 'DetourFunction': identifier not found
error C3861: 'DetourRemove': identifier not found
error C3861: 'DetourRemove': identifier not found

这是代码块:

此处出现 DetourFunction 错误

o_NtQuerySystemInformation = (t_NtQuerySystemInformation)DetourFunction((PBYTE)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation"), (PBYTE)My_NtQuerySystemInformation);
o_ZwOpenProcess = (t_ZwOpenProcess)DetourFunction((PBYTE)GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwOpenProcess"), (PBYTE)My_ZwOpenProcess);

DetourRemove 这里的错误

    DetourRemove((PBYTE)o_NtQuerySystemInformation, (PBYTE)My_NtQuerySystemInformation);
DetourRemove((PBYTE)o_ZwOpenProcess, (PBYTE)My_ZwOpenProcess);

更新

因此,我尝试将其更改为 DetourAttach 和 DetourDetach,但出现 PBYTE 到 PVOID 错误。

最佳答案

DetourFunctionDetourRemove 已替换为 DetourAttachDetourDetach。使用它们并不难,库附带了一组示例,您可以在其中了解如何使用这些 API。您的代码应如下所示:

BOOL APIENTRY DllMain( HANDLE hModule, 
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
o_NtQuerySystemInformation = (t_NtQuerySystemInformation)DetourAttach(&(PVOID&)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation"), My_NtQuerySystemInformation);
o_ZwOpenProcess = (t_ZwOpenProcess)DetourAttach(&(PVOID&)GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwOpenProcess"), My_ZwOpenProcess);

MyModuleHandle = (HMODULE)hModule;
MyPid = GetCurrentProcessId();
}
if (ul_reason_for_call == DLL_PROCESS_DETACH)
{
DetourDetach(&(PVOID&)o_NtQuerySystemInformation, My_NtQuerySystemInformation);
DetourDetach(&(PVOID&)o_ZwOpenProcess, My_ZwOpenProcess);
}

return TRUE;
}

关于C++ Detours 3.0 Express on MVS 2012 错误 "identifier not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16013559/

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