Gawdl3y / Resolute

Mod Manager GUI for Resonite
GNU General Public License v3.0
35 stars 0 forks source link

More mod info from DLL files for mods outside of the manifest #138

Open ljoonal opened 9 months ago

ljoonal commented 9 months ago

I'd love to see the DLL version info be tried to be parsed and be shown similarly as mods from the manifest. Though I'd except the unknown mods to keep the blue question mark to indicate that they aren't actually from the manifest, and the details are just provided by the file metadata :P

I do realize this is most likely a low priority feature request, so I did play around with the idea of making a PR but for now I ran out of time :sweat_smile:

fn get_assembly_version<P: AsRef<Path>>(path: &P) -> Option<semver::Version> {
    use pelite::FileMap;
    use pelite::pe32::{Pe, PeFile};

    let Some(file_map) = FileMap::open(path).ok() else { return None;};
    let Some(file) = PeFile::from_bytes(file_map.as_ref()).ok() else { return None;};
        let Some(resources) = file.resources().ok() else { return None;};
        let Some(version_info) = resources.version_info().ok() else { return None;};
        let Some(fixed_info) = version_info.fixed() else { return None;};
    Some(semver::Version {
            major: fixed_info.dwFileVersion.Major as u64,
            minor: fixed_info.dwFileVersion.Minor as u64,
            patch: fixed_info.dwFileVersion.Patch as u64,
            pre: Default::default(),
            build: semver::BuildMetadata::new(&fixed_info.dwFileVersion.Build.to_string()).unwrap_or_default(),
        })
}

The ProductName could be gotten in a similar way for the hypothetically correct GUIDs to show.