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.

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