microsoft / microsoft/wdkmetadata

Provide extra overloads where methods can accept EX struct values.

Open
#96 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
110
Forks
15
PR merge metrics
No merged PRs in 30d

Description

Actual behavior

Apologies in advance; I logged this feature request as a bug by mistake...

Say for RtlGetVersion() or CreateProcess(), these methods can accept OSVERSIONINFOEXW and STARTUPINFOEXW values, but because there's no friendly overloads to accept them, the caller is forced to use the direct P/Invoke and play with pointers to get the data through.

Expected behavior

That friendly overloads be provided to accept these EX struct values to manage the process for the caller without needing them to do fixed statements and casting down to OSVERSIONINFOW, etc.

Repro steps

  1. NativeMethods.txt content:
RtlGetVersion
CreateProcess
  1. NativeMethods.json content (if present): N/A

  2. Any of your own code that should be shared?

internal unsafe static NTSTATUS RtlGetVersion(out OSVERSIONINFOEXW lpVersionInformation)
{
    lpVersionInformation = new() { dwOSVersionInfoSize = (uint)Marshal.SizeOf<OSVERSIONINFOEXW>() };
    fixed (OSVERSIONINFOEXW* lpVersionInformationLocal = &lpVersionInformation)
    {
        NTSTATUS res = Windows.Wdk.PInvoke.RtlGetVersion((OSVERSIONINFOW*)lpVersionInformationLocal);
        if (res != NTSTATUS.STATUS_SUCCESS)
        {
            throw ExceptionUtilities.GetExceptionForLastWin32Error((WIN32_ERROR)Windows.Win32.PInvoke.RtlNtStatusToDosError(res));
        }
        return res;
    }
}
Context
  • CsWin32 version: 0.3.253
  • Win32Metadata version (if explicitly set by project): N/A
  • Target Framework: net472
  • LangVersion (if explicitly set by project): N/A

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 NativeMethods.txt entries for RtlGetVersion and CreateProcess and reproduce the provided C# overload scenario. Determine where generated APIs handle OSVERSIONINFOEXW and STARTUPINFOEXW values; done means callers can pass those EX structs without fixed statements, pointer manipulation, or casts to the non-EX types.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
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.