Android java脱壳(修改art源码方案)

9.0 aosp 修改源码地方:

android-p/art/runtime/dex/art_dex_file_loader.cc
OpenCommon函数中添加

7.0 8.0 8.1 修改源码地方:

android-p/art/runtime/dex_file.cc
OpenMemory函数添加

  ALOGD("OpenMemory begin... %s", path.c_str());

  if (!base) {
    ALOGD("OpenMemory, base is null");
  }

  bool flag = true;
  if (flag && base && size > 0) {
    char savePath[512] = {0,};

    sprintf(savePath, "/data/data/com.abchina.ebizbtob/files/%p.dex", base);

    ALOGD("openmemory, savePath: %s", savePath);
    //create file whose path is savePath
#ifdef __LP64__
    int fd_save = -1; 
#else
    int flags = O_RDWR | O_CREAT;
    mode_t mode = S_IRWXO | S_IRWXU;
    int fd_save = syscall(__NR_open, savePath, flags, mode);
#endif


// if (fd_save <= 0) {

// sprintf(savePath, "/sdcard/%p.dex", base);
// fd_save = open(savePath, flags, mode);
// }
    if (fd_save <= 0) {
      char * mesg = strerror(errno);
      ALOGD("OpenMemory, open %s failed,error msg: %s", savePath, mesg);
    }   
    //int fd_save = 100;
    char* dexAddr = (char *)base;
    size_t write_size = 0;
    while (fd_save > 0 && write_size < size) {
      syscall(__NR_write, fd_save, dexAddr, kPageSize);
      dexAddr += kPageSize;
      write_size += kPageSize;
    }   
    ALOGD("OpenMemory, location: %s, base: %p, size: %zu, write_size: %zu", location.c_str(), base, size, write_size);
    if (fd_save > 0) syscall(__NR_close, fd_save);
  }

你可能感兴趣的:(Android,Framework)