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

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Windows Types 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: winnt.h, released August 2001. The original Pascal     }
  9. { code is: WinNT.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 JwaWinNT;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "winnt.h"'}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT 'typedef PACL *PPACL'}
  49. {$HPPEMIT 'typedef PSID *PPSID'}
  50. {$HPPEMIT 'typedef PSECURITY_DESCRIPTOR *PPSECURITY_DESCRIPTOR'}
  51. {$HPPEMIT ''}
  52. {$I WINDEFINES.INC}
  53. interface
  54. uses
  55.   JwaWinType;
  56. const
  57.   MAXBYTE  = BYTE($ff);
  58.   {$EXTERNALSYM MAXBYTE}
  59.   MAXWORD  = WORD($ffff);
  60.   {$EXTERNALSYM MAXWORD}
  61.   MAXDWORD = DWORD($ffffffff);
  62.   {$EXTERNALSYM MAXDWORD}
  63. const
  64.   VER_SERVER_NT                      = DWORD($80000000);
  65.   {$EXTERNALSYM VER_SERVER_NT}
  66.   VER_WORKSTATION_NT                 = $40000000;
  67.   {$EXTERNALSYM VER_WORKSTATION_NT}
  68.   VER_SUITE_SMALLBUSINESS            = $00000001;
  69.   {$EXTERNALSYM VER_SUITE_SMALLBUSINESS}
  70.   VER_SUITE_ENTERPRISE               = $00000002;
  71.   {$EXTERNALSYM VER_SUITE_ENTERPRISE}
  72.   VER_SUITE_BACKOFFICE               = $00000004;
  73.   {$EXTERNALSYM VER_SUITE_BACKOFFICE}
  74.   VER_SUITE_COMMUNICATIONS           = $00000008;
  75.   {$EXTERNALSYM VER_SUITE_COMMUNICATIONS}
  76.   VER_SUITE_TERMINAL                 = $00000010;
  77.   {$EXTERNALSYM VER_SUITE_TERMINAL}
  78.   VER_SUITE_SMALLBUSINESS_RESTRICTED = $00000020;
  79.   {$EXTERNALSYM VER_SUITE_SMALLBUSINESS_RESTRICTED}
  80.   VER_SUITE_EMBEDDEDNT               = $00000040;
  81.   {$EXTERNALSYM VER_SUITE_EMBEDDEDNT}
  82.   VER_SUITE_DATACENTER               = $00000080;
  83.   {$EXTERNALSYM VER_SUITE_DATACENTER}
  84.   VER_SUITE_SINGLEUSERTS             = $00000100;
  85.   {$EXTERNALSYM VER_SUITE_SINGLEUSERTS}
  86.   VER_SUITE_PERSONAL                 = $00000200;
  87.   {$EXTERNALSYM VER_SUITE_PERSONAL}
  88.   VER_SUITE_BLADE                    = $00000400;
  89.   {$EXTERNALSYM VER_SUITE_BLADE}
  90.   VER_SUITE_EMBEDDED_RESTRICTED      = $00000800;
  91.   {$EXTERNALSYM VER_SUITE_EMBEDDED_RESTRICTED}
  92. //
  93. //  Language IDs.
  94. //
  95. //  The following two combinations of primary language ID and
  96. //  sublanguage ID have special semantics:
  97. //
  98. //    Primary Language ID   Sublanguage ID      Result
  99. //    -------------------   ---------------     ------------------------
  100. //    LANG_NEUTRAL          SUBLANG_NEUTRAL     Language neutral
  101. //    LANG_NEUTRAL          SUBLANG_DEFAULT     User default language
  102. //    LANG_NEUTRAL          SUBLANG_SYS_DEFAULT System default language
  103. //    LANG_INVARIANT        SUBLANG_NEUTRAL     Invariant locale
  104. //
  105. //
  106. //  Primary language IDs.
  107. //
  108. const
  109.   LANG_NEUTRAL    = $00;
  110.   {$EXTERNALSYM LANG_NEUTRAL}
  111.   LANG_INVARIANT  = $7f;
  112.   {$EXTERNALSYM LANG_INVARIANT}
  113.   LANG_AFRIKAANS  = $36;
  114.   {$EXTERNALSYM LANG_AFRIKAANS}
  115.   LANG_ALBANIAN   = $1c;
  116.   {$EXTERNALSYM LANG_ALBANIAN}
  117.   LANG_ARABIC     = $01;
  118.   {$EXTERNALSYM LANG_ARABIC}
  119.   LANG_ARMENIAN   = $2b;
  120.   {$EXTERNALSYM LANG_ARMENIAN}
  121.   LANG_ASSAMESE   = $4d;
  122.   {$EXTERNALSYM LANG_ASSAMESE}
  123.   LANG_AZERI      = $2c;
  124.   {$EXTERNALSYM LANG_AZERI}
  125.   LANG_BASQUE     = $2d;
  126.   {$EXTERNALSYM LANG_BASQUE}
  127.   LANG_BELARUSIAN = $23;
  128.   {$EXTERNALSYM LANG_BELARUSIAN}
  129.   LANG_BENGALI    = $45;
  130.   {$EXTERNALSYM LANG_BENGALI}
  131.   LANG_BULGARIAN  = $02;
  132.   {$EXTERNALSYM LANG_BULGARIAN}
  133.   LANG_CATALAN    = $03;
  134.   {$EXTERNALSYM LANG_CATALAN}
  135.   LANG_CHINESE    = $04;
  136.   {$EXTERNALSYM LANG_CHINESE}
  137.   LANG_CROATIAN   = $1a;
  138.   {$EXTERNALSYM LANG_CROATIAN}
  139.   LANG_CZECH      = $05;
  140.   {$EXTERNALSYM LANG_CZECH}
  141.   LANG_DANISH     = $06;
  142.   {$EXTERNALSYM LANG_DANISH}
  143.   LANG_DIVEHI     = $65;
  144.   {$EXTERNALSYM LANG_DIVEHI}
  145.   LANG_DUTCH      = $13;
  146.   {$EXTERNALSYM LANG_DUTCH}
  147.   LANG_ENGLISH    = $09;
  148.   {$EXTERNALSYM LANG_ENGLISH}
  149.   LANG_ESTONIAN   = $25;
  150.   {$EXTERNALSYM LANG_ESTONIAN}
  151.   LANG_FAEROESE   = $38;
  152.   {$EXTERNALSYM LANG_FAEROESE}
  153.   LANG_FARSI      = $29;
  154.   {$EXTERNALSYM LANG_FARSI}
  155.   LANG_FINNISH    = $0b;
  156.   {$EXTERNALSYM LANG_FINNISH}
  157.   LANG_FRENCH     = $0c;
  158.   {$EXTERNALSYM LANG_FRENCH}
  159.   LANG_GALICIAN   = $56;
  160.   {$EXTERNALSYM LANG_GALICIAN}
  161.   LANG_GEORGIAN   = $37;
  162.   {$EXTERNALSYM LANG_GEORGIAN}
  163.   LANG_GERMAN     = $07;
  164.   {$EXTERNALSYM LANG_GERMAN}
  165.   LANG_GREEK      = $08;
  166.   {$EXTERNALSYM LANG_GREEK}
  167.   LANG_GUJARATI   = $47;
  168.   {$EXTERNALSYM LANG_GUJARATI}
  169.   LANG_HEBREW     = $0d;
  170.   {$EXTERNALSYM LANG_HEBREW}
  171.   LANG_HINDI      = $39;
  172.   {$EXTERNALSYM LANG_HINDI}
  173.   LANG_HUNGARIAN  = $0e;
  174.   {$EXTERNALSYM LANG_HUNGARIAN}
  175.   LANG_ICELANDIC  = $0f;
  176.   {$EXTERNALSYM LANG_ICELANDIC}
  177.   LANG_INDONESIAN = $21;
  178.   {$EXTERNALSYM LANG_INDONESIAN}
  179.   LANG_ITALIAN    = $10;
  180.   {$EXTERNALSYM LANG_ITALIAN}
  181.   LANG_JAPANESE   = $11;
  182.   {$EXTERNALSYM LANG_JAPANESE}
  183.   LANG_KANNADA    = $4b;
  184.   {$EXTERNALSYM LANG_KANNADA}
  185.   LANG_KASHMIRI   = $60;
  186.   {$EXTERNALSYM LANG_KASHMIRI}
  187.   LANG_KAZAK      = $3f;
  188.   {$EXTERNALSYM LANG_KAZAK}
  189.   LANG_KONKANI    = $57;
  190.   {$EXTERNALSYM LANG_KONKANI}
  191.   LANG_KOREAN     = $12;
  192.   {$EXTERNALSYM LANG_KOREAN}
  193.   LANG_KYRGYZ     = $40;
  194.   {$EXTERNALSYM LANG_KYRGYZ}
  195.   LANG_LATVIAN    = $26;
  196.   {$EXTERNALSYM LANG_LATVIAN}
  197.   LANG_LITHUANIAN = $27;
  198.   {$EXTERNALSYM LANG_LITHUANIAN}
  199.   LANG_MACEDONIAN = $2f;            // the Former Yugoslav Republic of Macedonia
  200.   {$EXTERNALSYM LANG_MACEDONIAN}
  201.   LANG_MALAY      = $3e;
  202.   {$EXTERNALSYM LANG_MALAY}
  203.   LANG_MALAYALAM  = $4c;
  204.   {$EXTERNALSYM LANG_MALAYALAM}
  205.   LANG_MANIPURI   = $58;
  206.   {$EXTERNALSYM LANG_MANIPURI}
  207.   LANG_MARATHI    = $4e;
  208.   {$EXTERNALSYM LANG_MARATHI}
  209.   LANG_MONGOLIAN  = $50;
  210.   {$EXTERNALSYM LANG_MONGOLIAN}
  211.   LANG_NEPALI     = $61;
  212.   {$EXTERNALSYM LANG_NEPALI}
  213.   LANG_NORWEGIAN  = $14;
  214.   {$EXTERNALSYM LANG_NORWEGIAN}
  215.   LANG_ORIYA      = $48;
  216.   {$EXTERNALSYM LANG_ORIYA}
  217.   LANG_POLISH     = $15;
  218.   {$EXTERNALSYM LANG_POLISH}
  219.   LANG_PORTUGUESE = $16;
  220.   {$EXTERNALSYM LANG_PORTUGUESE}
  221.   LANG_PUNJABI    = $46;
  222.   {$EXTERNALSYM LANG_PUNJABI}
  223.   LANG_ROMANIAN   = $18;
  224.   {$EXTERNALSYM LANG_ROMANIAN}
  225.   LANG_RUSSIAN    = $19;
  226.   {$EXTERNALSYM LANG_RUSSIAN}
  227.   LANG_SANSKRIT   = $4f;
  228.   {$EXTERNALSYM LANG_SANSKRIT}
  229.   LANG_SERBIAN    = $1a;
  230.   {$EXTERNALSYM LANG_SERBIAN}
  231.   LANG_SINDHI     = $59;
  232.   {$EXTERNALSYM LANG_SINDHI}
  233.   LANG_SLOVAK     = $1b;
  234.   {$EXTERNALSYM LANG_SLOVAK}
  235.   LANG_SLOVENIAN  = $24;
  236.   {$EXTERNALSYM LANG_SLOVENIAN}
  237.   LANG_SPANISH    = $0a;
  238.   {$EXTERNALSYM LANG_SPANISH}
  239.   LANG_SWAHILI    = $41;
  240.   {$EXTERNALSYM LANG_SWAHILI}
  241.   LANG_SWEDISH    = $1d;
  242.   {$EXTERNALSYM LANG_SWEDISH}
  243.   LANG_SYRIAC     = $5a;
  244.   {$EXTERNALSYM LANG_SYRIAC}
  245.   LANG_TAMIL      = $49;
  246.   {$EXTERNALSYM LANG_TAMIL}
  247.   LANG_TATAR      = $44;
  248.   {$EXTERNALSYM LANG_TATAR}
  249.   LANG_TELUGU     = $4a;
  250.   {$EXTERNALSYM LANG_TELUGU}
  251.   LANG_THAI       = $1e;
  252.   {$EXTERNALSYM LANG_THAI}
  253.   LANG_TURKISH    = $1f;
  254.   {$EXTERNALSYM LANG_TURKISH}
  255.   LANG_UKRAINIAN  = $22;
  256.   {$EXTERNALSYM LANG_UKRAINIAN}
  257.   LANG_URDU       = $20;
  258.   {$EXTERNALSYM LANG_URDU}
  259.   LANG_UZBEK      = $43;
  260.   {$EXTERNALSYM LANG_UZBEK}
  261.   LANG_VIETNAMESE = $2a;
  262.   {$EXTERNALSYM LANG_VIETNAMESE}
  263. //
  264. //  Sublanguage IDs.
  265. //
  266. //  The name immediately following SUBLANG_ dictates which primary
  267. //  language ID that sublanguage ID can be combined with to form a
  268. //  valid language ID.
  269. //
  270.   SUBLANG_NEUTRAL     = $00; // language neutral
  271.   {$EXTERNALSYM SUBLANG_NEUTRAL}
  272.   SUBLANG_DEFAULT     = $01; // user default
  273.   {$EXTERNALSYM SUBLANG_DEFAULT}
  274.   SUBLANG_SYS_DEFAULT = $02; // system default
  275.   {$EXTERNALSYM SUBLANG_SYS_DEFAULT}
  276.   SUBLANG_ARABIC_SAUDI_ARABIA        = $01; // Arabic (Saudi Arabia)
  277.   {$EXTERNALSYM SUBLANG_ARABIC_SAUDI_ARABIA}
  278.   SUBLANG_ARABIC_IRAQ                = $02; // Arabic (Iraq)
  279.   {$EXTERNALSYM SUBLANG_ARABIC_IRAQ}
  280.   SUBLANG_ARABIC_EGYPT               = $03; // Arabic (Egypt)
  281.   {$EXTERNALSYM SUBLANG_ARABIC_EGYPT}
  282.   SUBLANG_ARABIC_LIBYA               = $04; // Arabic (Libya)
  283.   {$EXTERNALSYM SUBLANG_ARABIC_LIBYA}
  284.   SUBLANG_ARABIC_ALGERIA             = $05; // Arabic (Algeria)
  285.   {$EXTERNALSYM SUBLANG_ARABIC_ALGERIA}
  286.   SUBLANG_ARABIC_MOROCCO             = $06; // Arabic (Morocco)
  287.   {$EXTERNALSYM SUBLANG_ARABIC_MOROCCO}
  288.   SUBLANG_ARABIC_TUNISIA             = $07; // Arabic (Tunisia)
  289.   {$EXTERNALSYM SUBLANG_ARABIC_TUNISIA}
  290.   SUBLANG_ARABIC_OMAN                = $08; // Arabic (Oman)
  291.   {$EXTERNALSYM SUBLANG_ARABIC_OMAN}
  292.   SUBLANG_ARABIC_YEMEN               = $09; // Arabic (Yemen)
  293.   {$EXTERNALSYM SUBLANG_ARABIC_YEMEN}
  294.   SUBLANG_ARABIC_SYRIA               = $0a; // Arabic (Syria)
  295.   {$EXTERNALSYM SUBLANG_ARABIC_SYRIA}
  296.   SUBLANG_ARABIC_JORDAN              = $0b; // Arabic (Jordan)
  297.   {$EXTERNALSYM SUBLANG_ARABIC_JORDAN}
  298.   SUBLANG_ARABIC_LEBANON             = $0c; // Arabic (Lebanon)
  299.   {$EXTERNALSYM SUBLANG_ARABIC_LEBANON}
  300.   SUBLANG_ARABIC_KUWAIT              = $0d; // Arabic (Kuwait)
  301.   {$EXTERNALSYM SUBLANG_ARABIC_KUWAIT}
  302.   SUBLANG_ARABIC_UAE                 = $0e; // Arabic (U.A.E)
  303.   {$EXTERNALSYM SUBLANG_ARABIC_UAE}
  304.   SUBLANG_ARABIC_BAHRAIN             = $0f; // Arabic (Bahrain)
  305.   {$EXTERNALSYM SUBLANG_ARABIC_BAHRAIN}
  306.   SUBLANG_ARABIC_QATAR               = $10; // Arabic (Qatar)
  307.   {$EXTERNALSYM SUBLANG_ARABIC_QATAR}
  308.   SUBLANG_AZERI_LATIN                = $01; // Azeri (Latin)
  309.   {$EXTERNALSYM SUBLANG_AZERI_LATIN}
  310.   SUBLANG_AZERI_CYRILLIC             = $02; // Azeri (Cyrillic)
  311.   {$EXTERNALSYM SUBLANG_AZERI_CYRILLIC}
  312.   SUBLANG_CHINESE_TRADITIONAL        = $01; // Chinese (Taiwan)
  313.   {$EXTERNALSYM SUBLANG_CHINESE_TRADITIONAL}
  314.   SUBLANG_CHINESE_SIMPLIFIED         = $02; // Chinese (PR China)
  315.   {$EXTERNALSYM SUBLANG_CHINESE_SIMPLIFIED}
  316.   SUBLANG_CHINESE_HONGKONG           = $03; // Chinese (Hong Kong S.A.R., P.R.C.)
  317.   {$EXTERNALSYM SUBLANG_CHINESE_HONGKONG}
  318.   SUBLANG_CHINESE_SINGAPORE          = $04; // Chinese (Singapore)
  319.   {$EXTERNALSYM SUBLANG_CHINESE_SINGAPORE}
  320.   SUBLANG_CHINESE_MACAU              = $05; // Chinese (Macau S.A.R.)
  321.   {$EXTERNALSYM SUBLANG_CHINESE_MACAU}
  322.   SUBLANG_DUTCH                      = $01; // Dutch
  323.   {$EXTERNALSYM SUBLANG_DUTCH}
  324.   SUBLANG_DUTCH_BELGIAN              = $02; // Dutch (Belgian)
  325.   {$EXTERNALSYM SUBLANG_DUTCH_BELGIAN}
  326.   SUBLANG_ENGLISH_US                 = $01; // English (USA)
  327.   {$EXTERNALSYM SUBLANG_ENGLISH_US}
  328.   SUBLANG_ENGLISH_UK                 = $02; // English (UK)
  329.   {$EXTERNALSYM SUBLANG_ENGLISH_UK}
  330.   SUBLANG_ENGLISH_AUS                = $03; // English (Australian)
  331.   {$EXTERNALSYM SUBLANG_ENGLISH_AUS}
  332.   SUBLANG_ENGLISH_CAN                = $04; // English (Canadian)
  333.   {$EXTERNALSYM SUBLANG_ENGLISH_CAN}
  334.   SUBLANG_ENGLISH_NZ                 = $05; // English (New Zealand)
  335.   {$EXTERNALSYM SUBLANG_ENGLISH_NZ}
  336.   SUBLANG_ENGLISH_EIRE               = $06; // English (Irish)
  337.   {$EXTERNALSYM SUBLANG_ENGLISH_EIRE}
  338.   SUBLANG_ENGLISH_SOUTH_AFRICA       = $07; // English (South Africa)
  339.   {$EXTERNALSYM SUBLANG_ENGLISH_SOUTH_AFRICA}
  340.   SUBLANG_ENGLISH_JAMAICA            = $08; // English (Jamaica)
  341.   {$EXTERNALSYM SUBLANG_ENGLISH_JAMAICA}
  342.   SUBLANG_ENGLISH_CARIBBEAN          = $09; // English (Caribbean)
  343.   {$EXTERNALSYM SUBLANG_ENGLISH_CARIBBEAN}
  344.   SUBLANG_ENGLISH_BELIZE             = $0a; // English (Belize)
  345.   {$EXTERNALSYM SUBLANG_ENGLISH_BELIZE}
  346.   SUBLANG_ENGLISH_TRINIDAD           = $0b; // English (Trinidad)
  347.   {$EXTERNALSYM SUBLANG_ENGLISH_TRINIDAD}
  348.   SUBLANG_ENGLISH_ZIMBABWE           = $0c; // English (Zimbabwe)
  349.   {$EXTERNALSYM SUBLANG_ENGLISH_ZIMBABWE}
  350.   SUBLANG_ENGLISH_PHILIPPINES        = $0d; // English (Philippines)
  351.   {$EXTERNALSYM SUBLANG_ENGLISH_PHILIPPINES}
  352.   SUBLANG_FRENCH                     = $01; // French
  353.   {$EXTERNALSYM SUBLANG_FRENCH}
  354.   SUBLANG_FRENCH_BELGIAN             = $02; // French (Belgian)
  355.   {$EXTERNALSYM SUBLANG_FRENCH_BELGIAN}
  356.   SUBLANG_FRENCH_CANADIAN            = $03; // French (Canadian)
  357.   {$EXTERNALSYM SUBLANG_FRENCH_CANADIAN}
  358.   SUBLANG_FRENCH_SWISS               = $04; // French (Swiss)
  359.   {$EXTERNALSYM SUBLANG_FRENCH_SWISS}
  360.   SUBLANG_FRENCH_LUXEMBOURG          = $05; // French (Luxembourg)
  361.   {$EXTERNALSYM SUBLANG_FRENCH_LUXEMBOURG}
  362.   SUBLANG_FRENCH_MONACO              = $06; // French (Monaco)
  363.   {$EXTERNALSYM SUBLANG_FRENCH_MONACO}
  364.   SUBLANG_GERMAN                     = $01; // German
  365.   {$EXTERNALSYM SUBLANG_GERMAN}
  366.   SUBLANG_GERMAN_SWISS               = $02; // German (Swiss)
  367.   {$EXTERNALSYM SUBLANG_GERMAN_SWISS}
  368.   SUBLANG_GERMAN_AUSTRIAN            = $03; // German (Austrian)
  369.   {$EXTERNALSYM SUBLANG_GERMAN_AUSTRIAN}
  370.   SUBLANG_GERMAN_LUXEMBOURG          = $04; // German (Luxembourg)
  371.   {$EXTERNALSYM SUBLANG_GERMAN_LUXEMBOURG}
  372.   SUBLANG_GERMAN_LIECHTENSTEIN       = $05; // German (Liechtenstein)
  373.   {$EXTERNALSYM SUBLANG_GERMAN_LIECHTENSTEIN}
  374.   SUBLANG_ITALIAN                    = $01; // Italian
  375.   {$EXTERNALSYM SUBLANG_ITALIAN}
  376.   SUBLANG_ITALIAN_SWISS              = $02; // Italian (Swiss)
  377.   {$EXTERNALSYM SUBLANG_ITALIAN_SWISS}
  378.   SUBLANG_KASHMIRI_SASIA             = $02; // Kashmiri (South Asia)
  379.   {$EXTERNALSYM SUBLANG_KASHMIRI_SASIA}
  380.   SUBLANG_KASHMIRI_INDIA             = $02; // For app compatibility only
  381.   {$EXTERNALSYM SUBLANG_KASHMIRI_INDIA}
  382.   SUBLANG_KOREAN                     = $01; // Korean (Extended Wansung)
  383.   {$EXTERNALSYM SUBLANG_KOREAN}
  384.   SUBLANG_LITHUANIAN                 = $01; // Lithuanian
  385.   {$EXTERNALSYM SUBLANG_LITHUANIAN}
  386.   SUBLANG_MALAY_MALAYSIA             = $01; // Malay (Malaysia)
  387.   {$EXTERNALSYM SUBLANG_MALAY_MALAYSIA}
  388.   SUBLANG_MALAY_BRUNEI_DARUSSALAM    = $02; // Malay (Brunei Darussalam)
  389.   {$EXTERNALSYM SUBLANG_MALAY_BRUNEI_DARUSSALAM}
  390.   SUBLANG_NEPALI_INDIA               = $02; // Nepali (India)
  391.   {$EXTERNALSYM SUBLANG_NEPALI_INDIA}
  392.   SUBLANG_NORWEGIAN_BOKMAL           = $01; // Norwegian (Bokmal)
  393.   {$EXTERNALSYM SUBLANG_NORWEGIAN_BOKMAL}
  394.   SUBLANG_NORWEGIAN_NYNORSK          = $02; // Norwegian (Nynorsk)
  395.   {$EXTERNALSYM SUBLANG_NORWEGIAN_NYNORSK}
  396.   SUBLANG_PORTUGUESE                 = $02; // Portuguese
  397.   {$EXTERNALSYM SUBLANG_PORTUGUESE}
  398.   SUBLANG_PORTUGUESE_BRAZILIAN       = $01; // Portuguese (Brazilian)
  399.   {$EXTERNALSYM SUBLANG_PORTUGUESE_BRAZILIAN}
  400.   SUBLANG_SERBIAN_LATIN              = $02; // Serbian (Latin)
  401.   {$EXTERNALSYM SUBLANG_SERBIAN_LATIN}
  402.   SUBLANG_SERBIAN_CYRILLIC           = $03; // Serbian (Cyrillic)
  403.   {$EXTERNALSYM SUBLANG_SERBIAN_CYRILLIC}
  404.   SUBLANG_SPANISH                    = $01; // Spanish (Castilian)
  405.   {$EXTERNALSYM SUBLANG_SPANISH}
  406.   SUBLANG_SPANISH_MEXICAN            = $02; // Spanish (Mexican)
  407.   {$EXTERNALSYM SUBLANG_SPANISH_MEXICAN}
  408.   SUBLANG_SPANISH_MODERN             = $03; // Spanish (Spain)
  409.   {$EXTERNALSYM SUBLANG_SPANISH_MODERN}
  410.   SUBLANG_SPANISH_GUATEMALA          = $04; // Spanish (Guatemala)
  411.   {$EXTERNALSYM SUBLANG_SPANISH_GUATEMALA}
  412.   SUBLANG_SPANISH_COSTA_RICA         = $05; // Spanish (Costa Rica)
  413.   {$EXTERNALSYM SUBLANG_SPANISH_COSTA_RICA}
  414.   SUBLANG_SPANISH_PANAMA             = $06; // Spanish (Panama)
  415.   {$EXTERNALSYM SUBLANG_SPANISH_PANAMA}
  416.   SUBLANG_SPANISH_DOMINICAN_REPUBLIC = $07; // Spanish (Dominican Republic)
  417.   {$EXTERNALSYM SUBLANG_SPANISH_DOMINICAN_REPUBLIC}
  418.   SUBLANG_SPANISH_VENEZUELA          = $08; // Spanish (Venezuela)
  419.   {$EXTERNALSYM SUBLANG_SPANISH_VENEZUELA}
  420.   SUBLANG_SPANISH_COLOMBIA           = $09; // Spanish (Colombia)
  421.   {$EXTERNALSYM SUBLANG_SPANISH_COLOMBIA}
  422.   SUBLANG_SPANISH_PERU               = $0a; // Spanish (Peru)
  423.   {$EXTERNALSYM SUBLANG_SPANISH_PERU}
  424.   SUBLANG_SPANISH_ARGENTINA          = $0b; // Spanish (Argentina)
  425.   {$EXTERNALSYM SUBLANG_SPANISH_ARGENTINA}
  426.   SUBLANG_SPANISH_ECUADOR            = $0c; // Spanish (Ecuador)
  427.   {$EXTERNALSYM SUBLANG_SPANISH_ECUADOR}
  428.   SUBLANG_SPANISH_CHILE              = $0d; // Spanish (Chile)
  429.   {$EXTERNALSYM SUBLANG_SPANISH_CHILE}
  430.   SUBLANG_SPANISH_URUGUAY            = $0e; // Spanish (Uruguay)
  431.   {$EXTERNALSYM SUBLANG_SPANISH_URUGUAY}
  432.   SUBLANG_SPANISH_PARAGUAY           = $0f; // Spanish (Paraguay)
  433.   {$EXTERNALSYM SUBLANG_SPANISH_PARAGUAY}
  434.   SUBLANG_SPANISH_BOLIVIA            = $10; // Spanish (Bolivia)
  435.   {$EXTERNALSYM SUBLANG_SPANISH_BOLIVIA}
  436.   SUBLANG_SPANISH_EL_SALVADOR        = $11; // Spanish (El Salvador)
  437.   {$EXTERNALSYM SUBLANG_SPANISH_EL_SALVADOR}
  438.   SUBLANG_SPANISH_HONDURAS           = $12; // Spanish (Honduras)
  439.   {$EXTERNALSYM SUBLANG_SPANISH_HONDURAS}
  440.   SUBLANG_SPANISH_NICARAGUA          = $13; // Spanish (Nicaragua)
  441.   {$EXTERNALSYM SUBLANG_SPANISH_NICARAGUA}
  442.   SUBLANG_SPANISH_PUERTO_RICO        = $14; // Spanish (Puerto Rico)
  443.   {$EXTERNALSYM SUBLANG_SPANISH_PUERTO_RICO}
  444.   SUBLANG_SWEDISH                    = $01; // Swedish
  445.   {$EXTERNALSYM SUBLANG_SWEDISH}
  446.   SUBLANG_SWEDISH_FINLAND            = $02; // Swedish (Finland)
  447.   {$EXTERNALSYM SUBLANG_SWEDISH_FINLAND}
  448.   SUBLANG_URDU_PAKISTAN              = $01; // Urdu (Pakistan)
  449.   {$EXTERNALSYM SUBLANG_URDU_PAKISTAN}
  450.   SUBLANG_URDU_INDIA                 = $02; // Urdu (India)
  451.   {$EXTERNALSYM SUBLANG_URDU_INDIA}
  452.   SUBLANG_UZBEK_LATIN                = $01; // Uzbek (Latin)
  453.   {$EXTERNALSYM SUBLANG_UZBEK_LATIN}
  454.   SUBLANG_UZBEK_CYRILLIC             = $02; // Uzbek (Cyrillic)
  455.   {$EXTERNALSYM SUBLANG_UZBEK_CYRILLIC}
  456. //
  457. //  Sorting IDs.
  458. //
  459.   SORT_DEFAULT = $0; // sorting default
  460.   {$EXTERNALSYM SORT_DEFAULT}
  461.   SORT_JAPANESE_XJIS    = $0; // Japanese XJIS order
  462.   {$EXTERNALSYM SORT_JAPANESE_XJIS}
  463.   SORT_JAPANESE_UNICODE = $1; // Japanese Unicode order
  464.   {$EXTERNALSYM SORT_JAPANESE_UNICODE}
  465.   SORT_CHINESE_BIG5     = $0; // Chinese BIG5 order
  466.   {$EXTERNALSYM SORT_CHINESE_BIG5}
  467.   SORT_CHINESE_PRCP     = $0; // PRC Chinese Phonetic order
  468.   {$EXTERNALSYM SORT_CHINESE_PRCP}
  469.   SORT_CHINESE_UNICODE  = $1; // Chinese Unicode order
  470.   {$EXTERNALSYM SORT_CHINESE_UNICODE}
  471.   SORT_CHINESE_PRC      = $2; // PRC Chinese Stroke Count order
  472.   {$EXTERNALSYM SORT_CHINESE_PRC}
  473.   SORT_CHINESE_BOPOMOFO = $3; // Traditional Chinese Bopomofo order
  474.   {$EXTERNALSYM SORT_CHINESE_BOPOMOFO}
  475.   SORT_KOREAN_KSC     = $0; // Korean KSC order
  476.   {$EXTERNALSYM SORT_KOREAN_KSC}
  477.   SORT_KOREAN_UNICODE = $1; // Korean Unicode order
  478.   {$EXTERNALSYM SORT_KOREAN_UNICODE}
  479.   SORT_GERMAN_PHONE_BOOK = $1; // German Phone Book order
  480.   {$EXTERNALSYM SORT_GERMAN_PHONE_BOOK}
  481.   SORT_HUNGARIAN_DEFAULT   = $0; // Hungarian Default order
  482.   {$EXTERNALSYM SORT_HUNGARIAN_DEFAULT}
  483.   SORT_HUNGARIAN_TECHNICAL = $1; // Hungarian Technical order
  484.   {$EXTERNALSYM SORT_HUNGARIAN_TECHNICAL}
  485.   SORT_GEORGIAN_TRADITIONAL = $0; // Georgian Traditional order
  486.   {$EXTERNALSYM SORT_GEORGIAN_TRADITIONAL}
  487.   SORT_GEORGIAN_MODERN      = $1; // Georgian Modern order
  488.   {$EXTERNALSYM SORT_GEORGIAN_MODERN}
  489. //
  490. //  A language ID is a 16 bit value which is the combination of a
  491. //  primary language ID and a secondary language ID.  The bits are
  492. //  allocated as follows:
  493. //
  494. //       +-----------------------+-------------------------+
  495. //       |     Sublanguage ID    |   Primary Language ID   |
  496. //       +-----------------------+-------------------------+
  497. //        15                   10 9                       0   bit
  498. //
  499. //
  500. //  Language ID creation/extraction macros:
  501. //
  502. //    MAKELANGID    - construct language id from a primary language id and
  503. //                    a sublanguage id.
  504. //    PRIMARYLANGID - extract primary language id from a language id.
  505. //    SUBLANGID     - extract sublanguage id from a language id.
  506. //
  507. function MAKELANGID(PrimaryLang, SubLang: USHORT): WORD;
  508. {$EXTERNALSYM MAKELANGID}
  509. function PRIMARYLANGID(LangId: WORD): WORD;
  510. {$EXTERNALSYM PRIMARYLANGID}
  511. function SUBLANGID(LangId: WORD): WORD;
  512. {$EXTERNALSYM SUBLANGID}
  513. //
  514. //  A locale ID is a 32 bit value which is the combination of a
  515. //  language ID, a sort ID, and a reserved area.  The bits are
  516. //  allocated as follows:
  517. //
  518. //       +-------------+---------+-------------------------+
  519. //       |   Reserved  | Sort ID |      Language ID        |
  520. //       +-------------+---------+-------------------------+
  521. //        31         20 19     16 15                      0   bit
  522. //
  523. //
  524. //  Locale ID creation/extraction macros:
  525. //
  526. //    MAKELCID            - construct the locale id from a language id and a sort id.
  527. //    MAKESORTLCID        - construct the locale id from a language id, sort id, and sort version.
  528. //    LANGIDFROMLCID      - extract the language id from a locale id.
  529. //    SORTIDFROMLCID      - extract the sort id from a locale id.
  530. //    SORTVERSIONFROMLCID - extract the sort version from a locale id.
  531. //
  532. const
  533.   NLS_VALID_LOCALE_MASK = $000fffff;
  534.   {$EXTERNALSYM NLS_VALID_LOCALE_MASK}
  535. function MAKELCID(LangId, SortId: WORD): DWORD;
  536. {$EXTERNALSYM MAKELCID}
  537. function MAKESORTLCID(LangId, SortId, SortVersion: WORD): DWORD;
  538. {$EXTERNALSYM MAKESORTLCID}
  539. function LANGIDFROMLCID(LocaleId: LCID): WORD;
  540. {$EXTERNALSYM LANGIDFROMLCID}
  541. function SORTIDFROMLCID(LocaleId: LCID): WORD;
  542. {$EXTERNALSYM SORTIDFROMLCID}
  543. function SORTVERSIONFROMLCID(LocaleId: LCID): WORD;
  544. {$EXTERNALSYM SORTVERSIONFROMLCID}
  545. //
  546. //  Default System and User IDs for language and locale.
  547. //
  548. function LANG_SYSTEM_DEFAULT: WORD;
  549. {$EXTERNALSYM LANG_SYSTEM_DEFAULT}
  550. function LANG_USER_DEFAULT: WORD;
  551. {$EXTERNALSYM LANG_USER_DEFAULT}
  552. function LOCALE_SYSTEM_DEFAULT: DWORD;
  553. {$EXTERNALSYM LOCALE_SYSTEM_DEFAULT}
  554. function LOCALE_USER_DEFAULT: DWORD;
  555. {$EXTERNALSYM LOCALE_USER_DEFAULT}
  556. function LOCALE_NEUTRAL: DWORD;
  557. {$EXTERNALSYM LOCALE_NEUTRAL}
  558. function LOCALE_INVARIANT: DWORD;
  559. {$EXTERNALSYM LOCALE_NEUTRAL}
  560. {$IFNDEF WIN32_NO_STATUS}
  561. const
  562.   STATUS_WAIT_0                   = DWORD($00000000);
  563.   {$EXTERNALSYM STATUS_WAIT_0}
  564.   STATUS_ABANDONED_WAIT_0         = DWORD($00000080);
  565.   {$EXTERNALSYM STATUS_ABANDONED_WAIT_0}
  566.   STATUS_USER_APC                 = DWORD($000000C0);
  567.   {$EXTERNALSYM STATUS_USER_APC}
  568.   STATUS_TIMEOUT                  = DWORD($00000102);
  569.   {$EXTERNALSYM STATUS_TIMEOUT}
  570.   STATUS_PENDING                  = DWORD($00000103);
  571.   {$EXTERNALSYM STATUS_PENDING}
  572.   DBG_EXCEPTION_HANDLED           = DWORD($00010001);
  573.   {$EXTERNALSYM DBG_EXCEPTION_HANDLED}
  574.   DBG_CONTINUE                    = DWORD($00010002);
  575.   {$EXTERNALSYM DBG_CONTINUE}
  576.   STATUS_SEGMENT_NOTIFICATION     = DWORD($40000005);
  577.   {$EXTERNALSYM STATUS_SEGMENT_NOTIFICATION}
  578.   DBG_TERMINATE_THREAD            = DWORD($40010003);
  579.   {$EXTERNALSYM DBG_TERMINATE_THREAD}
  580.   DBG_TERMINATE_PROCESS           = DWORD($40010004);
  581.   {$EXTERNALSYM DBG_TERMINATE_PROCESS}
  582.   DBG_CONTROL_C                   = DWORD($40010005);
  583.   {$EXTERNALSYM DBG_CONTROL_C}
  584.   DBG_CONTROL_BREAK               = DWORD($40010008);
  585.   {$EXTERNALSYM DBG_CONTROL_BREAK}
  586.   DBG_COMMAND_EXCEPTION           = DWORD($40010009);
  587.   {$EXTERNALSYM DBG_COMMAND_EXCEPTION}
  588.   STATUS_GUARD_PAGE_VIOLATION     = DWORD($80000001);
  589.   {$EXTERNALSYM STATUS_GUARD_PAGE_VIOLATION}
  590.   STATUS_DATATYPE_MISALIGNMENT    = DWORD($80000002);
  591.   {$EXTERNALSYM STATUS_DATATYPE_MISALIGNMENT}
  592.   STATUS_BREAKPOINT               = DWORD($80000003);
  593.   {$EXTERNALSYM STATUS_BREAKPOINT}
  594.   STATUS_SINGLE_STEP              = DWORD($80000004);
  595.   {$EXTERNALSYM STATUS_SINGLE_STEP}
  596.   DBG_EXCEPTION_NOT_HANDLED       = DWORD($80010001);
  597.   {$EXTERNALSYM DBG_EXCEPTION_NOT_HANDLED}
  598.   STATUS_ACCESS_VIOLATION         = DWORD($C0000005);
  599.   {$EXTERNALSYM STATUS_ACCESS_VIOLATION}
  600.   STATUS_IN_PAGE_ERROR            = DWORD($C0000006);
  601.   {$EXTERNALSYM STATUS_IN_PAGE_ERROR}
  602.   STATUS_INVALID_HANDLE           = DWORD($C0000008);
  603.   {$EXTERNALSYM STATUS_INVALID_HANDLE}
  604.   STATUS_NO_MEMORY                = DWORD($C0000017);
  605.   {$EXTERNALSYM STATUS_NO_MEMORY}
  606.   STATUS_ILLEGAL_INSTRUCTION      = DWORD($C000001D);
  607.   {$EXTERNALSYM STATUS_ILLEGAL_INSTRUCTION}
  608.   STATUS_NONCONTINUABLE_EXCEPTION = DWORD($C0000025);
  609.   {$EXTERNALSYM STATUS_NONCONTINUABLE_EXCEPTION}
  610.   STATUS_INVALID_DISPOSITION      = DWORD($C0000026);
  611.   {$EXTERNALSYM STATUS_INVALID_DISPOSITION}
  612.   STATUS_ARRAY_BOUNDS_EXCEEDED    = DWORD($C000008C);
  613.   {$EXTERNALSYM STATUS_ARRAY_BOUNDS_EXCEEDED}
  614.   STATUS_FLOAT_DENORMAL_OPERAND   = DWORD($C000008D);
  615.   {$EXTERNALSYM STATUS_FLOAT_DENORMAL_OPERAND}
  616.   STATUS_FLOAT_DIVIDE_BY_ZERO     = DWORD($C000008E);
  617.   {$EXTERNALSYM STATUS_FLOAT_DIVIDE_BY_ZERO}
  618.   STATUS_FLOAT_INEXACT_RESULT     = DWORD($C000008F);
  619.   {$EXTERNALSYM STATUS_FLOAT_INEXACT_RESULT}
  620.   STATUS_FLOAT_INVALID_OPERATION  = DWORD($C0000090);
  621.   {$EXTERNALSYM STATUS_FLOAT_INVALID_OPERATION}
  622.   STATUS_FLOAT_OVERFLOW           = DWORD($C0000091);
  623.   {$EXTERNALSYM STATUS_FLOAT_OVERFLOW}
  624.   STATUS_FLOAT_STACK_CHECK        = DWORD($C0000092);
  625.   {$EXTERNALSYM STATUS_FLOAT_STACK_CHECK}
  626.   STATUS_FLOAT_UNDERFLOW          = DWORD($C0000093);
  627.   {$EXTERNALSYM STATUS_FLOAT_UNDERFLOW}
  628.   STATUS_INTEGER_DIVIDE_BY_ZERO   = DWORD($C0000094);
  629.   {$EXTERNALSYM STATUS_INTEGER_DIVIDE_BY_ZERO}
  630.   STATUS_INTEGER_OVERFLOW         = DWORD($C0000095);
  631.   {$EXTERNALSYM STATUS_INTEGER_OVERFLOW}
  632.   STATUS_PRIVILEGED_INSTRUCTION   = DWORD($C0000096);
  633.   {$EXTERNALSYM STATUS_PRIVILEGED_INSTRUCTION}
  634.   STATUS_STACK_OVERFLOW           = DWORD($C00000FD);
  635.   {$EXTERNALSYM STATUS_STACK_OVERFLOW}
  636.   STATUS_CONTROL_C_EXIT           = DWORD($C000013A);
  637.   {$EXTERNALSYM STATUS_CONTROL_C_EXIT}
  638.   STATUS_FLOAT_MULTIPLE_FAULTS    = DWORD($C00002B4);
  639.   {$EXTERNALSYM STATUS_FLOAT_MULTIPLE_FAULTS}
  640.   STATUS_FLOAT_MULTIPLE_TRAPS     = DWORD($C00002B5);
  641.   {$EXTERNALSYM STATUS_FLOAT_MULTIPLE_TRAPS}
  642.   STATUS_REG_NAT_CONSUMPTION      = DWORD($C00002C9);
  643.   {$EXTERNALSYM STATUS_REG_NAT_CONSUMPTION}
  644.   STATUS_SXS_EARLY_DEACTIVATION   = DWORD($C015000F);
  645.   {$EXTERNALSYM STATUS_SXS_EARLY_DEACTIVATION}
  646.   STATUS_SXS_INVALID_DEACTIVATION = DWORD($C0150010);
  647.   {$EXTERNALSYM STATUS_SXS_INVALID_DEACTIVATION}
  648. {$ENDIF}
  649. const
  650.   MAXIMUM_WAIT_OBJECTS  = 64;      // Maximum number of wait objects
  651.   {$EXTERNALSYM MAXIMUM_WAIT_OBJECTS}
  652.   MAXIMUM_SUSPEND_COUNT = MAXCHAR; // Maximum times thread can be suspended
  653.   {$EXTERNALSYM MAXIMUM_SUSPEND_COUNT}
  654. type
  655.   KSPIN_LOCK = ULONG_PTR;
  656.   {$EXTERNALSYM KSPIN_LOCK}
  657.   PKSPIN_LOCK = ^KSPIN_LOCK;
  658.   {$EXTERNALSYM PKSPIN_LOCK}
  659. //
  660. // Define functions to get the address of the current fiber and the
  661. // current fiber data.
  662. //
  663. //
  664. // Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver
  665. // writers to not leave them inadvertantly in their code.
  666. //
  667. function GetFiberData: PVOID;
  668. {$EXTERNALSYM GetFiberData}
  669. function GetCurrentFiber: PVOID;
  670. {$EXTERNALSYM GetCurrentFiber}
  671. //
  672. //  Define the size of the 80387 save area, which is in the context frame.
  673. //
  674. const
  675.   SIZE_OF_80387_REGISTERS = 80;
  676.   {$EXTERNALSYM SIZE_OF_80387_REGISTERS}
  677. //
  678. // The following flags control the contents of the CONTEXT structure.
  679. //
  680. const
  681.   CONTEXT_i386 = $00010000; // this assumes that i386 and
  682.   {$EXTERNALSYM CONTEXT_i386}
  683.   CONTEXT_i486 = $00010000; // i486 have identical context records
  684.   {$EXTERNALSYM CONTEXT_i486}
  685. const
  686.   CONTEXT_CONTROL            = (CONTEXT_i386 or $00000001); // SS:SP, CS:IP, FLAGS, BP
  687.   {$EXTERNALSYM CONTEXT_CONTROL}
  688.   CONTEXT_INTEGER            = (CONTEXT_i386 or $00000002); // AX, BX, CX, DX, SI, DI
  689.   {$EXTERNALSYM CONTEXT_INTEGER}
  690.   CONTEXT_SEGMENTS           = (CONTEXT_i386 or $00000004); // DS, ES, FS, GS
  691.   {$EXTERNALSYM CONTEXT_SEGMENTS}
  692.   CONTEXT_FLOATING_POINT     = (CONTEXT_i386 or $00000008); // 387 state
  693.   {$EXTERNALSYM CONTEXT_FLOATING_POINT}
  694.   CONTEXT_DEBUG_REGISTERS    = (CONTEXT_i386 or $00000010); // DB 0-3,6,7
  695.   {$EXTERNALSYM CONTEXT_DEBUG_REGISTERS}
  696.   CONTEXT_EXTENDED_REGISTERS = (CONTEXT_i386 or $00000020); // cpu specific extensions
  697.   {$EXTERNALSYM CONTEXT_EXTENDED_REGISTERS}
  698.   CONTEXT_FULL = (CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_SEGMENTS);
  699.   {$EXTERNALSYM CONTEXT_FULL}
  700.   CONTEXT_ALL = (CONTEXT_CONTROL or CONTEXT_INTEGER or CONTEXT_SEGMENTS or CONTEXT_FLOATING_POINT or CONTEXT_DEBUG_REGISTERS);
  701.   {$EXTERNALSYM CONTEXT_ALL}
  702. //
  703. // Define initial MxCsr control.
  704. //
  705.   INITIAL_MXCSR = $1f80;            // initial MXCSR value
  706.   {$EXTERNALSYM INITIAL_MXCSR}
  707.   MAXIMUM_SUPPORTED_EXTENSION = 512;
  708.   {$EXTERNALSYM MAXIMUM_SUPPORTED_EXTENSION}
  709. type
  710.   PFLOATING_SAVE_AREA = ^FLOATING_SAVE_AREA;
  711.   {$EXTERNALSYM PFLOATING_SAVE_AREA}
  712.   _FLOATING_SAVE_AREA = record
  713.     ControlWord: DWORD;
  714.     StatusWord: DWORD;
  715.     TagWord: DWORD;
  716.     ErrorOffset: DWORD;
  717.     ErrorSelector: DWORD;
  718.     DataOffset: DWORD;
  719.     DataSelector: DWORD;
  720.     RegisterArea: array [0..SIZE_OF_80387_REGISTERS - 1] of BYTE;
  721.     Cr0NpxState: DWORD;
  722.   end;
  723.   {$EXTERNALSYM _FLOATING_SAVE_AREA}
  724.   FLOATING_SAVE_AREA = _FLOATING_SAVE_AREA;
  725.   {$EXTERNALSYM FLOATING_SAVE_AREA}
  726.   TFloatingSaveArea = FLOATING_SAVE_AREA;
  727.   PFloatingSaveArea = PFLOATING_SAVE_AREA;
  728. //
  729. // Context Frame
  730. //
  731. //  This frame has a several purposes: 1) it is used as an argument to
  732. //  NtContinue, 2) is is used to constuct a call frame for APC delivery,
  733. //  and 3) it is used in the user level thread creation routines.
  734. //
  735. //  The layout of the record conforms to a standard call frame.
  736. //
  737. type
  738.   PContext = ^CONTEXT;
  739.   _CONTEXT  = record
  740.     //
  741.     // The flags values within this flag control the contents of
  742.     // a CONTEXT record.
  743.     //
  744.     // If the context record is used as an input parameter, then
  745.     // for each portion of the context record controlled by a flag
  746.     // whose value is set, it is assumed that that portion of the
  747.     // context record contains valid context. If the context record
  748.     // is being used to modify a threads context, then only that
  749.     // portion of the threads context will be modified.
  750.     //
  751.     // If the context record is used as an IN OUT parameter to capture
  752.     // the context of a thread, then only those portions of the thread's
  753.     // context corresponding to set flags will be returned.
  754.     //
  755.     // The context record is never used as an OUT only parameter.
  756.     //
  757.     ContextFlags: DWORD;
  758.     //
  759.     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  760.     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
  761.     // included in CONTEXT_FULL.
  762.     //
  763.     Dr0: DWORD;
  764.     Dr1: DWORD;
  765.     Dr2: DWORD;
  766.     Dr3: DWORD;
  767.     Dr6: DWORD;
  768.     Dr7: DWORD;
  769.     //
  770.     // This section is specified/returned if the
  771.     // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  772.     //
  773.     FloatSave: FLOATING_SAVE_AREA;
  774.     //
  775.     // This section is specified/returned if the
  776.     // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  777.     //
  778.     SegGs: DWORD;
  779.     SegFs: DWORD;
  780.     SegEs: DWORD;
  781.     SegDs: DWORD;
  782.     //
  783.     // This section is specified/returned if the
  784.     // ContextFlags word contians the flag CONTEXT_INTEGER.
  785.     //
  786.     Edi: DWORD;
  787.     Esi: DWORD;
  788.     Ebx: DWORD;
  789.     Edx: DWORD;
  790.     Ecx: DWORD;
  791.     Eax: DWORD;
  792.     //
  793.     // This section is specified/returned if the
  794.     // ContextFlags word contians the flag CONTEXT_CONTROL.
  795.     //
  796.     Ebp: DWORD;
  797.     Eip: DWORD;
  798.     SegCs: DWORD;              // MUST BE SANITIZED
  799.     EFlags: DWORD;             // MUST BE SANITIZED
  800.     Esp: DWORD;
  801.     SegSs: DWORD;
  802.     //
  803.     // This section is specified/returned if the ContextFlags word
  804.     // contains the flag CONTEXT_EXTENDED_REGISTERS.
  805.     // The format and contexts are processor specific
  806.     //
  807.     ExtendedRegisters: array [0..MAXIMUM_SUPPORTED_EXTENSION - 1] of BYTE;
  808.   end;
  809.   {$EXTERNALSYM _CONTEXT}
  810.   CONTEXT = _CONTEXT;
  811.   {$EXTERNALSYM CONTEXT}
  812.   TContext = CONTEXT;
  813. const
  814.   LDTENTRY_FLAGS1_TYPE        = $1F;
  815.   LDTENTRY_FLAGS1_DPL         = $60;
  816.   LDTENTRY_FLAGS1_PRES        = $80;
  817.   LDTENTRY_FLAGS2_LIMITHI     = $0F;
  818.   LDTENTRY_FLAGS2_SYS         = $10;
  819.   LDTENTRY_FLAGS2_RESERVED_0  = $20;
  820.   LDTENTRY_FLAGS2_DEFAULT_BIG = $40;
  821.   LDTENTRY_FLAGS2_GRANULARITY = $80;
  822. type
  823.   PLDT_ENTRY = ^LDT_ENTRY;
  824.   {$EXTERNALSYM PLDT_ENTRY}
  825.   _LDT_ENTRY = record
  826.     LimitLow: WORD;
  827.     BaseLow: WORD;
  828.     BaseMid: BYTE;
  829.     Flags1: BYTE;     // Declare as bytes to avoid alignment
  830.     Flags2: BYTE;     // Problems.
  831.     BaseHi: BYTE;
  832.   end;
  833.   {$EXTERNALSYM _LDT_ENTRY}
  834.   LDT_ENTRY = _LDT_ENTRY;
  835.   {$EXTERNALSYM LDT_ENTRY}
  836.   TLdtEntry = LDT_ENTRY;
  837.   PLdtEntry = PLDT_ENTRY;
  838. // Please contact INTEL to get IA64-specific information
  839. const
  840.   EXCEPTION_NONCONTINUABLE     = $1; // Noncontinuable exception
  841.   {$EXTERNALSYM EXCEPTION_NONCONTINUABLE}
  842.   EXCEPTION_MAXIMUM_PARAMETERS = 15; // maximum number of exception parameters
  843.   {$EXTERNALSYM EXCEPTION_MAXIMUM_PARAMETERS}
  844. //
  845. // Exception record definition.
  846. //
  847. type
  848.   PEXCEPTION_RECORD = ^EXCEPTION_RECORD;
  849.   {$EXTERNALSYM PEXCEPTION_RECORD}
  850.   _EXCEPTION_RECORD = record
  851.     ExceptionCode: DWORD;
  852.     ExceptionFlags: DWORD;
  853.     ExceptionRecord: PEXCEPTION_RECORD;
  854.     ExceptionAddress: Pointer;
  855.     NumberParameters: DWORD;
  856.     ExceptionInformation: array [0..EXCEPTION_MAXIMUM_PARAMETERS - 1] of ULONG_PTR;
  857.   end;
  858.   {$EXTERNALSYM _EXCEPTION_RECORD}
  859.   EXCEPTION_RECORD = _EXCEPTION_RECORD;
  860.   {$EXTERNALSYM EXCEPTION_RECORD}
  861.   TExceptionRecord = EXCEPTION_RECORD;
  862.   PExceptionRecord = PEXCEPTION_RECORD;
  863.   PEXCEPTION_RECORD32 = ^EXCEPTION_RECORD32;
  864.   {$EXTERNALSYM PEXCEPTION_RECORD32}
  865.   _EXCEPTION_RECORD32 = record
  866.     ExceptionCode: DWORD;
  867.     ExceptionFlags: DWORD;
  868.     ExceptionRecord: DWORD;
  869.     ExceptionAddress: DWORD;
  870.     NumberParameters: DWORD;
  871.     ExceptionInformation: array [0..EXCEPTION_MAXIMUM_PARAMETERS - 1] of DWORD;
  872.   end;
  873.   {$EXTERNALSYM _EXCEPTION_RECORD32}
  874.   EXCEPTION_RECORD32 = _EXCEPTION_RECORD32;
  875.   {$EXTERNALSYM EXCEPTION_RECORD32}
  876.   TExceptionRecord32 = EXCEPTION_RECORD32;
  877.   PExceptionRecord32 = PEXCEPTION_RECORD32;
  878.   PEXCEPTION_RECORD64 = ^EXCEPTION_RECORD64;
  879.   {$EXTERNALSYM PEXCEPTION_RECORD64}
  880.   _EXCEPTION_RECORD64 = record
  881.     ExceptionCode: DWORD;
  882.     ExceptionFlags: DWORD;
  883.     ExceptionRecord: DWORD64;
  884.     ExceptionAddress: DWORD64;
  885.     NumberParameters: DWORD;
  886.     __unusedAlignment: DWORD;
  887.     ExceptionInformation: array [0..EXCEPTION_MAXIMUM_PARAMETERS - 1] of DWORD64;
  888.   end;
  889.   {$EXTERNALSYM _EXCEPTION_RECORD64}
  890.   EXCEPTION_RECORD64 = _EXCEPTION_RECORD64;
  891.   {$EXTERNALSYM EXCEPTION_RECORD64}
  892.   TExceptionRecord64 = EXCEPTION_RECORD64;
  893.   PExceptionRecord64 = PEXCEPTION_RECORD64;
  894. //
  895. // Typedef for pointer returned by exception_info()
  896. //
  897.   PEXCEPTION_POINTERS = ^EXCEPTION_POINTERS;
  898.   {$EXTERNALSYM PEXCEPTION_POINTERS}
  899.   _EXCEPTION_POINTERS = record
  900.     ExceptionRecord: PEXCEPTION_RECORD;
  901.     ContextRecord: PCONTEXT;
  902.   end;
  903.   {$EXTERNALSYM _EXCEPTION_POINTERS}
  904.   EXCEPTION_POINTERS = _EXCEPTION_POINTERS;
  905.   {$EXTERNALSYM EXCEPTION_POINTERS}
  906.   TExceptionPointers = EXCEPTION_POINTERS;
  907.   PExceptionPointers = ^TExceptionPointers;
  908.   PACCESS_TOKEN = Pointer;
  909.   {$EXTERNALSYM PACCESS_TOKEN}
  910. ////////////////////////////////////////////////////////////////////////
  911. //                                                                    //
  912. //                             ACCESS MASK                            //
  913. //                                                                    //
  914. ////////////////////////////////////////////////////////////////////////
  915. //
  916. //  Define the access mask as a longword sized structure divided up as
  917. //  follows:
  918. //
  919. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  920. //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  921. //      +---------------+---------------+-------------------------------+
  922. //      |G|G|G|G|Res'd|A| StandardRights|         SpecificRights        |
  923. //      |R|W|E|A|     |S|               |                               |
  924. //      +-+-------------+---------------+-------------------------------+
  925. //
  926. //      typedef struct _ACCESS_MASK {
  927. //          WORD   SpecificRights;
  928. //          BYTE  StandardRights;
  929. //          BYTE  AccessSystemAcl : 1;
  930. //          BYTE  Reserved : 3;
  931. //          BYTE  GenericAll : 1;
  932. //          BYTE  GenericExecute : 1;
  933. //          BYTE  GenericWrite : 1;
  934. //          BYTE  GenericRead : 1;
  935. //      } ACCESS_MASK;
  936. //      typedef ACCESS_MASK *PACCESS_MASK;
  937. //
  938. //  but to make life simple for programmer's we'll allow them to specify
  939. //  a desired access mask by simply OR'ing together mulitple single rights
  940. //  and treat an access mask as a DWORD.  For example
  941. //
  942. //      DesiredAccess = DELETE | READ_CONTROL
  943. //
  944. //  So we'll declare ACCESS_MASK as DWORD
  945. //
  946. type
  947.   ACCESS_MASK = DWORD;
  948.   {$EXTERNALSYM ACCESS_MASK}
  949.   PACCESS_MASK = ^ACCESS_MASK;
  950.   {$EXTERNALSYM PACCESS_MASK}
  951.   TAccessMask = ACCESS_MASK;
  952.   PAccessMask = PACCESS_MASK;  
  953. ////////////////////////////////////////////////////////////////////////
  954. //                                                                    //
  955. //                             ACCESS TYPES                           //
  956. //                                                                    //
  957. ////////////////////////////////////////////////////////////////////////
  958. //
  959. //  The following are masks for the predefined standard access types
  960. //
  961. const
  962.   DELETE                   = ($00010000);
  963.   {$EXTERNALSYM DELETE}
  964.   READ_CONTROL             = ($00020000);
  965.   {$EXTERNALSYM READ_CONTROL}
  966.   WRITE_DAC                = ($00040000);
  967.   {$EXTERNALSYM WRITE_DAC}
  968.   WRITE_OWNER              = ($00080000);
  969.   {$EXTERNALSYM WRITE_OWNER}
  970.   SYNCHRONIZE              = ($00100000);
  971.   {$EXTERNALSYM SYNCHRONIZE}
  972.   STANDARD_RIGHTS_REQUIRED = ($000F0000);
  973.   {$EXTERNALSYM STANDARD_RIGHTS_REQUIRED}
  974.   STANDARD_RIGHTS_READ     = (READ_CONTROL);
  975.   {$EXTERNALSYM STANDARD_RIGHTS_READ}
  976.   STANDARD_RIGHTS_WRITE    = (READ_CONTROL);
  977.   {$EXTERNALSYM STANDARD_RIGHTS_WRITE}
  978.   STANDARD_RIGHTS_EXECUTE  = (READ_CONTROL);
  979.   {$EXTERNALSYM STANDARD_RIGHTS_EXECUTE}
  980.   STANDARD_RIGHTS_ALL      = ($001F0000);
  981.   {$EXTERNALSYM STANDARD_RIGHTS_ALL}
  982.   SPECIFIC_RIGHTS_ALL      = ($0000FFFF);
  983.   {$EXTERNALSYM SPECIFIC_RIGHTS_ALL}
  984. //
  985. // AccessSystemAcl access type
  986. //
  987.   ACCESS_SYSTEM_SECURITY = ($01000000);
  988.   {$EXTERNALSYM ACCESS_SYSTEM_SECURITY}
  989. //
  990. // MaximumAllowed access type
  991. //
  992.   MAXIMUM_ALLOWED = ($02000000);
  993.   {$EXTERNALSYM MAXIMUM_ALLOWED}
  994. //
  995. //  These are the generic rights.
  996. //
  997.   GENERIC_READ    = DWORD($80000000);
  998.   {$EXTERNALSYM GENERIC_READ}
  999.   GENERIC_WRITE   = ($40000000);
  1000.   {$EXTERNALSYM GENERIC_WRITE}
  1001.   GENERIC_EXECUTE = ($20000000);
  1002.   {$EXTERNALSYM GENERIC_EXECUTE}
  1003.   GENERIC_ALL     = ($10000000);
  1004.   {$EXTERNALSYM GENERIC_ALL}
  1005. //
  1006. //  Define the generic mapping array.  This is used to denote the
  1007. //  mapping of each generic access right to a specific access mask.
  1008. //
  1009. type
  1010.   PGENERIC_MAPPING = ^GENERIC_MAPPING;
  1011.   {$EXTERNALSYM PGENERIC_MAPPING}
  1012.   _GENERIC_MAPPING = record
  1013.     GenericRead: ACCESS_MASK;
  1014.     GenericWrite: ACCESS_MASK;
  1015.     GenericExecute: ACCESS_MASK;
  1016.     GenericAll: ACCESS_MASK;
  1017.   end;
  1018.   {$EXTERNALSYM _GENERIC_MAPPING}
  1019.   GENERIC_MAPPING = _GENERIC_MAPPING;
  1020.   {$EXTERNALSYM GENERIC_MAPPING}
  1021.   TGenericMapping = GENERIC_MAPPING;
  1022.   PGenericMapping = PGENERIC_MAPPING;
  1023. ////////////////////////////////////////////////////////////////////////
  1024. //                                                                    //
  1025. //                        LUID_AND_ATTRIBUTES                         //
  1026. //                                                                    //
  1027. ////////////////////////////////////////////////////////////////////////
  1028. //
  1029. //
  1030. //#include <pshpack4.h>
  1031.   PLUID_AND_ATTRIBUTES = ^LUID_AND_ATTRIBUTES;
  1032.   {$EXTERNALSYM PLUID_AND_ATTRIBUTES}
  1033.   _LUID_AND_ATTRIBUTES = record
  1034.     Luid: LUID;
  1035.     Attributes: DWORD;
  1036.   end;
  1037.   {$EXTERNALSYM _LUID_AND_ATTRIBUTES}
  1038.   LUID_AND_ATTRIBUTES = _LUID_AND_ATTRIBUTES;
  1039.   {$EXTERNALSYM LUID_AND_ATTRIBUTES}
  1040.   TLuidAndAttributes = LUID_AND_ATTRIBUTES;
  1041.   PLuidAndAttributes = PLUID_AND_ATTRIBUTES;
  1042.   LUID_AND_ATTRIBUTES_ARRAY = array [0..ANYSIZE_ARRAY - 1] of LUID_AND_ATTRIBUTES;
  1043.   {$EXTERNALSYM LUID_AND_ATTRIBUTES_ARRAY}
  1044.   PLUID_AND_ATTRIBUTES_ARRAY = ^LUID_AND_ATTRIBUTES_ARRAY;
  1045.   {$EXTERNALSYM PLUID_AND_ATTRIBUTES_ARRAY}
  1046.   TLuidAndAttributesArray = LUID_AND_ATTRIBUTES_ARRAY;
  1047.   PLuidAndAttributesArray = ^TLuidAndAttributesArray;
  1048. //#include <poppack.h>
  1049. ////////////////////////////////////////////////////////////////////////
  1050. //                                                                    //
  1051. //              Security Id     (SID)                                 //
  1052. //                                                                    //
  1053. ////////////////////////////////////////////////////////////////////////
  1054. //
  1055. //
  1056. // Pictorially the structure of an SID is as follows:
  1057. //
  1058. //         1   1   1   1   1   1
  1059. //         5   4   3   2   1   0   9   8   7   6   5   4   3   2   1   0
  1060. //      +---------------------------------------------------------------+
  1061. //      |      SubAuthorityCount        |Reserved1 (SBZ)|   Revision    |
  1062. //      +---------------------------------------------------------------+
  1063. //      |                   IdentifierAuthority[0]                      |
  1064. //      +---------------------------------------------------------------+
  1065. //      |                   IdentifierAuthority[1]                      |
  1066. //      +---------------------------------------------------------------+
  1067. //      |                   IdentifierAuthority[2]                      |
  1068. //      +---------------------------------------------------------------+
  1069. //      |                                                               |
  1070. //      +- -  -  -  -  -  -  -  SubAuthority[]  -  -  -  -  -  -  -  - -+
  1071. //      |                                                               |
  1072. //      +---------------------------------------------------------------+
  1073. //
  1074. //
  1075. type
  1076.   PSID_IDENTIFIER_AUTHORITY = ^SID_IDENTIFIER_AUTHORITY;
  1077.   {$EXTERNALSYM PSID_IDENTIFIER_AUTHORITY}
  1078.   _SID_IDENTIFIER_AUTHORITY = record
  1079.     Value: array [0..5] of Byte;
  1080.   end;
  1081.   {$EXTERNALSYM _SID_IDENTIFIER_AUTHORITY}
  1082.   SID_IDENTIFIER_AUTHORITY = _SID_IDENTIFIER_AUTHORITY;
  1083.   {$EXTERNALSYM SID_IDENTIFIER_AUTHORITY}
  1084.   TSidIdentifierAuthority = SID_IDENTIFIER_AUTHORITY;
  1085.   PSidIdentifierAuthority = PSID_IDENTIFIER_AUTHORITY;
  1086.   PSid = ^SID;
  1087.   _SID = record
  1088.     Revision: Byte;
  1089.     SubAuthorityCount: Byte;
  1090.     IdentifierAuthority: SID_IDENTIFIER_AUTHORITY;
  1091.     SubAuthority: array [0..ANYSIZE_ARRAY - 1] of DWORD;
  1092.   end;
  1093.   {$EXTERNALSYM _SID}
  1094.   SID = _SID;
  1095.   {$EXTERNALSYM SID}
  1096.   PPSID = ^PSID;
  1097.   {$NODEFINE PPSID}
  1098.   TSid = SID;
  1099. const
  1100.   SID_REVISION                    = (1); // Current revision level
  1101.   {$EXTERNALSYM SID_REVISION}
  1102.   SID_MAX_SUB_AUTHORITIES         = (15);
  1103.   {$EXTERNALSYM SID_MAX_SUB_AUTHORITIES}
  1104.   SID_RECOMMENDED_SUB_AUTHORITIES = (1); // Will change to around 6 in a future release.
  1105.   {$EXTERNALSYM SID_RECOMMENDED_SUB_AUTHORITIES}
  1106.   SECURITY_MAX_SID_SIZE = SizeOf(SID) - SizeOf(DWORD) + (SID_MAX_SUB_AUTHORITIES * SizeOf(DWORD));
  1107.   {$EXTERNALSYM SECURITY_MAX_SID_SIZE}
  1108.   SidTypeUser           = 1;
  1109.   {$EXTERNALSYM SidTypeUser}
  1110.   SidTypeGroup          = 2;
  1111.   {$EXTERNALSYM SidTypeGroup}
  1112.   SidTypeDomain         = 3;
  1113.   {$EXTERNALSYM SidTypeDomain}
  1114.   SidTypeAlias          = 4;
  1115.   {$EXTERNALSYM SidTypeAlias}
  1116.   SidTypeWellKnownGroup = 5;
  1117.   {$EXTERNALSYM SidTypeWellKnownGroup}
  1118.   SidTypeDeletedAccount = 6;
  1119.   {$EXTERNALSYM SidTypeDeletedAccount}
  1120.   SidTypeInvalid        = 7;
  1121.   {$EXTERNALSYM SidTypeInvalid}
  1122.   SidTypeUnknown        = 8;
  1123.   {$EXTERNALSYM SidTypeUnknown}
  1124.   SidTypeComputer       = 9;
  1125.   {$EXTERNALSYM SidTypeComputer}
  1126. type
  1127.   _SID_NAME_USE = DWORD;
  1128.   {$EXTERNALSYM _SID_NAME_USE}
  1129.   SID_NAME_USE = _SID_NAME_USE;
  1130.   {$EXTERNALSYM SID_NAME_USE}
  1131.   PSID_NAME_USE = ^SID_NAME_USE;
  1132.   {$EXTERNALSYM PSID_NAME_USE}
  1133.   TSidNameUse = SID_NAME_USE;
  1134.   PSidNameUSe = PSID_NAME_USE;
  1135.   PSID_AND_ATTRIBUTES = ^SID_AND_ATTRIBUTES;
  1136.   {$EXTERNALSYM PSID_AND_ATTRIBUTES}
  1137.   _SID_AND_ATTRIBUTES = record
  1138.     Sid: PSID;
  1139.     Attributes: DWORD;
  1140.   end;
  1141.   {$EXTERNALSYM _SID_AND_ATTRIBUTES}
  1142.   SID_AND_ATTRIBUTES = _SID_AND_ATTRIBUTES;
  1143.   {$EXTERNALSYM SID_AND_ATTRIBUTES}
  1144.   TSidAndAttributes = SID_AND_ATTRIBUTES;
  1145.   PSidAndAttributes = PSID_AND_ATTRIBUTES;
  1146.   SID_AND_ATTRIBUTES_ARRAY = array [0..ANYSIZE_ARRAY - 1] of SID_AND_ATTRIBUTES;
  1147.   {$EXTERNALSYM SID_AND_ATTRIBUTES_ARRAY}
  1148.   PSID_AND_ATTRIBUTES_ARRAY = ^SID_AND_ATTRIBUTES_ARRAY;
  1149.   {$EXTERNALSYM PSID_AND_ATTRIBUTES_ARRAY}
  1150.   PSidAndAttributesArray = ^TSidAndAttributesArray;
  1151.   TSidAndAttributesArray = SID_AND_ATTRIBUTES_ARRAY;
  1152. /////////////////////////////////////////////////////////////////////////////
  1153. //                                                                         //
  1154. // Universal well-known SIDs                                               //
  1155. //                                                                         //
  1156. //     Null SID                     S-1-0-0                                //
  1157. //     World                        S-1-1-0                                //
  1158. //     Local                        S-1-2-0                                //
  1159. //     Creator Owner ID             S-1-3-0                                //
  1160. //     Creator Group ID             S-1-3-1                                //
  1161. //     Creator Owner Server ID      S-1-3-2                                //
  1162. //     Creator Group Server ID      S-1-3-3                                //
  1163. //                                                                         //
  1164. //     (Non-unique IDs)             S-1-4                                  //
  1165. //                                                                         //
  1166. /////////////////////////////////////////////////////////////////////////////
  1167. const
  1168.   SECURITY_NULL_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 0));
  1169.   {$EXTERNALSYM SECURITY_NULL_SID_AUTHORITY}
  1170.   SECURITY_WORLD_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 1));
  1171.   {$EXTERNALSYM SECURITY_WORLD_SID_AUTHORITY}
  1172.   SECURITY_LOCAL_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 2));
  1173.   {$EXTERNALSYM SECURITY_LOCAL_SID_AUTHORITY}
  1174.   SECURITY_CREATOR_SID_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 3));
  1175.   {$EXTERNALSYM SECURITY_CREATOR_SID_AUTHORITY}
  1176.   SECURITY_NON_UNIQUE_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 4));
  1177.   {$EXTERNALSYM SECURITY_NON_UNIQUE_AUTHORITY}
  1178.   SECURITY_RESOURCE_MANAGER_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 9));
  1179.   {$EXTERNALSYM SECURITY_RESOURCE_MANAGER_AUTHORITY}
  1180.   SECURITY_NULL_RID                 = ($00000000);
  1181.   {$EXTERNALSYM SECURITY_NULL_RID}
  1182.   SECURITY_WORLD_RID                = ($00000000);
  1183.   {$EXTERNALSYM SECURITY_WORLD_RID}
  1184.   SECURITY_LOCAL_RID                = ($00000000);
  1185.   {$EXTERNALSYM SECURITY_LOCAL_RID}
  1186.   SECURITY_CREATOR_OWNER_RID        = ($00000000);
  1187.   {$EXTERNALSYM SECURITY_CREATOR_OWNER_RID}
  1188.   SECURITY_CREATOR_GROUP_RID        = ($00000001);
  1189.   {$EXTERNALSYM SECURITY_CREATOR_GROUP_RID}
  1190.   SECURITY_CREATOR_OWNER_SERVER_RID = ($00000002);
  1191.   {$EXTERNALSYM SECURITY_CREATOR_OWNER_SERVER_RID}
  1192.   SECURITY_CREATOR_GROUP_SERVER_RID = ($00000003);
  1193.   {$EXTERNALSYM SECURITY_CREATOR_GROUP_SERVER_RID}
  1194. /////////////////////////////////////////////////////////////////////////////
  1195. //                                                                         //
  1196. // NT well-known SIDs                                                        //
  1197. //                                                                           //
  1198. //     NT Authority            S-1-5                                         //
  1199. //     Dialup                  S-1-5-1                                       //
  1200. //                                                                           //
  1201. //     Network                 S-1-5-2                                       //
  1202. //     Batch                   S-1-5-3                                       //
  1203. //     Interactive             S-1-5-4                                       //
  1204. //     (Logon IDs)             S-1-5-5-X-Y                                   //
  1205. //     Service                 S-1-5-6                                       //
  1206. //     AnonymousLogon          S-1-5-7       (aka null logon session)        //
  1207. //     Proxy                   S-1-5-8                                       //
  1208. //     Enterprise DC (EDC)     S-1-5-9       (aka domain controller account) //
  1209. //     Self                    S-1-5-10      (self RID)                      //
  1210. //     Authenticated User      S-1-5-11      (Authenticated user somewhere)  //
  1211. //     Restricted Code         S-1-5-12      (Running restricted code)       //
  1212. //     Terminal Server         S-1-5-13      (Running on Terminal Server)    //
  1213. //     Remote Logon            S-1-5-14      (Remote Interactive Logon)      //
  1214. //     This Organization       S-1-5-15                                      //
  1215. //                                                                           //
  1216. //     Local System            S-1-5-18                                      //
  1217. //     Local Service           S-1-5-19                                      //
  1218. //     Network Service         S-1-5-20                                      //
  1219. //                                                                           //
  1220. //     (NT non-unique IDs)     S-1-5-0x15-... (NT Domain Sids)               //
  1221. //                                                                           //
  1222. //     (Built-in domain)       S-1-5-0x20                                    //
  1223. //                                                                           //
  1224. //     (Security Package IDs)  S-1-5-0x40                                    //
  1225. //     NTLM Authentication     S-1-5-0x40-10                                 //
  1226. //     SChannel Authentication S-1-5-0x40-14                                 //
  1227. //     Digest Authentication   S-1-5-0x40-21                                 //
  1228. //                                                                           //
  1229. //     Other Organization      S-1-5-1000    (>=1000 can not be filtered)    //
  1230. //                                                                           //
  1231. //                                                                           //
  1232. // NOTE: the relative identifier values (RIDs) determine which security      //
  1233. //       boundaries the SID is allowed to cross.  Before adding new RIDs,    //
  1234. //       a determination needs to be made regarding which range they should  //
  1235. //       be added to in order to ensure proper "SID filtering"               //
  1236. //                                                                         //
  1237. /////////////////////////////////////////////////////////////////////////////
  1238. const
  1239.   SECURITY_NT_AUTHORITY: TSidIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5));
  1240.   {$EXTERNALSYM SECURITY_NT_AUTHORITY}
  1241.   SECURITY_DIALUP_RID                 = ($00000001);
  1242.   {$EXTERNALSYM SECURITY_DIALUP_RID}
  1243.   SECURITY_NETWORK_RID                = ($00000002);
  1244.   {$EXTERNALSYM SECURITY_NETWORK_RID}
  1245.   SECURITY_BATCH_RID                  = ($00000003);
  1246.   {$EXTERNALSYM SECURITY_BATCH_RID}
  1247.   SECURITY_INTERACTIVE_RID            = ($00000004);
  1248.   {$EXTERNALSYM SECURITY_INTERACTIVE_RID}
  1249.   SECURITY_LOGON_IDS_RID              = ($00000005);
  1250.   {$EXTERNALSYM SECURITY_LOGON_IDS_RID}
  1251.   SECURITY_LOGON_IDS_RID_COUNT        = (3);
  1252.   {$EXTERNALSYM SECURITY_LOGON_IDS_RID_COUNT}
  1253.   SECURITY_SERVICE_RID                = ($00000006);
  1254.   {$EXTERNALSYM SECURITY_SERVICE_RID}
  1255.   SECURITY_ANONYMOUS_LOGON_RID        = ($00000007);
  1256.   {$EXTERNALSYM SECURITY_ANONYMOUS_LOGON_RID}
  1257.   SECURITY_PROXY_RID                  = ($00000008);
  1258.   {$EXTERNALSYM SECURITY_PROXY_RID}
  1259.   SECURITY_ENTERPRISE_CONTROLLERS_RID = ($00000009);
  1260.   {$EXTERNALSYM SECURITY_ENTERPRISE_CONTROLLERS_RID}
  1261.   SECURITY_SERVER_LOGON_RID           = SECURITY_ENTERPRISE_CONTROLLERS_RID;
  1262.   {$EXTERNALSYM SECURITY_SERVER_LOGON_RID}
  1263.   SECURITY_PRINCIPAL_SELF_RID         = ($0000000A);
  1264.   {$EXTERNALSYM SECURITY_PRINCIPAL_SELF_RID}
  1265.   SECURITY_AUTHENTICATED_USER_RID     = ($0000000B);
  1266.   {$EXTERNALSYM SECURITY_AUTHENTICATED_USER_RID}
  1267.   SECURITY_RESTRICTED_CODE_RID        = ($0000000C);
  1268.   {$EXTERNALSYM SECURITY_RESTRICTED_CODE_RID}
  1269.   SECURITY_TERMINAL_SERVER_RID        = ($0000000D);
  1270.   {$EXTERNALSYM SECURITY_TERMINAL_SERVER_RID}
  1271.   SECURITY_REMOTE_LOGON_RID           = ($0000000E);
  1272.   {$EXTERNALSYM SECURITY_REMOTE_LOGON_RID}
  1273.   SECURITY_THIS_ORGANIZATION_RID      = ($0000000F);
  1274.   {$EXTERNALSYM SECURITY_THIS_ORGANIZATION_RID}
  1275.   SECURITY_LOCAL_SYSTEM_RID    = ($00000012);
  1276.   {$EXTERNALSYM SECURITY_LOCAL_SYSTEM_RID}
  1277.   SECURITY_LOCAL_SERVICE_RID   = ($00000013);
  1278.   {$EXTERNALSYM SECURITY_LOCAL_SERVICE_RID}
  1279.   SECURITY_NETWORK_SERVICE_RID = ($00000014);
  1280.   {$EXTERNALSYM SECURITY_NETWORK_SERVICE_RID}
  1281.   SECURITY_NT_NON_UNIQUE       = ($00000015);
  1282.   {$EXTERNALSYM SECURITY_NT_NON_UNIQUE}
  1283.   SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT = (3);
  1284.   {$EXTERNALSYM SECURITY_NT_NON_UNIQUE_SUB_AUTH_COUNT}
  1285.   SECURITY_BUILTIN_DOMAIN_RID  = ($00000020);
  1286.   {$EXTERNALSYM SECURITY_BUILTIN_DOMAIN_RID}
  1287.   SECURITY_PACKAGE_BASE_RID       = ($00000040);
  1288.   {$EXTERNALSYM SECURITY_PACKAGE_BASE_RID}
  1289.   SECURITY_PACKAGE_RID_COUNT      = (2);
  1290.   {$EXTERNALSYM SECURITY_PACKAGE_RID_COUNT}
  1291.   SECURITY_PACKAGE_NTLM_RID       = ($0000000A);
  1292.   {$EXTERNALSYM SECURITY_PACKAGE_NTLM_RID}
  1293.   SECURITY_PACKAGE_SCHANNEL_RID   = ($0000000E);
  1294.   {$EXTERNALSYM SECURITY_PACKAGE_SCHANNEL_RID}
  1295.   SECURITY_PACKAGE_DIGEST_RID     = ($00000015);
  1296.   {$EXTERNALSYM SECURITY_PACKAGE_DIGEST_RID}
  1297.   SECURITY_MAX_ALWAYS_FILTERED    = ($000003E7);
  1298.   {$EXTERNALSYM SECURITY_MAX_ALWAYS_FILTERED}
  1299.   SECURITY_MIN_NEVER_FILTERED     = ($000003E8);
  1300.   {$EXTERNALSYM SECURITY_MIN_NEVER_FILTERED}
  1301.   SECURITY_OTHER_ORGANIZATION_RID = ($000003E8);
  1302.   {$EXTERNALSYM SECURITY_OTHER_ORGANIZATION_RID}
  1303. /////////////////////////////////////////////////////////////////////////////
  1304. //                                                                         //
  1305. // well-known domain relative sub-authority values (RIDs)...               //
  1306. //                                                                         //
  1307. /////////////////////////////////////////////////////////////////////////////
  1308. // Well-known users ...
  1309.   FOREST_USER_RID_MAX    = ($000001F3);
  1310.   {$EXTERNALSYM FOREST_USER_RID_MAX}
  1311.   DOMAIN_USER_RID_ADMIN  = ($000001F4);
  1312.   {$EXTERNALSYM DOMAIN_USER_RID_ADMIN}
  1313.   DOMAIN_USER_RID_GUEST  = ($000001F5);
  1314.   {$EXTERNALSYM DOMAIN_USER_RID_GUEST}
  1315.   DOMAIN_USER_RID_KRBTGT = ($000001F6);
  1316.   {$EXTERNALSYM DOMAIN_USER_RID_KRBTGT}
  1317.   DOMAIN_USER_RID_MAX    = ($000003E7);
  1318.   {$EXTERNALSYM DOMAIN_USER_RID_MAX}
  1319. // well-known groups ...
  1320.   DOMAIN_GROUP_RID_ADMINS            = ($00000200);
  1321.   {$EXTERNALSYM DOMAIN_GROUP_RID_ADMINS}
  1322.   DOMAIN_GROUP_RID_USERS             = ($00000201);
  1323.   {$EXTERNALSYM DOMAIN_GROUP_RID_USERS}
  1324.   DOMAIN_GROUP_RID_GUESTS            = ($00000202);
  1325.   {$EXTERNALSYM DOMAIN_GROUP_RID_GUESTS}
  1326.   DOMAIN_GROUP_RID_COMPUTERS         = ($00000203);
  1327.   {$EXTERNALSYM DOMAIN_GROUP_RID_COMPUTERS}
  1328.   DOMAIN_GROUP_RID_CONTROLLERS       = ($00000204);
  1329.   {$EXTERNALSYM DOMAIN_GROUP_RID_CONTROLLERS}
  1330.   DOMAIN_GROUP_RID_CERT_ADMINS       = ($00000205);
  1331.   {$EXTERNALSYM DOMAIN_GROUP_RID_CERT_ADMINS}
  1332.   DOMAIN_GROUP_RID_SCHEMA_ADMINS     = ($00000206);
  1333.   {$EXTERNALSYM DOMAIN_GROUP_RID_SCHEMA_ADMINS}
  1334.   DOMAIN_GROUP_RID_ENTERPRISE_ADMINS = ($00000207);
  1335.   {$EXTERNALSYM DOMAIN_GROUP_RID_ENTERPRISE_ADMINS}
  1336.   DOMAIN_GROUP_RID_POLICY_ADMINS     = ($00000208);
  1337.   {$EXTERNALSYM DOMAIN_GROUP_RID_POLICY_ADMINS}
  1338. // well-known aliases ...
  1339.   DOMAIN_ALIAS_RID_ADMINS           = ($00000220);
  1340.   {$EXTERNALSYM DOMAIN_ALIAS_RID_ADMINS}
  1341.   DOMAIN_ALIAS_RID_USERS            = ($00000221);
  1342.   {$EXTERNALSYM DOMAIN_ALIAS_RID_USERS}
  1343.   DOMAIN_ALIAS_RID_GUESTS           = ($00000222);
  1344.   {$EXTERNALSYM DOMAIN_ALIAS_RID_GUESTS}
  1345.   DOMAIN_ALIAS_RID_POWER_USERS      = ($00000223);
  1346.   {$EXTERNALSYM DOMAIN_ALIAS_RID_POWER_USERS}
  1347.   DOMAIN_ALIAS_RID_ACCOUNT_OPS      = ($00000224);
  1348.   {$EXTERNALSYM DOMAIN_ALIAS_RID_ACCOUNT_OPS}
  1349.   DOMAIN_ALIAS_RID_SYSTEM_OPS       = ($00000225);
  1350.   {$EXTERNALSYM DOMAIN_ALIAS_RID_SYSTEM_OPS}
  1351.   DOMAIN_ALIAS_RID_PRINT_OPS        = ($00000226);
  1352.   {$EXTERNALSYM DOMAIN_ALIAS_RID_PRINT_OPS}
  1353.   DOMAIN_ALIAS_RID_BACKUP_OPS       = ($00000227);
  1354.   {$EXTERNALSYM DOMAIN_ALIAS_RID_BACKUP_OPS}
  1355.   DOMAIN_ALIAS_RID_REPLICATOR       = ($00000228);
  1356.   {$EXTERNALSYM DOMAIN_ALIAS_RID_REPLICATOR}
  1357.   DOMAIN_ALIAS_RID_RAS_SERVERS      = ($00000229);
  1358.   {$EXTERNALSYM DOMAIN_ALIAS_RID_RAS_SERVERS}
  1359.   DOMAIN_ALIAS_RID_PREW2KCOMPACCESS = ($0000022A);
  1360.   {$EXTERNALSYM DOMAIN_ALIAS_RID_PREW2KCOMPACCESS}
  1361.   DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS = ($0000022B);
  1362.   {$EXTERNALSYM DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS}
  1363.   DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS = ($0000022C);
  1364.   {$EXTERNALSYM DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS}
  1365.   DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS = ($0000022D);
  1366.   {$EXTERNALSYM DOMAIN_ALIAS_RID_INCOMING_FOREST_TRUST_BUILDERS}
  1367.   DOMAIN_ALIAS_RID_MONITORING_USERS      = ($0000022E);
  1368.   {$EXTERNALSYM DOMAIN_ALIAS_RID_MONITORING_USERS}
  1369.   DOMAIN_ALIAS_RID_LOGGING_USERS         = ($0000022F);
  1370.   {$EXTERNALSYM DOMAIN_ALIAS_RID_LOGGING_USERS}
  1371. type
  1372.   WELL_KNOWN_SID_TYPE = (
  1373.     WinNullSid,
  1374.     WinWorldSid,
  1375.     WinLocalSid,
  1376.     WinCreatorOwnerSid,
  1377.     WinCreatorGroupSid,
  1378.     WinCreatorOwnerServerSid,
  1379.     WinCreatorGroupServerSid,
  1380.     WinNtAuthoritySid,
  1381.     WinDialupSid,
  1382.     WinNetworkSid,
  1383.     WinBatchSid,
  1384.     WinInteractiveSid,
  1385.     WinServiceSid,
  1386.     WinAnonymousSid,
  1387.     WinProxySid,
  1388.     WinEnterpriseControllersSid,
  1389.     WinSelfSid,
  1390.     WinAuthenticatedUserSid,
  1391.     WinRestrictedCodeSid,
  1392.     WinTerminalServerSid,
  1393.     WinRemoteLogonIdSid,
  1394.     WinLogonIdsSid,
  1395.     WinLocalSystemSid,
  1396.     WinLocalServiceSid,
  1397.     WinNetworkServiceSid,
  1398.     WinBuiltinDomainSid,
  1399.     WinBuiltinAdministratorsSid,
  1400.     WinBuiltinUsersSid,
  1401.     WinBuiltinGuestsSid,
  1402.     WinBuiltinPowerUsersSid,
  1403.     WinBuiltinAccountOperatorsSid,
  1404.     WinBuiltinSystemOperatorsSid,
  1405.     WinBuiltinPrintOperatorsSid,
  1406.     WinBuiltinBackupOperatorsSid,
  1407.     WinBuiltinReplicatorSid,
  1408.     WinBuiltinPreWindows2000CompatibleAccessSid,
  1409.     WinBuiltinRemoteDesktopUsersSid,
  1410.     WinBuiltinNetworkConfigurationOperatorsSid,
  1411.     WinAccountAdministratorSid,
  1412.     WinAccountGuestSid,
  1413.     WinAccountKrbtgtSid,
  1414.     WinAccountDomainAdminsSid,
  1415.     WinAccountDomainUsersSid,
  1416.     WinAccountDomainGuestsSid,
  1417.     WinAccountComputersSid,
  1418.     WinAccountControllersSid,
  1419.     WinAccountCertAdminsSid,
  1420.     WinAccountSchemaAdminsSid,
  1421.     WinAccountEnterpriseAdminsSid,
  1422.     WinAccountPolicyAdminsSid,
  1423.     WinAccountRasAndIasServersSid,
  1424.     WinNTLMAuthenticationSid,
  1425.     WinDigestAuthenticationSid,
  1426.     WinSChannelAuthenticationSid,
  1427.     WinThisOrganizationSid,
  1428.     WinOtherOrganizationSid,
  1429.     WinBuiltinIncomingForestTrustBuildersSid,
  1430.     WinBuiltinPerfMonitoringUsersSid,
  1431.     WinBuiltinPerfLoggingUsersSid);
  1432.   {$EXTERNALSYM WELL_KNOWN_SID_TYPE}
  1433.   TWellKnownSidType = WELL_KNOWN_SID_TYPE;
  1434. //
  1435. // Allocate the System Luid.  The first 1000 LUIDs are reserved.
  1436. // Use #999 here (0x3E7 = 999)
  1437. //
  1438. const
  1439.   SYSTEM_LUID: LUID = (LowPart: $3E7; HighPart: $0);
  1440.   {$EXTERNALSYM SYSTEM_LUID}
  1441.   ANONYMOUS_LOGON_LUID: LUID = (LowPart: $3E6; HighPart: $0);
  1442.   {$EXTERNALSYM ANONYMOUS_LOGON_LUID}
  1443.   LOCALSERVICE_LUID: LUID = (LowPart: $3E5; HighPart: $0);
  1444.   {$EXTERNALSYM LOCALSERVICE_LUID}
  1445.   NETWORKSERVICE_LUID: LUID = (LowPart: $3E4; HighPart: $0);
  1446.   {$EXTERNALSYM NETWORKSERVICE_LUID}
  1447. ////////////////////////////////////////////////////////////////////////
  1448. //                                                                    //
  1449. //                          User and Group related SID attributes     //
  1450. //                                                                    //
  1451. ////////////////////////////////////////////////////////////////////////
  1452. //
  1453. // Group attributes
  1454. //
  1455.   SE_GROUP_MANDATORY          = ($00000001);
  1456.   {$EXTERNALSYM SE_GROUP_MANDATORY}
  1457.   SE_GROUP_ENABLED_BY_DEFAULT = ($00000002);
  1458.   {$EXTERNALSYM SE_GROUP_ENABLED_BY_DEFAULT}
  1459.   SE_GROUP_ENABLED            = ($00000004);
  1460.   {$EXTERNALSYM SE_GROUP_ENABLED}
  1461.   SE_GROUP_OWNER              = ($00000008);
  1462.   {$EXTERNALSYM SE_GROUP_OWNER}
  1463.   SE_GROUP_USE_FOR_DENY_ONLY  = ($00000010);
  1464.   {$EXTERNALSYM SE_GROUP_USE_FOR_DENY_ONLY}
  1465.   SE_GROUP_LOGON_ID           = ($C0000000);
  1466.   {$EXTERNALSYM SE_GROUP_LOGON_ID}
  1467.   SE_GROUP_RESOURCE           = ($20000000);
  1468.   {$EXTERNALSYM SE_GROUP_RESOURCE}
  1469. //
  1470. // User attributes
  1471. //
  1472. // (None yet defined.)
  1473. ////////////////////////////////////////////////////////////////////////
  1474. //                                                                    //
  1475. //                         ACL  and  ACE                              //
  1476. //                                                                    //
  1477. ////////////////////////////////////////////////////////////////////////
  1478. //
  1479. //  Define an ACL and the ACE format.  The structure of an ACL header
  1480. //  followed by one or more ACEs.  Pictorally the structure of an ACL header
  1481. //  is as follows:
  1482. //
  1483. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  1484. //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  1485. //      +-------------------------------+---------------+---------------+
  1486. //      |            AclSize            |      Sbz1     |  AclRevision  |
  1487. //      +-------------------------------+---------------+---------------+
  1488. //      |              Sbz2             |           AceCount            |
  1489. //      +-------------------------------+-------------------------------+
  1490. //
  1491. //  The current AclRevision is defined to be ACL_REVISION.
  1492. //
  1493. //  AclSize is the size, in bytes, allocated for the ACL.  This includes
  1494. //  the ACL header, ACES, and remaining free space in the buffer.
  1495. //
  1496. //  AceCount is the number of ACES in the ACL.
  1497. //
  1498. // This is the *current* ACL revision
  1499.   ACL_REVISION    = (2);
  1500.   {$EXTERNALSYM ACL_REVISION}
  1501.   ACL_REVISION_DS = (4);
  1502.   {$EXTERNALSYM ACL_REVISION_DS}
  1503. // This is the history of ACL revisions.  Add a new one whenever
  1504. // ACL_REVISION is updated
  1505.   ACL_REVISION1    = (1);
  1506.   {$EXTERNALSYM ACL_REVISION1}
  1507.   ACL_REVISION2    = (2);
  1508.   {$EXTERNALSYM ACL_REVISION2}
  1509.   MIN_ACL_REVISION = ACL_REVISION2;
  1510.   {$EXTERNALSYM MIN_ACL_REVISION}
  1511.   ACL_REVISION3    = (3);
  1512.   {$EXTERNALSYM ACL_REVISION3}
  1513.   ACL_REVISION4    = (4);
  1514.   {$EXTERNALSYM ACL_REVISION4}
  1515.   MAX_ACL_REVISION = ACL_REVISION4;
  1516.   {$EXTERNALSYM MAX_ACL_REVISION}
  1517. type
  1518.   PACL = ^ACL;
  1519.   {$EXTERNALSYM PACL}
  1520.   _ACL = record
  1521.     AclRevision: Byte;
  1522.     Sbz1: Byte;
  1523.     AclSize: Word;
  1524.     AceCount: Word;
  1525.     Sbz2: Word;
  1526.   end;
  1527.   {$EXTERNALSYM _ACL}
  1528.   ACL = _ACL;
  1529.   {$EXTERNALSYM ACL}
  1530.   TAcl = ACL;
  1531.   PPACL = ^PAcl;
  1532.   {$NODEFINE PPACL}
  1533. //
  1534. //  The structure of an ACE is a common ace header followed by ace type
  1535. //  specific data.  Pictorally the structure of the common ace header is
  1536. //  as follows:
  1537. //
  1538. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  1539. //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  1540. //      +---------------+-------+-------+---------------+---------------+
  1541. //      |            AceSize            |    AceFlags   |     AceType   |
  1542. //      +---------------+-------+-------+---------------+---------------+
  1543. //
  1544. //  AceType denotes the type of the ace, there are some predefined ace
  1545. //  types
  1546. //
  1547. //  AceSize is the size, in bytes, of ace.
  1548. //
  1549. //  AceFlags are the Ace flags for audit and inheritance, defined shortly.
  1550. type
  1551.   PACE_HEADER = ^ACE_HEADER;
  1552.   {$EXTERNALSYM PACE_HEADER}
  1553.   _ACE_HEADER = record
  1554.     AceType: Byte;
  1555.     AceFlags: Byte;
  1556.     AceSize: Word;
  1557.   end;
  1558.   {$EXTERNALSYM _ACE_HEADER}
  1559.   ACE_HEADER = _ACE_HEADER;
  1560.   {$EXTERNALSYM ACE_HEADER}
  1561.   TAceHeader = ACE_HEADER;
  1562.   PAceHeader = PACE_HEADER;
  1563. //
  1564. //  The following are the predefined ace types that go into the AceType
  1565. //  field of an Ace header.
  1566. //
  1567. const
  1568.   ACCESS_MIN_MS_ACE_TYPE    = ($0);
  1569.   {$EXTERNALSYM ACCESS_MIN_MS_ACE_TYPE}
  1570.   ACCESS_ALLOWED_ACE_TYPE   = ($0);
  1571.   {$EXTERNALSYM ACCESS_ALLOWED_ACE_TYPE}
  1572.   ACCESS_DENIED_ACE_TYPE    = ($1);
  1573.   {$EXTERNALSYM ACCESS_DENIED_ACE_TYPE}
  1574.   SYSTEM_AUDIT_ACE_TYPE     = ($2);
  1575.   {$EXTERNALSYM SYSTEM_AUDIT_ACE_TYPE}
  1576.   SYSTEM_ALARM_ACE_TYPE     = ($3);
  1577.   {$EXTERNALSYM SYSTEM_ALARM_ACE_TYPE}
  1578.   ACCESS_MAX_MS_V2_ACE_TYPE = ($3);
  1579.   {$EXTERNALSYM ACCESS_MAX_MS_V2_ACE_TYPE}
  1580.   ACCESS_ALLOWED_COMPOUND_ACE_TYPE = ($4);
  1581.   {$EXTERNALSYM ACCESS_ALLOWED_COMPOUND_ACE_TYPE}
  1582.   ACCESS_MAX_MS_V3_ACE_TYPE        = ($4);
  1583.   {$EXTERNALSYM ACCESS_MAX_MS_V3_ACE_TYPE}
  1584.   ACCESS_MIN_MS_OBJECT_ACE_TYPE  = ($5);
  1585.   {$EXTERNALSYM ACCESS_MIN_MS_OBJECT_ACE_TYPE}
  1586.   ACCESS_ALLOWED_OBJECT_ACE_TYPE = ($5);
  1587.   {$EXTERNALSYM ACCESS_ALLOWED_OBJECT_ACE_TYPE}
  1588.   ACCESS_DENIED_OBJECT_ACE_TYPE  = ($6);
  1589.   {$EXTERNALSYM ACCESS_DENIED_OBJECT_ACE_TYPE}
  1590.   SYSTEM_AUDIT_OBJECT_ACE_TYPE   = ($7);
  1591.   {$EXTERNALSYM SYSTEM_AUDIT_OBJECT_ACE_TYPE}
  1592.   SYSTEM_ALARM_OBJECT_ACE_TYPE   = ($8);
  1593.   {$EXTERNALSYM SYSTEM_ALARM_OBJECT_ACE_TYPE}
  1594.   ACCESS_MAX_MS_OBJECT_ACE_TYPE  = ($8);
  1595.   {$EXTERNALSYM ACCESS_MAX_MS_OBJECT_ACE_TYPE}
  1596.   ACCESS_MAX_MS_V4_ACE_TYPE = ($8);
  1597.   {$EXTERNALSYM ACCESS_MAX_MS_V4_ACE_TYPE}
  1598.   ACCESS_MAX_MS_ACE_TYPE    = ($8);
  1599.   {$EXTERNALSYM ACCESS_MAX_MS_ACE_TYPE}
  1600.   ACCESS_ALLOWED_CALLBACK_ACE_TYPE        = $9;
  1601.   {$EXTERNALSYM ACCESS_ALLOWED_CALLBACK_ACE_TYPE}
  1602.   ACCESS_DENIED_CALLBACK_ACE_TYPE         = $A;
  1603.   {$EXTERNALSYM ACCESS_DENIED_CALLBACK_ACE_TYPE}
  1604.   ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE = $B;
  1605.   {$EXTERNALSYM ACCESS_ALLOWED_CALLBACK_OBJECT_ACE_TYPE}
  1606.   ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE  = $C;
  1607.   {$EXTERNALSYM ACCESS_DENIED_CALLBACK_OBJECT_ACE_TYPE}
  1608.   SYSTEM_AUDIT_CALLBACK_ACE_TYPE          = $D;
  1609.   {$EXTERNALSYM SYSTEM_AUDIT_CALLBACK_ACE_TYPE}
  1610.   SYSTEM_ALARM_CALLBACK_ACE_TYPE          = $E;
  1611.   {$EXTERNALSYM SYSTEM_ALARM_CALLBACK_ACE_TYPE}
  1612.   SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE   = $F;
  1613.   {$EXTERNALSYM SYSTEM_AUDIT_CALLBACK_OBJECT_ACE_TYPE}
  1614.   SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE   = $10;
  1615.   {$EXTERNALSYM SYSTEM_ALARM_CALLBACK_OBJECT_ACE_TYPE}
  1616.   ACCESS_MAX_MS_V5_ACE_TYPE               = $10;
  1617.   {$EXTERNALSYM ACCESS_MAX_MS_V5_ACE_TYPE}
  1618. //
  1619. //  The following are the inherit flags that go into the AceFlags field
  1620. //  of an Ace header.
  1621. //
  1622.   OBJECT_INHERIT_ACE       = ($1);
  1623.   {$EXTERNALSYM OBJECT_INHERIT_ACE}
  1624.   CONTAINER_INHERIT_ACE    = ($2);
  1625.   {$EXTERNALSYM CONTAINER_INHERIT_ACE}
  1626.   NO_PROPAGATE_INHERIT_ACE = ($4);
  1627.   {$EXTERNALSYM NO_PROPAGATE_INHERIT_ACE}
  1628.   INHERIT_ONLY_ACE         = ($8);
  1629.   {$EXTERNALSYM INHERIT_ONLY_ACE}
  1630.   INHERITED_ACE            = ($10);
  1631.   {$EXTERNALSYM INHERITED_ACE}
  1632.   VALID_INHERIT_FLAGS      = ($1F);
  1633.   {$EXTERNALSYM VALID_INHERIT_FLAGS}
  1634. //  The following are the currently defined ACE flags that go into the
  1635. //  AceFlags field of an ACE header.  Each ACE type has its own set of
  1636. //  AceFlags.
  1637. //
  1638. //  SUCCESSFUL_ACCESS_ACE_FLAG - used only with system audit and alarm ACE
  1639. //  types to indicate that a message is generated for successful accesses.
  1640. //
  1641. //  FAILED_ACCESS_ACE_FLAG - used only with system audit and alarm ACE types
  1642. //  to indicate that a message is generated for failed accesses.
  1643. //
  1644. //
  1645. //  SYSTEM_AUDIT and SYSTEM_ALARM AceFlags
  1646. //
  1647. //  These control the signaling of audit and alarms for success or failure.
  1648. //
  1649.   SUCCESSFUL_ACCESS_ACE_FLAG = ($40);
  1650.   {$EXTERNALSYM SUCCESSFUL_ACCESS_ACE_FLAG}
  1651.   FAILED_ACCESS_ACE_FLAG     = ($80);
  1652.   {$EXTERNALSYM FAILED_ACCESS_ACE_FLAG}
  1653. //
  1654. //  We'll define the structure of the predefined ACE types.  Pictorally
  1655. //  the structure of the predefined ACE's is as follows:
  1656. //
  1657. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  1658. //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  1659. //      +---------------+-------+-------+---------------+---------------+
  1660. //      |    AceFlags   | Resd  |Inherit|    AceSize    |     AceType   |
  1661. //      +---------------+-------+-------+---------------+---------------+
  1662. //      |                              Mask                             |
  1663. //      +---------------------------------------------------------------+
  1664. //      |                                                               |
  1665. //      +                                                               +
  1666. //      |                                                               |
  1667. //      +                              Sid                              +
  1668. //      |                                                               |
  1669. //      +                                                               +
  1670. //      |                                                               |
  1671. //      +---------------------------------------------------------------+
  1672. //
  1673. //  Mask is the access mask associated with the ACE.  This is either the
  1674. //  access allowed, access denied, audit, or alarm mask.
  1675. //
  1676. //  Sid is the Sid associated with the ACE.
  1677. //
  1678. //  The following are the four predefined ACE types.
  1679. //  Examine the AceType field in the Header to determine
  1680. //  which structure is appropriate to use for casting.
  1681. type
  1682.   PACCESS_ALLOWED_ACE = ^ACCESS_ALLOWED_ACE;
  1683.   {$EXTERNALSYM PACCESS_ALLOWED_ACE}
  1684.   _ACCESS_ALLOWED_ACE = record
  1685.     Header: ACE_HEADER;
  1686.     Mask: ACCESS_MASK;
  1687.     SidStart: DWORD;
  1688.   end;
  1689.   {$EXTERNALSYM _ACCESS_ALLOWED_ACE}
  1690.   ACCESS_ALLOWED_ACE = _ACCESS_ALLOWED_ACE;
  1691.   {$EXTERNALSYM ACCESS_ALLOWED_ACE}
  1692.   TAccessAllowedAce = ACCESS_ALLOWED_ACE;
  1693.   PAccessAllowedAce = PACCESS_ALLOWED_ACE;
  1694.   PACCESS_DENIED_ACE = ^ACCESS_DENIED_ACE;
  1695.   {$EXTERNALSYM PACCESS_DENIED_ACE}
  1696.   _ACCESS_DENIED_ACE = record
  1697.     Header: ACE_HEADER;
  1698.     Mask: ACCESS_MASK;
  1699.     SidStart: DWORD;
  1700.   end;
  1701.   {$EXTERNALSYM _ACCESS_DENIED_ACE}
  1702.   ACCESS_DENIED_ACE = _ACCESS_DENIED_ACE;
  1703.   {$EXTERNALSYM ACCESS_DENIED_ACE}
  1704.   TAccessDeniedAce = ACCESS_DENIED_ACE;
  1705.   PAccessDeniedAce = PACCESS_DENIED_ACE;
  1706.   PSYSTEM_AUDIT_ACE = ^SYSTEM_AUDIT_ACE;
  1707.   {$EXTERNALSYM PSYSTEM_AUDIT_ACE}
  1708.   _SYSTEM_AUDIT_ACE = record
  1709.     Header: ACE_HEADER;
  1710.     Mask: ACCESS_MASK;
  1711.     SidStart: DWORD;
  1712.   end;
  1713.   {$EXTERNALSYM _SYSTEM_AUDIT_ACE}
  1714.   SYSTEM_AUDIT_ACE = _SYSTEM_AUDIT_ACE;
  1715.   {$EXTERNALSYM SYSTEM_AUDIT_ACE}
  1716.   TSystemAuditAce = SYSTEM_AUDIT_ACE;
  1717.   PSystemAuditAce = PSYSTEM_AUDIT_ACE;
  1718.   PSYSTEM_ALARM_ACE = ^SYSTEM_ALARM_ACE;
  1719.   {$EXTERNALSYM PSYSTEM_ALARM_ACE}
  1720.   _SYSTEM_ALARM_ACE = record
  1721.     Header: ACE_HEADER;
  1722.     Mask: ACCESS_MASK;
  1723.     SidStart: DWORD;
  1724.   end;
  1725.   {$EXTERNALSYM _SYSTEM_ALARM_ACE}
  1726.   SYSTEM_ALARM_ACE = _SYSTEM_ALARM_ACE;
  1727.   {$EXTERNALSYM SYSTEM_ALARM_ACE}
  1728.   TSystemAlarmAce = SYSTEM_ALARM_ACE;
  1729.   PSystemAlarmAce = PSYSTEM_ALARM_ACE;
  1730.   PACCESS_ALLOWED_OBJECT_ACE = ^ACCESS_ALLOWED_OBJECT_ACE;
  1731.   {$EXTERNALSYM PACCESS_ALLOWED_OBJECT_ACE}
  1732.   _ACCESS_ALLOWED_OBJECT_ACE = record
  1733.     Header: ACE_HEADER;
  1734.     Mask: ACCESS_MASK;
  1735.     Flags: DWORD;
  1736.     ObjectType: GUID;
  1737.     InheritedObjectType: GUID;
  1738.     SidStart: DWORD;
  1739.   end;
  1740.   {$EXTERNALSYM _ACCESS_ALLOWED_OBJECT_ACE}
  1741.   ACCESS_ALLOWED_OBJECT_ACE = _ACCESS_ALLOWED_OBJECT_ACE;
  1742.   {$EXTERNALSYM ACCESS_ALLOWED_OBJECT_ACE}
  1743.   TAccessAllowedObjectAce = ACCESS_ALLOWED_OBJECT_ACE;
  1744.   PAccessAllowedObjectAce = PACCESS_ALLOWED_OBJECT_ACE;
  1745.   PACCESS_DENIED_OBJECT_ACE = ^ACCESS_DENIED_OBJECT_ACE;
  1746.   {$EXTERNALSYM PACCESS_DENIED_OBJECT_ACE}
  1747.   _ACCESS_DENIED_OBJECT_ACE = record
  1748.     Header: ACE_HEADER;
  1749.     Mask: ACCESS_MASK;
  1750.     Flags: DWORD;
  1751.     ObjectType: GUID;
  1752.     InheritedObjectType: GUID;
  1753.     SidStart: DWORD;
  1754.   end;
  1755.   {$EXTERNALSYM _ACCESS_DENIED_OBJECT_ACE}
  1756.   ACCESS_DENIED_OBJECT_ACE = _ACCESS_DENIED_OBJECT_ACE;
  1757.   {$EXTERNALSYM ACCESS_DENIED_OBJECT_ACE}
  1758.   TAccessDeniedObjectAce = ACCESS_DENIED_OBJECT_ACE;
  1759.   PAccessDeniedObjectAce = PACCESS_DENIED_OBJECT_ACE;
  1760.   PSYSTEM_AUDIT_OBJECT_ACE = ^SYSTEM_AUDIT_OBJECT_ACE;
  1761.   {$EXTERNALSYM PSYSTEM_AUDIT_OBJECT_ACE}
  1762.   _SYSTEM_AUDIT_OBJECT_ACE = record
  1763.     Header: ACE_HEADER;
  1764.     Mask: ACCESS_MASK;
  1765.     Flags: DWORD;
  1766.     ObjectType: GUID;
  1767.     InheritedObjectType: GUID;
  1768.     SidStart: DWORD;
  1769.   end;
  1770.   {$EXTERNALSYM _SYSTEM_AUDIT_OBJECT_ACE}
  1771.   SYSTEM_AUDIT_OBJECT_ACE = _SYSTEM_AUDIT_OBJECT_ACE;
  1772.   {$EXTERNALSYM SYSTEM_AUDIT_OBJECT_ACE}
  1773.   TSystemAuditObjectAce = SYSTEM_AUDIT_OBJECT_ACE;
  1774.   PSystemAuditObjectAce = PSYSTEM_AUDIT_OBJECT_ACE;
  1775.   PSYSTEM_ALARM_OBJECT_ACE = ^SYSTEM_ALARM_OBJECT_ACE;
  1776.   {$EXTERNALSYM PSYSTEM_ALARM_OBJECT_ACE}
  1777.   _SYSTEM_ALARM_OBJECT_ACE = record
  1778.     Header: ACE_HEADER;
  1779.     Mask: ACCESS_MASK;
  1780.     Flags: DWORD;
  1781.     ObjectType: GUID;
  1782.     InheritedObjectType: GUID;
  1783.     SidStart: DWORD;
  1784.   end;
  1785.   {$EXTERNALSYM _SYSTEM_ALARM_OBJECT_ACE}
  1786.   SYSTEM_ALARM_OBJECT_ACE = _SYSTEM_ALARM_OBJECT_ACE;
  1787.   {$EXTERNALSYM SYSTEM_ALARM_OBJECT_ACE}
  1788.   TSystemAlarmObjectAce = SYSTEM_ALARM_OBJECT_ACE;
  1789.   PSystemAlarmObjectAce = PSYSTEM_ALARM_OBJECT_ACE;
  1790. //
  1791. // Callback ace support in post Win2000.
  1792. // Resource managers can put their own data after Sidstart + Length of the sid
  1793. //
  1794.   _ACCESS_ALLOWED_CALLBACK_ACE = record
  1795.     Header: ACE_HEADER;
  1796.     Mask: ACCESS_MASK;
  1797.     SidStart: DWORD;
  1798.     // Opaque resouce manager specific data
  1799.   end;
  1800.   {$EXTERNALSYM _ACCESS_ALLOWED_CALLBACK_ACE}
  1801.   ACCESS_ALLOWED_CALLBACK_ACE = _ACCESS_ALLOWED_CALLBACK_ACE;
  1802.   {$EXTERNALSYM ACCESS_ALLOWED_CALLBACK_ACE}
  1803.   PACCESS_ALLOWED_CALLBACK_ACE = ^ACCESS_ALLOWED_CALLBACK_ACE;
  1804.   {$EXTERNALSYM PACCESS_ALLOWED_CALLBACK_ACE}
  1805.   TAccessAllowedCallBackAce = ACCESS_ALLOWED_CALLBACK_ACE;
  1806.   PAccessAllowedCallBackAce = PACCESS_ALLOWED_CALLBACK_ACE;  
  1807.   _ACCESS_DENIED_CALLBACK_ACE = record
  1808.     Header: ACE_HEADER;
  1809.     Mask: ACCESS_MASK;
  1810.     SidStart: DWORD;
  1811.     // Opaque resouce manager specific data
  1812.   end;
  1813.   {$EXTERNALSYM _ACCESS_DENIED_CALLBACK_ACE}
  1814.   ACCESS_DENIED_CALLBACK_ACE = _ACCESS_DENIED_CALLBACK_ACE;
  1815.   {$EXTERNALSYM ACCESS_DENIED_CALLBACK_ACE}
  1816.   PACCESS_DENIED_CALLBACK_ACE = ^ACCESS_DENIED_CALLBACK_ACE;
  1817.   {$EXTERNALSYM PACCESS_DENIED_CALLBACK_ACE}
  1818.   TAccessDeniedCallBackAce = ACCESS_DENIED_CALLBACK_ACE;
  1819.   PAccessDeniedCallBackAce = PACCESS_DENIED_CALLBACK_ACE;
  1820.   _SYSTEM_AUDIT_CALLBACK_ACE = record
  1821.     Header: ACE_HEADER;
  1822.     Mask: ACCESS_MASK;
  1823.     SidStart: DWORD;
  1824.     // Opaque resouce manager specific data
  1825.   end;
  1826.   {$EXTERNALSYM _SYSTEM_AUDIT_CALLBACK_ACE}
  1827.   SYSTEM_AUDIT_CALLBACK_ACE = _SYSTEM_AUDIT_CALLBACK_ACE;
  1828.   {$EXTERNALSYM SYSTEM_AUDIT_CALLBACK_ACE}
  1829.   PSYSTEM_AUDIT_CALLBACK_ACE = ^SYSTEM_AUDIT_CALLBACK_ACE;
  1830.   {$EXTERNALSYM PSYSTEM_AUDIT_CALLBACK_ACE}
  1831.   TSystemAuditCallBackAce = SYSTEM_AUDIT_CALLBACK_ACE;
  1832.   PSystemAuditCallBackAce = PSYSTEM_AUDIT_CALLBACK_ACE;
  1833.   _SYSTEM_ALARM_CALLBACK_ACE = record
  1834.     Header: ACE_HEADER;
  1835.     Mask: ACCESS_MASK;
  1836.     SidStart: DWORD;
  1837.     // Opaque resouce manager specific data
  1838.   end;
  1839.   {$EXTERNALSYM _SYSTEM_ALARM_CALLBACK_ACE}
  1840.   SYSTEM_ALARM_CALLBACK_ACE = _SYSTEM_ALARM_CALLBACK_ACE;
  1841.   {$EXTERNALSYM SYSTEM_ALARM_CALLBACK_ACE}
  1842.   PSYSTEM_ALARM_CALLBACK_ACE = ^SYSTEM_ALARM_CALLBACK_ACE;
  1843.   {$EXTERNALSYM PSYSTEM_ALARM_CALLBACK_ACE}
  1844.   TSystemAlarmCallBackAce = SYSTEM_ALARM_CALLBACK_ACE;
  1845.   PSystemAlarmCallBackAce = PSYSTEM_ALARM_CALLBACK_ACE;
  1846.   _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE = record
  1847.     Header: ACE_HEADER;
  1848.     Mask: ACCESS_MASK;
  1849.     Flags: DWORD;
  1850.     ObjectType: GUID;
  1851.     InheritedObjectType: GUID;
  1852.     SidStart: DWORD;
  1853.     // Opaque resouce manager specific data
  1854.   end;
  1855.   {$EXTERNALSYM _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE}
  1856.   ACCESS_ALLOWED_CALLBACK_OBJECT_ACE = _ACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  1857.   {$EXTERNALSYM ACCESS_ALLOWED_CALLBACK_OBJECT_ACE}
  1858.   PACCESS_ALLOWED_CALLBACK_OBJECT_ACE = ^ACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  1859.   {$EXTERNALSYM PACCESS_ALLOWED_CALLBACK_OBJECT_ACE}
  1860.   TAccessAllowedCallBackObjectAce = ACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  1861.   PAccessAllowedCallBackObjectAce = PACCESS_ALLOWED_CALLBACK_OBJECT_ACE;
  1862.   _ACCESS_DENIED_CALLBACK_OBJECT_ACE = record
  1863.     Header: ACE_HEADER;
  1864.     Mask: ACCESS_MASK;
  1865.     Flags: DWORD;
  1866.     ObjectType: GUID;
  1867.     InheritedObjectType: GUID;
  1868.     SidStart: DWORD;
  1869.     // Opaque resouce manager specific data
  1870.   end;
  1871.   {$EXTERNALSYM _ACCESS_DENIED_CALLBACK_OBJECT_ACE}
  1872.   ACCESS_DENIED_CALLBACK_OBJECT_ACE = _ACCESS_DENIED_CALLBACK_OBJECT_ACE;
  1873.   {$EXTERNALSYM ACCESS_DENIED_CALLBACK_OBJECT_ACE}
  1874.   PACCESS_DENIED_CALLBACK_OBJECT_ACE = ^ACCESS_DENIED_CALLBACK_OBJECT_ACE;
  1875.   {$EXTERNALSYM PACCESS_DENIED_CALLBACK_OBJECT_ACE}
  1876.   TAccessDeniedCallBackObjectAce = ACCESS_DENIED_CALLBACK_OBJECT_ACE;
  1877.   PAccessDeniedCallBackObjectAce = PACCESS_DENIED_CALLBACK_OBJECT_ACE;
  1878.   _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE = record
  1879.     Header: ACE_HEADER;
  1880.     Mask: ACCESS_MASK;
  1881.     Flags: DWORD;
  1882.     ObjectType: GUID;
  1883.     InheritedObjectType: GUID;
  1884.     SidStart: DWORD;
  1885.     // Opaque resouce manager specific data
  1886.   end;
  1887.   {$EXTERNALSYM _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE}
  1888.   SYSTEM_AUDIT_CALLBACK_OBJECT_ACE = _SYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  1889.   {$EXTERNALSYM SYSTEM_AUDIT_CALLBACK_OBJECT_ACE}
  1890.   PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE = ^SYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  1891.   {$EXTERNALSYM PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE}
  1892.   TSystemAuditCallBackObjectAce = SYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  1893.   PSystemAuditCallBackObjectAce = PSYSTEM_AUDIT_CALLBACK_OBJECT_ACE;
  1894.   _SYSTEM_ALARM_CALLBACK_OBJECT_ACE = record
  1895.     Header: ACE_HEADER;
  1896.     Mask: ACCESS_MASK;
  1897.     Flags: DWORD;
  1898.     ObjectType: GUID;
  1899.     InheritedObjectType: GUID;
  1900.     SidStart: DWORD;
  1901.     // Opaque resouce manager specific data
  1902.   end;
  1903.   {$EXTERNALSYM _SYSTEM_ALARM_CALLBACK_OBJECT_ACE}
  1904.   SYSTEM_ALARM_CALLBACK_OBJECT_ACE = _SYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  1905.   {$EXTERNALSYM SYSTEM_ALARM_CALLBACK_OBJECT_ACE}
  1906.   PSYSTEM_ALARM_CALLBACK_OBJECT_ACE = ^SYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  1907.   {$EXTERNALSYM PSYSTEM_ALARM_CALLBACK_OBJECT_ACE}
  1908.   TSystemAlarmCallBackObjectAce = SYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  1909.   PSystemAlarmCallBackObjectAce = PSYSTEM_ALARM_CALLBACK_OBJECT_ACE;
  1910. //
  1911. // Currently define Flags for "OBJECT" ACE types.
  1912. //
  1913. const
  1914.   ACE_OBJECT_TYPE_PRESENT           = $1;
  1915.   {$EXTERNALSYM ACE_OBJECT_TYPE_PRESENT}
  1916.   ACE_INHERITED_OBJECT_TYPE_PRESENT = $2;
  1917.   {$EXTERNALSYM ACE_INHERITED_OBJECT_TYPE_PRESENT}
  1918. //
  1919. //  The following declarations are used for setting and querying information
  1920. //  about and ACL.  First are the various information classes available to
  1921. //  the user.
  1922. //
  1923.   AclRevisionInformation = 1;
  1924.   {$EXTERNALSYM AclRevisionInformation}
  1925.   AclSizeInformation = 2;
  1926.   {$EXTERNALSYM AclSizeInformation}
  1927. type
  1928.   _ACL_INFORMATION_CLASS = DWORD;
  1929.   {$EXTERNALSYM _ACL_INFORMATION_CLASS}
  1930.   ACL_INFORMATION_CLASS = _ACL_INFORMATION_CLASS;
  1931.   {$EXTERNALSYM ACL_INFORMATION_CLASS}
  1932.   TAclInformationClass = ACL_INFORMATION_CLASS;
  1933. //
  1934. //  This record is returned/sent if the user is requesting/setting the
  1935. //  AclRevisionInformation
  1936. //
  1937.   PACL_REVISION_INFORMATION = ^ACL_REVISION_INFORMATION;
  1938.   {$EXTERNALSYM PACL_REVISION_INFORMATION}
  1939.   _ACL_REVISION_INFORMATION = record
  1940.     AclRevision: DWORD;
  1941.   end;
  1942.   {$EXTERNALSYM _ACL_REVISION_INFORMATION}
  1943.   ACL_REVISION_INFORMATION = _ACL_REVISION_INFORMATION;
  1944.   {$EXTERNALSYM ACL_REVISION_INFORMATION}
  1945.   TAclRevisionInformation = ACL_REVISION_INFORMATION;
  1946.   PAclRevisionInformation = PACL_REVISION_INFORMATION;
  1947. //
  1948. //  This record is returned if the user is requesting AclSizeInformation
  1949. //
  1950.   PACL_SIZE_INFORMATION = ^ACL_SIZE_INFORMATION;
  1951.   {$EXTERNALSYM PACL_SIZE_INFORMATION}
  1952.   _ACL_SIZE_INFORMATION = record
  1953.     AceCount: DWORD;
  1954.     AclBytesInUse: DWORD;
  1955.     AclBytesFree: DWORD;
  1956.   end;
  1957.   {$EXTERNALSYM _ACL_SIZE_INFORMATION}
  1958.   ACL_SIZE_INFORMATION = _ACL_SIZE_INFORMATION;
  1959.   {$EXTERNALSYM ACL_SIZE_INFORMATION}
  1960.   TAclSizeInformation = ACL_SIZE_INFORMATION;
  1961.   PAclSizeInformation = PACL_SIZE_INFORMATION;
  1962. ////////////////////////////////////////////////////////////////////////
  1963. //                                                                    //
  1964. //                             SECURITY_DESCRIPTOR                    //
  1965. //                                                                    //
  1966. ////////////////////////////////////////////////////////////////////////
  1967. //
  1968. //  Define the Security Descriptor and related data types.
  1969. //  This is an opaque data structure.
  1970. //
  1971. //
  1972. // Current security descriptor revision value
  1973. //
  1974. const
  1975.   SECURITY_DESCRIPTOR_REVISION  = (1);
  1976.   {$EXTERNALSYM SECURITY_DESCRIPTOR_REVISION}
  1977.   SECURITY_DESCRIPTOR_REVISION1 = (1);
  1978.   {$EXTERNALSYM SECURITY_DESCRIPTOR_REVISION1}
  1979. type
  1980.   SECURITY_DESCRIPTOR_CONTROL = WORD;
  1981.   {$EXTERNALSYM SECURITY_DESCRIPTOR_CONTROL}
  1982.   PSECURITY_DESCRIPTOR_CONTROL = ^SECURITY_DESCRIPTOR_CONTROL;
  1983.   {$EXTERNALSYM PSECURITY_DESCRIPTOR_CONTROL}
  1984.   TSecurityDescriptorControl = SECURITY_DESCRIPTOR_CONTROL;
  1985.   PSecurityDescriptorControl = PSECURITY_DESCRIPTOR_CONTROL;
  1986. const
  1987.   SE_OWNER_DEFAULTED       = ($0001);
  1988.   {$EXTERNALSYM SE_OWNER_DEFAULTED}
  1989.   SE_GROUP_DEFAULTED       = ($0002);
  1990.   {$EXTERNALSYM SE_GROUP_DEFAULTED}
  1991.   SE_DACL_PRESENT          = ($0004);
  1992.   {$EXTERNALSYM SE_DACL_PRESENT}
  1993.   SE_DACL_DEFAULTED        = ($0008);
  1994.   {$EXTERNALSYM SE_DACL_DEFAULTED}
  1995.   SE_SACL_PRESENT          = ($0010);
  1996.   {$EXTERNALSYM SE_SACL_PRESENT}
  1997.   SE_SACL_DEFAULTED        = ($0020);
  1998.   {$EXTERNALSYM SE_SACL_DEFAULTED}
  1999.   SE_DACL_AUTO_INHERIT_REQ = ($0100);
  2000.   {$EXTERNALSYM SE_DACL_AUTO_INHERIT_REQ}
  2001.   SE_SACL_AUTO_INHERIT_REQ = ($0200);
  2002.   {$EXTERNALSYM SE_SACL_AUTO_INHERIT_REQ}
  2003.   SE_DACL_AUTO_INHERITED   = ($0400);
  2004.   {$EXTERNALSYM SE_DACL_AUTO_INHERITED}
  2005.   SE_SACL_AUTO_INHERITED   = ($0800);
  2006.   {$EXTERNALSYM SE_SACL_AUTO_INHERITED}
  2007.   SE_DACL_PROTECTED        = ($1000);
  2008.   {$EXTERNALSYM SE_DACL_PROTECTED}
  2009.   SE_SACL_PROTECTED        = ($2000);
  2010.   {$EXTERNALSYM SE_SACL_PROTECTED}
  2011.   SE_RM_CONTROL_VALID      = ($4000);
  2012.   {$EXTERNALSYM SE_RM_CONTROL_VALID}
  2013.   SE_SELF_RELATIVE         = ($8000);
  2014.   {$EXTERNALSYM SE_SELF_RELATIVE}
  2015. //
  2016. //  Where:
  2017. //
  2018. //      SE_OWNER_DEFAULTED - This boolean flag, when set, indicates that the
  2019. //          SID pointed to by the Owner field was provided by a
  2020. //          defaulting mechanism rather than explicitly provided by the
  2021. //          original provider of the security descriptor.  This may
  2022. //          affect the treatment of the SID with respect to inheritence
  2023. //          of an owner.
  2024. //
  2025. //      SE_GROUP_DEFAULTED - This boolean flag, when set, indicates that the
  2026. //          SID in the Group field was provided by a defaulting mechanism
  2027. //          rather than explicitly provided by the original provider of
  2028. //          the security descriptor.  This may affect the treatment of
  2029. //          the SID with respect to inheritence of a primary group.
  2030. //
  2031. //      SE_DACL_PRESENT - This boolean flag, when set, indicates that the
  2032. //          security descriptor contains a discretionary ACL.  If this
  2033. //          flag is set and the Dacl field of the SECURITY_DESCRIPTOR is
  2034. //          null, then a null ACL is explicitly being specified.
  2035. //
  2036. //      SE_DACL_DEFAULTED - This boolean flag, when set, indicates that the
  2037. //          ACL pointed to by the Dacl field was provided by a defaulting
  2038. //          mechanism rather than explicitly provided by the original
  2039. //          provider of the security descriptor.  This may affect the
  2040. //          treatment of the ACL with respect to inheritence of an ACL.
  2041. //          This flag is ignored if the DaclPresent flag is not set.
  2042. //
  2043. //      SE_SACL_PRESENT - This boolean flag, when set,  indicates that the
  2044. //          security descriptor contains a system ACL pointed to by the
  2045. //          Sacl field.  If this flag is set and the Sacl field of the
  2046. //          SECURITY_DESCRIPTOR is null, then an empty (but present)
  2047. //          ACL is being specified.
  2048. //
  2049. //      SE_SACL_DEFAULTED - This boolean flag, when set, indicates that the
  2050. //          ACL pointed to by the Sacl field was provided by a defaulting
  2051. //          mechanism rather than explicitly provided by the original
  2052. //          provider of the security descriptor.  This may affect the
  2053. //          treatment of the ACL with respect to inheritence of an ACL.
  2054. //          This flag is ignored if the SaclPresent flag is not set.
  2055. //
  2056. //      SE_SELF_RELATIVE - This boolean flag, when set, indicates that the
  2057. //          security descriptor is in self-relative form.  In this form,
  2058. //          all fields of the security descriptor are contiguous in memory
  2059. //          and all pointer fields are expressed as offsets from the
  2060. //          beginning of the security descriptor.  This form is useful
  2061. //          for treating security descriptors as opaque data structures
  2062. //          for transmission in communication protocol or for storage on
  2063. //          secondary media.
  2064. //
  2065. //
  2066. //
  2067. // Pictorially the structure of a security descriptor is as follows:
  2068. //
  2069. //       3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  2070. //       1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  2071. //      +---------------------------------------------------------------+
  2072. //      |            Control            |Reserved1 (SBZ)|   Revision    |
  2073. //      +---------------------------------------------------------------+
  2074. //      |                            Owner                              |
  2075. //      +---------------------------------------------------------------+
  2076. //      |                            Group                              |
  2077. //      +---------------------------------------------------------------+
  2078. //      |                            Sacl                               |
  2079. //      +---------------------------------------------------------------+
  2080. //      |                            Dacl                               |
  2081. //      +---------------------------------------------------------------+
  2082. //
  2083. // In general, this data structure should be treated opaquely to ensure future
  2084. // compatibility.
  2085. //
  2086. //
  2087. type
  2088.   PSECURITY_DESCRIPTOR_RELATIVE = ^SECURITY_DESCRIPTOR_RELATIVE;
  2089.   {$EXTERNALSYM PSECURITY_DESCRIPTOR_RELATIVE}
  2090.   _SECURITY_DESCRIPTOR_RELATIVE = record
  2091.     Revision: Byte;
  2092.     Sbz1: Byte;
  2093.     Control: SECURITY_DESCRIPTOR_CONTROL;
  2094.     Owner: DWORD;
  2095.     Group: DWORD;
  2096.     Sacl: DWORD;
  2097.     Dacl: DWORD;
  2098.   end;
  2099.   {$EXTERNALSYM _SECURITY_DESCRIPTOR_RELATIVE}
  2100.   SECURITY_DESCRIPTOR_RELATIVE = _SECURITY_DESCRIPTOR_RELATIVE;
  2101.   {$EXTERNALSYM SECURITY_DESCRIPTOR_RELATIVE}
  2102.   TSecurityDescriptorRelative = SECURITY_DESCRIPTOR_RELATIVE;
  2103.   PSecurityDescriptorRelative = PSECURITY_DESCRIPTOR_RELATIVE;
  2104.   PSECURITY_DESCRIPTOR = ^SECURITY_DESCRIPTOR;
  2105.   {$EXTERNALSYM PSECURITY_DESCRIPTOR}
  2106.   _SECURITY_DESCRIPTOR = record
  2107.     Revision: Byte;
  2108.     Sbz1: Byte;
  2109.     Control: SECURITY_DESCRIPTOR_CONTROL;
  2110.     Owner: PSID;
  2111.     Group: PSID;
  2112.     Sacl: PACL;
  2113.     Dacl: PACL;
  2114.   end;
  2115.   {$EXTERNALSYM _SECURITY_DESCRIPTOR}
  2116.   SECURITY_DESCRIPTOR = _SECURITY_DESCRIPTOR;
  2117.   {$EXTERNALSYM SECURITY_DESCRIPTOR}
  2118.   TSecurityDescriptor = SECURITY_DESCRIPTOR;
  2119.   PSecurityDescriptor = PSECURITY_DESCRIPTOR;
  2120.   PPSECURITY_DESCRIPTOR = ^PSECURITY_DESCRIPTOR;
  2121.   {$NODEFINE PPSECURITY_DESCRIPTOR}
  2122. const
  2123.   SECURITY_DESCRIPTOR_MIN_LENGTH = SizeOf(SECURITY_DESCRIPTOR);
  2124.   {$EXTERNALSYM SECURITY_DESCRIPTOR_MIN_LENGTH}
  2125. // Where:
  2126. //
  2127. //     Revision - Contains the revision level of the security
  2128. //         descriptor.  This allows this structure to be passed between
  2129. //         systems or stored on disk even though it is expected to
  2130. //         change in the future.
  2131. //
  2132. //     Control - A set of flags which qualify the meaning of the
  2133. //         security descriptor or individual fields of the security
  2134. //         descriptor.
  2135. //
  2136. //     Owner - is a pointer to an SID representing an object's owner.
  2137. //         If this field is null, then no owner SID is present in the
  2138. //         security descriptor.  If the security descriptor is in
  2139. //         self-relative form, then this field contains an offset to
  2140. //         the SID, rather than a pointer.
  2141. //
  2142. //     Group - is a pointer to an SID representing an object's primary
  2143. //         group.  If this field is null, then no primary group SID is
  2144. //         present in the security descriptor.  If the security descriptor
  2145. //         is in self-relative form, then this field contains an offset to
  2146. //         the SID, rather than a pointer.
  2147. //
  2148. //     Sacl - is a pointer to a system ACL.  This field value is only
  2149. //         valid if the DaclPresent control flag is set.  If the
  2150. //         SaclPresent flag is set and this field is null, then a null
  2151. //         ACL  is specified.  If the security descriptor is in
  2152. //         self-relative form, then this field contains an offset to
  2153. //         the ACL, rather than a pointer.
  2154. //
  2155. //     Dacl - is a pointer to a discretionary ACL.  This field value is
  2156. //         only valid if the DaclPresent control flag is set.  If the
  2157. //         DaclPresent flag is set and this field is null, then a null
  2158. //         ACL (unconditionally granting access) is specified.  If the
  2159. //         security descriptor is in self-relative form, then this field
  2160. //         contains an offset to the ACL, rather than a pointer.
  2161. //
  2162. ////////////////////////////////////////////////////////////////////////
  2163. //                                                                    //
  2164. //               Object Type list for AccessCheckByType               //
  2165. //                                                                    //
  2166. ////////////////////////////////////////////////////////////////////////
  2167. type
  2168.   POBJECT_TYPE_LIST = ^OBJECT_TYPE_LIST;
  2169.   {$EXTERNALSYM POBJECT_TYPE_LIST}
  2170.   _OBJECT_TYPE_LIST = record
  2171.     Level: Word;
  2172.     Sbz: Word;
  2173.     ObjectType: PGUID;
  2174.   end;
  2175.   {$EXTERNALSYM _OBJECT_TYPE_LIST}
  2176.   OBJECT_TYPE_LIST = _OBJECT_TYPE_LIST;
  2177.   {$EXTERNALSYM OBJECT_TYPE_LIST}
  2178.   TObjectTypeList = OBJECT_TYPE_LIST;
  2179.   PObjectTypeList = POBJECT_TYPE_LIST;
  2180. //
  2181. // DS values for Level
  2182. //
  2183. const
  2184.   ACCESS_OBJECT_GUID       = 0;
  2185.   {$EXTERNALSYM ACCESS_OBJECT_GUID}
  2186.   ACCESS_PROPERTY_SET_GUID = 1;
  2187.   {$EXTERNALSYM ACCESS_PROPERTY_SET_GUID}
  2188.   ACCESS_PROPERTY_GUID     = 2;
  2189.   {$EXTERNALSYM ACCESS_PROPERTY_GUID}
  2190.   ACCESS_MAX_LEVEL         = 4;
  2191.   {$EXTERNALSYM ACCESS_MAX_LEVEL}
  2192. //
  2193. // Parameters to NtAccessCheckByTypeAndAditAlarm
  2194. //
  2195. type
  2196.   _AUDIT_EVENT_TYPE = (AuditEventObjectAccess, AuditEventDirectoryServiceAccess);
  2197.   {$EXTERNALSYM _AUDIT_EVENT_TYPE}
  2198.   AUDIT_EVENT_TYPE = _AUDIT_EVENT_TYPE;
  2199.   {$EXTERNALSYM AUDIT_EVENT_TYPE}
  2200.   PAUDIT_EVENT_TYPE = ^AUDIT_EVENT_TYPE;
  2201.   {$EXTERNALSYM PAUDIT_EVENT_TYPE}
  2202.   TAuditEventType = AUDIT_EVENT_TYPE;
  2203.   PAuditEventType = PAUDIT_EVENT_TYPE;
  2204. const
  2205.   AUDIT_ALLOW_NO_PRIVILEGE = $1;
  2206.   {$EXTERNALSYM AUDIT_ALLOW_NO_PRIVILEGE}
  2207. //
  2208. // DS values for Source and ObjectTypeName
  2209. //
  2210.   ACCESS_DS_SOURCE_A           = 'DS';
  2211.   {$EXTERNALSYM ACCESS_DS_SOURCE_A}
  2212.   ACCESS_DS_SOURCE_W           = WideString('DS');
  2213.   {$EXTERNALSYM ACCESS_DS_SOURCE_W}
  2214.   ACCESS_DS_OBJECT_TYPE_NAME_A = 'Directory Service Object';
  2215.   {$EXTERNALSYM ACCESS_DS_OBJECT_TYPE_NAME_A}
  2216.   ACCESS_DS_OBJECT_TYPE_NAME_W = WideString('Directory Service Object');
  2217.   {$EXTERNALSYM ACCESS_DS_OBJECT_TYPE_NAME_W}
  2218. ////////////////////////////////////////////////////////////////////////
  2219. //                                                                    //
  2220. //               Privilege Related Data Structures                    //
  2221. //                                                                    //
  2222. ////////////////////////////////////////////////////////////////////////
  2223. //
  2224. // Privilege attributes
  2225. //
  2226. const
  2227.   SE_PRIVILEGE_ENABLED_BY_DEFAULT = ($00000001);
  2228.   {$EXTERNALSYM SE_PRIVILEGE_ENABLED_BY_DEFAULT}
  2229.   SE_PRIVILEGE_ENABLED            = ($00000002);
  2230.   {$EXTERNALSYM SE_PRIVILEGE_ENABLED}
  2231.   SE_PRIVILEGE_REMOVED            = ($00000004);
  2232.   {$EXTERNALSYM SE_PRIVILEGE_REMOVED}
  2233.   SE_PRIVILEGE_USED_FOR_ACCESS    = DWORD($80000000);
  2234.   {$EXTERNALSYM SE_PRIVILEGE_USED_FOR_ACCESS}
  2235. //
  2236. // Privilege Set Control flags
  2237. //
  2238.   PRIVILEGE_SET_ALL_NECESSARY = (1);
  2239.   {$EXTERNALSYM PRIVILEGE_SET_ALL_NECESSARY}
  2240. //
  2241. //  Privilege Set - This is defined for a privilege set of one.
  2242. //                  If more than one privilege is needed, then this structure
  2243. //                  will need to be allocated with more space.
  2244. //
  2245. //  Note: don't change this structure without fixing the INITIAL_PRIVILEGE_SET
  2246. //  structure (defined in se.h)
  2247. //
  2248. type
  2249.   PPRIVILEGE_SET = ^PRIVILEGE_SET;
  2250.   {$EXTERNALSYM PPRIVILEGE_SET}
  2251.   _PRIVILEGE_SET = record
  2252.     PrivilegeCount: DWORD;
  2253.     Control: DWORD;
  2254.     Privilege: array [0..ANYSIZE_ARRAY - 1] of LUID_AND_ATTRIBUTES;
  2255.     //Privilege: LUID_AND_ATTRIBUTES;
  2256.   end;
  2257.   {$EXTERNALSYM _PRIVILEGE_SET}
  2258.   PRIVILEGE_SET = _PRIVILEGE_SET;
  2259.   {$EXTERNALSYM PRIVILEGE_SET}
  2260.   TPrivilegeSet = PRIVILEGE_SET;
  2261.   PPrivilegeSet = PPRIVILEGE_SET;
  2262. ////////////////////////////////////////////////////////////////////////
  2263. //                                                                    //
  2264. //               NT Defined Privileges                                //
  2265. //                                                                    //
  2266. ////////////////////////////////////////////////////////////////////////
  2267. const
  2268.   SE_CREATE_TOKEN_NAME        = 'SeCreateTokenPrivilege';
  2269.   {$EXTERNALSYM SE_CREATE_TOKEN_NAME}
  2270.   SE_ASSIGNPRIMARYTOKEN_NAME  = 'SeAssignPrimaryTokenPrivilege';
  2271.   {$EXTERNALSYM SE_ASSIGNPRIMARYTOKEN_NAME}
  2272.   SE_LOCK_MEMORY_NAME         = 'SeLockMemoryPrivilege';
  2273.   {$EXTERNALSYM SE_LOCK_MEMORY_NAME}
  2274.   SE_INCREASE_QUOTA_NAME      = 'SeIncreaseQuotaPrivilege';
  2275.   {$EXTERNALSYM SE_INCREASE_QUOTA_NAME}
  2276.   SE_UNSOLICITED_INPUT_NAME   = 'SeUnsolicitedInputPrivilege';
  2277.   {$EXTERNALSYM SE_UNSOLICITED_INPUT_NAME}
  2278.   SE_MACHINE_ACCOUNT_NAME     = 'SeMachineAccountPrivilege';
  2279.   {$EXTERNALSYM SE_MACHINE_ACCOUNT_NAME}
  2280.   SE_TCB_NAME                 = 'SeTcbPrivilege';
  2281.   {$EXTERNALSYM SE_TCB_NAME}
  2282.   SE_SECURITY_NAME            = 'SeSecurityPrivilege';
  2283.   {$EXTERNALSYM SE_SECURITY_NAME}
  2284.   SE_TAKE_OWNERSHIP_NAME      = 'SeTakeOwnershipPrivilege';
  2285.   {$EXTERNALSYM SE_TAKE_OWNERSHIP_NAME}
  2286.   SE_LOAD_DRIVER_NAME         = 'SeLoadDriverPrivilege';
  2287.   {$EXTERNALSYM SE_LOAD_DRIVER_NAME}
  2288.   SE_SYSTEM_PROFILE_NAME      = 'SeSystemProfilePrivilege';
  2289.   {$EXTERNALSYM SE_SYSTEM_PROFILE_NAME}
  2290.   SE_SYSTEMTIME_NAME          = 'SeSystemtimePrivilege';
  2291.   {$EXTERNALSYM SE_SYSTEMTIME_NAME}
  2292.   SE_PROF_SINGLE_PROCESS_NAME = 'SeProfileSingleProcessPrivilege';
  2293.   {$EXTERNALSYM SE_PROF_SINGLE_PROCESS_NAME}
  2294.   SE_INC_BASE_PRIORITY_NAME   = 'SeIncreaseBasePriorityPrivilege';
  2295.   {$EXTERNALSYM SE_INC_BASE_PRIORITY_NAME}
  2296.   SE_CREATE_PAGEFILE_NAME     = 'SeCreatePagefilePrivilege';
  2297.   {$EXTERNALSYM SE_CREATE_PAGEFILE_NAME}
  2298.   SE_CREATE_PERMANENT_NAME    = 'SeCreatePermanentPrivilege';
  2299.   {$EXTERNALSYM SE_CREATE_PERMANENT_NAME}
  2300.   SE_BACKUP_NAME              = 'SeBackupPrivilege';
  2301.   {$EXTERNALSYM SE_BACKUP_NAME}
  2302.   SE_RESTORE_NAME             = 'SeRestorePrivilege';
  2303.   {$EXTERNALSYM SE_RESTORE_NAME}
  2304.   SE_SHUTDOWN_NAME            = 'SeShutdownPrivilege';
  2305.   {$EXTERNALSYM SE_SHUTDOWN_NAME}
  2306.   SE_DEBUG_NAME               = 'SeDebugPrivilege';
  2307.   {$EXTERNALSYM SE_DEBUG_NAME}
  2308.   SE_AUDIT_NAME               = 'SeAuditPrivilege';
  2309.   {$EXTERNALSYM SE_AUDIT_NAME}
  2310.   SE_SYSTEM_ENVIRONMENT_NAME  = 'SeSystemEnvironmentPrivilege';
  2311.   {$EXTERNALSYM SE_SYSTEM_ENVIRONMENT_NAME}
  2312.   SE_CHANGE_NOTIFY_NAME       = 'SeChangeNotifyPrivilege';
  2313.   {$EXTERNALSYM SE_CHANGE_NOTIFY_NAME}
  2314.   SE_REMOTE_SHUTDOWN_NAME     = 'SeRemoteShutdownPrivilege';
  2315.   {$EXTERNALSYM SE_REMOTE_SHUTDOWN_NAME}
  2316.   SE_UNDOCK_NAME              = 'SeUndockPrivilege';
  2317.   {$EXTERNALSYM SE_UNDOCK_NAME}
  2318.   SE_SYNC_AGENT_NAME          = 'SeSyncAgentPrivilege';
  2319.   {$EXTERNALSYM SE_SYNC_AGENT_NAME}
  2320.   SE_ENABLE_DELEGATION_NAME   = 'SeEnableDelegationPrivilege';
  2321.   {$EXTERNALSYM SE_ENABLE_DELEGATION_NAME}
  2322.   SE_MANAGE_VOLUME_NAME       = 'SeManageVolumePrivilege';
  2323.   {$EXTERNALSYM SE_MANAGE_VOLUME_NAME}
  2324. ////////////////////////////////////////////////////////////////////
  2325. //                                                                //
  2326. //           Security Quality Of Service                          //
  2327. //                                                                //
  2328. //                                                                //
  2329. ////////////////////////////////////////////////////////////////////
  2330. //
  2331. // Impersonation Level
  2332. //
  2333. // Impersonation level is represented by a pair of bits in Windows.
  2334. // If a new impersonation level is added or lowest value is changed from
  2335. // 0 to something else, fix the Windows CreateFile call.
  2336. //
  2337. type
  2338.   _SECURITY_IMPERSONATION_LEVEL = (SecurityAnonymous, SecurityIdentification,
  2339.     SecurityImpersonation, SecurityDelegation);
  2340.   {$EXTERNALSYM _SECURITY_IMPERSONATION_LEVEL}
  2341.   SECURITY_IMPERSONATION_LEVEL = _SECURITY_IMPERSONATION_LEVEL;
  2342.   {$EXTERNALSYM SECURITY_IMPERSONATION_LEVEL}
  2343.   PSECURITY_IMPERSONATION_LEVEL = ^SECURITY_IMPERSONATION_LEVEL;
  2344.   {$EXTERNALSYM PSECURITY_IMPERSONATION_LEVEL}
  2345.   TSecurityImpersonationLevel = SECURITY_IMPERSONATION_LEVEL;
  2346.   PSecurityImpersonationLevel = PSECURITY_IMPERSONATION_LEVEL;
  2347. const
  2348.   SECURITY_MAX_IMPERSONATION_LEVEL = SecurityDelegation;
  2349.   {$EXTERNALSYM SECURITY_MAX_IMPERSONATION_LEVEL}
  2350.   SECURITY_MIN_IMPERSONATION_LEVEL = SecurityAnonymous;
  2351.   {$EXTERNALSYM SECURITY_MIN_IMPERSONATION_LEVEL}
  2352.   DEFAULT_IMPERSONATION_LEVEL      = SecurityImpersonation;
  2353.   {$EXTERNALSYM DEFAULT_IMPERSONATION_LEVEL}
  2354. function VALID_IMPERSONATION_LEVEL(L: TSecurityImpersonationLevel): BOOL;
  2355. {$EXTERNALSYM VALID_IMPERSONATION_LEVEL}
  2356. ////////////////////////////////////////////////////////////////////
  2357. //                                                                //
  2358. //           Token Object Definitions                             //
  2359. //                                                                //
  2360. //                                                                //
  2361. ////////////////////////////////////////////////////////////////////
  2362. //
  2363. // Token Specific Access Rights.
  2364. //
  2365. const
  2366.   TOKEN_ASSIGN_PRIMARY    = ($0001);
  2367.   {$EXTERNALSYM TOKEN_ASSIGN_PRIMARY}
  2368.   TOKEN_DUPLICATE         = ($0002);
  2369.   {$EXTERNALSYM TOKEN_DUPLICATE}
  2370.   TOKEN_IMPERSONATE       = ($0004);
  2371.   {$EXTERNALSYM TOKEN_IMPERSONATE}
  2372.   TOKEN_QUERY             = ($0008);
  2373.   {$EXTERNALSYM TOKEN_QUERY}
  2374.   TOKEN_QUERY_SOURCE      = ($0010);
  2375.   {$EXTERNALSYM TOKEN_QUERY_SOURCE}
  2376.   TOKEN_ADJUST_PRIVILEGES = ($0020);
  2377.   {$EXTERNALSYM TOKEN_ADJUST_PRIVILEGES}
  2378.   TOKEN_ADJUST_GROUPS     = ($0040);
  2379.   {$EXTERNALSYM TOKEN_ADJUST_GROUPS}
  2380.   TOKEN_ADJUST_DEFAULT    = ($0080);
  2381.   {$EXTERNALSYM TOKEN_ADJUST_DEFAULT}
  2382.   TOKEN_ADJUST_SESSIONID  = ($0100);
  2383.   {$EXTERNALSYM TOKEN_ADJUST_SESSIONID}
  2384.   TOKEN_ALL_ACCESS_P = STANDARD_RIGHTS_REQUIRED or TOKEN_ASSIGN_PRIMARY or
  2385.     TOKEN_DUPLICATE or TOKEN_IMPERSONATE or TOKEN_QUERY or TOKEN_QUERY_SOURCE or
  2386.     TOKEN_ADJUST_PRIVILEGES or TOKEN_ADJUST_GROUPS or TOKEN_ADJUST_DEFAULT;
  2387.   {$EXTERNALSYM TOKEN_ALL_ACCESS_P}
  2388.   TOKEN_ALL_ACCESS = TOKEN_ALL_ACCESS_P or TOKEN_ADJUST_SESSIONID;
  2389.   {$EXTERNALSYM TOKEN_ALL_ACCESS}
  2390.   TOKEN_READ = (STANDARD_RIGHTS_READ or TOKEN_QUERY);
  2391.   {$EXTERNALSYM TOKEN_READ}
  2392.   TOKEN_WRITE = (STANDARD_RIGHTS_WRITE or TOKEN_ADJUST_PRIVILEGES or
  2393.     TOKEN_ADJUST_GROUPS or TOKEN_ADJUST_DEFAULT);
  2394.   {$EXTERNALSYM TOKEN_WRITE}
  2395.   TOKEN_EXECUTE = (STANDARD_RIGHTS_EXECUTE);
  2396.   {$EXTERNALSYM TOKEN_EXECUTE}
  2397. //
  2398. // Token Types
  2399. //
  2400. type
  2401.   _TOKEN_TYPE = (TokenTypePad0, TokenPrimary, TokenImpersonation);
  2402.   {$EXTERNALSYM _TOKEN_TYPE}
  2403.   TOKEN_TYPE = _TOKEN_TYPE;
  2404.   {$EXTERNALSYM TOKEN_TYPE}
  2405.   PTOKEN_TYPE = ^TOKEN_TYPE;
  2406.   {$EXTERNALSYM PTOKEN_TYPE}
  2407.   TTokenType = TOKEN_TYPE;
  2408.   PTokenType = PTOKEN_TYPE;
  2409. //
  2410. // Token Information Classes.
  2411. //
  2412. type
  2413.   _TOKEN_INFORMATION_CLASS = (TokenInfoClassPad0, TokenUser, TokenGroups,
  2414.     TokenPrivileges, TokenOwner, TokenPrimaryGroup, TokenDefaultDacl, TokenSource,
  2415.     TokenType, TokenImpersonationLevel, TokenStatistics, TokenRestrictedSids,
  2416.     TokenSessionId, TokenGroupsAndPrivileges, TokenSessionReference,
  2417.     TokenSandBoxInert, TokenAuditPolicy,
  2418.     MaxTokenInfoClass); {MaxTokenInfoClass should always be the last enum}
  2419.   {$EXTERNALSYM _TOKEN_INFORMATION_CLASS}
  2420.   TOKEN_INFORMATION_CLASS = _TOKEN_INFORMATION_CLASS;
  2421.   {$EXTERNALSYM TOKEN_INFORMATION_CLASS}
  2422.   PTOKEN_INFORMATION_CLASS = ^TOKEN_INFORMATION_CLASS;
  2423.   {$EXTERNALSYM PTOKEN_INFORMATION_CLASS}
  2424.   TTokenInformationClass = TOKEN_INFORMATION_CLASS;
  2425.   PTokenInformationClass = PTOKEN_INFORMATION_CLASS;
  2426. //
  2427. // Token information class structures
  2428. //
  2429. type
  2430.   PTOKEN_USER = ^TOKEN_USER;
  2431.   {$EXTERNALSYM PTOKEN_USER}
  2432.   _TOKEN_USER = record
  2433.     User: SID_AND_ATTRIBUTES;
  2434.   end;
  2435.   {$EXTERNALSYM _TOKEN_USER}
  2436.   TOKEN_USER = _TOKEN_USER;
  2437.   {$EXTERNALSYM TOKEN_USER}
  2438.   TTokenUser = TOKEN_USER;
  2439.   PTokenUser = PTOKEN_USER;
  2440.   PTOKEN_GROUPS = ^TOKEN_GROUPS;
  2441.   {$EXTERNALSYM PTOKEN_GROUPS}
  2442.   _TOKEN_GROUPS = record
  2443.     GroupCount: DWORD;
  2444.     Groups: array [0..ANYSIZE_ARRAY - 1] of SID_AND_ATTRIBUTES;
  2445.   end;
  2446.   {$EXTERNALSYM _TOKEN_GROUPS}
  2447.   TOKEN_GROUPS = _TOKEN_GROUPS;
  2448.   {$EXTERNALSYM TOKEN_GROUPS}
  2449.   TTokenGroups = TOKEN_GROUPS;
  2450.   PTokenGroups = PTOKEN_GROUPS;
  2451.   PTOKEN_PRIVILEGES = ^TOKEN_PRIVILEGES;
  2452.   {$EXTERNALSYM PTOKEN_PRIVILEGES}
  2453.   _TOKEN_PRIVILEGES = record
  2454.     PrivilegeCount: DWORD;
  2455.     Privileges: array [0..ANYSIZE_ARRAY - 1] of LUID_AND_ATTRIBUTES;
  2456.   end;
  2457.   {$EXTERNALSYM _TOKEN_PRIVILEGES}
  2458.   TOKEN_PRIVILEGES = _TOKEN_PRIVILEGES;
  2459.   {$EXTERNALSYM TOKEN_PRIVILEGES}
  2460.   TTokenPrivileges = TOKEN_PRIVILEGES;
  2461.   PTokenPrivileges = PTOKEN_PRIVILEGES;
  2462.   PTOKEN_OWNER = ^TOKEN_OWNER;
  2463.   {$EXTERNALSYM PTOKEN_OWNER}
  2464.   _TOKEN_OWNER = record
  2465.     Owner: PSID;
  2466.   end;
  2467.   {$EXTERNALSYM _TOKEN_OWNER}
  2468.   TOKEN_OWNER = _TOKEN_OWNER;
  2469.   {$EXTERNALSYM TOKEN_OWNER}
  2470.   TTokenOwner = TOKEN_OWNER;
  2471.   PTokenOwner = PTOKEN_OWNER;
  2472.   PTOKEN_PRIMARY_GROUP = ^TOKEN_PRIMARY_GROUP;
  2473.   {$EXTERNALSYM PTOKEN_PRIMARY_GROUP}
  2474.   _TOKEN_PRIMARY_GROUP = record
  2475.     PrimaryGroup: PSID;
  2476.   end;
  2477.   {$EXTERNALSYM _TOKEN_PRIMARY_GROUP}
  2478.   TOKEN_PRIMARY_GROUP = _TOKEN_PRIMARY_GROUP;
  2479.   {$EXTERNALSYM TOKEN_PRIMARY_GROUP}
  2480.   TTokenPrimaryGroup = TOKEN_PRIMARY_GROUP;
  2481.   PTokenPrimaryGroup = PTOKEN_PRIMARY_GROUP;
  2482.   PTOKEN_DEFAULT_DACL = ^TOKEN_DEFAULT_DACL;
  2483.   {$EXTERNALSYM PTOKEN_DEFAULT_DACL}
  2484.   _TOKEN_DEFAULT_DACL = record
  2485.     DefaultDacl: PACL;
  2486.   end;
  2487.   {$EXTERNALSYM _TOKEN_DEFAULT_DACL}
  2488.   TOKEN_DEFAULT_DACL = _TOKEN_DEFAULT_DACL;
  2489.   {$EXTERNALSYM TOKEN_DEFAULT_DACL}
  2490.   TTokenDefaultDacl = TOKEN_DEFAULT_DACL;
  2491.   PTokenDefaultDacl = PTOKEN_DEFAULT_DACL;
  2492.   _TOKEN_GROUPS_AND_PRIVILEGES = record
  2493.     SidCount: DWORD;
  2494.     SidLength: DWORD;
  2495.     Sids: PSID_AND_ATTRIBUTES;
  2496.     RestrictedSidCount: DWORD;
  2497.     RestrictedSidLength: DWORD;
  2498.     RestrictedSids: PSID_AND_ATTRIBUTES;
  2499.     PrivilegeCount: DWORD;
  2500.     PrivilegeLength: DWORD;
  2501.     Privileges: PLUID_AND_ATTRIBUTES;
  2502.     AuthenticationId: LUID;
  2503.   end;
  2504.   {$EXTERNALSYM _TOKEN_GROUPS_AND_PRIVILEGES}
  2505.   TOKEN_GROUPS_AND_PRIVILEGES = _TOKEN_GROUPS_AND_PRIVILEGES;
  2506.   {$EXTERNALSYM TOKEN_GROUPS_AND_PRIVILEGES}
  2507.   PTOKEN_GROUPS_AND_PRIVILEGES = ^TOKEN_GROUPS_AND_PRIVILEGES;
  2508.   {$EXTERNALSYM PTOKEN_GROUPS_AND_PRIVILEGES}
  2509.   TTokenGroupsAndPrivileges = TOKEN_GROUPS_AND_PRIVILEGES;
  2510.   PTokenGroupsAndPrivileges = PTOKEN_GROUPS_AND_PRIVILEGES;
  2511. //
  2512. // Valid bits for each TOKEN_AUDIT_POLICY policy mask field.
  2513. //
  2514. const
  2515.   TOKEN_AUDIT_SUCCESS_INCLUDE = $1;
  2516.   {$EXTERNALSYM TOKEN_AUDIT_SUCCESS_INCLUDE}
  2517.   TOKEN_AUDIT_SUCCESS_EXCLUDE = $2;
  2518.   {$EXTERNALSYM TOKEN_AUDIT_SUCCESS_EXCLUDE}
  2519.   TOKEN_AUDIT_FAILURE_INCLUDE = $4;
  2520.   {$EXTERNALSYM TOKEN_AUDIT_FAILURE_INCLUDE}
  2521.   TOKEN_AUDIT_FAILURE_EXCLUDE = $8;
  2522.   {$EXTERNALSYM TOKEN_AUDIT_FAILURE_EXCLUDE}
  2523.   VALID_AUDIT_POLICY_BITS = (TOKEN_AUDIT_SUCCESS_INCLUDE or
  2524.                              TOKEN_AUDIT_SUCCESS_EXCLUDE or
  2525.                              TOKEN_AUDIT_FAILURE_INCLUDE or
  2526.                              TOKEN_AUDIT_FAILURE_EXCLUDE);
  2527.   {$EXTERNALSYM VALID_AUDIT_POLICY_BITS}
  2528. type
  2529.   _TOKEN_AUDIT_POLICY_ELEMENT = record
  2530.     Category: DWORD;
  2531.     PolicyMask: DWORD;
  2532.   end;
  2533.   {$EXTERNALSYM _TOKEN_AUDIT_POLICY_ELEMENT}
  2534.   TOKEN_AUDIT_POLICY_ELEMENT = _TOKEN_AUDIT_POLICY_ELEMENT;
  2535.   {$EXTERNALSYM TOKEN_AUDIT_POLICY_ELEMENT}
  2536.   PTOKEN_AUDIT_POLICY_ELEMENT = ^TOKEN_AUDIT_POLICY_ELEMENT;
  2537.   {$EXTERNALSYM PTOKEN_AUDIT_POLICY_ELEMENT}
  2538.   TTokenAuditPolicyElement = TOKEN_AUDIT_POLICY_ELEMENT;
  2539.   PTokenAuditPolicyElement = PTOKEN_AUDIT_POLICY_ELEMENT;
  2540. // TODO Implementation references AuditEventMaxType, which isn't defined anywhere
  2541. //function VALID_TOKEN_AUDIT_POLICY_ELEMENT(P: TOKEN_AUDIT_POLICY_ELEMENT): BOOL;
  2542. //{$EXTERNALSYM VALID_TOKEN_AUDIT_POLICY_ELEMENT}
  2543. type
  2544.   _TOKEN_AUDIT_POLICY = record
  2545.     PolicyCount: DWORD;
  2546.     Policy: array [0..ANYSIZE_ARRAY - 1] of TOKEN_AUDIT_POLICY_ELEMENT;
  2547.   end;
  2548.   {$EXTERNALSYM _TOKEN_AUDIT_POLICY}
  2549.   TOKEN_AUDIT_POLICY = _TOKEN_AUDIT_POLICY;
  2550.   {$EXTERNALSYM TOKEN_AUDIT_POLICY}
  2551.   PTOKEN_AUDIT_POLICY = ^TOKEN_AUDIT_POLICY;
  2552.   {$EXTERNALSYM PTOKEN_AUDIT_POLICY}
  2553.   TTokenAuditPolicy = TOKEN_AUDIT_POLICY;
  2554.   PTokenAuditPolicy = PTOKEN_AUDIT_POLICY;
  2555. function PER_USER_AUDITING_POLICY_SIZE(p: PTOKEN_AUDIT_POLICY): DWORD;
  2556. {$EXTERNALSYM PER_USER_AUDITING_POLICY_SIZE}
  2557. function PER_USER_AUDITING_POLICY_SIZE_BY_COUNT(C: DWORD): DWORD;
  2558. {$EXTERNALSYM PER_USER_AUDITING_POLICY_SIZE_BY_COUNT}
  2559. const
  2560.   TOKEN_SOURCE_LENGTH = 8;
  2561.   {$EXTERNALSYM TOKEN_SOURCE_LENGTH}
  2562. type
  2563.   PTOKEN_SOURCE = ^TOKEN_SOURCE;
  2564.   {$EXTERNALSYM PTOKEN_SOURCE}
  2565.   _TOKEN_SOURCE = record
  2566.     SourceName: array [0..TOKEN_SOURCE_LENGTH - 1] of CHAR;
  2567.     SourceIdentifier: LUID;
  2568.   end;
  2569.   {$EXTERNALSYM _TOKEN_SOURCE}
  2570.   TOKEN_SOURCE = _TOKEN_SOURCE;
  2571.   {$EXTERNALSYM TOKEN_SOURCE}
  2572.   TTokenSource = TOKEN_SOURCE;
  2573.   PTokenSource = PTOKEN_SOURCE;
  2574.   PTOKEN_STATISTICS = ^TOKEN_STATISTICS;
  2575.   {$EXTERNALSYM PTOKEN_STATISTICS}
  2576.   _TOKEN_STATISTICS = record
  2577.     TokenId: LUID;
  2578.     AuthenticationId: LUID;
  2579.     ExpirationTime: LARGE_INTEGER;
  2580.     TokenType: TOKEN_TYPE;
  2581.     ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL;
  2582.     DynamicCharged: DWORD;
  2583.     DynamicAvailable: DWORD;
  2584.     GroupCount: DWORD;
  2585.     PrivilegeCount: DWORD;
  2586.     ModifiedId: LUID;
  2587.   end;
  2588.   {$EXTERNALSYM _TOKEN_STATISTICS}
  2589.   TOKEN_STATISTICS = _TOKEN_STATISTICS;
  2590.   {$EXTERNALSYM TOKEN_STATISTICS}
  2591.   TTokenStatistics = TOKEN_STATISTICS;
  2592.   PTokenStatistics = PTOKEN_STATISTICS;
  2593.   PTOKEN_CONTROL = ^TOKEN_CONTROL;
  2594.   {$EXTERNALSYM PTOKEN_CONTROL}
  2595.   _TOKEN_CONTROL = record
  2596.     TokenId: LUID;
  2597.     AuthenticationId: LUID;
  2598.     ModifiedId: LUID;
  2599.     TokenSource: TOKEN_SOURCE;
  2600.   end;
  2601.   {$EXTERNALSYM _TOKEN_CONTROL}
  2602.   TOKEN_CONTROL = _TOKEN_CONTROL;
  2603.   {$EXTERNALSYM TOKEN_CONTROL}
  2604.   TTokenControl = TOKEN_CONTROL;
  2605.   PTokenControl = PTOKEN_CONTROL;
  2606. //
  2607. // Security Tracking Mode
  2608. //
  2609. const
  2610.   SECURITY_DYNAMIC_TRACKING = (TRUE);
  2611.   {$EXTERNALSYM SECURITY_DYNAMIC_TRACKING}
  2612.   SECURITY_STATIC_TRACKING  = (FALSE);
  2613.   {$EXTERNALSYM SECURITY_STATIC_TRACKING}
  2614. type
  2615.   SECURITY_CONTEXT_TRACKING_MODE = ByteBool;
  2616.   {$EXTERNALSYM SECURITY_CONTEXT_TRACKING_MODE}
  2617.   PSECURITY_CONTEXT_TRACKING_MODE = ^SECURITY_CONTEXT_TRACKING_MODE;
  2618.   {$EXTERNALSYM PSECURITY_CONTEXT_TRACKING_MODE}
  2619. //
  2620. // Quality Of Service
  2621. //
  2622.   PSECURITY_QUALITY_OF_SERVICE = ^SECURITY_QUALITY_OF_SERVICE;
  2623.   {$EXTERNALSYM PSECURITY_QUALITY_OF_SERVICE}
  2624.   _SECURITY_QUALITY_OF_SERVICE = record
  2625.     Length: DWORD;
  2626.     ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL;
  2627.     ContextTrackingMode: SECURITY_CONTEXT_TRACKING_MODE;
  2628.     EffectiveOnly: ByteBool;
  2629.   end;
  2630.   {$EXTERNALSYM _SECURITY_QUALITY_OF_SERVICE}
  2631.   SECURITY_QUALITY_OF_SERVICE = _SECURITY_QUALITY_OF_SERVICE;
  2632.   {$EXTERNALSYM SECURITY_QUALITY_OF_SERVICE}
  2633.   TSecurityQualityOfService = SECURITY_QUALITY_OF_SERVICE;
  2634.   PSecurityQualityOfService = PSECURITY_QUALITY_OF_SERVICE;
  2635. //
  2636. // Used to represent information related to a thread impersonation
  2637. //
  2638.   PSE_IMPERSONATION_STATE = ^SE_IMPERSONATION_STATE;
  2639.   {$EXTERNALSYM PSE_IMPERSONATION_STATE}
  2640.   _SE_IMPERSONATION_STATE = record
  2641.     Token: PACCESS_TOKEN;
  2642.     CopyOnOpen: ByteBool;
  2643.     EffectiveOnly: ByteBool;
  2644.     Level: SECURITY_IMPERSONATION_LEVEL;
  2645.   end;
  2646.   {$EXTERNALSYM _SE_IMPERSONATION_STATE}
  2647.   SE_IMPERSONATION_STATE = _SE_IMPERSONATION_STATE;
  2648.   {$EXTERNALSYM SE_IMPERSONATION_STATE}
  2649.   TSeImpersonationState = SE_IMPERSONATION_STATE;
  2650.   PSeImpersonationState = PSE_IMPERSONATION_STATE;
  2651. const
  2652.   DISABLE_MAX_PRIVILEGE = $1;
  2653.   {$EXTERNALSYM DISABLE_MAX_PRIVILEGE}
  2654.   SANDBOX_INERT         = $2;
  2655.   {$EXTERNALSYM SANDBOX_INERT}
  2656. type
  2657.   SECURITY_INFORMATION = DWORD;
  2658.   {$EXTERNALSYM SECURITY_INFORMATION}
  2659.   PSECURITY_INFORMATION = ^SECURITY_INFORMATION;
  2660.   {$EXTERNALSYM PSECURITY_INFORMATION}
  2661.   TSecurityInformation = SECURITY_INFORMATION;
  2662.   PSecurityInformation = PSECURITY_INFORMATION;  
  2663. const
  2664.   OWNER_SECURITY_INFORMATION = ($00000001);
  2665.   {$EXTERNALSYM OWNER_SECURITY_INFORMATION}
  2666.   GROUP_SECURITY_INFORMATION = ($00000002);
  2667.   {$EXTERNALSYM GROUP_SECURITY_INFORMATION}
  2668.   DACL_SECURITY_INFORMATION  = ($00000004);
  2669.   {$EXTERNALSYM DACL_SECURITY_INFORMATION}
  2670.   SACL_SECURITY_INFORMATION  = ($00000008);
  2671.   {$EXTERNALSYM SACL_SECURITY_INFORMATION}
  2672.   PROTECTED_DACL_SECURITY_INFORMATION   = ($80000000);
  2673.   {$EXTERNALSYM PROTECTED_DACL_SECURITY_INFORMATION}
  2674.   PROTECTED_SACL_SECURITY_INFORMATION   = ($40000000);
  2675.   {$EXTERNALSYM PROTECTED_SACL_SECURITY_INFORMATION}
  2676.   UNPROTECTED_DACL_SECURITY_INFORMATION = ($20000000);
  2677.   {$EXTERNALSYM UNPROTECTED_DACL_SECURITY_INFORMATION}
  2678.   UNPROTECTED_SACL_SECURITY_INFORMATION = ($10000000);
  2679.   {$EXTERNALSYM UNPROTECTED_SACL_SECURITY_INFORMATION}
  2680.   PROCESS_TERMINATE         = ($0001);
  2681.   {$EXTERNALSYM PROCESS_TERMINATE}
  2682.   PROCESS_CREATE_THREAD     = ($0002);
  2683.   {$EXTERNALSYM PROCESS_CREATE_THREAD}
  2684.   PROCESS_SET_SESSIONID     = ($0004);
  2685.   {$EXTERNALSYM PROCESS_SET_SESSIONID}
  2686.   PROCESS_VM_OPERATION      = ($0008);
  2687.   {$EXTERNALSYM PROCESS_VM_OPERATION}
  2688.   PROCESS_VM_READ           = ($0010);
  2689.   {$EXTERNALSYM PROCESS_VM_READ}
  2690.   PROCESS_VM_WRITE          = ($0020);
  2691.   {$EXTERNALSYM PROCESS_VM_WRITE}
  2692.   PROCESS_DUP_HANDLE        = ($0040);
  2693.   {$EXTERNALSYM PROCESS_DUP_HANDLE}
  2694.   PROCESS_CREATE_PROCESS    = ($0080);
  2695.   {$EXTERNALSYM PROCESS_CREATE_PROCESS}
  2696.   PROCESS_SET_QUOTA         = ($0100);
  2697.   {$EXTERNALSYM PROCESS_SET_QUOTA}
  2698.   PROCESS_SET_INFORMATION   = ($0200);
  2699.   {$EXTERNALSYM PROCESS_SET_INFORMATION}
  2700.   PROCESS_QUERY_INFORMATION = ($0400);
  2701.   {$EXTERNALSYM PROCESS_QUERY_INFORMATION}
  2702.   PROCESS_SUSPEND_RESUME    = ($0800);
  2703.   {$EXTERNALSYM PROCESS_SUSPEND_RESUME}
  2704.   PROCESS_ALL_ACCESS        = (STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $FFF);
  2705.   {$EXTERNALSYM PROCESS_ALL_ACCESS}
  2706.   MAXIMUM_PROCESSORS = 32;
  2707.   {$EXTERNALSYM MAXIMUM_PROCESSORS}
  2708.   THREAD_TERMINATE            = ($0001);
  2709.   {$EXTERNALSYM THREAD_TERMINATE}
  2710.   THREAD_SUSPEND_RESUME       = ($0002);
  2711.   {$EXTERNALSYM THREAD_SUSPEND_RESUME}
  2712.   THREAD_GET_CONTEXT          = ($0008);
  2713.   {$EXTERNALSYM THREAD_GET_CONTEXT}
  2714.   THREAD_SET_CONTEXT          = ($0010);
  2715.   {$EXTERNALSYM THREAD_SET_CONTEXT}
  2716.   THREAD_SET_INFORMATION      = ($0020);
  2717.   {$EXTERNALSYM THREAD_SET_INFORMATION}
  2718.   THREAD_QUERY_INFORMATION    = ($0040);
  2719.   {$EXTERNALSYM THREAD_QUERY_INFORMATION}
  2720.   THREAD_SET_THREAD_TOKEN     = ($0080);
  2721.   {$EXTERNALSYM THREAD_SET_THREAD_TOKEN}
  2722.   THREAD_IMPERSONATE          = ($0100);
  2723.   {$EXTERNALSYM THREAD_IMPERSONATE}
  2724.   THREAD_DIRECT_IMPERSONATION = ($0200);
  2725.   {$EXTERNALSYM THREAD_DIRECT_IMPERSONATION}
  2726.   THREAD_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $3FF);
  2727.   {$EXTERNALSYM THREAD_ALL_ACCESS}
  2728.   JOB_OBJECT_ASSIGN_PROCESS          = ($0001);
  2729.   {$EXTERNALSYM JOB_OBJECT_ASSIGN_PROCESS}
  2730.   JOB_OBJECT_SET_ATTRIBUTES          = ($0002);
  2731.   {$EXTERNALSYM JOB_OBJECT_SET_ATTRIBUTES}
  2732.   JOB_OBJECT_QUERY                   = ($0004);
  2733.   {$EXTERNALSYM JOB_OBJECT_QUERY}
  2734.   JOB_OBJECT_TERMINATE               = ($0008);
  2735.   {$EXTERNALSYM JOB_OBJECT_TERMINATE}
  2736.   JOB_OBJECT_SET_SECURITY_ATTRIBUTES = ($0010);
  2737.   {$EXTERNALSYM JOB_OBJECT_SET_SECURITY_ATTRIBUTES}
  2738.   JOB_OBJECT_ALL_ACCESS              = (STANDARD_RIGHTS_REQUIRED or SYNCHRONIZE or $1F );
  2739.   {$EXTERNALSYM JOB_OBJECT_ALL_ACCESS}
  2740. type
  2741.   _JOB_SET_ARRAY = record
  2742.     JobHandle: HANDLE;   // Handle to job object to insert
  2743.     MemberLevel: DWORD;  // Level of this job in the set. Must be > 0. Can be sparse.
  2744.     Flags: DWORD;        // Unused. Must be zero
  2745.   end;
  2746.   {$EXTERNALSYM _JOB_SET_ARRAY}
  2747.   JOB_SET_ARRAY = _JOB_SET_ARRAY;
  2748.   {$EXTERNALSYM JOB_SET_ARRAY}
  2749.   PJOB_SET_ARRAY = ^JOB_SET_ARRAY;
  2750.   {$EXTERNALSYM PJOB_SET_ARRAY}
  2751.   TJobSetArray = JOB_SET_ARRAY;
  2752.   PJobSetArray = PJOB_SET_ARRAY;
  2753. const
  2754.   FLS_MAXIMUM_AVAILABLE = 128;
  2755.   {$EXTERNALSYM FLS_MAXIMUM_AVAILABLE}
  2756.   TLS_MINIMUM_AVAILABLE = 64;
  2757.   {$EXTERNALSYM TLS_MINIMUM_AVAILABLE}
  2758. type
  2759.   PEXCEPTION_REGISTRATION_RECORD = ^EXCEPTION_REGISTRATION_RECORD;
  2760.   _EXCEPTION_REGISTRATION_RECORD = packed record
  2761.     pNext: PEXCEPTION_REGISTRATION_RECORD;
  2762.     pfnHandler: FARPROC;
  2763.   end;
  2764.   EXCEPTION_REGISTRATION_RECORD = _EXCEPTION_REGISTRATION_RECORD;
  2765.   TExceptionRegistrationRecord = EXCEPTION_REGISTRATION_RECORD;
  2766.   PExceptionRegistrationRecord = PEXCEPTION_REGISTRATION_RECORD;
  2767.   PNT_TIB = ^NT_TIB;
  2768.   {$EXTERNALSYM PNT_TIB}
  2769.   _NT_TIB = record
  2770.     ExceptionList: PEXCEPTION_REGISTRATION_RECORD; // 00h Head of exception record list
  2771.     StackBase: PVOID;     // 04h Top of user stack
  2772.     StackLimit: PVOID;    // 08h Base of user stack
  2773.     //union                       // 0Ch (NT/Win95 differences)
  2774.     //{
  2775.     //    struct  // Win95 fields
  2776.     //    {
  2777.     //        WORD    pvTDB;         // 0Ch TDB
  2778.     //        WORD    pvThunkSS;     // 0Eh SS selector used for thunking to 16 bits
  2779.     //        DWORD   unknown1;      // 10h
  2780.     //    } WIN95;
  2781.     //
  2782.     //    struct  // WinNT fields
  2783.     //    {
  2784.     SubSystemTib: PVOID;     // 0Ch
  2785.     Union: record             // 10H
  2786.     case Integer of
  2787.       0: (FiberData: PVOID);
  2788.       1: (Version: DWORD);
  2789.     end;
  2790.     //    } WINNT;
  2791.     //} TIB_UNION1;
  2792.     ArbitraryUserPointer: PVOID;      // 14h Available for application use
  2793.     Self: PNT_TIB;          // 18h Linear address of TIB structure
  2794.     //union                       // 1Ch (NT/Win95 differences)
  2795.     //{
  2796.     //    struct  // Win95 fields
  2797.     //    {
  2798.     //        WORD    TIBFlags;           // 1Ch
  2799.     //        WORD    Win16MutexCount;    // 1Eh
  2800.     //        DWORD   DebugContext;       // 20h
  2801.     //        DWORD   pCurrentPriority;   // 24h
  2802.     //        DWORD   pvQueue;            // 28h Message Queue selector
  2803.     //    } WIN95;
  2804.     //