* Use platform specific implementation of GetCurrentProcessId
directly in shared location instead of relying on runtime export
* Move GetCurrentProcessId to Interop class
* Update ES_BUILD_STANDALONE build
Commit migrated from https://github.com/dotnet/coreclr/commit/
0fee55abb6b7c742cb487b12706dc54080e9e128
<Compile Include="$(BclSourcesRoot)\System\ValueType.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReference.cs" />
<Compile Include="$(BclSourcesRoot)\System\WeakReferenceOfT.cs" />
- <Compile Include="shared\Interop\Windows\Kernel32\Interop.GetCurrentProcessId.cs" />
<Compile Include="shared\Interop\Windows\Kernel32\Interop.GetStdHandle.cs" />
<Compile Include="shared\Interop\Windows\Kernel32\Interop.LocalAlloc.cs" />
<Compile Include="shared\Interop\Windows\Kernel32\Interop.QueryUnbiasedInterruptTime.cs" />
{
// If set, bail out early if the specified process does not match the current process.
int processID = Convert.ToInt32(strProcessID);
- if (processID != Interop.Kernel32.GetCurrentProcessId())
+ if (processID != (int)Interop.GetCurrentProcessId())
{
return null;
}
private static string BuildTraceFileName()
{
- return GetAppName() + "." + Interop.Kernel32.GetCurrentProcessId().ToString() + NetPerfFileExtension;
+ return GetAppName() + "." + Interop.GetCurrentProcessId().ToString() + NetPerfFileExtension;
}
private static string GetAppName()
--- /dev/null
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+ internal static partial class Sys
+ {
+ [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPid")]
+ internal static extern int GetPid();
+ }
+
+ internal static uint GetCurrentProcessId() => (uint)Sys.GetPid();
+}
[DllImport(Libraries.Kernel32)]
internal extern static uint GetCurrentProcessId();
}
+
+ internal static uint GetCurrentProcessId() => Kernel32.GetCurrentProcessId();
}
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FlushFileBuffers.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetComputerName.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetCPInfo.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetCurrentProcessId.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetCurrentProcess_IntPtr.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetCurrentDirectory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.GetFileAttributesEx.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetCwd.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetEUid.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetHostName.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetPid.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetPwUid.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetRandomBytes.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.GetSystemTimeAsTicks.cs" />
// for non-BCL EventSource we must assert SecurityPermission
new SecurityPermission(PermissionState.Unrestricted).Assert();
#endif
- s_currentPid = Interop.Kernel32.GetCurrentProcessId();
+ s_currentPid = Interop.GetCurrentProcessId();
}
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
internal static extern uint GetCurrentProcessId();
}
+
+ internal static uint GetCurrentProcessId() => Kernel32.GetCurrentProcessId();
}
#endif