Hello All,
I need to intercept any Read/Write operations with RAM, Storage Card
and HardDisk(If there is one in PocketPC, i don't really know). So I am
trying to use FSDSPY Example code using Visual Studio 2005(Not Platform
Builder).
Registry Settings Done:
===============
HKEY_LOCAL_MACHINE\System\StorageManager\FATFS\Filters\FSDSPY
Name Type Value
Dll String FSDSPY.dll
Order DWORD 0
I have added Log messages to the file under \\Temp Directory while any
directory is created in RAM, Storage Card. But Messages gets logged only when
there is operation with Storage Card. This is the way I made sure FSDSPY.dll
is working fine.
Questions:
=======
1. Is there a way to intercept RAM read/Write file operations?
2. By doing the above registry settings, the File System Filter is
applicable for all the storage. Is this understanding correct?
Now i tried to write an UI Application to Call DeviceIOControl() of FSDSPY
example.
void GetItWorked()
{
HANDLE hCommDevice = INVALID_HANDLE_VALUE;
HANDLE hCommEvent = INVALID_HANDLE_VALUE;
DWORD dwReturn;
TCHAR Buf[128];
BOOL DevIORes = FALSE;
int error;
hCommDevice = CreateFile(_T("DSK1:"), // drive to open
GENERIC_READ | GENERIC_WRITE, // no access to the drive
FILE_SHARE_READ | FILE_SHARE_WRITE, // share mode
NULL, // default security attributes
CREATE_ALWAYS, // disposition
FILE_ATTRIBUTE_NORMAL, // file attributes
NULL); // do not copy file attributes
if(hCommDevice == INVALID_HANDLE_VALUE)
{
error = GetLastError();
wsprintf(Buf , L"Error [%d]",error);
MessageBox(NULL , Buf , L"Error" , MB_OK);
}
else
{
MessageBox(NULL , L"Success in getting the DSK1 handle!!" , L"Info" ,
MB_OK);
}
hCommEvent = CreateEvent(NULL, false, false, NULL);
if( hCommEvent )
{
//download event object to device driver
DevIORes = DeviceIoControl( hCommDevice,
0 ,
(LPVOID) hCommEvent,
0,
NULL,
0,
&dwReturn,
NULL);
if( DevIORes == TRUE )
{
MessageBox(NULL , L"Success in Calling DevIOCtrl!!" , L"Info" , MB_OK);
}
}
else
{
error = GetLastError();
wsprintf(Buf , L"Error [%d]",error);
MessageBox(NULL , Buf , L"hCommEvent Error" , MB_OK);
}
}
Questions:
=======
3. To get the Driver handle so as to call DeviceIOControl(), i used L"DSK1",
was this right, since DeviceIOControl of FSDSPY is NOT called?
Thanks in advance
-Srini