MCPcopy Create free account
hub / github.com/XorTroll/uLaunch / ApplicationVerifyMain

Function ApplicationVerifyMain

projects/uSystem/source/main.cpp:462–534  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460 }
461
462 void ApplicationVerifyMain(void *ctx_raw) {
463 auto ctx = reinterpret_cast<ApplicationVerifyContext*>(ctx_raw);
464
465 // Like qlaunch does, same size and align
466 auto verify_buf = new (std::align_val_t(ams::os::MemoryPageSize)) u8[VerifyWorkBufferSize]();
467 NsProgressAsyncResult async_rc;
468 NsSystemUpdateProgress progress;
469 UL_RC_ASSERT(nsRequestVerifyApplication(&async_rc, ctx->app_id, 0x7, verify_buf, VerifyWorkBufferSize));
470
471 Result verify_rc;
472 Result verify_detail_rc;
473 while(true) {
474 const auto rc = nsProgressAsyncResultWait(&async_rc, VerifyStepWaitTimeNs);
475 if(rc == ul::svc::ResultTimedOut) {
476 // Still not finished
477 UL_RC_ASSERT(nsProgressAsyncResultGetProgress(&async_rc, &progress, sizeof(progress)));
478
479 if(progress.total_size > 0) {
480 const auto progress_val = (float)progress.current_size / (float)progress.total_size;
481 UL_LOG_INFO("[Verify-0x%016lX] done: %lld, total: %lld, prog: %.2f%", ctx->app_id, progress.current_size, progress.total_size, progress_val * 100.0f);
482
483 if(IsMenuRunning()) {
484 const ul::smi::MenuMessageContext menu_ctx = {
485 .msg = ul::smi::MenuMessage::ApplicationVerifyProgress,
486 .app_verify_progress = {
487 .app_id = ctx->app_id,
488 .done = (u64)progress.current_size,
489 .total = (u64)progress.total_size
490 }
491 };
492 PushMenuMessageContext(menu_ctx);
493 }
494 }
495 else {
496 UL_LOG_INFO("[Verify-0x%016lX] invalid progress...", ctx->app_id);
497 }
498 }
499 else if(R_SUCCEEDED(rc)) {
500 // Finished
501 verify_rc = nsProgressAsyncResultGet(&async_rc);
502 verify_detail_rc = nsProgressAsyncResultGetDetailResult(&async_rc);
503 break;
504 }
505 else {
506 // Unexpected
507 UL_LOG_WARN("[Verify-0x%016lX] nsProgressAsyncResultWait failed unexpectedly: %s", ctx->app_id, ul::util::FormatResultDisplay(rc).c_str());
508
509 verify_rc = rc;
510 verify_detail_rc = rc;
511 break;
512 }
513 }
514
515 ctx->finished = true;
516
517 nsProgressAsyncResultClose(&async_rc);
518 delete[] verify_buf;
519

Callers

nothing calls this directly

Calls 3

IsMenuRunningFunction · 0.85
PushMenuMessageContextFunction · 0.85
FormatResultDisplayFunction · 0.85

Tested by

no test coverage detected