@@ -14,24 +14,11 @@ namespace ModuleBase {
1414 * @return true if attach succeeded, false otherwise.
1515 */
1616 bool BaseCommands::attach () {
17- u64 pid = 0 ;
18- Result rc = pmdmntGetApplicationProcessId (& pid);
17+ Logger::instance (). log ( " attach() Attaching to pid= " + std::to_string (m_metaData. pid ) + " . " ) ;
18+ Result rc = svcDebugActiveProcess (&m_debugHandle, m_metaData. pid );
1919 if (R_FAILED (rc)) {
20- Logger::instance ().log (" attach() pmdmntGetApplicationProcessId() failed." , std::to_string (R_DESCRIPTION (rc)));
21- return false ;
22- }
23-
24- if (m_metaData.pid != pid) {
25- Logger::instance ().log (" attach() m_metaData.pid != pid, calling initMetaData()." );
26- m_metaData.pid = pid;
27- initMetaData ();
28- } else {
20+ Logger::instance ().log (" attach() svcDebugActiveProcess() failed: pid=" + std::to_string (m_metaData.pid ), std::to_string (R_DESCRIPTION (rc)));
2921 detach ();
30- }
31-
32- rc = svcDebugActiveProcess (&m_debugHandle, pid);
33- if (R_FAILED (rc)) {
34- Logger::instance ().log (" attach() svcDebugActiveProcess() failed." , std::to_string (R_DESCRIPTION (rc)));
3522 return false ;
3623 }
3724
@@ -53,7 +40,6 @@ namespace ModuleBase {
5340 void BaseCommands::initMetaData () {
5441 if (!attach ()) {
5542 Logger::instance ().log (" initMetaData() attach() failed." );
56- detach ();
5743 return ;
5844 }
5945
@@ -63,9 +49,8 @@ namespace ModuleBase {
6349 m_metaData.titleVersion = GetTitleVersion ();
6450 m_metaData.buildID = getBuildID ();
6551
66- detach ();
6752 if (metaHasZeroValue (m_metaData)) {
68- Logger::instance ().log (" initMetaData() MetaData had one or more zero value ." );
53+ Logger::instance ().log (" initMetaData() One or more metadata values are zero ." );
6954 }
7055 }
7156
@@ -116,6 +101,7 @@ namespace ModuleBase {
116101 u64 BaseCommands::getHeapBase () {
117102 u64 heap_base = 0 ;
118103 Result rc = svcGetInfo (&heap_base, InfoType_HeapRegionAddress, m_debugHandle, 0 );
104+ detach ();
119105 if (R_FAILED (rc)) {
120106 Logger::instance ().log (" getHeapBase() svcGetInfo() failed." , std::to_string (R_DESCRIPTION (rc)));
121107 return 0 ;
@@ -182,7 +168,6 @@ namespace ModuleBase {
182168 }
183169
184170 std::vector<NsApplicationControlData> buf (1 );
185- initMetaData ();
186171 rc = nsGetApplicationControlData (NsApplicationControlSource_Storage, m_metaData.titleID , buf.data (), sizeof (NsApplicationControlData), &out);
187172 nsExit ();
188173 if (R_FAILED (rc)) {
@@ -441,7 +426,7 @@ namespace ModuleBase {
441426
442427 /* *
443428 * @brief Get the current Switch time.
444- * @param[out] buffer Output buffer for time value.
429+ * @param[out] Output buffer for time value.
445430 */
446431 void BaseCommands::getSwitchTime (std::vector<char >& buffer) {
447432 time_t posix = 0 ;
@@ -506,7 +491,7 @@ namespace ModuleBase {
506491
507492 /* *
508493 * @brief Reset the Switch time using NTP if available.
509- * @param[out] buffer Output buffer indicating success.
494+ * @param[out] Output buffer indicating success.
510495 */
511496 void BaseCommands::resetSwitchTime (std::vector<char >& buffer) {
512497 bool success = false ;
0 commit comments