+++ /dev/null
-#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.
-}
+++ /dev/null
-#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
#include <3ds.h>
#include "patcher.h"
#include "exheader.h"
-#include "ifile.h"
#include "fsldr.h"
#include "fsreg.h"
#include "pxipm.h"
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;
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);
}
-#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)
-#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)
-#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)
-#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)
-#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)
#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);
-#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)
-#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)
-#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)
#include <3ds.h>
#include "patcher.h"
-#include "ifile.h"
+#include "fsldr.h"
#include "internal.h"
#ifndef PATH_MAX
}
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;
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;
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') {
return;
}
-
+/*
static int
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];
}
}
}
-
+*/
static void
adjust_cpu_settings(u64 progId, u8* code, u32 size)
{
}
}
+/*
void
language_emu(u64 progId, u8* code, u32 size)
{
}
}
}
-
+*/
void
overlay_patch(u64 progId, u8* code, u32 size)
{
}
default: // Anything else.
{
- language_emu(progId, text, orig_size);
+ // language_emu(progId, text, orig_size);
break;
}
}