void listClasses(_Module* module, int pageSize) { const wchar16_t* moduleName = module->Name(); int row = 0; ReferenceMap::Iterator it = ((Module*)module)->References(); while (!it.Eof()) { const wchar16_t* reference = it.key(); NamespaceName ns(it.key()); if (StringHelper::compare(moduleName, ns)) { ReferenceName name(it.key()); if (module->mapSection(*it | mskVMTRef, true)) { wprintf(_T("class %s\n"), (const wchar16_t*)name); } else wprintf(_T("symbol %s\n"), (const wchar16_t*)name); row++; if (row == pageSize) { wprintf(_T("Press any key to continue...")); fgetchar(); wprintf(_T("\n")); row = 0; } } it++; } }
int Linker :: fillImportTable(ImageInfo& info) { int count = 0; ReferenceMap::Iterator it = info.image->getExternalIt(); while (!it.Eof()) { ident_t external = it.key(); ident_t function = external + external.findLast('.') + 1; IdentifierString dll(external + getlength(DLL_NAMESPACE) + 1, function - (external + getlength(DLL_NAMESPACE)) - 2); if (dll.ident().compare(RTDLL_FORWARD)) { dll.copy(info.project->resolvePrimitive(RTDLL_FORWARD)); } ReferenceMap* functions = info.importTable.get(dll); if (functions==NULL) { functions = new ReferenceMap(0); info.importTable.add(dll, functions); } functions->add(function, *it); it++; count++; } return count; }
void Linker::createImportTable64(ImageInfo& info) { size_t count = fillImportTable(info); Section* import = info.image->getImportSection(); MemoryWriter writer(import); // reference to the import section ref_t importRef = (count + 1) | mskImportRef; info.map.importMapping.add(importRef, 0); MemoryWriter tableWriter(import); writer.writeBytes(0, (count + 1) * 20); // fill import table MemoryWriter fwdWriter(import); writer.writeBytes(0, (info.importTable.Count() + count) * 8); // fill forward table MemoryWriter lstWriter(import); writer.writeBytes(0, (info.importTable.Count() + count) * 8); // fill import list ImportTable::Iterator dll = info.importTable.start(); while (!dll.Eof()) { tableWriter.writeRef(importRef, lstWriter.Position()); // OriginalFirstThunk tableWriter.writeDWord((pos_t)time(NULL)); // TimeDateStamp tableWriter.writeDWord((pos_t)-1); // ForwarderChain tableWriter.writeRef(importRef, import->Length()); // Name const char* dllName = dll.key(); writer.write(dllName, getlength(dllName)); writer.writeChar('.'); writer.writeLiteral("dll"); tableWriter.writeRef(importRef, fwdWriter.Position()); // ForwarderChain // fill OriginalFirstThunk & ForwarderChain ReferenceMap::Iterator fun = (*dll)->start(); while (!fun.Eof()) { info.map.importMapping.add(*fun, fwdWriter.Position()); // NOTE : the reference are 64 bit, but fixing function will ignore the high dword fwdWriter.writeRef(importRef, import->Length()); fwdWriter.writeDWord(0); lstWriter.writeRef(importRef, import->Length()); lstWriter.writeDWord(0); writer.writeWord(1); // Hint (not used) writer.writeLiteral(fun.key()); fun++; } lstWriter.writeDWord(0); // mark end of chains lstWriter.writeDWord(0); fwdWriter.writeDWord(0); fwdWriter.writeDWord(0); dll++; } }
void listClasses(_Module* module, int pageSize) { ident_t moduleName = module->Name(); int row = 0; ReferenceMap::Iterator it = ((Module*)module)->References(); while (!it.Eof()) { ident_t reference = it.key(); if (isWeakReference(reference)) { if (module->mapSection(*it | mskVMTRef, true)) { printLine("class ", reference + 1, row, pageSize); } else if (module->mapSection(*it | mskSymbolRef, true)) { printLine("symbol ", reference + 1, row, pageSize); } } it++; } }
void printAPI(_Module* module, int pageSize) { ident_t moduleName = module->Name(); ReferenceMap::Iterator it = ((Module*)module)->References(); while (!it.Eof()) { ident_t reference = it.key(); NamespaceName ns(it.key()); if (moduleName.compare(ns)) { ReferenceName name(it.key()); if (module->mapSection(*it | mskVMTRef, true)) { printLine("class ", name); listClassMethods(module, name, pageSize, true, true); printLine(); } else if (module->mapSection(*it | mskSymbolRef, true)) { printLine("symbol ", name); } } it++; } }