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;
|
s64 out;
|
||||||
u32 version, commitHash;
|
u32 version, commitHash;
|
||||||
bool isRelease;
|
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)))
|
if(R_FAILED(MCUHWC_GetBatteryLevel(&batteryLevel)))
|
||||||
batteryLevel = 255;
|
batteryLevel = 255;
|
||||||
mcuHwcExit();
|
mcuHwcExit();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
batteryLevel = 255;
|
||||||
|
|
||||||
svcGetSystemInfo(&out, 0x10000, 0);
|
svcGetSystemInfo(&out, 0x10000, 0);
|
||||||
version = (u32)out;
|
version = (u32)out;
|
||||||
|
@ -69,12 +69,10 @@ void DebuggerMenu_EnableDebugger(void)
|
|||||||
bool done = false, alreadyEnabled = gdbServer.super.running;
|
bool done = false, alreadyEnabled = gdbServer.super.running;
|
||||||
Result res = 0;
|
Result res = 0;
|
||||||
char buf[65];
|
char buf[65];
|
||||||
bool cantStart;
|
bool isSocURegistered;
|
||||||
Handle dummy;
|
|
||||||
|
|
||||||
res = OpenProcessByName("socket", &dummy);
|
res = srvIsServiceRegistered(&isSocURegistered, "soc:U");
|
||||||
cantStart = R_FAILED(res);
|
isSocURegistered = R_SUCCEEDED(res) && isSocURegistered;
|
||||||
svcCloseHandle(dummy);
|
|
||||||
|
|
||||||
Draw_Lock();
|
Draw_Lock();
|
||||||
Draw_ClearFramebuffer();
|
Draw_ClearFramebuffer();
|
||||||
@ -88,7 +86,7 @@ void DebuggerMenu_EnableDebugger(void)
|
|||||||
|
|
||||||
if(alreadyEnabled)
|
if(alreadyEnabled)
|
||||||
Draw_DrawString(10, 30, COLOR_WHITE, "Already enabled!");
|
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.");
|
Draw_DrawString(10, 30, COLOR_WHITE, "Can't start the debugger before the system has fi-\nnished loading.");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -80,6 +80,18 @@ Result miniSocInit()
|
|||||||
|
|
||||||
u32 tmp = 0;
|
u32 tmp = 0;
|
||||||
Result ret = 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);
|
ret = svcControlMemory(&tmp, socContextAddr, 0, socContextSize, MEMOP_ALLOC, MEMPERM_READ | MEMPERM_WRITE);
|
||||||
if(ret != 0) goto cleanup;
|
if(ret != 0) goto cleanup;
|
||||||
@ -89,8 +101,7 @@ Result miniSocInit()
|
|||||||
ret = svcCreateMemoryBlock(&socMemhandle, (u32)socContextAddr, socContextSize, 0, 3);
|
ret = svcCreateMemoryBlock(&socMemhandle, (u32)socContextAddr, socContextSize, 0, 3);
|
||||||
if(ret != 0) goto cleanup;
|
if(ret != 0) goto cleanup;
|
||||||
|
|
||||||
ret = srvGetServiceHandle(&SOCU_handle, "soc:U");
|
|
||||||
if(ret != 0) goto cleanup;
|
|
||||||
|
|
||||||
ret = SOCU_Initialize(socMemhandle, socContextSize);
|
ret = SOCU_Initialize(socMemhandle, socContextSize);
|
||||||
if(ret != 0) goto cleanup;
|
if(ret != 0) goto cleanup;
|
||||||
|
Reference in New Issue
Block a user