diff --git a/stratosphere/dmnt/source/dmnt_debug_monitor.cpp b/stratosphere/dmnt/source/dmnt_debug_monitor.cpp
new file mode 100644
index 000000000..30c4e19a4
--- /dev/null
+++ b/stratosphere/dmnt/source/dmnt_debug_monitor.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2018 Atmosphère-NX
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+#include "dmnt_debug_monitor.hpp"
+
+Result DebugMonitorService::BreakDebugProcess(Handle debug_hnd) {
+ /* Nintendo discards the output of this command, but we will return it. */
+ return svcBreakDebugProcess(debug_hnd);
+}
+
+Result DebugMonitorService::TerminateDebugProcess(Handle debug_hnd) {
+ /* Nintendo discards the output of this command, but we will return it. */
+ return svcTerminateDebugProcess(debug_hnd);
+}
+
+Result DebugMonitorService::CloseHandle(Handle debug_hnd) {
+ /* Nintendo discards the output of this command, but we will return it. */
+ /* This command is, entertainingly, also pretty unsafe in general... */
+ return svcCloseHandle(debug_hnd);
+}
diff --git a/stratosphere/dmnt/source/dmnt_debug_monitor.hpp b/stratosphere/dmnt/source/dmnt_debug_monitor.hpp
new file mode 100644
index 000000000..028e5173d
--- /dev/null
+++ b/stratosphere/dmnt/source/dmnt_debug_monitor.hpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2018 Atmosphère-NX
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#pragma once
+#include
+#include
+
+enum DmntCmd {
+ DebugMonitor_Cmd_BreakDebugProcess = 0,
+ DebugMonitor_Cmd_TerminateDebugProcess = 1,
+ DebugMonitor_Cmd_CloseHandle = 2,
+ DebugMonitor_Cmd_LoadImage = 3,
+ DebugMonitor_Cmd_GetProcessId = 4,
+ DebugMonitor_Cmd_GetProcessHandle = 5,
+ DebugMonitor_Cmd_WaitSynchronization = 6,
+ DebugMonitor_Cmd_GetDebugEvent = 7,
+ DebugMonitor_Cmd_GetProcessModuleInfo = 8,
+ DebugMonitor_Cmd_GetProcessList = 9,
+ DebugMonitor_Cmd_GetThreadList = 10,
+ DebugMonitor_Cmd_GetDebugThreadContext = 11,
+ DebugMonitor_Cmd_ContinueDebugEvent = 12,
+ DebugMonitor_Cmd_ReadDebugProcessMemory = 13,
+ DebugMonitor_Cmd_WriteDebugProcessMemory = 14,
+ DebugMonitor_Cmd_SetDebugThreadContext = 15,
+ DebugMonitor_Cmd_GetDebugThreadParam = 16,
+ DebugMonitor_Cmd_InitializeThreadInfo = 17,
+ DebugMonitor_Cmd_SetHardwareBreakPoint = 18,
+ DebugMonitor_Cmd_QueryDebugProcessMemory = 19,
+ DebugMonitor_Cmd_GetProcessMemoryDetails = 20,
+ DebugMonitor_Cmd_AttachByProgramId = 21,
+ DebugMonitor_Cmd_AttachOnLaunch = 22,
+ DebugMonitor_Cmd_GetDebugMonitorProcessId = 23,
+ DebugMonitor_Cmd_GetJitDebugProcessList = 25,
+ DebugMonitor_Cmd_CreateCoreDump = 26,
+ DebugMonitor_Cmd_GetAllDebugThreadInfo = 27,
+ DebugMonitor_Cmd_TargetIO_FileOpen = 29,
+ DebugMonitor_Cmd_TargetIO_FileClose = 30,
+ DebugMonitor_Cmd_TargetIO_FileRead = 31,
+ DebugMonitor_Cmd_TargetIO_FileWrite = 32,
+ DebugMonitor_Cmd_TargetIO_FileSetAttributes = 33,
+ DebugMonitor_Cmd_TargetIO_FileGetInformation = 34,
+ DebugMonitor_Cmd_TargetIO_FileSetTime = 35,
+ DebugMonitor_Cmd_TargetIO_FileSetSize = 36,
+ DebugMonitor_Cmd_TargetIO_FileDelete = 37,
+ DebugMonitor_Cmd_TargetIO_FileMove = 38,
+ DebugMonitor_Cmd_TargetIO_DirectoryCreate = 39,
+ DebugMonitor_Cmd_TargetIO_DirectoryDelete = 40,
+ DebugMonitor_Cmd_TargetIO_DirectoryRename = 41,
+ DebugMonitor_Cmd_TargetIO_DirectoryGetCount = 42,
+ DebugMonitor_Cmd_TargetIO_DirectoryOpen = 43,
+ DebugMonitor_Cmd_TargetIO_DirectoryGetNext = 44,
+ DebugMonitor_Cmd_TargetIO_DirectoryClose = 45,
+ DebugMonitor_Cmd_TargetIO_GetFreeSpace = 46,
+ DebugMonitor_Cmd_TargetIO_GetVolumeInformation = 47,
+ DebugMonitor_Cmd_InitiateCoreDump = 48,
+ DebugMonitor_Cmd_ContinueCoreDump = 49,
+ DebugMonitor_Cmd_AddTTYToCoreDump = 50,
+ DebugMonitor_Cmd_AddImageToCoreDump = 51,
+ DebugMonitor_Cmd_CloseCoreDump = 52,
+ DebugMonitor_Cmd_CancelAttach = 53,
+};
+
+class DebugMonitorService final : public IServiceObject {
+ private:
+ Result BreakDebugProcess(Handle debug_hnd);
+ Result TerminateDebugProcess(Handle debug_hnd);
+ Result CloseHandle(Handle debug_hnd);
+ public:
+ DEFINE_SERVICE_DISPATCH_TABLE {
+ MakeServiceCommandMeta(),
+ MakeServiceCommandMeta(),
+ MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ // MakeServiceCommandMeta(),
+ };
+};
diff --git a/stratosphere/dmnt/source/dmnt_main.cpp b/stratosphere/dmnt/source/dmnt_main.cpp
index 73adbbcaf..dbf936635 100644
--- a/stratosphere/dmnt/source/dmnt_main.cpp
+++ b/stratosphere/dmnt/source/dmnt_main.cpp
@@ -23,6 +23,8 @@
#include
#include
+#include "dmnt_debug_monitor.hpp"
+
extern "C" {
extern u32 __start__;
@@ -121,8 +123,17 @@ void __appExit(void) {
int main(int argc, char **argv)
{
consoleDebugInit(debugDevice_SVC);
-
- /* TODO: Make a server manager, and process on it. */
+
+ /* Nintendo uses four threads. */
+ auto server_manager = new WaitableManager(4);
+
+ /* Create services. */
+ server_manager->AddWaitable(new ServiceServer("dmnt:-", 4));
+
+ /* Loop forever, servicing our services. */
+ server_manager->Process();
+
+ delete server_manager;
return 0;
}