Exemplo n.º 1
0
        private void RunDoorDOSBox(string command, string parameters)
        {
            if (Helpers.Debug)
            {
                _ClientThread.UpdateStatus("DEBUG: DOSBox launching " + command + " " + parameters);
            }

            string DOSBoxConf      = StringUtils.PathCombine("node" + _ClientThread.NodeInfo.Node.ToString(), "dosbox.conf");
            string ProgramFilesX86 = Environment.GetEnvironmentVariable("PROGRAMFILES(X86)") ?? Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
            string DOSBoxExe       = StringUtils.PathCombine(ProgramFilesX86, @"DOSBox-0.73\dosbox.exe"); // TODOZ add configuration variable so this path is not hardcoded

            // Copy base dosbox.conf
            FileUtils.FileDelete(DOSBoxConf);
            FileUtils.FileCopy("dosbox.conf", DOSBoxConf);

            // If we're running a batch file, add a CALL to it
            if (command.ToUpper().Contains(".BAT"))
            {
                command = "call " + command;
            }

            string[] ExternalBat = new string[] { "mount c " + StringUtils.ExtractShortPathName(ProcessUtils.StartupPath), "C:", command + " " + parameters, "exit" };
            FileUtils.FileAppendAllText(DOSBoxConf, string.Join("\r\n", ExternalBat));

            // TODOZ Todd/maskreet does it this way -- maybe safer with commands passed this way, or at the very least with -securemode?

            /* dosbox.exe -c "mount d c:\games\!u_games\%4\%1" -c "mount e c:\doorway"
             *  -c "mount f c:\doorsrv\node%3" -c "e:" -c "bnu" -c "DOORWAY.EXE SYSF
             *  CFG\%1.cfg" -securemode -socket %2 -c "exit"
             */
            string Arguments = "-telnet -conf " + DOSBoxConf + " -socket " + _ClientThread.NodeInfo.Connection.GetSocket().Handle.ToInt32().ToString();

            if (Helpers.Debug)
            {
                _ClientThread.UpdateStatus("Executing " + DOSBoxExe + " " + Arguments);
            }

            // Start the process
            using (RMProcess P = new RMProcess()) {
                P.ProcessWaitEvent += _ClientThread.OnDoorWait;

                ProcessStartInfo PSI = new ProcessStartInfo(DOSBoxExe, Arguments)
                {
                    WindowStyle      = _ClientThread.NodeInfo.Door.WindowStyle,
                    WorkingDirectory = ProcessUtils.StartupPath,
                };
                P.StartAndWait(PSI);
            }
        }
Exemplo n.º 2
0
        public void RunDoorNative(string command, string parameters)
        {
            if (Helpers.Debug)
            {
                _ClientThread.UpdateStatus("DEBUG: Natively launching " + command + " " + parameters);
            }
            using (RMProcess P = new RMProcess()) {
                P.ProcessWaitEvent += _ClientThread.OnDoorWait;

                ProcessStartInfo PSI = new ProcessStartInfo(command, parameters)
                {
                    WindowStyle      = _ClientThread.NodeInfo.Door.WindowStyle,
                    WorkingDirectory = ProcessUtils.StartupPath,
                };
                P.StartAndWait(PSI);
            }
        }