https://github.com/ex-exe/windowsdumpwriter
Library function that output dump on Windows.
https://github.com/ex-exe/windowsdumpwriter
csharp dump library windows
Last synced: 12 months ago
JSON representation
Library function that output dump on Windows.
- Host: GitHub
- URL: https://github.com/ex-exe/windowsdumpwriter
- Owner: EX-EXE
- License: mit
- Created: 2023-07-08T08:38:14.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-19T00:55:40.000Z (over 2 years ago)
- Last Synced: 2025-06-16T22:45:47.756Z (about 1 year ago)
- Topics: csharp, dump, library, windows
- Language: C#
- Homepage:
- Size: 39.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://badge.fury.io/nu/WindowsDumpWriter)
# WindowsDumpWriter
Library function that output dump on Windows.
# Library Usage
PM> Install-Package [WindowsDumpWriter](https://www.nuget.org/packages/WindowsDumpWriter/)
```
var result = WindowsDumpWriter.Write(
outputFilePath,
dumpType,
processId,
threadId,
address);
```
# App Usage
## CommandLine Example
```
WindowsDumpWriter.exe --Output "./MiniDump.dmp" --DumpType 6182 --ProcessId 39520
```
```
WindowsDumpWriter.exe --Output "./MiniDump.dmp" --DumpType 6182 --ProcessId 39520 --ThreadId 46800 --ExceptionAddress 0x000000FD0E4FEBE0
```
| Param | Description |
|---|---|
| --Output | Output dump file path. |
| --DumpType | DumpType |
| --ProcessId | Dump process id. |
| --ThreadId | ThreadId in exception info. |
| --ExceptionAddress | ExceptionAddress in exception info. |
## VC++ Example
```cpp
#include
#include
#include
int GenerateDump(EXCEPTION_POINTERS* exceptionPtr)
{
const DWORD processId = GetCurrentProcessId();
const DWORD threadId = GetCurrentThreadId();
// Create ProcessInfo
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;
ZeroMemory(&startupInfo, sizeof(startupInfo));
ZeroMemory(&processInfo, sizeof(processInfo));
startupInfo.cb = sizeof(startupInfo);
// Cmd
static constexpr int bufferSize = 4096;
WCHAR cmd[bufferSize];
const int dumpType = MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithUnloadedModules | MiniDumpWithFullMemoryInfo | MiniDumpWithThreadInfo;
swprintf(cmd,
bufferSize,
L"\"%s\" --Output \"%s\" --DumpType %d --ProcessId %d --ThreadId %d --ExceptionAddress 0x%p",
L"./WindowsDumpWriter.exe",
L"./MiniDump.dmp",
dumpType,
processId,
threadId,
exceptionPtr);
// Process
if (CreateProcess(
nullptr,
cmd,
nullptr,
nullptr,
false,
0,
nullptr,
nullptr,
&startupInfo,
&processInfo))
{
// Wait Process
WaitForSingleObject(processInfo.hProcess, INFINITE);
// Exit Code
unsigned long exitCode;
GetExitCodeProcess(processInfo.hProcess, &exitCode);
// Close Handle
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
return EXCEPTION_EXECUTE_HANDLER;
}
int main()
{
std::thread thread([&]
{
__try
{
// Exception Code
int* ptr = nullptr;
*ptr = 0;
}
__except (GenerateDump(GetExceptionInformation()))
{
}
});
thread.join();
}
```