Use IPC helpers for srv

This commit is contained in:
Lectem 2015-09-09 17:07:37 -04:00
parent 123d8c6d6e
commit a117a287fd

View File

@ -6,6 +6,7 @@
#include <3ds/types.h>
#include <3ds/srv.h>
#include <3ds/svc.h>
#include <3ds/ipc.h>
/*
@ -108,8 +109,8 @@ Result srvRegisterClient(void)
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x10002;
cmdbuf[1] = 0x20;
cmdbuf[0] = IPC_MakeHeader(0x1,0,2); // 0x10002
cmdbuf[1] = IPC_Desc_CurProcessHandle();
if((rc = svcSendSyncRequest(g_srv_handle)))return rc;
@ -121,8 +122,8 @@ Result srvGetServiceHandleDirect(Handle* out, const char* name)
Result rc = 0;
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x50100;
strcpy((char*) &cmdbuf[1], name);
cmdbuf[0] = IPC_MakeHeader(0x5,4,0); // 0x50100
strncpy((char*) &cmdbuf[1], name,2);
cmdbuf[3] = strlen(name);
cmdbuf[4] = 0x0;
@ -149,8 +150,8 @@ Result srvGetServiceHandle(Handle* out, const char* name)
Result srvRegisterService(Handle* out, const char* name, int maxSessions)
{
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x30100;
strcpy((char*) &cmdbuf[1], name);
cmdbuf[0] = IPC_MakeHeader(0x3,4,0); // 0x30100
strncpy((char*) &cmdbuf[1], name,2);
cmdbuf[3] = strlen(name);
cmdbuf[4] = maxSessions;
@ -164,8 +165,8 @@ Result srvRegisterService(Handle* out, const char* name, int maxSessions)
Result srvUnregisterService(const char* name)
{
u32* cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x400C0;
strcpy((char*) &cmdbuf[1], name);
cmdbuf[0] = IPC_MakeHeader(0x4,3,0); // 0x400C0
strncpy((char*) &cmdbuf[1], name,2);
cmdbuf[3] = strlen(name);
Result rc;
@ -195,10 +196,10 @@ Result srvRegisterProcess(u32 procid, u32 count, void *serviceaccesscontrol)
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x04030082; // <7.x
cmdbuf[0] = IPC_MakeHeader(0x403,2,2); // 0x4030082 // <7.x
cmdbuf[1] = procid;
cmdbuf[2] = count;
cmdbuf[3] = (count << 16) | 2;
cmdbuf[3] = IPC_Desc_StaticBuffer(count*4,0);
cmdbuf[4] = (u32)serviceaccesscontrol;
if((rc = svcSendSyncRequest(g_srv_handle))) return rc;
@ -212,7 +213,7 @@ Result srvUnregisterProcess(u32 procid)
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x04040040; // <7.x
cmdbuf[0] = IPC_MakeHeader(0x404,1,0); // 0x4040040 // <7.x
cmdbuf[1] = procid;
if((rc = svcSendSyncRequest(g_srv_handle))) return rc;