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.

231 lines
6.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. plus95.c
  5. Abstract:
  6. This source file implements the operations needed to properly migrate Plus!95 from
  7. Windows 9x to Windows NT. This is part of the Setup Migration DLL.
  8. Author:
  9. Calin Negreanu (calinn) 15-Mar-1999
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #include "setupmigp.h"
  14. #define S_MIGRATION_PATHS "Migration Paths"
  15. #define S_PLUS95_FILE "JPEGIM32.FLT"
  16. #define MEMDB_CATEGORY_PLUS95A "Plus95"
  17. #define MEMDB_CATEGORY_PLUS95W L"Plus95"
  18. #define S_COMPANYNAME "CompanyName"
  19. #define S_PRODUCTVER "ProductVersion"
  20. #define S_PLUS95_COMPANYNAME1 "Microsoft*"
  21. #define S_PLUS95_PRODUCTVER1 "6.*"
  22. #define S_PLUS95_FILEW L"JPEGIM32.FLT"
  23. static GROWBUFFER g_FilesBuff = GROWBUF_INIT;
  24. BOOL
  25. Plus95_Attach (
  26. IN HINSTANCE DllInstance
  27. )
  28. {
  29. return TRUE;
  30. }
  31. BOOL
  32. Plus95_Detach (
  33. IN HINSTANCE DllInstance
  34. )
  35. {
  36. FreeGrowBuffer (&g_FilesBuff);
  37. return TRUE;
  38. }
  39. LONG
  40. Plus95_QueryVersion (
  41. IN PCSTR *ExeNamesBuf
  42. )
  43. {
  44. HKEY key = NULL;
  45. PCTSTR fullFileName = NULL;
  46. PCTSTR fileName = NULL;
  47. DWORD result = ERROR_SUCCESS;
  48. MultiSzAppendA (&g_FilesBuff, S_PLUS95_FILE);
  49. *ExeNamesBuf = g_FilesBuff.Buf;
  50. return result;
  51. }
  52. LONG
  53. Plus95_Initialize9x (
  54. IN PCSTR WorkingDirectory,
  55. IN PCSTR SourceDirectories
  56. )
  57. {
  58. INFSTRUCT context = INITINFSTRUCT_GROWBUFFER;
  59. PCSTR fullFileName = NULL;
  60. PCSTR fileName = NULL;
  61. PCSTR companyName = NULL;
  62. PCSTR productVer = NULL;
  63. LONG result = ERROR_NOT_INSTALLED;
  64. //
  65. // Let's find out where are our files located
  66. //
  67. if (g_MigrateInf != INVALID_HANDLE_VALUE) {
  68. if (InfFindFirstLineA (g_MigrateInf, S_MIGRATION_PATHS, NULL, &context)) {
  69. do {
  70. fullFileName = InfGetStringFieldA (&context, 1);
  71. if (fullFileName) {
  72. __try {
  73. fileName = GetFileNameFromPathA (fullFileName);
  74. if (StringIMatchA (fileName, S_PLUS95_FILE)) {
  75. companyName = QueryVersionEntry (fullFileName, S_COMPANYNAME);
  76. if ((!companyName) ||
  77. (!IsPatternMatchA (S_PLUS95_COMPANYNAME1, companyName))
  78. ) {
  79. #pragma prefast(suppress:242, "Don't care about perf of try/finally here")
  80. continue;
  81. }
  82. productVer = QueryVersionEntry (fullFileName, S_PRODUCTVER);
  83. if ((!productVer) ||
  84. (!IsPatternMatchA (S_PLUS95_PRODUCTVER1, productVer))
  85. ) {
  86. #pragma prefast(suppress:242, "Don't care about perf of try/finally here")
  87. continue;
  88. }
  89. result = ERROR_SUCCESS;
  90. MemDbSetValueExA (MEMDB_CATEGORY_PLUS95A, fullFileName, NULL, NULL, 0, NULL);
  91. FreePathStringA (productVer);
  92. productVer = NULL;
  93. FreePathStringA (companyName);
  94. companyName = NULL;
  95. }
  96. }
  97. __finally {
  98. if (productVer) {
  99. FreePathStringA (productVer);
  100. productVer = NULL;
  101. }
  102. if (companyName) {
  103. FreePathStringA (companyName);
  104. companyName = NULL;
  105. }
  106. }
  107. }
  108. } while (InfFindNextLine (&context));
  109. InfCleanUpInfStruct (&context);
  110. }
  111. if (result == ERROR_NOT_INSTALLED) {
  112. DEBUGMSGA ((DBG_VERBOSE, "Plus!95 migration DLL: Could not find needed files."));
  113. }
  114. } else {
  115. DEBUGMSGA ((DBG_ERROR, "Plus!95 migration DLL: Could not open MIGRATE.INF."));
  116. }
  117. return result;
  118. }
  119. LONG
  120. Plus95_MigrateUser9x (
  121. IN HWND ParentWnd,
  122. IN PCSTR UnattendFile,
  123. IN HKEY UserRegKey,
  124. IN PCSTR UserName
  125. )
  126. {
  127. return ERROR_NOT_INSTALLED;
  128. }
  129. LONG
  130. Plus95_MigrateSystem9x (
  131. IN HWND ParentWnd,
  132. IN PCSTR UnattendFile
  133. )
  134. {
  135. MEMDB_ENUMA e;
  136. CHAR pattern[MEMDB_MAX];
  137. // Handle all files from MEMDB_CATEGORY_PLUS95
  138. MemDbBuildKeyA (pattern, MEMDB_CATEGORY_PLUS95A, "*", NULL, NULL);
  139. if (MemDbEnumFirstValueA (&e, pattern, MEMDB_ALL_SUBLEVELS, MEMDB_ENDPOINTS_ONLY)) {
  140. do {
  141. // write this file to Handled
  142. if (!WritePrivateProfileStringA (S_HANDLED, e.szName, "FILE", g_MigrateInfPath)) {
  143. DEBUGMSGA ((DBG_ERROR, "Plus!95 migration DLL: Could not write one or more handled files."));
  144. }
  145. } while (MemDbEnumNextValueA (&e));
  146. }
  147. return ERROR_SUCCESS;
  148. }
  149. LONG
  150. Plus95_InitializeNT (
  151. IN PCWSTR WorkingDirectory,
  152. IN PCWSTR SourceDirectories
  153. )
  154. {
  155. PWSTR DllLocation;
  156. MEMDB_ENUMW e;
  157. WCHAR pattern[MEMDB_MAX];
  158. DllLocation = JoinPathsW (WorkingDirectory, S_PLUS95_FILEW);
  159. if (!DoesFileExistW (DllLocation)) {
  160. FreePathStringW (DllLocation);
  161. DEBUGMSG ((DBG_ERROR, "Plus!95 migration DLL: Could not find required file."));
  162. return ERROR_SUCCESS;
  163. }
  164. // replace all files from MEMDB_CATEGORY_PLUS95
  165. MemDbBuildKeyW (pattern, MEMDB_CATEGORY_PLUS95W, L"*", NULL, NULL);
  166. if (MemDbEnumFirstValueW (&e, pattern, MEMDB_ALL_SUBLEVELS, MEMDB_ENDPOINTS_ONLY)) {
  167. do {
  168. if (!CopyFileW (DllLocation, e.szName, FALSE)) {
  169. DEBUGMSGW ((DBG_ERROR, "Plus!95 migration DLL: Could not replace one or more handled files."));
  170. }
  171. } while (MemDbEnumNextValueW (&e));
  172. }
  173. return ERROR_SUCCESS;
  174. }
  175. LONG
  176. Plus95_MigrateUserNT (
  177. IN HINF UnattendFile,
  178. IN HKEY UserRegKey,
  179. IN PCWSTR UserName
  180. )
  181. {
  182. return ERROR_SUCCESS;
  183. }
  184. LONG
  185. Plus95_MigrateSystemNT (
  186. IN HINF UnattendFile
  187. )
  188. {
  189. return ERROR_SUCCESS;
  190. }