MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / get_lib_size

Function get_lib_size

core/src/utils/dylib.cc:104–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104static size_t get_lib_size(void *base_address)
105{
106#if OS_WIN
107 auto dos_header = (IMAGE_DOS_HEADER *)base_address;
108 auto nt_headers = (IMAGE_NT_HEADERS *)((uint8_t *)(base_address) + dos_header->e_lfanew);
109 return nt_headers->OptionalHeader.SizeOfImage;
110#elif OS_MAC
111 struct mach_header_64 *header = (struct mach_header_64 *)base_address;
112
113 size_t size = sizeof(*header); // Size of the header
114 size += header->sizeofcmds; // Size of the load commands
115
116 struct load_command *lc = (struct load_command *)(header + 1);
117 for (uint32_t i = 0; i < header->ncmds; i++)
118 {
119 if (lc->cmd == LC_SEGMENT_64)
120 {
121 size += ((struct segment_command_64 *)lc)->vmsize; // Size of segments
122 }
123 lc = (struct load_command *)((char *)lc + lc->cmdsize);
124 }
125 return size;
126#endif
127}
128
129void *dylib::find_memory(const void *rladdr, const char *pattern)
130{

Callers 1

find_memoryMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected