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.

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