#1
|
|||
|
|||
Modifying Assembly Attributes (.NET)
Is there a way to modify Assembly Attributes of existing assembly?
What I want to achieve is to add InternalsVisibleTo attribute to expose assembly's internals to my library.
__________________
http://youtu.be/H0QfVDebLFg |
#2
|
||||
|
||||
You can use something like Mono.Cecil to rewrite parts of the file and then save the changed file. Check out Mono.Cecil here:
http://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cecil/ dnlib is another similar library: https://github.com/0xd4d/dnlib You should be able to alter the attributes of classes and such to your needs to make it work as desired. |
The Following 2 Users Gave Reputation+1 to atom0s For This Useful Post: | ||
Dreamer (05-07-2015), The Old Pirate (05-09-2015) |
#3
|
|||
|
|||
I accomplished the task with Mono.Cecil, thanks.
By the way, I guess it's not possible to import .NET 4.0 module into .NET 2.0 assembly?
__________________
http://youtu.be/H0QfVDebLFg |
#4
|
||||
|
||||
You can if the 4.0 module exposes what you need via COM. The 2.0 assembly can then use the object(s) via COM. A straight import is not possible though because of the .NET version mis-match though.
You can see more info on how to accomplish this here: http://www.codeproject.com/Articles/204406/How-To-Use-a-NET-Based-DLL-From-NET-Based-Appl |
The Following User Gave Reputation+1 to atom0s For This Useful Post: | ||
The Old Pirate (05-09-2015) |
#5
|
|||
|
|||
Thank you very much atom0s. Very useful.
Sorry to bother you, but I have one last problem. The app stores resources in separate .dll file. I had to remove Strong Name from the .exe, but then I noticed that it won't load strong-named .dll. Why? What am I missing here?
__________________
http://youtu.be/H0QfVDebLFg |
#6
|
||||
|
||||
These links may help some:
https://msdn.microsoft.com/en-us/library/s1sx4kfb(v=vs.100).aspx https://msdn.microsoft.com/en-us/library/xwb8f617(v=vs.110).aspx As MSDN states as well: Quote:
|
#7
|
|||
|
|||
Sounds weird to me. An exe without strong name should be able to load a dll with strong name. Anyways, strong name doesn't work as far as I know. You could just modify things and maybe hook StrongNameSignatureVerification if the program checks the strong name.
An alternative solution is to simply re-sign everything using your own strong name |
The Following User Gave Reputation+1 to mr.exodia For This Useful Post: | ||
The Old Pirate (05-11-2015) |
#8
|
|||
|
|||
I have read that paragraph, but as mr.exodia points out - the .exe has been stripped out of Strong Name, hence the question. Shouldn't it be able to load any strong-named .dll? Nonetheless, if I remove the Strong Name from resource .dll, it loads correctly then.
__________________
http://youtu.be/H0QfVDebLFg |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modifying/replacing class in .NET binary | jonwil | General Discussion | 9 | 08-22-2020 12:49 |
HexRaysAST Matcher - PoC of Modifying HexRays AST | TechLord | Source Code | 0 | 08-31-2018 15:47 |
Highly self modifying code | chants | General Discussion | 1 | 09-21-2016 17:46 |
Modifying programs to use more than one copy at a time. | Fade | General Discussion | 7 | 05-13-2006 14:12 |
Modifying resources of self-checking exe | c4p0ne | General Discussion | 8 | 09-17-2004 21:32 |