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.

4336 lines
164 KiB

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