How to create file with help of P/Invoke to read boot sector and display .MBR?
Asked Answered
M

2

1

I've browsed through the CreateFile documentation... still wondering how should I use P/Invoke to call CreateFile and to read the boot sector, to display out the .MBR?

Any reference code for this portion? Thank you in advance!

Mcgean answered 5/1, 2009 at 9:23 Comment(0)
L
3

To expand on Baget's answer, you can call CreateFile like this:

hFile = CreateFile("\\\\.\\physicaldrive0", 
    GENERIC_READ | FILE_SHARE_READ,
    0,
    OPEN_EXISTING,
    0,
    0);
Lookout answered 5/1, 2009 at 9:37 Comment(1)
Vote up, because of the example :-)Hypomania
H
1

Maybe this question will help you

Basically you need to access a device using this syntax in the filename "\\.\PHYSICALDRIVE0"

Hypomania answered 5/1, 2009 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.