Skip to content

Commit eb93307

Browse files
author
Sam Byass
committed
Core: Actually populate custom attributes in injector on v29
1 parent d0028d4 commit eb93307

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Cpp2IL.Core/CorePlugin/AttributeInjectorProcessingLayer.cs

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Linq;
34
using System.Reflection;
45
using System.Threading.Tasks;
@@ -39,6 +40,9 @@ private static void InjectFieldOffsetAttribute(ApplicationAnalysisContext appCon
3940

4041
foreach (var f in assemblyAnalysisContext.Types.SelectMany(t => t.Fields))
4142
{
43+
if (f.DeclaringType.Name == "FIFJGNHHBKJ")
44+
Debugger.Break();
45+
4246
if (f.CustomAttributes == null || f.BackingData == null || f.IsStatic)
4347
continue;
4448

@@ -116,10 +120,25 @@ private static void InjectTokenAttribute(ApplicationAnalysisContext appContext)
116120

117121
private static void InjectAttributeAttribute(ApplicationAnalysisContext appContext)
118122
{
119-
if(LibCpp2IlMain.MetadataVersion >= 29f)
123+
if (LibCpp2IlMain.MetadataVersion >= 29f)
124+
{
120125
//All attributes should be fully serializable anyway, as they're stored in metadata
126+
//However, we still need to read them all
127+
var toAnalyze = appContext.Assemblies.SelectMany(ctx => ctx.Types)
128+
.SelectMany(ctx =>
129+
ctx.Methods.SelectMany(m => m.Parameters.Cast<HasCustomAttributes>().Append(m)
130+
.Concat(ctx.Fields)
131+
.Concat(ctx.Events)
132+
.Concat(ctx.Properties)
133+
.Append(ctx)));
134+
135+
foreach (var hasCustomAttributes in toAnalyze)
136+
hasCustomAttributes.AnalyzeCustomAttributeData();
137+
138+
// MiscUtils.ExecuteParallel(toAnalyze, ctx => ctx.AnalyzeCustomAttributeData());
121139
return;
122-
140+
}
141+
123142
var attributeAttributes = appContext.InjectTypeIntoAllAssemblies("Cpp2ILInjected", "AttributeAttribute", appContext.SystemTypes.SystemAttributeType);
124143

125144
var attributeNameFields = attributeAttributes.InjectFieldToAllAssemblies("Name", appContext.SystemTypes.SystemStringType, FieldAttributes.Public);

LibCpp2IL/BinarySearcher.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ internal ulong FindCodeRegistrationPost2019()
209209

210210
if (pCodegenModules.Count == 1)
211211
{
212-
LibLogger.Verbose($"\t\t\tOnly found one codegen module pointer, so assuming it's correct and returning pCodeReg = 0x{address:X}");
212+
LibLogger.VerboseNewline($"\t\t\tOnly found one codegen module pointer, so assuming it's correct and returning pCodeReg = 0x{address:X}");
213213
return address;
214214
}
215215

0 commit comments

Comments
 (0)