Hello:

I've been trying for the last few days to access a hard disk in windows and be able to read in raw format (a la dd).

I've tried many ways and somewhat been successful but not good enough. I tried forking dd and then read its output, but on large disks the buffer just grows too much and the program dies. I need to be able to control the buffer, so I guees I must open the file in perl without using an external program.

I have been trying using the Win32API, but without success. The following code works on a normal file, but not when i try to open a partition or a physical disk. The Function OsFHandleOpen just dies saying wrong parameter. Any ideas on how can i fix this, or some other way to read the raw disk in perl?



use Win32API::File 0.08 qw( :ALL );

$winHandle= createFile( "//./c:", "r") or die "$^E\n";
OsFHandleOpen( FILE, $winHandle, "r" ) or die " $^E\n";

while(<FILE>){
print "$_\n";
}

In reply to Reading a physical disk in windows as a File by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.