// // RQAppEventAnnotation.m // jiaPei // // Created by 张嵘 on 2020/4/8. // Copyright © 2020 JCZ. All rights reserved. // #import "RQAppEventAnnotation.h" #include #include #include #include static NSArray* FFReadConfiguration(char *section) { NSMutableArray *configs = [NSMutableArray array]; Dl_info info; dladdr(FFReadConfiguration, &info); #ifndef __LP64__ // const struct mach_header *mhp = _dyld_get_image_header(0); // both works as below line const struct mach_header *mhp = (struct mach_header*)info.dli_fbase; unsigned long size = 0; uint32_t *memory = (uint32_t*)getsectiondata(mhp, "__DATA", section, & size); #else /* defined(__LP64__) */ const struct mach_header_64 *mhp = (struct mach_header_64*)info.dli_fbase; unsigned long size = 0; uint64_t *memory = (uint64_t*)getsectiondata(mhp, "__DATA", section, & size); #endif /* defined(__LP64__) */ for(int idx = 0; idx < size/sizeof(void*); ++idx){ char *string = (char*)memory[idx]; NSString *str = [NSString stringWithUTF8String:string]; if(!str)continue; if(str) [configs addObject:str]; } return configs; } @implementation RQAppEventAnnotation + (NSArray *)AnnotationModules { static NSArray *mods = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ mods = FFReadConfiguration(RQAppEventModSectName); }); return mods; } @end