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.

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