Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(windows): report on processor type in tsysinfo #13084

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions windows/src/engine/tsysinfo/si_overview.pas
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class function TSI_Overview.GetCaption: String;
Result := 'Overview';
end;

type
TIsWow64Process2 = function(hProcess: THandle; out pProcessMachine: USHORT; out pNativeMachine: USHORT): BOOL; stdcall;

function TSI_Overview.DoCollect: Boolean;
var
n, nn, node: IXMLDOMNode;
Expand All @@ -55,6 +58,9 @@ function TSI_Overview.DoCollect: Boolean;
buf: array[0..1023] of char;
freespace, totalspace, totalfree: Int64;
stat: TMemoryStatus;
processMachine: USHORT;
nativeMachine: USHORT;
IsWow64Process2: TIsWow64Process2;
begin
{
SYSTEM INFO:
Expand Down Expand Up @@ -85,6 +91,17 @@ function TSI_Overview.DoCollect: Boolean;
then xmlSetAttribute(n,'x64', 'true')
else xmlSetAttribute(n,'x64', 'false');

IsWow64Process2 := GetProcAddress(GetModuleHandle(kernel32), 'IsWow64Process2');
if Assigned(IsWow64Process2) then
begin
if IsWow64Process2(GetCurrentProcess, processMachine, nativeMachine) then
begin
// https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants
xmlSetAttribute(n, 'ProcessMachine', IntToHex(processMachine, 4));
xmlSetAttribute(n, 'NativeMachine', IntToHex(nativeMachine, 4));
end;
end;

{ Free disk space }

n := xmlAddChild(node,'DiskSpace');
Expand Down
42 changes: 40 additions & 2 deletions windows/src/engine/tsysinfo/si_overview.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</tbody>
</table>
</xsl:template>


<xsl:template match="HardDrive">
<tr>
Expand Down Expand Up @@ -128,8 +128,46 @@
<xsl:value-of select="@x64"/>
</td>
</tr>
<tr>
<th>Native Machine</th>
<td>
<xsl:choose>
<xsl:when test="@NativeMachine = '014C'">Intel 386</xsl:when>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do these table values come from?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are documented at https://learn.microsoft.com/en-us/windows/win32/sysinfo/image-file-machine-constants (that link is in the .pas, not in the .xslt though)

<xsl:when test="@NativeMachine = '0162'">MIPS R3000</xsl:when>
<xsl:when test="@NativeMachine = '0160'">MIPS R3000</xsl:when>
<xsl:when test="@NativeMachine = '0166'">MIPS R4000</xsl:when>
<xsl:when test="@NativeMachine = '0168'">MIPS R10000</xsl:when>
<xsl:when test="@NativeMachine = '0169'">MIPS WCE v2</xsl:when>
<xsl:when test="@NativeMachine = '0184'">Alpha AXP</xsl:when>
<xsl:when test="@NativeMachine = '01A2'">SH3</xsl:when>
<xsl:when test="@NativeMachine = '01A3'">SH3 DSP</xsl:when>
<xsl:when test="@NativeMachine = '01A4'">SH3E</xsl:when>
<xsl:when test="@NativeMachine = '01A6'">SH4</xsl:when>
<xsl:when test="@NativeMachine = '01A8'">SH5</xsl:when>
<xsl:when test="@NativeMachine = '01C0'">ARM</xsl:when>
<xsl:when test="@NativeMachine = '01C2'">ARM Thumb</xsl:when>
<xsl:when test="@NativeMachine = '01C4'">ARM Thumb 2</xsl:when>
<xsl:when test="@NativeMachine = '01D3'">TAM33BD</xsl:when>
<xsl:when test="@NativeMachine = '01F0'">PowerPC</xsl:when>
<xsl:when test="@NativeMachine = '01F1'">PowerPC FP</xsl:when>
<xsl:when test="@NativeMachine = '0200'">Intel IA64</xsl:when>
<xsl:when test="@NativeMachine = '0266'">MIPS 16</xsl:when>
<xsl:when test="@NativeMachine = '0284'">Alpha 64</xsl:when>
<xsl:when test="@NativeMachine = '0366'">MIPSFPU</xsl:when>
<xsl:when test="@NativeMachine = '0466'">AXP64</xsl:when>
<xsl:when test="@NativeMachine = '0520'">Infineon</xsl:when>
<xsl:when test="@NativeMachine = '0CEF'">CEF</xsl:when>
<xsl:when test="@NativeMachine = '0EBC'">EBC (EFI Byte Code)</xsl:when>
<xsl:when test="@NativeMachine = '8664'">AMD64</xsl:when>
<xsl:when test="@NativeMachine = '9041'">M32R</xsl:when>
<xsl:when test="@NativeMachine = 'AA64'">ARM64</xsl:when>
<xsl:when test="@NativeMachine = 'C0EE'">CEE</xsl:when>
<xsl:otherwise><xsl:value-of select="@NativeMachine" /></xsl:otherwise>
</xsl:choose>
</td>
</tr>
</tbody>
</table>
</xsl:template>

</xsl:stylesheet>
</xsl:stylesheet>