use RegGetKeySecurity() directly to read the security information

svn path=/trunk/; revision=18014
This commit is contained in:
Thomas Bluemel 2005-09-23 15:31:42 +00:00
parent 0243833fef
commit ff1322e0a3
2 changed files with 27 additions and 19 deletions

View file

@ -86,7 +86,7 @@ SI_INHERIT_TYPE RegInheritTypes[] = {
};
LPREGKEYSECURITY CRegKeySecurity_fnConstructor(HANDLE Handle, SE_OBJECT_TYPE ObjectType, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn)
static LPREGKEYSECURITY CRegKeySecurity_fnConstructor(HANDLE Handle, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn)
{
LPREGKEYSECURITY obj;
@ -96,7 +96,6 @@ LPREGKEYSECURITY CRegKeySecurity_fnConstructor(HANDLE Handle, SE_OBJECT_TYPE Obj
obj->ref = 1;
obj->lpVtbl = &efvt;
obj->Handle = Handle;
obj->ObjectType = ObjectType;
obj->ObjectInfo = *ObjectInfo;
obj->Btn = Btn;
}
@ -153,11 +152,32 @@ CRegKeySecurity_fnGetSecurity(LPREGKEYSECURITY this,
PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
BOOL fDefault)
{
/* FIXME */
if(GetSecurityInfo(this->Handle, this->ObjectType, RequestedInformation, 0, 0,
0, 0, ppSecurityDescriptor) == ERROR_SUCCESS)
DWORD DescriptorSize = 0;
PSECURITY_DESCRIPTOR SecurityDescriptor;
LONG ErrorCode;
/* find out how much memory we need to allocate */
ErrorCode = RegGetKeySecurity(this->Handle, RequestedInformation, NULL, &DescriptorSize);
if(ErrorCode == ERROR_INSUFFICIENT_BUFFER)
{
return S_OK;
SecurityDescriptor = (PSECURITY_DESCRIPTOR)LocalAlloc(LMEM_FIXED, DescriptorSize);
if (SecurityDescriptor != NULL)
{
if (RegGetKeySecurity(this->Handle, RequestedInformation, SecurityDescriptor, &DescriptorSize) == ERROR_SUCCESS)
{
*ppSecurityDescriptor = SecurityDescriptor;
return S_OK;
}
else
{
LocalFree((HLOCAL)SecurityDescriptor);
return E_ACCESSDENIED;
}
}
else
{
return E_OUTOFMEMORY;
}
}
else
{
@ -345,7 +365,7 @@ RegKeyEditPermissions(HWND hWndOwner,
ObjectInfo.pszObjectName = KeyName;
ObjectInfo.pszPageTitle = KeyName;
if(!(RegKeySecurity = CRegKeySecurity_fnConstructor(hInfoKey, SE_REGISTRY_KEY, &ObjectInfo, &Result)))
if(!(RegKeySecurity = CRegKeySecurity_fnConstructor(hInfoKey, &ObjectInfo, &Result)))
{
/* FIXME - print error with FormatMessage */
return FALSE;

View file

@ -7,17 +7,6 @@ InitializeAclUiDll(VOID);
VOID
UnloadAclUiDll(VOID);
/* FIXME - remove the definition */
DWORD STDCALL
GetSecurityInfo(HANDLE handle,
SE_OBJECT_TYPE ObjectType,
SECURITY_INFORMATION SecurityInfo,
PSID* ppsidOwner,
PSID* ppsidGroup,
PACL* ppDacl,
PACL* ppSacl,
PSECURITY_DESCRIPTOR* ppSecurityDescriptor);
DEFINE_GUID(IID_CRegKeySecurity, 0x965fc360, 0x16ff, 0x11d0, 0x0091, 0xcb,0x00,0xaa,0x00,0xbb,0xb7,0x23);
/******************************************************************************
@ -72,7 +61,6 @@ typedef struct CRegKeySecurity
DWORD ref;
/* CRegKeySecurity fields */
HANDLE Handle;
SE_OBJECT_TYPE ObjectType;
SI_OBJECT_INFO ObjectInfo;
BOOL *Btn;
} REGKEYSECURITY;