Source code of Windows XP (NT5)
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.

192 lines
3.9 KiB

  1. #include "precomp.h"
  2. DWORD WINAPI ServiceStart( LPVOID lparam);
  3. DWORD WINAPI InitWirelessPolicy (void);
  4. BOOL Is_Whistler_Home_Edition ()
  5. {
  6. OSVERSIONINFOEX osvi;
  7. DWORDLONG dwlConditionMask = 0;
  8. // Initialize the OSVERSIONINFOEX structure.
  9. ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
  10. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
  11. //osvi.dwMajorVersion = 5;
  12. //osvi.dwMinorVersion = 1;
  13. osvi.wSuiteMask = VER_SUITE_PERSONAL;
  14. // Initialize the condition mask.
  15. /*
  16. VER_SET_CONDITION(
  17. dwlConditionMask,
  18. VER_MAJORVERSION,
  19. VER_EQUAL
  20. );
  21. VER_SET_CONDITION(
  22. dwlConditionMask,
  23. VER_MINORVERSION,
  24. VER_EQUAL
  25. );
  26. VER_SET_CONDITION(
  27. dwlConditionMask,
  28. VER_PRODUCT_TYPE,
  29. VER_EQUAL
  30. );
  31. */
  32. VER_SET_CONDITION(
  33. dwlConditionMask,
  34. VER_SUITENAME,
  35. VER_AND
  36. );
  37. // Perform the test.
  38. return VerifyVersionInfo(
  39. &osvi,
  40. VER_SUITENAME,
  41. dwlConditionMask
  42. );
  43. }
  44. DWORD
  45. InitPolicyEngine(DWORD dwParam, HANDLE * hThread)
  46. {
  47. DWORD dwError = 0;
  48. DWORD dwLocThreadId;
  49. HANDLE hLocThread = NULL;
  50. WiFiTrcInit();
  51. if (Is_Whistler_Home_Edition()) {
  52. _WirelessDbg(TRC_ERR, "Policy Engine Not Starting :: This is Home Edition ");
  53. return(dwError);
  54. }
  55. dwError = InitWirelessPolicy();
  56. BAIL_ON_WIN32_ERROR(dwError);
  57. _WirelessDbg(TRC_TRACK, "Starting the Policy Engine in a New Thread ");
  58. hLocThread = CreateThread(
  59. NULL, // no security attributes
  60. 0, // use default stack size
  61. ServiceStart, // thread function
  62. &dwParam, // argument to thread function
  63. 0, // use default creation flags
  64. &dwLocThreadId); // returns the thread identifier
  65. if (hThread == NULL)
  66. {
  67. _WirelessDbg(TRC_ERR, "CreateThread failed." );
  68. dwError = GetLastError();
  69. }
  70. BAIL_ON_WIN32_ERROR(dwError);
  71. *hThread = hLocThread;
  72. // Set the flag that Policy Engine is Initialized
  73. gdwWirelessPolicyEngineInited = 1;
  74. return(dwError);
  75. error:
  76. // State Cleanup Here
  77. ClearPolicyStateBlock(
  78. gpWirelessPolicyState
  79. );
  80. ClearSPDGlobals();
  81. WiFiTrcTerm();
  82. return(dwError);
  83. }
  84. DWORD
  85. TerminatePolicyEngine(HANDLE hThread)
  86. {
  87. DWORD dwError =0;
  88. DWORD dwExitCode = 0;
  89. // send appropriate Event ....
  90. if (Is_Whistler_Home_Edition()) {
  91. _WirelessDbg(TRC_ERR, "Policy Engine Not Started :: This is Home Edition ");
  92. WiFiTrcTerm();
  93. return(dwError);
  94. }
  95. if (!gdwWirelessPolicyEngineInited) {
  96. // Policy Engine was not started. No need to do cleanup;
  97. return(ERROR_NOT_SUPPORTED);
  98. }
  99. if (!SetEvent(ghPolicyEngineStopEvent)) {
  100. dwError = GetLastError();
  101. BAIL_ON_WIN32_ERROR(dwError);
  102. }
  103. dwError = WaitForSingleObject(hThread, INFINITE);
  104. if (dwError) {
  105. _WirelessDbg(TRC_ERR, "Wait Failed ");
  106. }
  107. BAIL_ON_WIN32_ERROR(dwError);
  108. _WirelessDbg(TRC_TRACK, "Thread Exited ");
  109. error:
  110. CloseHandle(hThread);
  111. ClearPolicyStateBlock(
  112. gpWirelessPolicyState
  113. );
  114. ClearSPDGlobals();
  115. WiFiTrcTerm();
  116. // Set that the wireless Policy Engine has been non-inited
  117. gdwWirelessPolicyEngineInited = 0;
  118. return(dwError);
  119. }
  120. DWORD
  121. ReApplyPolicy8021x(void)
  122. {
  123. DWORD dwError =0;
  124. if (ghReApplyPolicy8021x == NULL) {
  125. dwError = ERROR_INVALID_STATE;
  126. _WirelessDbg(TRC_ERR, "Policy Loop Not Initialized Yet ");
  127. return(dwError);
  128. }
  129. _WirelessDbg(TRC_TRACK, " ReApplyPolicy8021x called ");
  130. // send appropriate Event ....
  131. if (!SetEvent(ghReApplyPolicy8021x)) {
  132. dwError = GetLastError();
  133. }
  134. return(dwError);
  135. }