Ace128 has asked for the wisdom of the Perl Monks concerning the following question:
Comments?use Win32API::File qw /:Func :IOCTL_DISK_ :MEDIA_TYPE :Misc/; use Data::Dumper; use strict; use warnings; use diagnostics; my $sDosDeviceName = []; my $osTargetPath; my @devices = Win32API::File::QueryDosDevice($sDosDeviceName, $osTarge +tPath, []) or die "Can't open: $^E\n"; print Dumper($sDosDeviceName); #foreach (@devices) { # print $_ . "\n"; #} my $hObject = createFile( "//./PhysicalDrive3", "r", "rw") or die "Can't open: $^E\n"; #Usage: Win32API::File::DeviceIoControl(hDevice, uIoControlCode, pInBu +f, lInBuf, opOutBuf, lOutBuf, olRetBytes, pOverlapped) my $opOutBuf; my $olRetBytes; Win32API::File::DeviceIoControl($hObject, IOCTL_DISK_GET_DRIVE_GEOMETR +Y, [], 0, $opOutBuf, [], $olRetBytes, []); # Calculate the number of DISK_GEOMETRY structures returned: my $cStructs = length($opOutBuf)/(4+4+4+4+4+4); my @fields = unpack( "L l I L L L" x $cStructs, $opOutBuf ); my( @ucCylsLow, @ivcCylsHigh, @uMediaType, @uTracksPerCyl, @uSectsPerT +rack, @uBytesPerSect ) = (); print Dumper(@fields); my $ucCylsLow = shift @fields; my $ivcCylsHigh = shift @fields; my $uMediaType = shift @fields; my $uTracksPerCyl = shift @fields; my $uSectsPerTrack = shift @fields; my $uBytesPerSect = shift @fields; if ($uMediaType eq FixedMedia) { print "FixedMedia"; }
UPDATE 2: $ivcCylsHigh is 0 here. That can't be right!my ($opBuffer, $lBytes, $olBytesRead); $lBytes = $uBytesPerSect; my $bool = ReadFile( $hObject, $opBuffer, $lBytes, $olBytesRead, []);
and it seems ok, but if I compare the printout, with HxD, its not the same...my $ivOffset = 25096704; my $uNewPos = SetFilePointer( $hObject, $ivOffset, [], FILE_CURRENT ); + # change to use Win32API::File qw /:Func :IOCTL_DISK_ :MEDIA_TYPE :M +isc/;
maybe I need to do some tricks to get the _right_ data... although it does seem like right data (no need to convert to hex or shift because of some wierd reason).if ($bool) { print $opBuffer . "\n"; } else { print "ERROR: $^E\n"; }
edit (broquaint): Made URLs into links.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Accessing a RAW partition (Part Two)!
by CountZero (Bishop) on Oct 03, 2005 at 19:44 UTC | |
|