| Crates.io | dos |
| lib.rs | dos |
| version | 0.0.3 |
| created_at | 2025-09-21 18:18:56.583715+00 |
| updated_at | 2025-09-27 10:58:23.547671+00 |
| description | Rust-friendly bindings for Windows APIs |
| homepage | |
| repository | https://github.com/dlon/dos-rs |
| max_upload_size | |
| id | 1849019 |
| size | 126,644 |
⚠️ This project is a work in progress.
Rust-friendly bindings for Windows APIs. It is not meant to be exhaustive, only cover areas that the standard library does not.
Add this to your Cargo.toml: cargo add dos
full - Enable all featuresnet - Networkingprocess - Process and module enumerationstring - String conversion utilitiessecurity - Security and access controlsys - System informationIn descending order of importance:
unsafe must be avoided as much as possible, particularly in public APIs.GetUnicastIpAddressTable API is called get_unicast_ip_address_table.List all running processes in the system:
use dos::process::{SnapshotFlags, create_toolhelp32_snapshot};
let snapshot = create_toolhelp32_snapshot(SnapshotFlags::PROCESS, 0)?;
for process in snapshot.processes().take(5) {
let process = process?;
println!("Process ID: {}, Parent ID: {}", process.pid(), process.parent_pid());
}
Get all unicast IP addresses on the system:
use dos::net::get_unicast_ip_address_table;
for address in get_unicast_ip_address_table(None)? {
println!("Interface Index: {}", address.interface_index());
println!("Address: {}", address.address());
println!("Address Family: {:?}", address.family());
}
Get the alias of a network interface using its LUID:
use dos::net::convert_interface_luid_to_alias;
let my_luid = 1234;
let alias = convert_interface_luid_to_alias(my_luid)?;
Get a security descriptor for a file:
use dos::security::{get_security_info, SecurityInformation, ObjectType};
use std::fs::File;
let file = File::open("example.txt")?;
let security_info = get_security_info(
&file,
ObjectType::File,
SecurityInformation::OWNER | SecurityInformation::GROUP
)?;
if let Some(owner) = security_info.owner() {
println!("File has owner SID");
}
if let Some(group) = security_info.group() {
println!("File has group SID");
}
Convert from various code pages to Rust strings:
use dos::string::{multi_byte_to_wide_char, CodePage};
// Convert UTF-8 encoded C string to an OsString
let c_str = c"Hello, World!";
let os_string = multi_byte_to_wide_char(c_str, CodePage::Utf8)?;
println!("Converted: {:?}", os_string);
// Convert from Windows-1252 (Western European)
let c_str = c"Caf\xe9"; // "Café" in Windows-1252
let os_string = multi_byte_to_wide_char(c_str, CodePage::Windows1252)?;
println!("From Windows-1252: {:?}", os_string);
This crate is tested on Windows 10 or later. It may work on earlier Windows versions, but there is no guarantee of that.
Contributions are welcome! Please open an issue or a pull request.
License: MIT