Esempio n. 1
0
        static void RunRedir()
        {
            if (net == null)
            {
                return;
            }

            Console.CancelKeyPress += Console_CancelKeyPress;

            StdInHandle  = ConsoleUtilities.GetStdHandle((int)ConsoleUtilities.StdHandle.STD_INPUT_HANDLE);
            StdOutHandle = ConsoleUtilities.GetStdHandle((int)ConsoleUtilities.StdHandle.STD_OUTPUT_HANDLE);

            int OldFlags;

            ConsoleUtilities.GetConsoleMode(StdInHandle, out OldFlags);
            int NewFlags = OldFlags & ~(int)(ConsoleUtilities.ConsoleModes.ENABLE_ECHO_INPUT | ConsoleUtilities.ConsoleModes.ENABLE_LINE_INPUT | ConsoleUtilities.ConsoleModes.ENABLE_PROCESSED_INPUT);

            ConsoleUtilities.SetConsoleMode(StdInHandle, NewFlags);

            RecvData = new Thread(new ThreadStart(RecvDataThread));
            RecvData.Start();

            do
            {
                ConsoleUtilities.INPUT_RECORD_Flat[] ir = new ConsoleUtilities.INPUT_RECORD_Flat[128];
                int read;
                if (ConsoleUtilities.ReadConsoleInput(StdInHandle, ir, 128, out read) == false)
                {
                    Debug.WriteLine("Err ReadConsoleInput()");
                    continue;
                }
                if (read == 0)
                {
                    Debug.WriteLine("Nix ReadConsoleInput()");
                    continue;
                }

                List <ConsoleUtilities.INPUT_RECORD_Flat> ir2 = new List <ConsoleUtilities.INPUT_RECORD_Flat>();
                for (int i = 0; i < read; i++)
                {
                    switch (BitConverter.ToInt16(ir[i].d, 0))
                    {
                    case 0x1:     //KEY_EVENT
                        ir2.Add(ir[i]);
                        break;

                    case 0x2:     //MOUSE_EVENT
                        if (EnableMouseInput == true)
                        {
                            ir2.Add(ir[i]);
                        }
                        break;
                    }
                }

                net.PushPushStdIO(MachineID, StdIOSession, ir2.ToArray());
            } while (End == false);

            ConsoleUtilities.SetConsoleMode(StdInHandle, OldFlags);
        }
Esempio n. 2
0
        public void RunConsoleEnd()
        {
            Console.Clear();
            Console.WriteLine("Fox SDC Redirector on " + Environment.MachineName);

            try
            {
                consoleproc = new Process();
                consoleproc.StartInfo.Arguments       = Args;
                consoleproc.StartInfo.FileName        = Filename;
                consoleproc.StartInfo.UseShellExecute = false;
                consoleproc.Start();
                consolestdin  = ConsoleUtilities.GetStdHandle((int)ConsoleUtilities.StdHandle.STD_INPUT_HANDLE);
                consolestdout = ConsoleUtilities.GetStdHandle((int)ConsoleUtilities.StdHandle.STD_OUTPUT_HANDLE);
                TScreen       = new Thread(new ThreadStart(PullScreen));
                ConsoleT      = new Thread(new ThreadStart(InternalThreadConsoleEnd));
                TScreen.Start();
                ConsoleT.Start();
                consoleproc.WaitForExit();
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.ToString());
                Push_Stdio_StdOut std = new Push_Stdio_StdOut();
                std.SessionID = SessionID;
                std.State     = PushStdoutState.End;
                try
                {
                    consoleendSetResultStacked.SetResultStacked(std);
                }
                catch (Exception eee)
                {
                    Debug.WriteLine(eee.ToString());
                }
            }
        }