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.

148 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. match.c
  5. Abstract:
  6. This module implements ...
  7. Author:
  8. vadimb created sometime in 2000
  9. Revision History:
  10. clupu cleanup 12/27/2000
  11. --*/
  12. #include "apphelp.h"
  13. // global Hinst
  14. HINSTANCE ghInstance;
  15. BOOL
  16. DllMain(
  17. HANDLE hModule,
  18. DWORD ul_reason,
  19. LPVOID lpReserved
  20. )
  21. /*++
  22. Return: TRUE on success, FALSE otherwise.
  23. Desc: apphelp.dll entry point.
  24. --*/
  25. {
  26. switch (ul_reason) {
  27. case DLL_PROCESS_ATTACH:
  28. ghInstance = hModule;
  29. break;
  30. case DLL_THREAD_ATTACH:
  31. break;
  32. case DLL_THREAD_DETACH:
  33. break;
  34. case DLL_PROCESS_DETACH:
  35. break;
  36. }
  37. return TRUE;
  38. }
  39. BOOL
  40. GetExeSxsData(
  41. IN HSDB hSDB, // handle to the database channel
  42. IN TAGREF trExe, // tagref of an exe entry
  43. OUT PVOID* ppSxsData, // pointer to the SXS data
  44. OUT DWORD* pcbSxsData // pointer to the SXS data size
  45. )
  46. /*++
  47. Return: TRUE on success, FALSE otherwise.
  48. Desc: Gets SXS (Fusion) data for the specified EXE from the database.
  49. --*/
  50. {
  51. TAGID tiExe;
  52. TAGID tiSxsManifest;
  53. PDB pdb;
  54. WCHAR* pszManifest;
  55. DWORD dwManifestLength; // in chars
  56. PVOID pSxsData = NULL;
  57. if (!SdbTagRefToTagID(hSDB, trExe, &pdb, &tiExe)) {
  58. DBGPRINT((sdlError,
  59. "GetExeSxsData",
  60. "Failed to get the database the TAGREF 0x%x belongs to.\n",
  61. trExe));
  62. return FALSE;
  63. }
  64. tiSxsManifest = SdbFindFirstTag(pdb, tiExe, TAG_SXS_MANIFEST);
  65. if (!tiSxsManifest) {
  66. DBGPRINT((sdlInfo,
  67. "GetExeSxsData",
  68. "No SXS data for TAGREF 0x%x.\n",
  69. trExe));
  70. return FALSE;
  71. }
  72. pszManifest = SdbGetStringTagPtr(pdb, tiSxsManifest);
  73. if (pszManifest == NULL) {
  74. DBGPRINT((sdlError,
  75. "GetExeSxsData",
  76. "Failed to get manifest string tagid 0x%lx\n",
  77. tiSxsManifest));
  78. return FALSE;
  79. }
  80. dwManifestLength = wcslen(pszManifest);
  81. //
  82. // check if this is just a query for existance of the data tag
  83. //
  84. if (ppSxsData == NULL) {
  85. if (pcbSxsData != NULL) {
  86. *pcbSxsData = dwManifestLength * sizeof(WCHAR);
  87. }
  88. return TRUE;
  89. }
  90. //
  91. // Allocate the string and return it. NOTE: SXS.DLL cannot handle
  92. // a NULL terminator at the end of the string. We must provide the
  93. // string without the NULL terminator.
  94. //
  95. pSxsData = (PVOID)RtlAllocateHeap(RtlProcessHeap(),
  96. HEAP_ZERO_MEMORY,
  97. dwManifestLength * sizeof(WCHAR));
  98. if (pSxsData == NULL) {
  99. DBGPRINT((sdlError,
  100. "GetExeSxsData",
  101. "Failed to allocate %d bytes\n",
  102. dwManifestLength * sizeof(WCHAR)));
  103. return FALSE;
  104. }
  105. RtlMoveMemory(pSxsData, pszManifest, dwManifestLength * sizeof(WCHAR));
  106. if (ppSxsData != NULL) {
  107. *ppSxsData = pSxsData;
  108. }
  109. if (pcbSxsData != NULL) {
  110. *pcbSxsData = dwManifestLength * sizeof(WCHAR);
  111. }
  112. return TRUE;
  113. }