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

View file

@ -7,17 +7,6 @@ InitializeAclUiDll(VOID);
VOID VOID
UnloadAclUiDll(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); DEFINE_GUID(IID_CRegKeySecurity, 0x965fc360, 0x16ff, 0x11d0, 0x0091, 0xcb,0x00,0xaa,0x00,0xbb,0xb7,0x23);
/****************************************************************************** /******************************************************************************
@ -72,7 +61,6 @@ typedef struct CRegKeySecurity
DWORD ref; DWORD ref;
/* CRegKeySecurity fields */ /* CRegKeySecurity fields */
HANDLE Handle; HANDLE Handle;
SE_OBJECT_TYPE ObjectType;
SI_OBJECT_INFO ObjectInfo; SI_OBJECT_INFO ObjectInfo;
BOOL *Btn; BOOL *Btn;
} REGKEYSECURITY; } REGKEYSECURITY;