Exemple #1
0
 /// <summary>
 /// Отмена публикации объекта
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="or"></param>
 public void UnmarshaledObject(object obj, System.Runtime.Remoting.ObjRef or)
 {
     if (_debugInfo)
     {
         _eventLink.Post(DeviceManager.EventSource,
                         string.Format(_objUnMarshalled, obj.GetType(), or.URI));
     }
 }
Exemple #2
0
        public static bool _CreateObjRef_Microsoft_Win32_RegistryKey_System_Type( )
        {
            //class object
            Microsoft.Win32.RegistryKey _Microsoft_Win32_RegistryKey = new Microsoft.Win32.RegistryKey();

            //Parameters
            System.Type requestedType = null;

            //ReturnType/Value
            System.Runtime.Remoting.ObjRef returnVal_Real        = null;
            System.Runtime.Remoting.ObjRef returnVal_Intercepted = null;

            //Exception
            System.Exception exception_Real        = null;
            System.Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnVal_Real = _Microsoft_Win32_RegistryKey.CreateObjRef(requestedType);
            }

            catch (System.Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnVal_Intercepted = _Microsoft_Win32_RegistryKey.CreateObjRef(requestedType);
            }

            catch (System.Exception e)
            {
                exception_Intercepted = e;
            }


            return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }
        public static bool _CreateObjRef_System_ComponentModel_Component_System_Type( )
        {
            //class object
            System.ComponentModel.Component _System_ComponentModel_Component = new System.ComponentModel.Component();

            //Parameters
            System.Type requestedType = null;

            //ReturnType/Value
            System.Runtime.Remoting.ObjRef returnVal_Real        = null;
            System.Runtime.Remoting.ObjRef returnVal_Intercepted = null;

            //Exception
            System.Exception exception_Real        = null;
            System.Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnVal_Real = _System_ComponentModel_Component.CreateObjRef(requestedType);
            }

            catch (System.Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnVal_Intercepted = _System_ComponentModel_Component.CreateObjRef(requestedType);
            }

            catch (System.Exception e)
            {
                exception_Intercepted = e;
            }


            return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }
        public static bool _CreateObjRef_System_IO_FileInfo_System_Type( )
        {
            //Parameters
            System.Type requestedType = null;

            //ReturnType/Value
            System.Runtime.Remoting.ObjRef returnVal_Real        = null;
            System.Runtime.Remoting.ObjRef returnVal_Intercepted = null;

            //Exception
            Exception exception_Real        = null;
            Exception exception_Intercepted = null;

            InterceptionMaintenance.disableInterception( );

            try
            {
                returnValue_Real = System.IO.FileInfo.CreateObjRef(requestedType);
            }

            catch (Exception e)
            {
                exception_Real = e;
            }


            InterceptionMaintenance.enableInterception( );

            try
            {
                returnValue_Intercepted = System.IO.FileInfo.CreateObjRef(requestedType);
            }

            catch (Exception e)
            {
                exception_Intercepted = e;
            }


            Return((exception_Real.Messsage == exception_Intercepted.Message) && (returnValue_Real == returnValue_Intercepted));
        }
Exemple #5
0
        private void InternalMain()
        {
            System.Threading.Thread.CurrentThread.Name = "Root";

            System.AppDomain.CurrentDomain.SetPrincipalPolicy(System.Security.Principal.PrincipalPolicy.UnauthenticatedPrincipal);
            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            {
                List <string> addrs = new List <string>();
                foreach (System.Net.NetworkInformation.NetworkInterface itf in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
                {
                    foreach (System.Net.NetworkInformation.UnicastIPAddressInformation info in itf.GetIPProperties().UnicastAddresses)
                    {
                        if (!System.Net.IPAddress.IsLoopback(info.Address) &&
                            (info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork ||
                             (info.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetworkV6 && !info.Address.IsIPv6LinkLocal)
                            )
                            )
                        {
                            addrs.Add(info.Address.ToString());
                        }
                    }
                }
                Logger.Info("Local addresses: " + string.Join(",", addrs.ToArray()));
            }

            int port = 8081;

            Root root = new Root();

            root.Initialize();

            SC.Remoting.ServerEncryptionSinkProvider     encrProvider = new SC.Remoting.ServerEncryptionSinkProvider();
            SC.Remoting.ServerAuthenticationSinkProvider authProvider = new SC.Remoting.ServerAuthenticationSinkProvider(SC.Security.SecurityManager.Instance);
            System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider soapFormatter = new System.Runtime.Remoting.Channels.SoapServerFormatterSinkProvider();
            soapFormatter.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

            encrProvider.Next = authProvider;
            authProvider.Next = soapFormatter;

            System.Runtime.Remoting.Channels.Http.HttpServerChannel channel = null;
            while (channel == null)
            {
                try
                {
                    channel = new System.Runtime.Remoting.Channels.Http.HttpServerChannel("Access", port, encrProvider);
                }
                catch (System.Net.Sockets.SocketException se)
                {
                    Logger.Error("Waiting 5 seconds for socket on port " + port, se);
                    System.Threading.Thread.Sleep(5000);
                }
            }
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, false);

            System.Runtime.Remoting.ObjRef Ref = System.Runtime.Remoting.RemotingServices.Marshal(root, "ServerChecker4Root");

            //root.AddServer("Blah");

            /*Server s = root.GetServer("Blah");
             * s.Arguments = "file.txt";
             * s.EndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("81.19.219.88"), 27015);
             * s.Executable = "notepad.exe";
             * s.Protocol = System.Net.TransportType.Udp;
             * s.StartupTimeout = 1000;
             * //s.Username = "******";
             * s.WorkingDirectory = "c:\\";
             * s.StopOnExit = true;
             * s.AcquireOnStart = true;
             * System.Console.WriteLine(s.ToString());
             *
             * SC.DefaultPlugins.ServerCheckPlugin plugin = s.GetPlugin("ServerCheckPlugin") as SC.DefaultPlugins.ServerCheckPlugin;
             * plugin.GameType = SC.DefaultPlugins.eGameType.HalfLife;
             * plugin.Timeout = 1000;*/

            if (semaphore != null)
            {
                semaphore.WaitOne();
            }
            else
            {
                System.Console.ReadKey();
            }

            System.Runtime.Remoting.RemotingServices.Disconnect(root);
            System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(channel);

            root.Cleanup();
        }
 public virtual RealProxy CreateProxy(System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext)
 {
 }
        public RealProxy CreateProxy(System.Runtime.Remoting.ObjRef objRef, Type serverType, object serverObject, System.Runtime.Remoting.Contexts.Context serverContext)
        {
            CodeContract.Requires(serverContext == null);

            return(default(RealProxy));
        }
 public void UnmarshaledObject(object obj, System.Runtime.Remoting.ObjRef or)
 {
     //Console.WriteLine("对象{0}在{1}被解组!", obj.ToString(), DateTime.Now.ToShortTimeString());
 }