Major update
Changed titlekey dump methodology to no longer need reboot. Added SD seed dumping. Reorganized and clarified UI text. Swapped C++-style I/O for C-style. Tightened up dependencies.
This commit is contained in:
parent
41c2604d9a
commit
922cf3f4c4
25 changed files with 23552 additions and 372 deletions
170
source/nx/es.c
Normal file
170
source/nx/es.c
Normal file
|
@ -0,0 +1,170 @@
|
|||
#include "es.h"
|
||||
|
||||
#include <switch/arm/atomics.h>
|
||||
#include <switch/kernel/ipc.h>
|
||||
#include <switch/services/sm.h>
|
||||
|
||||
static Service g_esSrv;
|
||||
static u64 g_esRefCnt;
|
||||
|
||||
Result esInitialize() {
|
||||
atomicIncrement64(&g_esRefCnt);
|
||||
|
||||
if (serviceIsActive(&g_esSrv))
|
||||
return 0;
|
||||
|
||||
return smGetService(&g_esSrv, "es");
|
||||
}
|
||||
|
||||
void esExit()
|
||||
{
|
||||
if (atomicDecrement64(&g_esRefCnt) == 0) {
|
||||
serviceClose(&g_esSrv);
|
||||
}
|
||||
}
|
||||
|
||||
Result esCountCommonTicket(u32 *num_tickets)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 9;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_esSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 num_tickets;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*num_tickets = resp->num_tickets;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result esCountPersonalizedTicket(u32 *num_tickets)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 10;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_esSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 num_tickets;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
*num_tickets = resp->num_tickets;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result esListCommonTicket(u32 *numRightsIdsWritten, NcmRightsId *outBuf, size_t bufSize) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddRecvBuffer(&c, outBuf, bufSize, BufferType_Normal);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 11;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_esSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 num_rights_ids_written;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (numRightsIdsWritten) *numRightsIdsWritten = resp->num_rights_ids_written;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result esListPersonalizedTicket(u32 *numRightsIdsWritten, NcmRightsId *outBuf, size_t bufSize) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddRecvBuffer(&c, outBuf, bufSize, BufferType_Normal);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 12;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_esSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 num_rights_ids_written;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (numRightsIdsWritten) *numRightsIdsWritten = resp->num_rights_ids_written;
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
12
source/nx/es.h
Normal file
12
source/nx/es.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <switch/types.h>
|
||||
#include <switch/services/ncm.h>
|
||||
|
||||
Result esInitialize();
|
||||
void esExit();
|
||||
|
||||
Result esCountCommonTicket(u32 *num_tickets); //9
|
||||
Result esCountPersonalizedTicket(u32 *num_tickets); // 10
|
||||
Result esListCommonTicket(u32 *numRightsIdsWritten, NcmRightsId *outBuf, size_t bufSize);
|
||||
Result esListPersonalizedTicket(u32 *numRightsIdsWritten, NcmRightsId *outBuf, size_t bufSize);
|
55
source/nx/set_ext.c
Normal file
55
source/nx/set_ext.c
Normal file
|
@ -0,0 +1,55 @@
|
|||
#include "set_ext.h"
|
||||
|
||||
#include <switch/arm/atomics.h>
|
||||
#include <switch/services/sm.h>
|
||||
#include <switch/types.h>
|
||||
|
||||
static Service g_setcalSrv;
|
||||
static u64 g_refCntCal;
|
||||
|
||||
Result setcalInitialize(void) {
|
||||
atomicIncrement64(&g_refCntCal);
|
||||
|
||||
if (serviceIsActive(&g_setcalSrv))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_AlreadyInitialized);
|
||||
|
||||
return smGetService(&g_setcalSrv, "set:cal");
|
||||
}
|
||||
|
||||
void setcalExit(void) {
|
||||
if (atomicDecrement64(&g_refCntCal) == 0) {
|
||||
serviceClose(&g_setcalSrv);
|
||||
}
|
||||
}
|
||||
|
||||
Result setcalGetEticketDeviceKey(void *key) {
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
ipcAddRecvBuffer(&c, key, 0x244, 0);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 21;
|
||||
|
||||
Result rc = serviceIpcDispatch(&g_setcalSrv);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcParsedCommand r;
|
||||
ipcParse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
12
source/nx/set_ext.h
Normal file
12
source/nx/set_ext.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <switch/result.h>
|
||||
|
||||
Result setcalInitialize(void);
|
||||
void setcalExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the extended ETicket RSA-2048 Key from CAL0
|
||||
* @param key Pointer to 0x244-byte output buffer.
|
||||
*/
|
||||
Result setcalGetEticketDeviceKey(void *key);
|
Loading…
Add table
Add a link
Reference in a new issue