From 139e72b533f175222d9bc75aa61052b3924b2da9 Mon Sep 17 00:00:00 2001 From: Sam Harwood Date: Sun, 22 Jul 2018 14:58:10 +0200 Subject: [PATCH] #5 https://github.com/XenocodeRCE/neo-ConfuserEx/issues/5 --- .vs/Confuser2/DesignTimeBuild/.dtbcache | Bin 1428 -> 1560 bytes .../TypeScrambler/Scrambler/ScannedItem.cs | 13 ++++- Confuser.Runtime/Compressor.cs | 5 +- Confuser2.sln | 6 ++ UnitTest/App.config | 6 ++ UnitTest/GenericTest.cs | 13 +++++ UnitTest/Program.cs | 17 ++++++ UnitTest/Properties/AssemblyInfo.cs | 36 ++++++++++++ UnitTest/UnitTest.csproj | 53 ++++++++++++++++++ 9 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 UnitTest/App.config create mode 100644 UnitTest/GenericTest.cs create mode 100644 UnitTest/Program.cs create mode 100644 UnitTest/Properties/AssemblyInfo.cs create mode 100644 UnitTest/UnitTest.csproj diff --git a/.vs/Confuser2/DesignTimeBuild/.dtbcache b/.vs/Confuser2/DesignTimeBuild/.dtbcache index f88b8d8b93c8d5c890c756981ad9d551c71dcf78..b289e7207d3ef088f6b9142d3307e13535252656 100644 GIT binary patch delta 28 icmbQjJ%eY%7Zyg_i3bz8lNiz&Vi-~wfb`_MEZYHz=m}*2 delta 11 ScmbQiGlhG@7naEttP21ekp!Fo diff --git a/Confuser.Protections/TypeScrambler/Scrambler/ScannedItem.cs b/Confuser.Protections/TypeScrambler/Scrambler/ScannedItem.cs index 6fd72cf9b..c1cd2544d 100644 --- a/Confuser.Protections/TypeScrambler/Scrambler/ScannedItem.cs +++ b/Confuser.Protections/TypeScrambler/Scrambler/ScannedItem.cs @@ -29,14 +29,23 @@ public bool RegisterGeneric(TypeSig t) { public GenericMVar GetGeneric(TypeSig t) { GenericParam gp = null; - if(Generics.TryGetValue(t.ScopeType.MDToken.Raw, out gp)) { + + if (t.ContainsGenericParameter) return null; + if(t.ScopeType == null) return null; + + if (Generics.TryGetValue(t.ScopeType.MDToken.Raw, out gp)) + { return new GenericMVar(gp.Number); - } else { + } + else + { return null; } + } public TypeSig ConvertToGenericIfAvalible(TypeSig t) { + TypeSig newSig = GetGeneric(t); if(newSig != null && t.IsSingleOrMultiDimensionalArray) { var tarr = t as SZArraySig; diff --git a/Confuser.Runtime/Compressor.cs b/Confuser.Runtime/Compressor.cs index e654442cd..bfefe63bc 100644 --- a/Confuser.Runtime/Compressor.cs +++ b/Confuser.Runtime/Compressor.cs @@ -55,8 +55,9 @@ static int Main(string[] args) { Module n = a.ManifestModule; GCHandle h = Decrypt(q, (uint)Mutation.KeyI1); var b = (byte[])h.Target; - Module m = a.LoadModule("koi", b); - Array.Clear(b, 0, b.Length); + Module m = a.LoadModule("koi", b); + + Array.Clear(b, 0, b.Length); h.Free(); Array.Clear(q, 0, q.Length); diff --git a/Confuser2.sln b/Confuser2.sln index 0624b4871..01f7d6064 100644 --- a/Confuser2.sln +++ b/Confuser2.sln @@ -28,6 +28,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser.Runtime", "Confuse EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfuserEx", "ConfuserEx\ConfuserEx.csproj", "{B5205EBA-EC32-4C53-86A0-FAEEE7393EC0}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTest", "UnitTest\UnitTest.csproj", "{E98490BB-63E5-492D-B14E-304DE928F81A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -66,6 +68,10 @@ Global {B5205EBA-EC32-4C53-86A0-FAEEE7393EC0}.Debug|Any CPU.Build.0 = Debug|Any CPU {B5205EBA-EC32-4C53-86A0-FAEEE7393EC0}.Release|Any CPU.ActiveCfg = Release|Any CPU {B5205EBA-EC32-4C53-86A0-FAEEE7393EC0}.Release|Any CPU.Build.0 = Release|Any CPU + {E98490BB-63E5-492D-B14E-304DE928F81A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E98490BB-63E5-492D-B14E-304DE928F81A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E98490BB-63E5-492D-B14E-304DE928F81A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E98490BB-63E5-492D-B14E-304DE928F81A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/UnitTest/App.config b/UnitTest/App.config new file mode 100644 index 000000000..731f6de6c --- /dev/null +++ b/UnitTest/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/UnitTest/GenericTest.cs b/UnitTest/GenericTest.cs new file mode 100644 index 000000000..36c2d68d4 --- /dev/null +++ b/UnitTest/GenericTest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UnitTest +{ + internal class GenericTest where T : IEnumerable + { + public IEnumerable GetReverse(T input) => input.Reverse(); + } +} diff --git a/UnitTest/Program.cs b/UnitTest/Program.cs new file mode 100644 index 000000000..dea76988a --- /dev/null +++ b/UnitTest/Program.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UnitTest +{ + class Program + { + static void Main(string[] args) + { + Console.Write("Hello o/"); + Console.ReadKey(); + } + } +} diff --git a/UnitTest/Properties/AssemblyInfo.cs b/UnitTest/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..97d8cc689 --- /dev/null +++ b/UnitTest/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Les informations générales relatives à un assembly dépendent de +// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations +// associées à un assembly. +[assembly: AssemblyTitle("UnitTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("UnitTest")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly +// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de +// COM, affectez la valeur true à l'attribut ComVisible sur ce type. +[assembly: ComVisible(false)] + +// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM +[assembly: Guid("e98490bb-63e5-492d-b14e-304de928f81a")] + +// Les informations de version pour un assembly se composent des quatre valeurs suivantes : +// +// Version principale +// Version secondaire +// Numéro de build +// Révision +// +// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut +// en utilisant '*', comme indiqué ci-dessous : +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/UnitTest/UnitTest.csproj b/UnitTest/UnitTest.csproj new file mode 100644 index 000000000..d3c95300f --- /dev/null +++ b/UnitTest/UnitTest.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {E98490BB-63E5-492D-B14E-304DE928F81A} + Exe + UnitTest + UnitTest + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file