Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"The four building blocks of the universe are fire, water, gravel and vinyl." -- Dave Barry


devel / comp.os.msdos.programmer / Re: Booting process 0: how to find out its full path?

SubjectAuthor
* Booting process 0: how to find out its full path?Mateusz Viste
+* Re: Booting process 0: how to find out its full path?Auric__
|`* Re: Booting process 0: how to find out its full path?Mateusz Viste
| `* Re: Booting process 0: how to find out its full path?Auric__
|  `- Re: Booting process 0: how to find out its full path?Mateusz Viste
`* Re: Booting process 0: how to find out its full path?JJ
 `- Re: Booting process 0: how to find out its full path?Mateusz Viste

1
Booting process 0: how to find out its full path?

<20211116104416.2b3d207f@mateusz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=126&group=comp.os.msdos.programmer#126

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!fJ3fCem/Ge388nCVHersJA.user.46.165.242.75.POSTED!not-for-mail
From: mateusz@xyz.invalid (Mateusz Viste)
Newsgroups: comp.os.msdos.programmer
Subject: Booting process 0: how to find out its full path?
Date: Tue, 16 Nov 2021 10:44:16 +0100
Organization: . . .
Message-ID: <20211116104416.2b3d207f@mateusz>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="52814"; posting-host="fJ3fCem/Ge388nCVHersJA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu)
 by: Mateusz Viste - Tue, 16 Nov 2021 09:44 UTC

Hello,

I am working on a shell that would replace COMMAND.COM and I wonder: is
there any way I can figure out where my shell is, once it is executed
by the MS-DOS kernel?

By default MS-DOS launches whatever it finds at [BOOTDRV]:\COMMAND.COM.
This situation is easy, but there is also the possibility that the shell
was configured through a "SHELL" or "SHELLHIGH" CONFIG.SYS directive:
SHELL=X:\EXOTIC\PATH\CUSTOM.COM

I am unable to find a way to discover the above path. Any ideas if this
is feasible at all? I went through RBIL but with no luck so far.

The environment contains the full path/name of the executed program,
but this does not apply to process 0, as the MS-DOS kernel does not
allocate any environment for it (env segment in PSP = 0x0000).

Mateusz

Re: Booting process 0: how to find out its full path?

<XnsADE464DA8276Bauricauricauricauric@144.76.35.252>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=127&group=comp.os.msdos.programmer#127

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: not.my.real@email.address (Auric__)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Booting process 0: how to find out its full path?
Date: Tue, 16 Nov 2021 16:54:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <XnsADE464DA8276Bauricauricauricauric@144.76.35.252>
References: <20211116104416.2b3d207f@mateusz>
Injection-Date: Tue, 16 Nov 2021 16:54:51 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9e7d690ce5ce02f4b2096fa307f459e8";
logging-data="23966"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18CKoV7/Bk/PPEwygDUmQRi"
User-Agent: Xnews/2009.05.01
Cancel-Lock: sha1:7lPSKF2phBtIctlgOXMLUAGr2D4=
X-Face: +,&^!i3LPqz7/qfxgF[JJqAP^>bTVLZ-zj})PmI{auZ']fwMM4mh`$]b0sacD4p@R[yU'Mf=.T}|aW6^#_lm6U|e|/#d:nfRn29,GBLvX=ygRH(?h.=KFfJ\INamt#H|)k@,x[ko$(d~iAo'<1XzB@%];
 by: Auric__ - Tue, 16 Nov 2021 16:54 UTC

Mateusz Viste wrote:

> I am working on a shell that would replace COMMAND.COM and I wonder: is
> there any way I can figure out where my shell is, once it is executed
> by the MS-DOS kernel?
>
> By default MS-DOS launches whatever it finds at [BOOTDRV]:\COMMAND.COM.
> This situation is easy, but there is also the possibility that the shell
> was configured through a "SHELL" or "SHELLHIGH" CONFIG.SYS directive:
> SHELL=X:\EXOTIC\PATH\CUSTOM.COM
>
> I am unable to find a way to discover the above path. Any ideas if this
> is feasible at all? I went through RBIL but with no luck so far.
>
> The environment contains the full path/name of the executed program,
> but this does not apply to process 0, as the MS-DOS kernel does not
> allocate any environment for it (env segment in PSP = 0x0000).

Just throwing out the obvious here... have you considered just looking
through config.sys for the shell?

--
"Armies with ammo" comes before "damsels in distress" alphabetically.

Re: Booting process 0: how to find out its full path?

<20211116180721.434ef838@mateusz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=128&group=comp.os.msdos.programmer#128

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!fJ3fCem/Ge388nCVHersJA.user.46.165.242.75.POSTED!not-for-mail
From: mateusz@xyz.invalid (Mateusz Viste)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Booting process 0: how to find out its full path?
Date: Tue, 16 Nov 2021 18:07:21 +0100
Organization: . . .
Message-ID: <20211116180721.434ef838@mateusz>
References: <20211116104416.2b3d207f@mateusz>
<XnsADE464DA8276Bauricauricauricauric@144.76.35.252>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="39843"; posting-host="fJ3fCem/Ge388nCVHersJA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mateusz Viste - Tue, 16 Nov 2021 17:07 UTC

2021-11-16 at 16:54 -0000, Auric__ wrote:
> Mateusz Viste wrote:
>
> > I am working on a shell that would replace COMMAND.COM and I
> > wonder: is there any way I can figure out where my shell is, once
> > it is executed by the MS-DOS kernel?
> >
> > By default MS-DOS launches whatever it finds at
> > [BOOTDRV]:\COMMAND.COM. This situation is easy, but there is also
> > the possibility that the shell was configured through a "SHELL" or
> > "SHELLHIGH" CONFIG.SYS directive: SHELL=X:\EXOTIC\PATH\CUSTOM.COM
> >
> > I am unable to find a way to discover the above path. Any ideas if
> > this is feasible at all? I went through RBIL but with no luck so
> > far.
> >
> > The environment contains the full path/name of the executed program,
> > but this does not apply to process 0, as the MS-DOS kernel does not
> > allocate any environment for it (env segment in PSP = 0x0000).
>
> Just throwing out the obvious here... have you considered just
> looking through config.sys for the shell?

Yes, of course, but this seemingly obvious solution is extremely complex
and unreliable.

Such parser would have not only to look for SHELL or SHELLHIGH
directives in CONFIG.SYS, but also understand the logic behind
conditional instructions (config menus), with possible dialect
variations between DOS versions. There are also DOSes that use a file
named differently than "CONFIG.SYS". And then, there's also the
possibility that the user simply skipped the SHELL directive (F5/F8) or
that the shell has been entered by hand at boot time (some DOSes ask
for the command interpreter path if the default file cannot be found).

Mateusz

Re: Booting process 0: how to find out its full path?

<XnsADE478512A181auricauricauricauric@144.76.35.252>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=129&group=comp.os.msdos.programmer#129

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: not.my.real@email.address (Auric__)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Booting process 0: how to find out its full path?
Date: Tue, 16 Nov 2021 18:49:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <XnsADE478512A181auricauricauricauric@144.76.35.252>
References: <20211116104416.2b3d207f@mateusz> <XnsADE464DA8276Bauricauricauricauric@144.76.35.252> <20211116180721.434ef838@mateusz>
Injection-Date: Tue, 16 Nov 2021 18:49:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9e7d690ce5ce02f4b2096fa307f459e8";
logging-data="21885"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+V2uhiU76rRutebRf1RCse"
User-Agent: Xnews/2009.05.01
Cancel-Lock: sha1:zL56/QWmqYCEJ3Nfw3CWzLC7WOk=
X-Face: +,&^!i3LPqz7/qfxgF[JJqAP^>bTVLZ-zj})PmI{auZ']fwMM4mh`$]b0sacD4p@R[yU'Mf=.T}|aW6^#_lm6U|e|/#d:nfRn29,GBLvX=ygRH(?h.=KFfJ\INamt#H|)k@,x[ko$(d~iAo'<1XzB@%];
 by: Auric__ - Tue, 16 Nov 2021 18:49 UTC

Mateusz Viste wrote:

> 2021-11-16 at 16:54 -0000, Auric__ wrote:
>> Mateusz Viste wrote:
>>
>> > I am working on a shell that would replace COMMAND.COM and I
>> > wonder: is there any way I can figure out where my shell is, once
>> > it is executed by the MS-DOS kernel?
>> >
>> > By default MS-DOS launches whatever it finds at
>> > [BOOTDRV]:\COMMAND.COM. This situation is easy, but there is also
>> > the possibility that the shell was configured through a "SHELL" or
>> > "SHELLHIGH" CONFIG.SYS directive: SHELL=X:\EXOTIC\PATH\CUSTOM.COM
>> >
>> > I am unable to find a way to discover the above path. Any ideas if
>> > this is feasible at all? I went through RBIL but with no luck so
>> > far.
>> >
>> > The environment contains the full path/name of the executed program,
>> > but this does not apply to process 0, as the MS-DOS kernel does not
>> > allocate any environment for it (env segment in PSP = 0x0000).
>>
>> Just throwing out the obvious here... have you considered just
>> looking through config.sys for the shell?
>
> Yes, of course, but this seemingly obvious solution is extremely complex
> and unreliable.
>
> Such parser would have not only to look for SHELL or SHELLHIGH
> directives in CONFIG.SYS, but also understand the logic behind
> conditional instructions (config menus), with possible dialect
> variations between DOS versions. There are also DOSes that use a file
> named differently than "CONFIG.SYS". And then, there's also the
> possibility that the user simply skipped the SHELL directive (F5/F8) or
> that the shell has been entered by hand at boot time (some DOSes ask
> for the command interpreter path if the default file cannot be found).

Well...

The MS-DOS 2.0 source code is on Github, where you might look into the file
SYSINIT.ASM, available here:

https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/SYSINIT.ASM

AFAIK, this was the first time DOS could use external shells. I don't know
if it's at all relevant to modern DOS, but it's a start.

Alternately, if you can find a copy of the MS-DOS 6 source code (which was
leaked to the internet some time back), you might want to look at these
files:
BIOS\CONFIG.INC
BIOS\SYSCONF.ASM
BIOS\SYSINIT1.ASM
BIOS\SYSINIT2.ASM
Just sayin'. SYSCONF.ASM has this comment which seems *very* relevant:

HACK: when 4DOS.COM is the shell and it doesn't have an environment from
which to obtain its original program name, it grovels through all of
memory to find the filename that was used to exec it; it wants to find
the SHELL= line in the in-memory copy of CONFIG.SYS, and it knows that
sysinit converts the SHELL= keyword to an 'S', so it expects to find an 'S'
immediately before the filename, but since we are now storing line # info
in the config.sys memory image, 4DOS fails to find the 'S' in the right
spot.
So, on the final pass of CONFIG.SYS, copy the command code (eg, 'S')
over the line number info, since we no longer need that info anyway. This
relies on the fact that getchr leaves ES:SI pointing to the last byte
retrieved.

As for other flavors of DOS, most of them are open source, so I think it
would be worth it to download some source code and search for "shell".

--
Money is truthful. If a man speaks of his honor, make him pay cash.

Re: Booting process 0: how to find out its full path?

<20211116204601.0eabe49c@mateusz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=130&group=comp.os.msdos.programmer#130

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!fJ3fCem/Ge388nCVHersJA.user.46.165.242.75.POSTED!not-for-mail
From: mateusz@xyz.invalid (Mateusz Viste)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Booting process 0: how to find out its full path?
Date: Tue, 16 Nov 2021 20:46:01 +0100
Organization: . . .
Message-ID: <20211116204601.0eabe49c@mateusz>
References: <20211116104416.2b3d207f@mateusz>
<XnsADE464DA8276Bauricauricauricauric@144.76.35.252>
<20211116180721.434ef838@mateusz>
<XnsADE478512A181auricauricauricauric@144.76.35.252>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="23787"; posting-host="fJ3fCem/Ge388nCVHersJA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Newsreader: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu)
 by: Mateusz Viste - Tue, 16 Nov 2021 19:46 UTC

2021-11-16 at 18:49 -0000, Auric__ wrote:
> The MS-DOS 2.0 source code is on Github, where you might look into
> the file SYSINIT.ASM, available here:
>
> https://github.com/microsoft/MS-DOS/blob/master/v2.0/source/SYSINIT.ASM

Actually I did glance at the MS-DOS 2.0 code already, and my
understanding is that they didn't even try addressing this, just relied
on COMSPEC (if defined, either through SET or by feeding it as an
argument to command.com), and if no COMSPEC then using the default
location.

That sounds okay when it's MS that does it, because it's their OS, but
an alternative shell does not have this luxury.

> HACK: when 4DOS.COM is the shell and it doesn't have an environment
> from which to obtain its original program name, it grovels through
> all of memory to find the filename that was used to exec it; it
> wants to find the SHELL= line in the in-memory copy of CONFIG.SYS,
> and it knows that sysinit converts the SHELL= keyword to an 'S', so
> it expects to find an 'S' immediately before the filename, but since
> we are now storing line # info in the config.sys memory image, 4DOS
> fails to find the 'S' in the right spot.
> So, on the final pass of CONFIG.SYS, copy the command code (eg, 'S')
> over the line number info, since we no longer need that info anyway.
> This relies on the fact that getchr leaves ES:SI pointing to the
> last byte retrieved.

That is very interesting indeed, thanks for sharing! This at least
confirms that there is no "clean" way to do what I wanted... So I will
probably give up on that. MS compatibility was only a bonus, my primary
target is working with the DOS-C kernel, and there I do not have any
such problems.

Nonetheless, thank you for your kind research.

> As for other flavors of DOS, most of them are open source, so I think
> it would be worth it to download some source code and search for
> "shell".

Under DOS-C it is a no-brainer: the kernel actually allocates a tiny
(96 bytes) environment and passes it to COMMAND.COM. There, the entire
path is present.

Mateusz

Re: Booting process 0: how to find out its full path?

<alkpd8bmk1pw$.14b1qw57mbkel.dlg@40tude.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=132&group=comp.os.msdos.programmer#132

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!m2Axp5dqt5QeKnuwR5N9ww.user.46.165.242.91.POSTED!not-for-mail
From: jj4public@gmail.com (JJ)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Booting process 0: how to find out its full path?
Date: Wed, 17 Nov 2021 08:23:43 +0700
Organization: Aioe.org NNTP Server
Message-ID: <alkpd8bmk1pw$.14b1qw57mbkel.dlg@40tude.net>
References: <20211116104416.2b3d207f@mateusz>
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="61237"; posting-host="m2Axp5dqt5QeKnuwR5N9ww.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: 40tude_Dialog/2.0.15.84
X-Bitcoin: 1LcqwCQBQmhcWfWsVEAeyLchkAY8ZfuMnS
X-Notice: Filtered by postfilter v. 0.9.2
X-Face: \*\`0(1j~VfYC>ebz[&O.]=,Nm\oRM{of,liRO#7Eqi4|!]!(Gs=Akgh{J)605>C9Air?pa d{sSZ09u+A7f<^paR"/NH_#<mE1S"hde\c6PZLUB[t/s5-+Iu5DSc?P0+4%,Hl
 by: JJ - Wed, 17 Nov 2021 01:23 UTC

On Tue, 16 Nov 2021 10:44:16 +0100, Mateusz Viste wrote:
> Hello,
>
> I am working on a shell that would replace COMMAND.COM and I wonder: is
> there any way I can figure out where my shell is, once it is executed
> by the MS-DOS kernel?
>
> By default MS-DOS launches whatever it finds at [BOOTDRV]:\COMMAND.COM.
> This situation is easy, but there is also the possibility that the shell
> was configured through a "SHELL" or "SHELLHIGH" CONFIG.SYS directive:
> SHELL=X:\EXOTIC\PATH\CUSTOM.COM
>
> I am unable to find a way to discover the above path. Any ideas if this
> is feasible at all? I went through RBIL but with no luck so far.
>
> The environment contains the full path/name of the executed program,
> but this does not apply to process 0, as the MS-DOS kernel does not
> allocate any environment for it (env segment in PSP = 0x0000).
>
> Mateusz

You may want to walk the MCB chain to find the master environment block.

Re: Booting process 0: how to find out its full path?

<20211117091109.08b0e807@mateusz>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=135&group=comp.os.msdos.programmer#135

  copy link   Newsgroups: comp.os.msdos.programmer
Path: i2pn2.org!i2pn.org!aioe.org!fJ3fCem/Ge388nCVHersJA.user.46.165.242.75.POSTED!not-for-mail
From: mateusz@xyz.invalid (Mateusz Viste)
Newsgroups: comp.os.msdos.programmer
Subject: Re: Booting process 0: how to find out its full path?
Date: Wed, 17 Nov 2021 09:11:09 +0100
Organization: . . .
Message-ID: <20211117091109.08b0e807@mateusz>
References: <20211116104416.2b3d207f@mateusz>
<alkpd8bmk1pw$.14b1qw57mbkel.dlg@40tude.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="45506"; posting-host="fJ3fCem/Ge388nCVHersJA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Newsreader: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu)
X-Notice: Filtered by postfilter v. 0.9.2
 by: Mateusz Viste - Wed, 17 Nov 2021 08:11 UTC

2021-11-17 at 08:23 +0700, JJ wrote:
> On Tue, 16 Nov 2021 10:44:16 +0100, Mateusz Viste wrote:
> > Hello,
> >
> > I am working on a shell that would replace COMMAND.COM and I
> > wonder: is there any way I can figure out where my shell is, once
> > it is executed by the MS-DOS kernel?
> >
> > By default MS-DOS launches whatever it finds at
> > [BOOTDRV]:\COMMAND.COM. This situation is easy, but there is also
> > the possibility that the shell was configured through a "SHELL" or
> > "SHELLHIGH" CONFIG.SYS directive: SHELL=X:\EXOTIC\PATH\CUSTOM.COM
> >
> > I am unable to find a way to discover the above path. Any ideas if
> > this is feasible at all? I went through RBIL but with no luck so
> > far.
> >
> > The environment contains the full path/name of the executed program,
> > but this does not apply to process 0, as the MS-DOS kernel does not
> > allocate any environment for it (env segment in PSP = 0x0000).
> >
> > Mateusz
>
> You may want to walk the MCB chain to find the master environment
> block.

No, because such an environment simply does not exists at the time
process 0 is being loaded.

Mateusz

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor