-
-
Save TuxSH/7ffa4a03f2423b55324008e6be1fb3da to your computer and use it in GitHub Desktop.
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <3ds.h> | |
#include "csvc.h" | |
u8 *rdbuf = NULL; | |
Handle fsPxiHandle = 0; | |
void test1(void) | |
{ | |
Result res = 0; | |
//u64 tid = 0x0004001000022E00ULL; // EUR AR Games | |
//FS_MediaType medtype = MEDIATYPE_NAND; | |
//u64 tid = 0x000400000FF55600ULL; // some random hb app | |
//FS_MediaType medtype = MEDIATYPE_SD; | |
u64 tid = 0; | |
FS_MediaType medtype = MEDIATYPE_GAME_CARD; | |
u32 archivePath[] = {tid & 0xFFFFFFFF, (tid >> 32) & 0xFFFFFFFF, medtype, 0x00000000}; | |
static const u32 codePath[] = {0x00000000, 0x00000000, 0x00000002, 0x646F632E, 0x00000065}; | |
FSPXI_File fileHandle = 0; | |
FSPXI_Archive archiveHandle = 0; | |
res = FSPXI_OpenArchive(fsPxiHandle, &archiveHandle, ARCHIVE_SAVEDATA_AND_CONTENT, (FS_Path){PATH_BINARY, sizeof(archivePath), archivePath}); | |
if (R_FAILED(res)) | |
printf("Failed to open archive: %08lx\n", res); | |
res = FSPXI_OpenFile(fsPxiHandle, &fileHandle, archiveHandle, (FS_Path){PATH_BINARY, sizeof(codePath), codePath}, FS_OPEN_READ, 0); | |
if (R_FAILED(res)) | |
printf("Failed to open file: %08lx\n", res); | |
u32 numRead = 0; | |
u32 sz = 0x1000; | |
u32 szHashBlock = 0x1000; | |
// 0xD900458x expected | |
res = FSPXI_ReadFileSHA256(fsPxiHandle, fileHandle, &numRead, 0, rdbuf+1, sz, rdbuf + 0x20000, (sz / szHashBlock) * 32, szHashBlock); | |
printf("ReadFileSha256: %08lx\n", res); | |
FSPXI_CloseFile(fsPxiHandle, fileHandle); | |
FSPXI_CloseArchive(fsPxiHandle, archiveHandle); | |
} | |
int main(int argc, char* argv[]) | |
{ | |
gfxInitDefault(); | |
consoleInit(GFX_TOP, NULL); | |
rdbuf = linearMemAlign(20 << 20, 0x1000); | |
printf("Hello, world!\n"); | |
Result res = svcControlService(SERVICEOP_STEAL_CLIENT_SESSION, &fsPxiHandle, "PxiFS0"); // custom svc | |
printf("steal res = %08lx\n", res); | |
test1(); | |
svcCloseHandle(fsPxiHandle); | |
linearFree(rdbuf); | |
// Main loop | |
while (aptMainLoop()) | |
{ | |
gspWaitForVBlank(); | |
gfxSwapBuffers(); | |
hidScanInput(); | |
// Your code goes here | |
u32 kDown = hidKeysDown(); | |
if (kDown & KEY_START) | |
break; // break in order to return to hbmenu | |
} | |
gfxExit(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment