// include/linux/mm_types.h
/*
* This struct defines a memory VMM memory area. There is one of these
* per VM-area/task. A VM area is any part of the process virtual memory
* space that has a special rule for the page-fault handlers (ie a shared
* library, the executable area etc).
*/structvm_area_struct{/* The first cache line has the info for VMA tree walking. */unsignedlongvm_start;/* Our start address within vm_mm. */unsignedlongvm_end;/* The first byte after our end address
within vm_mm. *//* linked list of VM areas per task, sorted by address */structvm_area_struct*vm_next,*vm_prev;structrb_nodevm_rb;/*
* Largest free memory gap in bytes to the left of this VMA.
* Either between this VMA and vma->vm_prev, or between one of the
* VMAs below us in the VMA rbtree and its ->vm_prev. This helps
* get_unmapped_area find a free area of the right size.
*/unsignedlongrb_subtree_gap;/* Second cache line starts here. */structmm_struct*vm_mm;/* The address space we belong to. */pgprot_tvm_page_prot;/* Access permissions of this VMA. */unsignedlongvm_flags;/* Flags, see mm.h. *//*
* For areas with an address space and backing store,
* linkage into the address_space->i_mmap interval tree.
*
* For private anonymous mappings, a pointer to a null terminated string
* in the user process containing the name given to the vma, or NULL
* if unnamed.
*/union{struct{structrb_noderb;unsignedlongrb_subtree_last;}shared;constchar__user*anon_name;};/*
* A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
* list, after a COW of one of the file pages. A MAP_SHARED vma
* can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
* or brk vma (with NULL file) can only be in an anon_vma list.
*/structlist_headanon_vma_chain;/* Serialized by mmap_sem &
* page_table_lock */structanon_vma*anon_vma;/* Serialized by page_table_lock *//* Function pointers to deal with this struct. */conststructvm_operations_struct*vm_ops;/* Information about our backing store: */unsignedlongvm_pgoff;/* Offset (within vm_file) in PAGE_SIZE
units */structfile*vm_file;/* File we map to (can be NULL). */void*vm_private_data;/* was vm_pte (shared mem) */atomic_long_tswap_readahead_info;#ifndef CONFIG_MMU
structvm_region*vm_region;/* NOMMU mapping region */#endif
#ifdef CONFIG_NUMA
structmempolicy*vm_policy;/* NUMA policy for the VMA */#endif
structvm_userfaultfd_ctxvm_userfaultfd_ctx;#ifdef CONFIG_SPECULATIVE_PAGE_FAULT
seqcount_tvm_sequence;atomic_tvm_ref_count;/* see vma_get(), vma_put() */#endif
}__randomize_layout;
staticvoid// 入参为文件指针以及vma指针
show_map_vma(structseq_file*m,structvm_area_struct*vma){structmm_struct*mm=vma->vm_mm;structfile*file=vma->vm_file;vm_flags_tflags=vma->vm_flags;unsignedlongino=0;unsignedlonglongpgoff=0;unsignedlongstart,end;dev_tdev=0;constchar*name=NULL;if(file){// 判断是否是普通文件映射,是的话则关联的几个字段都需要赋值
structinode*inode=file_inode(vma->vm_file);dev=inode->i_sb->s_dev;ino=inode->i_ino;pgoff=((loff_t)vma->vm_pgoff)<<PAGE_SHIFT;}start=vma->vm_start;end=vma->vm_end;// 打印前五列
show_vma_header_prefix(m,start,end,flags,pgoff,dev,ino);/*
* Print the dentry name for named mappings, and a
* special [heap] marker for the heap:
*/if(file){seq_pad(m,' ');seq_file_path(m,file,"\n");gotodone;}if(vma->vm_ops&&vma->vm_ops->name){name=vma->vm_ops->name(vma);if(name)gotodone;}name=arch_vma_name(vma);// 判断具体类型:文件、堆栈还是其他
if(!name){if(!mm){name="[vdso]";gotodone;}if(vma->vm_start<=mm->brk&&vma->vm_end>=mm->start_brk){name="[heap]";gotodone;}if(is_stack(vma)){name="[stack]";gotodone;}if(vma_get_anon_name(vma)){seq_pad(m,' ');seq_print_vma_name(m,vma);}}done:if(name){seq_pad(m,' ');seq_puts(m,name);}seq_putc(m,'\n');}staticvoidshow_vma_header_prefix(structseq_file*m,unsignedlongstart,unsignedlongend,vm_flags_tflags,unsignedlonglongpgoff,dev_tdev,unsignedlongino){seq_setwidth(m,25+sizeof(void*)*6-1);seq_printf(m,"%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu ",start,end,flags&VM_READ?'r':'-',flags&VM_WRITE?'w':'-',flags&VM_EXEC?'x':'-',flags&VM_MAYSHARE?'s':'p',pgoff,MAJOR(dev),MINOR(dev),ino);}
voidInstallInlineHooks(){if(installed.exchange(true))[[unlikely]]{LOGD("Inline hooks have been installed, skip");return;}LOGD("Start to install inline hooks");constauto&handle_libart=*art_img;if(!handle_libart.isValid()){LOGE("Failed to fetch libart.so");}art::Runtime::Setup(handle_libart);art::hidden_api::DisableHiddenApi(handle_libart);art::art_method::Setup(handle_libart);art::Thread::Setup(handle_libart);art::ClassLinker::Setup(handle_libart);art::mirror::Class::Setup(handle_libart);art::JNIEnvExt::Setup(handle_libart);art::instrumentation::DisableUpdateHookedMethodsCode(handle_libart);art::thread_list::ScopedSuspendAll::Setup(handle_libart);art::gc::ScopedGCCriticalSection::Setup(handle_libart);art::jit::jit_code_cache::Setup(handle_libart);art_img.reset();LOGD("Inline hooks installed");}