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.

445 lines
12 KiB

  1. /***************************************************************************
  2. INCLUDE FILE: dospif.h - DOSPIF include file
  3. This file contains definitions (#define, #typedef, external variable and
  4. function declarations) used in Windows Setup for setting up DOS PIFs.
  5. ********* IMPORTANT **********
  6. This file contains typedefs and bit masks which were copied from the pif
  7. editor include files. Do not change before consulting with pif editor
  8. sources.
  9. Copyright (C) Microsoft, 1991
  10. HISTORY:
  11. Modified by: Date: Comment:
  12. PAK 8/21/91 Created
  13. SUNILP 2/6/92 Modified, retained just PIF stuff.
  14. Added rgszApp fields ENUM.
  15. ***************************************************************************/
  16. /* lengths of certain PIF entries */
  17. #define PIFNAMESIZE 30
  18. #define PIFSTARTLOCSIZE 63
  19. #define PIFDEFPATHSIZE 64
  20. #define PIFPARAMSSIZE 64
  21. #define PIFSHPROGSIZE 64
  22. #define PIFSHDATASIZE 64
  23. #define PIFEXTSIGSIZE 16
  24. /* Miscellaneous defines */
  25. #define LASTHEADERPTR 0xFFFF
  26. #define STDHDRSIG "MICROSOFT PIFEX"
  27. #define W386HDRSIG "WINDOWS 386 3.0"
  28. #define W286HDRSIG30 "WINDOWS 286 3.0"
  29. #define DFLT_ICON_FILE "PROGMAN.EXE"
  30. /* Standard and enhanced modes */
  31. #define MODE_STANDARD "STANDARD"
  32. #define MODE_ENHANCED "ENHANCED"
  33. /* String switches used in APPS.INF to set PIF options */
  34. #define GRAF_MULTXT "gra"
  35. #define COM1 "c1"
  36. #define COM2 "c2"
  37. #define COM3 "c3"
  38. #define COM4 "c4"
  39. #define NO_SCRN_EXCHANGE "nse"
  40. #define KEYB "kbd"
  41. #define PREVENT_PROG_SW "pps"
  42. #define FULL_SCREEN "fs"
  43. #define WINDOWED_OPT "win"
  44. #define BACKGROUND "bgd"
  45. #define EXCLUSIVE "exc"
  46. #define DETECT_IDLE_TIME "dit"
  47. #define EMS_LOCKED "eml"
  48. #define XMS_LOCKED "xml"
  49. #define USE_HIMEM_AREA "hma"
  50. #define LOCK_APP_MEM "lam"
  51. #define LO_RES_GRAPH "lgr"
  52. #define HI_RES_GRAPH "hgr"
  53. #define EMULATE_TEXT_MODE "emt"
  54. #define RETAIN_VIDEO_MEM "rvm"
  55. #define ALLOW_FAST_PASTE "afp"
  56. #define ALLOW_CLOSE_ACTIVE "cwa"
  57. #define ALT_SPACE "asp"
  58. #define ALT_ENTER "aen"
  59. #define NO_SAVE_SCREEN "nss"
  60. #define TEXT_OPT "txt"
  61. #define CLOSE_ON_EXIT "cwe"
  62. #define ALT_TAB "ata"
  63. #define ALT_ESC "aes"
  64. #define CTRL_ESC "ces"
  65. #define PRSCRN "psc"
  66. #define ALT_PRSCRN "aps"
  67. /* Standard and Enhanced section options */
  68. #define UNKNOWN_OPTION -1
  69. #define PARAMS 1
  70. #define MINCONVMEM 2
  71. #define VIDEOMODE 3
  72. #define XMSMEM 4
  73. #define CHECKBOXES 5
  74. #define EMSMEM 6
  75. #define CONVMEM 7
  76. #define DISPLAY_USAGE 8
  77. #define EXEC_FLAGS 9
  78. #define MULTASK_OPT 10
  79. #define PROC_MEM_FLAGS 11
  80. #define DISP_OPT_VIDEO 12
  81. #define DISP_OPT_PORTS 13
  82. #define DISP_OPT_FLAGS 14
  83. #define OTHER_OPTIONS 15
  84. /* Bit masks for MSFlags field of PIFNEWSTRUCT */
  85. #define GRAPHMASK 0x02
  86. #define TEXTMASK 0xfd
  87. #define PSMASK 0x04
  88. #define SGMASK 0x08
  89. #define EXITMASK 0x10
  90. #define COM2MASK 0x40
  91. #define COM1MASK 0x80
  92. /* Bit masks for behavior field of PIFNEWSTRUCT */
  93. #define KEYMASK 0x10
  94. /* Bit masks for PfW286Flags field of PIF286EXT30 */
  95. #define fALTTABdis286 0x0001
  96. #define fALTESCdis286 0x0002
  97. #define fALTPRTSCdis286 0x0004
  98. #define fPRTSCdis286 0x0008
  99. #define fCTRLESCdis286 0x0010
  100. #define fNoSaveVid286 0x0020
  101. #define fCOM3_286 0x4000
  102. #define fCOM4_286 0x8000
  103. /* Bit masks for PfW386Flags field of PIF386EXT */
  104. #define fEnableClose 0x00000001L
  105. #define fBackground 0x00000002L
  106. #define fExclusive 0x00000004L
  107. #define fFullScreen 0x00000008L
  108. #define fALTTABdis 0x00000020L
  109. #define fALTESCdis 0x00000040L
  110. #define fALTSPACEdis 0x00000080L
  111. #define fALTENTERdis 0x00000100L
  112. #define fALTPRTSCdis 0x00000200L
  113. #define fPRTSCdis 0x00000400L
  114. #define fCTRLESCdis 0x00000800L
  115. #define fPollingDetect 0x00001000L
  116. #define fNoHMA 0x00002000L
  117. #define fHasHotKey 0x00004000L
  118. #define fEMSLocked 0x00008000L
  119. #define fXMSLocked 0x00010000L
  120. #define fINT16Paste 0x00020000L
  121. #define fVMLocked 0x00040000L
  122. /* Bit masks for PfW386Flags2 field of PIF386EXT */
  123. #define fVidTxtEmulate 0x00000001L
  124. #define fVidNoTrpTxt 0x00000002L
  125. #define fVidNoTrpLRGrfx 0x00000004L
  126. #define fVidNoTrpHRGrfx 0x00000008L
  127. #define fVidTextMd 0x00000010L
  128. #define fVidLowRsGrfxMd 0x00000020L
  129. #define fVidHghRsGrfxMd 0x00000040L
  130. #define fVidRetainAllo 0x00000080L
  131. /* PIF Extension Header */
  132. typedef struct {
  133. char extsig[PIFEXTSIGSIZE];
  134. WORD extnxthdrfloff;
  135. WORD extfileoffset;
  136. WORD extsizebytes;
  137. } PIFEXTHEADER, *LPPIFEXTHEADER;
  138. /* PIF Structure */
  139. typedef struct {
  140. char unknown;
  141. char id;
  142. char name[PIFNAMESIZE];
  143. WORD maxmem;
  144. WORD minmem;
  145. char startfile[PIFSTARTLOCSIZE];
  146. char MSflags;
  147. char reserved;
  148. char defpath[PIFDEFPATHSIZE];
  149. char params[PIFPARAMSSIZE];
  150. char screen;
  151. char cPages;
  152. BYTE lowVector;
  153. BYTE highVector;
  154. char rows;
  155. char cols;
  156. char rowoff;
  157. char coloff;
  158. WORD sysmem;
  159. char shprog[PIFSHPROGSIZE];
  160. char shdata[PIFSHDATASIZE];
  161. BYTE behavior;
  162. BYTE sysflags;
  163. PIFEXTHEADER stdpifext;
  164. } PIFNEWSTRUCT, *LPPIFNEWSTRUCT;
  165. /* WINDOWS/286 3.0 PIF Extension */
  166. typedef struct {
  167. WORD PfMaxXmsK;
  168. WORD PfMinXmsK;
  169. WORD PfW286Flags;
  170. } PIF286EXT30, *LPPIF286EXT30;
  171. /* WINDOWS/386 3.0 PIF Extension */
  172. typedef struct {
  173. WORD maxmem;
  174. WORD minmem;
  175. WORD PfFPriority;
  176. WORD PfBPriority;
  177. WORD PfMaxEMMK;
  178. WORD PfMinEMMK;
  179. WORD PfMaxXmsK;
  180. WORD PfMinXmsK;
  181. DWORD PfW386Flags;
  182. DWORD PfW386Flags2;
  183. WORD PfHotKeyScan;
  184. WORD PfHotKeyShVal;
  185. WORD PfHotKeyShMsk;
  186. BYTE PfHotKeyVal;
  187. BYTE PfHotKeyPad[9];
  188. char params[PIFPARAMSSIZE];
  189. } PIF386EXT, *LPPIF386EXT;
  190. typedef struct {
  191. PIFNEWSTRUCT DfltPIF;
  192. PIF286EXT30 DfltStd;
  193. PIF386EXT DfltEnha;
  194. PIFNEWSTRUCT CurrPIF;
  195. PIFEXTHEADER StdExtHdr;
  196. PIF286EXT30 CurrStd;
  197. PIFEXTHEADER EnhaExtHdr;
  198. PIF386EXT CurrEnha;
  199. } PIF386Combined, *LPPIF386Combined;
  200. typedef struct {
  201. PIFNEWSTRUCT DfltPIF;
  202. PIF286EXT30 DfltStd;
  203. PIF386EXT DfltEnha;
  204. PIFNEWSTRUCT CurrPIF;
  205. PIFEXTHEADER StdExtHdr;
  206. PIF286EXT30 CurrStd;
  207. } PIF286Combined, *LPPIF286Combined;
  208. #pragma pack(1)
  209. /* PIF Structure */
  210. typedef struct {
  211. char unknown;
  212. char id;
  213. char name[PIFNAMESIZE];
  214. WORD maxmem;
  215. WORD minmem;
  216. char startfile[PIFSTARTLOCSIZE];
  217. char MSflags;
  218. char reserved;
  219. char defpath[PIFDEFPATHSIZE];
  220. char params[PIFPARAMSSIZE];
  221. char screen;
  222. char cPages;
  223. BYTE lowVector;
  224. BYTE highVector;
  225. char rows;
  226. char cols;
  227. char rowoff;
  228. char coloff;
  229. WORD sysmem;
  230. char shprog[PIFSHPROGSIZE];
  231. char shdata[PIFSHDATASIZE];
  232. BYTE behavior;
  233. BYTE sysflags;
  234. PIFEXTHEADER stdpifext;
  235. } PACKED_PIFNEWSTRUCT, *LPPACKED_PIFNEWSTRUCT;
  236. #pragma pack()
  237. //
  238. // The following types and macros are used to help unpack the packed and
  239. // misaligned fields found in the PIFNEWSTRUCT
  240. //
  241. typedef union _UCHAR1 {
  242. UCHAR Uchar[1];
  243. UCHAR ForceAlignment;
  244. } UCHAR1, *PUCHAR1;
  245. typedef union _UCHAR2 {
  246. UCHAR Uchar[2];
  247. USHORT ForceAlignment;
  248. } UCHAR2, *PUCHAR2;
  249. typedef union _UCHAR4 {
  250. UCHAR Uchar[4];
  251. ULONG ForceAlignment;
  252. } UCHAR4, *PUCHAR4;
  253. #define CopyUchar1(Dst,Src) { \
  254. ((PUCHAR1)(Dst))->Uchar[0] = ((PUCHAR1)(Src))->Uchar[0]; \
  255. }
  256. #define CopyUchar2(Dst,Src) { \
  257. ((PUCHAR2)(Dst))->Uchar[0] = ((PUCHAR2)(Src))->Uchar[0]; \
  258. ((PUCHAR2)(Dst))->Uchar[1] = ((PUCHAR2)(Src))->Uchar[1]; \
  259. }
  260. #define CopyUchar4(Dst,Src) { \
  261. ((PUCHAR4)(Dst))->Uchar[0] = ((PUCHAR4)(Src))->Uchar[0]; \
  262. ((PUCHAR4)(Dst))->Uchar[1] = ((PUCHAR4)(Src))->Uchar[1]; \
  263. ((PUCHAR4)(Dst))->Uchar[2] = ((PUCHAR4)(Src))->Uchar[2]; \
  264. ((PUCHAR4)(Dst))->Uchar[3] = ((PUCHAR4)(Src))->Uchar[3]; \
  265. }
  266. #define CopyUcharn(Dst, Src, n) { \
  267. memmove((PVOID)Dst, (PVOID)Src, n); \
  268. }
  269. #define PackPif(Pif,PPif) { \
  270. CopyUchar1(&((PPif)->unknown) ,&((Pif)->unknown) ); \
  271. CopyUchar1(&((PPif)->id) ,&((Pif)->id) ); \
  272. CopyUcharn(&((PPif)->name) ,&((Pif)->name) , PIFNAMESIZE ); \
  273. CopyUchar2(&((PPif)->maxmem) ,&((Pif)->maxmem) ); \
  274. CopyUchar2(&((PPif)->minmem) ,&((Pif)->minmem) ); \
  275. CopyUcharn(&((PPif)->startfile) ,&((Pif)->startfile) , PIFSTARTLOCSIZE ); \
  276. CopyUchar1(&((PPif)->MSflags) ,&((Pif)->MSflags) ); \
  277. CopyUchar1(&((PPif)->reserved) ,&((Pif)->reserved) ); \
  278. CopyUcharn(&((PPif)->defpath) ,&((Pif)->defpath) , PIFDEFPATHSIZE ); \
  279. CopyUcharn(&((PPif)->params) ,&((Pif)->params) , PIFPARAMSSIZE ); \
  280. CopyUchar1(&((PPif)->screen) ,&((Pif)->screen) ); \
  281. CopyUchar1(&((PPif)->cPages) ,&((Pif)->cPages) ); \
  282. CopyUchar1(&((PPif)->lowVector) ,&((Pif)->lowVector) ); \
  283. CopyUchar1(&((PPif)->highVector) ,&((Pif)->highVector) ); \
  284. CopyUchar1(&((PPif)->rows) ,&((Pif)->rows) ); \
  285. CopyUchar1(&((PPif)->cols) ,&((Pif)->cols) ); \
  286. CopyUchar1(&((PPif)->rowoff) ,&((Pif)->rowoff) ); \
  287. CopyUchar1(&((PPif)->coloff) ,&((Pif)->coloff) ); \
  288. CopyUchar2(&((PPif)->sysmem) ,&((Pif)->sysmem) ); \
  289. CopyUcharn(&((PPif)->shprog) ,&((Pif)->shprog) , PIFSHPROGSIZE ); \
  290. CopyUcharn(&((PPif)->shdata) ,&((Pif)->shdata) , PIFSHDATASIZE ); \
  291. CopyUchar1(&((PPif)->behavior) ,&((Pif)->behavior) ); \
  292. CopyUchar1(&((PPif)->sysflags) ,&((Pif)->sysflags) ); \
  293. CopyUcharn(&((PPif)->stdpifext) ,&((Pif)->stdpifext) , sizeof(PIFEXTHEADER)); \
  294. }
  295. enum tagAppRgszFields {
  296. nEXETYPE,
  297. nNAME,
  298. nEXE,
  299. nDIR,
  300. nPIF,
  301. nDEFDIR,
  302. nCWE,
  303. nSTDOPT,
  304. nENHOPT,
  305. nICOFIL,
  306. nICONUM
  307. };
  308. typedef enum {
  309. ADDAPP_SUCCESS,
  310. ADDAPP_GENFAIL,
  311. ADDAPP_GRPFAIL
  312. } ADDAPP_STATUS;
  313. /* Make New Long Pointer MACRO */
  314. #define MKNLP(lp,w) (LONG)((DWORD)lp + (DWORD)w)
  315. /* DOS PIF INTERNAL ROUTINE DECLARATIONS */
  316. ADDAPP_STATUS
  317. AddDosAppItem(
  318. IN RGSZ rgszApp,
  319. IN SZ szPifDir,
  320. IN SZ szGroup
  321. );
  322. ADDAPP_STATUS
  323. AddWinItem(
  324. IN RGSZ rgszApp,
  325. IN SZ szGroup
  326. );
  327. BOOL
  328. FDeterminePIFName(
  329. IN RGSZ rgszApp,
  330. IN SZ szPifDir,
  331. IN OUT SZ szPIFPath
  332. );
  333. BOOL
  334. FCreatePIF(
  335. RGSZ rgszApp,
  336. SZ szPIFPath
  337. );
  338. VOID
  339. ProcessCommonInfo(
  340. RGSZ rgszApp,
  341. LPPIFNEWSTRUCT fpPNS
  342. );
  343. BOOL
  344. FProcessStdModeInfo(
  345. SZ szStdOptions,
  346. LPPIFNEWSTRUCT fpPNS,
  347. LPPIF286EXT30 fpPStd
  348. );
  349. VOID
  350. ProcessCheckBoxSwitches(
  351. RGSZ rgsz,
  352. LPPIFNEWSTRUCT fpPNS,
  353. LPPIF286EXT30 fpPStd
  354. );
  355. BOOL
  356. FProcessEnhaModeInfo(
  357. SZ szEnhOptions,
  358. LPPIF386EXT fpPEnha
  359. );
  360. INT
  361. GetExtOption(
  362. LPSTR lpsz
  363. );
  364. BOOL
  365. FInitializePIFStructs(
  366. BOOL bIsEnhanced,
  367. SZ szDfltStdOpt,
  368. SZ szDfltEnhOpt
  369. );
  370. VOID
  371. FreePIFStructs(
  372. VOID
  373. );
  374. VOID
  375. ExtractStrFromPIF(
  376. LPSTR lpsz,
  377. int n
  378. );