in reply to Win32::API: deciphering a returned pointer to a struct
- Always turn on double quotes before using Data::Dumper on data with possible unprintable data;
otherwise, you cannot tell what your data really is:
local $Data::Dumper::Useqq = 1;
-
Ignore the keys typedef and buffer_recipients in the Dumper output. This will leave you with just the expected fields in DOMAIN_CONTROLLER_INFO, and an extra buffer field which contains the raw bytes of the structure.
-
What happens if you declare the DsGetDcName API using the `prototype` style, instead of the older `parameter list` style you are using? Does that resolve the problem, or at least change the behavior? i.e. change:
my $DsGetDcName = Win32::API->new('Netapi32', 'DsGetDcName', 'PPSPNS',
+ 'N')
or die Win32::FormatMessage(Win32::GetLastError);
to:
my $DsGetDcName_declare = <<'END_OF_DECLARE';
DWORD DsGetDcName(
LPCTSTR ComputerName,
LPCTSTR DomainName,
LPGUID DomainGuid,
LPCTSTR SiteName,
ULONG Flags,
LPDOMAIN_CONTROLLER_INFO DomainControllerInfo
);
END_OF_DECLARE
my $DsGetDcName = Win32::API->new( Netapi32 => $DsGetDcName_declare )
or die Win32::FormatMessage(Win32::GetLastError);
|