internal DataDirectory(PortableExecutableImage image, DataDirectories dataDirs, DataDirectoryType dirType, IMAGE_DATA_DIRECTORY dataDirectory, ulong imageBase) { _image = image; _type = dirType; _header = dataDirectory; _imageBase = imageBase; _sectionName = new Lazy <string>(DoGetSectionName); _section = new Lazy <Section>(DoGetSection); Directories = dataDirs; }
private static void DataDirectory_Exists(string fileName, DataDirectoryType type, bool expectedValue) { var file = TestingUtils.GetFileFromResources(fileName); using (var image = PortableExecutableImage.FromStream(file)) { var value = image.NTHeaders.DataDirectories.ExistsAndNotEmpty(type); value.Should().Be(expectedValue); } }
public DataDirectoryEntry this[DataDirectoryType idx] { get { return(Items[(int)idx]); } set { Items[(int)idx] = value; } }
/// <summary> /// 获得目录 /// </summary> /// <param name="type"></param> /// <param name="appendix"></param> /// <returns></returns> public static string GetDirectory(DataDirectoryType type, string appendix) { switch (type) { case DataDirectoryType.Global: return(GlobalDataDirectory + "\\" + (appendix == null ? string.Empty : appendix)); case DataDirectoryType.User: return(UserDataDirectory + "\\" + (appendix == null ? string.Empty : appendix)); default: throw new ArgumentException("Invalid DataDirectory Type1"); } }
public bool ExistsAndNotEmpty(DataDirectoryType directoryType) { if (!_directories.ContainsKey(directoryType)) { return(false); } var dataDirectory = _directories[directoryType]; if (DataDirectory.IsNullOrEmpty(dataDirectory)) { return(false); } return(true); }
public void LoadDataDirectories() { DataDirectories = new Dictionary <DataDirectoryType, DataDirectory>(DataDirectoryHeaders.Length); for (int i = 0; i < DataDirectoryHeaders.Length; i++) { var ddh = DataDirectoryHeaders[i]; if (ddh.Size == 0) { continue; } var begin = ddh.VirtualAddress; var end = begin + ddh.Size; var section = SectionFromVirtualAddressRange(begin, end); DataDirectoryType type = (DataDirectoryType)i; DataDirectories[type] = new DataDirectory { Type = type, Offset = ddh.VirtualAddress - section.VirtualAddress, Section = section, Size = ddh.Size }; } }
/// <summary> /// 获得目录 /// </summary> /// <param name="type"></param> /// <param name="appendix"></param> /// <returns></returns> public static string GetDirectory(DataDirectoryType type, string appendix) { switch (type) { case DataDirectoryType.Global: return GlobalDataDirectory + "\\" + (appendix == null ? string.Empty : appendix); case DataDirectoryType.User: return UserDataDirectory + "\\" + (appendix == null ? string.Empty : appendix); default: throw new ArgumentException("Invalid DataDirectory Type1"); } }
public Directory(string name, uint addr, uint size) { this._type = (DataDirectoryType)Enum.Parse(typeof(DataDirectoryType), name); this.VirtualAddr = addr; this.VirtualSize = size; }
public Directory(DataDirectoryType type, uint addr, uint size) { this._type = type; this.VirtualAddr = addr; this.VirtualSize = size; }
public Directory(ImageDataDirectory dir, DataDirectoryType type) : this(type, dir.VirtualAddress, dir.Size) { this._directory = dir; }
public bool Exists(DataDirectoryType directoryType) { return(_directories.ContainsKey(directoryType)); }
public DataDirectory this[DataDirectoryType directoryType] => (_directories.ContainsKey(directoryType) ? _directories[directoryType] : null);
internal DataDirectoryEntry(DataDirectoryType type, uint adr, uint s) { Type = type; Address = adr; Size = s; }
int FindDataDirectoryOffset(DataDirectoryType type) { var rva = (uint)_dataDirectories[(int)type].RVA; return FindRvaOffset(rva); }
public DataDirectory DataDirectory(DataDirectoryType type) => DataDirectory((int)type);