Rust for Debug Interface Access (DIA) SDK
Перейти к файлу
Rafael Rivera 067973229c Update README 2022-03-22 13:53:02 -07:00
.github Update README 2022-03-22 13:53:02 -07:00
.metadata Move to crate gen, update deps 2022-03-02 00:04:00 -08:00
.windows Move to crate gen, update deps 2022-03-02 00:04:00 -08:00
crates Update windows crate dependency (#3) 2022-03-22 09:59:35 -07:00
src Update windows crate dependency (#3) 2022-03-22 09:59:35 -07:00
.gitattributes Initial crate 2021-11-18 22:10:59 -08:00
.gitignore Initial crate 2021-11-18 22:10:59 -08:00
Cargo.toml Update windows crate dependency (#3) 2022-03-22 09:59:35 -07:00
rustfmt.toml Initial crate 2021-11-18 22:10:59 -08:00

.github/README.md

crates.io

Rust for Debug Interface Access (DIA) SDK

The Microsoft Debug Interface Access Software Development Kit (DIA SDK) provides access to debug information stored in program database (.pdb) files generated by Microsoft postcompiler tools.

Start by adding windows and microsoft-dia dependencies to Cargo.toml:

[dependencies.windows]
version = "0.34"
features = [
    "alloc",
    "Win32_System_Com"
]

[dependencies.microsoft-dia]
git = "https://github.com/microsoft/dia-rs"
version = "0.3.0"

Make use of any DIA SDK APIs as needed.

fn main() -> windows::core::Result<()> {
    unsafe {
        CoInitializeEx(std::ptr::null_mut(), COINIT_MULTITHREADED)?;

        let source: IDiaDataSource = microsoft_dia::helpers::NoRegCoCreate("msdia140.dll", &DiaSource)?;
        let executable = std::env::current_exe().unwrap();
        source.loadDataForExe(executable.as_os_str(), None, None)?;
        let session = source.openSession()?;
        let symbols = session.globalScope()?.findChildren(
            SymTagFunction,
            "sample::*",
            nsfRegularExpression.0 as u32,
        )?;

        println!(
            "Function symbols found in sample::* ({}):",
            &executable.to_string_lossy()
        );

        for i in 0..symbols.Count()? {
            println!("\t{}", symbols.Item(i as u32)?.name()?);
        }

        Ok(())
    }
}