MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / ResolveSymbol

Method ResolveSymbol

tools/gdc-psyfork/MemoryUtils.cpp:187–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187void *MemoryUtils::ResolveSymbol(void *handle, const char *symbol)
188{
189#ifdef PLATFORM_WINDOWS
190
191 return GetProcAddress((HMODULE)handle, symbol);
192
193#elif defined PLATFORM_LINUX
194
195 struct link_map *dlmap;
196 struct stat dlstat;
197 int dlfile;
198 uintptr_t map_base;
199 Elf32_Ehdr *file_hdr;
200 Elf32_Shdr *sections, *shstrtab_hdr, *symtab_hdr, *strtab_hdr;
201 Elf32_Sym *symtab;
202 const char *shstrtab, *strtab;
203 uint16_t section_count;
204 uint32_t symbol_count;
205 LibSymbolTable *libtable;
206 SymbolTable *table;
207 AddrTable *table2;
208 Symbol *symbol_entry;
209
210 dlmap = (struct link_map *)handle;
211 symtab_hdr = NULL;
212 strtab_hdr = NULL;
213 table = NULL;
214 table2 = NULL;
215
216 /* See if we already have a symbol table for this library */
217 for (size_t i = 0; i < m_SymTables.size(); i++)
218 {
219 libtable = m_SymTables[i];
220 if (libtable->lib_base == dlmap->l_addr)
221 {
222 table = &libtable->table;
223 table2 = &libtable->table2;
224 break;
225 }
226 }
227
228 /* If we don't have a symbol table for this library, then create one */
229 if (table == NULL)
230 {
231 libtable = new LibSymbolTable();
232 libtable->table.Initialize();
233 libtable->table2.Initialize();
234 libtable->lib_base = dlmap->l_addr;
235 libtable->last_pos = 0;
236 table = &libtable->table;
237 table2 = &libtable->table2;
238 m_SymTables.push_back(libtable);
239 }
240
241 /* See if the symbol is already cached in our table */
242 symbol_entry = table->FindSymbol(symbol, strlen(symbol));
243 if (symbol_entry != NULL)
244 {

Callers 3

mainFunction · 0.45
GetLinuxSigPtrFunction · 0.45
checkSigStringLFunction · 0.45

Calls 5

push_backMethod · 0.80
sizeMethod · 0.45
InitializeMethod · 0.45
FindSymbolMethod · 0.45
InternSymbolMethod · 0.45

Tested by

no test coverage detected