protected override void OnSessionChange(SessionChangeDescription changeDescription) { switch (changeDescription.Reason) { case SessionChangeReason.SessionLogon: case SessionChangeReason.SessionLogoff: case SessionChangeReason.SessionLock: case SessionChangeReason.SessionUnlock: { var packet = new SessionEventPacket(changeDescription); Connection.SendPacket(packet); break; } case SessionChangeReason.ConsoleConnect: break; case SessionChangeReason.ConsoleDisconnect: break; case SessionChangeReason.RemoteConnect: break; case SessionChangeReason.RemoteDisconnect: break; case SessionChangeReason.SessionRemoteControl: break; default: throw new ArgumentOutOfRangeException(); } }
public void StartService() { Connection = new Connection { ServerAddress = Properties.Settings.Default.ServerAddress, ServerPort = Properties.Settings.Default.ServerPort, BindHandler = (_) => new BindPacket("Service"), PostBindHandler = (_) => { if (WindowsAPI.WTSGetActiveConsoleSessionId() == 0) { return; } var packet = new SessionEventPacket((int)WindowsAPI.WTSGetActiveConsoleSessionId(), "SessionLogon"); Connection.SendPacket(packet); }, ExceptionHandler = (exception) => { EventLog.WriteEntry( "Networking exception occured: " + exception.GetType().ToString() + "\n" + exception.Message, EventLogEntryType.Error); }, KnownPackets = { ["Action"] = new ActionPacket(), ["Execute"] = new ExecutePacket(), ["PatchFile"] = new PatchFilePacket() } }; Connection.Connect(); }