Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

diassemble managed code issue

I am using Windbg to diassemble managed code (written in C#, console application) using Windbg's !U command from sos.dll. I find when using !U to diassemble a managed function, the diassembled IL code only contains function calls I made, and for remaining parts (non-function call C# code), for example a=a*2, and foreach loops in C#, only native assembly language code is shown, is that the correct expected behavior?

My question is, I want to know whether !U is capable of diassemble managed code binary DLL into IL with all code (besides function call code)?

Thanks in advance, George

like image 431
George2 Avatar asked Aug 07 '26 20:08

George2


1 Answers

If you want to dump IL while debugging you can use the !dumpil command from SOS. It takes a MethodDesc pointer as input, so you have to obtain that first.

One way to get the MethodDesc pointer use the !name2ee command.

So for instance if you have a method Foo in the type Bar (in assembly ClassLibrary1) use !name2ee like this

0:000> !name2ee ClassLibrary1!ClassLibrary1.Bar.Foo
Module: 001630bc (ClassLibrary1.dll)
Token: 0x06000001
MethodDesc: 00163450  <=== HERE
Name: ClassLibrary1.Bar.Foo()
JITTED Code Address: 007500f0

Following that, you can do a !dumpil 00163450 to dump the IL for method Foo like this

0:000> !dumpil 00163450
ilAddr = 73532050
IL_0000: ldstr "Foo"
IL_0005: call System.Console::WriteLine
like image 62
Brian Rasmussen Avatar answered Aug 10 '26 10:08

Brian Rasmussen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!