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.

443 lines
12 KiB

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