C# 抓取进程快照 propDump方式
2022/6/29 5:22:50
本文主要是介绍C# 抓取进程快照 propDump方式,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
private static void CreateMiniDump(string processName)
{
var pl = Process.GetProcessesByName(processName);
if (pl.Length == 0)
{
Console.WriteLine($"找不到进程:{processName}");
return;
}
var process = pl[0];
{
Process.Start("plugins\\procdump.exe", $"-ma {process.Id} -o {AppDomain.CurrentDomain.BaseDirectory}");
//MiniDumpWriteDump(process.Handle,
// process.Id,
// fs.SafeFileHandle.DangerousGetHandle(),
// MINIDUMP_TYPE.MiniDumpNormal,
// IntPtr.Zero,
// IntPtr.Zero,
// IntPtr.Zero);
Console.WriteLine("完成");
}
}
[DllImport("dbghelp.dll")]
public static extern bool MiniDumpWriteDump(IntPtr hProcess,
Int32 ProcessId,
IntPtr hFile,
int DumpType,
IntPtr ExceptionParam,
IntPtr UserStreamParam,
IntPtr CallackParam);
public static class MINIDUMP_TYPE
{
public const int MiniDumpNormal = 0x00000000;
public const int MiniDumpWithDataSegs = 0x00000001;
public const int MiniDumpWithFullMemory = 0x00000002;
public const int MiniDumpWithHandleData = 0x00000004;
public const int MiniDumpFilterMemory = 0x00000008;
public const int MiniDumpScanMemory = 0x00000010;
public const int MiniDumpWithUnloadedModules = 0x00000020;
public const int MiniDumpWithIndirectlyReferencedMemory = 0x00000040;
public const int MiniDumpFilterModulePaths = 0x00000080;
public const int MiniDumpWithProcessThreadData = 0x00000100;
public const int MiniDumpWithPrivateReadWriteMemory = 0x00000200;
public const int MiniDumpWithoutOptionalData = 0x00000400;
public const int MiniDumpWithFullMemoryInfo = 0x00000800;
public const int MiniDumpWithThreadInfo = 0x00001000;
public const int MiniDumpWithCodeSegs = 0x00002000;
}
static void Main(string[] args)
{
//https://docs.microsoft.com/en-us/sysinternals/downloads/procdump
//procdump -ma 4572
Console.WriteLine("正在生成内存快照,请稍等");
CreateMiniDump();
for (int i = 5; i > 0; i--)
{
Console.WriteLine($"完毕,{i}秒后退出...");
Thread.Sleep(1000);
}
}
这篇关于C# 抓取进程快照 propDump方式的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-12-06使用Microsoft.Extensions.AI在.NET中生成嵌入向量
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#