On Sun, 29 Feb 2004, FreeCOM wrote:

> Bart Oldeman wrote:
>
> >>Why not use the I/O stack (char_api_tos)? When process0 terminates & the
> >
> > this may be possible but tricky in C. As the code must make sure it
> > doesn't use any stack that it relies from before int21/ah=4b after
> > int21/ah=4b.
>
> I don't understand:

you're right that the stack doesn't matter for
mov ax,4b00
int 21
(ie. the cs, ip that are pushed now are stored in the PSP so these aren't
lost).

But in

  exec_blk exb;
  CommandTail Cmd;
  int rc;

[...]

  exb.exec.cmd_line = (CommandTail FAR *) & Cmd;
  exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0xfffffffful;

#ifdef DEBUG
  printf("Process 0 starting: %s\n\n", Config.cfgInit);
#endif

  while ((rc =
          DosExec(Config.cfgP_0_startmode, &exb,
                  Config.cfgInit)) != SUCCESS)
  {
    BYTE *pLine;
    printf("\nBad or missing Command Interpreter: %d - %s\n", rc,
           Cmd.ctBuffer);
    printf
        ("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n");
    rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer) - 1);
    Cmd.ctBuffer[rc] = '\0';

    /* Get the string argument that represents the new init pgm     */
    pLine = GetStringArg(Cmd.ctBuffer, Config.cfgInit);

    /* Now take whatever tail is left and add it on as a single     */
    /* string.                                                      */
    strcpy(Cmd.ctBuffer, pLine);

    /* and add a DOS new line just to be safe                       */
    strcat(Cmd.ctBuffer, "\r\n");

    Cmd.ctCount = rc - (pLine - Cmd.ctBuffer);

#ifdef DEBUG
    printf("Process 0 starting: %s\n\n", Config.cfgInit);
#endif
  }
  printf("\nSystem shutdown complete\nReboot now.\n");
  for (;;) ;


exb, Cmd and rc are all living on the stack. So at least some of them
would have to be made "static".

Also the "DosExec" call needs to do the int21/ah=4b "inlined" since the
return address of the "call" will be destroyed.

All possible, but a little tricky.

Bart



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Freedos-kernel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freedos-kernel

Reply via email to