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.

379 lines
10 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. Works99.cpp
  5. Abstract:
  6. This shim is to add in the missing/corrupted registry values
  7. for Works Suite 99 / Works Deluxe 99
  8. Notes:
  9. This is a app specific shim.
  10. History:
  11. 03/12/2001 rankala Created
  12. 03/12/2001 a-leelat Modified for shim.
  13. --*/
  14. #include "precomp.h"
  15. IMPLEMENT_SHIM_BEGIN(Works99)
  16. #include "ShimHookMacro.h"
  17. APIHOOK_ENUM_BEGIN
  18. APIHOOK_ENUM_END
  19. static LONG SetThreadingModel2Both(IN WCHAR *szKeyPath);
  20. static LONG AddCAGKey(void);
  21. VOID Works99()
  22. {
  23. WCHAR szPath[MAX_PATH];
  24. // Fix broken ThreadingModel value for several CLSID
  25. wcscpy(szPath, L"CLSID\\{29D44CA0-DD3A-11d0-95DF-00C04FD57E8C}\\InProcServer32");
  26. SetThreadingModel2Both(szPath);
  27. wcscpy(szPath, L"CLSID\\{4BA2C080-68BB-11d0-95BD-00C04FD57E8C}\\InProcServer32");
  28. SetThreadingModel2Both(szPath);
  29. wcscpy(szPath, L"CLSID\\{4BA2C081-68BB-11d0-95BD-00C04FD57E8C}\\InProcServer32");
  30. SetThreadingModel2Both(szPath);
  31. wcscpy(szPath, L"CLSID\\{56EE2738-BDF7-11d1-8C28-00C04FB995C9}\\InProcServer32");
  32. SetThreadingModel2Both(szPath);
  33. wcscpy(szPath, L"CLSID\\{6CFFE322-6E97-11d1-8C1C-00C04FB995C9}\\InProcServer32");
  34. SetThreadingModel2Both(szPath);
  35. wcscpy(szPath, L"CLSID\\{711D9B80-02F2-11d1-B244-00AA00A74BFF}\\InProcServer32");
  36. SetThreadingModel2Both(szPath);
  37. wcscpy(szPath, L"CLSID\\{8EE20D86-6DEC-11d1-8C1C-00C04FB995C9}\\InProcServer32");
  38. SetThreadingModel2Both(szPath);
  39. wcscpy(szPath, L"CLSID\\{92AABF20-39C8-11d1-95F6-00C04FD57E8C}\\InProcServer32");
  40. SetThreadingModel2Both(szPath);
  41. wcscpy(szPath, L"CLSID\\{9B3B23C0-E236-11d0-A5C9-0080C7195D7E}\\InProcServer32");
  42. SetThreadingModel2Both(szPath);
  43. wcscpy(szPath, L"CLSID\\{9B3B23C1-E236-11d0-A5C9-0080C7195D7E}\\InProcServer32");
  44. SetThreadingModel2Both(szPath);
  45. wcscpy(szPath, L"CLSID\\{9B3B23C2-E236-11d0-A5C9-0080C7195D7E}\\LocalServer32");
  46. SetThreadingModel2Both(szPath);
  47. wcscpy(szPath, L"CLSID\\{9B3B23C3-E236-11d0-A5C9-0080C7195D7E}\\InProcServer32");
  48. SetThreadingModel2Both(szPath);
  49. wcscpy(szPath, L"CLSID\\{CB40F470-02F1-11D1-B244-00AA00A74BFF}\\InProcServer32");
  50. SetThreadingModel2Both(szPath);
  51. wcscpy(szPath, L"CLSID\\{EAF6F280-DD53-11d0-95DF-00C04FD57E8C}\\InProcServer32");
  52. SetThreadingModel2Both(szPath);
  53. // Add CAG key and all of its values if missing
  54. AddCAGKey();
  55. }
  56. /*
  57. Function Description:
  58. Set ThreadingModel Registry REG_SZ value to "Both" for a given key
  59. */
  60. static
  61. LONG SetThreadingModel2Both(
  62. IN WCHAR *szKeyPath
  63. )
  64. {
  65. HKEY hKey;
  66. WCHAR szValue[32];
  67. WCHAR szData[32];
  68. LONG lStatus;
  69. // Fix broken ThreadingModel value for several CLSID
  70. wcscpy(szValue, L"ThreadingModel");
  71. wcscpy(szData, L"Both");
  72. lStatus = RegOpenKeyExW (HKEY_CLASSES_ROOT,
  73. szKeyPath,
  74. 0,
  75. KEY_ALL_ACCESS,
  76. &hKey);
  77. if ( lStatus == ERROR_SUCCESS ) {
  78. // Set it always since this is a one-time operation and
  79. //it must have "Both", no matter what is the current data
  80. lStatus = RegSetValueExW(hKey,
  81. szValue,
  82. 0,
  83. REG_SZ,
  84. (BYTE*)szData,
  85. (wcslen(szData) + 1) * sizeof(WCHAR));
  86. RegCloseKey(hKey);
  87. }
  88. return lStatus;
  89. }
  90. /*
  91. Function Description:
  92. Check existance of CAG key, add key + all values if it doesn't exist
  93. */
  94. static
  95. LONG AddCAGKey(
  96. void
  97. )
  98. {
  99. HKEY hKey, hKey1, hKey2;
  100. WCHAR szKeyPath[MAX_PATH];
  101. WCHAR szSubKeyPath[32];
  102. WCHAR szValue[32];
  103. WCHAR szData[MAX_PATH];
  104. DWORD dwData;
  105. LONG lStatus;
  106. DWORD dwCreated;
  107. // If this key doesn't exist, assume that something
  108. // is completely wrong and don't try to complete the Registry
  109. wcscpy(szKeyPath, L"SOFTWARE\\Microsoft\\ClipArt Gallery\\5.0\\ConcurrentDatabases");
  110. lStatus = RegOpenKeyExW (HKEY_LOCAL_MACHINE,
  111. szKeyPath,
  112. 0,
  113. KEY_ALL_ACCESS,
  114. &hKey);
  115. if (ERROR_SUCCESS != lStatus) {
  116. return lStatus;
  117. }
  118. // Check for next sub key, create if missing
  119. wcscpy(szSubKeyPath, L"Core");
  120. lStatus = RegCreateKeyExW (hKey,
  121. szSubKeyPath,
  122. 0,
  123. NULL,
  124. REG_OPTION_NON_VOLATILE,
  125. KEY_ALL_ACCESS,
  126. NULL,
  127. &hKey1,
  128. NULL);
  129. RegCloseKey(hKey);
  130. if (ERROR_SUCCESS != lStatus) {
  131. return lStatus;
  132. }
  133. // Check for next sub key, create if missing,
  134. // if so, we need create a set of values as well
  135. wcscpy(szSubKeyPath, L"CAG");
  136. lStatus = RegCreateKeyExW (hKey1,
  137. szSubKeyPath,
  138. 0,
  139. NULL,
  140. REG_OPTION_NON_VOLATILE,
  141. KEY_ALL_ACCESS,
  142. NULL,
  143. &hKey2,
  144. &dwCreated);
  145. RegCloseKey(hKey1);
  146. if (ERROR_SUCCESS != lStatus) {
  147. return lStatus;
  148. }
  149. if (REG_CREATED_NEW_KEY == dwCreated) {
  150. // Create the appropriate set of values
  151. wcscpy(szValue, L"Section1Path1");
  152. if (! SHGetSpecialFolderPathW(NULL, szData, CSIDL_PROGRAM_FILES, FALSE)) {
  153. RegCloseKey(hKey2);
  154. return ERROR_FILE_NOT_FOUND;
  155. }
  156. wcscat(szData, L"\\Common Files\\Microsoft Shared\\Clipart\\cagcat50");
  157. lStatus = RegSetValueExW(hKey2,
  158. szValue,
  159. 0,
  160. REG_SZ,
  161. (BYTE*)szData,
  162. (wcslen(szData) + 1) * sizeof(WCHAR));
  163. if (ERROR_SUCCESS != lStatus) {
  164. RegCloseKey(hKey2);
  165. return lStatus;
  166. }
  167. wcscpy(szValue, L"CatalogPath0");
  168. wcscat(szData, L"\\CagCat50.MMC");
  169. lStatus = RegSetValueExW(hKey2,
  170. szValue,
  171. 0,
  172. REG_SZ,
  173. (BYTE*)szData,
  174. (wcslen(szData) + 1) * sizeof(WCHAR));
  175. if (ERROR_SUCCESS != lStatus) {
  176. RegCloseKey(hKey2);
  177. return lStatus;
  178. }
  179. wcscpy(szValue, L"CatalogDriveType0");
  180. dwData = 3;
  181. lStatus = RegSetValueExW(hKey2,
  182. szValue,
  183. 0,
  184. REG_DWORD,
  185. (BYTE*)&dwData,
  186. sizeof(DWORD));
  187. if (ERROR_SUCCESS != lStatus) {
  188. RegCloseKey(hKey2);
  189. return lStatus;
  190. }
  191. wcscpy(szValue, L"CatalogSections");
  192. dwData = 1;
  193. lStatus = RegSetValueExW(hKey2,
  194. szValue,
  195. 0,
  196. REG_DWORD,
  197. (BYTE*)&dwData,
  198. sizeof(DWORD));
  199. if (ERROR_SUCCESS != lStatus) {
  200. RegCloseKey(hKey2);
  201. return lStatus;
  202. }
  203. wcscpy(szValue, L"Section1Name");
  204. wcscpy(szData, L"MAIN");
  205. lStatus = RegSetValueExW(hKey2,
  206. szValue,
  207. 0,
  208. REG_SZ,
  209. (BYTE*)szData,
  210. (wcslen(szData) + 1) * sizeof(WCHAR));
  211. if (ERROR_SUCCESS != lStatus) {
  212. RegCloseKey(hKey2);
  213. return lStatus;
  214. }
  215. wcscpy(szValue, L"Section1DriveType1");
  216. dwData = 3;
  217. lStatus = RegSetValueExW(hKey2,
  218. szValue,
  219. 0,
  220. REG_DWORD,
  221. (BYTE*)&dwData,
  222. sizeof(DWORD));
  223. if (ERROR_SUCCESS != lStatus) {
  224. RegCloseKey(hKey2);
  225. return lStatus;
  226. }
  227. wcscpy(szValue, L"Section1Paths");
  228. dwData = 1;
  229. lStatus = RegSetValueExW(hKey2,
  230. szValue,
  231. 0,
  232. REG_DWORD,
  233. (BYTE*)&dwData,
  234. sizeof(DWORD));
  235. if (ERROR_SUCCESS != lStatus) {
  236. RegCloseKey(hKey2);
  237. return lStatus;
  238. }
  239. wcscpy(szValue, L"CatalogLCID");
  240. dwData = 1033;
  241. lStatus = RegSetValueExW(hKey2,
  242. szValue,
  243. 0,
  244. REG_DWORD,
  245. (BYTE*)&dwData,
  246. sizeof(DWORD));
  247. if (ERROR_SUCCESS != lStatus) {
  248. RegCloseKey(hKey2);
  249. return lStatus;
  250. }
  251. wcscpy(szValue, L"CatalogVersionID");
  252. dwData = 1;
  253. lStatus = RegSetValueExW(hKey2,
  254. szValue,
  255. 0,
  256. REG_DWORD,
  257. (BYTE*)&dwData, sizeof(DWORD));
  258. if (ERROR_SUCCESS != lStatus) {
  259. RegCloseKey(hKey2);
  260. return lStatus;
  261. }
  262. }
  263. RegCloseKey(hKey2);
  264. return lStatus;
  265. }
  266. /*++
  267. Register hooked functions
  268. --*/
  269. BOOL
  270. NOTIFY_FUNCTION(
  271. DWORD fdwReason)
  272. {
  273. if (fdwReason == SHIM_STATIC_DLLS_INITIALIZED) {
  274. Works99();
  275. }
  276. return TRUE;
  277. }
  278. HOOK_BEGIN
  279. CALL_NOTIFY_FUNCTION
  280. HOOK_END
  281. IMPLEMENT_SHIM_END