1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-26 19:52:11 +00:00

Add use of wildcard "*" for loading kips from a folder

This commit is contained in:
Kostas Missos 2018-09-24 23:47:35 +03:00
parent 381d5c9236
commit 1392e6eaf4
7 changed files with 82 additions and 24 deletions

View file

@ -37,6 +37,7 @@ There are four possible type of entries. "**[ ]**": Boot entry, "**{ }**": Capti
| bootwait=3 | 0: Disable (It also disables bootlogo. Having **VOL-** pressed since injection goes to menu.), #: Time to wait for **VOL-** to enter menu. | | bootwait=3 | 0: Disable (It also disables bootlogo. Having **VOL-** pressed since injection goes to menu.), #: Time to wait for **VOL-** to enter menu. |
| customlogo=0 | 0: Use default hekate bootlogo, 1: Use bootlogo.bmp. | | customlogo=0 | 0: Use default hekate bootlogo, 1: Use bootlogo.bmp. |
| verification=2 | 0: Disable Backup/Restore verification, 1: Sparse (block based, fast and not 100% reliable), 2: Full (sha256 based, slow and 100% reliable). | | verification=2 | 0: Disable Backup/Restore verification, 1: Sparse (block based, fast and not 100% reliable), 2: Full (sha256 based, slow and 100% reliable). |
| autohosoff=1 | If woke up from HOS via an rtc alarm, power off completely.|
| backlight=100 | Screen backlight level. 0-255. | | backlight=100 | Screen backlight level. 0-255. |
@ -49,6 +50,7 @@ There are four possible type of entries. "**[ ]**": Boot entry, "**{ }**": Capti
| secmon={SD path} | Replaces the security monitor binary | | secmon={SD path} | Replaces the security monitor binary |
| kernel={SD path} | Replaces the kernel binary | | kernel={SD path} | Replaces the kernel binary |
| kip1={SD path} | Replaces/Adds kernel initial process. Multiple can be set. | | kip1={SD path} | Replaces/Adds kernel initial process. Multiple can be set. |
| kip1={SD folder}/* | Loads every .kip/.kip1 inside a folder. Compatible with single kip1 keys. |
| kip1patch=patchname| Enables a kip1 patch. Specify with multiple lines and/or as CSV. Implemented patches right now are nosigchk,nogc | | kip1patch=patchname| Enables a kip1 patch. Specify with multiple lines and/or as CSV. Implemented patches right now are nosigchk,nogc |
| fullsvcperm=1 | Disables SVC verification (full services permission) | | fullsvcperm=1 | Disables SVC verification (full services permission) |
| debugmode=1 | Enables Debug mode | | debugmode=1 | Enables Debug mode |

View file

@ -45,7 +45,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
if (is_dir) if (is_dir)
{ {
filelist = dirlist(filename); filelist = dirlist(filename, "*.ini");
if (!filelist) if (!filelist)
{ {
free(filename); free(filename);

View file

@ -38,6 +38,7 @@
#include "../config/config.h" #include "../config/config.h"
#include "../mem/mc.h" #include "../mem/mc.h"
#include "../soc/fuse.h" #include "../soc/fuse.h"
#include "../utils/dirlist.h"
#include "../gfx/gfx.h" #include "../gfx/gfx.h"
extern gfx_ctxt_t gfx_ctxt; extern gfx_ctxt_t gfx_ctxt;
@ -367,14 +368,61 @@ static int _config_kernel(launch_ctxt_t *ctxt, const char *value)
static int _config_kip1(launch_ctxt_t *ctxt, const char *value) static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
{ {
FIL fp; FIL fp;
if (f_open(&fp, value, FA_READ) != FR_OK)
return 0; if (!memcmp(value + strlen(value) - 1, "*", 1))
merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t)); {
mkip1->kip1 = malloc(f_size(&fp)); char *dir = (char *)malloc(256);
f_read(&fp, mkip1->kip1, f_size(&fp), NULL); memcpy(dir, value, strlen(value) + 1);
DPRINTF("Loaded kip1 from SD (size %08X)\n", f_size(&fp));
f_close(&fp); u32 dirlen = 0;
list_append(&ctxt->kip1_list, &mkip1->link); dir[strlen(dir) - 2] = 0;
char *filelist = dirlist(dir, "*.kip*");
memcpy(dir + strlen(dir), "/", 2);
dirlen = strlen(dir);
u32 i = 0;
if (filelist)
{
while (true)
{
if (!filelist[i * 256])
break;
memcpy(dir + dirlen, &filelist[i * 256], strlen(&filelist[i * 256]) + 1);
if (f_open(&fp, dir, FA_READ))
{
free(dir);
free(filelist);
return 0;
}
merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t));
mkip1->kip1 = malloc(f_size(&fp));
f_read(&fp, mkip1->kip1, f_size(&fp), NULL);
DPRINTF("Loaded kip1 from SD (size %08X)\n", f_size(&fp));
f_close(&fp);
list_append(&ctxt->kip1_list, &mkip1->link);
i++;
}
}
free(dir);
free(filelist);
}
else
{
if (f_open(&fp, value, FA_READ))
return 0;
merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t));
mkip1->kip1 = malloc(f_size(&fp));
f_read(&fp, mkip1->kip1, f_size(&fp), NULL);
DPRINTF("Loaded kip1 from SD (size %08X)\n", f_size(&fp));
f_close(&fp);
list_append(&ctxt->kip1_list, &mkip1->link);
}
return 1; return 1;
} }

View file

@ -33,7 +33,7 @@
/ 2: Enable with LF-CRLF conversion. */ / 2: Enable with LF-CRLF conversion. */
#define FF_USE_FIND 0 #define FF_USE_FIND 1
/* This option switches filtered directory read functions, f_findfirst() and /* This option switches filtered directory read functions, f_findfirst() and
/ f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */ / f_findnext(). (0:Disable, 1:Enable 2:Enable with matching altname[] too) */

View file

@ -1968,7 +1968,7 @@ void launch_tools(u8 type)
else else
memcpy(dir, "bootloader/libtools", 20); memcpy(dir, "bootloader/libtools", 20);
filelist = dirlist(dir); filelist = dirlist(dir, NULL);
u32 i = 0; u32 i = 0;

View file

@ -21,7 +21,7 @@
#include "../mem/heap.h" #include "../mem/heap.h"
#include "../utils/types.h" #include "../utils/types.h"
char *dirlist(char *directory) char *dirlist(const char *directory, const char *pattern)
{ {
u8 max_entries = 61; u8 max_entries = 61;
@ -33,7 +33,7 @@ char *dirlist(char *directory)
char *dir_entries = (char *)calloc(max_entries, 256); char *dir_entries = (char *)calloc(max_entries, 256);
char *temp = (char *)calloc(1, 256); char *temp = (char *)calloc(1, 256);
if (!f_opendir(&dir, directory)) if (!pattern && !f_opendir(&dir, directory))
{ {
for (;;) for (;;)
{ {
@ -47,22 +47,30 @@ char *dirlist(char *directory)
if (k > (max_entries - 1)) if (k > (max_entries - 1))
break; break;
} }
else
continue;
} }
f_closedir(&dir); f_closedir(&dir);
if (!k)
{
free(temp);
free(dir_entries);
return NULL;
}
} }
else else if (pattern && !f_findfirst(&dir, &fno, directory, pattern) && fno.fname[0])
{
do
{
if (!(fno.fattrib & AM_DIR))
{
memcpy(dir_entries + (k * 256), fno.fname, strlen(fno.fname) + 1);
k++;
if (k > (max_entries - 1))
break;
}
res = f_findnext(&dir, &fno);
} while (fno.fname[0] && !res);
f_closedir(&dir);
}
if (!k)
{ {
free(temp); free(temp);
free(dir_entries); free(dir_entries);
return NULL; return NULL;
} }

View file

@ -16,4 +16,4 @@
#include "../utils/types.h" #include "../utils/types.h"
char *dirlist(char *directory); char *dirlist(const char *directory, const char *pattern);