Esempio n. 1
0
        bool checkInitMethod(MethodDefinition method)
        {
            var type = method.DeclaringType;

            if (type.NestedTypes.Count != 3)
            {
                return(false);
            }
            if (DotNetUtils.getPInvokeMethod(type, "kernel32", "MoveFileEx") == null)
            {
                return(false);
            }

            var resolveHandler = EfUtils.getResolveMethod(method);

            if (resolveHandler == null)
            {
                return(false);
            }
            if (!DeobUtils.hasInteger(resolveHandler, ',') ||
                !DeobUtils.hasInteger(resolveHandler, '|'))
            {
                return(false);
            }

            initMethod    = method;
            resolverType  = type;
            handlerMethod = resolveHandler;
            return(true);
        }
Esempio n. 2
0
        bool checkInitMethod(MethodDefinition method)
        {
            if (method == null || !method.IsStatic || method.Body == null)
            {
                return(false);
            }
            if (!DotNetUtils.isMethod(method, "System.Void", "()"))
            {
                return(false);
            }
            var type = method.DeclaringType;

            if (type.NestedTypes.Count != 1)
            {
                return(false);
            }
            if (DotNetUtils.getField(type, "System.Reflection.Assembly") == null)
            {
                return(false);
            }

            var resolveHandler = EfUtils.getResolveMethod(method);

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

            initMethod    = method;
            resolverType  = type;
            handlerMethod = resolveHandler;
            return(true);
        }
Esempio n. 3
0
        EmbeddedResource FindResourceFromStringBuilder(MethodDef method)
        {
            int startIndex = EfUtils.FindOpCodeIndex(method, 0, Code.Newobj, "System.Void System.Text.StringBuilder::.ctor()");

            if (startIndex < 0)
            {
                return(null);
            }
            int endIndex = EfUtils.FindOpCodeIndex(method, startIndex, Code.Call, "System.String System.Text.StringBuilder::ToString()");

            if (endIndex < 0)
            {
                return(null);
            }

            var sb = new StringBuilder();
            var instrs = method.Body.Instructions;
            int val = 0, shift = 0;

            for (int i = startIndex; i < endIndex; i++)
            {
                var instr = instrs[i];
                if (instr.OpCode.Code == Code.Call && instr.Operand.ToString() == "System.Text.StringBuilder System.Text.StringBuilder::Append(System.Char)")
                {
                    sb.Append((char)(val >> shift));
                    shift = 0;
                }
                if (stringMethodConsts.IsLoadConstantInt32(instr))
                {
                    int tmp;
                    if (!stringMethodConsts.GetInt32(ref i, out tmp))
                    {
                        break;
                    }
                    if (i >= endIndex)
                    {
                        break;
                    }

                    var next = instrs[i];
                    if (next.OpCode.Code == Code.Shr)
                    {
                        shift = tmp;
                    }
                    else
                    {
                        val   = tmp;
                        shift = 0;
                    }
                }
            }

            return(DotNetUtils.GetResource(module, sb.ToString()) as EmbeddedResource);
        }