From d8266a6a417bdef04407d42aaf93045e021fc554 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Mon, 23 Mar 2009 10:55:36 +0000 Subject: [PATCH] revise switchToLongcmd a bit. allow execution of mount/imgmount from menus and such.(beta3) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3326 --- include/shell.h | 5 +---- src/misc/programs.cpp | 24 +++++++++++++++++------- src/shell/shell.cpp | 9 +-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/shell.h b/include/shell.h index 689ad1d2..e5dc80a1 100644 --- a/include/shell.h +++ b/include/shell.h @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.h,v 1.25 2009-01-19 19:55:03 qbix79 Exp $ */ +/* $Id: shell.h,v 1.26 2009-03-23 10:55:35 qbix79 Exp $ */ #ifndef DOSBOX_SHELL_H #define DOSBOX_SHELL_H @@ -40,9 +40,6 @@ extern Bitu call_shellstop; * by "external" programs. (config) */ extern Program * first_shell; -/* command_slashc indicates that the next commands are being run from command /c. Remove parameters for internal .COM files */ -extern bool command_slashc; - class DOS_Shell; class BatchFile { diff --git a/src/misc/programs.cpp b/src/misc/programs.cpp index 3176e911..58736618 100644 --- a/src/misc/programs.cpp +++ b/src/misc/programs.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: programs.cpp,v 1.35 2009-02-01 14:19:20 qbix79 Exp $ */ +/* $Id: programs.cpp,v 1.36 2009-03-23 10:55:36 qbix79 Exp $ */ #include #include @@ -109,12 +109,22 @@ Program::Program() { extern std::string full_arguments; void Program::ChangeToLongCmd() { - CommandLine* temp = 0; - //If command_slashc => then don't pass any parameters to the internal .COM files - if(command_slashc) temp = new CommandLine(cmd->GetFileName(),""); - else temp = new CommandLine(cmd->GetFileName(),full_arguments.c_str()); - delete cmd; - cmd = temp; + /* + * Get arguments directly from the shell instead of the psp. + * this is done in securemode: (as then the arguments to mount and friends + * can only be given on the shell ( so no int 21 4b) + * Securemode part is disabled as each of the internal command has already + * protection for it. (and it breaks games like cdman) + * it is also done for long arguments to as it is convient (as the total commandline can be longer then 127 characters. + * imgmount with lot's of parameters + * Length of arguments can be ~120. but switch when above 100 to be sure + */ + + if(/*control->SecureMode() ||*/ cmd->Get_arglength() > 100) { + CommandLine* temp = new CommandLine(cmd->GetFileName(),full_arguments.c_str()); + delete cmd; + cmd = temp; + } full_arguments.assign(""); //Clear so it gets even more save } diff --git a/src/shell/shell.cpp b/src/shell/shell.cpp index efd621f5..ae9d40a3 100644 --- a/src/shell/shell.cpp +++ b/src/shell/shell.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: shell.cpp,v 1.97 2009-02-01 14:07:05 qbix79 Exp $ */ +/* $Id: shell.cpp,v 1.98 2009-03-23 10:55:36 qbix79 Exp $ */ #include #include @@ -278,22 +278,15 @@ void DOS_Shell::RunInternal(void) return; } -bool command_slashc = false; - void DOS_Shell::Run(void) { char input_line[CMD_MAXLINE] = {0}; std::string line; if (cmd->FindStringRemain("/C",line)) { - //command_slashc indicates that the following commands are run with command /c. Forbid parameters to mount. - //command_allready_set prevents against command /c "command /c command" - bool command_allready_set = command_slashc; - command_slashc = true; strcpy(input_line,line.c_str()); DOS_Shell temp; temp.echo = echo; temp.ParseLine(input_line); //for *.exe *.com |*.bat creates the bf needed by runinternal; temp.RunInternal(); // exits when no bf is found. - if(!command_allready_set) command_slashc = false; return; } /* Start a normal shell and check for a first command init */