Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Win32::API::Struct: Pointers of Pointers

by BrowserUk (Patriarch)
on Jun 29, 2006 at 00:12 UTC ( [id://558190]=note: print w/replies, xml ) Need Help??


in reply to Win32::API::Struct: Pointers of Pointers

Since you are not going to benefit from compile time pointer checking, dodge the issue and change the prototype to one that avoids the unknown type

my $func = import_api_ex( 'advapi32', 'DWORD QueryUsersOnEncryptedFile(LPCWSTR lpFileName, LPVOID* +pUsers)' );

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Win32::API::Struct: Pointers of Pointers
by esskar (Deacon) on Jun 29, 2006 at 05:48 UTC
    Would be an idea. but where do i go from there? Meaning, how do i access pUsers for example?

      Just as you would normally using W::API::Struct. Create the struct per your example and the pass the variable as the parameter when your call the API. The only thing that is checked is the your are passing in a pointer. Once the call returns, you should be able to access the elements of the struct in the usual way.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Win32::API::Struct: Pointers of Pointers
by esskar (Deacon) on Jun 29, 2006 at 08:25 UTC
    well,

    it is not working. here is would i did.
    my $func = import_api_ex( 'advapi32', 'DWORD QueryUsersOnEncryptedFile(LPCWSTR lpFileName, LPVOID pUsers +)' ) ; # LPVOID* is not known die "Could not import API QueryUsersOnEncryptedFile: $!" unless define +d $func; my $encCertHashList = Win32::API::Struct->new('ENCRYPTION_CERTIFICATE_HASH_LIST'); $func->Call( make_unicode( File::Spec->canonpath($filename) ), $encCertHashList ); print $encCertHashList-> {nCert_Hash}; # i get: Can't use string ("ÈÖƒ?") as a HASH ref while + "strict refs" in use $encCertHashList = Win32::API::Struct->new('ENCRYPTION_CERTIFICATE_HAS +H_LIST'); $func->Call( make_unicode( File::Spec->canonpath($filename) ), \$encCertHashList ); print $encCertHashList-> {nCert_Hash}; # i get: Use of uninitialized value in print
    i tried both variants without the make_unicode call <- made no differences!

      I wonder what return code you're getting?


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        okay. i get 87 as a result, which means: The parameter is incorrect.

        now i tried the following:
        sub query_users { my ( $self, $filename ) = @_; my $func = import_api( 'advapi32', 'QueryUsersOnEncryptedFile', 'PP', 'N' ) +; die "Could not import API QueryUsersOnEncryptedFile: $!" unless defined $func; $filename = make_unicode( File::Spec->canonpath($filename) ); print "filename: $filename\n"; my $encCertHashList = Win32::API::Struct->new( 'ENCRYPTION_CERTIFI +CATE_HASH_LIST' ); print "retval: " . $func->Call( $filename, $encCertHashList) . "\n +"; print $encCertHashList->{nCert_Hash}, "\n"; $encCertHashList = Win32::API::Struct->new( 'ENCRYPTION_CERTIFICAT +E_HASH_LIST' ); print "retval: " . $func->Call( $filename, \$encCertHashList) . "\ +n"; print $encCertHashList->{nCert_Hash}, "\n"; $encCertHashList = " " x 1024; print "retval: " . $func->Call( $filename, $encCertHashList) . "\n +"; print $encCertHashList, "\n"; $encCertHashList = " " x 1024; print "retval: " . $func->Call( $filename, \$encCertHashList) . "\ +n"; print $encCertHashList, "\n"; }
        as a result i get
        filename: C : \ e f s . p l retval: 0 Use of uninitialized value in print at C:/Perl/site/lib/Win32/Security +/EFS.pm line 180, <DATA> line 164. retval: 0 Use of uninitialized value in print at C:/Perl/site/lib/Win32/Security +/EFS.pm line 184, <DATA> line 164. retval: 0 @¤&#9830; retval: 0
        in this case, the call works. but the structure is not really filled.
        btw. the file is encrypted!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-03-28 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found