阅读:2608回复:2
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-01-24 05:08
char* p=new...
p="xxx"; 你这么做new的那部分内存根本没用上,直接泄露了。 |
|
板凳#
发布于:2010-01-24 12:36
TO:cracker_ma
那回调中应该怎么写入自己的内容到buf中啊??? |
|