Skip to content

Commit c1c76ca

Browse files
committed
Avoid calling NativeLibrary.Load in RuntimeInformation.OSArchitecture.
1 parent 9ebb601 commit c1c76ca

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeInformation.Windows.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public static unsafe Architecture OSArchitecture
4242
// If we are running an x64 process on a non-x64 windows machine, we will report x64 as OS architecutre.
4343
//
4444
// IsWow64Process2 is only available on Windows 10+, so we will perform run-time introspection via indirect load
45-
if (NativeLibrary.TryGetExport(NativeLibrary.Load(Interop.Libraries.Kernel32), "IsWow64Process2", out IntPtr isWow64Process2Ptr))
45+
IntPtr kernel32 = Interop.Kernel32.LoadLibraryEx(Interop.Libraries.Kernel32, 0, Interop.Kernel32.LOAD_LIBRARY_SEARCH_SYSTEM32);
46+
if (NativeLibrary.TryGetExport(kernel32, "IsWow64Process2", out IntPtr isWow64Process2Ptr))
4647
{
4748
ushort processMachine, nativeMachine;
4849
var isWow64Process2 = (delegate* unmanaged<IntPtr, ushort*, ushort*, int>)isWow64Process2Ptr;

0 commit comments

Comments
 (0)