Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix and improve documentation #3

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/opt/OpenOrbis-PS4-Toolchain/**"
],
"defines": [],
"macFrameworkPath": [
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"compilerPath": "/opt/homebrew/opt/llvm/bin/clang",
"cStandard": "c17",
"cppStandard": "c++98",
"intelliSenseMode": "linux-clang-x86"
}
],
"version": 4
}
88 changes: 88 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Package metadata.
TITLE := Remote Package Installer (OOSDK Port)
VERSION := 1.01
TITLE_ID := KPBR01111
CONTENT_ID := IV0000-KPBR01111_00-AAAAAAAAAAAAAAAA

# Libraries linked into the ELF.
LIBS := -lc -lkernel -lc++ -lSceUserService -lSceSystemService -lSceNet -lSceHttp -lSceBgft -lSceAppInstUtil -lSceSsl -lSceSysmodule -lSceNetCtl -lSceJson -lSceNpUtility -lSceNpCommon

# Additional compile flags.
#EXTRAFLAGS :=

# 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 := RPI
COMMONDIR := $(TOOLCHAIN)/samples/_common
INTDIR := $(PROJDIR)/x64/Debug

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

# Define final C/C++ flags
CFLAGS := --target=x86_64-pc-freebsd12-elf -fPIC -funwind-tables -c $(EXTRAFLAGS) -isysroot $(TOOLCHAIN) -isystem $(TOOLCHAIN)/include
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 := /opt/homebrew/opt/llvm/bin/clang
CCX := /opt/homebrew/opt/llvm/bin/clang++
LD := /opt/homebrew/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 sce_sys/pic0.png sce_sys/pic1.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-fself -in=$(INTDIR)/$(PROJDIR).elf -out=$(INTDIR)/$(PROJDIR).oelf --eboot "eboot.bin" --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)
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
# ps4_remote_pkg_installer-OOSDK
This is a OOSDK port of flat's ps4_remote_pkg_installer, all credit goes to them and their amazing work!

# NOTES
- Some functions are not in OOSDK yet(:tm:) so i worked around this by manually importing them.
This is a OOSDK port of flat's ps4_remote_pkg_installer, all credit goes to them and their amazing work!

## Building

A visual studio project has been included for building on Windows. On Linux, a makefile has been included.

To build this project, the developer will need clang, which is provided in the [toolchain](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain). The `OO_PS4_TOOLCHAIN` environment variable will also need to be set to the root directory of the SDK installation.

__Windows__
Open the Visual Studio project and build, or run the batch file from command prompt or powershell with the following command:

```bash
.\build.bat .\x64\Debug "RPI" "%OO_PS4_TOOLCHAIN%\\RPI"
```

__Linux__
Run the makefile.

```bash
make
```

__MacOS__
Run the makefile.

```bash
brew install llvm
sudo OO_PS4_TOOLCHAIN=/opt/OpenOrbis-PS4-Toolchain make
```

## NOTES

- The default port is 12801
- Some freeBSD net functions where giving issue with printing debug info out, so i swapped these to the sceNet* versions as they seemed to work.
- if you have ran the orginal remote package installer it will cause a port conflict and this one will fail to function, restart your unit and only run this
- WINDOWS building only for the time being

## Thanks

- [OpenOrbis/OpenOrbis-PS4-Toolchain](https://github.com/OpenOrbis/OpenOrbis-PS4-Toolchain)
- [flatz/ps4_remote_pkg_installer](https://github.com/flatz/ps4_remote_pkg_installer)
4 changes: 2 additions & 2 deletions RPI/build.bat
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ SETLOCAL EnableDelayedExpansion

Rem Package information
set PKG_TITLE="Remote Package Installer (OOSDK Port)"
set PKG_VERSION="01.00"
set PKG_VERSION="01.01"
set PKG_ASSETS="assets"
set PKG_TITLE_ID="KPBR01111"
set PKG_CONTENT_ID="IV0000-KPBR01111_00-AAAAAAAAAAAAAAAA"
@@ -79,7 +79,7 @@ set asset_videos_files=
for %%f in (assets\\videos\\*) do set asset_videos_files=!asset_videos_files! assets/videos/%%~nxf

Rem Create gp4
%OO_PS4_TOOLCHAIN%\bin\windows\create-gp4.exe -out pkg.gp4 --content-id=%PKG_CONTENT_ID% --files "eboot.bin sce_sys/about/right.sprx sce_sys/param.sfo sce_sys/icon0.png %module_files% %asset_audio_files% %asset_fonts_files% %asset_images_files% %asset_misc_files% %asset_videos_files%"
%OO_PS4_TOOLCHAIN%\bin\windows\create-gp4.exe -out pkg.gp4 --content-id=%PKG_CONTENT_ID% --files "eboot.bin sce_sys/about/right.sprx sce_sys/param.sfo sce_sys/icon0.png sce_sys/pic0.png sce_sys/pic1.png %module_files% %asset_audio_files% %asset_fonts_files% %asset_images_files% %asset_misc_files% %asset_videos_files%"

Rem Create pkg
%OO_PS4_TOOLCHAIN%\bin\windows\PkgTool.Core.exe pkg_build pkg.gp4 .
21 changes: 15 additions & 6 deletions RPI/http.c
Original file line number Diff line number Diff line change
@@ -14,6 +14,15 @@

#define USER_AGENT "Download/1.00"

typedef enum SceHttpsFlag {
SCE_HTTPS_FLAG_SERVER_VERIFY = (0x01U),
SCE_HTTPS_FLAG_CLIENT_VERIFY = (0x02U),
SCE_HTTPS_FLAG_CN_CHECK = (0x04U),
SCE_HTTPS_FLAG_NOT_AFTER_CHECK = (0x08U),
SCE_HTTPS_FLAG_NOT_BEFORE_CHECK = (0x10U),
SCE_HTTPS_FLAG_KNOWN_CA_CHECK = (0x20U)
} SceHttpsFlag;

struct download_file_cb_args {
uint8_t* data;
uint64_t data_size;
@@ -127,7 +136,7 @@ bool http_get_file_size(const char* url, uint64_t* total_size) {
}


ret = do_request(url, ORBIS_HTTP_METHOD_GET, NULL, 0, NULL, 0, &download_file_cb, &args);
ret = do_request(url, ORBIS_METHOD_GET, NULL, 0, NULL, 0, &download_file_cb, &args);
if (ret) {
goto err;
}
@@ -182,7 +191,7 @@ bool http_download_file(const char* url, uint8_t** data, uint64_t* data_size, ui
++header_count;
}

ret = do_request(url, ORBIS_HTTP_METHOD_GET, NULL, 0, headers, header_count, &download_file_cb, &args);
ret = do_request(url, ORBIS_METHOD_GET, NULL, 0, headers, header_count, &download_file_cb, &args);
if (ret) {
goto err_data_free;
}
@@ -353,7 +362,7 @@ static int download_file_cb(void* arg, int req_id, int status_code, uint64_t con
}

if (!is_good_status(status_code)) {
ret = ORBIS_HTTP_ERROR_NOT_FOUND;
ret = 404;
goto err;
}

@@ -452,9 +461,9 @@ static int do_request(const char* url, int method, const void* data, size_t data
}
req_id = ret;

ssl_flags = ORBIS_HTTPS_FLAG_SERVER_VERIFY | ORBIS_HTTPS_FLAG_CLIENT_VERIFY;
ssl_flags |= ORBIS_HTTPS_FLAG_CN_CHECK | ORBIS_HTTPS_FLAG_KNOWN_CA_CHECK;
ssl_flags |= ORBIS_HTTPS_FLAG_NOT_AFTER_CHECK | ORBIS_HTTPS_FLAG_NOT_BEFORE_CHECK;
ssl_flags = SCE_HTTPS_FLAG_SERVER_VERIFY | SCE_HTTPS_FLAG_CLIENT_VERIFY;
ssl_flags |= SCE_HTTPS_FLAG_CN_CHECK | SCE_HTTPS_FLAG_KNOWN_CA_CHECK;
ssl_flags |= SCE_HTTPS_FLAG_NOT_AFTER_CHECK | SCE_HTTPS_FLAG_NOT_BEFORE_CHECK;

ret = sceHttpsDisableOption(tpl_id, ssl_flags);
if (ret) {
Loading