http://www.perlmonks.org?node_id=558186

esskar has asked for the wisdom of the Perl Monks concerning the following question:

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!