parsePeVersionResources function

List<PeVersionResource> parsePeVersionResources(
  1. Uint8List bytes
)

Every RT_VERSION leaf in an in-memory image. See readPeVersionResources.

Implementation

List<PeVersionResource> parsePeVersionResources(Uint8List bytes) {
  try {
    final data = ByteData.sublistView(bytes);
    final headers = _parseHeaders(data, bytes.length);
    if (headers == null) return const [];
    final resourceBase = _rvaToOffset(headers.sections, headers.resourceRva);
    if (resourceBase == null) return const [];
    return _readVersionLeaves(
        data, bytes.length, headers.sections, resourceBase);
  } on RangeError {
    // Defence in depth: every read below is bounds-checked, so reaching here
    // means a case was missed — still no throw for the caller.
    return const [];
  }
}