@@ -303,17 +303,17 @@ std::string dump_type_info(Il2CppMetadataType type_info) {
303303 }
304304 outPut << type_info.name ; // TODO genericContainerIndex
305305 std::vector<std::string> extends;
306- auto parent = il2cpp_class_get_parent (klass);
307- if (!is_valuetype && !is_enum && parent) {
308- auto parent_type = il2cpp_class_get_type (parent);
309- if (parent_type->type != IL2CPP_TYPE_OBJECT) {
310- extends.emplace_back (il2cpp_class_get_name (parent));
311- }
312- }
313- void *iter = nullptr ;
314- while (auto itf = il2cpp_class_get_interfaces (klass, &iter)) {
315- extends.emplace_back (il2cpp_class_get_name (itf));
316- }
306+ // auto parent = il2cpp_class_get_parent(klass);
307+ // if (!is_valuetype && !is_enum && parent) {
308+ // auto parent_type = il2cpp_class_get_type(parent);
309+ // if (parent_type->type != IL2CPP_TYPE_OBJECT) {
310+ // extends.emplace_back(il2cpp_class_get_name(parent));
311+ // }
312+ // }
313+ // void *iter = nullptr;
314+ // while (auto itf = il2cpp_class_get_interfaces(klass, &iter)) {
315+ // extends.emplace_back(il2cpp_class_get_name(itf));
316+ // }
317317 if (!extends.empty ()) {
318318 outPut << " : " << extends[0 ];
319319 for (int i = 1 ; i < extends.size (); ++i) {
@@ -329,6 +329,74 @@ std::string dump_type_info(Il2CppMetadataType type_info) {
329329 return outPut.str ();
330330}
331331
332+
333+ void test_il2cpp_api (Il2CppMetadataType type_info){
334+ auto klass = reinterpret_cast <Il2CppClass*>(type_info.typeInfoAddress );
335+ LOGD (" checking il2cpp_class_is_valuetype..." );
336+ il2cpp_class_is_valuetype (klass);
337+ LOGD (" checking il2cpp_class_is_enum..." );
338+ il2cpp_class_is_enum (klass);
339+ LOGD (" checking il2cpp_class_get_fields..." );
340+ void *iter = nullptr ;
341+ auto field = il2cpp_class_get_fields (klass, &iter);
342+ LOGD (" checking il2cpp_field_get_flags..." );
343+ il2cpp_field_get_flags (field);
344+ LOGD (" checking il2cpp_field_get_type..." );
345+ auto field_type = il2cpp_field_get_type (field);
346+ LOGD (" checking il2cpp_class_from_type..." );
347+ auto field_class = il2cpp_class_from_type (field_type);
348+ LOGD (" checking il2cpp_class_get_name..." );
349+ il2cpp_class_get_name (field_class);
350+ LOGD (" checking il2cpp_field_get_name..." );
351+ il2cpp_field_get_name (field);
352+ LOGD (" checking il2cpp_field_static_get_value..." );
353+ uint64_t val = 0 ;
354+ il2cpp_field_static_get_value (field, &val);
355+ LOGD (" checking il2cpp_field_get_offset..." );
356+ il2cpp_field_get_offset (field);
357+
358+ LOGD (" checking il2cpp_class_get_properties..." );
359+ iter = nullptr ;
360+ auto prop_const = il2cpp_class_get_properties (klass, &iter);
361+
362+ auto prop = const_cast <PropertyInfo *>(prop_const);
363+ LOGD (" checking il2cpp_property_get_get_method..." );
364+ auto get = il2cpp_property_get_get_method (prop);
365+ LOGD (" checking il2cpp_property_get_set_method..." );
366+ il2cpp_property_get_set_method (prop);
367+ LOGD (" checking il2cpp_property_get_name..." );
368+ auto prop_name = il2cpp_property_get_name (prop);
369+
370+ uint32_t iflags = 0 ;
371+ LOGD (" checking il2cpp_method_get_flags..." );
372+ auto method_flag = il2cpp_method_get_flags (get, &iflags);
373+ LOGD (" checking get_method_modifier..." );
374+ get_method_modifier (method_flag);
375+ LOGD (" checking il2cpp_method_get_return_type..." );
376+ auto return_type = il2cpp_method_get_return_type (get);
377+ LOGD (" checking il2cpp_type_is_byref..." );
378+ il2cpp_type_is_byref (return_type);
379+
380+ iter = nullptr ;
381+ LOGD (" checking il2cpp_class_get_methods..." );
382+ auto method = il2cpp_class_get_methods (klass, &iter);
383+ LOGD (" checking il2cpp_method_get_name..." );
384+ il2cpp_method_get_name (method);
385+ LOGD (" checking il2cpp_method_get_param_count..." );
386+ auto count = il2cpp_method_get_param_count (method);
387+ if (count!=0 ){
388+ LOGD (" checking il2cpp_method_get_param..." );
389+ il2cpp_method_get_param (method, 0 );
390+ LOGD (" checking il2cpp_method_get_param_name..." );
391+ il2cpp_method_get_param_name (method, 0 );
392+ } else {
393+ LOGE (" no test il2cpp_method_get_param and il2cpp_method_get_param_name" );
394+ }
395+
396+ LOGD (" all test success." );
397+
398+ }
399+
332400void il2cpp_api_init (void *handle) {
333401 LOGI (" il2cpp_handle: %p" , handle);
334402 init_il2cpp_api (handle);
@@ -360,6 +428,15 @@ void il2cpp_dump(const char *outDir) {
360428 auto all_type_infos_count = memorySnapshot->metadata .typeCount ;
361429 auto all_type_infos = memorySnapshot->metadata .types ;
362430 LOGD (" all_typeCount:%d" ,all_type_infos_count);
431+
432+ for (int i = 0 ; i < all_type_infos_count; ++i) {
433+ if (strcmp (all_type_infos[i].name ," System.String" )==0 ){
434+ LOGD (" test start." );
435+ test_il2cpp_api (all_type_infos[i]);
436+ break ;
437+ }
438+ }
439+
363440 for (int k = 0 ; k < all_type_infos_count; ++k) {
364441 auto tmp_type_info = all_type_infos[k];
365442 auto outPut = std::string (tmp_type_info.assemblyName )+" .dll\n " + dump_type_info (tmp_type_info);
@@ -380,6 +457,8 @@ void il2cpp_dump(const char *outDir) {
380457 for (int i = 0 ; i < count; ++i) {
381458 outStream << outPuts[i];
382459 }
460+
461+
383462 outStream.close ();
384463 LOGI (" dump done!" );
385464}
0 commit comments