Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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