Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnumProcessModules can not return modules collection. #1281

Closed
NeverMorewd opened this issue Sep 11, 2024 · 1 comment
Closed

EnumProcessModules can not return modules collection. #1281

NeverMorewd opened this issue Sep 11, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@NeverMorewd
Copy link

Actual behavior

EnumProcessModules receive FreeLibrarySafeHandle as module handles. However FreeLibrarySafeHandle contains only one module handle.

Expected behavior

Get all module handles.

Repro steps

  1. NativeMethods.txt content:
EnumProcessModules 
  1. NativeMethods.json content (if present):
  1. 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();
	}
}
  • CsWin32 version: [0.3.106]
  • Win32Metadata version (if explicitly set by project):
  • Target Framework: [net6.0;net8.0;netframework4.8]
  • LangVersion (if explicitly set by project): [latest]
@NeverMorewd NeverMorewd added the bug Something isn't working label Sep 11, 2024
@AArnott
Copy link
Member

AArnott commented Sep 30, 2024

Same root cause as #1266.

@AArnott AArnott closed this as not planned Won't fix, can't repro, duplicate, stale Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants