export_symbols.idc
1 #include <idc.idc> 2 3 static bna_format_address(ea) { 4 return sprintf("%08X", ea); 5 } 6 7 static bna_save_function_symbols(fd) { 8 auto func_address; 9 auto func_name; 10 auto func_start; 11 auto func_end; 12 auto func_line; 13 14 while ((func_address = get_next_func(func_address)) != -1) { 15 func_name = get_func_name(func_address); 16 17 if (func_name) { 18 func_start = get_func_attr(func_address, FUNCATTR_START); 19 func_end = get_func_attr(func_address, FUNCATTR_END); 20 21 func_line = sprintf( 22 "%s %s f end=%s ; %08X", 23 func_name, bna_format_address(func_start), bna_format_address(func_end), get_func_attr(func_address, FUNCATTR_FLAGS)); 24 25 if (fprintf(fd, "%s\n", func_line) != 0) { 26 error("bna_save_function_symbols: failed to write line break to file"); 27 return 0; 28 } 29 } 30 } 31 32 return 1; 33 } 34 35 static bna_save_label_symbols(fd) { 36 return 1; 37 } 38 39 static main() { 40 // Ask use for output file 41 auto output_filename; 42 auto output_file; 43 44 output_filename = ask_file(1, "all.sym", "Enter a path to export your symbols"); 45 if (output_filename == 0) { 46 error("No output file specified. Doing NOTHING."); 47 return 1; 48 } 49 50 output_file = fopen(output_filename, "w"); 51 52 if (!output_file) { 53 error("Failed to open output file '%s' for writing", output_filename); 54 return 0; 55 } 56 57 if (!bna_save_function_symbols(output_file)) { 58 return 0; 59 } 60 61 if (!bna_save_label_symbols(output_file)) { 62 return 0; 63 } 64 65 fclose(output_file); 66 67 warning("Successfully exported to %s", output_filename); 68 69 return 1; 70 }