I am copying registry keys using a function I created. I am making perfect copies of them(including their security descriptor info). To do this, I was required to open the keys using RegCreateKeyEx and REG_OPTION_BACKUP_RESTORE with the Backup and Restore Privileges enabled in order to gain access to registry keys that otherwise would have prohibited me from opening them. This works fine with almost every key I have encountered.
However in Windows XP Pro, there is one key that is giving me tremendous trouble(tested on two seperate systems). It is HKEY_LOCAL_MACHINE/Software/Microsoft/Windows NT/CurrentVersion/Perflib. When I attempt to copy its subkey "009", I run into a problem. I am successfully able to enumerate the values in 009 and write them to my new key. However, when I try to GetSecurityInfo on the source key handle I used to enumerate its values, GetSecurityInfo returns ERROR_INVALID_HANDLE. I have tried only using the Backup privilege to see if the Restore privilege was causing the problem, but it did not work. It fails the same way using RegOpenKeyEx with READ_KEY | ACCESS_SYSTEM_SECURITY.
Does anyone know why the GetSecurityInfo would see it as an invalid handle? Can anyone else test it in the same way and see if the result is the same? I noticed the HKEY value in the debugger is absolutely huge compared to most HKEYs(being very close to the HKEY values of HKEY_LOCAL_MACHINE).
Thank you for any help/testing you can provide.