2010-09-19 01:04:39 +02:00
|
|
|
#ifndef NANDTITLE_H
|
|
|
|
#define NANDTITLE_H
|
|
|
|
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <sys/stat.h>
|
2010-09-19 15:03:16 +02:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
2010-09-19 01:04:39 +02:00
|
|
|
|
|
|
|
#include "wstring.hpp"
|
2010-09-19 15:03:16 +02:00
|
|
|
using namespace std;
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
|
|
|
|
#define TITLE_UPPER(x) ((u32)((x) >> 32))
|
|
|
|
#define TITLE_LOWER(x) ((u32)(x))
|
|
|
|
|
|
|
|
#define TITLE_1(x) ((u8)((x) >> 8))
|
|
|
|
#define TITLE_2(x) ((u8)((x) >> 16))
|
|
|
|
#define TITLE_3(x) ((u8)((x) >> 24))
|
|
|
|
#define TITLE_4(x) ((u8)((x) >> 32))
|
|
|
|
#define TITLE_5(x) ((u8)((x) >> 40))
|
|
|
|
#define TITLE_6(x) ((u8)((x) >> 48))
|
|
|
|
#define TITLE_7(x) ((u8)((x) >> 56))
|
2010-09-19 01:04:39 +02:00
|
|
|
|
|
|
|
#define IMET_MAX_NAME_LEN 0x2a
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
#define IMET_OFFSET 0x40
|
|
|
|
#define IMET_SIGNATURE 0x494d4554
|
|
|
|
#define DOWNLOADED_CHANNELS 0x00010001
|
|
|
|
#define SYSTEM_CHANNELS 0x00010002
|
|
|
|
#define RF_NEWS_CHANNEL 0x48414741
|
|
|
|
#define RF_FORECAST_CHANNEL 0x48414641
|
2010-09-19 01:04:39 +02:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
u8 zeroes1[0x40];
|
|
|
|
u32 sig; // "IMET"
|
|
|
|
u32 unk1;
|
|
|
|
u32 unk2;
|
|
|
|
u32 filesizes[3];
|
|
|
|
u32 unk3;
|
|
|
|
u16 name_japanese[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_english[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_german[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_french[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_spanish[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_italian[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_dutch[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_simp_chinese[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_trad_chinese[IMET_MAX_NAME_LEN];
|
|
|
|
u16 name_korean[IMET_MAX_NAME_LEN];
|
|
|
|
u8 zeroes2[0x24c];
|
|
|
|
u8 md5[0x10];
|
2010-09-19 01:04:39 +02:00
|
|
|
} IMET;
|
|
|
|
|
|
|
|
class NandTitle
|
|
|
|
{
|
2011-07-26 00:28:22 +02:00
|
|
|
public:
|
|
|
|
NandTitle();
|
|
|
|
~NandTitle();
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
s32 Get();
|
|
|
|
u64 At(u32 i);
|
|
|
|
int IndexOf(u64 tid);
|
|
|
|
u32 Count()
|
|
|
|
{
|
|
|
|
return titleIds.size();
|
|
|
|
}
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
const char* NameOf(u64 tid);
|
|
|
|
const char* NameFromIndex(u32 i);
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u16 VersionOf(u64 tid);
|
|
|
|
u16 VersionFromIndex(u32 i);
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u32 CountType(u32 type);
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u32 SetType(u32 upper);
|
|
|
|
u64 Next();
|
|
|
|
void ResetCounter();
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
void AsciiTID(u64 tid, char* out);
|
|
|
|
void AsciiFromIndex(u32 i, char* out);
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
bool Exists(u64 tid);
|
|
|
|
bool ExistsFromIndex(u32 i);
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u64 FindU64(const char *s);
|
|
|
|
u64 FindU32(const char *s);
|
2010-09-19 12:53:24 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
s32 GetTicketViews(u64 tid, tikview **outbuf, u32 *outlen);
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u64 operator[](u32 i) { return At(i); }
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-11-12 19:14:09 +01:00
|
|
|
bool GetName(u64 tid, int language, wchar_t* name);
|
2012-05-06 12:59:58 +02:00
|
|
|
|
|
|
|
tmd* GetTMD(u64 tid);
|
2011-11-12 19:14:09 +01:00
|
|
|
|
2011-12-22 23:44:48 +01:00
|
|
|
static int LoadFileFromNand(const char *filepath, u8 **outbuffer, u32 *outfilesize);
|
|
|
|
static int ExtractFile(const char *nandPath, const char *filepath);
|
|
|
|
static int ExtractDir(const char *wiipath, const char *filepath);
|
2011-07-26 00:28:22 +02:00
|
|
|
private:
|
2011-09-24 01:49:18 +02:00
|
|
|
static int InternalExtractDir(char *nandPath, std::string &filepath);
|
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
std::vector<u64> titleIds;
|
|
|
|
std::map<u64, string> NameList;
|
2010-09-19 01:04:39 +02:00
|
|
|
|
2011-07-26 00:28:22 +02:00
|
|
|
u32 currentIndex;
|
|
|
|
u32 currentType;
|
2010-09-19 01:04:39 +02:00
|
|
|
};
|
|
|
|
|
2010-09-24 15:46:32 +02:00
|
|
|
extern NandTitle NandTitles;
|
|
|
|
|
2010-09-19 01:04:39 +02:00
|
|
|
#endif // NANDTITLE_H
|