-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement cfgs and frd functions from Reisyukaku's ctrulib
- Loading branch information
Showing
4 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "cfgs.h" | ||
|
||
Result cfgsInit() //Already initialized with CFGUinit(); | ||
{ | ||
return srvGetServiceHandle(&cfgHandle, "cfg:s"); | ||
} | ||
|
||
Result cfgsExit() | ||
{ | ||
return svcCloseHandle(cfgHandle); | ||
} | ||
|
||
Result cfgsSecureInfoGetSerialNo(char *serial) | ||
{ | ||
Result ret = 0; | ||
u32 *cmdbuf = getThreadCommandBuffer(); | ||
|
||
cmdbuf[0] = IPC_MakeHeader(0x408,1,2); // 0x10082 | ||
cmdbuf[1] = 0xF; | ||
cmdbuf[2] = 12 | (0xF << 4); | ||
cmdbuf[3] = (u32)serial; | ||
|
||
if(R_FAILED(ret = svcSendSyncRequest(cfgHandle)))return ret; | ||
|
||
return (Result)cmdbuf[1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <3ds.h> | ||
|
||
Handle cfgHandle; | ||
|
||
Result cfgsInit(); | ||
Result cfgsExit(); | ||
Result cfgsSecureInfoGetSerialNo(char *serial); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "frd.h" | ||
|
||
Result frdInit(u32 sdkVer) | ||
{ | ||
srvGetServiceHandle(&frdHandle, "frd:u"); | ||
srvGetServiceHandle(&frdHandle, "frd:n"); | ||
srvGetServiceHandle(&frdHandle, "frd:a"); | ||
return frdSetClientSdkVersion(sdkVer); | ||
} | ||
|
||
Result frdExit() | ||
{ | ||
return svcCloseHandle(frdHandle); | ||
} | ||
|
||
Result frdSetClientSdkVersion(u32 sdkVer) | ||
{ | ||
Result ret=0; | ||
u32 *cmdbuf = getThreadCommandBuffer(); | ||
|
||
cmdbuf[0] = IPC_MakeHeader(0x32,1,2); // 0x00320042 | ||
cmdbuf[1] = sdkVer; | ||
cmdbuf[2] = 0x20; | ||
|
||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle)))return ret; | ||
|
||
return (Result)cmdbuf[1]; | ||
} | ||
|
||
u64 frdPrincipalIdToFriendCode(u64 *fc, u64 pid) | ||
{ | ||
Result ret=0; | ||
u32 *cmdbuf = getThreadCommandBuffer(); | ||
|
||
cmdbuf[0] = IPC_MakeHeader(0x24,1,0); // 0x00240040 | ||
cmdbuf[1] = pid; | ||
|
||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle)))return ret; | ||
|
||
*fc = (u64)cmdbuf[2]; | ||
|
||
return (Result)cmdbuf[1]; | ||
} | ||
|
||
|
||
Result frdGetMyFriendKey(FriendKey *key) | ||
{ | ||
Result ret=0; | ||
u32 *cmdbuf = getThreadCommandBuffer(); | ||
|
||
cmdbuf[0] = IPC_MakeHeader(5,0,0); // 0x00050000 | ||
|
||
if(R_FAILED(ret = svcSendSyncRequest(frdHandle)))return ret; | ||
|
||
memcpy(key, &cmdbuf[2], 0x10); | ||
|
||
return (Result)cmdbuf[1]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <3ds.h> | ||
#include <string.h> | ||
|
||
Handle frdHandle; | ||
|
||
typedef struct | ||
{ | ||
u32 principalId; | ||
u64 localFriendCode; | ||
} FriendKey; | ||
|
||
Result frdInit(); | ||
Result frdExit(); | ||
Result frdSetClientSdkVersion(u32 sdkVer); | ||
u64 frdPrincipalIdToFriendCode(u64 *fc, u64 pid); | ||
Result frdGetMyFriendKey(FriendKey *key); |