Skip to content

The friendly wrapper for EnumProcessModules() isn't correct. #1561

@mjr4077au

Description

@mjr4077au

Actual behavior

This one's an oldie, but I never reported it and just used the direct P/Invoke. The friendly wrapper for EnumProcessModules() has a signature of internal static unsafe winmdroot.Foundation.BOOL EnumProcessModules(SafeHandle hProcess, out global::Windows.Win32.FreeLibrarySafeHandle lphModule, uint cb, out uint lpcbNeeded), however while the docs say lphModule is an out parameter, it needs to be a handle to a buffer to receive an array of handle pointers, at least as large enough as lpcbNeeded specifies.

Expected behavior

This friendly wrapper should probably accept a Span<HMODULE>() parameter if possible, or at least Span<byte> and then the caller can read the byte array as they would any of the other P/Invokes.

This would mean that the friendly overload for GetModuleInformation() would need to directly accept the HMODULE value as well.

Repro steps

N/A

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

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions