mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 21:02:39 +02:00
Implemented smGetService
This commit is contained in:
parent
92f8243a42
commit
8cec483f0a
@ -1,6 +1,6 @@
|
|||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
|
|
||||||
static Handle g_smHandle;
|
static Handle g_smHandle = -1;
|
||||||
|
|
||||||
Result smInitialize() {
|
Result smInitialize() {
|
||||||
Result rc = svcConnectToNamedPort(&g_smHandle, "sm:");
|
Result rc = svcConnectToNamedPort(&g_smHandle, "sm:");
|
||||||
@ -25,3 +25,32 @@ Result smInitialize() {
|
|||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result smGetService(const char* name) {
|
||||||
|
u64 name_encoded = 0;
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
for (i=0; i<8; i++) {
|
||||||
|
name_encoded = (name_encoded << 8) | name[i];
|
||||||
|
|
||||||
|
if (name[i] == '\0')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcCommand c;
|
||||||
|
ipcInitialize(&c);
|
||||||
|
|
||||||
|
struct {
|
||||||
|
u64 magic;
|
||||||
|
u64 cmd_id;
|
||||||
|
u64 service_name;
|
||||||
|
} *raw;
|
||||||
|
|
||||||
|
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||||
|
|
||||||
|
raw->magic = SFCI_MAGIC;
|
||||||
|
raw->cmd_id = 0;
|
||||||
|
raw->service_name = name_encoded;
|
||||||
|
|
||||||
|
return ipcDispatch(g_smHandle);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user