コード例 #1
0
        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");
            }
        }
コード例 #2
0
ファイル: MapWriter.cs プロジェクト: ossecsoft/obfuscar
        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);
            }
        }
コード例 #3
0
ファイル: MapWriter.cs プロジェクト: inspoy/obfuscar
        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 ? "" : ",")}");
        }
コード例 #4
0
        public void AddResource(string name, ObfuscationStatus status, string text)
        {
            ObfuscatedThing r = new ObfuscatedThing(name);

            r.Update(status, text);

            Resources.Add(r);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: MapWriter.cs プロジェクト: ossecsoft/obfuscar
        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);
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 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");
     }
 }
コード例 #11
0
        public void UpdateProperty(PropertyKey key, ObfuscationStatus status, string text)
        {
            ObfuscatedThing m = GetProperty(key);

            m.Update(status, text);
        }
コード例 #12
0
        public void UpdateMethod(MethodKey key, ObfuscationStatus status, string text)
        {
            ObfuscatedThing m = GetMethod(key);

            m.Update(status, text);
        }
コード例 #13
0
        public void UpdateField(FieldKey key, ObfuscationStatus status, string text)
        {
            ObfuscatedThing f = GetField(key);

            f.Update(status, text);
        }
コード例 #14
0
ファイル: ObfuscationMap.cs プロジェクト: tkmedt/obfuscar
		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;
		}
コード例 #15
0
ファイル: MapWriter.cs プロジェクト: inspoy/obfuscar
 private void DumpProperty(int tabs, PropertyKey key, ObfuscatedThing property, bool isLast)
 {
     WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{property.StatusText}\"{(isLast ? "" : ",")}");
 }
コード例 #16
0
ファイル: MapWriter.cs プロジェクト: chinshou/Obfuscar
        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");
            }
        }
コード例 #17
0
ファイル: MapWriter.cs プロジェクト: inspoy/obfuscar
 private void DumpField(int tabs, FieldKey key, ObfuscatedThing field, bool isLast)
 {
     WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{field.StatusText}\"{(isLast ? "" : ",")}");
 }
コード例 #18
0
ファイル: MapWriter.cs プロジェクト: chinshou/Obfuscar
        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 );
            }
        }
コード例 #19
0
ファイル: ObfuscationMap.cs プロジェクト: tkmedt/obfuscar
		public void AddResource(string name, ObfuscationStatus status, string text)
		{
			ObfuscatedThing r = new ObfuscatedThing(name);

			r.Update(status, text);

			resources.Add(r);
		}
コード例 #20
0
ファイル: ObfuscationMap.cs プロジェクト: tkmedt/obfuscar
		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;
		}
コード例 #21
0
        public void UpdateEvent(EventKey key, ObfuscationStatus status, string text)
        {
            ObfuscatedThing m = GetEvent(key);

            m.Update(status, text);
        }
コード例 #22
0
ファイル: MapWriter.cs プロジェクト: inspoy/obfuscar
 private void DumpEvent(int tabs, EventKey key, ObfuscatedThing @event, bool isLast)
 {
     WriteLine(tabs, $"\"{GetRawTypeName(key.TypeKey)} {key.Name}\": \"{@event.StatusText}\"{(isLast ? "" : ",")}");
 }
コード例 #23
0
ファイル: MapWriter.cs プロジェクト: chinshou/Obfuscar
 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");
     }
 }
コード例 #24
0
ファイル: MapWriter.cs プロジェクト: chinshou/Obfuscar
        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 );
            }
        }
コード例 #25
0
ファイル: ObfuscationMap.cs プロジェクト: tkmedt/obfuscar
		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;
		}