public void Chat_Client(int port) { try { Task.Factory.StartNew(() => { var c = new IpcClient(); c.Initialize(port); listBox1.Items.Add("Started client."); var rep = c.Send("Hello from client"); listBox1.Items.Add(rep); }); //while(true) //{ // Thread.Sleep(1000); //} } catch (Exception ex) { listBox1.Items.Add(ex.Message); } //Console.WriteLine(); }
private void ServerOnReceivedRequest(object sender, ReceivedRequestEventArgs e) { Log.Information("[PATCHERIPC] IPC: " + e.Request); var msg = JsonConvert.DeserializeObject <PatcherIpcEnvelope>(PatcherMain.Base64Decode(e.Request), XIVLauncher.PatchInstaller.PatcherMain.JsonSettings); switch (msg.OpCode) { case PatcherIpcOpCode.Hello: _client.Initialize(XIVLauncher.PatchInstaller.PatcherMain.IPC_CLIENT_PORT); Log.Information("[PATCHERIPC] GOT HELLO"); State = InstallerState.Ready; break; case PatcherIpcOpCode.InstallOk: Log.Information("[PATCHERIPC] INSTALL OK"); State = InstallerState.Ready; break; case PatcherIpcOpCode.InstallFailed: State = InstallerState.Failed; MessageBox.Show( "The patch installer ran into an error.\nPlease report this error.\nPlease use the official launcher."); Stop(); Environment.Exit(0); break; default: throw new ArgumentOutOfRangeException(); } }
internal UIClient() { _client.Initialize(12345); Console.WriteLine("Started client."); var rep = _client.Send("ConfigInitialized"); }
public Form1() { InitializeComponent(); this.WSController = new System.ServiceProcess.ServiceController(); Thread.Sleep(3000); c.Initialize(12345); }
static void Main(string[] args) { try { Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File(Path.Combine(Paths.RoamingPath, "patcher.log")) .WriteTo.Debug() .MinimumLevel.Verbose() .CreateLogger(); if (args.Length > 1) { try { InstallPatch(args[0], args[1]); Log.Information("OK"); } catch (Exception ex) { Log.Error(ex, "Patch installation failed."); Environment.Exit(-1); } Environment.Exit(0); return; } _client.Initialize(IPC_SERVER_PORT); _server.Start(IPC_CLIENT_PORT); _server.ReceivedRequest += ServerOnReceivedRequest; Log.Information("[PATCHER] IPC connected"); SendIpcMessage(new PatcherIpcEnvelope { OpCode = PatcherIpcOpCode.Hello, Data = DateTime.Now }); Log.Information("[PATCHER] sent hello"); while (true) { if (Process.GetProcesses().All(x => x.ProcessName != "XIVLauncher")) { Environment.Exit(0); return; } Thread.Sleep(1000); } } catch (Exception ex) { MessageBox.Show("Patcher init failed.\n\n" + ex, "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error); } }
private static void SendMessage(string arguments) { if (string.IsNullOrEmpty(arguments)) { return; } var c = new IpcClient(); c.Initialize(12345); c.Send(arguments); }
private static void Main() { var c = new IpcClient(); c.Initialize(12345); Console.WriteLine("Started client."); var rep = c.Send("Hello"); Console.WriteLine("Received: " + rep); while (true) { Thread.Sleep(1000); } }
/// <summary> /// Creates an IPC client and sends a message to the already /// running instance of Quaver /// </summary> private static void SendToRunningInstanceIpc(string[] messages) { try { var c = new IpcClient(); c.Initialize(IpcPort); foreach (var message in messages) { c.Send(message); } } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public static void StartIpcCommunication(JavaScriptBridge javaScriptBridge, int serverPort, int clientPort) { var server = new IpcServer(); server.Start(serverPort); server.ReceivedRequest += (sender, e) => { var deserialized = JsonConvert.DeserializeObject <WebUiMessageEventArgs>(e.Request); javaScriptBridge.SendMessageToOpenProject( deserialized.MessageType, deserialized.TrackingId, deserialized.MessagePayload); }; var client = new IpcClient(); client.Initialize(clientPort); javaScriptBridge.OnWebUiMessageReceived += (s, e) => client.Send(JsonConvert.SerializeObject(e)); }
public SecureBoxService(Database database, ILogger <SecureBoxService> logger) { _logger = logger; // IPC initialization var ipcServer = new IpcServer(); ipcServer.ReceivedRequest += OnCommandReceived; ipcServer.Start(7523); var ipcClient = new IpcClient(); ipcClient.Initialize(7524); var config = database.Config.ReadConfig(); var virtualDriveRequestHandler = new VirtualDriveRequestHandler(config, ipcClient); _virtualDrive = new VirtualDrive.VirtualDrive(PathUtils.VirtualDriveMirrorPath()); _virtualDrive.OnRequestFileOpen += virtualDriveRequestHandler.OnRequestFileOpen; }
protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // Send input to our main process, if running if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1) { // If we're running more than 1 process, bail, and send input to the main process var client = new IpcClient(); client.Initialize(IpcPort); client.Send(JsonConvert.SerializeObject(new IpcMessage { Name = "ProcStartArgs", Payload = e.Args })); // Shutdown the process Shutdown(0); return; } StartupUri = new Uri("MainWindow.xaml", UriKind.Relative); }
static void Main(string[] args) { Console.SetWindowSize(60, 10); var c = new IpcClient(); c.Initialize(12345); Console.WriteLine("Started client"); try { var rep = c.Send(args[0]); Console.WriteLine("Received: " + rep); } catch (Exception e) { Console.WriteLine("Error: did you start the server with admin privileges?"); Console.WriteLine("Press any key to continue.."); Console.ReadKey(); } }
/// <summary> /// Load event handler. /// </summary> private void Form1_Load(object sender, EventArgs e) { //Initialize IPC Server, try 3 times for (int i = 0; i < 3; i++) { int serverPort = FFunc.FreePortHelper.GetFreePort(23000); s.UIPort = serverPort; try { radioServer = new IpcServer(); radioServer.Start(serverPort); //this.radioServer.ReceivedRequest += (sender, args) => { }; radioServer.ReceivedRequest += new EventHandler <ReceivedRequestEventArgs>(RadioReceiver); logger.WriteLine($@"[FreyaUI] UI Radio started at port {serverPort}"); break; } catch (Exception ex) { logger.WriteLine(string.Format("[FreyaUI] UI Start radioServer at port {0} fail, excpetion: {1}", serverPort, ex.Message)); } } // For HiJacking SuperNotes WebService Communication /* * radioServer1 = new IpcServer(); * radioServer1.Start(8080); * radioServer1.ReceivedRequest += (ssender, sargs) => * { * UpdateMSGtoUI(sargs.Request); * }; */ int servicePort = (FFunc.GetRegKey("ServicePort1") == null) ? 10000 : (int)FFunc.GetRegKey("ServicePort1"); radioClient = new IpcClientFreyaUI(); radioClient.Initialize(servicePort); //**check service exist, running --> if not --> install and run if (!InitializeFreyaEnvironment()) { return; } //** Get Status from Service getStatus(); //** Timer for Miner IdleTimer = new System.Timers.Timer(); IdleTimer.Elapsed += new ElapsedEventHandler(CheckIdleTime); IdleTimer.Interval = 1000; IdleTimer.Start(); //** Timer for Service state update UpdateServiceStatus(null); StatusTimer = new System.Threading.Timer(new TimerCallback(UpdateServiceStatus), null, 5000, 5000); //** Timer for IMAP Quota update IMAPTimer = new System.Threading.Timer(new TimerCallback(UpdateIMAPQuota), null, 1000, 900000); //** DMS scheduler if (RegSetting.DMS_Enable) { var dateNow = DateTime.Now; var date = new DateTime(dateNow.Year, dateNow.Month, dateNow.Day, RegSetting.DMS_TriggerAt.Hour, RegSetting.DMS_TriggerAt.Minute, 0); updateDMSAt(getNextDate(date)); } //** UI Check if (RegSetting.hasRight(FConstants.FeatureByte.Hide) && !RegSetting.hasRight(FConstants.FeatureByte.Odin)) { label_IMAPQuota.Visible = false; pictureBox_DMS.Visible = false; pictureBox_Miner.Visible = false; } else { label_IMAPQuota.Image = (Image)Resources.QuotaUnAvailable; toolTip.SetToolTip(label_IMAPQuota, "Freya is trying to get MailBox quota..."); if (!IconLock_DMS) { pictureBox_DMS.Image = RegSetting.DMS_Enable ? (Image)Resources.dms_enable : (Image)Resources.dms_disable; toolTip.SetToolTip(pictureBox_DMS, RegSetting.DMS_Enable ? "Auto DMS is enable, Freya will fill out DMS daily for you." : "Auto DMS disabled."); } } label1.Text = ""; label2.Text = ""; label3.Text = ""; label4.Text = ""; alwaysActiveToolStripMenuItem.Checked = RegSetting.hasRight(FConstants.FeatureByte.AlwaysRun) ? true : false; enableToolStripMenuItem.Enabled = s.MinerEnable ? false : true; disableToolStripMenuItem.Enabled = s.MinerEnable ? true : false; //** Get arguments, restore windows state string[] args = Environment.GetCommandLineArgs(); if (args.Length == 2) //第一個是.exe路徑 { if (args[1].Equals("minimized")) { this.WindowState = FormWindowState.Minimized; this.ShowInTaskbar = false; this.notifyIcon1.Visible = true; startMinimized = true; } //this.Location //this.Size } }
static void Main(string[] args) { try { Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File(Path.Combine(Paths.RoamingPath, "patcher.log")) .WriteTo.Debug() .MinimumLevel.Verbose() .CreateLogger(); if (args.Length > 1 && args[0] == "install") { try { InstallPatch(args[1], args[2]); Log.Information("OK"); } catch (Exception ex) { Log.Error(ex, "Patch installation failed."); Environment.Exit(-1); } Environment.Exit(0); return; } if (args.Length == 0) { Log.Information("usage: XIVLauncher.PatchInstaller.exe install <patch> <game dir>\n" + "OR\n" + "usage: XIVLauncher.PatchInstaller.exe <server port> <client port>"); Environment.Exit(-1); return; } _client.Initialize(int.Parse(args[0])); _server.Start(int.Parse(args[1])); _server.ReceivedRequest += ServerOnReceivedRequest; Log.Information("[PATCHER] IPC connected"); SendIpcMessage(new PatcherIpcEnvelope { OpCode = PatcherIpcOpCode.Hello, Data = DateTime.Now }); Log.Information("[PATCHER] sent hello"); try { while (true) { if ((Process.GetProcesses().All(x => x.ProcessName != "XIVLauncher") && _queuedInstalls.IsEmpty) || !RunInstallQueue()) { Environment.Exit(0); return; } Thread.Sleep(1000); } } catch (Exception ex) { Log.Error(ex, "PatcherMain loop encountered an error."); } } catch (Exception ex) { MessageBox.Show("Patcher init failed.\n\n" + ex, "XIVLauncher", MessageBoxButton.OK, MessageBoxImage.Error); } }
public IPCClient(int port, int timeout = 0) { client = new IpcClient(); client.Initialize(port, timeout); }
static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File(Path.Combine(Paths.RoamingPath, "patcher.log")) .WriteTo.Debug() .MinimumLevel.Verbose() .CreateLogger(); if (args.Length > 1) { try { InstallPatch(args[0], args[1]); Log.Information("OK"); } catch (Exception ex) { Log.Error(ex, "Patch installation failed."); Environment.Exit(-1); } Environment.Exit(0); return; } _client.Initialize(IPC_SERVER_PORT); _server.Start(IPC_CLIENT_PORT); _server.ReceivedRequest += ServerOnReceivedRequest; Log.Information("[PATCHER] IPC connected"); SendIpcMessage(new PatcherIpcEnvelope { OpCode = PatcherIpcOpCode.Hello, Data = DateTime.Now }); Log.Information("[PATCHER] sent hello"); while (true) { if (Process.GetProcesses().All(x => x.ProcessName != "XIVLauncher")) { Environment.Exit(0); return; } Thread.Sleep(1000); } return; if (args.Length == 3) { var patchlist = new[] { "4e9a232b/H2017.06.06.0000.0001a.patch", "4e9a232b/H2017.06.06.0000.0001b.patch", "4e9a232b/H2017.06.06.0000.0001c.patch", "4e9a232b/H2017.06.06.0000.0001d.patch", "4e9a232b/H2017.06.06.0000.0001e.patch", "4e9a232b/H2017.06.06.0000.0001f.patch", "4e9a232b/H2017.06.06.0000.0001g.patch", "4e9a232b/H2017.06.06.0000.0001h.patch", "4e9a232b/H2017.06.06.0000.0001i.patch", "4e9a232b/H2017.06.06.0000.0001j.patch", "4e9a232b/H2017.06.06.0000.0001k.patch", "4e9a232b/H2017.06.06.0000.0001l.patch", "4e9a232b/H2017.06.06.0000.0001m.patch", "4e9a232b/H2017.06.06.0000.0001n.patch", "4e9a232b/D2017.07.11.0000.0001.patch", "4e9a232b/D2017.09.24.0000.0001.patch", "4e9a232b/D2017.10.11.0000.0001.patch", "4e9a232b/D2017.10.31.0000.0001.patch", "4e9a232b/D2017.11.24.0000.0001.patch", "4e9a232b/D2018.01.12.0000.0001.patch", "4e9a232b/D2018.02.09.0000.0001.patch", "4e9a232b/D2018.04.27.0000.0001.patch", "4e9a232b/D2018.05.26.0000.0001.patch", "4e9a232b/D2018.06.19.0000.0001.patch", "4e9a232b/D2018.07.18.0000.0001.patch", "4e9a232b/D2018.09.05.0000.0001.patch", "4e9a232b/D2018.10.19.0000.0001.patch", "4e9a232b/D2018.12.15.0000.0001.patch", "4e9a232b/D2019.01.26.0000.0001.patch", "4e9a232b/D2019.03.12.0000.0001.patch", "4e9a232b/D2019.03.15.0000.0001.patch", "4e9a232b/D2019.04.12.0000.0001.patch", "4e9a232b/D2019.04.16.0000.0000.patch", "4e9a232b/D2019.05.08.0000.0001.patch", "4e9a232b/D2019.05.09.0000.0000.patch", "4e9a232b/D2019.05.29.0000.0000.patch", "4e9a232b/D2019.05.29.0001.0000.patch", "4e9a232b/D2019.05.31.0000.0001.patch", "4e9a232b/D2019.06.07.0000.0001.patch", "4e9a232b/D2019.06.18.0000.0001.patch", "4e9a232b/D2019.06.22.0000.0000.patch", "4e9a232b/D2019.07.02.0000.0000.patch", "4e9a232b/D2019.07.09.0000.0000.patch", "4e9a232b/D2019.07.10.0000.0001.patch", "4e9a232b/D2019.07.10.0001.0000.patch", "4e9a232b/D2019.07.24.0000.0001.patch", "4e9a232b/D2019.07.24.0001.0000.patch", "4e9a232b/D2019.08.20.0000.0000.patch", "4e9a232b/D2019.08.21.0000.0000.patch", "4e9a232b/D2019.10.11.0000.0000.patch", "4e9a232b/D2019.10.16.0000.0001.patch", "4e9a232b/D2019.10.19.0000.0001.patch", "4e9a232b/D2019.10.24.0000.0000.patch", "4e9a232b/D2019.11.02.0000.0000.patch", "4e9a232b/D2019.11.05.0000.0001.patch", "4e9a232b/D2019.11.06.0000.0000.patch", "4e9a232b/D2019.11.19.0000.0000.patch", "4e9a232b/D2019.12.04.0000.0001.patch", "4e9a232b/D2019.12.05.0000.0000.patch", "4e9a232b/D2019.12.17.0000.0000.patch", "4e9a232b/D2019.12.19.0000.0000.patch", "4e9a232b/D2020.01.31.0000.0000.patch", "4e9a232b/D2020.01.31.0001.0000.patch", "4e9a232b/D2020.02.10.0000.0001.patch", "4e9a232b/D2020.02.11.0000.0000.patch", "4e9a232b/D2020.02.27.0000.0000.patch", "4e9a232b/D2020.02.29.0000.0001.patch", "4e9a232b/D2020.03.04.0000.0000.patch", "4e9a232b/D2020.03.12.0000.0000.patch", "4e9a232b/D2020.03.24.0000.0000.patch", "4e9a232b/D2020.03.25.0000.0000.patch", "4e9a232b/D2020.03.26.0000.0000.patch", "4e9a232b/D2020.03.27.0000.0000.patch", /*"ex1/6b936f08/H2017.06.01.0000.0001a.patch", * "ex1/6b936f08/H2017.06.01.0000.0001b.patch", * "ex1/6b936f08/H2017.06.01.0000.0001c.patch", * "ex1/6b936f08/H2017.06.01.0000.0001d.patch", * "ex1/6b936f08/D2017.09.24.0000.0000.patch", * "ex1/6b936f08/D2018.09.05.0000.0001.patch", * "ex1/6b936f08/D2019.11.06.0000.0001.patch", * "ex1/6b936f08/D2020.03.04.0000.0001.patch", * "ex1/6b936f08/D2020.03.24.0000.0000.patch", * "ex1/6b936f08/D2020.03.26.0000.0000.patch", * "ex2/f29a3eb2/D2017.03.18.0000.0000.patch", * "ex2/f29a3eb2/D2017.05.26.0000.0000.patch", * "ex2/f29a3eb2/D2017.05.26.0001.0000.patch", * "ex2/f29a3eb2/D2017.05.26.0002.0000.patch", * "ex2/f29a3eb2/D2017.06.27.0000.0001.patch", * "ex2/f29a3eb2/D2017.09.24.0000.0001.patch", * "ex2/f29a3eb2/D2018.01.12.0000.0001.patch", * "ex2/f29a3eb2/D2018.02.23.0000.0001.patch", * "ex2/f29a3eb2/D2018.04.27.0000.0001.patch", * "ex2/f29a3eb2/D2018.07.18.0000.0001.patch", * "ex2/f29a3eb2/D2018.09.05.0000.0001.patch", * "ex2/f29a3eb2/D2018.12.14.0000.0001.patch", * "ex2/f29a3eb2/D2019.01.26.0000.0001.patch", * "ex2/f29a3eb2/D2019.03.12.0000.0001.patch", * "ex2/f29a3eb2/D2019.05.29.0000.0001.patch", * "ex2/f29a3eb2/D2019.12.04.0000.0001.patch", * "ex2/f29a3eb2/D2020.02.29.0000.0001.patch", * "ex2/f29a3eb2/D2020.03.24.0000.0000.patch", * "ex2/f29a3eb2/D2020.03.26.0000.0000.patch", * "ex3/859d0e24/D2019.04.02.0000.0000.patch", * "ex3/859d0e24/D2019.05.29.0000.0000.patch", * "ex3/859d0e24/D2019.05.29.0001.0000.patch", * "ex3/859d0e24/D2019.05.29.0002.0000.patch", * "ex3/859d0e24/D2019.07.09.0000.0001.patch", * "ex3/859d0e24/D2019.10.11.0000.0001.patch", * "ex3/859d0e24/D2020.01.31.0000.0001.patch", * "ex3/859d0e24/D2020.02.29.0000.0001.patch", * "ex3/859d0e24/D2020.03.24.0000.0000.patch", * "ex3/859d0e24/D2020.03.26.0000.0000.patch"*/ }; foreach (var s in patchlist) { InstallPatch(args[0] + s, args[1]); } return; } if (args.Length == 1) { return; } Console.WriteLine("XIVLauncher.PatchInstaller\n\nUsage:\nXIVLauncher.PatchInstaller.exe <patch path> <game path> <repository>\nOR\nXIVLauncher.PatchInstaller.exe <pipe name>"); }
private static void updater_UpdatesFound(object sender, EventArgs e) { var freyaUpdater = Updater.Instance; Console.ForegroundColor = ConsoleColor.Yellow; logger.WriteLine(string.Format("[H] Local --> Server Version: {0} --> {1}", freyaUpdater.Context.CurrentVersion, freyaUpdater.Context.UpdateInfo.AppVersion)); logger.WriteLine("[H] New Version Found:" + freyaUpdater.Context.UpdateInfo.AppVersion); Console.ResetColor(); // Stop and Uninstall Service StopService(); UninstallService(); // Uninstall Registry keys (Startup) try { RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (key != null) { key.DeleteValue("FreyaUI"); } RegistryKey key1 = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (key1 != null) { key1.DeleteValue("FreyaUI"); } logger.WriteLine("[H] Registry key deleted"); } catch (Exception) { } if (!FFunc.HasRight(FConstants.FeatureByte.Hide)) { // Deploy FreyaUI WatchDog int servicePort = (FFunc.GetRegKey("FreyaUIPort") == null) ? 10000 : (int)FFunc.GetRegKey("FreyaUIPort"); logger.WriteLine($"[H] Deploying Watchdog for FreyaUI... (UIPort={servicePort})"); IpcClient radioClient = new IpcClient(); radioClient.Initialize(servicePort); string result = radioClient.Send("{ \"Type\": \"CMD\", \"Data\": \"StartUpdateProcess\", \"Data2\": \"\",\"Loglevel\": 0}"); Thread.Sleep(1000); logger.WriteLine("[H] UI feedback: " + result); //if (radioClient.Send("{ \"Type\": \"CMD\", \"Data\": \"DeployWacthDog\", \"Data2\": \"\",\"Loglevel\": 0}") != "WatchDogDeployed") // Console.WriteLine(radioClient.Send("{ \"Type\": \"CMD\", \"Data\": \"DeployWacthDog\", \"Data2\": \"\",\"Loglevel\": 0}")); Thread.Sleep(1000); } else { logger.WriteLine("[H] Hide mode, no watchdog."); } KillProcess(); Console.ForegroundColor = ConsoleColor.DarkYellow; logger.WriteLine("[H] Starting update"); logger.WriteLine("[H] Check Service exist:" + ServiceExists(FConstants.ServiceName).ToString()); freyaUpdater.StartExternalUpdater(); logger.WriteLine("[H] Updater thread started in background. Terminate Heimdallr."); Console.ResetColor(); }