Click here to Skip to main content
16,022,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
We are hooking ReadFile methods GLOBALLY .
C++
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
Posted
Updated 26-Jan-10 2:01am
v2

1 solution

Looking at the above I would suggest you get familiar with ordinary File Management[^], before trying to use hooking.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900