Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 06-06-2020, 09:57
jonwil jonwil is offline
VIP
 
Join Date: Feb 2004
Posts: 315
Rept. Given: 2
Rept. Rcvd 19 Times in 7 Posts
Thanks Given: 1
Thanks Rcvd at 40 Times in 26 Posts
jonwil Reputation: 19
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?
Reply With Quote
  #2  
Old 06-06-2020, 11:28
chessgod101's Avatar
chessgod101 chessgod101 is offline
Co-Administrator
 
Join Date: Jan 2011
Location: United States
Posts: 506
Rept. Given: 2,104
Rept. Rcvd 668 Times in 209 Posts
Thanks Given: 504
Thanks Rcvd at 712 Times in 149 Posts
chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699 chessgod101 Reputation: 500-699
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
__________________
"Real knowledge is to know the extent of one's ignorance." Confucius
Reply With Quote
The Following User Gave Reputation+1 to chessgod101 For This Useful Post:
user1 (06-06-2020)
The Following 2 Users Say Thank You to chessgod101 For This Useful Post:
user1 (06-06-2020), wilson bibe (06-06-2020)
  #3  
Old 06-06-2020, 16:46
val2032 val2032 is online now
Friend
 
Join Date: Apr 2010
Posts: 32
Rept. Given: 26
Rept. Rcvd 1 Time in 1 Post
Thanks Given: 61
Thanks Rcvd at 14 Times in 9 Posts
val2032 Reputation: 1
Also you can export project from dnspy and load it in VS.
Reply With Quote
  #4  
Old 06-07-2020, 03:59
atom0s's Avatar
atom0s atom0s is offline
Family
 
Join Date: Jan 2015
Location: 127.0.0.1
Posts: 279
Rept. Given: 24
Rept. Rcvd 102 Times in 48 Posts
Thanks Given: 46
Thanks Rcvd at 474 Times in 193 Posts
atom0s Reputation: 100-199 atom0s Reputation: 100-199
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
__________________
Personal Projects Site: https://atom0s.com
Reply With Quote
The Following 2 Users Say Thank You to atom0s For This Useful Post:
niculaita (06-07-2020), val2032 (06-07-2020)
  #5  
Old 06-07-2020, 16:56
niculaita's Avatar
niculaita niculaita is online now
Family
 
Join Date: Jun 2011
Location: here
Posts: 1,169
Rept. Given: 873
Rept. Rcvd 85 Times in 57 Posts
Thanks Given: 2,854
Thanks Rcvd at 436 Times in 313 Posts
niculaita Reputation: 85
also net reflector with reflexil 2.3 plugin
__________________
Decode and Conquer
Reply With Quote
The Following User Says Thank You to niculaita For This Useful Post:
val2032 (06-07-2020)
  #6  
Old 06-22-2020, 00:25
tusk tusk is offline
Friend
 
Join Date: Jun 2016
Posts: 26
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 5
Thanks Rcvd at 12 Times in 8 Posts
tusk Reputation: 0
Quote:
Originally Posted by jonwil View Post
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...
Reply With Quote
The Following User Says Thank You to tusk For This Useful Post:
niculaita (06-22-2020)
  #7  
Old 06-22-2020, 04:54
niculaita's Avatar
niculaita niculaita is online now
Family
 
Join Date: Jun 2011
Location: here
Posts: 1,169
Rept. Given: 873
Rept. Rcvd 85 Times in 57 Posts
Thanks Given: 2,854
Thanks Rcvd at 436 Times in 313 Posts
niculaita Reputation: 85
also, in some cases, the name of patched file have to be same as original one
__________________
Decode and Conquer
Reply With Quote
  #8  
Old 06-23-2020, 19:53
sendersu sendersu is offline
VIP
 
Join Date: Oct 2010
Posts: 847
Rept. Given: 324
Rept. Rcvd 216 Times in 110 Posts
Thanks Given: 168
Thanks Rcvd at 353 Times in 200 Posts
sendersu Reputation: 200-299 sendersu Reputation: 200-299 sendersu Reputation: 200-299
Quote:
Originally Posted by tusk View Post
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
Reply With Quote
The Following User Says Thank You to sendersu For This Useful Post:
tusk (06-27-2020)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT +8. The time now is 22:45.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX
( 1998 - 2020 )