EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Copying a locked file doesn't work anymore ?

Posted: 07/23/2010 12:25:21
by stephane  (Standard support level)
Joined: 03/17/2009
Posts: 39


I'm using rawdisk for a long time now and I wrote a CopyLockedFile() function that worked great but I've made some new testing recently on windows vista premium edition and it fails.

Driver version:
* TRawdisk.GetDriverStatus() is OK (sys driver is installed)
* TRawdisk.CreateFile(name,GENERIC_READ,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,key) is OK (return a valid file handle)
* But after that Windows.ReadFile() functions "waits" a few seconds (instead of returning instantly) and returns always false on the locked file (this is a simple text file that I opened with exclusive access in another application).

In order to be sure that my code is not buggy, can anyone show me a correct way to create a CopyLockedFile() function with Rawdisk driver ?

Thanks !
Posted: 07/23/2010 15:07:29
by Volodymyr Zinin (Team)

Hello Stephane,

I've tried to reproduce it but without success. Could you give us a test code (with sources) that has this problem?
Posted: 07/24/2010 11:20:25
by stephane  (Standard support level)
Joined: 03/17/2009
Posts: 39

Here is a very simple delphi code example (just tries to read the first 8192 bytes of a file with rawdisk).

[Note: you must first create a 'test.txt' file with some text inside]
[NOTE2: the elrawdsk.sys driver must be in the same directory as the executable]

=> All is ok except ReadFile(): hangs a few seconds and then returns false with GetLastError() =ERROR_IO_DEVICE 1117 (0x45D)

This occurs whenever 'test.txt' file is locked or not !
If I replace TRawdisk.CreateFile() with the standard windows CreateFile() then all is OK (returns an invalid handle if file is locked, else ReadFile() is ok).

uses RawDisk;

const  rawdiskkey:string='myvalidkey';

function GetFileSize(const APath: string): int64;
  Sr : TSearchRec;
  if FindFirst(APath,faAnyFile,Sr)=0 then
    Result := Int64(Sr.FindData.nFileSizeHigh) shl 32 + Sr.FindData.nFileSizeLow;
    Result := 0;

procedure ReadLocked(s:String);
const BUF_SIZE=1024*8;
var h:THandle;
    Buf2:array of Byte;
    BytesRead: Cardinal;
    InitialFileSize: int64;
  if (h=0) or (h=INVALID_HANDLE_VALUE) then
    ShowMessage('unable to open the file with rawdisk !');
  if InitialFileSize>0 then
      if not ok  then ShowMessage(Format('READ ERROR code=%d',[GetLastError()]))
      else ShowMessage('Read OK');
      ShowMessage('Exception !');

  try CloseHandle(h); except end;
  ShowMessage('Read end !');

procedure TForm1.Button1Click(Sender: TObject);
var RebootNeeded:longbool;
  if not TRawdisk.InstallDriver(name,'demoapp',RebootNeeded) then
    ShowMessage('unable to install driver !');  exit;
  // just read first 8ko bytes of locked file  test.txt  (locked by another delphi app : opened with exclusive access)

  if not TRawdisk.UninstallDriver('demoapp',RebootNeeded) then
    Showmessage('unable to uninstall driver !'); exit;
Posted: 07/25/2010 07:14:29
by goubin dylan (Standard support level)
Joined: 09/19/2006
Posts: 13

I confirm this issue on my Windows 7 Pro 64 bits edition since a few time.

It used to work before and suddenly it stops working.
Posted: 07/26/2010 04:50:55
by stephane  (Standard support level)
Joined: 03/17/2009
Posts: 39

As a side note and confirmation : I have tried the last elrawdsk.sys driver + the same delphi application on an old Windows XP SP3 virtual machine and all works fine.

There seems to be an issue with the last windows updates on vista/seven.
Posted: 07/26/2010 06:27:51
by Eugene Mayevski (Team)

Yes, we will check the issue this week. Vladimir Zinin is on vacation this week, and he asked to leave the issue to him, so he will investigate it either this or next week.

Sincerely yours
Eugene Mayevski
Posted: 08/02/2010 17:57:51
by goubin dylan (Standard support level)
Joined: 09/19/2006
Posts: 13

any news ?
Posted: 08/03/2010 01:29:41
by Volodymyr Zinin (Team)

Answered to the ticket you created in helpdesk.
Posted: 08/06/2010 07:55:35
by goubin dylan (Standard support level)
Joined: 09/19/2006
Posts: 13

We are still waiting for answers in our helpdesk;

i confirm Rawdisk does not work anymore on updated Windows 7 / Vista
Posted: 08/06/2010 09:40:22
by stephane  (Standard support level)
Joined: 03/17/2009
Posts: 39

We made some more testing (always with the example code) and the results are :

* Windows XP SP2 or Sp3 : OK [under virtual pc 2007 and oracle virtualbox]
* Windows 2003 server: OK [under oracle virtual box]
* one vista returns always : ERROR_INVALID_FUNCTION [real computer]
* another vista returns always: ERROR_IO_DEVICE [real computer]
* two 32 bit seven systems (french and english): ERROR_INVALID_FUNCTION [under oracle virtual box]
* one 64 bit seven system: ERROR_INVALID_FUNCTION [real computer]
* one 2008 server: ERROR_INVALID_FUNCTION [under oracle virtual box]

So it seems that the driver works on XP and 2003, but stopped working on 2008/Vista/Seven.

The most frequent error is ERROR_INVALID_FUNCTION when calling the win32 ReadFile() function.

Please note also that a try on an outlook.pst file (when outlook is running) hangs at the same time the test application (blocked in the readfile()) and the outlook interface => no other choice than a reboot !

This is obviously not a dephi code issue because this works fine on XP and 2003.

Hope this helps !



Topic viewed 27068 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!