Windows-rs - Rust for Windows

Overview

crates.io build

Rust for Windows

The windows crate lets you call any Windows API past, present, and future using code generated on the fly directly from the metadata describing the API and right into your Rust package where you can call them as if they were just another Rust module. The Rust language projection follows in the tradition established by C++/WinRT of building language projections for Windows using standard languages and compilers, providing a natural and idiomatic way for Rust developers to call Windows APIs.

Start by adding the following to your Cargo.toml file:

[dependencies.windows]
version = "0.29.0"
features = [
    "alloc",
    "Data_Xml_Dom",
    "Win32_Foundation",
    "Win32_Security",
    "Win32_System_Threading",
    "Win32_UI_WindowsAndMessaging",
]

Make use of any Windows APIs as needed.

use windows::{
    core::*, Data::Xml::Dom::*, Win32::Foundation::*, Win32::System::Threading::*,
    Win32::UI::WindowsAndMessaging::*,
};

fn main() -> Result<()> {
    let doc = XmlDocument::new()?;
    doc.LoadXml("<html>hello world</html>")?;

    let root = doc.DocumentElement()?;
    assert!(root.NodeName()? == "html");
    assert!(root.InnerText()? == "hello world");

    unsafe {
        let event = CreateEventW(std::ptr::null_mut(), true, false, None);
        SetEvent(event).ok()?;
        WaitForSingleObject(event, 0);
        CloseHandle(event).ok()?;

        MessageBoxA(None, "Text", "Caption", MB_OK);
    }

    Ok(())
}

windows-sys

The windows-sys crate is a zero-overhead fallback for the most demanding situations and primarily where the absolute best compile time is essential. It only includes function declarations (externs), structs, and constants. No convenience helpers, traits, or wrappers are provided.

Start by adding the following to your Cargo.toml file:

[dependencies.windows-sys]
version = "0.29.0"
features = [
    "Win32_Foundation",
    "Win32_Security",
    "Win32_System_Threading",
    "Win32_UI_WindowsAndMessaging",
]

Make use of any Windows APIs as needed.

use windows_sys::{Win32::Foundation::*, Win32::System::Threading::*, Win32::UI::WindowsAndMessaging::*};

fn main() {
    unsafe {
        let event = CreateEventW(std::ptr::null_mut(), 1, 0, std::ptr::null_mut());
        SetEvent(event);
        WaitForSingleObject(event, 0);
        CloseHandle(event);

        MessageBoxA(0, b"Text\0".as_ptr() as _, b"Caption\0".as_ptr() as _, MB_OK);
    }
}
Comments
  • Are you using the Windows crate?

    Are you using the Windows crate?

    Hi folks, we're trying to gauge adoption and understand how we can best serve the Rust community with the Windows crate. In order to do this, I would love to hear from you! How has the Windows crate influenced your decision making? Did it help you decide to use Rust or target Windows? Is Rust replacing another language for a product you've previously shipped?

    Feel free to leave a response here or email me directly to keep things private: [email protected]

    If the Windows crate matters to you, don't miss this opportunity to let me know and help influence the future of Rust on Windows.

    question 
    opened by kennykerr 44
  • Remove `unimplemented!(

    Remove `unimplemented!("Unsupported target OS");` to allow _running_ on Linux and WSL

    The "problem"

    Currently the windows crate is allowed to compile on non-windows systems thanks to a rather large block of code, replicated across every function:

    pub unsafe fn DxcCreateInstance2(...) -> Result {
        #[cfg(windows)]
        {
            #[link(name = "windows")]
            extern "system" {
                fn DxcCreateInstance2(...) -> ::windows::core::HRESULT;
            }
            let mut result__ = ::core::option::Option::None;
            DxcCreateInstance2(...).and_some(result__)
        }
        #[cfg(not(windows))]
        unimplemented!("Unsupported target OS");
    }
    

    I remember discussing this long ago: it was needed for CI but seems to have never been removed, as there wasn't much reason to run on non-windows anyway.

    Rust is supposed to omit linkage when functions aren't used: any extern "system" { pub fn blah(); } doesn't show up in the symbol table if it isn't called into. However, this isn't the case for #[link]: -lwindows is added to the linker invocation even if no functions from the extern "system" block it is annotating are called. That is evident in the windows-sys crate which doesn't carry any cfg(windows) around #[link] attributes: it is inconveniently used in the metadata crate that's subsequently used by all the tools, not allowing any of them to be ran on non-Windows (= note: mold: fatal: library not found: windows) even though they don't reference a single function, just some typedefs.

    Proposed solution

    Now, combine those two points and we can turn the above into:

    pub unsafe fn DxcCreateInstance2(...) -> Result {
        #[cfg_attr(windows, link(name = "windows"))]
        extern "system" {
            fn DxcCreateInstance2(...) -> ::windows::core::HRESULT;
        }
        let mut result__ = ::core::option::Option::None;
        DxcCreateInstance2(...).and_some(result__)
    }
    

    (Dis)advantages

    Disclaimer: most of the below applies to non-windows only, which perhaps still isn't "in scope" of the project - but I do hope we can discuss and consider this, especially in light of com-rs being officially deprecated! [^1]

    [^1]: I am of course again trying to find a proper, maintained, clean Rust alternative for DirectXShaderCompiler COM bindings. This is perhaps one of the few - or only? - binaries that has a functioning COM API outside of Windows. The proposed Quality-of-Life improvements will shorten generated code and allow me to use windows-rs outside of Windows at no additional maintenance cost here.

    This is much shorter and simpler (multiplied by thousands of functions), but there's an obvious catch: whenever this function is used, even in conditional code (consider for example error.rs using various functions for retrieving and stringifying/prettifying Error), linking fails.

    Perhaps that's (much) better than an unsuspecting unimplemented!() being reached in an optional codepath (e.g. Error handling).

    However, there's an immediate solution too. And I've alluded to / requested this in earlier issues: define your own fallback. (This goes anywhere in a user's codebase, could even be a dependent crate)

    #[no_mangle]
    pub extern "system" DxcCreateInstance2(...) -> ::windows::core::HRESULT {
        // My custom fallback implementation
    }
    

    (Badly chosen example, this'd be better on e.g. SysStringLen.)

    Then the linker error is gone again, and the user has the ability to provide the necessary functions themselves at no additional design cost to windows-rs 🎉.

    Proof of concept

    You can find the end result here: https://github.com/MarijnS95/windows-rs/compare/simplify-cfg-windows (Showing 429 changed files with 71,379 additions and 157,268 deletions). As bonus this includes the same cfg_attr in windows-sys to allow running the tools on non-Windows.

    Alternative (even smaller) approach

    Perhaps this isn't necessary (read: remove the #[cfg(windows)] entirely) at all if a blanket libwindows.so is provided by the user, possibly built straight from a Rust crate with aforementioned fallback implementations. This can be done directly through cargo by providing a:

    [package]
    name = "windows-fallback"
    
    [lib]
    name = "windows"
    crate-type = ["cdylib"]
    

    Such a crate can be specified directly as a dependency in another crate even if no Rust symbols are referenced and it's not explicitly linked against: "windows-fallback" here still builds and its libwindows.so result ends up in a path that's already part of the search path to cover the automatically-inserted -lwindows 🎉 (may be a bit fragile to depend on though?).

    That however doesn't provide a solution to the metadata/tools currently being only compilable on Windows, and I'm not suggesting to provide this crate within windows-rs!

    enhancement 
    opened by MarijnS95 43
  • Rust docs broken

    Rust docs broken

    Just leaving this issue here as a few people have asked. There are two separate issues.

    The Windows crate docs are broken due to this rustc bug.

    The generated documentation hasn't been updated because cargo hangs trying to build windows-docs-rs. I seem to have hit some kind of limit, but its not clear what's wrong. rustc allocates about 5 GB and then cargo hangs inside git_refdb_backend_fs. This happens reliably. Here's a repro if you want to play along.

    Running out of memory while the CPU idles is kind of sad. 😢 Here is stable/night/nightly-2021-03-16 running in parallel:

    image

    In all three cases, the hang happens here:

    image

    opened by kennykerr 41
  • Support Rust using WinUI3+ProjectReunion

    Support Rust using WinUI3+ProjectReunion

    On top of the impl_inner branch, I am trying to build a sample that uses WinUI3+ProjectReunion. For that I have used the xaml_app and reunioncppdesktopsampleapp as a basis. My Application already partially works. I am able to generate bindings for the WinUI3 winmd files (which I extracted from the ProjectReuinion NuGet package) and then use these to implement Microsoft.UI.Xaml.Application and override OnLaunch (Really much like the xaml_app example). However the app crashes with an internal exception from WinUI3: Exception thrown at 0x00007FFD11A73B19 (KernelBase.dll) in winui3.exe: WinRT originate error - 0x80004005 : 'WinUI: Error creating an UWP Window. Creating an UWP window is not allowed.'. The exception comes from a separate Thread (i.e. not the Main Rust thread and probably internally from within the WinUI3 implementation) with the following StackTrace:

    KernelBase.dll!RaiseException()	Unknown
    combase.dll!SendReport(HRESULT error, unsigned int cchMax, const wchar_t * message, unsigned short pSid, void * pExceptionObject, IUnknown *) Line 438	C++
    combase.dll!RoOriginateError(HRESULT error, HSTRING__ * message) Line 590	C++
    Microsoft.ui.xaml.dll!DirectUI::Window::Window(void)	Unknown
    Microsoft.ui.xaml.dll!ctl::ComObject<class DirectUI::Window>::ComObject<class DirectUI::Window>(struct IInspectable *)	Unknown
    Microsoft.ui.xaml.dll!DirectUI::Window::Create()	Unknown
    Microsoft.ui.xaml.dll!DirectUI::DXamlCore::InitializeInstance()	Unknown
    Microsoft.ui.xaml.dll!DirectUI::DXamlCore::InitializeImpl(enum InitializationType,bool)	Unknown
    Microsoft.ui.xaml.dll!DirectUI::FrameworkView::Initialize()	Unknown
    twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationView::CreateAndInitializeFrameworkView()	Unknown
    twinapi.appcore.dll!Windows::ApplicationModel::Core::CoreApplicationViewAgileContainer::InitializeView()	Unknown
    twinapi.appcore.dll!<lambda>(void)()	Unknown
    SHCore.dll!_WrapperThreadProc()	Unknown
    kernel32.dll!BaseThreadInitThunk()	Unknown
    ntdll.dll!RtlUserThreadStart()	Unknown
    

    I have also compared my Application with the reunioncppdesktopsampleapp one written in C++ (from which I already use the Appxmanifest and other things) but I am unable to find any differences (except that the C++ one uses a single threaded apartment, which when used in Rust gives the following exception: Exception thrown at 0x00007FFD11A73B19 (KernelBase.dll) in winui3.exe: WinRT originate error - 0x8001010E : 'The Application Object must initially be accessed from the multi-thread apartment.'. 🤔).

    enhancement 
    opened by clemenswasser 36
  • Many Win32-style enums would be better promoted to module-scope constants

    Many Win32-style enums would be better promoted to module-scope constants

    Compare the usability of WM_QUIT with D3D12_RESOURCE_BARRIER_TYPE_TRANSITION:

    let message = WM_QUIT;
    let barrier_type = D3D12_RESOURCE_BARRIER_TYPE::D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
    

    The barrier type one is much more awkward to use. IMO it would be much more convenient to be able to write:

    let barrier_type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
    

    As all the naming conventions were picked with the assumption that no further qualification would be required.

    Alternatively, the projection could try and figure out better names:

    let barrier_type = D3D12_RESOURCE_BARRIER_TYPE::TRANSITION;
    
    enhancement 
    opened by damyanp 32
  • RFC: Provide pre-built version of this library

    RFC: Provide pre-built version of this library

    First off: thanks for a nice addition to the Rust ecosystem, it's really wonderful to see Microsoft actively try to support what is going on and provide support for the win32 apis.

    However as a maintainer of several code-generation crates I've found that it's usually significantly nicer for the user of my crates to provide a pre-built version of the wrappers that I'm exposing. This has a few benefits

    • build.rs is a serial dependency and very slow for more complex projects since cargo has to stall building code further down the line, and it has to wait for code-gen crates like syn and quote to have been built before it can run a build.rs.
    • Right now the recommended workflow is for everybody else to create a pre-built version, however, this means making windows-rs types part of your public interface will lead to incompatibilities between crates, whereas before you could make sure that everything is on the same version through cargo deny for example.

    To see the impact of building this crate, one can run cargo +nightly build -Ztimings to see the build dependency graph and this crate's impact on it (for example on the minesweeper-rs example that you've provided it looks like the vast majority of it's ~70s build time is spent in code-gen related things).

    If a pre-generated version of this crate becomes available (or nicers: this crate switches into a pre-built library) please add feature toggles similar to how winapi-rs does things, this lets the cargo feature resolver make sure that the minimal set of features is built across the entire dependency tree.

    enhancement 
    opened by Jasper-Bekkers 32
  • Optimizing docs generation

    Optimizing docs generation

    I had brought up the size of the generated rustdoc for windows-rs on the Rust Community Discord and rustdoc team member @jyn514 mentioned that adding the #![doc(html_no_source)] to the crate should suppress the HTML rendering of the crate source.

    https://doc.rust-lang.org/stable/rustdoc/the-doc-attribute.html#html_no_source

    enhancement 
    opened by jcotton42 32
  • Remove binary packaging support

    Remove binary packaging support

    Cross-compiling a Windows-rs project from Linux (ie. one of the test crates within this repo) result in the following build error:

    $ cargo b -p test_bstr --target x86_64-pc-windows-gnu
    ...
    error: proc macro panicked
     --> tests/bstr/build.rs:4:5
      |
    4 | /     windows::build! {
    5 | |         Windows::Win32::Foundation::BSTR,
    6 | |     };
      | |______^
      |
      = help: message: Path not ending in `;`
    

    The PATH variable on Linux is separated with colons, not semicolons.

    It is worrying to see the same undocumented logic and error duplicated across three distinct places in the codebase. What is the first path in PATH supposed to point to? Why are the winmd files copied to ../../.windows/winmd relative to it? Do I need to worry about the bit that copies to %PROFILE%, too?

    On a related note, is it worth turning the cargo build for ubuntu-latest in the CI into cargo check --all --target x86_64-pc-windows-gnu, to ensure cross-compiling remains in working order?

    enhancement 
    opened by MarijnS95 30
  • IMMDevice.Activate fails with IAudioSessionManager2

    IMMDevice.Activate fails with IAudioSessionManager2

    Hello, thank you for this amazing library,

    I get an error while retrieving back a pointer that should be filled by the IMMDevice::Activate function.

    Exception 0xc0000005 encountered at address 0x7ff64e1d65e7: Access violation reading location 0xffffffffffffffff
    (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
    

    I have got this error on Windows 10 with the following configuration:

    • cargo 1.53.0 (4369396ce 2021-04-27)
    • rustc 1.53.0 (53cb7b09b 2021-06-17)
    • toolchain: stable-x86_64-pc-windows-msvc

    Here is a minimal (non!)working example. Code is commented to highlight the problem.

    Cargo.toml

    [package]
    name = "my-package"
    version = "0.1.0"
    authors = ["spineki"]
    edition = "2018"
    
    [dependencies.windows]
    version = "0.28.0"
    features = [
      "Win32_Foundation",
      "Win32_Media_Audio",
      "Win32_Media_Multimedia",
      "Win32_System_Com",
      "Win32_System_Com_StructuredStorage",
    ]
    
    

    Code:

    use windows::Win32::{
        Media::Audio::{
            eCapture, eMultimedia, IAudioSessionManager2, IMMDeviceEnumerator, MMDeviceEnumerator,
        },
        System::Com::{
            CoCreateInstance, CoInitializeEx, CoUninitialize, CLSCTX_ALL, CLSCTX_INPROC_SERVER,
            COINIT_APARTMENTTHREADED,
        },
    };
    
    use windows::core::{Interface, GUID};
    
    fn main() {
        unsafe {
            CoInitializeEx(std::ptr::null(), COINIT_APARTMENTTHREADED).expect("CoInitializeEx Failed");
    
            // Getting the device enumerator: works
            let imm_device_enumerator: IMMDeviceEnumerator =
                CoCreateInstance(&MMDeviceEnumerator, None, CLSCTX_INPROC_SERVER)
                    .expect("CoCreateInstance Failed");
    
            // Getting the IMMDevice of the defaultAudioEndpoint: works
            let endpoint = imm_device_enumerator
                .GetDefaultAudioEndpoint(eCapture, eMultimedia)
                .expect("GetDefaultAudioEnpoint Failed");
    
            // preparing a pointer that will store the address of the created IAudioSessionManager2
            let mut pinterface: *mut std::ffi::c_void = std::ptr::null_mut();
    
            // Activating: the target Interface is IAudioSessionManager2: No error!
            endpoint
                .Activate(
                    &IAudioSessionManager2::IID,
                    CLSCTX_ALL.0,
                    std::ptr::null_mut(),
                    &mut pinterface as *mut _,
                )
                .expect("Activate Failed");
    
            // -> Reaching this point, so Activate did not failed
    
            // Casting back to IAudioSessionManager2: works
            let audio_session_enumerator_ref = (pinterface as *mut IAudioSessionManager2)
                .as_ref()
                .expect("Pointer to ref failed");
    
    
            // -------------------- HERE IS THE PROBLEM-------------------- 
            // The call to GetSessionEnumerator fails.
            let audio_session_enumerator = audio_session_enumerator_ref
                .GetSessionEnumerator()
                .expect("GetSessionEnumerator Failed");
            CoUninitialize();
        }
    }
    
    enhancement 
    opened by spineki 26
  • Find winmd files without reading `PATH` nor copying to `target/`

    Find winmd files without reading `PATH` nor copying to `target/`

    Fixes #979

    Non-Windows platforms - which are supported for cross-compiling - do not set the output directory in PATH nor use semicolons to separate this variable, resulting in errors Split out winmd "discovery" by emitting the path to these files in a build step, that is subsequently compiled into windows_gen. This is more efficient than include_bytes! which was used prior to the PATH system as no copies or binary includes are required at all. Copying of DLL targets to the target/ dir for easy consumption and running of crates is still performed, but only on Windows for the same PATH reason.

    In the future, if a chain of crates is required to export winmd files for downstream crates to consume, this can be extended to also export their $CARGO_MANIFEST_DIR/.winmd/windows in such a way that the next crate can pick it up, again without copying any files around.

    TODO

    @riverar Linked to the copy function on an older commit, but I think he intended to link to the way the target directory for those copies was derived:

    https://github.com/microsoft/windows-rs/blob/49ecfbc2f99cbc4bac32d6d771eeb589fe9d4e76/crates/macros/src/lib.rs#L121

    Should be migrate back to this and drop any and all PATH handling entirely?

    opened by MarijnS95 25
  • How to correctly release `ID3D12Resource` for `IDXGISwapChain3::ResizeBuffers`

    How to correctly release `ID3D12Resource` for `IDXGISwapChain3::ResizeBuffers`

    Hi I'm new to rust, but experienced with win32/directx.

    I am trying to make a resizable swap chain from a window using IDXGISwapChain3::ResizeBuffers

    I get an error in the validation layer DXGI ERROR: IDXGISwapChain::ResizeBuffers: Swapchain cannot be resized unless all outstanding buffer references have been released. [ MISCELLANEOUS ERROR #19: ]

    I have working c++ code which calls ID3D12Resource::Release on buffers which are obtained from the IDXGISwapChain3::GetBuffer function before making the call to IDXGISwapChain3::ResizeBuffers.

    What would be the equivalent of a Release call in rust? because the api doesn't mention Release

    enhancement 
    opened by polymonster 24
  • Feature request: Win32 IEnumVARIANT iterator for collections

    Feature request: Win32 IEnumVARIANT iterator for collections

    Motivation

    This makes it easier to iterate though Win32 collections (eg INetFwRules, INetFwServices, ...)

    Drawbacks

    At the current time, it seems that the Windows projection does not mark what structs support this kind of operation, so it would be a manual process of determining which structures this can be implemented on.

    Rationale and alternatives

    It could be implemented as a separate library, but it would mean that the implementation wont be-able to use the IntoIterator trait on the objects directly

    Additional context

    I have created an iterator for this kind of object. I am using it to iterate over the INetFwRules.

    pub struct IEnumIterator<T: Interface>(IEnumVARIANT, PhantomData<T>);
    
    impl<T: Interface> IEnumIterator<T> {
        fn new(i_enum: IEnumVARIANT) -> IEnumIterator<T> {
            IEnumIterator(i_enum, PhantomData)
        }
    }
    
    impl<T: Interface> Iterator for IEnumIterator<T> {
        type Item = T;
    
        fn next(&mut self) -> Option<Self::Item> {
            unsafe {
                let mut c_fetched: u32 = u32::default();
                let mut var = VARIANT::default();
                self.0
                    .Next(slice::from_mut(&mut var), &mut c_fetched)
                    .ok()
                    .ok()?;
                VariantChangeType(&mut var, &var, 0, VT_DISPATCH).ok()?;
                let dispatch = var.Anonymous.Anonymous.Anonymous.pdispVal.as_ref();
                dispatch.and_then(|d| d.cast().ok())
            }
        }
    }
    
    enhancement 
    opened by aquacash5 2
  • Feature request: Add comments for the samples

    Feature request: Add comments for the samples

    Motivation

    • Easier to understand especially for newcommers

    Drawbacks

    • None really (except it takes time)

    Rationale and alternatives

    No response

    Additional context

    No response

    docs 
    opened by MEisebitt 1
  • Bug: LookupAccountNameW does not use Option for optional arguments

    Bug: LookupAccountNameW does not use Option for optional arguments

    Which crate is this about?

    windows

    Crate version

    0.42.0

    Summary

    As per the docs, this function has various optional arguments:

    BOOL LookupAccountNameW(
      [in, optional]  LPCWSTR       lpSystemName,
      [in]            LPCWSTR       lpAccountName,
      [out, optional] PSID          Sid,
      [in, out]       LPDWORD       cbSid,
      [out, optional] LPWSTR        ReferencedDomainName,
      [in, out]       LPDWORD       cchReferencedDomainName,
      [out]           PSID_NAME_USE peUse
    );
    

    However, these are not marked as such in the Rust crate:

    pub unsafe fn LookupAccountNameW<'a, P0, P1>(
        lpsystemname: P0,
        lpaccountname: P1,
        sid: super::Foundation::PSID,
        cbsid: *mut u32, referenceddomainname: ::windows::core::PWSTR,
        cchreferenceddomainname: *mut u32, peuse: *mut SID_NAME_USE) -> super::Foundation::BOOL
    where
        P0: ::std::convert::Into<::windows::core::PCWSTR>,
        P1: ::std::convert::Into<::windows::core::PCWSTR>,
    {
        #[cfg_attr(windows, link(name = "windows"))]
        extern "system" {
            fn LookupAccountNameW(lpsystemname: ::windows::core::PCWSTR, lpaccountname: ::windows::core::PCWSTR, sid: super::Foundation::PSID, cbsid: *mut u32, referenceddomainname: ::windows::core::PWSTR, cchreferenceddomainname: *mut u32, peuse: *mut SID_NAME_USE) -> super::Foundation::BOOL;
        }
        LookupAccountNameW(lpsystemname.into(), lpaccountname.into(), ::core::mem::transmute(sid), ::core::mem::transmute(cbsid), ::core::mem::transmute(referenceddomainname), ::core::mem::transmute(cchreferenceddomainname), ::core::mem::transmute(peuse))
    }
    

    Furthermore, PWSTR doesn't have a From implemntation from Option like PCWSTR so I'm left with something like this:

            let result = LookupAccountNameW(
                None, // Local Computer (this is technically a PCWSTR but is using the From trait defined)
                owner_name,
                PSID::default(),
                &mut owner_sid_size,
                PWSTR::null(),
                &mut domain_name_length,
                &mut sid_type,
            );
    

    I would love to be able to call this function as follows instead (similar to various others):

            let result = LookupAccountNameW(
                None, // Local Computer
                owner_name,
                None,
                &mut owner_sid_size,
                None,
                &mut domain_name_length,
                &mut sid_type,
            );
    

    Toolchain version/configuration

    Default host: x86_64-pc-windows-gnu
    rustup home:  C:\Users\Fots\scoop\persist\rustup\.rustup
    
    installed toolchains
    --------------------
    
    stable-x86_64-pc-windows-gnu (default)
    stable-x86_64-pc-windows-msvc
    
    active toolchain
    ----------------
    
    stable-x86_64-pc-windows-gnu (default)
    rustc 1.64.0 (a55dd71d5 2022-09-19)
    
    

    Reproducible example

    N/A
    

    Crate manifest

    [package]
    name = "file-owners"
    version = "0.1.0"
    edition = "2021"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    widestring = "1.0.2"
    
    [dependencies.windows]
    version = "0.42.0"
    features = [
        "Win32_Foundation",
        "Win32_Security",
        "Win32_Security_Authorization",
        "Win32_Storage_FileSystem",
        "Win32_System_Threading",
        "Win32_System_SystemServices",
    ]
    

    Expected behavior

    lpSystemName, Sid and ReferencedDomainName should all be Option<T>s 😄

    Actual behavior

    Currently, all parameters are marked as required even though several of them are optional.

    Additional comments

    I'm struggling to know where such issues originate (e.g. win32metadata vs windows-rs). I searched win32metadata for the definition of this function and others that have optional arguments but couldn't see a distinction, so I'm guessing this is handled within windows-rs? 😄

    enhancement 
    opened by fgimian 3
  • IDWriteGlyphRunAnalysis::CreateAlphaTexture uses a `&mut [u8]` slice, which implies unnecessary initialization of its contents

    IDWriteGlyphRunAnalysis::CreateAlphaTexture uses a `&mut [u8]` slice, which implies unnecessary initialization of its contents

    It seems that the signature of IDWriteGlyphRunAnalysis::CreateAlphaTexture was changed to take a &mut [u8] slice as an output parameter. If I'm not mistaken, such slices always contain initialized data, which shouldn't be necessary since CreateAlphaTexture should write to the buffer represented by the slice. IIRC, the previous signature took a combination of *mut u8 and a usize to specify the size of the output buffer, which allowed the use of uninitialized memory (via Vec::with_capacity + set_len or MaybeUninit).

    There might be a reason for this change but I couldn't find anything in the issues or the release notes.

    enhancement 
    opened by ennis 4
  • Simplify non-COM interface parameter bindings

    Simplify non-COM interface parameter bindings

    Hello, the last couple of days I tried to migrate my XAudio2 project from C++ to Rust and was simply unable to implement the IXAudio2VoiceCallback interface.

    I am quite new to the rust language and even after hours of research do not understand why the implement macro doesn't work in my case. I don't think this is a general rust question because the macro is a specific functionality of the windows crate.


    I want to call the function CreateSourceVoice on an XAudio2 instance:

    audio.CreateSourceVoice(&mut p_source_voice, &format, 0, 2.0, &audio_callback.into(), Some(&music_voice_sends), None)
    

    To create an implementation for the IXAudio2VoiceCallback interface I use the implement macro:

    #[implement(IXAudio2VoiceCallback)]
    struct MyCallbacks {}
    
    #[allow(non_snake_case)]
    impl IXAudio2VoiceCallback_Impl for MyCallbacks {
        fn OnVoiceProcessingPassStart(&self, bytesrequired:u32) {}
        fn OnVoiceProcessingPassEnd(&self) {}
        fn OnStreamEnd(&self) {}
        fn OnBufferStart(&self, pbuffercontext: *mut core::ffi::c_void) {}
        fn OnBufferEnd(&self, pbuffercontext: *mut core::ffi::c_void) {}
        fn OnLoopEnd(&self, pbuffercontext: *mut core::ffi::c_void) {}
        fn OnVoiceError(&self, pbuffercontext: *mut core::ffi::c_void, error: windows::core::HRESULT) {}
    }
    

    The compiler error for the implement macro is:

    this associated function takes 1 generic argument but 3 generic arguments were supplied
    expected 1 generic argumentrustc[E0107](https://doc.rust-lang.org/error-index.html#E0107)
    impl.rs(646, 18): associated function defined here, with 1 generic parameter: `Impl`
    main.rs(14, 1): remove these generic arguments
    the trait bound `IXAudio2VoiceCallback: RuntimeName` is not satisfied
    the following other types implement trait `RuntimeName`:
      IActivateAudioInterfaceAsyncOperation
      IActivateAudioInterfaceCompletionHandler
      IAudioAmbisonicsControl
      IAudioAutoGainControl
      IAudioBass
      IAudioCaptureClient
      IAudioChannelConfig
      IAudioClient
    and 77 othersrustc[E0277](https://doc.rust-lang.org/error-index.html#E0277)
    inspectable.rs(134, 52): required by a bound in `IInspectable_Vtbl::new`
    no function or associated item named `matches` found for struct `IXAudio2VoiceCallback_Vtbl` in the current scope
    function or associated item not found in `IXAudio2VoiceCallback_Vtbl`rustc[E0599](https://doc.rust-lang.org/error-index.html#E0599)
    

    The issue "How to get COM object as "base" Interface without move" shows a similar situation with the IAudioEndpointVolumeCallback interface but in their case it just works. It would be awesome if someone with more windows crate knowledge or more rust experience in generell could help me.

    enhancement 
    opened by stuntman11 5
  • Tests should run with Application Verifier

    Tests should run with Application Verifier

    Just a reminder to figure out how to get the CI build to execute all tests with Application Verifier turned on for test executables.

    https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier

    enhancement 
    opened by kennykerr 0
Releases(0.43.0)
  • 0.43.0(Oct 24, 2022)

    String constants now preserve their original encoding as either UTF-8 or UTF-16 null-terminated string constants. This makes many string constants directly and efficiently usable as constants to pass to various Windows APIs that expect either "ansi" or wide null-terminated string literals. This update also provides a collection of small improvements, particularly to string handling. Updated Win32 metadata provides fixes to various API definitions.

    This release does not include an update to the windows-sys crate, which remains stable and unchanged.

    What's Changed

    • Remove composable support by @kennykerr in https://github.com/microsoft/windows-rs/pull/2070
    • Remove unnecessary convertible parameters by @kennykerr in https://github.com/microsoft/windows-rs/pull/2071
    • Use consistent const GUID code gen across windows and windows-sys by @kennykerr in https://github.com/microsoft/windows-rs/pull/2072
    • Use std consistently in the windows crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/2073
    • Improve core string type testing by @kennykerr in https://github.com/microsoft/windows-rs/pull/2074
    • Update the Natvis definition for HSTRING by @ridwanabdillahi in https://github.com/microsoft/windows-rs/pull/2077
    • Improve windows::core::Error formatting by @kennykerr in https://github.com/microsoft/windows-rs/pull/2075
    • Make more of the HSTRING methods const by @kennykerr in https://github.com/microsoft/windows-rs/pull/2078
    • Replace boilerplate COM interface code gen with macro_rules by @kennykerr in https://github.com/microsoft/windows-rs/pull/2079
    • Fix D3D12 sample by @kennykerr in https://github.com/microsoft/windows-rs/pull/2084
    • Suppress fewer warnings by @kennykerr in https://github.com/microsoft/windows-rs/pull/2085
    • Fix a few new clippy warnings by @kaivol in https://github.com/microsoft/windows-rs/pull/2090
    • Update the win32 metadata to version 36.0.9 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2099
    • Provide original encoding for string constants by @kennykerr in https://github.com/microsoft/windows-rs/pull/2101
    • Minor housekeeping by @kennykerr in https://github.com/microsoft/windows-rs/pull/2102
    • Simpler non-COM interface code gen by @kennykerr in https://github.com/microsoft/windows-rs/pull/2103
    • Fix recursive PartialEq impl in BSTR by @rylev in https://github.com/microsoft/windows-rs/pull/2116
    • Version 0.43 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2117

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.42.0...0.43.0

    Source code(tar.gz)
    Source code(zip)
  • 0.42.0(Sep 27, 2022)

    This release provides a major update to the windows-sys crate, the first update since 0.36.1, and includes numerous fixes and improvements to the completeness and correctness of both API definitions and import libs.

    What's Changed

    • Exclude default winmd files from windows-metadata crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/2060
    • The implement macro traits need not be recursively dependent by @kennykerr in https://github.com/microsoft/windows-rs/pull/2062
    • Add windows-sys test coverage by @kennykerr in https://github.com/microsoft/windows-rs/pull/2063
    • Add support for non-COM interfaces by @kennykerr in https://github.com/microsoft/windows-rs/pull/2066
    • Update the win32 metadata to version 34.0.8 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2067
    • Version 0.42.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2069

    Changelog for windows crate: https://github.com/microsoft/windows-rs/compare/0.41.0...0.42.0 Changelog for windows-sys crate: https://github.com/microsoft/windows-rs/compare/0.36.1...0.42.0

    Source code(tar.gz)
    Source code(zip)
  • 0.41.0(Sep 22, 2022)

    This is a minor service release addressing a number of issues mostly originating from the underlying win32 metadata which have now been resolved.

    This release does not include an update to the windows-sys crate, which remains stable and unchanged.

    What's Changed

    • Harden win32 array support to avoid conflicting metadata by @kennykerr in https://github.com/microsoft/windows-rs/pull/2035
    • Don't transform pointers to references by @kennykerr in https://github.com/microsoft/windows-rs/pull/2036
    • Avoid transforming array parameters with mismatched metadata by @kennykerr in https://github.com/microsoft/windows-rs/pull/2037
    • Add support for reserved parameters by @kennykerr in https://github.com/microsoft/windows-rs/pull/2039
    • Add WMI sample by @kennykerr in https://github.com/microsoft/windows-rs/pull/2041
    • Add macros for creating null-terminated string literals to windows-sys by @kennykerr in https://github.com/microsoft/windows-rs/pull/2043
    • Further constrain transforming array parameters to avoid potentially polymorphic types by @kennykerr in https://github.com/microsoft/windows-rs/pull/2046
    • Add Natvis definitions for types defined in the core module of the windows crate by @ridwanabdillahi in https://github.com/microsoft/windows-rs/pull/2023
    • Add support for declaring interfaces derived from existing interfaces by @kennykerr in https://github.com/microsoft/windows-rs/pull/2048
    • Update the win32 metadata to version 33.0.18 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2050
    • Remove dlltool prefix hack by @glandium in https://github.com/microsoft/windows-rs/pull/2052
    • Separate Vtable support from Interface trait by @kennykerr in https://github.com/microsoft/windows-rs/pull/2051
    • Fix HSTRING to conform to Rust's aliasing rules by @ChrisDenton in https://github.com/microsoft/windows-rs/pull/2057
    • Version 0.41.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2058

    New Contributors

    • @ridwanabdillahi made their first contribution in https://github.com/microsoft/windows-rs/pull/2023

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.40.0...0.41.0

    Source code(tar.gz)
    Source code(zip)
  • 0.40.0(Sep 16, 2022)

    This release includes a rollup of fixes and improvements to the Win32 metadata and many small fixes to the Rust bindings themselves. Notably, fixed-size array parameters, APIs with non-system calling conventions such as cdecl, reproducible builds, and far more accurate import libs.

    This release does not include an update to the windows-sys crate, which remains stable and unchanged.

    What's Changed

    • Exclude MsHtml APIs by @kennykerr in https://github.com/microsoft/windows-rs/pull/1925
    • Replace unsafe strlen usage in metadata library with safe Rust by @Swatinem in https://github.com/microsoft/windows-rs/pull/1926
    • Minor FAQ tweaks by @kennykerr in https://github.com/microsoft/windows-rs/pull/1929
    • Adding documentation for factory by @BenJKuhn in https://github.com/microsoft/windows-rs/pull/1936
    • Include only Win32 features and modules in the windows-sys crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/1935
    • Use a consistent set of dependencies across the implement and interface crates by @kennykerr in https://github.com/microsoft/windows-rs/pull/1931
    • FAQ - What APIs are included? by @kennykerr in https://github.com/microsoft/windows-rs/pull/1933
    • Declare rust-version for windows-interface crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/1930
    • Provide 32-bit aliases for SetWindowLongPtrA and GetWindowLongPtrA by @kennykerr in https://github.com/microsoft/windows-rs/pull/1932
    • Prefer &T to *const T for Win32 input parameters by @kennykerr in https://github.com/microsoft/windows-rs/pull/1939
    • Support fixed-size array parameters by @kennykerr in https://github.com/microsoft/windows-rs/pull/1941
    • Remove hidden dead code in windows::core by @kennykerr in https://github.com/microsoft/windows-rs/pull/1943
    • Remove unnecessary parentheses by @riverar in https://github.com/microsoft/windows-rs/pull/1949
    • Add aarch64-pc-windows-gnullvm and x86_64-pc-windows-gnullvm targets by @mati865 in https://github.com/microsoft/windows-rs/pull/1883
    • Make the output of tool_yml more deterministic across machines by @glandium in https://github.com/microsoft/windows-rs/pull/1958
    • Produce the *_gnu import libraries more deterministically by @glandium in https://github.com/microsoft/windows-rs/pull/1967
    • Remove unused binding by @kennykerr in https://github.com/microsoft/windows-rs/pull/1976
    • Remove unnecessary symbols and sections from *_gnu import libs by @glandium in https://github.com/microsoft/windows-rs/pull/1968
    • Fix msvc lib generation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1979
    • Implement Debug for AgileReference by @kennykerr in https://github.com/microsoft/windows-rs/pull/1986
    • Update min rust version for windows-sys to 1.49 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1987
    • Update the faq to call out no_std support by @kennykerr in https://github.com/microsoft/windows-rs/pull/1992
    • Switch to custom bindings for the windows::core internals by @kennykerr in https://github.com/microsoft/windows-rs/pull/1993
    • Add samples readme by @kennykerr in https://github.com/microsoft/windows-rs/pull/1991
    • Remove unused bindgen options by @kennykerr in https://github.com/microsoft/windows-rs/pull/1994
    • Make BOOL, BOOLEAN, and NTSTATUS extensions rather than replacements by @kennykerr in https://github.com/microsoft/windows-rs/pull/1995
    • Update Win32 metadata version from 24.0.1 to 30.0.12 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1996
    • Add support for calling conventions by @kennykerr in https://github.com/microsoft/windows-rs/pull/1999
    • Address nightly clippy warnings by @kennykerr in https://github.com/microsoft/windows-rs/pull/2000
    • Introduce reproducible builds with stable sorting by @kennykerr in https://github.com/microsoft/windows-rs/pull/2003
    • Adds a workaround and test for MAKEINTRESOURCE style constants by @kennykerr in https://github.com/microsoft/windows-rs/pull/2007
    • Remove Xaml interop namespace by @kennykerr in https://github.com/microsoft/windows-rs/pull/2008
    • Make BSTR a core string type by @kennykerr in https://github.com/microsoft/windows-rs/pull/2006
    • Update the win32 metadata to version 31.0.4 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2009
    • Use $crate in s! and w! macros by @goffrie in https://github.com/microsoft/windows-rs/pull/2011
    • Adds unsafe helpers to cast from C++ or raw IUnknown pointers to Rust IUnknown values by @kennykerr in https://github.com/microsoft/windows-rs/pull/2010
    • Update the win32 metadata to version 32.0.17 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2015
    • Remove win32metadata workarounds by @kennykerr in https://github.com/microsoft/windows-rs/pull/2017
    • Misc. changes to import library generation tooling by @glandium in https://github.com/microsoft/windows-rs/pull/2016
    • Remove win32metadata workaround by @kennykerr in https://github.com/microsoft/windows-rs/pull/2021
    • Version 0.40.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/2026

    New Contributors

    • @Swatinem made their first contribution in https://github.com/microsoft/windows-rs/pull/1926
    • @BenJKuhn made their first contribution in https://github.com/microsoft/windows-rs/pull/1936
    • @mati865 made their first contribution in https://github.com/microsoft/windows-rs/pull/1883
    • @glandium made their first contribution in https://github.com/microsoft/windows-rs/pull/1958
    • @goffrie made their first contribution in https://github.com/microsoft/windows-rs/pull/2011

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.39.0...0.40.0

    Source code(tar.gz)
    Source code(zip)
  • 0.39.0(Jul 20, 2022)

    This release includes improves to string handling and parameter passing to both improve performance and simplify the way arguments are bound to API calls.

    Notably, the "alloc" feature has been removed. This feature allowed string literals to be implicitly converted to null terminated strings required by some Windows APIs. While convenient, it was rather complicated and expensive at runtime. Instead, the explicit s! and w! macros are now provided to create null terminated UTF-8 and UTF-16 string literals at compile time.

    This release does not include an update to the windows-sys crate, which remains stable and unchanged.

    What's Changed

    • Fix new Rust-1.62 lints by @MarijnS95 in https://github.com/microsoft/windows-rs/pull/1866
    • Clean up formatting and indetation by @MarijnS95 in https://github.com/microsoft/windows-rs/pull/1865
    • Support running on Linux/WSL targets by @MarijnS95 in https://github.com/microsoft/windows-rs/pull/1863
    • Derive Eq and PartialEq for NTSTATUS by @kennykerr in https://github.com/microsoft/windows-rs/pull/1869
    • Fix token formatting for derive macros by @kennykerr in https://github.com/microsoft/windows-rs/pull/1870
    • Basic field and constant metadata generation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1871
    • Add link to metadata used to generate crate in main readme by @poliorcetics in https://github.com/microsoft/windows-rs/pull/1875
    • Add tool_lib crate to hold some of the common support for the windows-rs tools by @kennykerr in https://github.com/microsoft/windows-rs/pull/1876
    • Update win32 metadata to v24 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1877
    • Move all docs to central location by @kennykerr in https://github.com/microsoft/windows-rs/pull/1878
    • Adjust license placement for GitHub auto-detection by @riverar in https://github.com/microsoft/windows-rs/pull/1879
    • Remove old license files by @kennykerr in https://github.com/microsoft/windows-rs/pull/1880
    • Borrowed by @rylev in https://github.com/microsoft/windows-rs/pull/1811
    • Use prettyplease for development formatting by @rylev in https://github.com/microsoft/windows-rs/pull/1849
    • Remove orphaned "alloc" feature by @kennykerr in https://github.com/microsoft/windows-rs/pull/1888
    • Convertible input strings by @kennykerr in https://github.com/microsoft/windows-rs/pull/1889
    • Add macros for creating null-terminated string literals by @kennykerr in https://github.com/microsoft/windows-rs/pull/1891
    • Update samples to use string literal macros by @kennykerr in https://github.com/microsoft/windows-rs/pull/1894
    • Use where clauses in codegen by @rylev in https://github.com/microsoft/windows-rs/pull/1893
    • Improve string pointer types by @rylev in https://github.com/microsoft/windows-rs/pull/1897
    • Small refactor by @rylev in https://github.com/microsoft/windows-rs/pull/1899
    • Avoid including primitive types with convertible types by @kennykerr in https://github.com/microsoft/windows-rs/pull/1900
    • Remove dead code by @rylev in https://github.com/microsoft/windows-rs/pull/1905
    • Add display methods for string pointer types by @rylev in https://github.com/microsoft/windows-rs/pull/1904
    • Avoid transmute for binding primitive argument types by @kennykerr in https://github.com/microsoft/windows-rs/pull/1907
    • Avoid generating redundant doc comments for methods by @kennykerr in https://github.com/microsoft/windows-rs/pull/1908
    • Infer ABI type for method result type by @kennykerr in https://github.com/microsoft/windows-rs/pull/1909
    • Avoid transmute for direct return values where no translation occurs by @kennykerr in https://github.com/microsoft/windows-rs/pull/1911
    • More accurate signature parameter parsing by @kennykerr in https://github.com/microsoft/windows-rs/pull/1913
    • Reduce dependence on transmute for WinRT arrays by @kennykerr in https://github.com/microsoft/windows-rs/pull/1914
    • Ensure that Display impl for HSTRING is infallible by @kennykerr in https://github.com/microsoft/windows-rs/pull/1915
    • Fix new nightly warning about unused return value by @kennykerr in https://github.com/microsoft/windows-rs/pull/1917
    • Use internal Decode helper in a few more places by @kennykerr in https://github.com/microsoft/windows-rs/pull/1918

    New Contributors

    • @poliorcetics made their first contribution in https://github.com/microsoft/windows-rs/pull/1875

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.38.0...0.39.0

    Source code(tar.gz)
    Source code(zip)
  • 0.38.0(Jun 22, 2022)

    This release includes a host of small improvements and fixes to the windows crate. Notably, the windows-bindgen and windows-metadata crates have been rewritten to avoid the static winmd cache in favor of a stateful metadata reader that allows multiple instances to be used independently (#1777).

    This release does not include an update to the windows-sys crate, which remains stable and unchanged.

    What's Changed

    • Small clean ups to factory caching by @rylev in https://github.com/microsoft/windows-rs/pull/1758
    • Add WinSock conversion utilities by @ryancerium in https://github.com/microsoft/windows-rs/pull/1742
    • Set windows-implement min rust-version by @wravery in https://github.com/microsoft/windows-rs/pull/1773
    • Stateful metadata & bindgen by @kennykerr in https://github.com/microsoft/windows-rs/pull/1777
    • Pay back some technical debt by @kennykerr in https://github.com/microsoft/windows-rs/pull/1779
    • Remove nightly test distinction by @kennykerr in https://github.com/microsoft/windows-rs/pull/1778
    • Update Win32 metadata to v23 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1783
    • Remove unused types by @kennykerr in https://github.com/microsoft/windows-rs/pull/1784
    • Remove hidden RawPtr type alias by @kennykerr in https://github.com/microsoft/windows-rs/pull/1791
    • Remove need for allocation inside Reader by @rylev in https://github.com/microsoft/windows-rs/pull/1794
    • Avoid redundant signature calculations by @kennykerr in https://github.com/microsoft/windows-rs/pull/1793
    • Improve Reader to Tree construction by @kennykerr in https://github.com/microsoft/windows-rs/pull/1797
    • Remove flatten comment by @kennykerr in https://github.com/microsoft/windows-rs/pull/1801
    • Test error propagation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1803
    • Trim error messages by @kennykerr in https://github.com/microsoft/windows-rs/pull/1804
    • Remove reverse dependency from core module by @kennykerr in https://github.com/microsoft/windows-rs/pull/1802
    • Make Type methods simpler to use by @kennykerr in https://github.com/microsoft/windows-rs/pull/1806
    • Add cross compilation tests by @riverar in https://github.com/microsoft/windows-rs/pull/1808
    • Support COM-style query signatures with unconventional parameter positions by @kennykerr in https://github.com/microsoft/windows-rs/pull/1805
    • Avoid truncating error codes when converting from windows::core::Error to std::io::Error by @kennykerr in https://github.com/microsoft/windows-rs/pull/1809
    • Borrowed<'a, T> RFC by @rylev in https://github.com/microsoft/windows-rs/pull/1788
    • Use standard library algorithm for finding query parameters by @kennykerr in https://github.com/microsoft/windows-rs/pull/1810
    • Avoid string allocations in Cfg by @kennykerr in https://github.com/microsoft/windows-rs/pull/1812
    • Followup to event PR feedback by @kennykerr in https://github.com/microsoft/windows-rs/pull/1814
    • Basic metadata generation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1820
    • Avoid UB in FactoryCache by @kennykerr in https://github.com/microsoft/windows-rs/pull/1829
    • Remove Xaml from windows crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/1836
    • Include cfg dependencies for types with generic interface type dependencies by @kennykerr in https://github.com/microsoft/windows-rs/pull/1832
    • Add component helper function to simplify component development by @kennykerr in https://github.com/microsoft/windows-rs/pull/1840
    • Version 0.38.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1841

    New Contributors

    • @ryancerium made their first contribution in https://github.com/microsoft/windows-rs/pull/1742

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.37.0...0.38.0

    Source code(tar.gz)
    Source code(zip)
  • 0.37.0(May 19, 2022)

    This release includes a host of small improvements and fixes to the windows crate. Notably, changes to the implement and interface macros improve interoperability, correctness, and safety for COM and WinRT implementations.

    This release does not include an update to the windows-sys crate, which remains stable and unchanged.

    What's Changed

    • Avoid double allocation when passing strings via IntoParam by @AronParker in https://github.com/microsoft/windows-rs/pull/1713
    • Correct compose offset in implement macro by @kennykerr in https://github.com/microsoft/windows-rs/pull/1724
    • Restore nightly validation by @riverar in https://github.com/microsoft/windows-rs/pull/1726
    • Correct implementation identity for MBM and .NET compatibility by @kennykerr in https://github.com/microsoft/windows-rs/pull/1729
    • Fix interface macro to handle qualified IUnknown parent by @rylev in https://github.com/microsoft/windows-rs/pull/1732
    • Shorten IUnknown check by @rylev in https://github.com/microsoft/windows-rs/pull/1735
    • Improve IUnknown Unsafe Annotations by @rylev in https://github.com/microsoft/windows-rs/pull/1734
    • Improve the Interface trait by @rylev in https://github.com/microsoft/windows-rs/pull/1738
    • Improve Vtable implementations by @rylev in https://github.com/microsoft/windows-rs/pull/1740
    • Propose an RFCs Process by @rylev in https://github.com/microsoft/windows-rs/pull/1731
    • Add HSTRING compatibility testing by @kennykerr in https://github.com/microsoft/windows-rs/pull/1749
    • Simplify header handling in HSTRING by @rylev in https://github.com/microsoft/windows-rs/pull/1747
    • Use core::ptr::write for out params by @rylev in https://github.com/microsoft/windows-rs/pull/1750
    • Fix ToImpl by @rylev in https://github.com/microsoft/windows-rs/pull/1748
    • Inline HSTRING::clear into the Drop impl by @rylev in https://github.com/microsoft/windows-rs/pull/1752
    • Make cast method produced by implement macro unsafe by @rylev in https://github.com/microsoft/windows-rs/pull/1753
    • Improve ABI conversion by @rylev in https://github.com/microsoft/windows-rs/pull/1746
    • Add GUID::to_u128 by @GamePad64 in https://github.com/microsoft/windows-rs/pull/1756
    • Version 0.37.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1765

    New Contributors

    • @AronParker made their first contribution in https://github.com/microsoft/windows-rs/pull/1713
    • @GamePad64 made their first contribution in https://github.com/microsoft/windows-rs/pull/1756

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.36.1...0.37.0

    Source code(tar.gz)
    Source code(zip)
  • 0.36.1(Apr 28, 2022)

    This is a minor service release to work around docs.rs limitations in order to publish windows-sys docs.

    What's Changed

    • Make target crates no_std by @ChrisDenton in https://github.com/microsoft/windows-rs/pull/1722
    • Version 0.36.1 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1723

    New Contributors

    • @ChrisDenton made their first contribution in https://github.com/microsoft/windows-rs/pull/1722

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.36.0...0.36.1

    Source code(tar.gz)
    Source code(zip)
  • 0.36.0(Apr 26, 2022)

    What's Changed

    • Avoid clearing SetLastError when allocating string params by @kennykerr in https://github.com/microsoft/windows-rs/pull/1665
    • Remove UB in the heap_string function by @rylev in https://github.com/microsoft/windows-rs/pull/1667
    • Add test component by @kennykerr in https://github.com/microsoft/windows-rs/pull/1666
    • Document heap functions by @rylev in https://github.com/microsoft/windows-rs/pull/1670
    • Heap functions are private by @kennykerr in https://github.com/microsoft/windows-rs/pull/1673
    • Correct x86 stdcall signature size calculation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1674
    • Replace internal IActivationFactory definition with tailored definition by @kennykerr in https://github.com/microsoft/windows-rs/pull/1678
    • Add the beginnings of an FAQ by @rylev in https://github.com/microsoft/windows-rs/pull/1684
    • Added conversions between HSTRING and OsStr/OsString by @kaivol in https://github.com/microsoft/windows-rs/pull/1693
    • Make Matrix3x2::identity() and Matrix3x2::translation(f32, f32) const by @TheOddGarlic in https://github.com/microsoft/windows-rs/pull/1695
    • Add missing features to enum bitwise operators by @kennykerr in https://github.com/microsoft/windows-rs/pull/1701
    • Update win32 metadata to 22.0.14-preview by @kennykerr in https://github.com/microsoft/windows-rs/pull/1702
    • Add Event<T> type that can be used to implement a WinRT event by @kennykerr in https://github.com/microsoft/windows-rs/pull/1705
    • Undo Rust 2021 adoption by @kennykerr in https://github.com/microsoft/windows-rs/pull/1706
    • Remove redundant warning suppression by @kennykerr in https://github.com/microsoft/windows-rs/pull/1709
    • Version 0.36.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1717

    New Contributors

    • @kaivol made their first contribution in https://github.com/microsoft/windows-rs/pull/1693
    • @TheOddGarlic made their first contribution in https://github.com/microsoft/windows-rs/pull/1695

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.35.0...0.36.0

    Source code(tar.gz)
    Source code(zip)
  • 0.35.0(Apr 5, 2022)

    What's Changed

    • Update Windows metadata, import libraries by @riverar in https://github.com/microsoft/windows-rs/pull/1604
    • Support richer COM interface hierarchies by @rylev in https://github.com/microsoft/windows-rs/pull/1608
    • Fix bug where COM interfaces needed to be declared pub by @rylev in https://github.com/microsoft/windows-rs/pull/1611
    • Fix bug where the interface feature could not be used without the implement feature by @rylev in https://github.com/microsoft/windows-rs/pull/1612
    • Update metadata, regen crates by @riverar in https://github.com/microsoft/windows-rs/pull/1613
    • Make a safer conversion From for INTERFACE by @rylev in https://github.com/microsoft/windows-rs/pull/1619
    • Make test checking for conversion to param by @rylev in https://github.com/microsoft/windows-rs/pull/1620
    • Do not emit cfg attribute if not requested by @riverar in https://github.com/microsoft/windows-rs/pull/1623
    • Add DataProtection sample by @kennykerr in https://github.com/microsoft/windows-rs/pull/1624
    • Expand DataProtection sample to illustrate buffer byte access by @kennykerr in https://github.com/microsoft/windows-rs/pull/1626
    • Basics of metadata generation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1633
    • Simpler metadata discovery by @kennykerr in https://github.com/microsoft/windows-rs/pull/1635
    • Adopt Rust 2021 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1636
    • Limit win32 array params to non-shared length params by @kennykerr in https://github.com/microsoft/windows-rs/pull/1641
    • Handle IDispatch edge case by @kennykerr in https://github.com/microsoft/windows-rs/pull/1642
    • Update Win32 metadata, regen crates by @riverar in https://github.com/microsoft/windows-rs/pull/1646
    • Type-specific handle validity checking by @kennykerr in https://github.com/microsoft/windows-rs/pull/1648
    • Avoids name collision in vtable generation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1649
    • Use BSTR allocator as PCSTR and PCWSTR parameter allocator by @kennykerr in https://github.com/microsoft/windows-rs/pull/1657
    • Handle type mismatch with invalid handle values by @kennykerr in https://github.com/microsoft/windows-rs/pull/1659
    • Version 0.35.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1660

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.34.0...0.35.0

    Source code(tar.gz)
    Source code(zip)
  • 0.34.0(Mar 15, 2022)

    What's Changed

    • Add support for Win32 array parameters by @kennykerr in https://github.com/microsoft/windows-rs/pull/1562
    • Add user consent verification sample by @kennykerr in https://github.com/microsoft/windows-rs/pull/1566
    • Anchor CI to Windows Server 2019 virtual image by @riverar in https://github.com/microsoft/windows-rs/pull/1569
    • Compact representation for pure IDispatch declarations by @kennykerr in https://github.com/microsoft/windows-rs/pull/1568
    • Fix nightly warning about unused must_use by @kennykerr in https://github.com/microsoft/windows-rs/pull/1580
    • Expose Interface trait and Weak object in documentation by @vthib in https://github.com/microsoft/windows-rs/pull/1576
    • Improved Win32 array transformation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1570
    • Avoid generating IDispatch members by @kennykerr in https://github.com/microsoft/windows-rs/pull/1584
    • Simplify common error code conversions by @kennykerr in https://github.com/microsoft/windows-rs/pull/1585
    • Remove nightly features that are no longer required by @kennykerr in https://github.com/microsoft/windows-rs/pull/1591
    • Provide hex output for Debug impl of HRESULT and NTSTATUS by @kennykerr in https://github.com/microsoft/windows-rs/pull/1590
    • Fix multi arg COM methods and allow all types in interface methods by @rylev in https://github.com/microsoft/windows-rs/pull/1594
    • Allow for non-HRESULT return types in COM by @rylev in https://github.com/microsoft/windows-rs/pull/1595
    • Double quote feature names in generated docs for easier cut/paste by @riverar in https://github.com/microsoft/windows-rs/pull/1599
    • Basic component development support by @kennykerr in https://github.com/microsoft/windows-rs/pull/1600
    • Add license files to crate packages by @kennykerr in https://github.com/microsoft/windows-rs/pull/1602
    • Version 0.34.0 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1603

    New Contributors

    • @vthib made their first contribution in https://github.com/microsoft/windows-rs/pull/1576

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.33.0...0.34.0

    Source code(tar.gz)
    Source code(zip)
  • 0.33.0(Feb 24, 2022)

    What's Changed

    • Add first-class types for PCSTR and PCWSTR by @kennykerr in https://github.com/microsoft/windows-rs/pull/1550
    • Prefer &self for COM interface traits by @kennykerr in https://github.com/microsoft/windows-rs/pull/1511
    • Only build the default doc target for windows-sys by @kennykerr in https://github.com/microsoft/windows-rs/pull/1508
    • Simplify implementing with WinRT generic interfaces by @kennykerr in https://github.com/microsoft/windows-rs/pull/1510
    • Update tests to use UnsafeCell by @kennykerr in https://github.com/microsoft/windows-rs/pull/1517
    • Correct aarch64 import lib and add tests by @riverar in https://github.com/microsoft/windows-rs/pull/1531
    • Explicit parameter direction by @kennykerr in https://github.com/microsoft/windows-rs/pull/1533
    • Include Win32 "retval" signatures in transformation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1534
    • Fix incorrect implementation shims by @kennykerr in https://github.com/microsoft/windows-rs/pull/1535
    • Experimental COM interface declaration support by @rylev in https://github.com/microsoft/windows-rs/pull/1540
    • Make NTSTATUS::ok a const fn by @roblabla in https://github.com/microsoft/windows-rs/pull/1542
    • Move feature and dependency tracking to the metadata crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/1544
    • Constrain borrowed parameter lifetime by @kennykerr in https://github.com/microsoft/windows-rs/pull/1545
    • Simplify and add test for Weak by @kennykerr in https://github.com/microsoft/windows-rs/pull/1548
    • Avoid unnecessary null_mut in samples by @kennykerr in https://github.com/microsoft/windows-rs/pull/1558
    • Restore ability to codegen with windows as dep crate by @riverar in https://github.com/microsoft/windows-rs/pull/1551
    • Minor doc improvements by @kennykerr in https://github.com/microsoft/windows-rs/pull/1564

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.32.0...0.33.0

    Source code(tar.gz)
    Source code(zip)
  • 0.32.0(Feb 3, 2022)

    What's Changed

    • Use correct lib for internal bindings by @kennykerr in https://github.com/microsoft/windows-rs/pull/1432
    • Derive PartialEq and Eq for scoped enums to support constant patterns by @kennykerr in https://github.com/microsoft/windows-rs/pull/1438
    • Trait-based implement macro by @kennykerr in https://github.com/microsoft/windows-rs/pull/1450
    • Improve enum code gen by @kennykerr in https://github.com/microsoft/windows-rs/pull/1457
    • Require delegates to be Send by @kennykerr in https://github.com/microsoft/windows-rs/pull/1458
    • Check windows-sys with 1.46 as MSRV by @kennykerr in https://github.com/microsoft/windows-rs/pull/1460
    • Simpler error interop by @kennykerr in https://github.com/microsoft/windows-rs/pull/1462
    • Improve core/xaml app sample ergonomics by @riverar in https://github.com/microsoft/windows-rs/pull/1463
    • Make handle fields const by @kennykerr in https://github.com/microsoft/windows-rs/pull/1468
    • Improve crate naming and build validation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1469
    • Make applicable fields const by @kennykerr in https://github.com/microsoft/windows-rs/pull/1470
    • Avoid generating invalid Debug traits by @kennykerr in https://github.com/microsoft/windows-rs/pull/1473
    • Reliably handle Unicode string literals by @kennykerr in https://github.com/microsoft/windows-rs/pull/1480
    • Update Win32 metadata to 17.0.9 by @kennykerr in https://github.com/microsoft/windows-rs/pull/1482
    • Support functions that don't return by @kennykerr in https://github.com/microsoft/windows-rs/pull/1485
    • Update target lib files by @riverar in https://github.com/microsoft/windows-rs/pull/1488
    • windows-implement crate refactor by @kennykerr in https://github.com/microsoft/windows-rs/pull/1489
    • Precise generic type code generation by @kennykerr in https://github.com/microsoft/windows-rs/pull/1492
    • Add AgileReference by @Nerixyz in https://github.com/microsoft/windows-rs/pull/1474

    New Contributors

    • @Nerixyz made their first contribution in https://github.com/microsoft/windows-rs/pull/1474

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.30.0...0.32.0

    Source code(tar.gz)
    Source code(zip)
  • 0.30.0(Jan 13, 2022)

    What's Changed

    • Implement Debug trait for windows crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/1395
    • Add bitwise operators for flag enums by @kennykerr in https://github.com/microsoft/windows-rs/pull/1413
    • Add uwp targets by @bdbai in https://github.com/microsoft/windows-rs/pull/1416
    • Add repository URLs to all library Cargo manifests by @complexspaces in https://github.com/microsoft/windows-rs/pull/1418
    • Reintroduces handle types for the windows crate by @kennykerr in https://github.com/microsoft/windows-rs/pull/1423
    • Remove std feature by @kennykerr in https://github.com/microsoft/windows-rs/pull/1424

    New Contributors

    • @complexspaces made their first contribution in https://github.com/microsoft/windows-rs/pull/1418

    Full Changelog: https://github.com/microsoft/windows-rs/compare/0.29.0...0.30.0

    Source code(tar.gz)
    Source code(zip)
  • 0.29.0(Dec 18, 2021)

    • Update win32 metadata (1387)
    • Feature and doc generation for windows-sys (1381)
    • New windows-bindgen for simpler code generation (1379)
    • Simplify and unify underlying types (1368)
    • Callbacks now consistently use Option (1344)
    • Reduce crate size by limiting Xaml bindings (1341)
    • Other small improvements and fixes
    Source code(tar.gz)
    Source code(zip)
  • 0.28.0(Nov 17, 2021)

  • 0.27.0(Nov 15, 2021)

  • 0.26.0(Nov 10, 2021)

    • no_std support by default (use the std feature to enable use of the standard library)
    • Updated Win32 metadata (mostly DirectX namespaces have been reorganized for improved compile time)
    • Other small improvements and fixes
    Source code(tar.gz)
    Source code(zip)
Owner
Microsoft
Open source projects and samples from Microsoft
Microsoft
Use Thunk to build your Rust program that runs on old Windows platforms, support Windows XP and more!

Use Thunk to build your Rust program that runs on old platforms. Thunk uses VC-LTL5 and YY-Thunks to build programs that support old platforms. So, ho

null 6 May 21, 2023
Switch windows of same app with alt + ` on windows pc.

Windows Switcher Switch windows of same app with alt + ` on windows pc. 250k single file executable downloaded from Github Release. No installation re

null 172 Dec 10, 2022
Check if the process is running inside Windows Subsystem for Linux (Bash on Windows)

is-wsl Check if the process is running inside Windows Subsystem for Linux (Bash on Windows) Inspired by sindresorhus/is-wsl and made for Rust lang. Ca

Sean Larkin 6 Jan 31, 2023
Windows Capture Simple Screen Capture for Windows 🔥

Windows Capture   Windows Capture is a highly efficient Rust library that enables you to effortlessly capture the screen using the Graphics Capture AP

null 3 Sep 24, 2023
A Rust curses library, supports Unix platforms and Windows

pancurses pancurses is a curses library for Rust that supports both Linux and Windows by abstracting away the backend that it uses (ncurses-rs and pdc

Ilkka Halila 360 Jan 7, 2023
Windows shellcode development in Rust

Write Windows Shellcode in Rust Project overview Windows shellcode project is located in shellcode/, it can build into a PE file with only .text secti

red 171 Dec 26, 2022
Rust crate to enable ANSI escape code support on Windows.

enable-ansi-support: Enable ANSI escape code support on Windows 10 About This crate provides one function, enable_ansi_support, which allows ANSI esca

Rain 9 Nov 18, 2022
Shared memory - A Rust wrapper around native shared memory for Linux and Windows

shared_memory A crate that allows you to share memory between processes. This crate provides lightweight wrappers around shared memory APIs in an OS a

elast0ny 274 Dec 29, 2022
A small Rust library that let's you get position and size of the active window on Windows and MacOS

active-win-pos-rs A small Rust library that let's you get position and size of the active window on Windows and MacOS Build % git clone https://github

Dmitry Malkov 21 Jan 6, 2023
A lightweight and ergonomic rust crate to handle system-wide hotkeys on windows

Windows Hotkeys An opinionated, lightweight crate to handle system-wide hotkeys on windows The windows-hotkeys crate abstracts and handles all interac

null 5 Dec 15, 2022
Rust crate for interacting with the Windows Packet Filter driver.

NDISAPI-RS NDISAPI-RS is a Rust crate for interacting with the Windows Packet Filter driver. It provides an easy-to-use, safe, and efficient interface

Vadim Smirnov 6 Jun 15, 2023
A Rust crate for parsing Windows user minidumps.

udmp-parser-rs: A Rust crate for parsing Windows user minidumps This is a cross-platform crate that parses Windows user minidump dumps that you can ge

Axel Souchet 14 Aug 16, 2023
A Windows virtual display driver written in Rust (works with VR, etc)

Virtual Display Driver This is a Windows driver made in Rust which creates a virtual desktop. It has many uses, such as: A private virtual desktop for

Cherry 28 Sep 19, 2023
Platform that enables Windows driver development in Rust. Developed by Surface.

windows-drivers-rs This repo is a collection of Rust crates that enable developers to develop Windows Drivers in Rust. It is the intention to support

Microsoft 1.1k Oct 11, 2023
A minimal window context for Rust on Windows.

winctx A minimal window context for Rust on Windows. I read msdn so you don't have to. This crate provides a minimalistic method for setting up and ru

John-John Tedro 19 Dec 25, 2023
A small unix and windows lib to search for executables in PATH folders.

A small unix and windows lib to search for executables in path folders.

Robiot 2 Dec 25, 2021
A small utility that moves the start menu to the top-center of the screen in Windows 11.

TopCenterStart11 A small utility that moves the start menu to the top-center of the screen in Windows 11. As of right now, this application can only p

Ryan de Jonge 12 Nov 12, 2022
Adds back-and-forth jumping between current and previous focused windows to Sway.

sway-focus-back-and-forth Implements back-and-forth movement between the current and the previous focused windows. It also can be seen as a fix to thi

Vinícius Müller 4 Aug 11, 2022
The library for those who need a little extra from their windows. â„¢

WinEx The library for those who need a little extra from their windows. â„¢ WinEx - Short for Window Extended - is a library whose goal is to implement

Matheus Branco Borella 2 Mar 27, 2022