保存dex文件
| 18 | |
| 19 | //保存dex文件 |
| 20 | void save_dex_file(u_int8_t *data, size_t length) { |
| 21 | char dname[1024]; |
| 22 | get_file_name(dname, sizeof(dname), length); |
| 23 | void *p = fopen(dname, "r"); |
| 24 | if (p != NULL) { |
| 25 | __android_log_print(ANDROID_LOG_INFO, TAG, "%s file exist", dname); |
| 26 | return; |
| 27 | } |
| 28 | __android_log_print(ANDROID_LOG_INFO, TAG, "dump dex file name is : %s", dname); |
| 29 | __android_log_print(ANDROID_LOG_INFO, TAG, "start dump"); |
| 30 | int dex = open(dname, O_CREAT | O_WRONLY, 0644); |
| 31 | if (dex < 0) { |
| 32 | __android_log_print(ANDROID_LOG_ERROR, TAG, "open or create file error"); |
| 33 | return; |
| 34 | } |
| 35 | int ret = (int) write(dex, data, length); |
| 36 | if (ret < 0) { |
| 37 | __android_log_print(ANDROID_LOG_ERROR, TAG, "write file error"); |
| 38 | } else { |
| 39 | __android_log_print(ANDROID_LOG_INFO, TAG, "dump dex file success `%s`", dname); |
| 40 | } |
| 41 | close(dex); |
| 42 | } |
| 43 | |
| 44 | |
| 45 | void init_package_name(char *package_name) { |
no test coverage detected