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.

158 lines
3.9 KiB

  1. //
  2. // loader.cpp
  3. //
  4. #include "private.h"
  5. #include "loader.h"
  6. #include "regwatch.h"
  7. #include "msutbapi.h"
  8. extern HINSTANCE g_hInst;
  9. extern BOOL g_fWinLogon;
  10. extern BOOL g_bOnWow64;
  11. const TCHAR c_szLoaderWndClass[] = TEXT("CicLoaderWndClass");
  12. extern void UninitApp(void);
  13. BOOL CLoaderWnd::_bWndClassRegistered = FALSE;
  14. BOOL CLoaderWnd::_bUninitedSystem = FALSE;
  15. //+---------------------------------------------------------------------------
  16. //
  17. // ctor
  18. //
  19. //----------------------------------------------------------------------------
  20. CLoaderWnd::CLoaderWnd()
  21. {
  22. _hWnd = NULL;
  23. }
  24. //+---------------------------------------------------------------------------
  25. //
  26. // dtor
  27. //
  28. //----------------------------------------------------------------------------
  29. CLoaderWnd::~CLoaderWnd()
  30. {
  31. }
  32. //+---------------------------------------------------------------------------
  33. //
  34. // Init
  35. //
  36. //----------------------------------------------------------------------------
  37. BOOL CLoaderWnd::Init()
  38. {
  39. if (!_bWndClassRegistered)
  40. {
  41. WNDCLASSEX wc;
  42. memset(&wc, 0, sizeof(wc));
  43. wc.cbSize = sizeof(wc);
  44. wc.style = CS_HREDRAW | CS_VREDRAW ;
  45. wc.hInstance = g_hInst;
  46. wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  47. wc.lpfnWndProc = _WndProc;
  48. wc.lpszClassName = c_szLoaderWndClass;
  49. if (RegisterClassEx(&wc))
  50. _bWndClassRegistered = TRUE;
  51. }
  52. return _bWndClassRegistered ? TRUE : FALSE;
  53. }
  54. //+---------------------------------------------------------------------------
  55. //
  56. // CreateWnd
  57. //
  58. //----------------------------------------------------------------------------
  59. HWND CLoaderWnd::CreateWnd()
  60. {
  61. _hWnd = CreateWindowEx(0, c_szLoaderWndClass, TEXT(""),
  62. WS_DISABLED,
  63. 0, 0, 0, 0,
  64. NULL, 0, g_hInst, 0);
  65. return _hWnd;
  66. }
  67. //+---------------------------------------------------------------------------
  68. //
  69. // _WndProc
  70. //
  71. //----------------------------------------------------------------------------
  72. LRESULT CALLBACK CLoaderWnd::_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  73. {
  74. switch (uMsg)
  75. {
  76. case WM_CREATE:
  77. break;
  78. case WM_DESTROY :
  79. PostQuitMessage(0);
  80. break;
  81. case WM_SYSCOLORCHANGE:
  82. case WM_DISPLAYCHANGE:
  83. if (! g_bOnWow64)
  84. {
  85. CRegWatcher::StartSysColorChangeTimer();
  86. }
  87. break;
  88. case WM_QUERYENDSESSION:
  89. if (g_fWinLogon && (lParam & ENDSESSION_LOGOFF))
  90. return 1;
  91. if (!IsOnNT())
  92. {
  93. //
  94. // uninit system.
  95. //
  96. ClosePopupTipbar();
  97. TF_UninitSystem();
  98. _bUninitedSystem = TRUE;
  99. }
  100. return 1;
  101. case WM_ENDSESSION:
  102. if (!wParam)
  103. {
  104. //
  105. // need to restore Cicero and Toolbar.
  106. //
  107. if (_bUninitedSystem)
  108. {
  109. TF_InitSystem();
  110. if (! g_bOnWow64)
  111. {
  112. GetPopupTipbar(hWnd, g_fWinLogon ? UTB_GTI_WINLOGON : 0);
  113. }
  114. _bUninitedSystem = FALSE;
  115. }
  116. }
  117. else // Do cleanup always no matter if this is from Winlogon session or not.
  118. {
  119. if (!_bUninitedSystem)
  120. {
  121. UninitApp();
  122. TF_UninitSystem();
  123. _bUninitedSystem = TRUE;
  124. }
  125. }
  126. break;
  127. default:
  128. return DefWindowProc(hWnd, uMsg, wParam, lParam);
  129. }
  130. return 0;
  131. }