Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1627 lines
47 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. tse.c
  5. Abstract:
  6. This module tests windows security api.
  7. Author:
  8. Robert Reichel (RobertRe) 01-Jan-92
  9. Revision History:
  10. --*/
  11. #include <nt.h>
  12. #include <ntrtl.h>
  13. #include <nturtl.h>
  14. #include <windows.h>
  15. #include <string.h>
  16. #include <stdarg.h>
  17. #include <assert.h>
  18. #include <stdio.h>
  19. #define _TST_USER_ // User mode test
  20. #define BUFFER_SIZE 256
  21. ////////////////////////////////////////////////////////////////////////
  22. // //
  23. // Global Variables //
  24. // //
  25. ////////////////////////////////////////////////////////////////////////
  26. LUID SystemAuthenticationId = SYSTEM_LUID;
  27. //
  28. // Universal well known SIDs
  29. //
  30. PSID NullSid;
  31. PSID WorldSid;
  32. PSID LocalSid;
  33. PSID CreatorOwnerSid;
  34. //
  35. // Sids defined by NT
  36. //
  37. PSID NtAuthoritySid;
  38. PSID DialupSid;
  39. PSID NetworkSid;
  40. PSID BatchSid;
  41. PSID InteractiveSid;
  42. PSID LocalSystemSid;
  43. //
  44. // Well known privilege values
  45. //
  46. LUID SeCreateTokenPrivilege;
  47. LUID SeAssignPrimaryTokenPrivilege;
  48. LUID SeLockMemoryPrivilege;
  49. LUID SeIncreaseQuotaPrivilege;
  50. LUID SeUnsolicitedInputPrivilege;
  51. LUID SeTcbPrivilege;
  52. LUID SeSecurityPrivilege;
  53. LUID SeTakeOwnershipPrivilege;
  54. LUID SeLoadDriverPrivilege;
  55. LUID SeCreatePagefilePrivilege;
  56. LUID SeIncreaseBasePriorityPrivilege;
  57. LUID SeSystemProfilePrivilege;
  58. LUID SeSystemtimePrivilege;
  59. LUID SeProfileSingleProcessPrivilege;
  60. LUID SeCreatePermanentPrivilege;
  61. LUID SeBackupPrivilege;
  62. LUID SeRestorePrivilege;
  63. LUID SeShutdownPrivilege;
  64. LUID SeDebugPrivilege;
  65. LUID SeAuditPrivilege;
  66. LUID SeSystemEnvironmentPrivilege;
  67. LUID SeChangeNotifyPrivilege;
  68. LUID SeRemoteShutdownPrivilege;
  69. ////////////////////////////////////////////////////////////////////////
  70. // //
  71. // Internal Prototypes //
  72. // //
  73. ////////////////////////////////////////////////////////////////////////
  74. VOID
  75. TestLookupSid();
  76. VOID
  77. TestLookupName();
  78. void
  79. TestGetPrivNameW(
  80. LPWSTR *PrivName,
  81. PLUID lpLuid
  82. );
  83. void
  84. TestGetPrivNameA(
  85. LPSTR *PrivName,
  86. PLUID lpLuid
  87. );
  88. VOID
  89. TestLookupPrivilegeValue();
  90. void
  91. TestLookupPrivilegeValueW(
  92. PLUID lpLuid
  93. );
  94. void
  95. TestLookupPrivilegeValueA(
  96. PLUID lpLuid
  97. );
  98. VOID
  99. TestLookupPrivilegeName();
  100. void
  101. TestLookupPrivilegeNameW(
  102. PLUID lpLuid
  103. );
  104. void
  105. TestLookupPrivilegeNameA(
  106. PLUID lpLuid
  107. );
  108. VOID
  109. TestLookupPrivilegeDisplayName();
  110. void
  111. TestLookupPrivilegeDisplayNameW(
  112. PLUID lpLuid
  113. );
  114. void
  115. TestLookupPrivilegeDisplayNameA(
  116. PLUID lpLuid
  117. );
  118. void
  119. initialize (void);
  120. void
  121. TestLookupSidW(
  122. IN PSID Sid
  123. );
  124. void
  125. TestLookupSidA(
  126. IN PSID Sid
  127. );
  128. void
  129. TestLookupNameW(
  130. LPWSTR Name
  131. );
  132. void
  133. DumpWCharString(
  134. PWSTR String
  135. );
  136. VOID
  137. DisplayAccountSid(
  138. PSID Sid
  139. );
  140. VOID
  141. DisplayUse(
  142. IN SID_NAME_USE Use
  143. );
  144. void
  145. initialize (void)
  146. {
  147. ULONG SidWithZeroSubAuthorities;
  148. ULONG SidWithOneSubAuthority;
  149. ULONG SidWithThreeSubAuthorities;
  150. ULONG SidWithFourSubAuthorities;
  151. SID_IDENTIFIER_AUTHORITY NullSidAuthority = SECURITY_NULL_SID_AUTHORITY;
  152. SID_IDENTIFIER_AUTHORITY WorldSidAuthority = SECURITY_WORLD_SID_AUTHORITY;
  153. SID_IDENTIFIER_AUTHORITY LocalSidAuthority = SECURITY_LOCAL_SID_AUTHORITY;
  154. SID_IDENTIFIER_AUTHORITY CreatorSidAuthority = SECURITY_CREATOR_SID_AUTHORITY;
  155. SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
  156. //
  157. // The following SID sizes need to be allocated
  158. //
  159. SidWithZeroSubAuthorities = GetSidLengthRequired( 0 );
  160. SidWithOneSubAuthority = GetSidLengthRequired( 1 );
  161. SidWithThreeSubAuthorities = GetSidLengthRequired( 3 );
  162. SidWithFourSubAuthorities = GetSidLengthRequired( 4 );
  163. //
  164. // Allocate and initialize the universal SIDs
  165. //
  166. NullSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  167. WorldSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  168. LocalSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  169. CreatorOwnerSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  170. InitializeSid( NullSid, &NullSidAuthority, 1 );
  171. InitializeSid( WorldSid, &WorldSidAuthority, 1 );
  172. InitializeSid( LocalSid, &LocalSidAuthority, 1 );
  173. InitializeSid( CreatorOwnerSid, &CreatorSidAuthority, 1 );
  174. *(GetSidSubAuthority( NullSid, 0 )) = SECURITY_NULL_RID;
  175. *(GetSidSubAuthority( WorldSid, 0 )) = SECURITY_WORLD_RID;
  176. *(GetSidSubAuthority( LocalSid, 0 )) = SECURITY_LOCAL_RID;
  177. *(GetSidSubAuthority( CreatorOwnerSid, 0 )) = SECURITY_CREATOR_OWNER_RID;
  178. //
  179. // Allocate and initialize the NT defined SIDs
  180. //
  181. NtAuthoritySid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithZeroSubAuthorities);
  182. DialupSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  183. NetworkSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  184. BatchSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  185. InteractiveSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  186. LocalSystemSid = (PSID)RtlAllocateHeap( RtlProcessHeap(), 0,SidWithOneSubAuthority);
  187. InitializeSid( NtAuthoritySid, &NtAuthority, 0 );
  188. InitializeSid( DialupSid, &NtAuthority, 1 );
  189. InitializeSid( NetworkSid, &NtAuthority, 1 );
  190. InitializeSid( BatchSid, &NtAuthority, 1 );
  191. InitializeSid( InteractiveSid, &NtAuthority, 1 );
  192. InitializeSid( LocalSystemSid, &NtAuthority, 1 );
  193. *(GetSidSubAuthority( DialupSid, 0 )) = SECURITY_DIALUP_RID;
  194. *(GetSidSubAuthority( NetworkSid, 0 )) = SECURITY_NETWORK_RID;
  195. *(GetSidSubAuthority( BatchSid, 0 )) = SECURITY_BATCH_RID;
  196. *(GetSidSubAuthority( InteractiveSid, 0 )) = SECURITY_INTERACTIVE_RID;
  197. *(GetSidSubAuthority( LocalSystemSid, 0 )) = SECURITY_LOCAL_SYSTEM_RID;
  198. //
  199. // Initialize the well known privilege values
  200. //
  201. SeCreateTokenPrivilege =
  202. RtlConvertLongToLargeInteger(SE_CREATE_TOKEN_PRIVILEGE);
  203. SeAssignPrimaryTokenPrivilege =
  204. RtlConvertLongToLargeInteger(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE);
  205. SeLockMemoryPrivilege =
  206. RtlConvertLongToLargeInteger(SE_LOCK_MEMORY_PRIVILEGE);
  207. SeIncreaseQuotaPrivilege =
  208. RtlConvertLongToLargeInteger(SE_INCREASE_QUOTA_PRIVILEGE);
  209. SeUnsolicitedInputPrivilege =
  210. RtlConvertLongToLargeInteger(SE_UNSOLICITED_INPUT_PRIVILEGE);
  211. SeTcbPrivilege =
  212. RtlConvertLongToLargeInteger(SE_TCB_PRIVILEGE);
  213. SeSecurityPrivilege =
  214. RtlConvertLongToLargeInteger(SE_SECURITY_PRIVILEGE);
  215. SeTakeOwnershipPrivilege =
  216. RtlConvertLongToLargeInteger(SE_TAKE_OWNERSHIP_PRIVILEGE);
  217. SeLoadDriverPrivilege =
  218. RtlConvertLongToLargeInteger(SE_LOAD_DRIVER_PRIVILEGE);
  219. SeCreatePagefilePrivilege =
  220. RtlConvertLongToLargeInteger(SE_CREATE_PAGEFILE_PRIVILEGE);
  221. SeIncreaseBasePriorityPrivilege =
  222. RtlConvertLongToLargeInteger(SE_INC_BASE_PRIORITY_PRIVILEGE);
  223. SeSystemProfilePrivilege =
  224. RtlConvertLongToLargeInteger(SE_SYSTEM_PROFILE_PRIVILEGE);
  225. SeSystemtimePrivilege =
  226. RtlConvertLongToLargeInteger(SE_SYSTEMTIME_PRIVILEGE);
  227. SeProfileSingleProcessPrivilege =
  228. RtlConvertLongToLargeInteger(SE_PROF_SINGLE_PROCESS_PRIVILEGE);
  229. SeCreatePermanentPrivilege =
  230. RtlConvertLongToLargeInteger(SE_CREATE_PERMANENT_PRIVILEGE);
  231. SeBackupPrivilege =
  232. RtlConvertLongToLargeInteger(SE_BACKUP_PRIVILEGE);
  233. SeRestorePrivilege =
  234. RtlConvertLongToLargeInteger(SE_RESTORE_PRIVILEGE);
  235. SeShutdownPrivilege =
  236. RtlConvertLongToLargeInteger(SE_SHUTDOWN_PRIVILEGE);
  237. SeDebugPrivilege =
  238. RtlConvertLongToLargeInteger(SE_DEBUG_PRIVILEGE);
  239. SeAuditPrivilege =
  240. RtlConvertLongToLargeInteger(SE_AUDIT_PRIVILEGE);
  241. SeSystemEnvironmentPrivilege =
  242. RtlConvertLongToLargeInteger(SE_SYSTEM_ENVIRONMENT_PRIVILEGE);
  243. SeChangeNotifyPrivilege =
  244. RtlConvertLongToLargeInteger(SE_CHANGE_NOTIFY_PRIVILEGE);
  245. SeRemoteShutdownPrivilege =
  246. RtlConvertLongToLargeInteger(SE_REMOTE_SHUTDOWN_PRIVILEGE);
  247. }
  248. void
  249. TestLookupSidW(
  250. IN PSID Sid
  251. )
  252. {
  253. //
  254. // LookupAccountSidW test
  255. //
  256. BOOL Bool;
  257. DWORD cbName = 0;
  258. DWORD cbReferencedDomainName = 0;
  259. DWORD cbSid = 0;
  260. WCHAR Name[BUFFER_SIZE];
  261. SID_NAME_USE peUse = SidTypeUser;
  262. WCHAR ReferencedDomainName[BUFFER_SIZE];
  263. printf(" LookupW call . . . . . . . . . . . . . . . . . ");
  264. cbName = 0;
  265. cbReferencedDomainName = 0;
  266. Bool = LookupAccountSidW(
  267. NULL,
  268. Sid,
  269. Name,
  270. &cbName,
  271. ReferencedDomainName,
  272. &cbReferencedDomainName,
  273. &peUse
  274. );
  275. //
  276. // Expect failure here
  277. //
  278. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  279. printf("** FAILED **\n");
  280. printf(" First call.\n");
  281. printf(" Status: %d\n", GetLastError());
  282. printf(" Name Length: %d\n", cbName);
  283. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  284. } else {
  285. Bool = LookupAccountSidW(
  286. NULL,
  287. Sid,
  288. Name,
  289. &cbName,
  290. ReferencedDomainName,
  291. &cbReferencedDomainName,
  292. &peUse
  293. );
  294. if ( !Bool ) {
  295. printf("** FAILED **\n");
  296. printf(" Second call.\n");
  297. printf(" Status: %d\n", GetLastError());
  298. printf(" Name Length: %d\n", cbName);
  299. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  300. } else {
  301. printf("Succeeded\n");
  302. printf(" Name Length: %d\n", cbName);
  303. printf(" Name: *");
  304. DumpWCharString( Name );
  305. printf("*\n");
  306. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  307. printf(" Domain Name: *");
  308. DumpWCharString( ReferencedDomainName );
  309. printf("*\n");
  310. printf(" Use: ");
  311. DisplayUse( peUse );
  312. printf("\n\n");
  313. }
  314. }
  315. }
  316. void
  317. TestLookupSidA(
  318. IN PSID Sid
  319. )
  320. {
  321. UCHAR Name[BUFFER_SIZE];
  322. UCHAR ReferencedDomainName[BUFFER_SIZE];
  323. BOOL Bool;
  324. DWORD cbName = 0;
  325. DWORD cbReferencedDomainName = 0;
  326. SID_NAME_USE peUse;
  327. printf(" LookupA call . . . . . . . . . . . . . . . . . ");
  328. Bool = LookupAccountSidA(
  329. NULL,
  330. Sid,
  331. Name,
  332. &cbName,
  333. ReferencedDomainName,
  334. &cbReferencedDomainName,
  335. &peUse
  336. );
  337. //
  338. // Expect failure here
  339. //
  340. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  341. printf("** FAILED **\n");
  342. printf(" First call.\n");
  343. printf(" Status: %d\n", GetLastError());
  344. printf(" Name Length: %d\n", cbName);
  345. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  346. } else {
  347. Bool = LookupAccountSidA(
  348. NULL,
  349. Sid,
  350. Name,
  351. &cbName,
  352. ReferencedDomainName,
  353. &cbReferencedDomainName,
  354. &peUse
  355. );
  356. if ( !Bool ) {
  357. printf("** FAILED **\n");
  358. printf(" Second call.\n");
  359. printf(" Status: %d\n", GetLastError());
  360. printf(" Name Length: %d\n", cbName);
  361. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  362. } else {
  363. printf("Succeeded\n");
  364. printf(" Name Length: %d\n", cbName);
  365. printf(" Name: *%s*\n",Name);
  366. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  367. printf(" Domain Name: *%s*\n", ReferencedDomainName );
  368. printf(" Use: ");
  369. DisplayUse( peUse );
  370. printf("\n\n");
  371. }
  372. }
  373. }
  374. void
  375. TestLookupNameW(
  376. LPWSTR Name
  377. )
  378. {
  379. //
  380. // LookupAccountNameW test
  381. //
  382. BOOL Bool;
  383. DWORD cbSid = 0;
  384. UCHAR Sid[BUFFER_SIZE];
  385. SID_NAME_USE peUse = SidTypeUser;
  386. DWORD cbReferencedDomainName = 0;
  387. WCHAR ReferencedDomainName[BUFFER_SIZE];
  388. printf(" LookupW call . . . . . . . . . . . . . . . . . ");
  389. Bool = LookupAccountNameW(
  390. NULL,
  391. Name,
  392. Sid,
  393. &cbSid,
  394. ReferencedDomainName,
  395. &cbReferencedDomainName,
  396. &peUse
  397. );
  398. //
  399. // Expect failure here
  400. //
  401. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  402. printf("** FAILED **\n");
  403. printf(" First call.\n");
  404. printf(" Status: %d\n", GetLastError());
  405. printf(" Sid Length: %d\n", cbSid);
  406. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  407. } else {
  408. Bool = LookupAccountNameW(
  409. NULL,
  410. Name,
  411. Sid,
  412. &cbSid,
  413. ReferencedDomainName,
  414. &cbReferencedDomainName,
  415. &peUse
  416. );
  417. if ( !Bool ) {
  418. printf("** FAILED **\n");
  419. printf(" Second call.\n");
  420. printf(" Status: %d\n", GetLastError());
  421. printf(" Sid Length: %d\n", cbSid);
  422. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  423. } else {
  424. printf("Succeeded\n");
  425. printf(" Sid Length: %d\n", cbSid);
  426. printf(" Sid: ");
  427. DisplayAccountSid( Sid );
  428. printf("\n");
  429. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  430. printf(" Domain Name: *");
  431. DumpWCharString( ReferencedDomainName );
  432. printf("*\n");
  433. printf(" Use: ");
  434. DisplayUse( peUse );
  435. printf("\n\n");
  436. }
  437. }
  438. }
  439. void
  440. TestLookupNameA(
  441. LPSTR Name
  442. )
  443. {
  444. //
  445. // LookupAccountNameA test
  446. //
  447. BOOL Bool;
  448. DWORD cbSid = 0;
  449. UCHAR Sid[BUFFER_SIZE];
  450. SID_NAME_USE peUse = SidTypeUser;
  451. DWORD cbReferencedDomainName = 0;
  452. UCHAR ReferencedDomainName[BUFFER_SIZE];
  453. printf(" LookupA call . . . . . . . . . . . . . . . . . ");
  454. Bool = LookupAccountNameA(
  455. NULL,
  456. Name,
  457. Sid,
  458. &cbSid,
  459. ReferencedDomainName,
  460. &cbReferencedDomainName,
  461. &peUse
  462. );
  463. //
  464. // Expect failure here
  465. //
  466. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  467. printf("** FAILED **\n");
  468. printf(" First call.\n");
  469. printf(" Status: %d\n", GetLastError());
  470. printf(" Sid Length: %d\n", cbSid);
  471. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  472. } else {
  473. Bool = LookupAccountNameA(
  474. NULL,
  475. Name,
  476. Sid,
  477. &cbSid,
  478. ReferencedDomainName,
  479. &cbReferencedDomainName,
  480. &peUse
  481. );
  482. if ( !Bool ) {
  483. printf("** FAILED **\n");
  484. printf(" Second call.\n");
  485. printf(" Status: %d\n", GetLastError());
  486. printf(" Sid Length: %d\n", cbSid);
  487. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  488. } else {
  489. printf("Succeeded\n");
  490. printf(" Sid Length: %d\n", cbSid);
  491. printf(" Sid: ");
  492. DisplayAccountSid( Sid );
  493. printf("\n");
  494. printf(" Domain Name Length: %d\n", cbReferencedDomainName);
  495. printf(" Domain Name: *%s*\n", ReferencedDomainName);
  496. printf(" Use: ");
  497. DisplayUse( peUse );
  498. printf("\n\n");
  499. }
  500. }
  501. }
  502. void
  503. TestLookupPrivilegeDisplayNameW(
  504. PLUID lpLuid
  505. )
  506. {
  507. //
  508. // LookupPrivilegeDisplayNameW test
  509. //
  510. BOOL Bool;
  511. DWORD cbName = 0;
  512. WCHAR Name[BUFFER_SIZE];
  513. DWORD LanguageId;
  514. LPWSTR PrivName;
  515. printf(" LookupW call . . . . . . . . . . . . . . . . . ");
  516. TestGetPrivNameW( &PrivName, lpLuid );
  517. Bool = LookupPrivilegeDisplayNameW(
  518. NULL,
  519. PrivName,
  520. Name,
  521. &cbName,
  522. &LanguageId
  523. );
  524. //
  525. // Expect failure here
  526. //
  527. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  528. printf("** FAILED **\n");
  529. printf(" First call.\n");
  530. printf(" Status: %d\n", GetLastError());
  531. printf(" Name Length: %d\n", cbName);
  532. } else {
  533. Bool = LookupPrivilegeDisplayNameW(
  534. NULL,
  535. PrivName,
  536. Name,
  537. &cbName,
  538. &LanguageId
  539. );
  540. if ( !Bool ) {
  541. printf("** FAILED **\n");
  542. printf(" Second call.\n");
  543. printf(" Status: %d\n", GetLastError());
  544. printf(" Name Length: %d\n", cbName);
  545. } else {
  546. printf("Succeeded\n");
  547. printf(" Name Length: %d\n", cbName);
  548. printf(" Name: *");
  549. DumpWCharString( Name );
  550. printf("*\n");
  551. printf(" LanguageID: %d\n", LanguageId);
  552. printf("\n\n");
  553. }
  554. }
  555. RtlFreeHeap( RtlProcessHeap(), 0, PrivName );
  556. return;
  557. }
  558. void
  559. TestLookupPrivilegeDisplayNameA(
  560. PLUID lpLuid
  561. )
  562. {
  563. //
  564. // LookupPrivilegeDisplayNameA test
  565. //
  566. BOOL Bool;
  567. DWORD cbName = 0;
  568. UCHAR Name[BUFFER_SIZE];
  569. DWORD LanguageId;
  570. LPSTR PrivName;
  571. printf(" LookupA call . . . . . . . . . . . . . . . . . ");
  572. TestGetPrivNameA( &PrivName, lpLuid );
  573. Bool = LookupPrivilegeDisplayNameA(
  574. NULL,
  575. PrivName,
  576. Name,
  577. &cbName,
  578. &LanguageId
  579. );
  580. //
  581. // Expect failure here
  582. //
  583. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  584. printf("** FAILED **\n");
  585. printf(" First call.\n");
  586. printf(" Status: %d\n", GetLastError());
  587. printf(" Name Length: %d\n", cbName);
  588. } else {
  589. Bool = LookupPrivilegeDisplayNameA(
  590. NULL,
  591. PrivName,
  592. Name,
  593. &cbName,
  594. &LanguageId
  595. );
  596. if ( !Bool ) {
  597. printf("** FAILED **\n");
  598. printf(" Second call.\n");
  599. printf(" Status: %d\n", GetLastError());
  600. printf(" Name Length: %d\n", cbName);
  601. } else {
  602. printf("Succeeded\n");
  603. printf(" Name Length: %d\n", cbName);
  604. printf(" Name: *%s*\n", Name);
  605. printf(" LanguageID: %d\n", LanguageId);
  606. printf("\n\n");
  607. }
  608. }
  609. RtlFreeHeap( RtlProcessHeap(), 0, PrivName );
  610. return;
  611. }
  612. void
  613. TestLookupPrivilegeValueA(
  614. PLUID lpLuid
  615. )
  616. {
  617. //
  618. // LookupPrivilegeValueA test
  619. //
  620. BOOL Bool;
  621. LPSTR PrivName;
  622. LUID ReturnedValue;
  623. TestGetPrivNameA( &PrivName, lpLuid );
  624. printf(" LookupA call . . . . . . . . . . . . . . . . . ");
  625. Bool = LookupPrivilegeValueA(
  626. NULL,
  627. PrivName,
  628. &ReturnedValue
  629. );
  630. if ( !Bool ) {
  631. printf("** FAILED **\n");
  632. printf(" Status: %d\n", GetLastError());
  633. } else {
  634. if (ReturnedValue.LowPart != lpLuid->LowPart ||
  635. ReturnedValue.HighPart != lpLuid->HighPart) {
  636. printf("** FAILED **\n");
  637. printf(" Value mismatch.\n");
  638. printf(" Passed Value: {0x%lx, 0x%lx}\n",
  639. lpLuid->HighPart,lpLuid->LowPart);
  640. printf(" Retrieved Value: {0x%lx, 0x%lx}\n",
  641. ReturnedValue.HighPart,ReturnedValue.LowPart);
  642. } else {
  643. printf("Succeeded\n");
  644. }
  645. }
  646. printf("\n\n");
  647. RtlFreeHeap( RtlProcessHeap(), 0, PrivName );
  648. return;
  649. }
  650. void
  651. TestLookupPrivilegeValueW(
  652. PLUID lpLuid
  653. )
  654. {
  655. //
  656. // LookupPrivilegeValueW test
  657. //
  658. BOOL Bool;
  659. LPWSTR PrivName;
  660. LUID ReturnedValue;
  661. TestGetPrivNameW( &PrivName, lpLuid );
  662. printf(" LookupW call . . . . . . . . . . . . . . . . . ");
  663. Bool = LookupPrivilegeValueW(
  664. NULL,
  665. PrivName,
  666. &ReturnedValue
  667. );
  668. if ( !Bool ) {
  669. printf("** FAILED **\n");
  670. printf(" Status: %d\n", GetLastError());
  671. } else {
  672. if (ReturnedValue.LowPart != lpLuid->LowPart ||
  673. ReturnedValue.HighPart != lpLuid->HighPart) {
  674. printf("** FAILED **\n");
  675. printf(" Value mismatch.\n");
  676. printf(" Passed Value: {0x%lx, 0x%lx}\n",
  677. lpLuid->HighPart,lpLuid->LowPart);
  678. printf(" Retrieved Value: {0x%lx, 0x%lx}\n",
  679. ReturnedValue.HighPart,ReturnedValue.LowPart);
  680. } else {
  681. printf("Succeeded\n");
  682. }
  683. }
  684. RtlFreeHeap( RtlProcessHeap(), 0, PrivName );
  685. return;
  686. }
  687. void
  688. TestGetPrivNameW(
  689. LPWSTR *PrivName,
  690. PLUID lpLuid
  691. )
  692. {
  693. BOOL Bool;
  694. DWORD cbName = 0;
  695. PWCHAR Name = NULL;
  696. Bool = LookupPrivilegeNameW(
  697. NULL,
  698. lpLuid,
  699. Name,
  700. &cbName
  701. );
  702. ASSERT( !Bool && GetLastError() == ERROR_INSUFFICIENT_BUFFER );
  703. Name = RtlAllocateHeap( RtlProcessHeap(), 0, (cbName+1)*sizeof(WCHAR) );
  704. Bool = LookupPrivilegeNameW(
  705. NULL,
  706. lpLuid,
  707. Name,
  708. &cbName
  709. );
  710. ASSERT(Bool);
  711. (*PrivName) = (LPWSTR)Name;
  712. return;
  713. }
  714. void
  715. TestGetPrivNameA(
  716. LPSTR *PrivName,
  717. PLUID lpLuid
  718. )
  719. {
  720. BOOL Bool;
  721. DWORD cbName = 0;
  722. PCHAR Name = NULL;
  723. Bool = LookupPrivilegeNameA(
  724. NULL,
  725. lpLuid,
  726. Name,
  727. &cbName
  728. );
  729. ASSERT( !Bool && GetLastError() == ERROR_INSUFFICIENT_BUFFER );
  730. Name = RtlAllocateHeap( RtlProcessHeap(), 0, (cbName+1)*sizeof(CHAR) );
  731. Bool = LookupPrivilegeNameA(
  732. NULL,
  733. lpLuid,
  734. Name,
  735. &cbName
  736. );
  737. ASSERT(Bool);
  738. (*PrivName) = (LPSTR)Name;
  739. return;
  740. }
  741. void
  742. TestLookupPrivilegeNameW(
  743. PLUID lpLuid
  744. )
  745. {
  746. //
  747. // LookupPrivilegeNameW test
  748. //
  749. BOOL Bool;
  750. DWORD cbName = 0;
  751. WCHAR Name[BUFFER_SIZE];
  752. printf(" LookupW call . . . . . . . . . . . . . . . . . ");
  753. Bool = LookupPrivilegeNameW(
  754. NULL,
  755. lpLuid,
  756. Name,
  757. &cbName
  758. );
  759. //
  760. // Expect failure here
  761. //
  762. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  763. printf("** FAILED **\n");
  764. printf(" First call.\n");
  765. printf(" Status: %d\n", GetLastError());
  766. printf(" Name Length: %d\n", cbName);
  767. } else {
  768. Bool = LookupPrivilegeNameW(
  769. NULL,
  770. lpLuid,
  771. Name,
  772. &cbName
  773. );
  774. if ( !Bool ) {
  775. printf("** FAILED **\n");
  776. printf(" Second call.\n");
  777. printf(" Status: %d\n", GetLastError());
  778. printf(" Name Length: %d\n", cbName);
  779. } else {
  780. printf("Succeeded\n");
  781. printf(" Name Length: %d\n", cbName);
  782. printf(" Name: *");
  783. DumpWCharString( Name );
  784. printf("*\n");
  785. printf("\n\n");
  786. }
  787. }
  788. return;
  789. }
  790. void
  791. TestLookupPrivilegeNameA(
  792. PLUID lpLuid
  793. )
  794. {
  795. //
  796. // LookupPrivilegeNameA test
  797. //
  798. BOOL Bool;
  799. DWORD cbName = 0;
  800. UCHAR Name[BUFFER_SIZE];
  801. printf(" LookupA call . . . . . . . . . . . . . . . . . ");
  802. Bool = LookupPrivilegeNameA(
  803. NULL,
  804. lpLuid,
  805. Name,
  806. &cbName
  807. );
  808. //
  809. // Expect failure here
  810. //
  811. if ( !Bool && GetLastError() != ERROR_INSUFFICIENT_BUFFER ) {
  812. printf("** FAILED **\n");
  813. printf(" First call.\n");
  814. printf(" Status: %d\n", GetLastError());
  815. printf(" Name Length: %d\n", cbName);
  816. } else {
  817. Bool = LookupPrivilegeNameA(
  818. NULL,
  819. lpLuid,
  820. Name,
  821. &cbName
  822. );
  823. if ( !Bool ) {
  824. printf("** FAILED **\n");
  825. printf(" Second call.\n");
  826. printf(" Status: %d\n", GetLastError());
  827. printf(" Name Length: %d\n", cbName);
  828. } else {
  829. printf("Succeeded\n");
  830. printf(" Name Length: %d\n", cbName);
  831. printf(" Name: *%s*\n", Name);
  832. printf("\n\n");
  833. }
  834. }
  835. }
  836. VOID
  837. DisplayUse(
  838. IN SID_NAME_USE Use
  839. )
  840. {
  841. switch (Use) {
  842. case SidTypeUser:
  843. printf("user");
  844. break;
  845. case SidTypeGroup:
  846. printf("group");
  847. break;
  848. case SidTypeDomain:
  849. printf("domain");
  850. break;
  851. case SidTypeAlias:
  852. printf("alias");
  853. break;
  854. case SidTypeWellKnownGroup:
  855. printf("well known group");
  856. break;
  857. case SidTypeDeletedAccount:
  858. printf("deleted account");
  859. break;
  860. case SidTypeInvalid:
  861. printf("invalid to lsa");
  862. break;
  863. case SidTypeUnknown:
  864. printf("unknown to lsa");
  865. break;
  866. default:
  867. printf("** invalid use value returned **");
  868. }
  869. }
  870. void
  871. DumpWCharString(
  872. PWSTR String
  873. )
  874. {
  875. UNICODE_STRING Unicode;
  876. ANSI_STRING AnsiString;
  877. RtlInitUnicodeString( &Unicode, String );
  878. // DbgPrint("*%Z*\n",&Unicode);
  879. // DbgPrint(" Length: %d\n", Unicode.Length);
  880. // DbgPrint(" Max: %d\n", Unicode.MaximumLength);
  881. RtlUnicodeStringToAnsiString( &AnsiString, &Unicode, TRUE );
  882. AnsiString.Buffer[AnsiString.Length]=0; // null terminate it
  883. printf("%s", AnsiString.Buffer );
  884. RtlFreeAnsiString( &AnsiString );
  885. return;
  886. }
  887. VOID
  888. DisplayAccountSid(
  889. PSID Sid
  890. )
  891. {
  892. UCHAR i;
  893. ULONG Tmp;
  894. PSID_IDENTIFIER_AUTHORITY IdentifierAuthority;
  895. UCHAR SubAuthorityCount;
  896. IdentifierAuthority = RtlIdentifierAuthoritySid(Sid);
  897. //
  898. // HACK! HACK!
  899. // The next line prints the revision of the SID. Since there is no
  900. // rtl routine which gives us the SID revision, we must make due.
  901. // luckily, the revision field is the first field in the SID, so we
  902. // can just cast the pointer.
  903. //
  904. printf("S-%u-", (USHORT) *((PUCHAR) Sid) );
  905. if ( (IdentifierAuthority->Value[0] != 0) ||
  906. (IdentifierAuthority->Value[1] != 0) ){
  907. printf("0x%02hx%02hx%02hx%02hx%02hx%02hx",
  908. IdentifierAuthority->Value[0],
  909. IdentifierAuthority->Value[1],
  910. IdentifierAuthority->Value[2],
  911. IdentifierAuthority->Value[3],
  912. IdentifierAuthority->Value[4],
  913. IdentifierAuthority->Value[5] );
  914. } else {
  915. Tmp = IdentifierAuthority->Value[5] +
  916. (IdentifierAuthority->Value[4] << 8) +
  917. (IdentifierAuthority->Value[3] << 16) +
  918. (IdentifierAuthority->Value[2] << 24);
  919. printf("%lu", Tmp);
  920. }
  921. SubAuthorityCount = *RtlSubAuthorityCountSid(Sid);
  922. for (i=0;i<SubAuthorityCount ;i++ ) {
  923. printf("-%lu", (*RtlSubAuthoritySid(Sid, i)));
  924. }
  925. printf("\n");
  926. }
  927. VOID
  928. TestLookupSid()
  929. {
  930. /////////////////////////////////////////////////////////////////////////
  931. // //
  932. // Sid -> Name test //
  933. // //
  934. /////////////////////////////////////////////////////////////////////////
  935. printf("\n\n\n");
  936. printf(" Sid lookup . . . . . . . . . . . . . . . . . . suite\n");
  937. printf(" Lookup NullSid\n");
  938. TestLookupSidW( NullSid ); TestLookupSidA( NullSid );
  939. printf(" Lookup WorldSid\n");
  940. TestLookupSidW( WorldSid ); TestLookupSidA( WorldSid );
  941. printf(" Lookup LocalSid\n");
  942. TestLookupSidW( LocalSid ); TestLookupSidA( LocalSid );
  943. printf(" Lookup CreatorOwnerSid\n");
  944. TestLookupSidW( CreatorOwnerSid ); TestLookupSidA( CreatorOwnerSid );
  945. printf(" Lookup NtAuthoritySid\n");
  946. TestLookupSidW( NtAuthoritySid ); TestLookupSidA( NtAuthoritySid );
  947. printf(" Lookup DialupSid\n");
  948. TestLookupSidW( DialupSid ); TestLookupSidA( DialupSid );
  949. printf(" Lookup NetworkSid\n");
  950. TestLookupSidW( NetworkSid ); TestLookupSidA( NetworkSid );
  951. printf(" Lookup BatchSid\n");
  952. TestLookupSidW( BatchSid ); TestLookupSidA( BatchSid );
  953. printf(" Lookup InteractiveSid\n");
  954. TestLookupSidW( InteractiveSid ); TestLookupSidA( InteractiveSid );
  955. printf(" Lookup LocalSystemSid\n");
  956. TestLookupSidW( LocalSystemSid ); TestLookupSidA( LocalSystemSid );
  957. printf("\n\n\n");
  958. return;
  959. }
  960. VOID
  961. TestLookupName()
  962. {
  963. /////////////////////////////////////////////////////////////////////////
  964. // //
  965. // Name -> Sid test //
  966. // //
  967. /////////////////////////////////////////////////////////////////////////
  968. printf(" Name Lookup . . . . . . . . . . . . . . . . . suite\n");
  969. printf(" Lookup Null\n");
  970. TestLookupNameW( L"" ); TestLookupNameA( "" );
  971. printf(" Lookup World\n");
  972. TestLookupNameW( L"World" ); TestLookupNameA( "World" );
  973. printf(" Lookup Local\n");
  974. TestLookupNameW( L"Local" ); TestLookupNameA( "Local" );
  975. printf(" Lookup CreatorOwner\n");
  976. TestLookupNameW( L"CreatorOwner" ); TestLookupNameA( "CreatorOwner" );
  977. printf(" Lookup NtAuthority\n");
  978. TestLookupNameW( L"NtAuthority" ); TestLookupNameA( "NtAuthority" );
  979. printf(" Lookup DialupName\n");
  980. TestLookupNameW( L"DialupName" ); TestLookupNameA( "DialupName" );
  981. printf(" Lookup Network\n");
  982. TestLookupNameW( L"Network" ); TestLookupNameA( "Network" );
  983. printf(" Lookup Batch\n");
  984. TestLookupNameW( L"Batch" ); TestLookupNameA( "Batch" );
  985. printf(" Lookup Interactive\n");
  986. TestLookupNameW( L"Interactive" ); TestLookupNameA( "Interactive" );
  987. printf(" Look up LocalSystem\n");
  988. TestLookupNameW( L"LocalSystem" ); TestLookupNameA( "LocalSystem" );
  989. printf("\n\n\n");
  990. return;
  991. }
  992. VOID
  993. TestLookupPrivilegeValue()
  994. {
  995. /////////////////////////////////////////////////////////////////////////
  996. // //
  997. // LookupPrivilegeValue Tests //
  998. // //
  999. /////////////////////////////////////////////////////////////////////////
  1000. printf("\n\n\n");
  1001. printf(" Privilege Value Lookup . . . . . . . . . . . . suite\n");
  1002. printf(" Lookup SeCreateTokenPrivilege\n");
  1003. TestLookupPrivilegeValueW( &SeCreateTokenPrivilege );
  1004. TestLookupPrivilegeValueA( &SeCreateTokenPrivilege );
  1005. printf(" Lookup SeAssignPrimaryTokenPrivilege\n");
  1006. TestLookupPrivilegeValueW( &SeAssignPrimaryTokenPrivilege );
  1007. TestLookupPrivilegeValueA( &SeAssignPrimaryTokenPrivilege );
  1008. printf(" Lookup SeLockMemoryPrivilege\n");
  1009. TestLookupPrivilegeValueW( &SeLockMemoryPrivilege );
  1010. TestLookupPrivilegeValueA( &SeLockMemoryPrivilege );
  1011. printf(" Lookup SeIncreaseQuotaPrivilege\n");
  1012. TestLookupPrivilegeValueW( &SeIncreaseQuotaPrivilege );
  1013. TestLookupPrivilegeValueA( &SeIncreaseQuotaPrivilege );
  1014. printf(" Lookup SeUnsolicitedInputPrivilege\n");
  1015. TestLookupPrivilegeValueW( &SeUnsolicitedInputPrivilege );
  1016. TestLookupPrivilegeValueA( &SeUnsolicitedInputPrivilege );
  1017. printf(" Lookup SeTcbPrivilege\n");
  1018. TestLookupPrivilegeValueW( &SeTcbPrivilege );
  1019. TestLookupPrivilegeValueA( &SeTcbPrivilege );
  1020. printf(" Lookup SeSecurityPrivilege\n");
  1021. TestLookupPrivilegeValueW( &SeSecurityPrivilege );
  1022. TestLookupPrivilegeValueA( &SeSecurityPrivilege );
  1023. printf(" Lookup SeTakeOwnershipPrivilege\n");
  1024. TestLookupPrivilegeValueW( &SeTakeOwnershipPrivilege );
  1025. TestLookupPrivilegeValueA( &SeTakeOwnershipPrivilege );
  1026. printf(" Lookup SeLoadDriverPrivilege\n");
  1027. TestLookupPrivilegeValueW( &SeLoadDriverPrivilege );
  1028. TestLookupPrivilegeValueA( &SeLoadDriverPrivilege );
  1029. printf(" Lookup SeCreatePagefilePrivilege\n");
  1030. TestLookupPrivilegeValueW( &SeCreatePagefilePrivilege );
  1031. TestLookupPrivilegeValueA( &SeCreatePagefilePrivilege );
  1032. printf(" Lookup SeIncreaseBasePriorityPrivilege\n");
  1033. TestLookupPrivilegeValueW( &SeIncreaseBasePriorityPrivilege );
  1034. TestLookupPrivilegeValueA( &SeIncreaseBasePriorityPrivilege );
  1035. printf(" Lookup SeSystemProfilePrivilege\n");
  1036. TestLookupPrivilegeValueW( &SeSystemProfilePrivilege );
  1037. TestLookupPrivilegeValueA( &SeSystemProfilePrivilege );
  1038. printf(" Lookup SeSystemtimePrivilege\n");
  1039. TestLookupPrivilegeValueW( &SeSystemtimePrivilege );
  1040. TestLookupPrivilegeValueA( &SeSystemtimePrivilege );
  1041. printf(" Lookup SeProfileSingleProcessPrivilege\n");
  1042. TestLookupPrivilegeValueW( &SeProfileSingleProcessPrivilege );
  1043. TestLookupPrivilegeValueA( &SeProfileSingleProcessPrivilege );
  1044. printf(" Lookup SeCreatePermanentPrivilege\n");
  1045. TestLookupPrivilegeValueW( &SeCreatePermanentPrivilege );
  1046. TestLookupPrivilegeValueA( &SeCreatePermanentPrivilege );
  1047. printf(" Lookup SeBackupPrivilege\n");
  1048. TestLookupPrivilegeValueW( &SeBackupPrivilege );
  1049. TestLookupPrivilegeValueA( &SeBackupPrivilege );
  1050. printf(" Lookup SeRestorePrivilege\n");
  1051. TestLookupPrivilegeValueW( &SeRestorePrivilege );
  1052. TestLookupPrivilegeValueA( &SeRestorePrivilege );
  1053. printf(" Lookup SeShutdownPrivilege\n");
  1054. TestLookupPrivilegeValueW( &SeShutdownPrivilege );
  1055. TestLookupPrivilegeValueA( &SeShutdownPrivilege );
  1056. printf(" Lookup SeDebugPrivilege\n");
  1057. TestLookupPrivilegeValueW( &SeDebugPrivilege );
  1058. TestLookupPrivilegeValueA( &SeDebugPrivilege );
  1059. printf(" Lookup SeAuditPrivilege\n");
  1060. TestLookupPrivilegeValueW( &SeAuditPrivilege );
  1061. TestLookupPrivilegeValueA( &SeAuditPrivilege );
  1062. printf(" Lookup SeSystemEnvironmentPrivilege\n");
  1063. TestLookupPrivilegeValueW( &SeSystemEnvironmentPrivilege );
  1064. TestLookupPrivilegeValueA( &SeSystemEnvironmentPrivilege );
  1065. printf(" Lookup SeChangeNotifyPrivilege\n");
  1066. TestLookupPrivilegeValueW( &SeChangeNotifyPrivilege );
  1067. TestLookupPrivilegeValueA( &SeChangeNotifyPrivilege );
  1068. printf(" Lookup SeRemoteShutdownPrivilege\n");
  1069. TestLookupPrivilegeValueW( &SeRemoteShutdownPrivilege );
  1070. TestLookupPrivilegeValueA( &SeRemoteShutdownPrivilege );
  1071. printf("\n\n\n");
  1072. return;
  1073. }
  1074. VOID
  1075. TestLookupPrivilegeName()
  1076. {
  1077. /////////////////////////////////////////////////////////////////////////
  1078. // //
  1079. // LookupPrivilegeName Tests //
  1080. // //
  1081. /////////////////////////////////////////////////////////////////////////
  1082. printf("\n\n\n");
  1083. printf(" Privilege Name Lookup . . . . . . . . . . . . suite\n");
  1084. printf(" Lookup SeCreateTokenPrivilege\n");
  1085. TestLookupPrivilegeNameW( &SeCreateTokenPrivilege );
  1086. TestLookupPrivilegeNameA( &SeCreateTokenPrivilege );
  1087. printf(" Lookup SeAssignPrimaryTokenPrivilege\n");
  1088. TestLookupPrivilegeNameW( &SeAssignPrimaryTokenPrivilege );
  1089. TestLookupPrivilegeNameA( &SeAssignPrimaryTokenPrivilege );
  1090. printf(" Lookup SeLockMemoryPrivilege\n");
  1091. TestLookupPrivilegeNameW( &SeLockMemoryPrivilege );
  1092. TestLookupPrivilegeNameA( &SeLockMemoryPrivilege );
  1093. printf(" Lookup SeIncreaseQuotaPrivilege\n");
  1094. TestLookupPrivilegeNameW( &SeIncreaseQuotaPrivilege );
  1095. TestLookupPrivilegeNameA( &SeIncreaseQuotaPrivilege );
  1096. printf(" Lookup SeUnsolicitedInputPrivilege\n");
  1097. TestLookupPrivilegeNameW( &SeUnsolicitedInputPrivilege );
  1098. TestLookupPrivilegeNameA( &SeUnsolicitedInputPrivilege );
  1099. printf(" Lookup SeTcbPrivilege\n");
  1100. TestLookupPrivilegeNameW( &SeTcbPrivilege );
  1101. TestLookupPrivilegeNameA( &SeTcbPrivilege );
  1102. printf(" Lookup SeSecurityPrivilege\n");
  1103. TestLookupPrivilegeNameW( &SeSecurityPrivilege );
  1104. TestLookupPrivilegeNameA( &SeSecurityPrivilege );
  1105. printf(" Lookup SeTakeOwnershipPrivilege\n");
  1106. TestLookupPrivilegeNameW( &SeTakeOwnershipPrivilege );
  1107. TestLookupPrivilegeNameA( &SeTakeOwnershipPrivilege );
  1108. printf(" Lookup SeLoadDriverPrivilege\n");
  1109. TestLookupPrivilegeNameW( &SeLoadDriverPrivilege );
  1110. TestLookupPrivilegeNameA( &SeLoadDriverPrivilege );
  1111. printf(" Lookup SeCreatePagefilePrivilege\n");
  1112. TestLookupPrivilegeNameW( &SeCreatePagefilePrivilege );
  1113. TestLookupPrivilegeNameA( &SeCreatePagefilePrivilege );
  1114. printf(" Lookup SeIncreaseBasePriorityPrivilege\n");
  1115. TestLookupPrivilegeNameW( &SeIncreaseBasePriorityPrivilege );
  1116. TestLookupPrivilegeNameA( &SeIncreaseBasePriorityPrivilege );
  1117. printf(" Lookup SeSystemProfilePrivilege\n");
  1118. TestLookupPrivilegeNameW( &SeSystemProfilePrivilege );
  1119. TestLookupPrivilegeNameA( &SeSystemProfilePrivilege );
  1120. printf(" Lookup SeSystemtimePrivilege\n");
  1121. TestLookupPrivilegeNameW( &SeSystemtimePrivilege );
  1122. TestLookupPrivilegeNameA( &SeSystemtimePrivilege );
  1123. printf(" Lookup SeProfileSingleProcessPrivilege\n");
  1124. TestLookupPrivilegeNameW( &SeProfileSingleProcessPrivilege );
  1125. TestLookupPrivilegeNameA( &SeProfileSingleProcessPrivilege );
  1126. printf(" Lookup SeCreatePermanentPrivilege\n");
  1127. TestLookupPrivilegeNameW( &SeCreatePermanentPrivilege );
  1128. TestLookupPrivilegeNameA( &SeCreatePermanentPrivilege );
  1129. printf(" Lookup SeBackupPrivilege\n");
  1130. TestLookupPrivilegeNameW( &SeBackupPrivilege );
  1131. TestLookupPrivilegeNameA( &SeBackupPrivilege );
  1132. printf(" Lookup SeRestorePrivilege\n");
  1133. TestLookupPrivilegeNameW( &SeRestorePrivilege );
  1134. TestLookupPrivilegeNameA( &SeRestorePrivilege );
  1135. printf(" Lookup SeShutdownPrivilege\n");
  1136. TestLookupPrivilegeNameW( &SeShutdownPrivilege );
  1137. TestLookupPrivilegeNameA( &SeShutdownPrivilege );
  1138. printf(" Lookup SeDebugPrivilege\n");
  1139. TestLookupPrivilegeNameW( &SeDebugPrivilege );
  1140. TestLookupPrivilegeNameA( &SeDebugPrivilege );
  1141. printf(" Lookup SeAuditPrivilege\n");
  1142. TestLookupPrivilegeNameW( &SeAuditPrivilege );
  1143. TestLookupPrivilegeNameA( &SeAuditPrivilege );
  1144. printf(" Lookup SeSystemEnvironmentPrivilege\n");
  1145. TestLookupPrivilegeNameW( &SeSystemEnvironmentPrivilege );
  1146. TestLookupPrivilegeNameA( &SeSystemEnvironmentPrivilege );
  1147. printf(" Lookup SeChangeNotifyPrivilege\n");
  1148. TestLookupPrivilegeNameW( &SeChangeNotifyPrivilege );
  1149. TestLookupPrivilegeNameA( &SeChangeNotifyPrivilege );
  1150. printf(" Lookup SeRemoteShutdownPrivilege\n");
  1151. TestLookupPrivilegeNameW( &SeRemoteShutdownPrivilege );
  1152. TestLookupPrivilegeNameA( &SeRemoteShutdownPrivilege );
  1153. printf("\n\n\n");
  1154. return;
  1155. }
  1156. VOID
  1157. TestLookupPrivilegeDisplayName()
  1158. {
  1159. /////////////////////////////////////////////////////////////////////////
  1160. // //
  1161. // LookupPrivilegeDisplayName Tests //
  1162. // //
  1163. /////////////////////////////////////////////////////////////////////////
  1164. printf(" Privilege Display Name Lookup . . . . . . . . suite\n");
  1165. printf(" Lookup SeCreateTokenPrivilege\n");
  1166. TestLookupPrivilegeDisplayNameW( &SeCreateTokenPrivilege );
  1167. TestLookupPrivilegeDisplayNameA( &SeCreateTokenPrivilege );
  1168. printf(" Lookup SeAssignPrimaryTokenPrivilege\n");
  1169. TestLookupPrivilegeDisplayNameW( &SeAssignPrimaryTokenPrivilege );
  1170. TestLookupPrivilegeDisplayNameA( &SeAssignPrimaryTokenPrivilege );
  1171. printf(" Lookup SeLockMemoryPrivilege\n");
  1172. TestLookupPrivilegeDisplayNameW( &SeLockMemoryPrivilege );
  1173. TestLookupPrivilegeDisplayNameA( &SeLockMemoryPrivilege );
  1174. printf(" Lookup SeIncreaseQuotaPrivilege\n");
  1175. TestLookupPrivilegeDisplayNameW( &SeIncreaseQuotaPrivilege );
  1176. TestLookupPrivilegeDisplayNameA( &SeIncreaseQuotaPrivilege );
  1177. printf(" Lookup SeUnsolicitedInputPrivilege\n");
  1178. TestLookupPrivilegeDisplayNameW( &SeUnsolicitedInputPrivilege );
  1179. TestLookupPrivilegeDisplayNameA( &SeUnsolicitedInputPrivilege );
  1180. printf(" Lookup SeTcbPrivilege\n");
  1181. TestLookupPrivilegeDisplayNameW( &SeTcbPrivilege );
  1182. TestLookupPrivilegeDisplayNameA( &SeTcbPrivilege );
  1183. printf(" Lookup SeSecurityPrivilege\n");
  1184. TestLookupPrivilegeDisplayNameW( &SeSecurityPrivilege );
  1185. TestLookupPrivilegeDisplayNameA( &SeSecurityPrivilege );
  1186. printf(" Lookup SeTakeOwnershipPrivilege\n");
  1187. TestLookupPrivilegeDisplayNameW( &SeTakeOwnershipPrivilege );
  1188. TestLookupPrivilegeDisplayNameA( &SeTakeOwnershipPrivilege );
  1189. printf(" Lookup SeLoadDriverPrivilege\n");
  1190. TestLookupPrivilegeDisplayNameW( &SeLoadDriverPrivilege );
  1191. TestLookupPrivilegeDisplayNameA( &SeLoadDriverPrivilege );
  1192. printf(" Lookup SeCreatePagefilePrivilege\n");
  1193. TestLookupPrivilegeDisplayNameW( &SeCreatePagefilePrivilege );
  1194. TestLookupPrivilegeDisplayNameA( &SeCreatePagefilePrivilege );
  1195. printf(" Lookup SeIncreaseBasePriorityPrivilege\n");
  1196. TestLookupPrivilegeDisplayNameW( &SeIncreaseBasePriorityPrivilege );
  1197. TestLookupPrivilegeDisplayNameA( &SeIncreaseBasePriorityPrivilege );
  1198. printf(" Lookup SeSystemProfilePrivilege\n");
  1199. TestLookupPrivilegeDisplayNameW( &SeSystemProfilePrivilege );
  1200. TestLookupPrivilegeDisplayNameA( &SeSystemProfilePrivilege );
  1201. printf(" Lookup SeSystemtimePrivilege\n");
  1202. TestLookupPrivilegeDisplayNameW( &SeSystemtimePrivilege );
  1203. TestLookupPrivilegeDisplayNameA( &SeSystemtimePrivilege );
  1204. printf(" Lookup SeProfileSingleProcessPrivilege\n");
  1205. TestLookupPrivilegeDisplayNameW( &SeProfileSingleProcessPrivilege );
  1206. TestLookupPrivilegeDisplayNameA( &SeProfileSingleProcessPrivilege );
  1207. printf(" Lookup SeCreatePermanentPrivilege\n");
  1208. TestLookupPrivilegeDisplayNameW( &SeCreatePermanentPrivilege );
  1209. TestLookupPrivilegeDisplayNameA( &SeCreatePermanentPrivilege );
  1210. printf(" Lookup SeBackupPrivilege\n");
  1211. TestLookupPrivilegeDisplayNameW( &SeBackupPrivilege );
  1212. TestLookupPrivilegeDisplayNameA( &SeBackupPrivilege );
  1213. printf(" Lookup SeRestorePrivilege\n");
  1214. TestLookupPrivilegeDisplayNameW( &SeRestorePrivilege );
  1215. TestLookupPrivilegeDisplayNameA( &SeRestorePrivilege );
  1216. printf(" Lookup SeShutdownPrivilege\n");
  1217. TestLookupPrivilegeDisplayNameW( &SeShutdownPrivilege );
  1218. TestLookupPrivilegeDisplayNameA( &SeShutdownPrivilege );
  1219. printf(" Lookup SeDebugPrivilege\n");
  1220. TestLookupPrivilegeDisplayNameW( &SeDebugPrivilege );
  1221. TestLookupPrivilegeDisplayNameA( &SeDebugPrivilege );
  1222. printf(" Lookup SeAuditPrivilege\n");
  1223. TestLookupPrivilegeDisplayNameW( &SeAuditPrivilege );
  1224. TestLookupPrivilegeDisplayNameA( &SeAuditPrivilege );
  1225. printf(" Lookup SeSystemEnvironmentPrivilege\n");
  1226. TestLookupPrivilegeDisplayNameW( &SeSystemEnvironmentPrivilege );
  1227. TestLookupPrivilegeDisplayNameA( &SeSystemEnvironmentPrivilege );
  1228. printf(" Lookup SeChangeNotifyPrivilege\n");
  1229. TestLookupPrivilegeDisplayNameW( &SeChangeNotifyPrivilege );
  1230. TestLookupPrivilegeDisplayNameA( &SeChangeNotifyPrivilege );
  1231. printf(" Lookup SeRemoteShutdownPrivilege\n");
  1232. TestLookupPrivilegeDisplayNameW( &SeRemoteShutdownPrivilege );
  1233. TestLookupPrivilegeDisplayNameA( &SeRemoteShutdownPrivilege );
  1234. printf("\n\n\n");
  1235. return;
  1236. }
  1237. int
  1238. main (void)
  1239. {
  1240. initialize();
  1241. TestLookupSid();
  1242. TestLookupName();
  1243. TestLookupPrivilegeName();
  1244. TestLookupPrivilegeValue();
  1245. TestLookupPrivilegeDisplayName();
  1246. return(0);
  1247. }