-
Notifications
You must be signed in to change notification settings - Fork 348
/
Copy pathStripSymbols.ps1
75 lines (63 loc) · 1.99 KB
/
StripSymbols.ps1
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
param(
[parameter(mandatory)][string] $InputDirectory,
[parameter(mandatory)][string] $OutputDirectory
)
Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"
function Get-Is64Bit
{
return $env:PROCESSOR_ARCHITECTURE -eq "AMD64"
}
function Get-DebuggingToolsRoot
{
# Constants
$windowsSDKRegPath = if (Get-Is64Bit) { "HKLM:\Software\WOW6432Node\Microsoft\Windows Kits\Installed Roots" } else { "HKLM:\Software\Microsoft\Windows Kits\Installed Roots" }
$windowsDebuggingToolsRegRootKey = "WindowsDebuggersRoot10"
try
{
return Get-ItemProperty -Path $windowsSDKRegPath | Select-Object -ExpandProperty $windowsDebuggingToolsRegRootKey
}
catch
{
return $null
}
}
function Remove-PrivateSymbolInformation(
[parameter(mandatory)][ValidateNotNullOrEmpty()] [string] $inputPdbPath,
[parameter(mandatory)][ValidateNotNullOrEmpty()] [string] $outputPdbPath)
{
$debuggingToolsRoot = Get-DebuggingToolsRoot
if (Get-Is64Bit)
{
$pdbCopy = Join-Path $debuggingToolsRoot "x64\pdbcopy.exe"
}
else
{
$pdbCopy = Join-Path $debuggingToolsRoot "x86\pdbcopy.exe"
}
$arguments = "$inputPdbPath $outputPdbPath -p"
Write-Host "$inputPdbPath => $outputPdbPath"
Start-Process -Wait -NoNewWindow $pdbCopy $arguments
}
Write-Host -NoNewline "Checking for installed Debugging Tools for Windows..."
$debuggingToolsRoot = Get-DebuggingToolsRoot
if ($debuggingToolsRoot)
{
Write-Host -ForegroundColor Green "FOUND"
}
else
{
Write-Host -ForegroundColor Yellow "MISSING"
}
if (Test-Path $OutputDirectory)
{
Remove-Item -Recurse $OutputDirectory
}
New-Item -ItemType Directory $OutputDirectory | Out-Null
Write-Host "Stripping private information from symbols..."
foreach ($inputPdb in (Get-ChildItem -Recurse -Filter "*.pdb" $InputDirectory))
{
$inputPdbPath = $inputPdb.FullName
$outputPdbPath = Join-Path $OutputDirectory $inputPdb.name
Remove-PrivateSymbolInformation $inputPdbPath $outputPdbPath
}