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.

214 lines
8.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. msmgen.h
  5. Abstract:
  6. header file for msm generation
  7. Author:
  8. Xiaoyu Wu(xiaoyuw) 01-Aug-2001
  9. --*/
  10. #define MAXDWORD 0xffffffff
  11. #include "stdinc.h"
  12. #include <msiquery.h>
  13. #define FUSION_GENMSM_ACTION_WRITE_TABLES (0x00000001)
  14. #define FUSION_GENMSM_ACTION_WRITE_CABITNET (0x00000002)
  15. #define COMPONENT_TABLE (0x00000001)
  16. #define DIRECTORY_TABLE (0x00000002)
  17. #define FEATURECOMPONENTS_TABLE (0x00000004)
  18. #define FILE_TABLE (0x00000008)
  19. #define MODULESIGNATURE_TABLE (0x00000010)
  20. #define MODULECOMPONENTS_TABLE (0x00000020)
  21. #define MSIASSEMLBY_TABLE (0x00000040)
  22. #define MSIASSEMLBYNAME_TABLE (0x00000080)
  23. #define MERGEMODULE_CABINET_FILENAME L"MergeModule.CABinet"
  24. #define SYSTEM_FOLDER L"SystemFolder"
  25. #define MSM_TEMPLATE_BARN L"%ProgramFiles%\\msmgen\\templates\\msmgen"
  26. #define MSMGEN_MSM_TEMPLATE L"%ProgramFiles%\\msmgen\\templates\\msmgen.msm"
  27. #define MSM_TEMP_CABIN_FILE "%Temp%\\msm_temp_cabinet.tmp"
  28. #define MSM_TEMP_CABIN_DIRECTORY_A "%Temp%\\msm_temp_cabinet_dir\\"
  29. #define MSM_TEMP_CABIN_DIRECTORY_W L"%Temp%\\msm_temp_cabinet_dir\\"
  30. #define MSIGUIDSTR_WITH_PREPEND_DOT 1
  31. // {BA0505B5-9044-4919-A2DD-7D71EA8F8306}
  32. #include "objbase.h"
  33. DEFINE_GUID(MSM_GUID,
  34. 0xba0505b5, 0x9044, 0x4919, 0xa2, 0xdd, 0x7d, 0x71, 0xea, 0x8f, 0x83, 0x6);
  35. typedef struct _ASSEMBLY_INFO_
  36. {
  37. CStringBuffer m_sbAssemblyPath; // always has a trailing slash
  38. CSmallStringBuffer m_sbManifestFileName;
  39. CSmallStringBuffer m_sbCatalogFileName;
  40. CSmallStringBuffer m_sbLangID; // defualt value is 0 - netural language id
  41. DWORD m_CchAssemblyPath;
  42. DWORD m_CchManifestFileName;
  43. DWORD m_CchCatalogFileName;
  44. CSmallStringBuffer m_sbComponentID; // guid for the assembly, if not specified, gennerate a new guid
  45. CSmallStringBuffer m_sbComponentIdentifier; // begin with AssemblyName, appended with .m_sbModuleGuidStr
  46. BOOL m_fComponentTableSet;
  47. }ASSEMBLY_INFO;
  48. #include "fci.h"
  49. #include "msi.h"
  50. typedef struct _MSM_INFO
  51. {
  52. GUID m_guidModuleID;
  53. CSmallStringBuffer m_sbModuleGuidStr; // prepend a "." before the numbers, since it is always used to append
  54. HFCI m_hfci; // init to be NULL and finally call FCIDestory to destroy it
  55. CSmallStringBuffer m_sbMsmFileName; // full-qualified path, default value is the same name as manifest with .msm
  56. PMSIHANDLE m_hdb; // database handle for msm file, init as NULL
  57. CSmallStringBuffer m_sbModuleIdentifier;
  58. SHORT m_sLanguageID; // get this from AssemblyIdentity, if it is not specified, use the default value
  59. CSmallStringBuffer m_sbCabinet; // fullpath of cabinet file
  60. CStringBuffer m_sbMsmTemplateFile;
  61. }MSM_INFO;
  62. typedef HRESULT (*PFN_MSM_GEN_WORKER)(IXMLDOMNode* node);
  63. typedef struct _MSM_DOMNODE_WORKER_
  64. {
  65. PCWSTR pwszNodeName;
  66. PFN_MSM_GEN_WORKER pfn;
  67. }MSM_DOMNODE_WORKER;
  68. typedef HRESULT (__stdcall * PMSMGEN_ATTRIBUTE_CALLBACK_FUNC_PTR)(PCWSTR, PCWSTR);
  69. typedef struct _ELEMENT_ALLOWED_ATTRIBUTE_{
  70. PCWSTR m_name;
  71. BOOL m_fRequired;
  72. PMSMGEN_ATTRIBUTE_CALLBACK_FUNC_PTR m_callbackFunc;
  73. BOOL m_fValued;
  74. CSmallStringBuffer *m_value;
  75. }ELEMENT_ALLOWED_ATTRIBUTE;
  76. //
  77. // extern variables
  78. //
  79. extern ASSEMBLY_INFO curAsmInfo;
  80. extern MSM_INFO g_MsmInfo;
  81. //
  82. // extern functions
  83. //
  84. extern HRESULT PrepareMsmOutputFiles(PCWSTR);
  85. extern HRESULT InitializeCabinetForWrite();
  86. extern HRESULT AddFileToCabinetW(PCWSTR, SIZE_T, PCWSTR, SIZE_T);
  87. extern HRESULT AddFileToCabinetA(PCSTR, SIZE_T, PCSTR, SIZE_T);
  88. extern HRESULT EndMsmGeneration();
  89. extern HRESULT OpenMsmFileForMsmGen(PCWSTR);
  90. extern HRESULT GetMsiGUIDStrFromGUID(DWORD, GUID &, CSmallStringBuffer &);
  91. extern HRESULT ExecuteQuerySQL(PCWSTR, PCWSTR, PCWSTR, BOOL &, MSIHANDLE *);
  92. extern HRESULT ExecuteUpdateSQL(PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR);
  93. extern HRESULT ExecuteInsertTableSQL(DWORD, UINT, ...);
  94. extern HRESULT SetModuleID();
  95. extern HRESULT PrepareMsm();
  96. extern HRESULT SetComponentId(PCWSTR, PCWSTR);
  97. extern HRESULT CloseCabinet();
  98. extern HRESULT InsertCabinetIntoMsm();
  99. extern HRESULT MoveFilesInCabinetA(char * sourceCabinet);
  100. extern HRESULT CheckComponentTable();
  101. //
  102. // constant
  103. //
  104. #define OPT_DIRECTORY 0
  105. #define OPT_COMPONENT 1
  106. #define OPT_FILE 2
  107. #define OPT_MSIASSEMBLY 3
  108. #define OPT_MSIASSEMBLYNAME 4
  109. #define OPT_MODULESIGNATURE 5
  110. #define OPT_MODULECOMPONENTS 6
  111. #define OPT_PROPERTY 7
  112. #define OPT_PROGID 8
  113. #define OPT_CLASS 9
  114. #define OPT_TYPELIB 10
  115. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_DIRECTORY 3
  116. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_COMPONENT 4
  117. // the acutal parameter-number for FILE_TABLE is 4 not 3,
  118. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_FILE 3
  119. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MSIASSEMBLY 3
  120. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MSIASSEMBLYNAME 3
  121. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MODULESIGNATURE 2
  122. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MODULECOMPONENTS 2
  123. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_PROPERTY 2
  124. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_PROGID 3
  125. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_CLASS 5
  126. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_TYPELIB 4
  127. #define CATALOG_FILE_EXT L"cat"
  128. #define MSM_FILE_EXT L"msm"
  129. #define MSM_TEMPLATE 1
  130. #define MSI_TEMPLATE 2
  131. #define MSMGEN_COMCLASS_ATTRIBUTE_CLSID 0
  132. #define MSMGEN_COMCLASS_ATTRIBUTE_DESCRIPTION 1
  133. #define MSMGEN_COMCLASS_ATTRIBUTE_PROGID 2
  134. #define MSMGEN_COMCLASS_ATTRIBUTE_TLBID 3
  135. #define MSMGEN_COMCLASS_ATTRIBUTE_THREADINGMODULE 4
  136. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_NAME 0
  137. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_LANGUAGE 1
  138. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_VERSION 2
  139. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_PROCESSORARCHITECTURE 3
  140. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_PUBLICKEYTOKEN 4
  141. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_TYPE 5
  142. #define MSMGEN_TYPELIB_ATTRIBUTE_TLBID 0
  143. #define MSMGEN_TYPELIB_ATTRIBUTE_VERSION 1
  144. #define MSMGEN_TYPELIB_ATTRIBUTE_HELPDIR 2
  145. #define GUID_NULL_IN_STRING L"{00000000-0000-0000-0000-000000000000}"
  146. //
  147. // macro
  148. //
  149. #define WIN32_FUNC_END do {fSuccess = TRUE; Exit: return fSuccess;} while (0)
  150. #define HRCOM_FUNC_END do {hr = S_OK; Exit: return hr;} while (0);
  151. #define IDT_EXT L".idt"
  152. #define DEFINE_ATTRIBUTE_MSM_INTERESTED(attributeName) \
  153. { \
  154. L ## #attributeName, \
  155. &MSM_PARSER_DOM_NODE_ ## attributeName \
  156. }
  157. #define DECLARE_FUNCTION(attributeName) \
  158. HRESULT MSM_PARSER_DOM_NODE ## attributeName (IXMLDOMNode* node)
  159. #define IFFALSE__MARKERROR_EXIT(x) if (!(x)) { hr = E_FAIL; goto Exit; }
  160. #define CurrentAssemblyRealign\
  161. do \
  162. { \
  163. if (curAsmInfo.m_CchAssemblyPath != 0) \
  164. { \
  165. curAsmInfo.m_sbAssemblyPath.Left(curAsmInfo.m_CchAssemblyPath); \
  166. curAsmInfo.m_sbManifestFileName.Left(curAsmInfo.m_CchManifestFileName); \
  167. curAsmInfo.m_sbCatalogFileName.Left(curAsmInfo.m_CchCatalogFileName); \
  168. } \
  169. } while (0)
  170. #define MAKE_PCWSTR(x) PCWSTR(x)
  171. #define ReportError printf
  172. #include "macros.h"