MSIL virtual addresses

Please see below MSIL code:

IL_00:  ldstr      "Hello World"
IL_05:  call       void [mscorlib]System.Console::WriteLine(string)
IL_10:  ret

      

What is meant by IL_00, IL_05 and IL_10? I was reading the operating system concept at university, so at that time I understood how the Windows operating system allocates virtual memory for a process. I also don't understand why in the case of the above; addresses increase by 5.

The managed code was generated from a VB.NET application.

I've spent some time on Google and I've read several articles on MSDN. I am still unclear and hence the reason for the question.

+3


source to share


1 answer


These are just bogus "addresses" generated by your IL disassembler. The LDSTR opcode requires one byte for the opcode, 0x72 and 4 bytes for the operand. This is a token value that fetches a row from the metadata table that stores string literals. So, the next IL opcode starts at offset 5. In the same recipe, CALL requires one byte for the opcode, 0x28 and 4 bytes for the operand, the method token. So the next IL opcode starts at offset 10. RET requires 1 byte, 0x2A, and has no operand. The total size of the IL code is 11 bytes.



Your disassembler generates these "addresses" to show you the purpose of the branch instruction. You don't have it, try to parse the code that uses the if () statement. They are otherwise irrelevant, since jitter translates this code into machine code that looks very different.

+6


source







All Articles