microsoft / microsoft/win32metadata

Media Foundation definitions are missing [Optional] attribute annotations (not honoring __RPC__in_opt annotation)

Open
#2,086 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

For example `mfobjects.h` defines this:

IMFMediaEventGenerator : public IUnknown
{
// omitted ....

virtual HRESULT STDMETHODCALLTYPE QueueEvent(
/* [in] */ MediaEventType met,
/* [in] */ __RPC__in REFGUID guidExtendedType,
/* [in] */ HRESULT hrStatus,
/* [unique][in] */ __RPC__in_opt const PROPVARIANT *pvValue) = 0; // this is an optional pointer (can be null)
};

While medatada contains this, where `pvValue `is not marked with `[Optional]` attribute:

unsafe HRESULT QueueEvent(
[In] uint met,
[In][Const] Guid* guidExtendedType, // this is OK
[In] HRESULT hrStatus,
[In][Const] PROPVARIANT* pvValue // this is not OK
);

Another example in `mfidl.h`:

IMFMediaSource : public IMFMediaEventGenerator
{
// omitted ....

virtual HRESULT STDMETHODCALLTYPE Start(
/* [in] */ __RPC__in_opt IMFPresentationDescriptor *pPresentationDescriptor,
/* [unique][in] */ __RPC__in_opt const GUID *pguidTimeFormat,
/* [unique][in] */ __RPC__in_opt const PROPVARIANT *pvarStartPosition) = 0;

In metadata:

unsafe HRESULT Start(
[In] IMFPresentationDescriptor pPresentationDescriptor,
[In][Const] Guid* pguidTimeFormat, // this is not OK
[In][Const] PROPVARIANT* pvarStartPosition // this is not OK
);

There are other places in win32metada where it's correct, for example `IAudioClient`'s `Initialize` method where AudioSessionGuid is marked with `[Optional]`:

unsafe HRESULT Initialize(
[In] AUDCLNT_SHAREMODE ShareMode,
[In] uint StreamFlags,
[In] long hnsBufferDuration,
[In] long hnsPeriodicity,
[In][Const] WAVEFORMATEX* pFormat,
[Optional][In][Const] Guid* AudioSessionGuid // this is OK
);

Contributor guide

Open the contributing guide

Research direction

Compare the declarations in mfobjects.h and mfidl.h with the generated metadata, focusing on parameters marked __RPC__in_opt and the existing AudioSessionGuid example. Trace the metadata generation entry point that maps these annotations to [Optional], then verify that optional pointers in the affected Media Foundation methods are annotated consistently.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.