Beispiel #1
0
		static void Main (string [] args)
		{
			IpcServerChannel channel = new IpcServerChannel ("Foo");
			ChannelServices.RegisterChannel (channel, false);
			RemotingConfiguration.RegisterWellKnownServiceType (typeof (Fooo), "Foo", WellKnownObjectMode.Singleton);
			Console.ReadLine ();
		}
        public HookProcess(Process process, OverlayConfig overlayConfig, OverlayInterface overlayInterface)
        {
            if (HookManager.IsHooked(process.Id))
            {
                throw new ProcessAlreadyHookedException();
            }

            overlayInterface.ProcessID = process.Id;
            OverlayInterface = overlayInterface;

            Server = RemoteHooking.IpcCreateServer<OverlayInterface>(ref ChannelName, WellKnownObjectMode.Singleton, OverlayInterface);

            try
            {
                var libraryName = typeof (OverlayInterface).Assembly.GetName()
                                                           .Name + ".dll";
                var location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, libraryName);
                RemoteHooking.Inject(process.Id, InjectionOptions.NoService | InjectionOptions.DoNotRequireStrongName, location, location, ChannelName, overlayConfig);
            }
            catch (Exception ex)
            {
                throw new InjectionFailedException(ex);
            }
            HookManager.AddHookedProcess(process.Id);
            InjectedProcess = process;
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            if ((args.Length == 2) && (args[0].Equals("-iphonepackager")))
            {
                // We were run as a 'child' process, quit when our 'parent' process exits
                // There is no parent-child relationship WRT windows, it's self-imposed.
                int ParentPID = int.Parse(args[1]);

                IpcServerChannel Channel = new IpcServerChannel("iPhonePackager");
                ChannelServices.RegisterChannel(Channel, false);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(DeploymentImplementation), "DeploymentServer_PID" + ParentPID.ToString(), WellKnownObjectMode.Singleton);

                Process ParentProcess = Process.GetProcessById(ParentPID);
                while (!ParentProcess.HasExited)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            else
            {
                // Run directly by some intrepid explorer
                Console.WriteLine("Note: This program should only be started by iPhonePackager");
                Console.WriteLine("  This program cannot be used on it's own.");

                DeploymentImplementation Deployer = new DeploymentImplementation();
                var DeviceList = Deployer.EnumerateConnectedDevices();
                foreach (var Device in DeviceList)
                {
                    Console.WriteLine("  - Found device named {0} of type {1} with UDID {2}", Device.DeviceName, Device.DeviceType, Device.UDID);
                }

                Console.WriteLine("Exiting.");
            }
        }
        public EntryPoint(
            EasyHook.RemoteHooking.IContext context,
            String channelName,
            CaptureConfig config)
        {
            // Get reference to IPC to host application
            // Note: any methods called or events triggered against _interface will execute in the host process.
            _interface = EasyHook.RemoteHooking.IpcConnectClient<CaptureInterface>(channelName);

            // We try to ping immediately, if it fails then injection fails
            _interface.Ping();

            #region Allow client event handlers (bi-directional IPC)
            
            // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"] = channelName;
            properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName

            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider binaryProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            binaryProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            System.Runtime.Remoting.Channels.Ipc.IpcServerChannel _clientServerChannel = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel(properties, binaryProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_clientServerChannel, false);
            
            #endregion
        }
Beispiel #5
0
        public EntryPoint(
            EasyHook.RemoteHooking.IContext context,
            String channelName,
            CaptureConfig config)
        {
            // Get reference to IPC to host application
            // Note: any methods called or events triggered against _interface will execute in the host process.
            _interface = EasyHook.RemoteHooking.IpcConnectClient <CaptureInterface>(channelName);

            // We try to ping immediately, if it fails then injection fails
            _interface.Ping();

            #region Allow client event handlers (bi-directional IPC)

            // Attempt to create a IpcServerChannel so that any event handlers on the client will function correctly
            System.Collections.IDictionary properties = new System.Collections.Hashtable();
            properties["name"]     = channelName;
            properties["portName"] = channelName + Guid.NewGuid().ToString("N"); // random portName so no conflict with existing channels of channelName

            System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider binaryProv = new System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider();
            binaryProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            System.Runtime.Remoting.Channels.Ipc.IpcServerChannel _clientServerChannel = new System.Runtime.Remoting.Channels.Ipc.IpcServerChannel(properties, binaryProv);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(_clientServerChannel, false);

            #endregion
        }
Beispiel #6
0
 private void FormMain_Load(object sender, EventArgs e)
 {
     channel = RemoteHooking.IpcCreateServer(
         ref channelName,
         WellKnownObjectMode.Singleton,
         IpcInterface,
         WellKnownSidType.WorldSid);
 }
Beispiel #7
0
 public PtAccServer()
 {
     // Create and register an IPC channel
     serverChannel = new IpcServerChannel("remote");
     ChannelServices.RegisterChannel(serverChannel, true);
     // Expose an object
     RemotingConfiguration.RegisterWellKnownServiceType(typeof(PtAccRemoteType), "PtAcc", WellKnownObjectMode.Singleton);
 }
        public static void Setup()
        {
            // Reset the channel name.
            ChannelName = null;

            // Start an Ipc server for the DLL to connect to.
            InjectionServer = RemoteHooking.IpcCreateServer<ChatInterface>(ref ChannelName, WellKnownObjectMode.Singleton);
        }
      public static void RegisterIpcChannel(EventHandler<NewInstanceDetectedEventArgs> handler)
      {
         IChannel ipcChannel = new IpcServerChannel(String.Format(CultureInfo.InvariantCulture, "hfm-{0}-{1}", Environment.UserName, AssemblyGuid));
         ChannelServices.RegisterChannel(ipcChannel, false);

         var obj = new IpcObject(handler);
         RemotingServices.Marshal(obj, ObjectName);
      }
Beispiel #10
0
 protected EyesarServer(EyesarSharedObject sharedObject)
 {
     if (ChannelServices.RegisteredChannels.Any(channel => channel.ChannelName == "Eyesar"))
         throw new InvalidOperationException();
     _channel = new IpcServerChannel("Eyesar", "eyesar");
     ChannelServices.RegisterChannel(_channel, false);
     RemotingServices.Marshal(SharedObject = sharedObject, "shared", typeof (EyesarSharedObject));
 }
Beispiel #11
0
        public static Server Start(ApplicationCore applicationCore)
        {
            var serverChannel = new IpcServerChannel("SassTray");
            ChannelServices.RegisterChannel(serverChannel, true);
            var server = new Server(applicationCore);
            RemotingServices.Marshal(server, "Server", typeof(Server));

            return server;
        }
		static void StartServer(AssemblyService service, string name, string uri) {
			var props = new Hashtable();
			props["portName"] = name;
			var provider = new BinaryServerFormatterSinkProvider();
			provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
			var channel = new IpcServerChannel(props, provider);
			ChannelServices.RegisterChannel(channel, false);
			RemotingServices.Marshal(service, uri);
		}
Beispiel #13
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // Initialise the IPC server
            ScreenshotServer = RemoteHooking.IpcCreateServer<ScreenshotInterface.ScreenshotInterface>(
                ref ChannelName,
                WellKnownObjectMode.Singleton);

            ScreenshotManager.OnScreenshotDebugMessage += new ScreenshotDebugMessage(ScreenshotManager_OnScreenshotDebugMessage);
        }
        /// <summary>
        /// Prepares capturing in the target process. Note that the process must not already be hooked, and must have a <see cref="Process.MainWindowHandle"/>.
        /// </summary>
        /// <param name="process">The process to inject into</param>
        /// <exception cref="ProcessHasNoWindowHandleException">Thrown if the <paramref name="process"/> does not have a window handle. This could mean that the process does not have a UI, or that the process has not yet finished starting.</exception>
        /// <exception cref="ProcessAlreadyHookedException">Thrown if the <paramref name="process"/> is already hooked</exception>
        /// <exception cref="InjectionFailedException">Thrown if the injection failed - see the InnerException for more details.</exception>
        /// <remarks>The target process will have its main window brought to the foreground after successful injection.</remarks>
        public CaptureProcess(Process process, CaptureConfig config, CaptureInterface captureInterface)
        {
            // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc)
            //if (process.MainWindowHandle == IntPtr.Zero)
            //{
            //    throw new ProcessHasNoWindowHandleException();
            //}

            // Skip if the process is already hooked (and we want to hook multiple applications)
            if (HookManager.IsHooked(process.Id))
            {
                throw new ProcessAlreadyHookedException();
            }

            captureInterface.ProcessId = process.Id;
            this._serverInterface = captureInterface;
            //_serverInterface = new CaptureInterface() { ProcessId = process.Id };

            // Initialise the IPC server (with our instance of _serverInterface)
            this._screenshotServer = RemoteHooking.IpcCreateServer<CaptureInterface>(
                ref this._channelName,
                WellKnownObjectMode.Singleton,
                this._serverInterface);

            try
            {
                var location = typeof(CaptureInterface).Assembly.Location;
                if (String.IsNullOrEmpty(location))
                {
                    var dllName = typeof(CaptureInterface).Assembly.GetName().Name + ".dll";
                    location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, dllName);
                }

                // Inject DLL into target process
                RemoteHooking.Inject(
                    process.Id,
                    InjectionOptions.Default,
                    location,
                    //"Capture.dll", // 32-bit version (the same because AnyCPU) could use different assembly that links to 32-bit C++ helper dll
                    location,
                    //"Capture.dll", // 64-bit version (the same because AnyCPU) could use different assembly that links to 64-bit C++ helper dll
                    // the optional parameter list...
                    this._channelName,
                    // The name of the IPC channel for the injected assembly to connect to
                    config
                    );
            }
            catch (Exception e)
            {
                throw new InjectionFailedException(e);
            }

            HookManager.AddHookedProcess(process.Id);

            this.Process = process;
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            if (args == null)
                throw new ArgumentNullException("args");

            if (args.Length != 1)
                throw new ArgumentException("Arguments number doesn't match!", "args");

            var name = args[0];

            if (string.IsNullOrEmpty(name))
                throw new Exception("Name cannot be null or empty.");

            name = name.Trim('"');

            var channelPort = string.Format(ProcessAppConst.PortNameTemplate, name, Process.GetCurrentProcess().Id);

            var currentDomain = AppDomain.CurrentDomain;
            var root = Path.Combine(Path.Combine(currentDomain.BaseDirectory, ProcessAppConst.WorkingDir), name);

            //Hack to change the default AppDomain's root
            if (NDockEnv.IsMono) //for Mono
            {
                var pro = typeof(AppDomain).GetProperty("SetupInformationNoCopy", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetProperty);
                var setupInfo = (AppDomainSetup)pro.GetValue(currentDomain, null);
                setupInfo.ApplicationBase = root;
            }
            else // for .NET
            {
                currentDomain.SetData("APPBASE", root);
            }

            currentDomain.SetData(typeof(IsolationMode).Name, IsolationMode.Process);

            try
            {
                var serverChannel = new IpcServerChannel("IpcAgent", channelPort, new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full });
                var clientChannel = new IpcClientChannel();
                ChannelServices.RegisterChannel(serverChannel, false);
                ChannelServices.RegisterChannel(clientChannel, false);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(ManagedAppWorker), ProcessAppConst.WorkerRemoteName, WellKnownObjectMode.Singleton);

                Console.WriteLine("Ok");

                var line = Console.ReadLine();

                while (!"quit".Equals(line, StringComparison.OrdinalIgnoreCase))
                {
                    line = Console.ReadLine();
                }
            }
            catch
            {
                Console.Write("Failed");
            }
        }
Beispiel #16
0
        /// <summary>
        ///     Prepares capturing in the target process. Note that the process must not already be hooked, and must have a
        ///     <see cref="Process.MainWindowHandle" />.
        /// </summary>
        /// <param name="process">The process to inject into</param>
        /// <exception cref="ProcessHasNoWindowHandleException">
        ///     Thrown if the <paramref name="process" /> does not have a window
        ///     handle. This could mean that the process does not have a UI, or that the process has not yet finished starting.
        /// </exception>
        /// <exception cref="ProcessAlreadyHookedException">Thrown if the <paramref name="process" /> is already hooked</exception>
        /// <exception cref="InjectionFailedException">Thrown if the injection failed - see the InnerException for more details.</exception>
        /// <remarks>The target process will have its main window brought to the foreground after successful injection.</remarks>
        public CaptureProcess(Process process, CaptureConfig config, CaptureInterface captureInterface)
        {
            // If the process doesn't have a mainwindowhandle yet, skip it (we need to be able to get the hwnd to set foreground etc)
            if (process.MainWindowHandle == IntPtr.Zero)
            {
                throw new ProcessHasNoWindowHandleException();
            }

            // Skip if the process is already hooked (and we want to hook multiple applications)
            if (HookManager.IsHooked(process.Id))
            {
                throw new ProcessAlreadyHookedException();
            }

            captureInterface.ProcessId = process.Id;
            CaptureInterface = captureInterface;
            //_serverInterface = new CaptureInterface() { ProcessId = process.Id };

            // Initialise the IPC server (with our instance of _serverInterface)
            _screenshotServer = RemoteHooking.IpcCreateServer(
                ref _channelName,
                WellKnownObjectMode.Singleton,
                CaptureInterface);

            try
            {
                // Inject DLL into target process
                RemoteHooking.Inject(
                    process.Id,
                    InjectionOptions.Default,
                    typeof (CaptureInterface).Assembly.Location,
                    //"Capture.dll", // 32-bit version (the same because AnyCPU) could use different assembly that links to 32-bit C++ helper dll
                    typeof (CaptureInterface).Assembly.Location,
                    //"Capture.dll", // 64-bit version (the same because AnyCPU) could use different assembly that links to 64-bit C++ helper dll
                    // the optional parameter list...
                    _channelName, // The name of the IPC channel for the injected assembly to connect to
                    config
                    );
            }
            catch (Exception e)
            {
                throw new InjectionFailedException(e);
            }

            HookManager.AddHookedProcess(process.Id);

            Process = process;

            // Ensure the target process is in the foreground,
            // this prevents an issue where the target app appears to be in
            // the foreground but does not receive any user inputs.
            // Note: the first Alt+Tab out of the target application after injection
            //       may still be an issue - switching between windowed and
            //       fullscreen fixes the issue however (see ScreenshotInjection.cs for another option)
            BringProcessWindowToFront();
        }
        /// <summary>
        /// Cleanup unneeded resources upon disposal.
        /// </summary>
        protected override void OnCleanup()
        {
            if (channel != null)
            {
                ChannelServices.UnregisterChannel(channel);
                channel = null;
            }

            base.OnCleanup();
        }
        public ScreenCapturer(ScreenshotRequestResponseNotification notify)
        {
            // Initialise the IPC server
            ScreenshotServer = RemoteHooking.IpcCreateServer<ScreenshotInterface.ScreenshotInterface>(
                ref ChannelName,
                WellKnownObjectMode.Singleton);

            Trace.TraceInformation("IPC server started, channel ref: {0}", ChannelName);
            this.notify = notify;
        }
Beispiel #19
0
        public static void Cleanup()
        {
            _singleInstanceMutex.Dispose();

            if (_channel != null)
            {
                ChannelServices.UnregisterChannel(_channel);
                _channel = null;
            }
        }
        public void ListenForLaunches()
        {
            if (!IsFirstInstance)
            {
                throw new InvalidOperationException();
            }

            IpcServerChannel channel = new IpcServerChannel(ApplicationId);
            ChannelServices.RegisterChannel(channel, true);

            RemotingServices.Marshal(this, ApplicationId, typeof (IFirstInstanceServer));
        }
Beispiel #21
0
        static ProcessBootstrap()
        {
            // Create the channel.
            var clientChannel = new IpcClientChannel();
            // Register the channel.
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(clientChannel, false);

            var serverChannel = new IpcServerChannel("Bootstrap", BootstrapIpcPort);
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(serverChannel, false);

            RemotingConfiguration.RegisterWellKnownServiceType(typeof(ProcessBootstrapProxy), "Bootstrap.rem", WellKnownObjectMode.Singleton);
        }
Beispiel #22
0
        /// <summary>
        /// Mains the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        static void Main(string[] args)
        {
            if (args == null)
                throw new ArgumentNullException("args");

            if(args.Length != 3)
                throw new ArgumentException("Arguments number doesn't match!", "args");

            var name = args[0];

            if(string.IsNullOrEmpty(name))
                throw new Exception("Name cannot be null or empty.");

            name = name.Trim('"');

            var channelPort = args[1];

            if (string.IsNullOrEmpty(channelPort))
                throw new Exception("Channel port cannot be null or empty.");

            channelPort = channelPort.Trim('"');
            channelPort = string.Format(channelPort, Process.GetCurrentProcess().Id);

            var root = args[2];

            if (string.IsNullOrEmpty(root))
                throw new Exception("Root cannot be null or empty.");

            AppDomain.CurrentDomain.SetData("APPBASE", root);
            AppDomain.CurrentDomain.SetData(typeof(IsolationMode).Name, IsolationMode.Process);

            try
            {
                var serverChannel = new IpcServerChannel("IpcAgent", channelPort);
                var clientChannel = new IpcClientChannel();
                ChannelServices.RegisterChannel(serverChannel, false);
                ChannelServices.RegisterChannel(clientChannel, false);
                RemotingConfiguration.RegisterWellKnownServiceType(typeof(WorkItemAgent), "WorkItemAgent.rem", WellKnownObjectMode.Singleton);
                Console.WriteLine("Ok");

                var line = Console.ReadLine();

                while (!"quit".Equals(line, StringComparison.OrdinalIgnoreCase))
                {
                    line = Console.ReadLine();
                }
            }
            catch
            {
                Console.WriteLine("Failed");
            }
        }
Beispiel #23
0
        /// <summary>
        /// Register the Service Property as IPC Server
        /// </summary>
        private void RegisterServer()
        {
            Repeater = new DataEventRepeator();
            IpcServerChannel channel = new IpcServerChannel("NetOffice.SampleChannel");
            ChannelServices.RegisterChannel(channel, true);
            RemotingConfiguration.RegisterWellKnownServiceType(
                                        typeof(WebTranslationService),
                                        "NetOffice.WebTranslationService.DataService",
                                        WellKnownObjectMode.Singleton);

            Service = new WebTranslationService();
            Repeater.Translation += new TranslationEventHandler(ServiceOnTranslation);
            Service.AddEventRepeater(Repeater);
        }
        /// <summary>
        /// Registers the remote type.
        /// </summary>
        /// <param name="uri">The URI.</param>
        private static void RegisterRemoteType(string uri)
        {
            // register remote channel (net-pipes)
            var serverChannel = new IpcServerChannel(Environment.MachineName + uri);
            ChannelServices.RegisterChannel(serverChannel, true);

            // register shared type
            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(InstanceProxy), uri, WellKnownObjectMode.Singleton);

            // close channel, on process exit
            Process process = Process.GetCurrentProcess();
            process.Exited += delegate { ChannelServices.UnregisterChannel(serverChannel); };
        }
Beispiel #25
0
        static int Main(string[] args)
        {
            if ((args.Length == 2) && (args[0].Equals("-iphonepackager")))
            {
				try
				{
					// We were run as a 'child' process, quit when our 'parent' process exits
					// There is no parent-child relationship WRT windows, it's self-imposed.
					int ParentPID = int.Parse(args[1]);

					DeploymentProxy.Deployer = new DeploymentImplementation();
					IpcServerChannel Channel = new IpcServerChannel("iPhonePackager");
					ChannelServices.RegisterChannel(Channel, false);
					RemotingConfiguration.RegisterWellKnownServiceType(typeof(DeploymentProxy), "DeploymentServer_PID" + ParentPID.ToString(), WellKnownObjectMode.Singleton);

					Process ParentProcess = Process.GetProcessById(ParentPID);
					while (!ParentProcess.HasExited)
					{
						CoreFoundationRunLoop.RunLoopRunInMode(CoreFoundationRunLoop.kCFRunLoopDefaultMode(), 1.0, 0);
					}
				}
				catch (System.Exception Ex)
				{
					Console.WriteLine(Ex.Message);
				}
            }
            else
            {
				// Parse the command
				if (ParseCommand(args))
				{
					Deployer = new DeploymentImplementation();
					bool bCommandComplete = false;
					System.Threading.Thread enumerateLoop = new System.Threading.Thread(delegate()
					{
						RunCommand();
						bCommandComplete = true;
					});
					enumerateLoop.Start();
					while (!bCommandComplete)
					{
						CoreFoundationRunLoop.RunLoopRunInMode(CoreFoundationRunLoop.kCFRunLoopDefaultMode(), 1.0, 0);
					}
				}
                Console.WriteLine("Exiting.");
            }

			Environment.ExitCode = Program.ExitCode;
			return Program.ExitCode;
        }
 public MainWindow()
 {
     InitializeComponent();
     try
     {
         server = RemoteHooking.IpcCreateServer<InjectInterface>(
             ref channelName,
             WellKnownObjectMode.Singleton);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Beispiel #27
0
        private static void _CreateRemoteService(string channelName)
        {
            _channel = new IpcServerChannel(
                new Dictionary<string, string>
                {
                    { "name", channelName },
                    { "portName", channelName },
                    { "exclusiveAddressUse", "false" },
                },
                new BinaryServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full });

            ChannelServices.RegisterChannel(_channel, true);
            RemotingServices.Marshal(new _IpcRemoteService(), _RemoteServiceName);
        }
 protected override void StartImpl()
 {
     this._channel = new IpcServerChannel(new Dictionary<Object, Object>()
     {
         {"name", ""},
         {"secure", true},
         {"portName", this._portName},
     }, new BinaryServerFormatterSinkProvider()
     {
         TypeFilterLevel = TypeFilterLevel.Full,
     });
     ChannelServices.RegisterChannel(this._channel, false);
     RemotingServices.Marshal((MarshalByRefObject) this.Host, "", typeof(IServerCore));
 }
        public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor)
        {
            this._channelPriority = 20;
            this._channelName     = "ipc";
            Hashtable hashtable  = new Hashtable();
            Hashtable hashtable2 = new Hashtable();
            bool      flag       = false;

            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    string key = (string)entry.Key;
                    if (key == null)
                    {
                        goto Label_00CC;
                    }
                    if (!(key == "name"))
                    {
                        if (key == "priority")
                        {
                            goto Label_0098;
                        }
                        if (key == "portName")
                        {
                            goto Label_00B6;
                        }
                        goto Label_00CC;
                    }
                    this._channelName = (string)entry.Value;
                    continue;
Label_0098:
                    this._channelPriority = Convert.ToInt32((string)entry.Value, CultureInfo.InvariantCulture);
                    continue;
Label_00B6:
                    hashtable2["portName"] = entry.Value;
                    flag = true;
                    continue;
Label_00CC:
                    hashtable[entry.Key]  = entry.Value;
                    hashtable2[entry.Key] = entry.Value;
                }
            }
            this._clientChannel = new IpcClientChannel(hashtable, clientSinkProvider);
            if (flag)
            {
                this._serverChannel = new IpcServerChannel(hashtable2, serverSinkProvider, securityDescriptor);
            }
        }
        public EntryPoint(RemoteHooking.IContext InContext, string InChannelName)
        {
            _interface = RemoteHooking.IpcConnectClient<OverlayInterface>(InChannelName);
            _interface.Ping();

            IDictionary properties = new Hashtable();
            properties["name"] = InChannelName;
            properties["portName"] = InChannelName + Guid.NewGuid().ToString("N");

            BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
            provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            _serverChannel = new IpcServerChannel(properties, provider);
            ChannelServices.RegisterChannel(_serverChannel, false);
        }
 public IpcChannel(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider, CommonSecurityDescriptor securityDescriptor)
 {
     this._channelPriority = 20;
     this._channelName = "ipc";
     Hashtable hashtable = new Hashtable();
     Hashtable hashtable2 = new Hashtable();
     bool flag = false;
     if (properties != null)
     {
         foreach (DictionaryEntry entry in properties)
         {
             string key = (string) entry.Key;
             if (key == null)
             {
                 goto Label_00CC;
             }
             if (!(key == "name"))
             {
                 if (key == "priority")
                 {
                     goto Label_0098;
                 }
                 if (key == "portName")
                 {
                     goto Label_00B6;
                 }
                 goto Label_00CC;
             }
             this._channelName = (string) entry.Value;
             continue;
         Label_0098:
             this._channelPriority = Convert.ToInt32((string) entry.Value, CultureInfo.InvariantCulture);
             continue;
         Label_00B6:
             hashtable2["portName"] = entry.Value;
             flag = true;
             continue;
         Label_00CC:
             hashtable[entry.Key] = entry.Value;
             hashtable2[entry.Key] = entry.Value;
         }
     }
     this._clientChannel = new IpcClientChannel(hashtable, clientSinkProvider);
     if (flag)
     {
         this._serverChannel = new IpcServerChannel(hashtable2, serverSinkProvider, securityDescriptor);
     }
 }
Beispiel #32
0
        public static void InitializeServer(string objectUri, string portName, System.Type type)
        {
            if (_serverChannel != null) {
                Logger.Info("IpcHelper.InitializeServer chiude il canale aperto ...");
                ChannelServices.UnregisterChannel(_serverChannel);
            }

            Hashtable props = new Hashtable();
            props.Add("authorizedGroup", "Everyone");
            props.Add("portName", portName);
            props.Add("exclusiveAddressUse", "false");
            _serverChannel = new IpcServerChannel(props, null, null);
            ChannelServices.RegisterChannel(_serverChannel, false);
            RemotingConfiguration.RegisterWellKnownServiceType(type, objectUri, WellKnownObjectMode.SingleCall);
            Logger.Info("CacheService inizializzato");
        }
        public IpcChannel(IDictionary properties,
                          IClientChannelSinkProvider clientSinkProvider,
                          IServerChannelSinkProvider serverSinkProvider,
                          CommonSecurityDescriptor securityDescriptor)
        {
            Hashtable clientData = new Hashtable();
            Hashtable serverData = new Hashtable();

            bool portFound = false;

            // divide properties up for respective channels
            if (properties != null)
            {
                foreach (DictionaryEntry entry in properties)
                {
                    switch ((String)entry.Key)
                    {
                    // general channel properties
                    case "name": _channelName = (String)entry.Value; break;

                    case "priority": _channelPriority = Convert.ToInt32((String)entry.Value, CultureInfo.InvariantCulture); break;

                    case "portName":
                    {
                        serverData["portName"] = entry.Value;
                        portFound = true;
                        break;
                    }

                    default:
                        clientData[entry.Key] = entry.Value;
                        serverData[entry.Key] = entry.Value;
                        break;
                    }
                }
            }

            _clientChannel = new IpcClientChannel(clientData, clientSinkProvider);

            if (portFound)
            {
                _serverChannel = new IpcServerChannel(serverData, serverSinkProvider, securityDescriptor);
            }
        } // IpcChannel
        } // IpcChannel

        public IpcChannel(String portName) : this()
        {
            _serverChannel = new IpcServerChannel(portName);
        } // IpcChannel
 public IpcChannel(string portName) : this()
 {
     this._serverChannel = new IpcServerChannel(portName);
 }