Skip to content

Commit 65a8b69

Browse files
committed
Analyze methods not in original metadata
1 parent c5cbb03 commit 65a8b69

3 files changed

Lines changed: 7 additions & 11 deletions

File tree

Confuser.Renamer/Analyzers/InterReferenceAnalyzer.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Linq;
23
using Confuser.Core;
34
using Confuser.Renamer.References;
45
using dnlib.DotNet;
@@ -12,14 +13,9 @@ public void Analyze(ConfuserContext context, INameService service, ProtectionPar
1213
var module = def as ModuleDefMD;
1314
if (module == null) return;
1415

15-
MDTable table;
16-
uint len;
17-
1816
// MemberRef/MethodSpec
19-
table = module.TablesStream.Get(Table.Method);
20-
len = table.Rows;
21-
for (uint i = 1; i <= len; i++) {
22-
MethodDef methodDef = module.ResolveMethod(i);
17+
var methods = module.GetTypes().SelectMany(type => type.Methods);
18+
foreach(var methodDef in methods) {
2319
foreach (var ov in methodDef.Overrides) {
2420
ProcessMemberRef(context, service, module, ov.MethodBody);
2521
ProcessMemberRef(context, service, module, ov.MethodDeclaration);
@@ -34,8 +30,8 @@ public void Analyze(ConfuserContext context, INameService service, ProtectionPar
3430
}
3531

3632
// TypeRef
37-
table = module.TablesStream.Get(Table.TypeRef);
38-
len = table.Rows;
33+
var table = module.TablesStream.Get(Table.TypeRef);
34+
uint len = table.Rows;
3935
for (uint i = 1; i <= len; i++) {
4036
TypeRef typeRef = module.ResolveTypeRef(i);
4137

Confuser.Renamer/Analyzers/TypeBlobAnalyzer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ public void Analyze(ConfuserContext context, INameService service, ProtectionPar
2020
// MemberRef
2121
table = module.TablesStream.Get(Table.Method);
2222
len = table.Rows;
23-
IEnumerable<MethodDef> methods = Enumerable.Range(1, (int)len)
24-
.Select(rid => module.ResolveMethod((uint)rid));
23+
IEnumerable<MethodDef> methods = module.GetTypes().SelectMany(type => type.Methods);
2524
foreach (MethodDef method in methods) {
2625
foreach (MethodOverride methodImpl in method.Overrides) {
2726
if (methodImpl.MethodBody is MemberRef)

Confuser.Renamer/Confuser.Renamer.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<Compile Include="AnalyzePhase.cs" />
5252
<Compile Include="Analyzers\CaliburnAnalyzer.cs" />
5353
<Compile Include="Analyzers\InterReferenceAnalyzer.cs" />
54+
<Compile Include="Analyzers\JsonAnalyzer.cs" />
5455
<Compile Include="Analyzers\LdtokenEnumAnalyzer.cs" />
5556
<Compile Include="Analyzers\ResourceAnalyzer.cs" />
5657
<Compile Include="Analyzers\TypeBlobAnalyzer.cs" />

0 commit comments

Comments
 (0)