Closed NeverMorewd closed 1 month ago
EnumProcessModules receive FreeLibrarySafeHandle as module handles. However FreeLibrarySafeHandle contains only one module handle.
Get all module handles.
NativeMethods.txt content:
NativeMethods.txt
EnumProcessModules
NativeMethods.json
Any of your own code that should be shared? Current function content generated by cswin32 SG.
public static unsafe winmdroot.Foundation.BOOL EnumProcessModules(SafeHandle hProcess, out FreeLibrarySafeHandle lphModule, uint cb, out uint lpcbNeeded) { bool hProcessAddRef = false; try { fixed (uint* lpcbNeededLocal = &lpcbNeeded) { winmdroot.Foundation.HANDLE hProcessLocal; if (hProcess is object) { hProcess.DangerousAddRef(ref hProcessAddRef); hProcessLocal = (winmdroot.Foundation.HANDLE)hProcess.DangerousGetHandle(); } else throw new ArgumentNullException(nameof(hProcess)); winmdroot.Foundation.HMODULE lphModuleLocal; winmdroot.Foundation.BOOL __result = PInvoke.EnumProcessModules(hProcessLocal, &lphModuleLocal, cb, lpcbNeededLocal); lphModule = new FreeLibrarySafeHandle(lphModuleLocal, ownsHandle: true); return __result; } } finally { if (hProcessAddRef) hProcess.DangerousRelease(); } }
LangVersion
Same root cause as #1266.
Actual behavior
EnumProcessModules receive FreeLibrarySafeHandle as module handles. However FreeLibrarySafeHandle contains only one module handle.
Expected behavior
Get all module handles.
Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):Any of your own code that should be shared? Current function content generated by cswin32 SG.
LangVersion
(if explicitly set by project): [latest]