Skip to content

Commit 1cd6a94

Browse files
committed
copy headers from libnx rather than add to includes
1 parent dac1dcf commit 1cd6a94

File tree

4 files changed

+150
-3
lines changed

4 files changed

+150
-3
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ find_package(libconfig REQUIRED)
1414

1515
add_compile_options(
1616
-DVERSION=\"3.6.0\"
17-
-iquote $ENV{DEVKITPRO}/libnx/include
1817
)
1918

2019
add_executable(${PROJECT_NAME})

common/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ typedef enum
9797

9898
// when building for pc we need to include these separately
9999
#ifndef __SWITCH__
100-
#include "switch/nro.h"
101-
#include "switch/nacp.h"
100+
#include "nro.h"
101+
#include "nacp.h"
102102
#endif
103103

104104
#include "font.h"

common/nacp.h

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* @file nacp.h
3+
* @brief Control.nacp structure / related code for nacp.
4+
* @copyright libnx Authors
5+
*/
6+
7+
#pragma once
8+
9+
/// Language entry. These strings are UTF-8.
10+
typedef struct {
11+
char name[0x200];
12+
char author[0x100];
13+
} NacpLanguageEntry;
14+
15+
/// ApplicationNeighborDetectionGroupConfiguration
16+
typedef struct {
17+
u64 group_id; ///< GroupId
18+
u8 key[0x10];
19+
} NacpApplicationNeighborDetectionGroupConfiguration;
20+
21+
/// NeighborDetectionClientConfiguration
22+
typedef struct {
23+
NacpApplicationNeighborDetectionGroupConfiguration send_group_configuration; ///< SendGroupConfiguration
24+
NacpApplicationNeighborDetectionGroupConfiguration receivable_group_configurations[0x10]; ///< ReceivableGroupConfigurations
25+
} NacpNeighborDetectionClientConfiguration;
26+
27+
/// ApplicationJitConfiguration
28+
typedef struct {
29+
u64 flags; ///< Flags
30+
u64 memory_size; ///< MemorySize
31+
} NacpApplicationJitConfiguration;
32+
33+
/// ns ApplicationControlProperty
34+
typedef struct {
35+
NacpLanguageEntry lang[16]; ///< \ref NacpLanguageEntry
36+
u8 isbn[0x25]; ///< Isbn
37+
u8 startup_user_account; ///< StartupUserAccount
38+
u8 user_account_switch_lock; ///< UserAccountSwitchLock
39+
u8 add_on_content_registration_type; ///< AddOnContentRegistrationType
40+
u32 attribute_flag; ///< AttributeFlag
41+
u32 supported_language_flag; ///< SupportedLanguageFlag
42+
u32 parental_control_flag; ///< ParentalControlFlag
43+
u8 screenshot; ///< Screenshot
44+
u8 video_capture; ///< VideoCapture
45+
u8 data_loss_confirmation; ///< DataLossConfirmation
46+
u8 play_log_policy; ///< PlayLogPolicy
47+
u64 presence_group_id; ///< PresenceGroupId
48+
s8 rating_age[0x20]; ///< RatingAge
49+
char display_version[0x10]; ///< DisplayVersion
50+
u64 add_on_content_base_id; ///< AddOnContentBaseId
51+
u64 save_data_owner_id; ///< SaveDataOwnerId
52+
u64 user_account_save_data_size; ///< UserAccountSaveDataSize
53+
u64 user_account_save_data_journal_size; ///< UserAccountSaveDataJournalSize
54+
u64 device_save_data_size; ///< DeviceSaveDataSize
55+
u64 device_save_data_journal_size; ///< DeviceSaveDataJournalSize
56+
u64 bcat_delivery_cache_storage_size; ///< BcatDeliveryCacheStorageSize
57+
u64 application_error_code_category; ///< ApplicationErrorCodeCategory
58+
u64 local_communication_id[0x8]; ///< LocalCommunicationId
59+
u8 logo_type; ///< LogoType
60+
u8 logo_handling; ///< LogoHandling
61+
u8 runtime_add_on_content_install; ///< RuntimeAddOnContentInstall
62+
u8 runtime_parameter_delivery; ///< RuntimeParameterDelivery
63+
u8 reserved_x30f4[0x2]; ///< Reserved
64+
u8 crash_report; ///< CrashReport
65+
u8 hdcp; ///< Hdcp
66+
u64 pseudo_device_id_seed; ///< SeedForPseudoDeviceId
67+
char bcat_passphrase[0x41]; ///< BcatPassphrase
68+
u8 startup_user_account_option; ///< StartupUserAccountOption
69+
u8 reserved_for_user_account_save_data_operation[0x6]; ///< ReservedForUserAccountSaveDataOperation
70+
u64 user_account_save_data_size_max; ///< UserAccountSaveDataSizeMax
71+
u64 user_account_save_data_journal_size_max; ///< UserAccountSaveDataJournalSizeMax
72+
u64 device_save_data_size_max; ///< DeviceSaveDataSizeMax
73+
u64 device_save_data_journal_size_max; ///< DeviceSaveDataJournalSizeMax
74+
u64 temporary_storage_size; ///< TemporaryStorageSize
75+
u64 cache_storage_size; ///< CacheStorageSize
76+
u64 cache_storage_journal_size; ///< CacheStorageJournalSize
77+
u64 cache_storage_data_and_journal_size_max; ///< CacheStorageDataAndJournalSizeMax
78+
u16 cache_storage_index_max; ///< CacheStorageIndexMax
79+
u8 reserved_x318a[0x6]; ///< Reserved
80+
u64 play_log_queryable_application_id[0x10]; ///< PlayLogQueryableApplicationId
81+
u8 play_log_query_capability; ///< PlayLogQueryCapability
82+
u8 repair_flag; ///< RepairFlag
83+
u8 program_index; ///< ProgramIndex
84+
u8 required_network_service_license_on_launch; ///< RequiredNetworkServiceLicenseOnLaunchFlag
85+
u32 reserved_x3214; ///< Reserved
86+
NacpNeighborDetectionClientConfiguration neighbor_detection_client_configuration; ///< NeighborDetectionClientConfiguration
87+
NacpApplicationJitConfiguration jit_configuration; ///< JitConfiguration
88+
u8 reserved_x33c0[0xc40]; ///< Reserved
89+
} NacpStruct;
90+
91+
/// Get the NacpLanguageEntry from the input nacp corresponding to the current system language (this may fallback to other languages when needed). Output langentry is NULL if none found / content of entry is empty.
92+
/// If you're using ns you may want to use \ref nsGetApplicationDesiredLanguage instead.
93+
Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry);
94+

common/nro.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* @file nro.h
3+
* @brief NRO headers.
4+
* @copyright libnx Authors
5+
*/
6+
7+
#pragma once
8+
9+
#define NROHEADER_MAGIC 0x304f524e
10+
11+
#define NROASSETHEADER_MAGIC 0x54455341
12+
#define NROASSETHEADER_VERSION 0
13+
14+
/// Entry for each segment in the codebin.
15+
typedef struct {
16+
u32 file_off;
17+
u32 size;
18+
} NroSegment;
19+
20+
/// Offset 0x0 in the NRO.
21+
typedef struct {
22+
u32 unused;
23+
u32 mod_offset;
24+
u8 padding[8];
25+
} NroStart;
26+
27+
/// This follows NroStart, the actual nro-header.
28+
typedef struct {
29+
u32 magic;
30+
u32 unk1;
31+
u32 size;
32+
u32 unk2;
33+
NroSegment segments[3];
34+
u32 bss_size;
35+
u32 unk3;
36+
u8 build_id[0x20];
37+
u8 padding[0x20];
38+
} NroHeader;
39+
40+
/// Custom asset section.
41+
typedef struct {
42+
u64 offset;
43+
u64 size;
44+
} NroAssetSection;
45+
46+
/// Custom asset header.
47+
typedef struct {
48+
u32 magic;
49+
u32 version;
50+
NroAssetSection icon;
51+
NroAssetSection nacp;
52+
NroAssetSection romfs;
53+
} NroAssetHeader;
54+

0 commit comments

Comments
 (0)