PDA

View Full Version : QFile: cannot retrieve size from PHYSICALDRIVE



brasco2k9
24th February 2013, 16:49
I wrote a tool which was originally thought for analyzing hard disc images. Now I'm trying to use this tool for live analyzis of computer systems, means my tool tries to access the physical drive.

I implemented my tool in QT accessing the images using the QFile class. Instead of images I hand over the physical drive, under windows it is \.\PHYSICALDRIVE0.

I was wondering first I didnt get any errors, I can open the device, I can seek, get the position, almost everything. The only thing I have problems with is retrieving the drive size with size().

Some code example:

QFile file( "\\.\PHYSICALDRIVE0" );
file.open( QIODevice::ReadOnly );

file.size(); //returns 0

I'm not too deep into QT, probably this is some easy thing. I would like to thank everybody who has an idea what is the reason.

thanks in advance!

d_stranz
24th February 2013, 17:53
What happens if you open this file using fopen(), fseek() to SEEK_END then call ftell()? Do you still get 0?

Perhaps this really isn't a "file" in the normal sense. Some operations might appear to work, but others fail because the underlying device isn't a real file.