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.

141 lines
3.0 KiB

  1. #include "pch.h"
  2. void _cdecl wmain(int argc, WCHAR * argv[])
  3. {
  4. AUTHZ_RESOURCE_MANAGER_HANDLE hRM = NULL;
  5. AUTHZ_AUDIT_EVENT_HANDLE hAE = NULL;
  6. AUTHZ_AUDIT_EVENT_TYPE_HANDLE hAET = NULL;
  7. LONG i = 0;
  8. LONG Iterations = 0;
  9. BOOL b = TRUE;
  10. PAUDIT_PARAMS pParams = NULL;
  11. b = AuthzInitializeResourceManager(
  12. 0,
  13. NULL,
  14. NULL,
  15. NULL,
  16. L"3rd Party",
  17. &hRM
  18. );
  19. if (!b)
  20. {
  21. wprintf(L"AuthzInitializeResourceManager failed with %d\n", GetLastError());
  22. return;
  23. }
  24. #define SE_AUDITID_THIRD_PARTY_AUDIT 0x259
  25. b = AuthziInitializeAuditEventType(
  26. 0,
  27. SE_CATEGID_DETAILED_TRACKING,
  28. SE_AUDITID_THIRD_PARTY_AUDIT,
  29. 2,
  30. &hAET
  31. );
  32. if (!b)
  33. {
  34. wprintf(L"AuthziInitializeAuditEventType failed with %d\n", GetLastError());
  35. return;
  36. }
  37. b = AuthziAllocateAuditParams(
  38. &pParams,
  39. 2
  40. );
  41. if (!b)
  42. {
  43. wprintf(L"AuthzAllocateAuditParams failed with %d\n", GetLastError());
  44. }
  45. b = AuthziInitializeAuditParamsWithRM(
  46. 0,
  47. hRM,
  48. 2,
  49. pParams,
  50. APT_String, L"I am the 3rd Party, and the next param is a number.",
  51. APT_Ulong, 5
  52. );
  53. if (!b)
  54. {
  55. wprintf(L"AuthzInitializeAuditParamsWithRM failed with %d\n", GetLastError());
  56. }
  57. b = AuthziInitializeAuditEvent(
  58. 0,
  59. hRM,
  60. hAET,
  61. pParams,
  62. NULL,
  63. INFINITE,
  64. L"",
  65. L"",
  66. L"",
  67. L"",
  68. &hAE
  69. );
  70. if (!b)
  71. {
  72. wprintf(L"AuthziInitializeAuditEvent failed with %d\n", GetLastError());
  73. return;
  74. }
  75. for (i = 0; i < 1000; i++)
  76. {
  77. b = AuthziLogAuditEvent(
  78. 0,
  79. hAE,
  80. NULL
  81. );
  82. if (!b)
  83. {
  84. wprintf(L"AuthzLogAuditEvent (no queue) failed with %d\n", GetLastError());
  85. }
  86. }
  87. b = AuthzFreeAuditEvent(
  88. hAE
  89. );
  90. if (!b)
  91. {
  92. wprintf(L"AuthziFreeAuditEvent failed with %d\n", GetLastError());
  93. return;
  94. }
  95. b = AuthziFreeAuditEventType(
  96. hAET
  97. );
  98. if (!b)
  99. {
  100. wprintf(L"AuthziFreeAuditEventType failed with %d\n", GetLastError());
  101. return;
  102. }
  103. b = AuthziFreeAuditParams(
  104. pParams
  105. );
  106. if (!b)
  107. {
  108. wprintf(L"AuthziFreeAuditParams failed with %d\n", GetLastError());
  109. return;
  110. }
  111. b = AuthzFreeResourceManager(
  112. hRM
  113. );
  114. if (!b)
  115. {
  116. wprintf(L"AuthzFreeResourceManager failed with %d\n", GetLastError());
  117. return;
  118. }
  119. }