Patch WinMM header structure#89
Merged
atsushieno merged 1 commit intoatsushieno:masterfrom Feb 25, 2026
Merged
Conversation
Owner
|
Thanks for the fix! |
There was a problem hiding this comment.
I just tested this with .NET 10. Granted, that is likely a different version than you are using, but I wanted to check this because it didn't look correct.
- Be sure to add Pack=1 otherwise you get the wrong structure size. I was getting a size of 120 on 64 bit compiles without this.
- The [] after IntPtr are required to get a proper size for the struct, at least in .NET 10. In .NET 10, you get an exception if you don't include this.
You should end up with a size of 112. No more, no less.
[StructLayout(LayoutKind.Sequential, Pack =1)]
struct MidiHdr
{
public IntPtr Data;
public int BufferLength; // should be uint
public int BytesRecorded; // should be uint
public IntPtr User;
public int Flags;
public IntPtr Next; // of MidiHdr
public IntPtr Reserved;
public int Offset; // should be uint
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
private IntPtr[] reservedArray;
}|
Just to also be clear, the structure was always incorrect, and could have resulted in app crashes. What changed is we're now validating the passed-in size in the WinMM call. :) |
Contributor
Author
|
Thanks. This PR should fix it #90 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Patched according to #88
I did not change the ints to uints because it would require more changes in other parts of the code.
This has not been tested.