microsoft / microsoft/win32metadata

Return types for IDebugEventContextCallbacks

Open
#2,075 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

Hi,

This is a follow up of https://github.com/microsoft/windows-rs/issues/3559.

According to https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/dbgeng/nf-dbgeng-idebugeventcallbacks-breakpoint, Breakpoint should return something of the form DEBUG_STATUS_XXXX.

The latest winmd files contain the return type of HRESULT, which is correct, but turns into windows_core::Result<()> in the windows_rs bindings, which isn't correct. This is the unit type and doesn't reflect the correct return type.

fn Breakpoint(&self, bp: windows_core::Ref<'_, IDebugBreakpoint2>, context: *const core::ffi::c_void, contextsize: u32) -> windows_core::Result<()>;

in the impl,

pub trait IDebugEventContextCallbacks_Impl: windows_core::IUnknownImpl {
    fn GetInterestMask(&self) -> windows_core::Result<u32>;
    fn Breakpoint(&self, bp: windows_core::Ref<'_, IDebugBreakpoint2>, context: *const core::ffi::c_void, contextsize: u32) -> windows_core::Result<()>;

From ILSpy I can see that the interface matches learn.microsoft.com. However, and this is my assumption, for the rust bindings to be correct, it must have an [Out] parameter in order to be able to produce the correct return type, Result<u32>.

GetInterestMask above is correct.

The question is how can this be fixed? The interfaces do appear to match learn.microsoft.com but the bindings are incomplete in my view.

To me this means I can't implement an override like this,

https://github.com/glslang/win-kexp/blob/main/src/dbgeng.rs#L360

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the IDebugEventContextCallbacks metadata in the latest winmd files and compare Breakpoint with the Microsoft Learn signature and the generated windows-rs trait shown in the issue. Check the linked win-kexp implementation and determine what metadata representation is needed for the DEBUG_STATUS_XXXX return; done when the generated binding exposes the expected result type and the override can compile.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.