After the classic header, a PIF holds a chain of named sections. Each has a 22-byte
heading giving its name and where its data is. A program reads along the chain until it
finds a section it knows. Microsoft did not publish these layouts. They come from Michael
Maurice’s PIFSTRUC.H (Dr. Dobb’s Journal, July 1993) for the 386, 286 and
NT 3.1 sections, from Sergey Merzlikin’s table for the Windows 95 and NT 4.0 sections,
and from 165 distinct real PIF files, which agree with both. Every field of every
section is listed here; the few whose meaning no source gives are marked unknown with
the values seen.
Section heading
0Name a zero-terminated name in 16 bytes1616Next heading a file offset, orFFFFat the end218Data offset a file offset220Data size in bytes2
The first heading is always at offset 0x171 and named
MICROSOFT PIFEX. Its data offset is 0 and its size 0x171: it stands for
the classic header, which has no heading of its own. Finding this name at
0x171 is how a Windows PIF is recognised (WinOldAp, the Windows module that
runs DOS programs, uses the same test as a sanity check).
The headings are chained by their next-heading offsets: a reader goes to the offset in
Next heading until it reads FFFF. The data of a section is found by
its data offset, not by its position, so the layout of a file may differ from the usual
one. The sections other than the first may come in any order, and each may be left out
(a missing section means its defaults, or the values of another section). A section the
PIF editor has switched off keeps its place with the first letter of its name zeroed
(\0INDOWS 286 3.0), and another section of the same kind follows
(Dr. Dobb’s). The smallest PIF every Windows version accepts is 0x187 bytes (the header
and the first heading); Windows 1.x and 2.x, TopView and DESQview wrote files of exactly
0x171 bytes with no chain, and Windows 3.x and 95 read those too. The Windows 3.x PIF editor
reads and writes at most 0x3FF bytes (Dr. Dobb’s: 0x400 does not work).
A hex example, the start of the chain in DOSPRMPT.PIF from Windows 3.1:
000171 4D 49 43 52 4F 53 4F 46 54 20 50 49 46 45 58 00 MICROSOFT PIFEX.
000181 87 01 00 00 71 01 next 0x0187, data 0, size 0x0171
000187 57 49 4E 44 4F 57 53 20 32 38 36 20 33 2E 30 00 WINDOWS 286 3.0.
000197 A3 01 9D 01 06 00 next 0x01A3, data 0x019D, size 6
00019D 00 00 00 00 00 00 the 286 data
0001A3 57 49 4E 44 4F 57 53 20 33 38 36 20 33 2E 30 00 WINDOWS 386 3.0.
0001B3 FF FF B9 01 68 00 last, data 0x01B9, size 0x68
The sections
| Name | Data size | Used by | Fields |
|---|---|---|---|
MICROSOFT PIFEX | 0x171 | every version | Classic header |
WINDOWS 286 3.0 | 6 | Windows 3.x standard mode | below |
WINDOWS 386 3.0 | 0x68 | Windows 3.x enhanced mode, Windows 95 and later, NT | below |
WINDOWS VMM 4.0 | 0x1AC | Windows 95 and 98, written by NT 4.0 and later too | below |
WINDOWS NT 3.1 | 0x8C or 0x8E | Windows NT | below |
WINDOWS NT 4.0 | 0x68C | Windows NT 4.0 and later | below |
CONFIG SYS 4.0 | varies | Windows 95 MS-DOS mode | below |
AUTOEXECBAT 4.0 | varies | Windows 95 MS-DOS mode | below |
Note the two spaces in WINDOWS NT 3.1, WINDOWS NT 4.0 and
CONFIG SYS 4.0. Among 165 real files the section orders found are: 386 then
286 (25), 386 then VMM (118), 286 only (2), 286 then 386 (2), 386, 286 and NT 3.1 (1), 386,
286 and VMM (3), and 386, VMM, NT 4.0 and NT 3.1 (14: files saved by Windows NT 4.0 or later).
An unknown section is skipped by every reader, so a file may carry sections this page
does not list; the viewer keeps their bytes. A comment section is mentioned by Dr. Dobb’s
(a name and offsets plugged in by hand) and has not been seen in a real file.
WINDOWS 386 3.0
Data size 0x68. The settings of enhanced mode, still used by Windows 95, 98 and NT for the memory limits, priorities, shortcut keys, hot key and the parameters.
| Offset | Size | Name | Description |
|---|---|---|---|
| 0x00 | 2 | Memory limit | KB of conventional memory it may use. 0x0280 (640) in 32-bit Windows, meaning automatic, FFFF in Windows 3.x to take all. |
| 0x02 | 2 | Memory required | KB it needs. 0 in 32-bit Windows (automatic), 0x80 or FFFF in Windows 3.x. |
| 0x04 | 2 | Foreground priority | 1 to 10000, 100 by default. |
| 0x06 | 2 | Background priority | 1 to 10000, 50 by default. |
| 0x08 | 2 | EMS limit | KB of expanded memory, at most 16384; FFFF is automatic (32-bit Windows) or all (3.x); 1024 is the Windows 3.x default. |
| 0x0A | 2 | EMS required | KB it needs; 0 by default. |
| 0x0C | 2 | XMS limit | KB of extended memory, at most 16384; same codes. |
| 0x0E | 2 | XMS required | KB it needs. |
| 0x10 | 4 | 386 flags | A 32-bit mask, see below. 0x00021002 is the Windows 3.x default. |
| 0x14 | 2 | Video flags | See below. 0x001F by default. |
| 0x16 | 2 | Unknown | Zero in every real file. |
| 0x18 | 2 | Hot key scan code | The keyboard scan code of the key that brings the program to the front; 0 means none. See Hot key. |
| 0x1A | 2 | Hot key modifiers | Bit 0 Shift, bit 2 Ctrl, bit 3 Alt. |
| 0x1C | 2 | Hot key defined | 0x000F when a hot key is set, else 0. |
| 0x1E | 2 | Hot key extended | 1 when the scan code is that of an extended key (a cursor key and so on). |
| 0x20 | 2 | Unknown | Zero; 0x0064 in files written by Windows NT (Merzlikin; none of the real files has it). |
| 0x22 | 2 | Unknown | Zero; 0x0032 in files written by Windows NT (Merzlikin; none of the real files has it). |
| 0x24 | 4 | Unknown | Zero in every real file. |
| 0x28 | 64 | Optional parameters | A zero-terminated string; in 32-bit Windows and enhanced mode it replaces the parameters of the classic header. Windows 95, 98, NT and 2000 keep it in the ANSI character set although the header is OEM (a bug), and Windows 95 and 98 convert it again when they run the program. |
Dr. Dobb’s lists the first 16 bits of the flag field as FLAGS386 and the next
16 as FLAGSXMS and unused bits; Merzlikin treats them as one 32-bit mask, as does
this page (and Ralf Brown’s interrupt list, whose table for the Windows 3.x shell
confirms bits 5 to 18, including “VM not allowed to use high memory” for bit 13).
| Bit | Mask | Name | Meaning |
|---|---|---|---|
| 0 | 0x00000001 | AllowCloseAct | Permit exit when active |
| 1 | 0x00000002 | BackgroundON | Keep running in the background |
| 2 | 0x00000004 | ExclusiveON | Exclusive use of the processor |
| 3 | 0x00000008 | FullScreenYes | Full-screen rather than a window |
| 5 | 0x00000020 | RSV_ALTTAB | Alt+Tab left to the program |
| 6 | 0x00000040 | RSV_ALTESC | Alt+Esc left to the program |
| 7 | 0x00000080 | RSV_ALTSPACE | Alt+Space left to the program |
| 8 | 0x00000100 | RSV_ALTENTER | Alt+Enter left to the program |
| 9 | 0x00000200 | RSV_ALTPRTSCR | Alt+PrtSc left to the program |
| 10 | 0x00000400 | RSV_PRTSCR | PrtSc left to the program |
| 11 | 0x00000800 | RSV_CTRLESC | Ctrl+Esc left to the program |
| 12 | 0x00001000 | Detect_Idle | Detect idle time. In 32-bit Windows the bit is cleared when the highest priority is set. |
| 13 | 0x00002000 | UseHMA | The program may not use the high memory area (Dr. Dobb’s name; the interrupt list and Merzlikin say “not allowed”) |
| 14 | 0x00004000 | (Use shortcut key) | A hot key is set (Merzlikin) |
| 15 | 0x00008000 | EMS_Locked | Expanded memory is locked |
| 16 | 0x00010000 | XMS_Locked | Extended memory is locked |
| 17 | 0x00020000 | Allow_FastPst | Fast paste allowed |
| 18 | 0x00040000 | Lock_App | Lock the application memory |
| 19 | 0x00080000 | Memory protection | Windows 95 and later |
| 20 | 0x00100000 | Minimized window | Windows 95 and later: start minimised |
| 21 | 0x00200000 | Maximized window | Windows 95 and later: start maximised |
| 23 | 0x00800000 | MS-DOS mode | Windows 95: restart the computer in MS-DOS mode for the program |
| 24 | 0x01000000 | Prevent Windows detection | Windows 95: MS-DOS mode, hide Windows |
| 26 | 0x04000000 | No automatic offer of MS-DOS mode | Windows 95 |
| 28 | 0x10000000 | No warning before MS-DOS mode | Windows 95 |
| Video flags bit | Name | Meaning (Merzlikin) |
|---|---|---|
| 0 (0x01) | VidEmulateTxt | Video ROM emulation |
| 1 (0x02) | MonitorText | Do not check ports: text |
| 2 (0x04) | MonitorMGr | Do not check ports: low graphics |
| 3 (0x08) | MonitorHiGr | Do not check ports: high graphics |
| 4 (0x10) | InitModeText | Video memory: text |
| 5 (0x20) | InitModeMGr | Video memory: low graphics |
| 6 (0x40) | InitModeHiGr | Video memory: high graphics |
| 7 (0x80) | VidRetainVid | Retain video memory |
The Ralf Brown table for the shell’s display options names bits 0 to 3 and 7 as “emulate text mode”, “monitor text port”, “monitor low graphics port”, “monitor high graphics port” and “retain video memory”, so the Dr. Dobb’s names are the monitoring options and the “do not check” wording of Merzlikin is the same setting seen from the other side. Real files hold 0x001F (156 of 165), 0x0017 (2), 0x004F, 0x00C6, 0x00C9 and 0x00CE.
Hot key
The hot key is three fields of the 386 section: the scan code (0x18), the
modifier mask (0x1A) and the “defined” word (0x1C), plus the
extended flag at 0x1E. The scan code is the PC keyboard scan code
(set 1) of the key, so 0x13 is R, 0x16 U, 0x18 O, 0x1F S, 0x21 F and 0x23 H, all seen with
modifiers 0x0C (Ctrl+Alt) and 0x000F in the defined word. A scan code of an extended key
(Home, the cursor keys, Insert, Delete, the keypad Enter and /) has the flag at 0x1E set.
WINDOWS 286 3.0
Data size 6. The settings of standard mode.
| Offset | Size | Name | Description |
|---|---|---|---|
| 0 | 2 | XMS limit | KB of extended memory, at most 16384, FFFF for all; 0x0400 by default. |
| 2 | 2 | XMS required | KB it needs. |
| 4 | 2 | 286 flags | Bit 0 Alt+Tab, 1 Alt+Esc, 2 Alt+PrtSc, 3 PrtSc, 4 Ctrl+Esc (each left to the program), bit 5 do not save the screen, bit 14 COM3 used directly, bit 15 COM4 used directly. |
WINDOWS VMM 4.0
Data size 0x1AC. Windows 95 and 98 keep here what the new Properties window sets: the icon,
run options, fonts, mouse and the last window position. Offsets are within the section data;
all values are little-endian. The last window position fields are those of a 16-bit
WINDOWPLACEMENT (its first word, 22, is at 0x13C), which is how their meaning was
worked out against the real files.
| Offset | Size | Name | Description |
|---|---|---|---|
| 0x00 | 88 | Unknown | Zeros (one file in 135 differs). |
| 0x58 | 80 | Icon file | ANSI, zero-terminated; PIFMGR.DLL by default. May hold a full path and a long name without quotes. |
| 0xA8 | 2 | Icon index | The number of the icon in that file, from 0. |
| 0xAA | 2 | Run flags | Bit 1 (0x02) keep running in the background, bit 4 (0x10) no warning on exit, bit 5 (0x20) disallow the screen saver. 0x0002 by default. |
| 0xAC | 10 | Unknown | Zeros. |
| 0xB6 | 2 | Priority | 0 (highest) to 100 (lowest); 50 by default. |
| 0xB8 | 2 | Video flags | Bit 0 video ROM emulation, bit 7 (0x80) no dynamic video memory, bit 8 (0x100) full-screen. 0x0001 by default. |
| 0xBA | 8 | Unknown | Zeros. |
| 0xC2 | 2 | Text lines | 0 automatic, or 25, 43 or 50. |
| 0xC4 | 2 | Key flags | Bit 0 fast paste, then the keys left to the program: 0x20 Alt+Tab, 0x40 Alt+Esc, 0x80 Alt+Space, 0x100 Alt+Enter, 0x200 Alt+PrtSc, 0x400 PrtSc, 0x800 Ctrl+Esc. 0x0001 by default. |
| 0xC6 | 2 | Unknown | Zero. |
| 0xC8 | 14 | Unknown | Seven words, always 5, 25, 3, 200, 1000, 2, 10 in the 135 real files; no source names them. |
| 0xD6 | 2 | Mouse flags | Bit 0 the mouse is not used for selecting text, bit 1 exclusive use of the mouse. 0x0001 by default. |
| 0xD8 | 6 | Unknown | Zeros. |
| 0xDE | 2 | Font flags | 0x04 raster fonts allowed, 0x08 TrueType fonts allowed, 0x10 choose the size automatically, 0x400 the current font is raster, 0x800 it is TrueType. 0x001C by default. |
| 0xE0 | 2 | Unknown | Zero. |
| 0xE2 | 2 | Font width chosen | Pixels, 0 when automatic. |
| 0xE4 | 2 | Font height chosen | Pixels, 0 when automatic. |
| 0xE6 | 2 | Font width in use | Pixels; 8 in 121 of the 135 real files. |
| 0xE8 | 2 | Font height in use | Pixels; 12 in 121 files (an 8 by 12 raster font). |
| 0xEA | 32 | Raster font name | ANSI, Terminal; not used. |
| 0x10A | 32 | TrueType font name | ANSI, Lucida Console; not used. |
| 0x12A | 2 | Unknown | 0 from Windows 95; 0x04E3 (1251) from Windows NT and 2000 (Merzlikin). |
| 0x12C | 2 | Toolbar flags | Bit 0 unknown (set in every file), bit 1 show the toolbar. 0x0003 by default (0x0001 in a few files). |
| 0x12E | 2 | Restore flags | Bit 0: do not restore the saved window settings at start. |
| 0x130 | 2 | Screen columns | Of the window when last run (80, 320 or 640 in real files); 0 before the first run. |
| 0x132 | 2 | Screen rows | 25, 43, 50, 80, 300, 350 or 400 in real files (graphics modes put pixel counts here). |
| 0x134 | 2 | Client width | Pixels. |
| 0x136 | 2 | Client height | Pixels. |
| 0x138 | 2 | Window width | Pixels; in real files the client width plus 12. |
| 0x13A | 2 | Window height | Pixels. |
| 0x13C | 2 | Placement length | 22 (0x16): the size of the placement. |
| 0x13E | 2 | Placement flags | Bit 0 WPF_SETMINPOSITION, bit 1 WPF_RESTORETOMAXIMIZED. |
| 0x140 | 2 | Show state | 1 normal, 2 minimised, 3 maximised (SW_SHOWNORMAL and so on). Merzlikin reads 0x13E and 0x140 as the “maximised” and “normal” state bits. |
| 0x142 | 4 | Minimised position | Two signed words x and y; -1, -1 when not set. |
| 0x146 | 4 | Maximised position | x and y; -1 or -4 in real files. Merzlikin calls these two words the right and bottom edge of the maximised window. |
| 0x14A | 8 | Normal position | Four signed words: left, top, right, bottom in pixels. Top is -6 in some files (the window sat against the top edge). |
| 0x152 | 4 | Unknown | Zeros. |
| 0x156 | 80 | Batch file | OEM, zero-terminated; a batch file for MS-DOS mode. Names with spaces are quoted. |
| 0x1A6 | 2 | Environment size | KB, 0 for automatic, at most 4096. |
| 0x1A8 | 2 | DPMI memory | KB, 0 for automatic, at most 16384. |
| 0x1AA | 2 | Unknown | One in every real file. |
WINDOWS NT 3.1
Data size 0x8C (140) in files from NT 3.1, 0x8E (142) in files saved by NT 4.0 and later (the two bytes at 0x8C are zero).
| Offset | Size | Name | Description |
|---|---|---|---|
| 0x00 | 2 | Flags | Bit 4 (0x10): compatible hardware timer emulation. Zero in every real file. |
| 0x02 | 10 | Unknown | Zeros. |
| 0x0C | 64 | CONFIG file | ANSI path of the file NT uses in place of CONFIG.SYS; %SystemRoot%\SYSTEM32\CONFIG.NT in every real file. |
| 0x4C | 64 | AUTOEXEC file | The file used in place of AUTOEXEC.BAT; %SystemRoot%\SYSTEM32\AUTOEXEC.NT. |
| 0x8C | 2 | Unknown | Only in the 0x8E form; zero. |
WINDOWS NT 4.0
Data size 0x68C (1676). Windows NT 4.0 and later keep a Unicode copy of the command line, PIF path, title, icon file and directory next to the ANSI copy. The Unicode text is used only when, once converted, it equals the ANSI copy (which in turn must equal what the rest of the file says); so a program that edits the PIF without updating this section makes NT ignore it. In the 14 real files the pairs are identical.
| Offset | Size | Name | Description |
|---|---|---|---|
| 0x000 | 4 | Unknown | Zero. |
| 0x004 | 256 | Command line (Unicode) | UTF-16LE, zero-terminated: the program and its parameters; names with spaces in quotes. |
| 0x104 | 128 | Command line (ANSI) | The same in the ANSI set. |
| 0x184 | 240 | Unknown | Merzlikin: “most likely random values”; all zero in the real files. |
| 0x274 | 160 | PIF file name (Unicode) | The full path of the PIF file. |
| 0x314 | 80 | PIF file name (ANSI) | |
| 0x364 | 60 | Title (Unicode) | Used only when it equals the title at 0x3A0. |
| 0x3A0 | 30 | Title (ANSI) | |
| 0x3BE | 160 | Icon file (Unicode) | Usually PIFMGR.DLL. |
| 0x45E | 80 | Icon file (ANSI) | |
| 0x4AE | 128 | Start directory (Unicode) | |
| 0x52E | 64 | Start directory (ANSI) | |
| 0x56E | 286 | Unknown | Zeros. |
CONFIG SYS 4.0 and AUTOEXECBAT 4.0
Windows 95 and 98, for a program run in MS-DOS mode with its own configuration, keep the text
of the CONFIG.SYS and AUTOEXEC.BAT it asks for in two sections of variable length. The data is
the file’s text in the ANSI set, each line ended by 0D 0A. The names are
CONFIG SYS 4.0 (two spaces) and AUTOEXECBAT 4.0. No real file on
this machine has them (they need a PIF with a custom MS-DOS mode configuration), so the viewer’s
reading of them is checked on built files only.
Character sets
Text fields are in the OEM character set of the machine (code page 437 in the United States; the viewer shows 437) in the classic header, the batch file and the title; in the ANSI set (Windows 1252 in Western Europe) in the 386 parameters, the NT 3.1 paths, the icon file and font names; and in UTF-16 in the NT 4.0 section. A name with accents therefore reads differently in the two halves of one file.