]> Chaos Git - corbenik/corbenik.git/commitdiff
Remove IFile from loader - it's just a wrapper, and uses up two pages for nothing...
authorchaoskagami <chaos.kagami@gmail.com>
Tue, 31 May 2016 08:03:08 +0000 (04:03 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Tue, 31 May 2016 08:03:08 +0000 (04:03 -0400)
13 files changed:
external/loader/source/ifile.c [deleted file]
external/loader/source/ifile.h [deleted file]
external/loader/source/loader.c
external/loader/source/patch/block_cart_update.c
external/loader/source/patch/block_eshop_update.c
external/loader/source/patch/block_nim_update.c
external/loader/source/patch/friends_ver.c
external/loader/source/patch/mset_str.c
external/loader/source/patch/patch.h
external/loader/source/patch/regionfree.c
external/loader/source/patch/ro_sigs.c
external/loader/source/patch/secinfo_sigs.c
external/loader/source/patcher.c

diff --git a/external/loader/source/ifile.c b/external/loader/source/ifile.c
deleted file mode 100644 (file)
index 746b02a..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <3ds.h>
-#include "ifile.h"
-#include "fsldr.h"
-
-// TODO - What exactly is the point of these? Can't we just use FSFILE directly?
-//        These are just shitty wrappers.
-
-Result
-IFile_Open(IFile* file, FS_ArchiveID archiveId, FS_Path archivePath,
-           FS_Path filePath, u32 flags)
-{
-    Result res;
-
-    res = FSLDR_OpenFileDirectly(&file->handle, archiveId, archivePath,
-                                 filePath, flags, 0);
-    file->pos = 0;
-    file->size = 0;
-    return res;
-}
-
-Result
-IFile_Close(IFile* file)
-{
-    return FSFILE_Close(file->handle);
-}
-
-Result
-IFile_GetSize(IFile* file, u64* size)
-{
-    Result res;
-
-    res = FSFILE_GetSize(file->handle, size);
-    file->size = *size;
-    return res;
-}
-
-Result
-IFile_Read(IFile* file, u64* total, void* buffer, u32 len)
-{
-    u32 read;
-    u32 left;
-    char* buf;
-    u64 cur;
-    Result res;
-
-    if (len == 0) {
-        *total = 0;
-        return 0;
-    }
-
-    buf = (char*)buffer;
-    cur = 0;
-    left = len;
-    while (1) {
-        res = FSFILE_Read(file->handle, &read, file->pos, buf, left);
-        if (R_FAILED(res)) {
-            break;
-        }
-
-        cur += read;
-        file->pos += read;
-        if (read == left) {
-            break;
-        }
-        buf += read;
-        left -= read;
-    }
-
-    *total = cur;
-    return res;
-}
-
-Result
-IFile_Write(IFile* file, u64* total, void* buffer, u32 len)
-{
-    return 1; // FIXME - Not yet implemented.
-}
diff --git a/external/loader/source/ifile.h b/external/loader/source/ifile.h
deleted file mode 100644 (file)
index 5cda305..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __IFILE_H
-#define __IFILE_H
-
-#include <3ds/types.h>
-
-typedef struct
-{
-    Handle handle;
-    u64 pos;
-    u64 size;
-} IFile;
-
-Result IFile_Open(IFile* file, FS_ArchiveID archiveId, FS_Path archivePath,
-                  FS_Path filePath, u32 flags);
-Result IFile_Close(IFile* file);
-Result IFile_GetSize(IFile* file, u64* size);
-Result IFile_Read(IFile* file, u64* total, void* buffer, u32 len);
-Result IFile_Write(IFile* file, u64* total, void* buffer, u32 len);
-
-#endif
index 4db617ff53e454695fc81c04d8874aab29a77d31..a50505399edcce3ab05ba7ed207be6ab8af879a5 100644 (file)
@@ -1,7 +1,6 @@
 #include <3ds.h>
 #include "patcher.h"
 #include "exheader.h"
-#include "ifile.h"
 #include "fsldr.h"
 #include "fsreg.h"
 #include "pxipm.h"
@@ -55,12 +54,12 @@ static Result
 load_code(u64 progid, prog_addrs_t* shared, prog_addrs_t* original,
           u64 prog_handle, int is_compressed)
 {
-    IFile file;
+       Handle handle;
     FS_Path archivePath;
     FS_Path path;
     Result res;
     u64 size;
-    u64 total;
+    u32 total;
 
     archivePath.type = PATH_BINARY;
     archivePath.data = &prog_handle;
@@ -70,26 +69,26 @@ load_code(u64 progid, prog_addrs_t* shared, prog_addrs_t* original,
     path.data = CODE_PATH;
     path.size = sizeof(CODE_PATH);
 
-    if (R_FAILED(IFile_Open(&file, ARCHIVE_SAVEDATA_AND_CONTENT2, archivePath,
-                            path, FS_OPEN_READ))) {
+    if (R_FAILED(FSLDR_OpenFileDirectly(&handle, ARCHIVE_SAVEDATA_AND_CONTENT2, archivePath,
+                            path, FS_OPEN_READ, 0))) {
         svcBreak(USERBREAK_ASSERT);
     }
 
     // get file size
-    if (R_FAILED(IFile_GetSize(&file, &size))) {
-        IFile_Close(&file);
+    if (R_FAILED(FSFILE_GetSize(handle, &size))) {
+        FSFILE_Close(handle);
         svcBreak(USERBREAK_ASSERT);
     }
 
     // check size
     if (size > (u64)shared->total_size << 12) {
-        IFile_Close(&file);
+        FSFILE_Close(handle);
         return 0xC900464F;
     }
 
     // read code
-    res = IFile_Read(&file, &total, (void*)shared->text_addr, size);
-    IFile_Close(&file); // done reading
+    res = FSFILE_Read(handle, &total, 0, (void*)shared->text_addr, size);
+    FSFILE_Close(handle); // done reading
     if (R_FAILED(res)) {
         svcBreak(USERBREAK_ASSERT);
     }
index 06e3adbc340423d5ac8ebfd715fe5eee326d6b6c..bf307c8c1e5e81bee485d4f95fca673c9ef61251 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 disable_cart_updates(u64 progId, u8* code, u32 size)
index edcaf31ba9820abf5bac171ec168cd65387f85eb..d240154915ddb5dc57de4207a3f6ba6f9fd2dcb6 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 disable_eshop_updates(u64 progId, u8* code, u32 size)
index 682b8f5c58a9e35bd2d99306ec516017263941ba..eee7d5397300f215b67853bc549ac844b0112f45 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 disable_nim_updates(u64 progId, u8* code, u32 size)
index ac8cfae162d5cd057f45658e18ea716d37797ae5..fc50ecb7174e40b598a066f1998eb40c02f51071 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 fake_friends_version(u64 progId, u8* code, u32 size)
index daad227e016a0e8e43025c850835206a044c2bd8..96908792f6fceb9ad38ccc9cf739e787eecfb950 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 settings_string(u64 progId, u8* code, u32 size)
index 90d8c2f99c8645efec8d6d0c4a30786e4ed542f7..a9ed7ed39b285c94587dd1f4197255f0d39e37cf 100644 (file)
@@ -1,6 +1,16 @@
 #ifndef __PATCH_PATCH_H
 #define __PATCH_PATCH_H
 
+#include <3ds.h>
+#include "../patcher.h"
+
+#ifndef PATH_MAX
+#define PATH_MAX 255
+#define _MAX_LFN 255
+#endif
+#include "../config.h"
+#include "../../../../source/patch_format.h"
+
 void disable_cart_updates(u64 progId, u8* code, u32 size);
 void disable_eshop_updates(u64 progId, u8* code, u32 size);
 void disable_nim_updates(u64 progId, u8* code, u32 size);
index ee821ce581463d5141b7b5647ba67dff9d37c1f7..a50a00bc129d3c413aac2f24232c233e49818be9 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 region_patch(u64 progId, u8* code, u32 size)
index c6c0fd1c9b7c43ea0a6fa20c3949777e3227151a..c9985a204ec0858a511b7a66fd7a5f38fbaf02d0 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 ro_sigpatch(u64 progId, u8* code, u32 size)
index 11b37dfe78ce89164cf6df3d08cc2d8c953183bc..c7bd706c87682a9052ed18c30589744ed8195b29 100644 (file)
@@ -1,13 +1,4 @@
-#include <3ds.h>
-#include "../patcher.h"
-#include "../ifile.h"
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#define _MAX_LFN 255
-#endif
-#include "../config.h"
-#include "../../../../source/patch_format.h"
+#include "patch.h"
 
 void
 secureinfo_sigpatch(u64 progId, u8* code, u32 size)
index 115c85cf18d46189b0baa860b541325068b8e17c..655911d26238f84e349706dd548fe51cd16da4c2 100644 (file)
@@ -1,6 +1,6 @@
 #include <3ds.h>
 #include "patcher.h"
-#include "ifile.h"
+#include "fsldr.h"
 #include "internal.h"
 
 #ifndef PATH_MAX
@@ -93,7 +93,7 @@ strnlen(const char* string, size_t maxlen)
 }
 
 static int
-fileOpen(IFile* file, FS_ArchiveID id, const char* path, int flags)
+fileOpen(Handle* file, FS_ArchiveID id, const char* path, int flags)
 {
     FS_Path apath;
     FS_Path ppath;
@@ -106,7 +106,7 @@ fileOpen(IFile* file, FS_ArchiveID id, const char* path, int flags)
     ppath.data = path;
     ppath.size = strnlen(path, PATH_MAX) + 1;
 
-    return IFile_Open(file, id, apath, ppath, flags);
+    return FSLDR_OpenFileDirectly(file, id, apath, ppath, flags, 0);
 }
 
 static struct config_file config;
@@ -115,26 +115,25 @@ static int failed_load_config = 1;
 void
 load_config()
 {
-    static IFile file;
-    static u64 total;
+    static Handle file;
+    static u32 total;
 
     // Open file.
-    if (!R_SUCCEEDED(
-            fileOpen(&file, ARCHIVE_SDMC, PATH_CONFIG, FS_OPEN_READ))) {
+    if (!R_SUCCEEDED(fileOpen(&file, ARCHIVE_SDMC, PATH_CONFIG, FS_OPEN_READ))) {
         // Failed to open.
         return;
     }
 
     // Read file.
     if (!R_SUCCEEDED(
-            IFile_Read(&file, &total, &config, sizeof(struct config_file)))) {
-        IFile_Close(&file); // Read to memory.
+            FSFILE_Read(file, &total, 0, &config, sizeof(struct config_file)))) {
+        FSFILE_Close(file); // Read to memory.
 
         // Failed to read.
         return;
     }
 
-    IFile_Close(&file); // Read to memory.
+    FSFILE_Close(file); // Read to memory.
 
     if (config.magic[0] != 'O' || config.magic[1] != 'V' ||
         config.magic[2] != 'A' || config.magic[3] != 'N') {
@@ -152,7 +151,7 @@ load_config()
 
     return;
 }
-
+/*
 static int
 loadTitleLocaleConfig(u64 progId, u8* regionId, u8* languageId)
 {
@@ -282,10 +281,10 @@ loadTitleLocaleConfig(u64 progId, u8* regionId, u8* languageId)
 static u8*
 getCfgOffsets(u8* code, u32 size, u32* CFGUHandleOffset)
 {
-    /* HANS:
-       Look for error code which is known to be stored near cfg:u handle
-       this way we can find the right candidate
-       (handle should also be stored right after end of candidate function) */
+    // HANS:
+    // Look for error code which is known to be stored near cfg:u handle
+    // this way we can find the right candidate
+    // (handle should also be stored right after end of candidate function)
 
     u32 n = 0, possible[24];
 
@@ -408,7 +407,7 @@ patchCfgGetRegion(u8* code, u32 size, u8 regionId, u32 CFGUHandleOffset)
         }
     }
 }
-
+*/
 static void
 adjust_cpu_settings(u64 progId, u8* code, u32 size)
 {
@@ -435,6 +434,7 @@ adjust_cpu_settings(u64 progId, u8* code, u32 size)
     }
 }
 
+/*
 void
 language_emu(u64 progId, u8* code, u32 size)
 {
@@ -464,7 +464,7 @@ language_emu(u64 progId, u8* code, u32 size)
         }
     }
 }
-
+*/
 void
 overlay_patch(u64 progId, u8* code, u32 size)
 {
@@ -541,7 +541,7 @@ patch_text(u64 progId, u8* text, u32 size, u32 orig_size)
         }
         default: // Anything else.
         {
-            language_emu(progId, text, orig_size);
+            // language_emu(progId, text, orig_size);
             break;
         }
     }