from the whirlpool.net.au discussion forums
web hosting by WebCentral Australia
   .net reflector, debug 3rd party dll View full version
User #81037   164 posts
Forum Regular

Hello All,

Can anyone give me any pointers on how to debug a 3rd party DLL (no source). I am looking at the DLL in reflector and know exactly where the problem lies, I just need to add one line of code.

Is this difficult ? Do I need to modify IL code ?.

Thanks.
Rob.

posted 2008-May-12, 9pm AEST
User #15584   2002 posts
Whirlpool Forums Addict

your best bet is to get the 3rd party to fix it.

failing that is the method overridable, if so you can inherit the class, then copy the code from reflector adding in your fix though that is prone to issues after an upgrade)

failing that you can copy the entire class's source and use that or get a reflector addin that dumps an assembly to source code.

its probably possible using something like Cecil to rewrite the IL but ive never done that (where as i have done all of the other options on various classes/assemblies)

posted 2008-May-12, 11pm AEST
User #825   831 posts
Whirlpool Enthusiast

trendy covered most of it. by far easiest is to get 3rd party to fix, but otherwise see if you can inherit and override the method.

one issue if you can override it, is you will need to call any private/friend methods/fields via reflector in your inherited method call.

also think about whether you can modify some field of the object that will cause whatever code you're after to be executed (it all depends on what the 1 line of code you need to add is going to do)

posted 2008-May-16, 7pm AEST
User #81037   164 posts
Forum Regular

Thanks Guys,

Yep, normally I would have inherited and overwritten (or shadow) a broken function, but in this case, it was the entire application that was broken, I simply wanted to edit the DLL. Doesn't matter now, I work-around has been found to make the app work, however it would have been an interesting learning exercise.

posted 2008-May-16, 9pm AEST
edited 2008-May-16, 9pm AEST
User #7441   21145 posts
Section Moderator

Assuming you have permission.

You can try dumping all the code from reflector and recompiling it with a change. Or, a more low level way...

Use ildasm (disassembler, it comes with the .net sdk/VS), it will dump the assembly to MSIL/CIL (basically the .net 'assembly language').

Make your change (it will be harder than editing source, and you should have some familiarity with low level languages if you are doing more than a few lines changes). Either way, you might find it interesting to learn.

Then use ilasm (assembler) to regenerate the dll.

posted 2008-May-18, 4am AEST
 
© Whirlpool Broadband Multimedia