yck1509 / ConfuserEx

An open-source, free protector for .NET applications
http://yck1509.github.io/ConfuserEx/
Other
3.54k stars 1.61k forks source link

NGEN fails on obfuscated assemblies #207

Open milsnips opened 9 years ago

milsnips commented 9 years ago

NGEN command fails to run on assemblies that have been obfuscated. This is the error:

C:\WINDOWS\system32>ngen install "E:{myexecutable}.exe Microsoft (R) CLR Native Image Generator - Version 4.0.30319.33440 Copyright (c) Microsoft Corporation. All rights reserved. Failed to load dependency balaruXCNWGCGovuHcNkdMXMhgrx of assembly Myapp.Assembly1 , Version=1.0.5571.21343, Culture=neutral, PublicKeyToken=null because of the fo llowing error : The system cannot find the file specified. (Exception from HRESU LT: 0x80070002) ........ 2>Error compiling Myapp.Assembly1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=n ull: Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) 2>Ngen failed to generate native code for image Myapp.Assembly1, Version=1.0.0.0, Cul ture=neutral, PublicKeyToken=null because of the following error: Catastrophic f ailure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED)) 2>Ngen will retry compilation of image Myapp.Assembly1, Version=1.0.0.0, Culture=neut ral, PublicKeyToken=null

before running confuserEx, ngen compiles all assemblies fine.

yck1509 commented 9 years ago

Hi, ConfuserEx applies different protections, that might cause problem with external tools, including ngen. You might want to try to lower the protection levels to see whether it works.

milsnips commented 9 years ago

Technically, obfuscated code should be functionally identical to non-obfuscated code so it should work with ngen. other obfuscation libraries out there seem to be ok with running ngen on their obfuscated files. I'll try some lower (not ideal) obfuscation settings to see if it makes any difference.