Hi,

I think what you propose is the best way to achieve this. I'm not sure
if 'ret' is the only opcode that can leave a method normally, though.

Regards,
Alex

On Thu, Jul 7, 2011 at 11:47 AM, Indiefreaks.com
<[email protected]> wrote:
> Hi,
>
> In my current Xna game profiler tool (learn more at http://indiefreaks.com),
> I'm wrapping each method that should be profiled with my profiling
> code.
>
> Right now, in order to do so, I'm getting the first instruction from
> the MethodDefinition Body as well as the last one and inject my code
> before them.
>
> It works perfectly fine on most cases except when a control flow
> operation code is set in the body.
>
> My profiling code that is injected before the actual method is invoked
> works fine but because of the previous statement, the code I inject at
> what I would consider the end of the method never gets called or gets
> called inside an if or switch statement which crashes the resulting
> assembly.
>
> From what I understand, if I have such control flow operations, the
> last instruction in a method body may not be the end of the current
> Method.
>
> I'm now considering parsing the whole method instructions and look for
> each OpCodes.Ret instance to add my custom code there but I wondered
> if there was a better solution to find the end of a method or hook to
> it.
>
> Thanks
>
> --
> --
> mono-cecil

-- 
--
mono-cecil

Reply via email to