Check service existence before GetServiceHandle
This commit is contained in:
parent
9074688491
commit
11f820efa7
@ -193,13 +193,16 @@ static void menuDraw(Menu *menu, u32 selected)
|
||||
s64 out;
|
||||
u32 version, commitHash;
|
||||
bool isRelease;
|
||||
bool isMcuHwcRegistered;
|
||||
|
||||
if(R_SUCCEEDED(mcuHwcInit()))
|
||||
if(R_SUCCEEDED(srvIsServiceRegistered(&isMcuHwcRegistered, "mcu::HWC")) && isMcuHwcRegistered && R_SUCCEEDED(mcuHwcInit()))
|
||||
{
|
||||
if(R_FAILED(MCUHWC_GetBatteryLevel(&batteryLevel)))
|
||||
batteryLevel = 255;
|
||||
mcuHwcExit();
|
||||
}
|
||||
else
|
||||
batteryLevel = 255;
|
||||
|
||||
svcGetSystemInfo(&out, 0x10000, 0);
|
||||
version = (u32)out;
|
||||
|
@ -69,12 +69,10 @@ void DebuggerMenu_EnableDebugger(void)
|
||||
bool done = false, alreadyEnabled = gdbServer.super.running;
|
||||
Result res = 0;
|
||||
char buf[65];
|
||||
bool cantStart;
|
||||
Handle dummy;
|
||||
bool isSocURegistered;
|
||||
|
||||
res = OpenProcessByName("socket", &dummy);
|
||||
cantStart = R_FAILED(res);
|
||||
svcCloseHandle(dummy);
|
||||
res = srvIsServiceRegistered(&isSocURegistered, "soc:U");
|
||||
isSocURegistered = R_SUCCEEDED(res) && isSocURegistered;
|
||||
|
||||
Draw_Lock();
|
||||
Draw_ClearFramebuffer();
|
||||
@ -88,7 +86,7 @@ void DebuggerMenu_EnableDebugger(void)
|
||||
|
||||
if(alreadyEnabled)
|
||||
Draw_DrawString(10, 30, COLOR_WHITE, "Already enabled!");
|
||||
else if(cantStart)
|
||||
else if(!isSocURegistered)
|
||||
Draw_DrawString(10, 30, COLOR_WHITE, "Can't start the debugger before the system has fi-\nnished loading.");
|
||||
else
|
||||
{
|
||||
|
@ -80,6 +80,18 @@ Result miniSocInit()
|
||||
|
||||
u32 tmp = 0;
|
||||
Result ret = 0;
|
||||
bool isSocURegistered;
|
||||
|
||||
ret = srvIsServiceRegistered(&isSocURegistered, "soc:U");
|
||||
if(ret != 0) goto cleanup;
|
||||
if(!isSocURegistered)
|
||||
{
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret = srvGetServiceHandle(&SOCU_handle, "soc:U");
|
||||
if(ret != 0) goto cleanup;
|
||||
|
||||
ret = svcControlMemory(&tmp, socContextAddr, 0, socContextSize, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
|
||||
if(ret != 0) goto cleanup;
|
||||
@ -89,8 +101,7 @@ Result miniSocInit()
|
||||
ret = svcCreateMemoryBlock(&socMemhandle, (u32)socContextAddr, socContextSize, 0, 3);
|
||||
if(ret != 0) goto cleanup;
|
||||
|
||||
ret = srvGetServiceHandle(&SOCU_handle, "soc:U");
|
||||
if(ret != 0) goto cleanup;
|
||||
|
||||
|
||||
ret = SOCU_Initialize(socMemhandle, socContextSize);
|
||||
if(ret != 0) goto cleanup;
|
||||
|
Reference in New Issue
Block a user