* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
+#include <regedit.h>
+
#define INITGUID
-#include <windows.h>
-#include <tchar.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <accctrl.h>
-#include <objbase.h>
-#include <basetyps.h>
-#include <unknwn.h>
-#include "security.h"
-#include "regproc.h"
-#include "resource.h"
+#include <guiddef.h>
+
+DEFINE_GUID(IID_CRegKeySecurity, 0x965fc360, 0x16ff, 0x11d0, 0x0091, 0xcb,0x00,0xaa,0x00,0xbb,0xb7,0x23);
/******************************************************************************
Implementation of the CRegKeySecurity interface
******************************************************************************/
+static ifaceCRegKeySecurityVbtl efvt =
+{
+ /* IUnknown methods */
+ CRegKeySecurity_fnQueryInterface,
+ CRegKeySecurity_fnAddRef,
+ CRegKeySecurity_fnRelease,
+
+ /* CRegKeySecurity methods */
+ CRegKeySecurity_fnGetObjectInformation,
+ CRegKeySecurity_fnGetSecurity,
+ CRegKeySecurity_fnSetSecurity,
+ CRegKeySecurity_fnGetAccessRights,
+ CRegKeySecurity_fnMapGeneric,
+ CRegKeySecurity_fnGetInheritTypes,
+ CRegKeySecurity_fnPropertySheetPageCallback
+};
+
SI_ACCESS RegAccess[] = {
{&GUID_NULL, KEY_ALL_ACCESS, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_FULLCONTROL), SI_ACCESS_GENERAL | SI_ACCESS_SPECIFIC},
{&GUID_NULL, KEY_READ, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_READ), SI_ACCESS_GENERAL},
};
-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;
obj->ref = 1;
obj->lpVtbl = &efvt;
obj->Handle = Handle;
- obj->ObjectType = ObjectType;
obj->ObjectInfo = *ObjectInfo;
obj->Btn = Btn;
}
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
{
LPCTSTR lpMachine,
LPCTSTR lpKeyName)
{
- BOOL Result;
- HMODULE hAclEditDll;
+ BOOL Result = FALSE;
LPWSTR Machine, KeyName;
HKEY hInfoKey;
LPREGKEYSECURITY RegKeySecurity;
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;