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.

107 lines
2.4 KiB

  1. #include "stdinc.h"
  2. #include <windows.h>
  3. #include "sxsp.h"
  4. #include "comclsidmap.h"
  5. #include "SxsExceptionHandling.h"
  6. #define CLASS_ID_MAPPINGS_SUBKEY_NAME L"ClassIdMappings\\"
  7. CClsidMap::CClsidMap() :
  8. m_cLocalMappings(0),
  9. m_pLocalMappingListHead(NULL)
  10. {
  11. }
  12. CClsidMap::~CClsidMap()
  13. {
  14. }
  15. BOOL
  16. CClsidMap::Initialize()
  17. {
  18. BOOL fSuccess = FALSE;
  19. FN_TRACE_WIN32(fSuccess);
  20. fSuccess = TRUE;
  21. // Exit:
  22. return fSuccess;
  23. }
  24. BOOL
  25. CClsidMap::Uninitialize()
  26. {
  27. BOOL fSuccess = FALSE;
  28. FN_TRACE_WIN32(fSuccess);
  29. LocalMapping *pMapping = m_pLocalMappingListHead;
  30. while (pMapping != NULL)
  31. {
  32. LocalMapping *pNext = pMapping->m_pNext;
  33. FUSION_DELETE_SINGLETON(pMapping);
  34. pMapping = pNext;
  35. }
  36. fSuccess = TRUE;
  37. //Exit:
  38. return fSuccess;
  39. }
  40. BOOL
  41. CClsidMap::MapReferenceClsidToConfiguredClsid(
  42. const GUID *ReferenceClsid,
  43. PCACTCTXCTB_ASSEMBLY_CONTEXT AssemblyContext,
  44. GUID *ConfiguredClsid,
  45. GUID *ImplementedClsid
  46. )
  47. {
  48. BOOL fSuccess = FALSE;
  49. FN_TRACE_WIN32(fSuccess);
  50. LocalMapping *pMapping = NULL;
  51. // We're in the unnamed assembly - there can be at most one unnamed assembly, so this
  52. // must be the root assembly. We'll look for it in our local map. If it's not there,
  53. // we'll just generate a GUID and store it in the map.
  54. for (pMapping = m_pLocalMappingListHead; pMapping != NULL; pMapping = pMapping->m_pNext)
  55. {
  56. if (pMapping->m_ReferenceClsid == *ReferenceClsid)
  57. break;
  58. }
  59. // Not found; create one.
  60. if (pMapping == NULL)
  61. {
  62. IFALLOCFAILED_EXIT(pMapping = new LocalMapping);
  63. #if DBG
  64. ::FusionpDbgPrintEx(FUSION_DBG_LEVEL_INFO, "SXS.DLL: Adding clsid local mapping %p\n", pMapping);
  65. #endif
  66. pMapping->m_pNext = m_pLocalMappingListHead;
  67. pMapping->m_ReferenceClsid = *ReferenceClsid;
  68. pMapping->m_ImplementedClsid = *ReferenceClsid;
  69. // No ConfiguredClsid... we'll make one up.
  70. RPC_STATUS st = ::UuidCreate(&pMapping->m_ConfiguredClsid);
  71. RETAIL_UNUSED(st);
  72. SOFT_ASSERT((st == RPC_S_OK) ||
  73. (st == RPC_S_UUID_LOCAL_ONLY) ||
  74. (st == RPC_S_UUID_NO_ADDRESS));
  75. m_pLocalMappingListHead = pMapping;
  76. m_cLocalMappings++;
  77. }
  78. ASSERT(pMapping != NULL);
  79. *ConfiguredClsid = pMapping->m_ConfiguredClsid;
  80. *ImplementedClsid = pMapping->m_ImplementedClsid;
  81. fSuccess = TRUE;
  82. Exit:
  83. return fSuccess;
  84. }