summaryrefslogtreecommitdiff
path: root/src/env.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-07-18 02:24:44 -0400
committerisanae <14251494+isanae@users.noreply.github.com>2020-11-03 11:39:01 -0500
commit5e528fb4cf16ae208944d15d568c9140e3d741e4 (patch)
tree8fd4927aeffb19406e2356d39c2bec0751c7f53d /src/env.cpp
parentb103f297752b170ee4ade6e0e9085c6d31c020ca (diff)
new CommandLine class
implemented crashdump as a command, fixed dump_running_process.bat to use it attach to console if present instead of always create one
Diffstat (limited to 'src/env.cpp')
-rw-r--r--src/env.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/env.cpp b/src/env.cpp
index 2862aa95..bf75c9fa 100644
--- a/src/env.cpp
+++ b/src/env.cpp
@@ -16,9 +16,15 @@ using namespace MOBase;
Console::Console()
: m_hasConsole(false), m_in(nullptr), m_out(nullptr), m_err(nullptr)
{
- // open a console
- if (!AllocConsole()) {
- // failed, ignore
+ // try to attach to parent
+ if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
+ if (GetLastError() != ERROR_ACCESS_DENIED) {
+ // parent has no console, create one
+ if (!AllocConsole()) {
+ // failed, ignore
+ return;
+ }
+ }
}
m_hasConsole = true;
@@ -1032,6 +1038,36 @@ HandlePtr dumpFile()
return {};
}
+
+CoreDumpTypes coreDumpTypeFromString(const std::string& s)
+{
+ if (s == "data")
+ return env::CoreDumpTypes::Data;
+ else if (s == "full")
+ return env::CoreDumpTypes::Full;
+ else
+ return env::CoreDumpTypes::Mini;
+}
+
+std::string toString(CoreDumpTypes type)
+{
+ switch (type)
+ {
+ case CoreDumpTypes::Mini:
+ return "mini";
+
+ case CoreDumpTypes::Data:
+ return "data";
+
+ case CoreDumpTypes::Full:
+ return "full";
+
+ default:
+ return "?";
+ }
+}
+
+
bool createMiniDump(HANDLE process, CoreDumpTypes type)
{
const DWORD pid = GetProcessId(process);