阅读:1952回复:1
Hook ReadFile问题 ,请高手们帮忙了
代码如下,我挂接了ReadFile,下面为回调函数,我想先读取到文件内容,之后写入自己的内容到m_pBuf ,为什么我写的内容,显示不出来,而且会报Debug异常?哪位大侠做过类似的挂接,请指教啊?
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 ) { bool nResult = TRUE; int iFileSize = 8; char *m_pBuf = new char[iFileSize+1]; memset(m_pBuf,0,iFileSize+1); ::ReadFile(hFile,m_pBuf,iFileSize,lpNumberOfBytesRead,lpOverlapped); //文件内容读到m_pBuf中,下面改写了内容,放入缓存Buf中,让文件读取出来的是我写的内容!?????? m_pBuf = (char *)"zxcvzxcv"; nResult = ((PFNReadFile)(PROC)g_ReadFile)(hFile, m_pBuf, iFileSize, lpNumberOfBytesRead, lpOverlapped); return nResult; } |
|
沙发#
发布于:2010-02-02 09:19
再读到m_pBuf中不是把上一次的缓存内容覆盖掉了吗?
|
|