in reply to Re^2: From File to at Sectors on harddrive (Windows)
in thread From File to at Sectors on harddrive (Windows)

I experiment a little with the same idea, and I have something that might work :

#!perl use Win32API::File qw(:Func :FILE_ :FILE_SHARE_); sub FILE_FLAG_BACKUP_SEMANTICS () { 0x0200_0000 } sub FSCTL_GET_RETRIEVAL_POINTERS () { 0x90073 } my $f = $0; $f =~ s,/,\\,go; # CreateFile->Call # FH, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANT +ICS, NULL; my $fh= createFile( "$f", { Access => 'r', Share => FILE_SHARE_READ, Create => 'e', #Attributes=>"hst", Flags=>FILE_FLAG_BACKUP_SEMANTICS() } ) or die "Can't create file, $0: $^E\n"; my $vcn = 0 ; # virtual cluster number ... my $inBuf = pack ('L2',$vcn,0); # LARGE: Quad hence L2 !!! ; my $outBuf = pack ('L8',0); # ExCount,StartVCN,NextVCN,LCN my $dwByteReturned = 0; # DWORD; printf "Control code: %x\n",FSCTL_GET_RETRIEVAL_POINTERS; DeviceIoControl($fh, FSCTL_GET_RETRIEVAL_POINTERS, $inBuf,length($inBuf), $outBuf,length($outBuf), $dwBytesReturned, []); my $error = Win32::GetLastError(); print "error-no: $error\n"; warn "DeviceIoControl->Call: ", Win32::FormatMessage($error) if ($er +ror); printf "BytesReturned: %u\n",$dwBytesReturned; printf "outBuf %s\n",unpack 'H*',substr($outBuf,0,80); 1;

Let me know if it works for you ?
+Michel

Replies are listed 'Best First'.
Re^4: From File to at Sectors on harddrive (Windows)
by BrowserUk (Patriarch) on Aug 31, 2009 at 01:00 UTC

    You can simplify your error handling. This:

    DeviceIoControl($fh, FSCTL_GET_RETRIEVAL_POINTERS, $inBuf,length($inBuf), $outBuf,length($outBuf), $dwBytesReturned, []); my $error = Win32::GetLastError(); print "error-no: $error\n"; warn "DeviceIoControl->Call: ", Win32::FormatMessage($error) if ($er +ror);

    can be replaced by:

    DeviceIoControl($fh, FSCTL_GET_RETRIEVAL_POINTERS, $inBuf,length($inBuf), $outBuf,length($outBuf), $dwBytesReturned, [] ) or warn sprintf "DeviceIOControl failed with (%d) '%s'\n", $^E, $^E;

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^4: From File to at Sectors on harddrive (Windows)
by Ace128 (Hermit) on Jan 09, 2010 at 10:29 UTC
    Wow, 3 years later reply.. Anyway, I tried this and I get:
    Control code: 90073 error-no: 0 BytesReturned: 32 outBuf 01000000000000000000000000000000010000000000000071d803000000000 +0
    So, seems to be working.. but I have no idea where to go from here...