SedDiscretionaryAclEditor 怎么用?(200分)

  • 主题发起人 主题发起人 kcahcn
  • 开始时间 开始时间
K

kcahcn

Unregistered / Unconfirmed
GUEST, unregistred user!
Hi All.<br>SedDiscretionaryAclEditor &nbsp;是一个未公开的函数。<br>我找了很长时间关于它的资料,只有Mark Russinovich写了个好文章关于 ACL Edit<br>http://www.sysinternals.com/ntw2k/info/acledit.shtml<br>问题我不知道怎么用这个函数,我试过很多次还是没成功。<br>我反汇编了一些软件用了这个函数(“WinObj、Procexp“ Mark Russinovich 的作品, “Pview“微软的)<br>可是很难懂 :(<br>我需要一个简单的例子。<br>Waiting ...
 
???<br>delphibbs 的人去哪儿了??<br><br>up
 
Incredible!<br>这儿有没有人?<br>这么多人,没有一个感兴趣吗??<br>是不是200分不够?<br>这是我第一次在这儿问问题。真让我失望。
 
这个函数将弹出一个对话框<br>DWORD SedDiscretionaryAclEditor( // 函数调用成功返回 0<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HWND Owner, // 所有者窗口句柄,比如 Form1.Handle<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HINSTANCE Instance, // 应用程序实例 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PWCHAR MachineName, // 主机名(宽字符) optional ,NUIL 为本机名<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PACLDLGCONTROL AclDlgControl,// 指向 ACL 对话框控件数据结构<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PACLEDITCONTROL AclEditControl,// 指向 ACL 编辑控件数据结构<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PWCHAR ObjectName,// 对象名字串,指向一个需要定义安全属性的对象(宽字符) <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PACLCHANGE ChangeCallback, // 回调函数,一旦对话框关闭或 Edit 改变<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PVOID ChangeCallbackContext, // 回调上下文,是你定义的,回调时被返回来<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PSECURITY_DESCRIPTOR ObjectSecurity, // 对象安全描述<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN NoReadPermission, // 安全属性的读取许可与否<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN ReadOnly, // 只读标志,没有添加和删除按钮<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PDWORD ChangeContextStatus,// 状态,表示回调时的状况<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PVOID MustBeZero // 必须为零——看来是保留参数 <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br>注意有宽字符的必须做点转换,不然乱码。<br>我在你提供的地址没有发现回调函数的格式说明,估计和 Windows 其他 32770 类<br>的格式是差不多的吧,难就难在这里了啊。不对,有回调结构:<br>typedef DWORD CALLBACK (*ACLCHANGE )( <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HWND Owner, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HANDLE Instance, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PVOID CallbackContext, <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PSECURITY_DESCRIPTOR NewSD,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PSECURITY_DESCRIPTOR NewObjectSD,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN ApplyToSubContainers,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN ApplyToSubObjects,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PDWORD ChangeContextStatus<br>);<br>数据结构也有。所以我觉得这个问题太复杂了,首先要定义数据结构,<br>再要定义函数调用,然后写自己的回调。这得好好研究一些时间了。<br><br>TO:kcahcn<br>&nbsp; 试试看直接向 Mark Russinovich 或 Bryce Cogswell 写信请教请教 。
 
终于有人说话了! [:D]<br>谢谢你。<br>你所写的我都知道,在sysinternal都有。我已经把结构换成delphi代码<br>我的问题是怎么调用那函数。有些参数不知道怎么初始,该赋什么值。。。<br>再次感谢你 (小雨哥)。
 
Thank you all in delphibbs<br>我已经找到了有关的例子<br>是 Trevor Scroggins 写的,网上好像没有。我是通过Email得到的。<br>如果有人有兴趣的话,我会放代码在这儿。。。<br><br>CIONO1
 
需要,放吧,谢谢!
 
TO:CIONO1<br>其实我很想看看,如果可以,给我发一份 wangxy@371.net 谢谢。
 
感谢 Trevor Scroggins 提供代码 。<br>SEDAPI.H :<br>/**********************************************************************/<br>/** &nbsp;Microsoft LAN Manager &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; **/<br>/** Copyright(c) Microsoft Corp., 1990-1993 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; **/<br>/**********************************************************************/<br><br>/*<br>&nbsp; &nbsp; SEDAPI.h<br><br>&nbsp; &nbsp; This File contains the prototypes and descriptions for the interface to<br>&nbsp; &nbsp; the generic security editor dialogs for NT objects.<br><br>&nbsp; &nbsp; FILE HISTORY:<br> Johnl 02-Aug-1991 Created<br> Johnl 27-Dec-1991 Updated to reflect reality<br> JohnL 25-Feb-1992 Nuked NewObjValidMask (new obj use generic/stan.<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; only, Added GENERIC_MAPPING param.<br>&nbsp; &nbsp; &nbsp; &nbsp; Johnl &nbsp; 15-Jan-1993 &nbsp; &nbsp; Added CantRead flags, cleaned up comments<br><br>*/<br><br>#ifndef _SEDAPI_H_<br>#define _SEDAPI_H_<br><br>#ifdef __cplusplus<br>extern "C" {<br>#endif<br><br>//<br>// The following are status codes indicating the state of the permissions on<br>// the resource we are setting permissions for.<br>//<br>#define SED_STATUS_MODIFIED (1)<br>#define SED_STATUS_NOT_MODIFIED (2)<br>#define SED_STATUS_NOT_ALL_MODIFIED (3)<br>#define SED_STATUS_FAILED_TO_MODIFY (4)<br><br>//<br>// Current Security editor revision level.<br>//<br>#define SED_REVISION &nbsp; &nbsp;(1)<br><br>#define SED_REVISION1 &nbsp; &nbsp;(1)<br><br>//<br>// The following structure is for user help in the various dialogs. &nbsp;Each<br>// use of the security editor (whether for files/directories, Registry, Printer<br>// stuff etc.) will have its own set of permission names/capabilities, thus<br>// each will require its own help file. &nbsp;This structure allows the client<br>// of the security editor to specify which help files and which help<br>// contexts should be used for each dialog.<br>//<br>typedef struct _SED_HELP_INFO<br>{<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The name of the ".hlp" file to be passed to the help engine APIs.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR pszHelpFileName ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // An array of help contexts corresponding to each dialog.<br>&nbsp; &nbsp; // Use the HC_ manifiests defined below to fill this array. &nbsp;The<br>&nbsp; &nbsp; // manifests correspond to the following dialogs:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // &nbsp;HC_MAIN_DLG - First dialog brought up by the ACL editor<br>&nbsp; &nbsp; // &nbsp;HC_SPECIAL_ACCESS_DLG - Container/object special access dialog<br>&nbsp; &nbsp; // &nbsp;HC_NEW_ITEM_SPECIAL_ACCESS_DLG - New item special access dialog<br>&nbsp; &nbsp; // (not needed for containers that do not support new item<br>&nbsp; &nbsp; // permissions).<br>&nbsp; &nbsp; // &nbsp;HC_ADD_USER_DLG - The "Add" dialog (brought up when the "Add..."<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;button is pressed).<br>&nbsp; &nbsp; // &nbsp; &nbsp;HC_ADD_USER_MEMBERS_LG_DLG - The Local Group members dialog (brought<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;up from the "Members" button in the "Add" dialog)<br>&nbsp; &nbsp; // &nbsp; &nbsp;HC_ADD_USER_MEMBERS_GG_DLG - The Global Group members dialog (brought<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;up from the "Members" button in the "Add" dialog).<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; aulHelpContext[7] ;<br>} SED_HELP_INFO, *PSED_HELP_INFO ;<br><br>#define HC_MAIN_DLG 0<br>#define HC_SPECIAL_ACCESS_DLG 1<br>#define HC_NEW_ITEM_SPECIAL_ACCESS_DLG 2<br>#define HC_ADD_USER_DLG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3<br>#define HC_ADD_USER_MEMBERS_LG_DLG &nbsp; &nbsp; &nbsp; 4 &nbsp;// Members Local Group Dialog<br>#define HC_ADD_USER_MEMBERS_GG_DLG &nbsp; &nbsp; &nbsp; 5 &nbsp;// Members Global Group Dialog<br>#define HC_ADD_USER_SEARCH_DLG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 6 &nbsp;// Search Dialog<br><br>//<br>// This data type defines information related to a single class of object.<br>// For example, a FILE object, or PRINT_QUEUE object would have a structure<br>// like this defined.<br>//<br><br>typedef struct _SED_OBJECT_TYPE_DESCRIPTOR<br>{<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The current revision level being used by the client. &nbsp;This is for<br>&nbsp; &nbsp; // support in case structure definitions change. &nbsp;It should contain<br>&nbsp; &nbsp; // the current revision supported.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; UCHAR Revision ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // Defines whether the object is a container or not.<br>&nbsp; &nbsp; // TRUE indicates the object may contain other objects. &nbsp;Means the<br>&nbsp; &nbsp; // user can Tree apply the permissions if desired.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; BOOLEAN IsContainer;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // Defines whether "New Object" permissions can be assigned (i.e.,<br>&nbsp; &nbsp; // a "New Object" is an object that will be created in the future).<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This field is ignored when editting Auditting information<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; BOOLEAN AllowNewObjectPerms ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This flag, if set to TRUE, will make the ACL editor map all specific<br>&nbsp; &nbsp; // permissions in the security descriptor to the corresponding generic<br>&nbsp; &nbsp; // permissions (using the passed generic mapping) and clear the mapped<br>&nbsp; &nbsp; // specific bits.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // * Note that specific bits for Generic All will always &nbsp; &nbsp;*<br>&nbsp; &nbsp; // * be mapped regardless of this flag (due to Full Control *<br>&nbsp; &nbsp; // * in the special access dialogs). &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // Clients who only expose the Generic and Standard permissions will<br>&nbsp; &nbsp; // generally set this flag to TRUE. &nbsp;If you are exposing the specific<br>&nbsp; &nbsp; // bits (note you should not expose both specific and generic except for<br>&nbsp; &nbsp; // Generic All) then this flag should be FALSE.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; BOOLEAN MapSpecificPermsToGeneric ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The generic mapping for the container or object permissions.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This is used for mapping the specific permissions to the generic<br>&nbsp; &nbsp; // flags.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; PGENERIC_MAPPING GenericMapping ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The generic mapping for the New Object permissions.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This is used for mapping the specific permissions to the generic<br>&nbsp; &nbsp; // flags for new object permissions (not used if AllowNewObjectPerms<br>&nbsp; &nbsp; // is FALSE).<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; PGENERIC_MAPPING GenericMappingNewObjects ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The (localized) name of the object type.<br>&nbsp; &nbsp; // For example, "File", &nbsp;"Print Job" or "Directory".<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR ObjectTypeName;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The help information suitable for the type of object the Security<br>&nbsp; &nbsp; // Editor will be operating on.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; PSED_HELP_INFO HelpInfo ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The (localized) title to display if protection/auditting can be applied<br>&nbsp; &nbsp; // to sub-objects/sub-containers. &nbsp;This is the Tree apply<br>&nbsp; &nbsp; // checkbox title.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This string will be presented with a checkbox before it.<br>&nbsp; &nbsp; // If this box is checked, then the callback entry point<br>&nbsp; &nbsp; // will be called with the ApplyToSubContainers flag set to TRUE.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This field is ignored if the IsContainer field is FALSE.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // As an example of how this field is used, the File Manager may<br>&nbsp; &nbsp; // specify the following string in the DIRECTORY object's<br>&nbsp; &nbsp; // descriptor:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"R&amp;eplace Permissions on Subdirectories"<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR &nbsp; &nbsp; &nbsp; ApplyToSubContainerTitle;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The (localized) title to display if protection/auditting can be applied<br>&nbsp; &nbsp; // to sub-objects.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This string will be presented with a checkbox before it.<br>&nbsp; &nbsp; // If this box is checked, then the callback entry point<br>&nbsp; &nbsp; // will be called with the ApplyTuSubObjects flag set to TRUE.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This field is ignored if the IsContainer flag is FALSE or the<br>&nbsp; &nbsp; // AllowNewObjectPerms flag is FALSE.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // As an example of how this field is used, the File Manager may<br>&nbsp; &nbsp; // specify the following string in the DIRECTORY object's<br>&nbsp; &nbsp; // descriptor:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"Replace Permissions on Existing &amp;Files"<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyToObjectsTitle;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The (localized) text is presented in a confirmation message box<br>&nbsp; &nbsp; // that is displayed to the user after the user has checked the<br>&nbsp; &nbsp; // "ApplyToSubContainer" checkbox.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This field is ignored if the IsContainer field is FALSE.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // For directories, this text might be:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // "Do you want to replace the permissions on all existing<br>&nbsp; &nbsp; // files and subdirectories within %1?"<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // %1 will be substituted by the Acl Editor with the object name<br>&nbsp; &nbsp; // field (i.e., "C:/MyDirectory")<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR &nbsp; &nbsp; &nbsp; ApplyToSubContainerConfirmation ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The (localized) title to display in the "Type of Access" combo<br>&nbsp; &nbsp; // that brings up the Special access dialog. &nbsp;This same title is<br>&nbsp; &nbsp; // used for the title of this dialog except the "..." is stripped<br>&nbsp; &nbsp; // from the end.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This field is ignored if the System Acl editor was invoked.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // As an example of how this field is used, the File Manager may<br>&nbsp; &nbsp; // specify the following string in the DIRECTORY object's<br>&nbsp; &nbsp; // descriptor:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // "Special Directory Access..."<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR &nbsp; &nbsp; &nbsp; SpecialObjectAccessTitle ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The (localized) title to display in the "Type of Access" combo<br>&nbsp; &nbsp; // that brings up the Special new object access dialog. &nbsp;This same title<br>&nbsp; &nbsp; // is used for the title of this dialog except the "..." is stripped<br>&nbsp; &nbsp; // from the end.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // This item is required if AllowNewObjectPerms is TRUE, it is ignored<br>&nbsp; &nbsp; // if AllowNewObjectPerms is FALSE or we are editting a SACL.<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // As an example of how this field is used, the file browser may<br>&nbsp; &nbsp; // specify the following string in the DIRECTORY object's<br>&nbsp; &nbsp; // descriptor:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;"Special File Access..."<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; LPWSTR &nbsp; &nbsp; &nbsp; SpecialNewObjectAccessTitle ;<br><br>} SED_OBJECT_TYPE_DESCRIPTOR, *PSED_OBJECT_TYPE_DESCRIPTOR;<br><br><br>//<br>// It is desirable to display access names that are<br>// meaningful in the context of the type of object whose ACL<br>// is being worked on. &nbsp;For example, for a PRINT_QUEUE object type,<br>// it may be desirable to display an access type named "Submit Print Jobs".<br>// The following structures are used for defining these application defined<br>// access groupings that appear in the "Type of access" combobox and the<br>// Special Access dialogs.<br>//<br><br>//<br>// The following are the different permission description types that the user<br>// will manipulate for setting permissions.<br>//<br>// SED_DESC_TYPE_RESOURCE - The SED_APPLICATION_ACCESS structure is describing<br>// an object or container permission that will be displayed in the main<br>// permissions listbox. &nbsp;These should be the permissions that the<br>// user will use all the time and will generally be a conglomeration<br>// of permissions (for example, "Edit" which would include Read, Write<br>// and possibly delete).<br>//<br>// SED_DESC_TYPE_CONT_AND_NEW_OBJECT - The structure is describing a container<br>// and new object permission that will be shown in the main permissions<br>// listbox. &nbsp;The Container permission is contained in AccessMask1 and<br>// the New Object resource is in AccessMask2. &nbsp;When the permission name<br>// is selected by the user, the container access permissions *and* the<br>// new object access permissions will be set to the corresponding access<br>// mask. &nbsp;This is useful when inherittance can be used to set the New<br>// Object Access permissions.<br>//<br>// SED_DESC_TYPE_RESOURCE_SPECIAL - The structure is describing an object<br>// or container permissions that will be displayed in the Special<br>// access dialog. These are generally generic/standard permissions (such as<br>// Read, Write, Execute, Set Permissions etc.). &nbsp;The permission names<br>// will appear next to checkboxes, thus they should have the "&amp;"<br>// accelerator next to the appropriate letter.<br>//<br>// SED_DESC_TYPE_NEW_OBJECT_SPECIAL - The structure is describing a new object<br>// permission that will be shown in the Special New Object access<br>// dialog. &nbsp;This is used the same way the SED_DESC_TYPE_RESOURCE_SPECIAL<br>// type is used, that is, the permissions should be the primitive, per<br>// bit permissions. &nbsp;The permission names<br>// will appear next to checkboxes, thus they should have the "&amp;"<br>// accelerator next to the appropriate letter.<br>//<br>// SED_DESC_TYPE_AUDIT - The structure is describing an Audit access mask.<br>// AccessMask1 contains the audit mask to be associated with the<br>// permission title string. &nbsp;The title string will appear next to<br>// a checkbox, thus they should have the "&amp;" accelerator next to<br>// the appropriate letter in the title string.<br>//<br>// Note that they cannot be freely intermixed, use the following table<br>// as a guide for which ones to use where:<br>//<br>// &nbsp;IsContainer &nbsp;AllowNewObjectPerms<br>// &nbsp; &nbsp; False &nbsp; &nbsp; &nbsp;False &nbsp; &nbsp; RESOURCE, RESOURCE_SPECIAL<br>// &nbsp; &nbsp; True &nbsp; &nbsp; &nbsp;False &nbsp; &nbsp; RESOURCE, RESOURCE_SPECIAL<br>// &nbsp; &nbsp; True &nbsp; &nbsp; &nbsp;True &nbsp; &nbsp; RESOURCE_SPECIAL, CONT_AND_NEW_OBJECT,<br>// &nbsp; &nbsp; NEW_OBJECT_SPECIAL<br>// &nbsp; &nbsp; True &nbsp; &nbsp; &nbsp;False &nbsp; &nbsp; SED_DESC_TYPE_AUDIT<br>//<br>// &nbsp;Note that in the third case (IsContainer &amp;&amp; AllowNewObjectPerms) you<br>// &nbsp;*cannot* use the RESOURCE permission description type, you must always<br>// &nbsp;associate the permission on the resource with new object permissions.<br>//<br>#define SED_DESC_TYPE_RESOURCE (1)<br>#define SED_DESC_TYPE_RESOURCE_SPECIAL (2)<br><br>#define SED_DESC_TYPE_CONT_AND_NEW_OBJECT (3)<br>#define SED_DESC_TYPE_NEW_OBJECT_SPECIAL (4)<br><br>#define SED_DESC_TYPE_AUDIT (5)<br><br><br>//<br>// To describe the permissions to the ACL Editor, build an array consisting<br>// of SED_APPLICATION_ACCESS structures. &nbsp;The use of each field is as follows:<br>//<br>// Type - Contains one of the SED_DESC_TYPE_* manifests, determines what the<br>// rest of the fields in this structure mean. &nbsp;Specifically, if Type<br>// equals:<br>//<br>// &nbsp; &nbsp;AccessMask1 &nbsp; AccessMask2 PermissionTitle<br>// &nbsp; ============================================<br>//SED_DESC_TYPE_RESOURCE &nbsp; &nbsp; &nbsp; Perm &nbsp; Not Used &nbsp; &nbsp;Name of this Perm<br>//SED_DESC_TYPE_RESOURCE_SPECIAL &nbsp; &nbsp;Special Perm &nbsp; Not Used &nbsp; &nbsp;Name of this Perm<br>//SED_DESC_TYPE_CONT_AND_NEW_OBJECT &nbsp; &nbsp;Perm &nbsp;Special Perm Name of this Perm<br>//SED_DESC_TYPE_NEW_OBJECT_SPECIAL &nbsp;Special Perm &nbsp; Not Used &nbsp; &nbsp;Name of this Perm<br>//SED_DESC_TYPE_AUDIT &nbsp; &nbsp; Audit Mask &nbsp; &nbsp;Not Used &nbsp; &nbsp;Name of this Audit mask<br>//<br>// AccessMask1 - Access mask to be associated with the PermissionTitle string,<br>// see the table under Type for what this field contains.<br>//<br>// AccessMask2 - Either used for Special permissions or ignored.<br>//<br>// PermissionTitle - Title string this permission set is being associated with.<br>typedef struct _SED_APPLICATION_ACCESS<br>{<br>&nbsp; &nbsp; UINT Type ;<br>&nbsp; &nbsp; ACCESS_MASK AccessMask1 ;<br>&nbsp; &nbsp; ACCESS_MASK AccessMask2 ;<br>&nbsp; &nbsp; LPWSTR PermissionTitle ;<br><br>} SED_APPLICATION_ACCESS, *PSED_APPLICATION_ACCESS;<br><br>//<br>// This can be used for AccessMask2 when dealing with containers that support<br>// new object permissions and you need a SED_DESC_TYPE_CONT_AND_NEW_OBJECT<br>// that doesn't have a new object permission.<br>//<br>#define ACCESS_MASK_NEW_OBJ_NOT_SPECIFIED &nbsp; &nbsp;(0xffffffff)<br><br><br>typedef struct _SED_APPLICATION_ACCESSES<br>{<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The count field indicates how many application defined access groupings<br>&nbsp; &nbsp; // are defined by this data structure. &nbsp;The AccessGroup[] array then<br>&nbsp; &nbsp; // contains that number of elements.<br>&nbsp; &nbsp; //<br><br>&nbsp; &nbsp; ULONG &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Count;<br>&nbsp; &nbsp; PSED_APPLICATION_ACCESS AccessGroup ;<br><br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The default permission that should be selected in in the<br>&nbsp; &nbsp; // "Type of Access" combobox of the "Add" dialog. &nbsp;Should be one of<br>&nbsp; &nbsp; // the SED_DESC_TYPE_RESOURCE permissions (i.e., what is shown in the<br>&nbsp; &nbsp; // main dialog).<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // The default permission for "Files" &amp; "Directories" for example might<br>&nbsp; &nbsp; // be:<br>&nbsp; &nbsp; //<br>&nbsp; &nbsp; // &nbsp; &nbsp;"Read"<br>&nbsp; &nbsp; //<br><br>&nbsp; &nbsp; LPWSTR DefaultPermName ;<br><br>} SED_APPLICATION_ACCESSES, *PSED_APPLICATION_ACCESSES ;<br><br>/*++<br><br>Routine Description:<br><br>&nbsp; &nbsp; This routine is provided by a caller of the graphical ACL editor.<br><br>&nbsp; &nbsp; It is called by the ACL editor to apply security/auditting info to<br>&nbsp; &nbsp; target object(s) when requested by the user.<br><br>&nbsp; &nbsp; All error notification should be performed in this call. &nbsp;To dismiss<br>&nbsp; &nbsp; the ACL Editor, return 0, otherwise return a non-zero error code.<br><br>Parameters:<br><br>&nbsp; &nbsp; hwndParent - Parent window handle to use for message boxes or subsequent<br> dialogs.<br><br>&nbsp; &nbsp; hInstance - Instance handle suitable for retrieving resources from the<br> applications .exe or .dll.<br><br>&nbsp; &nbsp; CallbackContext - This is the value passed as the CallbackContext argument<br> to the SedDiscretionaryAclEditor() or SedSystemAclEditor api when<br> the graphical editor was invoked.<br><br>&nbsp; &nbsp; SecDesc - This parameter points to a security descriptor<br> that should be applied to this object/container and optionally<br>&nbsp; &nbsp; &nbsp; &nbsp; sub-containers if the user selects the apply to tree option.<br><br>&nbsp; &nbsp; SecDescNewObjects - This parameter is used only when operating on a<br> resource that is a container and supports new objects (for<br> example, directories). If the user chooses the apply to tree option,<br> then this security descriptor will have all of the "New Object"<br> permission ACEs contained in the primary container and the inherit<br> bits will be set appropriately.<br><br>&nbsp; &nbsp; ApplyToSubContainers - When TRUE, indicates that Dacl/Sacl is to be applied<br> to sub-containers of the target container as well as the target container.<br>&nbsp; &nbsp; &nbsp; &nbsp; This will only be TRUE if the target object is a container object.<br><br>&nbsp; &nbsp; ApplyToSubObjects - When TRUE, indicates the Dacl/Sacl is to be applied to<br>&nbsp; &nbsp; &nbsp; &nbsp; sub-objects of the target object.<br> The SecDescNewObjects should be used for applying the permissions<br> in this instance.<br><br>&nbsp; &nbsp; StatusReturn - This status flag indicates what condition the<br> resources permissions were left in after an error occurred.<br><br> &nbsp; &nbsp;SED_STATUS_MODIFIED - This (success) status code indicates the<br> protection has successfully been modified.<br><br> &nbsp; &nbsp;SED_STATUS_NOT_ALL_MODIFIED - This (warning) status code<br> indicates an attempt to modify the resource permissions<br> has only partially succeeded.<br><br> &nbsp; &nbsp;SED_STATUS_FAILED_TO_MODIFY - This (error) status code indicates<br> an attempt to modify the permissions has failed completely.<br><br>Return Status:<br><br>&nbsp; &nbsp; The return code is a standard Win32 error code. &nbsp;All errors that occur<br>&nbsp; &nbsp; must be reported inside this function. &nbsp;If the return code is NO_ERROR,<br>&nbsp; &nbsp; then the security editor will dismiss itself. &nbsp;If you do not wish the<br>&nbsp; &nbsp; security editor dismissed, return a non-zero value (the actual value is<br>&nbsp; &nbsp; ignored).<br><br>--*/<br>typedef DWORD (WINAPI *PSED_FUNC_APPLY_SEC_CALLBACK)(<br> &nbsp; &nbsp; &nbsp; HWND hwndParent,<br> &nbsp; &nbsp; &nbsp; HANDLE hInstance,<br> &nbsp; &nbsp; &nbsp; ULONG CallbackContext,<br> &nbsp; &nbsp; &nbsp; PSECURITY_DESCRIPTOR SecDesc,<br> &nbsp; &nbsp; &nbsp; PSECURITY_DESCRIPTOR SecDescNewObjects,<br> &nbsp; &nbsp; &nbsp; BOOLEAN ApplyToSubContainers,<br> &nbsp; &nbsp; &nbsp; BOOLEAN ApplyToSubObjects,<br> &nbsp; &nbsp; &nbsp; LPDWORD StatusReturn<br> &nbsp; &nbsp; ) ;<br><br>/*++<br><br>Routine Description:<br><br>&nbsp; &nbsp; This routine invokes the graphical Discretionary ACL editor DLL. &nbsp;The<br>&nbsp; &nbsp; graphical DACL editor may be used to modify or create:<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - A default Discretionary ACL<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - A Discretionary ACL for a particular type of object.<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - A Discretionary ACL for a particular named instance of an<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; object.<br><br>&nbsp; &nbsp; Additionally, in the case where the ACl is that of a named object<br>&nbsp; &nbsp; instance, and that object may contain other object instances, the<br>&nbsp; &nbsp; user will be presented with the opportunity to apply the protection<br>&nbsp; &nbsp; to the entire sub-tree of objects.<br><br>&nbsp; &nbsp; If an error occurs, the user will be properly notified by the ACL<br>&nbsp; &nbsp; editor.<br><br><br>Parameters:<br><br>&nbsp; &nbsp; Owner - Handle of the owner window the security editor should use for<br> dialog creation and error messages. &nbsp;This will lock down the passed<br> window.<br><br>&nbsp; &nbsp; Instance - Instance handle of the application. &nbsp;This will be passed<br> to the security editor callback where it can be used for retrieving<br> any necessary resources such as message strings, dialog boxes etc.<br><br>&nbsp; &nbsp; Server - The server name in the form "//server" that the resource resides<br> on. &nbsp;This is used for adding users, groups and aliases to the<br> DACL and SACL. NULL indicates the local machine.<br><br>&nbsp; &nbsp; ObjectType - This parameter is used to specify information<br>&nbsp; &nbsp; &nbsp; &nbsp; about the type of object whose security is being edited.<br><br>&nbsp; &nbsp; ApplicationAccesses - This parameter is used to specify<br> groupings of access types when operating<br>&nbsp; &nbsp; &nbsp; &nbsp; on security for the specified object type. &nbsp;For example, it may be<br>&nbsp; &nbsp; &nbsp; &nbsp; useful to define an access type called "Submit Print Job" for a<br> PRINT_QUEUE class of object.<br><br>&nbsp; &nbsp; ObjectName - This optional parameter is used to pass the name of the<br>&nbsp; &nbsp; &nbsp; &nbsp; object whose security is being edited.<br><br>&nbsp; &nbsp; ApplySecurityCallbackRoutine - This parameter is used to provide the<br>&nbsp; &nbsp; &nbsp; &nbsp; address of a routine to be called to apply security to either the<br>&nbsp; &nbsp; &nbsp; &nbsp; object specified, or, in the case that the object is a container,<br>&nbsp; &nbsp; &nbsp; &nbsp; to sub-containers or sub-non-containers of that object.<br><br>&nbsp; &nbsp; CallbackContext - This value is opaque to the DACL editor. &nbsp;Its only<br>&nbsp; &nbsp; &nbsp; &nbsp; purpose is so that a context value may be passed back to the<br>&nbsp; &nbsp; &nbsp; &nbsp; application via the ApplySecurityCallbackRoutine when that routine<br>&nbsp; &nbsp; &nbsp; &nbsp; is invoked. &nbsp;This may be used by the application to re-locate<br>&nbsp; &nbsp; &nbsp; &nbsp; context related to the edit session. &nbsp;For example, it may be a<br>&nbsp; &nbsp; &nbsp; &nbsp; handle to the object whose security is being edited.<br><br>&nbsp; &nbsp; SecurityDescriptor - This parameter points to a security descriptor<br>&nbsp; &nbsp; &nbsp; &nbsp; containing the current discretionary ACL of the object. &nbsp;This<br>&nbsp; &nbsp; &nbsp; &nbsp; security descriptor may, but does not have to, contain the owner<br>&nbsp; &nbsp; &nbsp; &nbsp; and group of that object as well. &nbsp;Note that the security descriptor's<br>&nbsp; &nbsp; &nbsp; &nbsp; DaclPresent flag may be FALSE, indicating either that the object<br> had no protection, or that the user couldn't read the protection.<br>&nbsp; &nbsp; &nbsp; &nbsp; This security descriptor will not be modified by the ACL editor.<br>&nbsp; &nbsp; &nbsp; &nbsp; This may be NULL, in which case, the user will be presented with<br>&nbsp; &nbsp; &nbsp; &nbsp; an empty permission list.<br><br>&nbsp; &nbsp; CouldntReadDacl - This boolean flag is used to indicate that the<br>&nbsp; &nbsp; &nbsp; &nbsp; user does not have read access to the target object's discretionary<br>&nbsp; &nbsp; &nbsp; &nbsp; acl. &nbsp;In this case, a warning<br>&nbsp; &nbsp; &nbsp; &nbsp; to the user will be presented along with the option to continue<br>&nbsp; &nbsp; &nbsp; &nbsp; or cancel.<br><br>&nbsp; &nbsp; CantWriteDacl - This boolean flag is used to indicate that the user<br>&nbsp; &nbsp; &nbsp; &nbsp; does not have write acces to the target object's discretionary<br>&nbsp; &nbsp; &nbsp; &nbsp; acl (but does have read access). &nbsp;This invokes the editor in a<br>&nbsp; &nbsp; &nbsp; &nbsp; read only mode that allows the user to view the security but not<br>&nbsp; &nbsp; &nbsp; &nbsp; change it.<br><br>&nbsp; &nbsp; &nbsp; &nbsp; Note that SACL access is determined by the SeSecurity privilege.<br>&nbsp; &nbsp; &nbsp; &nbsp; If you have the privilege, then you can both read *and* write the<br>&nbsp; &nbsp; &nbsp; &nbsp; SACL, if you do not have the privilege, you cannot read or write the<br>&nbsp; &nbsp; &nbsp; &nbsp; SACL.<br><br>&nbsp; &nbsp; SEDStatusReturn - This status flag indicates what condition the<br> resources permissions were left in after the ACL editor was<br> dismissed. &nbsp;It may be one of:<br><br> &nbsp; &nbsp;SED_STATUS_MODIFIED - This (success) status code indicates the<br> editor has been exited and protection has successfully been<br> modified.<br><br> &nbsp; &nbsp;SED_STATUS_NOT_MODIFIED - &nbsp;This (success) status code indicates<br> the editor has been exited without attempting to modify the<br> protection.<br><br> &nbsp; &nbsp;SED_STATUS_NOT_ALL_MODIFIED - This (warning) status code indicates<br> the user requested the protection to be modified, but an attempt<br> to do so only partially succeeded. &nbsp;The user has been notified<br> of this situation.<br><br> &nbsp; &nbsp;SED_STATUS_FAILED_TO_MODIFY - This (error) status code indicates<br> the user requested the protection to be modified, but an<br> attempt to do so has failed. &nbsp;The user has been notified of<br> this situation.<br><br>&nbsp; &nbsp; Flags - Should be zero.<br><br>Return Code:<br><br>&nbsp; &nbsp; A standard windows error return such as ERROR_NOT_ENOUGH_MEMORY. &nbsp;This<br>&nbsp; &nbsp; means the ACL editor was never displayed. &nbsp;The user will be notified<br>&nbsp; &nbsp; of the error before this procedure returns.<br><br>--*/<br><br>DWORD WINAPI<br>SedDiscretionaryAclEditor(<br> HWND &nbsp; &nbsp; Owner,<br> HANDLE &nbsp; &nbsp; Instance,<br> LPWSTR &nbsp; &nbsp; Server,<br> PSED_OBJECT_TYPE_DESCRIPTOR &nbsp;ObjectType,<br> PSED_APPLICATION_ACCESSES &nbsp; &nbsp;ApplicationAccesses,<br> LPWSTR &nbsp; &nbsp; ObjectName,<br> PSED_FUNC_APPLY_SEC_CALLBACK ApplySecurityCallbackRoutine,<br> ULONG &nbsp; &nbsp; CallbackContext,<br> PSECURITY_DESCRIPTOR &nbsp; &nbsp; SecurityDescriptor,<br>&nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CouldntReadDacl,<br>&nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CantWriteDacl,<br>&nbsp; &nbsp; &nbsp; &nbsp; LPDWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SEDStatusReturn,<br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flags<br> ) ;<br><br>//<br>// The parameters for the SACL editor are exactly the same except where<br>// noted as that of the SedDiscretionaryAclEditor.<br>//<br><br>DWORD WINAPI<br>SedSystemAclEditor(<br> HWND &nbsp; &nbsp; Owner,<br> HANDLE &nbsp; &nbsp; Instance,<br> LPWSTR &nbsp; &nbsp; Server,<br> PSED_OBJECT_TYPE_DESCRIPTOR &nbsp;ObjectType,<br> PSED_APPLICATION_ACCESSES &nbsp; &nbsp;ApplicationAccesses,<br> LPWSTR &nbsp; &nbsp; ObjectName,<br> PSED_FUNC_APPLY_SEC_CALLBACK ApplySecurityCallbackRoutine,<br> ULONG &nbsp; &nbsp; CallbackContext,<br> PSECURITY_DESCRIPTOR &nbsp; &nbsp; SecurityDescriptor,<br>&nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CouldntEditSacl,<br>&nbsp; &nbsp; &nbsp; &nbsp; LPDWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SEDStatusReturn,<br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flags<br> ) ;<br><br>/*++<br><br>Routine Description:<br><br>&nbsp; &nbsp; This routine invokes the take ownership dialog which is used<br>&nbsp; &nbsp; to view and/or set the owner of a security descriptor. &nbsp;The current owner<br>&nbsp; &nbsp; is displayed along with an optional button for the currently logged<br>&nbsp; &nbsp; on user to take ownership.<br><br>&nbsp; &nbsp; If an error occurs, the user will be properly notified by the API.<br><br>Parameters:<br><br>&nbsp; &nbsp; Owner - Handle of the owner window the security editor should use for<br> dialog creation and error messages. &nbsp;This will lock down the passed<br> window.<br><br>&nbsp; &nbsp; Instance - Instance handle of the application. &nbsp;This will be passed<br> to the security editor callback where it can be used for retrieving<br> any necessary resources such as message strings, dialog boxes etc.<br><br>&nbsp; &nbsp; Server - The server name in the form "//server" that the resource resides<br>&nbsp; &nbsp; &nbsp; &nbsp; on. NULL indicates the local machine.<br><br>&nbsp; &nbsp; ObjectTypeName - NT Resource type of object the user wants to look<br> at the owner of.<br> Examples for this parameter would be "File", "Directory"<br> or "Files/Directories".<br><br>&nbsp; &nbsp; ObjectName - This parameter is used to pass the name of the<br> object whose security is being edited. This might be<br> "C:/status.doc" or some other qualified name.<br><br>&nbsp; &nbsp; CountOfObjects - The number of objects the user wants to change permissions<br> on. &nbsp;If this number is greater then one, then the ObjectName is<br> ignored and a message of the form "%d ObjectTypeName Selected".<br><br>&nbsp; &nbsp; ApplySecurityCallbackRoutine - This parameter is used to provide the<br> address of a routine to be called to apply the new security<br> descriptor. &nbsp;The flags in the PSED_FUNC_APPLY_SEC_CALLBACK<br> type are not used.<br><br>&nbsp; &nbsp; CallbackContext - This value is opaque to this API. &nbsp;Its only<br>&nbsp; &nbsp; &nbsp; &nbsp; purpose is so that a context value may be passed back to the<br>&nbsp; &nbsp; &nbsp; &nbsp; application via the ApplySecurityCallbackRoutine when that routine<br>&nbsp; &nbsp; &nbsp; &nbsp; is invoked. &nbsp;This may be used by the application to re-locate<br>&nbsp; &nbsp; &nbsp; &nbsp; context related to the edit session. &nbsp;For example, it may be a<br>&nbsp; &nbsp; &nbsp; &nbsp; handle to the object whose security is being edited.<br><br>&nbsp; &nbsp; SecurityDescriptor - This parameter points to a security descriptor<br>&nbsp; &nbsp; &nbsp; &nbsp; containing the current owner and group. &nbsp;May be NULL.<br><br>&nbsp; &nbsp; CouldntReadOwner - This boolean flag may be used to indicate that the<br>&nbsp; &nbsp; &nbsp; &nbsp; user does not have read access to the target object's owner/group<br>&nbsp; &nbsp; &nbsp; &nbsp; SID. &nbsp;In this case, a warning<br>&nbsp; &nbsp; &nbsp; &nbsp; to the user will be presented along with the option to continue<br>&nbsp; &nbsp; &nbsp; &nbsp; or cancel.<br><br>&nbsp; &nbsp; CantWriteOwner - The boolean flag may be used to indicate that the user<br>&nbsp; &nbsp; &nbsp; &nbsp; does not have write access to the target object's owner/group SID.<br><br>&nbsp; &nbsp; SEDStatusReturn - This status flag indicates what condition the<br> resources security descriptor were left in after the take ownership<br> dialog was dismissed. &nbsp;It may be one of:<br><br> &nbsp; &nbsp;SED_STATUS_MODIFIED - This (success) status code indicates the<br> dialog has been exited and the new owner has successfully been<br> modified.<br><br> &nbsp; &nbsp;SED_STATUS_NOT_MODIFIED - &nbsp;This (success) status code indicates<br> the dialog has been exited without attempting to modify the<br> owner.<br><br> &nbsp; &nbsp;SED_STATUS_NOT_ALL_MODIFIED - This (warning) status code indicates<br> the user requested the owner to be modified, but an attempt<br> to do so only partially succeeded. &nbsp;The user has been notified<br> of this situation.<br><br> &nbsp; &nbsp;SED_STATUS_FAILED_TO_MODIFY - This (error) status code indicates<br> the user requested the owner to be modified, but an<br> attempt to do so has failed. &nbsp;The user has been notified of<br> this situation.<br><br>&nbsp; &nbsp; Flags - Should be zero.<br>Return Code:<br><br>&nbsp; &nbsp; A standard windows error return such as ERROR_NOT_ENOUGH_MEMORY. &nbsp;This<br>&nbsp; &nbsp; means the dialog was never displayed. &nbsp;The user will be notified<br>&nbsp; &nbsp; of the error before this procedure returns.<br><br>--*/<br><br>DWORD WINAPI<br>SedTakeOwnership(<br> HWND &nbsp; &nbsp; Owner,<br> HANDLE &nbsp; &nbsp; Instance,<br> LPWSTR &nbsp; &nbsp; Server,<br> LPWSTR &nbsp; &nbsp; ObjectTypeName,<br> LPWSTR &nbsp; &nbsp; ObjectName,<br> UINT &nbsp; &nbsp; CountOfObjects,<br> PSED_FUNC_APPLY_SEC_CALLBACK ApplySecurityCallbackRoutine,<br> ULONG &nbsp; &nbsp; CallbackContext,<br> PSECURITY_DESCRIPTOR &nbsp; &nbsp; SecurityDescriptor,<br>&nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CouldntReadOwner,<br>&nbsp; &nbsp; &nbsp; &nbsp; BOOLEAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;CantWriteOwner,<br> LPDWORD &nbsp; &nbsp; SEDStatusReturn,<br>&nbsp; &nbsp; &nbsp; &nbsp; PSED_HELP_INFO &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HelpInfo,<br>&nbsp; &nbsp; &nbsp; &nbsp; DWORD &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Flags<br> );<br><br><br>#ifdef __cplusplus<br>}<br>#endif<br><br>#endif //_SEDAPI_H_<br>
 
// aclx.cpp : Defines the entry point for the console application.<br>//<br><br>#include "stdafx.h"<br><br>/*<br>Hello. . . . Here's a quick test app I put together about six months ago. In the<br>call to SedDiscretionaryAclEditor, you'll need to replace the ninth parameter<br>with a real security descriptor. You'll also need to fill the various SED_*<br>structures with your own permissions and descriptions. The Microsoft Platform<br>SDK section on low-level security functions comes in handy at this point.<br><br>Trev*/<br><br>#include &lt;stdio.h&gt;<br>#include &lt;windows.h&gt;<br>#include "sedapi.h"<br><br>// ***************************************************************************<br><br>typedef DWORD (WINAPI *PSedDiscretionaryAclEditor) (HWND, HANDLE, LPWSTR,<br>PSED_OBJECT_TYPE_DESCRIPTOR, PSED_APPLICATION_ACCESSES, LPWSTR,<br>PSED_FUNC_APPLY_SEC_CALLBACK, ULONG, PSECURITY_DESCRIPTOR, BOOLEAN, BOOLEAN,<br>LPDWORD, DWORD);<br><br>static DWORD WINAPI ApplySecCallback(<br>HWND hwndParent,<br>HANDLE hInstance,<br>ULONG CallbackContext,<br>PSECURITY_DESCRIPTOR SecDesc,<br>PSECURITY_DESCRIPTOR SecDescNewObjects,<br>BOOLEAN ApplyToSubContainers,<br>BOOLEAN ApplyToSubObjects,<br>LPDWORD StatusReturn);<br><br>PSED_FUNC_APPLY_SEC_CALLBACK m_pfnApplySecCallback = ApplySecCallback;<br><br>SED_APPLICATION_ACCESS m_SedApplicationAccessFolder[] =<br>{<br>{SED_DESC_TYPE_RESOURCE_SPECIAL, GENERIC_READ, 0, L"&amp;Read (R)"},<br>{SED_DESC_TYPE_RESOURCE_SPECIAL, GENERIC_WRITE, 0, L"&amp;Write (W)"},<br>{SED_DESC_TYPE_RESOURCE_SPECIAL, GENERIC_EXECUTE, 0, L"E&amp;xecute (X)"},<br>{SED_DESC_TYPE_CONT_AND_NEW_OBJECT, GENERIC_READ | GENERIC_EXECUTE,<br>GENERIC_READ | GENERIC_EXECUTE, L"Read"},<br>{SED_DESC_TYPE_CONT_AND_NEW_OBJECT, GENERIC_READ | GENERIC_WRITE |<br>GENERIC_EXECUTE, GENERIC_READ | GENERIC_WRITE | GENERIC_EXECUTE, L"Change"},<br>{SED_DESC_TYPE_CONT_AND_NEW_OBJECT, GENERIC_ALL, GENERIC_ALL, L"Full Control"},<br>{SED_DESC_TYPE_NEW_OBJECT_SPECIAL, GENERIC_READ, 0, L"&amp;Read (R)"},<br>{SED_DESC_TYPE_NEW_OBJECT_SPECIAL, GENERIC_WRITE, 0, L"&amp;Write (W)"},<br>{SED_DESC_TYPE_NEW_OBJECT_SPECIAL, GENERIC_EXECUTE, 0, L"E&amp;xecute (X)"}<br>};<br><br>SED_APPLICATION_ACCESSES m_SedApplicationAccesses =<br>{<br>sizeof(m_SedApplicationAccessFolder) /<br>sizeof(m_SedApplicationAccessFolder[0]),<br>&amp;m_SedApplicationAccessFolder[0],<br>m_SedApplicationAccessFolder[0].PermissionTitle<br>};<br><br>SED_HELP_INFO m_SedHelpInfo = {L"ACLEDT32.HLP", 0, 0, 0, 0, 0, 0, 0};<br><br>GENERIC_MAPPING m_GenericMapping =<br>{<br>GENERIC_READ,<br>GENERIC_WRITE,<br>GENERIC_EXECUTE,<br>GENERIC_ALL<br>};<br><br>// ***************************************************************************<br><br>int main(int argc, char* argv[])<br>{<br><br>BOOL bResult = NULL;<br>DWORD dwStatus = 0;<br>HINSTANCE hAclEdit = NULL;<br>PSedDiscretionaryAclEditor pfnSedDiscretionaryAclEditor = NULL;<br>SED_OBJECT_TYPE_DESCRIPTOR SedObjectTypeDescriptor;<br><br>hAclEdit = LoadLibrary("acledit.dll");<br><br>if ( hAclEdit )<br>{<br><br>pfnSedDiscretionaryAclEditor = (PSedDiscretionaryAclEditor)<br>GetProcAddress(hAclEdit,"SedDiscretionaryAclEditor");<br><br>if ( pfnSedDiscretionaryAclEditor )<br>{<br><br>SedObjectTypeDescriptor.Revision = SED_REVISION;<br>SedObjectTypeDescriptor.IsContainer = TRUE;<br>SedObjectTypeDescriptor.AllowNewObjectPerms = TRUE;<br>SedObjectTypeDescriptor.GenericMapping = &amp;m_GenericMapping;<br>SedObjectTypeDescriptor.GenericMappingNewObjects =<br>&amp;m_GenericMapping;<br>SedObjectTypeDescriptor.ObjectTypeName = L"Container";<br>SedObjectTypeDescriptor.HelpInfo = &amp;m_SedHelpInfo;<br>SedObjectTypeDescriptor.ApplyToSubContainerTitle = L"R&amp;eplace Permissions on Subcontainers";<br>SedObjectTypeDescriptor.ApplyToObjectsTitle = L"Replace Permissions on Existing Objects";<br>SedObjectTypeDescriptor.ApplyToSubContainerConfirmation = L"Do you want to replace the security information on all existing subfolders and shortcuts in this folder?";<br>SedObjectTypeDescriptor.SpecialObjectAccessTitle = L"Special Container Access...";<br>SedObjectTypeDescriptor.SpecialNewObjectAccessTitle = L"Special Object Access...";<br><br>DWORD dwResult =<br>(*pfnSedDiscretionaryAclEditor)(GetDesktopWindow(), NULL, NULL,<br>&amp;SedObjectTypeDescriptor, &amp;m_SedApplicationAccesses, L"My Container",<br>m_pfnApplySecCallback, 0, NULL, FALSE, FALSE, &amp;dwStatus, 0);<br><br>TCHAR pszResult[MAX_PATH] = {0};<br>TCHAR pszStatus[MAX_PATH] = {0};<br>sprintf(pszResult, "dwResult: %d/n", dwResult);<br>sprintf(pszStatus, "dwStatus: %d/n", dwStatus);<br>OutputDebugString(pszResult);<br>OutputDebugString(pszStatus);<br><br>}<br><br>}<br><br>if ( hAclEdit )<br>FreeLibrary(hAclEdit);<br><br>return 0;<br><br>}<br><br>// ***************************************************************************<br><br>DWORD WINAPI ApplySecCallback(<br>HWND hwndParent,<br>HANDLE hInstance,<br>ULONG CallbackContext,<br>PSECURITY_DESCRIPTOR SecDesc,<br>PSECURITY_DESCRIPTOR SecDescNewObjects,<br>BOOLEAN ApplyToSubContainers,<br>BOOLEAN ApplyToSubObjects,<br>LPDWORD StatusReturn)<br>{<br><br>return 0;<br><br>};<br>//-----------------------------------------<br>CIONO1<br>
 
谢谢,谢谢,有得看了啊。<br>并请教:<br>#define SED_STATUS_MODIFIED (1)<br>#define SED_STATUS_NOT_MODIFIED (2)<br>#define SED_STATUS_NOT_ALL_MODIFIED (3)<br>#define SED_STATUS_FAILED_TO_MODIFY (4)<br>这边的 (1)、(2)、(3)、(4)怎么解释 ?
 
后退
顶部