Exemple #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);
            }
        }
Exemple #2
0
 private void CheckForW32DoorRun()
 {
     // Watch for a W32DOOR.RUN file to be created in the node directory
     // If it gets created, it's our signal that a DOS BBS package wants us to launch a W32 door
     // W32DOOR.RUN will contain two lines, the first is the command to run, the second is the parameters
     if (File.Exists(W32DoorFile))
     {
         try {
             if (Helpers.Debug)
             {
                 _ClientThread.UpdateStatus("DEBUG: w32door.run found");
             }
             string[] W32DoorRunLines = FileUtils.FileReadAllLines(W32DoorFile);
             ConvertDoorSysToDoor32Sys(W32DoorRunLines[0]);
             // TODOX A way to do this without making RunDoorNative public?
             (new RunDoor(_ClientThread)).RunDoorNative(W32DoorRunLines[1], W32DoorRunLines[2]);
         } finally {
             FileUtils.FileDelete(W32DoorFile);
         }
     }
 }