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.

4092 lines
152 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. regconv.c
  5. Abstract:
  6. Implements registry special conversion.
  7. Author:
  8. Calin Negreanu (calinn) 5-May-2000
  9. Revision History:
  10. <alias> <date> <comments>
  11. --*/
  12. //
  13. // Includes
  14. //
  15. #include "pch.h"
  16. #include "v1p.h"
  17. #include <wingdip.h>
  18. #include <shlobjp.h>
  19. #include <shlwapi.h>
  20. //
  21. // Strings
  22. //
  23. #define DBG_CONVERSION "SpecialConversion"
  24. //
  25. // Constants
  26. //
  27. #define COLOR_MENU 4
  28. #define COLOR_HIGHLIGHT 13
  29. #define COLOR_BTNFACE 15
  30. #define COLOR_BUTTONALTFACE 25
  31. #define COLOR_HOTLIGHT 26
  32. #define COLOR_GRADIENTACTIVECAPTION 27
  33. #define COLOR_GRADIENTINACTIVECAPTION 28
  34. #define COLOR_MENUHILIGHT 29
  35. #define COLOR_MENUBAR 30
  36. #define DISPLAY_BITMASK 0x00161E2F
  37. #define MOUSE_BITMASK 0x0001E000
  38. //
  39. // Macros
  40. //
  41. #define pGetDestDwordValue(Key,Value) pGetDwordValue(Key, Value, PLATFORM_DESTINATION)
  42. #define pGetSrcDwordValue(Key,Value) pGetDwordValue(Key, Value, PLATFORM_SOURCE)
  43. //
  44. // Types
  45. //
  46. typedef struct {
  47. SHORT lfHeight;
  48. SHORT lfWidth;
  49. SHORT lfEscapement;
  50. SHORT lfOrientation;
  51. SHORT lfWeight;
  52. BYTE lfItalic;
  53. BYTE lfUnderline;
  54. BYTE lfStrikeOut;
  55. BYTE lfCharSet;
  56. BYTE lfOutPrecision;
  57. BYTE lfClipPrecision;
  58. BYTE lfQuality;
  59. BYTE lfPitchAndFamily;
  60. char lfFaceName[LF_FACESIZE];
  61. } SHORT_LOGFONT, *PSHORT_LOGFONT;
  62. //
  63. // NT uses only UNICODE structures, and pads the members
  64. // to 32-bit boundaries.
  65. //
  66. #define COLOR_MAX_V1 25
  67. #define COLOR_MAX_V2 25
  68. #define COLOR_MAX_V3 25
  69. #define COLOR_MAX_V4 29
  70. #define COLOR_MAX_NT 29 // this is a modified version 2 format, similar to 4
  71. typedef struct {
  72. SHORT version; // 2 for NT UNICODE
  73. WORD wDummy; // for alignment
  74. NONCLIENTMETRICSW ncm;
  75. LOGFONTW lfIconTitle;
  76. COLORREF rgb[COLOR_MAX_NT];
  77. } SCHEMEDATA_NT, *PSCHEMEDATA_NT;
  78. //
  79. // Win95 uses NONCLIENTMETRICSA which has LOGFONTA members,
  80. // but it uses a 16-bit LOGFONT as well.
  81. //
  82. #pragma pack(push)
  83. #pragma pack(1)
  84. typedef struct {
  85. SHORT version; // 1 for Win95 ANSI
  86. NONCLIENTMETRICSA ncm;
  87. SHORT_LOGFONT lfIconTitle;
  88. COLORREF rgb[COLOR_MAX_V1];
  89. } SCHEMEDATA_V1, *PSCHEMEDATA_V1;
  90. typedef struct {
  91. SHORT version; // 1 for Win95 ANSI
  92. NONCLIENTMETRICSA ncm;
  93. SHORT_LOGFONT lfIconTitle;
  94. COLORREF rgb[COLOR_MAX_V4];
  95. } SCHEMEDATA_V1A, *PSCHEMEDATA_V1A;
  96. typedef struct {
  97. SHORT version; // 2 for WinNT UNICODE with reduced color table
  98. WORD Dummy;
  99. NONCLIENTMETRICSW ncm;
  100. LOGFONTW lfIconTitle;
  101. COLORREF rgb[COLOR_MAX_V2];
  102. } SCHEMEDATA_V2, *PSCHEMEDATA_V2;
  103. typedef struct {
  104. SHORT version; // 3 for Win98 ANSI, 4 for portable format
  105. WORD Dummy;
  106. NONCLIENTMETRICSA ncm;
  107. LOGFONTA lfIconTitle;
  108. COLORREF rgb[COLOR_MAX_V3];
  109. } SCHEMEDATA_V3, *PSCHEMEDATA_V3;
  110. typedef struct {
  111. SHORT version; // 4 for Win32 format (whatever that means)
  112. WORD Dummy;
  113. NONCLIENTMETRICSA ncm;
  114. LOGFONTA lfIconTitle;
  115. COLORREF rgb[COLOR_MAX_V4];
  116. } SCHEMEDATA_V4, *PSCHEMEDATA_V4;
  117. #pragma pack(pop)
  118. typedef struct
  119. {
  120. UINT cbSize;
  121. SHELLSTATE ss;
  122. } REGSHELLSTATE, *PREGSHELLSTATE;
  123. //
  124. // Globals
  125. //
  126. MIG_OPERATIONID g_ConvertToDwordOp;
  127. MIG_OPERATIONID g_ConvertToStringOp;
  128. DWORD g_IdentityCount = 0;
  129. HASHTABLE g_IdentityDestTable;
  130. //
  131. // Macro expansion list
  132. //
  133. #define CONVERSION_FUNCTIONS \
  134. DEFMAC(CONVERTTODWORD, NULL, EDIT.ConvertToDword, pConvertToDwordCallback ) \
  135. DEFMAC(CONVERTTOSTRING, NULL, EDIT.ConvertToString, pConvertToStringCallback ) \
  136. DEFMAC(CONVERTLOGFONT, NULL, EDIT.ConvertLogFont, pConvertLogFontCallback ) \
  137. DEFMAC(ANTIALIAS, NULL, EDIT.AntiAlias, pAntiAliasCallback ) \
  138. DEFMAC(FIXACTIVEDESKTOP, NULL, EDIT.FixActiveDesktop, pFixActiveDesktopCallback ) \
  139. DEFMAC(CONVERTRECENTDOCSMRU, NULL, EDIT.ConvertRecentDocsMRU, pConvertRecentDocsMRUCallback ) \
  140. DEFMAC(CONVERTAPPEARANCESCHEME, NULL, EDIT.ConvertAppearanceScheme, pConvertAppearanceSchemeCallback) \
  141. DEFMAC(CONVERTSCNSAVER, NULL, EDIT.ConvertScnSaver, pConvertScnSaver ) \
  142. DEFMAC(CONVERTOE4IAMACCTNAME, NULL, EDIT.ConvertOE4IAMAcctName, pConvertOE4IAMAcctName ) \
  143. DEFMAC(CONVERTOE5IAMACCTNAME, NULL, EDIT.ConvertOE5IAMAcctName, pConvertOE5IAMAcctName ) \
  144. DEFMAC(CONVERTIAMACCTNAME, NULL, EDIT.ConvertIAMAcctName, pConvertIAMAcctName ) \
  145. DEFMAC(CONVERTOMIACCOUNTNAME, NULL, EDIT.ConvertOMIAccountName, pConvertOMIAccountName ) \
  146. DEFMAC(CONVERTIDENTITYCOUNT, NULL, EDIT.ConvertIdentityCount, pConvertIdentityCount ) \
  147. DEFMAC(CONVERTIDENTITYINDEX, NULL, EDIT.ConvertIdentityIndex, pConvertIdentityIndex ) \
  148. DEFMAC(CONVERTIDENTITYUSERNAME, NULL, EDIT.ConvertIdentityUsername, pConvertIdentityUsername ) \
  149. DEFMAC(CONVERTIDENTITYGUID, NULL, EDIT.ConvertIdentityGuid, pConvertIdentityGuid ) \
  150. DEFMAC(CONVERTSETDWORDTRUE, NULL, EDIT.ConvertSetDwordTrue, pConvertSetDwordTrue ) \
  151. DEFMAC(CONVERTSETDWORDFALSE, NULL, EDIT.ConvertSetDwordFalse, pConvertSetDwordFalse ) \
  152. DEFMAC(CONVERTPSTBLOB, NULL, EDIT.ConvertPSTBlob, pConvertPSTBlob ) \
  153. DEFMAC(CONVERTOFFICELANGID, NULL, EDIT.ConvertOfficeLangId, pConvertOfficeLangId ) \
  154. DEFMAC(CONVERTOUTLOOKLANGID, NULL, EDIT.ConvertOutlookLangId, pConvertOutlookLangId ) \
  155. DEFMAC(CONVERTACCESSLANGID, NULL, EDIT.ConvertAccessLangId, pConvertAccessLangId ) \
  156. DEFMAC(CONVERTEXCELLANGID, NULL, EDIT.ConvertExcelLangId, pConvertExcelLangId ) \
  157. DEFMAC(CONVERTFRONTPAGELANGID, NULL, EDIT.ConvertFrontPageLangId, pConvertFrontPageLangId ) \
  158. DEFMAC(CONVERTPOWERPOINTLANGID, NULL, EDIT.ConvertPowerPointLangId, pConvertPowerPointLangId ) \
  159. DEFMAC(CONVERTPUBLISHERLANGID, NULL, EDIT.ConvertPublisherLangId, pConvertPublisherLangId ) \
  160. DEFMAC(CONVERTWORDLANGID, NULL, EDIT.ConvertWordLangId, pConvertWordLangId ) \
  161. DEFMAC(CONVERTOFFICE2000LANGID, NULL, EDIT.ConvertOffice2000LangId, pConvertOffice2000LangId ) \
  162. DEFMAC(MIGRATESOUNDSYSTRAY, NULL, EDIT.MigrateSoundSysTray, pMigrateSoundSysTray ) \
  163. DEFMAC(MIGRATEAPPEARANCEUPM, NULL, EDIT.MigrateAppearanceUPM, pMigrateAppearanceUPM ) \
  164. DEFMAC(MIGRATEMOUSEUPM, NULL, EDIT.MigrateMouseUPM, pMigrateMouseUPM ) \
  165. DEFMAC(MIGRATEOFFLINESYSTRAY, NULL, EDIT.MigrateOfflineSysTray, pMigrateOfflineSysTray ) \
  166. DEFMAC(MIGRATEDISPLAYSS, NULL, EDIT.MigrateDisplaySS, pMigrateDisplaySS ) \
  167. DEFMAC(MIGRATEDISPLAYCS, NULL, EDIT.MigrateDisplayCS, pMigrateDisplayCS ) \
  168. DEFMAC(MIGRATETASKBARSSPRESERVE,NULL, EDIT.MigrateTaskBarSSPreserve, pMigrateTaskBarSSPreserve ) \
  169. DEFMAC(MIGRATETASKBARSSFORCE, NULL, EDIT.MigrateTaskBarSSForce, pMigrateTaskBarSSForce ) \
  170. DEFMAC(CONVERTSHOWIEONDESKTOP, NULL, EDIT.ConvertShowIEOnDesktop, pConvertShowIEOnDesktop ) \
  171. DEFMAC(MIGRATEACTIVEDESKTOP, NULL, EDIT.MigrateActiveDesktop, pMigrateActiveDesktop ) \
  172. //
  173. // Private function prototypes
  174. //
  175. // None
  176. //
  177. // Macro expansion definition
  178. //
  179. //
  180. // Declare special conversion operation apply callback functions
  181. //
  182. #define DEFMAC(ifn,ec,opn,opc) OPMAPPLYCALLBACK opc;
  183. CONVERSION_FUNCTIONS
  184. #undef DEFMAC
  185. //
  186. // This is the structure used for handling action functions
  187. //
  188. typedef struct {
  189. PCTSTR InfFunctionName;
  190. PSGMENUMERATIONCALLBACK EnumerationCallback;
  191. PCTSTR OperationName;
  192. MIG_OPERATIONID OperationId;
  193. POPMAPPLYCALLBACK OperationCallback;
  194. } CONVERSION_STRUCT, *PCONVERSION_STRUCT;
  195. //
  196. // Declare a global array of conversion functions
  197. //
  198. #define DEFMAC(ifn,ec,opn,opc) {TEXT("\\")TEXT(#ifn),ec,TEXT(#opn),0,opc},
  199. static CONVERSION_STRUCT g_ConversionFunctions[] = {
  200. CONVERSION_FUNCTIONS
  201. {NULL, NULL, NULL, 0, NULL}
  202. };
  203. #undef DEFMAC
  204. //
  205. // Code
  206. //
  207. BOOL
  208. IsValidRegSz(
  209. IN PCMIG_CONTENT ObjectContent
  210. )
  211. {
  212. return ((!ObjectContent->ContentInFile) &&
  213. (ObjectContent->MemoryContent.ContentSize) &&
  214. (ObjectContent->MemoryContent.ContentBytes) &&
  215. (ObjectContent->Details.DetailsSize == sizeof (DWORD)) &&
  216. (ObjectContent->Details.DetailsData) &&
  217. ((*((PDWORD)ObjectContent->Details.DetailsData) == REG_SZ) ||
  218. (*((PDWORD)ObjectContent->Details.DetailsData) == REG_EXPAND_SZ)));
  219. }
  220. BOOL
  221. IsValidRegType (
  222. IN PCMIG_CONTENT CurrentContent,
  223. IN DWORD RegType
  224. )
  225. {
  226. return ((!CurrentContent->ContentInFile) &&
  227. (CurrentContent->Details.DetailsSize == sizeof (DWORD)) &&
  228. (CurrentContent->Details.DetailsData) &&
  229. (*((PDWORD)CurrentContent->Details.DetailsData) == RegType) &&
  230. (CurrentContent->MemoryContent.ContentSize) &&
  231. (CurrentContent->MemoryContent.ContentBytes));
  232. }
  233. DWORD
  234. pGetDwordValue (
  235. IN PTSTR Key,
  236. IN PTSTR Value,
  237. IN MIG_PLATFORMTYPEID Platform
  238. )
  239. {
  240. DWORD value = 0;
  241. MIG_OBJECTSTRINGHANDLE objectName;
  242. MIG_CONTENT objectContent;
  243. objectName = IsmCreateObjectHandle (Key, Value);
  244. if (IsmAcquireObject (g_RegType | Platform, objectName, &objectContent)) {
  245. if (IsValidRegType(&objectContent, REG_DWORD)) {
  246. value = *(DWORD *)objectContent.MemoryContent.ContentBytes;
  247. }
  248. IsmReleaseObject (&objectContent);
  249. }
  250. IsmDestroyObjectHandle (objectName);
  251. return value;
  252. }
  253. VOID
  254. pSetDwordValue (
  255. OUT PMIG_CONTENT NewContent,
  256. IN DWORD Value
  257. )
  258. {
  259. NewContent->Details.DetailsSize = sizeof(DWORD);
  260. NewContent->Details.DetailsData = IsmGetMemory (sizeof (DWORD));
  261. *((PDWORD)NewContent->Details.DetailsData) = REG_DWORD;
  262. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  263. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof(DWORD));
  264. *((PDWORD)NewContent->MemoryContent.ContentBytes) = Value;
  265. }
  266. UINT
  267. pDefaultEnumerationCallback (
  268. IN PCMIG_OBJECTENUMDATA Data,
  269. IN ULONG_PTR CallerArg
  270. )
  271. {
  272. PCONVERSION_STRUCT p = (PCONVERSION_STRUCT)CallerArg;
  273. if (Data->IsLeaf) {
  274. IsmSetOperationOnObject (Data->ObjectTypeId, Data->ObjectName, p->OperationId, NULL, NULL);
  275. }
  276. return CALLBACK_ENUM_CONTINUE;
  277. }
  278. PCONVERSION_STRUCT
  279. pGetConversionStruct (
  280. IN PCTSTR FunctionName
  281. )
  282. {
  283. PCONVERSION_STRUCT p = g_ConversionFunctions;
  284. INT i = 0;
  285. while (p->InfFunctionName != NULL) {
  286. if (StringIMatch (p->InfFunctionName, FunctionName)) {
  287. return p;
  288. }
  289. p++;
  290. i++;
  291. }
  292. return NULL;
  293. }
  294. VOID
  295. InitSpecialConversion (
  296. IN MIG_PLATFORMTYPEID Platform
  297. )
  298. {
  299. PCONVERSION_STRUCT p = g_ConversionFunctions;
  300. while (p->InfFunctionName) {
  301. p->OperationId = IsmRegisterOperation (p->OperationName, FALSE);
  302. if (Platform == PLATFORM_DESTINATION) {
  303. IsmRegisterOperationApplyCallback (p->OperationId, p->OperationCallback, TRUE);
  304. }
  305. p++;
  306. }
  307. g_IdentityDestTable = HtAllocWithData (sizeof (PTSTR));
  308. if (Platform == PLATFORM_DESTINATION) {
  309. // Read the starting Identity count
  310. g_IdentityCount = pGetDestDwordValue (TEXT("HKCU\\Identities"), TEXT("Identity Ordinal"));
  311. }
  312. }
  313. VOID
  314. TerminateSpecialConversion (
  315. VOID
  316. )
  317. {
  318. HtFree (g_IdentityDestTable);
  319. g_IdentityDestTable = NULL;
  320. OETerminate();
  321. }
  322. BOOL
  323. pProcessDataConversionSection (
  324. IN PINFSTRUCT InfStruct,
  325. IN HINF InfHandle,
  326. IN PCTSTR Section
  327. )
  328. {
  329. PCTSTR pattern;
  330. ENCODEDSTRHANDLE encodedPattern = NULL;
  331. PCTSTR functionName;
  332. PCONVERSION_STRUCT functionStruct = NULL;
  333. BOOL result = FALSE;
  334. __try {
  335. if (InfFindFirstLine (InfHandle, Section, NULL, InfStruct)) {
  336. do {
  337. if (IsmCheckCancel()) {
  338. __leave;
  339. }
  340. pattern = InfGetStringField (InfStruct, 0);
  341. if (!pattern) {
  342. continue;
  343. }
  344. encodedPattern = TurnRegStringIntoHandle (pattern, TRUE, NULL);
  345. functionName = InfGetStringField (InfStruct, 1);
  346. if (functionName) {
  347. functionStruct = pGetConversionStruct (functionName);
  348. if (functionStruct) {
  349. IsmHookEnumeration (
  350. MIG_REGISTRY_TYPE,
  351. encodedPattern,
  352. functionStruct->EnumerationCallback?
  353. functionStruct->EnumerationCallback:
  354. pDefaultEnumerationCallback,
  355. (ULONG_PTR)functionStruct,
  356. functionStruct->InfFunctionName
  357. );
  358. } else {
  359. LOG ((
  360. LOG_ERROR,
  361. (PCSTR) MSG_DATA_CONVERSION_BAD_FN,
  362. functionName,
  363. pattern
  364. ));
  365. }
  366. } else {
  367. LOG ((LOG_ERROR, (PCSTR) MSG_DATA_CONVERSION_NO_FN, pattern));
  368. }
  369. IsmDestroyObjectHandle (encodedPattern);
  370. encodedPattern = NULL;
  371. } while (InfFindNextLine (InfStruct));
  372. }
  373. result = TRUE;
  374. }
  375. __finally {
  376. InfCleanUpInfStruct (InfStruct);
  377. }
  378. return result;
  379. }
  380. BOOL
  381. DoRegistrySpecialConversion (
  382. IN HINF InfHandle,
  383. IN PCTSTR Section
  384. )
  385. {
  386. PCTSTR osSpecificSection;
  387. BOOL b;
  388. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  389. b = pProcessDataConversionSection (&is, InfHandle, Section);
  390. if (b) {
  391. osSpecificSection = GetMostSpecificSection (&is, InfHandle, Section);
  392. if (osSpecificSection) {
  393. b = pProcessDataConversionSection (&is, InfHandle, osSpecificSection);
  394. FreeText (osSpecificSection);
  395. }
  396. }
  397. InfCleanUpInfStruct (&is);
  398. return b;
  399. }
  400. BOOL
  401. DoesDestRegExist (
  402. IN MIG_OBJECTSTRINGHANDLE DestName,
  403. IN DWORD RegType
  404. )
  405. {
  406. BOOL result = FALSE;
  407. MIG_CONTENT content;
  408. if (IsmAcquireObject (g_RegType | PLATFORM_DESTINATION, DestName, &content)) {
  409. if (IsValidRegType(&content, RegType)) {
  410. result = TRUE;
  411. }
  412. IsmReleaseObject (&content);
  413. }
  414. return result;
  415. }
  416. BOOL
  417. WINAPI
  418. pConvertToDwordCallback (
  419. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  420. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  421. IN PCMIG_CONTENT OriginalContent,
  422. IN PCMIG_CONTENT CurrentContent,
  423. OUT PMIG_CONTENT NewContent,
  424. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  425. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  426. )
  427. {
  428. DWORD value = 0;
  429. BOOL converted = FALSE;
  430. PDWORD valueType;
  431. //
  432. // Filter the data for any references to %windir%
  433. //
  434. if (!CurrentContent->ContentInFile) {
  435. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  436. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  437. if (*valueType == REG_SZ) {
  438. converted = TRUE;
  439. if (CurrentContent->MemoryContent.ContentSize > 0) {
  440. value = _tcstoul ((PCTSTR)CurrentContent->MemoryContent.ContentBytes, NULL, 10);
  441. }
  442. } else if (*valueType == REG_BINARY ||
  443. *valueType == REG_NONE ||
  444. *valueType == REG_DWORD
  445. ) {
  446. if (CurrentContent->MemoryContent.ContentSize == sizeof (DWORD)) {
  447. converted = TRUE;
  448. value = *((PDWORD)CurrentContent->MemoryContent.ContentBytes);
  449. }
  450. }
  451. if (converted) {
  452. pSetDwordValue (NewContent, value);
  453. }
  454. }
  455. return TRUE;
  456. }
  457. BOOL
  458. WINAPI
  459. pConvertToStringCallback (
  460. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  461. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  462. IN PCMIG_CONTENT OriginalContent,
  463. IN PCMIG_CONTENT CurrentContent,
  464. OUT PMIG_CONTENT NewContent,
  465. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  466. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  467. )
  468. {
  469. PTSTR result = NULL;
  470. PTSTR resultPtr;
  471. UINT i;
  472. BOOL converted = FALSE;
  473. UINT convertedSize = 0;
  474. PDWORD valueType;
  475. //
  476. // Filter the data for any references to %windir%
  477. //
  478. if (!CurrentContent->ContentInFile) {
  479. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  480. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  481. if (*valueType == REG_DWORD) {
  482. MYASSERT (CurrentContent->MemoryContent.ContentSize == sizeof (DWORD));
  483. if (CurrentContent->MemoryContent.ContentSize == sizeof (DWORD)) {
  484. converted = TRUE;
  485. convertedSize = 11 * sizeof (TCHAR); // DWORD takes no more than 11 characters
  486. result = IsmGetMemory (convertedSize);
  487. if (result) {
  488. wsprintf (result, TEXT("%lu"), *((PDWORD)CurrentContent->MemoryContent.ContentBytes));
  489. convertedSize = SizeOfString (result);
  490. }
  491. }
  492. } else if (*valueType == REG_BINARY) {
  493. converted = TRUE;
  494. convertedSize = (CurrentContent->MemoryContent.ContentSize?(CurrentContent->MemoryContent.ContentSize * 3):1) * sizeof (TCHAR);
  495. result = IsmGetMemory (convertedSize);
  496. if (result) {
  497. resultPtr = result;
  498. *resultPtr = 0;
  499. for (i = 0; i < CurrentContent->MemoryContent.ContentSize; i++) {
  500. wsprintf (resultPtr, TEXT("%02X"), CurrentContent->MemoryContent.ContentBytes[i]);
  501. resultPtr = GetEndOfString (resultPtr);
  502. if (i < CurrentContent->MemoryContent.ContentSize - 1) {
  503. _tcscat (resultPtr, TEXT(" "));
  504. resultPtr = GetEndOfString (resultPtr);
  505. }
  506. }
  507. convertedSize = SizeOfString (result);
  508. }
  509. }
  510. if (converted && convertedSize && result) {
  511. NewContent->Details.DetailsSize = sizeof (DWORD);
  512. NewContent->Details.DetailsData = IsmGetMemory (NewContent->Details.DetailsSize);
  513. *((PDWORD)NewContent->Details.DetailsData) = REG_SZ;
  514. NewContent->MemoryContent.ContentSize = convertedSize;
  515. NewContent->MemoryContent.ContentBytes = (PCBYTE) result;
  516. }
  517. }
  518. return TRUE;
  519. }
  520. VOID
  521. pConvertShortLogFontWorker (
  522. PLOGFONTW plfDest,
  523. PSHORT_LOGFONT plfSrc
  524. )
  525. {
  526. PCWSTR faceName;
  527. if (plfSrc->lfHeight > 0) {
  528. plfDest->lfHeight = 0xFFFFFFFF - plfSrc->lfHeight - ((plfSrc->lfHeight + 1) / 3) + 1;
  529. } else {
  530. plfDest->lfHeight = plfSrc->lfHeight;
  531. }
  532. plfDest->lfWidth = plfSrc->lfWidth;
  533. plfDest->lfEscapement = plfSrc->lfEscapement;
  534. plfDest->lfOrientation = plfSrc->lfOrientation;
  535. plfDest->lfWeight = plfSrc->lfWeight;
  536. plfDest->lfItalic = plfSrc->lfItalic;
  537. plfDest->lfUnderline = plfSrc->lfUnderline;
  538. plfDest->lfStrikeOut = plfSrc->lfStrikeOut;
  539. plfDest->lfCharSet = plfSrc->lfCharSet;
  540. plfDest->lfOutPrecision = plfSrc->lfOutPrecision;
  541. plfDest->lfClipPrecision = plfSrc->lfClipPrecision;
  542. plfDest->lfQuality = plfSrc->lfQuality;
  543. plfDest->lfPitchAndFamily = plfSrc->lfPitchAndFamily;\
  544. faceName = ConvertAtoW (plfSrc->lfFaceName);
  545. StringCopyByteCountW (plfDest->lfFaceName, faceName, sizeof (plfDest->lfFaceName));
  546. FreeConvertedStr (faceName);
  547. }
  548. VOID
  549. pConvertLogFontWorker (
  550. PLOGFONTW plfDest,
  551. PLOGFONTA plfSrc
  552. )
  553. {
  554. PCWSTR faceName;
  555. if (plfSrc->lfHeight > 0) {
  556. plfDest->lfHeight = 0xFFFFFFFF - plfSrc->lfHeight + 1 + ((plfSrc->lfHeight + 1) / 3);
  557. } else {
  558. plfDest->lfHeight = plfSrc->lfHeight;
  559. }
  560. plfDest->lfWidth = plfSrc->lfWidth;
  561. plfDest->lfEscapement = plfSrc->lfEscapement;
  562. plfDest->lfOrientation = plfSrc->lfOrientation;
  563. plfDest->lfWeight = plfSrc->lfWeight;
  564. plfDest->lfItalic = plfSrc->lfItalic;
  565. plfDest->lfUnderline = plfSrc->lfUnderline;
  566. plfDest->lfStrikeOut = plfSrc->lfStrikeOut;
  567. plfDest->lfCharSet = plfSrc->lfCharSet;
  568. plfDest->lfOutPrecision = plfSrc->lfOutPrecision;
  569. plfDest->lfClipPrecision = plfSrc->lfClipPrecision;
  570. plfDest->lfQuality = plfSrc->lfQuality;
  571. plfDest->lfPitchAndFamily = plfSrc->lfPitchAndFamily;\
  572. faceName = ConvertAtoW (plfSrc->lfFaceName);
  573. StringCopyByteCountW (plfDest->lfFaceName, faceName, sizeof (plfDest->lfFaceName));
  574. FreeConvertedStr (faceName);
  575. }
  576. VOID
  577. pCopyLogFontWorker (
  578. PLOGFONTW plfDest,
  579. PLOGFONTW plfSrc
  580. )
  581. {
  582. PCWSTR faceName;
  583. plfDest->lfHeight = plfSrc->lfHeight;
  584. plfDest->lfWidth = plfSrc->lfWidth;
  585. plfDest->lfEscapement = plfSrc->lfEscapement;
  586. plfDest->lfOrientation = plfSrc->lfOrientation;
  587. plfDest->lfWeight = plfSrc->lfWeight;
  588. plfDest->lfItalic = plfSrc->lfItalic;
  589. plfDest->lfUnderline = plfSrc->lfUnderline;
  590. plfDest->lfStrikeOut = plfSrc->lfStrikeOut;
  591. plfDest->lfCharSet = plfSrc->lfCharSet;
  592. plfDest->lfOutPrecision = plfSrc->lfOutPrecision;
  593. plfDest->lfClipPrecision = plfSrc->lfClipPrecision;
  594. plfDest->lfQuality = plfSrc->lfQuality;
  595. plfDest->lfPitchAndFamily = plfSrc->lfPitchAndFamily;\
  596. StringCopyByteCountW (plfDest->lfFaceName, plfSrc->lfFaceName, sizeof (plfDest->lfFaceName));
  597. }
  598. BOOL
  599. WINAPI
  600. pConvertLogFontCallback (
  601. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  602. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  603. IN PCMIG_CONTENT OriginalContent,
  604. IN PCMIG_CONTENT CurrentContent,
  605. OUT PMIG_CONTENT NewContent,
  606. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  607. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  608. )
  609. {
  610. BOOL converted = FALSE;
  611. UINT convertedSize = 0;
  612. PLOGFONTW logFont = NULL;
  613. PDWORD valueType;
  614. //
  615. // Filter the data for any references to %windir%
  616. //
  617. if (!CurrentContent->ContentInFile) {
  618. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  619. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  620. if (*valueType == REG_BINARY) {
  621. if (CurrentContent->MemoryContent.ContentSize == sizeof (SHORT_LOGFONT)) {
  622. converted = TRUE;
  623. convertedSize = sizeof (LOGFONTW);
  624. logFont = (PLOGFONTW) IsmGetMemory (convertedSize);
  625. ZeroMemory (logFont, sizeof (LOGFONTW));
  626. pConvertShortLogFontWorker (logFont, (PSHORT_LOGFONT)CurrentContent->MemoryContent.ContentBytes);
  627. }
  628. if (CurrentContent->MemoryContent.ContentSize == sizeof (LOGFONTA)) {
  629. converted = TRUE;
  630. convertedSize = sizeof (LOGFONTW);
  631. logFont = (PLOGFONTW) IsmGetMemory (convertedSize);
  632. ZeroMemory (logFont, sizeof (LOGFONTW));
  633. pConvertLogFontWorker (logFont, (PLOGFONTA)CurrentContent->MemoryContent.ContentBytes);
  634. }
  635. }
  636. if (converted && convertedSize && logFont) {
  637. NewContent->MemoryContent.ContentSize = convertedSize;
  638. NewContent->MemoryContent.ContentBytes = (PBYTE)logFont;
  639. }
  640. }
  641. return TRUE;
  642. }
  643. VOID
  644. pConvertNonClientMetrics (
  645. OUT NONCLIENTMETRICSW *Dest,
  646. IN NONCLIENTMETRICSA *Src
  647. )
  648. {
  649. Dest->cbSize = sizeof (NONCLIENTMETRICSW);
  650. Dest->iBorderWidth = Src->iBorderWidth;
  651. Dest->iScrollWidth = Src->iScrollWidth;
  652. Dest->iScrollHeight = Src->iScrollHeight;
  653. Dest->iCaptionWidth = Src->iCaptionWidth;
  654. Dest->iCaptionHeight = Src->iCaptionHeight;
  655. Dest->iSmCaptionWidth = Src->iSmCaptionWidth;
  656. Dest->iSmCaptionHeight = Src->iSmCaptionHeight;
  657. Dest->iMenuWidth = Src->iMenuWidth;
  658. Dest->iMenuHeight = Src->iMenuHeight;
  659. pConvertLogFontWorker (&Dest->lfCaptionFont, &Src->lfCaptionFont);
  660. pConvertLogFontWorker (&Dest->lfSmCaptionFont, &Src->lfSmCaptionFont);
  661. pConvertLogFontWorker (&Dest->lfMenuFont, &Src->lfMenuFont);
  662. pConvertLogFontWorker (&Dest->lfStatusFont, &Src->lfStatusFont);
  663. pConvertLogFontWorker (&Dest->lfMessageFont, &Src->lfMessageFont);
  664. }
  665. VOID
  666. pCopyNonClientMetrics (
  667. OUT NONCLIENTMETRICSW *Dest,
  668. IN NONCLIENTMETRICSW *Src
  669. )
  670. {
  671. Dest->cbSize = sizeof (NONCLIENTMETRICSW);
  672. Dest->iBorderWidth = Src->iBorderWidth;
  673. Dest->iScrollWidth = Src->iScrollWidth;
  674. Dest->iScrollHeight = Src->iScrollHeight;
  675. Dest->iCaptionWidth = Src->iCaptionWidth;
  676. Dest->iCaptionHeight = Src->iCaptionHeight;
  677. Dest->iSmCaptionWidth = Src->iSmCaptionWidth;
  678. Dest->iSmCaptionHeight = Src->iSmCaptionHeight;
  679. Dest->iMenuWidth = Src->iMenuWidth;
  680. Dest->iMenuHeight = Src->iMenuHeight;
  681. pCopyLogFontWorker (&Dest->lfCaptionFont, &Src->lfCaptionFont);
  682. pCopyLogFontWorker (&Dest->lfSmCaptionFont, &Src->lfSmCaptionFont);
  683. pCopyLogFontWorker (&Dest->lfMenuFont, &Src->lfMenuFont);
  684. pCopyLogFontWorker (&Dest->lfStatusFont, &Src->lfStatusFont);
  685. pCopyLogFontWorker (&Dest->lfMessageFont, &Src->lfMessageFont);
  686. }
  687. #define S_SCHEMELOCATION TEXT("HKCU\\Control Panel\\Appearance\\New Schemes")
  688. #define S_SCHEMECURRENT TEXT("HKCU\\Control Panel\\Appearance")
  689. #define S_SCHEMELOCATIONT1 TEXT("HKCU\\Control Panel\\Appearance\\New Schemes\\Current Settings SaveAll\\Sizes\\0")
  690. #define S_SCHEMELOCATIONT2 TEXT("HKCU\\Control Panel\\Appearance\\New Schemes\\Current Settings SaveNoVisualStyle\\Sizes\\0")
  691. #define S_SCHEMECOLORS TEXT("HKCU\\Control Panel\\Colors")
  692. #define S_SCHEMEMETRICS TEXT("HKCU\\Control Panel\\Desktop\\WindowMetrics")
  693. BOOL
  694. pFindWhistlerScheme (
  695. IN PCTSTR SchemeName,
  696. OUT PUINT SchemeNr,
  697. OUT PUINT SchemeSize
  698. )
  699. {
  700. BOOL result = FALSE;
  701. HKEY rootKey = NULL;
  702. HKEY schemeKey = NULL;
  703. HKEY sizeKey = NULL;
  704. HKEY currSizeKey = NULL;
  705. TCHAR schemeNrStr [MAX_PATH + 1];
  706. TCHAR schemeSizeStr [MAX_PATH + 1];
  707. PCTSTR subKeyStr = NULL;
  708. DWORD index = 0, index1 = 0;
  709. INT maxScheme = -1;
  710. INT currScheme = 0;
  711. LONG err, err1, err2;
  712. DWORD valueType = 0;
  713. DWORD valueDataSize = 0;
  714. PTSTR valueData = NULL;
  715. *SchemeNr = 0;
  716. *SchemeSize = 0;
  717. rootKey = OpenRegKeyStr (S_SCHEMELOCATION);
  718. if (rootKey) {
  719. index = 0;
  720. err = ERROR_SUCCESS;
  721. while (err == ERROR_SUCCESS) {
  722. err = RegEnumKey (rootKey, index, schemeNrStr, MAX_PATH + 1);
  723. if (err == ERROR_SUCCESS) {
  724. currScheme = _ttoi (schemeNrStr);
  725. if (currScheme > maxScheme) {
  726. maxScheme = currScheme;
  727. }
  728. subKeyStr = JoinPaths (schemeNrStr, TEXT("Sizes"));
  729. if (subKeyStr) {
  730. sizeKey = OpenRegKey (rootKey, subKeyStr);
  731. if (sizeKey) {
  732. index1 = 0;
  733. err1 = ERROR_SUCCESS;
  734. while (err1 == ERROR_SUCCESS) {
  735. err1 = RegEnumKey (sizeKey, index1, schemeSizeStr, MAX_PATH + 1);
  736. if (err1 == ERROR_SUCCESS) {
  737. currSizeKey = OpenRegKey (sizeKey, schemeSizeStr);
  738. if (currSizeKey) {
  739. err2 = RegQueryValueEx (
  740. currSizeKey,
  741. TEXT("LegacyName"),
  742. NULL,
  743. &valueType,
  744. NULL,
  745. &valueDataSize
  746. );
  747. if (((err2 == ERROR_SUCCESS) || (err2 == ERROR_MORE_DATA)) &&
  748. ((valueType == REG_SZ) || (valueType == REG_EXPAND_SZ)) &&
  749. valueDataSize
  750. ) {
  751. valueData = (PTSTR) IsmGetMemory (valueDataSize);
  752. err2 = RegQueryValueEx (
  753. currSizeKey,
  754. TEXT("LegacyName"),
  755. NULL,
  756. &valueType,
  757. (PBYTE) valueData,
  758. &valueDataSize
  759. );
  760. if ((err2 == ERROR_SUCCESS) &&
  761. (StringIMatch (valueData, SchemeName))
  762. ) {
  763. *SchemeNr = _ttoi (schemeNrStr);
  764. *SchemeSize = _ttoi (schemeSizeStr);
  765. IsmReleaseMemory (valueData);
  766. valueData = NULL;
  767. CloseRegKey (currSizeKey);
  768. currSizeKey = NULL;
  769. CloseRegKey (sizeKey);
  770. sizeKey = NULL;
  771. FreePathString (subKeyStr);
  772. subKeyStr = NULL;
  773. result = TRUE;
  774. break;
  775. }
  776. IsmReleaseMemory (valueData);
  777. valueData = NULL;
  778. }
  779. CloseRegKey (currSizeKey);
  780. currSizeKey = NULL;
  781. }
  782. }
  783. index1 ++;
  784. }
  785. if (result) {
  786. break;
  787. }
  788. CloseRegKey (sizeKey);
  789. sizeKey = NULL;
  790. }
  791. FreePathString (subKeyStr);
  792. subKeyStr = NULL;
  793. }
  794. index ++;
  795. }
  796. }
  797. CloseRegKey (rootKey);
  798. rootKey = NULL;
  799. }
  800. if (!result) {
  801. *SchemeNr = maxScheme + 1;
  802. }
  803. return result;
  804. }
  805. DWORD
  806. pConvertColor (
  807. IN PCTSTR ColorStr
  808. )
  809. {
  810. DWORD color = 0;
  811. PBYTE colorPtr;
  812. UINT index = 0;
  813. colorPtr = (PBYTE)&color;
  814. while (ColorStr && *ColorStr) {
  815. if (index >= 3) {
  816. return FALSE;
  817. }
  818. *colorPtr = (BYTE) _tcstoul ((PTSTR)ColorStr, &((PTSTR)ColorStr), 10);
  819. if (*ColorStr) {
  820. if (_tcsnextc (ColorStr) != ' ') {
  821. return FALSE;
  822. }
  823. ColorStr = _tcsinc (ColorStr);
  824. }
  825. colorPtr++;
  826. index++;
  827. }
  828. return color;
  829. }
  830. BOOL
  831. pBuildSchemeColor (
  832. IN PCTSTR SchemeDest,
  833. IN PCTSTR SrcColorName,
  834. IN PCTSTR AltSrcColorName,
  835. IN PCTSTR AltSrcColorStr,
  836. IN PCTSTR DestColorName
  837. )
  838. {
  839. MIG_OBJECTTYPEID srcTypeId;
  840. MIG_OBJECTSTRINGHANDLE srcName;
  841. MIG_CONTENT srcContent;
  842. MIG_OBJECTTYPEID destTypeId;
  843. MIG_OBJECTSTRINGHANDLE destName;
  844. MIG_CONTENT destContent;
  845. DWORD color;
  846. DWORD valueType;
  847. BOOL needExtraColor = FALSE;
  848. PCTSTR extraColorStr = NULL;
  849. srcTypeId = MIG_REGISTRY_TYPE | PLATFORM_SOURCE;
  850. destTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  851. ZeroMemory (&destContent, sizeof (MIG_CONTENT));
  852. destContent.ObjectTypeId = destTypeId;
  853. destContent.ContentInFile = FALSE;
  854. destContent.Details.DetailsSize = sizeof (DWORD);
  855. destContent.Details.DetailsData = &valueType;
  856. valueType = REG_DWORD;
  857. destContent.MemoryContent.ContentSize = sizeof (DWORD);
  858. destContent.MemoryContent.ContentBytes = (PBYTE) (&color);
  859. srcName = IsmCreateObjectHandle (S_SCHEMECOLORS, SrcColorName);
  860. if (IsmAcquireObject (srcTypeId, srcName, &srcContent)) {
  861. if (IsValidRegSz(&srcContent)) {
  862. color = pConvertColor ((PCTSTR) srcContent.MemoryContent.ContentBytes);
  863. destName = IsmCreateObjectHandle (SchemeDest, DestColorName);
  864. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  865. IsmDestroyObjectHandle (destName);
  866. destName = NULL;
  867. }
  868. IsmReleaseObject (&srcContent);
  869. } else if (AltSrcColorName) {
  870. IsmDestroyObjectHandle (srcName);
  871. srcName = NULL;
  872. srcName = IsmCreateObjectHandle (S_SCHEMECOLORS, AltSrcColorName);
  873. if (IsmAcquireObject (srcTypeId, srcName, &srcContent)) {
  874. if (IsValidRegSz(&srcContent)) {
  875. color = pConvertColor ((PCTSTR) srcContent.MemoryContent.ContentBytes);
  876. destName = IsmCreateObjectHandle (SchemeDest, DestColorName);
  877. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  878. IsmDestroyObjectHandle (destName);
  879. destName = NULL;
  880. needExtraColor = TRUE;
  881. extraColorStr = DuplicatePathString ((PCTSTR) srcContent.MemoryContent.ContentBytes, 0);
  882. }
  883. IsmReleaseObject (&srcContent);
  884. }
  885. } else if (AltSrcColorStr) {
  886. color = pConvertColor (AltSrcColorStr);
  887. destName = IsmCreateObjectHandle (SchemeDest, DestColorName);
  888. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  889. IsmDestroyObjectHandle (destName);
  890. destName = NULL;
  891. needExtraColor = TRUE;
  892. extraColorStr = DuplicatePathString (AltSrcColorStr, 0);
  893. }
  894. IsmDestroyObjectHandle (srcName);
  895. srcName = NULL;
  896. if (needExtraColor) {
  897. if (extraColorStr) {
  898. valueType = REG_SZ;
  899. destContent.MemoryContent.ContentSize = SizeOfString (extraColorStr);
  900. destContent.MemoryContent.ContentBytes = (PBYTE) extraColorStr;
  901. destName = IsmCreateObjectHandle (S_SCHEMECOLORS, SrcColorName);
  902. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  903. IsmDestroyObjectHandle (destName);
  904. destName = NULL;
  905. FreePathString (extraColorStr);
  906. extraColorStr = NULL;
  907. }
  908. }
  909. return TRUE;
  910. }
  911. LONGLONG
  912. pConvertSize (
  913. IN PCTSTR SizeStr
  914. )
  915. {
  916. INT size = 0;
  917. size = _tcstoul ((PTSTR)SizeStr, &((PTSTR)SizeStr), 10);
  918. size = -(size);
  919. size /= 15;
  920. return size;
  921. }
  922. BOOL
  923. pBuildSchemeSize (
  924. IN PCTSTR SchemeDest,
  925. IN PCTSTR SrcSizeName,
  926. IN PCTSTR DestSizeName
  927. )
  928. {
  929. MIG_OBJECTTYPEID srcTypeId;
  930. MIG_OBJECTSTRINGHANDLE srcName;
  931. MIG_CONTENT srcContent;
  932. MIG_OBJECTTYPEID destTypeId;
  933. MIG_OBJECTSTRINGHANDLE destName;
  934. MIG_CONTENT destContent;
  935. LONGLONG size;
  936. DWORD valueType;
  937. srcTypeId = MIG_REGISTRY_TYPE | PLATFORM_SOURCE;
  938. destTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  939. ZeroMemory (&destContent, sizeof (MIG_CONTENT));
  940. destContent.ObjectTypeId = destTypeId;
  941. destContent.ContentInFile = FALSE;
  942. destContent.Details.DetailsSize = sizeof (DWORD);
  943. destContent.Details.DetailsData = &valueType;
  944. valueType = REG_QWORD;
  945. destContent.MemoryContent.ContentSize = sizeof (LONGLONG);
  946. destContent.MemoryContent.ContentBytes = (PBYTE) (&size);
  947. srcName = IsmCreateObjectHandle (S_SCHEMEMETRICS, SrcSizeName);
  948. if (IsmAcquireObject (srcTypeId, srcName, &srcContent)) {
  949. if (IsValidRegSz(&srcContent)) {
  950. size = pConvertSize ((PCTSTR) srcContent.MemoryContent.ContentBytes);
  951. destName = IsmCreateObjectHandle (SchemeDest, DestSizeName);
  952. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  953. IsmDestroyObjectHandle (destName);
  954. destName = NULL;
  955. }
  956. IsmReleaseObject (&srcContent);
  957. }
  958. IsmDestroyObjectHandle (srcName);
  959. srcName = NULL;
  960. return TRUE;
  961. }
  962. BOOL
  963. pBuildSchemeFont (
  964. IN PCTSTR SchemeDest,
  965. IN PCTSTR SrcSizeName,
  966. IN PCTSTR DestSizeName
  967. )
  968. {
  969. MIG_OBJECTTYPEID srcTypeId;
  970. MIG_OBJECTSTRINGHANDLE srcName;
  971. MIG_CONTENT srcContent;
  972. MIG_OBJECTTYPEID destTypeId;
  973. MIG_OBJECTSTRINGHANDLE destName;
  974. MIG_CONTENT destContent;
  975. LOGFONTW destFont;
  976. DWORD valueType;
  977. srcTypeId = MIG_REGISTRY_TYPE | PLATFORM_SOURCE;
  978. destTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  979. ZeroMemory (&destContent, sizeof (MIG_CONTENT));
  980. destContent.ObjectTypeId = destTypeId;
  981. destContent.ContentInFile = FALSE;
  982. destContent.Details.DetailsSize = sizeof (DWORD);
  983. destContent.Details.DetailsData = &valueType;
  984. ZeroMemory (&destFont, sizeof (LOGFONTW));
  985. valueType = REG_BINARY;
  986. destContent.MemoryContent.ContentSize = sizeof (LOGFONTW);
  987. destContent.MemoryContent.ContentBytes = (PBYTE) (&destFont);
  988. srcName = IsmCreateObjectHandle (S_SCHEMEMETRICS, SrcSizeName);
  989. if (IsmAcquireObject (srcTypeId, srcName, &srcContent)) {
  990. if (IsValidRegType (&srcContent, REG_BINARY)) {
  991. if (srcContent.MemoryContent.ContentSize == sizeof (SHORT_LOGFONT)) {
  992. pConvertShortLogFontWorker (&destFont, (PSHORT_LOGFONT) srcContent.MemoryContent.ContentBytes);
  993. } else if (srcContent.MemoryContent.ContentSize == sizeof (LOGFONTA)) {
  994. pConvertLogFontWorker (&destFont, (PLOGFONTA) srcContent.MemoryContent.ContentBytes);
  995. } else {
  996. CopyMemory (&destFont, srcContent.MemoryContent.ContentBytes, sizeof (LOGFONTW));
  997. }
  998. destName = IsmCreateObjectHandle (SchemeDest, DestSizeName);
  999. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  1000. IsmDestroyObjectHandle (destName);
  1001. destName = NULL;
  1002. }
  1003. IsmReleaseObject (&srcContent);
  1004. }
  1005. IsmDestroyObjectHandle (srcName);
  1006. srcName = NULL;
  1007. return TRUE;
  1008. }
  1009. BOOL
  1010. pBuildTempScheme (
  1011. IN PCTSTR SchemeDest
  1012. )
  1013. {
  1014. MIG_OBJECTTYPEID srcTypeId;
  1015. MIG_OBJECTSTRINGHANDLE srcName;
  1016. MIG_CONTENT srcContent;
  1017. MIG_OBJECTTYPEID destTypeId;
  1018. MIG_OBJECTSTRINGHANDLE destName;
  1019. MIG_CONTENT destContent;
  1020. DWORD value;
  1021. DWORD valueType;
  1022. srcTypeId = MIG_REGISTRY_TYPE | PLATFORM_SOURCE;
  1023. destTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  1024. ZeroMemory (&destContent, sizeof (MIG_CONTENT));
  1025. destContent.ObjectTypeId = destTypeId;
  1026. destContent.ContentInFile = FALSE;
  1027. destContent.Details.DetailsSize = sizeof (DWORD);
  1028. destContent.Details.DetailsData = &valueType;
  1029. // first we build the Color #<nr> values
  1030. pBuildSchemeColor (SchemeDest, TEXT("Scrollbar"), NULL, NULL, TEXT("Color #0"));
  1031. pBuildSchemeColor (SchemeDest, TEXT("Background"), NULL, NULL, TEXT("Color #1"));
  1032. pBuildSchemeColor (SchemeDest, TEXT("ActiveTitle"), NULL, NULL, TEXT("Color #2"));
  1033. pBuildSchemeColor (SchemeDest, TEXT("InactiveTitle"), NULL, NULL, TEXT("Color #3"));
  1034. pBuildSchemeColor (SchemeDest, TEXT("Menu"), NULL, NULL, TEXT("Color #4"));
  1035. pBuildSchemeColor (SchemeDest, TEXT("Window"), NULL, NULL, TEXT("Color #5"));
  1036. pBuildSchemeColor (SchemeDest, TEXT("WindowFrame"), NULL, NULL, TEXT("Color #6"));
  1037. pBuildSchemeColor (SchemeDest, TEXT("MenuText"), NULL, NULL, TEXT("Color #7"));
  1038. pBuildSchemeColor (SchemeDest, TEXT("WindowText"), NULL, NULL, TEXT("Color #8"));
  1039. pBuildSchemeColor (SchemeDest, TEXT("TitleText"), NULL, NULL, TEXT("Color #9"));
  1040. pBuildSchemeColor (SchemeDest, TEXT("ActiveBorder"), NULL, NULL, TEXT("Color #10"));
  1041. pBuildSchemeColor (SchemeDest, TEXT("InactiveBorder"), NULL, NULL, TEXT("Color #11"));
  1042. pBuildSchemeColor (SchemeDest, TEXT("AppWorkSpace"), NULL, NULL, TEXT("Color #12"));
  1043. pBuildSchemeColor (SchemeDest, TEXT("Hilight"), NULL, NULL, TEXT("Color #13"));
  1044. pBuildSchemeColor (SchemeDest, TEXT("HilightText"), NULL, NULL, TEXT("Color #14"));
  1045. pBuildSchemeColor (SchemeDest, TEXT("ButtonFace"), NULL, NULL, TEXT("Color #15"));
  1046. pBuildSchemeColor (SchemeDest, TEXT("ButtonShadow"), NULL, NULL, TEXT("Color #16"));
  1047. pBuildSchemeColor (SchemeDest, TEXT("GrayText"), NULL, NULL, TEXT("Color #17"));
  1048. pBuildSchemeColor (SchemeDest, TEXT("ButtonText"), NULL, NULL, TEXT("Color #18"));
  1049. pBuildSchemeColor (SchemeDest, TEXT("InactiveTitleText"), NULL, NULL, TEXT("Color #19"));
  1050. pBuildSchemeColor (SchemeDest, TEXT("ButtonHilight"), NULL, NULL, TEXT("Color #20"));
  1051. pBuildSchemeColor (SchemeDest, TEXT("ButtonDkShadow"), NULL, NULL, TEXT("Color #21"));
  1052. pBuildSchemeColor (SchemeDest, TEXT("ButtonLight"), NULL, NULL, TEXT("Color #22"));
  1053. pBuildSchemeColor (SchemeDest, TEXT("InfoText"), NULL, NULL, TEXT("Color #23"));
  1054. pBuildSchemeColor (SchemeDest, TEXT("InfoWindow"), NULL, NULL, TEXT("Color #24"));
  1055. pBuildSchemeColor (SchemeDest, TEXT("ButtonAlternateFace"), NULL, TEXT("180 180 180"), TEXT("Color #25"));
  1056. pBuildSchemeColor (SchemeDest, TEXT("HotTrackingColor"), NULL, TEXT("0 0 255"), TEXT("Color #26"));
  1057. pBuildSchemeColor (SchemeDest, TEXT("GradientActiveTitle"), NULL, TEXT("16 132 208"), TEXT("Color #27"));
  1058. pBuildSchemeColor (SchemeDest, TEXT("GradientInactiveTitle"), NULL, TEXT("181 181 181"), TEXT("Color #28"));
  1059. pBuildSchemeColor (SchemeDest, TEXT("MenuHilight"), TEXT("Hilight"), NULL, TEXT("Color #29"));
  1060. pBuildSchemeColor (SchemeDest, TEXT("MenuBar"), TEXT("Menu"), NULL, TEXT("Color #30"));
  1061. // now we build the Size #<nr> values
  1062. pBuildSchemeSize (SchemeDest, TEXT("BorderWidth"), TEXT("Size #0"));
  1063. pBuildSchemeSize (SchemeDest, TEXT("ScrollWidth"), TEXT("Size #1"));
  1064. pBuildSchemeSize (SchemeDest, TEXT("ScrollHeight"), TEXT("Size #2"));
  1065. pBuildSchemeSize (SchemeDest, TEXT("CaptionWidth"), TEXT("Size #3"));
  1066. pBuildSchemeSize (SchemeDest, TEXT("CaptionHeight"), TEXT("Size #4"));
  1067. pBuildSchemeSize (SchemeDest, TEXT("SmCaptionWidth"), TEXT("Size #5"));
  1068. pBuildSchemeSize (SchemeDest, TEXT("SmCaptionHeight"), TEXT("Size #6"));
  1069. pBuildSchemeSize (SchemeDest, TEXT("MenuWidth"), TEXT("Size #7"));
  1070. pBuildSchemeSize (SchemeDest, TEXT("MenuHeight"), TEXT("Size #8"));
  1071. // finally build the Font #<nr> values
  1072. pBuildSchemeFont (SchemeDest, TEXT("CaptionFont"), TEXT("Font #0"));
  1073. pBuildSchemeFont (SchemeDest, TEXT("SmCaptionFont"), TEXT("Font #1"));
  1074. pBuildSchemeFont (SchemeDest, TEXT("MenuFont"), TEXT("Font #2"));
  1075. pBuildSchemeFont (SchemeDest, TEXT("IconFont"), TEXT("Font #3"));
  1076. pBuildSchemeFont (SchemeDest, TEXT("StatusFont"), TEXT("Font #4"));
  1077. pBuildSchemeFont (SchemeDest, TEXT("MessageFont"), TEXT("Font #5"));
  1078. value = 0;
  1079. valueType = REG_DWORD;
  1080. destContent.MemoryContent.ContentSize = sizeof (DWORD);
  1081. destContent.MemoryContent.ContentBytes = (PBYTE) (&value);
  1082. destName = IsmCreateObjectHandle (SchemeDest, TEXT("Contrast"));
  1083. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  1084. IsmDestroyObjectHandle (destName);
  1085. destName = NULL;
  1086. destName = IsmCreateObjectHandle (SchemeDest, TEXT("Flat Menus"));
  1087. IsmReplacePhysicalObject (destTypeId, destName, &destContent);
  1088. IsmDestroyObjectHandle (destName);
  1089. destName = NULL;
  1090. return TRUE;
  1091. }
  1092. BOOL
  1093. pUpdateSchemeData (
  1094. IN PCTSTR SchemeName,
  1095. IN UINT SchemeNr,
  1096. IN UINT SchemeSize
  1097. )
  1098. {
  1099. static BOOL firstTime = TRUE;
  1100. BOOL current = FALSE;
  1101. MIG_OBJECTTYPEID objectTypeId;
  1102. MIG_OBJECTSTRINGHANDLE objectName;
  1103. MIG_CONTENT objectContent;
  1104. TCHAR schemeNrStr [20];
  1105. TCHAR schemeSizeStr [20];
  1106. PCTSTR keyStr = NULL;
  1107. DWORD valueType = REG_SZ;
  1108. BOOL noCurrent = FALSE;
  1109. // first let's see if this is the current scheme
  1110. objectTypeId = MIG_REGISTRY_TYPE | PLATFORM_SOURCE;
  1111. objectName = IsmCreateObjectHandle (S_SCHEMECURRENT, TEXT("Current"));
  1112. if (IsmAcquireObject (objectTypeId, objectName, &objectContent)) {
  1113. current = ((IsValidRegSz(&objectContent)) &&
  1114. (StringIMatch (SchemeName, (PCTSTR) objectContent.MemoryContent.ContentBytes))
  1115. );
  1116. noCurrent = ((IsValidRegSz(&objectContent)) &&
  1117. (StringIMatch (TEXT(""), (PCTSTR) objectContent.MemoryContent.ContentBytes))
  1118. );
  1119. IsmReleaseObject (&objectContent);
  1120. } else {
  1121. noCurrent = TRUE;
  1122. }
  1123. IsmDestroyObjectHandle (objectName);
  1124. objectName = NULL;
  1125. if (noCurrent) {
  1126. // we did not have a current scheme, so we had only a temporary scheme
  1127. // First time when we encounter this we will attempt to fix it.
  1128. if (firstTime) {
  1129. // we will build HKR\Control Panel\Appearance\New Schemes\Current Settings SaveAll and
  1130. // HKR\Control Panel\Appearance\New Schemes\Current Settings SaveNoVisualStyle from
  1131. // HKR\Control Panel\Colors and HKR\Control Panel\Desktop\WindowMetrics
  1132. // We need to be carefull since we are reading source machine information and we need to
  1133. // convert it (especially font blobs).
  1134. pBuildTempScheme (S_SCHEMELOCATIONT1);
  1135. pBuildTempScheme (S_SCHEMELOCATIONT2);
  1136. firstTime = FALSE;
  1137. }
  1138. }
  1139. if (!current) {
  1140. return TRUE;
  1141. }
  1142. objectTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  1143. ZeroMemory (&objectContent, sizeof (MIG_CONTENT));
  1144. objectContent.ObjectTypeId = objectTypeId;
  1145. objectContent.ContentInFile = FALSE;
  1146. objectContent.MemoryContent.ContentSize = SizeOfString (SchemeName);
  1147. objectContent.MemoryContent.ContentBytes = (PBYTE) SchemeName;
  1148. objectContent.Details.DetailsSize = sizeof (DWORD);
  1149. objectContent.Details.DetailsData = &valueType;
  1150. objectName = IsmCreateObjectHandle (S_SCHEMECURRENT, TEXT("Current"));
  1151. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1152. IsmDestroyObjectHandle (objectName);
  1153. objectName = NULL;
  1154. objectName = IsmCreateObjectHandle (S_SCHEMECURRENT, TEXT("NewCurrent"));
  1155. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1156. IsmDestroyObjectHandle (objectName);
  1157. objectName = NULL;
  1158. _ultot (SchemeNr, schemeNrStr, 10);
  1159. objectContent.MemoryContent.ContentSize = SizeOfString (schemeNrStr);
  1160. objectContent.MemoryContent.ContentBytes = (PBYTE) schemeNrStr;
  1161. objectName = IsmCreateObjectHandle (S_SCHEMELOCATION, TEXT("SelectedStyle"));
  1162. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1163. IsmDestroyObjectHandle (objectName);
  1164. objectName = NULL;
  1165. keyStr = JoinPaths (S_SCHEMELOCATION, schemeNrStr);
  1166. _ultot (SchemeSize, schemeSizeStr, 10);
  1167. objectContent.MemoryContent.ContentSize = SizeOfString (schemeSizeStr);
  1168. objectContent.MemoryContent.ContentBytes = (PBYTE) schemeSizeStr;
  1169. objectName = IsmCreateObjectHandle (keyStr, TEXT("SelectedSize"));
  1170. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1171. IsmDestroyObjectHandle (objectName);
  1172. objectName = NULL;
  1173. FreePathString (keyStr);
  1174. keyStr = NULL;
  1175. // finally we need to copy the current scheme into
  1176. // HKR\Control Panel\Appearance\New Schemes\Current Settings SaveAll and
  1177. // HKR\Control Panel\Appearance\New Schemes\Current Settings SaveNoVisualStyle
  1178. pBuildTempScheme (S_SCHEMELOCATIONT1);
  1179. pBuildTempScheme (S_SCHEMELOCATIONT2);
  1180. return TRUE;
  1181. }
  1182. BOOL
  1183. pCreateWhistlerScheme (
  1184. IN PCTSTR SchemeName,
  1185. IN PSCHEMEDATA_NT SchemeData,
  1186. IN UINT SchemeNr
  1187. )
  1188. {
  1189. MIG_OBJECTTYPEID objectTypeId;
  1190. MIG_OBJECTSTRINGHANDLE objectName;
  1191. MIG_CONTENT objectContent;
  1192. DWORD valueType = 0;
  1193. TCHAR schemeNrStr [20];
  1194. TCHAR valueName [20];
  1195. TCHAR normalStr [] = TEXT("Normal");
  1196. PCTSTR keyStr = NULL;
  1197. DWORD value = 0;
  1198. DWORD index = 0;
  1199. ULONGLONG qvalue = 0;
  1200. objectTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  1201. ZeroMemory (&objectContent, sizeof (MIG_CONTENT));
  1202. objectContent.ObjectTypeId = objectTypeId;
  1203. objectContent.ContentInFile = FALSE;
  1204. objectContent.Details.DetailsSize = sizeof (DWORD);
  1205. objectContent.Details.DetailsData = &valueType;
  1206. _ultot (SchemeNr, schemeNrStr, 10);
  1207. keyStr = JoinPathsInPoolEx ((NULL, S_SCHEMELOCATION, schemeNrStr, NULL));
  1208. valueType = REG_SZ;
  1209. objectContent.MemoryContent.ContentSize = SizeOfString (SchemeName);
  1210. objectContent.MemoryContent.ContentBytes = (PBYTE) SchemeName;
  1211. objectName = IsmCreateObjectHandle (keyStr, TEXT("DisplayName"));
  1212. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1213. IsmDestroyObjectHandle (objectName);
  1214. FreePathString (keyStr);
  1215. keyStr = NULL;
  1216. keyStr = JoinPathsInPoolEx ((NULL, S_SCHEMELOCATION, schemeNrStr, TEXT("Sizes\\0"), NULL));
  1217. valueType = REG_SZ;
  1218. objectContent.MemoryContent.ContentSize = SizeOfString (normalStr);
  1219. objectContent.MemoryContent.ContentBytes = (PBYTE) normalStr;
  1220. objectName = IsmCreateObjectHandle (keyStr, TEXT("DisplayName"));
  1221. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1222. IsmDestroyObjectHandle (objectName);
  1223. objectName = NULL;
  1224. objectContent.MemoryContent.ContentSize = SizeOfString (SchemeName);
  1225. objectContent.MemoryContent.ContentBytes = (PBYTE) SchemeName;
  1226. objectName = IsmCreateObjectHandle (keyStr, TEXT("LegacyName"));
  1227. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1228. IsmDestroyObjectHandle (objectName);
  1229. objectName = NULL;
  1230. value = 0;
  1231. valueType = REG_DWORD;
  1232. objectContent.MemoryContent.ContentSize = sizeof (DWORD);
  1233. objectContent.MemoryContent.ContentBytes = (PBYTE) (&value);
  1234. objectName = IsmCreateObjectHandle (keyStr, TEXT("Contrast"));
  1235. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1236. IsmDestroyObjectHandle (objectName);
  1237. objectName = NULL;
  1238. objectName = IsmCreateObjectHandle (keyStr, TEXT("Flat Menus"));
  1239. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1240. IsmDestroyObjectHandle (objectName);
  1241. objectName = NULL;
  1242. // write Color #<nr> values
  1243. objectContent.MemoryContent.ContentSize = sizeof (DWORD);
  1244. objectContent.MemoryContent.ContentBytes = (PBYTE) (&value);
  1245. for (index = 0; index < COLOR_MAX_NT; index ++) {
  1246. value = SchemeData->rgb [index];
  1247. wsprintf (valueName, TEXT("Color #%u"), index);
  1248. objectName = IsmCreateObjectHandle (keyStr, valueName);
  1249. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1250. IsmDestroyObjectHandle (objectName);
  1251. objectName = NULL;
  1252. }
  1253. value = SchemeData->rgb [COLOR_HIGHLIGHT];
  1254. wsprintf (valueName, TEXT("Color #%u"), COLOR_MENUHILIGHT);
  1255. objectName = IsmCreateObjectHandle (keyStr, valueName);
  1256. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1257. IsmDestroyObjectHandle (objectName);
  1258. objectName = NULL;
  1259. value = SchemeData->rgb [COLOR_MENU];
  1260. wsprintf (valueName, TEXT("Color #%u"), COLOR_MAX_NT + 1);
  1261. objectName = IsmCreateObjectHandle (keyStr, valueName);
  1262. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1263. IsmDestroyObjectHandle (objectName);
  1264. objectName = NULL;
  1265. // now, let's write the sizes
  1266. valueType = REG_QWORD;
  1267. objectContent.MemoryContent.ContentSize = sizeof (ULONGLONG);
  1268. objectContent.MemoryContent.ContentBytes = (PBYTE) (&qvalue);
  1269. qvalue = SchemeData->ncm.iBorderWidth;
  1270. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #0"));
  1271. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1272. IsmDestroyObjectHandle (objectName);
  1273. objectName = NULL;
  1274. qvalue = SchemeData->ncm.iScrollWidth;
  1275. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #1"));
  1276. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1277. IsmDestroyObjectHandle (objectName);
  1278. objectName = NULL;
  1279. qvalue = SchemeData->ncm.iScrollHeight;
  1280. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #2"));
  1281. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1282. IsmDestroyObjectHandle (objectName);
  1283. objectName = NULL;
  1284. qvalue = SchemeData->ncm.iCaptionWidth;
  1285. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #3"));
  1286. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1287. IsmDestroyObjectHandle (objectName);
  1288. objectName = NULL;
  1289. qvalue = SchemeData->ncm.iCaptionHeight;
  1290. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #4"));
  1291. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1292. IsmDestroyObjectHandle (objectName);
  1293. objectName = NULL;
  1294. qvalue = SchemeData->ncm.iSmCaptionWidth;
  1295. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #5"));
  1296. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1297. IsmDestroyObjectHandle (objectName);
  1298. objectName = NULL;
  1299. qvalue = SchemeData->ncm.iSmCaptionHeight;
  1300. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #6"));
  1301. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1302. IsmDestroyObjectHandle (objectName);
  1303. objectName = NULL;
  1304. qvalue = SchemeData->ncm.iMenuWidth;
  1305. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #7"));
  1306. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1307. IsmDestroyObjectHandle (objectName);
  1308. objectName = NULL;
  1309. qvalue = SchemeData->ncm.iMenuHeight;
  1310. objectName = IsmCreateObjectHandle (keyStr, TEXT("Size #8"));
  1311. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1312. IsmDestroyObjectHandle (objectName);
  1313. objectName = NULL;
  1314. // finally, let's write the fonts
  1315. valueType = REG_BINARY;
  1316. objectContent.MemoryContent.ContentSize = sizeof (LOGFONTW);
  1317. objectContent.MemoryContent.ContentBytes = (PBYTE) (&SchemeData->ncm.lfCaptionFont);
  1318. objectName = IsmCreateObjectHandle (keyStr, TEXT("Font #0"));
  1319. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1320. IsmDestroyObjectHandle (objectName);
  1321. objectName = NULL;
  1322. objectContent.MemoryContent.ContentBytes = (PBYTE) (&SchemeData->ncm.lfSmCaptionFont);
  1323. objectName = IsmCreateObjectHandle (keyStr, TEXT("Font #1"));
  1324. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1325. IsmDestroyObjectHandle (objectName);
  1326. objectName = NULL;
  1327. objectContent.MemoryContent.ContentBytes = (PBYTE) (&SchemeData->ncm.lfMenuFont);
  1328. objectName = IsmCreateObjectHandle (keyStr, TEXT("Font #2"));
  1329. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1330. IsmDestroyObjectHandle (objectName);
  1331. objectName = NULL;
  1332. objectContent.MemoryContent.ContentBytes = (PBYTE) (&SchemeData->lfIconTitle);
  1333. objectName = IsmCreateObjectHandle (keyStr, TEXT("Font #3"));
  1334. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1335. IsmDestroyObjectHandle (objectName);
  1336. objectName = NULL;
  1337. objectContent.MemoryContent.ContentBytes = (PBYTE) (&SchemeData->ncm.lfStatusFont);
  1338. objectName = IsmCreateObjectHandle (keyStr, TEXT("Font #4"));
  1339. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1340. IsmDestroyObjectHandle (objectName);
  1341. objectName = NULL;
  1342. objectContent.MemoryContent.ContentBytes = (PBYTE) (&SchemeData->ncm.lfMessageFont);
  1343. objectName = IsmCreateObjectHandle (keyStr, TEXT("Font #5"));
  1344. IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  1345. IsmDestroyObjectHandle (objectName);
  1346. objectName = NULL;
  1347. FreePathString (keyStr);
  1348. keyStr = NULL;
  1349. return TRUE;
  1350. }
  1351. BOOL
  1352. pDoesNewSchemeKeyExist (
  1353. VOID
  1354. )
  1355. {
  1356. BOOL result = FALSE;
  1357. HKEY rootKey = NULL;
  1358. rootKey = OpenRegKeyStr (S_SCHEMELOCATION);
  1359. result = rootKey != NULL;
  1360. if (rootKey) {
  1361. CloseRegKey (rootKey);
  1362. }
  1363. return result;
  1364. }
  1365. BOOL
  1366. WINAPI
  1367. pConvertAppearanceSchemeCallback (
  1368. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  1369. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  1370. IN PCMIG_CONTENT OriginalContent,
  1371. IN PCMIG_CONTENT CurrentContent,
  1372. OUT PMIG_CONTENT NewContent,
  1373. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  1374. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  1375. )
  1376. {
  1377. BOOL converted = FALSE;
  1378. UINT convertedSize = 0;
  1379. PBYTE result = NULL;
  1380. PDWORD valueType;
  1381. SCHEMEDATA_NT sd_nt;
  1382. PSCHEMEDATA_V1 psd_v1;
  1383. PSCHEMEDATA_V2 psd_v2;
  1384. PSCHEMEDATA_V3 psd_v3;
  1385. PSCHEMEDATA_V4 psd_v4;
  1386. PSCHEMEDATA_V1A psd_v1a;
  1387. BOOL Copy3dValues = FALSE;
  1388. PCTSTR node = NULL, leaf = NULL;
  1389. UINT schemeNr = 0;
  1390. UINT schemeSize = 0;
  1391. //
  1392. // Filter the data for any references to %windir%
  1393. //
  1394. ZeroMemory (&sd_nt, sizeof (SCHEMEDATA_NT));
  1395. if (!CurrentContent->ContentInFile) {
  1396. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  1397. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  1398. if (*valueType == REG_BINARY) {
  1399. if (CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V1) ||
  1400. CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V2) ||
  1401. CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V3) ||
  1402. CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V4) ||
  1403. CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V1A)
  1404. ) {
  1405. psd_v1 = (PSCHEMEDATA_V1)CurrentContent->MemoryContent.ContentBytes;
  1406. if (psd_v1->version == 1 ||
  1407. psd_v1->version == 2 ||
  1408. psd_v1->version == 3 ||
  1409. psd_v1->version == 4
  1410. ) {
  1411. //
  1412. // this is a valid scheme and it has a supported version
  1413. //
  1414. //
  1415. // Convert the structure
  1416. //
  1417. if (psd_v1->version == 1) {
  1418. sd_nt.version = 2;
  1419. pConvertNonClientMetrics (&sd_nt.ncm, &psd_v1->ncm);
  1420. pConvertShortLogFontWorker (&sd_nt.lfIconTitle, &psd_v1->lfIconTitle);
  1421. ZeroMemory (sd_nt.rgb, sizeof (sd_nt.rgb));
  1422. CopyMemory (
  1423. &sd_nt.rgb,
  1424. &psd_v1->rgb,
  1425. min (sizeof (psd_v1->rgb), sizeof (sd_nt.rgb))
  1426. );
  1427. Copy3dValues = TRUE;
  1428. } else if (psd_v1->version == 3 && CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V1A)) {
  1429. psd_v1a = (PSCHEMEDATA_V1A) psd_v1;
  1430. sd_nt.version = 2;
  1431. pConvertNonClientMetrics (&sd_nt.ncm, &psd_v1a->ncm);
  1432. pConvertShortLogFontWorker (&sd_nt.lfIconTitle, &psd_v1a->lfIconTitle);
  1433. ZeroMemory (sd_nt.rgb, sizeof (sd_nt.rgb));
  1434. CopyMemory (
  1435. &sd_nt.rgb,
  1436. &psd_v1a->rgb,
  1437. min (sizeof (psd_v1a->rgb), sizeof (sd_nt.rgb))
  1438. );
  1439. Copy3dValues = TRUE;
  1440. } else if (psd_v1->version == 2 && CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V2)) {
  1441. psd_v2 = (PSCHEMEDATA_V2) psd_v1;
  1442. sd_nt.version = 2;
  1443. pCopyNonClientMetrics (&sd_nt.ncm, &psd_v2->ncm);
  1444. pCopyLogFontWorker (&sd_nt.lfIconTitle, &psd_v2->lfIconTitle);
  1445. ZeroMemory (sd_nt.rgb, sizeof (sd_nt.rgb));
  1446. CopyMemory (
  1447. &sd_nt.rgb,
  1448. &psd_v2->rgb,
  1449. min (sizeof (psd_v2->rgb), sizeof (sd_nt.rgb))
  1450. );
  1451. Copy3dValues = TRUE;
  1452. } else if (psd_v1->version == 3 && CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_V3)) {
  1453. psd_v3 = (PSCHEMEDATA_V3) psd_v1;
  1454. sd_nt.version = 2;
  1455. pConvertNonClientMetrics (&sd_nt.ncm, &psd_v3->ncm);
  1456. pConvertLogFontWorker (&sd_nt.lfIconTitle, &psd_v3->lfIconTitle);
  1457. ZeroMemory (sd_nt.rgb, sizeof (sd_nt.rgb));
  1458. CopyMemory (
  1459. &sd_nt.rgb,
  1460. &psd_v3->rgb,
  1461. min (sizeof (psd_v3->rgb), sizeof (sd_nt.rgb))
  1462. );
  1463. Copy3dValues = TRUE;
  1464. } else if (psd_v1->version == 4) {
  1465. psd_v4 = (PSCHEMEDATA_V4) psd_v1;
  1466. sd_nt.version = 2;
  1467. pConvertNonClientMetrics (&sd_nt.ncm, &psd_v4->ncm);
  1468. pConvertLogFontWorker (&sd_nt.lfIconTitle, &psd_v4->lfIconTitle);
  1469. ZeroMemory (sd_nt.rgb, sizeof (sd_nt.rgb));
  1470. CopyMemory (
  1471. &sd_nt.rgb,
  1472. &psd_v4->rgb,
  1473. min (sizeof (psd_v4->rgb), sizeof (sd_nt.rgb))
  1474. );
  1475. }
  1476. if (Copy3dValues) {
  1477. //
  1478. // Make sure the NT structure has values for 3D colors
  1479. //
  1480. sd_nt.rgb[COLOR_BUTTONALTFACE] = sd_nt.rgb[COLOR_BTNFACE];
  1481. sd_nt.rgb[COLOR_HOTLIGHT] = sd_nt.rgb[COLOR_ACTIVECAPTION];
  1482. sd_nt.rgb[COLOR_GRADIENTACTIVECAPTION] = sd_nt.rgb[COLOR_ACTIVECAPTION];
  1483. sd_nt.rgb[COLOR_GRADIENTINACTIVECAPTION] = sd_nt.rgb[COLOR_INACTIVECAPTION];
  1484. }
  1485. converted = TRUE;
  1486. convertedSize = sizeof (sd_nt);
  1487. result = IsmGetMemory (convertedSize);
  1488. CopyMemory (result, &sd_nt, convertedSize);
  1489. }
  1490. }
  1491. }
  1492. if (converted && convertedSize && result) {
  1493. NewContent->MemoryContent.ContentSize = convertedSize;
  1494. NewContent->MemoryContent.ContentBytes = result;
  1495. }
  1496. if ((*valueType == REG_BINARY) &&
  1497. (converted || (CurrentContent->MemoryContent.ContentSize == sizeof (SCHEMEDATA_NT))) &&
  1498. (pDoesNewSchemeKeyExist ())
  1499. ) {
  1500. // now we need to do some extra work
  1501. // Each scheme must be converted to the new Whistler format
  1502. // First we look to see if the scheme that we just processed exists in new Whistler format
  1503. // For this we enumerate the HKR\Control Panel\Appearance\New Schemes
  1504. // and try to find the valuename "Legacy Name" that matches the value name of this scheme
  1505. // If we find it, we only update HKR\Control Panel\Appearance [Current],
  1506. // HKR\Control Panel\Appearance [NewCurrent], HKR\Control Panel\Appearance\New Schemes [SelectedStyle]
  1507. // and HKR\Control Panel\Appearance\New Schemes\<Scheme Number> [SelectedSize].
  1508. // If not, we create a new Whistler scheme and update the above 4 value names.
  1509. if (IsmCreateObjectStringsFromHandle (SrcObjectName, &node, &leaf)) {
  1510. if (leaf) {
  1511. if (pFindWhistlerScheme (leaf, &schemeNr, &schemeSize)) {
  1512. pUpdateSchemeData (leaf, schemeNr, schemeSize);
  1513. } else {
  1514. if (pCreateWhistlerScheme (
  1515. leaf,
  1516. converted?
  1517. (PSCHEMEDATA_NT)NewContent->MemoryContent.ContentBytes:
  1518. (PSCHEMEDATA_NT)CurrentContent->MemoryContent.ContentBytes,
  1519. schemeNr
  1520. )) {
  1521. pUpdateSchemeData (leaf, schemeNr, 0);
  1522. }
  1523. }
  1524. }
  1525. IsmDestroyObjectString (node);
  1526. IsmDestroyObjectString (leaf);
  1527. }
  1528. }
  1529. }
  1530. return TRUE;
  1531. }
  1532. BOOL
  1533. WINAPI
  1534. pAntiAliasCallback (
  1535. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  1536. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  1537. IN PCMIG_CONTENT OriginalContent,
  1538. IN PCMIG_CONTENT CurrentContent,
  1539. OUT PMIG_CONTENT NewContent,
  1540. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  1541. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  1542. )
  1543. {
  1544. DWORD value = 0;
  1545. BOOL converted = FALSE;
  1546. PTSTR result = NULL;
  1547. UINT convertedSize = 0;
  1548. PDWORD valueType;
  1549. //
  1550. // Filter the data for any references to %windir%
  1551. //
  1552. if (!CurrentContent->ContentInFile) {
  1553. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  1554. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  1555. if (*valueType == REG_SZ) {
  1556. if (CurrentContent->MemoryContent.ContentSize > 0) {
  1557. value = _tcstoul ((PCTSTR)CurrentContent->MemoryContent.ContentBytes, NULL, 10);
  1558. }
  1559. if (value > 0) {
  1560. converted = TRUE;
  1561. convertedSize = 11 * sizeof (TCHAR); // DWORD takes no more than 11 characters
  1562. result = IsmGetMemory (convertedSize);
  1563. wsprintf (result, TEXT("%d"), FE_AA_ON);
  1564. }
  1565. }
  1566. if (converted && convertedSize && result) {
  1567. NewContent->MemoryContent.ContentSize = convertedSize;
  1568. NewContent->MemoryContent.ContentBytes = (PCBYTE) result;
  1569. }
  1570. }
  1571. return TRUE;
  1572. }
  1573. BOOL
  1574. pBufferMatch (
  1575. IN PCBYTE Buffer1,
  1576. IN PCBYTE Buffer2,
  1577. IN UINT Size
  1578. )
  1579. {
  1580. UINT i;
  1581. for (i = 0; i < Size; i ++) {
  1582. if (Buffer1 [i] != Buffer2 [i]) {
  1583. return FALSE;
  1584. }
  1585. }
  1586. return TRUE;
  1587. }
  1588. BOOL
  1589. WINAPI
  1590. pFixActiveDesktopCallback (
  1591. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  1592. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  1593. IN PCMIG_CONTENT OriginalContent,
  1594. IN PCMIG_CONTENT CurrentContent,
  1595. OUT PMIG_CONTENT NewContent,
  1596. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  1597. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  1598. )
  1599. {
  1600. #define badBufferSize 16
  1601. #define goodBufferSize 28
  1602. const BYTE badBuffer[badBufferSize] =
  1603. {0x10, 0x00, 0x00, 0x00,
  1604. 0x01, 0x00, 0x00, 0x00,
  1605. 0x00, 0x00, 0x00, 0x00,
  1606. 0x00, 0x00, 0x00, 0x00};
  1607. const BYTE goodBuffer[goodBufferSize] =
  1608. {0x1C, 0x00, 0x00, 0x00,
  1609. 0x20, 0x08, 0x00, 0x00,
  1610. 0x00, 0x00, 0x00, 0x00,
  1611. 0x00, 0x00, 0x00, 0x00,
  1612. 0x00, 0x00, 0x00, 0x00,
  1613. 0x00, 0x00, 0x00, 0x00,
  1614. 0x0A, 0x00, 0x00, 0x00};
  1615. BOOL converted = FALSE;
  1616. PBYTE result = NULL;
  1617. UINT convertedSize = 0;
  1618. PDWORD valueType;
  1619. //
  1620. // Filter the data for any references to %windir%
  1621. //
  1622. if (!CurrentContent->ContentInFile) {
  1623. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  1624. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  1625. if (*valueType == REG_BINARY) {
  1626. if (CurrentContent->MemoryContent.ContentSize == badBufferSize) {
  1627. if (pBufferMatch (CurrentContent->MemoryContent.ContentBytes, badBuffer, badBufferSize)) {
  1628. converted = TRUE;
  1629. convertedSize = goodBufferSize;
  1630. result = IsmGetMemory (convertedSize);
  1631. CopyMemory (result, goodBuffer, convertedSize);
  1632. }
  1633. }
  1634. }
  1635. if (converted && convertedSize && result) {
  1636. NewContent->MemoryContent.ContentSize = convertedSize;
  1637. NewContent->MemoryContent.ContentBytes = result;
  1638. }
  1639. }
  1640. return TRUE;
  1641. }
  1642. BOOL
  1643. WINAPI
  1644. pConvertRecentDocsMRUCallback (
  1645. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  1646. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  1647. IN PCMIG_CONTENT OriginalContent,
  1648. IN PCMIG_CONTENT CurrentContent,
  1649. OUT PMIG_CONTENT NewContent,
  1650. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  1651. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  1652. )
  1653. {
  1654. BOOL converted = FALSE;
  1655. PBYTE result = NULL;
  1656. UINT convertedSize = 0;
  1657. PDWORD valueType;
  1658. PCSTR str, structPtr;
  1659. PCWSTR strW;
  1660. UINT size, sizeW;
  1661. //
  1662. // Filter the data for any references to %windir%
  1663. //
  1664. if (!CurrentContent->ContentInFile) {
  1665. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  1666. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  1667. if ((*valueType == REG_BINARY) && (CurrentContent->MemoryContent.ContentSize)) {
  1668. // The content of this is a NULL terminated string followed by some binary data.
  1669. // We need to convert the string to unicode and add the existent
  1670. // binary data
  1671. str = (PCSTR)CurrentContent->MemoryContent.ContentBytes;
  1672. __try {
  1673. structPtr = GetEndOfStringA (str);
  1674. structPtr = _mbsinc (structPtr);
  1675. if (structPtr && (structPtr > str)) {
  1676. size = CurrentContent->MemoryContent.ContentSize - (UINT)(structPtr - str);
  1677. if (size == sizeof (WORD) + *((PWORD)structPtr)) {
  1678. converted = TRUE;
  1679. strW = ConvertAtoW (str);
  1680. sizeW = SizeOfStringW (strW);
  1681. convertedSize = sizeW + size;
  1682. result = IsmGetMemory (convertedSize);
  1683. CopyMemory (result, strW, sizeW);
  1684. CopyMemory (result + sizeW, structPtr, size);
  1685. FreeConvertedStr (strW);
  1686. }
  1687. }
  1688. }
  1689. __except (EXCEPTION_EXECUTE_HANDLER) {
  1690. // the structure was not well formed
  1691. converted = FALSE;
  1692. if (result) {
  1693. IsmReleaseMemory (result);
  1694. }
  1695. }
  1696. }
  1697. if (converted && convertedSize && result) {
  1698. NewContent->MemoryContent.ContentSize = convertedSize;
  1699. NewContent->MemoryContent.ContentBytes = result;
  1700. }
  1701. }
  1702. return TRUE;
  1703. }
  1704. PCTSTR
  1705. pFindNewScreenSaver (
  1706. IN PCTSTR OldScreenSaver
  1707. )
  1708. {
  1709. PTSTR multiSz = NULL;
  1710. MULTISZ_ENUM e;
  1711. UINT sizeNeeded;
  1712. HINF infHandle = INVALID_HANDLE_VALUE;
  1713. ENVENTRY_TYPE dataType;
  1714. INFSTRUCT is = INITINFSTRUCT_PMHANDLE;
  1715. PCTSTR newScrName;
  1716. PCTSTR result = NULL;
  1717. if (IsmGetEnvironmentValue (
  1718. IsmGetRealPlatform (),
  1719. NULL,
  1720. S_GLOBAL_INF_HANDLE,
  1721. (PBYTE)(&infHandle),
  1722. sizeof (HINF),
  1723. &sizeNeeded,
  1724. &dataType
  1725. ) &&
  1726. (sizeNeeded == sizeof (HINF)) &&
  1727. (dataType == ENVENTRY_BINARY)
  1728. ) {
  1729. if (InfFindFirstLine (infHandle, TEXT("SCR Rename"), OldScreenSaver, &is)) {
  1730. newScrName = InfGetStringField (&is, 1);
  1731. if (newScrName) {
  1732. result = DuplicatePathString (newScrName, 0);
  1733. }
  1734. }
  1735. InfNameHandle (infHandle, NULL, FALSE);
  1736. } else {
  1737. if (!IsmGetEnvironmentValue (IsmGetRealPlatform (), NULL, S_INF_FILE_MULTISZ, NULL, 0, &sizeNeeded, NULL)) {
  1738. result = DuplicatePathString (OldScreenSaver, 0);
  1739. return result;
  1740. }
  1741. __try {
  1742. multiSz = AllocText (sizeNeeded);
  1743. if (!IsmGetEnvironmentValue (IsmGetRealPlatform (), NULL, S_INF_FILE_MULTISZ, (PBYTE) multiSz, sizeNeeded, NULL, NULL)) {
  1744. __leave;
  1745. }
  1746. if (EnumFirstMultiSz (&e, multiSz)) {
  1747. do {
  1748. infHandle = InfOpenInfFile (e.CurrentString);
  1749. if (infHandle != INVALID_HANDLE_VALUE) {
  1750. if (InfFindFirstLine (infHandle, TEXT("SCR Rename"), OldScreenSaver, &is)) {
  1751. newScrName = InfGetStringField (&is, 1);
  1752. if (newScrName) {
  1753. result = DuplicatePathString (newScrName, 0);
  1754. InfCloseInfFile (infHandle);
  1755. infHandle = INVALID_HANDLE_VALUE;
  1756. __leave;
  1757. }
  1758. }
  1759. } else {
  1760. LOG ((LOG_ERROR, (PCSTR) MSG_CANT_OPEN_INF, e.CurrentString));
  1761. }
  1762. InfCloseInfFile (infHandle);
  1763. infHandle = INVALID_HANDLE_VALUE;
  1764. } while (EnumNextMultiSz (&e));
  1765. }
  1766. }
  1767. __finally {
  1768. FreeText (multiSz);
  1769. }
  1770. }
  1771. InfResetInfStruct (&is);
  1772. if (!result) {
  1773. result = DuplicatePathString (OldScreenSaver, 0);
  1774. }
  1775. return result;
  1776. }
  1777. BOOL
  1778. pIsEmptyStr (
  1779. IN PCTSTR String
  1780. )
  1781. {
  1782. if (String) {
  1783. String = SkipSpace (String);
  1784. if (String) {
  1785. if (*String) {
  1786. return FALSE;
  1787. }
  1788. }
  1789. }
  1790. return TRUE;
  1791. }
  1792. BOOL
  1793. WINAPI
  1794. pConvertScnSaver (
  1795. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  1796. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  1797. IN PCMIG_CONTENT OriginalContent,
  1798. IN PCMIG_CONTENT CurrentContent,
  1799. OUT PMIG_CONTENT NewContent,
  1800. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  1801. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  1802. )
  1803. {
  1804. PDWORD valueType;
  1805. PCTSTR exePath = NULL;
  1806. PTSTR exeName = NULL;
  1807. PCTSTR exeNativeName = NULL;
  1808. PCTSTR newExeName = NULL;
  1809. PCTSTR expExePath = NULL;
  1810. MIG_OBJECTSTRINGHANDLE sourceObjectName = NULL;
  1811. MIG_OBJECTSTRINGHANDLE destObjectName = NULL;
  1812. MIG_CONTENT destContent;
  1813. MIG_OBJECTTYPEID destObjectTypeId;
  1814. BOOL deleted;
  1815. BOOL replaced;
  1816. BOOL migrateSrcReg = FALSE;
  1817. if (!CurrentContent->ContentInFile) {
  1818. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  1819. valueType = (PDWORD)(CurrentContent->Details.DetailsData);
  1820. if (*valueType == REG_SZ) {
  1821. //
  1822. // Extract the source screen saver path from the reg value data
  1823. //
  1824. if (pIsEmptyStr ((PCTSTR) CurrentContent->MemoryContent.ContentBytes)) {
  1825. migrateSrcReg = TRUE;
  1826. } else {
  1827. // first we try to see if the source SCR exists on the destination
  1828. // we have two steps :
  1829. // 1. Filter the source and see if the destination exists
  1830. // 2. Filter the source path, append the source file and see if the destination exists
  1831. exePath = (PCTSTR) (CurrentContent->MemoryContent.ContentBytes);
  1832. if (exePath) {
  1833. expExePath = IsmExpandEnvironmentString (PLATFORM_SOURCE, S_SYSENVVAR_GROUP, exePath, NULL);
  1834. exeName = (PTSTR) FindLastWack (expExePath?expExePath:exePath);
  1835. }
  1836. if (exeName) {
  1837. *exeName++ = 0;
  1838. sourceObjectName = IsmCreateObjectHandle (expExePath?expExePath:exePath, exeName);
  1839. destObjectName = IsmFilterObject(
  1840. MIG_FILE_TYPE | PLATFORM_SOURCE,
  1841. sourceObjectName,
  1842. &destObjectTypeId,
  1843. &deleted,
  1844. &replaced
  1845. );
  1846. migrateSrcReg = !deleted || replaced;
  1847. if (migrateSrcReg) {
  1848. migrateSrcReg = FALSE;
  1849. exeNativeName = IsmGetNativeObjectName (MIG_FILE_TYPE, destObjectName?destObjectName:sourceObjectName);
  1850. if (exeNativeName) {
  1851. NewContent->MemoryContent.ContentSize = SizeOfString (exeNativeName);
  1852. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  1853. StringCopy ((PTSTR)NewContent->MemoryContent.ContentBytes, exeNativeName);
  1854. migrateSrcReg = TRUE;
  1855. IsmReleaseMemory (exeNativeName);
  1856. }
  1857. if (sourceObjectName) {
  1858. IsmDestroyObjectHandle (sourceObjectName);
  1859. sourceObjectName = NULL;
  1860. }
  1861. if (destObjectName) {
  1862. IsmDestroyObjectHandle (destObjectName);
  1863. destObjectName = NULL;
  1864. }
  1865. } else {
  1866. if (sourceObjectName) {
  1867. IsmDestroyObjectHandle (sourceObjectName);
  1868. sourceObjectName = NULL;
  1869. }
  1870. if (destObjectName) {
  1871. IsmDestroyObjectHandle (destObjectName);
  1872. destObjectName = NULL;
  1873. }
  1874. sourceObjectName = IsmCreateObjectHandle (expExePath?expExePath:exePath, NULL);
  1875. destObjectName = IsmFilterObject(
  1876. MIG_FILE_TYPE | PLATFORM_SOURCE,
  1877. sourceObjectName,
  1878. &destObjectTypeId,
  1879. &deleted,
  1880. &replaced
  1881. );
  1882. migrateSrcReg = !deleted || replaced;
  1883. if (migrateSrcReg) {
  1884. migrateSrcReg = FALSE;
  1885. //
  1886. // get the equivalent SCR file from the INF
  1887. //
  1888. newExeName = pFindNewScreenSaver (exeName);
  1889. if (newExeName) {
  1890. exeNativeName = IsmGetNativeObjectName (MIG_FILE_TYPE, destObjectName?destObjectName:sourceObjectName);
  1891. if (destObjectName) {
  1892. IsmDestroyObjectHandle (destObjectName);
  1893. destObjectName = NULL;
  1894. }
  1895. if (exeNativeName) {
  1896. destObjectName = IsmCreateObjectHandle (exeNativeName, newExeName);
  1897. IsmReleaseMemory (exeNativeName);
  1898. if (IsmAcquireObject (MIG_FILE_TYPE | PLATFORM_DESTINATION, destObjectName, &destContent)) {
  1899. IsmReleaseObject (&destContent);
  1900. exeNativeName = IsmGetNativeObjectName (MIG_FILE_TYPE, destObjectName);
  1901. if (exeNativeName) {
  1902. NewContent->MemoryContent.ContentSize = SizeOfString (exeNativeName);
  1903. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  1904. StringCopy ((PTSTR)NewContent->MemoryContent.ContentBytes, exeNativeName);
  1905. migrateSrcReg = TRUE;
  1906. IsmReleaseMemory (exeNativeName);
  1907. }
  1908. }
  1909. }
  1910. FreePathString (newExeName);
  1911. }
  1912. }
  1913. if (sourceObjectName) {
  1914. IsmDestroyObjectHandle (sourceObjectName);
  1915. sourceObjectName = NULL;
  1916. }
  1917. if (destObjectName) {
  1918. IsmDestroyObjectHandle (destObjectName);
  1919. destObjectName = NULL;
  1920. }
  1921. }
  1922. }
  1923. if (expExePath) {
  1924. IsmReleaseMemory (expExePath);
  1925. expExePath = NULL;
  1926. }
  1927. }
  1928. //
  1929. // If we should migrate the entry, then just leave everything
  1930. // alone. If not, then we need to put the destination value in the
  1931. // outbound content.
  1932. //
  1933. if (!migrateSrcReg) {
  1934. MYASSERT (!(SrcObjectTypeId & PLATFORM_DESTINATION));
  1935. destObjectName = IsmFilterObject(
  1936. SrcObjectTypeId | PLATFORM_SOURCE,
  1937. SrcObjectName,
  1938. &destObjectTypeId,
  1939. &deleted,
  1940. NULL
  1941. );
  1942. if (!deleted) {
  1943. destObjectTypeId = SrcObjectTypeId & ~(PLATFORM_MASK);
  1944. destObjectTypeId |= PLATFORM_DESTINATION;
  1945. if (IsmAcquireObject (destObjectTypeId, destObjectName?destObjectName:SrcObjectName, &destContent)) {
  1946. NewContent->MemoryContent.ContentSize = destContent.MemoryContent.ContentSize;
  1947. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  1948. CopyMemory ((PBYTE)NewContent->MemoryContent.ContentBytes, destContent.MemoryContent.ContentBytes, NewContent->MemoryContent.ContentSize);
  1949. IsmReleaseObject (&destContent);
  1950. }
  1951. }
  1952. IsmDestroyObjectHandle (destObjectName);
  1953. INVALID_POINTER (destObjectName);
  1954. }
  1955. }
  1956. }
  1957. return TRUE;
  1958. }
  1959. BOOL
  1960. WINAPI
  1961. pConvertIdentityCount(
  1962. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  1963. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  1964. IN PCMIG_CONTENT OriginalContent,
  1965. IN PCMIG_CONTENT CurrentContent,
  1966. OUT PMIG_CONTENT NewContent,
  1967. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  1968. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  1969. )
  1970. {
  1971. MIG_CONTENT objectContent;
  1972. MIG_OBJECT_ENUM objectEnum;
  1973. MIG_OBJECTSTRINGHANDLE enumPattern;
  1974. MIG_OBJECTSTRINGHANDLE filteredName;
  1975. DWORD value = 0;
  1976. PTSTR node;
  1977. PTSTR leaf;
  1978. MIG_OBJECTTYPEID destObjectTypeId;
  1979. BOOL deleted;
  1980. BOOL replaced;
  1981. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  1982. // Read the current Identity count
  1983. value = pGetDestDwordValue (TEXT("HKCU\\Identities"), TEXT("Identity Ordinal"));
  1984. // Add the number of new source identities
  1985. enumPattern = IsmCreateSimpleObjectPattern (
  1986. TEXT("HKCU\\Identities"),
  1987. TRUE,
  1988. TEXT("Username"),
  1989. FALSE);
  1990. if (IsmEnumFirstSourceObject (&objectEnum, g_RegType, enumPattern)) {
  1991. do {
  1992. if (IsmIsApplyObjectId (objectEnum.ObjectId)) {
  1993. IsmCreateObjectStringsFromHandle (objectEnum.ObjectName, &node, &leaf);
  1994. if (leaf && *leaf) {
  1995. // Check if we created this identity on the dest
  1996. filteredName = IsmFilterObject (g_RegType | PLATFORM_SOURCE,
  1997. objectEnum.ObjectName,
  1998. &destObjectTypeId,
  1999. &deleted,
  2000. &replaced);
  2001. if (filteredName) {
  2002. if (DoesDestRegExist(filteredName, REG_SZ) == FALSE) {
  2003. value++;
  2004. }
  2005. IsmDestroyObjectHandle(filteredName);
  2006. } else if (DoesDestRegExist(objectEnum.ObjectName, REG_SZ) == FALSE) {
  2007. value++;
  2008. }
  2009. }
  2010. IsmDestroyObjectString (node);
  2011. IsmDestroyObjectString (leaf);
  2012. }
  2013. } while (IsmEnumNextObject (&objectEnum));
  2014. }
  2015. IsmDestroyObjectHandle (enumPattern);
  2016. // Update the value with the new Identity count
  2017. pSetDwordValue (NewContent, value);
  2018. }
  2019. return TRUE;
  2020. }
  2021. BOOL
  2022. WINAPI
  2023. pConvertIdentityIndex(
  2024. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2025. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2026. IN PCMIG_CONTENT OriginalContent,
  2027. IN PCMIG_CONTENT CurrentContent,
  2028. OUT PMIG_CONTENT NewContent,
  2029. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2030. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2031. )
  2032. {
  2033. PTSTR node = NULL;
  2034. PTSTR leaf = NULL;
  2035. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  2036. IsmCreateObjectStringsFromHandle (SrcObjectName, &node, &leaf);
  2037. if (node && !StringMatch(node, TEXT("HKCU\\Identities"))) {
  2038. // Only set this identity's index if this is new on the dest
  2039. if (DoesDestRegExist(SrcObjectName, REG_DWORD)) {
  2040. IsmClearApplyOnObject((g_RegType & (~PLATFORM_MASK)) | PLATFORM_SOURCE, SrcObjectName);
  2041. } else {
  2042. pSetDwordValue (NewContent, g_IdentityCount);
  2043. g_IdentityCount++;
  2044. }
  2045. }
  2046. IsmDestroyObjectString(node);
  2047. IsmDestroyObjectString(leaf);
  2048. }
  2049. return TRUE;
  2050. }
  2051. BOOL
  2052. pIsIdentityCollision (
  2053. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2054. IN PCTSTR OriginalUsername
  2055. )
  2056. {
  2057. MIG_CONTENT objectContent;
  2058. MIG_OBJECT_ENUM objectEnum;
  2059. MIG_OBJECTSTRINGHANDLE enumPattern;
  2060. BOOL retval = FALSE;
  2061. // Check if this already exists
  2062. if (HtFindString (g_IdentityDestTable, OriginalUsername)) {
  2063. return TRUE;
  2064. }
  2065. // Check for collisions on Destination
  2066. enumPattern = IsmCreateSimpleObjectPattern (TEXT("HKCU\\Identities"),
  2067. TRUE,
  2068. TEXT("Username"),
  2069. FALSE);
  2070. if (IsmEnumFirstDestinationObject (&objectEnum, g_RegType, enumPattern)) {
  2071. do {
  2072. // don't collide with same identity on destination
  2073. if (!StringIMatch (SrcObjectName, objectEnum.ObjectName)) {
  2074. if (IsmAcquireObject (g_RegType | PLATFORM_DESTINATION, objectEnum.ObjectName, &objectContent)) {
  2075. if (IsValidRegSz(&objectContent)) {
  2076. if (StringIMatch (OriginalUsername, (PCTSTR) objectContent.MemoryContent.ContentBytes)) {
  2077. retval = TRUE;
  2078. IsmReleaseObject (&objectContent);
  2079. IsmAbortObjectEnum (&objectEnum);
  2080. break;
  2081. }
  2082. }
  2083. IsmReleaseObject (&objectContent);
  2084. }
  2085. }
  2086. } while (IsmEnumNextObject (&objectEnum));
  2087. }
  2088. IsmDestroyObjectHandle (enumPattern);
  2089. return retval;
  2090. }
  2091. PTSTR
  2092. pCollideIdentityUsername (
  2093. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2094. IN PCTSTR OriginalUsername
  2095. )
  2096. {
  2097. PTSTR username = NULL;
  2098. PTSTR tmpName;
  2099. PTSTR testName = NULL;
  2100. PTSTR openParen = NULL;
  2101. PTSTR closeParen = NULL;
  2102. PTSTR chr;
  2103. TCHAR buff[20];
  2104. UINT index = 1;
  2105. BOOL replaceOk = TRUE;
  2106. if (pIsIdentityCollision (SrcObjectName, OriginalUsername)) {
  2107. tmpName = DuplicateText (OriginalUsername);
  2108. // Check if name already has a (number) tacked on
  2109. openParen = _tcsrchr (tmpName, TEXT('('));
  2110. closeParen = _tcsrchr (tmpName, TEXT(')'));
  2111. if (closeParen && openParen &&
  2112. closeParen > openParen &&
  2113. closeParen - openParen > 1) {
  2114. // Make sure it's purely numerical
  2115. for (chr = openParen+1; chr < closeParen; chr++) {
  2116. if (!_istdigit (*chr)) {
  2117. replaceOk = FALSE;
  2118. break;
  2119. }
  2120. }
  2121. if (replaceOk == TRUE) {
  2122. if (_stscanf (openParen, TEXT("(%d)"), &index)) {
  2123. *openParen = 0;
  2124. }
  2125. }
  2126. }
  2127. // Loop until we find a non-colliding name
  2128. do {
  2129. IsmReleaseMemory (username);
  2130. index++;
  2131. wsprintf (buff, TEXT("(%d)"), index);
  2132. username = IsmGetMemory (ByteCount (OriginalUsername) + ByteCount (buff) + 1);
  2133. StringCopy (username, tmpName);
  2134. StringCat (username, buff);
  2135. } while (pIsIdentityCollision (SrcObjectName, username));
  2136. FreeText (tmpName);
  2137. // Put the new name in the hash tables
  2138. HtAddStringEx (g_IdentityDestTable, username, &username, FALSE);
  2139. } else {
  2140. username = IsmGetMemory (ByteCount (OriginalUsername) + 1);
  2141. StringCopy (username, OriginalUsername);
  2142. }
  2143. return username;
  2144. }
  2145. BOOL
  2146. WINAPI
  2147. pConvertIdentityGuid (
  2148. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2149. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2150. IN PCMIG_CONTENT OriginalContent,
  2151. IN PCMIG_CONTENT CurrentContent,
  2152. OUT PMIG_CONTENT NewContent,
  2153. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2154. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2155. )
  2156. {
  2157. PTSTR newId;
  2158. if (IsValidRegSz (CurrentContent)) {
  2159. newId = OEGetRemappedId ((PCTSTR)CurrentContent->MemoryContent.ContentBytes);
  2160. if (newId) {
  2161. NewContent->Details.DetailsSize = sizeof(DWORD);
  2162. NewContent->Details.DetailsData = IsmGetMemory (sizeof (DWORD));
  2163. *((PDWORD)NewContent->Details.DetailsData) = REG_SZ;
  2164. NewContent->MemoryContent.ContentSize = ByteCount (newId) + 1;
  2165. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  2166. StringCopy ((PTSTR)NewContent->MemoryContent.ContentBytes, newId);
  2167. FreeText(newId);
  2168. }
  2169. }
  2170. return TRUE;
  2171. }
  2172. BOOL
  2173. WINAPI
  2174. pConvertIdentityUsername (
  2175. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2176. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2177. IN PCMIG_CONTENT OriginalContent,
  2178. IN PCMIG_CONTENT CurrentContent,
  2179. OUT PMIG_CONTENT NewContent,
  2180. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2181. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2182. )
  2183. {
  2184. if (IsValidRegSz (OriginalContent)) {
  2185. // Update the value with a potentially new username
  2186. NewContent->Details.DetailsSize = sizeof(DWORD);
  2187. NewContent->Details.DetailsData = IsmGetMemory (sizeof (DWORD));
  2188. *((PDWORD)NewContent->Details.DetailsData) = REG_SZ;
  2189. NewContent->MemoryContent.ContentBytes = (PBYTE) pCollideIdentityUsername (SrcObjectName, (PCTSTR) OriginalContent->MemoryContent.ContentBytes);
  2190. NewContent->MemoryContent.ContentSize = ByteCount ((PCTSTR) NewContent->MemoryContent.ContentBytes) + 1;
  2191. }
  2192. return TRUE;
  2193. }
  2194. BOOL
  2195. WINAPI
  2196. pConvertSetDwordTrue (
  2197. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2198. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2199. IN PCMIG_CONTENT OriginalContent,
  2200. IN PCMIG_CONTENT CurrentContent,
  2201. OUT PMIG_CONTENT NewContent,
  2202. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2203. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2204. )
  2205. {
  2206. if (IsValidRegType (OriginalContent, REG_DWORD)) {
  2207. pSetDwordValue (NewContent, 1);
  2208. }
  2209. return TRUE;
  2210. }
  2211. BOOL
  2212. WINAPI
  2213. pConvertSetDwordFalse (
  2214. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2215. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2216. IN PCMIG_CONTENT OriginalContent,
  2217. IN PCMIG_CONTENT CurrentContent,
  2218. OUT PMIG_CONTENT NewContent,
  2219. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2220. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2221. )
  2222. {
  2223. if (IsValidRegType (OriginalContent, REG_DWORD)) {
  2224. pSetDwordValue (NewContent, 0);
  2225. }
  2226. return TRUE;
  2227. }
  2228. BOOL
  2229. WINAPI
  2230. pConvertPSTBlob (
  2231. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2232. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2233. IN PCMIG_CONTENT OriginalContent,
  2234. IN PCMIG_CONTENT CurrentContent,
  2235. OUT PMIG_CONTENT NewContent,
  2236. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2237. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2238. )
  2239. {
  2240. PCTSTR originalStr = NULL;
  2241. PCSTR finalStr = NULL;
  2242. PTSTR joinedStr = NULL;
  2243. PTSTR node = NULL;
  2244. PTSTR leaf = NULL;
  2245. MIG_OBJECTSTRINGHANDLE filteredName = NULL;
  2246. MIG_OBJECTSTRINGHANDLE srcName = NULL;
  2247. MIG_OBJECTTYPEID destObjectTypeId;
  2248. BOOL deleted;
  2249. BOOL replaced;
  2250. TCHAR *p = NULL;
  2251. char *ptr;
  2252. HALF_PTR oldSize;
  2253. PCBYTE blob;
  2254. if (IsValidRegType(OriginalContent, REG_BINARY)) {
  2255. // Find the NULL before the PST filename
  2256. blob = OriginalContent->MemoryContent.ContentBytes;
  2257. ptr = (char *)(ULONG_PTR)((PBYTE)blob + OriginalContent->MemoryContent.ContentSize - 2);
  2258. while ((ptr > blob) && (*ptr != 0)) {
  2259. ptr--;
  2260. }
  2261. if (ptr <= blob) {
  2262. // couldn't find it.. this isn't a PSTBlob
  2263. return TRUE;
  2264. }
  2265. ptr++;
  2266. oldSize = (HALF_PTR)(ptr - blob);
  2267. #ifdef UNICODE
  2268. originalStr = ConvertAtoW(ptr);
  2269. #else
  2270. originalStr = DuplicateText(ptr);
  2271. #endif
  2272. if (originalStr) {
  2273. p = (PTSTR)FindLastWack(originalStr);
  2274. if (p) {
  2275. *p = 0;
  2276. srcName = IsmCreateObjectHandle (originalStr, p+1);
  2277. if (srcName) {
  2278. filteredName = IsmFilterObject(MIG_FILE_TYPE | PLATFORM_SOURCE,
  2279. srcName,
  2280. &destObjectTypeId,
  2281. &deleted,
  2282. &replaced);
  2283. if (filteredName) {
  2284. IsmCreateObjectStringsFromHandle (filteredName, &node, &leaf);
  2285. IsmDestroyObjectHandle (filteredName);
  2286. joinedStr = JoinPaths (node, leaf);
  2287. if (joinedStr) {
  2288. #ifdef UNICODE
  2289. finalStr = ConvertWtoA(joinedStr);
  2290. #else
  2291. finalStr = DuplicateText(joinedStr);
  2292. #endif
  2293. FreePathString (joinedStr);
  2294. }
  2295. IsmDestroyObjectString (node);
  2296. IsmDestroyObjectString (leaf);
  2297. }
  2298. IsmDestroyObjectHandle (srcName);
  2299. }
  2300. }
  2301. #ifdef UNICODE
  2302. FreeConvertedStr (originalStr);
  2303. #else
  2304. FreeText(originalStr);
  2305. #endif
  2306. }
  2307. if (finalStr) {
  2308. NewContent->Details.DetailsSize = sizeof(DWORD);
  2309. NewContent->Details.DetailsData = IsmGetMemory (sizeof (DWORD));
  2310. *((PDWORD)NewContent->Details.DetailsData) = REG_BINARY;
  2311. NewContent->MemoryContent.ContentSize = oldSize + ByteCountA(finalStr) + 1;
  2312. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  2313. CopyMemory ((PVOID)NewContent->MemoryContent.ContentBytes,
  2314. OriginalContent->MemoryContent.ContentBytes,
  2315. oldSize);
  2316. CopyMemory ((PVOID)(NewContent->MemoryContent.ContentBytes + oldSize),
  2317. finalStr,
  2318. NewContent->MemoryContent.ContentSize);
  2319. #ifdef UNICODE
  2320. FreeConvertedStr (finalStr);
  2321. #else
  2322. FreeText(finalStr);
  2323. #endif
  2324. }
  2325. }
  2326. return TRUE;
  2327. }
  2328. DWORD
  2329. pCountSourceSubKeys (
  2330. IN PTSTR RootKey
  2331. )
  2332. {
  2333. MIG_OBJECT_ENUM objectEnum;
  2334. MIG_OBJECTSTRINGHANDLE enumPattern;
  2335. DWORD value = 0;
  2336. enumPattern = IsmCreateSimpleObjectPattern (RootKey, TRUE, NULL, FALSE);
  2337. if (IsmEnumFirstSourceObject (&objectEnum, g_RegType, enumPattern)) {
  2338. do {
  2339. if (IsmIsApplyObjectId (objectEnum.ObjectId)) {
  2340. value++;
  2341. }
  2342. } while (IsmEnumNextObject (&objectEnum));
  2343. }
  2344. IsmDestroyObjectHandle (enumPattern);
  2345. // We enumerated the root key too, which we don't want to count
  2346. value--;
  2347. return value;
  2348. }
  2349. BOOL
  2350. WINAPI
  2351. pConvertIAMAcctName (
  2352. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2353. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2354. IN PCMIG_CONTENT OriginalContent,
  2355. IN PCMIG_CONTENT CurrentContent,
  2356. OUT PMIG_CONTENT NewContent,
  2357. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2358. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2359. )
  2360. {
  2361. MIG_OBJECTSTRINGHANDLE filteredName = NULL;
  2362. MIG_CONTENT objectContent;
  2363. PTSTR subKey;
  2364. DWORD value = 1;
  2365. PTSTR node;
  2366. PTSTR leaf;
  2367. MIG_OBJECTTYPEID destObjectTypeId;
  2368. BOOL deleted;
  2369. BOOL replaced;
  2370. // Only increment the base account count
  2371. if (StrStrI(SrcObjectName, TEXT("\\Accounts\\"))) {
  2372. return TRUE;
  2373. }
  2374. // Get the destination value where we are writing to
  2375. filteredName = IsmFilterObject(g_RegType | PLATFORM_SOURCE,
  2376. SrcObjectName,
  2377. &destObjectTypeId,
  2378. &deleted,
  2379. &replaced);
  2380. if (IsmAcquireObject (g_RegType | PLATFORM_DESTINATION,
  2381. filteredName ? filteredName : SrcObjectName,
  2382. &objectContent)) {
  2383. if (IsValidRegType(&objectContent, REG_DWORD)) {
  2384. value = *objectContent.MemoryContent.ContentBytes;
  2385. if (value == 0) {
  2386. value = 1;
  2387. }
  2388. }
  2389. IsmReleaseObject (&objectContent);
  2390. }
  2391. if (filteredName) {
  2392. IsmDestroyObjectHandle (filteredName);
  2393. }
  2394. // Now increment the value by the number of accounts we are writing from the source
  2395. IsmCreateObjectStringsFromHandle (SrcObjectName, &node, &leaf);
  2396. if (node) {
  2397. subKey = JoinText(node, TEXT("\\Accounts"));
  2398. if (subKey) {
  2399. value += pCountSourceSubKeys (subKey);
  2400. pSetDwordValue (NewContent, value);
  2401. FreeText(subKey);
  2402. }
  2403. IsmDestroyObjectString(node);
  2404. }
  2405. if (leaf) {
  2406. IsmDestroyObjectString(leaf);
  2407. }
  2408. return TRUE;
  2409. }
  2410. BOOL
  2411. WINAPI
  2412. pConvertOE5IAMAcctName (
  2413. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2414. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2415. IN PCMIG_CONTENT OriginalContent,
  2416. IN PCMIG_CONTENT CurrentContent,
  2417. OUT PMIG_CONTENT NewContent,
  2418. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2419. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2420. )
  2421. {
  2422. DWORD value = 1;
  2423. PTSTR srcIdentity;
  2424. PTSTR tmpText;
  2425. PTSTR tmpNode;
  2426. PTSTR newIdentity = NULL;
  2427. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  2428. // Starting value is always in this location
  2429. // Extract the source's associated ID.
  2430. srcIdentity = OEGetAssociatedId (PLATFORM_SOURCE);
  2431. if (srcIdentity) {
  2432. newIdentity = OEGetRemappedId(srcIdentity);
  2433. if (newIdentity) {
  2434. if (OEIsIdentityAssociated(newIdentity)) {
  2435. // Migrating IAM to IAM
  2436. value = pGetDestDwordValue (TEXT("HKCU\\Software\\Microsoft\\Internet Account Manager"),
  2437. TEXT("Account Name"));
  2438. if (value == 0) {
  2439. value = 1;
  2440. }
  2441. } else {
  2442. // Migrating IAM to ID
  2443. tmpText = JoinText(TEXT("HKCU\\Identities\\"),
  2444. newIdentity);
  2445. if (tmpText) {
  2446. tmpNode = JoinText(tmpText,
  2447. TEXT("\\Software\\Microsoft\\Internet Account Manager"));
  2448. if (tmpNode) {
  2449. value = pGetDestDwordValue (tmpNode, TEXT("Account Name"));
  2450. if (value == 0) {
  2451. value = 1;
  2452. }
  2453. FreeText(tmpNode);
  2454. }
  2455. FreeText(tmpText);
  2456. }
  2457. }
  2458. FreeText(newIdentity);
  2459. }
  2460. FreeText(srcIdentity);
  2461. }
  2462. value += pCountSourceSubKeys (TEXT("HKCU\\Software\\Microsoft\\Internet Account Manager\\Accounts"));
  2463. pSetDwordValue (NewContent, value);
  2464. }
  2465. return TRUE;
  2466. }
  2467. BOOL
  2468. WINAPI
  2469. pConvertOE4IAMAcctName (
  2470. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2471. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2472. IN PCMIG_CONTENT OriginalContent,
  2473. IN PCMIG_CONTENT CurrentContent,
  2474. OUT PMIG_CONTENT NewContent,
  2475. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2476. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2477. )
  2478. {
  2479. PTSTR tmpName = NULL;
  2480. PTSTR defaultId = NULL;
  2481. DWORD value = 0;
  2482. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  2483. // Check if destination has Default ID. If so, we're going to merge into that Identity.
  2484. defaultId = OEGetDefaultId(PLATFORM_DESTINATION);
  2485. if (defaultId) {
  2486. tmpName = AllocText (61 + CharCount(defaultId));
  2487. StringCopy (tmpName, TEXT("HKCU\\Identities\\")); // 16
  2488. StringCat (tmpName, defaultId);
  2489. StringCat (tmpName, TEXT("\\Software\\Microsoft\\Internet Account Manager")); // 44
  2490. FreeText(defaultId);
  2491. }
  2492. // First try to get the AccountName from the identity key
  2493. if (tmpName != NULL) {
  2494. value = pGetDestDwordValue (tmpName, TEXT("Account Name"));
  2495. }
  2496. // If not there, look in the common key
  2497. if (tmpName == NULL || value == 0) {
  2498. value = pGetDestDwordValue (TEXT("HKCU\\Software\\Microsoft\\Internet Account Manager"),
  2499. TEXT("Account Name"));
  2500. }
  2501. if (value == 0) {
  2502. value = 1;
  2503. }
  2504. value += pCountSourceSubKeys (TEXT("HKCU\\Software\\Microsoft\\Internet Account Manager\\Accounts"));
  2505. pSetDwordValue (NewContent, value);
  2506. }
  2507. if (tmpName != NULL) {
  2508. FreeText (tmpName);
  2509. }
  2510. return TRUE;
  2511. }
  2512. BOOL
  2513. WINAPI
  2514. pConvertOMIAccountName (
  2515. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2516. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2517. IN PCMIG_CONTENT OriginalContent,
  2518. IN PCMIG_CONTENT CurrentContent,
  2519. OUT PMIG_CONTENT NewContent,
  2520. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2521. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2522. )
  2523. {
  2524. MIG_CONTENT objectContent;
  2525. DWORD value;
  2526. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  2527. value = pGetDestDwordValue (TEXT("HKCU\\Software\\Microsoft\\Office\\Outlook\\OMI Account Manager"),
  2528. TEXT("Account Name"));
  2529. value += pCountSourceSubKeys (TEXT("HKCU\\Software\\Microsoft\\Office\\Outlook\\OMI Account Manager\\Accounts"));
  2530. pSetDwordValue (NewContent, value);
  2531. }
  2532. return TRUE;
  2533. }
  2534. BOOL
  2535. pConvertLangId (
  2536. IN PCMIG_CONTENT CurrentContent,
  2537. OUT PMIG_CONTENT NewContent,
  2538. IN PCTSTR OfficeApp
  2539. )
  2540. {
  2541. MIG_CONTENT objectContent;
  2542. MIG_OBJECT_ENUM objectEnum;
  2543. MIG_OBJECTSTRINGHANDLE enumPattern;
  2544. PTSTR node;
  2545. PTSTR leaf;
  2546. DWORD value;
  2547. DWORD result = 0;
  2548. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  2549. enumPattern = IsmCreateSimpleObjectPattern (
  2550. TEXT("HKLM\\Software\\Microsoft\\MS Setup (ACME)\\Table Files"),
  2551. TRUE,
  2552. NULL,
  2553. TRUE);
  2554. if (IsmEnumFirstSourceObject (&objectEnum, g_RegType, enumPattern)) {
  2555. do {
  2556. IsmCreateObjectStringsFromHandle (objectEnum.ObjectName, &node, &leaf);
  2557. if (leaf && *leaf) {
  2558. if (_tcsnicmp(leaf, TEXT("MS Office"), 9) == 0 ||
  2559. _tcsnicmp(leaf, OfficeApp, CharCount(OfficeApp)) == 0) {
  2560. result = _stscanf(leaf, TEXT("%*[^\\(](%d)"), &value);
  2561. // In Office installs, the Outlook entry may not have the (1033) piece,
  2562. // so we MUST check the result
  2563. }
  2564. }
  2565. IsmDestroyObjectString (node);
  2566. IsmDestroyObjectString (leaf);
  2567. if (result) {
  2568. IsmAbortObjectEnum (&objectEnum);
  2569. break;
  2570. }
  2571. } while (IsmEnumNextObject (&objectEnum));
  2572. }
  2573. IsmDestroyObjectHandle (enumPattern);
  2574. if (result) {
  2575. pSetDwordValue (NewContent, value);
  2576. }
  2577. }
  2578. return TRUE;
  2579. }
  2580. BOOL
  2581. WINAPI
  2582. pConvertOfficeLangId (
  2583. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2584. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2585. IN PCMIG_CONTENT OriginalContent,
  2586. IN PCMIG_CONTENT CurrentContent,
  2587. OUT PMIG_CONTENT NewContent,
  2588. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2589. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2590. )
  2591. {
  2592. pConvertLangId(CurrentContent, NewContent, TEXT("MS Office"));
  2593. return TRUE;
  2594. }
  2595. BOOL
  2596. WINAPI
  2597. pConvertOutlookLangId (
  2598. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2599. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2600. IN PCMIG_CONTENT OriginalContent,
  2601. IN PCMIG_CONTENT CurrentContent,
  2602. OUT PMIG_CONTENT NewContent,
  2603. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2604. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2605. )
  2606. {
  2607. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft Outlook"));
  2608. return TRUE;
  2609. }
  2610. BOOL
  2611. WINAPI
  2612. pConvertAccessLangId (
  2613. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2614. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2615. IN PCMIG_CONTENT OriginalContent,
  2616. IN PCMIG_CONTENT CurrentContent,
  2617. OUT PMIG_CONTENT NewContent,
  2618. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2619. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2620. )
  2621. {
  2622. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft Access"));
  2623. return TRUE;
  2624. }
  2625. BOOL
  2626. WINAPI
  2627. pConvertExcelLangId (
  2628. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2629. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2630. IN PCMIG_CONTENT OriginalContent,
  2631. IN PCMIG_CONTENT CurrentContent,
  2632. OUT PMIG_CONTENT NewContent,
  2633. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2634. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2635. )
  2636. {
  2637. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft Excel"));
  2638. return TRUE;
  2639. }
  2640. BOOL
  2641. WINAPI
  2642. pConvertFrontPageLangId (
  2643. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2644. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2645. IN PCMIG_CONTENT OriginalContent,
  2646. IN PCMIG_CONTENT CurrentContent,
  2647. OUT PMIG_CONTENT NewContent,
  2648. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2649. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2650. )
  2651. {
  2652. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft FrontPage"));
  2653. return TRUE;
  2654. }
  2655. BOOL
  2656. WINAPI
  2657. pConvertPowerPointLangId (
  2658. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2659. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2660. IN PCMIG_CONTENT OriginalContent,
  2661. IN PCMIG_CONTENT CurrentContent,
  2662. OUT PMIG_CONTENT NewContent,
  2663. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2664. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2665. )
  2666. {
  2667. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft PowerPoint"));
  2668. return TRUE;
  2669. }
  2670. BOOL
  2671. WINAPI
  2672. pConvertPublisherLangId (
  2673. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2674. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2675. IN PCMIG_CONTENT OriginalContent,
  2676. IN PCMIG_CONTENT CurrentContent,
  2677. OUT PMIG_CONTENT NewContent,
  2678. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2679. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2680. )
  2681. {
  2682. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft Publisher"));
  2683. return TRUE;
  2684. }
  2685. BOOL
  2686. WINAPI
  2687. pConvertWordLangId (
  2688. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2689. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2690. IN PCMIG_CONTENT OriginalContent,
  2691. IN PCMIG_CONTENT CurrentContent,
  2692. OUT PMIG_CONTENT NewContent,
  2693. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2694. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2695. )
  2696. {
  2697. pConvertLangId(CurrentContent, NewContent, TEXT("Microsoft Word"));
  2698. return TRUE;
  2699. }
  2700. BOOL
  2701. WINAPI
  2702. pConvertOffice2000LangId (
  2703. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2704. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2705. IN PCMIG_CONTENT OriginalContent,
  2706. IN PCMIG_CONTENT CurrentContent,
  2707. OUT PMIG_CONTENT NewContent,
  2708. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2709. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2710. )
  2711. {
  2712. DWORD value;
  2713. if (IsValidRegType (CurrentContent, REG_DWORD)) {
  2714. value = pGetSrcDwordValue (TEXT("HKCU\\Software\\Microsoft\\Office\\9.0\\Common\\LanguageResources"),
  2715. TEXT("EXEMode"));
  2716. pSetDwordValue (NewContent, value);
  2717. }
  2718. return TRUE;
  2719. }
  2720. BOOL
  2721. WINAPI
  2722. pMigrateSoundSysTray (
  2723. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2724. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2725. IN PCMIG_CONTENT OriginalContent,
  2726. IN PCMIG_CONTENT CurrentContent,
  2727. OUT PMIG_CONTENT NewContent,
  2728. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2729. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2730. )
  2731. {
  2732. MIG_OBJECTTYPEID newObjectTypeId;
  2733. MIG_OBJECTSTRINGHANDLE newObjectName;
  2734. PDWORD valueType1, valueType2, valueType;
  2735. BOOL deleted = TRUE, replaced = FALSE;
  2736. MIG_CONTENT destContent;
  2737. if (!CurrentContent->ContentInFile) {
  2738. MYASSERT (OriginalContent->Details.DetailsSize == sizeof (DWORD));
  2739. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  2740. valueType1 = (PDWORD)(OriginalContent->Details.DetailsData);
  2741. valueType2 = (PDWORD)(CurrentContent->Details.DetailsData);
  2742. if ((*valueType1 == REG_DWORD) &&
  2743. (*valueType2 == REG_DWORD)
  2744. ) {
  2745. // if the object was not changed yet we need to read the destination object and then
  2746. // just move the "Show volume control" bit.
  2747. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  2748. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  2749. ) {
  2750. // find out the destination object and read it
  2751. newObjectName = IsmFilterObject (
  2752. SrcObjectTypeId,
  2753. SrcObjectName,
  2754. &newObjectTypeId,
  2755. &deleted,
  2756. &replaced
  2757. );
  2758. if ((!deleted || replaced) &&
  2759. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  2760. ) {
  2761. if (IsmAcquireObject (
  2762. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  2763. newObjectName?newObjectName:SrcObjectName,
  2764. &destContent
  2765. )) {
  2766. if (IsValidRegType(&destContent, REG_DWORD)) {
  2767. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2768. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2769. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)destContent.MemoryContent.ContentBytes);
  2770. if (*((PDWORD)OriginalContent->MemoryContent.ContentBytes) & 0x00000004) {
  2771. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= 0x00000004;
  2772. }
  2773. }
  2774. IsmReleaseObject (&destContent);
  2775. }
  2776. if (newObjectName) {
  2777. IsmDestroyObjectHandle (newObjectName);
  2778. newObjectName = NULL;
  2779. }
  2780. }
  2781. } else {
  2782. // just transfer the "Show volume control" bit.
  2783. if (*((PDWORD)OriginalContent->MemoryContent.ContentBytes) & 0x00000004) {
  2784. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2785. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2786. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)CurrentContent->MemoryContent.ContentBytes) | 0x00000004;
  2787. }
  2788. }
  2789. }
  2790. }
  2791. return TRUE;
  2792. }
  2793. BOOL
  2794. WINAPI
  2795. pMigrateAppearanceUPM (
  2796. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2797. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2798. IN PCMIG_CONTENT OriginalContent,
  2799. IN PCMIG_CONTENT CurrentContent,
  2800. OUT PMIG_CONTENT NewContent,
  2801. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2802. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2803. )
  2804. {
  2805. MIG_OBJECTTYPEID newObjectTypeId;
  2806. MIG_OBJECTSTRINGHANDLE newObjectName;
  2807. BOOL deleted = TRUE, replaced = FALSE;
  2808. MIG_CONTENT destContent;
  2809. DWORD tempValue;
  2810. if (IsValidRegType (OriginalContent, REG_BINARY) &&
  2811. IsValidRegType (CurrentContent, REG_BINARY)) {
  2812. // if the object was not changed yet we need to read the destination object and then
  2813. // just move the appropriate bits.
  2814. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  2815. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  2816. ) {
  2817. // find out the destination object and read it
  2818. newObjectName = IsmFilterObject (
  2819. SrcObjectTypeId,
  2820. SrcObjectName,
  2821. &newObjectTypeId,
  2822. &deleted,
  2823. &replaced
  2824. );
  2825. if ((!deleted || replaced) &&
  2826. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  2827. ) {
  2828. if (IsmAcquireObject (
  2829. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  2830. newObjectName?newObjectName:SrcObjectName,
  2831. &destContent
  2832. )) {
  2833. if (IsValidRegType(&destContent, REG_BINARY)) {
  2834. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2835. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2836. *((PDWORD)NewContent->MemoryContent.ContentBytes) = (*((PDWORD)destContent.MemoryContent.ContentBytes)) &~ DISPLAY_BITMASK;
  2837. tempValue = ((*((PDWORD)OriginalContent->MemoryContent.ContentBytes)) & DISPLAY_BITMASK);
  2838. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= tempValue;
  2839. }
  2840. IsmReleaseObject (&destContent);
  2841. }
  2842. if (newObjectName) {
  2843. IsmDestroyObjectHandle (newObjectName);
  2844. newObjectName = NULL;
  2845. }
  2846. }
  2847. } else {
  2848. // just transfer the appropriate bits.
  2849. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2850. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2851. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)CurrentContent->MemoryContent.ContentBytes) &~ DISPLAY_BITMASK;
  2852. tempValue = ((*((PDWORD)OriginalContent->MemoryContent.ContentBytes)) & DISPLAY_BITMASK);
  2853. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= tempValue;
  2854. }
  2855. }
  2856. return TRUE;
  2857. }
  2858. BOOL
  2859. WINAPI
  2860. pMigrateMouseUPM (
  2861. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2862. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2863. IN PCMIG_CONTENT OriginalContent,
  2864. IN PCMIG_CONTENT CurrentContent,
  2865. OUT PMIG_CONTENT NewContent,
  2866. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2867. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2868. )
  2869. {
  2870. MIG_OBJECTTYPEID newObjectTypeId;
  2871. MIG_OBJECTSTRINGHANDLE newObjectName;
  2872. BOOL deleted = TRUE, replaced = FALSE;
  2873. MIG_CONTENT destContent;
  2874. DWORD tempValue;
  2875. if (IsValidRegType (OriginalContent, REG_BINARY) &&
  2876. IsValidRegType (CurrentContent, REG_BINARY)) {
  2877. // if the object was not changed yet we need to read the destination object and then
  2878. // just move the appropriate bits.
  2879. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  2880. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  2881. ) {
  2882. // find out the destination object and read it
  2883. newObjectName = IsmFilterObject (
  2884. SrcObjectTypeId,
  2885. SrcObjectName,
  2886. &newObjectTypeId,
  2887. &deleted,
  2888. &replaced
  2889. );
  2890. if ((!deleted || replaced) &&
  2891. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  2892. ) {
  2893. if (IsmAcquireObject (
  2894. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  2895. newObjectName?newObjectName:SrcObjectName,
  2896. &destContent
  2897. )) {
  2898. if (IsValidRegType (&destContent, REG_BINARY)) {
  2899. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2900. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2901. *((PDWORD)NewContent->MemoryContent.ContentBytes) = (*((PDWORD)destContent.MemoryContent.ContentBytes)) &~ MOUSE_BITMASK;
  2902. tempValue = ((*((PDWORD)OriginalContent->MemoryContent.ContentBytes)) & MOUSE_BITMASK);
  2903. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= tempValue;
  2904. }
  2905. IsmReleaseObject (&destContent);
  2906. }
  2907. if (newObjectName) {
  2908. IsmDestroyObjectHandle (newObjectName);
  2909. newObjectName = NULL;
  2910. }
  2911. }
  2912. } else {
  2913. // just transfer the appropriate bits.
  2914. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2915. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2916. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)CurrentContent->MemoryContent.ContentBytes) &~ MOUSE_BITMASK;
  2917. tempValue = ((*((PDWORD)OriginalContent->MemoryContent.ContentBytes)) & MOUSE_BITMASK);
  2918. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= tempValue;
  2919. }
  2920. }
  2921. return TRUE;
  2922. }
  2923. BOOL
  2924. WINAPI
  2925. pMigrateOfflineSysTray (
  2926. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  2927. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  2928. IN PCMIG_CONTENT OriginalContent,
  2929. IN PCMIG_CONTENT CurrentContent,
  2930. OUT PMIG_CONTENT NewContent,
  2931. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  2932. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  2933. )
  2934. {
  2935. MIG_OBJECTTYPEID newObjectTypeId;
  2936. MIG_OBJECTSTRINGHANDLE newObjectName;
  2937. PDWORD valueType1, valueType2, valueType;
  2938. BOOL deleted = TRUE, replaced = FALSE;
  2939. MIG_CONTENT destContent;
  2940. if (!CurrentContent->ContentInFile) {
  2941. MYASSERT (OriginalContent->Details.DetailsSize == sizeof (DWORD));
  2942. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  2943. valueType1 = (PDWORD)(OriginalContent->Details.DetailsData);
  2944. valueType2 = (PDWORD)(CurrentContent->Details.DetailsData);
  2945. if ((*valueType1 == REG_DWORD) &&
  2946. (*valueType2 == REG_DWORD)
  2947. ) {
  2948. // if the object was not changed yet we need to read the destination object and then
  2949. // just move the "Enable offline folders" bit.
  2950. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  2951. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  2952. ) {
  2953. // find out the destination object and read it
  2954. newObjectName = IsmFilterObject (
  2955. SrcObjectTypeId,
  2956. SrcObjectName,
  2957. &newObjectTypeId,
  2958. &deleted,
  2959. &replaced
  2960. );
  2961. if ((!deleted || replaced) &&
  2962. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  2963. ) {
  2964. if (IsmAcquireObject (
  2965. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  2966. newObjectName?newObjectName:SrcObjectName,
  2967. &destContent
  2968. )) {
  2969. if (IsValidRegType (&destContent, REG_DWORD)) {
  2970. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2971. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2972. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)destContent.MemoryContent.ContentBytes);
  2973. if (*((PDWORD)OriginalContent->MemoryContent.ContentBytes) & 0x00000008) {
  2974. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= 0x00000008;
  2975. } else {
  2976. *((PDWORD)NewContent->MemoryContent.ContentBytes) &= (~0x00000008);
  2977. }
  2978. }
  2979. IsmReleaseObject (&destContent);
  2980. }
  2981. if (newObjectName) {
  2982. IsmDestroyObjectHandle (newObjectName);
  2983. newObjectName = NULL;
  2984. }
  2985. }
  2986. } else {
  2987. // just transfer the "Enable offline folders" bit.
  2988. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  2989. NewContent->MemoryContent.ContentBytes = IsmGetMemory (sizeof (DWORD));
  2990. if (*((PDWORD)OriginalContent->MemoryContent.ContentBytes) & 0x00000008) {
  2991. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)CurrentContent->MemoryContent.ContentBytes) | 0x00000008;
  2992. } else {
  2993. *((PDWORD)NewContent->MemoryContent.ContentBytes) = *((PDWORD)CurrentContent->MemoryContent.ContentBytes) & (~0x00000008);
  2994. }
  2995. }
  2996. }
  2997. }
  2998. return TRUE;
  2999. }
  3000. BOOL
  3001. WINAPI
  3002. pMigrateTaskBarSS (
  3003. IN BOOL Force,
  3004. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3005. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3006. IN PCMIG_CONTENT OriginalContent,
  3007. IN PCMIG_CONTENT CurrentContent,
  3008. OUT PMIG_CONTENT NewContent,
  3009. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3010. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3011. )
  3012. {
  3013. MIG_OBJECTTYPEID newObjectTypeId;
  3014. MIG_OBJECTSTRINGHANDLE newObjectName;
  3015. PDWORD valueType1, valueType2, valueType;
  3016. BOOL deleted = TRUE, replaced = FALSE;
  3017. MIG_CONTENT destContent;
  3018. BYTE defShellState [sizeof (REGSHELLSTATE)] =
  3019. {0x24, 0x00, 0x00, 0x00,
  3020. 0x20, 0x28, 0x00, 0x00,
  3021. 0x00, 0x00, 0x00, 0x00,
  3022. 0x00, 0x00, 0x00, 0x00,
  3023. 0x00, 0x00, 0x00, 0x00,
  3024. 0x01, 0x00, 0x00, 0x00,
  3025. 0x0D, 0x00, 0x00, 0x00,
  3026. 0x00, 0x00, 0x00, 0x00,
  3027. 0x02, 0x00, 0x00, 0x00};
  3028. PREGSHELLSTATE shellState1 = NULL, shellState2 = NULL;
  3029. if (!CurrentContent->ContentInFile) {
  3030. MYASSERT (OriginalContent->Details.DetailsSize == sizeof (DWORD));
  3031. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  3032. valueType1 = (PDWORD)(OriginalContent->Details.DetailsData);
  3033. valueType2 = (PDWORD)(CurrentContent->Details.DetailsData);
  3034. if ((*valueType1 == REG_BINARY) &&
  3035. (*valueType2 == REG_BINARY)
  3036. ) {
  3037. // if the object was not changed yet we need to read the destination object and then
  3038. // just transfer the "fStartPanelOn" setting if present.
  3039. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  3040. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  3041. ) {
  3042. // find out the destination object and read it
  3043. newObjectName = IsmFilterObject (
  3044. SrcObjectTypeId,
  3045. SrcObjectName,
  3046. &newObjectTypeId,
  3047. &deleted,
  3048. &replaced
  3049. );
  3050. if ((!deleted || replaced) &&
  3051. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  3052. ) {
  3053. if (IsmAcquireObject (
  3054. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  3055. newObjectName?newObjectName:SrcObjectName,
  3056. &destContent
  3057. )) {
  3058. if ((IsValidRegType (&destContent, REG_BINARY)) &&
  3059. (destContent.MemoryContent.ContentSize == sizeof (REGSHELLSTATE))
  3060. ) {
  3061. NewContent->MemoryContent.ContentSize = sizeof (REGSHELLSTATE);
  3062. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3063. CopyMemory (
  3064. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3065. destContent.MemoryContent.ContentBytes,
  3066. NewContent->MemoryContent.ContentSize
  3067. );
  3068. if (Force) {
  3069. shellState2 = (REGSHELLSTATE *)NewContent->MemoryContent.ContentBytes;
  3070. shellState2->ss.fStartPanelOn = FALSE;
  3071. } else {
  3072. if (OriginalContent->MemoryContent.ContentSize == sizeof (REGSHELLSTATE)) {
  3073. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3074. if (shellState1->ss.version == SHELLSTATEVERSION) {
  3075. shellState2 = (PREGSHELLSTATE)NewContent->MemoryContent.ContentBytes;
  3076. shellState2->ss.fStartPanelOn = shellState1->ss.fStartPanelOn;
  3077. }
  3078. }
  3079. }
  3080. }
  3081. IsmReleaseObject (&destContent);
  3082. } else {
  3083. if (Force) {
  3084. NewContent->MemoryContent.ContentSize = sizeof (REGSHELLSTATE);
  3085. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3086. CopyMemory (
  3087. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3088. defShellState,
  3089. NewContent->MemoryContent.ContentSize
  3090. );
  3091. shellState2 = (REGSHELLSTATE *)NewContent->MemoryContent.ContentBytes;
  3092. shellState2->ss.fStartPanelOn = FALSE;
  3093. }
  3094. }
  3095. if (newObjectName) {
  3096. IsmDestroyObjectHandle (newObjectName);
  3097. newObjectName = NULL;
  3098. }
  3099. }
  3100. } else {
  3101. if (Force) {
  3102. NewContent->MemoryContent.ContentSize = sizeof (REGSHELLSTATE);
  3103. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3104. CopyMemory (
  3105. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3106. CurrentContent->MemoryContent.ContentBytes,
  3107. NewContent->MemoryContent.ContentSize
  3108. );
  3109. shellState2 = (REGSHELLSTATE *)NewContent->MemoryContent.ContentBytes;
  3110. shellState2->ss.fStartPanelOn = FALSE;
  3111. } else {
  3112. // just transfer the "fStartPanelOn" setting if present.
  3113. if ((OriginalContent->MemoryContent.ContentSize == sizeof (REGSHELLSTATE)) &&
  3114. (CurrentContent->MemoryContent.ContentSize == sizeof (REGSHELLSTATE))
  3115. ) {
  3116. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3117. if (shellState1->ss.version == SHELLSTATEVERSION) {
  3118. NewContent->MemoryContent.ContentSize = sizeof (REGSHELLSTATE);
  3119. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3120. CopyMemory (
  3121. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3122. CurrentContent->MemoryContent.ContentBytes,
  3123. NewContent->MemoryContent.ContentSize
  3124. );
  3125. shellState2 = (PREGSHELLSTATE)NewContent->MemoryContent.ContentBytes;
  3126. shellState2->ss.fStartPanelOn = shellState1->ss.fStartPanelOn;
  3127. }
  3128. }
  3129. }
  3130. }
  3131. }
  3132. }
  3133. return TRUE;
  3134. }
  3135. BOOL
  3136. WINAPI
  3137. pMigrateTaskBarSSPreserve (
  3138. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3139. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3140. IN PCMIG_CONTENT OriginalContent,
  3141. IN PCMIG_CONTENT CurrentContent,
  3142. OUT PMIG_CONTENT NewContent,
  3143. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3144. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3145. )
  3146. {
  3147. return pMigrateTaskBarSS (
  3148. FALSE,
  3149. SrcObjectTypeId,
  3150. SrcObjectName,
  3151. OriginalContent,
  3152. CurrentContent,
  3153. NewContent,
  3154. SourceOperationData,
  3155. DestinationOperationData
  3156. );
  3157. }
  3158. BOOL
  3159. WINAPI
  3160. pMigrateTaskBarSSForce (
  3161. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3162. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3163. IN PCMIG_CONTENT OriginalContent,
  3164. IN PCMIG_CONTENT CurrentContent,
  3165. OUT PMIG_CONTENT NewContent,
  3166. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3167. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3168. )
  3169. {
  3170. return pMigrateTaskBarSS (
  3171. TRUE,
  3172. SrcObjectTypeId,
  3173. SrcObjectName,
  3174. OriginalContent,
  3175. CurrentContent,
  3176. NewContent,
  3177. SourceOperationData,
  3178. DestinationOperationData
  3179. );
  3180. }
  3181. BOOL
  3182. WINAPI
  3183. pConvertShowIEOnDesktop (
  3184. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3185. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3186. IN PCMIG_CONTENT OriginalContent,
  3187. IN PCMIG_CONTENT CurrentContent,
  3188. OUT PMIG_CONTENT NewContent,
  3189. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3190. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3191. )
  3192. {
  3193. BOOL dontShowIE = FALSE;
  3194. MIG_OBJECTTYPEID newObjectTypeId;
  3195. MIG_OBJECTSTRINGHANDLE newObjectName;
  3196. MIG_CONTENT destContent;
  3197. BOOL deleted = TRUE, replaced = FALSE;
  3198. if (IsValidRegType(CurrentContent, REG_DWORD)) {
  3199. dontShowIE = *((PDWORD)CurrentContent->MemoryContent.ContentBytes) & 0x00100000;
  3200. // find out the destination object and read it
  3201. newObjectName = IsmFilterObject (
  3202. SrcObjectTypeId,
  3203. SrcObjectName,
  3204. &newObjectTypeId,
  3205. &deleted,
  3206. &replaced
  3207. );
  3208. if ((!deleted || replaced) &&
  3209. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  3210. ) {
  3211. if (IsmAcquireObject (
  3212. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  3213. newObjectName?newObjectName:SrcObjectName,
  3214. &destContent
  3215. )) {
  3216. if (IsValidRegType(&destContent, REG_DWORD)) {
  3217. NewContent->MemoryContent.ContentSize = sizeof (DWORD);
  3218. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3219. CopyMemory (
  3220. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3221. destContent.MemoryContent.ContentBytes,
  3222. NewContent->MemoryContent.ContentSize
  3223. );
  3224. if (dontShowIE) {
  3225. *((PDWORD)NewContent->MemoryContent.ContentBytes) |= 0x00100000;
  3226. } else {
  3227. *((PDWORD)NewContent->MemoryContent.ContentBytes) &= 0xFFEFFFFF;
  3228. }
  3229. }
  3230. IsmReleaseObject (&destContent);
  3231. }
  3232. if (newObjectName) {
  3233. IsmDestroyObjectHandle (newObjectName);
  3234. newObjectName = NULL;
  3235. }
  3236. }
  3237. }
  3238. return TRUE;
  3239. }
  3240. BOOL
  3241. WINAPI
  3242. pMigrateActiveDesktop (
  3243. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3244. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3245. IN PCMIG_CONTENT OriginalContent,
  3246. IN PCMIG_CONTENT CurrentContent,
  3247. OUT PMIG_CONTENT NewContent,
  3248. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3249. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3250. )
  3251. {
  3252. MIG_OBJECTTYPEID newObjectTypeId;
  3253. MIG_OBJECTSTRINGHANDLE newObjectName;
  3254. PDWORD valueType1, valueType2, valueType;
  3255. BOOL deleted = TRUE, replaced = FALSE;
  3256. MIG_CONTENT destContent;
  3257. PREGSHELLSTATE shellState1 = NULL, shellState2 = NULL;
  3258. if (!CurrentContent->ContentInFile) {
  3259. MYASSERT (OriginalContent->Details.DetailsSize == sizeof (DWORD));
  3260. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  3261. valueType1 = (PDWORD)(OriginalContent->Details.DetailsData);
  3262. valueType2 = (PDWORD)(CurrentContent->Details.DetailsData);
  3263. if ((*valueType1 == REG_BINARY) &&
  3264. (*valueType2 == REG_BINARY)
  3265. ) {
  3266. // if the object was not changed yet we need to read the destination object and then
  3267. // just transfer the meaningfull settings.
  3268. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  3269. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  3270. ) {
  3271. // find out the destination object and read it
  3272. newObjectName = IsmFilterObject (
  3273. SrcObjectTypeId,
  3274. SrcObjectName,
  3275. &newObjectTypeId,
  3276. &deleted,
  3277. &replaced
  3278. );
  3279. if ((!deleted || replaced) &&
  3280. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  3281. ) {
  3282. if (IsmAcquireObject (
  3283. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  3284. newObjectName?newObjectName:SrcObjectName,
  3285. &destContent
  3286. )) {
  3287. if ((IsValidRegType(&destContent, REG_BINARY)) &&
  3288. (destContent.MemoryContent.ContentSize == sizeof (REGSHELLSTATE))
  3289. ) {
  3290. NewContent->MemoryContent.ContentSize = sizeof (REGSHELLSTATE);
  3291. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3292. CopyMemory (
  3293. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3294. destContent.MemoryContent.ContentBytes,
  3295. NewContent->MemoryContent.ContentSize
  3296. );
  3297. if (OriginalContent->MemoryContent.ContentSize >= sizeof(UINT)+sizeof(SHELLSTATE_SIZE_WIN95)) {
  3298. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3299. shellState2 = (PREGSHELLSTATE)NewContent->MemoryContent.ContentBytes;
  3300. shellState2->ss.fDesktopHTML= shellState1->ss.fDesktopHTML;
  3301. }
  3302. }
  3303. IsmReleaseObject (&destContent);
  3304. }
  3305. if (newObjectName) {
  3306. IsmDestroyObjectHandle (newObjectName);
  3307. newObjectName = NULL;
  3308. }
  3309. }
  3310. } else {
  3311. // just transfer the meaningfull settings.
  3312. if (OriginalContent->MemoryContent.ContentSize >= sizeof(UINT)+sizeof(SHELLSTATE_SIZE_WIN95)) {
  3313. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3314. shellState2 = (PREGSHELLSTATE)NewContent->MemoryContent.ContentBytes;
  3315. shellState2->ss.fDesktopHTML = shellState1->ss.fDesktopHTML;
  3316. }
  3317. }
  3318. }
  3319. }
  3320. return TRUE;
  3321. }
  3322. BOOL
  3323. CreateDwordRegObject (
  3324. IN PCTSTR KeyStr,
  3325. IN PCTSTR ValueName,
  3326. IN DWORD Value
  3327. )
  3328. {
  3329. MIG_OBJECTTYPEID objectTypeId;
  3330. MIG_OBJECTSTRINGHANDLE objectName;
  3331. MIG_CONTENT objectContent;
  3332. DWORD regType = REG_DWORD;
  3333. BOOL result = FALSE;
  3334. objectTypeId = MIG_REGISTRY_TYPE | PLATFORM_DESTINATION;
  3335. objectName = IsmCreateObjectHandle (KeyStr, ValueName);
  3336. ZeroMemory (&objectContent, sizeof (MIG_CONTENT));
  3337. objectContent.ContentInFile = FALSE;
  3338. objectContent.MemoryContent.ContentSize = sizeof (DWORD);
  3339. objectContent.MemoryContent.ContentBytes = (PBYTE)&Value;
  3340. objectContent.Details.DetailsSize = sizeof (DWORD);
  3341. objectContent.Details.DetailsData = &regType;
  3342. result = IsmReplacePhysicalObject (objectTypeId, objectName, &objectContent);
  3343. IsmDestroyObjectHandle (objectName);
  3344. return result;
  3345. }
  3346. BOOL
  3347. WINAPI
  3348. pMigrateDisplaySS (
  3349. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3350. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3351. IN PCMIG_CONTENT OriginalContent,
  3352. IN PCMIG_CONTENT CurrentContent,
  3353. OUT PMIG_CONTENT NewContent,
  3354. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3355. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3356. )
  3357. {
  3358. MIG_OBJECTTYPEID newObjectTypeId;
  3359. MIG_OBJECTSTRINGHANDLE newObjectName;
  3360. PDWORD valueType1, valueType2, valueType;
  3361. BOOL deleted = TRUE, replaced = FALSE;
  3362. MIG_CONTENT destContent;
  3363. PREGSHELLSTATE shellState1 = NULL, shellState2 = NULL;
  3364. if (!CurrentContent->ContentInFile) {
  3365. MYASSERT (OriginalContent->Details.DetailsSize == sizeof (DWORD));
  3366. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  3367. valueType1 = (PDWORD)(OriginalContent->Details.DetailsData);
  3368. valueType2 = (PDWORD)(CurrentContent->Details.DetailsData);
  3369. if ((*valueType1 == REG_BINARY) &&
  3370. (*valueType2 == REG_BINARY)
  3371. ) {
  3372. // if the object was not changed yet we need to read the destination object and then
  3373. // just transfer the meaningfull settings.
  3374. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  3375. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  3376. ) {
  3377. // find out the destination object and read it
  3378. newObjectName = IsmFilterObject (
  3379. SrcObjectTypeId,
  3380. SrcObjectName,
  3381. &newObjectTypeId,
  3382. &deleted,
  3383. &replaced
  3384. );
  3385. if ((!deleted || replaced) &&
  3386. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  3387. ) {
  3388. if (IsmAcquireObject (
  3389. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  3390. newObjectName?newObjectName:SrcObjectName,
  3391. &destContent
  3392. )) {
  3393. if ((IsValidRegType(&destContent, REG_BINARY)) &&
  3394. (destContent.MemoryContent.ContentSize == sizeof (REGSHELLSTATE))
  3395. ) {
  3396. NewContent->MemoryContent.ContentSize = sizeof (REGSHELLSTATE);
  3397. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3398. CopyMemory (
  3399. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3400. destContent.MemoryContent.ContentBytes,
  3401. NewContent->MemoryContent.ContentSize
  3402. );
  3403. if (OriginalContent->MemoryContent.ContentSize == sizeof(UINT)+SHELLSTATE_SIZE_WIN95) {
  3404. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3405. CreateDwordRegObject (
  3406. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
  3407. TEXT("Hidden"),
  3408. shellState1->ss.fShowAllObjects?0x00000001:0x00000002
  3409. );
  3410. CreateDwordRegObject (
  3411. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
  3412. TEXT("HideFileExt"),
  3413. shellState1->ss.fShowExtensions?0x00000000:0x00000001
  3414. );
  3415. // on really old SHELLSTATE the "Show compressed folders" flag is in the place of fShowSysFiles
  3416. CreateDwordRegObject (
  3417. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
  3418. TEXT("ShowCompColor"),
  3419. shellState1->ss.fShowSysFiles?0x00000001:0x00000000
  3420. );
  3421. }
  3422. if (OriginalContent->MemoryContent.ContentSize >= sizeof(UINT)+sizeof(SHELLSTATE_SIZE_WIN95)) {
  3423. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3424. shellState2 = (PREGSHELLSTATE)NewContent->MemoryContent.ContentBytes;
  3425. // If fWebView is not ON on the source system, fDoubleClickInWebView can have random
  3426. // values.
  3427. if (shellState1->ss.fWebView) {
  3428. shellState2->ss.fDoubleClickInWebView = shellState1->ss.fDoubleClickInWebView;
  3429. } else {
  3430. shellState2->ss.fDoubleClickInWebView = TRUE;
  3431. }
  3432. }
  3433. }
  3434. IsmReleaseObject (&destContent);
  3435. }
  3436. if (newObjectName) {
  3437. IsmDestroyObjectHandle (newObjectName);
  3438. newObjectName = NULL;
  3439. }
  3440. }
  3441. } else {
  3442. // just transfer the meaningfull settings.
  3443. if (OriginalContent->MemoryContent.ContentSize == sizeof(UINT)+SHELLSTATE_SIZE_WIN95) {
  3444. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3445. CreateDwordRegObject (
  3446. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
  3447. TEXT("Hidden"),
  3448. shellState1->ss.fShowAllObjects?0x00000001:0x00000002
  3449. );
  3450. CreateDwordRegObject (
  3451. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
  3452. TEXT("HideFileExt"),
  3453. shellState1->ss.fShowExtensions?0x00000000:0x00000001
  3454. );
  3455. // on really old SHELLSTATE the "Show compressed folders" flag is in the place of fShowSysFiles
  3456. CreateDwordRegObject (
  3457. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced"),
  3458. TEXT("ShowCompColor"),
  3459. shellState1->ss.fShowSysFiles?0x00000001:0x00000000
  3460. );
  3461. }
  3462. if (OriginalContent->MemoryContent.ContentSize == sizeof(UINT)+sizeof(SHELLSTATE)) {
  3463. shellState1 = (PREGSHELLSTATE)OriginalContent->MemoryContent.ContentBytes;
  3464. shellState2 = (PREGSHELLSTATE)NewContent->MemoryContent.ContentBytes;
  3465. // If fWebView is not ON on the source system, fDoubleClickInWebView can have random
  3466. // values.
  3467. if (shellState1->ss.fWebView) {
  3468. shellState2->ss.fDoubleClickInWebView = shellState1->ss.fDoubleClickInWebView;
  3469. } else {
  3470. shellState2->ss.fDoubleClickInWebView = TRUE;
  3471. }
  3472. }
  3473. }
  3474. }
  3475. }
  3476. return TRUE;
  3477. }
  3478. BOOL
  3479. WINAPI
  3480. pMigrateDisplayCS (
  3481. IN MIG_OBJECTTYPEID SrcObjectTypeId,
  3482. IN MIG_OBJECTSTRINGHANDLE SrcObjectName,
  3483. IN PCMIG_CONTENT OriginalContent,
  3484. IN PCMIG_CONTENT CurrentContent,
  3485. OUT PMIG_CONTENT NewContent,
  3486. IN PCMIG_BLOB SourceOperationData, OPTIONAL
  3487. IN PCMIG_BLOB DestinationOperationData OPTIONAL
  3488. )
  3489. {
  3490. MIG_OBJECTTYPEID newObjectTypeId;
  3491. MIG_OBJECTSTRINGHANDLE newObjectName;
  3492. PDWORD valueType1, valueType2, valueType;
  3493. BOOL deleted = TRUE, replaced = FALSE;
  3494. MIG_CONTENT destContent;
  3495. LPCABINETSTATE cabState1 = NULL, cabState2 = NULL;
  3496. if (!CurrentContent->ContentInFile) {
  3497. MYASSERT (OriginalContent->Details.DetailsSize == sizeof (DWORD));
  3498. MYASSERT (CurrentContent->Details.DetailsSize == sizeof (DWORD));
  3499. valueType1 = (PDWORD)(OriginalContent->Details.DetailsData);
  3500. valueType2 = (PDWORD)(CurrentContent->Details.DetailsData);
  3501. if ((*valueType1 == REG_BINARY) &&
  3502. (*valueType2 == REG_BINARY)
  3503. ) {
  3504. // if the object was not changed yet we need to read the destination object and then
  3505. // just transfer the meaningfull settings.
  3506. if ((!CurrentContent->MemoryContent.ContentBytes) ||
  3507. (CurrentContent->MemoryContent.ContentBytes == OriginalContent->MemoryContent.ContentBytes)
  3508. ) {
  3509. // find out the destination object and read it
  3510. newObjectName = IsmFilterObject (
  3511. SrcObjectTypeId,
  3512. SrcObjectName,
  3513. &newObjectTypeId,
  3514. &deleted,
  3515. &replaced
  3516. );
  3517. if ((!deleted || replaced) &&
  3518. ((newObjectTypeId & ~PLATFORM_MASK) == MIG_REGISTRY_TYPE)
  3519. ) {
  3520. if (IsmAcquireObject (
  3521. (newObjectTypeId & ~PLATFORM_MASK) | PLATFORM_DESTINATION,
  3522. newObjectName?newObjectName:SrcObjectName,
  3523. &destContent
  3524. )) {
  3525. if ((IsValidRegType (&destContent, REG_BINARY)) &&
  3526. (destContent.MemoryContent.ContentSize == sizeof (CABINETSTATE))
  3527. ) {
  3528. NewContent->MemoryContent.ContentSize = sizeof (CABINETSTATE);
  3529. NewContent->MemoryContent.ContentBytes = IsmGetMemory (NewContent->MemoryContent.ContentSize);
  3530. CopyMemory (
  3531. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3532. destContent.MemoryContent.ContentBytes,
  3533. NewContent->MemoryContent.ContentSize
  3534. );
  3535. if (OriginalContent->MemoryContent.ContentSize == sizeof(CABINETSTATE)) {
  3536. cabState1 = (LPCABINETSTATE)OriginalContent->MemoryContent.ContentBytes;
  3537. cabState2 = (LPCABINETSTATE)NewContent->MemoryContent.ContentBytes;
  3538. if (cabState1->nVersion >= 2) {
  3539. CopyMemory (
  3540. (PBYTE)NewContent->MemoryContent.ContentBytes,
  3541. OriginalContent->MemoryContent.ContentBytes,
  3542. NewContent->MemoryContent.ContentSize
  3543. );
  3544. } else {
  3545. CreateDwordRegObject (
  3546. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState"),
  3547. TEXT("FullPath"),
  3548. cabState1->fFullPathTitle?0x00000001:0x00000000
  3549. );
  3550. cabState2->fNewWindowMode = cabState1->fNewWindowMode;
  3551. }
  3552. }
  3553. }
  3554. IsmReleaseObject (&destContent);
  3555. }
  3556. if (newObjectName) {
  3557. IsmDestroyObjectHandle (newObjectName);
  3558. newObjectName = NULL;
  3559. }
  3560. }
  3561. } else {
  3562. // just transfer the meaningfull settings.
  3563. if (OriginalContent->MemoryContent.ContentSize == sizeof(CABINETSTATE)) {
  3564. cabState1 = (LPCABINETSTATE)OriginalContent->MemoryContent.ContentBytes;
  3565. cabState2 = (LPCABINETSTATE)NewContent->MemoryContent.ContentBytes;
  3566. if (cabState1->nVersion < 2) {
  3567. CreateDwordRegObject (
  3568. TEXT("HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CabinetState"),
  3569. TEXT("FullPath"),
  3570. cabState1->fFullPathTitle?0x00000001:0x00000000
  3571. );
  3572. cabState2->fNewWindowMode = cabState1->fNewWindowMode;
  3573. }
  3574. }
  3575. }
  3576. }
  3577. }
  3578. return TRUE;
  3579. }