yck1509 / ConfuserEx

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

ResourceManager.GetString doesn't work after obfuscation #345

Open User199011 opened 9 years ago

User199011 commented 9 years ago

Hello,

I have downloaded the last version of ConfuserEx and tried to obfuscate my project. Everything seems to work fine until I try to change the language of my application :

            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("fr");
            System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr");

I have a generated resourceManager for languages and I checked its System.Globalization.CultureInfo resourceCulture variable is set to "French".

However the following line always returns the english version once confuserEx has protected my exe : internal static string MY_TEXT{ get { MessageBox.Show(resourceCulture.EnglishName); return ResourceManager.GetString("KEY", resourceCulture); } }

I have the following configuration for my project : and

(I didn't manage to paste code, you may have to check the source of the post to see the properties)

What is the problem ?

Thank you

yck1509 commented 9 years ago

Hi, I can't reproduce the issue here. Are you using satellite assemblies?

User199011 commented 9 years ago

Yes I set the ResourceManager variable in a custom assembly. which is linked in my main project references.

private static System.Resources.ResourceManager _rm = null; public static System.Resources.ResourceManager RM { get { return _rm; } set { _rm = value; } }

public static string GetStringFromResources(string key) { try { if (_rm != null) { string retour = _rm.GetString(key, CurrentCulture); if (retour != null) return retour; else return ""; } else return ""; } catch { return ""; } }

So in my main project I do: MyAssembly.RM = TextsProject.ResourceManager; where TextsProject is the class generated by VS for each language (I have TextsProject.resx associated with TextsProject.Designer.cs, TextsProject.fr.resx ...)

I tried to put a MessageBox in the resourceManager designer (generated file), and resourceCulture was correctly set to French.

User199011 commented 9 years ago

Are you able to reproduce it ? Maybe you can give me an hint on how to avoid this behavior and still be able to user both resource Manager and ConfuserEx :)

My main project (not the assembly) had the preset maximum, I had to remove "rename" in the rules to make the resourceManager work again.

yck1509 commented 9 years ago

Hi, Did you use any packers? Do you have satellite assemblies under the language folder? (e.g. If you app is in /App/App.exe, you have a dll at /App/fr/App.resources.dll)

sarpaykent commented 8 years ago

I confirm this. (I have files like App/fr/App.resources.dll)

yck1509 commented 8 years ago

If you have satellite assemblies, you'll need to include them in ConfuserEx to protect it correctly.

sarpaykent commented 8 years ago

@yck1509 yeah it works sorry :)

ahmedosama007 commented 8 years ago

@yck1509 When I try to add satellite assemblies to ConfuserEx I get the following error:

[ERROR] Failed to resolve a type, check if all dependencies are present in the correct version.
Exception: dnlib.DotNet.TypeResolveException: Could not find type: GameFire.Resources
   at dnlib.DotNet.Extensions.FindReflectionThrow(ITypeDefFinder self, String fullName) in E:\Source\Public\Confuser2\dnlib\src\DotNet\ITypeDefFinder.cs:line 105
   at Confuser.Renamer.Analyzers.ResourceAnalyzer.Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) in e:\Source\Public\Confuser2\Confuser.Renamer\Analyzers\ResourceAnalyzer.cs:line 33
   at Confuser.Renamer.AnalyzePhase.Analyze(NameService service, ConfuserContext context, ProtectionParameters parameters, IDnlibDef def, Boolean runAnalyzer) in e:\Source\Public\Confuser2\Confuser.Renamer\AnalyzePhase.cs:line 133
   at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) in e:\Source\Public\Confuser2\Confuser.Renamer\AnalyzePhase.cs:line 55
   at Confuser.Core.ProtectionPipeline.ExecuteStage(PipelineStage stage, Action`1 func, Func`1 targets, ConfuserContext context) in e:\Source\Public\Confuser2\Confuser.Core\ProtectionPipeline.cs:line 138
   at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 219
   at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 173
12gods commented 7 years ago

User199011 Have you find solution about your problem with resource files?