private void DumpMethod(MethodKey key, ObfuscatedThing info) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}(", info.Name); for (int i = 0; i < key.Count; i++) { if (i > 0) { sb.Append(","); } sb.Append(key.ParamTypes[i]); } sb.Append(")"); if (info.Status == ObfuscationStatus.Renamed) { writer.WriteStartElement("renamedMethod"); writer.WriteAttributeString("oldName", sb.ToString()); writer.WriteAttributeString("newName", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } else { writer.WriteStartElement("skippedMethod"); writer.WriteAttributeString("name", sb.ToString()); writer.WriteAttributeString("reason", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } }
private void DumpMethod(MethodKey key, ObfuscatedThing info) { writer.Write("\t{0}(", info.Name); for (int i = 0; i < key.Count; i++) { if (i > 0) { writer.Write(", "); } else { writer.Write(" "); } writer.Write(key.ParamTypes[i]); } if (info.Status == ObfuscationStatus.Renamed) { writer.WriteLine(" ) -> {0}", info.StatusText); } else { Debug.Assert(info.Status == ObfuscationStatus.Skipped, "Status is expected to be either Renamed or Skipped."); writer.WriteLine(" ) skipped: {0}", info.StatusText); } }
private void DumpMethod(int tabs, MethodKey key, ObfuscatedThing method, bool isLast) { var oldSig = $"{GetRawTypeName(key.Method.ReturnType.FullName)} {method.Name}"; if (key.Method.GenericParameters.Count > 0) { oldSig += "<"; for (var i = 0; i < key.Method.GenericParameters.Count; ++i) { oldSig += i > 0 ? ", " : ""; oldSig += GetRawTypeName(key.Method.GenericParameters[i].FullName); } oldSig += ">"; } oldSig += "("; for (var i = 0; i < key.Count; ++i) { oldSig += i > 0 ? ", " : ""; oldSig += GetRawTypeName(key.ParamTypes[i]); } oldSig += ")"; var newSig = method.StatusText; WriteLine(tabs, $"\"{oldSig}\": \"{newSig}\"{(isLast ? "" : ",")}"); }
public void AddResource(string name, ObfuscationStatus status, string text) { ObfuscatedThing r = new ObfuscatedThing(name); r.Update(status, text); Resources.Add(r); }
public void CheckClassHasAttribute() { Obfuscar.ObfuscationMap map = BuildAndObfuscateAssemblies(); string assmName = "AssemblyWithOverrides.dll"; AssemblyDefinition inAssmDef = AssemblyDefinition.ReadAssembly( Path.Combine(TestHelper.InputPath, assmName)); AssemblyDefinition outAssmDef = AssemblyDefinition.ReadAssembly( Path.Combine(TestHelper.OutputPath, assmName)); TypeDefinition classAType = inAssmDef.MainModule.GetType("TestClasses.ClassA"); MethodDefinition classAmethod2 = FindByName(classAType, "Method2"); MethodDefinition classAcompare = FindByName(classAType, "CompareTo"); TypeDefinition classBType = inAssmDef.MainModule.GetType("TestClasses.ClassB"); MethodDefinition classBmethod2 = FindByName(classBType, "Method2"); MethodDefinition classBcompare = FindByName(classBType, "CompareTo"); TypeDefinition classCType = inAssmDef.MainModule.GetType("TestClasses.ClassC"); MethodDefinition classCmethod1 = FindByName(classCType, "Method1"); TypeDefinition classDType = inAssmDef.MainModule.GetType("TestClasses.ClassD"); MethodDefinition classDmethod1 = FindByName(classDType, "Method1"); Obfuscar.ObfuscatedThing classAEntry = map.GetMethod(new Obfuscar.MethodKey(classAmethod2)); ObfuscatedThing classAEntry1 = map.GetMethod(new MethodKey(classAcompare)); Obfuscar.ObfuscatedThing classBEntry = map.GetMethod(new Obfuscar.MethodKey(classBmethod2)); Obfuscar.ObfuscatedThing classBEntry1 = map.GetMethod(new Obfuscar.MethodKey(classBcompare)); ObfuscatedThing classCEntry = map.GetMethod(new MethodKey(classCmethod1)); ObfuscatedThing classDEntry = map.GetMethod(new MethodKey(classDmethod1)); Assert.IsTrue( classAEntry.Status == Obfuscar.ObfuscationStatus.Renamed && classBEntry.Status == Obfuscar.ObfuscationStatus.Renamed, "Both methods should have been renamed."); Assert.IsTrue( classAEntry.StatusText == classBEntry.StatusText, "Both methods should have been renamed to the same thing."); Assert.IsTrue(classAEntry1.Status == ObfuscationStatus.Skipped); Assert.IsTrue(classBEntry1.Status == ObfuscationStatus.Skipped); Assert.IsTrue(classCEntry.Status == ObfuscationStatus.Renamed); Assert.IsTrue(classDEntry.Status == ObfuscationStatus.Renamed); }
private void DumpEvent(TextWriter writer, EventKey key, ObfuscatedThing info) { if (info.Status == ObfuscationStatus.Renamed) { writer.WriteLine("\t{0} {1} -> {2}", key.Type, info.Name, info.StatusText); } else { Debug.Assert(info.Status == ObfuscationStatus.Skipped, "Status is expected to be either Renamed or Skipped."); writer.WriteLine("\t{0} {1} skipped: {2}", key.Type, info.Name, info.StatusText); } }
public ObfuscatedThing GetEvent(EventKey key) { ObfuscatedClass c = GetClass(key.TypeKey); ObfuscatedThing t; if (!c.Events.TryGetValue(key, out t)) { t = new ObfuscatedThing(key.ToString()); c.Events[key] = t; } return(t); }
public ObfuscatedThing GetMethod(MethodKey key) { ObfuscatedClass c = GetClass(key.TypeKey); ObfuscatedThing t; if (!c.Methods.TryGetValue(key, out t)) { t = new ObfuscatedThing(key.ToString()); c.Methods[key] = t; } return(t); }
public ObfuscatedThing GetProperty(PropertyKey key) { ObfuscatedClass c = GetClass(key.TypeKey); ObfuscatedThing t; if (!c.Properties.TryGetValue(key, out t)) { t = new ObfuscatedThing(key.ToString()); c.Properties[key] = t; } return(t); }
private void DumpEvent(XmlWriter writer, EventKey key, ObfuscatedThing info) { if (info.Status == ObfuscationStatus.Renamed) { writer.WriteStartElement("renamedEvent"); writer.WriteAttributeString("oldName", info.Name); writer.WriteAttributeString("newName", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } else { writer.WriteStartElement("skippedEvent"); writer.WriteAttributeString("name", info.Name); writer.WriteAttributeString("reason", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } }
public void UpdateProperty(PropertyKey key, ObfuscationStatus status, string text) { ObfuscatedThing m = GetProperty(key); m.Update(status, text); }
public void UpdateMethod(MethodKey key, ObfuscationStatus status, string text) { ObfuscatedThing m = GetMethod(key); m.Update(status, text); }
public void UpdateField(FieldKey key, ObfuscationStatus status, string text) { ObfuscatedThing f = GetField(key); f.Update(status, text); }
public ObfuscatedThing GetProperty(PropertyKey key) { ObfuscatedClass c = GetClass(key.TypeKey); ObfuscatedThing t; if (!c.Properties.TryGetValue(key, out t)) { t = new ObfuscatedThing(key.ToString()); c.Properties[key] = t; } return t; }
private void DumpProperty(int tabs, PropertyKey key, ObfuscatedThing property, bool isLast) { WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{property.StatusText}\"{(isLast ? "" : ",")}"); }
private void DumpMethod( MethodKey key, ObfuscatedThing info ) { StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0}(", info.Name ); for ( int i = 0; i < key.Count; i++ ) { if ( i > 0 ) sb.Append( "," ); sb.Append(key.ParamTypes[i]); } sb.Append(")"); if (info.Status == ObfuscationStatus.Renamed) { writer.WriteStartElement("renamedMethod"); writer.WriteAttributeString("oldName", sb.ToString()); writer.WriteAttributeString("newName", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } else { writer.WriteStartElement("skippedMethod"); writer.WriteAttributeString("name", sb.ToString()); writer.WriteAttributeString("reason", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } }
private void DumpField(int tabs, FieldKey key, ObfuscatedThing field, bool isLast) { WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{field.StatusText}\"{(isLast ? "" : ",")}"); }
private void DumpMethod( MethodKey key, ObfuscatedThing info ) { writer.Write( "\t{0}(", info.Name ); for ( int i = 0; i < key.Count; i++ ) { if ( i > 0 ) writer.Write( ", " ); else writer.Write( " " ); writer.Write( key.ParamTypes[i] ); } if ( info.Status == ObfuscationStatus.Renamed ) writer.WriteLine( " ) -> {0}", info.StatusText ); else { Debug.Assert( info.Status == ObfuscationStatus.Skipped, "Status is expected to be either Renamed or Skipped." ); writer.WriteLine( " ) skipped: {0}", info.StatusText ); } }
public void AddResource(string name, ObfuscationStatus status, string text) { ObfuscatedThing r = new ObfuscatedThing(name); r.Update(status, text); resources.Add(r); }
public ObfuscatedThing GetEvent(EventKey key) { ObfuscatedClass c = GetClass(key.TypeKey); ObfuscatedThing t; if (!c.Events.TryGetValue(key, out t)) { t = new ObfuscatedThing(key.ToString()); c.Events[key] = t; } return t; }
public void UpdateEvent(EventKey key, ObfuscationStatus status, string text) { ObfuscatedThing m = GetEvent(key); m.Update(status, text); }
private void DumpEvent(int tabs, EventKey key, ObfuscatedThing @event, bool isLast) { WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{@event.StatusText}\"{(isLast ? "" : ",")}"); }
private void DumpProperty( XmlWriter writer, PropertyKey key, ObfuscatedThing info ) { if (info.Status == ObfuscationStatus.Renamed) { writer.WriteStartElement("renamedProperty"); writer.WriteAttributeString("oldName", info.Name); writer.WriteAttributeString("newName", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } else { writer.WriteStartElement("skippedProperty"); writer.WriteAttributeString("name", info.Name); writer.WriteAttributeString("reason", info.StatusText); writer.WriteEndElement(); writer.WriteString("\r\n"); } }
private void DumpProperty( TextWriter writer, PropertyKey key, ObfuscatedThing info ) { if ( info.Status == ObfuscationStatus.Renamed ) writer.WriteLine( "\t{0} {1} -> {2}", key.Type, info.Name, info.StatusText ); else { Debug.Assert( info.Status == ObfuscationStatus.Skipped, "Status is expected to be either Renamed or Skipped." ); writer.WriteLine( "\t{0} {1} skipped: {2}", key.Type, info.Name, info.StatusText ); } }
public ObfuscatedThing GetMethod(MethodKey key) { ObfuscatedClass c = GetClass(key.TypeKey); ObfuscatedThing t; if (!c.Methods.TryGetValue(key, out t)) { t = new ObfuscatedThing(key.ToString()); c.Methods[key] = t; } return t; }