Skip to content

Commit

Permalink
First ps4 ported code
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Nov 15, 2021
1 parent 5a997e3 commit 54b69ba
Show file tree
Hide file tree
Showing 131 changed files with 25,614 additions and 0 deletions.
90 changes: 90 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Package metadata.
TITLE := Apollo Save Tool
VERSION := 1.00
TITLE_ID := BREW00080
CONTENT_ID := IV0000-BREW00080_00-AUDIOWAVEX000000

# Libraries linked into the ELF.
LIBS := -lc -lkernel -lc++ -lSceAudioOut -lSceUserService -lorbis2d -lSceVideoOut -lSceGnmDriver -lSceSysmodule -lSceFreeType -lScePad -ldbglogger -lpolarssl -lz

# Additional compile flags.
EXTRAFLAGS := -DAPOLLO_ENABLE_LOGGING

# Asset and module directories.
ASSETS := $(wildcard assets/**/*)
LIBMODULES := $(wildcard sce_module/*)

# You likely won't need to touch anything below this point.

# Root vars
TOOLCHAIN := $(OO_PS4_TOOLCHAIN)
#PROJDIR := $(shell basename $(CURDIR))
PROJDIR := source
COMMONDIR := $(TOOLCHAIN)/samples/_common
#INTDIR := $(PROJDIR)/x64/Debug
INTDIR := build/x64/Debug

# Define objects to build
CFILES := $(wildcard $(PROJDIR)/*.c)
CPPFILES := $(wildcard $(PROJDIR)/*.cpp)
COMMONFILES := $(wildcard $(COMMONDIR)/*.cpp)
OBJS := $(patsubst $(PROJDIR)/%.c, $(INTDIR)/%.o, $(CFILES)) $(patsubst $(PROJDIR)/%.cpp, $(INTDIR)/%.o, $(CPPFILES))

# Define final C/C++ flags
CFLAGS := -cc1 -triple x86_64-pc-freebsd-elf -munwind-tables -fuse-init-array -debug-info-kind=limited -debugger-tuning=gdb -emit-obj $(EXTRAFLAGS) -isysroot $(TOOLCHAIN) -isystem $(TOOLCHAIN)/include -Iinclude
CXXFLAGS := $(CFLAGS) -isystem $(TOOLCHAIN)/include/c++/v1
LDFLAGS := -m elf_x86_64 -pie --script $(TOOLCHAIN)/link.x --eh-frame-hdr -L$(TOOLCHAIN)/lib $(LIBS) $(TOOLCHAIN)/lib/crt1.o

# Create the intermediate directory incase it doesn't already exist.
_unused := $(shell mkdir -p $(INTDIR))

# Check for linux vs macOS and account for clang/ld path
UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Linux)
CC := clang
CCX := clang++
LD := ld.lld
CDIR := linux
endif
ifeq ($(UNAME_S),Darwin)
CC := /usr/local/opt/llvm/bin/clang
CCX := /usr/local/opt/llvm/bin/clang++
LD := /usr/local/opt/llvm/bin/ld.lld
CDIR := macos
endif

all: $(CONTENT_ID).pkg

$(CONTENT_ID).pkg: pkg.gp4
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core pkg_build $< .

pkg.gp4: eboot.bin sce_sys/about/right.sprx sce_sys/param.sfo sce_sys/icon0.png $(LIBMODULES) $(ASSETS)
$(TOOLCHAIN)/bin/$(CDIR)/create-gp4 -out $@ --content-id=$(CONTENT_ID) --files "$^"

sce_sys/param.sfo: Makefile
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_new $@
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ APP_TYPE --type Integer --maxsize 4 --value 1
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ APP_VER --type Utf8 --maxsize 8 --value '$(VERSION)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ ATTRIBUTE --type Integer --maxsize 4 --value 0
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ CATEGORY --type Utf8 --maxsize 4 --value 'gd'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ CONTENT_ID --type Utf8 --maxsize 48 --value '$(CONTENT_ID)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ DOWNLOAD_DATA_SIZE --type Integer --maxsize 4 --value 0
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ SYSTEM_VER --type Integer --maxsize 4 --value 0
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ TITLE --type Utf8 --maxsize 128 --value '$(TITLE)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ TITLE_ID --type Utf8 --maxsize 12 --value '$(TITLE_ID)'
$(TOOLCHAIN)/bin/$(CDIR)/PkgTool.Core sfo_setentry $@ VERSION --type Utf8 --maxsize 8 --value '$(VERSION)'

eboot.bin: $(INTDIR) $(OBJS)
$(LD) $(INTDIR)/*.o -o $(INTDIR)/$(PROJDIR).elf $(LDFLAGS)
$(TOOLCHAIN)/bin/$(CDIR)/create-eboot -in=$(INTDIR)/$(PROJDIR).elf -out=$(INTDIR)/$(PROJDIR).oelf --paid 0x3800000000000011

$(INTDIR)/%.o: $(PROJDIR)/%.c
$(CC) $(CFLAGS) -o $@ $<

$(INTDIR)/%.o: $(PROJDIR)/%.cpp
$(CCX) $(CXXFLAGS) -o $@ $<

clean:
rm -f $(CONTENT_ID).pkg pkg.gp4 pkg/sce_sys/param.sfo eboot.bin \
$(INTDIR)/$(PROJDIR).elf $(INTDIR)/$(PROJDIR).oelf $(OBJS)
Empty file added assets/audio/.gitkeep
Empty file.
Empty file added assets/fonts/.gitkeep
Empty file.
Binary file added assets/images/bgimg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/buk_scr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_about.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_bup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_cheats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_db.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_empty.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_hdd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_opt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_sav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_usb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cat_warning.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/cheat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/circle_error_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/circle_error_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/circle_loading_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/circle_loading_seek.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/column_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/edit_shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/footer_ico_circle.png
Binary file added assets/images/footer_ico_cross.png
Binary file added assets/images/footer_ico_square.png
Binary file added assets/images/footer_ico_triangle.png
Binary file added assets/images/header_dot.png
Binary file added assets/images/header_line.png
Binary file added assets/images/help.png
Binary file added assets/images/jar_about.png
Binary file added assets/images/jar_about_hover.png
Binary file added assets/images/jar_bup.png
Binary file added assets/images/jar_bup_hover.png
Binary file added assets/images/jar_db.png
Binary file added assets/images/jar_db_hover.png
Binary file added assets/images/jar_hdd.png
Binary file added assets/images/jar_hdd_hover.png
Binary file added assets/images/jar_opt.png
Binary file added assets/images/jar_opt_hover.png
Binary file added assets/images/jar_trophy.png
Binary file added assets/images/jar_trophy_hover.png
Binary file added assets/images/jar_usb.png
Binary file added assets/images/jar_usb_hover.png
Binary file added assets/images/logo.png
Binary file added assets/images/logo_text.png
Binary file added assets/images/mark_arrow.png
Binary file added assets/images/mark_line.png
Binary file added assets/images/mark_line_nowork.png
Binary file added assets/images/opt_off.png
Binary file added assets/images/opt_on.png
Binary file added assets/images/scroll_bg.png
Binary file added assets/images/scroll_lock.png
Binary file added assets/images/tag_apply.png
Binary file added assets/images/tag_lock.png
Binary file added assets/images/tag_own.png
Binary file added assets/images/tag_pce.png
Binary file added assets/images/tag_ps1.png
Binary file added assets/images/tag_ps2.png
Binary file added assets/images/tag_ps3.png
Binary file added assets/images/tag_psp.png
Binary file added assets/images/tag_psv.png
Binary file added assets/images/tag_transfer.png
Binary file added assets/images/tag_warning.png
Binary file added assets/images/tag_zip.png
Empty file added assets/misc/.gitkeep
Empty file.
Empty file added assets/videos/.gitkeep
Empty file.
88 changes: 88 additions & 0 deletions include/backend.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#ifndef _PFD__BACKEND_H_
#define _PFD__BACKEND_H_

#include "types.h"
#include "list.h"
#include "pfd.h"

#define PFDTOOL_VERSION_BASE "0.2.3"
#define PFDTOOL_VERSION PFDTOOL_VERSION_BASE

#define PFDTOOL_CONFIG_GLOBAL "global.conf"
#define PFDTOOL_CONFIG_GAMES "games.conf"

#ifdef __cplusplus
extern "C" {
#endif

#define BACKEND_UPDATE_FLAG_NONE (0)
#define BACKEND_UPDATE_FLAG_PARTIAL (1U << 0)

#define BACKEND_VALIDATE_FLAG_NONE (0)
#define BACKEND_VALIDATE_FLAG_PARTIAL (1U << 0)

typedef struct secure_file_id_s {
char file_path[MAX_PATH];
char file_name[PFD_ENTRY_NAME_SIZE];
u8 secure_file_id[PFD_PARAM_SFO_KEY_SIZE];
u8 real_hash[PFD_HASH_SIZE];
u8 *data;
u64 data_size;
int found;
} secure_file_id_t;

typedef struct structure_status_s {
int top;
int bottom;
} structure_status_t;

typedef struct entry_status_s {
int signature;
} entry_status_t;

typedef struct file_status_s {
char *file_name;
int file;
int cid;
int dhk_cid2;
int aid_uid;
} file_status_t;

typedef struct entry_info_s {
u64 index;
char *file_name;
u64 file_size;
} entry_info_t;

typedef struct backend_s {
pfd_config_t *config;
list_t *secure_file_ids;
pfd_context_t *pfd;

union {
struct {
list_t *entries;
} list;
struct {
structure_status_t structure;
entry_status_t *entries;
file_status_t *files;
} validate;
} storage;
} backend_t;

backend_t * backend_initialize(pfd_config_t *config, list_t *secure_file_ids, const char *directory_path);
int backend_shutdown(backend_t *ctx);

int backend_cmd_list(backend_t *ctx);
int backend_cmd_check(backend_t *ctx, u32 options);
int backend_cmd_update(backend_t *ctx, u32 options);
int backend_cmd_encrypt(backend_t *ctx, list_t *file_names);
int backend_cmd_decrypt(backend_t *ctx, list_t *file_names);
int backend_cmd_brute(backend_t *ctx, const char *file_path, u64 file_offset, s64 advance_offset, list_t *secure_file_ids);

#ifdef __cplusplus
}
#endif

#endif /* !_PFD__BACKEND_H_ */
41 changes: 41 additions & 0 deletions include/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef _COMMON_H_
#define _COMMON_H_

#define SUCCESS 0
#define FAILED -1

//----------------------------------------
//String Utils
//----------------------------------------
int is_char_integer(char c);
int is_char_letter(char c);

//----------------------------------------
//FILE UTILS
//----------------------------------------

int file_exists(const char *path);
int dir_exists(const char *path);
int unlink_secure(const char *path);
int mkdirs(const char* dir);
int copy_file(const char* input, const char* output);
int copy_directory(const char* startdir, const char* inputdir, const char* outputdir);
int clean_directory(const char* inputdir);

//----------------------------------------
//CONSOLE ID UTILS
//----------------------------------------

int ss_aim_get_device_id(uint8_t *idps);
int ss_aim_get_open_psid(uint8_t *psid);
int sys_ss_get_open_psid(uint64_t psid[2]);
int is_ps3hen(void);

//----------------------------------------
//POWER UTILS
//----------------------------------------

int sys_shutdown();
int sys_reboot();

#endif
8 changes: 8 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef _CONFIG_H_
#define _CONFIG_H_

#include "types.h"

int parse_config_file(const char *file_path, int (*handler)(void *, const char *, const char *, const char *), void *user);

#endif /* !_CONFIG_H_ */
Loading

0 comments on commit 54b69ba

Please sign in to comment.