EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Handling errors in FileRead & FileWrite callbacks

Posted: 05/05/2011 02:21:29
by Oleg Savelos (Standard support level)
Joined: 08/25/2008
Posts: 21

Hi. I am curious what error code should be thrown in Read or Write callback if read error occours.
In my case i have a file being read or written over tcp connection and i want to inform the driver that the file read/write error occoured in case connection or some other error.
The problem now is that when generic CBFSError is thrown calling applications still tries to access the file and issiues read/write calls on the file.
Posted: 05/05/2011 07:09:13
by Eugene Mayevski (Team)

Use Win32 errors as an error code and no text (it's ignored). Unfortunately there's no way to pass error codes directly back to the user mode - they are converted to native API error codes and then back to Win32 errors (as you know, win32 is just a subsystem). During this double conversion some information can be lost (in other words there's a chance that the user-mode code will get another error that you reported). So the only way is an experiment.

Sincerely yours
Eugene Mayevski
Posted: 05/10/2011 12:14:50
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I have this same exact problem. I experimented with some error codes, specifically ERROR_READ_FAULT, and ERROR_UNIDENTIFIED_ERROR and both of those do not cause Windows to stop trying to read the file. The behavior I would like is for Windows to abort the read or write and put up an error window or message. Do you know of an error code that will cause that behavior?
Posted: 05/10/2011 12:25:01
by Eugene Mayevski (Team)

Did you try to just return 0 bytes read or written? This would tell Windows that something has gone wrong.

Sincerely yours
Eugene Mayevski
Posted: 05/10/2011 13:00:06
by Volodymyr Zinin (Team)

Use Process Monitor from sysinternals.com to look what happens in the system after you throw an error from the read/write callback. In order to look only I/O operations on your virtual disk set in Process Monitor the following filter:
"Path"->"Begins with"->"X:" (where 'X' is a drive letter for your disk).
Posted: 05/10/2011 13:21:28
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

OK, Vladimir, I'm on it!

I'll let you know what I find out.
Posted: 05/10/2011 13:54:31
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I'm having a very peculiar problem with Process Monitor. The first time I ran it, a few weeks ago, it seemed to work fine. I put in the filter as you suggested and I saw all the activity to my X: drive. Today, when I did the exact same thing, the process monitor showed me nothing, absolutely blank screen. Am I missing a check box somewhere? Maybe something like "Show processes from all users" or "Show processes from all sessions"?
Posted: 05/10/2011 14:43:34
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I fixed my problem with Process Monitor, but it still doesn't ahow me anything after throwing the exception. It seems like Windows or your driver are not even seeing that exception.
Posted: 05/10/2011 14:55:24
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

It is pretty easy to simulate this in the Mounter sample. Just put a throw of an ECbFsError in the CbFsReadFile callback. Maybe if you run it with process monitor you'll see something I don't.
Posted: 05/11/2011 09:12:35
by  Victor Voytko
Trying to reproduce your issue, put a throw of an ECbFsError in the CbFsReadFile callback of the C# VMounter sample


Then set the Process Monitor filter to 'Path | contains | Z:', run the sample and added Z: mounting point. When I tried to open Z:\TestFile_1.txt file, the message from Notepad 'Cannot open the Z:\TestFile_1.txt file' appeared.
After that, looking throw the Process Monitor log I can see the item

NOTEPAD.EXE | ReadFile | Z:\TestFile_1.txt | ACCESS DENIED

which corresponds to the thrown exception.
So it seems like I cannot reproduse your problem.

Tested on Win7 x64 with the latest CbFS code.



Topic viewed 4371 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!