Hi,
i'm working on a a new module right now (Win32::Security::EFS).
internally i use two functions to talk to Win32::API and Win32::API::Struct.
sub import_api_ex {
my ( $lib, $sig ) = @_;
my $key = join "_", map { uc } ( $lib, $sig );
$api{$key} = Win32::API->new( $lib, $sig )
unless exists $api{$key};
return $api{$key};
}
sub define_struct {
my ( $name, @params ) = @_;
Win32::API::Struct->typedef( $name, @params );
}
Now, i want to implement the following function from advapi32.dll
DWORD QueryUsersOnEncryptedFile(
LPCWSTR lpFileName, // file name
PENCRYPTION_CERTIFICATE_HASH_LIST *pUsers // hash list
);
as you can see, the 2nd parameter is a pointer to pointer of a structure.
anyways, i defined all needed structers.
BEGIN {
define_struct(
'EFS_HASH_BLOB',
qw/
DWORD cbData;
LPBYTE pbData;
/
);
define_struct(
'ENCRYPTION_CERTIFICATE_HASH',
qw/
DWORD cbTotalLength;
void* pUserSid;
LPEFS_HASH_BLOB pHash;
LPWSTR lpDisplayInformation;
/
);
define_struct(
'ENCRYPTION_CERTIFICATE_HASH_LIST',
qw/
DWORD nCert_Hash;
LPENCRYPTION_CERTIFICATE_HASH* pUsers;
/
);
}
Then, i tried to import the function
sub query_users {
my ( $self, $filename ) = @_;
my $func = import_api_ex( 'advapi32', 'DWORD QueryUsersOnEncrypted
+File(LPCWSTR lpFileName, LPENCRYPTION_CERTIFICATE_HASH_LIST* pUsers)'
);
die "Could not import API QueryUsersOnEncryptedFile: $!"
unless defined $func;
}
nothing special yet, but when i try to call the function, i get a WARNING:
Win32::API::parse_prototype: WARNING unknown parameter type 'LPENCRYPT
+ION_CERTIFICATE_HASH_LIST*' at C:/Perl/site/lib/Wi
n32/API.pm line 248, <DATA> line 164.
How do i fix this problem? Any hints appreciated!
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.