; 创建进程转储文件
OwnPID   := DllCall("GetCurrentProcessId")
FileName := A_Hour "_" A_Min "_" A_Sec "-Dumped.dmp"

MiniDump(OwnPID, FileName)


MiniDump(ProcessID, FileName, DumpType := 0) {
  if !(hProc := DllCall("OpenProcess", "uint", 0x0450, "int", 0, "uint", ProcessID, "ptr"))
    throw Exception("OpenProcess failure", -1)
  if !(hFile := DllCall("CreateFile", "str", FileName, "uint", 0xC0000000, "uint", 3, "ptr", 0, "uint", 2, "uint", 0, "ptr", 0, "ptr"))
    throw Exception("Failed to create a file", -1)
  if !(DllCall("dbghelp.dll\MiniDumpWriteDump", "ptr", hProc, "uint", ProcessID, "ptr", hFile, "int", DumpType, "ptr", 0, "ptr", 0, "ptr", 0))
    throw Exception("Failed to create a mini dump", -1)
  return 1, DllCall("CloseHandle", "ptr", hFile) && DllCall("CloseHandle", "ptr", hProc)
}

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。