1
0
Fork 0

Fixes to shell to correctly support /c command

Fixed not saving cs:ip when executing a program


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@469
This commit is contained in:
Sjoerd van der Berg 2002-10-31 15:16:27 +00:00
parent 98f3407fc4
commit 4543cc2d8f
3 changed files with 20 additions and 13 deletions

View file

@ -79,7 +79,7 @@ void DOS_Shell::ParseLine(char * line) {
char * fname1=0;
/* Check for a leading @ */
if (line[0]=='@') line[0]=' ';
if (line[0]=='@') line[0]=' ';
line=trim(line);
Bit32u num=0; /* Number of commands in this line */
@ -97,14 +97,11 @@ void DOS_Shell::Run(void) {
char input_line[CMD_MAXLINE];
std::string line;
if (cmd->FindString("/C",line,false)) {
char command[256];
cmd->GetFullLine(command);
char * blah=strstr(command, "/C");
blah+=2; //add the size of "/C"
ParseLine(blah);
return;
}
if (cmd->FindStringRemain("/C",line)) {
strcpy(input_line,line.c_str());
ParseLine(input_line);
return;
}
/* Start a normal shell and check for a first command init */
WriteOut(MSG_Get("SHELL_STARTUP"));
if (cmd->FindString("/INIT",line,true)) {
@ -220,10 +217,14 @@ void SHELL_Init() {
MSG_Add("SHELL_CMD_GOTO_HELP","Jump to a labeled line in a batch script.\n");
MSG_Add("SHELL_CMD_TYPE_HELP","Display the contents of a text-file.\n");
MSG_Add("SHELL_CMD_REM_HELP","Add comments in a batch file.\n");
MSG_Add("SHELL_CMD_RENAME_WILD","This is a simple Rename, no wildcards allowed!\n");
MSG_Add("SHELL_CMD_RENAME_HELP","Renames files.\n");
MSG_Add("SHELL_CMD_RENAME_WILD","This is a simple Rename, no wildcards allowed!\n");
MSG_Add("SHELL_CMD_RENAME_HELP","Renames files.\n");
/* Regular startup */
call_shellstop=CALLBACK_Allocate();
/* Setup the startup CS:IP to kill the last running machine when exitted */
RealPt newcsip=CALLBACK_RealPointer(call_shellstop);
SegSet16(cs,RealSeg(newcsip));
reg_ip=RealOff(newcsip);
CALLBACK_Setup(call_shellstop,shellstop_handler,CB_IRET);
PROGRAMS_MakeFile("COMMAND.COM",SHELL_ProgramStart);

View file

@ -38,8 +38,8 @@ static SHELL_Cmd cmd_list[]={
"GOTO", 0, &DOS_Shell::CMD_GOTO, "SHELL_CMD_GOTO_HELP",
"TYPE", 0, &DOS_Shell::CMD_TYPE, "SHELL_CMD_TYPE_HELP",
"REM", 0, &DOS_Shell::CMD_REM, "SHELL_CMD_REM_HELP",
"RENAME", 0, &DOS_Shell::CMD_RENAME, "SHELL_CMD_RENAME_HELP",
"RENAME", 0, &DOS_Shell::CMD_RENAME, "SHELL_CMD_RENAME_HELP",
"REN", 0, &DOS_Shell::CMD_RENAME, "SHELL_CMD_RENAME_HELP",
/*
"CHDIR", 0, &DOS_Shell::CMD_CHDIR, "Change Directory",
"MKDIR", 0, &DOS_Shell::CMD_MKDIR, "Make Directory",
@ -397,3 +397,4 @@ nextfile:
void DOS_Shell::CMD_REM(char * args) {
}

View file

@ -168,6 +168,8 @@ void DOS_Shell::Execute(char * name,char * args) {
block.exec.cmdtail=RealMakeSeg(ss,reg_sp+0x100);
block.SaveData();
/* Save CS:IP to some point where i can return them from */
Bit32u oldeip=reg_eip;
Bit16u oldcs=SegValue(cs);
RealPt newcsip=CALLBACK_RealPointer(call_shellstop);
SegSet16(cs,RealSeg(newcsip));
reg_ip=RealOff(newcsip);
@ -181,7 +183,10 @@ void DOS_Shell::Execute(char * name,char * args) {
reg_bx=reg_sp;
flags.intf=false;
CALLBACK_RunRealInt(0x21);
/* Restore CS:IP and the stack */
reg_sp+=0x200;
reg_eip=oldeip;
SegSet16(cs,oldcs);
}
}