mirror of
https://github.com/CTCaer/hekate.git
synced 2024-11-22 18:06:40 +00:00
bdk: remove sd mounts from ianos and check if sd is mounted in sd ops
This commit is contained in:
parent
73d38e1183
commit
ce8d1eca91
2 changed files with 13 additions and 10 deletions
|
@ -74,19 +74,16 @@ uintptr_t ianos_loader(char *path, elfType_t type, void *moduleConfig)
|
||||||
el_ctx ctx;
|
el_ctx ctx;
|
||||||
uintptr_t epaddr = 0;
|
uintptr_t epaddr = 0;
|
||||||
|
|
||||||
if (!sd_mount())
|
|
||||||
goto elfLoadFinalOut;
|
|
||||||
|
|
||||||
// Read library.
|
// Read library.
|
||||||
fileBuf = sd_file_read(path, NULL);
|
fileBuf = sd_file_read(path, NULL);
|
||||||
|
|
||||||
if (!fileBuf)
|
if (!fileBuf)
|
||||||
goto elfLoadFinalOut;
|
goto out;
|
||||||
|
|
||||||
ctx.pread = _ianos_read_cb;
|
ctx.pread = _ianos_read_cb;
|
||||||
|
|
||||||
if (el_init(&ctx))
|
if (el_init(&ctx))
|
||||||
goto elfLoadFinalOut;
|
goto out;
|
||||||
|
|
||||||
// Set our relocated library's buffer.
|
// Set our relocated library's buffer.
|
||||||
switch (type & 0xFFFF)
|
switch (type & 0xFFFF)
|
||||||
|
@ -100,15 +97,15 @@ uintptr_t ianos_loader(char *path, elfType_t type, void *moduleConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!elfBuf)
|
if (!elfBuf)
|
||||||
goto elfLoadFinalOut;
|
goto out;
|
||||||
|
|
||||||
// Load and relocate library.
|
// Load and relocate library.
|
||||||
ctx.base_load_vaddr = ctx.base_load_paddr = (uintptr_t)elfBuf;
|
ctx.base_load_vaddr = ctx.base_load_paddr = (uintptr_t)elfBuf;
|
||||||
if (el_load(&ctx, _ianos_alloc_cb))
|
if (el_load(&ctx, _ianos_alloc_cb))
|
||||||
goto elfFreeOut;
|
goto out_free;
|
||||||
|
|
||||||
if (el_relocate(&ctx))
|
if (el_relocate(&ctx))
|
||||||
goto elfFreeOut;
|
goto out_free;
|
||||||
|
|
||||||
// Launch.
|
// Launch.
|
||||||
epaddr = ctx.ehdr.e_entry + (uintptr_t)elfBuf;
|
epaddr = ctx.ehdr.e_entry + (uintptr_t)elfBuf;
|
||||||
|
@ -116,11 +113,11 @@ uintptr_t ianos_loader(char *path, elfType_t type, void *moduleConfig)
|
||||||
|
|
||||||
_ianos_call_ep(ep, moduleConfig);
|
_ianos_call_ep(ep, moduleConfig);
|
||||||
|
|
||||||
elfFreeOut:
|
out_free:
|
||||||
free(fileBuf);
|
free(fileBuf);
|
||||||
elfBuf = NULL;
|
elfBuf = NULL;
|
||||||
fileBuf = NULL;
|
fileBuf = NULL;
|
||||||
|
|
||||||
elfLoadFinalOut:
|
out:
|
||||||
return epaddr;
|
return epaddr;
|
||||||
}
|
}
|
|
@ -210,6 +210,9 @@ bool sd_is_gpt()
|
||||||
void *sd_file_read(const char *path, u32 *fsize)
|
void *sd_file_read(const char *path, u32 *fsize)
|
||||||
{
|
{
|
||||||
FIL fp;
|
FIL fp;
|
||||||
|
if (!sd_get_card_mounted())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (f_open(&fp, path, FA_READ) != FR_OK)
|
if (f_open(&fp, path, FA_READ) != FR_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -236,6 +239,9 @@ int sd_save_to_file(void *buf, u32 size, const char *filename)
|
||||||
{
|
{
|
||||||
FIL fp;
|
FIL fp;
|
||||||
u32 res = 0;
|
u32 res = 0;
|
||||||
|
if (!sd_get_card_mounted())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
res = f_open(&fp, filename, FA_CREATE_ALWAYS | FA_WRITE);
|
res = f_open(&fp, filename, FA_CREATE_ALWAYS | FA_WRITE);
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue