hiddbg: Add hiddbgIsHdlsVirtualDeviceAttached (#345)

This commit is contained in:
cathery 2019-11-07 21:27:13 +03:00 committed by fincs
parent 5a7f14409e
commit d4c5fbdf0f
2 changed files with 38 additions and 0 deletions

View File

@ -182,6 +182,9 @@ Result hiddbgAttachHdlsWorkBuffer(void);
/// Exit Hdls, must be called at some point prior to hiddbgExit. Only available with [7.0.0+].
Result hiddbgReleaseHdlsWorkBuffer(void);
/// Checks if the given HdlsHandle is still attached, where the result is written to isAttached. Only available with [7.0.0+].
Result hiddbgIsHdlsVirtualDeviceAttached(u64 HdlsHandle, bool *isAttached);
/// Gets state for \ref HiddbgHdlsNpadAssignment. Only available with [7.0.0+].
Result hiddbgDumpHdlsNpadAssignmentState(HiddbgHdlsNpadAssignment *state);

View File

@ -392,6 +392,41 @@ Result hiddbgReleaseHdlsWorkBuffer(void) {
return rc;
}
Result hiddbgIsHdlsVirtualDeviceAttached(u64 HdlsHandle, bool *isAttached) {
Result rc = 0;
if (hosversionBefore(7,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
if (!g_hiddbgHdlsInitialized)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
rc = _hiddbgCmdNoIO(327);
if (R_FAILED(rc)) return rc;
if (isAttached) {
*isAttached = false;
if (hosversionBefore(9,0,0)) {
HiddbgHdlsStateListV7 *stateList = (HiddbgHdlsStateListV7*)(g_hiddbgHdlsTmem.src_addr);
for (s32 i=0; i<stateList->total_entries; i++) {
if (stateList->entries[i].HdlsHandle == HdlsHandle) {
*isAttached = true;
break;
}
}
}
else {
HiddbgHdlsStateList *stateList = (HiddbgHdlsStateList*)(g_hiddbgHdlsTmem.src_addr);
for (s32 i=0; i<stateList->total_entries; i++) {
if (stateList->entries[i].HdlsHandle == HdlsHandle) {
*isAttached = true;
break;
}
}
}
}
return rc;
}
Result hiddbgDumpHdlsNpadAssignmentState(HiddbgHdlsNpadAssignment *state) {
Result rc=0;