Make sure the iconCache is aligned properly

This commit is contained in:
Maschell 2022-02-14 19:35:01 +01:00
parent 5e53161cb1
commit c6a700bf51
2 changed files with 15 additions and 6 deletions

View File

@ -42,7 +42,7 @@ DECL_FUNCTION(int, RPX_FSOpenFile, FSClient *client, FSCmdBlock *block, char *pa
if (StringTools::EndsWith(path, iconTex)) {
if (gReplacementInfo.rpxReplacementInfo.isRPXReplaced) {
if (StringTools::EndsWith(path, iconTex)) {
auto *reader = new FileReader(reinterpret_cast<uint8_t *>(gReplacementInfo.rpxReplacementInfo.iconCache), sizeof(gReplacementInfo.rpxReplacementInfo.iconCache));
auto *reader = new FileReader(reinterpret_cast<uint8_t *>(gReplacementInfo.rpxReplacementInfo.iconCache), ICON_SIZE);
*handle = (uint32_t) reader;
return FS_STATUS_OK;
}
@ -144,7 +144,7 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
}
if (reader) {
uint32_t alreadyRead = 0;
uint32_t toRead = sizeof(gReplacementInfo.rpxReplacementInfo.iconCache);
uint32_t toRead = ICON_SIZE;
do {
int read = reader->read(reinterpret_cast<uint8_t *>(&gReplacementInfo.rpxReplacementInfo.iconCache[alreadyRead]), toRead);
if (read <= 0) {
@ -152,7 +152,7 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
}
alreadyRead += read;
toRead -= read;
} while (alreadyRead < sizeof(gReplacementInfo.rpxReplacementInfo.iconCache));
} while (alreadyRead < ICON_SIZE);
delete reader;
} else {
memset(gReplacementInfo.rpxReplacementInfo.iconCache, 0, sizeof(gReplacementInfo.rpxReplacementInfo.iconCache));

View File

@ -1,12 +1,15 @@
#include "utils/utils.h"
#include <coreinit/filesystem.h>
#include <coreinit/mutex.h>
#include <wums.h>
#include <wut.h>
typedef struct MetaInformation_t {
typedef struct WUT_PACKED MetaInformation_t {
char shortname[64];
char longname[64];
char author[64];
} MetaInformation;
WUT_CHECK_SIZE(MetaInformation_t, 0xC0);
typedef struct BundleMountInformation_t {
bool isMounted;
@ -14,12 +17,18 @@ typedef struct BundleMountInformation_t {
char mountedPath[255];
} BundleMountInformation;
typedef struct RPXReplacementInfo_t {
#define ICON_SIZE 65580
typedef struct WUT_PACKED RPXReplacementInfo_t {
bool willRPXBeReplaced;
bool isRPXReplaced;
MetaInformation metaInformation;
char iconCache[65580];
WUT_UNKNOWN_BYTES(0x3E);
char iconCache[ROUNDUP(ICON_SIZE, 0x040)];
} RPXReplacementInfo;
// make sure the iconCache is aligned to 0x40
WUT_CHECK_OFFSET(RPXReplacementInfo, 0x100, iconCache);
typedef enum ContentRedirect_Mode {
CONTENTREDIRECT_NONE,