private void LoadImports() { importDataDir = header.OptionalHeader.DataDirectories[(int)DataDirectoryName.Import]; if (importDataDir.TargetOffset.FileOffset != 0) { offsetConverter = new OffsetConverter(importDataDir.Section); image.SetOffset(importDataDir.TargetOffset.FileOffset); LibraryReference libraryRef = null; while (true) { libraryRef = ReadLibraryImport(); if (libraryRef == null) { break; } else { foreach (ImportMethod method in libraryRef.ImportMethods) { method.ParentLibrary = libraryRef; } imports.Add(libraryRef); } } } }
public static LibraryReference1 L2L(LibraryReference lf) { LibraryReference1 tmp = new LibraryReference1(lf.LibraryName); tmp.ImportMethods = new ImportMethods1[lf.ImportMethods.Count()]; for (int i = 0; i < lf.ImportMethods.Count(); i++) { tmp.ImportMethods[i] = new ImportMethods1(lf.ImportMethods[i].RVA, lf.ImportMethods[i].Ordinal, lf.ImportMethods[i].Name); } return tmp; }
private LibraryReference ReadLibraryImport() { uint importDirOffset = (uint)image.Position; var rawImportDir = image.ReadStructure <Structures.IMAGE_IMPORT_DESCRIPTOR>(); if (ASMGlobals.IsEmptyStructure(rawImportDir)) { return(null); } string libName = ReadLibraryName(rawImportDir); ImportMethod[] methods = ReadImportMethods(rawImportDir); LibraryReference libReference = new LibraryReference(image, importDirOffset, rawImportDir, libName, methods); // advance to next datadir. image.SetOffset(importDirOffset + sizeof(Structures.IMAGE_IMPORT_DESCRIPTOR)); return(libReference); }
private LibraryReference ReadLibraryImport() { uint importDirOffset = (uint)image.Position; var rawImportDir = image.ReadStructure<Structures.IMAGE_IMPORT_DESCRIPTOR>(); if (ASMGlobals.IsEmptyStructure(rawImportDir)) return null; string libName = ReadLibraryName(rawImportDir); ImportMethod[] methods = ReadImportMethods(rawImportDir); LibraryReference libReference = new LibraryReference(image, importDirOffset, rawImportDir, libName, methods); // advance to next datadir. image.SetOffset(importDirOffset + sizeof(Structures.IMAGE_IMPORT_DESCRIPTOR)); return libReference; }