Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any IL editor to change the bytecode of an assembly?

I've detected some defects on legacy third party assemblies that we're using on our code decompilind them. I would like to fix them but as I don't have the source code I need to directly modify the bytecode. The changes are really simple (changing an AND for an OR and NOPing some lines).

Is there an editor to do this kind of things? Doing the work with an hex editor would be the last option, I would preffer to have a hint of what instructions I have around the cursor ...

like image 717
Ignacio Soler Garcia Avatar asked Apr 27 '12 10:04

Ignacio Soler Garcia


4 Answers

dnSpy, allows you to modify IL and C# code. See their screenshots.

like image 180
Chris Xue Avatar answered Oct 18 '22 13:10

Chris Xue


I think what you are looking for is .NET Reflector with the Reflexil add-on. Take a look at the screenshots, it's pretty powerful and it can modify IL code at runtime. Reflector used to be free of charge, you might be able to get some older version somewhere.

like image 43
kuba Avatar answered Oct 18 '22 14:10

kuba


I am assuming the assemblies are not strongly named because otherwise there's nothing you can do without the signing key.

If not, it sounds like Ildasm would work for you. You can decompile the assemblies, perform modifications and assemble them again with Ilasm.

Another free option might be Telerik's JustDecompile, which "can create a Visual Studio project from a decompiled assembly." -- I haven't used it, but this sounds like it decompiles to source and creates a ready-to-build project. That would be super convenient since you won't even have to work with IL.

like image 21
Jon Avatar answered Oct 18 '22 14:10

Jon


Try Simple Assembly Explorer, it allows you to edit bytecode and works by default more life Reflexil

https://sites.google.com/site/simpledotnet/simple-assembly-explorer

like image 22
Bartosz Wójcik Avatar answered Oct 18 '22 15:10

Bartosz Wójcik