C ++ Detours 3.0 экспресс на MVS 2012 ошибка «идентификатор не найден»

Мой компилятор: Microsoft Visual Studio 2012.
Мой код работает на обходах 2.1, но я больше не могу скомпилировать его с помощью моего компилятора (модуль небезопасен для образа SAFESEH.). Мне нужно использовать более старый компилятор, такой как MVS2005, но я бы не хотел.

Поэтому мне нужно обновить мой код и использовать обходы 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 to PVOID.

2

Решение

DetourFunction а также DetourRemove были заменены на DetourAttach а также DetourDetach, Использовать их не так сложно, и библиотека поставляется с набором примеров, где вы можете увидеть, как использовать эти 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;
}
3

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector