dahall / Vanara

A set of .NET libraries for Windows implementing PInvoke calls to many native Windows APIs with supporting wrappers.
MIT License
1.81k stars 196 forks source link

NtQueryInformationProcess has incorrect signature #384

Closed zhuxb711 closed 1 year ago

zhuxb711 commented 1 year ago

Describe the bug and how to reproduce In Vanara:

[DllImport("ntdll.dll", ExactSpelling = true)]
[PInvokeData("winternl.h", MSDNShortId = "0eae7899-c40b-4a5f-9e9c-adae021885e7")]
public static extern NTStatus NtQueryInformationProcess([In] HPROCESS ProcessHandle, PROCESSINFOCLASS ProcessInformationClass, [Out] IntPtr ProcessInformation, uint ProcessInformationLength, out uint ReturnLength);

Should be:

[DllImport("ntdll.dll", ExactSpelling = true, SetLastError = true)]
public static extern NTStatus NtQueryInformationProcess([In] IntPtr ProcessHandle, [In] NtDll.PROCESSINFOCLASS ProcessInformationClass, [Out] out IntPtr ProcessInformation, [In] uint ProcessInformationLength, [Optional] out uint ReturnLength);
dahall commented 1 year ago

What basis do you have for the change? I don't think you're correct. The documentation says: ProcessHandle:

A handle to the process for which information is to be retrieved.

ProcessInformation:

A pointer to a buffer supplied by the calling application into which the function writes the requested information.

Also, the unit test runs successfully.

zhuxb711 commented 1 year ago

Ok, maybe you are right, but the second one also works for me~~~