replace hiddbgGetWorkBufferTransferMemoryAddress() with hiddbgIsHdlsVirtualDeviceAttached()

This commit is contained in:
cathery 2019-11-07 20:21:28 +03:00
parent 8e34244089
commit 9362e2be4d
2 changed files with 43 additions and 4 deletions

View File

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

View File

@ -392,9 +392,48 @@ Result hiddbgReleaseHdlsWorkBuffer(void) {
return rc; return rc;
} }
TransferMemory *hiddbgGetWorkBufferTransferMemoryAddress() Result hiddbgIsHdlsVirtualDeviceAttached(u64 HdlsHandle, bool *isAttached)
{ {
return &g_hiddbgHdlsTmem; 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 hiddbgDumpHdlsNpadAssignmentState(HiddbgHdlsNpadAssignment *state) {