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.

299 lines
12 KiB

  1. //***************************************************************************
  2. //* Copyright (c) Microsoft Corporation 1995. All rights reserved. *
  3. //***************************************************************************
  4. //* *
  5. //* CABPACK.H - Wizard to build a Win32 Self-Extracting and self-installing *
  6. //* EXE from a Cabinet (CAB) file. *
  7. //* *
  8. //***************************************************************************
  9. #ifndef _CABPACK_H_
  10. #define _CABPACK_H_
  11. //***************************************************************************
  12. //* INCLUDE FILES *
  13. //***************************************************************************
  14. #include <prsht.h>
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <fcntl.h>
  18. #include <io.h>
  19. #include "resource.h"
  20. #include "res.h"
  21. #include "cpldebug.h"
  22. #include "updres.h"
  23. #include "pagefcns.h"
  24. //***************************************************************************
  25. //* DEFINES *
  26. //***************************************************************************
  27. #define SMALL_BUF_LEN 48 // good size for small text buffers
  28. #define STRING_BUF_LEN 512
  29. #define MAX_STRING 512
  30. #define MAX_INFLINE MAX_PATH
  31. #define LARGE_POINTSIZE 15
  32. #define SIZE_CHECKSTRING 3
  33. #define ORD_PAGE_WELCOME 0
  34. #define ORD_PAGE_MODIFY 1
  35. #define ORD_PAGE_PURPOSE 2
  36. #define ORD_PAGE_TITLE 3
  37. #define ORD_PAGE_PROMPT 4
  38. #define ORD_PAGE_LICENSETXT 5
  39. #define ORD_PAGE_FILES 6
  40. #define ORD_PAGE_COMMAND 7
  41. #define ORD_PAGE_SHOWWINDOW 8
  42. #define ORD_PAGE_FINISHMSG 9
  43. #define ORD_PAGE_TARGET 10
  44. #define ORD_PAGE_TARGET_CAB 11
  45. #define ORD_PAGE_CABLABEL 12
  46. #define ORD_PAGE_REBOOT 13
  47. #define ORD_PAGE_SAVE 14
  48. #define ORD_PAGE_CREATE 15
  49. #define NUM_WIZARD_PAGES 16 // total number of pages in wizard
  50. //***************************************************************************
  51. //* MACRO DEFINITIONS *
  52. //***************************************************************************
  53. #define SetPropSheetResult( hwnd, result ) SetWindowLongPtr( hwnd, DWLP_MSGRESULT, result )
  54. #define MsgBox( hWnd, nMsgID, uIcon, uButtons ) \
  55. MsgBox2Param( hWnd, nMsgID, NULL, NULL, uIcon, uButtons )
  56. #define MsgBox1Param( hWnd, nMsgID, szParam, uIcon, uButtons ) \
  57. MsgBox2Param( hWnd, nMsgID, szParam, NULL, uIcon, uButtons )
  58. #define ErrorMsg( hWnd, nMsgID ) \
  59. MsgBox2Param( hWnd, nMsgID, NULL, NULL, MB_ICONERROR, MB_OK )
  60. #define ErrorMsg1Param( hWnd, nMsgID, szParam ) \
  61. MsgBox2Param( hWnd, nMsgID, szParam, NULL, MB_ICONERROR, MB_OK )
  62. #define ErrorMsg2Param( hWnd, nMsgID, szParam1, szParam2 ) \
  63. MsgBox2Param( hWnd, nMsgID, szParam1, szParam2, MB_ICONERROR, MB_OK )
  64. //***************************************************************************
  65. //* TYPE DEFINITIONS *
  66. //***************************************************************************
  67. // Structure to hold information about wizard state:
  68. // keeps a history of which pages were visited, so user can
  69. // back up and we know the last page completed in case of reboot.
  70. typedef struct _WIZARDSTATE {
  71. UINT uCurrentPage; // index of current page wizard
  72. UINT uPageHistory[NUM_WIZARD_PAGES]; // array of page #'s we visited
  73. UINT uPagesCompleted; // # of pages in uPageHistory
  74. DWORD dwRunFlags; // flags passed to us
  75. } WIZARDSTATE, *PWIZARDSTATE;
  76. // handler proc for OK, cancel, etc button handlers
  77. typedef BOOL (* INITPROC)( HWND, BOOL );
  78. typedef BOOL (* CMDPROC)( HWND, UINT, BOOL *, UINT *, BOOL * );
  79. typedef BOOL (* NOTIFYPROC)( HWND, WPARAM, LPARAM );
  80. typedef BOOL (* OKPROC)( HWND, BOOL, UINT *, BOOL * );
  81. typedef BOOL (* CANCELPROC)( HWND );
  82. // Structure with information for each wizard page:
  83. // handler procedures for each page-- any of these can be
  84. // NULL in which case the default behavior is used
  85. typedef struct _PAGEINFO {
  86. UINT uDlgID; // dialog ID to use for page
  87. INITPROC InitProc;
  88. CMDPROC CmdProc;
  89. NOTIFYPROC NotifyProc;
  90. OKPROC OKProc;
  91. CANCELPROC CancelProc;
  92. } PAGEINFO, *PPAGEINFO;
  93. typedef struct _CDFSTRINGINFO {
  94. LPCSTR lpSec;
  95. LPCSTR lpKey;
  96. LPCSTR lpDef;
  97. LPSTR lpBuf;
  98. UINT uSize;
  99. LPCSTR lpOverideSec;
  100. BOOL* lpFlag;
  101. } CDFSTRINGINFO, *PCDFSTRINGINFO;
  102. typedef struct _CDFOPTINFO {
  103. LPCSTR lpKey;
  104. DWORD dwOpt;
  105. } CDFOPTINFO, *PCDFOPTINFO;
  106. //***************************************************************************
  107. //* GLOBAL CONSTANTS *
  108. //***************************************************************************
  109. // These two variables are used to check the validity of the CABPack
  110. // Directive File. The version should be incremented when the format
  111. // of the file changes. The Check String is just a small character
  112. // string that is used to make sure we're reading a CDF file.
  113. // Since Channel Guy use the CDF as Channel Definition File, we change our
  114. // IExpress batch directive file extension to SED (Self Extracting Directive file)
  115. #define DIAMONDEXE "diamond.exe"
  116. #define DIANTZEXE "makecab.exe"
  117. #define WEXTRACTEXE "wextract.exe"
  118. //***************************************************************************
  119. //* CDF batch file Key Name defines *
  120. //***************************************************************************
  121. #define IEXPRESS_VER "3"
  122. #define IEXPRESS_CLASS "IEXPRESS"
  123. // pre-defined section name
  124. #define SEC_OPTIONS "Options"
  125. #define SEC_STRINGS "Strings"
  126. #define SEC_COMMANDS "AppCommands"
  127. // pre-define key name for version section
  128. #define KEY_CLASS "Class"
  129. #define KEY_VERSION "CDFVersion"
  130. #define KEY_NEWVER "SEDVersion"
  131. // pre-defined Key name for options section
  132. #define KEY_SHOWWIN "ShowInstallProgramWindow"
  133. #define KEY_NOEXTRACTUI "HideExtractAnimation"
  134. #define KEY_EXTRACTONLY "ExtractOnly"
  135. #define KEY_REBOOTMODE "RebootMode"
  136. #define KEY_LOCALE "Locale"
  137. #define KEY_USELFN "UseLongFileName"
  138. #define KEY_QUANTUM "Quantum"
  139. #define KEY_PLATFORM_DIR "PlatformDir"
  140. #define KEY_FILELIST "SourceFiles"
  141. #define KEY_STRINGS "Strings"
  142. #define KEY_FILEBASE "FILE%d"
  143. #define KEY_VERSIONINFO "VersionInfo"
  144. #define KEY_INSTPROMPT "InstallPrompt"
  145. #define KEY_DSPLICENSE "DisplayLicense"
  146. #define KEY_APPLAUNCH "AppLaunched"
  147. #define KEY_POSTAPPLAUNCH "PostInstallCmd"
  148. #define KEY_ENDMSG "FinishMessage"
  149. #define KEY_PACKNAME "TargetName"
  150. #define KEY_FRIENDLYNAME "FriendlyName"
  151. #define KEY_PACKINSTSPACE "PackageInstallSpace(KB)"
  152. #define KEY_PACKPURPOSE "PackagePurpose"
  153. #define KEY_CABFIXEDSIZE "CAB_FixedSize"
  154. #define KEY_CABRESVCODESIGN "CAB_ResvCodeSigning"
  155. #define KEY_LAYOUTINF "IEXP_LayoutINF"
  156. #define KEY_CABLABEL "SourceMediaLabel"
  157. #define KEY_NESTCOMPRESSED "InsideCompressed"
  158. #define KEY_KEEPCABINET "KeepCabinet"
  159. #define KEY_UPDHELPDLLS "UpdateAdvDlls"
  160. #define KEY_INSTANCECHK "MultiInstanceCheck"
  161. #define KEY_ADMQCMD "AdminQuietInstCmd"
  162. #define KEY_USERQCMD "UserQuietInstCmd"
  163. #define KEY_CHKADMRIGHT "CheckAdminRights"
  164. #define KEY_NTVERCHECK "TargetNTVersion"
  165. #define KEY_WIN9XVERCHECK "TargetWin9xVersion"
  166. #define KEY_SYSFILE "TargetFileVersion"
  167. #define KEY_PASSRETURN "PropogateCmdExitCode"
  168. #define KEY_PASSRETALWAYS "AlwaysPropogateCmdExitCode"
  169. #define KEY_STUBEXE "ExtractorStub"
  170. #define KEY_CROSSPROCESSOR "PackageForX86"
  171. #define KEY_COMPRESSTYPE "CompressionType"
  172. #define KEY_CMDSDEPENDED "AppErrorCheck"
  173. #define KEY_COMPRESS "Compress"
  174. #define KEY_COMPRESSMEMORY "CompressionMemory"
  175. // ADVANCED DLL names
  176. #define ADVANCEDLL "ADVPACK.DLL"
  177. #define ADVANCEDLL32 "W95INF32.DLL"
  178. #define ADVANCEDLL16 "W95INF16.DLL"
  179. //static CHAR achMSZIP[] = "MSZIP";
  180. //static CHAR achQUANTUM[] = "QUANTUM";
  181. // package purpose key string value
  182. #define STR_INSTALLAPP "InstallApp"
  183. #define STR_EXTRACTONLY "ExtractOnly"
  184. #define STR_CREATECAB "CreateCAB"
  185. // code sign resv space
  186. #define CAB_0K "0"
  187. #define CAB_2K "2048"
  188. #define CAB_4K "4096"
  189. #define CAB_6K "6144"
  190. // define temp filename for diamond to use
  191. #define CABPACK_INFFILE "~%s_LAYOUT.INF"
  192. #define CABPACK_TMPFILE "~%s%s"
  193. // file extentions with dot
  194. #define EXT_RPT ".RPT"
  195. #define EXT_DDF ".DDF"
  196. #define EXT_CAB ".CAB"
  197. #define EXT_CDF ".CDF"
  198. #define EXT_SED ".SED"
  199. // file extentions without dot '.' used as default file extention
  200. #define EXT_SED_NODOT "SED"
  201. #define EXT_CAB_NODOT "CAB"
  202. #define EXT_TXT_NODOT "TXT"
  203. #define EXT_EXE_NODOT "EXE"
  204. #define EXT_INF_NODOT "INF"
  205. #define CAB_DEFSETUPMEDIA "Application Source Media"
  206. #define CH_STRINGKEY '%'
  207. #define SYS_DEFAULT "ZZZZZZ"
  208. #define KBYTES 1000
  209. //***************************************************************************
  210. //* FUNCTION PROTOTYPES *
  211. //***************************************************************************
  212. BOOL RunCABPackWizard( VOID );
  213. INT_PTR CALLBACK GenDlgProc( HWND, UINT, WPARAM, LPARAM );
  214. VOID InitWizardState( PWIZARDSTATE );
  215. VOID NEAR PASCAL MEditSubClassWnd( HWND, FARPROC );
  216. LRESULT CALLBACK MEditSubProc( HWND, UINT, WPARAM, LPARAM );
  217. UINT GetDlgIDFromIndex( UINT );
  218. VOID EnableWizard( HWND, BOOL );
  219. DWORD MsgWaitForMultipleObjectsLoop( HANDLE );
  220. INT MsgBox2Param( HWND, UINT, LPCSTR, LPCSTR, UINT, UINT );
  221. VOID DisplayFieldErrorMsg( HWND, UINT, UINT );
  222. VOID InitBigFont( HWND, UINT );
  223. VOID DestroyBigFont( VOID );
  224. BOOL EnableDlgItem( HWND, UINT, BOOL );
  225. LPSTR LoadSz( UINT, LPSTR, UINT );
  226. BOOL WINAPI IsDuplicate( HWND, INT, LPSTR, BOOL );
  227. BOOL WriteCDF( HWND );
  228. BOOL ReadCDF( HWND );
  229. BOOL WriteDDF( HWND );
  230. BOOL MyOpen( HWND, UINT, LPSTR, DWORD, DWORD, INT *, INT *, PSTR );
  231. BOOL MySave( HWND, UINT, LPSTR, DWORD, DWORD, INT *, INT *, PSTR );
  232. BOOL MakePackage( HWND );
  233. BOOL MakeCAB( HWND );
  234. BOOL MakeEXE( HWND );
  235. VOID Status( HWND, UINT, LPSTR );
  236. //int CALLBACK CompareFunc( LPARAM, LPARAM, LPARAM );
  237. VOID InitItemList( VOID );
  238. VOID DeleteAllItems( VOID );
  239. PMYITEM GetFirstItem( VOID );
  240. PMYITEM GetNextItem( PMYITEM );
  241. VOID FreeItem( PMYITEM * );
  242. LPSTR GetItemSz( PMYITEM, UINT );
  243. FILETIME GetItemTime( PMYITEM );
  244. VOID SetItemTime( PMYITEM, FILETIME );
  245. BOOL LastItem( PMYITEM );
  246. PMYITEM AddItem( LPCSTR, LPCSTR );
  247. VOID RemoveItem( PMYITEM );
  248. BOOL ParseCmdLine( LPSTR lpszCmdLineOrg );
  249. BOOL DoVersionInfo(HWND hDlg, LPSTR szFile,HANDLE hUpdate);
  250. LONG RO_GetPrivateProfileSection( LPCSTR, LPSTR, DWORD, LPCSTR , BOOL );
  251. BOOL GetFileFromModulePath( LPCSTR pFile, LPSTR pPathBuf, int iBufSize );
  252. BOOL GetThisModulePath( LPSTR lpPath, int size );
  253. BOOL GetVersionInfoFromFile();
  254. void CleanFileListWriteFlag();
  255. BOOL MakeCabName( HWND hwnd, PSTR pszTarget, PSTR pszCab );
  256. BOOL MakeDirectory( HWND hwnd,LPCSTR pszPath, BOOL bDoUI );
  257. #endif // _CABPACK_H_