Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

Modifying Registry Security

I am writing an app in vc 5.0 which will update a NT 4.0 registry key. The registry key has Administrator as the owner, SYSTEM has FULL CONTROL and everyone has READ access.  
I looked at RegSetSecurityKey but could not figure out how to get ownership privilege to update the key. This application will be run by Administrator. Please elaborate your answer.
0
mnyeu
Asked:
mnyeu
  • 4
  • 3
1 Solution
 
mnyeuAuthor Commented:
Edited text of question
0
 
mnyeuAuthor Commented:
Adjusted points to 200
0
 
craven080297Commented:
Hello,
first you have to be conscious that you need at least a "sight" on the registry key, in order to get its handle, using, as usual the RegOpenKeyEx(YOUR_ROOT, "Key Name", 0, WRITE_OWNER, &hKey) command. This will return handle in hKey.
You then have to call RegSetSecurityKey(hKey, OWNER_SECURITY_INFORMATION, &Descript). Descript is a PSECURITY_DESCRIPTOR object, initialized via InitializeSecurityDescriptor() and SetSecurityDescriptorOwner().
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mnyeuAuthor Commented:
Well, I have tried that before.  The problem was I could not open the key with WRITE_OWNER options although I have administrative privilege. That is core of the problem. It is a reg key to which SYSTEM has FULL CONTROL and EVERYONE have READ access. The question is how to open it with WRITE_OWNER option? If you can
anwser this question, you get the points.
0
 
craven080297Commented:
Wel, I have a few ideas, such as SetSecurityDescriptorDacl() and ~Owner(), after having called AdjustTokenPrivileges() using SE_PRIVILEGE_ENABLED and so on, halas I do not manage to get denied access on any element of my own registry :-S
If you see what I mean just try it, it should allow you to get WRITE_OWNER even if not allowed. It seems AdjustTokenPrivileges() should do the job...
0
 
craven080297Commented:
Er, let me add this: correct syntax for AdjustTokenPrivileges() sould be:
AdjustTokenPrivileges(tokHandle, FALSE, &tokPriv, sizeof( tokPriv ), NULL, NULL );
Getting topPriv value:
LookupPrivilegeValue( NULL, "SeTakeOwnershipPrivilege", &ownValue); then filling in TOKEN_PRIVILEGES struct called topPriv.
0
 
mnyeuAuthor Commented:
I have found out that even if you can open a registry with WRITE_OWNER privilege, you can not modify it.  You need to have KEY_WRITE access, and I could not find out how.  However, I have promised to give you full point for WRITE_OWNER privilege. So you have it. Thanks anyway.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now