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);
  • Comment on Error retrieving Security Information (SACL) of certain registry keys
  • Download Code

Replies are listed 'Best First'.
Re: Error retrieving Security Information (SACL) of certain registry keys
by Anonymous Monk on Oct 02, 2014 at 00:43 UTC
    Well, what authorization level do you have? Are you an Administrator?? (Or to put it another way: Are You a God?)
      Not sure how I missed your reply way back when, but this is still an issue. I may not be a god, but I am running as administrator.
Re: Error retrieving Security Information (SACL) of certain registry keys
by misterperl (Friar) on Oct 02, 2014 at 13:37 UTC
    Replied by accident, and don't see any DELETE REPLY button.. oops