Esempio n. 1
0
            // Token: 0x0600009D RID: 157 RVA: 0x0000CFBC File Offset: 0x0000B1BC
            private static TypeDef PopulateContext(TypeDef typeDef, InjectHelper1.InjectHelper.InjectContext ctx)
            {
                IDnlibDef dnlibDef;
                bool      flag = !ctx.Map.TryGetValue(typeDef, out dnlibDef);
                TypeDef   typeDef2;

                if (flag)
                {
                    typeDef2         = InjectHelper1.InjectHelper.Clone(typeDef);
                    ctx.Map[typeDef] = typeDef2;
                }
                else
                {
                    typeDef2 = (TypeDef)dnlibDef;
                }
                foreach (TypeDef typeDef3 in typeDef.NestedTypes)
                {
                    typeDef2.NestedTypes.Add(InjectHelper1.InjectHelper.PopulateContext(typeDef3, ctx));
                }
                foreach (MethodDef methodDef in typeDef.Methods)
                {
                    typeDef2.Methods.Add((MethodDef)(ctx.Map[methodDef] = InjectHelper1.InjectHelper.Clone(methodDef)));
                }
                foreach (FieldDef fieldDef in typeDef.Fields)
                {
                    typeDef2.Fields.Add((FieldDef)(ctx.Map[fieldDef] = InjectHelper1.InjectHelper.Clone(fieldDef)));
                }
                return(typeDef2);
            }
Esempio n. 2
0
 // Token: 0x060000A3 RID: 163 RVA: 0x0000D8CC File Offset: 0x0000BACC
 public static MethodDef Inject(MethodDef methodDef, ModuleDef target)
 {
     InjectHelper1.InjectHelper.InjectContext injectContext = new InjectHelper1.InjectHelper.InjectContext(methodDef.Module, target);
     injectContext.Map[methodDef] = InjectHelper1.InjectHelper.Clone(methodDef);
     InjectHelper1.InjectHelper.CopyMethodDef(methodDef, injectContext);
     return((MethodDef)injectContext.Map[methodDef]);
 }
Esempio n. 3
0
 // Token: 0x060000A2 RID: 162 RVA: 0x0000D888 File Offset: 0x0000BA88
 public static TypeDef Inject(TypeDef typeDef, ModuleDef target)
 {
     InjectHelper1.InjectHelper.InjectContext injectContext = new InjectHelper1.InjectHelper.InjectContext(typeDef.Module, target);
     InjectHelper1.InjectHelper.PopulateContext(typeDef, injectContext);
     InjectHelper1.InjectHelper.Copy(typeDef, injectContext, true);
     return((TypeDef)injectContext.Map[typeDef]);
 }
Esempio n. 4
0
            // Token: 0x0600009E RID: 158 RVA: 0x0000D128 File Offset: 0x0000B328
            private static void CopyTypeDef(TypeDef typeDef, InjectHelper1.InjectHelper.InjectContext ctx)
            {
                TypeDef typeDef2 = (TypeDef)ctx.Map[typeDef];

                typeDef2.BaseType = (ITypeDefOrRef)ctx.Importer.Import(typeDef.BaseType);
                foreach (InterfaceImpl interfaceImpl in typeDef.Interfaces)
                {
                    typeDef2.Interfaces.Add(new InterfaceImplUser((ITypeDefOrRef)ctx.Importer.Import(interfaceImpl.Interface)));
                }
            }
Esempio n. 5
0
 // Token: 0x060000A4 RID: 164 RVA: 0x0000D918 File Offset: 0x0000BB18
 public static IEnumerable <IDnlibDef> Inject(TypeDef typeDef, TypeDef newType, ModuleDef target)
 {
     InjectHelper1.InjectHelper.InjectContext injectContext = new InjectHelper1.InjectHelper.InjectContext(typeDef.Module, target);
     injectContext.Map[typeDef] = newType;
     InjectHelper1.InjectHelper.PopulateContext(typeDef, injectContext);
     InjectHelper1.InjectHelper.Copy(typeDef, injectContext, false);
     return(injectContext.Map.Values.Except(new TypeDef[]
     {
         newType
     }));
 }
Esempio n. 6
0
 // Token: 0x060000A1 RID: 161 RVA: 0x0000D7A0 File Offset: 0x0000B9A0
 private static void Copy(TypeDef typeDef, InjectHelper1.InjectHelper.InjectContext ctx, bool copySelf)
 {
     if (copySelf)
     {
         InjectHelper1.InjectHelper.CopyTypeDef(typeDef, ctx);
     }
     foreach (TypeDef typeDef2 in typeDef.NestedTypes)
     {
         InjectHelper1.InjectHelper.Copy(typeDef2, ctx, true);
     }
     foreach (MethodDef methodDef in typeDef.Methods)
     {
         InjectHelper1.InjectHelper.CopyMethodDef(methodDef, ctx);
     }
     foreach (FieldDef fieldDef in typeDef.Fields)
     {
         InjectHelper1.InjectHelper.CopyFieldDef(fieldDef, ctx);
     }
 }
Esempio n. 7
0
            // Token: 0x0600009F RID: 159 RVA: 0x0000D1D0 File Offset: 0x0000B3D0
            private static void CopyMethodDef(MethodDef methodDef, InjectHelper1.InjectHelper.InjectContext ctx)
            {
                MethodDef methodDef2 = (MethodDef)ctx.Map[methodDef];

                methodDef2.Signature = ctx.Importer.Import(methodDef.Signature);
                methodDef2.Parameters.UpdateParameterTypes();
                bool flag = methodDef.ImplMap != null;

                if (flag)
                {
                    methodDef2.ImplMap = new ImplMapUser(new ModuleRefUser(ctx.TargetModule, methodDef.ImplMap.Module.Name), methodDef.ImplMap.Name, methodDef.ImplMap.Attributes);
                }
                foreach (CustomAttribute customAttribute in methodDef.CustomAttributes)
                {
                    methodDef2.CustomAttributes.Add(new CustomAttribute((ICustomAttributeType)ctx.Importer.Import(customAttribute.Constructor)));
                }
                bool hasBody = methodDef.HasBody;

                if (hasBody)
                {
                    methodDef2.Body          = new CilBody(methodDef.Body.InitLocals, new List <Instruction>(), new List <ExceptionHandler>(), new List <Local>());
                    methodDef2.Body.MaxStack = methodDef.Body.MaxStack;
                    Dictionary <object, object> bodyMap = new Dictionary <object, object>();
                    foreach (Local local in methodDef.Body.Variables)
                    {
                        Local local2 = new Local(ctx.Importer.Import(local.Type));
                        methodDef2.Body.Variables.Add(local2);
                        local2.Name          = local.Name;
                        local2.PdbAttributes = local.PdbAttributes;
                        bodyMap[local]       = local2;
                    }
                    foreach (Instruction instruction in methodDef.Body.Instructions)
                    {
                        Instruction instruction2 = new Instruction(instruction.OpCode, instruction.Operand);
                        instruction2.SequencePoint = instruction.SequencePoint;
                        bool flag2 = instruction2.Operand is IType;
                        if (flag2)
                        {
                            instruction2.Operand = ctx.Importer.Import((IType)instruction2.Operand);
                        }
                        else
                        {
                            bool flag3 = instruction2.Operand is IMethod;
                            if (flag3)
                            {
                                instruction2.Operand = ctx.Importer.Import((IMethod)instruction2.Operand);
                            }
                            else
                            {
                                bool flag4 = instruction2.Operand is IField;
                                if (flag4)
                                {
                                    instruction2.Operand = ctx.Importer.Import((IField)instruction2.Operand);
                                }
                            }
                        }
                        methodDef2.Body.Instructions.Add(instruction2);
                        bodyMap[instruction] = instruction2;
                    }
                    Func <Instruction, Instruction> < > 9__0;
                    foreach (Instruction instruction3 in methodDef2.Body.Instructions)
                    {
                        bool flag5 = instruction3.Operand != null && bodyMap.ContainsKey(instruction3.Operand);
                        if (flag5)
                        {
                            instruction3.Operand = bodyMap[instruction3.Operand];
                        }
                        else
                        {
                            bool flag6 = instruction3.Operand is Instruction[];
                            if (flag6)
                            {
                                Instruction instruction4 = instruction3;
                                IEnumerable <Instruction>       source = (Instruction[])instruction3.Operand;
                                Func <Instruction, Instruction> selector;
                                if ((selector = < > 9__0) == null)
                                {
                                    selector = (< > 9__0 = ((Instruction target) => (Instruction)bodyMap[target]));
                                }
                                instruction4.Operand = source.Select(selector).ToArray <Instruction>();
                            }
                        }
                    }
                    foreach (ExceptionHandler exceptionHandler in methodDef.Body.ExceptionHandlers)
                    {
                        methodDef2.Body.ExceptionHandlers.Add(new ExceptionHandler(exceptionHandler.HandlerType)
                        {
                            CatchType    = ((exceptionHandler.CatchType == null) ? null : ((ITypeDefOrRef)ctx.Importer.Import(exceptionHandler.CatchType))),
                            TryStart     = (Instruction)bodyMap[exceptionHandler.TryStart],
                            TryEnd       = (Instruction)bodyMap[exceptionHandler.TryEnd],
                            HandlerStart = (Instruction)bodyMap[exceptionHandler.HandlerStart],
                            HandlerEnd   = (Instruction)bodyMap[exceptionHandler.HandlerEnd],
                            FilterStart  = ((exceptionHandler.FilterStart == null) ? null : ((Instruction)bodyMap[exceptionHandler.FilterStart]))
                        });
                    }
                    methodDef2.Body.SimplifyMacros(methodDef2.Parameters);
                }
            }
Esempio n. 8
0
            // Token: 0x060000A0 RID: 160 RVA: 0x0000D764 File Offset: 0x0000B964
            private static void CopyFieldDef(FieldDef fieldDef, InjectHelper1.InjectHelper.InjectContext ctx)
            {
                FieldDef fieldDef2 = (FieldDef)ctx.Map[fieldDef];

                fieldDef2.Signature = ctx.Importer.Import(fieldDef.Signature);
            }