Ejemplo n.º 1
0
        public static bool TryToConnectToOnyxLoader(Process _targetProcess, int _maxAttemptsCount = 100)
        {
            if (_targetProcess == null)
            {
                throw new ArgumentNullException("_targetProcess");
            }
            var binding = OnyxServiceHost <IOnyxLoaderContract> .GeneratePipeBinding();

            var serviceName = OnyxServiceHost <IOnyxLoaderContract> .GeneratePipeUri(_targetProcess.Id);

            var client = ChannelFactory <IOnyxLoaderContract> .CreateChannel(binding, new EndpointAddress(serviceName));

            var attemptsCount         = 0;
            var connectedSuccessfully = false;

            while (attemptsCount < _maxAttemptsCount)
            {
                try
                {
                    client.Ping();
                    connectedSuccessfully = true;
                    break;
                }
                catch (Exception)
                {
                    Thread.Sleep(100);
                }
                attemptsCount++;
            }
            return(connectedSuccessfully);
        }
Ejemplo n.º 2
0
        private static void InitializeWcfHost()
        {
            var instance = new OnyxLoader();

            EventLogLogger.Write(EventLogEntryType.Information, "Initializing wcf host of type {0} (instance {1})", typeof(IOnyxLoaderContract), instance);
            m_host = new OnyxServiceHost <IOnyxLoaderContract>(instance);
            m_host.Start();
        }
Ejemplo n.º 3
0
 private static void EnterEndlessCycle()
 {
     EventLogLogger.Write(EventLogEntryType.Information, "Onyx successfully initialized, awaiting for commands @ {0}...", OnyxServiceHost <IOnyxLoaderContract> .GeneratePipeUri(m_process.Id));
     //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     // Если не использовать подобный цикл, то при выгрузке последнего домена целевая программа вылетает
     //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     while (true)
     {
         Thread.Sleep(100);
     }
 }