static void PushThreadActionRunner(object o) { if (!(o is PushDataForThreadRunner)) { return; } PushDataForThreadRunner t = (PushDataForThreadRunner)o; try { switch (t.p.Action) { case "ping": t.net.ResponsePushData2("ok", t.p.Action, 2, t.p.ReplyID); break; //case "getfullscreen": // t.net.ResponsePushData2(Redirs.MainScreenSystem.GetFullscreen(), t.p.Action, 2, t.p.ReplyID); // break; //case "getdeltascreen": // t.net.ResponsePushData2(Redirs.MainScreenSystem.GetDeltaScreen(), t.p.Action, 2, t.p.ReplyID); // break; case "startwsscreen": t.net.ResponsePushData2(Redirs.MainScreenDataWS.StartRemoteScreen(t.net, t.p.AdditionalData1), t.p.Action, 1, t.p.ReplyID); break; } } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.VerboseWriteEventLog("Push2: PushThreadActionRunner thread crashed", System.Diagnostics.EventLogEntryType.Information); } }
static void PushThreadActionRunner(object o) { if (!(o is PushDataForThreadRunner)) { return; } PushDataForThreadRunner t = (PushDataForThreadRunner)o; try { switch (t.p.Action) { case "ping": t.net.ResponsePushData1("ok", t.p.Action, 1, t.p.ReplyID); break; case "netcreatedata2": t.net.ResponsePushData1(NetRedirPWS.StartNet(t.p.AdditionalData1, t.net), t.p.Action, 1, t.p.ReplyID); break; case "netclosedata2": t.net.ResponsePushData1(NetRedirPWS.CloseConnection(t.p.AdditionalData1, t.net), t.p.Action, 1, t.p.ReplyID); break; } } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.VerboseWriteEventLog("Push1: PushThreadActionRunner thread crashed", System.Diagnostics.EventLogEntryType.Information); } }
static void PushThreadActionRunner(object o) { if (!(o is PushDataForThreadRunner)) { return; } PushDataForThreadRunner t = (PushDataForThreadRunner)o; try { switch (t.p.Action) { case "ping": t.net.ResponsePushData10("ok", t.p.Action, 10, t.p.ReplyID); break; case "chatmessage": try { PushChatMessage m = JsonConvert.DeserializeObject <PushChatMessage>(t.p.AdditionalData1); PushMessage(m); } catch { } t.net.ResponsePushData10(new NetBool() { Data = true }, t.p.Action, 10, t.p.ReplyID); break; } } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.VerboseWriteEventLog("Push10: PushThreadActionRunner thread crashed", System.Diagnostics.EventLogEntryType.Information); } }
static void PushThreadActionRunner(object o) { if (!(o is PushDataForThreadRunner)) { return; } PushDataForThreadRunner t = (PushDataForThreadRunner)o; try { switch (t.p.Action) { case "clock": t.net.ResponsePushData0(DateTime.UtcNow, t.p.Action, 0, t.p.ReplyID); break; case "ping": t.net.ResponsePushData0("ok", t.p.Action, 0, t.p.ReplyID); break; case "tasks": t.net.ResponsePushData0(TaskManager.GetTasks(), t.p.Action, 0, t.p.ReplyID); break; case "killtask": t.net.ResponsePushData0(TaskManager.KillTask(t.p.AdditionalData1), t.p.Action, 0, t.p.ReplyID); break; case "listfiles": t.net.ResponsePushData0(Filesystem.ListFiles(t.p.AdditionalData1), t.p.Action, 0, t.p.ReplyID); break; case "checkfile": t.net.ResponsePushData0(Filesystem.CheckFile(t.p.AdditionalData1), t.p.Action, 0, t.p.ReplyID); break; case "getsessions": t.net.ResponsePushData0(TaskManager.GetTSRunningSessions(), t.p.Action, 0, t.p.ReplyID); break; case "runtask": t.net.ResponsePushData0(TaskManager.RunTask(t.p.AdditionalData1, t.net), t.p.Action, 0, t.p.ReplyID); break; case "wugetlist": t.net.ResponsePushData0(WindowsUpdateClient.GetUpdateList(), t.p.Action, 0, t.p.ReplyID); break; case "wucheck": t.net.ResponsePushData0(WindowsUpdateClient.CheckForUpdates(), t.p.Action, 0, t.p.ReplyID); break; case "wustatus": t.net.ResponsePushData0(WindowsUpdateClient.GetStatus(), t.p.Action, 0, t.p.ReplyID); break; case "wuinstall": t.net.ResponsePushData0(WindowsUpdateClient.InstallUpdates(), t.p.Action, 0, t.p.ReplyID); break; case "wustatusrestart": t.net.ResponsePushData0(WindowsUpdateClient.QueryRestartPending(), t.p.Action, 0, t.p.ReplyID); break; case "restartsystem": ProgramAgent.CPP.RestartSystem(); t.net.ResponsePushData0(new NetInt32() { Data = 0 }, t.p.Action, 0, t.p.ReplyID); break; case "restartsystemforced": ProgramAgent.CPP.RestartSystemForced(); t.net.ResponsePushData0(new NetInt32() { Data = 0 }, t.p.Action, 0, t.p.ReplyID); break; case "services": t.net.ResponsePushData0(Services.GetServices(), t.p.Action, 0, t.p.ReplyID); break; case "servicecontrol": t.net.ResponsePushData0(Services.ServiceControl(t.p.AdditionalData1), t.p.Action, 0, t.p.ReplyID); break; case "efigetdevices": t.net.ResponsePushData0(EFIBios.GetEFIBootDevices(), t.p.Action, 0, t.p.ReplyID); break; case "efisetnextdevice": t.net.ResponsePushData0(EFIBios.SetNextEFIBootDevice(t.p.AdditionalData1), t.p.Action, 0, t.p.ReplyID); break; } } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.VerboseWriteEventLog("Push0: PushThreadActionRunner thread crashed", System.Diagnostics.EventLogEntryType.Information); } }
static void PushThread() { Network net = null; PushDataRoot pd; int Crashes = 0; do { try { if (net == null) { net = Utilities.ConnectNetwork(-1); } if (net == null) { FoxEventLog.VerboseWriteEventLog("Push0: no connection", System.Diagnostics.EventLogEntryType.Information); for (int i = 0; i < WaitNoConnection; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } pd = net.GetPushData0(); if (pd == null) { FoxEventLog.VerboseWriteEventLog("Push0: pd==null", System.Diagnostics.EventLogEntryType.Information); for (int i = 0; i < WaitPDisNULL; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } pd = net.GetPushData0(); if (pd == null) { net = null; FoxEventLog.VerboseWriteEventLog("Push0: pd==null - 2nd time - resetting connection", System.Diagnostics.EventLogEntryType.Information); for (int i = 0; i < WaitPDisNULL2; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } } if (ApplicationCertificate.Verify(pd) == false) { FoxEventLog.WriteEventLog("Push0: One or more PushData were tampered - no PushData will be processed.", System.Diagnostics.EventLogEntryType.Error); for (int i = 0; i < WaitTamperIssue; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } Crashes = 0; if (pd.Data.Action == "repeat") { if (StopThread == true) { return; } FoxEventLog.VerboseWriteEventLog("Push0: repeat", System.Diagnostics.EventLogEntryType.Information); continue; } if (pd.Data.Action == "quit") { FoxEventLog.VerboseWriteEventLog("Push0: quit", System.Diagnostics.EventLogEntryType.Information); net = null; for (int i = 0; i < WaitQuit; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } if (pd.Data.Action == "stdin") { Redirs.MainSTDIORedir.ProcessStdInAgent(pd.Data.AdditionalData1); continue; } Thread a = new Thread(new ParameterizedThreadStart(PushThreadActionRunner)); PushDataForThreadRunner t = new PushDataForThreadRunner(); t.net = net.CloneElement(); t.p = pd.Data; a.Start(t); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.VerboseWriteEventLog("Push0: SEH internally", System.Diagnostics.EventLogEntryType.Information); Crashes++; if (Crashes > 3) { FoxEventLog.VerboseWriteEventLog("Push0: Resetting connection due too many crashes", System.Diagnostics.EventLogEntryType.Information); net = null; Crashes = 0; } for (int i = 0; i < WaitCrash; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } } } while (StopThread == false); }
static void PushThread() { Network net = null; PushDataRoot pd; int Crashes = 0; DateTime? ChatPickup = null; do { try { if (net == null) { net = Utilities.ConnectNetwork(-1); } if (net == null) { FoxEventLog.VerboseWriteEventLog("Push10: no connection", System.Diagnostics.EventLogEntryType.Information); for (int i = 0; i < WaitNoConnection; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } ConfirmPopMessage(net); if (ChatPickup == null) { ChatPickup = DateTime.UtcNow.AddDays(-1); } if ((DateTime.UtcNow - ChatPickup.Value).TotalMinutes > ChatPickupPeriodMin) { PickupMessages(net); ChatPickup = DateTime.UtcNow; } pd = net.GetPushData10(); if (pd == null) { FoxEventLog.VerboseWriteEventLog("Push10: pd==null", System.Diagnostics.EventLogEntryType.Information); for (int i = 0; i < WaitPDisNULL; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } pd = net.GetPushData10(); if (pd == null) { net = null; FoxEventLog.VerboseWriteEventLog("Push10: pd==null - 2nd time - resetting connection", System.Diagnostics.EventLogEntryType.Information); for (int i = 0; i < WaitPDisNULL2; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } } if (ApplicationCertificate.Verify(pd) == false) { FoxEventLog.WriteEventLog("Push10: One or more PushData were tampered - no PushData will be processed.", System.Diagnostics.EventLogEntryType.Error); for (int i = 0; i < WaitTamperIssue; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } Crashes = 0; if (pd.Data.Action == "repeat") { if (StopThread == true) { return; } FoxEventLog.VerboseWriteEventLog("Push10: repeat", System.Diagnostics.EventLogEntryType.Information); continue; } if (pd.Data.Action == "quit") { FoxEventLog.VerboseWriteEventLog("Push10: quit", System.Diagnostics.EventLogEntryType.Information); net = null; for (int i = 0; i < WaitQuit; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } continue; } Thread a = new Thread(new ParameterizedThreadStart(PushThreadActionRunner)); PushDataForThreadRunner t = new PushDataForThreadRunner(); t.net = net.CloneElement2(); t.p = pd.Data; a.Start(t); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); FoxEventLog.VerboseWriteEventLog("Push10: SEH internally", System.Diagnostics.EventLogEntryType.Information); Crashes++; if (Crashes > 3) { FoxEventLog.VerboseWriteEventLog("Push10: Resetting connection due too many crashes", System.Diagnostics.EventLogEntryType.Information); net = null; Crashes = 0; } for (int i = 0; i < WaitCrash; i++) { Thread.Sleep(1000); if (StopThread == true) { return; } } } } while (StopThread == false); }