I'm using:
MS VS 10
Detours v3.0 Express
The complete source code DLL:
#include <windows.h>
#include <detours.h>
ofstream prclist ;
#pragma comment(lib,"detours.lib")
FARPROC (WINAPI * pGetProcAddress)(HMODULE hModule,LPCSTR lpProcName) = GetProcAddress;
FARPROC WINAPI myGetProcAddress(HMODULE hModule,LPCSTR lpProcName);
FARPROC WINAPI myGetProcAddress(HMODULE hModule,LPCSTR lpProcName)
{
prclist << lpProcName << endl; // <- ACCESS_VIOLATION READ
return pGetProcAddress( hModule, lpProcName);
}
BOOL APIENTRY DllMain(HINSTANCE hDLL, DWORD reason, LPVOID reserved)
{
switch(reason)
{
case DLL_PROCESS_ATTACH:
{
prclist.open("proclst.log",ios::out | ios::app );
DisableThreadLibraryCalls(hDLL);
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)pGetProcAddress, myGetProcAddress);
DetourTransactionCommit();
break;
}
case DLL_PROCESS_DETACH:
{
prclist.close();
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)pGetProcAddress, myGetProcAddress);
DetourTransactionCommit();
break;
}
}
return TRUE;
}
I try to view the list of functions received by GetProcAddress. But after start, the program is closed with an error: "ACCESS_VIOLATION, UNABLE_TO_READ"
Somebody can prompt how to fix it ?
... DecodePointer
DecodePointer
EncodePointer
DecodePointer
DecodePointer
DecodePointer
EncodePointer
DecodePointer
DecodePointer
DecodePointer
IsDebuggerPresent
and This application has encountered a critical error: Program: Exception: 0xC0000005 (ACCESS_VIOLATION) at 001B:604DD950 The instruction at '0x604DD950' referenced memory at '0x00000068'. The memory could not be 'read'. Press OK to terminate the application. --------------------------- ОК --------------------------- – NORM_4EL Jun 02 '13 at 13:11