mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-12-22 20:31:14 +00:00
strat: fixes for compat with latest libnx
This commit is contained in:
parent
c6b9a0c4bf
commit
1636668762
12 changed files with 35 additions and 34 deletions
|
@ -112,7 +112,7 @@ namespace ams::creport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrashReport::GetFatalContext(FatalContext *_out) const {
|
void CrashReport::GetFatalContext(::FatalCpuContext *_out) const {
|
||||||
static_assert(sizeof(*_out) == sizeof(ams::fatal::CpuContext));
|
static_assert(sizeof(*_out) == sizeof(ams::fatal::CpuContext));
|
||||||
ams::fatal::CpuContext *out = reinterpret_cast<ams::fatal::CpuContext *>(_out);
|
ams::fatal::CpuContext *out = reinterpret_cast<ams::fatal::CpuContext *>(_out);
|
||||||
std::memset(out, 0, sizeof(*out));
|
std::memset(out, 0, sizeof(*out));
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace ams::creport {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildReport(os::ProcessId process_id, bool has_extra_info);
|
void BuildReport(os::ProcessId process_id, bool has_extra_info);
|
||||||
void GetFatalContext(FatalContext *out) const;
|
void GetFatalContext(::FatalCpuContext *out) const;
|
||||||
void SaveReport();
|
void SaveReport();
|
||||||
private:
|
private:
|
||||||
void ProcessExceptions();
|
void ProcessExceptions();
|
||||||
|
|
|
@ -132,7 +132,7 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Throw fatal error. */
|
/* Throw fatal error. */
|
||||||
FatalContext ctx;
|
::FatalCpuContext ctx;
|
||||||
g_crash_report.GetFatalContext(&ctx);
|
g_crash_report.GetFatalContext(&ctx);
|
||||||
fatalWithContext(g_crash_report.GetResult().GetValue(), FatalType_ErrorScreen, &ctx);
|
fatalThrowWithContext(g_crash_report.GetResult().GetValue(), FatalPolicy_ErrorScreen, &ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,23 +49,23 @@ namespace ams::fatal::srv {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ThrowFatal(Result result, os::ProcessId process_id) {
|
Result ThrowFatal(Result result, os::ProcessId process_id) {
|
||||||
return this->ThrowFatalWithCpuContext(result, process_id, FatalType_ErrorReportAndErrorScreen, {});
|
return this->ThrowFatalWithCpuContext(result, process_id, FatalPolicy_ErrorReportAndErrorScreen, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ThrowFatalWithPolicy(Result result, os::ProcessId process_id, FatalType policy) {
|
Result ThrowFatalWithPolicy(Result result, os::ProcessId process_id, FatalPolicy policy) {
|
||||||
return this->ThrowFatalWithCpuContext(result, process_id, policy, {});
|
return this->ThrowFatalWithCpuContext(result, process_id, policy, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx);
|
Result ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalPolicy policy, const CpuContext &cpu_ctx);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Context global. */
|
/* Context global. */
|
||||||
ServiceContext g_context;
|
ServiceContext g_context;
|
||||||
|
|
||||||
/* Throw implementation. */
|
/* Throw implementation. */
|
||||||
Result ServiceContext::ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalType policy, const CpuContext &cpu_ctx) {
|
Result ServiceContext::ThrowFatalWithCpuContext(Result result, os::ProcessId process_id, FatalPolicy policy, const CpuContext &cpu_ctx) {
|
||||||
/* We don't support Error Report only fatals. */
|
/* We don't support Error Report only fatals. */
|
||||||
R_UNLESS(policy != FatalType_ErrorReport, ResultSuccess());
|
R_UNLESS(policy != FatalPolicy_ErrorReport, ResultSuccess());
|
||||||
|
|
||||||
/* Note that we've thrown fatal. */
|
/* Note that we've thrown fatal. */
|
||||||
R_TRY(this->TrySetHasThrown());
|
R_TRY(this->TrySetHasThrown());
|
||||||
|
@ -100,7 +100,7 @@ namespace ams::fatal::srv {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decide whether to generate a report. */
|
/* Decide whether to generate a report. */
|
||||||
this->context.generate_error_report = (policy == FatalType_ErrorReportAndErrorScreen);
|
this->context.generate_error_report = (policy == FatalPolicy_ErrorReportAndErrorScreen);
|
||||||
|
|
||||||
/* Adjust error code (2000-0000 -> 2162-0002). */
|
/* Adjust error code (2000-0000 -> 2162-0002). */
|
||||||
if (R_SUCCEEDED(this->context.result)) {
|
if (R_SUCCEEDED(this->context.result)) {
|
||||||
|
@ -108,8 +108,8 @@ namespace ams::fatal::srv {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (policy) {
|
switch (policy) {
|
||||||
case FatalType_ErrorReportAndErrorScreen:
|
case FatalPolicy_ErrorReportAndErrorScreen:
|
||||||
case FatalType_ErrorScreen:
|
case FatalPolicy_ErrorScreen:
|
||||||
/* Signal that we're throwing. */
|
/* Signal that we're throwing. */
|
||||||
this->event_manager.SignalEvents();
|
this->event_manager.SignalEvents();
|
||||||
|
|
||||||
|
@ -127,18 +127,18 @@ namespace ams::fatal::srv {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ThrowFatalForSelf(Result result) {
|
Result ThrowFatalForSelf(Result result) {
|
||||||
return g_context.ThrowFatalWithPolicy(result, os::GetCurrentProcessId(), FatalType_ErrorScreen);
|
return g_context.ThrowFatalWithPolicy(result, os::GetCurrentProcessId(), FatalPolicy_ErrorScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result UserService::ThrowFatal(Result result, const sf::ClientProcessId &client_pid) {
|
Result UserService::ThrowFatal(Result result, const sf::ClientProcessId &client_pid) {
|
||||||
return g_context.ThrowFatal(result, client_pid.GetValue());
|
return g_context.ThrowFatal(result, client_pid.GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
Result UserService::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalType policy) {
|
Result UserService::ThrowFatalWithPolicy(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy) {
|
||||||
return g_context.ThrowFatalWithPolicy(result, client_pid.GetValue(), policy);
|
return g_context.ThrowFatalWithPolicy(result, client_pid.GetValue(), policy);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result UserService::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx) {
|
Result UserService::ThrowFatalWithCpuContext(Result result, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx) {
|
||||||
return g_context.ThrowFatalWithCpuContext(result, client_pid.GetValue(), policy, cpu_ctx);
|
return g_context.ThrowFatalWithCpuContext(result, client_pid.GetValue(), policy, cpu_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ namespace ams::fatal::srv {
|
||||||
private:
|
private:
|
||||||
/* Actual commands. */
|
/* Actual commands. */
|
||||||
Result ThrowFatal(Result error, const sf::ClientProcessId &client_pid);
|
Result ThrowFatal(Result error, const sf::ClientProcessId &client_pid);
|
||||||
Result ThrowFatalWithPolicy(Result error, const sf::ClientProcessId &client_pid, FatalType policy);
|
Result ThrowFatalWithPolicy(Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy);
|
||||||
Result ThrowFatalWithCpuContext(Result error, const sf::ClientProcessId &client_pid, FatalType policy, const CpuContext &cpu_ctx);
|
Result ThrowFatalWithCpuContext(Result error, const sf::ClientProcessId &client_pid, FatalPolicy policy, const CpuContext &cpu_ctx);
|
||||||
public:
|
public:
|
||||||
DEFINE_SERVICE_DISPATCH_TABLE {
|
DEFINE_SERVICE_DISPATCH_TABLE {
|
||||||
MAKE_SERVICE_COMMAND_META(ThrowFatal),
|
MAKE_SERVICE_COMMAND_META(ThrowFatal),
|
||||||
|
|
|
@ -137,7 +137,7 @@ namespace ams::fatal::srv {
|
||||||
R_TRY(viOpenDefaultDisplay(&this->display));
|
R_TRY(viOpenDefaultDisplay(&this->display));
|
||||||
|
|
||||||
/* Reset the display magnification to its default value. */
|
/* Reset the display magnification to its default value. */
|
||||||
u32 display_width, display_height;
|
s32 display_width, display_height;
|
||||||
R_TRY(viGetDisplayLogicalResolution(&this->display, &display_width, &display_height));
|
R_TRY(viGetDisplayLogicalResolution(&this->display, &display_width, &display_height));
|
||||||
|
|
||||||
/* viSetDisplayMagnification was added in 3.0.0. */
|
/* viSetDisplayMagnification was added in 3.0.0. */
|
||||||
|
@ -153,10 +153,10 @@ namespace ams::fatal::srv {
|
||||||
/* Display a layer of 1280 x 720 at 1.5x magnification */
|
/* Display a layer of 1280 x 720 at 1.5x magnification */
|
||||||
/* NOTE: N uses 2 (770x400) RGBA4444 buffers (tiled buffer + linear). */
|
/* NOTE: N uses 2 (770x400) RGBA4444 buffers (tiled buffer + linear). */
|
||||||
/* We use a single 1280x720 tiled RGB565 buffer. */
|
/* We use a single 1280x720 tiled RGB565 buffer. */
|
||||||
constexpr u32 raw_width = FatalScreenWidth;
|
constexpr s32 raw_width = FatalScreenWidth;
|
||||||
constexpr u32 raw_height = FatalScreenHeight;
|
constexpr s32 raw_height = FatalScreenHeight;
|
||||||
constexpr u32 layer_width = ((raw_width) * 3) / 2;
|
constexpr s32 layer_width = ((raw_width) * 3) / 2;
|
||||||
constexpr u32 layer_height = ((raw_height) * 3) / 2;
|
constexpr s32 layer_height = ((raw_height) * 3) / 2;
|
||||||
|
|
||||||
const float layer_x = static_cast<float>((display_width - layer_width) / 2);
|
const float layer_x = static_cast<float>((display_width - layer_width) / 2);
|
||||||
const float layer_y = static_cast<float>((display_height - layer_height) / 2);
|
const float layer_y = static_cast<float>((display_height - layer_height) / 2);
|
||||||
|
|
|
@ -25,16 +25,16 @@ namespace ams::pm::dmnt {
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetProcessId(os::ProcessId *out_process_id, const ncm::TitleId title_id) {
|
Result GetProcessId(os::ProcessId *out_process_id, const ncm::TitleId title_id) {
|
||||||
return pmdmntGetTitlePid(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(title_id));
|
return pmdmntGetProcessId(reinterpret_cast<u64 *>(out_process_id), static_cast<u64>(title_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetApplicationProcessId(os::ProcessId *out_process_id) {
|
Result GetApplicationProcessId(os::ProcessId *out_process_id) {
|
||||||
return pmdmntGetApplicationPid(reinterpret_cast<u64 *>(out_process_id));
|
return pmdmntGetApplicationProcessId(reinterpret_cast<u64 *>(out_process_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result HookToCreateApplicationProcess(Handle *out_handle) {
|
Result HookToCreateApplicationProcess(Handle *out_handle) {
|
||||||
Event evt;
|
Event evt;
|
||||||
R_TRY(pmdmntEnableDebugForApplication(&evt));
|
R_TRY(pmdmntHookToCreateApplicationProcess(&evt));
|
||||||
*out_handle = evt.revent;
|
*out_handle = evt.revent;
|
||||||
return ResultSuccess();
|
return ResultSuccess();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::pm::info {
|
||||||
Result GetTitleId(ncm::TitleId *out_title_id, os::ProcessId process_id) {
|
Result GetTitleId(ncm::TitleId *out_title_id, os::ProcessId process_id) {
|
||||||
std::scoped_lock lk(g_info_lock);
|
std::scoped_lock lk(g_info_lock);
|
||||||
|
|
||||||
return pminfoGetTitleId(reinterpret_cast<u64 *>(out_title_id), static_cast<u64>(process_id));
|
return pminfoGetProgramId(reinterpret_cast<u64 *>(out_title_id), static_cast<u64>(process_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
Result GetProcessId(os::ProcessId *out_process_id, ncm::TitleId title_id) {
|
Result GetProcessId(os::ProcessId *out_process_id, ncm::TitleId title_id) {
|
||||||
|
|
|
@ -19,7 +19,9 @@ namespace ams::pm::shell {
|
||||||
|
|
||||||
/* Shell API. */
|
/* Shell API. */
|
||||||
Result WEAK LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) {
|
Result WEAK LaunchTitle(os::ProcessId *out_process_id, const ncm::TitleLocation &loc, u32 launch_flags) {
|
||||||
return pmshellLaunchProcess(launch_flags, static_cast<u64>(loc.title_id), loc.storage_id, reinterpret_cast<u64 *>(out_process_id));
|
static_assert(sizeof(ncm::TitleLocation) == sizeof(NcmProgramLocation));
|
||||||
|
static_assert(alignof(ncm::TitleLocation) == alignof(NcmProgramLocation));
|
||||||
|
return pmshellLaunchProgram(launch_flags, reinterpret_cast<const NcmProgramLocation *>(&loc), reinterpret_cast<u64 *>(out_process_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace ams::result::impl {
|
||||||
AMS_ASSERT((ams::result::CallFatalOnResultAssertion));
|
AMS_ASSERT((ams::result::CallFatalOnResultAssertion));
|
||||||
|
|
||||||
/* TODO: ams::fatal:: */
|
/* TODO: ams::fatal:: */
|
||||||
fatalSimple(result.GetValue());
|
fatalThrow(result.GetValue());
|
||||||
while (true) { /* ... */ }
|
while (true) { /* ... */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,10 @@ namespace ams::updater {
|
||||||
NcmContentMetaKey *records = reinterpret_cast<NcmContentMetaKey *>(work_buffer);
|
NcmContentMetaKey *records = reinterpret_cast<NcmContentMetaKey *>(work_buffer);
|
||||||
|
|
||||||
const auto title_type = GetNcmContentMetaType(mode);
|
const auto title_type = GetNcmContentMetaType(mode);
|
||||||
u32 written_entries;
|
s32 written_entries;
|
||||||
u32 total_entries;
|
s32 total_entries;
|
||||||
R_TRY(ncmContentMetaDatabaseList(&meta_db, &total_entries, &written_entries, records, MaxContentMetas * sizeof(*records), title_type, 0, 0, UINT64_MAX, NcmContentInstallType_Full));
|
R_TRY(ncmContentMetaDatabaseList(&meta_db, &total_entries, &written_entries, records, MaxContentMetas * sizeof(*records), title_type, 0, 0, UINT64_MAX, NcmContentInstallType_Full));
|
||||||
if (total_entries == 0) {
|
if (total_entries <= 0) {
|
||||||
return ResultBootImagePackageNotFound();
|
return ResultBootImagePackageNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ namespace ams::updater {
|
||||||
|
|
||||||
/* Output is sorted, return the lowest valid exfat entry. */
|
/* Output is sorted, return the lowest valid exfat entry. */
|
||||||
if (total_entries > 1) {
|
if (total_entries > 1) {
|
||||||
for (size_t i = 0; i < total_entries; i++) {
|
for (size_t i = 0; i < size_t(total_entries); i++) {
|
||||||
u8 attr;
|
u8 attr;
|
||||||
R_TRY(ncmContentMetaDatabaseGetAttributes(&meta_db, &records[i], &attr));
|
R_TRY(ncmContentMetaDatabaseGetAttributes(&meta_db, &records[i], &attr));
|
||||||
|
|
||||||
|
|
|
@ -86,8 +86,7 @@ namespace ams::ro::impl {
|
||||||
R_ASSERT(svcGetInfo(&title_id.value, InfoType_TitleId, process_h, 0));
|
R_ASSERT(svcGetInfo(&title_id.value, InfoType_TitleId, process_h, 0));
|
||||||
} else {
|
} else {
|
||||||
/* 1.0.0-2.3.0: We're not inside loader, so ask pm. */
|
/* 1.0.0-2.3.0: We're not inside loader, so ask pm. */
|
||||||
os::ProcessId process_id = os::GetProcessId(process_h);
|
R_ASSERT(pm::info::GetTitleId(&title_id, os::GetProcessId(process_h)));
|
||||||
R_ASSERT(pminfoGetTitleId(&title_id.value, process_id.value));
|
|
||||||
}
|
}
|
||||||
return title_id;
|
return title_id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue