Revert removal of seed file support.

This commit is contained in:
Steven Smith 2016-06-30 15:35:04 -07:00
parent f31f4ccb5f
commit ff8773e0ff

View File

@ -256,8 +256,26 @@ 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;
FS_Path* fsPath = util_make_path_utf8(pathBuf);
if(fsPath != NULL) {
u8 seed[16];
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));
FSFILE_Close(fileHandle);
}
util_free_path_utf8(fsPath);
if(R_FAILED(res)) {
u8 region = CFG_REGION_USA; u8 region = CFG_REGION_USA;
CFGU_SecureInfoGetRegion(&region); CFGU_SecureInfoGetRegion(&region);
@ -271,12 +289,8 @@ Result util_import_seed(u64 titleId) {
if(R_SUCCEEDED(res = httpcOpenContext(&context, HTTPC_METHOD_GET, url, 1))) { 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(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) { if(import_response_code == 200) {
u8 seed[16];
u32 bytesRead = 0; u32 bytesRead = 0;
if(R_SUCCEEDED(res = httpcDownloadData(&context, seed, sizeof(seed), &bytesRead))) { res = httpcDownloadData(&context, seed, sizeof(seed), &bytesRead);
res = FSUSER_AddSeed(titleId, seed);
}
} else { } else {
res = R_FBI_HTTP_RESPONSE_CODE; res = R_FBI_HTTP_RESPONSE_CODE;
} }
@ -287,6 +301,14 @@ Result util_import_seed(u64 titleId) {
} else { } else {
res = R_FBI_OUT_OF_RANGE; res = R_FBI_OUT_OF_RANGE;
} }
}
if(R_SUCCEEDED(res)) {
res = FSUSER_AddSeed(titleId, seed);
}
} else {
res = R_FBI_OUT_OF_MEMORY;
}
return res; return res;
} }