It's a bunch of methods, both private and public.

I tried using a try/finally block but then peverify complained that I
can't return out of a finally block.

The easiest thing I can think of is to make a second copy of the
method and dump the original contents of the method in there, then
just call that, store the result in a local, call my new instructions,
and return the local... but that would make my original code
completely non debuggable right?

On Nov 21, 8:07 am, Simon Cropp <[email protected]> wrote:
> Jeff
>
> Is it a private method ?
>
> On 21/11/2010, at 10:14 PM, Jb Evain <[email protected]> wrote:
>
>
>
> > You have to analyze the whole body of the method to determine its exit
> > points and track the stack usage to be sure to not mess up with it.
>
> > On Sun, Nov 21, 2010 at 3:48 AM, Jeff Nevins <[email protected]> wrote:
> >> Anyone?....please :)
>
> >> On Nov 18, 4:22 pm, Jeff Nevins <[email protected]> wrote:
> >>> I guess this is more of an IL instruction but I'd appreciate any help
> >>> all the same.
>
> >>> I need to add a method call at the end of an arbitrary set of methods.
> >>> The Instructions I'm emitting are fine for most methods - I'm adding
> >>> my new Instructions before the last found instruction with a Ret code:
>
> >>>            var returnInstruction =
> >>> method.Body.Instructions.LastOrDefault(i => i.OpCode.Code ==
> >>> Code.Ret);
>
> >>> ....
>
> >>>             foreach (Instruction instruction in exitInstructions)
> >>>             {
> >>>                 processor.InsertBefore(returnInstruction,
> >>> instruction);
> >>>             }
>
> >>> However, sometimes this approach bombs and I get an Invalid Program
> >>> exception, which seems to happen when there is a Br_S instruction
> >>> before the Ret instruction....which I guess makes sense.
>
> >>> So, my question is...how can I reliably determine where to insert my
> >>> new instruction(s) at the end of the method, before it returns?
>
> >>> Thanks in advance.
>
> >> --
> >> --
> >> mono-cecil
>
> > --
> > --
> > mono-cecil

-- 
--
mono-cecil

Reply via email to