jwauserenv.pas 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884
  1. {******************************************************************************}
  2. { }
  3. { User Profile 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: userenv.h, released June 2000. The original Pascal }
  9. { code is: UserEnv.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott 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 }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaUserEnv.pas,v 1.12 2007/09/05 11:58:52 dezipaitor Exp $
  43. {$IFNDEF JWA_OMIT_SECTIONS}
  44. unit JwaUserEnv;
  45. {$WEAKPACKAGEUNIT}
  46. {$ENDIF JWA_OMIT_SECTIONS}
  47. {$HPPEMIT ''}
  48. {$HPPEMIT '#include "userenv.h"'}
  49. {$HPPEMIT ''}
  50. {$HPPEMIT 'typedef PGROUP_POLICY_OBJECTA *PPGROUP_POLICY_OBJECTA'}
  51. {$HPPEMIT 'typedef PGROUP_POLICY_OBJECTW *PPGROUP_POLICY_OBJECTW'}
  52. {$HPPEMIT ''}
  53. {$HPPEMIT 'typedef #ifdef UNICODE'}
  54. {$HPPEMIT 'typedef PPGROUP_POLICY_OBJECTW PPGROUP_POLICY_OBJECT'}
  55. {$HPPEMIT 'typedef #else'}
  56. {$HPPEMIT 'typedef PPGROUP_POLICY_OBJECTA PPGROUP_POLICY_OBJECT'}
  57. {$HPPEMIT 'typedef #endif'}
  58. {$HPPEMIT ''}
  59. {$IFNDEF JWA_OMIT_SECTIONS}
  60. {$I jediapilib.inc}
  61. interface
  62. uses
  63. JwaActiveX, JwaProfInfo, JwaWbemCli, JwaWinType, JWaWinBase, JwaWinNT;
  64. {$ENDIF JWA_OMIT_SECTIONS}
  65. //=============================================================================
  66. //
  67. // LoadUserProfile
  68. //
  69. // Loads the specified user's profile.
  70. //
  71. // Most applications should not need to use this function. It's used
  72. // when a user has logged onto the system or a service starts in a named
  73. // user account.
  74. //
  75. // hToken - Token for the user, returned from LogonUser()
  76. // lpProfileInfo - Address of a PROFILEINFO structure
  77. //
  78. // Returns: TRUE if successful
  79. // FALSE if not. Call GetLastError() for more details
  80. //
  81. // Note: The caller of this function must have admin privileges on the machine.
  82. //
  83. // Upon successful return, the hProfile member of the PROFILEINFO
  84. // structure is a registry key handle opened to the root
  85. // of the user's hive. It has been opened with full access. If
  86. // you need to read or write to the user's registry file, use
  87. // this key instead of HKEY_CURRENT_USER. Do not close this
  88. // handle. Instead pass it to UnloadUserProfile to close
  89. // the handle.
  90. //
  91. //=============================================================================
  92. {$IFNDEF JWA_IMPLEMENTATIONSECTION}
  93. //
  94. // Flags that can be set in the dwFlags field
  95. //
  96. const
  97. PI_NOUI = $00000001; // Prevents displaying of messages
  98. {$EXTERNALSYM PI_NOUI}
  99. PI_APPLYPOLICY = $00000002; // Apply NT4 style policy
  100. {$EXTERNALSYM PI_APPLYPOLICY}
  101. function LoadUserProfileA(hToken: HANDLE; var lpProfileInfo: PROFILEINFOA): BOOL; stdcall;
  102. {$EXTERNALSYM LoadUserProfileA}
  103. function LoadUserProfileW(hToken: HANDLE; var lpProfileInfo: PROFILEINFOW): BOOL; stdcall;
  104. {$EXTERNALSYM LoadUserProfileW}
  105. function LoadUserProfile(hToken: HANDLE; var lpProfileInfo: PROFILEINFO): BOOL; stdcall;
  106. {$EXTERNALSYM LoadUserProfile}
  107. //=============================================================================
  108. //
  109. // UnloadUserProfile
  110. //
  111. // Unloads a user's profile that was loaded by LoadUserProfile()
  112. //
  113. // hToken - Token for the user, returned from LogonUser()
  114. // hProfile - hProfile member of the PROFILEINFO structure
  115. //
  116. // Returns: TRUE if successful
  117. // FALSE if not. Call GetLastError() for more details
  118. //
  119. // Note: The caller of this function must have admin privileges on the machine.
  120. //
  121. //=============================================================================
  122. function UnloadUserProfile(hToken: HANDLE; hProfile: HANDLE): BOOL; stdcall;
  123. {$EXTERNALSYM UnloadUserProfile}
  124. //=============================================================================
  125. //
  126. // GetProfilesDirectory
  127. //
  128. // Returns the path to the root of where all user profiles are stored.
  129. //
  130. // lpProfilesDir - Receives the path
  131. // lpcchSize - Size of lpProfilesDir
  132. //
  133. // Returns: TRUE if successful
  134. // FALSE if not. Call GetLastError() for more details
  135. //
  136. // Note: If lpProfilesDir is not large enough, the function will fail,
  137. // and lpcchSize will contain the necessary buffer size.
  138. //
  139. // Example return value: C:\Documents and Settings
  140. //
  141. //=============================================================================
  142. function GetProfilesDirectoryA(lpProfilesDir: LPSTR; var lpcchSize: DWORD): BOOL; stdcall;
  143. {$EXTERNALSYM GetProfilesDirectoryA}
  144. function GetProfilesDirectoryW(lpProfilesDir: LPWSTR; var lpcchSize: DWORD): BOOL; stdcall;
  145. {$EXTERNALSYM GetProfilesDirectoryW}
  146. function GetProfilesDirectory(lpProfilesDir: LPTSTR; var lpcchSize: DWORD): BOOL; stdcall;
  147. {$EXTERNALSYM GetProfilesDirectory}
  148. //=============================================================================
  149. //
  150. // GetProfileType()
  151. //
  152. // Returns the type of the profile that is loaded for a user.
  153. //
  154. // dwFlags - Returns the profile flags
  155. //
  156. // Return: TRUE if successful
  157. // FALSE if an error occurs. Call GetLastError for more details
  158. //
  159. // Comments: if profile is not already loaded the function will return an error.
  160. // The caller needs to have access to HKLM part of the registry.
  161. // (exists by default)
  162. //
  163. //=============================================================================
  164. //
  165. // Flags that can be set in the dwFlags field
  166. //
  167. const
  168. PT_TEMPORARY = $00000001; // A profile has been allocated that will be deleted at logoff.
  169. {$EXTERNALSYM PT_TEMPORARY}
  170. PT_ROAMING = $00000002; // The loaded profile is a roaming profile.
  171. {$EXTERNALSYM PT_ROAMING}
  172. PT_MANDATORY = $00000004; // The loaded profile is mandatory.
  173. {$EXTERNALSYM PT_MANDATORY}
  174. function GetProfileType(var dwFlags: DWORD): BOOL; stdcall;
  175. {$EXTERNALSYM GetProfileType}
  176. //=============================================================================
  177. //
  178. // DeleteProfile()
  179. //
  180. // Deletes the profile and all other user related settings from the machine
  181. //
  182. // lpSidString - String form of the user sid.
  183. // lpProfilePath - ProfilePath (if Null, lookup in the registry)
  184. // lpComputerName - Computer Name from which profile has to be deleted
  185. //
  186. // Return: TRUE if successful
  187. // FALSE if an error occurs. Call GetLastError for more details
  188. //
  189. // Comments: Deletes the profile directory, registry and appmgmt stuff
  190. //=============================================================================
  191. function DeleteProfileA(lpSidString: LPCSTR; lpProfilePath: LPCSTR;
  192. lpComputerName: LPCSTR): BOOL; stdcall;
  193. {$EXTERNALSYM DeleteProfileA}
  194. function DeleteProfileW(lpSidString: LPCWSTR; lpProfilePath: LPCWSTR;
  195. lpComputerName: LPCWSTR): BOOL; stdcall;
  196. {$EXTERNALSYM DeleteProfileW}
  197. function DeleteProfile(lpSidString: LPCTSTR; lpProfilePath: LPCTSTR;
  198. lpComputerName: LPCTSTR): BOOL; stdcall;
  199. {$EXTERNALSYM DeleteProfile}
  200. //=============================================================================
  201. //
  202. // GetDefaultUserProfilesDirectory
  203. //
  204. // Returns the path to the root of the default user profile
  205. //
  206. // lpProfileDir - Receives the path
  207. // lpcchSize - Size of lpProfileDir
  208. //
  209. // Returns: TRUE if successful
  210. // FALSE if not. Call GetLastError() for more details
  211. //
  212. // Note: If lpProfileDir is not large enough, the function will fail,
  213. // and lpcchSize will contain the necessary buffer size.
  214. //
  215. // Example return value: C:\Documents and Settings\Default User
  216. //
  217. //=============================================================================
  218. function GetDefaultUserProfileDirectoryA(lpProfileDir: LPSTR; var lpcchSize: DWORD): BOOL; stdcall;
  219. {$EXTERNALSYM GetDefaultUserProfileDirectoryA}
  220. function GetDefaultUserProfileDirectoryW(lpProfileDir: LPWSTR; var lpcchSize: DWORD): BOOL; stdcall;
  221. {$EXTERNALSYM GetDefaultUserProfileDirectoryW}
  222. function GetDefaultUserProfileDirectory(lpProfileDir: LPTSTR; var lpcchSize: DWORD): BOOL; stdcall;
  223. {$EXTERNALSYM GetDefaultUserProfileDirectory}
  224. //=============================================================================
  225. //
  226. // GetAllUsersProfilesDirectory
  227. //
  228. // Returns the path to the root of the All Users profile
  229. //
  230. // lpProfileDir - Receives the path
  231. // lpcchSize - Size of lpProfileDir
  232. //
  233. // Returns: TRUE if successful
  234. // FALSE if not. Call GetLastError() for more details
  235. //
  236. // Note: If lpProfileDir is not large enough, the function will fail,
  237. // and lpcchSize will contain the necessary buffer size.
  238. //
  239. // Example return value: C:\Documents and Settings\All Users
  240. //
  241. //=============================================================================
  242. function GetAllUsersProfileDirectoryA(lpProfileDir: LPSTR; var lpcchSize: DWORD): BOOL; stdcall;
  243. {$EXTERNALSYM GetAllUsersProfileDirectoryA}
  244. function GetAllUsersProfileDirectoryW(lpProfileDir: LPWSTR; var lpcchSize: DWORD): BOOL; stdcall;
  245. {$EXTERNALSYM GetAllUsersProfileDirectoryW}
  246. function GetAllUsersProfileDirectory(lpProfileDir: LPTSTR; var lpcchSize: DWORD): BOOL; stdcall;
  247. {$EXTERNALSYM GetAllUsersProfileDirectory}
  248. //=============================================================================
  249. //
  250. // GetUserProfileDirectory
  251. //
  252. // Returns the path to the root of the requested user's profile
  253. //
  254. // hToken - User's token returned from LogonUser()
  255. // lpProfileDir - Receives the path
  256. // lpcchSize - Size of lpProfileDir
  257. //
  258. // Returns: TRUE if successful
  259. // FALSE if not. Call GetLastError() for more details
  260. //
  261. // Note: If lpProfileDir is not large enough, the function will fail,
  262. // and lpcchSize will contain the necessary buffer size.
  263. //
  264. // Example return value: C:\Documents and Settings\Joe
  265. //
  266. //=============================================================================
  267. function GetUserProfileDirectoryA(hToken: HANDLE; lpProfileDir: LPSTR;
  268. var lpcchSize: DWORD): BOOL; stdcall;
  269. {$EXTERNALSYM GetUserProfileDirectoryA}
  270. function GetUserProfileDirectoryW(hToken: HANDLE; lpProfileDir: LPWSTR;
  271. var lpcchSize: DWORD): BOOL; stdcall;
  272. {$EXTERNALSYM GetUserProfileDirectoryW}
  273. function GetUserProfileDirectory(hToken: HANDLE; lpProfileDir: LPTSTR;
  274. var lpcchSize: DWORD): BOOL; stdcall;
  275. {$EXTERNALSYM GetUserProfileDirectory}
  276. //=============================================================================
  277. //
  278. // CreateEnvironmentBlock
  279. //
  280. // Returns the environment variables for the specified user. This block
  281. // can then be passed to CreateProcessAsUser().
  282. //
  283. // lpEnvironment - Receives a pointer to the new environment block
  284. // hToken - User's token returned from LogonUser() (optional, can be NULL)
  285. // bInherit - Inherit from the current process's environment block
  286. // or start from a clean state.
  287. //
  288. // Returns: TRUE if successful
  289. // FALSE if not. Call GetLastError() for more details
  290. //
  291. // Note: If hToken is NULL, the returned environment block will contain
  292. // system variables only.
  293. //
  294. // Call DestroyEnvironmentBlock to free the buffer when finished.
  295. //
  296. // If this block is passed to CreateProcessAsUser, the
  297. // CREATE_UNICODE_ENVIRONMENT flag must also be set.
  298. //
  299. //=============================================================================
  300. function CreateEnvironmentBlock(lpEnvironment: LPLPVOID; hToken: HANDLE;
  301. bInherit: BOOL): BOOL; stdcall;
  302. {$EXTERNALSYM CreateEnvironmentBlock}
  303. //=============================================================================
  304. //
  305. // DestroyEnvironmentBlock
  306. //
  307. // Frees environment variables created by CreateEnvironmentBlock
  308. //
  309. // lpEnvironment - A pointer to the environment block
  310. //
  311. // Returns: TRUE if successful
  312. // FALSE if not. Call GetLastError() for more details
  313. //
  314. //=============================================================================
  315. function DestroyEnvironmentBlock(lpEnvironment: LPVOID): BOOL; stdcall;
  316. {$EXTERNALSYM DestroyEnvironmentBlock}
  317. //=============================================================================
  318. //
  319. // ExpandEnvironmentStringsForUser
  320. //
  321. // Expands the source string using the environment block for the
  322. // specified user. If hToken is null, the system environment block
  323. // will be used (no user environment variables).
  324. //
  325. // hToken - User's token returned from LogonUser() (optional, can be NULL)
  326. // lpSrc - Pointer to the string with environment variables
  327. // lpDest - Buffer that receives the expanded string
  328. // dwSize - Size of lpDest in characters (max chars)
  329. //
  330. // Returns: TRUE if successful
  331. // FALSE if not. Call GetLastError() for more details
  332. //
  333. // Note: If the user profile for hToken is not loaded, this api will fail.
  334. //
  335. //=============================================================================
  336. function ExpandEnvironmentStringsForUserA(hToken: HANDLE; lpSrc: LPCSTR;
  337. lpDest: LPSTR; dwSize: DWORD): BOOL; stdcall;
  338. {$EXTERNALSYM ExpandEnvironmentStringsForUserA}
  339. function ExpandEnvironmentStringsForUserW(hToken: HANDLE; lpSrc: LPCWSTR;
  340. lpDest: LPWSTR; dwSize: DWORD): BOOL; stdcall;
  341. {$EXTERNALSYM ExpandEnvironmentStringsForUserW}
  342. function ExpandEnvironmentStringsForUser(hToken: HANDLE; lpSrc: LPCTSTR;
  343. lpDest: LPTSTR; dwSize: DWORD): BOOL; stdcall;
  344. {$EXTERNALSYM ExpandEnvironmentStringsForUser}
  345. //=============================================================================
  346. //
  347. // RefreshPolicy()
  348. //
  349. // Causes group policy to be applied immediately on the client machine
  350. //
  351. // bMachine - Refresh machine or user policy
  352. //
  353. // Returns: TRUE if successful
  354. // FALSE if not. Call GetLastError() for more details
  355. //
  356. //=============================================================================
  357. function RefreshPolicy(bMachine: BOOL): BOOL; stdcall;
  358. {$EXTERNALSYM RefreshPolicy}
  359. //=============================================================================
  360. //
  361. // RefreshPolicyEx()
  362. //
  363. // Causes group policy to be applied immediately on the client machine.
  364. //
  365. // bMachine - Refresh machine or user policy
  366. // dwOptions - Option specifying the kind of refresh that needs to be done.
  367. //
  368. // Returns: TRUE if successful
  369. // FALSE if not. Call GetLastError() for more details
  370. //
  371. //=============================================================================
  372. const
  373. RP_FORCE = 1; // Refresh policies without any optimisations.
  374. {$EXTERNALSYM RP_FORCE}
  375. function RefreshPolicyEx(bMachine: BOOL; dwOptions: DWORD): BOOL; stdcall;
  376. {$EXTERNALSYM RefreshPolicyEx}
  377. //=============================================================================
  378. //
  379. // EnterCriticalPolicySection
  380. //
  381. // Pauses the background application of group policy to allow safe
  382. // reading of the registry. Applications that need to read multiple
  383. // policy entries and ensure that the values are not changed while reading
  384. // them should use this function.
  385. //
  386. // The maximum amount of time an application can hold a critical section
  387. // is 10 minutes. After 10 minutes, policy can be applied again.
  388. //
  389. // bMachine - Pause machine or user policy
  390. //
  391. // Returns: Handle if successful
  392. // NULL if not. Call GetLastError() for more details
  393. //
  394. // Note 1: The handle returned should be passed to LeaveCriticalPolicySection
  395. // when finished. Do not close this handle, LeaveCriticalPolicySection
  396. // will do that.
  397. //
  398. // Note 2: If both user and machine critical sections need to be acquired then
  399. // they should be done in this order: first acquire user critical section and
  400. // then acquire machine critical section.
  401. //
  402. //=============================================================================
  403. function EnterCriticalPolicySection(bMachine: BOOL): HANDLE; stdcall;
  404. {$EXTERNALSYM EnterCriticalPolicySection}
  405. //=============================================================================
  406. //
  407. // LeaveCriticalPolicySection
  408. //
  409. // Resumes the background application of group policy. See
  410. // EnterCriticalPolicySection for more details.
  411. //
  412. // hSection - Handle returned from EnterCriticalPolicySection
  413. //
  414. // Returns: TRUE if successful
  415. // FALSE if not. Call GetLastError() for more details
  416. //
  417. // Note: This function will close the handle.
  418. //
  419. //=============================================================================
  420. function LeaveCriticalPolicySection(hSection: HANDLE): BOOL; stdcall;
  421. {$EXTERNALSYM LeaveCriticalPolicySection}
  422. //=============================================================================
  423. //
  424. // RegisterGPNotification
  425. //
  426. // Entry point for registering for Group Policy change notification.
  427. //
  428. // Parameters: hEvent - Event to be notified, by calling SetEvent(hEvent)
  429. // bMachine - If true, then register machine policy notification
  430. // else register user policy notification
  431. //
  432. // Returns: True if successful
  433. // False if error occurs
  434. //
  435. // Notes: Group Policy Notifications. There are 2 ways an application can
  436. // be notify when Group Policy is finished being applied.
  437. //
  438. // 1) Using the RegisterGPNotifcation function and waiting for the
  439. // event to be signalled.
  440. //
  441. // 2) A WM_SETTINGCHANGE message is broadcast to all desktops.
  442. // wParam - 1 if machine policy was applied, 0 if user policy was applied.
  443. // lParam - Points to the string "Policy"
  444. //
  445. //=============================================================================
  446. function RegisterGPNotification(hEvent: HANDLE; bMachine: BOOL): BOOL; stdcall;
  447. {$EXTERNALSYM RegisterGPNotification}
  448. //=============================================================================
  449. //
  450. // UnregisterGPNotification
  451. //
  452. // Removes registration for a Group Policy change notification.
  453. //
  454. // Parameters: hEvent - Event to be removed
  455. //
  456. // Returns: True if successful
  457. // False if error occurs
  458. //
  459. //=============================================================================
  460. function UnregisterGPNotification(hEvent: HANDLE): BOOL; stdcall;
  461. {$EXTERNALSYM UnregisterGPNotification}
  462. //=============================================================================
  463. //
  464. // GPOptions flags
  465. //
  466. // These are the flags found in the GPOptions property of a DS object
  467. //
  468. // For a given DS object (Site, Domain, OU), the GPOptions property
  469. // contains options that effect all the GPOs link to this SDOU.
  470. //
  471. // This is a DWORD type
  472. //
  473. //=============================================================================
  474. const
  475. GPC_BLOCK_POLICY = $00000001; // Block all non-forced policy from above
  476. {$EXTERNALSYM GPC_BLOCK_POLICY}
  477. //=============================================================================
  478. //
  479. // GPLink flags
  480. //
  481. // These are the flags found on the GPLink property of a DS object after
  482. // the GPO path.
  483. //
  484. // For a given DS object (Site, Domain, OU), the GPLink property will
  485. // be in this text format
  486. //
  487. // [LDAP://CN={E615A0E3-C4F1-11D1-A3A7-00AA00615092},CN=Policies,CN=System,DC=mydomain,DC=Microsoft,DC=Com;1]
  488. //
  489. // The GUID is the GPO name, and the number following the LDAP path are the options
  490. // for that link from this DS object. Note, there can be multiple GPOs
  491. // each in their own square brackets in a prioritized list.
  492. //
  493. //=============================================================================
  494. //
  495. // Options for a GPO link
  496. //
  497. const
  498. GPO_FLAG_DISABLE = $00000001; // This GPO is disabled
  499. {$EXTERNALSYM GPO_FLAG_DISABLE}
  500. GPO_FLAG_FORCE = $00000002; // Don't override the settings in
  501. {$EXTERNALSYM GPO_FLAG_FORCE} // this GPO with settings from a GPO below it.
  502. //=============================================================================
  503. //
  504. // GetGPOList
  505. //
  506. //
  507. // Queries for the list of Group Policy Objects for the specified
  508. // user or machine. This function will return a link list
  509. // of Group Policy Objects. Call FreeGPOList to free the list.
  510. //
  511. // Note, most applications will not need to call this function.
  512. // This will primarily be used by services acting on behalf of
  513. // another user or machine. The caller of this function will
  514. // need to look in each GPO for their specific policy
  515. //
  516. // This function can be called in two different ways. Either the hToken for
  517. // a user or machine can be supplied and the correct name and domain
  518. // controller name will be generated, or hToken is NULL and the caller
  519. // must supply the name and the domain controller name.
  520. //
  521. // Calling this function with an hToken ensures the list of Group Policy
  522. // Objects is correct for the user or machine since security access checking
  523. // can be perfomed. If hToken is not supplied, the security of the caller
  524. // is used instead which means that list may or may not be 100% correct
  525. // for the intended user / machine. However, this is the fastest way
  526. // to call this function.
  527. //
  528. // hToken - User or machine token, if NULL, lpName and lpHostName must be supplied
  529. // lpName - User or machine name in DN format, if hToken is supplied, this must be NULL
  530. // lpHostName - Domain DN name or domain controller name. If hToken is supplied, this must be NULL
  531. // lpComputerName - Computer name to use to determine site location. If NULL,
  532. // the local computer is used as the reference. Format: \\machinename
  533. // dwFlags - Flags field. See flags definition below
  534. // pGPOList - Address of a pointer which receives the link list of GPOs
  535. //
  536. //
  537. // Returns: TRUE if successful
  538. // FALSE if not. Use GetLastError() for more details.
  539. //
  540. // Examples:
  541. //
  542. // Here's how this function will typically be called for
  543. // looking up the list of GPOs for a user:
  544. //
  545. // LPGROUP_POLICY_OBJECT pGPOList;
  546. //
  547. // if (GetGPOList (hToken, NULL, NULL, NULL, 0, &pGPOList))
  548. // {
  549. // // do processing here...
  550. // FreeGPOList (pGPOList);
  551. // }
  552. //
  553. //
  554. // Here's how this function will typically be called for
  555. // looking up the list of GPOs for a machine:
  556. //
  557. // LPGROUP_POLICY_OBJECT pGPOList;
  558. //
  559. // if (GetGPOList (NULL, lpMachineName, lpHostName, lpMachineName,
  560. // GPO_LIST_FLAG_MACHINE, &pGPOList))
  561. // {
  562. // // do processing here...
  563. // FreeGPOList (pGPOList);
  564. // }
  565. //
  566. //=============================================================================
  567. //
  568. // Each Group Policy Object is associated (linked) with a site, domain,
  569. // organizational unit, or machine.
  570. //
  571. type
  572. _GPO_LINK = (
  573. GPLinkUnknown, // No link information available
  574. GPLinkMachine, // GPO linked to a machine (local or remote)
  575. GPLinkSite, // GPO linked to a site
  576. GPLinkDomain, // GPO linked to a domain
  577. GPLinkOrganizationalUnit); // GPO linked to a organizational unit
  578. {$EXTERNALSYM _GPO_LINK}
  579. GPO_LINK = _GPO_LINK;
  580. {$EXTERNALSYM GPO_LINK}
  581. PGPO_LINK = ^GPO_LINK;
  582. {$EXTERNALSYM PGPO_LINK}
  583. TGpoLink = GPO_LINK;
  584. PGpoLink = PGPO_LINK;
  585. PGROUP_POLICY_OBJECTA = ^GROUP_POLICY_OBJECTA;
  586. {$EXTERNALSYM PGROUP_POLICY_OBJECTA}
  587. _GROUP_POLICY_OBJECTA = record
  588. dwOptions: DWORD; // See GPLink option flags above
  589. dwVersion: DWORD; // Revision number of the GPO
  590. lpDSPath: LPSTR; // Path to the Active Directory portion of the GPO
  591. lpFileSysPath: LPSTR; // Path to the file system portion of the GPO
  592. lpDisplayName: LPSTR; // Friendly display name
  593. szGPOName: array [0..49] of CHAR; // Unique name
  594. GPOLink: GPO_LINK; // Link information
  595. lParam: LPARAM; // Free space for the caller to store GPO specific information
  596. pNext: PGROUP_POLICY_OBJECTA; // Next GPO in the list
  597. pPrev: PGROUP_POLICY_OBJECTA; // Previous GPO in the list
  598. lpExtensions: LPSTR; // Extensions that are relevant for this GPO
  599. lParam2: LPARAM; // Free space for the caller to store GPO specific information
  600. lpLink: LPSTR; // Path to the Active Directory site, domain, or organizational unit this GPO is linked to
  601. // If this is the local GPO, this points to the word "Local"
  602. end;
  603. {$EXTERNALSYM _GROUP_POLICY_OBJECTA}
  604. GROUP_POLICY_OBJECTA = _GROUP_POLICY_OBJECTA;
  605. {$EXTERNALSYM GROUP_POLICY_OBJECTA}
  606. TGroupPolicyObjectA = GROUP_POLICY_OBJECTA;
  607. PGroupPolicyObjectA = PGROUP_POLICY_OBJECTA;
  608. PGROUP_POLICY_OBJECTW = ^GROUP_POLICY_OBJECTW;
  609. {$EXTERNALSYM PGROUP_POLICY_OBJECTW}
  610. _GROUP_POLICY_OBJECTW = record
  611. dwOptions: DWORD; // See GPLink option flags above
  612. dwVersion: DWORD; // Revision number of the GPO
  613. lpDSPath: LPWSTR; // Path to the Active Directory portion of the GPO
  614. lpFileSysPath: LPWSTR; // Path to the file system portion of the GPO
  615. lpDisplayName: LPWSTR; // Friendly display name
  616. szGPOName: array [0..49] of WCHAR; // Unique name
  617. GPOLink: GPO_LINK; // Link information
  618. lParam: LPARAM; // Free space for the caller to store GPO specific information
  619. pNext: PGROUP_POLICY_OBJECTW; // Next GPO in the list
  620. pPrev: PGROUP_POLICY_OBJECTW; // Previous GPO in the list
  621. lpExtensions: LPWSTR; // Extensions that are relevant for this GPO
  622. lParam2: LPARAM; // Free space for the caller to store GPO specific information
  623. lpLink: LPWSTR; // Path to the Active Directory site, domain, or organizational unit this GPO is linked to
  624. // If this is the local GPO, this points to the word "Local"
  625. end;
  626. {$EXTERNALSYM _GROUP_POLICY_OBJECTW}
  627. GROUP_POLICY_OBJECTW = _GROUP_POLICY_OBJECTW;
  628. {$EXTERNALSYM GROUP_POLICY_OBJECTW}
  629. TGroupPolicyObjectW = GROUP_POLICY_OBJECTW;
  630. PGroupPolicyObjectW = PGROUP_POLICY_OBJECTW;
  631. PPGROUP_POLICY_OBJECTA = ^PGROUP_POLICY_OBJECTA;
  632. {$NODEFINE PPGROUP_POLICY_OBJECTA}
  633. PPGROUP_POLICY_OBJECTW = ^PGROUP_POLICY_OBJECTW;
  634. {$NODEFINE PPGROUP_POLICY_OBJECTW}
  635. {$IFDEF UNICODE}
  636. GROUP_POLICY_OBJECT = GROUP_POLICY_OBJECTW;
  637. {$EXTERNALSYM GROUP_POLICY_OBJECT}
  638. PGROUP_POLICY_OBJECT = PGROUP_POLICY_OBJECTW;
  639. {$EXTERNALSYM PGROUP_POLICY_OBJECT}
  640. PPGROUP_POLICY_OBJECT = PPGROUP_POLICY_OBJECTW;
  641. {$NODEFINE PPGROUP_POLICY_OBJECT}
  642. TGroupPolicyObject = TGroupPolicyObjectW;
  643. PGroupPolicyObject = PGroupPolicyObjectW;
  644. {$ELSE}
  645. GROUP_POLICY_OBJECT = GROUP_POLICY_OBJECTA;
  646. {$EXTERNALSYM GROUP_POLICY_OBJECT}
  647. PGROUP_POLICY_OBJECT = PGROUP_POLICY_OBJECTA;
  648. {$EXTERNALSYM PGROUP_POLICY_OBJECT}
  649. PPGROUP_POLICY_OBJECT = PPGROUP_POLICY_OBJECTA;
  650. {$NODEFINE PPGROUP_POLICY_OBJECT}
  651. TGroupPolicyObject = TGroupPolicyObjectA;
  652. PGroupPolicyObject = PGroupPolicyObjectA;
  653. {$ENDIF UNICODE}
  654. //
  655. // dwFlags for GetGPOList()
  656. //
  657. const
  658. GPO_LIST_FLAG_MACHINE = $00000001; // Return machine policy information
  659. {$EXTERNALSYM GPO_LIST_FLAG_MACHINE}
  660. GPO_LIST_FLAG_SITEONLY = $00000002; // Return site policy information only
  661. {$EXTERNALSYM GPO_LIST_FLAG_SITEONLY}
  662. function GetGPOListA(hToken: HANDLE; lpName: LPCSTR; lpHostName: LPCSTR;
  663. lpComputerName: LPCSTR; dwFlags: DWORD; pGPOList: PPGROUP_POLICY_OBJECTA): BOOL; stdcall;
  664. {$EXTERNALSYM GetGPOListA}
  665. function GetGPOListW(hToken: HANDLE; lpName: LPCWSTR; lpHostName: LPCWSTR;
  666. lpComputerName: LPCWSTR; dwFlags: DWORD; pGPOList: PPGROUP_POLICY_OBJECTW): BOOL; stdcall;
  667. {$EXTERNALSYM GetGPOListW}
  668. function GetGPOList(hToken: HANDLE; lpName: LPCTSTR; lpHostName: LPCTSTR;
  669. lpComputerName: LPCTSTR; dwFlags: DWORD; pGPOList: PPGROUP_POLICY_OBJECT): BOOL; stdcall;
  670. {$EXTERNALSYM GetGPOList}
  671. //=============================================================================
  672. //
  673. // FreeGPOList
  674. //
  675. //
  676. // Frees the linked list returned from GetGPOList
  677. //
  678. // pGPOList - Pointer to the linked list of GPOs
  679. //
  680. //
  681. // Returns: TRUE if successful
  682. // FALSE if not
  683. //
  684. //=============================================================================
  685. function FreeGPOListA(pGPOList: PGROUP_POLICY_OBJECTA): BOOL; stdcall;
  686. {$EXTERNALSYM FreeGPOListA}
  687. function FreeGPOListW(pGPOList: PGROUP_POLICY_OBJECTW): BOOL; stdcall;
  688. {$EXTERNALSYM FreeGPOListW}
  689. function FreeGPOList(pGPOList: PGROUP_POLICY_OBJECT): BOOL; stdcall;
  690. {$EXTERNALSYM FreeGPOList}
  691. //=============================================================================
  692. //
  693. // GetAppliedGPOList
  694. //
  695. // Queries for the list of applied Group Policy Objects for the specified
  696. // user or machine and specified client side extension. This function will return
  697. // a linked listof Group Policy Objects. Call FreeGPOList to free the list.
  698. //
  699. // dwFlags - User or machine policy, if it is GPO_LIST_FLAG_MACHINE then
  700. // return machine policy information
  701. // pMachineName - Name of remote computer in the form \\computername. If null
  702. // then local computer is used.
  703. // pSidUser - Security id of user (relevant for user policy). If pMachineName is
  704. // null and pSidUser is null then it means current logged on user.
  705. // If pMachine is null and pSidUser is non-null then it means user
  706. // represented by pSidUser on local machine. If pMachineName is non-null
  707. // then and if dwFlags specifies user policy, then pSidUser must be
  708. // non-null.
  709. // pGuidExtension - Guid of the specified extension
  710. // ppGPOList - Address of a pointer which receives the link list of GPOs
  711. //
  712. // The return value is a Win32 error code. ERROR_SUCCESS means the GetAppliedGPOList
  713. // function completed successfully. Otherwise it indicates that the function failed.
  714. //
  715. //=============================================================================
  716. function GetAppliedGPOListA(dwFlags: DWORD; pMachineName: LPCSTR; pSidUser: PSID;
  717. pGuidExtension: LPGUID; ppGPOList: PPGROUP_POLICY_OBJECTA): DWORD; stdcall;
  718. {$EXTERNALSYM GetAppliedGPOListA}
  719. function GetAppliedGPOListW(dwFlags: DWORD; pMachineName: LPCWSTR; pSidUser: PSID;
  720. pGuidExtension: LPGUID; ppGPOList: PPGROUP_POLICY_OBJECTW): DWORD; stdcall;
  721. {$EXTERNALSYM GetAppliedGPOListW}
  722. function GetAppliedGPOList(dwFlags: DWORD; pMachineName: LPCTSTR; pSidUser: PSID;
  723. pGuidExtension: LPGUID; ppGPOList: PPGROUP_POLICY_OBJECT): DWORD; stdcall;
  724. {$EXTERNALSYM GetAppliedGPOList}
  725. //=============================================================================
  726. //
  727. // Group Policy Object client side extension support
  728. //
  729. // Flags, data structures and function prototype
  730. //
  731. // To register your extension, create a subkey under this key
  732. //
  733. // Software\Microsoft\Windows NT\CurrentVersion\Winlogon\GPExtensions
  734. //
  735. // The subkey needs to be a guid so that it is unique. The noname value of the subkey
  736. // can be the friendly name of the extension. Then add these values:
  737. //
  738. // DllName REG_EXPAND_SZ Path to your DLL
  739. // ProcessGroupPolicy REG_SZ Function name (see PFNPROCESSGROUPPOLICY prototype). This
  740. // is obsolete, it has been superseded by ProcessGroupPolicyEx.
  741. // It's here for backward compatibility reasons only.
  742. // ProcessGroupPolicyEx REG_SZ Function name (see PFNPROCESSGROUPPOLICYEX prototype)
  743. // GenerateGroupPolicy REG_SZ Function name for Rsop (see PFNGENERATEGROUPPOLICY prototype)
  744. // NoMachinePolicy REG_DWORD True, if extension does not have to be called when
  745. // machine policies are being processed.
  746. // NoUserPolicy REG_DWORD True, if extension does not have to be called when
  747. // user policies are being processed.
  748. // NoSlowLink REG_DWORD True, if extension does not have to be called on a slow link
  749. // NoBackgroundPolicy REG_DWORD True, if extension does not have to be called
  750. // for background policy processing.
  751. // NoGPOListChanges REG_DWORD True, if extension does not have to be called when
  752. // there are no changes between cached and current GPO lists.
  753. // PerUserLocalSettings REG_DWORD True, if user policies have to be cached on a per user and
  754. // per machine basis.
  755. // RequiresSuccessfulRegistry REG_DWORD True, if extension should be called only if registry extension
  756. // was successfully processed.
  757. // EnableAsynchronousProcessing REG_DWORD True, if registry extension will complete its processing
  758. // asynchronously.
  759. // NotifyLinkTransition REG_DWORD True, if extension should be called when a change in link
  760. // speed is detected between previous policy application and
  761. // current policy application.
  762. //
  763. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicy
  764. // function completed successfully. If return value is ERROR_OVERRIDE_NOCHANGES then it
  765. // means that the extension will be called the next time even if NoGPOListChanges is set
  766. // and there are no changes to the GPO list. Any other return value indicates that the
  767. // ProcessGroupPolicy or ProcessGroupPolicyEx function failed.
  768. //
  769. //=============================================================================
  770. const
  771. GP_DLLNAME = 'DllName';
  772. {$EXTERNALSYM GP_DLLNAME}
  773. GP_ENABLEASYNCHRONOUSPROCESSING = 'EnableAsynchronousProcessing';
  774. {$EXTERNALSYM GP_ENABLEASYNCHRONOUSPROCESSING}
  775. GP_MAXNOGPOLISTCHANGESINTERVAL = 'MaxNoGPOListChangesInterval';
  776. {$EXTERNALSYM GP_MAXNOGPOLISTCHANGESINTERVAL}
  777. GP_NOBACKGROUNDPOLICY = 'NoBackgroundPolicy';
  778. {$EXTERNALSYM GP_NOBACKGROUNDPOLICY}
  779. GP_NOGPOLISTCHANGES = 'NoGPOListChanges';
  780. {$EXTERNALSYM GP_NOGPOLISTCHANGES}
  781. GP_NOMACHINEPOLICY = 'NoMachinePolicy';
  782. {$EXTERNALSYM GP_NOMACHINEPOLICY}
  783. GP_NOSLOWLINK = 'NoSlowLink';
  784. {$EXTERNALSYM GP_NOSLOWLINK}
  785. GP_NOTIFYLINKTRANSITION = 'NotifyLinkTransition';
  786. {$EXTERNALSYM GP_NOTIFYLINKTRANSITION}
  787. GP_NOUSERPOLICY = 'NoUserPolicy';
  788. {$EXTERNALSYM GP_NOUSERPOLICY}
  789. GP_PERUSERLOCALSETTINGS = 'PerUserLocalSettings';
  790. {$EXTERNALSYM GP_PERUSERLOCALSETTINGS}
  791. GP_PROCESSGROUPPOLICY = 'ProcessGroupPolicy';
  792. {$EXTERNALSYM GP_PROCESSGROUPPOLICY}
  793. GP_REQUIRESSUCCESSFULREGISTRY = 'RequiresSuccessfulRegistry';
  794. {$EXTERNALSYM GP_REQUIRESSUCCESSFULREGISTRY}
  795. GPO_INFO_FLAG_MACHINE = $00000001; // Apply machine policy rather than user policy
  796. {$EXTERNALSYM GPO_INFO_FLAG_MACHINE}
  797. GPO_INFO_FLAG_BACKGROUND = $00000010; // Background refresh of policy (ok to do slow stuff)
  798. {$EXTERNALSYM GPO_INFO_FLAG_BACKGROUND}
  799. GPO_INFO_FLAG_SLOWLINK = $00000020; // Policy is being applied across a slow link
  800. {$EXTERNALSYM GPO_INFO_FLAG_SLOWLINK}
  801. GPO_INFO_FLAG_VERBOSE = $00000040; // Verbose output to the eventlog
  802. {$EXTERNALSYM GPO_INFO_FLAG_VERBOSE}
  803. GPO_INFO_FLAG_NOCHANGES = $00000080; // No changes were detected to the Group Policy Objects
  804. {$EXTERNALSYM GPO_INFO_FLAG_NOCHANGES}
  805. GPO_INFO_FLAG_LINKTRANSITION = $00000100; // A change in link speed was detected between previous policy
  806. {$EXTERNALSYM GPO_INFO_FLAG_LINKTRANSITION} // application and current policy application
  807. GPO_INFO_FLAG_LOGRSOP_TRANSITION = $00000200; // A Change in Rsop Logging was detected between previous policy
  808. {$EXTERNALSYM GPO_INFO_FLAG_LOGRSOP_TRANSITION} // application and current policy application, (new intf only)
  809. GPO_INFO_FLAG_FORCED_REFRESH = $00000400; // Forced Refresh is being applied. redo policies.
  810. {$EXTERNALSYM GPO_INFO_FLAG_FORCED_REFRESH}
  811. GPO_INFO_FLAG_SAFEMODE_BOOT = $00000800; // windows safe mode boot flag
  812. {$EXTERNALSYM GPO_INFO_FLAG_SAFEMODE_BOOT}
  813. GPO_INFO_FLAG_ASYNC_FOREGROUND = $00001000; // Asynchronous foreground refresh of policy
  814. {$EXTERNALSYM GPO_INFO_FLAG_ASYNC_FOREGROUND}
  815. GPO_INFO_FLAG_REPORT = $00002000; // Report all settings for one GPO rather than the resultant settings across multiple GPOs
  816. {$EXTERNALSYM GPO_INFO_FLAG_REPORT}
  817. type
  818. ASYNCCOMPLETIONHANDLE = UINT_PTR;
  819. {$EXTERNALSYM ASYNCCOMPLETIONHANDLE}
  820. PFNSTATUSMESSAGECALLBACK = function(bVerbose: BOOL; lpMessage: LPWSTR): DWORD; stdcall;
  821. {$EXTERNALSYM PFNSTATUSMESSAGECALLBACK}
  822. PFNPROCESSGROUPPOLICY = function(
  823. dwFlags: DWORD; // GPO_INFO_FLAGS
  824. hToken: HANDLE; // User or machine token
  825. hKeyRoot: HKEY; // Root of registry
  826. pDeletedGPOList: PGROUP_POLICY_OBJECT; // Linked list of deleted GPOs
  827. pChangedGPOList: PGROUP_POLICY_OBJECT; // Linked list of changed GPOs
  828. pHandle: ASYNCCOMPLETIONHANDLE; // For asynchronous completion
  829. pbAbort: LPBOOL; // If true, then abort GPO processing
  830. pStatusCallback: PFNSTATUSMESSAGECALLBACK // Callback function for displaying status messages
  831. ): DWORD; stdcall; // Note, this can be NULL
  832. {$EXTERNALSYM PFNPROCESSGROUPPOLICY}
  833. PFNPROCESSGROUPPOLICYEX = function(
  834. dwFlags: DWORD; // GPO_INFO_FLAGS
  835. hToken: HANDLE; // User or machine token
  836. hKeyRoot: HKEY; // Root of registry
  837. pDeletedGPOList: PGROUP_POLICY_OBJECT; // Linked list of deleted GPOs
  838. pChangedGPOList: PGROUP_POLICY_OBJECT; // Linked list of changed GPOs
  839. pHandle: ASYNCCOMPLETIONHANDLE; // For asynchronous completion
  840. pbAbort: PBOOL; // If true, then abort GPO processing
  841. pStatusCallback: PFNSTATUSMESSAGECALLBACK; // Callback function for displaying status messages
  842. // Note, this can be NULL
  843. pWbemServices: IWbemServices; // Pointer to namespace to log diagnostic mode data
  844. // Note, this will be NULL when Rsop logging is disabled
  845. var pRsopStatus: HRESULT // RSOP Logging succeeded or not.
  846. ): DWORD; stdcall;
  847. {$EXTERNALSYM PFNPROCESSGROUPPOLICYEX}
  848. PRSOPTOKEN = PVOID;
  849. {$EXTERNALSYM PRSOPTOKEN}
  850. _RSOP_TARGET = record
  851. pwszAccountName: PWCHAR; // Account name
  852. pwszNewSOM: PWCHAR; // New domain or OU location for account
  853. psaSecurityGroups: PSafeArray; // New security groups
  854. pRsopToken: PRSOPTOKEN; // Rsop token for use with Rsop security Api's
  855. pGPOList: PGROUP_POLICY_OBJECT; // Linked list of GPOs
  856. pWbemServices: IWbemServices; // Pointer to namespace to log planning mode data
  857. end;
  858. {$EXTERNALSYM _RSOP_TARGET}
  859. RSOP_TARGET = _RSOP_TARGET;
  860. {$EXTERNALSYM RSOP_TARGET}
  861. PRSOP_TARGET = ^RSOP_TARGET;
  862. {$EXTERNALSYM PRSOP_TARGET}
  863. TRsopTarget = RSOP_TARGET;
  864. PRsopTarget = PRSOP_TARGET;
  865. PFNGENERATEGROUPPOLICY = function(
  866. dwFlags: DWORD; // GPO_INFO_FLAGS
  867. var pbAbort: BOOL; // If true, then abort GPO processing
  868. pwszSite: PWCHAR; // Site the target computer is in
  869. pComputerTarget: PRSOP_TARGET; // Computer target info, can be null
  870. pUserTarget: PRSOP_TARGET // User target info, can be null
  871. ): DWORD; stdcall;
  872. {$EXTERNALSYM PFNGENERATEGROUPPOLICY}
  873. //
  874. // GUID that identifies the registry extension
  875. //
  876. const
  877. REGISTRY_EXTENSION_GUID: GUID = (
  878. D1: $35378EAC; D2:$683F; D3:$11D2; D4:($A8, $9A, $00, $C0, $4F, $BB, $CF, $A2));
  879. {$EXTERNALSYM REGISTRY_EXTENSION_GUID}
  880. //=============================================================================
  881. //
  882. // Group Policy Object client side asynchronous extension processing
  883. //
  884. // extensionId - Unique guid identifying the extension
  885. // pAsyncHandle - Asynchronous completion handle that was passed to extension in
  886. // ProcessGroupPolicy call
  887. // dwStatus - Completion status of asynchronous processing
  888. //
  889. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
  890. // function completed successfully. Otherwise it indicates that the function failed.
  891. //
  892. //=============================================================================
  893. type
  894. REFGPEXTENSIONID = LPGUID;
  895. {$EXTERNALSYM REFGPEXTENSIONID}
  896. function ProcessGroupPolicyCompleted(extensionId: REFGPEXTENSIONID;
  897. pAsyncHandle: ASYNCCOMPLETIONHANDLE; dwStatus: DWORD): DWORD; stdcall;
  898. {$EXTERNALSYM ProcessGroupPolicyCompleted}
  899. //=============================================================================
  900. //
  901. // Group Policy Object client side asynchronous extension processing
  902. //
  903. // extensionId - Unique guid identifying the extension
  904. // pAsyncHandle - Asynchronous completion handle that was passed to extension in
  905. // ProcessGroupPolicy call
  906. // dwStatus - Completion status of asynchronous processing
  907. // RsopStatus - RSoP Logging status
  908. //
  909. // The return value is a Win32 error code. ERROR_SUCCESS means the ProcessGroupPolicyCompleted
  910. // function completed successfully. Otherwise it indicates that the function failed.
  911. //
  912. //=============================================================================
  913. function ProcessGroupPolicyCompletedEx(extensionId: REFGPEXTENSIONID; pAsyncHandle: ASYNCCOMPLETIONHANDLE;
  914. dwStatus: DWORD; RsopStatus: HRESULT): DWORD; stdcall;
  915. {$EXTERNALSYM ProcessGroupPolicyCompletedEx}
  916. //=============================================================================
  917. //
  918. // Function: RsopAccessCheckByType
  919. //
  920. // Description: Determines whether the security descriptor pointed to by pSecurityDescriptor
  921. // grants the set of access rights specified in dwDesiredAccessMask
  922. // to the client identified by the RSOPTOKEN pointed to by pRsopToken.
  923. //
  924. // pSecurityDescriptor - Security Descriptor on the object
  925. // pPrincipalSelfSid - Principal Sid
  926. // pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
  927. // dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
  928. // pObjectTypeList - Object Type List
  929. // ObjectTypeListLength - Object Type List Length
  930. // pGenericMapping - Generic Mapping
  931. // pPrivilegeSet - privilege set
  932. // pdwPrivilegeSetLength- privilege set length
  933. // pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
  934. // the mask of standard and specific rights granted.
  935. // If pbAccessStatus is false, it is set to 0.
  936. // On failure, it is not modified.
  937. // pbAccessStatus - On success, indicates wether the requested set
  938. // of access rights was granted.
  939. // On failure, it is not modified
  940. //
  941. // Returns S_OK on success or appropriate error code.
  942. // For additional details, look at the documentation of AccessCheckByType
  943. //=============================================================================
  944. function RsopAccessCheckByType(pSecurityDescriptor: PSECURITY_DESCRIPTOR; pPrincipalSelfSid: PSID;
  945. pRsopToken: PRSOPTOKEN; dwDesiredAccessMask: DWORD; pObjectTypeList: POBJECT_TYPE_LIST;
  946. ObjectTypeListLength: DWORD; pGenericMapping: PGENERIC_MAPPING; pPrivilegeSet: PPRIVILEGE_SET;
  947. pdwPrivilegeSetLength: LPDWORD; pdwGrantedAccessMask: LPDWORD; pbAccessStatus: LPBOOL): HRESULT; stdcall;
  948. {$EXTERNALSYM RsopAccessCheckByType}
  949. //=============================================================================
  950. //
  951. // Function: RsopFileAccessCheck
  952. //
  953. // Description: Determines whether the security descriptor on the file grants the set of file access
  954. // rights specified in dwDesiredAccessMask
  955. // to the client identified by the RSOPTOKEN pointed to by pRsopToken.
  956. //
  957. // pszFileName - Name of an existing filename
  958. // pRsopToken - Pointer to a valid RSOPTOKEN against which access needs to be checked
  959. // dwDesiredAccessMask - Mask of requested generic and/or standard and or specific access rights
  960. // pdwGrantedAccessMask - On success, if pbAccessStatus is true, it contains
  961. // the mask of standard and specific rights granted.
  962. // If pbAccessStatus is false, it is set to 0.
  963. // On failure, it is not modified.
  964. // pbAccessStatus - On success, indicates wether the requested set
  965. // of access rights was granted.
  966. // On failure, it is not modified
  967. //
  968. // Returns S_OK on success or appropriate error code
  969. //=============================================================================
  970. function RsopFileAccessCheck(pszFileName: LPWSTR; pRsopToken: PRSOPTOKEN; dwDesiredAccessMask: DWORD;
  971. pdwGrantedAccessMask: LPDWORD; pbAccessStatus: LPBOOL): HRESULT; stdcall;
  972. {$EXTERNALSYM RsopFileAccessCheck}
  973. type
  974. _SETTINGSTATUS = (
  975. RSOPUnspecified,
  976. RSOPApplied,
  977. RSOPIgnored,
  978. RSOPFailed,
  979. RSOPSubsettingFailed);
  980. {$EXTERNALSYM _SETTINGSTATUS}
  981. SETTINGSTATUS = _SETTINGSTATUS;
  982. {$EXTERNALSYM SETTINGSTATUS}
  983. TSettingStatus = SETTINGSTATUS;
  984. //=============================================================================
  985. //
  986. // POLICYSETTINGSTATUSINFO
  987. //
  988. // Describes the instance of RSOP_PolicySettingStatus
  989. //
  990. // szKey - OPTIONAL, if NULL, the key is generated on the fly
  991. // szEventSource - name of the source generation event log messages
  992. // szEventLogName - name of the event log database where the messages are logged
  993. // dwEventID - event log message ID
  994. // status - status of the policy setting
  995. // timeLogged - time at which the event log message was logged
  996. //
  997. //=============================================================================
  998. type
  999. _POLICYSETTINGSTATUSINFO = record
  1000. szKey: LPWSTR;
  1001. szEventSource: LPWSTR;
  1002. szEventLogName: LPWSTR;
  1003. dwEventID: DWORD;
  1004. dwErrorCode: DWORD;
  1005. status: SETTINGSTATUS;
  1006. timeLogged: SYSTEMTIME;
  1007. end;
  1008. {$EXTERNALSYM _POLICYSETTINGSTATUSINFO}
  1009. POLICYSETTINGSTATUSINFO = _POLICYSETTINGSTATUSINFO;
  1010. {$EXTERNALSYM POLICYSETTINGSTATUSINFO}
  1011. LPPOLICYSETTINGSTATUSINFO = ^POLICYSETTINGSTATUSINFO;
  1012. {$EXTERNALSYM LPPOLICYSETTINGSTATUSINFO}
  1013. TPolicySettingStatusInfo = POLICYSETTINGSTATUSINFO;
  1014. PPolicySettingStatusInfo = LPPOLICYSETTINGSTATUSINFO;
  1015. //=============================================================================
  1016. //
  1017. // RsopSetPolicySettingStatus
  1018. //
  1019. // Creates an instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
  1020. // and links RSOP_PolicySettingStatus to RSOP_PolicySetting
  1021. //
  1022. // dwFlags - flags
  1023. // pServices - RSOP namespace
  1024. // pSettingInstance - instance of RSOP_PolicySetting or its children
  1025. // nInfo - number of PolicySettingStatusInfo
  1026. // pStatus - array of PolicySettingStatusInfo
  1027. //
  1028. // Return: S_OK if successful, HRESULT otherwise
  1029. //
  1030. //=============================================================================
  1031. function RsopSetPolicySettingStatus(dwFlags: DWORD; pServices: IWbemServices;
  1032. pSettingInstance: IWbemClassObject; nInfo: DWORD;
  1033. pStatus: LPPOLICYSETTINGSTATUSINFO): HRESULT; stdcall;
  1034. {$EXTERNALSYM RsopSetPolicySettingStatus}
  1035. //=============================================================================
  1036. //
  1037. // RsopResetPolicySettingStatus
  1038. //
  1039. // Unlinks RSOP_PolicySettingStatus from RSOP_PolicySetting,
  1040. // deletes the instance of RSOP_PolicySettingStatus and RSOP_PolicySettingLink
  1041. // and optionally deletes the instance of RSOP_PolicySetting
  1042. //
  1043. // dwFlags - flags
  1044. // pServices - RSOP namespace
  1045. // pSettingInstance - instance of RSOP_PolicySetting or its children
  1046. //
  1047. // Return: S_OK if successful, HRESULT otherwise
  1048. //
  1049. //=============================================================================
  1050. function RsopResetPolicySettingStatus(dwFlags: DWORD; pServices: IWbemServices;
  1051. pSettingInstance: IWbemClassObject): HRESULT; stdcall;
  1052. {$EXTERNALSYM RsopResetPolicySettingStatus}
  1053. //=============================================================================
  1054. //
  1055. // Flags for RSoP WMI providers
  1056. //
  1057. //=============================================================================
  1058. // planning mode provider flags
  1059. const
  1060. FLAG_NO_GPO_FILTER = DWORD($80000000); // GPOs are not filtered, implies FLAG_NO_CSE_INVOKE
  1061. {$EXTERNALSYM FLAG_NO_GPO_FILTER}
  1062. FLAG_NO_CSE_INVOKE = $40000000; // only GP processing done for planning mode
  1063. {$EXTERNALSYM FLAG_NO_CSE_INVOKE}
  1064. FLAG_ASSUME_SLOW_LINK = $20000000; // planning mode RSoP assumes slow link
  1065. {$EXTERNALSYM FLAG_ASSUME_SLOW_LINK}
  1066. FLAG_LOOPBACK_MERGE = $10000000; // planning mode RSoP assumes merge loop back
  1067. {$EXTERNALSYM FLAG_LOOPBACK_MERGE}
  1068. FLAG_LOOPBACK_REPLACE = $08000000; // planning mode RSoP assumes replace loop back
  1069. {$EXTERNALSYM FLAG_LOOPBACK_REPLACE}
  1070. FLAG_ASSUME_USER_WQLFILTER_TRUE = $04000000; // planning mode RSoP assumes all comp filters to be true
  1071. {$EXTERNALSYM FLAG_ASSUME_USER_WQLFILTER_TRUE}
  1072. FLAG_ASSUME_COMP_WQLFILTER_TRUE = $02000000; // planning mode RSoP assumes all user filters to be true
  1073. {$EXTERNALSYM FLAG_ASSUME_COMP_WQLFILTER_TRUE}
  1074. FLAG_PLANNING_MODE = $01000000; // flag that indicates that a given namespace was created
  1075. {$EXTERNALSYM FLAG_PLANNING_MODE} // for planning mode. This flag cannot be passed in but the
  1076. // relevant subnamespace will be marked with this flag
  1077. // diagnostic mode provider flags
  1078. FLAG_NO_USER = $00000001; // Don't get any user data
  1079. {$EXTERNALSYM FLAG_NO_USER}
  1080. FLAG_NO_COMPUTER = $00000002; // Don't get any machine data
  1081. {$EXTERNALSYM FLAG_NO_COMPUTER}
  1082. FLAG_FORCE_CREATENAMESPACE = $00000004; // Delete and recreate the namespace for this snapshot.
  1083. {$EXTERNALSYM FLAG_FORCE_CREATENAMESPACE}
  1084. //=============================================================================
  1085. //
  1086. // Extended Errors returned by RSoP WMI Providers
  1087. //
  1088. //=============================================================================
  1089. // User accessing the rsop provider doesn't have access to user data.
  1090. RSOP_USER_ACCESS_DENIED = $00000001;
  1091. {$EXTERNALSYM RSOP_USER_ACCESS_DENIED}
  1092. // User accessing the rsop provider doesn't have access to computer data.
  1093. RSOP_COMPUTER_ACCESS_DENIED = $00000002;
  1094. {$EXTERNALSYM RSOP_COMPUTER_ACCESS_DENIED}
  1095. // This user is an interactive non admin user, the temp snapshot namespace already exists
  1096. // and the FLAG_FORCE_CREATENAMESPACE was not passed in
  1097. RSOP_TEMPNAMESPACE_EXISTS = $00000004;
  1098. {$EXTERNALSYM RSOP_TEMPNAMESPACE_EXISTS}
  1099. {$ENDIF JWA_IMPLEMENTATIONSECTION}
  1100. {$IFNDEF JWA_OMIT_SECTIONS}
  1101. implementation
  1102. //uses ...
  1103. {$ENDIF JWA_OMIT_SECTIONS}
  1104. {$IFNDEF JWA_INTERFACESECTION}
  1105. {$IFNDEF JWA_INCLUDEMODE}
  1106. const
  1107. userenvlib = 'userenv.dll';
  1108. {$IFDEF UNICODE}
  1109. AWSuffix = 'W';
  1110. {$ELSE}
  1111. AWSuffix = 'A';
  1112. {$ENDIF UNICODE}
  1113. {$ENDIF JWA_INCLUDEMODE}
  1114. {$IFDEF DYNAMIC_LINK}
  1115. var
  1116. _LoadUserProfileA: Pointer;
  1117. function LoadUserProfileA;
  1118. begin
  1119. GetProcedureAddress(_LoadUserProfileA, userenvlib, 'LoadUserProfileA');
  1120. asm
  1121. MOV ESP, EBP
  1122. POP EBP
  1123. JMP [_LoadUserProfileA]
  1124. end;
  1125. end;
  1126. var
  1127. _LoadUserProfileW: Pointer;
  1128. function LoadUserProfileW;
  1129. begin
  1130. GetProcedureAddress(_LoadUserProfileW, userenvlib, 'LoadUserProfileW');
  1131. asm
  1132. MOV ESP, EBP
  1133. POP EBP
  1134. JMP [_LoadUserProfileW]
  1135. end;
  1136. end;
  1137. var
  1138. _LoadUserProfile: Pointer;
  1139. function LoadUserProfile;
  1140. begin
  1141. GetProcedureAddress(_LoadUserProfile, userenvlib, 'LoadUserProfile' + AWSuffix);
  1142. asm
  1143. MOV ESP, EBP
  1144. POP EBP
  1145. JMP [_LoadUserProfile]
  1146. end;
  1147. end;
  1148. var
  1149. _UnloadUserProfile: Pointer;
  1150. function UnloadUserProfile;
  1151. begin
  1152. GetProcedureAddress(_UnloadUserProfile, userenvlib, 'UnloadUserProfile');
  1153. asm
  1154. MOV ESP, EBP
  1155. POP EBP
  1156. JMP [_UnloadUserProfile]
  1157. end;
  1158. end;
  1159. var
  1160. _GetProfilesDirectoryA: Pointer;
  1161. function GetProfilesDirectoryA;
  1162. begin
  1163. GetProcedureAddress(_GetProfilesDirectoryA, userenvlib, 'GetProfilesDirectoryA');
  1164. asm
  1165. MOV ESP, EBP
  1166. POP EBP
  1167. JMP [_GetProfilesDirectoryA]
  1168. end;
  1169. end;
  1170. var
  1171. _GetProfilesDirectoryW: Pointer;
  1172. function GetProfilesDirectoryW;
  1173. begin
  1174. GetProcedureAddress(_GetProfilesDirectoryW, userenvlib, 'GetProfilesDirectoryW');
  1175. asm
  1176. MOV ESP, EBP
  1177. POP EBP
  1178. JMP [_GetProfilesDirectoryW]
  1179. end;
  1180. end;
  1181. var
  1182. _GetProfilesDirectory: Pointer;
  1183. function GetProfilesDirectory;
  1184. begin
  1185. GetProcedureAddress(_GetProfilesDirectory, userenvlib, 'GetProfilesDirectory' + AWSuffix);
  1186. asm
  1187. MOV ESP, EBP
  1188. POP EBP
  1189. JMP [_GetProfilesDirectory]
  1190. end;
  1191. end;
  1192. var
  1193. _GetProfileType: Pointer;
  1194. function GetProfileType;
  1195. begin
  1196. GetProcedureAddress(_GetProfileType, userenvlib, 'GetProfileType');
  1197. asm
  1198. MOV ESP, EBP
  1199. POP EBP
  1200. JMP [_GetProfileType]
  1201. end;
  1202. end;
  1203. var
  1204. _DeleteProfileA: Pointer;
  1205. function DeleteProfileA;
  1206. begin
  1207. GetProcedureAddress(_DeleteProfileA, userenvlib, 'DeleteProfileA');
  1208. asm
  1209. MOV ESP, EBP
  1210. POP EBP
  1211. JMP [_DeleteProfileA]
  1212. end;
  1213. end;
  1214. var
  1215. _DeleteProfileW: Pointer;
  1216. function DeleteProfileW;
  1217. begin
  1218. GetProcedureAddress(_DeleteProfileW, userenvlib, 'DeleteProfileW');
  1219. asm
  1220. MOV ESP, EBP
  1221. POP EBP
  1222. JMP [_DeleteProfileW]
  1223. end;
  1224. end;
  1225. var
  1226. _DeleteProfile: Pointer;
  1227. function DeleteProfile;
  1228. begin
  1229. GetProcedureAddress(_DeleteProfile, userenvlib, 'DeleteProfile' + AWSuffix);
  1230. asm
  1231. MOV ESP, EBP
  1232. POP EBP
  1233. JMP [_DeleteProfile]
  1234. end;
  1235. end;
  1236. var
  1237. _GetDefaultUserProfileDirectoryA: Pointer;
  1238. function GetDefaultUserProfileDirectoryA;
  1239. begin
  1240. GetProcedureAddress(_GetDefaultUserProfileDirectoryA, userenvlib, 'GetDefaultUserProfileDirectoryA');
  1241. asm
  1242. MOV ESP, EBP
  1243. POP EBP
  1244. JMP [_GetDefaultUserProfileDirectoryA]
  1245. end;
  1246. end;
  1247. var
  1248. _GetDefaultUserProfileDirectoryW: Pointer;
  1249. function GetDefaultUserProfileDirectoryW;
  1250. begin
  1251. GetProcedureAddress(_GetDefaultUserProfileDirectoryW, userenvlib, 'GetDefaultUserProfileDirectoryW');
  1252. asm
  1253. MOV ESP, EBP
  1254. POP EBP
  1255. JMP [_GetDefaultUserProfileDirectoryW]
  1256. end;
  1257. end;
  1258. var
  1259. _GetDefaultUserProfileDirectory: Pointer;
  1260. function GetDefaultUserProfileDirectory;
  1261. begin
  1262. GetProcedureAddress(_GetDefaultUserProfileDirectory, userenvlib, 'GetDefaultUserProfileDirectory' + AWSuffix);
  1263. asm
  1264. MOV ESP, EBP
  1265. POP EBP
  1266. JMP [_GetDefaultUserProfileDirectory]
  1267. end;
  1268. end;
  1269. var
  1270. _GetAllUsersProfileDirectoryA: Pointer;
  1271. function GetAllUsersProfileDirectoryA;
  1272. begin
  1273. GetProcedureAddress(_GetAllUsersProfileDirectoryA, userenvlib, 'GetAllUsersProfileDirectoryA');
  1274. asm
  1275. MOV ESP, EBP
  1276. POP EBP
  1277. JMP [_GetAllUsersProfileDirectoryA]
  1278. end;
  1279. end;
  1280. var
  1281. _GetAllUsersProfileDirectoryW: Pointer;
  1282. function GetAllUsersProfileDirectoryW;
  1283. begin
  1284. GetProcedureAddress(_GetAllUsersProfileDirectoryW, userenvlib, 'GetAllUsersProfileDirectoryW');
  1285. asm
  1286. MOV ESP, EBP
  1287. POP EBP
  1288. JMP [_GetAllUsersProfileDirectoryW]
  1289. end;
  1290. end;
  1291. var
  1292. _GetAllUsersProfileDirectory: Pointer;
  1293. function GetAllUsersProfileDirectory;
  1294. begin
  1295. GetProcedureAddress(_GetAllUsersProfileDirectory, userenvlib, 'GetAllUsersProfileDirectory' + AWSuffix);
  1296. asm
  1297. MOV ESP, EBP
  1298. POP EBP
  1299. JMP [_GetAllUsersProfileDirectory]
  1300. end;
  1301. end;
  1302. var
  1303. _GetUserProfileDirectoryA: Pointer;
  1304. function GetUserProfileDirectoryA;
  1305. begin
  1306. GetProcedureAddress(_GetUserProfileDirectoryA, userenvlib, 'GetUserProfileDirectoryA');
  1307. asm
  1308. MOV ESP, EBP
  1309. POP EBP
  1310. JMP [_GetUserProfileDirectoryA]
  1311. end;
  1312. end;
  1313. var
  1314. _GetUserProfileDirectoryW: Pointer;
  1315. function GetUserProfileDirectoryW;
  1316. begin
  1317. GetProcedureAddress(_GetUserProfileDirectoryW, userenvlib, 'GetUserProfileDirectoryW');
  1318. asm
  1319. MOV ESP, EBP
  1320. POP EBP
  1321. JMP [_GetUserProfileDirectoryW]
  1322. end;
  1323. end;
  1324. var
  1325. _GetUserProfileDirectory: Pointer;
  1326. function GetUserProfileDirectory;
  1327. begin
  1328. GetProcedureAddress(_GetUserProfileDirectory, userenvlib, 'GetUserProfileDirectory' + AWSuffix);
  1329. asm
  1330. MOV ESP, EBP
  1331. POP EBP
  1332. JMP [_GetUserProfileDirectory]
  1333. end;
  1334. end;
  1335. var
  1336. _CreateEnvironmentBlock: Pointer;
  1337. function CreateEnvironmentBlock;
  1338. begin
  1339. GetProcedureAddress(_CreateEnvironmentBlock, userenvlib, 'CreateEnvironmentBlock');
  1340. asm
  1341. MOV ESP, EBP
  1342. POP EBP
  1343. JMP [_CreateEnvironmentBlock]
  1344. end;
  1345. end;
  1346. var
  1347. _DestroyEnvironmentBlock: Pointer;
  1348. function DestroyEnvironmentBlock;
  1349. begin
  1350. GetProcedureAddress(_DestroyEnvironmentBlock, userenvlib, 'DestroyEnvironmentBlock');
  1351. asm
  1352. MOV ESP, EBP
  1353. POP EBP
  1354. JMP [_DestroyEnvironmentBlock]
  1355. end;
  1356. end;
  1357. var
  1358. _ExpandEnvStringsForUserA: Pointer;
  1359. function ExpandEnvironmentStringsForUserA;
  1360. begin
  1361. GetProcedureAddress(_ExpandEnvStringsForUserA, userenvlib, 'ExpandEnvironmentStringsForUserA');
  1362. asm
  1363. MOV ESP, EBP
  1364. POP EBP
  1365. JMP [_ExpandEnvStringsForUserA]
  1366. end;
  1367. end;
  1368. var
  1369. _ExpandEnvStringsForUserW: Pointer;
  1370. function ExpandEnvironmentStringsForUserW;
  1371. begin
  1372. GetProcedureAddress(_ExpandEnvStringsForUserW, userenvlib, 'ExpandEnvironmentStringsForUserW');
  1373. asm
  1374. MOV ESP, EBP
  1375. POP EBP
  1376. JMP [_ExpandEnvStringsForUserW]
  1377. end;
  1378. end;
  1379. var
  1380. _ExpandEnvironmentStringsForUser: Pointer;
  1381. function ExpandEnvironmentStringsForUser;
  1382. begin
  1383. GetProcedureAddress(_ExpandEnvironmentStringsForUser, userenvlib, 'ExpandEnvironmentStringsForUser' + AWSuffix);
  1384. asm
  1385. MOV ESP, EBP
  1386. POP EBP
  1387. JMP [_ExpandEnvironmentStringsForUser]
  1388. end;
  1389. end;
  1390. var
  1391. _RefreshPolicy: Pointer;
  1392. function RefreshPolicy;
  1393. begin
  1394. GetProcedureAddress(_RefreshPolicy, userenvlib, 'RefreshPolicy');
  1395. asm
  1396. MOV ESP, EBP
  1397. POP EBP
  1398. JMP [_RefreshPolicy]
  1399. end;
  1400. end;
  1401. var
  1402. _RefreshPolicyEx: Pointer;
  1403. function RefreshPolicyEx;
  1404. begin
  1405. GetProcedureAddress(_RefreshPolicyEx, userenvlib, 'RefreshPolicyEx');
  1406. asm
  1407. MOV ESP, EBP
  1408. POP EBP
  1409. JMP [_RefreshPolicyEx]
  1410. end;
  1411. end;
  1412. var
  1413. _EnterCriticalPolicySection: Pointer;
  1414. function EnterCriticalPolicySection;
  1415. begin
  1416. GetProcedureAddress(_EnterCriticalPolicySection, userenvlib, 'EnterCriticalPolicySection');
  1417. asm
  1418. MOV ESP, EBP
  1419. POP EBP
  1420. JMP [_EnterCriticalPolicySection]
  1421. end;
  1422. end;
  1423. var
  1424. _LeaveCriticalPolicySection: Pointer;
  1425. function LeaveCriticalPolicySection;
  1426. begin
  1427. GetProcedureAddress(_LeaveCriticalPolicySection, userenvlib, 'LeaveCriticalPolicySection');
  1428. asm
  1429. MOV ESP, EBP
  1430. POP EBP
  1431. JMP [_LeaveCriticalPolicySection]
  1432. end;
  1433. end;
  1434. var
  1435. _RegisterGPNotification: Pointer;
  1436. function RegisterGPNotification;
  1437. begin
  1438. GetProcedureAddress(_RegisterGPNotification, userenvlib, 'RegisterGPNotification');
  1439. asm
  1440. MOV ESP, EBP
  1441. POP EBP
  1442. JMP [_RegisterGPNotification]
  1443. end;
  1444. end;
  1445. var
  1446. _UnregisterGPNotification: Pointer;
  1447. function UnregisterGPNotification;
  1448. begin
  1449. GetProcedureAddress(_UnregisterGPNotification, userenvlib, 'UnregisterGPNotification');
  1450. asm
  1451. MOV ESP, EBP
  1452. POP EBP
  1453. JMP [_UnregisterGPNotification]
  1454. end;
  1455. end;
  1456. var
  1457. _GetGPOListA: Pointer;
  1458. function GetGPOListA;
  1459. begin
  1460. GetProcedureAddress(_GetGPOListA, userenvlib, 'GetGPOListA');
  1461. asm
  1462. MOV ESP, EBP
  1463. POP EBP
  1464. JMP [_GetGPOListA]
  1465. end;
  1466. end;
  1467. var
  1468. _GetGPOListW: Pointer;
  1469. function GetGPOListW;
  1470. begin
  1471. GetProcedureAddress(_GetGPOListW, userenvlib, 'GetGPOListW');
  1472. asm
  1473. MOV ESP, EBP
  1474. POP EBP
  1475. JMP [_GetGPOListW]
  1476. end;
  1477. end;
  1478. var
  1479. _GetGPOList: Pointer;
  1480. function GetGPOList;
  1481. begin
  1482. GetProcedureAddress(_GetGPOList, userenvlib, 'GetGPOList' + AWSuffix);
  1483. asm
  1484. MOV ESP, EBP
  1485. POP EBP
  1486. JMP [_GetGPOList]
  1487. end;
  1488. end;
  1489. var
  1490. _FreeGPOListA: Pointer;
  1491. function FreeGPOListA;
  1492. begin
  1493. GetProcedureAddress(_FreeGPOListA, userenvlib, 'FreeGPOListA');
  1494. asm
  1495. MOV ESP, EBP
  1496. POP EBP
  1497. JMP [_FreeGPOListA]
  1498. end;
  1499. end;
  1500. var
  1501. _FreeGPOListW: Pointer;
  1502. function FreeGPOListW;
  1503. begin
  1504. GetProcedureAddress(_FreeGPOListW, userenvlib, 'FreeGPOListW');
  1505. asm
  1506. MOV ESP, EBP
  1507. POP EBP
  1508. JMP [_FreeGPOListW]
  1509. end;
  1510. end;
  1511. var
  1512. _FreeGPOList: Pointer;
  1513. function FreeGPOList;
  1514. begin
  1515. GetProcedureAddress(_FreeGPOList, userenvlib, 'FreeGPOList' + AWSuffix);
  1516. asm
  1517. MOV ESP, EBP
  1518. POP EBP
  1519. JMP [_FreeGPOList]
  1520. end;
  1521. end;
  1522. var
  1523. _GetAppliedGPOListA: Pointer;
  1524. function GetAppliedGPOListA;
  1525. begin
  1526. GetProcedureAddress(_GetAppliedGPOListA, userenvlib, 'GetAppliedGPOListA');
  1527. asm
  1528. MOV ESP, EBP
  1529. POP EBP
  1530. JMP [_GetAppliedGPOListA]
  1531. end;
  1532. end;
  1533. var
  1534. _GetAppliedGPOListW: Pointer;
  1535. function GetAppliedGPOListW;
  1536. begin
  1537. GetProcedureAddress(_GetAppliedGPOListW, userenvlib, 'GetAppliedGPOListW');
  1538. asm
  1539. MOV ESP, EBP
  1540. POP EBP
  1541. JMP [_GetAppliedGPOListW]
  1542. end;
  1543. end;
  1544. var
  1545. _GetAppliedGPOList: Pointer;
  1546. function GetAppliedGPOList;
  1547. begin
  1548. GetProcedureAddress(_GetAppliedGPOList, userenvlib, 'GetAppliedGPOList' + AWSuffix);
  1549. asm
  1550. MOV ESP, EBP
  1551. POP EBP
  1552. JMP [_GetAppliedGPOList]
  1553. end;
  1554. end;
  1555. var
  1556. _ProcessGroupPolicyCompleted: Pointer;
  1557. function ProcessGroupPolicyCompleted;
  1558. begin
  1559. GetProcedureAddress(_ProcessGroupPolicyCompleted, userenvlib, 'ProcessGroupPolicyCompleted');
  1560. asm
  1561. MOV ESP, EBP
  1562. POP EBP
  1563. JMP [_ProcessGroupPolicyCompleted]
  1564. end;
  1565. end;
  1566. var
  1567. _ProcessGroupPolicyCompletedEx: Pointer;
  1568. function ProcessGroupPolicyCompletedEx;
  1569. begin
  1570. GetProcedureAddress(_ProcessGroupPolicyCompletedEx, userenvlib, 'ProcessGroupPolicyCompletedEx');
  1571. asm
  1572. MOV ESP, EBP
  1573. POP EBP
  1574. JMP [_ProcessGroupPolicyCompletedEx]
  1575. end;
  1576. end;
  1577. var
  1578. _RsopAccessCheckByType: Pointer;
  1579. function RsopAccessCheckByType;
  1580. begin
  1581. GetProcedureAddress(_RsopAccessCheckByType, userenvlib, 'RsopAccessCheckByType');
  1582. asm
  1583. MOV ESP, EBP
  1584. POP EBP
  1585. JMP [_RsopAccessCheckByType]
  1586. end;
  1587. end;
  1588. var
  1589. _RsopFileAccessCheck: Pointer;
  1590. function RsopFileAccessCheck;
  1591. begin
  1592. GetProcedureAddress(_RsopFileAccessCheck, userenvlib, 'RsopFileAccessCheck');
  1593. asm
  1594. MOV ESP, EBP
  1595. POP EBP
  1596. JMP [_RsopFileAccessCheck]
  1597. end;
  1598. end;
  1599. var
  1600. _RsopSetPolicySettingStatus: Pointer;
  1601. function RsopSetPolicySettingStatus;
  1602. begin
  1603. GetProcedureAddress(_RsopSetPolicySettingStatus, userenvlib, 'RsopSetPolicySettingStatus');
  1604. asm
  1605. MOV ESP, EBP
  1606. POP EBP
  1607. JMP [_RsopSetPolicySettingStatus]
  1608. end;
  1609. end;
  1610. var
  1611. _RsopResetPolicySettingStatus: Pointer;
  1612. function RsopResetPolicySettingStatus;
  1613. begin
  1614. GetProcedureAddress(_RsopResetPolicySettingStatus, userenvlib, 'RsopResetPolicySettingStatus');
  1615. asm
  1616. MOV ESP, EBP
  1617. POP EBP
  1618. JMP [_RsopResetPolicySettingStatus]
  1619. end;
  1620. end;
  1621. {$ELSE}
  1622. function LoadUserProfileA; external userenvlib name 'LoadUserProfileA';
  1623. function LoadUserProfileW; external userenvlib name 'LoadUserProfileW';
  1624. function LoadUserProfile; external userenvlib name 'LoadUserProfile' + AWSuffix;
  1625. function UnloadUserProfile; external userenvlib name 'UnloadUserProfile';
  1626. function GetProfilesDirectoryA; external userenvlib name 'GetProfilesDirectoryA';
  1627. function GetProfilesDirectoryW; external userenvlib name 'GetProfilesDirectoryW';
  1628. function GetProfilesDirectory; external userenvlib name 'GetProfilesDirectory' + AWSuffix;
  1629. function GetProfileType; external userenvlib name 'GetProfileType';
  1630. function DeleteProfileA; external userenvlib name 'DeleteProfileA';
  1631. function DeleteProfileW; external userenvlib name 'DeleteProfileW';
  1632. function DeleteProfile; external userenvlib name 'DeleteProfile' + AWSuffix;
  1633. function GetDefaultUserProfileDirectoryA; external userenvlib name 'GetDefaultUserProfileDirectoryA';
  1634. function GetDefaultUserProfileDirectoryW; external userenvlib name 'GetDefaultUserProfileDirectoryW';
  1635. function GetDefaultUserProfileDirectory; external userenvlib name 'GetDefaultUserProfileDirectory' + AWSuffix;
  1636. function GetAllUsersProfileDirectoryA; external userenvlib name 'GetAllUsersProfileDirectoryA';
  1637. function GetAllUsersProfileDirectoryW; external userenvlib name 'GetAllUsersProfileDirectoryW';
  1638. function GetAllUsersProfileDirectory; external userenvlib name 'GetAllUsersProfileDirectory' + AWSuffix;
  1639. function GetUserProfileDirectoryA; external userenvlib name 'GetUserProfileDirectoryA';
  1640. function GetUserProfileDirectoryW; external userenvlib name 'GetUserProfileDirectoryW';
  1641. function GetUserProfileDirectory; external userenvlib name 'GetUserProfileDirectory' + AWSuffix;
  1642. function CreateEnvironmentBlock; external userenvlib name 'CreateEnvironmentBlock';
  1643. function DestroyEnvironmentBlock; external userenvlib name 'DestroyEnvironmentBlock';
  1644. function ExpandEnvironmentStringsForUserA; external userenvlib name 'ExpandEnvironmentStringsForUserA';
  1645. function ExpandEnvironmentStringsForUserW; external userenvlib name 'ExpandEnvironmentStringsForUserW';
  1646. function ExpandEnvironmentStringsForUser; external userenvlib name 'ExpandEnvironmentStringsForUser' + AWSuffix;
  1647. function RefreshPolicy; external userenvlib name 'RefreshPolicy';
  1648. function RefreshPolicyEx; external userenvlib name 'RefreshPolicyEx';
  1649. function EnterCriticalPolicySection; external userenvlib name 'EnterCriticalPolicySection';
  1650. function LeaveCriticalPolicySection; external userenvlib name 'LeaveCriticalPolicySection';
  1651. function RegisterGPNotification; external userenvlib name 'RegisterGPNotification';
  1652. function UnregisterGPNotification; external userenvlib name 'UnregisterGPNotification';
  1653. function GetGPOListA; external userenvlib name 'GetGPOListA';
  1654. function GetGPOListW; external userenvlib name 'GetGPOListW';
  1655. function GetGPOList; external userenvlib name 'GetGPOList' + AWSuffix;
  1656. function FreeGPOListA; external userenvlib name 'FreeGPOListA';
  1657. function FreeGPOListW; external userenvlib name 'FreeGPOListW';
  1658. function FreeGPOList; external userenvlib name 'FreeGPOList' + AWSuffix;
  1659. function GetAppliedGPOListA; external userenvlib name 'GetAppliedGPOListA';
  1660. function GetAppliedGPOListW; external userenvlib name 'GetAppliedGPOListW';
  1661. function GetAppliedGPOList; external userenvlib name 'GetAppliedGPOList' + AWSuffix;
  1662. function ProcessGroupPolicyCompleted; external userenvlib name 'ProcessGroupPolicyCompleted';
  1663. function ProcessGroupPolicyCompletedEx; external userenvlib name 'ProcessGroupPolicyCompletedEx';
  1664. function RsopAccessCheckByType; external userenvlib name 'RsopAccessCheckByType';
  1665. function RsopFileAccessCheck; external userenvlib name 'RsopFileAccessCheck';
  1666. function RsopSetPolicySettingStatus; external userenvlib name 'RsopSetPolicySettingStatus';
  1667. function RsopResetPolicySettingStatus; external userenvlib name 'RsopResetPolicySettingStatus';
  1668. {$ENDIF DYNAMIC_LINK}
  1669. {$ENDIF JWA_INTERFACESECTION}
  1670. {$IFNDEF JWA_OMIT_SECTIONS}
  1671. end.
  1672. {$ENDIF JWA_OMIT_SECTIONS}