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.

173 lines
4.5 KiB

  1. /*++
  2. Copyright (C) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. main.cpp
  5. Abstract:
  6. DllRegServer implementation, and other important DLL entry points
  7. History:
  8. --*/
  9. #include "precomp.h"
  10. #include <wbemint.h>
  11. #include <cominit.h>
  12. #include "upgrade.h"
  13. #include <str.h>
  14. char g_szLangId[LANG_ID_STR_SIZE];
  15. //***************************************************************************
  16. //
  17. // DllRegisterServer
  18. //
  19. // Purpose: Called during NT setup to perform various setup tasks
  20. // (This is not the normal use of DllRegisterServer!)
  21. //
  22. // Return: NOERROR
  23. //***************************************************************************
  24. STDAPI DllRegisterServer(void)
  25. {
  26. LogMessage(MSG_INFO, "================================================================================");
  27. LogMessage(MSG_INFO, "Beginning Wbemupgd.dll Registration");
  28. bool t_Upgrade = false ;
  29. HRESULT t_Result = CheckForServiceSecurity () ;
  30. if ( t_Result == S_FALSE )
  31. {
  32. t_Upgrade = true ;
  33. }
  34. RecordFileVersion();
  35. InitializeCom();
  36. CallEscapeRouteBeforeMofCompilation();
  37. DoCoreUpgrade(Core);
  38. CallEscapeRouteAfterMofCompilation();
  39. if ( t_Upgrade )
  40. {
  41. HRESULT t_Result = UpdateServiceSecurity () ;
  42. if ( SUCCEEDED ( t_Result ) )
  43. {
  44. LogMessage(MSG_INFO, "Wbemupgd.dll Service Security upgrade succeeded.");
  45. }
  46. else
  47. {
  48. LogMessage(MSG_ERROR, "Wbemupgd.dll Service Security upgrade failed.");
  49. }
  50. }
  51. else
  52. {
  53. LogMessage(MSG_INFO, "Wbemupgd.dll Service Security upgrade not required.");
  54. }
  55. DoWDMNamespaceInit();
  56. SetWBEMBuildRegValue();
  57. EnableESS();
  58. #ifdef _X86_
  59. RemoveOldODBC();
  60. #endif
  61. CoUninitialize();
  62. ClearWMISetupRegValue();
  63. LogMessage(MSG_INFO, "Wbemupgd.dll Registration completed.");
  64. LogMessage(MSG_INFO, "================================================================================");
  65. return NOERROR;
  66. }
  67. //***************************************************************************
  68. //
  69. // MUI_InstallMFLFiles
  70. //
  71. // Purpose: Do the MUI MFL install
  72. //
  73. // Return: bRet -- true indicates success
  74. //***************************************************************************
  75. BOOL CALLBACK MUI_InstallMFLFiles(wchar_t* pMUIInstallLanguage)
  76. {
  77. LogMessage(MSG_INFO, "================================================================================");
  78. if (!pMUIInstallLanguage || !wcslen(pMUIInstallLanguage) || (wcslen(pMUIInstallLanguage) > MAX_MSG_TEXT_LENGTH))
  79. {
  80. LogMessage(MSG_ERROR, "MUI installation failed because no language code was passed.");
  81. LogMessage(MSG_INFO, "================================================================================");
  82. return FALSE;
  83. }
  84. char szTemp[MAX_MSG_TEXT_LENGTH];
  85. StringCchPrintfA(szTemp, MAX_MSG_TEXT_LENGTH, "Beginning MUI installation for language %S.", pMUIInstallLanguage);
  86. LogMessage(MSG_INFO, szTemp);
  87. wcstombs(g_szLangId, pMUIInstallLanguage, LANG_ID_STR_SIZE);
  88. InitializeCom();
  89. CMultiString mszSystemMofs;
  90. GetStandardMofs(mszSystemMofs, MUI);
  91. bool bRet = DoMofLoad(L"MUI", mszSystemMofs);
  92. CoUninitialize();
  93. LogMessage(MSG_INFO, "MUI installation completed.");
  94. LogMessage(MSG_INFO, "================================================================================");
  95. return bRet;
  96. }
  97. //***************************************************************************
  98. //
  99. // LoadMofFiles
  100. //
  101. // Purpose: Call IMofCompiler on a list of MOF files
  102. //
  103. // Return: bRet -- true indicates success
  104. //***************************************************************************
  105. BOOL LoadMofFiles(wchar_t* pComponentName, const char* rgpszMofFilename[])
  106. {
  107. if (!pComponentName || !wcslen(pComponentName))
  108. {
  109. LogMessage(MSG_ERROR, "Component MOF load failed because no component name was passed.");
  110. return FALSE;
  111. }
  112. char szTemp[MAX_MSG_TEXT_LENGTH];
  113. StringCchPrintfA(szTemp, MAX_MSG_TEXT_LENGTH, "Beginning %S MOF Installation", pComponentName);
  114. LogMessage(MSG_INFO, szTemp);
  115. if (!rgpszMofFilename)
  116. {
  117. LogMessage(MSG_ERROR, "Component MOF load failed because no file list was passed.");
  118. return FALSE;
  119. }
  120. InitializeCom();
  121. CMultiString mszMofs;
  122. GetMofList(rgpszMofFilename, mszMofs);
  123. bool bRet = DoMofLoad(pComponentName, mszMofs);
  124. CoUninitialize();
  125. StringCchPrintfA(szTemp, MAX_MSG_TEXT_LENGTH, "%S MOF Installation Completed", pComponentName);
  126. LogMessage(MSG_INFO, szTemp);
  127. return bRet;
  128. }