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.

221 lines
8.7 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. enum MSMGEN_MODE
  49. {
  50. MSMGEN_OPR_NEW,
  51. MSMGEN_OPR_REGEN,
  52. MSMGEN_OPR_ADD
  53. };
  54. #include "fci.h"
  55. #include "msi.h"
  56. typedef struct _MSM_INFO
  57. {
  58. GUID m_guidModuleID;
  59. CSmallStringBuffer m_sbModuleGuidStr; // prepend a "." before the numbers, since it is always used to append
  60. HFCI m_hfci; // init to be NULL and finally call FCIDestory to destroy it
  61. CSmallStringBuffer m_sbMsmFileName; // full-qualified path, default value is the same name as manifest with .msm
  62. PMSIHANDLE m_hdb; // database handle for msm file, init as NULL
  63. CSmallStringBuffer m_sbModuleIdentifier;
  64. SHORT m_sLanguageID; // get this from AssemblyIdentity, if it is not specified, use the default value
  65. MSMGEN_MODE m_enumGenMode;
  66. CSmallStringBuffer m_sbCabinet; // fullpath of cabinet file
  67. CStringBuffer m_sbMsmTemplateFile;
  68. }MSM_INFO;
  69. typedef HRESULT (*PFN_MSM_GEN_WORKER)(IXMLDOMNode* node);
  70. typedef struct _MSM_DOMNODE_WORKER_
  71. {
  72. PCWSTR pwszNodeName;
  73. PFN_MSM_GEN_WORKER pfn;
  74. }MSM_DOMNODE_WORKER;
  75. typedef HRESULT (__stdcall * PMSMGEN_ATTRIBUTE_CALLBACK_FUNC_PTR)(PCWSTR, PCWSTR);
  76. typedef struct _ELEMENT_ALLOWED_ATTRIBUTE_{
  77. PCWSTR m_name;
  78. BOOL m_fRequired;
  79. PMSMGEN_ATTRIBUTE_CALLBACK_FUNC_PTR m_callbackFunc;
  80. BOOL m_fValued;
  81. CSmallStringBuffer *m_value;
  82. }ELEMENT_ALLOWED_ATTRIBUTE;
  83. //
  84. // extern variables
  85. //
  86. extern ASSEMBLY_INFO curAsmInfo;
  87. extern MSM_INFO g_MsmInfo;
  88. //
  89. // extern functions
  90. //
  91. extern HRESULT PrepareMsmOutputFiles(PCWSTR);
  92. extern HRESULT InitializeCabinetForWrite();
  93. extern HRESULT AddFileToCabinetW(PCWSTR, SIZE_T, PCWSTR, SIZE_T);
  94. extern HRESULT AddFileToCabinetA(PCSTR, SIZE_T, PCSTR, SIZE_T);
  95. extern HRESULT EndMsmGeneration();
  96. extern HRESULT OpenMsmFileForMsmGen(PCWSTR);
  97. extern HRESULT GetMsiGUIDStrFromGUID(DWORD, GUID &, CSmallStringBuffer &);
  98. extern HRESULT ExecuteQuerySQL(PCWSTR, PCWSTR, PCWSTR, BOOL &, MSIHANDLE *);
  99. extern HRESULT ExecuteUpdateSQL(PCWSTR, PCWSTR, PCWSTR, PCWSTR, PCWSTR);
  100. extern HRESULT ExecuteInsertTableSQL(DWORD, UINT, ...);
  101. extern HRESULT SetModuleID();
  102. extern HRESULT PrepareMsm();
  103. extern HRESULT SetComponentId(PCWSTR, PCWSTR);
  104. extern HRESULT CloseCabinet();
  105. extern HRESULT InsertCabinetIntoMsm();
  106. extern HRESULT MoveFilesInCabinetA(char * sourceCabinet);
  107. extern HRESULT CheckComponentTable();
  108. //
  109. // constant
  110. //
  111. #define OPT_DIRECTORY 0
  112. #define OPT_COMPONENT 1
  113. #define OPT_FILE 2
  114. #define OPT_MSIASSEMBLY 3
  115. #define OPT_MSIASSEMBLYNAME 4
  116. #define OPT_MODULESIGNATURE 5
  117. #define OPT_MODULECOMPONENTS 6
  118. #define OPT_PROPERTY 7
  119. #define OPT_PROGID 8
  120. #define OPT_CLASS 9
  121. #define OPT_TYPELIB 10
  122. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_DIRECTORY 3
  123. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_COMPONENT 4
  124. // the acutal parameter-number for FILE_TABLE is 4 not 3,
  125. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_FILE 3
  126. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MSIASSEMBLY 3
  127. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MSIASSEMBLYNAME 3
  128. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MODULESIGNATURE 2
  129. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_MODULECOMPONENTS 2
  130. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_PROPERTY 2
  131. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_PROGID 3
  132. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_CLASS 5
  133. #define NUMBER_OF_PARAM_TO_INSERT_TABLE_TYPELIB 4
  134. #define CATALOG_FILE_EXT L"cat"
  135. #define MSM_FILE_EXT L"msm"
  136. #define MSM_TEMPLATE 1
  137. #define MSI_TEMPLATE 2
  138. #define MSMGEN_COMCLASS_ATTRIBUTE_CLSID 0
  139. #define MSMGEN_COMCLASS_ATTRIBUTE_DESCRIPTION 1
  140. #define MSMGEN_COMCLASS_ATTRIBUTE_PROGID 2
  141. #define MSMGEN_COMCLASS_ATTRIBUTE_TLBID 3
  142. #define MSMGEN_COMCLASS_ATTRIBUTE_THREADINGMODULE 4
  143. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_NAME 0
  144. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_LANGUAGE 1
  145. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_VERSION 2
  146. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_PROCESSORARCHITECTURE 3
  147. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_PUBLICKEYTOKEN 4
  148. #define MSMGEN_ASSEMBLYIDENTTIY_ATTRIBUTE_TYPE 5
  149. #define MSMGEN_TYPELIB_ATTRIBUTE_TLBID 0
  150. #define MSMGEN_TYPELIB_ATTRIBUTE_VERSION 1
  151. #define MSMGEN_TYPELIB_ATTRIBUTE_HELPDIR 2
  152. #define GUID_NULL_IN_STRING L"{00000000-0000-0000-0000-000000000000}"
  153. //
  154. // macro
  155. //
  156. #define WIN32_FUNC_END do {fSuccess = TRUE; Exit: return fSuccess;} while (0)
  157. #define HRCOM_FUNC_END do {hr = S_OK; Exit: return hr;} while (0);
  158. #define IDT_EXT L".idt"
  159. #define DEFINE_ATTRIBUTE_MSM_INTERESTED(attributeName) \
  160. { \
  161. L ## #attributeName, \
  162. &MSM_PARSER_DOM_NODE_ ## attributeName \
  163. }
  164. #define DECLARE_FUNCTION(attributeName) \
  165. HRESULT MSM_PARSER_DOM_NODE ## attributeName (IXMLDOMNode* node)
  166. #define IFFALSE__MARKERROR_EXIT(x) if (!(x)) { hr = E_FAIL; goto Exit; }
  167. #define CurrentAssemblyReset\
  168. do \
  169. { \
  170. if (curAsmInfo.m_CchAssemblyPath != 0) \
  171. { \
  172. curAsmInfo.m_sbAssemblyPath.Left(curAsmInfo.m_CchAssemblyPath); \
  173. curAsmInfo.m_sbManifestFileName.Left(curAsmInfo.m_CchManifestFileName); \
  174. curAsmInfo.m_sbCatalogFileName.Left(curAsmInfo.m_CchCatalogFileName); \
  175. } \
  176. } while (0)
  177. #define MAKE_PCWSTR(x) PCWSTR(x)
  178. #include "macros.h"