Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MFTEnumEx signature incorrect #1229

Open
jimm98y opened this issue Jul 1, 2024 · 0 comments
Open

MFTEnumEx signature incorrect #1229

jimm98y opened this issue Jul 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@jimm98y
Copy link

jimm98y commented Jul 1, 2024

Actual behavior

The signature of the generated MFTEnumEx is not correct, causing a crash. This used to be working in 0.3.49-beta, it is broken since the latest version 0.3.106. The new generated function in the latest version is:

public static unsafe winmdroot.Foundation.HRESULT MFTEnumEx(global::System.Guid guidCategory, winmdroot.Media.MediaFoundation.MFT_ENUM_FLAG Flags, winmdroot.Media.MediaFoundation.MFT_REGISTER_TYPE_INFO? pInputType, winmdroot.Media.MediaFoundation.MFT_REGISTER_TYPE_INFO? pOutputType, out winmdroot.Media.MediaFoundation.IMFActivate pppMFTActivate, out uint pnumMFTActivate)

In 0.3.49-beta which was working it is:

public static unsafe winmdroot.Foundation.HRESULT MFTEnumEx(global::System.Guid guidCategory, winmdroot.Media.MediaFoundation.MFT_ENUM_FLAG Flags, winmdroot.Media.MediaFoundation.MFT_REGISTER_TYPE_INFO? pInputType, winmdroot.Media.MediaFoundation.MFT_REGISTER_TYPE_INFO? pOutputType, out winmdroot.Media.MediaFoundation.IMFActivate[] pppMFTActivate, out uint pnumMFTActivate)

You can notice the IMFActivate[] parameter is now typed as IMFActivate which is why it's not working. The definition looks correct:

STDAPI
MFTEnumEx(
    _In_                                GUID                            guidCategory,
    _In_                                UINT32                          Flags,
    _In_opt_                            const MFT_REGISTER_TYPE_INFO*   pInputType,
    _In_opt_                            const MFT_REGISTER_TYPE_INFO*   pOutputType,
    _Outptr_result_buffer_(*pnumMFTActivate) IMFActivate***                 pppMFTActivate,
    _Out_                               UINT32*                         pnumMFTActivate
);

Expected behavior

The function definition should include IMFActivate[] and calling it should not crash the app.

Repro steps

  1. NativeMethods.txt content:
mf.*
mfplat.*
MF*
_MFT_INPUT_STATUS_FLAGS
_MFT_PROCESS_OUTPUT_FLAGS
_MFT_PROCESS_OUTPUT_STATUS
_MFT_OUTPUT_DATA_BUFFER_FLAGS
MFT_INPUT_STREAM_INFO
MFT_OUTPUT_STREAM_INFO
MFT_MESSAGE_TYPE
MFT_OUTPUT_DATA_BUFFER
  1. NativeMethods.json content (if present):
{
  "$schema": "https://aka.ms/CsWin32.schema.json",
  "public": true,
  "wideCharOnly": false,
  "allowMarshaling": true,
  "comInterop": {
    "preserveSigMethods": [ "IMFTransform" ]
  }
}
  1. Any of your own code that should be shared?
PInvoke.MFTEnumEx(category, flags, input, output, out IMFActivate[] activates, out uint activateCount)

Context

  • CsWin32 version: 0.3.106
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: net8.0
@jimm98y jimm98y added the bug Something isn't working label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant