Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid major windows crate dependency #31

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,24 @@ 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:
Start by adding `windows-core` and `microsoft-dia` dependencies to Cargo.toml:

```toml
[dependencies.windows]
version = "0.58.0"
features = [
"Win32_System_Com"
]
[dependencies.windows-core]
version = "0.59"

[dependencies.microsoft-dia]
version = "0.11.0"
version = "0.11"
```

Make use of any DIA SDK APIs as needed.

```rust
use microsoft_dia::{nsfRegularExpression, DiaSource, IDiaDataSource, SymTagFunction};
use windows::{core::*, Win32::System::Com::{CoInitializeEx, COINIT_MULTITHREADED}};
use windows_core::*;

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

let source: IDiaDataSource = microsoft_dia::helpers::NoRegCoCreate(s!("msdia140.dll"), &DiaSource)?;
let executable = std::env::current_exe().unwrap();
source.loadDataForExe(&HSTRING::from(executable.as_os_str()), None, None)?;
Expand Down
12 changes: 3 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,11 @@ exclude = [".github", ".metadata", "docs", "tests"]
[workspace]
members = ["crates/samples/*", "crates/tests/*"]

[dependencies.windows]
version = "0.59"
features = [
"Win32_System_Variant",
"Win32_System_LibraryLoader",
"Win32_System_Com_StructuredStorage",
"Win32_System_Ole",
]

[dependencies.windows-core]
version = "0.59"

[dependencies.windows-targets]
version = "0.53"

[build-dependencies.windows-bindgen]
version = "0.59"
16 changes: 15 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,22 @@ fn main() {
"default",
".windows/winmd/Microsoft.Dia.winmd",
"--out",
"src/bindings.rs",
"src/public_bindings.rs",
"--flat",
"--filter",
"Microsoft.Dia",
]);

windows_bindgen::bindgen([
"--in",
"default",
"--out",
"src/helper_bindings.rs",
"--flat",
"--filter",
"IClassFactory",
"LoadLibraryExA",
"GetProcAddress",
"LOAD_WITH_ALTERED_SEARCH_PATH",
]);
}
6 changes: 3 additions & 3 deletions crates/samples/checksum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
publish = false

[dependencies.windows]
version = "0.59"

[dependencies.microsoft-dia]
path = "../../../"

[dependencies.windows-core]
version = "0.59"
7 changes: 1 addition & 6 deletions crates/samples/checksum/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
use microsoft_dia::{nsNone, DiaSource, IDiaDataSource, SymTagCompiland};
use windows::{
core::*,
Win32::System::Com::{CoInitializeEx, COINIT_MULTITHREADED},
};
use windows_core::*;

fn main() -> Result<()> {
unsafe {
// Initialize COM and DIA
CoInitializeEx(None, COINIT_MULTITHREADED).ok()?;
let source: IDiaDataSource = microsoft_dia::helpers::NoRegCoCreate(
s!(
r#"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\DIA SDK\bin\amd64\msdia140.dll"#
Expand Down
6 changes: 3 additions & 3 deletions crates/samples/functions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
publish = false

[dependencies.windows]
version = "0.59"

[dependencies.microsoft-dia]
path = "../../../"

[dependencies.windows-core]
version = "0.59"
6 changes: 1 addition & 5 deletions crates/samples/functions/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use microsoft_dia::{nsfRegularExpression, DiaSource, IDiaDataSource, SymTagFunction};
use windows::{
core::*,
Win32::System::Com::{CoInitializeEx, COINIT_MULTITHREADED},
};
use windows_core::*;

fn main() -> Result<()> {
unsafe {
CoInitializeEx(None, COINIT_MULTITHREADED).ok()?;
let source: IDiaDataSource = microsoft_dia::helpers::NoRegCoCreate(
s!(
r#"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\DIA SDK\bin\amd64\msdia140.dll"#
Expand Down
2 changes: 1 addition & 1 deletion crates/tests/enumerators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.0.0"
edition = "2021"
publish = false

[dependencies.windows]
[dependencies.windows-core]
version = "0.59"

[dependencies.microsoft-dia]
Expand Down
10 changes: 2 additions & 8 deletions crates/tests/enumerators/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
use microsoft_dia::{nsfRegularExpression, DiaSource, IDiaDataSource, IDiaSession, SymTagNull};
use windows::{
core::*,
Win32::{
Foundation::S_OK,
System::Com::{CoInitializeEx, COINIT_MULTITHREADED},
},
};
use windows_core::*;
const S_OK: HRESULT = HRESULT(0);

fn get_test_session() -> Result<IDiaSession> {
unsafe {
CoInitializeEx(None, COINIT_MULTITHREADED).ok()?;
let path = if cfg!(target_arch = "x86_64") {
s!(
r"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\DIA SDK\bin\amd64\msdia140.dll"
Expand Down
Loading