Browse Source

fix #206 - BAML decompiler - NotImplementedException: StaticResourceStart

pull/462/head
Siegfried Pammer 12 years ago
parent
commit
ee5ddb7695
  1. 5
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KeyMapping.cs
  2. 3
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs
  3. 20
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

5
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KeyMapping.cs

@ -14,8 +14,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -14,8 +14,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
get { return staticResources; }
}
public bool HasStaticResources {
get { return staticResources != null && staticResources.Count > 0; }
public bool HasStaticResource(int identifier)
{
return staticResources != null && staticResources.Count > identifier;
}
public string KeyString { get; set; }

3
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs

@ -1175,6 +1175,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1175,6 +1175,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
KnownResourceTable.Add(0xda, new ResourceName("InternalSystemParametersEnd"));
KnownResourceTable.Add(0x5e, new ResourceName("InternalSystemParametersStart"));
KnownResourceTable.Add(0xe8, new ResourceName("InternalSystemThemeStylesEnd"));
KnownResourceTable.Add(0xe9, new ResourceName("InternalSystemColorsExtendedStart"));
KnownResourceTable.Add(0xea, new ResourceName("InactiveSelectionHighlightBrush"));
KnownResourceTable.Add(0xeb, new ResourceName("InactiveSelectionHighlightTextBrush"));
KnownResourceTable.Add(0xd6, new ResourceName("InternalSystemThemeStylesStart"));
KnownResourceTable.Add(0x95, new ResourceName("SystemParameters.IsImmEnabled"));
KnownResourceTable.Add(150, new ResourceName("SystemParameters.IsMediaCenter"));

20
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

@ -682,13 +682,21 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -682,13 +682,21 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
return declaration;
} else {
identifier = (short)-identifier;
bool isNotKey = (identifier > 0xe8);
if (isNotKey)
identifier = (short)(identifier - 0xe8);
bool isKey = true;
if (identifier > 0xe8 && identifier < 0x1d0) {
isKey = false;
identifier -= 0xe8;
} else if (identifier > 0x1d0 && identifier < 0x1d3) {
identifier -= 0xe7;
} else if (identifier > 0x1d3 && identifier < 0x1d6) {
identifier -= 0xea;
isKey = false;
}
ResourceName resource;
if (!KnownInfo.KnownResourceTable.TryGetValue(identifier, out resource))
// resource = new ResourceName("???Resource" + identifier + "???");
throw new ArgumentException("Cannot find resource name " + identifier);
if (!isNotKey)
if (isKey)
return new ResourceName(resource.Name + "Key");
return resource;
}
@ -1554,7 +1562,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1554,7 +1562,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
object GetStaticResource(short identifier)
{
int keyIndex = Math.Max(0, currentKey - 1);
while (keyIndex >= 0 && !keys[keyIndex].HasStaticResources)
while (keyIndex > keys.Count)
keyIndex--;
while (keyIndex >= 0 && !keys[keyIndex].HasStaticResource(identifier))
keyIndex--;
if (keyIndex >= 0 && identifier < keys[keyIndex].StaticResources.Count)
return keys[keyIndex].StaticResources[(int)identifier];

Loading…
Cancel
Save