microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.34k stars 119 forks source link

Missing FlushMenuThemes, SetPreferredAppMode #2003

Closed ghost1372 closed 2 weeks ago

ghost1372 commented 2 months ago

Actual behavior

i want to use FlushMenuThemes, SetPreferredAppMode and RtlGetVersion methods but none of them exist, currently i can use them with dllimport:

[DllImport(ExternDll.UxTheme, EntryPoint = "#136", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static extern void FlushMenuThemes();

[DllImport(ExternDll.UxTheme, EntryPoint = "#135", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)]
public static extern int SetPreferredAppMode(PreferredAppMode preferredAppMode);

[DllImport(ExternDll.NTdll)]
public static extern int RtlGetVersion(out RTL_OSVERSIONINFOEX lpVersionInformation);

but i can not access this methods because do not exist/available

Expected behavior

we should be able to use FlushMenuThemes, SetPreferredAppMode, RtlGetVersion

Repro steps

  1. NativeMethods.txt content:

    `RtlGetVersion`
    `FlushMenuThemes`
    `SetPreferredAppMode`
    `136`
    `135`
    `#136`
    `#135`
  2. NativeMethods.json content (if present):

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

Context

riverar commented 1 month ago

RtlGetVersion is already covered by WDK metadata.

FlushMenuThemes and SetPreferredAppMode appear to be undocumented, exported only by ordinal via uxtheme. While public, not sure those are a candidate for addition to metadata? @mikebattista

ghost1372 commented 1 month ago

Thank You @riverar so what should i do? i am not familiar with WDK metadata. should i install some nuget package to fix it?

riverar commented 1 month ago

@AArnott What's the official way to bring WDK metadata into CsWin32? Or does @ghost1372 need to manually add a reference like I did in https://github.com/microsoft/CsWin32/issues/1176?

AArnott commented 1 month ago

WDK metadata is brought in by default. RtlGetVersion is available already if you ask for it in NativeMethods.txt. It's generated as Windows.Wdk.PInvoke.RtlGetVersion

ghost1372 commented 1 month ago

WDK metadata is brought in by default. RtlGetVersion is available already if you ask for it in NativeMethods.txt. It's generated as Windows.Wdk.PInvoke.RtlGetVersion

tnx but its not working!

image

image

image

riverar commented 1 month ago

@ghost1372 Try just adding RtlGetVersion to NativeMethods.txt.

ghost1372 commented 1 month ago

RtlGetVersion

Tnx it is working fine! It's very strange, I tried this before and it didn't work (my first post), but now it works without any problem, of course I have to say that I installed the following packages (In CSWin32, their versions are less)

    <PackageReference Include="Microsoft.Windows.SDK.Win32Metadata" Version="62.0.23-preview" />
    <PackageReference Include="Microsoft.Windows.WDK.Win32Metadata" Version="0.12.8-experimental" />

but now that I have removed it, it still works.

ghost1372 commented 1 month ago

I was globally using the following namespace, so PInvoke was always called from there global using Windows.Win32; Now I found that PInvoke is also available in the following namespace using Windows.Wdk;

AArnott commented 1 month ago

I've dropped RtlGetVersion from the title since that's already there. That leaves the remaining two apparently undocumented functions for consideration.

mikebattista commented 2 weeks ago

I'm following up for some more context on these APIs. If they're internal/undocumented, then I won't add them here.

mikebattista commented 2 weeks ago

I confirmed these aren't ready for general use so will not be added here.