mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-26 11:26:37 +08:00
Revert removal of seed file support.
This commit is contained in:
parent
f31f4ccb5f
commit
ff8773e0ff
@ -256,36 +256,58 @@ static Result FSUSER_AddSeed(u64 titleId, const void* seed) {
|
|||||||
static u32 import_response_code = 0;
|
static u32 import_response_code = 0;
|
||||||
|
|
||||||
Result util_import_seed(u64 titleId) {
|
Result util_import_seed(u64 titleId) {
|
||||||
|
char pathBuf[64];
|
||||||
|
snprintf(pathBuf, 64, "/fbi/seed/%016llX.dat", titleId);
|
||||||
|
|
||||||
Result res = 0;
|
Result res = 0;
|
||||||
|
|
||||||
u8 region = CFG_REGION_USA;
|
FS_Path* fsPath = util_make_path_utf8(pathBuf);
|
||||||
CFGU_SecureInfoGetRegion(®ion);
|
if(fsPath != NULL) {
|
||||||
|
u8 seed[16];
|
||||||
|
|
||||||
if(region <= CFG_REGION_TWN) {
|
Handle fileHandle = 0;
|
||||||
static const char* regionStrings[] = {"JP", "US", "GB", "GB", "HK", "KR", "TW"};
|
if(R_SUCCEEDED(res = FSUSER_OpenFileDirectly(&fileHandle, ARCHIVE_SDMC, fsMakePath(PATH_EMPTY, ""), *fsPath, FS_OPEN_READ, 0))) {
|
||||||
|
u32 bytesRead = 0;
|
||||||
|
res = FSFILE_Read(fileHandle, &bytesRead, 0, seed, sizeof(seed));
|
||||||
|
|
||||||
char url[128];
|
FSFILE_Close(fileHandle);
|
||||||
snprintf(url, 128, "https://kagiya-ctr.cdn.nintendo.net/title/0x%016llX/ext_key?country=%s", titleId, regionStrings[region]);
|
}
|
||||||
|
|
||||||
httpcContext context;
|
util_free_path_utf8(fsPath);
|
||||||
if(R_SUCCEEDED(res = httpcOpenContext(&context, HTTPC_METHOD_GET, url, 1))) {
|
|
||||||
if(R_SUCCEEDED(res = httpcSetSSLOpt(&context, SSLCOPT_DisableVerify)) && R_SUCCEEDED(res = httpcBeginRequest(&context)) && R_SUCCEEDED(res = httpcGetResponseStatusCode(&context, &import_response_code, 0))) {
|
|
||||||
if(import_response_code == 200) {
|
|
||||||
u8 seed[16];
|
|
||||||
|
|
||||||
u32 bytesRead = 0;
|
if(R_FAILED(res)) {
|
||||||
if(R_SUCCEEDED(res = httpcDownloadData(&context, seed, sizeof(seed), &bytesRead))) {
|
u8 region = CFG_REGION_USA;
|
||||||
res = FSUSER_AddSeed(titleId, seed);
|
CFGU_SecureInfoGetRegion(®ion);
|
||||||
|
|
||||||
|
if(region <= CFG_REGION_TWN) {
|
||||||
|
static const char* regionStrings[] = {"JP", "US", "GB", "GB", "HK", "KR", "TW"};
|
||||||
|
|
||||||
|
char url[128];
|
||||||
|
snprintf(url, 128, "https://kagiya-ctr.cdn.nintendo.net/title/0x%016llX/ext_key?country=%s", titleId, regionStrings[region]);
|
||||||
|
|
||||||
|
httpcContext context;
|
||||||
|
if(R_SUCCEEDED(res = httpcOpenContext(&context, HTTPC_METHOD_GET, url, 1))) {
|
||||||
|
if(R_SUCCEEDED(res = httpcSetSSLOpt(&context, SSLCOPT_DisableVerify)) && R_SUCCEEDED(res = httpcBeginRequest(&context)) && R_SUCCEEDED(res = httpcGetResponseStatusCode(&context, &import_response_code, 0))) {
|
||||||
|
if(import_response_code == 200) {
|
||||||
|
u32 bytesRead = 0;
|
||||||
|
res = httpcDownloadData(&context, seed, sizeof(seed), &bytesRead);
|
||||||
|
} else {
|
||||||
|
res = R_FBI_HTTP_RESPONSE_CODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
res = R_FBI_HTTP_RESPONSE_CODE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
httpcCloseContext(&context);
|
httpcCloseContext(&context);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res = R_FBI_OUT_OF_RANGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(R_SUCCEEDED(res)) {
|
||||||
|
res = FSUSER_AddSeed(titleId, seed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
res = R_FBI_OUT_OF_RANGE;
|
res = R_FBI_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user