question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for custom CIL instructions

See original GitHub issue

Hi,

For a project I’m currently working on, I need to be able to insert custom CIL instructions into a method body (ones that are understood by the runtime I’m targeting). Basically, I just want to be able to provide dnlib with custom OpCode instances that inform it about how to decode/encode these instructions, calculate stack usage and control flow, etc.

From what I can gather looking at the source, what would need to happen for this to be possible is:

  • OpCode would need to be made extensible in some form (probably just a public constructor).
  • There would need to be some place in the API for registering custom OpCode instances.
  • MethodBodyReaderBase and a few other places need to be made aware about the experimental opcode range (0xf00xfb).

There may of course be other required changes that I’m not aware of, but I think that’s the gist of it.

Would a patch for this be welcome? If so, what would be an acceptable design for this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
0xd4dcommented, Jun 20, 2020

I would expect that if you want to define your own custom opcodes, you’d create a table with 256 values in it so an array should be enough. 0xF0-0xFB can then be overridden to use those arrays (if they’re not null).

0reactions
0xd4dcommented, Jul 1, 2020

Add new overloads

  • MethodBodyReader: an extra contex arg, pass it to base
  • CreateCilBody: two of these call CreateCilBody() and these two methods need to get a new overload with a contex arg

The opResolver is usually a module but we can’t assume it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Intermediate Language (CIL) - What Does It Look ...
CIL is an object-oriented assembly language and is CPU and platform-independent instructions that can be executed in any environment supporting the Common ...
Read more >
How to use CIL instruction conv.r4
Today I started to learn how CIL code works. ... I want to replace var1 with hard-written value. ... Convert to float32, pushing...
Read more >
CIL programming tutorial – The Basics Part I
For this tutorial you will need the IL Support Visual Studio extension which can be downloaded from here. Creating your first IL code....
Read more >
Common Intermediate Language
CIL is a CPU- and platform-independent instruction set that can be executed in any environment supporting the Common Language Infrastructure, such as the...
Read more >
Ted Neward - Busy Developer's Guide to .NET ... - YouTube
CIL (Common Intermediate Language) is the execution code set used by the .NET runtime (the Common Language Infrastructure, or CLI) that is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found