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.

200 lines
5.3 KiB

  1. #pragma once
  2. #include <comdef.h>
  3. #include "dbglog.h"
  4. // manifest data types:
  5. #define WZ_DATA_PLATFORM_MANAGED L"platform_managed"
  6. #define WZ_DATA_PLATFORM_OS L"platform_os"
  7. #define WZ_DATA_PLATFORM_DOTNET L"platform_dotnet"
  8. #define WZ_DATA_OSVERSIONINFO L"osversioninfo"
  9. class CAssemblyManifestImport : public IAssemblyManifestImport
  10. {
  11. public:
  12. // IUnknown methods
  13. STDMETHODIMP QueryInterface(REFIID riid,void ** ppv);
  14. STDMETHODIMP_(ULONG) AddRef();
  15. STDMETHODIMP_(ULONG) Release();
  16. STDMETHOD(GetAssemblyIdentity)(
  17. /* out */ LPASSEMBLY_IDENTITY *ppAssemblyId);
  18. STDMETHOD(GetManifestApplicationInfo)(
  19. /* out */ IManifestInfo **ppAppInfo);
  20. STDMETHOD(GetSubscriptionInfo)(
  21. /* out */ IManifestInfo **ppSubsInfo);
  22. STDMETHOD(GetNextPlatform)(
  23. /* in */ DWORD nIndex,
  24. /* out */ IManifestData **ppPlatformInfo);
  25. STDMETHOD(GetNextFile)(
  26. /* in */ DWORD nIndex,
  27. /* out */ IManifestInfo **ppAssemblyFile);
  28. STDMETHOD(QueryFile)(
  29. /* in */ LPCOLESTR pwzFileName,
  30. /* out */ IManifestInfo **ppAssemblyFile);
  31. STDMETHOD(GetNextAssembly)(
  32. /* in */ DWORD nIndex,
  33. /* out */ IManifestInfo **ppDependAsm);
  34. STDMETHOD(ReportManifestType)(
  35. /*out*/ DWORD *pdwType);
  36. STDMETHOD (GetXMLDoc)(
  37. /* out */ IXMLDOMDocument2 **pXMLDoc);
  38. static HRESULT XMLtoAssemblyIdentity(IXMLDOMNode *pIDOMNode,
  39. LPASSEMBLY_IDENTITY *ppAssemblyFile);
  40. static HRESULT ParseAttribute(IXMLDOMNode *pIXMLDOMNode, BSTR bstrAttributeName,
  41. LPWSTR *ppwzAttributeValue, LPDWORD pccAttributeValueOut);
  42. ~CAssemblyManifestImport();
  43. HRESULT static InitGlobalCritSect();
  44. void static DelGlobalCritSect();
  45. private:
  46. HRESULT XMLtoOSVersionInfo(IXMLDOMNode *pIDOMNode, LPMANIFEST_DATA pPlatformInfo);
  47. HRESULT XMLtoDotNetVersionInfo(IXMLDOMNode *pIDOMNode, LPMANIFEST_DATA pPlatformInfo);
  48. // Instance specific data
  49. DWORD _dwSig;
  50. HRESULT _hr;
  51. LONG _cRef;
  52. LPASSEMBLY_IDENTITY _pAssemblyId;
  53. IXMLDOMDocument2 *_pXMLDoc;
  54. IXMLDOMNodeList *_pXMLFileNodeList;
  55. LONG _nFileNodes;
  56. IXMLDOMNodeList *_pXMLAssemblyNodeList;
  57. LONG _nAssemblyNodes;
  58. IXMLDOMNodeList *_pXMLPlatformNodeList;
  59. LONG _nPlatformNodes;
  60. BSTR _bstrManifestFilePath;
  61. CDebugLog *_pDbgLog;
  62. // Globals
  63. static CRITICAL_SECTION g_cs;
  64. public:
  65. enum eStringTableId
  66. {
  67. Name = 0,
  68. Version,
  69. Language,
  70. PublicKey,
  71. PublicKeyToken,
  72. ProcessorArchitecture,
  73. Type,
  74. SelNameSpaces,
  75. NameSpace,
  76. SelLanguage,
  77. XPath,
  78. FileNode,
  79. FileName,
  80. FileHash,
  81. AssemblyId,
  82. DependentAssemblyNode,
  83. DependentAssemblyCodebase,
  84. Codebase,
  85. ShellState,
  86. FriendlyName, // note: this must be in sync with MAN_APPLICATION in fusenet.idl
  87. EntryPoint,
  88. EntryImageType,
  89. IconFile,
  90. IconIndex,
  91. ShowCommand,
  92. HotKey,
  93. Activation,
  94. AssemblyName,
  95. AssemblyClass,
  96. AssemblyMethod,
  97. AssemblyArgs,
  98. Patch,
  99. PatchInfo,
  100. Source,
  101. Target,
  102. PatchFile,
  103. AssemblyIdTag,
  104. Compressed,
  105. Subscription,
  106. SynchronizeInterval,
  107. IntervalUnit,
  108. SynchronizeEvent,
  109. EventDemandConnection,
  110. File,
  111. Cab,
  112. AssemblyNode,
  113. ApplicationNode,
  114. VersionWildcard,
  115. Desktop,
  116. Dependency,
  117. DependentAssembly,
  118. Install,
  119. InstallType,
  120. Platform,
  121. PlatformInfo,
  122. OSVersionInfo,
  123. DotNetVersionInfo,
  124. Href,
  125. OS,
  126. MajorVersion, // note: the following must be in order
  127. MinorVersion,
  128. BuildNumber,
  129. ServicePackMajor,
  130. ServicePackMinor,
  131. Suite,
  132. ProductType,
  133. SupportedRuntime,
  134. MAX_STRINGS
  135. };
  136. struct StringTableEntry
  137. {
  138. const WCHAR *pwz;
  139. BSTR bstr;
  140. SIZE_T Cch;
  141. };
  142. static StringTableEntry g_StringTable[MAX_STRINGS];
  143. static HRESULT InitGlobalStringTable();
  144. static HRESULT FreeGlobalStringTable();
  145. private:
  146. CAssemblyManifestImport(CDebugLog *);
  147. HRESULT Init(LPCOLESTR wzManifestFilePath);
  148. static HRESULT IsCLRManifest(LPCOLESTR pwzManifestFilePath);
  149. HRESULT LoadDocumentSync();
  150. HRESULT CreateAssemblyFileEx(IManifestInfo **ppAssemblyFile, IXMLDOMNode * pIDOMNode);
  151. friend HRESULT CreateAssemblyManifestImport(IAssemblyManifestImport** ppImport,
  152. LPCOLESTR pwzManifestFilePath, CDebugLog *pDbgLog, DWORD dwFlags);
  153. friend class CAssemblyManifestEmit; // for sharing BSTR and access to _pXMLDoc
  154. };
  155. inline CAssemblyManifestImport::eStringTableId operator++(CAssemblyManifestImport::eStringTableId &rs, int)
  156. {
  157. return rs = (CAssemblyManifestImport::eStringTableId) (rs+1);
  158. };