block access to a key?

delphi package - easy access to security apis

block access to a key?

Postby warfighter » Fri Oct 09, 2009 7:40 pm

to use the madsecurity to block access to a key?

I do not know how to use new code right, someone can help me
warfighter
 
Posts: 3
Joined: Fri Oct 09, 2009 7:35 pm

Postby madshi » Sat Oct 10, 2009 8:43 am

You can use something like this:

Code: Select all
RegistrySecurity(regKeyHandle).DAcl.NewItem(CurrentUser, STANDARD_RIGHTS, atDenied);

This would deny the STANDARD_RIGHTS to the current user. See MS documentation about which exact rights exist for registry keys, if STANDARD_RIGHTS isn't what you need. Of course instead of "CurrentUser" you can also use any other user. See madSecurity help for more information.

The above code will only work if you have enough access rights to change the DAcl of the specified registry key, of course...
madshi
Site Admin
 
Posts: 9757
Joined: Sun Mar 21, 2004 5:25 pm

Postby warfighter » Sat Oct 10, 2009 1:15 pm

procedure TForm1.Button1Click(Sender: TObject);
begin
Code: Select all
RegistrySecurity('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup').DAcl.NewItem(CurrentUser, STANDARD_RIGHTS_REQUIRED, atDenied);

end;

Correct ?
warfighter
 
Posts: 3
Joined: Fri Oct 09, 2009 7:35 pm

Postby madshi » Sat Oct 10, 2009 1:38 pm

I'm not sure which string the OS expects. I don't think the OS wants "HKEY_LOCAL_MACHINE", but I don't know myself right now. It's better to open the key with the registry APIs (RegOpenKeyEx, IIRC) and feed that to RegistrySecurity.
madshi
Site Admin
 
Posts: 9757
Joined: Sun Mar 21, 2004 5:25 pm


Return to madSecurity

Who is online

Users browsing this forum: No registered users and 1 guest