ReactOS 0.4.15-dev-5858-g16decc6
security.c
Go to the documentation of this file.
1/*
2 * Regedit ACL Editor for Registry Keys
3 *
4 * Copyright (C) 2004 - 2006 Thomas Weidenmueller <w3seek@reactos.com>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "regedit.h"
22
23#define INITGUID
24#include <guiddef.h>
25
26/* FIXME - shouldn't be defined here... */
27DEFINE_GUID(IID_IRegKeySecurity, 0x965fc360, 0x16ff, 0x11d0, 0x0091, 0xcb,0x00,0xaa,0x00,0xbb,0xb7,0x23);
28#if REGEDIT_IMPLEMENT_ISECURITYINFORMATION2
29DEFINE_GUID(IID_IRegKeySecurity2, 0xc3ccfdb4, 0x6f88, 0x11d2, 0x00a3, 0xce,0x00,0xc0,0x4f,0xb1,0x78,0x2a);
30#endif
31
32/* FIXME: already defined in aclui.h - causing problems when compiling with MSVC/PSDK*/
33#ifdef _MSC_VER
34#pragma message ("INVESTIGATE ME")
35#endif
36
37#if 1 //#ifndef _MSC_VER
38DEFINE_GUID(IID_IEffectivePermission, 0x3853dc76, 0x9f35, 0x407c, 0x0088, 0xa1,0xd1,0x93,0x44,0x36,0x5f,0xbc);
39DEFINE_GUID(IID_ISecurityObjectTypeInfo, 0xfc3066eb, 0x79ef, 0x444b, 0x0091, 0x11,0xd1,0x8a,0x75,0xeb,0xf2,0xfa);
40#endif
41
42/******************************************************************************
43 Implementation of the IUnknown methods of CRegKeySecurity
44 ******************************************************************************/
45
46static __inline PCRegKeySecurity
47impl_from_ISecurityInformation(struct ISecurityInformation *iface)
48{
50 lpISecurityInformationVtbl));
51}
52
53#if REGEDIT_IMPLEMENT_ISECURITYINFORMATION2
54static __inline PCRegKeySecurity
55impl_from_ISecurityInformation2(struct ISecurityInformation2 *iface)
56{
58 lpISecurityInformation2Vtbl));
59}
60#endif
61
62static __inline PCRegKeySecurity
63impl_from_ISecurityObjectTypeInfo(struct ISecurityObjectTypeInfo *iface)
64{
66 lpISecurityObjectTypeInfoVtbl));
67}
68
69static __inline PCRegKeySecurity
70impl_from_IEffectivePermission(struct IEffectivePermission *iface)
71{
73 lpIEffectivePermissionVtbl));
74}
75
76#define impl_to_interface(impl,iface) (struct iface *)(&(impl)->lp##iface##Vtbl)
77
78static __inline ULONG
80{
81 return (ULONG)InterlockedIncrement((LONG*)&obj->ref);
82}
83
84static __inline ULONG
86{
87 ULONG Ret;
88
89 Ret = (ULONG)InterlockedDecrement((LONG*)&obj->ref);
90 if (Ret == 0)
91 {
93 0,
94 obj);
95 }
96
97 return Ret;
98}
99
100static __inline HRESULT
102 REFIID iid,
103 PVOID *pvObject)
104{
105 PVOID pvObj = NULL;
106
107 if (IsEqualGUID(iid,
108 &IID_IRegKeySecurity))
109 {
110 pvObj = (PVOID)impl_to_interface(obj,
111 ISecurityInformation);
112 }
113#if REGEDIT_IMPLEMENT_ISECURITYINFORMATION2
114 else if (IsEqualGUID(iid,
115 &IID_IRegKeySecurity2))
116 {
117 pvObj = (PVOID)impl_to_interface(obj,
118 ISecurityInformation2);
119 }
120#endif
121 else if (IsEqualGUID(iid,
122 &IID_IEffectivePermission))
123 {
124 pvObj = (PVOID)impl_to_interface(obj,
125 IEffectivePermission);
126 }
127 else if (IsEqualGUID(iid,
128 &IID_ISecurityObjectTypeInfo))
129 {
130 pvObj = (PVOID)impl_to_interface(obj,
131 ISecurityObjectTypeInfo);
132 }
133
134 if (pvObj == NULL)
135 {
136 return E_NOINTERFACE;
137 }
138
139 *pvObject = pvObj;
141
142 return S_OK;
143}
144
145
146/******************************************************************************
147 Definition of the ISecurityInformation interface
148 ******************************************************************************/
149
150/* IUnknown */
152ISecurityInformation_fnQueryInterface(struct ISecurityInformation *this,
153 REFIID iid,
154 PVOID *pvObject);
155
157ISecurityInformation_fnAddRef(struct ISecurityInformation *this);
158
160ISecurityInformation_fnRelease(struct ISecurityInformation *this);
161
162/* ISecurityInformation */
164ISecurityInformation_fnGetObjectInformation(struct ISecurityInformation *this,
165 PSI_OBJECT_INFO pObjectInfo);
166
168ISecurityInformation_fnGetSecurity(struct ISecurityInformation *this,
169 SECURITY_INFORMATION RequestedInformation,
170 PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
171 BOOL fDefault);
172
174ISecurityInformation_fnSetSecurity(struct ISecurityInformation *this,
175 SECURITY_INFORMATION RequestedInformation,
176 PSECURITY_DESCRIPTOR pSecurityDescriptor);
177
179ISecurityInformation_fnGetAccessRights(struct ISecurityInformation *this,
180 const GUID* pguidObjectType,
182 PSI_ACCESS* ppAccess,
183 ULONG* pcAccesses,
184 ULONG* piDefaultAccess);
185
187ISecurityInformation_fnMapGeneric(struct ISecurityInformation *this,
188 const GUID* pguidObjectType,
189 UCHAR* pAceFlags,
190 ACCESS_MASK* pMask);
191
193ISecurityInformation_fnGetInheritTypes(struct ISecurityInformation *this,
194 PSI_INHERIT_TYPE* ppInheritTypes,
195 ULONG* pcInheritTypes);
197ISecurityInformation_fnPropertySheetPageCallback(struct ISecurityInformation *this,
198 HWND hwnd,
199 UINT uMsg,
200 SI_PAGE_TYPE uPage);
201
203{
204 /* IUnknown methods */
208
209 /* ISecurityInformation methods */
217};
218
219#if REGEDIT_IMPLEMENT_ISECURITYINFORMATION2
220/******************************************************************************
221 Definition of the ISecurityInformation2 interface
222 ******************************************************************************/
223
224/* IUnknown */
226ISecurityInformation2_fnQueryInterface(struct ISecurityInformation2 *this,
227 REFIID iid,
228 PVOID *pvObject);
229
231ISecurityInformation2_fnAddRef(struct ISecurityInformation2 *this);
232
234ISecurityInformation2_fnRelease(struct ISecurityInformation2 *this);
235
236/* ISecurityInformation2 */
238ISecurityInformation2_fnIsDaclCanonical(struct ISecurityInformation2 *this,
239 PACL pDacl);
240
242ISecurityInformation2_fnLookupSids(struct ISecurityInformation2 *this,
243 ULONG cSids,
244 PSID* rgpSids,
245 LPDATAOBJECT* ppdo);
246
247static const struct ifaceISecurityInformation2Vbtl vtblISecurityInformation2 =
248{
249 /* IUnknown methods */
250 ISecurityInformation2_fnQueryInterface,
251 ISecurityInformation2_fnAddRef,
252 ISecurityInformation2_fnRelease,
253
254 /* ISecurityInformation2 methods */
255 ISecurityInformation2_fnIsDaclCanonical,
256 ISecurityInformation2_fnLookupSids
257};
258#endif
259
260/******************************************************************************
261 Definition of the IEffectivePermission interface
262 ******************************************************************************/
263
264/* IUnknown */
266IEffectivePermission_fnQueryInterface(struct IEffectivePermission *this,
267 REFIID iid,
268 PVOID *pvObject);
269
271IEffectivePermission_fnAddRef(struct IEffectivePermission *this);
272
274IEffectivePermission_fnRelease(struct IEffectivePermission *this);
275
276/* IEffectivePermission */
278IEffectivePermission_fnGetEffectivePermission(struct IEffectivePermission *this,
279 const GUID* pguidObjectType,
280 PSID pUserSid,
281 LPCWSTR pszServerName,
283 POBJECT_TYPE_LIST* ppObjectTypeList,
284 ULONG* pcObjectTypeListLength,
285 PACCESS_MASK* ppGrantedAccessList,
286 ULONG* pcGrantedAccessListLength);
287
289{
290 /* IUnknown methods */
294
295 /* IEffectivePermissions methods */
297};
298
299/******************************************************************************
300 Definition of the ISecurityObjectTypeInfo interface
301 ******************************************************************************/
302
303/* IUnknown */
305ISecurityObjectTypeInfo_fnQueryInterface(struct ISecurityObjectTypeInfo *this,
306 REFIID iid,
307 PVOID *pvObject);
308
310ISecurityObjectTypeInfo_fnAddRef(struct ISecurityObjectTypeInfo *this);
311
313ISecurityObjectTypeInfo_fnRelease(struct ISecurityObjectTypeInfo *this);
314
315/* ISecurityObjectTypeInfo */
317ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
319 PACL pACL,
320 PINHERITED_FROM* ppInheritArray);
321
323{
324 /* IUnknown methods */
328
329 /* ISecurityObjectTypeInfo methods */
331};
332
333
334/******************************************************************************
335 Implementation of the ISecurityInformation interface
336 ******************************************************************************/
337
351};
352
353static const DWORD RegDefaultAccess = 1; /* KEY_READ */
354
356 KEY_READ,
357 KEY_WRITE,
360};
361
366};
367
369ISecurityInformation_fnQueryInterface(struct ISecurityInformation *this,
370 REFIID iid,
372{
373 if (IsEqualGUID(iid,
374 &IID_IUnknown))
375 {
376 *pvObject = (PVOID)this;
378 return S_OK;
379 }
380
382 iid,
383 pvObject);
384}
385
387ISecurityInformation_fnAddRef(struct ISecurityInformation *this)
388{
390}
391
393ISecurityInformation_fnRelease(struct ISecurityInformation *this)
394{
396}
397
399ISecurityInformation_fnGetObjectInformation(struct ISecurityInformation *this,
400 PSI_OBJECT_INFO pObjectInfo)
401{
403
404 *pObjectInfo = obj->ObjectInfo;
405 return S_OK;
406}
407
409ISecurityInformation_fnGetSecurity(struct ISecurityInformation *this,
410 SECURITY_INFORMATION RequestedInformation,
411 PSECURITY_DESCRIPTOR* ppSecurityDescriptor,
412 BOOL fDefault)
413{
416
419 RequestedInformation,
420 NULL,
421 NULL,
422 NULL,
423 NULL,
424 ppSecurityDescriptor);
425
427}
428
430ISecurityInformation_fnSetSecurity(struct ISecurityInformation *this,
431 SECURITY_INFORMATION RequestedInformation,
432 PSECURITY_DESCRIPTOR pSecurityDescriptor)
433{
435
436 /* FIXME */
437 *obj->Btn = TRUE;
438 return S_OK;
439}
440
442ISecurityInformation_fnGetAccessRights(struct ISecurityInformation *this,
443 const GUID* pguidObjectType,
445 PSI_ACCESS* ppAccess,
446 ULONG* pcAccesses,
447 ULONG* piDefaultAccess)
448{
449 *ppAccess = RegAccess;
450 *pcAccesses = ARRAY_SIZE(RegAccess);
451 *piDefaultAccess = RegDefaultAccess;
452 return S_OK;
453}
454
456ISecurityInformation_fnMapGeneric(struct ISecurityInformation *this,
457 const GUID* pguidObjectType,
458 UCHAR* pAceFlags,
459 ACCESS_MASK* pMask)
460{
461 MapGenericMask(pMask,
463 *pMask &= ~SYNCHRONIZE;
464 return S_OK;
465}
466
468ISecurityInformation_fnGetInheritTypes(struct ISecurityInformation *this,
469 PSI_INHERIT_TYPE* ppInheritTypes,
470 ULONG* pcInheritTypes)
471{
473
474 /* FIXME */
475 if (obj->ObjectInfo.dwFlags & SI_CONTAINER)
476 {
477 *ppInheritTypes = RegInheritTypes;
478 *pcInheritTypes = ARRAY_SIZE(RegInheritTypes);
479 return S_OK;
480 }
481
482 return E_NOTIMPL;
483}
484
486ISecurityInformation_fnPropertySheetPageCallback(struct ISecurityInformation *this,
487 HWND hwnd,
488 UINT uMsg,
489 SI_PAGE_TYPE uPage)
490{
491 return S_OK;
492}
493
494#if REGEDIT_IMPLEMENT_ISECURITYINFORMATION2
495/******************************************************************************
496 Implementation of the ISecurityInformation2 interface
497 ******************************************************************************/
498
500ISecurityInformation2_fnQueryInterface(struct ISecurityInformation2 *this,
501 REFIID iid,
503{
504 if (IsEqualGUID(iid,
505 &IID_IUnknown))
506 {
507 *pvObject = (PVOID)this;
508 ISecurityInformation2_fnAddRef(this);
509 return S_OK;
510 }
511
512 return CRegKeySecurity_fnQueryInterface(impl_from_ISecurityInformation2(this),
513 iid,
514 pvObject);
515}
516
518ISecurityInformation2_fnAddRef(struct ISecurityInformation2 *this)
519{
520 return CRegKeySecurity_fnAddRef(impl_from_ISecurityInformation2(this));
521}
522
524ISecurityInformation2_fnRelease(struct ISecurityInformation2 *this)
525{
526 return CRegKeySecurity_fnRelease(impl_from_ISecurityInformation2(this));
527}
528
530ISecurityInformation2_fnIsDaclCanonical(struct ISecurityInformation2 *this,
531 PACL pDacl)
532{
533 /* FIXME */
534 return TRUE;
535}
536
538ISecurityInformation2_fnLookupSids(struct ISecurityInformation2 *this,
539 ULONG cSids,
540 PSID* rgpSids,
541 LPDATAOBJECT* ppdo)
542{
543 /* FIXME */
544 return E_NOTIMPL;
545}
546#endif
547
548/******************************************************************************
549 Implementation of the IEffectivePermission interface
550 ******************************************************************************/
551
553IEffectivePermission_fnQueryInterface(struct IEffectivePermission *this,
554 REFIID iid,
556{
557 if (IsEqualGUID(iid,
558 &IID_IUnknown))
559 {
560 *pvObject = (PVOID)this;
562 return S_OK;
563 }
564
566 iid,
567 pvObject);
568}
569
571IEffectivePermission_fnAddRef(struct IEffectivePermission *this)
572{
574}
575
577IEffectivePermission_fnRelease(struct IEffectivePermission *this)
578{
580}
581
583IEffectivePermission_fnGetEffectivePermission(struct IEffectivePermission *this,
584 const GUID* pguidObjectType,
585 PSID pUserSid,
586 LPCWSTR pszServerName,
588 POBJECT_TYPE_LIST* ppObjectTypeList,
589 ULONG* pcObjectTypeListLength,
590 PACCESS_MASK* ppGrantedAccessList,
591 ULONG* pcGrantedAccessListLength)
592{
593 PACL Dacl = NULL;
595 PACCESS_MASK GrantedAccessList;
597 TRUSTEE Trustee = {0};
598 static OBJECT_TYPE_LIST DefObjTypeList = {0};
599
600 *ppObjectTypeList = &DefObjTypeList;
601 *pcObjectTypeListLength = 1;
602
603 BuildTrusteeWithSid(&Trustee,
604 pUserSid);
605
608 &Dacl,
610 {
611 GrantedAccessList = (PACCESS_MASK)LocalAlloc(LMEM_FIXED,
612 sizeof(ACCESS_MASK));
613 if (GrantedAccessList == NULL)
614 {
615 goto Fail;
616 }
617
619 &Trustee,
620 GrantedAccessList);
622 {
623 *ppGrantedAccessList = GrantedAccessList;
624 *pcGrantedAccessListLength = 1;
625 }
626 else
627 LocalFree((HLOCAL)GrantedAccessList);
628 }
629 else
630Fail:
632
634}
635
636/******************************************************************************
637 Implementation of the ISecurityObjectTypeInfo interface
638 ******************************************************************************/
639
641ISecurityObjectTypeInfo_fnQueryInterface(struct ISecurityObjectTypeInfo *this,
642 REFIID iid,
644{
645 if (IsEqualGUID(iid,
646 &IID_IUnknown))
647 {
648 *pvObject = (PVOID)this;
650 return S_OK;
651 }
652
654 iid,
655 pvObject);
656}
657
659ISecurityObjectTypeInfo_fnAddRef(struct ISecurityObjectTypeInfo *this)
660{
662}
663
665ISecurityObjectTypeInfo_fnRelease(struct ISecurityObjectTypeInfo *this)
666{
668}
669
671ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this,
673 PACL pACL,
674 PINHERITED_FROM* ppInheritArray)
675{
677 PINHERITED_FROM pif, pif2;
678 SIZE_T pifSize;
680 LPWSTR lpBuf;
681
682 pifSize = pACL->AceCount * sizeof(INHERITED_FROM);
683 pif = (PINHERITED_FROM)HeapAlloc(GetProcessHeap(),
684 0,
685 pifSize);
686 if (pif == NULL)
687 {
688 return E_OUTOFMEMORY;
689 }
690
693 si,
694 (obj->ObjectInfo.dwFlags & SI_CONTAINER) != 0,
695 NULL,
696 0,
697 pACL,
698 NULL,
700 pif);
701
703 {
704 /* Calculate the size of the buffer to return */
705 for (i = 0;
706 i < pACL->AceCount;
707 i++)
708 {
709 if (pif[i].AncestorName != NULL)
710 {
711 pifSize += (wcslen(pif[i].AncestorName) + 1) * sizeof(WCHAR);
712 }
713 }
714
715 /* Allocate enough space for the array and the strings */
716 pif2 = (PINHERITED_FROM)LocalAlloc(LMEM_FIXED,
717 pifSize);
718 if (pif2 == NULL)
719 {
721 goto Cleanup;
722 }
723
724 /* copy the array and strings to the buffer */
725 lpBuf = (LPWSTR)((ULONG_PTR)pif2 + (pACL->AceCount * sizeof(INHERITED_FROM)));
726 for (i = 0;
727 i < pACL->AceCount;
728 i++)
729 {
730 pif2[i].GenerationGap = pif[i].GenerationGap;
731 if (pif[i].AncestorName != NULL)
732 {
733 pif2[i].AncestorName = lpBuf;
734 wcscpy(lpBuf,
735 pif[i].AncestorName);
736 lpBuf += wcslen(pif[i].AncestorName) + 1;
737 }
738 else
739 pif2[i].AncestorName = NULL;
740 }
741
742 /* return the newly allocated array */
743 *ppInheritArray = pif2;
744 }
745
746Cleanup:
748 pACL->AceCount,
749 NULL);
751 0,
752 pif);
753
755}
756
757/******************************************************************************
758 Implementation of the CRegKeySecurity constructor
759 ******************************************************************************/
760
761static PCRegKeySecurity
763 HKEY hRootKey,
764 SI_OBJECT_INFO *ObjectInfo,
765 BOOL *Btn)
766{
768
772 szRegKey[wcslen(lpRegKey) + 1]));
773 if (obj != NULL)
774 {
775 obj->ref = 1;
776 obj->lpISecurityInformationVtbl = &vtblISecurityInformation;
777#if REGEDIT_IMPLEMENT_ISECURITYINFORMATION2
778 obj->lpISecurityInformation2Vtbl = &vtblISecurityInformation2;
779#endif
780 obj->lpIEffectivePermissionVtbl = &vtblIEffectivePermission;
781 obj->lpISecurityObjectTypeInfoVtbl = &vtblISecurityObjectTypeInfo;
782 obj->ObjectInfo = *ObjectInfo;
783 obj->Btn = Btn;
784 obj->hRootKey = hRootKey;
785 wcscpy(obj->szRegKey,
786 lpRegKey);
787 }
788 else
790
791 return obj;
792}
793
794/******************************************************************************/
795/******************************************************************************/
796/******************************************************************************/
797
798typedef struct _CHANGE_CONTEXT
799{
803
804typedef BOOL (WINAPI *PEDITSECURITY)(HWND hwndOwner,
805 struct ISecurityInformation *psi);
806
809
810BOOL
812{
813 if (!(hAclUiDll = LoadLibraryW(L"aclui.dll")))
814 {
815 return FALSE;
816 }
817
819 "EditSecurity")))
820 {
822 hAclUiDll = NULL;
823 return FALSE;
824 }
825
826 return TRUE;
827}
828
829VOID
831{
832 if (hAclUiDll != NULL)
833 {
835 }
836}
837
838BOOL
840 HKEY hKey,
841 LPCWSTR lpMachine,
842 LPCWSTR lpKeyName)
843{
844 BOOL Result = FALSE;
845 LPCWSTR lphKey = NULL;
846 LPWSTR lpKeyPath = NULL;
847 PCRegKeySecurity RegKeySecurity;
848 SI_OBJECT_INFO ObjectInfo;
849 size_t lnMachine = 0, lnKeyName = 0;
850
851 if (pfnEditSecurity == NULL)
852 {
853 return FALSE;
854 }
855
856 if (lpMachine != NULL)
857 lnMachine = wcslen(lpMachine);
858 if (lpKeyName != NULL)
859 lnKeyName = wcslen(lpKeyName);
860
861 /* build registry path */
862 if (lpMachine != NULL &&
863 (lpMachine[0] == L'\0' ||
864 (lpMachine[0] == L'.' && lpMachine[1] == L'.')))
865 {
866 lnMachine = 0;
867 }
868
869 if (hKey == HKEY_CLASSES_ROOT)
870 lphKey = L"CLASSES_ROOT";
871 else if (hKey == HKEY_CURRENT_USER)
872 lphKey = L"CURRENT_USER";
873 else if (hKey == HKEY_LOCAL_MACHINE)
874 lphKey = L"MACHINE";
875 else if (hKey == HKEY_USERS)
876 lphKey = L"USERS";
877 else if (hKey == HKEY_CURRENT_CONFIG)
878 lphKey = L"CONFIG";
879 else
880 goto Cleanup;
881
882 lpKeyPath = HeapAlloc(GetProcessHeap(),
883 0,
884 (2 + lnMachine + 1 + wcslen(lphKey) + 1 + lnKeyName) * sizeof(WCHAR));
885 if (lpKeyPath == NULL)
886 {
888 goto Cleanup;
889 }
890 lpKeyPath[0] = L'\0';
891
892 if (lnMachine != 0)
893 {
894 wcscat(lpKeyPath,
895 L"\\\\");
896 wcscat(lpKeyPath,
897 lpMachine);
898 wcscat(lpKeyPath,
899 L"\\");
900 }
901
902 wcscat(lpKeyPath,
903 lphKey);
904 if (lpKeyName != NULL && lpKeyName[0] != L'\0')
905 {
906 if (lpKeyName[0] != L'\\')
907 {
908 wcscat(lpKeyPath,
909 L"\\");
910 }
911
912 wcscat(lpKeyPath,
913 lpKeyName);
914 }
915
918 ObjectInfo.hInstance = hInst;
919 ObjectInfo.pszServerName = (LPWSTR)lpMachine;
920 ObjectInfo.pszObjectName = (LPWSTR)lpKeyName; /* FIXME */
921 ObjectInfo.pszPageTitle = (LPWSTR)lpKeyName; /* FIXME */
922
923 if (!(RegKeySecurity = CRegKeySecurity_fnConstructor(lpKeyPath,
924 hKey,
925 &ObjectInfo,
926 &Result)))
927 {
928 goto Cleanup;
929 }
930
931 /* display the security editor dialog */
932 pfnEditSecurity(hWndOwner,
933 impl_to_interface(RegKeySecurity,
934 ISecurityInformation));
935
936 /* dereference the interface, it should be destroyed here */
937 CRegKeySecurity_fnRelease(RegKeySecurity);
938
939Cleanup:
940 if (lpKeyPath != NULL)
941 {
943 0,
944 lpKeyPath);
945 }
946
947 return Result;
948}
949
950/* EOF */
DWORD WINAPI GetInheritanceSourceW(LPWSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, BOOL Container, GUID **pObjectClassGuids OPTIONAL, DWORD GuidCount, PACL pAcl, PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL, PGENERIC_MAPPING pGenericMapping, PINHERITED_FROMW pInheritArray)
Definition: ac.c:115
DWORD WINAPI FreeInheritedFromArray(PINHERITED_FROMW pInheritArray, USHORT AceCnt, PFN_OBJECT_MGR_FUNCTS pfnArray OPTIONAL)
Definition: ac.c:175
#define SI_CONTAINER
Definition: accctrl.h:116
@ SE_REGISTRY_KEY
Definition: accctrl.h:163
enum _SI_PAGE_TYPE SI_PAGE_TYPE
#define SI_RESET_DACL_TREE
Definition: accctrl.h:127
#define SI_OWNER_RECURSE
Definition: accctrl.h:122
#define SI_EDIT_ALL
Definition: accctrl.h:136
#define SI_ACCESS_SPECIFIC
Definition: accctrl.h:138
#define SI_ACCESS_GENERAL
Definition: accctrl.h:139
#define SI_EDIT_PERMS
Definition: accctrl.h:113
#define SI_EDIT_EFFECTIVE
Definition: accctrl.h:130
#define SI_RESET_SACL_TREE
Definition: accctrl.h:128
#define SI_ADVANCED
Definition: accctrl.h:118
#define BuildTrusteeWithSid
Definition: aclapi.h:230
#define GetEffectiveRightsFromAcl
Definition: aclapi.h:232
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define ARRAY_SIZE(A)
Definition: main.h:33
#define IDS_ACCESS_CREATELINK
Definition: resource.h:179
#define IDS_ACCESS_WRITEOWNER
Definition: resource.h:182
#define IDS_ACCESS_READ
Definition: resource.h:173
#define IDS_ACCESS_READCONTROL
Definition: resource.h:183
#define IDS_INHERIT_SUBKEYSONLY
Definition: resource.h:187
#define IDS_ACCESS_SETVALUE
Definition: resource.h:175
#define IDS_ACCESS_ENUMERATESUBKEYS
Definition: resource.h:177
#define IDS_ACCESS_NOTIFY
Definition: resource.h:178
#define IDS_ACCESS_FULLCONTROL
Definition: resource.h:172
#define IDS_ACCESS_QUERYVALUE
Definition: resource.h:174
#define IDS_ACCESS_WRITEDAC
Definition: resource.h:181
#define IDS_INHERIT_THISKEYONLY
Definition: resource.h:185
#define IDS_INHERIT_THISKEYANDSUBKEYS
Definition: resource.h:186
#define IDS_ACCESS_CREATESUBKEY
Definition: resource.h:176
#define IDS_ACCESS_DELETE
Definition: resource.h:180
static HRESULT STDMETHODCALLTYPE ISecurityObjectTypeInfo_fnQueryInterface(struct ISecurityObjectTypeInfo *this, REFIID iid, PVOID *pvObject)
Definition: security.c:641
static ULONG STDMETHODCALLTYPE ISecurityObjectTypeInfo_fnAddRef(struct ISecurityObjectTypeInfo *this)
Definition: security.c:659
static HRESULT STDMETHODCALLTYPE IEffectivePermission_fnQueryInterface(struct IEffectivePermission *this, REFIID iid, PVOID *pvObject)
Definition: security.c:553
static __inline PCRegKeySecurity impl_from_ISecurityInformation(struct ISecurityInformation *iface)
Definition: security.c:47
static HRESULT STDMETHODCALLTYPE ISecurityObjectTypeInfo_fnGetInheritSource(struct ISecurityObjectTypeInfo *this, SECURITY_INFORMATION si, PACL pACL, PINHERITED_FROM *ppInheritArray)
Definition: security.c:671
static __inline PCRegKeySecurity impl_from_IEffectivePermission(struct IEffectivePermission *iface)
Definition: security.c:70
static HRESULT STDMETHODCALLTYPE IEffectivePermission_fnGetEffectivePermission(struct IEffectivePermission *this, const GUID *pguidObjectType, PSID pUserSid, LPCWSTR pszServerName, PSECURITY_DESCRIPTOR pSD, POBJECT_TYPE_LIST *ppObjectTypeList, ULONG *pcObjectTypeListLength, PACCESS_MASK *ppGrantedAccessList, ULONG *pcGrantedAccessListLength)
Definition: security.c:583
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnQueryInterface(struct ISecurityInformation *this, REFIID iid, PVOID *pvObject)
Definition: security.c:369
BOOL(WINAPI * PEDITSECURITY)(HWND hwndOwner, struct ISecurityInformation *psi)
Definition: security.c:804
static ULONG STDMETHODCALLTYPE ISecurityInformation_fnAddRef(struct ISecurityInformation *this)
Definition: security.c:387
static ULONG STDMETHODCALLTYPE ISecurityObjectTypeInfo_fnRelease(struct ISecurityObjectTypeInfo *this)
Definition: security.c:665
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnGetSecurity(struct ISecurityInformation *this, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR *ppSecurityDescriptor, BOOL fDefault)
Definition: security.c:409
BOOL InitializeAclUiDll(VOID)
Definition: security.c:811
static ULONG STDMETHODCALLTYPE ISecurityInformation_fnRelease(struct ISecurityInformation *this)
Definition: security.c:393
static __inline ULONG CRegKeySecurity_fnAddRef(PCRegKeySecurity obj)
Definition: security.c:79
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnMapGeneric(struct ISecurityInformation *this, const GUID *pguidObjectType, UCHAR *pAceFlags, ACCESS_MASK *pMask)
Definition: security.c:456
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnSetSecurity(struct ISecurityInformation *this, SECURITY_INFORMATION RequestedInformation, PSECURITY_DESCRIPTOR pSecurityDescriptor)
Definition: security.c:430
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnGetObjectInformation(struct ISecurityInformation *this, PSI_OBJECT_INFO pObjectInfo)
Definition: security.c:399
static __inline HRESULT CRegKeySecurity_fnQueryInterface(PCRegKeySecurity obj, REFIID iid, PVOID *pvObject)
Definition: security.c:101
VOID UnloadAclUiDll(VOID)
Definition: security.c:830
static __inline ULONG CRegKeySecurity_fnRelease(PCRegKeySecurity obj)
Definition: security.c:85
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnGetInheritTypes(struct ISecurityInformation *this, PSI_INHERIT_TYPE *ppInheritTypes, ULONG *pcInheritTypes)
Definition: security.c:468
static const struct ifaceIEffectivePermissionVbtl vtblIEffectivePermission
Definition: security.c:288
static SI_ACCESS RegAccess[]
Definition: security.c:338
static GENERIC_MAPPING RegAccessMasks
Definition: security.c:355
static PCRegKeySecurity CRegKeySecurity_fnConstructor(LPWSTR lpRegKey, HKEY hRootKey, SI_OBJECT_INFO *ObjectInfo, BOOL *Btn)
Definition: security.c:762
#define impl_to_interface(impl, iface)
Definition: security.c:76
static const struct ifaceISecurityInformationVbtl vtblISecurityInformation
Definition: security.c:202
static const struct ifaceISecurityObjectTypeInfoVbtl vtblISecurityObjectTypeInfo
Definition: security.c:322
BOOL RegKeyEditPermissions(HWND hWndOwner, HKEY hKey, LPCWSTR lpMachine, LPCWSTR lpKeyName)
Definition: security.c:839
static PEDITSECURITY pfnEditSecurity
Definition: security.c:807
static HMODULE hAclUiDll
Definition: security.c:808
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnPropertySheetPageCallback(struct ISecurityInformation *this, HWND hwnd, UINT uMsg, SI_PAGE_TYPE uPage)
Definition: security.c:486
static HRESULT STDMETHODCALLTYPE ISecurityInformation_fnGetAccessRights(struct ISecurityInformation *this, const GUID *pguidObjectType, DWORD dwFlags, PSI_ACCESS *ppAccess, ULONG *pcAccesses, ULONG *piDefaultAccess)
Definition: security.c:442
static SI_INHERIT_TYPE RegInheritTypes[]
Definition: security.c:362
static ULONG STDMETHODCALLTYPE IEffectivePermission_fnAddRef(struct IEffectivePermission *this)
Definition: security.c:571
static ULONG STDMETHODCALLTYPE IEffectivePermission_fnRelease(struct IEffectivePermission *this)
Definition: security.c:577
struct _CHANGE_CONTEXT * PCHANGE_CONTEXT
static const DWORD RegDefaultAccess
Definition: security.c:353
static __inline PCRegKeySecurity impl_from_ISecurityObjectTypeInfo(struct ISecurityObjectTypeInfo *iface)
Definition: security.c:63
struct _CHANGE_CONTEXT CHANGE_CONTEXT
struct _CRegKeySecurity * PCRegKeySecurity
const GUID IID_IUnknown
#define STDMETHODCALLTYPE
Definition: bdasup.h:9
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD WINAPI GetNamedSecurityInfoW(LPWSTR pObjectName, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, PSID *ppsidOwner, PSID *ppsidGroup, PACL *ppDacl, PACL *ppSacl, PSECURITY_DESCRIPTOR *ppSecurityDescriptor)
Definition: misc.c:1147
#define GetProcessHeap()
Definition: compat.h:736
#define SetLastError(x)
Definition: compat.h:752
#define GetProcAddress(x, y)
Definition: compat.h:753
#define HeapAlloc
Definition: compat.h:733
#define FreeLibrary(x)
Definition: compat.h:748
#define HeapFree(x, y, z)
Definition: compat.h:735
#define LoadLibraryW(x)
Definition: compat.h:747
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const WCHAR Cleanup[]
Definition: register.c:80
#define ULONG_PTR
Definition: config.h:101
HINSTANCE hInst
Definition: dxdiag.c:13
int Fail
Definition: ehthrow.cxx:24
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define S_OK
Definition: intsafe.h:52
#define GUID_NULL
Definition: ks.h:106
DWORD SECURITY_INFORMATION
Definition: ms-dtyp.idl:311
unsigned int UINT
Definition: ndis.h:50
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1593
_In_ BOOLEAN DaclPresent
Definition: rtlfuncs.h:1635
_In_ BOOLEAN _In_opt_ PACL _In_opt_ BOOLEAN DaclDefaulted
Definition: rtlfuncs.h:1638
#define BOOL
Definition: nt_native.h:43
#define WRITE_DAC
Definition: nt_native.h:59
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define KEY_READ
Definition: nt_native.h:1023
ACCESS_MASK * PACCESS_MASK
Definition: nt_native.h:41
#define KEY_CREATE_SUB_KEY
Definition: nt_native.h:1018
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define KEY_EXECUTE
Definition: nt_native.h:1037
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
#define DELETE
Definition: nt_native.h:57
#define KEY_WRITE
Definition: nt_native.h:1031
#define READ_CONTROL
Definition: nt_native.h:58
#define WRITE_OWNER
Definition: nt_native.h:60
#define KEY_CREATE_LINK
Definition: nt_native.h:1021
#define KEY_NOTIFY
Definition: nt_native.h:1020
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
interface IDataObject * LPDATAOBJECT
Definition: objfwd.h:21
long LONG
Definition: pedump.c:60
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
BOOL WINAPI GetSecurityDescriptorDacl(PSECURITY_DESCRIPTOR pSecurityDescriptor, LPBOOL lpbDaclPresent, PACL *pDacl, LPBOOL lpbDaclDefaulted)
Definition: sec.c:45
USHORT AceCount
Definition: ms-dtyp.idl:297
LPWSTR KeyString
Definition: security.c:801
LPWSTR pszObjectName
Definition: accctrl.h:391
LPWSTR pszPageTitle
Definition: accctrl.h:392
DWORD dwFlags
Definition: accctrl.h:388
HINSTANCE hInstance
Definition: accctrl.h:389
LPWSTR pszServerName
Definition: accctrl.h:390
REFIID PVOID * pvObject
Definition: security.h:95
REFIID PVOID * pvObject
Definition: security.h:23
SECURITY_INFORMATION si
Definition: security.h:129
SECURITY_INFORMATION PACL PINHERITED_FROM * ppInheritArray
Definition: security.h:131
SECURITY_INFORMATION PACL pACL
Definition: security.h:130
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
VOID WINAPI MapGenericMask(PDWORD, PGENERIC_MAPPING)
#define LMEM_FIXED
Definition: winbase.h:368
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_CONFIG
Definition: winreg.h:15
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define HKEY_USERS
Definition: winreg.h:13
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define CONTAINER_INHERIT_ACE
Definition: setypes.h:747
#define INHERIT_ONLY_ACE
Definition: setypes.h:749
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185