Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order
ecm

Homepage E-mail

Düsseldorf, Germany,
22.01.2026, 12:24
 

PSP environment word as a selector - How is exec handled? (DOSX)

I've heard that for some DOS extenders, the word [PSP:2Ch] may be replaced by a selector that points to the environment, rather than a segment address.

If this is so, does the extender swap around the PSP field around exec calls? If DOS is given a zero in the exec block for the environment source, it'll retrieve the environment from the current PSP. But DOS expects a segment in that field.

---
l

tkchia

Homepage

22.01.2026, 16:54

@ ecm

PSP environment word as a selector - How is exec handled?

Hello ecm,

> If this is so, does the extender swap around the PSP field around exec
> calls? If DOS is given a zero in the exec block for the environment source,
> it'll retrieve the environment from the current PSP. But DOS expects a
> segment in that field.

In the case of Devore's CauseWay DOS extender, the extender does not simply pass the parameter block (at es:[bx] or es:[ebx]) verbatim to real/V86 mode DOS.

Instead, it interprets the block as containing protected mode selectors, and rewrites it into a different parameter block suitable for real mode. So the DOS extender has a chance to specially handle a zero selector value.

In fact, CauseWay will actually allocate a conventional memory area for a new copy of the environment (!), and copy out the environment variables from protected mode memory to it.

Thank you!

---
https://codeberg.org/tkchia · https://disroot.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"

tkchia

Homepage

22.01.2026, 17:24

@ ecm

PSP environment word as a selector - How is exec handled?

Hello ecm,

Another interesting tidbit: if CauseWay is running in "DOS/4G" mode -- which happens if the client program does a DOS/4G installation check -- then the environment address field in the parameter block is actually a 48-bit selector:offset address, not just a selector value. Shenanigans.

Thank you!

---
https://codeberg.org/tkchia · https://disroot.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"

Japheth

Homepage

Germany (South),
25.01.2026, 18:02

@ ecm

PSP environment word as a selector - How is exec handled?

> I've heard that for some DOS extenders, the word [PSP:2Ch] may
> be replaced by a selector that points to the environment, rather than a
> segment address.

It's not just what "some DOS extenders" do, but specified in DPMI: https://www.delorie.com/djgpp/doc/dpmi/ch4.1.html

> If this is so, does the extender swap around the PSP field around exec
> calls? If DOS is given a zero in the exec block for the environment source,
> it'll retrieve the environment from the current PSP.

HDPMI emulates int 21h, AX=4B00h and in this case expects a selector. But if a real-mode interrupt is simulated ( int 31h, ax=300h ), HDPMI does nothing.

---
MS-DOS forever!

ecm

Homepage E-mail

Düsseldorf, Germany,
25.01.2026, 19:15

@ Japheth

PSP environment word as a selector - How is exec handled?

> > I've heard that for some DOS extenders, the word [PSP:2Ch]
> may
> > be replaced by a selector that points to the environment, rather than a
> > segment address.
>
> It's not just what "some DOS extenders" do, but specified in DPMI:
> https://www.delorie.com/djgpp/doc/dpmi/ch4.1.html

Ah yes, indeed. However:

> If the client wishes to free the memory occupied by the environment, it should do so before entering protected mode and zero the word at PSP:2CH (segment address of the environment>.

I believe this (PSP environment field = 0) leads to a crash on MSW 98SE when running in a DOS window of the GUI, upon trying to enter Protected Mode.

---
l

ecm

Homepage E-mail

Düsseldorf, Germany,
25.01.2026, 19:21

@ ecm

PSP environment word as a selector - How is exec handled?

> > > I've heard that for some DOS extenders, the word
> [PSP:2Ch]
> > may
> > > be replaced by a selector that points to the environment, rather than
> a
> > > segment address.
> >
> > It's not just what "some DOS extenders" do, but specified in DPMI:
> > https://www.delorie.com/djgpp/doc/dpmi/ch4.1.html
>
> Ah yes, indeed. However:
>
> > If the client wishes to free the memory occupied by the environment, it
> should do so before entering protected mode and zero the word at PSP:2CH
> (segment address of the environment>.
>
> I believe this (PSP environment field = 0) leads to a crash on MSW 98SE
> when running in a DOS window of the GUI, upon trying to enter Protected
> Mode.

https://github.com/jeffpar/pcjs/issues/75#issuecomment-2132212965

> My DPMI test program was in error, it frees and zeroes
> the environment segment at word [PSP:2Ch] but MSWindows
> expects this field to be nonzero upon entering
> DPMI Protected Mode. With this part commented out
> the DPMI mini program runs fine on its own.

---
l

Back to the board
Thread view  Mix view  Order
23172 Postings in 2182 Threads, 404 registered users (0 online)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum