forked from yck1509/ConfuserEx
-
-
Notifications
You must be signed in to change notification settings - Fork 368
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of fully foreign vtable slots
Implemented handling for the renamer in case all methods of a VTable slot don't belong to the type, the slots belongs to. This happens in case a type implicitly implements an interface by inheriting another class.
- Loading branch information
Showing
15 changed files
with
245 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
Tests/306_ComplexClassStructureRename.Lib/306_ComplexClassStructureRename.Lib.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
<RootNamespace>ComplexClassStructureRename.Lib</RootNamespace> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace ComplexClassStructureRename.Lib { | ||
public interface ITestEvents { | ||
void FireLog(string message); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Tests/306_ComplexClassStructureRename.Lib/InternalBaseClass.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace ComplexClassStructureRename.Lib { | ||
internal class InternalBaseClass { | ||
public virtual void FireLog(string message) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System; | ||
|
||
namespace ComplexClassStructureRename.Lib { | ||
internal class InternalClass1 : InternalBaseClass { | ||
public new void FireLog(string message) => | ||
Console.WriteLine("InternalClass1: " + message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace ComplexClassStructureRename.Lib { | ||
internal class InternalClass2 : InternalBaseClass, ITestEvents { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace ComplexClassStructureRename.Lib { | ||
internal class MyTest { | ||
readonly InternalClass1 _test1 = new InternalClass1(); | ||
readonly InternalClass2 _test2 = new InternalClass2(); | ||
|
||
public void Test() { | ||
_test1.FireLog("test1 Hello"); | ||
_test2.FireLog("test2 Hello"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using System.Reflection; | ||
|
||
namespace ComplexClassStructureRename.Lib { | ||
[Obfuscation(Exclude = false, Feature = "-rename")] | ||
public class PublicClass1 : ITestEvents { | ||
public void FireLog(string message) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Reflection; | ||
|
||
namespace ComplexClassStructureRename.Lib { | ||
[Obfuscation(Exclude = false, Feature = "-rename")] | ||
public class PublicClass2 { | ||
readonly MyTest _test = new MyTest(); | ||
|
||
public void Test() => _test.Test(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Tests/306_ComplexClassStructureRename.Test/306_ComplexClassStructureRename.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
<RootNamespace>ComplexClassStructureRename.Test</RootNamespace> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Confuser.UnitTest\Confuser.UnitTest.csproj" /> | ||
<ProjectReference Include="..\306_ComplexClassStructureRename\306_ComplexClassStructureRename.csproj" /> | ||
</ItemGroup> | ||
</Project> |
33 changes: 33 additions & 0 deletions
33
Tests/306_ComplexClassStructureRename.Test/ComplexRenameTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Confuser.Core; | ||
using Confuser.Core.Project; | ||
using Confuser.UnitTest; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ComplexClassStructureRename.Test { | ||
public class ComplexRenameTest : TestBase { | ||
public ComplexRenameTest(ITestOutputHelper outputHelper) : base(outputHelper) { } | ||
|
||
[Fact] | ||
[Trait("Category", "Protection")] | ||
[Trait("Protection", "rename")] | ||
[Trait("Issue", "https://github.com/mkaring/ConfuserEx/issues/306")] | ||
public async Task ComplexClassStructureRename() => | ||
await Run( | ||
new[] { | ||
"306_ComplexClassStructureRename.exe", | ||
"306_ComplexClassStructureRename.Lib.dll" | ||
}, | ||
new[] { | ||
"InternalClass1: test1 Hello" | ||
}, | ||
new SettingItem<Protection>("rename") { | ||
{ "mode", "sequential" }, | ||
{ "renPublic", "true" }, | ||
{ "flatten", "false" } | ||
} | ||
); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Tests/306_ComplexClassStructureRename/306_ComplexClassStructureRename.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net461</TargetFramework> | ||
<RootNamespace>ComplexClassStructureRename</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\306_ComplexClassStructureRename.Lib\306_ComplexClassStructureRename.Lib.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Reflection; | ||
using ComplexClassStructureRename.Lib; | ||
|
||
[assembly: Obfuscation(Exclude = false, Feature = "-rename")] | ||
|
||
namespace ComplexClassStructureRename { | ||
public class Program { | ||
[SuppressMessage("Style", "IDE0060:Remove unused parameters", Justification = "Required signature")] | ||
static int Main(string[] args) { | ||
Console.WriteLine("START"); | ||
|
||
var t = new PublicClass2(); | ||
t.Test(); | ||
|
||
Console.WriteLine("END"); | ||
return 42; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters