Wrong IL Code's Address, Leave.s L_ffffffbc

66 views
Skip to first unread message

DongYong Lee

unread,
Sep 2, 2010, 2:01:09 AM9/2/10
to mono-cecil
Hi~

I’ve been using Mono-cecil to inject sets of IL Codes which store
parameters or return value of target method.

So I mainly inject IL Codes at two points in a method. Then I got
wrong IL Code’s Address such as

Leave.s L_ffffffbc after IL injection.

I had a look into Injected code output. Most of codes look just fine
except only one Leaves.s opcode has wrong

address as operand. That address does not exist in a code list too.

What’s interesting is that I got correct output IL Codes with target
method that has less than three parameters but

I got wrong IL Code with a method which has more than three
parameters.

I used this version of mono-cecil jbevain-cecil-0.9.3-49-g0ce348e.

Could you give me any ideas to figure this out?

Example:
http://leeways.tistory.com/attachment/cfile...@19749F1F4C7F2EFA10E44B.zip
Document:
http://leeways.tistory.com/attachment/cfil...@1111BB284C7F3D0973FF9B.ppt

Thanks,
DY

DongYong Lee

unread,
Sep 2, 2010, 2:09:59 AM9/2/10
to mono-cecil
<a href="http://leeways.tistory.com/attachment/
cfile...@19749F1F4C7F2EFA10E44B.zip">Example Code</a><br />

<a href="http://leeways.tistory.com/attachment/
cfil...@1111BB284C7F3D0973FF9B.ppt">Document</a>

Jb Evain

unread,
Sep 2, 2010, 4:33:48 AM9/2/10
to mono-...@googlegroups.com
On Thu, Sep 2, 2010 at 8:01 AM, DongYong Lee <leewit...@gmail.com> wrote:
> Leave.s L_ffffffbc after IL injection.

Use the extensions method from Mono.Cecil.Rocks:

body.SimplifyMacros ();

// inject IL

body.OptimizeMacros ();

That will make sure your branches don't overflow.

--
Jb Evain  <j...@nurv.fr>

DongYong Lee

unread,
Sep 6, 2010, 5:09:44 AM9/6/10
to mono-cecil
First of all, Thanks Jb

I added one statement "body.SimplifyMacros ()" to my code as your
comment.

then I needed to change some of my codes to adopt changes by
SimplifyMacros() method.

Finally, I have lovely injected output now.

Thank again.

On 9월2일, 오후5시33분, Jb Evain <j...@nurv.fr> wrote:
Reply all
Reply to author
Forward
0 new messages