internal static unsafe JetArchitecture GetOSArchitecture()

in JetBrains.HabitatDetector/src/Impl/Windows/WindowsHelper.cs [84:98]


    internal static unsafe JetArchitecture GetOSArchitecture()
    {
      if (WinApiCalls.IsWow64Process2 != null)
      {
        IMAGE_FILE_MACHINE processImageFileMachine, nativeImageFileMachine;
        if (WinApiCalls.IsWow64Process2(Kernel32Dll.GetCurrentProcess(), &processImageFileMachine, &nativeImageFileMachine) == 0)
          throw new Win32Exception();
        return ConvertToArchitecture(nativeImageFileMachine);
      }

      // Note(ww898): GetNativeSystemInfo() on Windows ARM64 returns 9(PROCESSOR_ARCHITECTURE_AMD64) instead of 12(PROCESSOR_ARCHITECTURE_ARM64) for X64 processes!!!
      SYSTEM_INFO nativeSystemInfo;
      Kernel32Dll.GetNativeSystemInfo(&nativeSystemInfo);
      return ConvertToArchitecture(nativeSystemInfo.wProcessorArchitecture);
    }