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.

162 lines
4.7 KiB

  1. //*************************************************************
  2. //
  3. // Main entry point
  4. //
  5. // Microsoft Confidential
  6. // Copyright (c) Microsoft Corporation 1995
  7. // All rights reserved
  8. //
  9. //*************************************************************
  10. #include "uenv.h"
  11. extern DWORD g_dwLoadFlags;
  12. //*************************************************************
  13. //
  14. // DllMain()
  15. //
  16. // Purpose: Main entry point
  17. //
  18. // Parameters: hInstance - Module instance
  19. // dwReason - Way this function is being called
  20. // lpReseved - Reserved
  21. //
  22. //
  23. // Return: (BOOL) TRUE if successfully initialized
  24. // FALSE if an error occurs
  25. //
  26. //
  27. // Comments:
  28. //
  29. //
  30. // History: Date Author Comment
  31. // 5/24/95 ericflo Created
  32. //
  33. //*************************************************************
  34. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  35. {
  36. switch (dwReason)
  37. {
  38. case DLL_PROCESS_ATTACH:
  39. {
  40. DisableThreadLibraryCalls (hInstance);
  41. InitializeGlobals (hInstance);
  42. InitializeAPIs();
  43. InitializeNotifySupport();
  44. InitializeGPOCriticalSection();
  45. InitializeSnapProv();
  46. {
  47. TCHAR szProcessName[MAX_PATH];
  48. DWORD dwLoadFlags = FALSE;
  49. DWORD WINLOGON_LEN = 12; // Length of string "winlogon.exe"
  50. DWORD SETUP_LEN = 9; // Length of string "setup.exe"
  51. DWORD dwRet = GetModuleFileName (NULL, szProcessName, ARRAYSIZE(szProcessName));
  52. if ( dwRet > WINLOGON_LEN ) {
  53. if ( CompareString ( LOCALE_USER_DEFAULT, NORM_IGNORECASE,
  54. &szProcessName[dwRet-WINLOGON_LEN], -1, L"winlogon.exe", -1 ) == CSTR_EQUAL ) {
  55. g_dwLoadFlags = dwLoadFlags = WINLOGON_LOAD;
  56. }
  57. }
  58. #if 0
  59. if ( dwRet > SETUP_LEN ) {
  60. if ( CompareString ( LOCALE_USER_DEFAULT, NORM_IGNORECASE,
  61. &szProcessName[dwRet-SETUP_LEN], -1, L"setup.exe", -1 ) == CSTR_EQUAL ) {
  62. g_dwLoadFlags = dwLoadFlags = SETUP_LOAD;
  63. }
  64. }
  65. #endif
  66. InitDebugSupport( dwLoadFlags );
  67. if (dwLoadFlags == WINLOGON_LOAD) {
  68. InitializePolicyProcessing(TRUE);
  69. InitializePolicyProcessing(FALSE);
  70. }
  71. DebugMsg((DM_VERBOSE, TEXT("LibMain: Process Name: %s"), szProcessName));
  72. }
  73. }
  74. break;
  75. case DLL_PROCESS_DETACH:
  76. if (g_hProfileSetup) {
  77. CloseHandle (g_hProfileSetup);
  78. g_hProfileSetup = NULL;
  79. }
  80. if (g_hPolicyCritMutexMach) {
  81. CloseHandle (g_hPolicyCritMutexMach);
  82. g_hPolicyCritMutexMach = NULL;
  83. }
  84. if (g_hPolicyCritMutexUser) {
  85. CloseHandle (g_hPolicyCritMutexUser);
  86. g_hPolicyCritMutexUser = NULL;
  87. }
  88. if (g_hPolicyNotifyEventMach) {
  89. CloseHandle (g_hPolicyNotifyEventMach);
  90. g_hPolicyNotifyEventMach = NULL;
  91. }
  92. if (g_hPolicyNotifyEventUser) {
  93. CloseHandle (g_hPolicyNotifyEventUser);
  94. g_hPolicyNotifyEventUser = NULL;
  95. }
  96. if (g_hPolicyNeedFGEventMach) {
  97. CloseHandle (g_hPolicyNeedFGEventMach);
  98. g_hPolicyNeedFGEventMach = NULL;
  99. }
  100. if (g_hPolicyNeedFGEventUser) {
  101. CloseHandle (g_hPolicyNeedFGEventUser);
  102. g_hPolicyNeedFGEventUser = NULL;
  103. }
  104. if (g_hPolicyDoneEventMach) {
  105. CloseHandle (g_hPolicyDoneEventMach);
  106. g_hPolicyDoneEventMach = NULL;
  107. }
  108. if (g_hPolicyDoneEventUser) {
  109. CloseHandle (g_hPolicyDoneEventUser);
  110. g_hPolicyDoneEventUser = NULL;
  111. }
  112. if ( g_hPolicyForegroundDoneEventUser )
  113. {
  114. CloseHandle( g_hPolicyForegroundDoneEventUser );
  115. g_hPolicyForegroundDoneEventUser = 0;
  116. }
  117. if ( g_hPolicyForegroundDoneEventMach )
  118. {
  119. CloseHandle( g_hPolicyForegroundDoneEventMach );
  120. g_hPolicyForegroundDoneEventMach = 0;
  121. }
  122. CloseApiDLLsCritSec();
  123. ShutdownEvents ();
  124. ShutdownNotifySupport();
  125. CloseGPOCriticalSection();
  126. ClosePingCritSec();
  127. break;
  128. }
  129. return TRUE;
  130. }