mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-22 18:32:05 +00:00
dmnt: fix some bugs in init
This commit is contained in:
parent
78a730ddf6
commit
8abee1bdaa
4 changed files with 20 additions and 12 deletions
|
@ -16,6 +16,7 @@
|
|||
},
|
||||
"service_access": [
|
||||
"pm:dmnt",
|
||||
"pm:info",
|
||||
"ldr:dmnt",
|
||||
"ro:dmnt",
|
||||
"ns:dev",
|
||||
|
|
|
@ -116,6 +116,9 @@ namespace sts::dmnt::cheat::impl {
|
|||
|
||||
void CloseActiveCheatProcess() {
|
||||
if (this->cheat_process_debug_handle != INVALID_HANDLE) {
|
||||
/* Knock out the debug events thread. */
|
||||
R_ASSERT(this->debug_events_thread.CancelSynchronization());
|
||||
|
||||
/* Close resources. */
|
||||
R_ASSERT(svcCloseHandle(this->cheat_process_debug_handle));
|
||||
this->cheat_process_debug_handle = INVALID_HANDLE;
|
||||
|
@ -146,6 +149,8 @@ namespace sts::dmnt::cheat::impl {
|
|||
u64 tmp;
|
||||
bool has_cheat_process = this->cheat_process_debug_handle != INVALID_HANDLE;
|
||||
has_cheat_process &= R_SUCCEEDED(svcGetProcessId(&tmp, this->cheat_process_debug_handle));
|
||||
has_cheat_process &= R_SUCCEEDED(pm::dmnt::GetApplicationProcessId(&tmp));
|
||||
has_cheat_process &= (tmp == this->cheat_process_metadata.process_id);
|
||||
|
||||
if (!has_cheat_process) {
|
||||
this->CloseActiveCheatProcess();
|
||||
|
@ -610,9 +615,6 @@ namespace sts::dmnt::cheat::impl {
|
|||
this->CloseActiveCheatProcess();
|
||||
}
|
||||
|
||||
/* Knock out the debug events thread. */
|
||||
R_ASSERT(this->debug_events_thread.CancelSynchronization());
|
||||
|
||||
/* Get the application process's ID. */
|
||||
R_ASSERT_IF_NEW_PROCESS(pm::dmnt::GetApplicationProcessId(&this->cheat_process_metadata.process_id));
|
||||
auto proc_guard = SCOPE_GUARD {
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace sts::dmnt::cheat::impl {
|
|||
static void PerCoreThreadFunction(void *_this) {
|
||||
/* This thread will wait on the appropriate message queue. */
|
||||
DebugEventsManager *this_ptr = reinterpret_cast<DebugEventsManager *>(_this);
|
||||
const u32 current_core = svcGetCurrentProcessorNumber();
|
||||
const size_t current_core = svcGetCurrentProcessorNumber();
|
||||
while (true) {
|
||||
/* Receive handle. */
|
||||
Handle debug_handle = this_ptr->WaitReceiveHandle(current_core);
|
||||
|
@ -46,9 +46,9 @@ namespace sts::dmnt::cheat::impl {
|
|||
}
|
||||
}
|
||||
|
||||
u32 GetTargetCore(const svc::DebugEventInfo &dbg_event, Handle debug_handle) {
|
||||
size_t GetTargetCore(const svc::DebugEventInfo &dbg_event, Handle debug_handle) {
|
||||
/* If we don't need to continue on a specific core, use the system core. */
|
||||
u32 target_core = NumCores - 1;
|
||||
size_t target_core = NumCores - 1;
|
||||
|
||||
/* Retrieve correct core for new thread event. */
|
||||
if (dbg_event.type == svc::DebugEventType::AttachThread) {
|
||||
|
@ -61,11 +61,11 @@ namespace sts::dmnt::cheat::impl {
|
|||
return target_core;
|
||||
}
|
||||
|
||||
void SendHandle(const svc::DebugEventInfo &dbg_event, Handle debug_handle) {
|
||||
this->message_queues[GetTargetCore(dbg_event, debug_handle)].Send(static_cast<uintptr_t>(debug_handle));
|
||||
void SendHandle(size_t target_core, Handle debug_handle) {
|
||||
this->message_queues[target_core].Send(static_cast<uintptr_t>(debug_handle));
|
||||
}
|
||||
|
||||
Handle WaitReceiveHandle(u32 core_id) {
|
||||
Handle WaitReceiveHandle(size_t core_id) {
|
||||
uintptr_t x = 0;
|
||||
this->message_queues[core_id].Receive(&x);
|
||||
return static_cast<Handle>(x);
|
||||
|
@ -105,12 +105,15 @@ namespace sts::dmnt::cheat::impl {
|
|||
void ContinueCheatProcess(Handle cheat_dbg_hnd) {
|
||||
/* Loop getting all debug events. */
|
||||
svc::DebugEventInfo d;
|
||||
size_t target_core = NumCores - 1;
|
||||
while (R_SUCCEEDED(svcGetDebugEvent(reinterpret_cast<u8 *>(&d), cheat_dbg_hnd))) {
|
||||
/* ... */
|
||||
if (d.type == svc::DebugEventType::AttachThread) {
|
||||
target_core = GetTargetCore(d, cheat_dbg_hnd);
|
||||
}
|
||||
}
|
||||
|
||||
/* Send handle to correct core, wait for continue to finish. */
|
||||
this->SendHandle(d, cheat_dbg_hnd);
|
||||
this->SendHandle(target_core, cheat_dbg_hnd);
|
||||
this->WaitContinued();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@ extern "C" {
|
|||
|
||||
u32 __nx_applet_type = AppletType_None;
|
||||
|
||||
#define INNER_HEAP_SIZE 0x80000
|
||||
#define INNER_HEAP_SIZE 0xC0000
|
||||
size_t nx_inner_heap_size = INNER_HEAP_SIZE;
|
||||
char nx_inner_heap[INNER_HEAP_SIZE];
|
||||
|
||||
|
@ -60,6 +60,7 @@ void __appInit(void) {
|
|||
|
||||
DoWithSmSession([&]() {
|
||||
R_ASSERT(pmdmntInitialize());
|
||||
R_ASSERT(pminfoInitialize());
|
||||
R_ASSERT(ldrDmntInitialize());
|
||||
/* TODO: We provide this on every sysver via ro. Do we need a shim? */
|
||||
if (GetRuntimeFirmwareVersion() >= FirmwareVersion_300) {
|
||||
|
@ -89,6 +90,7 @@ void __appExit(void) {
|
|||
nsdevExit();
|
||||
roDmntExit();
|
||||
ldrDmntExit();
|
||||
pminfoExit();
|
||||
pmdmntExit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue