mirror of
https://github.com/joel16/3DSident.git
synced 2024-11-23 03:29:45 +00:00
Clean up and follow up on code consistency
This commit is contained in:
parent
669b5d0115
commit
51697267e4
@ -4,16 +4,8 @@
|
||||
#include <3ds.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Handle actHandle;
|
||||
int actRefCount;
|
||||
|
||||
u32 *act_shareMemAddr;
|
||||
u32 act_shareMemSize;
|
||||
Handle act_shareMemHandle;
|
||||
|
||||
Result actInit(u32 sdkVer, u32 sharedMemSize);
|
||||
void actExit(void);
|
||||
Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize);
|
||||
|
@ -2,12 +2,7 @@
|
||||
#define AM_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
Handle amHandle;
|
||||
|
||||
char * base64encode(const char * input);
|
||||
Result amNetGetDeviceCert(u8 const * buffer);
|
||||
|
||||
#endif
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Handle cfgHandle;
|
||||
|
||||
Result cfgsInit();
|
||||
Result cfgsExit();
|
||||
Result CFG_GetConfig(u32 size, u32 blkID, u8* outData);
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Handle gspLcdHandle;
|
||||
|
||||
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness);
|
||||
|
||||
#endif
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Handle mcuhwcHandle;
|
||||
|
||||
Result mcuInit();
|
||||
Result mcuExit();
|
||||
Result mcuGetBatteryLevel(u8* out);
|
||||
|
@ -11,7 +11,7 @@ Option:
|
||||
UseOnSD : true # true if App is to be installed to SD
|
||||
FreeProductCode : true # Removes limitations on ProductCode
|
||||
MediaFootPadding : false # If true CCI files are created with padding
|
||||
EnableCrypt : false # Enables encryption for NCCH and CIA"
|
||||
EnableCrypt : false # Enables encryption for NCCH and CIA
|
||||
EnableCompress : true # Compresses where applicable (currently only exefs:/.code)
|
||||
|
||||
AccessControlInfo:
|
||||
@ -31,36 +31,37 @@ AccessControlInfo:
|
||||
# FS:USER Archive Access Permissions
|
||||
# Uncomment as required
|
||||
FileSystemAccess:
|
||||
#- CategorySystemApplication
|
||||
#- CategoryHardwareCheck
|
||||
- CategorySystemApplication
|
||||
- CategoryHardwareCheck
|
||||
- CategoryFileSystemTool
|
||||
#- Debug
|
||||
#- TwlCardBackup
|
||||
#- TwlNandData
|
||||
#- Boss
|
||||
- Debug
|
||||
- TwlCardBackup
|
||||
- TwlNandData
|
||||
- Boss
|
||||
- DirectSdmc
|
||||
#- Core
|
||||
#- CtrNandRo
|
||||
#- CtrNandRw
|
||||
#- CtrNandRoWrite
|
||||
#- CategorySystemSettings
|
||||
#- CardBoard
|
||||
#- ExportImportIvs
|
||||
#- DirectSdmcWrite
|
||||
#- SwitchCleanup
|
||||
#- SaveDataMove
|
||||
#- Shop
|
||||
#- Shell
|
||||
#- CategoryHomeMenu
|
||||
- Core
|
||||
- CtrNandRo
|
||||
- CtrNandRw
|
||||
- CtrNandRoWrite
|
||||
- CategorySystemSettings
|
||||
- CardBoard
|
||||
- ExportImportIvs
|
||||
- DirectSdmcWrite
|
||||
- SwitchCleanup
|
||||
- SaveDataMove
|
||||
- Shop
|
||||
- Shell
|
||||
- CategoryHomeMenu
|
||||
- SeedDB
|
||||
IoAccessControl:
|
||||
#- FsMountNand
|
||||
#- FsMountNandRoWrite
|
||||
#- FsMountTwln
|
||||
#- FsMountWnand
|
||||
#- FsMountCardSpi
|
||||
#- UseSdif3
|
||||
#- CreateSeed
|
||||
#- UseCardSpi
|
||||
- FsMountNand
|
||||
- FsMountNandRoWrite
|
||||
- FsMountTwln
|
||||
- FsMountWnand
|
||||
- FsMountCardSpi
|
||||
- UseSdif3
|
||||
- CreateSeed
|
||||
- UseCardSpi
|
||||
|
||||
# Process Settings
|
||||
MemoryType : Application # Application/System/Base
|
||||
@ -82,7 +83,7 @@ AccessControlInfo:
|
||||
|
||||
# New3DS Exclusive Process Settings
|
||||
SystemModeExt : $(APP_SYSTEM_MODE_EXT) # Legacy(Default)/124MB/178MB Legacy:Use Old3DS SystemMode
|
||||
CpuSpeed : 804MHz # 256MHz(Default)/804MHz
|
||||
CpuSpeed : $(APP_CPU_SPEED) # 268MHz(Default)/804MHz
|
||||
EnableL2Cache : true # false(default)/true
|
||||
CanAccessCore2 : true
|
||||
|
||||
@ -92,61 +93,115 @@ AccessControlInfo:
|
||||
MemoryMapping:
|
||||
- 1f000000-1f5fffff:r # VRAM
|
||||
|
||||
# Accessible SVCs, <Name>:<ID>
|
||||
# Accessible SVCs, <Name>:<ID>
|
||||
SystemCallAccess:
|
||||
ArbitrateAddress: 34
|
||||
Backdoor: 123
|
||||
Break: 60
|
||||
CancelTimer: 28
|
||||
ClearEvent: 25
|
||||
ClearTimer: 29
|
||||
CloseHandle: 35
|
||||
ConnectToPort: 45
|
||||
ControlMemory: 1
|
||||
ControlProcessMemory: 112
|
||||
CreateAddressArbiter: 33
|
||||
CreateEvent: 23
|
||||
CreateMemoryBlock: 30
|
||||
CreateMutex: 19
|
||||
CreateSemaphore: 21
|
||||
CreateThread: 8
|
||||
CreateTimer: 26
|
||||
DuplicateHandle: 39
|
||||
ExitProcess: 3
|
||||
ExitThread: 9
|
||||
GetCurrentProcessorNumber: 17
|
||||
GetHandleInfo: 41
|
||||
GetProcessId: 53
|
||||
GetProcessIdOfThread: 54
|
||||
GetProcessIdealProcessor: 6
|
||||
GetProcessInfo: 43
|
||||
GetResourceLimit: 56
|
||||
GetResourceLimitCurrentValues: 58
|
||||
GetResourceLimitLimitValues: 57
|
||||
GetSystemInfo: 42
|
||||
GetSystemTick: 40
|
||||
GetThreadContext: 59
|
||||
GetThreadId: 55
|
||||
GetThreadIdealProcessor: 15
|
||||
GetThreadInfo: 44
|
||||
GetThreadPriority: 11
|
||||
MapMemoryBlock: 31
|
||||
OutputDebugString: 61
|
||||
QueryMemory: 2
|
||||
ExitProcess: 3
|
||||
GetProcessAffinityMask: 4
|
||||
SetProcessAffinityMask: 5
|
||||
GetProcessIdealProcessor: 6
|
||||
SetProcessIdealProcessor: 7
|
||||
CreateThread: 8
|
||||
ExitThread: 9
|
||||
SleepThread: 10
|
||||
GetThreadPriority: 11
|
||||
SetThreadPriority: 12
|
||||
GetThreadAffinityMask: 13
|
||||
SetThreadAffinityMask: 14
|
||||
GetThreadIdealProcessor: 15
|
||||
SetThreadIdealProcessor: 16
|
||||
GetCurrentProcessorNumber: 17
|
||||
Run: 18
|
||||
CreateMutex: 19
|
||||
ReleaseMutex: 20
|
||||
CreateSemaphore: 21
|
||||
ReleaseSemaphore: 22
|
||||
CreateEvent: 23
|
||||
SignalEvent: 24
|
||||
ClearEvent: 25
|
||||
CreateTimer: 26
|
||||
SetTimer: 27
|
||||
CancelTimer: 28
|
||||
ClearTimer: 29
|
||||
CreateMemoryBlock: 30
|
||||
MapMemoryBlock: 31
|
||||
UnmapMemoryBlock: 32
|
||||
CreateAddressArbiter: 33
|
||||
ArbitrateAddress: 34
|
||||
CloseHandle: 35
|
||||
WaitSynchronization1: 36
|
||||
WaitSynchronizationN: 37
|
||||
SignalAndWait: 38
|
||||
DuplicateHandle: 39
|
||||
GetSystemTick: 40
|
||||
GetHandleInfo: 41
|
||||
GetSystemInfo: 42
|
||||
GetProcessInfo: 43
|
||||
GetThreadInfo: 44
|
||||
ConnectToPort: 45
|
||||
SendSyncRequest1: 46
|
||||
SendSyncRequest2: 47
|
||||
SendSyncRequest3: 48
|
||||
SendSyncRequest4: 49
|
||||
SendSyncRequest: 50
|
||||
SetThreadPriority: 12
|
||||
SetTimer: 27
|
||||
SignalEvent: 24
|
||||
SleepThread: 10
|
||||
UnmapMemoryBlock: 32
|
||||
WaitSynchronization1: 36
|
||||
WaitSynchronizationN: 37
|
||||
OpenProcess: 51
|
||||
OpenThread: 52
|
||||
GetProcessId: 53
|
||||
GetProcessIdOfThread: 54
|
||||
GetThreadId: 55
|
||||
GetResourceLimit: 56
|
||||
GetResourceLimitLimitValues: 57
|
||||
GetResourceLimitCurrentValues: 58
|
||||
GetThreadContext: 59
|
||||
Break: 60
|
||||
OutputDebugString: 61
|
||||
ControlPerformanceCounter: 62
|
||||
CreatePort: 71
|
||||
CreateSessionToPort: 72
|
||||
CreateSession: 73
|
||||
AcceptSession: 74
|
||||
ReplyAndReceive1: 75
|
||||
ReplyAndReceive2: 76
|
||||
ReplyAndReceive3: 77
|
||||
ReplyAndReceive4: 78
|
||||
ReplyAndReceive: 79
|
||||
BindInterrupt: 80
|
||||
UnbindInterrupt: 81
|
||||
InvalidateProcessDataCache: 82
|
||||
StoreProcessDataCache: 83
|
||||
FlushProcessDataCache: 84
|
||||
StartInterProcessDma: 85
|
||||
StopDma: 86
|
||||
GetDmaState: 87
|
||||
RestartDma: 88
|
||||
DebugActiveProcess: 96
|
||||
BreakDebugProcess: 97
|
||||
TerminateDebugProcess: 98
|
||||
GetProcessDebugEvent: 99
|
||||
ContinueDebugEvent: 100
|
||||
GetProcessList: 101
|
||||
GetThreadList: 102
|
||||
GetDebugThreadContext: 103
|
||||
SetDebugThreadContext: 104
|
||||
QueryDebugProcessMemory: 105
|
||||
ReadProcessMemory: 106
|
||||
WriteProcessMemory: 107
|
||||
SetHardwareBreakPoint: 108
|
||||
GetDebugThreadParam: 109
|
||||
ControlProcessMemory: 112
|
||||
MapProcessMemory: 113
|
||||
UnmapProcessMemory: 114
|
||||
CreateCodeSet: 115
|
||||
CreateProcess: 117
|
||||
TerminateProcess: 118
|
||||
SetProcessResourceLimits: 119
|
||||
CreateResourceLimit: 120
|
||||
SetResourceLimitValues: 121
|
||||
AddCodeSegment: 122
|
||||
Backdoor: 123
|
||||
KernelSetState: 124
|
||||
QueryProcessMemory: 125
|
||||
|
||||
# Service List
|
||||
# Maximum 34 services (32 if firmware is prior to 9.6.0)
|
||||
@ -155,41 +210,37 @@ AccessControlInfo:
|
||||
- ac:u
|
||||
- act:u
|
||||
- am:net
|
||||
- $hioFIO
|
||||
- $hostio0
|
||||
- $hostio1
|
||||
- boss:U
|
||||
- cam:u
|
||||
- cecd:u
|
||||
- cfg:nor
|
||||
- cfg:u
|
||||
- cfg:s
|
||||
- dlp:FKCL
|
||||
- dlp:SRVR
|
||||
- csnd:SND
|
||||
- dsp::DSP
|
||||
- fs:USER
|
||||
- gsp::Gpu
|
||||
- gsp::Lcd
|
||||
- hid:USER
|
||||
- http:C
|
||||
- ir:rst
|
||||
- ir:u
|
||||
- ir:USER
|
||||
- mcu::HWC
|
||||
- ndm:u
|
||||
- ps:ps
|
||||
- news:s
|
||||
- nwm::EXT
|
||||
- nwm::UDS
|
||||
- ptm:sysm
|
||||
- ptm:u
|
||||
- pxi:dev
|
||||
- soc:U
|
||||
- ssl:C
|
||||
- y2r:u
|
||||
- ldr:ro
|
||||
- csnd:SND
|
||||
- am:u
|
||||
- ns:s
|
||||
|
||||
|
||||
SystemControlInfo:
|
||||
SaveDataSize: 0KB # Change if the app uses savedata
|
||||
RemasterVersion: 2
|
||||
RemasterVersion: 1
|
||||
StackSize: 0x40000
|
||||
|
||||
# Modules that run services listed above should be included below
|
||||
@ -197,7 +248,7 @@ SystemControlInfo:
|
||||
# <module name>:<module titleid>
|
||||
Dependency:
|
||||
ac: 0x0004013000002402
|
||||
act: 0x0004013000003802
|
||||
#act: 0x0004013000003802
|
||||
am: 0x0004013000001502
|
||||
boss: 0x0004013000003402
|
||||
camera: 0x0004013000001602
|
||||
@ -218,13 +269,13 @@ SystemControlInfo:
|
||||
mic: 0x0004013000002002
|
||||
ndm: 0x0004013000002b02
|
||||
news: 0x0004013000003502
|
||||
nfc: 0x0004013000004002
|
||||
#nfc: 0x0004013000004002
|
||||
nim: 0x0004013000002c02
|
||||
nwm: 0x0004013000002d02
|
||||
pdn: 0x0004013000002102
|
||||
ps: 0x0004013000003102
|
||||
ptm: 0x0004013000002202
|
||||
qtm: 0x0004013020004202
|
||||
#qtm: 0x0004013020004202
|
||||
ro: 0x0004013000003702
|
||||
socket: 0x0004013000002e02
|
||||
spi: 0x0004013000002302
|
||||
|
@ -108,9 +108,9 @@ int main(int argc, char *argv[])
|
||||
ret = osGetSystemVersionData(nver, cver);
|
||||
|
||||
if (ret)
|
||||
printf("\x1b[33;1m*\x1b[0m osGetSystemVersionData returned 0x%08liX\n\n", ret);
|
||||
printf("\x1b[33;1m*\x1b[0m System version: 0x%08liX\n\n", ret);
|
||||
|
||||
snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m Current system version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
|
||||
snprintf(str_sysver, 100, "\x1b[33;1m*\x1b[0m System version: \x1b[33;1m%d.%d.%d-%d\x1b[0m\n\n",
|
||||
cver->mainver,
|
||||
cver->minor,
|
||||
cver->build,
|
||||
@ -163,7 +163,7 @@ int main(int argc, char *argv[])
|
||||
printf("\x1b[34;1m*\x1b[0m Battery percentage: \x1b[34;1m%3d%%\x1b[0m (\x1b[34;1m%s\x1b[0m) \n\x1b[0m", batteryPercent, batteryStatus());
|
||||
|
||||
mcuGetBatteryVoltage(&batteryVolt);
|
||||
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m\n", batteryVolt);//,(Estimated: %0.1lf V) estimatedVolt);
|
||||
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0)); // Estimated volt
|
||||
|
||||
u8 mcuFwMajor, mcuFwMinor;
|
||||
|
||||
@ -185,18 +185,6 @@ int main(int argc, char *argv[])
|
||||
printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize);
|
||||
|
||||
printf("\x1b[32;1m*\x1b[0m Installed titles: SD: \x1b[32;1m%i\x1b[0m (NAND: \x1b[32;1m%i\x1b[0m)\n", (int)titleCount(MEDIATYPE_SD), (int)titleCount(MEDIATYPE_NAND));
|
||||
|
||||
/*wifiPercent = (osGetWifiStrength() * 33.3333333333);
|
||||
printf("\x1b[32;1m*\x1b[0m WiFi signal strength: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
|
||||
|
||||
HIDUSER_GetSoundVolume(&volume);
|
||||
volPercent = (volume * 1.5873015873);
|
||||
printf("\x1b[32;1m*\x1b[0m Volume slider state: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", volume, volPercent);
|
||||
|
||||
_3dSliderPercent = (osGet3DSliderState() * 100.0);
|
||||
printf("\x1b[32;1m*\x1b[0m 3D slider state: \x1b[32;1m%.1lf\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
|
||||
|
||||
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));*/
|
||||
|
||||
while (aptMainLoop())
|
||||
{
|
||||
@ -210,7 +198,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
printf("\x1b[19;0H"); //Move the cursor to the top left corner of the screen
|
||||
mcuGetBatteryVoltage(&batteryVolt);
|
||||
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m\n", batteryVolt);//,(Estimated: %0.1lf V) estimatedVolt);
|
||||
printf("\x1b[34;1m*\x1b[0m Battery voltage: \x1b[34;1m%d\x1b[0m (\x1b[34;1m%.1f V\x1b[0m)\n", batteryVolt, 5.0 * ((double)batteryVolt / 256.0));//,(Estimated: %0.1lf V) estimatedVolt);
|
||||
//=====================================================================//
|
||||
//------------------------------Misc Info------------------------------//
|
||||
//=====================================================================//
|
||||
|
@ -1,11 +1,21 @@
|
||||
#include "actu.h"
|
||||
|
||||
static Handle actHandle;
|
||||
static int actRefCount;
|
||||
|
||||
static u32 *act_shareMemAddr;
|
||||
static u32 act_shareMemSize;
|
||||
static Handle act_shareMemHandle;
|
||||
|
||||
Result actInit(u32 sdkVer, u32 sharedMemSize)
|
||||
{
|
||||
Result ret=0;
|
||||
Result ret = 0;
|
||||
|
||||
ret = srvGetServiceHandle(&actHandle, "act:u");
|
||||
if (R_FAILED(ret)) ret = srvGetServiceHandle(&actHandle, "act:a");
|
||||
|
||||
if (R_FAILED(ret))
|
||||
ret = srvGetServiceHandle(&actHandle, "act:a");
|
||||
|
||||
if (R_SUCCEEDED(ret))
|
||||
{
|
||||
act_shareMemSize = sharedMemSize;
|
||||
@ -14,6 +24,7 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
|
||||
if(act_shareMemSize)
|
||||
{
|
||||
act_shareMemAddr = (u32*)memalign(0x1000, act_shareMemSize);
|
||||
|
||||
if(act_shareMemAddr != NULL)
|
||||
{
|
||||
memset((void*)act_shareMemAddr, 0, act_shareMemSize);
|
||||
@ -22,6 +33,7 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
|
||||
actExit();
|
||||
}
|
||||
}
|
||||
|
||||
ret = ACT_Initialize(sdkVer, &act_shareMemHandle, act_shareMemSize);
|
||||
|
||||
if (R_FAILED(ret))
|
||||
@ -32,7 +44,9 @@ Result actInit(u32 sdkVer, u32 sharedMemSize)
|
||||
|
||||
void actExit(void)
|
||||
{
|
||||
if (AtomicDecrement(&actRefCount)) return;
|
||||
if (AtomicDecrement(&actRefCount))
|
||||
return;
|
||||
|
||||
svcCloseHandle(actHandle);
|
||||
|
||||
if(act_shareMemHandle)
|
||||
@ -59,7 +73,8 @@ Result ACT_Initialize(u32 sdkVer, void *addr, u32 memSize)
|
||||
cmdbuf[5] = 0;
|
||||
cmdbuf[6] = (u32)addr;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle))) return ret;
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
@ -76,7 +91,8 @@ Result ACT_GetAccountInfo(void *buffer, u32 size, u32 blkId)
|
||||
cmdbuf[4] = 0x10 * size | 0xC;
|
||||
cmdbuf[5] = (u32)buffer;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle))) return ret;
|
||||
if(R_FAILED(ret = svcSendSyncRequest(actHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
@ -104,7 +120,8 @@ Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle)
|
||||
cmdbuf[5] = 0x0;
|
||||
cmdbuf[6] = handle;
|
||||
|
||||
if((ret = svcSendSyncRequest(actHandle))!=0) return ret;
|
||||
if((ret = svcSendSyncRequest(actHandle))!= 0)
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
@ -121,7 +138,8 @@ Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output
|
||||
cmdbuf[4] = (size << 4) | 0xC;
|
||||
cmdbuf[5] = (u32) output;
|
||||
|
||||
if((ret = svcSendSyncRequest(actHandle))!=0) return ret;
|
||||
if((ret = svcSendSyncRequest(actHandle))!= 0)
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
@ -1,59 +1,6 @@
|
||||
#include "am.h"
|
||||
|
||||
char * base64encode(const char * input)
|
||||
{
|
||||
int len = strlen(input);
|
||||
int leftover = len % 3;
|
||||
char *ret = malloc(((len/3) * 4) + ((leftover)?4:0) + 1);
|
||||
int n = 0;
|
||||
int outlen = 0;
|
||||
uint8_t i = 0;
|
||||
uint8_t *inp = (uint8_t *) input;
|
||||
const char *index = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"0123456789+/";
|
||||
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
// Convert each 3 bytes of input to 4 bytes of output.
|
||||
len -= leftover;
|
||||
for (n = 0; n < len; n+=3) {
|
||||
i = inp[n] >> 2;
|
||||
ret[outlen++] = index[i];
|
||||
|
||||
i = (inp[n] & 0x03) << 4;
|
||||
i |= (inp[n+1] & 0xf0) >> 4;
|
||||
ret[outlen++] = index[i];
|
||||
|
||||
i = ((inp[n+1] & 0x0f) << 2);
|
||||
i |= ((inp[n+2] & 0xc0) >> 6);
|
||||
ret[outlen++] = index[i];
|
||||
|
||||
i = (inp[n+2] & 0x3f);
|
||||
ret[outlen++] = index[i];
|
||||
}
|
||||
|
||||
// Handle leftover 1 or 2 bytes.
|
||||
if (leftover) {
|
||||
i = (inp[n] >> 2);
|
||||
ret[outlen++] = index[i];
|
||||
|
||||
i = (inp[n] & 0x03) << 4;
|
||||
if (leftover == 2) {
|
||||
i |= (inp[n+1] & 0xf0) >> 4;
|
||||
ret[outlen++] = index[i];
|
||||
|
||||
i = ((inp[n+1] & 0x0f) << 2);
|
||||
}
|
||||
ret[outlen++] = index[i];
|
||||
ret[outlen++] = '=';
|
||||
if (leftover == 1)
|
||||
ret[outlen++] = '=';
|
||||
}
|
||||
ret[outlen] = '\0';
|
||||
return ret;
|
||||
}
|
||||
static Handle amHandle;
|
||||
|
||||
Result amNetGetDeviceCert(u8 const * buffer)
|
||||
{
|
||||
@ -65,7 +12,8 @@ Result amNetGetDeviceCert(u8 const * buffer)
|
||||
cmdbuf[2] = (0x180 << 4) | 0xC;
|
||||
cmdbuf[3] = (u32)buffer;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(amHandle))) return ret;
|
||||
if(R_FAILED(ret = svcSendSyncRequest(amHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "cfgs.h"
|
||||
|
||||
static Handle cfgHandle;
|
||||
|
||||
Result cfgsInit() //Already initialized with CFGUinit();
|
||||
{
|
||||
return srvGetServiceHandle(&cfgHandle, "cfg:s");
|
||||
@ -21,7 +23,8 @@ Result CFG_GetConfig(u32 size, u32 blkID, u8* outData)
|
||||
cmdbuf[3] = IPC_Desc_Buffer(size,IPC_BUFFER_W);
|
||||
cmdbuf[4] = (u32)outData;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(cfgHandle)))return ret;
|
||||
if (R_FAILED(ret = svcSendSyncRequest(cfgHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
||||
@ -36,7 +39,8 @@ Result cfgsSecureInfoGetSerialNo(char *serial)
|
||||
cmdbuf[2] = 12 | (0xF << 4);
|
||||
cmdbuf[3] = (u32)serial;
|
||||
|
||||
if(R_FAILED(ret = svcSendSyncRequest(cfgHandle)))return ret;
|
||||
if (R_FAILED(ret = svcSendSyncRequest(cfgHandle)))
|
||||
return ret;
|
||||
|
||||
return (Result)cmdbuf[1];
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
#include "gsplcd.h"
|
||||
|
||||
static Handle gspLcdHandle;
|
||||
|
||||
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness)
|
||||
{
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "mcu.h"
|
||||
|
||||
static Handle mcuhwcHandle;
|
||||
|
||||
Result mcuInit()
|
||||
{
|
||||
return srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC");
|
||||
@ -12,31 +14,46 @@ Result mcuExit()
|
||||
|
||||
Result mcuGetBatteryLevel(u8* out)
|
||||
{
|
||||
u32* ipc = getThreadCommandBuffer();
|
||||
ipc[0] = 0x50000;
|
||||
Result ret = svcSendSyncRequest(mcuhwcHandle);
|
||||
if(ret < 0) return ret;
|
||||
u32* ipc = getThreadCommandBuffer();
|
||||
ipc[0] = 0x50000;
|
||||
|
||||
Result ret = svcSendSyncRequest(mcuhwcHandle);
|
||||
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
|
||||
*out = ipc[2];
|
||||
return ipc[1];
|
||||
|
||||
return ipc[1];
|
||||
}
|
||||
|
||||
Result mcuGetBatteryVoltage(u8* out)
|
||||
{
|
||||
u32* ipc = getThreadCommandBuffer();
|
||||
ipc[0] = 0x40000;
|
||||
Result ret = svcSendSyncRequest(mcuhwcHandle);
|
||||
if(ret < 0) return ret;
|
||||
u32* ipc = getThreadCommandBuffer();
|
||||
ipc[0] = 0x40000;
|
||||
|
||||
Result ret = svcSendSyncRequest(mcuhwcHandle);
|
||||
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
|
||||
*out = ipc[2];
|
||||
return ipc[1];
|
||||
|
||||
return ipc[1];
|
||||
}
|
||||
|
||||
Result GetMcuFwVerHigh(u8* out)
|
||||
{
|
||||
u32* ipc = getThreadCommandBuffer();
|
||||
ipc[0] = 0x100000;
|
||||
|
||||
Result ret = svcSendSyncRequest(mcuhwcHandle);
|
||||
if(ret < 0) return ret;
|
||||
*out = ipc[2];
|
||||
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
|
||||
*out = ipc[2];
|
||||
|
||||
return ipc[1];
|
||||
}
|
||||
|
||||
@ -44,8 +61,13 @@ Result GetMcuFwVerLow(u8* out)
|
||||
{
|
||||
u32* ipc = getThreadCommandBuffer();
|
||||
ipc[0] = 0x110000;
|
||||
|
||||
Result ret = svcSendSyncRequest(mcuhwcHandle);
|
||||
if(ret < 0) return ret;
|
||||
*out = ipc[2];
|
||||
|
||||
if(ret < 0)
|
||||
return ret;
|
||||
|
||||
*out = ipc[2];
|
||||
|
||||
return ipc[1];
|
||||
}
|
Loading…
Reference in New Issue
Block a user