Ejemplo n.º 1
0
        private static MethodInfo[] GetEmulatorMethods(MethodInfo defaultMethod, OpcodeAttribute opcodeAttribute)
        {
            var result = new MethodInfo[4];

            // Make sure the array is populated with sizes supported by the default method.
            if ((opcodeAttribute.OperandSize & 16) == 16 && (opcodeAttribute.AddressSize & 16) == 16)
            {
                result[0] = defaultMethod;
            }
            if ((opcodeAttribute.OperandSize & 32) == 32 && (opcodeAttribute.AddressSize & 16) == 16)
            {
                result[1] = defaultMethod;
            }
            if ((opcodeAttribute.OperandSize & 16) == 16 && (opcodeAttribute.AddressSize & 32) == 32)
            {
                result[2] = defaultMethod;
            }
            if ((opcodeAttribute.OperandSize & 32) == 32 && (opcodeAttribute.AddressSize & 32) == 32)
            {
                result[3] = defaultMethod;
            }

            // Look for altnerate methods defined in the same class.
            var otherMethods = defaultMethod.DeclaringType.GetMethods(BindingFlags.Static | BindingFlags.Public);

            foreach (var method in otherMethods)
            {
                var attrObjects = method.GetCustomAttributes(typeof(AlternateAttribute), false);
                if (attrObjects != null && attrObjects.Length == 1)
                {
                    var alt = (AlternateAttribute)attrObjects[0];
                    if (alt.MethodName == defaultMethod.Name)
                    {
                        if ((alt.OperandSize & 16) == 16 && (alt.AddressSize & 16) == 16)
                        {
                            result[0] = method;
                        }
                        if ((alt.OperandSize & 32) == 32 && (alt.AddressSize & 16) == 16)
                        {
                            result[1] = method;
                        }
                        if ((alt.OperandSize & 16) == 16 && (alt.AddressSize & 32) == 32)
                        {
                            result[2] = method;
                        }
                        if ((alt.OperandSize & 32) == 32 && (alt.AddressSize & 32) == 32)
                        {
                            result[3] = method;
                        }
                    }
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        public static void DefineOpcodeHandler()
        {
            Type[] array = PacketManager.smethod_1(PacketManager.smethod_0());
            while (true)
            {
IL_1DB:
                uint arg_1B6_0 = 1781133873u;
                while (true)
                {
                    uint num;
                    int  num2;
                    uint arg_142_0;
                    int  num3;
                    switch ((num = (arg_1B6_0 ^ 315123486u)) % 6u)
                    {
                    case 0u:
                        goto IL_1DB;

                    case 1u:
                        num2      = 0;
                        arg_1B6_0 = (num * 2433928120u ^ 2770631119u);
                        continue;

                    case 2u:
                        goto IL_186;

                    case 3u:
IL_11E:
                        if (num2 < array.Length)
                        {
                            goto IL_186;
                        }
                        arg_142_0 = 792245191u;
                        break;

                    case 4u:
                        num3 = 0;
                        goto IL_111;

                    case 5u:
                        goto IL_16A;

                    default:
                        goto IL_16A;
                    }
                    while (true)
                    {
IL_13D:
                        switch ((num = (arg_142_0 ^ 315123486u)) % 5u)
                        {
                        case 1u:
                            num2++;
                            arg_142_0 = (num * 2650436441u ^ 3815917589u);
                            continue;

                        case 2u:
                            goto IL_11E;

                        case 3u:
                            goto IL_111;

                        case 4u:
                            goto IL_163;
                        }
                        return;
                    }
IL_186:
                    MethodInfo[] array2 = PacketManager.smethod_2(array[num2]);
                    arg_1B6_0 = 2007019048u;
                    continue;
IL_111:
                    if (num3 >= array2.Length)
                    {
                        arg_142_0 = 235062078u;
                        goto IL_13D;
                    }
                    goto IL_16A;
IL_163:
                    arg_142_0 = 1841975739u;
                    goto IL_13D;
IL_16A:
                    MethodInfo methodInfo = array2[num3];
                    IEnumerator <OpcodeAttribute> enumerator = methodInfo.GetCustomAttributes <OpcodeAttribute>().GetEnumerator();
                    try
                    {
                        while (true)
                        {
IL_BA:
                            uint arg_8A_0 = PacketManager.smethod_5(enumerator) ? 2138237464u : 70193693u;
                            while (true)
                            {
                                switch ((num = (arg_8A_0 ^ 315123486u)) % 5u)
                                {
                                case 0u:
                                    arg_8A_0 = 2138237464u;
                                    continue;

                                case 1u:
                                    goto IL_BA;

                                case 2u:
                                {
                                    OpcodeAttribute current = enumerator.Current;
                                    arg_8A_0 = ((current == null) ? 314398218u : 1728240380u);
                                    continue;
                                }

                                case 4u:
                                {
                                    OpcodeAttribute current;
                                    PacketManager.OpcodeHandlers[current.Opcode] = (PacketManager.HandlePacket)PacketManager.smethod_4(PacketManager.smethod_3(typeof(PacketManager.HandlePacket).TypeHandle), methodInfo);
                                    arg_8A_0 = (num * 3181307333u ^ 518397664u);
                                    continue;
                                }
                                }
                                goto Block_7;
                            }
                        }
                        Block_7 :;
                    }
                    finally
                    {
                        if (enumerator != null)
                        {
                            while (true)
                            {
                                IL_103 :
                                uint arg_EA_0 = 921856005u;
                                while (true)
                                {
                                    switch ((num = (arg_EA_0 ^ 315123486u)) % 3u)
                                    {
                                    case 0u:
                                        goto IL_103;

                                    case 1u:
                                        PacketManager.smethod_6(enumerator);
                                        arg_EA_0 = (num * 374831327u ^ 897885318u);
                                        continue;
                                    }
                                    goto Block_11;
                                }
                            }
                            Block_11 :;
                        }
                    }
                    num3++;
                    goto IL_163;
                }
            }
        }