[net.micro.pc] Current DOS environment

maybee@pogo.UUCP (Joe Maybee) (04/10/86)

Does anyone out there know how to get a pointer to the
CURRENT environment in DOS?  What about version dependencies?

      Joe Maybee
      ...!tektronix!pogo!maybee

"We have met the enemy and he is US!"
       ---Pogo

-- 


                 ----maybee@pogo

"We have met the enemy and he is US!"
                 ----Pogo

connery@bnrmtv.UUCP (Glenn Connery) (04/16/86)

> 
> 
> Does anyone out there know how to get a pointer to the
> CURRENT environment in DOS?  What about version dependencies?
> 
>       Joe Maybee
>       ...!tektronix!pogo!maybee
> 
> "We have met the enemy and he is US!"
>        ---Pogo
> 
> -- 
> 
> 
>                  ----maybee@pogo
> 
> "We have met the enemy and he is US!"
>                  ----Pogo

The program segment prefix has the segment address of the environment
at offset 2C.  If you take this and add offset zero you will be able
to locate the current environment for THIS program, which is a COPY
of that for its parent, usually DOS.  It contains a series of strings,
as displayed by typing SET with no parms, each terminated by a null byte.
The end of the table is indicated by a trailing NULL (ie. two null bytes
in a row).

This should be valid for all DOS versions that support the environment.
-- 

Glenn Connery, Bell Northern Research, Mountain View, CA
{hplabs,amdahl,3comvax}!bnrmtv!connery

maybee@pogo.UUCP (Joe Maybee) (04/17/86)

In article <322@bnrmtv.UUCP> connery@bnrmtv.UUCP (Glenn Connery) writes:
>> 
>> 
>> Does anyone out there know how to get a pointer to the
>> CURRENT environment in DOS?  What about version dependencies?
>> 
>
>The program segment prefix has the segment address of the environment
>at offset 2C.  If you take this and add offset zero you will be able
>to locate the current environment for THIS program, which is a COPY
>of that for its parent, usually DOS.  It contains a series of strings,
>as displayed by typing SET with no parms, each terminated by a null byte.
>The end of the table is indicated by a trailing NULL (ie. two null bytes
>in a row).
>
>This should be valid for all DOS versions that support the environment.
>-- 
>
>Glenn Connery, Bell Northern Research, Mountain View, CA
>{hplabs,amdahl,3comvax}!bnrmtv!connery


Yes, but for "exit and stay resident" routines, can't that be
an "old" environment?  I need a pointer to the "latest and greatest"
environment.  That is to say the "real" DOS environment.  Can
anyone help?

                       
-- 


                 ----maybee@pogo

"We have met the enemy and he is US!"
                 ----Pogo

bc@cyb-eng.UUCP (Bill Crews) (04/22/86)

> Yes, but for "exit and stay resident" routines, can't that be
> an "old" environment?  I need a pointer to the "latest and greatest"
> environment.  That is to say the "real" DOS environment.  Can
> anyone help?

The "get current PSP" DOS call (DOS 3.x) will get you to the "current"
PSP.  From there, you can use the thing at 2Ch to locate its environment.
I don't know of any environment more "current" than that.  See the
appropriate DOS Technical Reference Manual.

For DOS 2.x, see the undocumented DOS call list that has been posted a
number of times.  There is one that also "gets the current PSP".

Good luck.

-- 
	- bc -

..!{seismo,topaz,gatech,nbires,ihnp4}!ut-sally!cyb-eng!bc  (512) 835-2266

ljz@well.UUCP (Lloyd Zusman) (05/08/86)

In article <322@bnrmtv.UUCP> connery@bnrmtv.UUCP (Glenn Connery) writes:
>> 
>> 
>> Does anyone out there know how to get a pointer to the
>> CURRENT environment in DOS?  What about version dependencies?
>> 
>>       Joe Maybee
>>       ...!tektronix!pogo!maybee
>> 
>> "We have met the enemy and he is US!"
>>        ---Pogo
>> 
>> -- 
>> 
>> 
>>                  ----maybee@pogo
>> 
>> "We have met the enemy and he is US!"
>>                  ----Pogo
>
>The program segment prefix has the segment address of the environment
>at offset 2C.  If you take this and add offset zero you will be able
>to locate the current environment for THIS program, which is a COPY
>of that for its parent, usually DOS.  It contains a series of strings,
>as displayed by typing SET with no parms, each terminated by a null byte.
>The end of the table is indicated by a trailing NULL (ie. two null bytes
>in a row).
>
>This should be valid for all DOS versions that support the environment.
>-- 
>
>Glenn Connery, Bell Northern Research, Mountain View, CA
>{hplabs,amdahl,3comvax}!bnrmtv!connery


Also, if you need to find the PSP (program segment prefix) in the first place
...

	mov ah, 62h
	int 21h

	The PSP segment address will be in BX.

The above is documented and works on all DOS versions 3.0 and above.  But if
you're using DOS 2.X ...

	mov ah, 51h
	int 21h

	The PSP segment address will be in BX.

This one isn't documented, but to quote Chris Dunford in a letter to Dr.
Dobbs Journal (the source for this information), "... but I don't forsee any
new releases of DOS 2.X in the near future!"

@hpislx.UUCP (05/08/86)

This message is empty.