mirror of
https://github.com/switchbrew/nx-hbloader.git
synced 2025-06-21 05:22:40 +02:00
Fix crash when taking over some games on 5.0.0+ (#10)
* HBL: Fix crash when taking over some games on 5.0.0+ where the title supports automatic video-recording via the nacp.
This commit is contained in:
parent
bde505a0bf
commit
2d7e01f938
@ -14,6 +14,9 @@ static u64 g_nroSize = 0;
|
|||||||
static NroHeader g_nroHeader;
|
static NroHeader g_nroHeader;
|
||||||
static bool g_isApplication = 0;
|
static bool g_isApplication = 0;
|
||||||
|
|
||||||
|
static NsApplicationControlData g_applicationControlData;
|
||||||
|
static bool g_isAutomaticGameplayRecording = 0;
|
||||||
|
|
||||||
static u8 g_savedTls[0x100];
|
static u8 g_savedTls[0x100];
|
||||||
|
|
||||||
// Used by trampoline.s
|
// Used by trampoline.s
|
||||||
@ -74,6 +77,10 @@ void setupHbHeap(void)
|
|||||||
if (size==0)
|
if (size==0)
|
||||||
size = 0x2000000*16;
|
size = 0x2000000*16;
|
||||||
|
|
||||||
|
if (size > 0x6000000 && g_isAutomaticGameplayRecording) {
|
||||||
|
size -= 0x6000000;
|
||||||
|
}
|
||||||
|
|
||||||
rc = svcSetHeapSize(&addr, size);
|
rc = svcSetHeapSize(&addr, size);
|
||||||
|
|
||||||
if (R_FAILED(rc) || addr==NULL)
|
if (R_FAILED(rc) || addr==NULL)
|
||||||
@ -136,6 +143,29 @@ void getIsApplication(void) {
|
|||||||
if (R_SUCCEEDED(rc) && cur_pid == app_pid) g_isApplication = 1;
|
if (R_SUCCEEDED(rc) && cur_pid == app_pid) g_isApplication = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets the control.nacp for the current title id, and then sets g_isAutomaticGameplayRecording if less memory should be allocated.
|
||||||
|
void getIsAutomaticGameplayRecording(void) {
|
||||||
|
if (kernelAbove500() && g_isApplication) {
|
||||||
|
Result rc=0;
|
||||||
|
u64 cur_tid=0;
|
||||||
|
|
||||||
|
rc = svcGetInfo(&cur_tid, 18, CUR_PROCESS_HANDLE, 0);
|
||||||
|
if (R_FAILED(rc)) return;
|
||||||
|
|
||||||
|
g_isAutomaticGameplayRecording = 0;
|
||||||
|
|
||||||
|
rc = nsInitialize();
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) {
|
||||||
|
size_t dummy;
|
||||||
|
rc = nsGetApplicationControlData(0x1, cur_tid, &g_applicationControlData, sizeof(g_applicationControlData), &dummy);
|
||||||
|
nsExit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc) && (((g_applicationControlData.nacp.x3034_unk >> 8) & 0xFF) == 2)) g_isAutomaticGameplayRecording = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void getOwnProcessHandle(void)
|
void getOwnProcessHandle(void)
|
||||||
{
|
{
|
||||||
static Thread t;
|
static Thread t;
|
||||||
@ -375,8 +405,9 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
memcpy(g_savedTls, (u8*)armGetTls() + 0x100, 0x100);
|
memcpy(g_savedTls, (u8*)armGetTls() + 0x100, 0x100);
|
||||||
|
|
||||||
setupHbHeap();
|
|
||||||
getIsApplication();
|
getIsApplication();
|
||||||
|
getIsAutomaticGameplayRecording();
|
||||||
|
setupHbHeap();
|
||||||
getOwnProcessHandle();
|
getOwnProcessHandle();
|
||||||
loadNro();
|
loadNro();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user