/// <summary> /// Returns the <see cref="FileOffset"/> and <see cref="RVA"/> of a /// <see cref="ResourceDirectoryEntry"/>. <see cref="SetOffset"/> must have been called. /// </summary> /// <param name="dirEntry">A <see cref="ResourceDirectoryEntry"/></param> /// <param name="fileOffset">Updated with the file offset</param> /// <param name="rva">Updated with the RVA</param> /// <returns><c>true</c> if <paramref name="dirEntry"/> is valid and /// <paramref name="fileOffset"/> and <paramref name="rva"/> have been updated. <c>false</c> /// if <paramref name="dirEntry"/> is not part of the Win32 resources.</returns> public bool GetFileOffsetAndRvaOf(ResourceDirectoryEntry dirEntry, out FileOffset fileOffset, out RVA rva) { var dir = dirEntry as ResourceDirectory; if (dir != null) return GetFileOffsetAndRvaOf(dir, out fileOffset, out rva); var dataHeader = dirEntry as ResourceData; if (dataHeader != null) return GetFileOffsetAndRvaOf(dataHeader, out fileOffset, out rva); fileOffset = 0; rva = 0; return false; }
/// <summary> /// Returns the <see cref="FileOffset"/> of a <see cref="ResourceDirectoryEntry"/>. /// <see cref="SetOffset"/> must have been called. /// </summary> /// <param name="dirEntry">A <see cref="ResourceDirectoryEntry"/></param> /// <returns>The file offset or 0 if <paramref name="dirEntry"/> is invalid</returns> public FileOffset GetFileOffset(ResourceDirectoryEntry dirEntry) { FileOffset fileOffset; RVA rva; GetFileOffsetAndRvaOf(dirEntry, out fileOffset, out rva); return fileOffset; }
uint GetDirectoryEntryOffset(ResourceDirectoryEntry e) { if (e is ResourceData) return dataHeaderDict[(ResourceData)e]; return 0x80000000 | dirDict[(ResourceDirectory)e]; }