Skip to content

Commit

Permalink
Bug 1875097 - Port the mozwer-rust crate to windows-sys r=gsvelto,gla…
Browse files Browse the repository at this point in the history
…ndium

This exchanges `winapi` functions/types for equivalent `windows-sys` ones. Some basic types (e.g.
`PBOOL`) don't exist in `windows-sys`, and I added `type` items for them (though those could be
removed and the types inlined; that's what `windows-sys` does itself).

The `psapi` library needed to be added for GetModuleFileNameExW; I guess previously `winapi` was
linking it?

Almost all manual definitions of types (`winapi::ENUM!` and `winapi::STRUCT!`) were no longer needed
because `windows-sys` has them. Only the version of `RTL_USER_PROCESS_PARAMETERS` with undocumented
fields was still needed.

Differential Revision: https://phabricator.services.mozilla.com/D199111
  • Loading branch information
afranchuk committed Jan 29, 2024
1 parent 41c7d12 commit d0787ae
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 263 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions build/workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,26 @@ features = [
version = "0.52"
optional = true
features = [
"Wdk_System_Threading",
"Win32_Foundation",
"Win32_Security",
"Win32_Storage_FileSystem",
"Win32_System_Com",
"Win32_System_Diagnostics_Debug",
"Win32_System_ErrorReporting",
"Win32_System_Kernel",
"Win32_System_LibraryLoader",
"Win32_System_Memory",
"Win32_System_Pipes",
"Win32_System_ProcessStatus",
"Win32_System_SystemInformation",
"Win32_System_SystemServices",
"Win32_System_Threading"
"Win32_System_Threading",
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
]


[features]
builtins-static = ["dep:bindgen", "dep:bitflags", "dep:memchr", "dep:nom", "dep:regex", "dep:smallvec"]
geckodriver = ["dep:bitflags", "dep:bytes", "dep:cc", "dep:chrono", "dep:flate2", "dep:futures-channel", "dep:futures-core", "dep:futures-sink", "dep:futures-util", "dep:getrandom", "dep:hashbrown", "dep:hyper", "dep:indexmap", "dep:log", "dep:memchr", "dep:mio", "dep:num-integer", "dep:num-traits", "dep:once_cell", "dep:regex", "dep:semver", "dep:serde_json", "dep:smallvec", "dep:time", "dep:tokio", "dep:tokio-util", "dep:tracing", "dep:url", "dep:uuid", "dep:windows-sys"]
Expand All @@ -177,5 +188,5 @@ gkrust-gtest = ["gkrust"]
http3server = ["dep:arrayvec", "dep:bindgen", "dep:bitflags", "dep:bytes", "dep:chrono", "dep:env_logger", "dep:futures-channel", "dep:futures-core", "dep:futures-sink", "dep:futures-util", "dep:getrandom", "dep:hashbrown", "dep:hyper", "dep:indexmap", "dep:log", "dep:memchr", "dep:mio", "dep:nom", "dep:num-integer", "dep:num-traits", "dep:once_cell", "dep:regex", "dep:serde_json", "dep:smallvec", "dep:time", "dep:tokio", "dep:tokio-util", "dep:tracing", "dep:url", "dep:windows-sys"]
ipcclientcerts-static = ["dep:bindgen", "dep:bitflags", "dep:memchr", "dep:nom", "dep:regex"]
jsrust = ["dep:arrayvec", "dep:cc", "dep:env_logger", "dep:getrandom", "dep:hashbrown", "dep:indexmap", "dep:log", "dep:memchr", "dep:num-traits", "dep:once_cell", "dep:semver", "dep:smallvec", "dep:url"]
mozwer_s = ["dep:getrandom", "dep:hashbrown", "dep:indexmap", "dep:once_cell", "dep:serde_json", "dep:uuid"]
mozwer_s = ["dep:getrandom", "dep:hashbrown", "dep:indexmap", "dep:once_cell", "dep:serde_json", "dep:uuid", "dep:windows-sys"]
osclientcerts-static = ["dep:bindgen", "dep:bitflags", "dep:env_logger", "dep:log", "dep:memchr", "dep:nom", "dep:regex"]
22 changes: 21 additions & 1 deletion toolkit/crashreporter/mozwer-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,27 @@ rust-ini = "0.10"
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
uuid = { version = "1.0", features = ["v4"] }
winapi = { version = "0.3", features = ["basetsd", "combaseapi", "handleapi", "impl-default", "knownfolders", "memoryapi", "minwinbase", "minwindef", "ntdef", "ntstatus", "processthreadsapi", "psapi", "shlobj", "synchapi", "winbase", "winerror"] }

[dependencies.windows-sys]
version = "0.52"
features = [
"Wdk_System_Threading",
"Win32_Foundation",
"Win32_Security",
"Win32_Storage_FileSystem",
"Win32_System_Com",
"Win32_System_Diagnostics_Debug",
"Win32_System_ErrorReporting",
"Win32_System_Kernel",
"Win32_System_LibraryLoader",
"Win32_System_Memory",
"Win32_System_ProcessStatus",
"Win32_System_SystemInformation",
"Win32_System_SystemServices",
"Win32_System_Threading",
"Win32_UI_Shell",
"Win32_UI_WindowsAndMessaging",
]

[lib]
name = "mozwer_s"
Expand Down
Loading

0 comments on commit d0787ae

Please sign in to comment.