mirror of
https://github.com/CTCaer/hekate
synced 2024-11-16 00:49:27 +00:00
[sept] Auto update sept payload via update.bin
This will check if payload.bin is the same version with update.bin
This commit is contained in:
parent
f911fab9f2
commit
50d4cbbda1
1 changed files with 29 additions and 1 deletions
|
@ -344,10 +344,38 @@ int launch_payload(char *path, bool update)
|
|||
f_close(&fp);
|
||||
free(path);
|
||||
|
||||
|
||||
// Check for updated version.
|
||||
if (update)
|
||||
{
|
||||
u8 *update_ft = calloc(1, 6);
|
||||
|
||||
bool update_sept = true;
|
||||
if (!f_open(&fp, "sept/payload.bin", FA_READ | FA_WRITE))
|
||||
{
|
||||
memset(update_ft, 0, 6);
|
||||
f_lseek(&fp, f_size(&fp) - 6);
|
||||
f_read(&fp, update_ft, 6, NULL);
|
||||
f_close(&fp);
|
||||
update_ft[4] -= '0';
|
||||
update_ft[5] -= '0';
|
||||
if (*(u32 *)update_ft == 0x43544349)
|
||||
{
|
||||
if (update_ft[4] == BLVERSIONMJ && update_ft[5] == BLVERSIONMN)
|
||||
update_sept = false;
|
||||
}
|
||||
else
|
||||
update_sept = false;
|
||||
}
|
||||
|
||||
if (update_sept)
|
||||
{
|
||||
if (!f_open(&fp, "sept/payload.bin", FA_CREATE_ALWAYS | FA_WRITE))
|
||||
{
|
||||
f_write(&fp, buf, size, NULL);
|
||||
f_close(&fp);
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(update_ft, buf + size - 6, 6);
|
||||
update_ft[4] -= '0';
|
||||
update_ft[5] -= '0';
|
||||
|
|
Loading…
Reference in a new issue