mirror of
https://github.com/reactos/reactos.git
synced 2025-01-03 21:09:19 +00:00
added a key security editor (not yet working properly)
svn path=/trunk/; revision=10075
This commit is contained in:
parent
13eda5be1f
commit
ce4aa8ef2e
8 changed files with 571 additions and 1 deletions
|
@ -69,6 +69,8 @@ BEGIN
|
|||
MENUITEM "&DWORD Value", ID_EDIT_NEW_DWORDVALUE
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Permissions...", ID_EDIT_PERMISSIONS
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Delete\tDel", ID_EDIT_DELETE
|
||||
MENUITEM "&Rename", ID_EDIT_RENAME
|
||||
MENUITEM SEPARATOR
|
||||
|
@ -289,6 +291,29 @@ BEGIN
|
|||
IDS_FLT_ALLFILES_FLT "*.*"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_ACCESS_FULLCONTROL "Full Control"
|
||||
IDS_ACCESS_READ "Read"
|
||||
IDS_ACCESS_QUERYVALUE "Query Value"
|
||||
IDS_ACCESS_SETVALUE "Set Value"
|
||||
IDS_ACCESS_CREATESUBKEY "Create Subkey"
|
||||
IDS_ACCESS_ENUMERATESUBKEYS "Enumerate Subkeys"
|
||||
IDS_ACCESS_NOTIFY "Notify"
|
||||
IDS_ACCESS_CREATELINK "Create Link"
|
||||
IDS_ACCESS_DELETE "Delete"
|
||||
IDS_ACCESS_WRITEDAC "Write DAC"
|
||||
IDS_ACCESS_WRITEOWNER "Write Owner"
|
||||
IDS_ACCESS_READCONTROL "Read Control"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_INHERIT_THISKEYONLY "This key only"
|
||||
IDS_INHERIT_THISKEYANDSUBKEYS "This key and subkeys"
|
||||
IDS_INHERIT_SUBKEYSONLY "Subkeys only"
|
||||
END
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
|
|
|
@ -597,6 +597,16 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case ID_EDIT_COPYKEYNAME:
|
||||
CopyKeyName(hWnd, _T(""));
|
||||
break;
|
||||
case ID_EDIT_PERMISSIONS:
|
||||
if(keyPath != NULL && _tcslen(keyPath) > 0)
|
||||
{
|
||||
RegKeyEditPermissions(hWnd, hKey, NULL, keyPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBeep(MB_ICONASTERISK);
|
||||
}
|
||||
break;
|
||||
case ID_REGISTRY_PRINTERSETUP:
|
||||
/*PRINTDLG pd;*/
|
||||
/*PrintDlg(&pd);*/
|
||||
|
|
|
@ -68,6 +68,8 @@ TCHAR szChildClass[MAX_LOADSTRING];
|
|||
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
BOOL AclUiAvailable;
|
||||
|
||||
WNDCLASSEX wcFrame = {
|
||||
sizeof(WNDCLASSEX),
|
||||
CS_HREDRAW | CS_VREDRAW/*style*/,
|
||||
|
@ -111,6 +113,21 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|||
|
||||
/* Initialize the Windows Common Controls DLL */
|
||||
InitCommonControls();
|
||||
|
||||
AclUiAvailable = InitializeAclUiDll();
|
||||
if(!AclUiAvailable)
|
||||
{
|
||||
HMENU hEditMenu;
|
||||
int mePos;
|
||||
/* hide the Edit/Permissions... menu entry */
|
||||
hEditMenu = GetSubMenu(hMenuFrame, 1);
|
||||
if(hEditMenu != NULL)
|
||||
{
|
||||
RemoveMenu(hEditMenu, ID_EDIT_PERMISSIONS, MF_BYCOMMAND);
|
||||
/* remove the separator after the menu item */
|
||||
RemoveMenu(hEditMenu, 4, MF_BYPOSITION);
|
||||
}
|
||||
}
|
||||
|
||||
nClipboardFormat = RegisterClipboardFormat(strClipboardFormat);
|
||||
/* if (nClipboardFormat == 0) {
|
||||
|
@ -145,6 +162,7 @@ void ExitInstance(HINSTANCE hInstance)
|
|||
{
|
||||
UnregisterHexEditorClass(hInstance);
|
||||
DestroyMenu(hMenuFrame);
|
||||
UnloadAclUiDll();
|
||||
}
|
||||
|
||||
BOOL TranslateChildTabMessage(MSG *msg)
|
||||
|
|
|
@ -14,7 +14,9 @@ TARGET_NAME = regedit
|
|||
|
||||
TARGET_CFLAGS = -D_WIN32_IE=0x0501 -D_WIN32_WINNT=0x0501 -D__USE_W32API
|
||||
|
||||
TARGET_GCCLIBS = msvcrt advapi32 kernel32 comctl32 comdlg32 shell32
|
||||
TARGET_GCCLIBS = msvcrt advapi32 kernel32 comctl32 comdlg32 shell32 ole32
|
||||
|
||||
TARGET_SDKLIBS = kernel32.a advapi32.a user32.a gdi32.a wine_uuid.a ole32.a
|
||||
|
||||
TARGET_OBJECTS = \
|
||||
about.o \
|
||||
|
@ -26,6 +28,7 @@ TARGET_OBJECTS = \
|
|||
main.o \
|
||||
regedit.o \
|
||||
regproc.o \
|
||||
security.o \
|
||||
treeview.o
|
||||
|
||||
include $(PATH_TO_TOP)/rules.mak
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#define SUCCESS 0
|
||||
#define KEY_VALUE_ALREADY_SET 2
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
||||
typedef void (*CommandAPI)(LPSTR lpsLine);
|
||||
|
||||
void doSetValue(LPSTR lpsLine);
|
||||
|
@ -71,3 +73,13 @@ HRESULT setValue(LPSTR val_name, LPSTR val_data);
|
|||
* api queryValue prototypes
|
||||
*/
|
||||
void processQueryValue(LPSTR cmdline);
|
||||
|
||||
/*
|
||||
* Permission prototypes
|
||||
*/
|
||||
|
||||
BOOL InitializeAclUiDll(VOID);
|
||||
VOID UnloadAclUiDll(VOID);
|
||||
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCTSTR lpMachine, LPCTSTR lpKeyName);
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -127,6 +127,7 @@
|
|||
#define IDS_ERR_RENVAL_CAPTION 32856
|
||||
#define IDS_ERR_RENVAL_TOEMPTY 32857
|
||||
#define ID_SWITCH_PANELS 32871
|
||||
#define ID_EDIT_PERMISSIONS 32872
|
||||
|
||||
#define IDS_FLT_REGFILES 31001
|
||||
#define IDS_FLT_REGFILES_FLT 31002
|
||||
|
@ -135,6 +136,24 @@
|
|||
#define IDS_FLT_ALLFILES 31005
|
||||
#define IDS_FLT_ALLFILES_FLT 31006
|
||||
|
||||
#define IDS_ACCESS_FULLCONTROL 31101
|
||||
#define IDS_ACCESS_READ 31102
|
||||
#define IDS_ACCESS_QUERYVALUE 31103
|
||||
#define IDS_ACCESS_SETVALUE 31104
|
||||
#define IDS_ACCESS_CREATESUBKEY 31105
|
||||
#define IDS_ACCESS_ENUMERATESUBKEYS 31106
|
||||
#define IDS_ACCESS_NOTIFY 31107
|
||||
#define IDS_ACCESS_CREATELINK 31108
|
||||
#define IDS_ACCESS_DELETE 31109
|
||||
#define IDS_ACCESS_WRITEDAC 31110
|
||||
#define IDS_ACCESS_WRITEOWNER 31111
|
||||
#define IDS_ACCESS_READCONTROL 31112
|
||||
|
||||
#define IDS_INHERIT_THISKEYONLY 31121
|
||||
#define IDS_INHERIT_THISKEYANDSUBKEYS 31122
|
||||
#define IDS_INHERIT_SUBKEYSONLY 31123
|
||||
|
||||
|
||||
#define IDD_EDIT_STRING 2000
|
||||
#define IDC_VALUE_NAME 2001
|
||||
#define IDC_VALUE_DATA 2002
|
||||
|
|
358
reactos/subsys/system/regedit/security.c
Normal file
358
reactos/subsys/system/regedit/security.c
Normal file
|
@ -0,0 +1,358 @@
|
|||
/*
|
||||
* Regedit ACL Editor for Registry Keys
|
||||
*
|
||||
* Copyright (C) 2004 Thomas Weidenmueller <w3seek@reactos.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
|
||||
#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"
|
||||
|
||||
/******************************************************************************
|
||||
Implementation of the CRegKeySecurity interface
|
||||
******************************************************************************/
|
||||
|
||||
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},
|
||||
{&GUID_NULL, KEY_QUERY_VALUE, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_QUERYVALUE), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, KEY_SET_VALUE, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_SETVALUE), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, KEY_CREATE_SUB_KEY, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_CREATESUBKEY), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, KEY_ENUMERATE_SUB_KEYS, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_ENUMERATESUBKEYS), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, KEY_NOTIFY, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_NOTIFY), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, KEY_CREATE_LINK, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_CREATELINK), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, DELETE, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_DELETE), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, WRITE_DAC, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_WRITEDAC), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, WRITE_OWNER, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_WRITEOWNER), SI_ACCESS_SPECIFIC},
|
||||
{&GUID_NULL, READ_CONTROL, (LPWSTR)MAKEINTRESOURCE(IDS_ACCESS_READCONTROL), SI_ACCESS_SPECIFIC},
|
||||
};
|
||||
|
||||
DWORD RegDefaultAccess = 1; /* KEY_READ */
|
||||
|
||||
GENERIC_MAPPING RegAccessMasks = {
|
||||
KEY_READ,
|
||||
KEY_WRITE,
|
||||
KEY_EXECUTE,
|
||||
KEY_ALL_ACCESS
|
||||
};
|
||||
|
||||
SI_INHERIT_TYPE RegInheritTypes[] = {
|
||||
{&GUID_NULL, 0, (LPWSTR)MAKEINTRESOURCE(IDS_INHERIT_THISKEYONLY)},
|
||||
{&GUID_NULL, CONTAINER_INHERIT_ACE, (LPWSTR)MAKEINTRESOURCE(IDS_INHERIT_THISKEYANDSUBKEYS)},
|
||||
{&GUID_NULL, INHERIT_ONLY_ACE | CONTAINER_INHERIT_ACE, (LPWSTR)MAKEINTRESOURCE(IDS_INHERIT_SUBKEYSONLY)},
|
||||
};
|
||||
|
||||
|
||||
LPREGKEYSECURITY CRegKeySecurity_fnConstructor(HANDLE Handle, SE_OBJECT_TYPE ObjectType, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn)
|
||||
{
|
||||
LPREGKEYSECURITY obj;
|
||||
|
||||
obj = (LPREGKEYSECURITY)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(REGKEYSECURITY));
|
||||
if(obj != NULL)
|
||||
{
|
||||
obj->ref = 1;
|
||||
obj->lpVtbl = &efvt;
|
||||
obj->Handle = Handle;
|
||||
obj->ObjectType = ObjectType;
|
||||
obj->ObjectInfo = *ObjectInfo;
|
||||
obj->Btn = Btn;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnQueryInterface(LPREGKEYSECURITY this,
|
||||
REFIID iid,
|
||||
PVOID *pvObject)
|
||||
{
|
||||
if(IsEqualGUID(iid, &IID_IUnknown) ||
|
||||
IsEqualGUID(iid, &IID_CRegKeySecurity))
|
||||
{
|
||||
*pvObject = this;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*pvObject = NULL;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnAddRef(LPREGKEYSECURITY this)
|
||||
{
|
||||
return (ULONG)InterlockedIncrement(&this->ref);
|
||||
}
|
||||
|
||||
ULONG STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnRelease(LPREGKEYSECURITY this)
|
||||
{
|
||||
ULONG rfc;
|
||||
|
||||
rfc = (ULONG)InterlockedDecrement(&this->ref);
|
||||
if(rfc == 0)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, this);
|
||||
}
|
||||
return rfc;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnGetObjectInformation(LPREGKEYSECURITY this,
|
||||
PSI_OBJECT_INFO pObjectInfo)
|
||||
{
|
||||
*pObjectInfo = this->ObjectInfo;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnGetSecurity(LPREGKEYSECURITY this,
|
||||
SECURITY_INFORMATION RequestedInformation,
|
||||
PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
|
||||
BOOL fDefault)
|
||||
{
|
||||
/* FIXME */
|
||||
if(GetSecurityInfo(this->Handle, this->ObjectType, RequestedInformation, 0, 0,
|
||||
0, 0, ppSecurityDescriptor) == ERROR_SUCCESS)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return E_ACCESSDENIED;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnSetSecurity(LPREGKEYSECURITY this,
|
||||
SECURITY_INFORMATION RequestedInformation,
|
||||
PSECURITY_DESCRIPTOR pSecurityDescriptor)
|
||||
{
|
||||
/* FIXME */
|
||||
*this->Btn = TRUE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnGetAccessRights(LPREGKEYSECURITY this,
|
||||
const GUID* pguidObjectType,
|
||||
DWORD dwFlags,
|
||||
PSI_ACCESS* ppAccess,
|
||||
ULONG* pcAccesses,
|
||||
ULONG* piDefaultAccess)
|
||||
{
|
||||
*ppAccess = RegAccess;
|
||||
*pcAccesses = sizeof(RegAccess) / sizeof(SI_ACCESS);
|
||||
*piDefaultAccess = RegDefaultAccess;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnMapGeneric(LPREGKEYSECURITY this,
|
||||
const GUID* pguidObjectType,
|
||||
UCHAR* pAceFlags,
|
||||
ACCESS_MASK* pMask)
|
||||
{
|
||||
MapGenericMask(pMask, (PGENERIC_MAPPING)&RegAccessMasks);
|
||||
*pMask &= ~SYNCHRONIZE;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnGetInheritTypes(LPREGKEYSECURITY this,
|
||||
PSI_INHERIT_TYPE* ppInheritTypes,
|
||||
ULONG* pcInheritTypes)
|
||||
{
|
||||
/* FIXME */
|
||||
if(this->ObjectInfo.dwFlags & SI_CONTAINER)
|
||||
{
|
||||
*ppInheritTypes = RegInheritTypes;
|
||||
*pcInheritTypes = sizeof(RegInheritTypes) / sizeof(SI_INHERIT_TYPE);
|
||||
return S_OK;
|
||||
}
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE
|
||||
CRegKeySecurity_fnPropertySheetPageCallback(LPREGKEYSECURITY this,
|
||||
HWND hwnd,
|
||||
UINT uMsg,
|
||||
SI_PAGE_TYPE uPage)
|
||||
{
|
||||
/* FIXME */
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
#define ACLUI_DLL _T("aclui.dll")
|
||||
#define FN_EDITSECURITY "EditSecurity" /* no unicode, GetProcAddr doesn't accept unicode! */
|
||||
|
||||
typedef struct _CHANGE_CONTEXT
|
||||
{
|
||||
HKEY hKey;
|
||||
LPTSTR KeyString;
|
||||
} CHANGE_CONTEXT, *PCHANGE_CONTEXT;
|
||||
|
||||
typedef BOOL (WINAPI *PEDITSECURITY)(HWND hwndOwner,
|
||||
LPREGKEYSECURITY psi);
|
||||
|
||||
static PEDITSECURITY pfnEditSecurity;
|
||||
static HMODULE hAclUiDll;
|
||||
|
||||
BOOL
|
||||
InitializeAclUiDll(VOID)
|
||||
{
|
||||
if(!(hAclUiDll = LoadLibrary(ACLUI_DLL)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if(!(pfnEditSecurity = (PEDITSECURITY)GetProcAddress(hAclUiDll, FN_EDITSECURITY)))
|
||||
{
|
||||
FreeLibrary(hAclUiDll);
|
||||
hAclUiDll = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID
|
||||
UnloadAclUiDll(VOID)
|
||||
{
|
||||
if(hAclUiDll != NULL)
|
||||
{
|
||||
FreeLibrary(hAclUiDll);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
RegKeyEditPermissions(HWND hWndOwner,
|
||||
HKEY hKey,
|
||||
LPCTSTR lpMachine,
|
||||
LPCTSTR lpKeyName)
|
||||
{
|
||||
BOOL Result;
|
||||
HMODULE hAclEditDll;
|
||||
LPWSTR Machine, KeyName;
|
||||
HKEY hInfoKey;
|
||||
LPREGKEYSECURITY RegKeySecurity;
|
||||
SI_OBJECT_INFO ObjectInfo;
|
||||
|
||||
if(pfnEditSecurity == NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef UNICODE
|
||||
/* aclui.dll only accepts unicode strings, convert them */
|
||||
if(lpMachine != NULL)
|
||||
{
|
||||
int lnMachine = lstrlen(lpMachine);
|
||||
if(!(Machine = HeapAlloc(GetProcessHeap(), 0, (lnMachine + 1) * sizeof(WCHAR))))
|
||||
{
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if(lnMachine > 0)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, lpMachine, -1, Machine, lnMachine + 1);
|
||||
}
|
||||
else
|
||||
*Machine = L'\0';
|
||||
}
|
||||
else
|
||||
Machine = NULL;
|
||||
|
||||
if(lpKeyName != NULL)
|
||||
{
|
||||
int lnKeyName = lstrlen(lpKeyName);
|
||||
if(!(KeyName = HeapAlloc(GetProcessHeap(), 0, (lnKeyName + 1) * sizeof(WCHAR))))
|
||||
{
|
||||
if(Machine != NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, Machine);
|
||||
}
|
||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||
return FALSE;
|
||||
}
|
||||
if(lnKeyName > 0)
|
||||
{
|
||||
MultiByteToWideChar(CP_ACP, 0, lpKeyName, -1, KeyName, lnKeyName + 1);
|
||||
}
|
||||
else
|
||||
*KeyName = L'\0';
|
||||
}
|
||||
else
|
||||
KeyName = NULL;
|
||||
#else
|
||||
Machine = (LPWSTR)lpMachine;
|
||||
KeyName = (LPWSTR)lpKeyName;
|
||||
#endif
|
||||
|
||||
/* try to open the key again with more access rights */
|
||||
if(RegOpenKeyEx(hKey, NULL, 0, READ_CONTROL, &hInfoKey) != ERROR_SUCCESS)
|
||||
{
|
||||
/* FIXME - print error with FormatMessage */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ObjectInfo.dwFlags = SI_EDIT_ALL | SI_ADVANCED | SI_CONTAINER | SI_OWNER_RECURSE | SI_EDIT_PERMS;
|
||||
ObjectInfo.hInstance = hInst;
|
||||
ObjectInfo.pszServerName = Machine;
|
||||
ObjectInfo.pszObjectName = KeyName;
|
||||
ObjectInfo.pszPageTitle = KeyName;
|
||||
|
||||
if(!(RegKeySecurity = CRegKeySecurity_fnConstructor(hInfoKey, SE_REGISTRY_KEY, &ObjectInfo, &Result)))
|
||||
{
|
||||
/* FIXME - print error with FormatMessage */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* display the security editor dialog */
|
||||
pfnEditSecurity(hWndOwner, RegKeySecurity);
|
||||
|
||||
/* dereference the interface, it should be destroyed here */
|
||||
CRegKeySecurity_fnRelease(RegKeySecurity);
|
||||
|
||||
RegCloseKey(hInfoKey);
|
||||
|
||||
#ifndef UNICODE
|
||||
if(Machine != NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, Machine);
|
||||
}
|
||||
if(KeyName != NULL)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, KeyName);
|
||||
}
|
||||
#endif
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/* EOF */
|
125
reactos/subsys/system/regedit/security.h
Normal file
125
reactos/subsys/system/regedit/security.h
Normal file
|
@ -0,0 +1,125 @@
|
|||
#ifndef _REGEXP_SECURITY_H
|
||||
#define _REGEXP_SECURITY_H
|
||||
|
||||
/* 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);
|
||||
|
||||
/******************************************************************************
|
||||
CRegKeySecurity
|
||||
******************************************************************************/
|
||||
|
||||
typedef struct CRegKeySecurity *LPREGKEYSECURITY;
|
||||
|
||||
typedef struct ifaceCRegKeySecurityVbtl ifaceCRegKeySecurityVbtl;
|
||||
struct ifaceCRegKeySecurityVbtl
|
||||
{
|
||||
/* IUnknown */
|
||||
HRESULT (STDMETHODCALLTYPE *QueryInterface)(LPREGKEYSECURITY this,
|
||||
REFIID iid,
|
||||
PVOID *pvObject);
|
||||
ULONG (STDMETHODCALLTYPE *AddRef)(LPREGKEYSECURITY this);
|
||||
ULONG (STDMETHODCALLTYPE *Release)(LPREGKEYSECURITY this);
|
||||
|
||||
/* CRegKeySecurity */
|
||||
HRESULT (STDMETHODCALLTYPE *GetObjectInformation)(LPREGKEYSECURITY this,
|
||||
PSI_OBJECT_INFO pObjectInfo);
|
||||
HRESULT (STDMETHODCALLTYPE *GetSecurity)(LPREGKEYSECURITY this,
|
||||
SECURITY_INFORMATION RequestedInformation,
|
||||
PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
|
||||
BOOL fDefault);
|
||||
HRESULT (STDMETHODCALLTYPE *SetSecurity)(LPREGKEYSECURITY this,
|
||||
SECURITY_INFORMATION RequestedInformation,
|
||||
PSECURITY_DESCRIPTOR pSecurityDescriptor);
|
||||
HRESULT (STDMETHODCALLTYPE *GetAccessRights)(LPREGKEYSECURITY this,
|
||||
const GUID* pguidObjectType,
|
||||
DWORD dwFlags,
|
||||
PSI_ACCESS* ppAccess,
|
||||
ULONG* pcAccesses,
|
||||
ULONG* piDefaultAccess);
|
||||
HRESULT (STDMETHODCALLTYPE *MapGeneric)(LPREGKEYSECURITY this,
|
||||
const GUID* pguidObjectType,
|
||||
UCHAR* pAceFlags,
|
||||
ACCESS_MASK* pMask);
|
||||
HRESULT (STDMETHODCALLTYPE *GetInheritTypes)(LPREGKEYSECURITY this,
|
||||
PSI_INHERIT_TYPE* ppInheritTypes,
|
||||
ULONG* pcInheritTypes);
|
||||
HRESULT (STDMETHODCALLTYPE *PropertySheetPageCallback)(LPREGKEYSECURITY this,
|
||||
HWND hwnd,
|
||||
UINT uMsg,
|
||||
SI_PAGE_TYPE uPage);
|
||||
};
|
||||
|
||||
typedef struct CRegKeySecurity
|
||||
{
|
||||
/* IUnknown fields */
|
||||
ifaceCRegKeySecurityVbtl* lpVtbl;
|
||||
DWORD ref;
|
||||
/* CRegKeySecurity fields */
|
||||
HANDLE Handle;
|
||||
SE_OBJECT_TYPE ObjectType;
|
||||
SI_OBJECT_INFO ObjectInfo;
|
||||
BOOL *Btn;
|
||||
} REGKEYSECURITY;
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnQueryInterface(LPREGKEYSECURITY this,
|
||||
REFIID iid,
|
||||
PVOID *pvObject);
|
||||
ULONG STDMETHODCALLTYPE CRegKeySecurity_fnAddRef(LPREGKEYSECURITY this);
|
||||
ULONG STDMETHODCALLTYPE CRegKeySecurity_fnRelease(LPREGKEYSECURITY this);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnGetObjectInformation(LPREGKEYSECURITY this,
|
||||
PSI_OBJECT_INFO pObjectInfo);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnGetSecurity(LPREGKEYSECURITY this,
|
||||
SECURITY_INFORMATION RequestedInformation,
|
||||
PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
|
||||
BOOL fDefault);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnSetSecurity(LPREGKEYSECURITY this,
|
||||
SECURITY_INFORMATION RequestedInformation,
|
||||
PSECURITY_DESCRIPTOR pSecurityDescriptor);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnGetAccessRights(LPREGKEYSECURITY this,
|
||||
const GUID* pguidObjectType,
|
||||
DWORD dwFlags,
|
||||
PSI_ACCESS* ppAccess,
|
||||
ULONG* pcAccesses,
|
||||
ULONG* piDefaultAccess);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnMapGeneric(LPREGKEYSECURITY this,
|
||||
const GUID* pguidObjectType,
|
||||
UCHAR* pAceFlags,
|
||||
ACCESS_MASK* pMask);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnGetInheritTypes(LPREGKEYSECURITY this,
|
||||
PSI_INHERIT_TYPE* ppInheritTypes,
|
||||
ULONG* pcInheritTypes);
|
||||
HRESULT STDMETHODCALLTYPE CRegKeySecurity_fnPropertySheetPageCallback(LPREGKEYSECURITY this,
|
||||
HWND hwnd,
|
||||
UINT uMsg,
|
||||
SI_PAGE_TYPE uPage);
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
#endif /* _REGEXP_SECURITY_H */
|
||||
|
||||
/* EOF */
|
Loading…
Reference in a new issue