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.

242 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. creatwr2.c
  5. Abstract:
  6. This source file implements the operations needed to properly migrate Creative Writer 2.0 from
  7. Windows 9x to Windows NT. This is part of the Setup Migration DLL.
  8. Author:
  9. Calin Negreanu (calinn) 07-Nov-1998
  10. Revision History:
  11. --*/
  12. #include "pch.h"
  13. #define S_MIGRATION_PATHS "Migration Paths"
  14. #define S_MS_WORDART_30 "HKCR\\CLSID\\{000212F0-0000-0000-C000-000000000046}\\AlternateLocalServer32"
  15. #define S_WRDART_FILE1 "KIDART32.EXE"
  16. #define S_WRDART_FILE2 "WRDART32.EXE"
  17. #define S_WRDART_FILE3 "WORDART.EXE"
  18. #define MEMDB_CATEGORY_FILE1 "CreativeWriter2\\File1"
  19. #define MEMDB_CATEGORY_FILE2 "CreativeWriter2\\File2"
  20. static GROWBUFFER g_FilesBuff = GROWBUF_INIT;
  21. BOOL
  22. CreativeWriter2_Attach (
  23. IN HINSTANCE DllInstance
  24. )
  25. {
  26. return TRUE;
  27. }
  28. BOOL
  29. CreativeWriter2_Detach (
  30. IN HINSTANCE DllInstance
  31. )
  32. {
  33. FreeGrowBuffer (&g_FilesBuff);
  34. return TRUE;
  35. }
  36. LONG
  37. CreativeWriter2_QueryVersion (
  38. IN PCSTR *ExeNamesBuf
  39. )
  40. {
  41. HKEY key = NULL;
  42. PCTSTR fullFileName = NULL;
  43. PCTSTR fileName = NULL;
  44. DWORD result = ERROR_SUCCESS;
  45. __try {
  46. key = OpenRegKeyStrA (S_MS_WORDART_30);
  47. if (!key) {
  48. DEBUGMSGA ((DBG_VERBOSE, "Creative Writer 2 migration DLL will not run."));
  49. result = ERROR_NOT_INSTALLED;
  50. __leave;
  51. }
  52. fullFileName = GetRegValueStringA (key, "");
  53. if (!fullFileName) {
  54. DEBUGMSGA ((DBG_VERBOSE, "Creative Writer 2 migration DLL will not run."));
  55. result = ERROR_NOT_INSTALLED;
  56. __leave;
  57. }
  58. fileName = GetFileNameFromPathA (fullFileName);
  59. if (!StringIMatchA (fileName, S_WRDART_FILE1)) {
  60. DEBUGMSGA ((DBG_VERBOSE, "Creative Writer 2 migration DLL will not run."));
  61. result = ERROR_NOT_INSTALLED;
  62. __leave;
  63. }
  64. MultiSzAppendA (&g_FilesBuff, S_WRDART_FILE1);
  65. MultiSzAppendA (&g_FilesBuff, S_WRDART_FILE2);
  66. *ExeNamesBuf = g_FilesBuff.Buf;
  67. }
  68. __finally {
  69. if (fullFileName) {
  70. MemFree (g_hHeap, 0, fullFileName);
  71. fullFileName = NULL;
  72. }
  73. if (key) {
  74. CloseRegKey (key);
  75. key = NULL;
  76. }
  77. }
  78. return result;
  79. }
  80. LONG
  81. CreativeWriter2_Initialize9x (
  82. IN PCSTR WorkingDirectory,
  83. IN PCSTR SourceDirectories
  84. )
  85. {
  86. INFSTRUCT context = INITINFSTRUCT_GROWBUFFER;
  87. PCSTR fullFileName;
  88. PCSTR fileName;
  89. LONG result = ERROR_SUCCESS;
  90. BOOL set1 = FALSE;
  91. BOOL set2 = FALSE;
  92. //
  93. // Let's find out where are our files located
  94. //
  95. if (g_MigrateInf != INVALID_HANDLE_VALUE) {
  96. if (InfFindFirstLineA (g_MigrateInf, S_MIGRATION_PATHS, NULL, &context)) {
  97. do {
  98. fullFileName = InfGetStringFieldA (&context, 1);
  99. if (fullFileName) {
  100. fileName = GetFileNameFromPathA (fullFileName);
  101. if (!set1 && StringIMatchA (fileName, S_WRDART_FILE1)) {
  102. set1 = TRUE;
  103. //
  104. // this copy is safe. S_WRDART_FILE1 is longer than S_WRDART_FILE3
  105. //
  106. MYASSERT (ByteCount (S_WRDART_FILE1) >= ByteCount (S_WRDART_FILE3));
  107. StringCopy ((PSTR)fileName, S_WRDART_FILE3);
  108. MemDbSetValueExA (MEMDB_CATEGORY_FILE1, fullFileName, NULL, NULL, 0, NULL);
  109. }
  110. if (!set2 && StringIMatchA (fileName, S_WRDART_FILE2)) {
  111. set2 = TRUE;
  112. MemDbSetValueExA (MEMDB_CATEGORY_FILE2, fullFileName, NULL, NULL, 0, NULL);
  113. }
  114. }
  115. } while (InfFindNextLine (&context));
  116. InfCleanUpInfStruct (&context);
  117. }
  118. if (!set1 || !set2) {
  119. DEBUGMSGA ((DBG_WARNING, "Creative Writer 2 migration DLL: Could not find needed files."));
  120. result = ERROR_NOT_INSTALLED;
  121. }
  122. } else {
  123. DEBUGMSGA ((DBG_ERROR, "Could not open MIGRATE.INF."));
  124. result = ERROR_NOT_INSTALLED;
  125. }
  126. return result;
  127. }
  128. LONG
  129. CreativeWriter2_MigrateUser9x (
  130. IN HWND ParentWnd,
  131. IN PCSTR UnattendFile,
  132. IN HKEY UserRegKey,
  133. IN PCSTR UserName
  134. )
  135. {
  136. return ERROR_SUCCESS;
  137. }
  138. LONG
  139. CreativeWriter2_MigrateSystem9x (
  140. IN HWND ParentWnd,
  141. IN PCSTR UnattendFile
  142. )
  143. {
  144. return ERROR_SUCCESS;
  145. }
  146. LONG
  147. CreativeWriter2_InitializeNT (
  148. IN PCWSTR WorkingDirectory,
  149. IN PCWSTR SourceDirectories
  150. )
  151. {
  152. PCSTR file1 = NULL;
  153. PCSTR file2 = NULL;
  154. CHAR pattern[MEMDB_MAX];
  155. MEMDB_ENUMA e;
  156. LONG result = ERROR_SUCCESS;
  157. MemDbBuildKeyA (pattern, MEMDB_CATEGORY_FILE1, "*", NULL, NULL);
  158. if (MemDbEnumFirstValueA (&e, pattern, MEMDB_ALL_SUBLEVELS, MEMDB_ENDPOINTS_ONLY)) {
  159. do {
  160. if (!file1) {
  161. file1 = DuplicatePathStringA (e.szName, 0);
  162. }
  163. } while (MemDbEnumNextValueA (&e));
  164. }
  165. MemDbBuildKeyA (pattern, MEMDB_CATEGORY_FILE2, "*", NULL, NULL);
  166. if (MemDbEnumFirstValueA (&e, pattern, MEMDB_ALL_SUBLEVELS, MEMDB_ENDPOINTS_ONLY)) {
  167. do {
  168. if (!file2) {
  169. file2 = DuplicatePathStringA (e.szName, 0);
  170. }
  171. } while (MemDbEnumNextValueA (&e));
  172. }
  173. if (!file1 ||
  174. !file2 ||
  175. !DoesFileExist (file1) ||
  176. !DoesFileExist (file2)
  177. ) {
  178. DEBUGMSGA ((DBG_WARNING, "Creative Writer 2 migration DLL: Could not find needed files."));
  179. result = ERROR_NOT_INSTALLED;
  180. } else {
  181. CopyFileA (file2, file1, FALSE);
  182. }
  183. if (file1) {
  184. FreePathStringA (file1);
  185. }
  186. if (file2) {
  187. FreePathStringA (file2);
  188. }
  189. return result;
  190. }
  191. LONG
  192. CreativeWriter2_MigrateUserNT (
  193. IN HINF UnattendFile,
  194. IN HKEY UserRegKey,
  195. IN PCWSTR UserName
  196. )
  197. {
  198. return ERROR_SUCCESS;
  199. }
  200. LONG
  201. CreativeWriter2_MigrateSystemNT (
  202. IN HINF UnattendFile
  203. )
  204. {
  205. return ERROR_SUCCESS;
  206. }