Skip to content

Instantly share code, notes, and snippets.

@cobalthex
Last active September 4, 2025 22:55
Show Gist options
  • Select an option

  • Save cobalthex/86367a2d09f941bb49bc3b81f6bb6e51 to your computer and use it in GitHub Desktop.

Select an option

Save cobalthex/86367a2d09f941bb49bc3b81f6bb6e51 to your computer and use it in GitHub Desktop.
[public] powershell
param([Parameter(Mandatory, Position=0)]$ExePath)
$exeBytes = Get-Content $ExePath -AsByteStream -TotalCount 4096
$peOffset = [BitConverter]::ToInt32($exeBytes, 0x3c)
$machine = [BitConverter]::ToUInt16($exeBytes, $peOffset + 4)
switch ($machine)
{
0x014c { "x86" }
0x8664 { "x64" }
0xAA64 { "ARM64" }
0x01c0 { "ARM" }
default { "Unknown (0x$($machine.ToString("X")))" }
}

Comments are disabled for this gist.