internal ResourcesReader(NTHeader header) { this.header = header; this.image = header._assembly._peImage; resourceDirectory = header.OptionalHeader.DataDirectories[(int)DataDirectoryName.Resource]; if (header._assembly._peImage.TrySetOffset(resourceDirectory.TargetOffset.FileOffset)) { stream = header._assembly._peImage.ReadStream((int)resourceDirectory.Size); reader = new BinaryReader(stream); ReadRootDirectory(); } }
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); } } } }
private void CompleteDataDirectories(Dictionary<uint, Structures.IMAGE_DATA_DIRECTORY> rawdatadirs) { var keys = rawdatadirs.Keys.ToArray(); var values = rawdatadirs.Values.ToArray(); for (int i = 0; i < rawdatadirs.Count - 1; i++) { DataDirectory datadir = new DataDirectory((DataDirectoryName)i, sections.ToArray(), keys[i], values[i]); datadirectories.Add(datadir); } }