• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1784
  • Last Modified:

Syntax to open a raw windows 2000 partition using CreateFile


What would be the correct naming scheme to open a raw windows 2000 partition using CreateFile?

hDevice = CreateFile("\\Device\\Harddisk0\\Partition0",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);

fails with the error

"The system cannot find the path specified"

My understanding is that \Device\Harddisk0\Partition0 is actually a symbolic link.

0
kdkirmse
Asked:
kdkirmse
  • 3
  • 2
1 Solution
 
_corey_Commented:
Well, you are able to open drives and volumes using the syntax:

\\.\PHYSICALDRIVE# where # is the volume number.

What kind of access do you need?

corey
0
 
jkrCommented:
>>My understanding is that \Device\Harddisk0\Partition0

It is - in the kernel's namespace, though. Have you tried "\\\\?\\Device\\Harddisk0\\Partition0" (yes, this is a shotin the dark from userland)? Apart from that, I'd suggest using the drive letter like '\\.\C:' aka "\\\\.\\C:"
0
 
_corey_Commented:
>>Have you tried "\\\\?\\Device\\Harddisk0\\Partition0"

Possibly it's not accessible in user land.  Using the \\?\ mode would simply not do path parsing, so probably less of a chance.

I think only volumes and mount points are accessible, but I'd be interested to hear if not.

corey
0
 
jkrCommented:
That's why I called it "a shot in the dark :o)

'NtCreateFile()' (http://msdn.microsoft.com/library/en-us/devnotes/winprog/ntcreatefile.asp) should work, though - especially with "\\Device\\Harddisk0\\Partition0"
0
 
_corey_Commented:
Hey guys,

In user mode looks like you should be able to use:

\\?\GLOBALROOT\Device\HarddiskVolumeX and partition

and

\\.\GLOBALROOT\C:\Partition0

Use this to read the raw sectors/etc.

corey
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now