microsoft / microsoft/win32metadata

Safe version of the EnumProcessModulesEx function seems to be incorrect

Open
#2,146 15 comments 0 reactions 1 assignee Claimed by @mikebattista View on GitHub
bug
Dominant language
C++
Stars
1.5k
Forks
149
Avg merge
5d 16h
Merged PRs (30d)
4

Description

## Actual behavior

I think that the safe version of the EnumProcessModulesEx has an invalid type for the lphModule parameter:

```cs
static unsafe winmdroot.Foundation.BOOL EnumProcessModulesEx(SafeHandle hProcess, out FreeLibrarySafeHandle lphModule, uint cb, out uint lpcbNeeded, winmdroot.System.ProcessStatus.ENUM_PROCESS_MODULES_EX_FLAGS dwFilterFlag)
```

The unsafe version:

```cs
static extern unsafe winmdroot.Foundation.BOOL EnumProcessModulesEx(winmdroot.Foundation.HANDLE hProcess, winmdroot.Foundation.HMODULE* lphModule, uint cb, uint* lpcbNeeded, winmdroot.System.ProcessStatus.ENUM_PROCESS_MODULES_EX_FLAGS dwFilterFlag);
```

## Expected behavior

I would expect lphModule to be an out array or a HMODULE pointer (like in the unsafe version).

## Repro steps

1. `NativeMethods.txt` content:
```
EnumProcessModulesEx
```

2. `NativeMethods.json` content (if present):
```json
```

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

### Context

- CsWin32 version: 0.3.106
- Target Framework: net8.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.