Lockpick/source/nx/es.c

72 lines
1.7 KiB
C
Raw Normal View History

#include "es.h"
2019-10-30 12:19:45 +01:00
#include "../service_guard.h"
#include <switch/kernel/ipc.h>
#include <switch/services/sm.h>
static Service g_esSrv;
2019-10-30 12:19:45 +01:00
NX_GENERATE_SERVICE_GUARD(es);
2019-10-30 12:19:45 +01:00
Result _esInitialize() {
return smGetService(&g_esSrv, "es");
}
2019-10-30 12:19:45 +01:00
void _esCleanup() {
serviceClose(&g_esSrv);
}
Result esCountCommonTicket(u32 *num_tickets)
{
struct {
2019-10-30 12:19:45 +01:00
u32 num_tickets;
} out;
2019-10-30 12:19:45 +01:00
Result rc = serviceDispatchOut(&g_esSrv, 9, out);
if (R_SUCCEEDED(rc) && num_tickets) *num_tickets = out.num_tickets;
2019-03-07 17:06:32 +01:00
return rc;
}
Result esCountPersonalizedTicket(u32 *num_tickets)
{
struct {
2019-10-30 12:19:45 +01:00
u32 num_tickets;
} out;
2019-10-30 12:19:45 +01:00
Result rc = serviceDispatchOut(&g_esSrv, 10, out);
if (R_SUCCEEDED(rc) && num_tickets) *num_tickets = out.num_tickets;
2019-03-07 17:06:32 +01:00
return rc;
}
2019-10-30 12:19:45 +01:00
Result esListCommonTicket(u32 *numRightsIdsWritten, NcmRightsId *outBuf, size_t bufSize)
{
struct {
2019-10-30 12:19:45 +01:00
u32 num_rights_ids_written;
} out;
2019-10-30 12:19:45 +01:00
Result rc = serviceDispatchInOut(&g_esSrv, 11, *numRightsIdsWritten, out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { outBuf, bufSize } },
);
if (R_SUCCEEDED(rc) && numRightsIdsWritten) *numRightsIdsWritten = out.num_rights_ids_written;
2019-03-07 17:06:32 +01:00
return rc;
}
2019-10-30 12:19:45 +01:00
Result esListPersonalizedTicket(u32 *numRightsIdsWritten, NcmRightsId *outBuf, size_t bufSize)
{
struct {
2019-10-30 12:19:45 +01:00
u32 num_rights_ids_written;
} out;
Result rc = serviceDispatchInOut(&g_esSrv, 12, *numRightsIdsWritten, out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { outBuf, bufSize } },
);
if (R_SUCCEEDED(rc) && numRightsIdsWritten) *numRightsIdsWritten = out.num_rights_ids_written;
2019-03-07 17:06:32 +01:00
return rc;
}