Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7445537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:51:30+00:00 2026-05-29T11:51:30+00:00

I can compile instructions to bytecode and even execute them easily but the only

  • 0

I can compile instructions to bytecode and even execute them easily but the only function I have found to extract CIL is GetILAsByteArray and, as the name implies, it just returns bytes and not CIL instructions.

So how do you programmatically disassemble CIL on .NET?

Note that I don’t want the result in human-readable form. I want to write metaprograms to manipulate the CIL generated from other programs.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:51:33+00:00Added an answer on May 29, 2026 at 11:51 am

    You can get reasonably far just using the byte array from GetILAsByteArray method, but you’ll need to write parsing of the bytes yourself (if you don’t want to rely on 3rd party library).

    The structure of the array is that there is one or two bytes identifying the instruction followed by operands for the instruction (which is either nothing, some 4 byte token or a 8 byte number).

    To get the codes, you can look at the OpCodes structure (MSDN) from System.Reflection.Emit. If you enumerate over all the fields, you can quite easily build a lookup table for reading of the bytes:

    // Iterate over all byte codes to build lookup table
    for fld in typeof<OpCodes>.GetFields() do
      let code = fld.GetValue(null) :?> OpCode
      printfn "%A (%d + %A)" code.Name code.Size code.OperandType
    

    The code.Value property gives you eithre byte or int16 value of the code. The code.Size property tells you whether this is 1 or 2 byte code and OperandType property specifies what arguments follow the code (the number of bytes and the meaning is explained on MSDN). I don’t remember how exactly you need to process things like tokens that refer to i.e. MethodInfo, but I guess you’ll be able to figure that out!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-module project. I thought I can compile only a single module
I have a problem - i can't compile SqlCipher. I'm using this http://groups.google.com/group/sqlcipher/browse_thread/thread/55c6296b56bf4533/c792bbec6df7d4f4?tvc=2#c792bbec6df7d4f4 instructions
After following instructions on the emscripten wiki I have managed to compile a small
I can't get the childbrowser to work on Android. I have followed the instructions
Do I have to compile GStreamer on my own? Can I do it using
Where can I find a simple set of instructions to compile an OpenJDK 7
Are there any more generic tools that can compile or basically merge multiple PHP
Although the Flex command-line compiler (mxmlc) can compile MXML + ActionScript files into SWFs
Although the MTASC command-line compiler can compile ActionScript class files into an SWF ,
Haxe has Apache httpd modules and can compile to PHP code. These are 2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.