Search code examples
dllnativereflector

How to get source code from native dll?


How can i get source code from native dll ? With Reflector no luck.


Solution

  • You cannot.

    Strictly speaking, you also cannot get the source code of a managed dll with Reflector (e.g. there are no comments; and if it's been obfucated you also will not see the source code). The .NET Reflector is just very good at disassembling the MSIL code.

    You can disassemble a native dll, you just won't like it. For example, i am trying to debug a crash in code that isn't mine:

    CPU Disasm
    Address   Hex dump          Command                                  Comments
    20C46D9B  |>  8B4424 14     |MOV EAX,DWORD PTR SS:[LOCAL.1]
    20C46D9F  |.  8B40 10       |MOV EAX,DWORD PTR DS:[EAX+10]
    20C46DA2  |.  83C0 08       |ADD EAX,8
    20C46DA5  |>  8B08          |/MOV ECX,DWORD PTR DS:[EAX]
    20C46DA7  |.  3B0F          ||CMP ECX,DWORD PTR DS:[EDI]             ; Crash with EDI=00000008
    20C46DA9  |.  75 12         ||JNE SHORT 20C46DBD
    20C46DAB  |.  83EE 04       ||SUB ESI,4
    20C46DAE  |.  83C7 04       ||ADD EDI,4
    20C46DB1  |.  83C0 04       ||ADD EAX,4
    20C46DB4  |.  83FE 04       ||CMP ESI,4
    20C46DB7  |.^ 73 EC         |\JAE SHORT 20C46DA5
    

    But source code? No.