selectPeVersionResource function

PeVersionResource? selectPeVersionResource(
  1. List<PeVersionResource> resources
)

Picks the single resource the OS view would report: the numeric id 1 entry when the image has one, otherwise the first the directory lists.

GetFileVersionInfo looks up id 1 only, so preferring it keeps the two views on the same leaf. Without the rule the answer would flip on entry order alone — resource directories sort named entries first, so an image carrying both #1 and VS_VERSION_INFO would otherwise report the named one.

Implementation

PeVersionResource? selectPeVersionResource(List<PeVersionResource> resources) {
  for (final resource in resources) {
    if (resource.resourceName == '#$_versionResourceId') return resource;
  }
  return resources.isEmpty ? null : resources.first;
}