Comments
4 comments
-
What you want to do, you can't currently do with Reflector ... unless someone out there has an addin that I don't know about.
There are a few things you can change the names of, but without doing a decompile and recompile you are going to limited.
A .Net assembly file keeps all of its names stored in a byte array and each item is accessed by and index where the first thing is the length of the string (encoded) ... so if you change the length of any of the strings in the user strings byte array you'll have problems ... otherwise for simple changes you can use any hex editor ... but by simple I mean pretty simple like changing "hello world" to "12345678901".
The names of types and other non user strings (like function names, namespaces, etc.) are stored in the strings heap. The strings heap is pretty much the same as the user strings - but one HUGE problem you'll run into is .Net loads things by their full name ... which it uses these strings to load/resolve the types JIT. So if you reference System.String and happen to change the string System to Ystsme (or something) you'll break pretty much all strings.
The only way I know is to find something that will let you edit things and then create a new version of the assembly for you. You might look into Mono's Cecil libraries (http://www.mono-project.com/Cecil).
If you find anything that works for you, I'd be interested to know how it goes. -
Also I think certain other issues might arise should the given library be encrypted with a strong name. Changes to the assembly name can cause the entire assembly to fail to load, such is the benefit of a library using a strong name. Granted that's under the assumption a strong name is used.
If not, you're really limited to small changes. I'm not entirely sure on how the PEHeader and CLR header work, but I think some of them work by using position notifiers to point to data. If the data length is shifted (ie. you change the length of a string, shifting all bytes left or right depending on whether you deleted or inserted data), and the numbers aren't updated, the assembly can be viewed as corrupted. Someone with more knowledge of the headers might be able to shed some light on this.
Also I'm curious as to the reason you'd want to alter the actual target name in the first place. I can't really see a viable reason to do so other than re-branding. Perhaps more information as to why you want to change it would be pertinent, as a different path might actually be more viable for reaching your end goal. -
There is a possibility to change the assembly name:
Compile a new (empty) assembly with the target name and the informal assembly attributes (company, product, copyright etc.)
Use ILMerge.exe (a freely available tool from Microsoft) to merge the two assemblies. Watch out that you specify your newly created assembly first to make it the main one.
What you get is a new assembly with the new name and the old content.
Hope that helps.
Chris -
Change the Namespace of an Assembly
1. Start Visual Studio .NET 2003, and then open your Office project.
2. On the View menu, click Solution Explorer.
3. In Solution Explorer, right-click your project, and then click Properties.
4. In the Common Properties list, click General.
5. Type the new namespace for your assembly in the Root Namespace box, and then click OK.
6. Locate the Assembly: System.Component Model.Description Attribute attribute in your This Workbook code module or in your This Document code module.
This is the Office Integration attribute.
7. Modify the Office Integration attribute to reflect the new namespace.
8.On the Build menu, click Build Solution.
Add comment
Please sign in to leave a comment.
Is there a way that I can do this in Reflector or any other tool ?
Thank you all in advance.