Overwriting the PSP of a TSR Application

ID Number: Q36310

2.x 3.x 4.00

MS-DOS

Question:

I am writing a Terminate-and-stay- resident (TSR) program that makes no

MS-DOS system calls after it has been initialized. Is it reasonable to use

the PSP (program segment prefix) of this program as a stack area when

the TSR is invoked from running programs? This is assuming, of course,

that this stack area never grows large enough to overwrite my code.

The PSP just seems to waste space once the command line is read by my

application.

Response:

You should not use the PSP as a stack area or in any other way

overwrite this area. There are areas in the PSP, both documented and

reserved, that MS-DOS uses. Among these areas are the address to the

critical-error handler and the CTRL+C error handler. If you write over

these, you will most likely not be able to trust the integrity of this

application, which should not be worth the small memory savings.