How to change registry key acl

delphi package - easy access to security apis

How to change registry key acl

Postby ch1c4um » Wed Jan 02, 2013 6:43 pm

I need permission to change a registry key for the user Everyone has Full Control access and this way I can delete this key.

I'm using this example

Code: Select all
with RegistrySecurity(HKLM\SYSTEM\ControlSet001\Enum\Root\LEGACY_DMLOAD) do
  begin
    ProtectedDAcl := false;

    DAcl.SetFileAccess(Everyone, True);
    if DAcl.DeleteItems(Everyone) then
      ShowMessage('OK')
    else
      ShowMessage('NOT OK');
  end;


But only modifying this permission and not deleting my key..

I'll use some to clean some keys after uninstall my program
ch1c4um
 
Posts: 6
Joined: Wed Jun 27, 2012 7:09 pm

Re: How to change registry key acl

Postby madshi » Wed Jan 09, 2013 6:07 pm

Hello,

I'm a bit confused. Your code first adds access for Everyone and then removes it again. Is that intentional? What purpose does that have?

Anyway, the code you're using should more or less work, as long as you have enough privileges to change the ACL. You may have to take ownership first if all else fails. One thing: I'm not sure right now which exact syntax you have to use when feeding a registry path into "RegistrySecurity". It might be safer to call RegOpen/CreateKeyEx() yourself and feed the resulting HKEY into RegistrySecurity.
madshi
Site Admin
 
Posts: 9880
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to change registry key acl

Postby ch1c4um » Wed Jan 09, 2013 10:29 pm

Good night my friend, the above code that i posted by mistake the wrong part
if DAcl.DeleteItems (Everyone) disregard the stretch.

I've got to do what i needed, i was only allowed to change and then run the function to remove key TRegistry, and windows XP I had to work with manipulating tokens to work
ch1c4um
 
Posts: 6
Joined: Wed Jun 27, 2012 7:09 pm

Re: How to change registry key acl

Postby madshi » Thu Jan 10, 2013 6:52 am

So everything is working fine now?
madshi
Site Admin
 
Posts: 9880
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to change registry key acl

Postby ch1c4um » Thu Jan 10, 2013 11:02 pm

okay my friend, thanks for the feedback
ch1c4um
 
Posts: 6
Joined: Wed Jun 27, 2012 7:09 pm


Return to madSecurity

Who is online

Users browsing this forum: No registered users and 1 guest

cron