-
-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathDetermine_the_process_bitness.ps1
More file actions
40 lines (38 loc) · 839 Bytes
/
Determine_the_process_bitness.ps1
File metadata and controls
40 lines (38 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# https://rkeithhill.wordpress.com/2014/04/28/how-to-determine-if-a-process-is-32-or-64-bit/
function ProcessBitness
{
param
(
[Parameter(Mandatory = $true)]
[string]
$ProcessName
)
$Signature = @{
Namespace = "Kernel32"
Name = "Bitness"
Language = "CSharp"
MemberDefinition = @"
[DllImport("kernel32.dll")]
public static extern bool IsWow64Process(System.IntPtr hProcess, [Out] out bool wow64Process);
"@
}
if (-not ("Kernel32.Bitness" -as [type]))
{
Add-Type @Signature
}
Get-Process -Name $ProcessName | ForEach-Object -Process {
$is32Bit = [int]0
if ([Kernel32.Bitness]::IsWow64Process($_.Handle, [ref]$is32Bit))
{
if ($is32Bit)
{
"$($_.Name) is 32-bit"
}
else
{
"$($_.Name) is 64-bit"
}
}
}
}
ProcessBitness -ProcessName pwsh