mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-25 03:07:14 +00:00
Replace DllImport with LibraryImport - 1 (#18603)
This commit is contained in:
27 files changed
+413
-333
No files matched your search
@@ -11,7 +11,7 @@ namespace Microsoft.PowerShell
|
||||
/// <summary>
|
||||
/// Helper functions for process info.
|
||||
/// </summary>
|
||||
public static partial class ProcessCodeMethods
|
||||
public static class ProcessCodeMethods
|
||||
{
|
||||
private const int InvalidProcessId = -1;
|
||||
|
||||
@@ -61,32 +61,12 @@ namespace Microsoft.PowerShell
|
||||
internal static int GetParentPid(Process process)
|
||||
{
|
||||
Diagnostics.Assert(process != null, "Ensure process is not null before calling");
|
||||
PROCESS_BASIC_INFORMATION pbi;
|
||||
Interop.Windows.PROCESS_BASIC_INFORMATION pbi;
|
||||
int size;
|
||||
var res = NtQueryInformationProcess(process.Handle, 0, out pbi, Marshal.SizeOf<PROCESS_BASIC_INFORMATION>(), out size);
|
||||
var res = Interop.Windows.NtQueryInformationProcess(process.Handle, 0, out pbi, Marshal.SizeOf<Interop.Windows.PROCESS_BASIC_INFORMATION>(), out size);
|
||||
|
||||
return res != 0 ? InvalidProcessId : pbi.InheritedFromUniqueProcessId.ToInt32();
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct PROCESS_BASIC_INFORMATION
|
||||
{
|
||||
public IntPtr ExitStatus;
|
||||
public IntPtr PebBaseAddress;
|
||||
public IntPtr AffinityMask;
|
||||
public IntPtr BasePriority;
|
||||
public IntPtr UniqueProcessId;
|
||||
public IntPtr InheritedFromUniqueProcessId;
|
||||
}
|
||||
|
||||
[LibraryImport("ntdll.dll")]
|
||||
private static partial int NtQueryInformationProcess(
|
||||
IntPtr processHandle,
|
||||
int processInformationClass,
|
||||
out PROCESS_BASIC_INFORMATION processInformation,
|
||||
int processInformationLength,
|
||||
out int returnLength);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user