1
- using System ;
2
- using System . Collections . Generic ;
3
- using System . Linq ;
4
- using System . Text ;
5
- using Mono . Cecil ;
1
+ using Mono . Cecil ;
6
2
using Mono . Cecil . Cil ;
7
3
using Mono . Collections . Generic ;
4
+ using System ;
5
+ using System . Collections . Generic ;
6
+ using System . Linq ;
8
7
9
8
namespace Il2CppDumper
10
9
{
@@ -21,7 +20,7 @@ public class DummyAssemblyGenerator
21
20
private TypeReference stringType ;
22
21
private Dictionary < string , MethodDefinition > knownAttributes = new Dictionary < string , MethodDefinition > ( ) ;
23
22
24
- public DummyAssemblyGenerator ( Il2CppExecutor il2CppExecutor )
23
+ public DummyAssemblyGenerator ( Il2CppExecutor il2CppExecutor , bool addToken )
25
24
{
26
25
executor = il2CppExecutor ;
27
26
metadata = il2CppExecutor . metadata ;
@@ -95,9 +94,12 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor)
95
94
var typeDef = metadata . typeDefs [ index ] ;
96
95
var typeDefinition = typeDefinitionDic [ typeDef ] ;
97
96
98
- var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
99
- customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ typeDef . token : X} ") ) ) ;
100
- typeDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
97
+ if ( addToken )
98
+ {
99
+ var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
100
+ customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ typeDef . token : X} ") ) ) ;
101
+ typeDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
102
+ }
101
103
102
104
//genericParameter
103
105
if ( typeDef . genericContainerIndex >= 0 )
@@ -150,9 +152,12 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor)
150
152
typeDefinition . Fields . Add ( fieldDefinition ) ;
151
153
fieldDefinitionDic . Add ( i , fieldDefinition ) ;
152
154
153
- var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
154
- customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ fieldDef . token : X} ") ) ) ;
155
- fieldDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
155
+ if ( addToken )
156
+ {
157
+ var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
158
+ customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ fieldDef . token : X} ") ) ) ;
159
+ fieldDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
160
+ }
156
161
157
162
//fieldDefault
158
163
if ( metadata . GetFieldDefaultValueFromIndex ( i , out var fieldDefault ) && fieldDefault . dataIndex != - 1 )
@@ -207,9 +212,12 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor)
207
212
var returnType = GetTypeReferenceWithByRef ( methodDefinition , methodReturnType ) ;
208
213
methodDefinition . ReturnType = returnType ;
209
214
210
- var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
211
- customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ methodDef . token : X} ") ) ) ;
212
- methodDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
215
+ if ( addToken )
216
+ {
217
+ var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
218
+ customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ methodDef . token : X} ") ) ) ;
219
+ methodDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
220
+ }
213
221
214
222
if ( methodDefinition . HasBody && typeDefinition . BaseType ? . FullName != "System.MulticastDelegate" )
215
223
{
@@ -308,9 +316,12 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor)
308
316
typeDefinition . Properties . Add ( propertyDefinition ) ;
309
317
propertyDefinitionDic . Add ( i , propertyDefinition ) ;
310
318
311
- var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
312
- customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ propertyDef . token : X} ") ) ) ;
313
- propertyDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
319
+ if ( addToken )
320
+ {
321
+ var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
322
+ customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ propertyDef . token : X} ") ) ) ;
323
+ propertyDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
324
+ }
314
325
}
315
326
//event
316
327
var eventEnd = typeDef . eventStart + typeDef . event_count ;
@@ -330,9 +341,12 @@ public DummyAssemblyGenerator(Il2CppExecutor il2CppExecutor)
330
341
typeDefinition . Events . Add ( eventDefinition ) ;
331
342
eventDefinitionDic . Add ( i , eventDefinition ) ;
332
343
333
- var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
334
- customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ eventDef . token : X} ") ) ) ;
335
- eventDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
344
+ if ( addToken )
345
+ {
346
+ var customTokenAttribute = new CustomAttribute ( typeDefinition . Module . ImportReference ( tokenAttribute ) ) ;
347
+ customTokenAttribute . Fields . Add ( new CustomAttributeNamedArgument ( "Token" , new CustomAttributeArgument ( stringType , $ "0x{ eventDef . token : X} ") ) ) ;
348
+ eventDefinition . CustomAttributes . Add ( customTokenAttribute ) ;
349
+ }
336
350
}
337
351
}
338
352
}
0 commit comments