Exetools

Exetools (https://forum.exetools.com/index.php)
-   General Discussion (https://forum.exetools.com/forumdisplay.php?f=2)
-   -   Modifying/replacing class in .NET binary (https://forum.exetools.com/showthread.php?t=19555)

jonwil 06-06-2020 09:57

Modifying/replacing class in .NET binary
 
I have a .NET binary (.NET only, no native code). Short of decompiling the entire binary, changing it and recompiling it (not really an option for my particular target), is there a way to take the decompiled code for the one class I am interested in, modify it and either A.Stick it back in the original binary somehow or B.Stick it into a dll file and make the binary use the dll instead of the original code?

Or any other way to modify the code?

chessgod101 06-06-2020 11:28

You should be able to directly replace or modify the decompiled class with dnSpy rather seamlessly, depending on how drastic the changes are:
Code:

https://github.com/0xd4d/dnSpy/releases

val2032 06-06-2020 16:46

Also you can export project from dnspy and load it in VS.

atom0s 06-07-2020 03:59

Projects like dnlib, Mono.Cecil, and Harmony are usable for things like this:

https://github.com/0xd4d/dnlib
https://github.com/jbevain/cecil
https://github.com/pardeike/Harmony

niculaita 06-07-2020 16:56

also net reflector with reflexil 2.3 plugin

tusk 06-22-2020 00:25

Quote:

Originally Posted by jonwil (Post 120307)
Or any other way to modify the code?

Using some of the the above tools (dnSpy for exemple), you can directly change the code in the binary.
This might be in IL, but it is not too complicated to learn (for small patches it is usually ok)

I wonder if new versions are able to change in .net directly (thus builing the IL code automatically. Last time i tried, dnSpy had some issues with this and changing the IL code directly was the way to go...

niculaita 06-22-2020 04:54

also, in some cases, the name of patched file have to be same as original one

sendersu 06-23-2020 19:53

Quote:

Originally Posted by tusk (Post 120412)
Using some of the the above tools (dnSpy for exemple), you can directly change the code in the binary.
This might be in IL, but it is not too complicated to learn (for small patches it is usually ok)

I wonder if new versions are able to change in .net directly (thus builing the IL code automatically. Last time i tried, dnSpy had some issues with this and changing the IL code directly was the way to go...

I'd recommend opening up an issue in dnSpy github tracker
author is responsive and is interested in in keeping his great product up to date and bugless

chicknsoup 08-22-2020 09:23

For small binary files, you can dump the file with dnSpy, load it with Visual Studio, patch then rebuild.

Tamrwa 08-22-2020 12:49

Why VS? Can patch directly in dnspy.


All times are GMT +8. The time now is 10:37.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX