Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

314 lines
8.5 KiB

  1. #include "csdrt.hxx"
  2. extern BOOL fVerbose;
  3. BOOL Compare(WCHAR *sz1, WCHAR *sz2)
  4. {
  5. return (wcscmp(sz1, sz2) == 0);
  6. }
  7. BOOL Compare(CSPLATFORM cp1, CSPLATFORM cp2)
  8. {
  9. return (memcmp((void *)&cp1, (void *)&cp2, sizeof(CSPLATFORM)) == 0);
  10. }
  11. BOOL Compare(GUID guid1, GUID guid2)
  12. {
  13. return (guid1 == guid2);
  14. }
  15. BOOL Compare(DWORD dw1, DWORD dw2)
  16. {
  17. return (dw1 == dw2);
  18. }
  19. BOOL Compare(CLASSDETAIL Cd1, CLASSDETAIL Cd2)
  20. {
  21. int i;
  22. if (Cd1.Clsid != Cd2.Clsid)
  23. return FALSE;
  24. /* if (Cd1.TreatAs != Cd2.TreatAs)
  25. return FALSE;
  26. if (Cd1.cProgId != Cd2.cProgId)
  27. return FALSE;
  28. for (i = 0; i < (int)(Cd1.cProgId); i++)
  29. if (!ArrayCompare((Cd1.prgProgId), (Cd2.prgProgId)[i], (Cd1.cProgId)))
  30. return FALSE;
  31. */
  32. return TRUE;
  33. }
  34. BOOL Compare(ACTIVATIONINFO Av1, ACTIVATIONINFO Av2)
  35. {
  36. int i;
  37. if ((Av1.cClasses) != (Av2.cClasses))
  38. return FALSE;
  39. for (i = 0; i < (int)(Av1.cClasses); i++)
  40. if (!ArrayCompare(Av1.pClasses, Av2.pClasses[i], (Av1.cClasses)))
  41. return FALSE;
  42. if ((Av1.cShellFileExt) != (Av2.cShellFileExt))
  43. return FALSE;
  44. for (i = 0; i < (int)(Av1.cShellFileExt); i++) {
  45. DWORD posn1=0, posn2=0;
  46. posn1 = ArrayCompare<LPOLESTR>((Av1.prgShellFileExt), (Av2.prgShellFileExt)[i], (Av1.cShellFileExt));
  47. posn2 = ArrayCompare((Av1.prgPriority), (Av2.prgPriority)[i], (Av1.cShellFileExt));
  48. if ((posn1 == 0) || (posn1 != posn2))
  49. return FALSE;
  50. }
  51. if ((Av1.cInterfaces) != (Av2.cInterfaces))
  52. return FALSE;
  53. for (i = 0; i < (int)(Av1.cInterfaces); i++) {
  54. if (!ArrayCompare<GUID>(Av1.prgInterfaceId, Av2.prgInterfaceId[i], Av1.cInterfaces))
  55. return FALSE;
  56. }
  57. if ((Av1.cTypeLib) != (Av2.cTypeLib))
  58. return FALSE;
  59. for (i = 0; i < (int)(Av1.cTypeLib); i++) {
  60. if (!ArrayCompare(Av1.prgTlbId, (Av2.prgTlbId)[i], (Av1.cTypeLib)))
  61. return FALSE;
  62. }
  63. return TRUE;
  64. }
  65. //+-------------------------------------------------------------------------
  66. //
  67. // Function: StringFromGUID
  68. //
  69. //--------------------------------------------------------------------------
  70. int StringFromGUID(REFGUID rguid, LPOLESTR lptsz)
  71. {
  72. swprintf(lptsz, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
  73. rguid.Data1, rguid.Data2, rguid.Data3,
  74. rguid.Data4[0], rguid.Data4[1],
  75. rguid.Data4[2], rguid.Data4[3],
  76. rguid.Data4[4], rguid.Data4[5],
  77. rguid.Data4[6], rguid.Data4[7]);
  78. return 36;
  79. }
  80. BOOL Compare(INSTALLINFO If1, INSTALLINFO If2)
  81. {
  82. if (If1.dwActFlags != If2.dwActFlags) {
  83. printf("ActFlags not matching 0x%x & 0x%x\n", If1.dwActFlags, If2.dwActFlags);
  84. return FALSE;
  85. }
  86. if (If1.PathType != If2.PathType) {
  87. printf("PathType not matching 0x%x & 0x%x\n", If1.PathType, If2.PathType);
  88. return FALSE;
  89. }
  90. if ((If1.pszScriptPath != If2.pszScriptPath) &&
  91. (wcscmp(If1.pszScriptPath, If2.pszScriptPath) != 0)) {
  92. printf("pszScriptPath not matching %S & %S\n", If1.pszScriptPath, If2.pszScriptPath);
  93. return FALSE;
  94. }
  95. if ((If1.pszSetupCommand != If2.pszSetupCommand) &&
  96. (wcscmp(If1.pszSetupCommand, If2.pszSetupCommand) != 0)) {
  97. printf("pszSetupCommand not matching %S & %S\n", If1.pszSetupCommand, If2.pszSetupCommand);
  98. return FALSE;
  99. }
  100. if ((If1.pszUrl != If2.pszUrl) &&
  101. (wcscmp(If1.pszUrl, If2.pszUrl) != 0)) {
  102. printf("pszUrl not matching %S & %S\n", If1.pszUrl, If2.pszUrl);
  103. return FALSE;
  104. }
  105. if (If1.dwComClassContext != If2.dwComClassContext) {
  106. printf("dwComClassContext not matching 0x%x & 0x%x\n", If1.dwComClassContext, If2.dwComClassContext);
  107. return FALSE;
  108. }
  109. if (If1.InstallUiLevel != If2.InstallUiLevel) {
  110. printf("InstallUiLevel not matching 0x%x & 0x%x\n", If1.InstallUiLevel, If2.InstallUiLevel);
  111. return FALSE;
  112. }
  113. // pClsid
  114. /* Not matching corrently
  115. if ((If1.ProductCode) != (If2.ProductCode)) {
  116. WCHAR szGuid1[100], szGuid2[100];
  117. StringFromGUID(If1.ProductCode, szGuid1);
  118. StringFromGUID(If2.ProductCode, szGuid2);
  119. printf("ProductCode not matching\n\t%S\n\t%S\n", szGuid1, szGuid2);
  120. return FALSE;
  121. }
  122. if ((If1.Mvipc) != (If2.Mvipc)) {
  123. WCHAR szGuid1[100], szGuid2[100];
  124. StringFromGUID(If1.Mvipc, szGuid1);
  125. StringFromGUID(If2.Mvipc, szGuid2);
  126. printf("Mvipc not matching\n\t%S\n\t%S\n", szGuid1, szGuid2);
  127. return FALSE;
  128. }
  129. */
  130. if (If1.dwVersionHi != If2.dwVersionHi) {
  131. printf("dwVersionHi not matching 0x%x & 0x%x\n", If1.dwVersionHi, If2.dwVersionHi);
  132. return FALSE;
  133. }
  134. if (If1.dwVersionLo != If2.dwVersionLo) {
  135. printf("dwVersionLo not matching 0x%x & 0x%x\n", If1.dwVersionLo, If2.dwVersionLo);
  136. return FALSE;
  137. }
  138. if (If1.cUpgrades != If2.cUpgrades) {
  139. printf("cUpgrades not matching 0x%x & 0x%x\n", If1.cUpgrades, If2.cUpgrades);
  140. return FALSE;
  141. }
  142. int i;
  143. for (i = 0; i < (int)(If1.cUpgrades); i++) {
  144. DWORD posn1=0, posn2=0;
  145. posn1 = ArrayCompare((If1.prgUpgradeScript), (If2.prgUpgradeScript)[i], (If1.cUpgrades));
  146. posn2 = ArrayCompare((If1.prgUpgradeFlag), (If2.prgUpgradeFlag)[i], (If1.cUpgrades));
  147. if ((posn1 == 0) || (posn1 != posn2))
  148. return FALSE;
  149. }
  150. if (If1.cScriptLen != If2.cScriptLen) {
  151. printf("cScriptLen not matching 0x%x & 0x%x\n", If1.cScriptLen, If2.cScriptLen);
  152. return FALSE;
  153. }
  154. return TRUE;
  155. }
  156. BOOL Compare(PLATFORMINFO Pf1, PLATFORMINFO Pf2)
  157. {
  158. UINT i = 0;
  159. if (Pf1.cPlatforms != Pf2.cPlatforms)
  160. return FALSE;
  161. for (i = 0; i < (int)(Pf1.cPlatforms); i++)
  162. if (!ArrayCompare(Pf1.prgPlatform, Pf2.prgPlatform[i], Pf1.cPlatforms))
  163. return FALSE;
  164. if (Pf1.cLocales != Pf2.cLocales)
  165. return FALSE;
  166. for (i = 0; i < (int)(Pf1.cLocales); i++)
  167. if (!ArrayCompare(Pf1.prgLocale, Pf2.prgLocale[i], (Pf1.cLocales)))
  168. return FALSE;
  169. return TRUE;
  170. }
  171. BOOL Compare(PACKAGEDETAIL Pd1, PACKAGEDETAIL Pd2)
  172. {
  173. UINT i = 0;
  174. VerbosePrint("Verify!! Package Name <<%S>> \n", Pd1.pszPackageName);
  175. if (Pd1.cSources != Pd2.cSources)
  176. return FALSE;
  177. for (i = 0; i < (int)(Pd1.cSources); i++)
  178. if (!ArrayCompare(Pd1.pszSourceList, Pd2.pszSourceList[i], (Pd1.cSources)))
  179. return FALSE;
  180. if (Pd1.cCategories != Pd2.cCategories)
  181. return FALSE;
  182. for (i = 0; i < (int)(Pd1.cCategories); i++)
  183. if (!ArrayCompare(Pd1.rpCategory, Pd2.rpCategory[i], (Pd1.cCategories)))
  184. return FALSE;
  185. if ((Pd1.pActInfo != Pd2.pActInfo) && (!Compare(*Pd1.pActInfo, *Pd2.pActInfo)))
  186. return FALSE;
  187. if (!Compare(*Pd1.pPlatformInfo, *Pd2.pPlatformInfo))
  188. return FALSE;
  189. if (!Compare(*Pd1.pInstallInfo, *Pd2.pInstallInfo))
  190. return FALSE;
  191. return TRUE;
  192. }
  193. BOOL Compare(PACKAGEDISPINFO Pi1, PACKAGEDISPINFO Pi2)
  194. {
  195. if (wcscmp(Pi1.pszPackageName, Pi2.pszPackageName) != 0)
  196. return FALSE;
  197. if (Pi1.dwActFlags != Pi2.dwActFlags)
  198. return FALSE;
  199. if (Pi1.PathType != Pi2.PathType)
  200. return FALSE;
  201. if (wcscmp(Pi1.pszScriptPath, Pi2.pszScriptPath) != 0)
  202. return FALSE;
  203. if (Pi1.cScriptLen != Pi2.cScriptLen)
  204. return FALSE;
  205. /* WCHAR pStoreUsn[20];
  206. SYSTEMTIME SystemTime;
  207. FileTimeToSystemTme((FILETIME *)&(Pi1.Usn), &SystemTime);
  208. wsprintf (pStoreUsn, L"%4d%2d%2d%2d%2d%2d",
  209. SystemTime.wYear,
  210. SystemTime.wMonth,
  211. SystemTime.wDay,
  212. SystemTime.wHour,
  213. SystemTime.wMinute,
  214. SystemTime.wSecond);
  215. VerbosePrint(L"VERIFY!!! Last modification time for Package Time %s\n", pStoreUsn);
  216. */
  217. if (Pi1.dwVersionHi != Pi2.dwVersionHi)
  218. return FALSE;
  219. if (Pi1.dwVersionLo != Pi2.dwVersionLo)
  220. return FALSE;
  221. if (Pi1.cUpgrades != Pi2.cUpgrades)
  222. return FALSE;
  223. int i;
  224. for (i = 0; i < (int)(Pi1.cUpgrades); i++) {
  225. DWORD posn1=0, posn2=0;
  226. posn1 = ArrayCompare((Pi1.prgUpgradeScript), (Pi2.prgUpgradeScript)[i], (Pi1.cUpgrades));
  227. posn2 = ArrayCompare((Pi1.prgUpgradeFlag), (Pi2.prgUpgradeFlag)[i], (Pi1.cUpgrades));
  228. if ((posn1 == 0) || (posn1 != posn2))
  229. return FALSE;
  230. }
  231. return TRUE;
  232. }
  233. BOOL Compare(CATEGORYINFO ci1, CATEGORYINFO ci2)
  234. {
  235. return ((ci1.catid == ci2.catid) && (ci1.lcid == ci2.lcid) &&
  236. (wcscmp(ci1.szDescription, ci2.szDescription) == 0));
  237. }