dia-rs/.github/README.md

50 строки
1.5 KiB
Markdown
Исходник Обычный вид История

2021-11-19 09:07:10 +03:00
[![crates.io](https://img.shields.io/crates/v/microsoft-dia.svg)](https://crates.io/crates/microsoft-dia)
## 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:
```toml
[dependencies.windows]
2024-02-25 21:18:40 +03:00
version = "0.53.0"
2021-11-19 09:07:10 +03:00
features = [
"Win32_System_Com"
]
[dependencies.microsoft-dia]
2024-02-25 21:18:40 +03:00
version = "0.10.0"
2021-11-19 09:07:10 +03:00
```
Make use of any DIA SDK APIs as needed.
```rust
2022-09-22 23:57:06 +03:00
use microsoft_dia::{nsfRegularExpression, DiaSource, IDiaDataSource, SymTagFunction};
use windows::{core::*, Win32::System::Com::{CoInitializeEx, COINIT_MULTITHREADED}};
2021-11-19 09:07:10 +03:00
fn main() -> windows::core::Result<()> {
unsafe {
2022-09-22 23:57:06 +03:00
CoInitializeEx(None, COINIT_MULTITHREADED)?;
2021-11-19 09:07:10 +03:00
2022-09-22 23:57:06 +03:00
let source: IDiaDataSource = microsoft_dia::helpers::NoRegCoCreate(s!("msdia140.dll"), &DiaSource)?;
2021-11-19 09:07:10 +03:00
let executable = std::env::current_exe().unwrap();
2022-09-22 23:57:06 +03:00
source.loadDataForExe(&HSTRING::from(executable.as_os_str()), None, None)?;
2021-11-19 09:07:10 +03:00
let session = source.openSession()?;
2022-09-22 23:57:06 +03:00
let symbols = session.globalScope()?.findChildren(SymTagFunction, w!("sample_functions::*"), nsfRegularExpression.0 as u32)?;
2021-11-19 09:07:10 +03:00
2022-09-22 23:57:06 +03:00
println!("Function symbols found in sample_functions::* ({}):", &executable.to_string_lossy());
2021-11-19 09:07:10 +03:00
for i in 0..symbols.Count()? {
println!("\t{}", symbols.Item(i as u32)?.name()?);
}
Ok(())
}
}
2022-09-22 23:57:06 +03:00
2021-11-19 09:07:10 +03:00
```