dyld way to explain traversal module source code

There are several ways to traverse module (in fact, do not call ergodic module, it should be called the macho all executable files in the traversal process, read on to know why) on mac ios.
Look here dyld way traversal, dyld we all know that this is the fruit of support dynamic linking start macho file, also when you have to depend on other libraries dyld will also fill these pits, traversing module code is: HTTPS: //blog.51cto.com/haidragon/2164203
dyld way to explain traversal module source code
functions used are:

int32_t nModNums= _dyld_image_count();  //获取所有image
pModSlide  = _dyld_get_image_vmaddr_slide(i);//获取单个image随机基址
pszModName = _dyld_get_image_name(i);//名称
pModHeader = _dyld_get_image_header(i); //头

We look directly dyld source, since these functions are packaged dyld above function is not, but we can see the following real, as we can see a getImageCount (); function.
dyld way to explain traversal module source code
See source, as shown in FIG.
dyld way to explain traversal module source code
Is directly returned sAllImages, description is a global variable.
dyld way to explain traversal module source code
It really is a vector. Double-below it will have the corresponding references.

dyld way to explain traversal module source code
We look at the first addImage function.
dyld way to explain traversal module source code

Guess you like

Origin blog.51cto.com/haidragon/2406235