tugger_binary_analysis/
pe.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5use {anyhow::Result, std::path::Path};
6
7pub fn find_pe_dependencies(data: &[u8]) -> Result<Vec<String>> {
8    let pe = goblin::pe::PE::parse(data)?;
9    Ok(pe.libraries.iter().map(|l| (*l).to_string()).collect())
10}
11
12#[allow(unused)]
13pub fn find_pe_dependencies_path(path: &Path) -> Result<Vec<String>> {
14    let data = std::fs::read(path)?;
15    find_pe_dependencies(&data)
16}