in reply to Win32API::Registry::RegGetKeySecurity how to unpack the structure of $pSecDesc?
Because you are not using strict or warnings, you cannot see that DACL_SECURITY_INFORMATION is not defined. This results in $pSecDesc containing the wrong data, which cannot be decoded.
Adding this line populates $pSecDesc correctly:
use Win32 qw( DACL_SECURITY_INFORMATION );
You still need to decode the Security Descriptor; this (thrown together, barely tested) program may help:
use strict; use warnings; use Data::Dumper; $Data::Dumper::Useqq = 1; $| = 1; my $host = '127.0.0.1'; my $reg_key = 'SOFTWARE\\7-zip'; use Win32 qw( DACL_SECURITY_INFORMATION ); use Win32API::Registry 0.21 qw( :ALL ); # Get the Security Descriptor my $reg_api; RegConnectRegistry( $host, HKEY_LOCAL_MACHINE, $reg_api ) or die $^E; my $key; RegOpenKeyEx( $reg_api, $reg_key, 0, KEY_READ, $key ) or die $^E; my $pSecDesc; RegGetKeySecurity( $key, DACL_SECURITY_INFORMATION, $pSecDesc ) or die + $^E; # Print the raw DACL. print "\n", Dumper $pSecDesc; # Decode the Security Descriptor use Win32::API; use constant SDDL_REVISION_1 => 0x1; my $ConvertSDToString = Win32::API->new( 'ADVAPI32', 'ConvertSecurityDescriptorToStringSecurityDescriptor', ['P', 'N', 'N', 'P', 'N'], 'N', ); my $ptr_strSDDL = pack 'L', 0; # DWORD; my $ObjSD = $ConvertSDToString->Call( $pSecDesc, SDDL_REVISION_1, 0xF, $ptr_strSDDL, 0, ) or die $^E; my $strSDDL = unpack 'p', $ptr_strSDDL; # Print the decoded DACL. print "\n", Dumper $strSDDL;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Win32API::Registry::RegGetKeySecurity how to unpack the structure of $pSecDesc? (misc)
by tye (Sage) on Jan 13, 2006 at 17:31 UTC | |
by Sioln (Sexton) on Jan 16, 2006 at 07:11 UTC | |
by tye (Sage) on Jan 16, 2006 at 07:16 UTC | |
|
Re^2: Win32API::Registry::RegGetKeySecurity how to unpack the structure of $pSecDesc?
by Sioln (Sexton) on Jan 13, 2006 at 15:01 UTC |