VC ++:如何挂接/解开API ReadFile [英] VC++ : how to hook/unhook API ReadFile
本文介绍了VC ++:如何挂接/解开API ReadFile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们在全球范围内都使用ReadFile方法.
Hi,
We are hooking ReadFile methods GLOBALLY .
CAPIHook g_ReadFile; //the main object of CAPIHook!
typedef bool (WINAPI *PFNReadFile)(
__in HANDLE hFile,
__out LPVOID lpBuffer,
__in DWORD nNumberOfBytesToRea
__out LPDWORD lpNumberOfBytesRead
__in LPOVERLAPPED lpOverlapped );
bool WINAPI MyReadFile(
__in HANDLE hFile,
__out LPVOID lpBuffer,
__in DWORD nNumberOfBytesToRead,
__out LPDWORD lpNumberOfBytesRead,
__in LPOVERLAPPED lpOverlapped )
{
char * m_pBuf = (char *)"zxcvzxcv"; //The problem is here, how to write my own data into the Buffer,and displayed it out?
DWORD len = 0;
nResult = ((PFNReadFile)(PROC)g_ReadFile)(hFile, m_pBuf, strlen(m_pBuf), &len, NULL);
return nResult;
}
这会产生垃圾!怎么修改?
请提供帮助.
谢谢
This will produce garbage! How to modify?
Please provide help.
Thank you
推荐答案
看上面的内容,我建议您熟悉普通的 ^ ],然后尝试使用挂钩.
Looking at the above I would suggest you get familiar with ordinary File Management[^], before trying to use hooking.
这篇关于VC ++:如何挂接/解开API ReadFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文