2525
2626
2727static uint64_t il2cpp_base = 0 ;
28+ std::stringstream method_info_outPut;
2829
2930void init_il2cpp_api (void *handle) {
3031#define DO_API (r, n, p ) { \
@@ -102,6 +103,7 @@ std::string dump_method(Il2CppClass *klass) {
102103 if (method->methodPointer ) {
103104 outPut << " \t // RVA: 0x" ;
104105 outPut << std::hex << (uint64_t ) method->methodPointer - il2cpp_base;
106+ method_info_outPut << std::hex << (uint64_t ) method->methodPointer - il2cpp_base;
105107 outPut << " VA: 0x" ;
106108 outPut << std::hex << (uint64_t ) method->methodPointer ;
107109 } else {
@@ -120,8 +122,12 @@ std::string dump_method(Il2CppClass *klass) {
120122 outPut << " ref " ;
121123 }
122124 auto return_class = il2cpp_class_from_type (return_type);
123- outPut << il2cpp_class_get_name (return_class) << " " << il2cpp_method_get_name (method)
125+ auto method_name = il2cpp_method_get_name (method);
126+ outPut << il2cpp_class_get_name (return_class) << " " << method_name
124127 << " (" ;
128+ if (method->methodPointer ){
129+ method_info_outPut << " :" << method_name << " \n " ;
130+ }
125131 auto param_count = il2cpp_method_get_param_count (method);
126132 for (int i = 0 ; i < param_count; ++i) {
127133 auto param = il2cpp_method_get_param (method, i);
@@ -420,9 +426,7 @@ void il2cpp_api_init(void *handle) {
420426
421427void il2cpp_dump (const char *outDir) {
422428 LOGI (" dumping..." );
423- std::stringstream imageOutput;
424429 std::vector<std::string> outPuts;
425-
426430 if (il2cpp_capture_memory_snapshot && il2cpp_free_captured_memory_snapshot) {
427431 auto memorySnapshot = il2cpp_capture_memory_snapshot ();
428432 auto all_type_infos_count = memorySnapshot->metadata .typeCount ;
@@ -447,18 +451,27 @@ void il2cpp_dump(const char *outDir) {
447451 LOGE (" can not find il2cpp_capture_memory_snapshot!!!" );
448452 }
449453
450-
451-
452454 LOGI (" write dump file" );
453- auto outPath = std::string (outDir).append (" /files/dump .cs" );
455+ auto outPath = std::string (outDir).append (" /files/test .cs" );
454456 std::ofstream outStream (outPath);
455- outStream << imageOutput.str ();
456- auto count = outPuts.size ();
457- for (int i = 0 ; i < count; ++i) {
458- outStream << outPuts[i];
459- }
457+ auto outPath2 = std::string (outDir).append (" /files/test_method_info.txt" );
458+ std::ofstream outStream2 (outPath2);
460459
460+ if (outStream.is_open ()){
461+ auto count = outPuts.size ();
462+ for (int i = 0 ; i < count; ++i) {
463+ outStream << outPuts[i];
464+ }
465+ } else
466+ LOGE (" can not open file:%s" ,outPath.c_str ());
461467
462468 outStream.close ();
469+ if (outStream2.is_open ()){
470+ outStream2 << method_info_outPut.str ();
471+ } else
472+ LOGE (" can not open file:%s" ,outPath2.c_str ());
473+ method_info_outPut.flush ();
474+ method_info_outPut.clear ();
475+ outStream2.close ();
463476 LOGI (" dump done!" );
464477}
0 commit comments