#include "stdafx.h"
#include <Windows.h>
#include "MinHook.h"
#include "Xul\nspr.h"
#include <fstream>
#if defined _M_X64
#pragma comment(lib, "libMinHook.x64.lib")
#elif defined _M_IX86
#pragma comment(lib, "libMinHook.x86.lib")
#endif
typedef int (WINAPI *PR_WRITE)(PRFileDesc *fd, void * buf, PRInt32 amount);
PR_WRITE fpPR_WRITE = NULL;
int WINAPI fPR_WRITE(PRFileDesc *fd, void * buf, PRInt32 amount)
{
std::ofstream output("D:\\Data.txt", std::ios::out || std::ios::app);
output << buf << "\n";
return fpPR_WRITE(fd, buf, amount);
}
BOOL APIENTRY DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
MessageBox(NULL, L"All Right", L"All Right", MB_OK);
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
{
if (MH_Initialize() != MH_OK)
{
return 1;
}
if (MH_CreateHook(&PR_Write, &fPR_WRITE,
reinterpret_cast<void**>(&fpPR_WRITE)) != MH_OK)
{
return 1;
}
if (MH_EnableHook(&PR_Write) != MH_OK)
{
return 1;
}
break;
}
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
{
if (MH_DisableHook(&PR_Write) != MH_OK)
{
return 1;
}
if (MH_Uninitialize() != MH_OK)
{
return 1;
}
break;
}
}
return TRUE;
}
Если вместо PR_Write, например, MessageBox то все инжектит а если нет то даже не входит в DllMain.