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

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

Can anyone help me understand why certain Windows registry keys return an error when trying Win32::Security::Raw::GetNamedSecurityInfo is called? The below code was written to try and flesh out why my Win32::Security::NamedObject of type SE_Registry_Key is throwing the error 'GetNamedSecurityInfo: The system cannot find the file specified. at test.pl line 8.'

For my system, 'MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Console' throws a different error and works as expected in my larger program that this snippet was pulled from.

MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\CorruptedFileRecovery throws the error in question.

Both registry keys have the same permissions as far as I can tell.

use Win32::Security::ACL; use Win32::Security::Raw; my $objectType = "SE_REGISTRY_KEY"; my($psidOwner, $psidGroup, $pDacl, $pSacl, $pSecurityDescriptor) = Win32::Security::Raw::GetNamedSecurityInfo("MACHINE\\SOFTWARE\ +\Microsoft\\Windows NT\\CurrentVersion\\Console", $objectType, 'SACL_ +SECURITY_INFORMATION'); if ($pSacl) { my($AceCount, $AclBytesInUse, $AclBytesFree) = Win32::Security::Ra +w::GetAclInformation($pSacl, 'AclSizeInformation'); $sacl = "Win32::Security::ACL::$objectType"->new(Win32::Security:: +Raw::CopyMemory_Read($pSacl, $AclBytesInUse)); } else { $sacl = "Win32::Security::ACL::$objectType"->new(undef); } use Data::Dumper; print Dumper($sacl);