-
Notifications
You must be signed in to change notification settings - Fork 4
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
RandalHoffman
committed
Apr 12, 2021
0 parents
commit e8ea6f4
Showing
33 changed files
with
2,885 additions
and
0 deletions.
There are no files selected for viewing
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,10 @@ | ||
*.nds | ||
*.srl | ||
*.cia | ||
*.3dsx | ||
*.smdh | ||
*.elf | ||
*.bin | ||
*.3ds | ||
.vscode/ | ||
build/ |
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,219 @@ | ||
#--------------------------------------------------------------------------------- | ||
.SUFFIXES: | ||
#--------------------------------------------------------------------------------- | ||
|
||
ifeq ($(strip $(DEVKITARM)),) | ||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM") | ||
endif | ||
|
||
TOPDIR ?= $(CURDIR) | ||
include $(DEVKITARM)/3ds_rules | ||
|
||
#--------------------------------------------------------------------------------- | ||
# TARGET is the name of the output | ||
# BUILD is the directory where object files & intermediate files will be placed | ||
# SOURCES is a list of directories containing source code | ||
# DATA is a list of directories containing data files | ||
# INCLUDES is a list of directories containing header files | ||
# | ||
# NO_SMDH: if set to anything, no SMDH file is generated. | ||
# APP_TITLE is the name of the app stored in the SMDH file (Optional) | ||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional) | ||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional) | ||
# ICON is the filename of the icon (.png), relative to the project folder. | ||
# If not set, it attempts to use one of the following (in this order): | ||
# - <Project name>.png | ||
# - icon.png | ||
# - <libctru folder>/default_icon.png | ||
#--------------------------------------------------------------------------------- | ||
|
||
APP_TITLE := NDS Forwarder Generator | ||
APP_DESCRIPTION := Creates nds forwarders on the home menu | ||
APP_AUTHOR := RandalHoffman | ||
|
||
TARGET := $(notdir $(CURDIR)) | ||
BUILD := build | ||
SOURCES := source | ||
DATA := | ||
INCLUDES := include | ||
GRAPHICS := gfx | ||
ROMFS := romfs | ||
|
||
#--------------------------------------------------------------------------------- | ||
# options for code generation | ||
#--------------------------------------------------------------------------------- | ||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft | ||
|
||
CFLAGS := -g -Wall -O2 -mword-relocations \ | ||
-ffunction-sections \ | ||
$(ARCH) | ||
|
||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS | ||
|
||
CXXFLAGS := $(CFLAGS) -fno-rtti -std=gnu++17 | ||
|
||
ASFLAGS := -g $(ARCH) | ||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) | ||
|
||
LIBS := -lcitro2d -lcitro3d -lctru -lm | ||
|
||
#--------------------------------------------------------------------------------- | ||
# list of directories containing libraries, this must be the top level containing | ||
# include and lib | ||
#--------------------------------------------------------------------------------- | ||
LIBDIRS := $(CTRULIB) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# no real need to edit anything past this point unless you need to add additional | ||
# rules for different file extensions | ||
#--------------------------------------------------------------------------------- | ||
ifneq ($(BUILD),$(notdir $(CURDIR))) | ||
#--------------------------------------------------------------------------------- | ||
|
||
export OUTPUT := $(CURDIR)/$(TARGET) | ||
export TOPDIR := $(CURDIR) | ||
|
||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) | ||
|
||
export DEPSDIR := $(CURDIR)/$(BUILD) | ||
|
||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) | ||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) | ||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) | ||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) | ||
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png))) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# use CXX for linking C++ projects, CC for standard C | ||
#--------------------------------------------------------------------------------- | ||
ifeq ($(strip $(CPPFILES)),) | ||
#--------------------------------------------------------------------------------- | ||
export LD := $(CC) | ||
#--------------------------------------------------------------------------------- | ||
else | ||
#--------------------------------------------------------------------------------- | ||
export LD := $(CXX) | ||
#--------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------- | ||
|
||
export OFILES_SOURCES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) | ||
|
||
export OFILES_BIN := $(addsuffix .o,$(BINFILES)) \ | ||
#$(PNGFILES:.png=.bgr.o) \ | ||
export OFILES := $(OFILES_BIN) $(OFILES_SOURCES) | ||
|
||
export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) #$(PNGFILES:.png=_bgr.h) | ||
|
||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ | ||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ | ||
-I$(CURDIR)/$(BUILD) | ||
|
||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) | ||
|
||
ifeq ($(strip $(ICON)),) | ||
icons := $(wildcard *.png) | ||
ifneq (,$(findstring $(TARGET).png,$(icons))) | ||
export APP_ICON := $(TOPDIR)/$(TARGET).png | ||
else | ||
ifneq (,$(findstring icon.png,$(icons))) | ||
export APP_ICON := $(TOPDIR)/icon.png | ||
endif | ||
endif | ||
else | ||
export APP_ICON := $(TOPDIR)/$(ICON) | ||
endif | ||
|
||
#IMAGEMAGICK := $(shell which convert) | ||
|
||
ifeq ($(strip $(NO_SMDH)),) | ||
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh | ||
endif | ||
|
||
ifneq ($(ROMFS),) | ||
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS) | ||
endif | ||
|
||
.PHONY: $(BUILD) clean all | ||
|
||
#--------------------------------------------------------------------------------- | ||
#ifneq ($(strip $(IMAGEMAGICK)),) | ||
#ifeq ($(findstring System32,$(IMAGEMAGICK)),) | ||
|
||
#HAVE_CONVERT := yes | ||
|
||
#endif | ||
#endif | ||
|
||
#ifeq ($(strip $(HAVE_CONVERT)),yes) | ||
|
||
all: $(BUILD) | ||
|
||
#else | ||
|
||
#all: | ||
# @echo "Image Magick not found!" | ||
# @echo | ||
# @echo "Please install Image Magick from http://www.imagemagick.org/ to build this example" | ||
|
||
#endif | ||
|
||
#--------------------------------------------------------------------------------- | ||
$(BUILD): | ||
@[ -d $@ ] || mkdir -p $@ | ||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile | ||
|
||
#--------------------------------------------------------------------------------- | ||
clean: | ||
@echo clean ... | ||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf | ||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
else | ||
|
||
DEPENDS := $(OFILES:.o=.d) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# main targets | ||
#--------------------------------------------------------------------------------- | ||
ifeq ($(strip $(NO_SMDH)),) | ||
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh | ||
else | ||
$(OUTPUT).3dsx : $(OUTPUT).elf | ||
endif | ||
|
||
$(OFILES_SOURCES) : $(HFILES) | ||
|
||
$(OUTPUT).elf : $(OFILES) | ||
|
||
#--------------------------------------------------------------------------------- | ||
# you need a rule like this for each extension you use as binary data | ||
#--------------------------------------------------------------------------------- | ||
#%.bin.o : %.bin | ||
#--------------------------------------------------------------------------------- | ||
# @echo $(notdir $<) | ||
# @$(bin2o) | ||
|
||
|
||
|
||
#--------------------------------------------------------------------------------- | ||
#%_bgr.h %.bgr.o: %.bgr | ||
#--------------------------------------------------------------------------------- | ||
# @echo $(notdir $<) | ||
# @$(bin2o) | ||
|
||
#--------------------------------------------------------------------------------- | ||
#%.bgr: %.png | ||
#--------------------------------------------------------------------------------- | ||
# @echo $(notdir $<) | ||
# @convert $< -rotate 90 $@ | ||
|
||
#-include $(DEPENDS) | ||
|
||
#--------------------------------------------------------------------------------------- | ||
endif | ||
#--------------------------------------------------------------------------------------- |
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,18 @@ | ||
# NDSForwarder | ||
|
||
DSiWare Template downloaded from http://olmectron.github.io/forwarders/sdcard.(fwd|nds). Thanks to Olmectron for providing templates via their website. | ||
|
||
Thanks to Martin Korth for GBATek, which provided pretty much all the information needed about the nds and dsi formats. | ||
|
||
Thanks to 3DSGuy and everyone else who contributed to CTR Toolkit (of which, make_cia which is used in Olmectron's forwarder3ds app) | ||
|
||
Thanks to RocketRobz and the DS-Homebrew team for all the nds-bootstrap and TWiLightMenu++ stuff. | ||
|
||
Thanks to Oreo639, Piepie62, Fenrir, and everyone else who helped me in my development career. | ||
|
||
Thanks to lifehackerhansol for helping me test | ||
|
||
Finally, thanks to the DevKitPro team for the toolchain (wintermute et al). Without that, homebrew just wouldn't be a thing. | ||
|
||
|
||
Anyone else that I forgot to list, it's not you, it's me. Thank you. My progress is a product of the community and all it gives back. Thank everyone for being a part of it and helping. |
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,96 @@ | ||
#ifndef _AES_H_ | ||
#define _AES_H_ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
#include <stdint.h> | ||
#include <stddef.h> | ||
|
||
// #define the macros below to 1/0 to enable/disable the mode of operation. | ||
// | ||
// CBC enables AES encryption in CBC-mode of operation. | ||
// CTR enables encryption in counter-mode. | ||
// ECB enables the basic ECB 16-byte block algorithm. All can be enabled simultaneously. | ||
|
||
// The #ifndef-guard allows it to be configured before #include'ing or at compile time. | ||
#ifndef CBC | ||
#define CBC 1 | ||
#endif | ||
|
||
#ifndef ECB | ||
#define ECB 0 | ||
#endif | ||
|
||
#ifndef CTR | ||
#define CTR 0 | ||
#endif | ||
|
||
|
||
#define AES128 1 | ||
//#define AES192 1 | ||
//#define AES256 1 | ||
|
||
#define AES_BLOCKLEN 16 // Block length in bytes - AES is 128b block only | ||
|
||
#if defined(AES256) && (AES256 == 1) | ||
#define AES_KEYLEN 32 | ||
#define AES_keyExpSize 240 | ||
#elif defined(AES192) && (AES192 == 1) | ||
#define AES_KEYLEN 24 | ||
#define AES_keyExpSize 208 | ||
#else | ||
#define AES_KEYLEN 16 // Key length in bytes | ||
#define AES_keyExpSize 176 | ||
#endif | ||
|
||
struct AES_ctx | ||
{ | ||
uint8_t RoundKey[AES_keyExpSize]; | ||
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) | ||
uint8_t Iv[AES_BLOCKLEN]; | ||
#endif | ||
}; | ||
|
||
void AES_init_ctx(struct AES_ctx* ctx, const uint8_t* key); | ||
#if (defined(CBC) && (CBC == 1)) || (defined(CTR) && (CTR == 1)) | ||
void AES_init_ctx_iv(struct AES_ctx* ctx, const uint8_t* key, const uint8_t* iv); | ||
void AES_ctx_set_iv(struct AES_ctx* ctx, const uint8_t* iv); | ||
#endif | ||
|
||
#if defined(ECB) && (ECB == 1) | ||
// buffer size is exactly AES_BLOCKLEN bytes; | ||
// you need only AES_init_ctx as IV is not used in ECB | ||
// NB: ECB is considered insecure for most uses | ||
void AES_ECB_encrypt(const struct AES_ctx* ctx, uint8_t* buf); | ||
void AES_ECB_decrypt(const struct AES_ctx* ctx, uint8_t* buf); | ||
|
||
#endif // #if defined(ECB) && (ECB == !) | ||
|
||
|
||
#if defined(CBC) && (CBC == 1) | ||
// buffer size MUST be mutile of AES_BLOCKLEN; | ||
// Suggest https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme | ||
// NOTES: you need to set IV in ctx via AES_init_ctx_iv() or AES_ctx_set_iv() | ||
// no IV should ever be reused with the same key | ||
void AES_CBC_encrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length); | ||
void AES_CBC_decrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length); | ||
|
||
#endif // #if defined(CBC) && (CBC == 1) | ||
|
||
|
||
#if defined(CTR) && (CTR == 1) | ||
|
||
// Same function for encrypting as for decrypting. | ||
// IV is incremented for every block, and used after encryption as XOR-compliment for output | ||
// Suggesting https://en.wikipedia.org/wiki/Padding_(cryptography)#PKCS7 for padding scheme | ||
// NOTES: you need to set IV in ctx with AES_init_ctx_iv() or AES_ctx_set_iv() | ||
// no IV should ever be reused with the same key | ||
void AES_CTR_xcrypt_buffer(struct AES_ctx* ctx, uint8_t* buf, size_t length); | ||
|
||
#endif // #if defined(CTR) && (CTR == 1) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // _AES_H_ |
Oops, something went wrong.