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

GetModuleInformation throws EntryPointNotFoundException #230

Closed
IS4Code opened this issue May 16, 2021 · 1 comment
Closed

GetModuleInformation throws EntryPointNotFoundException #230

IS4Code opened this issue May 16, 2021 · 1 comment

Comments

@IS4Code
Copy link

IS4Code commented May 16, 2021

Describe the bug

System.EntryPointNotFoundException: Unable to find an entry point named 'GetModuleInformation' in DLL 'kernelbase.dll'.
   at Vanara.PInvoke.Kernel32.GetModuleInformation(HPROCESS hProcess, HINSTANCE
hModule, MODULEINFO& lpmodinfo, UInt32 cb)

Tested on Windows 7, 64-bit.

What code is involved
Vanara.PInvoke.Kernel32.GetModuleInformation

Expected behavior
I haven't tested other psapi functions, but this was the only P/Invoke declaration that worked for me:

[DllImport(Lib.Kernel32, SetLastError = true, ExactSpelling = true, EntryPoint = "K32GetModuleInformation")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetModuleInformation(HPROCESS hProcess, HINSTANCE hModule, out MODULEINFO lpmodinfo, uint cb);

It is not in KernelBase, and must used the entry point "K32GetModuleInformation". It is also consistent with the documentation:

Programs that must run on earlier versions of Windows as well as Windows 7 and later versions should always call this function as K32GetModuleInformation.

@dahall
Copy link
Owner

dahall commented May 26, 2021

Thanks for bringing this to my attention. After some research and testing, it appears that importing from PSAPI.DLL allows the functions to work on all Windows versions (at least Vista - 10). I'll get the fixes pushed shortly and then they'll show up in the next released build.

@dahall dahall closed this as completed in 5b22a15 May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants