コード例 #1
0
        void detectHandlers(List <TypeDefinition> handlerTypes, CsvmInfo csvmInfo)
        {
            opCodeHandlers = new List <OpCodeHandler>();
            var detected = new List <OpCodeHandler>();

            foreach (var handlersList in OpCodeHandlers.opcodeHandlers)
            {
                opCodeHandlers.Clear();

                foreach (var handlerType in handlerTypes)
                {
                    var info = new UnknownHandlerInfo(handlerType, csvmInfo);
                    detected.Clear();
                    foreach (var opCodeHandler in handlersList)
                    {
                        if (opCodeHandler.detect(info))
                        {
                            detected.Add(opCodeHandler);
                        }
                    }
                    if (detected.Count != 1)
                    {
                        goto next;
                    }
                    opCodeHandlers.Add(detected[0]);
                }
                if (new List <OpCodeHandler>(Utils.unique(opCodeHandlers)).Count == opCodeHandlers.Count)
                {
                    return;
                }
                next :;
            }
            throw new ApplicationException("Could not detect all VM opcode handlers");
        }
コード例 #2
0
        void detectHandlers(List <TypeDefinition> handlerTypes)
        {
            opCodeHandlers = new List <OpCodeHandler>();
            var detected = new List <OpCodeHandler>();

            foreach (var handlerType in handlerTypes)
            {
                var info = new UnknownHandlerInfo(handlerType);
                detected.Clear();
                foreach (var opCodeHandler in opCodeHandlerDetectors)
                {
                    if (opCodeHandler.detect(info))
                    {
                        detected.Add(opCodeHandler);
                    }
                }
                if (detected.Count != 1)
                {
                    throw new ApplicationException("Could not detect VM opcode handler");
                }
                opCodeHandlers.Add(detected[0]);
            }
            if (new List <OpCodeHandler>(Utils.unique(opCodeHandlers)).Count != opCodeHandlers.Count)
            {
                throw new ApplicationException("Could not detect all VM opcode handlers");
            }
        }
コード例 #3
0
        public bool detect(UnknownHandlerInfo info)
        {
            var sigInfo = OpCodeHandlerSigInfo;

            if (!compare(sigInfo.NumStaticMethods, info.NumStaticMethods))
            {
                return(false);
            }
            if (!compare(sigInfo.NumInstanceMethods, info.NumInstanceMethods))
            {
                return(false);
            }
            if (!compare(sigInfo.NumVirtualMethods, info.NumVirtualMethods))
            {
                return(false);
            }
            if (!compare(sigInfo.NumCtors, info.NumCtors))
            {
                return(false);
            }
            if (!compare(sigInfo.ExecuteMethodThrows, info.ExecuteMethodThrows))
            {
                return(false);
            }
            if (!info.hasSameFieldTypes(sigInfo.RequiredFieldTypes))
            {
                return(false);
            }
            if (sigInfo.ExecuteMethodLocals != null && !new LocalTypes(info.ExecuteMethod).all(sigInfo.ExecuteMethodLocals))
            {
                return(false);
            }

            return(detectInternal(info));
        }
コード例 #4
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
        public bool detect(UnknownHandlerInfo info)
        {
            var sigInfo = OpCodeHandlerSigInfo;

            if (!compare(sigInfo.NumStaticMethods, info.NumStaticMethods))
                return false;
            if (!compare(sigInfo.NumInstanceMethods, info.NumInstanceMethods))
                return false;
            if (!compare(sigInfo.NumVirtualMethods, info.NumVirtualMethods))
                return false;
            if (!compare(sigInfo.NumCtors, info.NumCtors))
                return false;
            if (!compare(sigInfo.ExecuteMethodThrows, info.ExecuteMethodThrows))
                return false;
            if (!info.hasSameFieldTypes(sigInfo.RequiredFieldTypes))
                return false;
            if (sigInfo.ExecuteMethodLocals != null && !new LocalTypes(info.ExecuteMethod).all(sigInfo.ExecuteMethodLocals))
                return false;

            return detectInternal(info);
        }
コード例 #5
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return isEmptyMethod(info.ReadMethod) && isEmptyMethod(info.ExecuteMethod);
 }
コード例 #6
0
 static bool throw_check(UnknownHandlerInfo info)
 {
     return(!DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Reflection.BindingFlags)"));
 }
コード例 #7
0
 static bool rethrow_check(UnknownHandlerInfo info)
 {
     return(info.ExecuteMethod.Body.Variables.Count == 0);
 }
コード例 #8
0
 static bool ret_check(UnknownHandlerInfo info)
 {
     return(DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MethodBase System.Reflection.Module::ResolveMethod(System.Int32)"));
 }
コード例 #9
0
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return(isEmptyMethod(info.ReadMethod) && isEmptyMethod(info.ExecuteMethod));
 }
コード例 #10
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return true;
 }
コード例 #11
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return info.ExecuteMethod.Body.Variables.Count == 3;
 }
コード例 #12
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
 protected abstract bool detectInternal(UnknownHandlerInfo info);
コード例 #13
0
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return(true);
 }
コード例 #14
0
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return(DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Reflection.BindingFlags)"));
 }
コード例 #15
0
 protected abstract bool detectInternal(UnknownHandlerInfo info);
コード例 #16
0
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return(DotNetUtils.callsMethod(info.ExecuteMethod, "System.Type System.Reflection.Module::ResolveType(System.Int32)"));
 }
コード例 #17
0
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return(info.ExecuteMethod.Body.Variables.Count == 3);
 }
コード例 #18
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MethodBase System.Reflection.Module::ResolveMethod(System.Int32)");
 }
コード例 #19
0
 static bool leave_check(UnknownHandlerInfo info)
 {
     return(!DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MethodBase System.Reflection.Module::ResolveMethod(System.Int32)") &&
            !DotNetUtils.callsMethod(info.ExecuteMethod, "System.Type System.Reflection.Module::ResolveType(System.Int32)") &&
            !DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MemberInfo System.Reflection.Module::ResolveMember(System.Int32)"));
 }
コード例 #20
0
ファイル: OpCodeHandler.cs プロジェクト: ByteCatcher/de4dot
 protected override bool detectInternal(UnknownHandlerInfo info)
 {
     return DotNetUtils.callsMethod(info.ExecuteMethod, "System.Reflection.MethodInfo System.Type::GetMethod(System.String,System.Reflection.BindingFlags)");
 }
コード例 #21
0
 static bool nop_check(UnknownHandlerInfo info)
 {
     return(isEmptyMethod(info.ReadMethod) && isEmptyMethod(info.ExecuteMethod));
 }
コード例 #22
0
 void detectHandlers(List<TypeDefinition> handlerTypes)
 {
     opCodeHandlers = new List<OpCodeHandler>();
     var detected = new List<OpCodeHandler>();
     foreach (var handlerType in handlerTypes) {
         var info = new UnknownHandlerInfo(handlerType);
         detected.Clear();
         foreach (var opCodeHandler in opCodeHandlerDetectors) {
             if (opCodeHandler.detect(info))
                 detected.Add(opCodeHandler);
         }
         if (detected.Count != 1)
             throw new ApplicationException("Could not detect VM opcode handler");
         opCodeHandlers.Add(detected[0]);
     }
     if (new List<OpCodeHandler>(Utils.unique(opCodeHandlers)).Count != opCodeHandlers.Count)
         throw new ApplicationException("Could not detect all VM opcode handlers");
 }
コード例 #23
0
        void detectHandlers(List<TypeDefinition> handlerTypes, CsvmInfo csvmInfo)
        {
            opCodeHandlers = new List<OpCodeHandler>();
            var detected = new List<OpCodeHandler>();

            foreach (var handlersList in OpCodeHandlers.opcodeHandlers) {
                opCodeHandlers.Clear();

                foreach (var handlerType in handlerTypes) {
                    var info = new UnknownHandlerInfo(handlerType, csvmInfo);
                    detected.Clear();
                    foreach (var opCodeHandler in handlersList) {
                        if (opCodeHandler.detect(info))
                            detected.Add(opCodeHandler);
                    }
                    if (detected.Count != 1)
                        goto next;
                    opCodeHandlers.Add(detected[0]);
                }
                if (new List<OpCodeHandler>(Utils.unique(opCodeHandlers)).Count == opCodeHandlers.Count)
                    return;
            next: ;
            }
            throw new ApplicationException("Could not detect all VM opcode handlers");
        }