@@ -957,6 +957,21 @@ std::wstring GetProcessorArchitectureString(WORD const arch)
957
957
958
958
}
959
959
960
+ #define ENV_PROCESSOR_ARCHITECTURE L" PROCESSOR_ARCHITECTURE"
961
+ #define ENV_PROCESSOR_IDENTIFIER L" PROCESSOR_IDENTIFIER"
962
+ #define ENV_PROCESSOR_LEVEL L" PROCESSOR_LEVEL"
963
+ #define ENV_PROCESSOR_REVISION L" PROCESSOR_REVISION"
964
+
965
+
966
+ void OutputProcessorEnvVariables ()
967
+ {
968
+ OutputStringField (ENV_PROCESSOR_ARCHITECTURE, std::wstring{ _wgetenv (ENV_PROCESSOR_ARCHITECTURE)});
969
+ OutputStringField (ENV_PROCESSOR_IDENTIFIER, std::wstring{ _wgetenv (ENV_PROCESSOR_IDENTIFIER) });
970
+ OutputStringField (ENV_PROCESSOR_LEVEL, std::wstring{ _wgetenv (ENV_PROCESSOR_LEVEL) });
971
+ OutputStringField (ENV_PROCESSOR_REVISION, std::wstring{ _wgetenv (ENV_PROCESSOR_REVISION) });
972
+ }
973
+
974
+
960
975
void OutputSystemInfo (_In_ SYSTEM_INFO const & sysinfo)
961
976
{
962
977
// that sysinfo.dwNumberOfProcessors can return some strange results.
@@ -969,6 +984,51 @@ void OutputSystemInfo(_In_ SYSTEM_INFO const& sysinfo)
969
984
OutputHexNumericField (MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_PROCESSOR_REVISION, sysinfo.wProcessorRevision );
970
985
}
971
986
987
+ void OutputProcessAndNativeMachine ()
988
+ {
989
+ USHORT processMachine;
990
+ USHORT nativeMachine;
991
+
992
+ HANDLE hProcess = ::GetCurrentProcess ();
993
+
994
+ if (hProcess)
995
+ {
996
+ auto worked = ::IsWow64Process2 (hProcess, &processMachine, &nativeMachine);
997
+
998
+ if (worked)
999
+ {
1000
+ // if not running emulated, IsWow64Process2 returns machine unknown for the process.
1001
+ if ((processMachine == IMAGE_FILE_MACHINE_UNKNOWN || processMachine == IMAGE_FILE_MACHINE_ARM64) && nativeMachine == IMAGE_FILE_MACHINE_ARM64)
1002
+ {
1003
+ OutputStringField (MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_PROCESSOR_EMULATION, std::wstring{ L" Native Arm64 process on Arm64 PC (Note Emulated)" });
1004
+ }
1005
+ else if ((processMachine == IMAGE_FILE_MACHINE_UNKNOWN || processMachine == IMAGE_FILE_MACHINE_AMD64) && nativeMachine == IMAGE_FILE_MACHINE_AMD64)
1006
+ {
1007
+ OutputStringField (MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_PROCESSOR_EMULATION, std::wstring{ L" Native Intel/AMD x64 on x64 PC (Not Emulated)" });
1008
+ }
1009
+ else if (processMachine == IMAGE_FILE_MACHINE_AMD64 && nativeMachine == IMAGE_FILE_MACHINE_ARM64)
1010
+ {
1011
+ OutputStringField (MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_PROCESSOR_EMULATION, std::wstring{ L" Intel/AMD x64 process on Arm64 PC (Emulated)" });
1012
+ }
1013
+ else if (processMachine == IMAGE_FILE_MACHINE_ARM64 && nativeMachine == IMAGE_FILE_MACHINE_AMD64)
1014
+ {
1015
+ // not supported today, but here in case it is some day
1016
+ OutputStringField (MIDIDIAG_FIELD_LABEL_SYSTEM_INFO_PROCESSOR_EMULATION, std::wstring{ L" Arm64 process on Intel/AMD x64 PC (Emulated)" });
1017
+ }
1018
+ else
1019
+ {
1020
+ OutputError (L" Unidentified process and/or machine architecture" );
1021
+ }
1022
+ }
1023
+ else
1024
+ {
1025
+ OutputError (L" Unable to query process and machine architecture." );
1026
+ }
1027
+
1028
+ }
1029
+ }
1030
+
1031
+
972
1032
bool DoSectionSystemInfo (_In_ bool verbose)
973
1033
{
974
1034
UNREFERENCED_PARAMETER (verbose);
@@ -978,19 +1038,19 @@ bool DoSectionSystemInfo(_In_ bool verbose)
978
1038
979
1039
980
1040
// if running under emulation on Arm64, this is going to return the emulated sys info
981
- OutputSectionHeader (MIDIDIAG_SECTION_LABEL_APPARENT_SYSTEM_INFO);
1041
+ OutputSectionHeader (MIDIDIAG_SECTION_LABEL_PROCESSOR_ENV);
1042
+ OutputProcessorEnvVariables ();
982
1043
983
- SYSTEM_INFO sysinfo;
984
- ::GetNativeSystemInfo (&sysinfo);
985
- OutputSystemInfo (sysinfo);
986
-
987
- // if running under emulation on Arm64, this is going to return the Arm info
988
1044
OutputSectionHeader (MIDIDIAG_SECTION_LABEL_NATIVE_SYSTEM_INFO);
989
1045
990
1046
SYSTEM_INFO sysinfoNative;
991
1047
::GetNativeSystemInfo (&sysinfoNative);
992
1048
OutputSystemInfo (sysinfoNative);
993
1049
1050
+ OutputItemSeparator ();
1051
+ OutputProcessAndNativeMachine ();
1052
+ OutputItemSeparator ();
1053
+
994
1054
TIMECAPS timecaps;
995
1055
auto tcresult = ::timeGetDevCaps (&timecaps, sizeof (timecaps));
996
1056
0 commit comments