@@ -89,6 +89,7 @@ public void WriteScript(string outputDir)
8989 var methodPointer = il2Cpp . GetMethodPointer ( imageName , methodDef ) ;
9090 if ( methodPointer > 0 )
9191 {
92+ var methodTypeSignature = new List < Il2CppTypeEnum > ( ) ;
9293 var scriptMethod = new ScriptMethod ( ) ;
9394 json . ScriptMethod . Add ( scriptMethod ) ;
9495 scriptMethod . Address = il2Cpp . GetRVA ( methodPointer ) ;
@@ -101,15 +102,18 @@ public void WriteScript(string outputDir)
101102 {
102103 returnType += "*" ;
103104 }
105+ methodTypeSignature . Add ( methodReturnType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : methodReturnType . type ) ;
104106 var signature = $ "{ returnType } { FixName ( methodFullName ) } (";
105107 var parameterStrs = new List < string > ( ) ;
106108 if ( ( methodDef . flags & METHOD_ATTRIBUTE_STATIC ) == 0 )
107109 {
108110 var thisType = ParseType ( il2Cpp . types [ typeDef . byvalTypeIndex ] ) ;
111+ methodTypeSignature . Add ( il2Cpp . types [ typeDef . byvalTypeIndex ] . type ) ;
109112 parameterStrs . Add ( $ "{ thisType } __this") ;
110113 }
111114 else if ( il2Cpp . Version <= 24 )
112115 {
116+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
113117 parameterStrs . Add ( $ "Il2CppObject* __this") ;
114118 }
115119 for ( var j = 0 ; j < methodDef . parameterCount ; j ++ )
@@ -122,12 +126,15 @@ public void WriteScript(string outputDir)
122126 {
123127 parameterCType += "*" ;
124128 }
129+ methodTypeSignature . Add ( parameterType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : parameterType . type ) ;
125130 parameterStrs . Add ( $ "{ parameterCType } { FixName ( parameterName ) } ") ;
126131 }
132+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
127133 parameterStrs . Add ( "const MethodInfo* method" ) ;
128134 signature += string . Join ( ", " , parameterStrs ) ;
129135 signature += ");" ;
130136 scriptMethod . Signature = signature ;
137+ scriptMethod . TypeSignature = GetMethodTypeSignature ( methodTypeSignature ) ;
131138 }
132139 //泛型实例函数
133140 if ( il2Cpp . methodDefinitionMethodSpecs . TryGetValue ( i , out var methodSpecs ) )
@@ -137,6 +144,7 @@ public void WriteScript(string outputDir)
137144 var genericMethodPointer = il2Cpp . methodSpecGenericMethodPointers [ methodSpec ] ;
138145 if ( genericMethodPointer > 0 )
139146 {
147+ var methodTypeSignature = new List < Il2CppTypeEnum > ( ) ;
140148 var scriptMethod = new ScriptMethod ( ) ;
141149 json . ScriptMethod . Add ( scriptMethod ) ;
142150 scriptMethod . Address = il2Cpp . GetRVA ( genericMethodPointer ) ;
@@ -158,6 +166,7 @@ public void WriteScript(string outputDir)
158166 {
159167 returnType += "*" ;
160168 }
169+ methodTypeSignature . Add ( methodReturnType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : methodReturnType . type ) ;
161170 var signature = $ "{ returnType } { FixName ( methodFullName ) } (";
162171 var parameterStrs = new List < string > ( ) ;
163172 if ( ( methodDef . flags & METHOD_ATTRIBUTE_STATIC ) == 0 )
@@ -172,21 +181,25 @@ public void WriteScript(string outputDir)
172181 if ( nameGenericClassDic . TryGetValue ( typeStructName , out var il2CppType ) )
173182 {
174183 thisType = ParseType ( il2CppType ) ;
184+ methodTypeSignature . Add ( il2CppType . type ) ;
175185 }
176186 else
177187 {
178188 //没有单独的泛型实例类
179189 thisType = ParseType ( il2Cpp . types [ typeDef . byvalTypeIndex ] ) ;
190+ methodTypeSignature . Add ( il2Cpp . types [ typeDef . byvalTypeIndex ] . type ) ;
180191 }
181192 }
182193 else
183194 {
184195 thisType = ParseType ( il2Cpp . types [ typeDef . byvalTypeIndex ] ) ;
196+ methodTypeSignature . Add ( il2Cpp . types [ typeDef . byvalTypeIndex ] . type ) ;
185197 }
186198 parameterStrs . Add ( $ "{ thisType } __this") ;
187199 }
188200 else if ( il2Cpp . Version <= 24 )
189201 {
202+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
190203 parameterStrs . Add ( $ "Il2CppObject* __this") ;
191204 }
192205 for ( var j = 0 ; j < methodDef . parameterCount ; j ++ )
@@ -199,12 +212,15 @@ public void WriteScript(string outputDir)
199212 {
200213 parameterCType += "*" ;
201214 }
215+ methodTypeSignature . Add ( parameterType . byref == 1 ? Il2CppTypeEnum . IL2CPP_TYPE_PTR : parameterType . type ) ;
202216 parameterStrs . Add ( $ "{ parameterCType } { FixName ( parameterName ) } ") ;
203217 }
218+ methodTypeSignature . Add ( Il2CppTypeEnum . IL2CPP_TYPE_PTR ) ;
204219 parameterStrs . Add ( $ "const { methodInfoName } * method") ;
205220 signature += string . Join ( ", " , parameterStrs ) ;
206221 signature += ");" ;
207222 scriptMethod . Signature = signature ;
223+ scriptMethod . TypeSignature = GetMethodTypeSignature ( methodTypeSignature ) ;
208224 }
209225 }
210226 }
@@ -644,6 +660,57 @@ private string ParseType(Il2CppType il2CppType, Il2CppGenericContext context = n
644660 throw new NotSupportedException ( ) ;
645661 }
646662 }
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+ }
647714
648715 private void AddStruct ( Il2CppTypeDefinition typeDef )
649716 {
0 commit comments