Geeks With Blogs

News This is the *old* blog. The new one is at blog.sixeyed.com
Elton Stoneman
This is the *old* blog. The new one is at blog.sixeyed.com

[Source: http://geekswithblogs.net/EltonStoneman]

I was debugging a particularly nasty problem and found myself wanting to edit the manifest of a compiled .NET assembly, to change the version number of the assemblies it was referencing. Not necessarily best practice, but in this case it would enable me to confirm the exact issue without a two-hour build-and-deploy cycle. Turns out that nasty hacks like this are very straightforward:

  1. Run ILDASM, open the assembly and choose File…Dump to extract the IL
  2. Open the IL file in Visual Studio and edit the manifest – in this case, the version numbers of the referenced assemblies are easily found at the top of the file:

    // Metadata version: v2.0.50727
    .assembly extern mscorlib
    {
      .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )                         // .z\V.4..
      .ver 2:0:0:0
    }
    .assembly extern x.y.z
    {
      .publickeytoken = (E4 21 0D 54 23 66 A2 B4 )                         // . .D'f..
      .ver 1:0:9:12
    }

  3. Save the IL and reassemble it with ILASM – if the assembly was signed, re-sign it using ilasm /DLL x.y.z.il /KEY=x.y.z.snk
  4. Ensure the new assembly has the same name as the original, and it will operate as an exact replacement, only now its dependencies will be for the modified versions.

Simon McEnlly's article on CodeProject describes going further with the manifest to change the visibility of methods, and generally modifying and rebuilding assemblies where you don't have the source code. Note that if the assembly is signed and you don't have the strong name key to re-sign it, the modified assembly will warn about being tampered with and won't load.

Posted on Wednesday, March 11, 2009 5:44 PM Annoying problems , Debugging | Back to top


Comments on this post: Hacking the Assembly Manifest

# re: Hacking the Assembly Manifest
Requesting Gravatar...
I need to know h0w to wrote the codes for a missing assembly manifest
Left by Olurin Adeyinka on Jul 08, 2009 9:59 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
When it comes to loading assemblies that are strong named, there are tools to re-sign it. see my blog for the code:
http://blogs.compdj.com/post.aspx?id=7c9a67a9-e5fb-4233-9278-c5385fe76ee1
Left by Rick Ratayczak on Jul 09, 2009 7:16 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
This was a very well-written blog.I like the way you describe all the things in this post.Thanks a lot for sharing.
Left by neways-69 on Apr 28, 2010 7:56 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
I am following your blog regularly and got great information. I really like the tips you have given.Thank you so much for sharing this information. I have bookmarked this page for future use.
Left by weight-loss.78 on Apr 29, 2010 2:24 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Having written articles that require this much work, I commend you for your service to the future bloggers. I’m sure they will appreciate it! Really a great one.Thanks a lot.Keep blogging.
Left by digital scrapbook49 on May 20, 2010 6:59 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Interesting post and thanks for sharing.I like the way you describe all the things and the examples.This is exactly what I've been looking for.Thanks again.Keep blogging.
Left by platinum protection63 on May 25, 2010 4:32 AM

# Assembled code
Requesting Gravatar...
That's the problem with assembled type code, it's hard to look under the hood.
Left by Dust Collector Bag on Jun 27, 2010 12:31 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Your posts are always so interesting and informative.I was very pleased to find this site.I wanted to thank you for this great read!keep blogging.
Left by Charlotte Real Estate on Sep 18, 2010 4:59 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
A nasty hack, but it worked for you, well done.
Left by loans mortgages on Nov 16, 2010 8:38 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Assebled code is a right sod sometimes a hack is the only way.
Left by compare exchange rates on Nov 16, 2010 8:41 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Thanks vor this Posting, yor Blog ist god for my
Left by Strompreisvergleich on Dec 18, 2010 4:32 PM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Thx a lot for this code...well done
Left by BMI berechnen on Jan 10, 2011 11:39 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
I found this blog was very well written and very informative too. I have gone through it's details and got a lot of useful tips. Looking forward for more information....
Left by p90x reviews on Mar 29, 2011 6:38 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
The post is written in very a good manner and it entails many useful information for me. I am happy to find your distinguished way of writing the post.
Left by London oriental escorts on May 17, 2011 6:47 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Very impressive article, rarely do we encounter one that’s both educative and entertaining, check us out and one of us could be visiting you soon… Indian escorts London
Left by London Escorts on Jun 05, 2011 12:24 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Your a bunch of punk bitch's!!! I dare you to do your worst!
Shawn Jeffrey Weightman 
Lucerne on the lake
5877 Lake Street #14
County Road 307 Ad
Lucerne CA. 95458
DOB: 12/28/1987 
SSN: 608-05-3134
Plate# 4EEU074

I don't think a single one of you has the balls to come after me. I challenge anyone to try something. I give you my full permission to use my info and take full responsibility for the outcome. So, bring it on!!!
Left by Shawn on Feb 05, 2012 11:33 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
I must thank you a lot for this!
Left by Sanovnik on Jul 20, 2012 11:59 AM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Excellent writing! I am looking forward to hearing more from you
Left by Sanovnik on Jul 20, 2012 12:00 PM

# re: Hacking the Assembly Manifest
Requesting Gravatar...
Thank you for this wonderful article! It is extremely insightful.
Left by sedmicni horoskop on Jul 20, 2012 12:02 PM

Your comment:
 (will show your gravatar)


Copyright © Elton Stoneman | Powered by: GeeksWithBlogs.net