static void Main(string[] args) { ISLogger.EnableConsole = true; ISLogger.EnableLogFile = true; ISLogger.SetLogFileName("InputshareTest.log"); ISLogger.PrefixCaller = false; ISLogger.PrefixTime = true; while (true) { Console.Clear(); Console.WriteLine("This is an experimental version of Inputshare, may be unstable :S"); Console.WriteLine("Log file: " + ISLogger.LogFilePath); Console.WriteLine("Press S to run server, C to run client"); ConsoleKeyInfo key = Console.ReadKey(); if (key.Key == ConsoleKey.S) { TestServer.Run(); continue; } else if (key.Key == ConsoleKey.C) { TestClient.Run(); continue; } } }
internal static void Init(AnonIpcClient client) { ISLogger.SetLogFileName("InputshareSP_DefaultHost.log"); ISLogger.Write("Starting SP default host"); iClient = client; outMan = new WindowsOutputManager(); outMan.Start(); deskThread = new ActiveDesktopThread(); deskThread.Invoke(() => { Desktop.SwitchDesktop(Desktop.InputDesktop); }); outputDeskThread = new ActiveDesktopThread(); outputDeskThread.Invoke(() => { Desktop.SwitchDesktop(Desktop.InputDesktop); }); hWindow = new HookWindow("SPDesktopWatcher"); hWindow.InitWindow(); hWindow.InstallDesktopMonitor(); hWindow.DesktopSwitchEvent += HWindow_DesktopSwitchEvent; iClient.Disconnected += IClient_Disconnected; iClient.InputReceived += IClient_InputReceived; deskThread.Invoke(() => { GetDisplayConfig(); }); cursorPosUpdateTimer = new Timer((object o) => { CheckCursorPosition(); }, 0, 0, 50); displayCheckTimer = new Timer((object o) => { CheckForDisplayConfigChange(); }, 0, 0, 1500); while (true) { Thread.Sleep(5000); } }
public InputshareService() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; ISLogger.SetLogFileName("InputshareService.log"); ISLogger.EnableConsole = false; ISLogger.EnableLogFile = true; ISLogger.PrefixTime = true; CanHandleSessionChangeEvent = true; }
public static void Main() { ISLogger.SetLogFileName(@".\logs\Inputshare.log"); ISLogger.EnableConsole = false; ISLogger.EnableLogFile = true; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
static void Main(string[] args) { ISLogger.SetLogFileName(@".\logs\InputshareSP.log"); ISLogger.EnableConsole = true; ISLogger.EnableDebugLog = true; ISLogger.EnableLogFile = true; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Console.CancelKeyPress += Console_CancelKeyPress; SP p = new SP(); p.Run(args); }
public static void Main(string[] args) { ISLogger.PrefixCaller = false; ISLogger.PrefixTime = true; ISLogger.EnableConsole = true; ISLogger.EnableLogFile = true; ISLogger.SetLogFileName("Inputshare.log"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); }
public static void Main(string[] args) { try { if (!Directory.Exists(Environment.CurrentDirectory + "\\logs")) { Directory.CreateDirectory(Environment.CurrentDirectory + "\\logs"); } } catch (Exception ex) { } ISLogger.SetLogFileName(@".\logs\Inputshare.log"); ISLogger.EnableConsole = false; ISLogger.EnableLogFile = true; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; ISLogger.SetLogFileName("InputshareSP.log"); ISLogger.EnableConsole = true; ISLogger.EnableLogFile = true; if (args.Length != 3) { OnInvalidArgs(); return; } string mode = args[0]; string readPipe = args[1]; string writePipe = args[2]; AnonIpcClient client = new AnonIpcClient(readPipe, writePipe, "ServiceIPC"); if (!client.ConnectedEvent.WaitOne(2000)) { ISLogger.Write("Failed to connect to service... exiting"); return; } ISLogger.Write("Connected to service IPC!"); if (mode == "Default") { DefaultHost.SPDefaultHost.Init(client); } else if (mode == "Clipboard") { ClipboardHost.SPClipboardHost.Init(client); } else { OnInvalidArgs(); } }
internal static void Init(AnonIpcClient client) { ISLogger.SetLogFileName("InputshareSP_ClipboardHost.log"); ISLogger.Write("Starting SP clipboard host"); clipMan = new WindowsClipboardManager(); clipMan.Start(); ddMan = new WindowsDragDropManager(); ddMan.Start(); iClient = client; iClient.ClipboardDataReceived += IClient_ClipboardDataReceived; iClient.CheckForDropReceived += IClient_CheckForDropReceived; iClient.DoDragDropReceived += IClient_DoDragDropReceived; iClient.Disconnected += IClient_Disconnected; clipMan.ClipboardContentChanged += ClipMan_ClipboardContentChanged; ddMan.DataDropped += DdMan_DataDropped; ddMan.DragDropCancelled += DdMan_DragDropCancelled; ddMan.DragDropSuccess += DdMan_DragDropSuccess; mouseStateTimer = new Timer(MouseStateTimerCallback, 0, 0, 100); }
protected override void OnStart(string[] args) { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; string path = AppDomain.CurrentDomain.BaseDirectory; ISLogger.SetLogFileName(path + @"\logs\InputshareService.log"); ISLogger.EnableConsole = false; ISLogger.EnableLogFile = true; ISLogger.Write("Current path = " + path); if (!Directory.Exists(path + "\\logs")) { try { if (!Directory.Exists(path + "\\logs")) { Directory.CreateDirectory(path + "\\logs"); } if (!Directory.Exists(path + "\\Downloads")) { Directory.CreateDirectory(path + "\\Downloads"); } } catch (Exception ex) { ISLogger.Write($"Failed to create file folder: {ex.Message}"); } } ISLogger.Write("Service->Service started"); try { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; } catch (Exception ex) { ISLogger.Write($"Error setting realtime priority: {ex.Message}"); } try { namedIpc = new NamedIpcServer(); namedIpc.Ipc_Connect += NamedIpc_Connect; namedIpc.RequestedState += NamedIpc_RequestedState; namedIpc.Ipc_Disconnect += NamedIpc_Disconnect; namedIpc.RequestedSetDownloadFolder += NamedIpc_RequestedSetDownloadFolder; namedIpc.RequestedDownloadFolder += NamedIpc_RequestedDownloadFolder; ISLogger.Write("Service->Named IPC server started"); }catch (Exception ex) { ISLogger.Write($"Service->Failed to create NamedIPC server: " + ex.Message); } if (!File.Exists(path + "\\inputsharesp.exe")) { ISLogger.Write("Service->Error: inputsharepSP not found! stopping service!"); Stop(); return; } CreatePipes(); EnableSASHKey(); cSocket = new ServerSocket(); cSocket.FileReceivePath = path + "\\Downloads"; spMon = new SpMonitor(); spMon.StartMonitoring(); spMon.SpStarted += SpMon_SpStarted; spMon.SpStopped += SpMon_SpStopped; launcher = new SpLauncher(); if (!launcher.SpRunning) { ISLogger.Write("Service->SP not found... launching"); try { launcher.LaunchSp(ipcWrite.PipeHandleAsString, ipcRead.PipeHandleAsString); ipcWrite.RemoveHandle(); ipcRead.RemoveHandle(); } catch (Exception ex) { if (ex is InvalidOperationException || ex is Win32Exception) { ISLogger.Write($"Failed to launch inputsharesp: {ex.Message}"); } } } cSocket.InputReceived += CSocket_InputReceived; cSocket.ClipboardTextReceived += CSocket_ClipboardTextReceived; cSocket.MessageReceived += CSocket_MessageReceived; cSocket.Connected += CSocket_Connected; cSocket.Disconnected += CSocket_Disconnected; cSocket.ConnectionFailed += CSocket_ConnectionFailed; cSocket.ConnectionError += CSocket_ConnectionError; ISLogger.Write("Service->Service started"); //Read initial config string lastAddr = ConfigManager.ReadConfig("LastAddress"); string lastName = ConfigManager.ReadConfig("LastName"); string lastGuidStr = ConfigManager.ReadConfig("LastGuid"); if (lastAddr == null || lastName == null || lastGuidStr == null) { return; } IPEndPoint.TryParse(lastAddr, out IPEndPoint lastEp); if (lastEp == null) { ISLogger.Write($"Service->Config file contained invalid address"); return; } Guid.TryParse(lastGuidStr, out Guid lastGuid); if (lastGuid == null) { ISLogger.Write($"Service->Config file contained invalid guid"); return; } if (lastName == "" && lastName.Length > 32) { ISLogger.Write($"Serivce->Config file contained invalid username"); return; } lastServer = lastEp; keepRetryingConnection = true; Ipc_Connect(lastEp, lastName, lastGuid); }