|
|
Comments and Discussions
|
|
 |

|
Tnx Andrea,
Please keep it coming,
Splendid piece
|
|
|
|

|
Hi there!
very nice tool
any chances to add support for 64 bit .NET PE files?
would be really cool in a light of Win7, Win8, upcoming Win9 64 bit OSes!
thanks in advance
P.S. looks like the issue is inside old good library
Asmex.FileViewer.ModHeaders
.//
good luck!
|
|
|
|

|
Really good question! I'll have a look and report you back.
Maybe you debugged it yet? Do you want to collaborate to a patch?
|
|
|
|

|
Hi!
wow, I was not expecting any response as usually people like you are quite busy!
so, 1st of all, many thanks!
2ndly, yes, you have a good feeling of matter, I've already debuggged it, understoond the root reason (its obvious - PE32+ has a bit different format (eg QWord for some fields instead of DWord size)
I've made a small fix and it helped me to (wow) patch 64 bit .NET assemblies!
3) I've one more idea that will bring your tool to #1, lets discuss it afterwards
Alex.
good luck!
|
|
|
|

|
New version 2.3 is online, supporting PE+ files! Thank you Alex for spotting this out and providing a patch! Happy debugging!
|
|
|
|

|
Why not just use ILDASM to dump the IL, make the changes, then use ILASM to compile with the strong name key. It's very simple. I assume the company still has the SN key.
Relativity
|
|
|
|

|
good way only if your assembly is not protected/obfuscated!
in nowadays pure assembly is a rare thing
good luck!
|
|
|
|

|
Yes, but you said "He opens the executable and tries to find out the typos - he gets them and he fixes them, at least the worst ones, where the customer name is incorrect (yes, he can only overwrite existing bytes, but consider this enough for this scenario)...."
-Clearly in your scenario the assembly is not obfuscated
-Are the string's obfuscated too? Probably not.
-You can do the same thing with the solution I proposed.
Relativity
|
|
|
|
|

|
Is it possible to remove a reference to public key token inside .baml resource embedded into assembly?
it's simple to remove the outer .dll level pubkeytoken, but reosource one......
any ideas?
good luck!
|
|
|
|

|
I removed Strong-Names from a DLL within a program using this tool, and it does not run anymore; it crashes on startup. When I click Debug I get "A strongly-named assembly is required". I tried also patching the main executable but the result is the same. I even tried ticking all the assembly names and "Patching references" on both files (DLL and executable). Should I do it on _ALL_ the DLLs of the program? Is there a way to find the offending file?
|
|
|
|

|
Cant reflexil in reflector addin do this
|
|
|
|
|

|
Hi,
I had to change a .NET .dll to have 32-bit flags so it could run on 32-bit instance of Amazon EC2. Nothing would work until I used your utility to switch off signing. Awesome utility - thanks!
|
|
|
|

|
Is it possible to sign to an assembly that was compiled without strong name or replace a sign of an assembly that was signed using the same approach?
|
|
|
|

|
Hi Vasili,
please, take a look at previously posted questions under this article (on 2nd comments page). This question has already been asked, but has not a quick answer, it all depends on what kind of assembly you're working on. .NET Framework SN tool can sign and resign an existing DLL, but that one should not use particular programming tricks (like Reflection). Decompiling and reassembling thru ILDasm/ILAsm can be another try, but those are unsupported. You can also have a look at Mono Cecil project.
Hope this helps!
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
Oh, sorry, I missed the second page Thanks a lot
|
|
|
|

|
System.DivideByZeroException was unhandled
Message=Attempted to divide by zero.
Source=StrongNameRemove
StackTrace:
at vu.ch.argee.WindowsAPI.WrapperClasses.ManagedFileMappingAdaptor.GetAllocationGranularityOffset(UInt64& value) in D:\Chrome\StrongNameRemove21_src\vu.ch.argee.MemoryMapping\ManagedFileMappingAdaptor.cs:line 326
at vu.ch.argee.MemoryMapping.FileMappingView.Initialize(IntPtr fileMappingObjectHandle, MappingAccess viewAccess, UInt64 fileOffset, UInt32 numberOfBytesToMap) in D:\Chrome\StrongNameRemove21_src\vu.ch.argee.MemoryMapping\FileMappingView.cs:line 147
at vu.ch.argee.MemoryMapping.FileMappingView..ctor(FileMapping fileMapping) in D:\Chrome\StrongNameRemove21_src\vu.ch.argee.MemoryMapping\FileMappingView.cs:line 46
at StrongNameRemove.Utility.PatchAssemblyStrongSigning(String fileName, UInt32 cliHeaderFlag, Int64 cliHeaderFlagOffset, Int64 strongNameSignatureOffset, Int64 publicKeyIndexOffset, UInt32 assemblyFlag, Int64 assemblyFlagOffset, Int32 blobIndexSize) in D:\Chrome\StrongNameRemove21_src\Utility.cs:line 329
at StrongNameRemove.MainForm.btnPatch_Click(Object sender, EventArgs e) in D:\Chrome\StrongNameRemove21_src\MainForm.cs:line 241
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at StrongNameRemove.Program.Main(String[] args) in D:\Chrome\StrongNameRemove21_src\Program.cs:line 23
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
|
|
|
|

|
Thank you giammin for reporting this crash. This is related to MMF code. I've submitted a new version of application (2.2) and code to CodeProject. Just wait until they publish and approve it. Thank you for your patience and time.
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
thank you for your quick reply!
let me know if you need more info about
|
|
|
|

|
Just a heads up - ran on Win 7 x64, got a failure, copied program and target files to 32bit xp virtual box and it ran fine. Thanks.
|
|
|
|

|
I encountered the same issue. Changing the platform target to x86 allows it to run on Windows 7 x64 without crashing.
|
|
|
|

|
This crash is related to MMF library. Completely removed in version 2.2.
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
Hi,
- We have application common.dll using Nhibernate 1.0.2 that uses log4net.dll version 1.2.9.
- We also use xxx.dll that MUST use log4net.dll version of 1.2.10.
At the moment we can't used xxx.dll in the aplication while it would mean we have to use two log4net.dlls.
We try to remove signed dll with your application doing next, while we try to insert log4net.dll v 1.2.10 into our application and trick nhiberante.
1. Remove strong naming from log4net.ddl v.1.2.10
2. We used for nhibernate.dll to point to unsigned assembly log4net v 1.2.10
But the Nhibernate discard to load log4net v 1.2.10.
"[System.IO.FileLoadException] {"Could not load file or assembly
'log4net, Version=1.2.9.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)":"log4net, Version=1.2.9.0, Culture=neutral,
PublicKeyToken=null"} System.IO.FileLoadException"
Can it be that also version of referenced dll is checked.
Thank you for your help.
Regards,
Dusan
|
|
|
|

|
This one seems a little challenge. I really don't see how removing strong naming can help with your problem. Even if you could reference log4net 1.2.10 from nHibernate, xxx.dll should be patched too, because it would try to load a signed log4net dll. Moreover, removing strong signing from log4net 1.2.10, doesn't mean nHibernate can load it, even if patched, because it would look at another version (previous 1.2.9) - this can be patched too, but probably something wouldn't work at runtime, because subtle differences in log4net implementation.
At last, I would try another approach: keep your application ad xxx.dll as they are. Start from nHibernate source code (same version you are working on or a recent one) and modify that, removing references to log4net 1.2.9 and adding 1.2.10. If nHibernate can compile without problems, you would get an nHibernate custom version using log4net 1.2.10, but also signed. If it can't compile anymore, you should try to understand how to upgrade it to new log4net methods (I'm not using log4net, so don't know how it changed from 1.2.9 to 1.2.10). Maybe you can also ask some help from nHibernate community and request them to bind to new log4net version.
My general idea is to avoid byte patching if using open source code projects (and you are lucky enough to use them).
Hope this helps!
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
Hi,
Thank you for very quick response. We have try to solve this as you proposed, but the compilation of NHibernate goes Ok, but in runtime we got problems, not with log4net but with nhibernate!
We still investigate this problem ...
Thanks once more for help...
|
|
|
|

|
Imagine there are three assemblies. Assembly A, assembly B and assembly C. Assembly C is referenced by assembly B and assembly B is referenced by assembly A. All assemblies are signed. If you unsign assembly B, your utility offers to unsign assembly C too by clicking on button "Patch references". But! If you want assembly B to work, you must patch the reference to it in assembly A too. And that is something your utility cannot do. At least programaticaly. Now I must find all assemblies referencing assembly B and patch them manually (or using your utility).
|
|
|
|

|
That is an intended problem and not so easy to solve. It's easy to know what assemplies are referenced by a DLL, but it's not immediate to know who is using current DLL (it could require scanning all DLL/EXE in a folder of perhaps complete disk). This could surely be done, but it's far away from my proof of concept tool.
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
Hi!
I found two small bugs, which I fixed locally:
1) If the selected file's path contains spaces, upon restarting elevated, the path is considered as several arguments.
Fix: In VistaSecurity.cs, method RestartElevated(string arguments):
startInfo.Arguments = string.Format("\"{0}\"", arguments);
2) In non-English Windows installations, the name of the administrator role can be different.
Fix: In VistaSecurity.cs, method IsAdmin():
return p.IsInRole(WindowsBuiltInRole.Administrator);
|
|
|
|

|
Thank you for spotting those out!
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|
|

|
The article is great, but the application didn't work with me.
Any way, I've managed to patch the exe file manually. And I have this error on running the exe
"Could not load file or assembly 'Name, Version=1.0.869.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"
Also, I've altered its PublicKeyOrToken in the assembly ref of the exe to be null, as I edited this dll.
Got any clue what I've done wrong or what's missing ?!!
Familiarity sometimes keeps us from seeing the obvious.
|
|
|
|

|
This is normal exception from CLR when something is not correctly patched. Maybe it's another DLL reference or some DLL loading by reflection. You could send me an example by e-mail of what you are doing and I'll try to understand why my application is not working for you.
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
When I try to remove strong signing from assemblies that make use of the InternalsVisibleTo attribute in their AssemblyInfo I end up getting FieldAccessExceptions. I'm guessing that since InternalsVisibleTo can't find the strong named dll it doesn't grant access to any internal fields. Is there any way around this?
By the way, thanks for the fantastic article.
|
|
|
|

|
As far as I know there could be a way to deal with this situation too. It requires patching and registering assembly for verification skipping. Maybe you can mail me your code and DLL and we can have a look at them.
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
Hi,
How Remove the CLI header ?
To protect my source code
I need your help.
Thanks,
Luciano - From Brazil
|
|
|
|

|
Removing a CLI header from a .NET executable means that is not a .NET program anymore. This could be achieved building a Win32 wrapper outside your executable (a stub), which loads file from disk, decrypt in memory and starts .NET application at last. This scheme is used by some commercial applications protectors and encrypters, but I personally don't like mixing Win32 techniques with .NET (and this kind of protection was already defeated too). A good .NET protection should not rely on Win32.
Causing an automatic reboot is a feature for a program, not a bug.
|
|
|
|

|
Thanks a lot for this well written informative article!
|
|
|
|

|
Because of the vistasecurity.isadmin check it won't work on my dutch XP SP2. I changed the following lines in the source:
if (VistaSecurity.IsAdmin())
to
if (VistaSecurity.IsAdmin() | VistaSecurity.IsVistaOrHigher())
so it will work on my version of windows.
Thanks for this nice software
|
|
|
|

|
I had a look at it. It seems a problem when using it in Windows XP SP2 and not being an admin. Anyway, proposed solution is not working for me. IsVistaOrHigher method in VistaSecurity class, incorrectly reports a Vista system even on Windows XP. So I also changed that method to return Environment.OSVersion.Version.Major >= 6;
Thanks for spotting this out!
|
|
|
|

|
Now is working for me - thank you for this FANTASTIC program !!!!
|
|
|
|

|
Hi!
Please, check it. Now VistaSecurity contains:
internal static bool IsVistaOrHigher() {
return Environment.OSVersion.Version.Major < 6;
}
Also code p.IsInRole(@"BUILTIN\Administrators") not valid for localized versions of Windows.
Thanks!
modified on Saturday, October 25, 2008 10:25 AM
|
|
|
|
|

|
Thanks.
Finally... We have the very needed complimentary software for this.
Remove VS Add Strong Name.
I like you, and I love programming more. in C# & Java
|
|
|
|

|
Nice tool but I havent managed to test it successfully
C:\Program Files\Test>signer -k test.snk -outdir .\build -a test.dll -debug
Strong naming .\test.dll ...
An error occured while processing file .\test.dll: The assem
bly name was null or empty for type ##, parsed line: + "ib, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b77a"
|
|
|
|

|
Hi Verty,
I will have a look into this issue. It looks like the IL parser needs to become more robust when dealing with very long type names which are split into several lines.
Yours,
Alois Kraus
|
|
|
|

|
Hi,
this error should go away if you download the latest source release and patch with it the version 1.0 to get rid of this error. I am currently working on a solution to represent the contents of an IL file as an object model for the most important parts. This new parser which will fix this error once and for all along with many more benefits.
Yours,
Alois
|
|
|
|

|
Thanks
|
|
|
|

|
hey cool!
I might finally able to use string name now!
(I have unsigned 3rd parties...)
|
|
|
|

|
You could just use ILMerge (http://research.microsoft.com/~mbarnett/ILMerge.aspx) to do this:
ilmerge Original.dll /keyfile:KeyFile.snk /out:Signed.dll
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
This article describes how to remove Strong Signing from .NET assemblies without recompiling code.
| Type | Article |
| Licence | CPOL |
| First Posted | 28 Aug 2006 |
| Views | 117,833 |
| Downloads | 3,748 |
| Bookmarked | 161 times |
|
|