From 63558ee3f99908720a16bf229a711f7a075313ad Mon Sep 17 00:00:00 2001 From: cooolgamer <64099608+cooolgamer@users.noreply.github.com> Date: Sat, 23 Mar 2024 12:35:50 +0100 Subject: [PATCH] Add a special message for Kor if hm patch isn't installed --- include/fs.h | 2 ++ source/fs.c | 11 +++++++++++ source/main.c | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/include/fs.h b/include/fs.h index d140e17..a304a93 100644 --- a/include/fs.h +++ b/include/fs.h @@ -48,4 +48,6 @@ Result buf_to_file(u32 size, FS_Path path, FS_Archive archive, char *buf); void remake_file(FS_Path path, FS_Archive archive, u32 size); void save_zip_to_sd(char * filename, u32 size, char * buf, EntryMode mode); +Result korPatchInstalled(Result archive_result); + #endif diff --git a/source/fs.c b/source/fs.c index 55fba5b..2519882 100644 --- a/source/fs.c +++ b/source/fs.c @@ -468,3 +468,14 @@ void save_zip_to_sd(char * filename, u32 size, char * buf, EntryMode mode) remake_file(path, ArchiveSD, size); buf_to_file(size, path, ArchiveSD, buf); } + +Result korPatchInstalled(Result archive_result){ + Handle handle; + Result res = 0; + if (R_FAILED(res = FSUSER_OpenFile(&handle, ArchiveSD, fsMakePath(PATH_ASCII, "/luma/titles/000400300000A902/code.ips"), FS_OPEN_READ, 0))) return res; + FSFILE_Close(handle); + // The following file is needed to get the "change theme" button on the Home Menu allowing to create extdata, not needed if extdata is already created + if (R_FAILED(archive_result) && R_FAILED(res = FSUSER_OpenFile(&handle, ArchiveSD, fsMakePath(PATH_ASCII, "/luma/titles/000400300000A902/romfs/petit_LZ.bin"), FS_OPEN_READ, 0))) return res; + FSFILE_Close(handle); + return 0; +} diff --git a/source/main.c b/source/main.c index 91426fc..43f742c 100644 --- a/source/main.c +++ b/source/main.c @@ -362,6 +362,12 @@ int main(void) load_lists(lists); #endif + u8 regionCode; + Result korCheck = 0; + CFGU_SecureInfoGetRegion(®ionCode); + if(regionCode == 5) + korCheck = korPatchInstalled(archive_result); + EntryMode current_mode = MODE_THEMES; bool preview_mode = false; @@ -380,6 +386,12 @@ int main(void) return 0; } + if (R_FAILED(korCheck) && current_mode == MODE_THEMES){ + throw_error("Korean HOME Menu patch not found.\nYou must install it in order\nto use themes.", ERROR_LEVEL_ERROR); + quit = true; + continue; + } + #ifndef CITRA_MODE if(R_FAILED(archive_result) && current_mode == MODE_THEMES) {