internal IPlugin AddPlugin(IPlugin plugin, GetClientsDelegate getClientsDelegate) { lock (plugins) { ulong PluginId = GetPluginId(plugin); if (plugins.ContainsKey(PluginId)) { throw new Exception("The plugin " + plugin.Name + " is already registered"); } plugin.Client = Client; plugin.PluginId = PluginId; plugin.GetClients = getClientsDelegate; plugins.Add(PluginId, plugin); return(plugin); } }
internal unsafe bool ServerHandshake(ServerProperties serverProperties, Socket UdpClient, GetClientsDelegate getClientsDelegate, PrivateKeyHandler KeyHandler) { this.PeerSide = SecureSocketProtocol2.PeerSide.Server; //check certificate info if (serverProperties.ServerCertificate.PrivateKey == null || (serverProperties.ServerCertificate.PrivateKey != null && serverProperties.ServerCertificate.PrivateKey.Length <= 16)) { throw new ArgumentException("The private key must be longer then 16 in length", "PrivateKey"); } onAddProtection(Connection.protection); //no error handling by SSP, this must work or there is simply no connection //apply private key ApplyPrivateKey(serverProperties.ServerCertificate.PrivateKey); if (serverProperties.KeyFiles != null) { foreach (Stream stream in serverProperties.KeyFiles) { while (stream.Position < stream.Length) { byte[] data = new byte[32768]; int read = stream.Read(data, 0, data.Length); if (read <= 0) { break; } Array.Resize(ref data, read); ApplyPrivateKey(data); } } } ServerSideHandshake handShake = new ServerSideHandshake(this, serverProperties, UdpClient, getClientsDelegate, KeyHandler); if (!handShake.DoHandshake()) { Disconnect(DisconnectReason.HandShakeFailed); throw new Exception("An unexpected error occured in the HandShake"); } this.CompletedHandshake = true; this.Connection.KeepAliveSW = Stopwatch.StartNew(); return(true); }
private void LoadSmartMethods() { IntPtr functionAddress = Kernel32.GetProcAddress(hModule, "exp_getClients"); GetClients = Marshal.GetDelegateForFunctionPointer <GetClientsDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_getAvailablePID"); GetAvailablePID = Marshal.GetDelegateForFunctionPointer <GetAvailablePIDDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_killClient"); KillClient = Marshal.GetDelegateForFunctionPointer <KillClientDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_spawnClient"); SpawnClient = Marshal.GetDelegateForFunctionPointer <SpawnClientDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_pairClient"); PairClient = Marshal.GetDelegateForFunctionPointer <PairClientDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_getClientPID"); GetClientPID = Marshal.GetDelegateForFunctionPointer <GetClientPIDDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_freeClient"); FreeClient = Marshal.GetDelegateForFunctionPointer <FreeClientDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_getImageArray"); GetImageArray = Marshal.GetDelegateForFunctionPointer <GetImageArrayDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_getDebugArray"); GetDebugArray = Marshal.GetDelegateForFunctionPointer <GetDebugArrayDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_getRefresh"); GetRefresh = Marshal.GetDelegateForFunctionPointer <GetRefreshDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_setRefresh"); SetRefresh = Marshal.GetDelegateForFunctionPointer <SetRefreshDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_setTransparentColor"); SetTransparentColor = Marshal.GetDelegateForFunctionPointer <SetTransparentColorDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_setGraphics"); SetGraphics = Marshal.GetDelegateForFunctionPointer <SetGraphicsDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_setEnabled"); SetEnabled = Marshal.GetDelegateForFunctionPointer <SetEnabledDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_isActive"); IsActive = Marshal.GetDelegateForFunctionPointer <IsActiveDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_getMousePos"); GetMousePos = Marshal.GetDelegateForFunctionPointer <GetMousePosDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_holdMouse"); HoldMouse = Marshal.GetDelegateForFunctionPointer <HoldMouseDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_releaseMouse"); ReleaseMouse = Marshal.GetDelegateForFunctionPointer <ReleaseMouseDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_holdMousePlus"); HoldMousePlus = Marshal.GetDelegateForFunctionPointer <HoldMousePlusDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_releaseMousePlus"); ReleaseMousePlus = Marshal.GetDelegateForFunctionPointer <ReleaseMousePlusDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_moveMouse"); MoveMouse = Marshal.GetDelegateForFunctionPointer <MoveMouseDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_windMouse"); WindMouse = Marshal.GetDelegateForFunctionPointer <WindMouseDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_clickMouse"); ClickMouse = Marshal.GetDelegateForFunctionPointer <ClickMouseDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_clickMousePlus"); ClickMousePlus = Marshal.GetDelegateForFunctionPointer <ClickMousePlusDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_isMouseButtonHeld"); IsMouseButtonHeld = Marshal.GetDelegateForFunctionPointer <IsMouseButtonHeldDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_scrollMouse"); ScrollMouse = Marshal.GetDelegateForFunctionPointer <ScrollMouseDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_sendKeys"); SendKeys = Marshal.GetDelegateForFunctionPointer <SendKeysDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_holdKey"); HoldKey = Marshal.GetDelegateForFunctionPointer <HoldKeyDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_releaseKey"); ReleaseKey = Marshal.GetDelegateForFunctionPointer <ReleaseKeyDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_isKeyDown"); IsKeyDown = Marshal.GetDelegateForFunctionPointer <IsKeyDownDelegate>(functionAddress); functionAddress = Kernel32.GetProcAddress(hModule, "exp_setCapture"); SetCapture = Marshal.GetDelegateForFunctionPointer <SetCaptureDelegate>(functionAddress); }
public ServerSideHandshake(SSPClient client, ServerProperties serverProperties, Socket UdpClient, GetClientsDelegate getClientsDelegate, PrivateKeyHandler KeyHandler) { this.Client = client; this.HandShakes = new List <Handshake>(); this.HandShakes.Add(new SHS_Validation(client)); this.HandShakes.Add(new SHS_Seed(client)); this.HandShakes.Add(new SHS_KeyExchange(client, serverProperties, KeyHandler)); this.HandShakes.Add(new SHS_Authentication(client, serverProperties)); this.HandShakes.Add(new SHS_TimeSynchronisation(client)); this.HandShakes.Add(new SHS_ClientInfo(client, serverProperties)); this.HandShakes.Add(new SHS_UDP(client, serverProperties, UdpClient)); this.HandShakes.Add(new SHS_Plugins(client, getClientsDelegate)); this.HandShakes.Add(new SHS_ShareClasses(client)); }
public SHS_Plugins(SSPClient client, GetClientsDelegate getClientsDelegate) : base(client) { this.getClientsDelegate = getClientsDelegate; }