-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
The-4n
committed
Sep 19, 2018
0 parents
commit 82f6582
Showing
905 changed files
with
197,202 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/* | ||
* Copyright 2001-2004 Unicode, Inc. | ||
* | ||
* Disclaimer | ||
* | ||
* This source code is provided as is by Unicode, Inc. No claims are | ||
* made as to fitness for any particular purpose. No warranties of any | ||
* kind are expressed or implied. The recipient agrees to determine | ||
* applicability of information provided. If this file has been | ||
* purchased on magnetic or optical media from Unicode, Inc., the | ||
* sole remedy for any claim will be exchange of defective media | ||
* within 90 days of receipt. | ||
* | ||
* Limitations on Rights to Redistribute This Code | ||
* | ||
* Unicode, Inc. hereby grants the right to freely use the information | ||
* supplied in this file in the creation of products supporting the | ||
* Unicode Standard, and to make copies of this file in any form | ||
* for internal or external distribution as long as this notice | ||
* remains attached. | ||
*/ | ||
|
||
|
||
#ifndef ConvertUTF_INCLUDED | ||
#define ConvertUTF_INCLUDED | ||
|
||
/* --------------------------------------------------------------------- | ||
Conversions between UTF32, UTF-16, and UTF-8. Header file. | ||
Several funtions are included here, forming a complete set of | ||
conversions between the three formats. UTF-7 is not included | ||
here, but is handled in a separate source file. | ||
Each of these routines takes pointers to input buffers and output | ||
buffers. The input buffers are const. | ||
Each routine converts the text between *sourceStart and sourceEnd, | ||
putting the result into the buffer between *targetStart and | ||
targetEnd. Note: the end pointers are *after* the last item: e.g. | ||
*(sourceEnd - 1) is the last item. | ||
The return result indicates whether the conversion was successful, | ||
and if not, whether the problem was in the source or target buffers. | ||
(Only the first encountered problem is indicated.) | ||
After the conversion, *sourceStart and *targetStart are both | ||
updated to point to the end of last text successfully converted in | ||
the respective buffers. | ||
Input parameters: | ||
sourceStart - pointer to a pointer to the source buffer. | ||
The contents of this are modified on return so that | ||
it points at the next thing to be converted. | ||
targetStart - similarly, pointer to pointer to the target buffer. | ||
sourceEnd, targetEnd - respectively pointers to the ends of the | ||
two buffers, for overflow checking only. | ||
These conversion functions take a ConversionFlags argument. When this | ||
flag is set to strict, both irregular sequences and isolated surrogates | ||
will cause an error. When the flag is set to lenient, both irregular | ||
sequences and isolated surrogates are converted. | ||
Whether the flag is strict or lenient, all illegal sequences will cause | ||
an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>, | ||
or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code | ||
must check for illegal sequences. | ||
When the flag is set to lenient, characters over 0x10FFFF are converted | ||
to the replacement character; otherwise (when the flag is set to strict) | ||
they constitute an error. | ||
Output parameters: | ||
The value "sourceIllegal" is returned from some routines if the input | ||
sequence is malformed. When "sourceIllegal" is returned, the source | ||
value will point to the illegal value that caused the problem. E.g., | ||
in UTF-8 when a sequence is malformed, it points to the start of the | ||
malformed sequence. | ||
Author: Mark E. Davis, 1994. | ||
Rev History: Rick McGowan, fixes & updates May 2001. | ||
Fixes & updates, Sept 2001. | ||
------------------------------------------------------------------------ */ | ||
|
||
/* --------------------------------------------------------------------- | ||
The following 4 definitions are compiler-specific. | ||
The C standard does not guarantee that wchar_t has at least | ||
16 bits, so wchar_t is no less portable than unsigned short! | ||
All should be unsigned values to avoid sign extension during | ||
bit mask & shift operations. | ||
------------------------------------------------------------------------ */ | ||
|
||
typedef unsigned long UTF32; /* at least 32 bits */ | ||
typedef unsigned short UTF16; /* at least 16 bits */ | ||
typedef unsigned char UTF8; /* typically 8 bits */ | ||
typedef unsigned char Boolean; /* 0 or 1 */ | ||
|
||
/* Some fundamental constants */ | ||
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD | ||
#define UNI_MAX_BMP (UTF32)0x0000FFFF | ||
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF | ||
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF | ||
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF | ||
|
||
typedef enum { | ||
conversionOK, /* conversion successful */ | ||
sourceExhausted, /* partial character in source, but hit end */ | ||
targetExhausted, /* insuff. room in target for conversion */ | ||
sourceIllegal /* source sequence is illegal/malformed */ | ||
} ConversionResult; | ||
|
||
typedef enum { | ||
strictConversion = 0, | ||
lenientConversion | ||
} ConversionFlags; | ||
|
||
/* This is for C++ and does no harm in C */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
ConversionResult ConvertUTF8toUTF16 ( | ||
const UTF8** sourceStart, const UTF8* sourceEnd, | ||
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); | ||
|
||
ConversionResult ConvertUTF16toUTF8 ( | ||
const UTF16** sourceStart, const UTF16* sourceEnd, | ||
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); | ||
|
||
ConversionResult ConvertUTF8toUTF32 ( | ||
const UTF8** sourceStart, const UTF8* sourceEnd, | ||
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); | ||
|
||
ConversionResult ConvertUTF32toUTF8 ( | ||
const UTF32** sourceStart, const UTF32* sourceEnd, | ||
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags); | ||
|
||
ConversionResult ConvertUTF16toUTF32 ( | ||
const UTF16** sourceStart, const UTF16* sourceEnd, | ||
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags); | ||
|
||
ConversionResult ConvertUTF32toUTF16 ( | ||
const UTF32** sourceStart, const UTF32* sourceEnd, | ||
UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags); | ||
|
||
Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
/* --------------------------------------------------------------------- */ | ||
|
||
#endif /* ConvertUTF_INCLUDED */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ISC License | ||
|
||
Copyright (c) 2018, SciresM | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ISC License | ||
|
||
Copyright (c) 2018, SciresM | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Copyright 2017 libnx Authors | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
include config.mk | ||
|
||
.PHONY: clean | ||
|
||
INCLUDE = -I ./mbedtls/include | ||
LIBDIR = ./mbedtls/library | ||
CFLAGS += -D_BSD_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE -D__USE_MINGW_ANSI_STDIO=1 -D_FILE_OFFSET_BITS=64 | ||
|
||
all: | ||
cd mbedtls && $(MAKE) lib | ||
$(MAKE) hacbrewpack | ||
|
||
.c.o: | ||
$(CC) $(INCLUDE) -c $(CFLAGS) -o $@ $< | ||
|
||
hacbrewpack: sha.o aes.o extkeys.o pki.o utils.o main.o filepath.o ConvertUTF.o nca.o romfs.o pfs0.o ivfc.o nacp.o cnmt.o | ||
$(CC) -o $@ $^ $(LDFLAGS) -L $(LIBDIR) | ||
|
||
aes.o: aes.h types.h | ||
|
||
extkeys.o: extkeys.h types.h settings.h | ||
|
||
filepath.o: filepath.c types.h | ||
|
||
main.o: main.c pki.h types.h version.h | ||
|
||
pki.o: pki.h aes.h types.h | ||
|
||
nca.o: nca.h | ||
|
||
romfs.o: romfs.h | ||
|
||
pfs0.o: pfs0.h | ||
|
||
cnmt.o: cnmt.h | ||
|
||
nacp.o: nacp.h | ||
|
||
ivfc.o: ivfc.h | ||
|
||
sha.o: sha.h types.h | ||
|
||
utils.o: utils.h types.h | ||
|
||
ConvertUTF.o: ConvertUTF.h | ||
|
||
clean: | ||
rm -f *.o hacbrewpack hacbrewpack.exe | ||
|
||
clean_full: | ||
rm -f *.o hacbrewpack hacbrewpack.exe | ||
cd mbedtls && $(MAKE) clean | ||
|
||
dist: clean_full | ||
$(eval HACBREWPACKVER = $(shell grep '\bHACBREWPACK_VERSION\b' version.h \ | ||
| cut -d' ' -f3 \ | ||
| sed -e 's/"//g')) | ||
mkdir hacbrewpack-$(HACBREWPACKVER) | ||
cp -R *.c *.h config.mk.template Makefile README.md LICENSE mbedtls hacbrewpack-$(HACBREWPACKVER) | ||
tar czf hacbrewpack-$(HACBREWPACKVER).tar.gz hacbrewpack-$(HACBREWPACKVER) | ||
rm -r hacbrewpack-$(HACBREWPACKVER) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# hacBrewPack | ||
|
||
 | ||
|
||
hacBrewPack is a tool for creating Nintendo Switch NCAs (Nintendo Content Archive) from homebrews and pack them into NSPs (Nintendo Submission Package) | ||
|
||
Thanks: SciresM, yellows8, SwitchBrew | ||
|
||
## Usage | ||
You should place your keyset file with "keys.dat" filename in the same folder as hacBewPack | ||
Alternatively, You can use -k or --keyset option to load your keyset file | ||
Required keys are: | ||
|
||
Key Name | Description | ||
-------- | ----------- | ||
header_key | NCA Header Key | ||
key_area_key_application_xx | Application key area encryption keys | ||
|
||
You need to compile homebrew with proper makefile, you can use the one in template folder | ||
Compiled homebrew must have the following files: | ||
``` | ||
build\exefs\main | ||
build\exefs\main.npdm | ||
[TARGET].nacp | ||
``` | ||
You must place created 'main' and 'main.npdm' files in exefs folder, you can find them in build/exefs | ||
You must place created nacp file with 'control.nacp' filename in control folder | ||
You should place your icon with "icon_{Language}.dat" file name in control folder, "icon_AmericanEnglish.dat" is the default one if you don't manually edit your nacp | ||
Check [switchbrew](http://switchbrew.org/index.php/Settings_services#LanguageCode) for more info about language names | ||
Your icon file format must be JPEG with 256x256 dimensions | ||
If you have problems with icon, try to make it with Adobe Photoshop or inject Adobe Photoshop exif data to your icon file | ||
If you don't put your icon in control folder, you'll see a general icon after installing nsp (i don't recommend this) | ||
"logo" folder should contain "NintendoLogo.png" and "StartupMovie.gif", they'll appear when the app is loading | ||
Both files are not licensed according to [switchbrew](http://switchbrew.org/index.php/NCA_Content_FS) but i didn't include them anyway, You can also replace these files with custom ones | ||
You can use --nologo if you don't have any custom logo and you don't have the original ones, as the result switch will show a black screen without nintendo logo at top left and switch animation on bottom right | ||
CLI options: | ||
``` | ||
*nix: ./hacbrewpack [options...] | ||
Windows: .\hacbrewpack [options...] | ||
Usage: hackbrewpack [options...] | ||
Options: | ||
-k, --keyset Set keyset filepath, default filepath is ./keys.dat | ||
-h, --help Display usage | ||
--tempdir Set temp directory filepath, default filepath is ./hacbrewpack_temp/ | ||
--ncadir Set output nca directory path, default path is ./hacbrewpack_nca/ | ||
--nspdir Set output nsp directory path, default path is ./hacbrewpack_nsp/ | ||
--exefsdir Set program exefs directory path, default path is ./exefs/ | ||
--romfsdir Set program romfs directory path, default path is ./romfs/ | ||
--logodir Set program logo directory path, default path is ./logo/ | ||
--controldir Set control romfs directory path, default path is ./control/ | ||
--noromfs Skips creating program romfs section | ||
--nologo Skips creating program logo section | ||
``` | ||
Also check template folder for default folder structure, makefile and npdm json | ||
|
||
**Delete nca(hacbrewpack_nca) and temp(hacbrewpack_temp) folders before start or you may have bad nsp** | ||
|
||
## Licensing | ||
|
||
This software is licensed under the terms of the ISC License. | ||
You can find a copy of the license in the LICENSES file. | ||
Portions of project HacBrewPack are parts of other projects, make sure to check LICENSES folderw |
Oops, something went wrong.