JwaAccCtrl.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:41k
源码类别:

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Access Control API interface Unit for Object Pascal                          }
  4. {                                                                       }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
  6. { Corporation. All Rights Reserved.                                            }
  7. {                 }
  8. { The original file is: accctrl.h, released June 2000. The original Pascal     }
  9. { code is: AccCtrl.pas, released December 2000. The initial developer of the   }
  10. { Pascal code is Marcel van Brakel (brakelm@chello.nl).                        }
  11. {                                                                              }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
  13. { Marcel van Brakel. All Rights Reserved.                                      }
  14. {                 }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  16. {                }
  17. { You may retrieve the latest version of this file at the Project JEDI home    }
  18. { page, located at http://delphi-jedi.org or my personal homepage located at   }
  19. { http://members.chello.nl/m.vanbrakel2                                        }
  20. {                }
  21. { The contents of this file are used with permission, subject to the Mozilla   }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at      }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  25. {                                                                              }
  26. { Software distributed under the License is distributed on an "AS IS" basis,   }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License.    }
  29. {                                                                              }
  30. { Alternatively, the contents of this file may be used under the terms of the  }
  31. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  32. { provisions of the LGPL License are applicable instead of those above.        }
  33. { If you wish to allow use of your version of this file only under the terms   }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting  the provisions above and  }
  36. { replace  them with the notice and other provisions required by the LGPL      }
  37. { License.  If you do not delete the provisions above, a recipient may use     }
  38. { your version of this file under either the MPL or the LGPL License.          }
  39. {                 }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. {                 }
  42. {******************************************************************************}
  43. unit JwaAccCtrl;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "aclapi.h"'}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT 'typedef PTRUSTEE_A *PPTRUSTEE_A'}
  49. {$HPPEMIT 'typedef PTRUSTEE_W *PPTRUSTEE_W'}
  50. {$HPPEMIT '#ifdef UNICODE'}
  51. {$HPPEMIT 'typedef PPTRUSTEE_W PPTRUSTEE'}
  52. {$HPPEMIT '#else'}
  53. {$HPPEMIT 'typedef PPTRUSTEE_A PPTRUSTEE'}
  54. {$HPPEMIT '#endif'}
  55. {$HPPEMIT ''}
  56. {$I WINDEFINES.INC}
  57. interface
  58. uses
  59.   JwaWinNT, JwaWinType;
  60. (* Dependencies
  61. // winnt
  62. PSID
  63. //wintype
  64. HLOCAL
  65. DWORD
  66. GUID
  67. LPSTR
  68. LPWSTR
  69. ULONG
  70. PVOID
  71. HANDLE
  72. BOOL
  73. LONG
  74. *)
  75. function AccFree(hMem: HLOCAL): HLOCAL;
  76. {$EXTERNALSYM AccFree}
  77. //
  78. // Definition:
  79. // This enumerated type defines the objects supported by the get/set API within
  80. // this document.  See section 3.1, Object Types for a detailed definition of the
  81. // supported object types, and their name formats.
  82. //
  83. type
  84.   _SE_OBJECT_TYPE = (
  85.     SE_UNKNOWN_OBJECT_TYPE,
  86.     SE_FILE_OBJECT,
  87.     SE_SERVICE,
  88.     SE_PRINTER,
  89.     SE_REGISTRY_KEY,
  90.     SE_LMSHARE,
  91.     SE_KERNEL_OBJECT,
  92.     SE_WINDOW_OBJECT,
  93.     SE_DS_OBJECT,
  94.     SE_DS_OBJECT_ALL,
  95.     SE_PROVIDER_DEFINED_OBJECT,
  96.     SE_WMIGUID_OBJECT,
  97.     SE_REGISTRY_WOW64_32KEY);
  98.   {$EXTERNALSYM _SE_OBJECT_TYPE}
  99.   SE_OBJECT_TYPE = _SE_OBJECT_TYPE;
  100.   {$EXTERNALSYM SE_OBJECT_TYPE}
  101.   TSeObjectType = SE_OBJECT_TYPE;
  102. //
  103. // Definition: TRUSTEE_TYPE
  104. // This enumerated type specifies the type of trustee account for the trustee
  105. // returned by the API described in this document.
  106. // TRUSTEE_IS_UNKNOWN - The trustee is an unknown, but not necessarily invalid
  107. //                      type.  This field is not validated on input to the APIs
  108. //                      that take Trustees.
  109. // TRUSTEE_IS_USER      The trustee account is a user account.
  110. // TRUSTEE_IS_GROUP     The trustee account is a group account.
  111. //
  112.   _TRUSTEE_TYPE = (
  113.     TRUSTEE_IS_UNKNOWN,
  114.     TRUSTEE_IS_USER,
  115.     TRUSTEE_IS_GROUP,
  116.     TRUSTEE_IS_DOMAIN,
  117.     TRUSTEE_IS_ALIAS,
  118.     TRUSTEE_IS_WELL_KNOWN_GROUP,
  119.     TRUSTEE_IS_DELETED,
  120.     TRUSTEE_IS_INVALID,
  121.     TRUSTEE_IS_COMPUTER);
  122.   {$EXTERNALSYM _TRUSTEE_TYPE}
  123.   TRUSTEE_TYPE = _TRUSTEE_TYPE;
  124.   {$EXTERNALSYM TRUSTEE_TYPE}
  125.   TTrusteeType = TRUSTEE_TYPE;
  126. //
  127. // Definition: TRUSTEE_FORM
  128. // This enumerated type specifies the form the trustee identifier is in for a
  129. // particular trustee.
  130. // TRUSTEE_IS_SID       The trustee is identified with a SID rather than with a name.
  131. // TRUSTEE_IS_NAME      The trustee is identified with a name.
  132. //
  133.   _TRUSTEE_FORM = (
  134.     TRUSTEE_IS_SID,
  135.     TRUSTEE_IS_NAME,
  136.     TRUSTEE_BAD_FORM,
  137.     TRUSTEE_IS_OBJECTS_AND_SID,
  138.     TRUSTEE_IS_OBJECTS_AND_NAME);
  139.   {$EXTERNALSYM _TRUSTEE_FORM}
  140.   TRUSTEE_FORM = _TRUSTEE_FORM;
  141.   {$EXTERNALSYM TRUSTEE_FORM}
  142.   TTrusteeForm = TRUSTEE_FORM;
  143. //
  144. // Definition: MULTIPLE_TRUSTEE_OPERATION
  145. // If the trustee is a multiple trustee, this enumerated type specifies the type.
  146. // TRUSTEE_IS_IMPERSONATE       The trustee is an impersonate trustee and the multiple
  147. //                          trustee field in the trustee points to another trustee
  148. //                          that is a trustee for the server that will be doing the
  149. //                          impersonation.
  150. //
  151.   _MULTIPLE_TRUSTEE_OPERATION = (NO_MULTIPLE_TRUSTEE, TRUSTEE_IS_IMPERSONATE);
  152.   {$EXTERNALSYM _MULTIPLE_TRUSTEE_OPERATION}
  153.   MULTIPLE_TRUSTEE_OPERATION = _MULTIPLE_TRUSTEE_OPERATION;
  154.   {$EXTERNALSYM MULTIPLE_TRUSTEE_OPERATION}
  155.   TMultipleTrusteeOperation = MULTIPLE_TRUSTEE_OPERATION;
  156.   POBJECTS_AND_SID = ^OBJECTS_AND_SID;
  157.   {$EXTERNALSYM POBJECTS_AND_SID}
  158.   _OBJECTS_AND_SID = packed record
  159.     ObjectsPresent: DWORD;
  160.     ObjectTypeGuid: GUID;
  161.     InheritedObjectTypeGuid: GUID;
  162.     pSid: PSID;
  163.   end;
  164.   {$EXTERNALSYM _OBJECTS_AND_SID}
  165.   OBJECTS_AND_SID = _OBJECTS_AND_SID;
  166.   {$EXTERNALSYM OBJECTS_AND_SID}
  167.   TObjectsAndSid = OBJECTS_AND_SID;
  168.   PObjectsAndSid = POBJECTS_AND_SID;
  169.   POBJECTS_AND_NAME_A = ^OBJECTS_AND_NAME_A;
  170.   {$EXTERNALSYM POBJECTS_AND_NAME_A}
  171.   _OBJECTS_AND_NAME_A = packed record
  172.     ObjectsPresent: DWORD;
  173.     ObjectType: SE_OBJECT_TYPE;
  174.     ObjectTypeName: LPSTR;
  175.     InheritedObjectTypeName: LPSTR;
  176.     ptstrName: LPSTR;
  177.   end;
  178.   {$EXTERNALSYM _OBJECTS_AND_NAME_A}
  179.   OBJECTS_AND_NAME_A = _OBJECTS_AND_NAME_A;
  180.   {$EXTERNALSYM OBJECTS_AND_NAME_A}
  181.   TObjectsAndNameA = OBJECTS_AND_NAME_A;
  182.   PObjectsAndNameA = POBJECTS_AND_NAME_A;
  183.   POBJECTS_AND_NAME_W = ^OBJECTS_AND_NAME_W;
  184.   {$EXTERNALSYM POBJECTS_AND_NAME_W}
  185.   _OBJECTS_AND_NAME_W = packed record
  186.     ObjectsPresent: DWORD;
  187.     ObjectType: SE_OBJECT_TYPE;
  188.     ObjectTypeName: LPWSTR;
  189.     InheritedObjectTypeName: LPWSTR;
  190.     ptstrName: LPWSTR;
  191.   end;
  192.   {$EXTERNALSYM _OBJECTS_AND_NAME_W}
  193.   OBJECTS_AND_NAME_W = _OBJECTS_AND_NAME_W;
  194.   {$EXTERNALSYM OBJECTS_AND_NAME_W}
  195.   TObjectsAndNameW = OBJECTS_AND_NAME_W;
  196.   PObjectsAndNameW = POBJECTS_AND_NAME_W;
  197. {$IFDEF UNICODE}
  198.   OBJECTS_AND_NAME_ = OBJECTS_AND_NAME_W;
  199.   {$EXTERNALSYM OBJECTS_AND_NAME_}
  200.   POBJECTS_AND_NAME_ = POBJECTS_AND_NAME_W;
  201.   {$EXTERNALSYM POBJECTS_AND_NAME_}
  202.   TObjectsAndName = TObjectsAndNameW;
  203.   PObjectsAndName = PObjectsAndNameW;
  204. {$ELSE}
  205.   OBJECTS_AND_NAME_ = OBJECTS_AND_NAME_A;
  206.   {$EXTERNALSYM OBJECTS_AND_NAME_}
  207.   POBJECTS_AND_NAME_ = POBJECTS_AND_NAME_A;
  208.   {$EXTERNALSYM POBJECTS_AND_NAME_}
  209.   TObjectsAndName = TObjectsAndNameA;
  210.   PObjectsAndName = PObjectsAndNameA;
  211. {$ENDIF}
  212. //
  213. // Definition: TRUSTEE
  214. // This structure is used to pass account information into and out of the system
  215. // using the API defined in this document.
  216. // PMultipleTrustee     - if NON-NULL, points to another trustee structure, as
  217. //                    defined by the multiple trustee operation field.
  218. // MultipleTrusteeOperation - Defines the multiple trustee operation/type.
  219. // TrusteeForm - defines if the trustee is defined by name or SID.
  220. // TrusteeType - defines if the trustee type is unknown, a user or a group.
  221. // PwcsName     - points to the trustee name or the trustee SID.
  222. //
  223.   PTRUSTEE_A = ^TRUSTEE_A;
  224.   {$EXTERNALSYM PTRUSTEE_A}
  225.   _TRUSTEE_A = packed record
  226.     pMultipleTrustee: PTRUSTEE_A;
  227.     MultipleTrusteeOperation: MULTIPLE_TRUSTEE_OPERATION;
  228.     TrusteeForm: TRUSTEE_FORM;
  229.     TrusteeType: TRUSTEE_TYPE;
  230.     ptstrName: LPSTR;
  231.   end;
  232.   {$EXTERNALSYM _TRUSTEE_A}
  233.   TRUSTEE_A = _TRUSTEE_A;
  234.   {$EXTERNALSYM TRUSTEE_A}
  235.   TRUSTEEA = TRUSTEE_A;
  236.   {$EXTERNALSYM PTRUSTEEA}
  237.   PPTRUSTEE_A = ^PTRUSTEE_A;
  238.   {$NODEFINE PPTRUSTEE_A}
  239.   TTrusteeA = TRUSTEE_A;
  240.   PTrusteeA = PTRUSTEE_A;
  241.   PTRUSTEE_W = ^TRUSTEE_W;
  242.   {$EXTERNALSYM PTRUSTEE_W}
  243.   _TRUSTEE_W = packed record
  244.     pMultipleTrustee: PTRUSTEE_W;
  245.     MultipleTrusteeOperation: MULTIPLE_TRUSTEE_OPERATION;
  246.     TrusteeForm: TRUSTEE_FORM;
  247.     TrusteeType: TRUSTEE_TYPE;
  248.     ptstrName: LPWSTR;
  249.   end;
  250.   {$EXTERNALSYM _TRUSTEE_W}
  251.   TRUSTEE_W = _TRUSTEE_W;
  252.   {$EXTERNALSYM TRUSTEE_W}
  253.   TRUSTEEW = TRUSTEE_W;
  254.   {$EXTERNALSYM TRUSTEEW}
  255.   PPTRUSTEE_W = ^PTRUSTEE_W;
  256.   {$NODEFINE PPTRUSTEE_W}
  257.   TTrusteeW = TRUSTEE_W;
  258.   PTrusteeW = PTRUSTEE_W;
  259. {$IFDEF UNICODE}
  260.   TRUSTEE_ = TRUSTEE_W;
  261.   {$EXTERNALSYM TRUSTEE_}
  262.   PTRUSTEE_ = PTRUSTEE_W;
  263.   {$EXTERNALSYM PTRUSTEE_}
  264.   TRUSTEE = TRUSTEEW;
  265.   {$EXTERNALSYM TRUSTEE}
  266.   PPTRUSTEE = ^PPTRUSTEE_W;
  267.   {$NODEFINE PPTRUSTEE}
  268.   TTrustee = TTrusteeW;
  269.   PTrustee = PTrusteeW;
  270. {$ELSE}
  271.   TRUSTEE_ = TRUSTEE_A;
  272.   {$EXTERNALSYM TRUSTEE_}
  273.   PTRUSTEE_ = PTRUSTEE_A;
  274.   {$EXTERNALSYM PTRUSTEE_}
  275.   TRUSTEE = TRUSTEEA;
  276.   {$EXTERNALSYM TRUSTEE}
  277.   PPTRUSTEE = ^PPTRUSTEE_A;
  278.   {$NODEFINE PPTRUSTEE}
  279.   TTrustee = TTrusteeA;
  280.   PTrustee = PTrusteeA;
  281. {$ENDIF}
  282. //
  283. // Definition: ACCESS_MODE
  284. // This enumerated type specifies how permissions are (requested)/to be applied
  285. //  for the trustee by the access control entry.  On input this field can by any
  286. //  of the values, although it is not meaningful to mix access control and audit
  287. //  control entries.  On output this field will be either SET_ACCESS, DENY_ACCESS,
  288. // SET_AUDIT_SUCCESS, SET_AUDIT_FAILURE.
  289. // The following descriptions define how this type effects an explicit access
  290. // request to apply access permissions to an object.
  291. // GRANT_ACCESS - The trustee will have at least the requested permissions upon
  292. //                successful completion of the command. (If the trustee has
  293. //                additional permissions they will not be removed).
  294. // SET_ACCESS - The trustee will have exactly the requested permissions upon
  295. //              successful completion of the command.
  296. // DENY_ACCESS - The trustee will be denied the specified permissions.
  297. // REVOKE_ACCESS - Any explicit access rights the trustee has will be revoked.
  298. // SET_AUDIT_SUCCESS - The trustee will be audited for successful opens of the
  299. //                     object using the requested permissions.
  300. // SET_AUDIT_FAILURE - The trustee will be audited for failed opens of the object
  301. //                     using the requested permissions.
  302. //
  303.   _ACCESS_MODE = (
  304.     NOT_USED_ACCESS,
  305.     GRANT_ACCESS,
  306.     SET_ACCESS,
  307.     DENY_ACCESS,
  308.     REVOKE_ACCESS,
  309.     SET_AUDIT_SUCCESS,
  310.     SET_AUDIT_FAILURE);
  311.   {$EXTERNALSYM _ACCESS_MODE}
  312.   ACCESS_MODE = _ACCESS_MODE;
  313.   {$EXTERNALSYM ACCESS_MODE}
  314.   TAccessMode = _ACCESS_MODE;
  315. //
  316. // Definition: Inheritance flags
  317. // These bit masks are provided to allow simple application of inheritance in
  318. // explicit access requests on containers.
  319. // NO_INHERITANCE       The specific access permissions will only be applied to
  320. //                  the container, and will not be inherited by objects created
  321. //                  within the container.
  322. // SUB_CONTAINERS_ONLY_INHERIT  The specific access permissions will be inherited
  323. //                              and applied to sub containers created within the
  324. //                              container, and will be applied to the container
  325. //                              itself.
  326. // SUB_OBJECTS_ONLY_INHERIT     The specific access permissions will only be inherited
  327. //                              by objects created within the specific container.
  328. //                              The access permissions will not be applied to the
  329. //                              container itself.
  330. // SUB_CONTAINERS_AND_OBJECTS_INHERIT   The specific access permissions will be
  331. //                                      inherited by containers created within the
  332. //                                      specific container, will be applied to
  333. //                                      objects created within the container, but
  334. //                                      will not be applied to the container itself.
  335. //
  336. const
  337.   NO_INHERITANCE                     = $0;
  338.   {$EXTERNALSYM NO_INHERITANCE}
  339.   SUB_OBJECTS_ONLY_INHERIT           = $1;
  340.   {$EXTERNALSYM SUB_OBJECTS_ONLY_INHERIT}
  341.   SUB_CONTAINERS_ONLY_INHERIT        = $2;
  342.   {$EXTERNALSYM SUB_CONTAINERS_ONLY_INHERIT}
  343.   SUB_CONTAINERS_AND_OBJECTS_INHERIT = $3;
  344.   {$EXTERNALSYM SUB_CONTAINERS_AND_OBJECTS_INHERIT}
  345.   INHERIT_NO_PROPAGATE               = $4;
  346.   {$EXTERNALSYM INHERIT_NO_PROPAGATE}
  347.   INHERIT_ONLY                       = $8;
  348.   {$EXTERNALSYM INHERIT_ONLY}
  349. //
  350. // Informational bit that is returned
  351. //
  352.   INHERITED_ACCESS_ENTRY = $10;
  353.   {$EXTERNALSYM INHERITED_ACCESS_ENTRY}
  354. //
  355. // Informational bit that tells where a node was inherited from.  Valid only
  356. // for NT 5 APIs
  357. //
  358.   INHERITED_PARENT      = $10000000;
  359.   {$EXTERNALSYM INHERITED_PARENT}
  360.   INHERITED_GRANDPARENT = $20000000;
  361.   {$EXTERNALSYM INHERITED_GRANDPARENT}
  362. //
  363. // Definition: EXPLICIT_ACCESS
  364. // This structure is used to pass access control entry information into and out
  365. // of the system using the API defined in this document.
  366. // grfAccessPermissions - This contains the access permissions to assign for the
  367. //                     trustee.  It is in the form of an NT access mask.
  368. // grfAccessMode - This field defines how the permissions are to be applied for
  369. //                 the trustee.
  370. // grfInheritance - For containers, this field defines how the access control
  371. //                  entry is/(is requested) to be inherited on
  372. //                  objects/sub-containers created within the container.
  373. // Trustee - This field contains the definition of the trustee account the
  374. //           explicit access applies to.
  375. //
  376. type
  377.   PEXPLICIT_ACCESS_A = ^EXPLICIT_ACCESS_A;
  378.   {$EXTERNALSYM PEXPLICIT_ACCESS_A}
  379.   _EXPLICIT_ACCESS_A = packed record
  380.     grfAccessPermissions: DWORD;
  381.     grfAccessMode: ACCESS_MODE;
  382.     grfInheritance: DWORD;
  383.     Trustee: TRUSTEE_A;
  384.   end;
  385.   {$EXTERNALSYM _EXPLICIT_ACCESS_A}
  386.   EXPLICIT_ACCESS_A = _EXPLICIT_ACCESS_A;
  387.   {$EXTERNALSYM EXPLICIT_ACCESS_A}
  388.   EXPLICIT_ACCESSA = EXPLICIT_ACCESS_A;
  389.   {$EXTERNALSYM EXPLICIT_ACCESSA}
  390.   PEXPLICIT_ACCESSA = PEXPLICIT_ACCESS_A;
  391.   {$EXTERNALSYM PEXPLICIT_ACCESSA}
  392.   TExplicitAccessA = EXPLICIT_ACCESS_A;
  393.   PExplicitAccessA = PEXPLICIT_ACCESS_A;
  394.   PEXPLICIT_ACCESS_W = ^EXPLICIT_ACCESS_W;
  395.   {$EXTERNALSYM PEXPLICIT_ACCESS_W}
  396.   _EXPLICIT_ACCESS_W = packed record
  397.     grfAccessPermissions: DWORD;
  398.     grfAccessMode: ACCESS_MODE;
  399.     grfInheritance: DWORD;
  400.     Trustee: TRUSTEE_W;
  401.   end;
  402.   {$EXTERNALSYM _EXPLICIT_ACCESS_W}
  403.   EXPLICIT_ACCESS_W = _EXPLICIT_ACCESS_W;
  404.   {$EXTERNALSYM EXPLICIT_ACCESS_W}
  405.   EXPLICIT_ACCESSW = EXPLICIT_ACCESS_W;
  406.   {$EXTERNALSYM EXPLICIT_ACCESSW}
  407.   PEXPLICIT_ACCESSW = PEXPLICIT_ACCESS_W;
  408.   {$EXTERNALSYM PEXPLICIT_ACCESSW}
  409.   TExplicitAccessW = EXPLICIT_ACCESS_W;
  410.   PExplicitAccessW = PEXPLICIT_ACCESS_W;
  411. {$IFDEF UNICODE}
  412.   EXPLICIT_ACCESS_ = EXPLICIT_ACCESS_W;
  413.   {$EXTERNALSYM EXPLICIT_ACCESS_}
  414.   PEXPLICIT_ACCESS_ = PEXPLICIT_ACCESS_W;
  415.   {$EXTERNALSYM PEXPLICIT_ACCESS_}
  416.   EXPLICIT_ACCESS = EXPLICIT_ACCESSW;
  417.   {$EXTERNALSYM EXPLICIT_ACCESS}
  418.   PEXPLICIT_ACCESS = PEXPLICIT_ACCESSW;
  419.   {$EXTERNALSYM PEXPLICIT_ACCESS}
  420.   TExplicitAccess = TExplicitAccessW;
  421.   PExplicitAccess = PExplicitAccessW;
  422. {$ELSE}
  423.   EXPLICIT_ACCESS_ = EXPLICIT_ACCESS_A;
  424.   {$EXTERNALSYM EXPLICIT_ACCESS_}
  425.   PEXPLICIT_ACCESS_ = PEXPLICIT_ACCESS_A;
  426.   {$EXTERNALSYM PEXPLICIT_ACCESS_}
  427.   EXPLICIT_ACCESS = EXPLICIT_ACCESSA;
  428.   {$EXTERNALSYM EXPLICIT_ACCESS}
  429.   PEXPLICIT_ACCESS = PEXPLICIT_ACCESSA;
  430.   {$EXTERNALSYM PEXPLICIT_ACCESS}
  431.   TExplicitAccess = TExplicitAccessA;
  432.   PExplicitAccess = PExplicitAccessA;
  433. {$ENDIF}
  434. //------------------------------------------------------------------------------
  435. //                              NT5 APIs
  436. //------------------------------------------------------------------------------
  437. //
  438. // Default provider
  439. //
  440. const
  441.   ACCCTRL_DEFAULT_PROVIDERA = 'Windows NT Access Provider';
  442.   {$EXTERNALSYM ACCCTRL_DEFAULT_PROVIDERA}
  443.   ACCCTRL_DEFAULT_PROVIDERW = 'Windows NT Access Provider';
  444.   {$EXTERNALSYM ACCCTRL_DEFAULT_PROVIDERW}
  445. {$IFDEF UNICODE}
  446.   ACCCTRL_DEFAULT_PROVIDER = ACCCTRL_DEFAULT_PROVIDERW;
  447.   {$EXTERNALSYM ACCCTRL_DEFAULT_PROVIDER}
  448. {$ELSE}
  449.   ACCCTRL_DEFAULT_PROVIDER = ACCCTRL_DEFAULT_PROVIDERA;
  450.   {$EXTERNALSYM ACCCTRL_DEFAULT_PROVIDER}
  451. {$ENDIF}
  452. //
  453. // Access rights
  454. //
  455. type
  456.   ACCESS_RIGHTS = ULONG;
  457.   {$EXTERNALSYM ACCESS_RIGHTS}
  458.   PACCESS_RIGHTS = ^ACCESS_RIGHTS;
  459.   {$EXTERNALSYM PACCESS_RIGHTS}
  460. //
  461. // Inheritance flags
  462. //
  463.   INHERIT_FLAGS = ULONG;
  464.   {$EXTERNALSYM INHERIT_FLAGS}
  465.   PINHERIT_FLAGS = ^INHERIT_FLAGS;
  466.   {$EXTERNALSYM PINHERIT_FLAGS}
  467. //
  468. // Access / Audit structures
  469. //
  470.   PACTRL_ACCESS_ENTRYA = ^ACTRL_ACCESS_ENTRYA;
  471.   {$EXTERNALSYM PACTRL_ACCESS_ENTRYA}
  472.   _ACTRL_ACCESS_ENTRYA = packed record
  473.     Trustee: TRUSTEE_A;
  474.     fAccessFlags: ULONG;
  475.     Access: ACCESS_RIGHTS;
  476.     ProvSpecificAccess: ACCESS_RIGHTS;
  477.     Inheritance: INHERIT_FLAGS;
  478.     lpInheritProperty: LPSTR;
  479.   end;
  480.   {$EXTERNALSYM _ACTRL_ACCESS_ENTRYA}
  481.   ACTRL_ACCESS_ENTRYA = _ACTRL_ACCESS_ENTRYA;
  482.   {$EXTERNALSYM ACTRL_ACCESS_ENTRYA}
  483.   TActrlAccessEntryA = ACTRL_ACCESS_ENTRYA;
  484.   PActrlAccessEntryA = PACTRL_ACCESS_ENTRYA;
  485. //
  486. // Access / Audit structures
  487. //
  488.   PACTRL_ACCESS_ENTRYW = ^ACTRL_ACCESS_ENTRYW;
  489.   {$EXTERNALSYM PACTRL_ACCESS_ENTRYW}
  490.   _ACTRL_ACCESS_ENTRYW = packed record
  491.     Trustee: TRUSTEE_W;
  492.     fAccessFlags: ULONG;
  493.     Access: ACCESS_RIGHTS;
  494.     ProvSpecificAccess: ACCESS_RIGHTS;
  495.     Inheritance: INHERIT_FLAGS;
  496.     lpInheritProperty: LPWSTR;
  497.   end;
  498.   {$EXTERNALSYM _ACTRL_ACCESS_ENTRYW}
  499.   ACTRL_ACCESS_ENTRYW = _ACTRL_ACCESS_ENTRYW;
  500.   {$EXTERNALSYM ACTRL_ACCESS_ENTRYW}
  501.   TActrlAccessEntryW = ACTRL_ACCESS_ENTRYW;
  502.   PActrlAccessEntryW = PACTRL_ACCESS_ENTRYW;
  503. {$IFDEF UNICODE}
  504.   ACTRL_ACCESS_ENTRY = ACTRL_ACCESS_ENTRYW;
  505.   {$EXTERNALSYM ACTRL_ACCESS_ENTRY}
  506.   PACTRL_ACCESS_ENTRY = PACTRL_ACCESS_ENTRYW;
  507.   {$EXTERNALSYM PACTRL_ACCESS_ENTRY}
  508.   TActrlAccessEntry = TActrlAccessEntryW;
  509.   PActrlAccessEntry = PActrlAccessEntryW;
  510. {$ELSE}
  511.   ACTRL_ACCESS_ENTRY = ACTRL_ACCESS_ENTRYA;
  512.   {$EXTERNALSYM ACTRL_ACCESS_ENTRY}
  513.   PACTRL_ACCESS_ENTRY = PACTRL_ACCESS_ENTRYA;
  514.   {$EXTERNALSYM PACTRL_ACCESS_ENTRY}
  515.   TActrlAccessEntry = TActrlAccessEntryA;
  516.   PActrlAccessEntry = PActrlAccessEntryA;
  517. {$ENDIF}
  518.   PACTRL_ACCESS_ENTRY_LISTA = ^ACTRL_ACCESS_ENTRY_LISTA;
  519.   {$EXTERNALSYM PACTRL_ACCESS_ENTRY_LISTA}
  520.   _ACTRL_ACCESS_ENTRY_LISTA = packed record
  521.     cEntries: ULONG;
  522.     pAccessList: PACTRL_ACCESS_ENTRYA;
  523.   end;
  524.   {$EXTERNALSYM _ACTRL_ACCESS_ENTRY_LISTA}
  525.   ACTRL_ACCESS_ENTRY_LISTA = _ACTRL_ACCESS_ENTRY_LISTA;
  526.   {$EXTERNALSYM ACTRL_ACCESS_ENTRY_LISTA}
  527.   TActrlAccessEntryListA = ACTRL_ACCESS_ENTRY_LISTA;
  528.   PActrlAccessEntryListA = PACTRL_ACCESS_ENTRY_LISTA;
  529.   PACTRL_ACCESS_ENTRY_LISTW = ^ACTRL_ACCESS_ENTRY_LISTW;
  530.   {$EXTERNALSYM PACTRL_ACCESS_ENTRY_LISTW}
  531.   _ACTRL_ACCESS_ENTRY_LISTW = packed record
  532.     cEntries: ULONG;
  533.     pAccessList: PACTRL_ACCESS_ENTRYW;
  534.   end;
  535.   {$EXTERNALSYM _ACTRL_ACCESS_ENTRY_LISTW}
  536.   ACTRL_ACCESS_ENTRY_LISTW = _ACTRL_ACCESS_ENTRY_LISTW;
  537.   {$EXTERNALSYM ACTRL_ACCESS_ENTRY_LISTW}
  538.   TActrlAccessEntryListW = ACTRL_ACCESS_ENTRY_LISTW;
  539.   PActrlAccessEntryListW = PACTRL_ACCESS_ENTRY_LISTW;
  540. {$IFDEF UNICODE}
  541.   ACTRL_ACCESS_ENTRY_LIST = ACTRL_ACCESS_ENTRY_LISTW;
  542.   {$EXTERNALSYM ACTRL_ACCESS_ENTRY_LIST}
  543.   PACTRL_ACCESS_ENTRY_LIST = PACTRL_ACCESS_ENTRY_LISTW;
  544.   {$EXTERNALSYM PACTRL_ACCESS_ENTRY_LIST}
  545.   TActrlAccessEntryList = TActrlAccessEntryListW;
  546.   PActrlAccessEntryList = PActrlAccessEntryListW;
  547. {$ELSE}
  548.   ACTRL_ACCESS_ENTRY_LIST = ACTRL_ACCESS_ENTRY_LISTA;
  549.   {$EXTERNALSYM ACTRL_ACCESS_ENTRY_LIST}
  550.   PACTRL_ACCESS_ENTRY_LIST = PACTRL_ACCESS_ENTRY_LISTA;
  551.   {$EXTERNALSYM PACTRL_ACCESS_ENTRY_LIST}
  552.   TActrlAccessEntryList = TActrlAccessEntryListA;
  553.   PActrlAccessEntryList = PActrlAccessEntryListA;
  554. {$ENDIF}
  555.   PACTRL_PROPERTY_ENTRYA = ^ACTRL_PROPERTY_ENTRYA;
  556.   {$EXTERNALSYM PACTRL_PROPERTY_ENTRYA}
  557.   _ACTRL_PROPERTY_ENTRYA = packed record
  558.     lpProperty: LPSTR;
  559.     pAccessEntryList: PACTRL_ACCESS_ENTRY_LISTA;
  560.     fListFlags: ULONG;
  561.   end;
  562.   {$EXTERNALSYM _ACTRL_PROPERTY_ENTRYA}
  563.   ACTRL_PROPERTY_ENTRYA = _ACTRL_PROPERTY_ENTRYA;
  564.   {$EXTERNALSYM ACTRL_PROPERTY_ENTRYA}
  565.   TActrlPropertyEntryA = ACTRL_PROPERTY_ENTRYA;
  566.   PActrlPropertyEntryA = PACTRL_PROPERTY_ENTRYA;
  567.   PACTRL_PROPERTY_ENTRYW = ^ACTRL_PROPERTY_ENTRYW;
  568.   {$EXTERNALSYM PACTRL_PROPERTY_ENTRYW}
  569.   _ACTRL_PROPERTY_ENTRYW = packed record
  570.     lpProperty: LPWSTR;
  571.     pAccessEntryList: PACTRL_ACCESS_ENTRY_LISTW;
  572.     fListFlags: ULONG;
  573.   end;
  574.   {$EXTERNALSYM _ACTRL_PROPERTY_ENTRYW}
  575.   ACTRL_PROPERTY_ENTRYW = _ACTRL_PROPERTY_ENTRYW;
  576.   {$EXTERNALSYM ACTRL_PROPERTY_ENTRYW}
  577.   TActrlPropertyEntryW = ACTRL_PROPERTY_ENTRYW;
  578.   PActrlPropertyEntryW = PACTRL_PROPERTY_ENTRYW;
  579. {$IFDEF UNICODE}
  580.   ACTRL_PROPERTY_ENTRY = ACTRL_PROPERTY_ENTRYW;
  581.   {$EXTERNALSYM ACTRL_PROPERTY_ENTRY}
  582.   PACTRL_PROPERTY_ENTRY = PACTRL_PROPERTY_ENTRYW;
  583.   {$EXTERNALSYM PACTRL_PROPERTY_ENTRY}
  584.   TActrlPropertyEntry = TActrlPropertyEntryW;
  585.   PActrlPropertyEntry = PActrlPropertyEntryW;
  586. {$ELSE}
  587.   ACTRL_PROPERTY_ENTRY = ACTRL_PROPERTY_ENTRYA;
  588.   {$EXTERNALSYM ACTRL_PROPERTY_ENTRY}
  589.   PACTRL_PROPERTY_ENTRY = PACTRL_PROPERTY_ENTRYA;
  590.   {$EXTERNALSYM PACTRL_PROPERTY_ENTRY}
  591.   TActrlPropertyEntry = TActrlPropertyEntryA;
  592.   PActrlPropertyEntry = PActrlPropertyEntryA;
  593. {$ENDIF}
  594.   PActrlAlistA = ^TActrlAlistA;
  595.   _ACTRL_ALISTA = packed record
  596.     cEntries: ULONG;
  597.     pPropertyAccessList: PACTRL_PROPERTY_ENTRYA;
  598.   end;
  599.   {$EXTERNALSYM _ACTRL_ALISTA}
  600.   ACTRL_ACCESSA = _ACTRL_ALISTA;
  601.   {$EXTERNALSYM ACTRL_ACCESSA}
  602.   PACTRL_ACCESSA = ^_ACTRL_ALISTA;
  603.   {$EXTERNALSYM PACTRL_ACCESSA}
  604.   ACTRL_AUDITA = ACTRL_ACCESSA;
  605.   {$EXTERNALSYM ACTRL_AUDITA}
  606.   PACTRL_AUDITA = ^ACTRL_AUDITA;
  607.   {$EXTERNALSYM PACTRL_AUDITA}
  608.   TActrlAlistA = _ACTRL_ALISTA;
  609.   PActrlAlistW = ^TActrlAlistW;
  610.   _ACTRL_ALISTW = packed record
  611.     cEntries: ULONG;
  612.     pPropertyAccessList: PACTRL_PROPERTY_ENTRYW;
  613.   end;
  614.   {$EXTERNALSYM _ACTRL_ALISTW}
  615.   ACTRL_ACCESSW = _ACTRL_ALISTW;
  616.   {$EXTERNALSYM ACTRL_ACCESSW}
  617.   PACTRL_ACCESSW = ^_ACTRL_ALISTW;
  618.   {$EXTERNALSYM PACTRL_ACCESSW}
  619.   ACTRL_AUDITW = ACTRL_ACCESSW;
  620.   {$EXTERNALSYM ACTRL_AUDITW}
  621.   PACTRL_AUDITW = ^ACTRL_AUDITW;
  622.   {$EXTERNALSYM PACTRL_AUDITW}
  623.   TActrlAlistW = _ACTRL_ALISTW;
  624. {$IFDEF UNICODE}
  625.   ACTRL_ACCESS = ACTRL_ACCESSW;
  626.   {$EXTERNALSYM ACTRL_ACCESS}
  627.   PACTRL_ACCESS = PACTRL_ACCESSW;
  628.   {$EXTERNALSYM PACTRL_ACCESS}
  629.   ACTRL_AUDIT = ACTRL_AUDITW;
  630.   {$EXTERNALSYM ACTRL_AUDIT}
  631.   PACTRL_AUDIT = PACTRL_AUDITW;
  632.   {$EXTERNALSYM PACTRL_AUDIT}
  633.   TActrlAlist = TActrlAlistW;
  634.   PActrlAlist = PActrlAlistW;
  635. {$ELSE}
  636.   ACTRL_ACCESS = ACTRL_ACCESSA;
  637.   {$EXTERNALSYM ACTRL_ACCESS}
  638.   PACTRL_ACCESS = PACTRL_ACCESSA;
  639.   {$EXTERNALSYM PACTRL_ACCESS}
  640.   ACTRL_AUDIT = ACTRL_AUDITA;
  641.   {$EXTERNALSYM ACTRL_AUDIT}
  642.   PACTRL_AUDIT = PACTRL_AUDITA;
  643.   {$EXTERNALSYM PACTRL_AUDIT}
  644.   TActrlAlist = TActrlAlistA;
  645.   PActrlAlist = PActrlAlistA;
  646. {$ENDIF}
  647. //
  648. // TRUSTEE_ACCESS flags
  649. //
  650. const
  651.   TRUSTEE_ACCESS_ALLOWED    = $00000001;
  652.   {$EXTERNALSYM TRUSTEE_ACCESS_ALLOWED}
  653.   TRUSTEE_ACCESS_READ       = $00000002;
  654.   {$EXTERNALSYM TRUSTEE_ACCESS_READ}
  655.   TRUSTEE_ACCESS_WRITE      = $00000004;
  656.   {$EXTERNALSYM TRUSTEE_ACCESS_WRITE}
  657.   TRUSTEE_ACCESS_EXPLICIT   = $00000001;
  658.   {$EXTERNALSYM TRUSTEE_ACCESS_EXPLICIT}
  659.   TRUSTEE_ACCESS_READ_WRITE = TRUSTEE_ACCESS_READ or TRUSTEE_ACCESS_WRITE;
  660.   {$EXTERNALSYM TRUSTEE_ACCESS_READ_WRITE}
  661.   TRUSTEE_ACCESS_ALL = DWORD($FFFFFFFF);
  662.   {$EXTERNALSYM TRUSTEE_ACCESS_ALL}
  663. type
  664.   PTRUSTEE_ACCESSA = ^TRUSTEE_ACCESSA;
  665.   {$EXTERNALSYM PTRUSTEE_ACCESSA}
  666.   _TRUSTEE_ACCESSA = packed record
  667.     lpProperty: LPSTR;
  668.     Access: ACCESS_RIGHTS;
  669.     fAccessFlags: ULONG;
  670.     fReturnedAccess: ULONG;
  671.   end;
  672.   {$EXTERNALSYM _TRUSTEE_ACCESSA}
  673.   TRUSTEE_ACCESSA = _TRUSTEE_ACCESSA;
  674.   {$EXTERNALSYM TRUSTEE_ACCESSA}
  675.   TTrusteeAccessA = TRUSTEE_ACCESSA;
  676.   PTrusteeAccessA = PTRUSTEE_ACCESSA;
  677.   PTRUSTEE_ACCESSW = ^TRUSTEE_ACCESSW;
  678.   {$EXTERNALSYM PTRUSTEE_ACCESSW}
  679.   _TRUSTEE_ACCESSW = packed record
  680.     lpProperty: LPWSTR;
  681.     Access: ACCESS_RIGHTS;
  682.     fAccessFlags: ULONG;
  683.     fReturnedAccess: ULONG;
  684.   end;
  685.   {$EXTERNALSYM _TRUSTEE_ACCESSW}
  686.   TRUSTEE_ACCESSW = _TRUSTEE_ACCESSW;
  687.   {$EXTERNALSYM TRUSTEE_ACCESSW}
  688.   TTrusteeAccessW = TRUSTEE_ACCESSW;
  689.   PTrusteeAccessW = PTRUSTEE_ACCESSW;
  690. {$IFDEF UNICODE}
  691.   TRUSTEE_ACCESS = TRUSTEE_ACCESSW;
  692.   {$EXTERNALSYM TRUSTEE_ACCESS}
  693.   PTRUSTEE_ACCESS = PTRUSTEE_ACCESSW;
  694.   {$EXTERNALSYM PTRUSTEE_ACCESS}
  695.   TTrusteeAccess = TTrusteeAccessW;
  696.   PTrusteeAccess = PTrusteeAccessW;
  697. {$ELSE}
  698.   TRUSTEE_ACCESS = TRUSTEE_ACCESSA;
  699.   {$EXTERNALSYM TRUSTEE_ACCESS}
  700.   PTRUSTEE_ACCESS = PTRUSTEE_ACCESSA;
  701.   {$EXTERNALSYM PTRUSTEE_ACCESS}
  702.   TTrusteeAccess = TTrusteeAccessA;
  703.   PTrusteeAccess = PTrusteeAccessA;
  704. {$ENDIF}
  705. //
  706. // Generic permission values
  707. //
  708. const
  709.   ACTRL_RESERVED = $00000000;
  710.   {$EXTERNALSYM ACTRL_RESERVED}
  711.   ACTRL_PERM_1   = $00000001;
  712.   {$EXTERNALSYM ACTRL_PERM_1}
  713.   ACTRL_PERM_2   = $00000002;
  714.   {$EXTERNALSYM ACTRL_PERM_2}
  715.   ACTRL_PERM_3   = $00000004;
  716.   {$EXTERNALSYM ACTRL_PERM_3}
  717.   ACTRL_PERM_4   = $00000008;
  718.   {$EXTERNALSYM ACTRL_PERM_4}
  719.   ACTRL_PERM_5   = $00000010;
  720.   {$EXTERNALSYM ACTRL_PERM_5}
  721.   ACTRL_PERM_6   = $00000020;
  722.   {$EXTERNALSYM ACTRL_PERM_6}
  723.   ACTRL_PERM_7   = $00000040;
  724.   {$EXTERNALSYM ACTRL_PERM_7}
  725.   ACTRL_PERM_8   = $00000080;
  726.   {$EXTERNALSYM ACTRL_PERM_8}
  727.   ACTRL_PERM_9   = $00000100;
  728.   {$EXTERNALSYM ACTRL_PERM_9}
  729.   ACTRL_PERM_10  = $00000200;
  730.   {$EXTERNALSYM ACTRL_PERM_10}
  731.   ACTRL_PERM_11  = $00000400;
  732.   {$EXTERNALSYM ACTRL_PERM_11}
  733.   ACTRL_PERM_12  = $00000800;
  734.   {$EXTERNALSYM ACTRL_PERM_12}
  735.   ACTRL_PERM_13  = $00001000;
  736.   {$EXTERNALSYM ACTRL_PERM_13}
  737.   ACTRL_PERM_14  = $00002000;
  738.   {$EXTERNALSYM ACTRL_PERM_14}
  739.   ACTRL_PERM_15  = $00004000;
  740.   {$EXTERNALSYM ACTRL_PERM_15}
  741.   ACTRL_PERM_16  = $00008000;
  742.   {$EXTERNALSYM ACTRL_PERM_16}
  743.   ACTRL_PERM_17  = $00010000;
  744.   {$EXTERNALSYM ACTRL_PERM_17}
  745.   ACTRL_PERM_18  = $00020000;
  746.   {$EXTERNALSYM ACTRL_PERM_18}
  747.   ACTRL_PERM_19  = $00040000;
  748.   {$EXTERNALSYM ACTRL_PERM_19}
  749.   ACTRL_PERM_20  = $00080000;
  750.   {$EXTERNALSYM ACTRL_PERM_20}
  751. //
  752. // Access permissions
  753. //
  754.   ACTRL_ACCESS_ALLOWED = $00000001;
  755.   {$EXTERNALSYM ACTRL_ACCESS_ALLOWED}
  756.   ACTRL_ACCESS_DENIED  = $00000002;
  757.   {$EXTERNALSYM ACTRL_ACCESS_DENIED}
  758.   ACTRL_AUDIT_SUCCESS  = $00000004;
  759.   {$EXTERNALSYM ACTRL_AUDIT_SUCCESS}
  760.   ACTRL_AUDIT_FAILURE  = $00000008;
  761.   {$EXTERNALSYM ACTRL_AUDIT_FAILURE}
  762. //
  763. // Property list flags
  764. //
  765.   ACTRL_ACCESS_PROTECTED = $00000001;
  766.   {$EXTERNALSYM ACTRL_ACCESS_PROTECTED}
  767. //
  768. // Standard and object rights
  769. //
  770.   ACTRL_SYSTEM_ACCESS      = $04000000;
  771.   {$EXTERNALSYM ACTRL_SYSTEM_ACCESS}
  772.   ACTRL_DELETE             = $08000000;
  773.   {$EXTERNALSYM ACTRL_DELETE}
  774.   ACTRL_READ_CONTROL       = $10000000;
  775.   {$EXTERNALSYM ACTRL_READ_CONTROL}
  776.   ACTRL_CHANGE_ACCESS      = $20000000;
  777.   {$EXTERNALSYM ACTRL_CHANGE_ACCESS}
  778.   ACTRL_CHANGE_OWNER       = $40000000;
  779.   {$EXTERNALSYM ACTRL_CHANGE_OWNER}
  780.   ACTRL_SYNCHRONIZE        = DWORD($80000000);
  781.   {$EXTERNALSYM ACTRL_SYNCHRONIZE}
  782.   ACTRL_STD_RIGHTS_ALL     = DWORD($f8000000);
  783.   {$EXTERNALSYM ACTRL_STD_RIGHTS_ALL}
  784.   ACTRL_STD_RIGHT_REQUIRED = DWORD(ACTRL_STD_RIGHTS_ALL and not ACTRL_SYNCHRONIZE);
  785.   {$EXTERNALSYM ACTRL_STD_RIGHT_REQUIRED}
  786.   ACTRL_DS_OPEN           = ACTRL_RESERVED;
  787.   {$EXTERNALSYM ACTRL_DS_OPEN}
  788.   ACTRL_DS_CREATE_CHILD   = ACTRL_PERM_1;
  789.   {$EXTERNALSYM ACTRL_DS_CREATE_CHILD}
  790.   ACTRL_DS_DELETE_CHILD   = ACTRL_PERM_2;
  791.   {$EXTERNALSYM ACTRL_DS_DELETE_CHILD}
  792.   ACTRL_DS_LIST           = ACTRL_PERM_3;
  793.   {$EXTERNALSYM ACTRL_DS_LIST}
  794.   ACTRL_DS_SELF           = ACTRL_PERM_4;
  795.   {$EXTERNALSYM ACTRL_DS_SELF}
  796.   ACTRL_DS_READ_PROP      = ACTRL_PERM_5;
  797.   {$EXTERNALSYM ACTRL_DS_READ_PROP}
  798.   ACTRL_DS_WRITE_PROP     = ACTRL_PERM_6;
  799.   {$EXTERNALSYM ACTRL_DS_WRITE_PROP}
  800.   ACTRL_DS_DELETE_TREE    = ACTRL_PERM_7;
  801.   {$EXTERNALSYM ACTRL_DS_DELETE_TREE}
  802.   ACTRL_DS_LIST_OBJECT    = ACTRL_PERM_8;
  803.   {$EXTERNALSYM ACTRL_DS_LIST_OBJECT}
  804.   ACTRL_DS_CONTROL_ACCESS = ACTRL_PERM_9;
  805.   {$EXTERNALSYM ACTRL_DS_CONTROL_ACCESS}
  806.   ACTRL_FILE_READ           = ACTRL_PERM_1;
  807.   {$EXTERNALSYM ACTRL_FILE_READ}
  808.   ACTRL_FILE_WRITE          = ACTRL_PERM_2;
  809.   {$EXTERNALSYM ACTRL_FILE_WRITE}
  810.   ACTRL_FILE_APPEND         = ACTRL_PERM_3;
  811.   {$EXTERNALSYM ACTRL_FILE_APPEND}
  812.   ACTRL_FILE_READ_PROP      = ACTRL_PERM_4;
  813.   {$EXTERNALSYM ACTRL_FILE_READ_PROP}
  814.   ACTRL_FILE_WRITE_PROP     = ACTRL_PERM_5;
  815.   {$EXTERNALSYM ACTRL_FILE_WRITE_PROP}
  816.   ACTRL_FILE_EXECUTE        = ACTRL_PERM_6;
  817.   {$EXTERNALSYM ACTRL_FILE_EXECUTE}
  818.   ACTRL_FILE_READ_ATTRIB    = ACTRL_PERM_8;
  819.   {$EXTERNALSYM ACTRL_FILE_READ_ATTRIB}
  820.   ACTRL_FILE_WRITE_ATTRIB   = ACTRL_PERM_9;
  821.   {$EXTERNALSYM ACTRL_FILE_WRITE_ATTRIB}
  822.   ACTRL_FILE_CREATE_PIPE    = ACTRL_PERM_10;
  823.   {$EXTERNALSYM ACTRL_FILE_CREATE_PIPE}
  824.   ACTRL_DIR_LIST            = ACTRL_PERM_1;
  825.   {$EXTERNALSYM ACTRL_DIR_LIST}
  826.   ACTRL_DIR_CREATE_OBJECT   = ACTRL_PERM_2;
  827.   {$EXTERNALSYM ACTRL_DIR_CREATE_OBJECT}
  828.   ACTRL_DIR_CREATE_CHILD    = ACTRL_PERM_3;
  829.   {$EXTERNALSYM ACTRL_DIR_CREATE_CHILD}
  830.   ACTRL_DIR_DELETE_CHILD    = ACTRL_PERM_7;
  831.   {$EXTERNALSYM ACTRL_DIR_DELETE_CHILD}
  832.   ACTRL_DIR_TRAVERSE        = ACTRL_PERM_6;
  833.   {$EXTERNALSYM ACTRL_DIR_TRAVERSE}
  834.   ACTRL_KERNEL_TERMINATE    = ACTRL_PERM_1;
  835.   {$EXTERNALSYM ACTRL_KERNEL_TERMINATE}
  836.   ACTRL_KERNEL_THREAD       = ACTRL_PERM_2;
  837.   {$EXTERNALSYM ACTRL_KERNEL_THREAD}
  838.   ACTRL_KERNEL_VM           = ACTRL_PERM_3;
  839.   {$EXTERNALSYM ACTRL_KERNEL_VM}
  840.   ACTRL_KERNEL_VM_READ      = ACTRL_PERM_4;
  841.   {$EXTERNALSYM ACTRL_KERNEL_VM_READ}
  842.   ACTRL_KERNEL_VM_WRITE     = ACTRL_PERM_5;
  843.   {$EXTERNALSYM ACTRL_KERNEL_VM_WRITE}
  844.   ACTRL_KERNEL_DUP_HANDLE   = ACTRL_PERM_6;
  845.   {$EXTERNALSYM ACTRL_KERNEL_DUP_HANDLE}
  846.   ACTRL_KERNEL_PROCESS      = ACTRL_PERM_7;
  847.   {$EXTERNALSYM ACTRL_KERNEL_PROCESS}
  848.   ACTRL_KERNEL_SET_INFO     = ACTRL_PERM_8;
  849.   {$EXTERNALSYM ACTRL_KERNEL_SET_INFO}
  850.   ACTRL_KERNEL_GET_INFO     = ACTRL_PERM_9;
  851.   {$EXTERNALSYM ACTRL_KERNEL_GET_INFO}
  852.   ACTRL_KERNEL_CONTROL      = ACTRL_PERM_10;
  853.   {$EXTERNALSYM ACTRL_KERNEL_CONTROL}
  854.   ACTRL_KERNEL_ALERT        = ACTRL_PERM_11;
  855.   {$EXTERNALSYM ACTRL_KERNEL_ALERT}
  856.   ACTRL_KERNEL_GET_CONTEXT  = ACTRL_PERM_12;
  857.   {$EXTERNALSYM ACTRL_KERNEL_GET_CONTEXT}
  858.   ACTRL_KERNEL_SET_CONTEXT  = ACTRL_PERM_13;
  859.   {$EXTERNALSYM ACTRL_KERNEL_SET_CONTEXT}
  860.   ACTRL_KERNEL_TOKEN        = ACTRL_PERM_14;
  861.   {$EXTERNALSYM ACTRL_KERNEL_TOKEN}
  862.   ACTRL_KERNEL_IMPERSONATE  = ACTRL_PERM_15;
  863.   {$EXTERNALSYM ACTRL_KERNEL_IMPERSONATE}
  864.   ACTRL_KERNEL_DIMPERSONATE = ACTRL_PERM_16;
  865.   {$EXTERNALSYM ACTRL_KERNEL_DIMPERSONATE}
  866.   ACTRL_PRINT_SADMIN        = ACTRL_PERM_1;
  867.   {$EXTERNALSYM ACTRL_PRINT_SADMIN}
  868.   ACTRL_PRINT_SLIST         = ACTRL_PERM_2;
  869.   {$EXTERNALSYM ACTRL_PRINT_SLIST}
  870.   ACTRL_PRINT_PADMIN        = ACTRL_PERM_3;
  871.   {$EXTERNALSYM ACTRL_PRINT_PADMIN}
  872.   ACTRL_PRINT_PUSE          = ACTRL_PERM_4;
  873.   {$EXTERNALSYM ACTRL_PRINT_PUSE}
  874.   ACTRL_PRINT_JADMIN        = ACTRL_PERM_5;
  875.   {$EXTERNALSYM ACTRL_PRINT_JADMIN}
  876.   ACTRL_SVC_GET_INFO        = ACTRL_PERM_1;
  877.   {$EXTERNALSYM ACTRL_SVC_GET_INFO}
  878.   ACTRL_SVC_SET_INFO        = ACTRL_PERM_2;
  879.   {$EXTERNALSYM ACTRL_SVC_SET_INFO}
  880.   ACTRL_SVC_STATUS          = ACTRL_PERM_3;
  881.   {$EXTERNALSYM ACTRL_SVC_STATUS}
  882.   ACTRL_SVC_LIST            = ACTRL_PERM_4;
  883.   {$EXTERNALSYM ACTRL_SVC_LIST}
  884.   ACTRL_SVC_START           = ACTRL_PERM_5;
  885.   {$EXTERNALSYM ACTRL_SVC_START}
  886.   ACTRL_SVC_STOP            = ACTRL_PERM_6;
  887.   {$EXTERNALSYM ACTRL_SVC_STOP}
  888.   ACTRL_SVC_PAUSE           = ACTRL_PERM_7;
  889.   {$EXTERNALSYM ACTRL_SVC_PAUSE}
  890.   ACTRL_SVC_INTERROGATE     = ACTRL_PERM_8;
  891.   {$EXTERNALSYM ACTRL_SVC_INTERROGATE}
  892.   ACTRL_SVC_UCONTROL        = ACTRL_PERM_9;
  893.   {$EXTERNALSYM ACTRL_SVC_UCONTROL}
  894.   ACTRL_REG_QUERY           = ACTRL_PERM_1;
  895.   {$EXTERNALSYM ACTRL_REG_QUERY}
  896.   ACTRL_REG_SET             = ACTRL_PERM_2;
  897.   {$EXTERNALSYM ACTRL_REG_SET}
  898.   ACTRL_REG_CREATE_CHILD    = ACTRL_PERM_3;
  899.   {$EXTERNALSYM ACTRL_REG_CREATE_CHILD}
  900.   ACTRL_REG_LIST            = ACTRL_PERM_4;
  901.   {$EXTERNALSYM ACTRL_REG_LIST}
  902.   ACTRL_REG_NOTIFY          = ACTRL_PERM_5;
  903.   {$EXTERNALSYM ACTRL_REG_NOTIFY}
  904.   ACTRL_REG_LINK            = ACTRL_PERM_6;
  905.   {$EXTERNALSYM ACTRL_REG_LINK}
  906.   ACTRL_WIN_CLIPBRD         = ACTRL_PERM_1;
  907.   {$EXTERNALSYM ACTRL_WIN_CLIPBRD}
  908.   ACTRL_WIN_GLOBAL_ATOMS    = ACTRL_PERM_2;
  909.   {$EXTERNALSYM ACTRL_WIN_GLOBAL_ATOMS}
  910.   ACTRL_WIN_CREATE          = ACTRL_PERM_3;
  911.   {$EXTERNALSYM ACTRL_WIN_CREATE}
  912.   ACTRL_WIN_LIST_DESK       = ACTRL_PERM_4;
  913.   {$EXTERNALSYM ACTRL_WIN_LIST_DESK}
  914.   ACTRL_WIN_LIST            = ACTRL_PERM_5;
  915.   {$EXTERNALSYM ACTRL_WIN_LIST}
  916.   ACTRL_WIN_READ_ATTRIBS    = ACTRL_PERM_6;
  917.   {$EXTERNALSYM ACTRL_WIN_READ_ATTRIBS}
  918.   ACTRL_WIN_WRITE_ATTRIBS   = ACTRL_PERM_7;
  919.   {$EXTERNALSYM ACTRL_WIN_WRITE_ATTRIBS}
  920.   ACTRL_WIN_SCREEN          = ACTRL_PERM_8;
  921.   {$EXTERNALSYM ACTRL_WIN_SCREEN}
  922.   ACTRL_WIN_EXIT            = ACTRL_PERM_9;
  923.   {$EXTERNALSYM ACTRL_WIN_EXIT}
  924. type
  925.   PACTRL_OVERLAPPED = ^ACTRL_OVERLAPPED;
  926.   {$EXTERNALSYM PACTRL_OVERLAPPED}
  927.   _ACTRL_OVERLAPPED = packed record
  928.     //union {
  929.     Provider: PVOID;
  930.     //    ULONG Reserved1;
  931.     //};
  932.     Reserved2: ULONG;
  933.     hEvent: HANDLE;
  934.   end;
  935.   {$EXTERNALSYM _ACTRL_OVERLAPPED}
  936.   ACTRL_OVERLAPPED = _ACTRL_OVERLAPPED;
  937.   {$EXTERNALSYM ACTRL_OVERLAPPED}
  938.   TActrlOverlapped = ACTRL_OVERLAPPED;
  939.   PActrlOverlapped = PACTRL_OVERLAPPED;
  940.   PACTRL_ACCESS_INFOA = ^ACTRL_ACCESS_INFOA;
  941.   {$EXTERNALSYM PACTRL_ACCESS_INFOA}
  942.   _ACTRL_ACCESS_INFOA = packed record
  943.     fAccessPermission: ULONG;
  944.     lpAccessPermissionName: LPSTR;
  945.   end;
  946.   {$EXTERNALSYM _ACTRL_ACCESS_INFOA}
  947.   ACTRL_ACCESS_INFOA = _ACTRL_ACCESS_INFOA;
  948.   {$EXTERNALSYM ACTRL_ACCESS_INFOA}
  949.   TActrlAccessInfoA = ACTRL_ACCESS_INFOA;
  950.   PActrlAccessInfoA = PACTRL_ACCESS_INFOA;
  951.   PACTRL_ACCESS_INFOW = ^ACTRL_ACCESS_INFOW;
  952.   {$EXTERNALSYM PACTRL_ACCESS_INFOW}
  953.   _ACTRL_ACCESS_INFOW = packed record
  954.     fAccessPermission: ULONG;
  955.     lpAccessPermissionName: LPWSTR;
  956.   end;
  957.   {$EXTERNALSYM _ACTRL_ACCESS_INFOW}
  958.   ACTRL_ACCESS_INFOW = _ACTRL_ACCESS_INFOW;
  959.   {$EXTERNALSYM ACTRL_ACCESS_INFOW}
  960.   TActrlAccessInfoW = ACTRL_ACCESS_INFOW;
  961.   PActrlAccessInfoW = PACTRL_ACCESS_INFOW;
  962. {$IFDEF UNICODE}
  963.   ACTRL_ACCESS_INFO = ACTRL_ACCESS_INFOW;
  964.   {$EXTERNALSYM ACTRL_ACCESS_INFO}
  965.   PACTRL_ACCESS_INFO = PACTRL_ACCESS_INFOW;
  966.   {$EXTERNALSYM PACTRL_ACCESS_INFO}
  967.   TActrlAccessInfo = TActrlAccessInfoW;
  968.   PActrlAccessInfo = PActrlAccessInfoW;
  969. {$ELSE}
  970.   ACTRL_ACCESS_INFO = ACTRL_ACCESS_INFOA;
  971.   {$EXTERNALSYM ACTRL_ACCESS_INFO}
  972.   PACTRL_ACCESS_INFO = PACTRL_ACCESS_INFOA;
  973.   {$EXTERNALSYM PACTRL_ACCESS_INFO}
  974.   TActrlAccessInfo = TActrlAccessInfoA;
  975.   PActrlAccessInfo = PActrlAccessInfoA;
  976. {$ENDIF}
  977.   PACTRL_CONTROL_INFOA = ^ACTRL_CONTROL_INFOA;
  978.   {$EXTERNALSYM PACTRL_CONTROL_INFOA}
  979.   _ACTRL_CONTROL_INFOA = packed record
  980.     lpControlId: LPSTR;
  981.     lpControlName: LPSTR;
  982.   end;
  983.   {$EXTERNALSYM _ACTRL_CONTROL_INFOA}
  984.   ACTRL_CONTROL_INFOA = _ACTRL_CONTROL_INFOA;
  985.   {$EXTERNALSYM ACTRL_CONTROL_INFOA}
  986.   TActrlControlInfoA = ACTRL_CONTROL_INFOA;
  987.   PActrlControlInfoA = PACTRL_CONTROL_INFOA;
  988.   PACTRL_CONTROL_INFOW = ^ACTRL_CONTROL_INFOW;
  989.   {$EXTERNALSYM PACTRL_CONTROL_INFOW}
  990.   _ACTRL_CONTROL_INFOW = packed record
  991.     lpControlId: LPWSTR;
  992.     lpControlName: LPWSTR;
  993.   end;
  994.   {$EXTERNALSYM _ACTRL_CONTROL_INFOW}
  995.   ACTRL_CONTROL_INFOW = _ACTRL_CONTROL_INFOW;
  996.   {$EXTERNALSYM ACTRL_CONTROL_INFOW}
  997.   TActrlControlInfoW = ACTRL_CONTROL_INFOW;
  998.   PActrlControlInfoW = PACTRL_CONTROL_INFOW;
  999. {$IFDEF UNICODE}
  1000.   ACTRL_CONTROL_INFO = ACTRL_CONTROL_INFOW;
  1001.   {$EXTERNALSYM ACTRL_CONTROL_INFO}
  1002.   PACTRL_CONTROL_INFO = PACTRL_CONTROL_INFOW;
  1003.   {$EXTERNALSYM PACTRL_CONTROL_INFO}
  1004.   TActrlControlInfo = TActrlControlInfoW;
  1005.   PActrlControlInfo = PActrlControlInfoW;
  1006. {$ELSE}
  1007.   ACTRL_CONTROL_INFO = ACTRL_CONTROL_INFOA;
  1008.   {$EXTERNALSYM ACTRL_CONTROL_INFO}
  1009.   PACTRL_CONTROL_INFO = PACTRL_CONTROL_INFOA;
  1010.   {$EXTERNALSYM PACTRL_CONTROL_INFO}
  1011.   TActrlControlInfo = TActrlControlInfoA;
  1012.   PActrlControlInfo = PActrlControlInfoA;
  1013. {$ENDIF}
  1014. const
  1015.   ACTRL_ACCESS_NO_OPTIONS              = $00000000;
  1016.   {$EXTERNALSYM ACTRL_ACCESS_NO_OPTIONS}
  1017.   ACTRL_ACCESS_SUPPORTS_OBJECT_ENTRIES = $00000001;
  1018.   {$EXTERNALSYM ACTRL_ACCESS_SUPPORTS_OBJECT_ENTRIES}
  1019.   ProgressInvokeNever = 1;        // Never invoke the progress function
  1020.   {$EXTERNALSYM ProgressInvokeNever}
  1021.   ProgressInvokeEveryObject = 2;  // Invoke for each object
  1022.   {$EXTERNALSYM ProgressInvokeEveryObject}
  1023.   ProgressInvokeOnError = 3;      // Invoke only for each error case
  1024.   {$EXTERNALSYM ProgressInvokeOnError}
  1025.   ProgressCancelOperation = 4;    // Stop propagation and return
  1026.   {$EXTERNALSYM ProgressCancelOperation}
  1027.   ProgressRetryOperation = 5;     // Retry operation on subtree
  1028.   {$EXTERNALSYM ProgressRetryOperation}
  1029. type
  1030.   PROG_INVOKE_SETTING = DWORD;
  1031.   {$EXTERNALSYM PROG_INVOKE_SETTING}
  1032.   PPROG_INVOKE_SETTING = ^PROG_INVOKE_SETTING;
  1033.   {$EXTERNALSYM PPROG_INVOKE_SETTING}
  1034.   TProgInvokeSetting = PROG_INVOKE_SETTING;
  1035.   PProgInvokeSetting = PPROG_INVOKE_SETTING;
  1036. //
  1037. // Progress Function:
  1038. // Caller of tree operation implements this Progress function, then
  1039. // passes its function pointer to tree operation.
  1040. // Tree operation invokes Progress function to provide progress and error
  1041. // information to the caller during the potentially long execution
  1042. // of the tree operation.  Tree operation provides the name of the object
  1043. // last processed and the error status of the operation on that object.
  1044. // Tree operation also passes the current InvokeSetting value.
  1045. // Caller may change the InvokeSetting value, for example, from "Always"
  1046. // to "Only On Error."
  1047. //
  1048. type
  1049.   FN_PROGRESS = procedure (pObjectName: LPWSTR; Status: DWORD;
  1050.     var pInvokeSetting: PROG_INVOKE_SETTING; Args: PVOID; SecuritySet: BOOL); stdcall;
  1051.   {$EXTERNALSYM FN_PROGRESS}
  1052.   TFnProgress = FN_PROGRESS;
  1053. //
  1054. // New Object Type function pointers.  TBD.
  1055. // To support additional object resource managers generically, the
  1056. // resource manager must provide it's own functions for operations
  1057. // like:
  1058. // GetAncestorAcl(IN ObjName, IN GenerationGap, IN DaclOrSacl?, ...)
  1059. // GetAncestorName(...)
  1060. // FreeNameStructure(...)
  1061. //
  1062. type
  1063.   _FN_OBJECT_MGR_FUNCTIONS = record
  1064.     Placeholder: ULONG;
  1065.   end;
  1066.   {$EXTERNALSYM _FN_OBJECT_MGR_FUNCTIONS}
  1067.   FN_OBJECT_MGR_FUNCTS = _FN_OBJECT_MGR_FUNCTIONS;
  1068.   {$EXTERNALSYM FN_OBJECT_MGR_FUNCTS}
  1069.   PFN_OBJECT_MGR_FUNCTS = ^FN_OBJECT_MGR_FUNCTS;
  1070.   {$EXTERNALSYM PFN_OBJECT_MGR_FUNCTS}
  1071.   TFnObjectMgrFuncts = FN_OBJECT_MGR_FUNCTS;
  1072.   PFnObjectMgrFuncts = PFN_OBJECT_MGR_FUNCTS;  
  1073. //
  1074. // Name of ancestor and number of generations between
  1075. // ancestor and inheriting object.
  1076. //
  1077. // GenerationGap:
  1078. //     Name of ancestor from which ACE was inherited.
  1079. //     NULL for explicit ACE.
  1080. //
  1081. // AncestorName:
  1082. //     Number of levels (or generations) between the object and the ancestor.
  1083. //     Parent, gap=1.
  1084. //     Grandparent, gap=2.
  1085. //     Set to 0 for explicit ACE on object.
  1086. //
  1087. type
  1088.   _INHERITED_FROMA = record
  1089.     GenerationGap: LONG;
  1090.     AncestorName: LPSTR;
  1091.   end;
  1092.   {$EXTERNALSYM _INHERITED_FROMA}
  1093.   INHERITED_FROMA = _INHERITED_FROMA;
  1094.   {$EXTERNALSYM INHERITED_FROMA}
  1095.   PINHERITED_FROMA = ^INHERITED_FROMA;
  1096.   {$EXTERNALSYM PINHERITED_FROMA}
  1097.   TInheritedFromA = INHERITED_FROMA;
  1098.   PInheritedFromA = PINHERITED_FROMA;
  1099.   _INHERITED_FROMW = record
  1100.     GenerationGap: LONG;
  1101.     AncestorName: LPWSTR;
  1102.   end;
  1103.   {$EXTERNALSYM _INHERITED_FROMW}
  1104.   INHERITED_FROMW = _INHERITED_FROMW;
  1105.   {$EXTERNALSYM INHERITED_FROMW}
  1106.   PINHERITED_FROMW = ^INHERITED_FROMW;
  1107.   {$EXTERNALSYM PINHERITED_FROMW}
  1108.   TInheritedFromW = INHERITED_FROMW;
  1109.   PInheritedFromW = PINHERITED_FROMW;
  1110. {$IFDEF UNICODE}
  1111.   INHERITED_FROM = INHERITED_FROMW;
  1112.   {$EXTERNALSYM INHERITED_FROM}
  1113.   PINHERITED_FROM = PINHERITED_FROMW;
  1114.   {$EXTERNALSYM PINHERITED_FROM}
  1115.   TInheritedFrom = TInheritedFromW;
  1116.   PInheritedFrom = PInheritedFromW;
  1117. {$ELSE}
  1118.   INHERITED_FROM = INHERITED_FROMA;
  1119.   {$EXTERNALSYM INHERITED_FROM}
  1120.   PINHERITED_FROM = PINHERITED_FROMA;
  1121.   {$EXTERNALSYM PINHERITED_FROM}
  1122.   TInheritedFrom = TInheritedFromA;
  1123.   PInheritedFrom = PInheritedFromA;
  1124. {$ENDIF}
  1125. implementation
  1126. uses
  1127.   JwaWinBase;
  1128. function AccFree(hMem: HLOCAL): HLOCAL;
  1129. begin
  1130.   Result := LocalFree(hMem);
  1131. end;
  1132. end.