1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-26 20:22:17 +00:00
nxdumptool/source/es.c

77 lines
1.8 KiB
C
Raw Normal View History

2019-06-09 02:36:21 +01:00
#include <switch/arm/atomics.h>
#include <switch/kernel/ipc.h>
#include <switch/services/sm.h>
#include <stdlib.h>
#include <string.h>
#include "es.h"
2019-12-11 08:56:58 +00:00
#include "service_guard.h"
2019-06-09 02:36:21 +01:00
static Service g_esSrv;
2019-12-11 08:56:58 +00:00
NX_GENERATE_SERVICE_GUARD(es);
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
Result _esInitialize() {
2019-06-09 02:36:21 +01:00
return smGetService(&g_esSrv, "es");
}
2019-12-11 08:56:58 +00:00
void _esCleanup() {
serviceClose(&g_esSrv);
2019-06-09 02:36:21 +01:00
}
Result esCountCommonTicket(u32 *num_tickets)
{
struct {
2019-12-11 08:56:58 +00:00
u32 num_tickets;
} out;
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
Result rc = serviceDispatchOut(&g_esSrv, 9, out);
if (R_SUCCEEDED(rc) && num_tickets) *num_tickets = out.num_tickets;
2019-06-09 02:36:21 +01:00
return rc;
}
Result esCountPersonalizedTicket(u32 *num_tickets)
{
struct {
2019-12-11 08:56:58 +00:00
u32 num_tickets;
} out;
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
Result rc = serviceDispatchOut(&g_esSrv, 10, out);
if (R_SUCCEEDED(rc) && num_tickets) *num_tickets = out.num_tickets;
2019-06-09 02:36:21 +01:00
return rc;
}
2019-08-15 06:21:51 +01:00
Result esListCommonTicket(u32 *numRightsIdsWritten, FsRightsId *outBuf, size_t bufSize)
2019-06-09 02:36:21 +01:00
{
struct {
2019-12-11 08:56:58 +00:00
u32 num_rights_ids_written;
} out;
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
Result rc = serviceDispatchInOut(&g_esSrv, 11, *numRightsIdsWritten, out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { outBuf, bufSize } },
);
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
if (R_SUCCEEDED(rc) && numRightsIdsWritten) *numRightsIdsWritten = out.num_rights_ids_written;
2019-06-09 02:36:21 +01:00
return rc;
}
2019-08-15 06:21:51 +01:00
Result esListPersonalizedTicket(u32 *numRightsIdsWritten, FsRightsId *outBuf, size_t bufSize)
2019-06-09 02:36:21 +01:00
{
struct {
2019-12-11 08:56:58 +00:00
u32 num_rights_ids_written;
} out;
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
Result rc = serviceDispatchInOut(&g_esSrv, 12, *numRightsIdsWritten, out,
.buffer_attrs = { SfBufferAttr_HipcMapAlias | SfBufferAttr_Out },
.buffers = { { outBuf, bufSize } },
);
2019-06-09 02:36:21 +01:00
2019-12-11 08:56:58 +00:00
if (R_SUCCEEDED(rc) && numRightsIdsWritten) *numRightsIdsWritten = out.num_rights_ids_written;
2019-06-09 02:36:21 +01:00
return rc;
}