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
4.7 KiB

  1. /*++
  2. Copyright (c) 1990 - 2002 Microsoft Corporation
  3. Module Name:
  4. upgrade.c
  5. Abstract:
  6. This file upgrades the forms on OS upgrade. It used to upgrade the drivers
  7. for NT 3 to NT 4, but that is not necessary now.
  8. Author:
  9. Krishna Ganugapati (KrishnaG) 21-Apr-1994
  10. Revision History:
  11. Matthew A Felton ( MattFe ) Aug 9 1995
  12. Remove the code which was married to TextMode setup to move drivers for one directory to another
  13. Now all environment upgrade from 3.1 is handled the same.
  14. Mark Lawrence (MLawrenc) Mar 25 2002
  15. Removed driver upgrade code for moving driver files around.
  16. --*/
  17. #include <precomp.h>
  18. #pragma hdrstop
  19. #include "clusspl.h"
  20. extern WCHAR *szSpoolDirectory;
  21. extern WCHAR *szDirectory;
  22. extern PWCHAR ipszRegistryWin32Root;
  23. extern DWORD dwUpgradeFlag;
  24. extern BUILTIN_FORM BuiltInForms[];
  25. VOID
  26. QueryUpgradeFlag(
  27. PINISPOOLER pIniSpooler
  28. )
  29. /*++
  30. Description: the query update flag is set up by TedM. We will read this flag
  31. if the flag has been set, we will set a boolean variable saying that we're in
  32. the upgrade mode. All upgrade activities will be carried out based on this flag.
  33. For subsequents startups of the spooler, this flag will be unvailable so we
  34. won't run the spooler in upgrade mode.
  35. This code has been moved into router spoolss\dll\init.c
  36. --*/
  37. {
  38. dwUpgradeFlag = SplIsUpgrade ();
  39. DBGMSG(DBG_TRACE, ("The Spooler Upgrade flag is %d\n", dwUpgradeFlag));
  40. return;
  41. }
  42. VOID UpgradeForms(
  43. PINISPOOLER pIniSpooler
  44. )
  45. {
  46. PBUILTIN_FORM pBuiltInForm;
  47. HKEY hFormsKey;
  48. WCHAR BuiltInFormName[MAX_PATH];
  49. WCHAR CustomFormName[FORM_NAME_LEN+1];
  50. WCHAR CustomPad[CUSTOM_NAME_LEN+1];
  51. BYTE FormData[32];
  52. DWORD cbCustomFormName;
  53. DWORD cbFormData;
  54. int cForm;
  55. if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
  56. pIniSpooler->pszRegistryForms,
  57. 0,
  58. KEY_READ | DELETE,
  59. &hFormsKey) != ERROR_SUCCESS)
  60. {
  61. DBGMSG( DBG_WARN, ("UpgradeForms Could not open %ws key\n", ipszRegistryForms));
  62. return;
  63. }
  64. if(!LoadStringW(hInst,
  65. IDS_FORM_CUSTOMPAD,
  66. CustomPad,
  67. CUSTOM_NAME_LEN+1))
  68. {
  69. DBGMSG( DBG_WARN, ("UpgradeForms Could not find Custom string in resources"));
  70. goto CleanUp;
  71. }
  72. for(cForm=0;
  73. memset(CustomFormName, 0, sizeof(CustomFormName)),
  74. cbCustomFormName = COUNTOF(CustomFormName),
  75. RegEnumValueW(hFormsKey,
  76. cForm,
  77. CustomFormName,
  78. &cbCustomFormName,
  79. NULL,
  80. NULL,
  81. NULL,
  82. NULL) == ERROR_SUCCESS;
  83. cForm++)
  84. {
  85. for(pBuiltInForm = BuiltInForms; pBuiltInForm->NameId; pBuiltInForm++)
  86. {
  87. if(!LoadStringW(hInst,
  88. pBuiltInForm->NameId,
  89. BuiltInFormName,
  90. FORM_NAME_LEN+1))
  91. {
  92. DBGMSG( DBG_WARN, ("UpgradeForms Could not find Built in Form with Resource ID = %d in resource",pBuiltInForm->NameId));
  93. goto CleanUp;
  94. }
  95. if(!_wcsicmp(BuiltInFormName,CustomFormName))
  96. {
  97. SPLASSERT(wcslen(CustomFormName)<=FORM_NAME_LEN);
  98. cbFormData=FORM_DATA_LEN;
  99. if(RegQueryValueExW(hFormsKey, CustomFormName,
  100. NULL,NULL, (LPBYTE)FormData,
  101. &cbFormData)!=ERROR_SUCCESS)
  102. {
  103. DBGMSG( DBG_WARN, ("UpgradeForms Could not find value %ws",CustomFormName));
  104. goto CleanUp;
  105. }
  106. if(RegDeleteValueW(hFormsKey,CustomFormName)!=ERROR_SUCCESS)
  107. {
  108. DBGMSG( DBG_WARN, ("UpgradeForms Could not delete value %ws",CustomFormName));
  109. goto CleanUp;
  110. }
  111. StringCchCat(CustomFormName, CUSTOM_NAME_LEN, CustomPad);
  112. if(RegSetValueExW(hFormsKey,CustomFormName, 0, REG_BINARY,
  113. (LPBYTE)FormData,
  114. cbFormData)!=ERROR_SUCCESS)
  115. {
  116. DBGMSG( DBG_WARN, ("UpgradeForms Could not set value %s",CustomFormName));
  117. goto CleanUp;
  118. }
  119. cForm = -1;
  120. break;
  121. }
  122. }
  123. }
  124. CleanUp:
  125. RegCloseKey(hFormsKey);
  126. return;
  127. }