2018-06-25 06:42:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <switch.h>
|
|
|
|
|
2018-06-25 07:45:25 +00:00
|
|
|
#include "creport_debug_types.hpp"
|
|
|
|
|
2018-06-25 06:42:26 +00:00
|
|
|
class CrashReport {
|
|
|
|
private:
|
|
|
|
Handle debug_handle;
|
|
|
|
bool has_extra_info;
|
|
|
|
Result result;
|
|
|
|
|
2018-06-25 07:45:25 +00:00
|
|
|
/* Attach Process Info. */
|
|
|
|
AttachProcessInfo process_info;
|
|
|
|
u64 userdata_5x_address;
|
|
|
|
u64 userdata_5x_size;
|
|
|
|
|
2018-06-25 06:42:26 +00:00
|
|
|
public:
|
2018-06-25 07:45:25 +00:00
|
|
|
CrashReport() : debug_handle(INVALID_HANDLE), result(0xC6A8), process_info({0}) { }
|
2018-06-25 06:42:26 +00:00
|
|
|
|
|
|
|
void BuildReport(u64 pid, bool has_extra_info);
|
2018-06-25 07:45:25 +00:00
|
|
|
void ProcessExceptions();
|
2018-06-25 06:42:26 +00:00
|
|
|
|
|
|
|
Result GetResult() {
|
|
|
|
return this->result;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OpenProcess(u64 pid) {
|
|
|
|
return R_SUCCEEDED(svcDebugActiveProcess(&debug_handle, pid));
|
|
|
|
}
|
|
|
|
|
2018-06-25 07:45:25 +00:00
|
|
|
bool IsOpen() {
|
|
|
|
return this->debug_handle != INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
2018-06-25 06:42:26 +00:00
|
|
|
void Close() {
|
2018-06-25 07:45:25 +00:00
|
|
|
if (IsOpen()) {
|
2018-06-25 06:42:26 +00:00
|
|
|
svcCloseHandle(debug_handle);
|
|
|
|
debug_handle = INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
}
|
2018-06-25 07:45:25 +00:00
|
|
|
|
|
|
|
bool IsApplication() {
|
|
|
|
return (process_info.flags & 0x40) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Is64Bit() {
|
|
|
|
return (process_info.flags & 0x01) != 0;
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
void HandleAttachProcess(DebugEventInfo &d);
|
|
|
|
void HandleException(DebugEventInfo &d);
|
2018-06-25 06:42:26 +00:00
|
|
|
};
|