-
Notifications
You must be signed in to change notification settings - Fork 108
Add instructions for dumping all Bluetooth services. #43
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
base: master
Are you sure you want to change the base?
Changes from all commits
6e09356
859ccde
d78bbaf
11c1767
729b9fc
6178d65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| $WerNativeMethods = [PSObject].Assembly.GetType('System.Management.Automation.WindowsErrorReporting').GetNestedType('NativeMethods', 'NonPublic') | ||
| $MiniDumpWriteDump = $WerNativeMethods.GetMethod('MiniDumpWriteDump', ([Reflection.BindingFlags]'NonPublic, Static')) | ||
|
|
||
| $ServiceNames = @('BthServ', 'Bluetooth%', 'BTAGService', 'BthAvctpSvc') | ||
|
|
||
| If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` | ||
|
|
||
| [Security.Principal.WindowsBuiltInRole] “Administrator”)) { | ||
| Write-Error "Administrator rights are required to collect dumps." | ||
| Break | ||
| } | ||
|
|
||
| $DumpFolder = Join-Path ($Env:Temp) (Get-Random -Minimum 1000) | ||
| New-Item -Path $DumpFolder -Type Directory | Out-Null | ||
|
|
||
| foreach ( $ServiceName in $ServiceNames ) { | ||
| Trap [System.Management.Automation.ParameterBindingException] { | ||
| Write-Warning "Could not find $ServiceName, it is likely not running." | ||
| Continue } | ||
| $Process = $null #ensure null on failure below | ||
| $Process = Get-Process -Id (Get-WmiObject -Class Win32_Service -Filter "Name LIKE '$ServiceName'" | Select-Object -ExpandProperty ProcessId) | ||
|
|
||
| if ($Process) { | ||
| $DumpFilePath = Join-Path $DumpFolder "$($ServiceName)_$($Process.Id).dmp" | ||
| $DumpFile = New-Object IO.FileStream($DumpFilePath, [IO.FileMode]::Create) | ||
|
|
||
| Write-Host "Dumping service $ServiceName with PID $($Process.Id)..." | ||
| $Result = $MiniDumpWriteDump.Invoke($null, @($Process.Handle, $Process.Id, $DumpFile.SafeFileHandle, [UInt32]0x2, [IntPtr]::Zero, [IntPtr]::Zero, [IntPtr]::Zero)) | ||
|
|
||
| $DumpFile.Close() | ||
|
|
||
| if (-not $Result) { | ||
| Write-Error "Failed to write dump file for service $ServiceName with PID $($Process.Id)." | ||
| Break } | ||
| } | ||
| } | ||
|
|
||
| if ((gci $DumpFolder).Count -gt 1) { | ||
| Compress-Archive $DumpFolder "$DumpFolder.zip" -CompressionLevel Optimal -Force | ||
| Write-Host "Dumps stored in $DumpFolder.zip." | ||
| } | ||
|
|
||
| Trap {Continue} Remove-Item $DumpFolder -Force -Recurse |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,3 +51,10 @@ wpr.exe /? will also give you more information. | |
| From PowerShell execute: | ||
|
|
||
| wget https://github.com/Microsoft/busiotools/raw/master/bluetooth/tracing/GetBluetoothRadioInfo.ps1 -UseBasicParsing | iex | ||
|
|
||
| # How to collect memory dump | ||
|
|
||
| From elevated PowerShell execute: | ||
|
|
||
| wget https://github.com/Microsoft/busiotools/raw/master/bluetooth/tracing/GetMemoryDump.ps1 -UseBasicParsing | iex | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ProcessDump
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The script name is indeed GetMemoryDump are you suggesting it's be renamed to GetProcessDumps.ps1?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes I think that would make it clear. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.