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); }