yck1509 / ConfuserEx

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

ConfuserEx crashes when XAML uses Binding to SystemParameters.WorkArea #113

Closed aKzenT closed 9 years ago

aKzenT commented 9 years ago

The following XAML snippet currently crashes ConfuserEx:

<Label Content="{Binding Source={x:Static SystemParameters.WorkArea},Path=Height}" />

The Stack-Trace is as following:

Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at Confuser.Renamer.BAML.KnownThingsv4.<get_Properties>b__1(KnownProperties property) in e:\Source\Public\Confuser2\Confuser.Renamer\BAML\KnownThingsv4.cs:line 31
   at Confuser.Renamer.BAML.BAMLAnalyzer.ResolveAttribute(UInt16 attrId) in e:\Source\Public\Confuser2\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 198
   at Confuser.Renamer.BAML.BAMLAnalyzer.ProcessElementBody(BamlElement root, BamlElement elem) in e:\Source\Public\Confuser2\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 365
   at Confuser.Renamer.BAML.BAMLAnalyzer.Analyze(ModuleDefMD module, String bamlName, Byte[] data) in e:\Source\Public\Confuser2\Confuser.Renamer\BAML\BAMLAnalyzer.cs:line 77
   at Confuser.Renamer.Analyzers.WPFAnalyzer.AnalyzeResources(ConfuserContext context, INameService service, ModuleDefMD module) in e:\Source\Public\Confuser2\Confuser.Renamer\Analyzers\WPFAnalyzer.cs:line 234
   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 76
   at Confuser.Renamer.AnalyzePhase.Execute(ConfuserContext context, ProtectionParameters parameters) in e:\Source\Public\Confuser2\Confuser.Renamer\AnalyzePhase.cs:line 54
   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 141
   at Confuser.Core.ConfuserEngine.RunPipeline(ProtectionPipeline pipeline, ConfuserContext context) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 208
   at Confuser.Core.ConfuserEngine.RunInternal(ConfuserParameters parameters, CancellationToken token) in e:\Source\Public\Confuser2\Confuser.Core\ConfuserEngine.cs:line 162
Failed at 22:02, 0:00 elapsed.

The problem seems to be that Confuser is looking for a KnownProperties element with value 401, which does not exist.

aKzenT commented 9 years ago

I believe this is a general problem for attribute Ids between 233 and 463. These are not "Known properties" in BAML, but "System resource keys".

yck1509 commented 9 years ago

Should be fixed by f267bb94b67dbba56fe6c03bbd19c7e33140b63d.