mirror of
https://github.com/joel16/3DSident.git
synced 2024-11-23 03:29:45 +00:00
Merge upstream changes from GUI
(Excluding a few GUI exclusive NNID info.)
This commit is contained in:
parent
51697267e4
commit
738b237453
@ -4,7 +4,6 @@
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char * getNNIDNum();
|
||||
char * getVersion(int version);
|
||||
char * getCID(int type);
|
||||
|
||||
|
@ -8,11 +8,7 @@
|
||||
|
||||
Result actInit(u32 sdkVer, u32 sharedMemSize);
|
||||
void actExit(void);
|
||||
Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize);
|
||||
Result ACT_GetAccountInfo(void *buffer, u32 size, u32 blkId);
|
||||
Result actuInit(void);
|
||||
Result actuExit(void);
|
||||
Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle);
|
||||
Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output);
|
||||
Result ACTU_Initialize(u32 sdkVer, void *addr, u32 memSize);
|
||||
Result ACTU_GetAccountDataBlock(void *buffer, u32 size, u32 blkId);
|
||||
|
||||
#endif
|
@ -13,7 +13,7 @@ char * getSerialNum(void);
|
||||
u32 getDeviceId(void);
|
||||
u64 getSoapId(void);
|
||||
char * getDeviceCert(void);
|
||||
char * getNNID(void);
|
||||
char * getNNIDInfo(u32 size, u32 blkId);
|
||||
char * isDebugModeEnabled();
|
||||
char * getBrightness(u32 screen);
|
||||
char * getCardSlotStatus();
|
||||
|
@ -1,3 +1,6 @@
|
||||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -8,4 +11,7 @@
|
||||
KEY_CSTICK_UP | KEY_CSTICK_DOWN | KEY_CSTICK_LEFT | KEY_CSTICK_RIGHT)
|
||||
|
||||
void getSizeString(char *string, uint64_t size);
|
||||
char * base64Encode(u8 const * input);
|
||||
void utf2ascii(char* dst, u16* src);
|
||||
char * base64Encode(u8 const * input);
|
||||
|
||||
#endif
|
@ -231,6 +231,7 @@ AccessControlInfo:
|
||||
- news:s
|
||||
- nwm::EXT
|
||||
- nwm::UDS
|
||||
- ps:ps
|
||||
- ptm:sysm
|
||||
- ptm:u
|
||||
- pxi:dev
|
||||
|
@ -1,23 +1,6 @@
|
||||
#include "actu.h"
|
||||
#include "kernel.h"
|
||||
|
||||
char * getNNIDNum()
|
||||
{
|
||||
s32 ret = 0;
|
||||
static char nnidNumStr[30];
|
||||
u32 nnidNum = 0xFFFFFFFF;
|
||||
|
||||
ret = ACTU_Initialize(0xB0002C8, 0, 0);
|
||||
ret = ACTU_GetAccountDataBlock(0xFE, 4, 12, &nnidNum);
|
||||
if ((ret != 0 ) && (nnidNum != 0xFFFFFFFF))
|
||||
sprintf(nnidNumStr, "%08X", (int) nnidNum);
|
||||
|
||||
else
|
||||
sprintf(nnidNumStr, "could not retreive NNID num.");
|
||||
|
||||
return nnidNumStr;
|
||||
}
|
||||
|
||||
char * getVersion(int version)
|
||||
{
|
||||
char *str_kernel = (char *)malloc(sizeof(char) * 255), *str_ver = (char *)malloc(sizeof(char) * 255), *str_sysver = (char *)malloc(sizeof(char) * 255);
|
||||
|
@ -33,8 +33,7 @@ void initServices()
|
||||
psInit();
|
||||
aptInit();
|
||||
hidInit();
|
||||
actuInit();
|
||||
actInit(SDK(11,2,0,200), 0x20000);
|
||||
actInit(SDK(11, 2, 0, 200), 0x20000);
|
||||
httpcInit(0x9000);
|
||||
}
|
||||
|
||||
@ -42,7 +41,6 @@ void termServices()
|
||||
{
|
||||
httpcExit();
|
||||
actExit();
|
||||
actuExit();
|
||||
hidExit();
|
||||
aptExit();
|
||||
psExit();
|
||||
@ -78,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
char *str_ver = (char *)malloc(sizeof(char) * 255), *str_sysver = (char *)malloc(sizeof(char) * 255);
|
||||
double wifiPercent, volPercent, _3dSliderPercent;
|
||||
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(), nnidNum = 0xFFFFFFFF;
|
||||
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(), principalID = 0;
|
||||
u8 buf[16], batteryPercent, batteryVolt, volume;
|
||||
OS_VersionBin *nver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin)), *cver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin));
|
||||
char sdFreeSize[16], sdTotalSize[16];
|
||||
@ -127,15 +125,9 @@ int main(int argc, char *argv[])
|
||||
printf("\x1b[31;1m*\x1b[0m Model: \x1b[31;1m%s\x1b[0m (\x1b[31;1m%s\x1b[0m) \n\x1b[0m", getModel(), getRegion());
|
||||
printf("\x1b[31;1m*\x1b[0m Screen type: \x1b[31;1m %s \n\x1b[0m", getScreenType());
|
||||
printf("\x1b[31;1m*\x1b[0m Language: \x1b[31;1m%s\x1b[0m \n", getLang());
|
||||
printf("\x1b[31;1m*\x1b[0m NNID: \x1b[31;1m%s\x1b[0m ", (char*)getNNID());
|
||||
|
||||
ret = ACTU_Initialize(0xB0002C8, 0, 0);
|
||||
ret = ACTU_GetAccountDataBlock(0xFE, 4, 12, &nnidNum);
|
||||
|
||||
if (nnidNum != 0xFFFFFFFF)
|
||||
printf("(\x1b[31;1m%d\x1b[0m) \n", (int) nnidNum);
|
||||
else
|
||||
printf("\x1b[31;1mError could not retrieve NNID\x1b[0m\n");
|
||||
|
||||
ACTU_GetAccountDataBlock(&principalID, 0x4, 0xC);
|
||||
printf("\x1b[31;1m*\x1b[0m NNID: \x1b[31;1m%s\x1b[0m (\x1b[31;1m%u\x1b[0m) \n", getNNIDInfo(0x11, 0x8), (unsigned int)principalID);
|
||||
|
||||
printf("\x1b[31;1m*\x1b[0m Device ID: \x1b[31;1m%lu \n", getDeviceId());
|
||||
printf("\x1b[31;1m*\x1b[0m ECS Device ID: \x1b[31;1m%llu \n", getSoapId());
|
||||
|
@ -9,7 +9,7 @@ static Handle act_shareMemHandle;
|
||||
|
||||
Result actInit(u32 sdkVer, u32 sharedMemSize)
|
||||
{
|
||||
Result ret = 0;
|
||||
Result ret = 0;
|
||||
|
||||
ret = srvGetServiceHandle(&actHandle, "act:u");
|
||||
|
||||
@ -29,16 +29,16 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
|
||||
{
|
||||
memset((void*)act_shareMemAddr, 0, act_shareMemSize);
|
||||
ret = svcCreateMemoryBlock(&act_shareMemHandle, (u32)act_shareMemAddr, act_shareMemSize, 0, MEMPERM_READ | MEMPERM_WRITE);
|
||||
if(R_FAILED(ret))
|
||||
actExit();
|
||||
if(R_FAILED(ret))
|
||||
actExit();
|
||||
}
|
||||
}
|
||||
|
||||
ret = ACT_Initialize(sdkVer, &act_shareMemHandle, act_shareMemSize);
|
||||
ret = ACTU_Initialize(sdkVer, &act_shareMemHandle, act_shareMemSize);
|
||||
|
||||
if (R_FAILED(ret))
|
||||
actExit();
|
||||
}
|
||||
actExit();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -51,95 +51,48 @@ void actExit(void)
|
||||
|
||||
if(act_shareMemHandle)
|
||||
{
|
||||
svcUnmapMemoryBlock(act_shareMemHandle, (u32)act_shareMemAddr);
|
||||
free(act_shareMemAddr);
|
||||
act_shareMemAddr = NULL;
|
||||
svcCloseHandle(act_shareMemHandle);
|
||||
svcUnmapMemoryBlock(act_shareMemHandle, (u32)act_shareMemAddr);
|
||||
free(act_shareMemAddr);
|
||||
act_shareMemAddr = NULL;
|
||||
svcCloseHandle(act_shareMemHandle);
|
||||
act_shareMemHandle = 0;
|
||||
act_shareMemSize = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize)
|
||||
Result ACTU_Initialize(u32 sdkVer, void *addr, u32 memSize)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(0x1,2,4); // 0x00010084
|
||||
cmdbuf[1] = sdkVer;
|
||||
cmdbuf[2] = memSize;
|
||||
cmdbuf[3] = 0x20;
|
||||
cmdbuf[4] = IPC_Desc_CurProcessHandle();
|
||||
cmdbuf[5] = 0;
|
||||
cmdbuf[6] = (u32)addr;
|
||||
cmdbuf[1] = sdkVer;
|
||||
cmdbuf[2] = memSize;
|
||||
cmdbuf[3] = 0x20;
|
||||
cmdbuf[4] = IPC_Desc_CurProcessHandle();
|
||||
cmdbuf[5] = 0;
|
||||
cmdbuf[6] = (u32)addr;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result ACT_GetAccountInfo(void *buffer, u32 size, u32 blkId)
|
||||
Result ACTU_GetAccountDataBlock(void *buffer, u32 size, u32 blkId)
|
||||
{
|
||||
Result ret = 0;
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(6,3,2); // 0x00600C2
|
||||
cmdbuf[1] = 0xFE;
|
||||
cmdbuf[2] = size;
|
||||
cmdbuf[3] = blkId;
|
||||
cmdbuf[4] = 0x10 * size | 0xC;
|
||||
cmdbuf[5] = (u32)buffer;
|
||||
cmdbuf[1] = 0xFE;
|
||||
cmdbuf[2] = size;
|
||||
cmdbuf[3] = blkId;
|
||||
cmdbuf[4] = 0x10 * size | 0xC;
|
||||
cmdbuf[5] = (u32)buffer;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result actuInit(void)
|
||||
{
|
||||
return srvGetServiceHandle(&actHandle, "act:u");
|
||||
}
|
||||
|
||||
Result actuExit(void)
|
||||
{
|
||||
return svcCloseHandle(actHandle);
|
||||
}
|
||||
|
||||
Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x00010084;
|
||||
cmdbuf[1] = sdkVersion;
|
||||
cmdbuf[2] = unknown;
|
||||
cmdbuf[3] = 0x20;
|
||||
cmdbuf[4] = 0;
|
||||
cmdbuf[5] = 0x0;
|
||||
cmdbuf[6] = handle;
|
||||
|
||||
if((ret = svcSendSyncRequest(actHandle))!= 0)
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
||||
Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output)
|
||||
{
|
||||
Result ret = 0;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
||||
cmdbuf[0] = 0x000600C2;
|
||||
cmdbuf[1] = unknown;
|
||||
cmdbuf[2] = size;
|
||||
cmdbuf[3] = blockId;
|
||||
cmdbuf[4] = (size << 4) | 0xC;
|
||||
cmdbuf[5] = (u32) output;
|
||||
|
||||
if((ret = svcSendSyncRequest(actHandle))!= 0)
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
}
|
@ -83,7 +83,7 @@ char * getMacAddress()
|
||||
static char macAddress[18];
|
||||
|
||||
//sprintf automatically zero-terminates the string
|
||||
sprintf(macAddress, "%02X:%02X:%02X:%02X:%02X:%02X", *macByte, *(macByte + 1), *(macByte + 2), *(macByte + 3), *(macByte + 4), *(macByte + 5));
|
||||
snprintf(macAddress, 18, "%02X:%02X:%02X:%02X:%02X:%02X", *macByte, *(macByte + 1), *(macByte + 2), *(macByte + 3), *(macByte + 4), *(macByte + 5));
|
||||
|
||||
return macAddress;
|
||||
}
|
||||
@ -185,12 +185,15 @@ char * getDeviceCert(void)
|
||||
return base64Encode(cert);
|
||||
}
|
||||
|
||||
char * getNNID(void)
|
||||
char * getNNIDInfo(u32 size, u32 blkId)
|
||||
{
|
||||
static char tmp[0x11];
|
||||
ACT_GetAccountInfo(tmp, 0x11, 0x8);
|
||||
char info[size];
|
||||
static char str[100];
|
||||
|
||||
return tmp;
|
||||
ACTU_GetAccountDataBlock(info, size, blkId);
|
||||
snprintf(str, size, "%s", info);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char * isDebugModeEnabled()
|
||||
@ -240,10 +243,10 @@ char * getCardSlotStatus()
|
||||
if (isInserted)
|
||||
{
|
||||
FSUSER_GetCardType(&cardType);
|
||||
sprintf(card, "inserted %s", cardType? "(TWL)" : "(CTR)");
|
||||
snprintf(card, 20, "inserted %s", cardType? "(TWL)" : "(CTR)");
|
||||
return card;
|
||||
}
|
||||
|
||||
sprintf(card, "not inserted");
|
||||
snprintf(card, 20, "not inserted");
|
||||
return card;
|
||||
}
|
@ -14,6 +14,15 @@ void getSizeString(char *string, uint64_t size) //Thanks TheOfficialFloW
|
||||
sprintf(string, "%.*f %s", (i == 0) ? 0 : 2, double_size, units[i]);
|
||||
}
|
||||
|
||||
void utf2ascii(char* dst, u16* src)
|
||||
{
|
||||
if(!src || !dst)
|
||||
return;
|
||||
|
||||
while(*src)*(dst++)=(*(src++))&0xFF;
|
||||
*dst=0x00;
|
||||
}
|
||||
|
||||
char * base64Encode(u8 const * input)
|
||||
{
|
||||
int len = strlen((const char *)input);
|
||||
|
Loading…
Reference in New Issue
Block a user