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.

284 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. kkimgpro.c
  5. Abstract:
  6. This source file implements the operations needed to properly migrate Kodak Imaging Pro 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_KODAKIMG_FILE1 "KODAKIMG.EXE"
  15. #define S_KODAKIMG_FILE2 "KODAKPRV.EXE"
  16. #define MEMDB_CATEGORY_KKIMGPRO "KodakImagingPro"
  17. #define S_COMPANYNAME "CompanyName"
  18. #define S_PRODUCTVER "ProductVersion"
  19. #define S_KKIMG_COMPANYNAME1 "Eastman Software*"
  20. #define S_KKIMG_PRODUCTVER1 "2.*"
  21. #define S_KKIMG_COMPANYNAME2 "Eastman Software*"
  22. #define S_KKIMG_PRODUCTVER2 "2.*"
  23. static GROWBUFFER g_FilesBuff = GROWBUF_INIT;
  24. PSTR
  25. QueryVersionEntry (
  26. IN PCSTR FileName,
  27. IN PCSTR VersionEntry
  28. )
  29. /*++
  30. Routine Description:
  31. QueryVersionEntry queries the file's version structure returning the
  32. value for a specific entry
  33. Arguments:
  34. FileName - File to query for version struct.
  35. VersionEntry - Name to query in version structure.
  36. Return value:
  37. Value of specified entry or NULL if unsuccessful
  38. --*/
  39. {
  40. VERSION_STRUCT Version;
  41. PCSTR CurrentStr;
  42. PSTR result = NULL;
  43. MYASSERT (VersionEntry);
  44. if (CreateVersionStruct (&Version, FileName)) {
  45. __try {
  46. CurrentStr = EnumFirstVersionValue (&Version, VersionEntry);
  47. if (CurrentStr) {
  48. CurrentStr = SkipSpace (CurrentStr);
  49. result = DuplicatePathString (CurrentStr, 0);
  50. }
  51. else {
  52. __leave;
  53. }
  54. }
  55. __finally {
  56. DestroyVersionStruct (&Version);
  57. }
  58. }
  59. return result;
  60. }
  61. BOOL
  62. KodakImagingPro_Attach (
  63. IN HINSTANCE DllInstance
  64. )
  65. {
  66. return TRUE;
  67. }
  68. BOOL
  69. KodakImagingPro_Detach (
  70. IN HINSTANCE DllInstance
  71. )
  72. {
  73. FreeGrowBuffer (&g_FilesBuff);
  74. return TRUE;
  75. }
  76. LONG
  77. KodakImagingPro_QueryVersion (
  78. IN PCSTR *ExeNamesBuf
  79. )
  80. {
  81. HKEY key = NULL;
  82. PCTSTR fullFileName = NULL;
  83. PCTSTR fileName = NULL;
  84. DWORD result = ERROR_SUCCESS;
  85. MultiSzAppendA (&g_FilesBuff, S_KODAKIMG_FILE1);
  86. MultiSzAppendA (&g_FilesBuff, S_KODAKIMG_FILE2);
  87. *ExeNamesBuf = g_FilesBuff.Buf;
  88. return result;
  89. }
  90. LONG
  91. KodakImagingPro_Initialize9x (
  92. IN PCSTR WorkingDirectory,
  93. IN PCSTR SourceDirectories
  94. )
  95. {
  96. INFSTRUCT context = INITINFSTRUCT_GROWBUFFER;
  97. PCSTR fullFileName = NULL;
  98. PCSTR fileName = NULL;
  99. PCSTR companyName = NULL;
  100. PCSTR productVer = NULL;
  101. LONG result = ERROR_NOT_INSTALLED;
  102. //
  103. // Let's find out where are our files located
  104. //
  105. if (g_MigrateInf != INVALID_HANDLE_VALUE) {
  106. if (InfFindFirstLineA (g_MigrateInf, S_MIGRATION_PATHS, NULL, &context)) {
  107. do {
  108. fullFileName = InfGetStringFieldA (&context, 1);
  109. if (fullFileName) {
  110. __try {
  111. fileName = GetFileNameFromPathA (fullFileName);
  112. if (StringIMatchA (fileName, S_KODAKIMG_FILE1)) {
  113. companyName = QueryVersionEntry (fullFileName, S_COMPANYNAME);
  114. if ((!companyName) ||
  115. (!IsPatternMatchA (S_KKIMG_COMPANYNAME1, companyName))
  116. ) {
  117. continue;
  118. }
  119. productVer = QueryVersionEntry (fullFileName, S_PRODUCTVER);
  120. if ((!productVer) ||
  121. (!IsPatternMatchA (S_KKIMG_PRODUCTVER1, productVer))
  122. ) {
  123. continue;
  124. }
  125. result = ERROR_SUCCESS;
  126. MemDbSetValueExA (MEMDB_CATEGORY_KKIMGPRO, fullFileName, NULL, NULL, 0, NULL);
  127. FreePathStringA (productVer);
  128. productVer = NULL;
  129. FreePathStringA (companyName);
  130. companyName = NULL;
  131. }
  132. if (StringIMatchA (fileName, S_KODAKIMG_FILE2)) {
  133. companyName = QueryVersionEntry (fullFileName, S_COMPANYNAME);
  134. if ((!companyName) ||
  135. (!IsPatternMatchA (S_KKIMG_COMPANYNAME2, companyName))
  136. ) {
  137. continue;
  138. }
  139. productVer = QueryVersionEntry (fullFileName, S_PRODUCTVER);
  140. if ((!productVer) ||
  141. (!IsPatternMatchA (S_KKIMG_PRODUCTVER2, productVer))
  142. ) {
  143. continue;
  144. }
  145. result = ERROR_SUCCESS;
  146. MemDbSetValueExA (MEMDB_CATEGORY_KKIMGPRO, fullFileName, NULL, NULL, 0, NULL);
  147. FreePathStringA (productVer);
  148. productVer = NULL;
  149. FreePathStringA (companyName);
  150. companyName = NULL;
  151. }
  152. }
  153. __finally {
  154. if (productVer) {
  155. FreePathStringA (productVer);
  156. productVer = NULL;
  157. }
  158. if (companyName) {
  159. FreePathStringA (companyName);
  160. companyName = NULL;
  161. }
  162. }
  163. }
  164. } while (InfFindNextLine (&context));
  165. InfCleanUpInfStruct (&context);
  166. }
  167. if (result == ERROR_NOT_INSTALLED) {
  168. DEBUGMSGA ((DBG_VERBOSE, "Kodak Imaging Pro migration DLL: Could not find needed files."));
  169. }
  170. } else {
  171. DEBUGMSGA ((DBG_ERROR, "Kodak Imaging Pro migration DLL: Could not open MIGRATE.INF."));
  172. }
  173. return result;
  174. }
  175. LONG
  176. KodakImagingPro_MigrateUser9x (
  177. IN HWND ParentWnd,
  178. IN PCSTR UnattendFile,
  179. IN HKEY UserRegKey,
  180. IN PCSTR UserName
  181. )
  182. {
  183. return ERROR_NOT_INSTALLED;
  184. }
  185. LONG
  186. KodakImagingPro_MigrateSystem9x (
  187. IN HWND ParentWnd,
  188. IN PCSTR UnattendFile
  189. )
  190. {
  191. MEMDB_ENUMA e;
  192. CHAR pattern[MEMDB_MAX];
  193. // Handle all files from MEMDB_CATEGORY_KKIMGPRO
  194. MemDbBuildKeyA (pattern, MEMDB_CATEGORY_KKIMGPRO, "*", NULL, NULL);
  195. if (MemDbEnumFirstValueA (&e, pattern, MEMDB_ALL_SUBLEVELS, MEMDB_ENDPOINTS_ONLY)) {
  196. do {
  197. // write this file to Handled
  198. if (!WritePrivateProfileStringA (S_HANDLED, e.szName, "FILE", g_MigrateInfPath)) {
  199. DEBUGMSGA ((DBG_ERROR, "Kodak Imaging Pro migration DLL: Could not write one or more handled files."));
  200. }
  201. } while (MemDbEnumNextValueA (&e));
  202. }
  203. return ERROR_NOT_INSTALLED;
  204. }
  205. LONG
  206. KodakImagingPro_InitializeNT (
  207. IN PCWSTR WorkingDirectory,
  208. IN PCWSTR SourceDirectories
  209. )
  210. {
  211. MYASSERT (FALSE);
  212. return ERROR_SUCCESS;
  213. }
  214. LONG
  215. KodakImagingPro_MigrateUserNT (
  216. IN HINF UnattendFile,
  217. IN HKEY UserRegKey,
  218. IN PCWSTR UserName
  219. )
  220. {
  221. MYASSERT (FALSE);
  222. return ERROR_SUCCESS;
  223. }
  224. LONG
  225. KodakImagingPro_MigrateSystemNT (
  226. IN HINF UnattendFile
  227. )
  228. {
  229. MYASSERT (FALSE);
  230. return ERROR_SUCCESS;
  231. }