@@ -34,7 +34,7 @@ static IL2CPP()
3434 for ( var i = 0 ; i < assembliesCount ; i ++ )
3535 {
3636 var image = il2cpp_assembly_get_image ( assemblies [ i ] ) ;
37- var name = il2cpp_image_get_name_ ( image ) ! ;
37+ var name = il2cpp_image_get_name ( image ) ;
3838 ourImagesMap [ name ] = image ;
3939 }
4040 }
@@ -69,7 +69,7 @@ public static IntPtr GetIl2CppField(IntPtr clazz, string fieldName)
6969 var field = il2cpp_class_get_field_from_name ( clazz , fieldName ) ;
7070 if ( field == IntPtr . Zero )
7171 Logger . Instance . LogError (
72- "Field {FieldName} was not found on class {ClassName}" , fieldName , il2cpp_class_get_name_ ( clazz ) ) ;
72+ "Field {FieldName} was not found on class {ClassName}" , fieldName , il2cpp_class_get_name ( clazz ) ) ;
7373 return field ;
7474 }
7575
@@ -84,7 +84,7 @@ public static IntPtr GetIl2CppMethodByToken(IntPtr clazz, int token)
8484 if ( il2cpp_method_get_token ( method ) == token )
8585 return method ;
8686
87- var className = il2cpp_class_get_name_ ( clazz ) ;
87+ var className = il2cpp_class_get_name ( clazz ) ;
8888 Logger . Instance . LogTrace ( "Unable to find method {ClassName}::{Token}" , className , token ) ;
8989
9090 return NativeStructUtils . GetMethodInfoForMissingMethod ( className + "::" + token ) ;
@@ -110,7 +110,7 @@ public static IntPtr GetIl2CppMethod(IntPtr clazz, bool isGeneric, string method
110110 IntPtr method ;
111111 while ( ( method = il2cpp_class_get_methods ( clazz , ref iter ) ) != IntPtr . Zero )
112112 {
113- if ( il2cpp_method_get_name_ ( method ) != methodName )
113+ if ( il2cpp_method_get_name ( method ) != methodName )
114114 continue ;
115115
116116 if ( il2cpp_method_get_param_count ( method ) != argTypes . Length )
@@ -120,7 +120,7 @@ public static IntPtr GetIl2CppMethod(IntPtr clazz, bool isGeneric, string method
120120 continue ;
121121
122122 var returnType = il2cpp_method_get_return_type ( method ) ;
123- var returnTypeNameActual = il2cpp_type_get_name_ ( returnType ) ;
123+ var returnTypeNameActual = il2cpp_type_get_name ( returnType ) ;
124124 if ( returnTypeNameActual != returnTypeName )
125125 continue ;
126126
@@ -131,7 +131,7 @@ public static IntPtr GetIl2CppMethod(IntPtr clazz, bool isGeneric, string method
131131 for ( var i = 0 ; i < argTypes . Length ; i ++ )
132132 {
133133 var paramType = il2cpp_method_get_param ( method , ( uint ) i ) ;
134- var typeName = il2cpp_type_get_name_ ( paramType ) ;
134+ var typeName = il2cpp_type_get_name ( paramType ) ;
135135 if ( typeName != argTypes [ i ] )
136136 {
137137 badType = true ;
@@ -144,19 +144,19 @@ public static IntPtr GetIl2CppMethod(IntPtr clazz, bool isGeneric, string method
144144 return method ;
145145 }
146146
147- var className = il2cpp_class_get_name_ ( clazz ) ;
147+ var className = il2cpp_class_get_name ( clazz ) ;
148148
149149 if ( methodsSeen == 1 )
150150 {
151151 Logger . Instance . LogTrace (
152152 "Method {ClassName}::{MethodName} was stubbed with a random matching method of the same name" , className , methodName ) ;
153153 Logger . Instance . LogTrace (
154- "Stubby return type/target: {LastMethod} / {ReturnTypeName}" , il2cpp_type_get_name_ ( il2cpp_method_get_return_type ( lastMethod ) ) , returnTypeName ) ;
154+ "Stubby return type/target: {LastMethod} / {ReturnTypeName}" , il2cpp_type_get_name ( il2cpp_method_get_return_type ( lastMethod ) ) , returnTypeName ) ;
155155 Logger . Instance . LogTrace ( "Stubby parameter types/targets follow:" ) ;
156156 for ( var i = 0 ; i < argTypes . Length ; i ++ )
157157 {
158158 var paramType = il2cpp_method_get_param ( lastMethod , ( uint ) i ) ;
159- var typeName = il2cpp_type_get_name_ ( paramType ) ;
159+ var typeName = il2cpp_type_get_name ( paramType ) ;
160160 Logger . Instance . LogTrace ( " {TypeName} / {ArgType}" , typeName , argTypes [ i ] ) ;
161161 }
162162
@@ -171,17 +171,17 @@ public static IntPtr GetIl2CppMethod(IntPtr clazz, bool isGeneric, string method
171171 iter = IntPtr . Zero ;
172172 while ( ( method = il2cpp_class_get_methods ( clazz , ref iter ) ) != IntPtr . Zero )
173173 {
174- if ( il2cpp_method_get_name_ ( method ) != methodName )
174+ if ( il2cpp_method_get_name ( method ) != methodName )
175175 continue ;
176176
177177 var nParams = il2cpp_method_get_param_count ( method ) ;
178178 Logger . Instance . LogTrace ( "Method starts" ) ;
179179 Logger . Instance . LogTrace (
180- " return {MethodTypeName}" , il2cpp_type_get_name_ ( il2cpp_method_get_return_type ( method ) ) ) ;
180+ " return {MethodTypeName}" , il2cpp_type_get_name ( il2cpp_method_get_return_type ( method ) ) ) ;
181181 for ( var i = 0 ; i < nParams ; i ++ )
182182 {
183183 var paramType = il2cpp_method_get_param ( method , ( uint ) i ) ;
184- var typeName = il2cpp_type_get_name_ ( paramType ) ;
184+ var typeName = il2cpp_type_get_name ( paramType ) ;
185185 Logger . Instance . LogTrace ( " {TypeName}" , typeName ) ;
186186 }
187187
@@ -236,13 +236,18 @@ public static IntPtr GetIl2CppNestedType(IntPtr enclosingType, string nestedType
236236 }
237237
238238 while ( ( nestedTypePtr = il2cpp_class_get_nested_types ( enclosingType , ref iter ) ) != IntPtr . Zero )
239- if ( il2cpp_class_get_name_ ( nestedTypePtr ) == nestedTypeName )
239+ if ( il2cpp_class_get_name ( nestedTypePtr ) == nestedTypeName )
240240 return nestedTypePtr ;
241241
242- Logger . Instance . LogError (
243- "Nested type {NestedTypeName} on {EnclosingTypeName} not found!" , nestedTypeName , il2cpp_class_get_name_ ( enclosingType ) ) ;
242+ Logger . Instance . LogTrace ( "Failed to find nested type through enumeration, falling back to reflection" ) ;
244243
245- return IntPtr . Zero ;
244+ var result = RuntimeReflectionHelper . GetNestedTypeViaReflection ( enclosingType , nestedTypeName ) ;
245+
246+ if ( result == IntPtr . Zero )
247+ Logger . Instance . LogError (
248+ "Nested type {NestedTypeName} on {EnclosingTypeName} not found!" , nestedTypeName , il2cpp_class_get_name ( enclosingType ) ) ;
249+
250+ return result ;
246251 }
247252
248253 public static void ThrowIfNull ( object arg )
@@ -513,16 +518,12 @@ public static extern IntPtr il2cpp_class_get_method_from_name(IntPtr klass,
513518 [ MarshalAs ( UnmanagedType . LPUTF8Str ) ] string name , int argsCount ) ;
514519
515520 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
516- public static extern nint il2cpp_class_get_name ( IntPtr klass ) ;
517-
518- public static string ? il2cpp_class_get_name_ ( IntPtr klass )
519- => Marshal . PtrToStringUTF8 ( il2cpp_class_get_name ( klass ) ) ;
521+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
522+ public static extern string il2cpp_class_get_name ( IntPtr klass ) ;
520523
521524 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
522- public static extern nint il2cpp_class_get_namespace ( IntPtr klass ) ;
523-
524- public static string ? il2cpp_class_get_namespace_ ( IntPtr klass )
525- => Marshal . PtrToStringUTF8 ( il2cpp_class_get_namespace ( klass ) ) ;
525+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
526+ public static extern string il2cpp_class_get_namespace ( IntPtr klass ) ;
526527
527528 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
528529 public static extern IntPtr il2cpp_class_get_parent ( IntPtr klass ) ;
@@ -585,11 +586,9 @@ public static extern IntPtr il2cpp_class_get_method_from_name(IntPtr klass,
585586 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
586587 public static extern IntPtr il2cpp_class_get_image ( IntPtr klass ) ;
587588
588- [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
589- public static extern nint il2cpp_class_get_assemblyname ( IntPtr klass ) ;
590-
591- public static string ? il2cpp_class_get_assemblyname_ ( IntPtr klass )
592- => Marshal . PtrToStringUTF8 ( il2cpp_class_get_assemblyname ( klass ) ) ;
589+ [ DllImport ( "GameAssembly" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
590+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
591+ public static extern string il2cpp_class_get_assemblyname ( IntPtr klass ) ;
593592
594593 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
595594 public static extern int il2cpp_class_get_rank ( IntPtr klass ) ;
@@ -635,10 +634,8 @@ public static extern IntPtr
635634 public static extern int il2cpp_field_get_flags ( IntPtr field ) ;
636635
637636 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
638- public static extern nint il2cpp_field_get_name ( IntPtr field ) ;
639-
640- public static string ? il2cpp_field_get_name_ ( IntPtr field )
641- => Marshal . PtrToStringUTF8 ( il2cpp_field_get_name ( field ) ) ;
637+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
638+ public static extern string il2cpp_field_get_name ( IntPtr field ) ;
642639
643640 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
644641 public static extern IntPtr il2cpp_field_get_parent ( IntPtr field ) ;
@@ -728,11 +725,9 @@ public static extern IntPtr il2cpp_unity_liveness_calculation_begin(IntPtr filte
728725 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
729726 public static extern IntPtr il2cpp_method_get_declaring_type ( IntPtr method ) ;
730727
731- [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
732- public static extern nint il2cpp_method_get_name ( IntPtr method ) ;
733-
734- public static string ? il2cpp_method_get_name_ ( IntPtr method )
735- => Marshal . PtrToStringUTF8 ( il2cpp_method_get_name ( method ) ) ;
728+ [ DllImport ( "GameAssembly" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
729+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
730+ public static extern string il2cpp_method_get_name ( IntPtr method ) ;
736731
737732 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
738733 public static IntPtr il2cpp_method_get_from_reflection ( IntPtr method )
@@ -780,10 +775,8 @@ public static IntPtr il2cpp_method_get_from_reflection(IntPtr method)
780775 public static extern uint il2cpp_method_get_token ( IntPtr method ) ;
781776
782777 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
783- public static extern nint il2cpp_method_get_param_name ( IntPtr method , uint index ) ;
784-
785- public static string ? il2cpp_method_get_param_name_ ( IntPtr method , uint index )
786- => Marshal . PtrToStringUTF8 ( il2cpp_method_get_param_name ( method , index ) ) ;
778+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
779+ public static extern string il2cpp_method_get_param_name ( IntPtr method , uint index ) ;
787780
788781 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
789782 public static extern void il2cpp_profiler_install ( IntPtr prof , IntPtr shutdown_callback ) ;
@@ -815,10 +808,8 @@ public static IntPtr il2cpp_method_get_from_reflection(IntPtr method)
815808 public static extern IntPtr il2cpp_property_get_set_method ( IntPtr prop ) ;
816809
817810 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
818- public static extern nint il2cpp_property_get_name ( IntPtr prop ) ;
819-
820- public static string ? il2cpp_property_get_name_ ( IntPtr prop )
821- => Marshal . PtrToStringUTF8 ( il2cpp_property_get_name ( prop ) ) ;
811+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
812+ public static extern string il2cpp_property_get_name ( IntPtr prop ) ;
822813
823814 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
824815 public static extern IntPtr il2cpp_property_get_parent ( IntPtr prop ) ;
@@ -960,11 +951,9 @@ public static extern IntPtr il2cpp_runtime_invoke_convert_args(IntPtr method, In
960951 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
961952 public static extern IntPtr il2cpp_type_get_class_or_element_class ( IntPtr type ) ;
962953
963- [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
964- public static extern nint il2cpp_type_get_name ( IntPtr type ) ;
965-
966- public static string ? il2cpp_type_get_name_ ( IntPtr type )
967- => Marshal . PtrToStringUTF8 ( il2cpp_type_get_name ( type ) ) ;
954+ [ DllImport ( "GameAssembly" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
955+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
956+ public static extern string il2cpp_type_get_name ( IntPtr type ) ;
968957
969958 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
970959 [ return : MarshalAs ( UnmanagedType . I1 ) ]
@@ -984,16 +973,12 @@ public static extern IntPtr il2cpp_runtime_invoke_convert_args(IntPtr method, In
984973 public static extern IntPtr il2cpp_image_get_assembly ( IntPtr image ) ;
985974
986975 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
987- public static extern nint il2cpp_image_get_name ( IntPtr image ) ;
988-
989- public static string ? il2cpp_image_get_name_ ( IntPtr image )
990- => Marshal . PtrToStringUTF8 ( il2cpp_image_get_name ( image ) ) ;
976+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
977+ public static extern string il2cpp_image_get_name ( IntPtr image ) ;
991978
992979 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
993- public static extern nint il2cpp_image_get_filename ( IntPtr image ) ;
994-
995- public static string ? il2cpp_image_get_filename_ ( IntPtr image )
996- => Marshal . PtrToStringUTF8 ( il2cpp_image_get_filename ( image ) ) ;
980+ [ return : MarshalAs ( UnmanagedType . LPUTF8Str ) ]
981+ public static extern string il2cpp_image_get_filename ( IntPtr image ) ;
997982
998983 [ DllImport ( "libil2cpp.so" , CallingConvention = CallingConvention . Cdecl , CharSet = CharSet . Ansi ) ]
999984 public static extern IntPtr il2cpp_image_get_entry_point ( IntPtr image ) ;
0 commit comments