예제 #1
0
        public override int run()
        {
            if (ESession.isSystemMenuOpen())
            {
                EKeyboard.sendChar((char)0x1B);
                Thread.Sleep(600);
            }

            InterfaceEntry ok     = ESession.getOkButton();
            InterfaceEntry cancel = ESession.getCancelButton();

            if (ok != null || cancel != null)
            {
                if (cancel != null)
                {
                    EMouse.move(new Point(ERandom.Next(cancel.X, cancel.X + cancel.Width), ERandom.Next(cancel.Y, cancel.Y + cancel.Height)));
                }
                else
                {
                    EMouse.move(new Point(ERandom.Next(ok.X, ok.X + ok.Width), ERandom.Next(ok.Y, ok.Y + ok.Height)));
                }

                EMouse.click(true);
                Thread.Sleep(500);
            }

            return(200);
        }
예제 #2
0
        /// <summary>
        /// Open a menu at the given interface entry
        /// </summary>
        /// <param name="entry">The interface entry to open the menu on</param>
        /// <returns>True if sucess, false otherwise</returns>
        public Boolean open(InterfaceEntry entry)
        {
            Point pt = new Point(random.Next(entry.X, entry.X + entry.Width), random.Next(entry.Y, entry.Y + entry.Height - 5));

            m.move(pt);
            pm.synchronize(m);
            Thread.Sleep(random.Next(300, 400));
            m.click(false);
            Thread.Sleep(random.Next(1500, 1600));
            return(true);
        }
예제 #3
0
        /// <summary>
        /// Open a menu on the given character entry from the userlist
        /// </summary>
        /// <param name="charName">The character name to open the menu on</param>
        /// <returns>True on success, false otherwise</returns>
        public override bool openMenu(string charName)
        {
            int            passes    = 0;
            bool           direction = false;
            bool           found     = false;
            InterfaceEntry entry     = userlistGetEntry(charName);

            while (passes < 2 && entry != null)
            {
                InterfaceEntry userlist = userlistScrollBar();
                if (userlist != null)
                {
                    if (entry.X != 0)
                    {
                        found = true;
                        break;
                    }

                    if (userlist.Y + userlist.Height + 30 >= userlistBottom())
                    {
                        passes++;
                        direction = false;
                    }

                    if (userlist.Y - 30 <= userlistTop())
                    {
                        passes++;
                        direction = true;
                    }

                    if (!direction)
                    {
                        userlistScrollUp();
                    }

                    else
                    {
                        userlistScrollDown();
                    }

                    entry = userlistGetEntry(charName);
                    Thread.Sleep(200);
                }
            }
            if (found)
            {
                mh.open(entry);
            }
            return(found);
        }
예제 #4
0
        /// <summary>
        /// Scroll the userlist all the way down
        /// </summary>
        /// <returns>True on success, false on failure</returns>
        public bool userlistScrollToBottom()
        {
            InterfaceEntry scrollbar = userlistScrollBar();

            if (scrollbar == null)
            {
                return(false);
            }

            int bottom = userlistBottom();

            m.move(new Point(ran.Next(scrollbar.X, scrollbar.X + 3), ran.Next(scrollbar.Y, scrollbar.Y + scrollbar.Height - 5)));
            Thread.Sleep(ran.Next(100, 200));
            m.drag(new Point(ran.Next(scrollbar.X, scrollbar.X + 8), ran.Next(bottom - 5, bottom + 5)));
            pm.synchronize(m);

            return(true);
        }
예제 #5
0
        protected Guid?CreateInstance(InterfaceEntry ie, IConnection scope = null)
        {
            if (ie.Access == EntanglementAccess.Manual && scope != null)
            {
                return(null);
            }
            if (ie.Access == EntanglementAccess.Scoped && (scope == null || !scope.Connected))
            {
                return(null);
            }
            if (GetExistingEid(ie, scope).HasValue)
            {
                return(null);
            }

            var eid = GetFreeEidSlot();

            switch (ie.Access)
            {
            case EntanglementAccess.Scoped:
                if (!ScopedObjectMap.TryGetValue(scope, out var scopedMap))
                {
                    scopedMap = new ConcurrentDictionary <Guid, Guid>();
                    ScopedObjectMap.TryAdd(scope, scopedMap);
                }

                if (!scopedMap.TryAdd(ie.InterfaceId, eid))
                {
                    return(null);
                }
                break;

            case EntanglementAccess.Global:
                GlobalObjectMap[ie.InterfaceId] = eid;
                break;

            case EntanglementAccess.Manual:
                ManualMap.Add(eid);
                break;
            }

            Objects[eid] = (EntangledHostedObjectBase)Activator.CreateInstance(ie.Type, eid, ie.InterfaceDescriptor, Host);
            return(eid);
        }
예제 #6
0
        protected Guid?GetExistingEid(InterfaceEntry ie, IConnection scope = null)
        {
            Guid id = Guid.Empty;

            //net461 incorrectly marks the above declaration as 'possibly uninitialized'

            if (ie.Access == EntanglementAccess.Scoped && scope != null &&
                ScopedObjectMap.TryGetValue(scope, out var mapScoped) &&
                (mapScoped?.TryGetValue(ie.InterfaceId, out id) ?? false))
            {
                return(id);
            }
            if (ie.Access == EntanglementAccess.Global &&
                GlobalObjectMap.TryGetValue(ie.InterfaceId, out id))
            {
                return(id);
            }
            return(null);
        }
예제 #7
0
        private void RegisterTypes(ITypeResolver resolver, InterfaceEntry entry)
        {
            if (resolver == null)
            {
                throw new ArgumentNullException(nameof(resolver));
            }
            if (entry == null)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            resolver.RegisterAssembly(typeof(EntanglementHostService).GetTypeInfo().Assembly);

            foreach (var ml in entry.InterfaceDescriptor.Methods)
            {
                foreach (var m in ml.Value)
                {
                    resolver.RegisterType(m.RealReturnType);
                    foreach (var p in m.Parameters)
                    {
                        resolver.RegisterType(p.Type);
                    }
                }
            }

            foreach (var pl in entry.InterfaceDescriptor.Properties)
            {
                resolver.RegisterType(pl.Value.Property.PropertyType);
            }

            foreach (var ev in entry.InterfaceDescriptor.Events)
            {
                foreach (var parameter in ev.Value.Parameters)
                {
                    resolver.RegisterType(parameter.Type);
                }
            }
        }
예제 #8
0
        public static void AddMethodsForProxyOrService(IEnumerable <Type> interfaces, Type baseInterfaceType)
        {
            foreach (Type interfaceType in interfaces)
            {
                if (!baseInterfaceType.IsAssignableFrom(interfaceType) || interfaceType == baseInterfaceType)
                {
                    continue;
                }

                int interfaceIdv1 = IdUtil.ComputeId(interfaceType);
                int interfaceIdv2 = IdUtil.ComputeIdWithCRC(interfaceType);

                // Add if it's not there, don't add if it's there already
                if (!idToMethodNameMap.TryGetValue(interfaceIdv1, out InterfaceEntry ifc))
                {
                    // Since idToMethodNameMap can be accessed by multiple threads, it is important to make sure
                    // the inner dictionary has everything added, before this is added to idToMethodNameMap. The
                    // inner dictionary will never be thread safe and it doesn't need to be, as long as it always
                    // is effectively "read-only". If the order is reverse, you risk having another thread trying
                    // to fetch a method from it prematurely.
                    ifc = new InterfaceEntry(interfaceType);
                    foreach (MethodInfo method in interfaceType.GetMethods())
                    {
                        int methodIdv1 = IdUtil.ComputeId(method);
                        int methodIdv2 = IdUtil.ComputeIdWithCRC(method);

                        ifc.Methods[methodIdv1] = new MethodEntry(method);
                        ifc.Methods[methodIdv2] = new MethodEntry(method);
                    }

                    // If multiple threads are trying to set this entry, the last one wins, and this is ok to have
                    // since this method map should always look the same once it's constructed.
                    idToMethodNameMap[interfaceIdv1] = ifc;
                    idToMethodNameMap[interfaceIdv2] = ifc;
                }
            }
        }
예제 #9
0
        private void Register(Type baseType, Type type, EntanglementAccess access)
        {
            var            guid = baseType.GetTypeInfo().GUID;
            InterfaceEntry e;

            if (!Interfaces.TryAdd(guid,
                                   e = new InterfaceEntry
            {
                Access = access,
                Type = type,
                InterfaceId = guid,
                InterfaceDescriptor = InterfaceDescriptor.Get(baseType)
            }))
            {
                Interfaces[guid].Access = access;
            }
            else
            {
                if (Host?.TypeResolver != null)
                {
                    RegisterTypes(Host.TypeResolver, e);
                }
            }
        }
예제 #10
0
        protected Guid?GetInstance(InterfaceEntry ie, IConnection scope = null)
        {
            var existingEid = GetExistingEid(ie, scope);

            return(existingEid ?? CreateInstance(ie, scope));
        }