Update for latest libnx
This commit is contained in:
parent
f26331a828
commit
a9d4fb7830
@ -36,11 +36,15 @@ typedef union {
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "launch.h"
|
#include "launch.h"
|
||||||
#include "nro.h"
|
|
||||||
#include "nanojpeg.h"
|
#include "nanojpeg.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
|
|
||||||
|
// when building for pc we need to include nro.h separately
|
||||||
|
#ifndef SWITCH
|
||||||
|
#include "nro.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void menuStartup();
|
void menuStartup();
|
||||||
void menuLoop();
|
void menuLoop();
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ bool fileExists(const char* path) {
|
|||||||
|
|
||||||
static bool menuEntryLoadEmbeddedIcon(menuEntry_s* me) {
|
static bool menuEntryLoadEmbeddedIcon(menuEntry_s* me) {
|
||||||
NroHeader header;
|
NroHeader header;
|
||||||
AssetHeader asset_header;
|
NroAssetHeader asset_header;
|
||||||
|
|
||||||
FILE* f = fopen(me->path, "rb");
|
FILE* f = fopen(me->path, "rb");
|
||||||
if (!f) return false;
|
if (!f) return false;
|
||||||
@ -50,8 +50,8 @@ static bool menuEntryLoadEmbeddedIcon(menuEntry_s* me) {
|
|||||||
fseek(f, header.size, SEEK_SET);
|
fseek(f, header.size, SEEK_SET);
|
||||||
|
|
||||||
if (fread(&asset_header, sizeof(asset_header), 1, f) != 1
|
if (fread(&asset_header, sizeof(asset_header), 1, f) != 1
|
||||||
|| asset_header.magic != ASSETHEADER_MAGICNUM
|
|| asset_header.magic != NROASSETHEADER_MAGIC
|
||||||
|| asset_header.version > ASSETHEADER_VERSION
|
|| asset_header.version > NROASSETHEADER_VERSION
|
||||||
|| asset_header.icon.offset == 0
|
|| asset_header.icon.offset == 0
|
||||||
|| asset_header.icon.size == 0)
|
|| asset_header.icon.size == 0)
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ static bool menuEntryLoadEmbeddedIcon(menuEntry_s* me) {
|
|||||||
|
|
||||||
static bool menuEntryLoadEmbeddedNacp(menuEntry_s* me) {
|
static bool menuEntryLoadEmbeddedNacp(menuEntry_s* me) {
|
||||||
NroHeader header;
|
NroHeader header;
|
||||||
AssetHeader asset_header;
|
NroAssetHeader asset_header;
|
||||||
|
|
||||||
FILE* f = fopen(me->path, "rb");
|
FILE* f = fopen(me->path, "rb");
|
||||||
if (!f) return false;
|
if (!f) return false;
|
||||||
@ -90,8 +90,8 @@ static bool menuEntryLoadEmbeddedNacp(menuEntry_s* me) {
|
|||||||
fseek(f, header.size, SEEK_SET);
|
fseek(f, header.size, SEEK_SET);
|
||||||
|
|
||||||
if (fread(&asset_header, sizeof(asset_header), 1, f) != 1
|
if (fread(&asset_header, sizeof(asset_header), 1, f) != 1
|
||||||
|| asset_header.magic != ASSETHEADER_MAGICNUM
|
|| asset_header.magic != NROASSETHEADER_MAGIC
|
||||||
|| asset_header.version > ASSETHEADER_VERSION
|
|| asset_header.version > NROASSETHEADER_VERSION
|
||||||
|| asset_header.nacp.offset == 0
|
|| asset_header.nacp.offset == 0
|
||||||
|| asset_header.nacp.size == 0)
|
|| asset_header.nacp.size == 0)
|
||||||
{
|
{
|
||||||
|
53
common/nro.h
53
common/nro.h
@ -1,43 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* @file nro.h
|
||||||
|
* @brief NRO headers.
|
||||||
|
* @copyright libnx Authors
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define NROHEADER_MAGICNUM 0x304f524e
|
#define NROHEADER_MAGIC 0x304f524e
|
||||||
|
|
||||||
#define ASSETHEADER_MAGICNUM 0x54455341
|
#define NROASSETHEADER_MAGIC 0x54455341
|
||||||
#define ASSETHEADER_VERSION 0
|
#define NROASSETHEADER_VERSION 0
|
||||||
|
|
||||||
|
/// Entry for each segment in the codebin.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 FileOff;
|
u32 file_off;
|
||||||
u32 Size;
|
u32 size;
|
||||||
} NsoSegment;
|
} NroSegment;
|
||||||
|
|
||||||
|
/// Offset 0x0 in the NRO.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 unused;
|
u32 unused;
|
||||||
u32 modOffset;
|
u32 mod_offset;
|
||||||
u8 Padding[8];
|
u8 padding[8];
|
||||||
} NroStart;
|
} NroStart;
|
||||||
|
|
||||||
|
/// This follows NroStart, the actual nro-header.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 Magic;
|
u32 magic;
|
||||||
u32 Unk1;
|
u32 unk1;
|
||||||
u32 size;
|
u32 size;
|
||||||
u32 Unk2;
|
u32 unk2;
|
||||||
NsoSegment Segments[3];
|
NroSegment segments[3];
|
||||||
u32 bssSize;
|
u32 bss_size;
|
||||||
u32 Unk3;
|
u32 unk3;
|
||||||
u8 BuildId[0x20];
|
u8 build_id[0x20];
|
||||||
u8 Padding[0x20];
|
u8 padding[0x20];
|
||||||
} NroHeader;
|
} NroHeader;
|
||||||
|
|
||||||
|
/// Custom asset section.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u64 offset;
|
u64 offset;
|
||||||
u64 size;
|
u64 size;
|
||||||
} AssetSection;
|
} NroAssetSection;
|
||||||
|
|
||||||
|
/// Custom asset header.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 magic;
|
u32 magic;
|
||||||
u32 version;
|
u32 version;
|
||||||
AssetSection icon;
|
NroAssetSection icon;
|
||||||
AssetSection nacp;
|
NroAssetSection nacp;
|
||||||
AssetSection romfs;
|
NroAssetSection romfs;
|
||||||
} AssetHeader;
|
} NroAssetHeader;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user