EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Troubles with Excel files on CBFS volumes

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#25500
Posted: 07/02/2013 08:26:45
by Andrew Solonovich (Standard support level)
Joined: 04/05/2013
Posts: 12

Hello!

We encounter strange behaviour with excel files using CBFS 4 and need some help.

We try to develop a system that behaves exactly as shared drive on Windows.
Usually when user opens xls file from shared drive - no one can open the same file for writing - excel say that file can be opened only for reading (it else proposes to notify when file will become available).
Internally it made by locking file by process - and no other process can open this file for writing.

Using cbfs, we want to support this behavior. On Win7 everything is ok - file is opened for write and locks correctly. But there a trouble on WinXP (x86) - excel does not open file for write - it opens it for read - and it is not possible to lock the file.

We try use Mapper from examples, but with a little change in CbFsOpenFile callback - when it calls CreateFile we pass to it FileAccess from arguments:

sfh = CreateFile( mRootPath + FileName,
DesiredAccess,//GENERIC_READ | GENERIC_WRITE,
FileShare.ReadWrite | FileShare.Delete,
IntPtr.Zero,
FileMode.Open,
FILE_ATTRIBUTE_NORMAL,
IntPtr.Zero );

If to run this changed Mapper on WinXp (x86), and try to open xls file from mapped directory with excel 2010 - appears windows popup notification with error text (sorry for russian, if it is not clear - I try translate it into english):

Quote
Тип события: Уведомление
Источник события: Application Popup
Категория события: Отсутствует
Код события: 26
Дата: 02.07.2013
Время: 16:14:34
Пользователь: Н/Д
Компьютер: ......-VM-XP
Описание:
Всплывающее окно приложения: Windows - Ошибка отложенной записи : Не удалось сохранить все данные файла \Device\00000089\Грунт.xls. Часть данных потеряна. Эта ошибка может быть вызвана отказом оборудования компьютера или сетевого подключения. Попытайтесь сохранить этот файл в другом месте.



On windows system event log this present too.
And after closing Mapper (Delete-Unmount-Delete storage-Close App) unhandled exception occurs. In windows application event log present next error:

Quote
Тип события: Ошибка
Источник события: cbfs4
Категория события: Отсутствует
Код события: 1
Дата: 02.07.2013
Время: 15:48:13
Пользователь: Н/Д
Компьютер: ......-VM-XP
Описание:
5
Данные:
0000: 53 06 00 00 4d 61 79 20 S...May
0008: 32 34 20 32 30 31 33 00 24 2013.
0010: 2e 2e 5c 75 6d 6f 64 65 ..\umode
0018: 5c 63 62 66 73 61 70 69 \cbfsapi
0020: 5c 63 62 66 73 61 70 69 \cbfsapi
0028: 2e 63 00 .c.


When run Mapper on different computers, map it to same shared folder, and open xls file from one computer by one user, than by another - second one is opens file without any messages that file is already in use.

Any help appreciated!

Thanks in advance.
#25501
Posted: 07/02/2013 09:23:41
by Volodymyr Zinin (EldoS Corp.)

Most probably there are several file open requests in parallel. But in the case the property CallAllOpenCloseCallbacks is not set the OnOpen callback is called only for the first opening. And this opening can request the "read-only" access. This causes that modified by you CreateFile API call returns a "read-only" handle, which can't be used successfully in API calls that modify the file (for example WriteFile).

Check first whether the property CallAllOpenCloseCallbacks is set and then open (or reopen) a "backend file" in your OnCreate/OnOpen callback with maximum requested access rights (concatenated from all parallel open requests). And close this file only in the last OnClose callback.

BTW some kernel mode code (for example which belongs to antiviruses) in order to workaround access restriction can open a file with DesiredAccess which is zero, but then manually can generate request to read/write the file.
#25503
Posted: 07/02/2013 09:30:03
by Volodymyr Zinin (EldoS Corp.)

BTW you can use Process Monitor from sysinternals.com to see what I/O requests the system sends to CallbackFS. Usually it's easy to match them with the callbacks. Just set there the filter to show only I/O requests for your virtual disk (by setting the filter rule "Path"->"begins with"->"X:", where "X:" is drive letter for your disk) and mark the menu item "Filter->"Enable advanced output".
#25506
Posted: 07/02/2013 10:19:46
by Andrew Solonovich (Standard support level)
Joined: 04/05/2013
Posts: 12

Thanks for the answer.

Quote
Vladimir Zinin wrote:
Most probably there are several file open requests in parallel. But in the case the property CallAllOpenCloseCallbacks is not set the OnOpen callback is called only for the first opening. And this opening can request the "read-only" access.

this was my first assumption, but it does not confirmed (my first question today was exactly because of this). I'll check it more accurate.
Why this occurs only on WinXP?

I spent much time investigating problem with excel files, but with no success. It looks like that there is a bug somewhere..

There is also interesting feature which does not work properly with cbfs (and not only cbfs) - is excel file with 'common access'. I think that it somehow connected with troubles desribed earlier.

What about Process Monitor - it for some reason does not show all requests on WinXp, which show on Win7 with the same filters. I can see only requests to the server where files located, but no requests from excel or explorer to cbfs mapped volume..
#25518
Posted: 07/03/2013 04:10:35
by Volodymyr Zinin (EldoS Corp.)

Moved to HelpDesk.
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 1880 times

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




|

Back to top

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

Got it!