Hi, Could you describe the issues you're having?
Jb On Wed, Nov 26, 2014 at 6:29 AM, SM <[email protected]> wrote: > Hi, > > While injecting a private method call from different assembly , getting > issus > Can we inject private method call using Cecil ? > > > foreach (ModuleDefinition mod in asm.Modules) > { > foreach (TypeDefinition td in mod.Types) > { > if (td.Name == "<Module>") > { > continue; > } > > foreach (MethodDefinition md in td.Methods) > { > if (md.Name.ToString() != ".ctor" && > md.Name.ToString() != "Main") > { > ILProcessor ilProcessor = > md.Body.GetILProcessor(); > Instruction i1 = > ilProcessor.Create(OpCodes.Ldstr, md.ToString()); > injected = true; > > // Call the method which would call private > method from different assembly > string type_name = asm.Name.Name.ToString() + > "." + td.Name.ToString(); > Instruction i2 = > ilProcessor.Create(OpCodes.Call, > md.Module.Import(typeof(acc_check.Math1).GetMethod("Check"))); > ilProcessor.InsertAfter(md.Body.Instructions[0], > i2); > > } > } > td.Name = td.Name.ToString() + "_Accessor"; > td.Namespace = td.Namespace.ToString() + "_Accessor"; > } > asm.Name.Name += "_Accessor"; > } > asm.Write(accessor_dll ,new WriterParameters { WriteSymbols = > true }); > > > "Check" is a private method in acc_check.Math1 > > -- > -- > -- > mono-cecil > --- > You received this message because you are subscribed to the Google Groups > "mono-cecil" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
