feat: add process crash popups
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* CrashReportSyscall.hpp
|
||||
* SYS_CRASH_REPORT
|
||||
* Copyright (c) 2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include "Syscall.hpp"
|
||||
#include "../CrashReport.hpp"
|
||||
|
||||
namespace Montauk {
|
||||
|
||||
static int64_t Sys_CrashReport(CrashReportInfo* out) {
|
||||
if (!out) return 0;
|
||||
if (CrashReport::g_reportCount == 0) return 0;
|
||||
|
||||
int oldestIdx = (CrashReport::g_reportHead - CrashReport::g_reportCount + CrashReport::MaxReports) % CrashReport::MaxReports;
|
||||
auto* rep = &CrashReport::g_reports[oldestIdx];
|
||||
|
||||
out->pid = rep->pid;
|
||||
for (int i = 0; i < 64 && rep->processName[i]; i++) out->processName[i] = rep->processName[i];
|
||||
out->processName[63] = '\0';
|
||||
out->exceptionVector = rep->exceptionVector;
|
||||
for (int i = 0; i < 32 && rep->exceptionName[i]; i++) out->exceptionName[i] = rep->exceptionName[i];
|
||||
out->exceptionName[31] = '\0';
|
||||
out->faultingAddress = rep->faultingAddress;
|
||||
out->instructionPointer = rep->instructionPointer;
|
||||
out->stackPointer = rep->stackPointer;
|
||||
out->codeSegment = rep->codeSegment;
|
||||
out->flags = rep->flags;
|
||||
out->stackSegment = rep->stackSegment;
|
||||
out->pfPresent = rep->pfPresent;
|
||||
out->pfWrite = rep->pfWrite;
|
||||
out->pfUser = rep->pfUser;
|
||||
out->pfReservedWrite = rep->pfReservedWrite;
|
||||
out->pfInstructionFetch = rep->pfInstructionFetch;
|
||||
out->pfProtectionKey = rep->pfProtectionKey;
|
||||
out->pfShadowStack = rep->pfShadowStack;
|
||||
out->pfSGX = rep->pfSGX;
|
||||
out->timestampTick = rep->timestampTick;
|
||||
rep->valid = false;
|
||||
CrashReport::g_reportCount--;
|
||||
|
||||
return CrashReport::g_reportCount + 1;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "BluetoothSyscall.hpp" // SYS_BTSCAN, SYS_BTCONNECT, SYS_BTDISCONNECT, SYS_BTLIST, SYS_BTINFO
|
||||
#include "IpcSyscall.hpp" // SYS_DUPHANDLE, SYS_WAIT_HANDLE, SYS_STREAM_CREATE, SYS_STREAM_READ, SYS_STREAM_WRITE, SYS_MAILBOX_CREATE, SYS_MAILBOX_SEND, SYS_MAILBOX_RECV, SYS_WAITSET_CREATE, SYS_WAITSET_ADD, SYS_WAITSET_REMOVE, SYS_WAITSET_WAIT, SYS_PROC_OPEN, SYS_SURFACE_CREATE, SYS_SURFACE_MAP, SYS_SURFACE_RESIZE
|
||||
#include "LibSyscall.hpp" // SYS_LOAD_LIB, SYS_UNLOAD_LIB, SYS_DLSYM
|
||||
#include "CrashReportSyscall.hpp" // SYS_CRASH_REPORT
|
||||
|
||||
// Assembly entry point
|
||||
extern "C" void SyscallEntry();
|
||||
@@ -419,6 +420,8 @@ namespace Montauk {
|
||||
return (int64_t)Sys_DLSym(frame->arg1, frame->arg2);
|
||||
case SYS_GETLIBBASE:
|
||||
return (int64_t)Sys_GetLibBase(frame->arg1);
|
||||
case SYS_CRASH_REPORT:
|
||||
return Sys_CrashReport((CrashReportInfo*)frame->arg1);
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -212,6 +212,9 @@ namespace Montauk {
|
||||
static constexpr uint64_t SYS_DLSYM = 116;
|
||||
static constexpr uint64_t SYS_GETLIBBASE = 117;
|
||||
|
||||
/* CrashReport.hpp */
|
||||
static constexpr uint64_t SYS_CRASH_REPORT = 118;
|
||||
|
||||
static constexpr uint32_t IPC_SIGNAL_READABLE = 1u << 0;
|
||||
static constexpr uint32_t IPC_SIGNAL_WRITABLE = 1u << 1;
|
||||
static constexpr uint32_t IPC_SIGNAL_PEER_CLOSED = 1u << 2;
|
||||
@@ -422,6 +425,29 @@ namespace Montauk {
|
||||
uint32_t _pad;
|
||||
};
|
||||
|
||||
// Crash report (filled by kernel on process fault, returned via SYS_CRASH_REPORT)
|
||||
struct CrashReportInfo {
|
||||
int pid;
|
||||
char processName[64];
|
||||
uint8_t exceptionVector;
|
||||
char exceptionName[32];
|
||||
uint64_t faultingAddress;
|
||||
uint64_t instructionPointer;
|
||||
uint64_t stackPointer;
|
||||
uint64_t codeSegment;
|
||||
uint64_t flags;
|
||||
uint64_t stackSegment;
|
||||
uint8_t pfPresent : 1;
|
||||
uint8_t pfWrite : 1;
|
||||
uint8_t pfUser : 1;
|
||||
uint8_t pfReservedWrite : 1;
|
||||
uint8_t pfInstructionFetch : 1;
|
||||
uint8_t pfProtectionKey : 1;
|
||||
uint8_t pfShadowStack : 1;
|
||||
uint8_t pfSGX : 1;
|
||||
uint64_t timestampTick;
|
||||
};
|
||||
|
||||
// Stack frame pushed by SyscallEntry.asm
|
||||
struct SyscallFrame {
|
||||
uint64_t r15, r14, r13, r12, rbp, rbx; // callee-saved
|
||||
|
||||
Reference in New Issue
Block a user