Git Product home page Git Product logo

ps4-payload-sdk's Introduction

PS4 SDK

An open source PlayStation 4 SDK for writing userland applications which can be run with the PS4-playground.

Building and installing

You will need LLVM version 3.7 or later for compiling, and binutils for linking (from MinGW if you are on Windows).

Clone this repository locally, or download and extract a ZIP of the repository here.

Then create an environment variable called, PS4SDK which points to the base directory of the repository, using the Unix path style; for example:

/C/Users/Chris/Documents/GitHub/PS4-SDK

Build the libraries by running make on the libPS4 and libusbfatfs directories.

Finally, you can build examples by running make on them.

Design

At the moment, it is primarily focused on system calls.

However, using function pointers and the RESOLVE macro, we can call functions from other modules. For example, the socket functions from libSceNet.sprx.

Support

Whilst the SDK isn't capable of most basic functionality yet, such as displaying graphics, or receiving controller input, there are workarounds: rendering to an HTML5 canvas, and using third party USB controllers, or a DS/PSP wirelessly for example.

The SDK is currently in a state where projects like an FTP server, a mini Pong game, or GameBoy emulator could be developed.

Examples

hello - Load libc module and perform getpid system call

sockets - Send a message over a TCP socket

modules - Load and dump a module

threads - Create and wait for a thread to increment a variable

canvas - Render to an HTML5 canvas

camera - Initialise the PlayStation Camera and capture 10 frames

pad - Read controller input (not finished)

jit - Setting up JIT shared memory

Filesystem

directories - List the contents of a directory

files - Read a file's size, and its contents

USB

list_devices - List information about all USB devices connected

storage - Read raw image from a USB flash drive

usbfatfs - Read files from USB formatted with FAT

ps4-payload-sdk's People

Contributors

bigboss-ps3dev avatar cturt avatar idc avatar kr105 avatar masterzorag avatar maxton avatar patrickgill avatar psxdev avatar xerpi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ps4-payload-sdk's Issues

Cannot compile libPS4/source/syscall.s on Ubuntu 17.04

Hello,

it seems libPS4 won't compile on a freshly installed Ubuntu 17.04.
No idea if this is a regression caused by the GCC version.

user@ubuntu:~/ps4$ sudo apt-get -y install make gcc binutils tar bzip2 git

user@ubuntu:~/ps4$ uname -a
Linux ubuntu 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
user@ubuntu:~/ps4$ gcc --version
gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

user@ubuntu:~/ps4$ as --version
GNU assembler (GNU Binutils for Ubuntu) 2.28
Copyright (C) 2017 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-linux-gnu'.

user@ubuntu:~/ps4$ git clone https://github.com/idc/PS4-SDK.git PS4-SDK--idc && pushd PS4-SDK--idc

user@ubuntu:~/ps4/PS4-SDK--idc$ make -C libPS4
make: Entering directory '/home/user/ps4/PS4-SDK--idc/libPS4'
gcc -c -o build/semaphore.o source/semaphore.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/jit.o source/jit.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/registry.o source/registry.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/unknown.o source/unknown.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/usb.o source/usb.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/pad.o source/pad.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/file.o source/file.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/camera.o source/camera.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/memory.o source/memory.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/libc.o source/libc.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/network.o source/network.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/barrier.o source/barrier.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/module.o source/module.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/pthread.o source/pthread.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/eventflag.o source/eventflag.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/kernel.o source/kernel.c -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
gcc -c -o build/syscall.o source/syscall.s -nostartfiles -nostdlib -march=btver2 -mtune=btver2
source/syscall.s: Assembler messages:
source/syscall.s:7: Fatal error: bad .section directive: want a,l,w,x,M,S,G,T in string
Makefile:24: recipe for target 'build/syscall.o' failed
make: *** [build/syscall.o] Error 1
make: Leaving directory '/home/user/ps4/PS4-SDK--idc/libPS4'

EDIT: same error with 16.04 LTS / GCC 5.4

user@ubuntu16:~/ps4$ uname -a
Linux ubuntu16 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
user@ubuntu16:~/ps4$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

user@ubuntu16:~/ps4$ as --version
GNU assembler (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `x86_64-linux-gnu'.

Cannot compile libPS4/source/syscall.s

source/syscall.s:20:7: error: cannot use base register with variable reference
 call syscall_rop[rip]
      ^
source/syscall.s:25:17: error: cannot use base register with variable reference
  cmp qword ptr __error[rip], 0
                ^
source/syscall.s:28:8: error: cannot use base register with variable reference
  call __error[rip]
       ^

I'm trying to compile it under macOS, is this related to the problem? I know very little about x86 assembly.

ubuntu 16.04.3 fatal error No such file or directory include ps4.h

gcc -c -o build/MassStoreCommands.o source/MassStoreCommands.c -I/libPS4/include -I. -Iinclude -std=c11 -O2 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
In file included from source/MassStoreCommands.c:51:0:
include/MassStoreCommands.h:41:20: fatal error: ps4.h: No such file or directory
#include <ps4.h>
^
compilation terminated.
Makefile:20: recipe for target 'build/MassStoreCommands.o' failed
make: *** [build/MassStoreCommands.o] Error 1

the only workaround if i copy the content from
/home/user/Desktop/SDK/libPS4/include
To
/home/user/Desktop/SDK/libusbfatfs/include
not sure if am doing the right thing

Ubuntu 17.10 make error

**Hi,

I have installed llvm and binutils (+ reboot); when I try 'make' in libPS4 and libUSBfatfs I get the following error.**

gcc -c -o build/flash_drive.o source/flash_drive.c -I/home/consolehax/Desktop/SDK/libPS4/include -I. -Iinclude -std=c11 -O2 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large
In file included from /home/consolehax/Desktop/SDK/libPS4/include/file.h:3:0,
                 from /home/consolehax/Desktop/SDK/libPS4/include/ps4.h:5,
                 from source/flash_drive.c:24:
/home/consolehax/Desktop/SDK/libPS4/include/types.h:71:18: error: conflicting types for ‘__dev_t’
 typedef uint32_t __dev_t;
                  ^~~~~~~
In file included from /usr/include/stdint.h:27:0,
                 from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
                 from /home/consolehax/Desktop/SDK/libPS4/include/types.h:3,
                 from /home/consolehax/Desktop/SDK/libPS4/include/file.h:3,
                 from /home/consolehax/Desktop/SDK/libPS4/include/ps4.h:5,
                 from source/flash_drive.c:24:
/usr/include/x86_64-linux-gnu/bits/types.h:133:25: note: previous declaration of ‘__dev_t’ was here
 __STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers.  */
                         ^~~~~~~
Makefile:20: recipe for target 'build/flash_drive.o' failed
make: *** [build/flash_drive.o] Error 1

‘DT_DIR’ undeclared error

gcc -c -o build/main.o source/main.c -I/data/ps4-payload-sdk/libPS4/include -I. -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large -DTEXT_ADDRESS=0x926200000 -DDATA_ADDRESS=0x926300000
source/main.c: In function ‘entryName’:
source/main.c:12:8: error: ‘DT_DIR’ undeclared (first use in this function)
case DT_DIR: return "DIR";

Syscall.o Error 1

alfamodz@DESKTOP:/mnt/c/Users/AlFaMoDz/Desktop/PS4-SDK/libPS4$ sudo make
gcc -c -o build/syscall.o source/syscall.s -nostartfiles -nostdlib -march=btver2 -mtune=btver2
source/syscall.s: Assembler messages:
source/syscall.s:7: Fatal error: bad .section directive: want a,l,w,x,M,S,G,T in string
Makefile:24: recipe for target 'build/syscall.o' failed
make: *** [build/syscall.o] Error 1

libusbfatfs make error

If I run make on libusbfatfs, I'll get an fatal error: ps4.h: No such file or directory
#include <ps4.h>

Error on compiling any thing that includes libPS4.a

When ever I try to compile any of the examples or anything like PS4API-5.05 I get the following error.

user@ubuntu:~/Desktop/ps4-payload-sdk/examples/hello$ make gcc -c -o build/main.o source/main.c -I/home/user/PS4-SDK/libPS4/include -I. -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large -DTEXT_ADDRESS=0x926200000 -DDATA_ADDRESS=0x926300000 gcc /home/user/PS4-SDK/libPS4/crt0.s build/.o -o temp.t -I/home/user/PS4-SDK/libPS4/include -I. -Iinclude -O2 -std=c11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large -DTEXT_ADDRESS=0x926200000 -DDATA_ADDRESS=0x926300000 -L/home/user/PS4-SDK/libPS4 -L. -Llib -Xlinker -T /home/user/PS4-SDK/libPS4/linker.x -Wl,--build-id=none -Ttext=0x926200000 -Tdata=0x926300000 -lPS4 /home/user/PS4-SDK/libPS4/libPS4.a(kernel.o): In function kill': kernel.c:(.text+0x8): undefined reference tosyscall_macro' kernel.c:(.text+0x8): relocation truncated to fit: R_X86_64_PC32 against undefined symbol syscall_macro' /home/user/PS4-SDK/libPS4/libPS4.a(kernel.o): In functionioctl': kernel.c:(.text+0x14): undefined reference to syscall_macro' kernel.c:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against undefined symbolsyscall_macro' /home/user/PS4-SDK/libPS4/libPS4.a(kernel.o): In function kexec': kernel.c:(.text+0x20): undefined reference tosyscall_macro' kernel.c:(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against undefined symbol syscall_macro' /home/user/PS4-SDK/libPS4/libPS4.a(module.o): In functiongetFunctionAddressByName': module.c:(.text+0x8): undefined reference to syscall_macro' module.c:(.text+0x8): relocation truncated to fit: R_X86_64_PC32 against undefined symbolsyscall_macro' /home/user/PS4-SDK/libPS4/libPS4.a(module.o): In function getLoadedModules': module.c:(.text+0x14): undefined reference tosyscall_macro' module.c:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against undefined symbol syscall_macro' collect2: error: ld returned 1 exit status Makefile:25: recipe for target 'hello.bin' failed make: ** [hello.bin] Error 1`

Ubuntu 18.04 error: conflicting types for ‘__dev_t’

When I compile libps4 or libsbfatfs, this error always shows:

gcc -c -o build/jit.o source/jit.c -Iinclude -Os -std=gnu11 -ffunction-sections -fdata-sections -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=small -fpie
In file included from include/kernel.h:3:0,
from source/jit.c:1:
include/types.h:73:18: error: conflicting types for ‘__dev_t’
typedef uint32_t __dev_t;
^~~~~~~
In file included from /usr/include/stdint.h:27:0,
from /usr/lib/gcc/x86_64-linux-gnu/7/include/stdint.h:9,
from include/types.h:3,
from include/kernel.h:3,
from source/jit.c:1:
/usr/include/x86_64-linux-gnu/bits/types.h:133:25: note: previous declaration of ‘__dev_t’ was here
__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */
^~~~~~~
Makefile:17: recipe for target 'build/jit.o' failed
make: *** [build/jit.o] Error 1

Error Building Payload

Hello. I'm using Ubuntu 16.04.2 and trying to build a payload. I also tried with leaving the Main.c file as is but still get the same error when attempting a build. SDK was setup successfully and I can build example Bin's.

======= Error as follows =========================
jon@jon-VirtualBox:~/Desktop/DumpFileCturt176-backupPrep$ make
gcc -c -o build/main.o source/main.c -I/home/jon/Desktop/SDK/libPS4/include -I. -Iinclude -O3 -std=gnu11 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large -DTEXT_ADDRESS=0x926200000 -DDATA_ADDRESS=0x926300000
In file included from source/main.c:6:0:
source/main.c: In function ‘read_decrypt_segment’:
source/main.c:69:65: error: ‘errno’ undeclared (first use in this function)
printfsocket("mmap segment [%d] err(%d) : %s\n", index, errno, strerror
^
include/defines.h:5:41: note: in definition of macro ‘printfsocket’
int size = sprintf(buffer, format, ##VA_ARGS);
^
source/main.c:69:65: note: each undeclared identifier is reported only once for each function it appears in
printfsocket("mmap segment [%d] err(%d) : %s\n", index, errno, strerror
^
include/defines.h:5:41: note: in definition of macro ‘printfsocket’
int size = sprintf(buffer, format, ##VA_ARGS);
^
source/main.c:69:72: warning: implicit declaration of function ‘strerror’ [-Wimplicit-function-declaration]
printfsocket("mmap segment [%d] err(%d) : %s\n", index, errno, strerror(er
^
include/defines.h:5:41: note: in definition of macro ‘printfsocket’
int size = sprintf(buffer, format, ##VA_ARGS);
^
source/main.c: In function ‘do_dump’:
source/main.c:141:64: error: ‘errno’ undeclared (first use in this function)
printfsocket("fopen %s err : %s\n", saveFile, strerror(errno));
^
include/defines.h:5:41: note: in definition of macro ‘printfsocket’
int size = sprintf(buffer, format, ##VA_ARGS);
^
source/main.c: In function ‘decrypt_and_dump_self’:
source/main.c:169:72: error: ‘errno’ undeclared (first use in this function)
printfsocket("mmap file %s err : %s\n", selfFile, strerror(errno));
^
include/defines.h:5:41: note: in definition of macro ‘printfsocket’
int size = sprintf(buffer, format, ##VA_ARGS);
^
Makefile:30: recipe for target 'build/main.o' failed
make: *** [build/main.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.