@@ -89,6 +89,7 @@ public void WriteScript(string outputDir)
89
89
var methodPointer = il2Cpp . GetMethodPointer ( imageName , methodDef ) ;
90
90
if ( methodPointer > 0 )
91
91
{
92
+ var methodTypeSignature = new List < Il2CppTypeEnum > ( ) ;
92
93
var scriptMethod = new ScriptMethod ( ) ;
93
94
json . ScriptMethod . Add ( scriptMethod ) ;
94
95
scriptMethod . Address = il2Cpp . GetRVA ( methodPointer ) ;
@@ -101,15 +102,18 @@ public void WriteScript(string outputDir)
101
102
{
102
103
returnType += "*" ;
103
104
}
105
+ methodTypeSignature . Add ( methodReturnType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : methodReturnType . type ) ;
104
106
var signature = $ "{ returnType } { FixName ( methodFullName ) } (";
105
107
var parameterStrs = new List < string > ( ) ;
106
108
if ( ( methodDef . flags & METHOD_ATTRIBUTE_STATIC ) == 0 )
107
109
{
108
110
var thisType = ParseType ( il2Cpp . types [ typeDef . byvalTypeIndex ] ) ;
111
+ methodTypeSignature . Add ( il2Cpp . types [ typeDef . byvalTypeIndex ] . type ) ;
109
112
parameterStrs . Add ( $ "{ thisType } __this") ;
110
113
}
111
114
else if ( il2Cpp . Version <= 24 )
112
115
{
116
+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
113
117
parameterStrs . Add ( $ "Il2CppObject* __this") ;
114
118
}
115
119
for ( var j = 0 ; j < methodDef . parameterCount ; j ++ )
@@ -122,12 +126,15 @@ public void WriteScript(string outputDir)
122
126
{
123
127
parameterCType += "*" ;
124
128
}
129
+ methodTypeSignature . Add ( parameterType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : parameterType . type ) ;
125
130
parameterStrs . Add ( $ "{ parameterCType } { FixName ( parameterName ) } ") ;
126
131
}
132
+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
127
133
parameterStrs . Add ( "const MethodInfo* method" ) ;
128
134
signature += string . Join ( ", " , parameterStrs ) ;
129
135
signature += ");" ;
130
136
scriptMethod . Signature = signature ;
137
+ scriptMethod . TypeSignature = GetMethodTypeSignature ( methodTypeSignature ) ;
131
138
}
132
139
//泛型实例函数
133
140
if ( il2Cpp . methodDefinitionMethodSpecs . TryGetValue ( i , out var methodSpecs ) )
@@ -137,6 +144,7 @@ public void WriteScript(string outputDir)
137
144
var genericMethodPointer = il2Cpp . methodSpecGenericMethodPointers [ methodSpec ] ;
138
145
if ( genericMethodPointer > 0 )
139
146
{
147
+ var methodTypeSignature = new List < Il2CppTypeEnum > ( ) ;
140
148
var scriptMethod = new ScriptMethod ( ) ;
141
149
json . ScriptMethod . Add ( scriptMethod ) ;
142
150
scriptMethod . Address = il2Cpp . GetRVA ( genericMethodPointer ) ;
@@ -158,6 +166,7 @@ public void WriteScript(string outputDir)
158
166
{
159
167
returnType += "*" ;
160
168
}
169
+ methodTypeSignature . Add ( methodReturnType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : methodReturnType . type ) ;
161
170
var signature = $ "{ returnType } { FixName ( methodFullName ) } (";
162
171
var parameterStrs = new List < string > ( ) ;
163
172
if ( ( methodDef . flags & METHOD_ATTRIBUTE_STATIC ) == 0 )
@@ -172,21 +181,25 @@ public void WriteScript(string outputDir)
172
181
if ( nameGenericClassDic . TryGetValue ( typeStructName , out var il2CppType ) )
173
182
{
174
183
thisType = ParseType ( il2CppType ) ;
184
+ methodTypeSignature . Add ( il2CppType . type ) ;
175
185
}
176
186
else
177
187
{
178
188
//没有单独的泛型实例类
179
189
thisType = ParseType ( il2Cpp . types [ typeDef . byvalTypeIndex ] ) ;
190
+ methodTypeSignature . Add ( il2Cpp . types [ typeDef . byvalTypeIndex ] . type ) ;
180
191
}
181
192
}
182
193
else
183
194
{
184
195
thisType = ParseType ( il2Cpp . types [ typeDef . byvalTypeIndex ] ) ;
196
+ methodTypeSignature . Add ( il2Cpp . types [ typeDef . byvalTypeIndex ] . type ) ;
185
197
}
186
198
parameterStrs . Add ( $ "{ thisType } __this") ;
187
199
}
188
200
else if ( il2Cpp . Version <= 24 )
189
201
{
202
+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
190
203
parameterStrs . Add ( $ "Il2CppObject* __this") ;
191
204
}
192
205
for ( var j = 0 ; j < methodDef . parameterCount ; j ++ )
@@ -199,12 +212,15 @@ public void WriteScript(string outputDir)
199
212
{
200
213
parameterCType += "*" ;
201
214
}
215
+ methodTypeSignature . Add ( parameterType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : parameterType . type ) ;
202
216
parameterStrs . Add ( $ "{ parameterCType } { FixName ( parameterName ) } ") ;
203
217
}
218
+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
204
219
parameterStrs . Add ( $ "const { methodInfoName } * method") ;
205
220
signature += string . Join ( ", " , parameterStrs ) ;
206
221
signature += ");" ;
207
222
scriptMethod . Signature = signature ;
223
+ scriptMethod . TypeSignature = GetMethodTypeSignature ( methodTypeSignature ) ;
208
224
}
209
225
}
210
226
}
@@ -644,6 +660,57 @@ private string ParseType(Il2CppType il2CppType, Il2CppGenericContext context = n
644
660
throw new NotSupportedException ( ) ;
645
661
}
646
662
}
663
+ public string GetMethodTypeSignature ( List < Il2CppTypeEnum > types )
664
+ {
665
+ string signature = string . Empty ;
666
+ foreach ( Il2CppTypeEnum type in types )
667
+ {
668
+ switch ( type )
669
+ {
670
+ case Il2CppTypeEnum . IL2CPP_TYPE_VOID :
671
+ signature += "v" ;
672
+ break ;
673
+ case Il2CppTypeEnum . IL2CPP_TYPE_BOOLEAN :
674
+ case Il2CppTypeEnum . IL2CPP_TYPE_CHAR :
675
+ case Il2CppTypeEnum . IL2CPP_TYPE_I1 :
676
+ case Il2CppTypeEnum . IL2CPP_TYPE_U1 :
677
+ case Il2CppTypeEnum . IL2CPP_TYPE_I2 :
678
+ case Il2CppTypeEnum . IL2CPP_TYPE_U2 :
679
+ case Il2CppTypeEnum . IL2CPP_TYPE_I4 :
680
+ case Il2CppTypeEnum . IL2CPP_TYPE_U4 :
681
+ signature += "i" ;
682
+ break ;
683
+ case Il2CppTypeEnum . IL2CPP_TYPE_I8 :
684
+ case Il2CppTypeEnum . IL2CPP_TYPE_U8 :
685
+ signature += "j" ;
686
+ break ;
687
+ case Il2CppTypeEnum . IL2CPP_TYPE_R4 :
688
+ signature += "f" ;
689
+ break ;
690
+ case Il2CppTypeEnum . IL2CPP_TYPE_R8 :
691
+ signature += "d" ;
692
+ break ;
693
+ case Il2CppTypeEnum . IL2CPP_TYPE_STRING :
694
+ case Il2CppTypeEnum . IL2CPP_TYPE_PTR :
695
+ case Il2CppTypeEnum . IL2CPP_TYPE_VALUETYPE :
696
+ case Il2CppTypeEnum . IL2CPP_TYPE_CLASS :
697
+ case Il2CppTypeEnum . IL2CPP_TYPE_VAR :
698
+ case Il2CppTypeEnum . IL2CPP_TYPE_ARRAY :
699
+ case Il2CppTypeEnum . IL2CPP_TYPE_GENERICINST :
700
+ case Il2CppTypeEnum . IL2CPP_TYPE_TYPEDBYREF :
701
+ case Il2CppTypeEnum . IL2CPP_TYPE_I :
702
+ case Il2CppTypeEnum . IL2CPP_TYPE_U :
703
+ case Il2CppTypeEnum . IL2CPP_TYPE_OBJECT :
704
+ case Il2CppTypeEnum . IL2CPP_TYPE_SZARRAY :
705
+ case Il2CppTypeEnum . IL2CPP_TYPE_MVAR :
706
+ signature += "i" ;
707
+ break ;
708
+ default :
709
+ throw new NotSupportedException ( ) ;
710
+ }
711
+ }
712
+ return signature ;
713
+ }
647
714
648
715
private void AddStruct ( Il2CppTypeDefinition typeDef )
649
716
{
0 commit comments