mirror of
https://gitlab.com/Theopse/fbi-i18n-zh.git
synced 2025-04-06 03:58:02 +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;
|
||||
|
||||
Result util_import_seed(u64 titleId) {
|
||||
char pathBuf[64];
|
||||
snprintf(pathBuf, 64, "/fbi/seed/%016llX.dat", titleId);
|
||||
|
||||
Result res = 0;
|
||||
|
||||
u8 region = CFG_REGION_USA;
|
||||
CFGU_SecureInfoGetRegion(®ion);
|
||||
FS_Path* fsPath = util_make_path_utf8(pathBuf);
|
||||
if(fsPath != NULL) {
|
||||
u8 seed[16];
|
||||
|
||||
if(region <= CFG_REGION_TWN) {
|
||||
static const char* regionStrings[] = {"JP", "US", "GB", "GB", "HK", "KR", "TW"};
|
||||
Handle fileHandle = 0;
|
||||
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];
|
||||
snprintf(url, 128, "https://kagiya-ctr.cdn.nintendo.net/title/0x%016llX/ext_key?country=%s", titleId, regionStrings[region]);
|
||||
FSFILE_Close(fileHandle);
|
||||
}
|
||||
|
||||
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) {
|
||||
u8 seed[16];
|
||||
util_free_path_utf8(fsPath);
|
||||
|
||||
u32 bytesRead = 0;
|
||||
if(R_SUCCEEDED(res = httpcDownloadData(&context, seed, sizeof(seed), &bytesRead))) {
|
||||
res = FSUSER_AddSeed(titleId, seed);
|
||||
if(R_FAILED(res)) {
|
||||
u8 region = CFG_REGION_USA;
|
||||
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 {
|
||||
res = R_FBI_OUT_OF_RANGE;
|
||||
res = R_FBI_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
Loading…
x
Reference in New Issue
Block a user