seeking on volume handles

seeking on volume handles

Post by qfel » Tue, 29 Jun 2004 19:57:52


I obtain the handle through

HANDLE
hFile=CreateFile("\\\\.\\F:",GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,N
ULL,OPEN_EXISTING,NULL,NULL);

GetFileType returns FILE_TYPE_DISK and I can read it sequentially so it
looks like file pointer is advanced, but GetFileSize and SetFilePointer
aren't working (both return error 87 that is ERROR_INVALID_PARAMETER). Why?
How can I read some bytes at n offset of volume?
I try to seek to multiplies of 512 if it cares, but it still hasn't anything
to do with GetFileSize.
My OS WinXP SP1

PS. It's said to use FILE_SHARE_WRITE when opening volumes. Why? It works
like read share, without FILE_SHARE_WRITE I cannot enumerate volume files
 
 
 

seeking on volume handles

Post by eMV » Wed, 30 Jun 2004 00:20:37

Hi,

Use overlapped access. FILE_FLAG_OVERLAPPED

And you can use structure like bellow to set offset:
OVERLAPPED ov={0};

ov.hEvent=CreateEvent(0, TRUE, FALSE, 0);

*(unsigned __int64 *)&ov.Offset=Offset;

Regards,
Slobodan

PS: You don't need shares if you can open your volume, if not you will need to suply it to obtain access to already opened volume.

 
 
 

seeking on volume handles

Post by Alexander » Wed, 30 Jun 2004 11:38:00

You can use OVERLAPPED for random access even if you don't specify
FILE_FLAG_OVERLAPPED.



need to suply it to obtain access to already opened volume.


hFile=CreateFile("\\\\.\\F:",GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,N
Why?
anything
works
files
 
 
 

seeking on volume handles

Post by eMV » Wed, 30 Jun 2004 11:45:52

Thanks Alexander,

I must admit that I have never tried that, but it is good to know this.

Regards,
Slobodan