Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: From File to at Sectors on harddrive (Windows)

by dfaure (Chaplain)
on Mar 21, 2006 at 15:44 UTC ( [id://538204]=note: print w/replies, xml ) Need Help??


in reply to From File to at Sectors on harddrive (Windows)

Using the FILE_FLAG_BACKUP_SEMANTICS flag when calling CreateFile(...) requires some extra privileges to be enabled before proceding (cf. MSDN).

This was in fact the purpose of the _EnablePrivileges() and related subroutines you may have noticed in Win32::ReadDirectoryChangesW.

____
HTH, Dominique
My two favorites:
If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
Bien faire, et le faire savoir...

  • Comment on Re: From File to at Sectors on harddrive (Windows)

Replies are listed 'Best First'.
Re^2: From File to at Sectors on harddrive (Windows)
by Ace128 (Hermit) on Mar 27, 2006 at 21:24 UTC
    Updated with previleges. No progress.

      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

        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.
        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...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://538204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 19:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found