Answer the question
In order to leave comments, you need to log in
Why doesn't it inject a certain function?
#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;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question