Skip to content

Commit

Permalink
Publish v2.1 release source code
Browse files Browse the repository at this point in the history
  • Loading branch information
nkrapivin committed Oct 21, 2022
1 parent 68d9ec3 commit f864b60
Show file tree
Hide file tree
Showing 28 changed files with 1,472 additions and 294 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
"user.h": "c",
"errors.h": "c",
"sysmodule.h": "c",
"move.h": "c"
"move.h": "c",
"common.h": "c",
"utilities.h": "c",
"strings.h": "c"
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This is basically PS Move for the poor.
# How to install?

- For Mira CFW: Copy `libREMove.sprx` to `/data/mira/substitute/CUSAXXXXX/`, where `CUSAXXXXX` is the game you wish to patch.
- For GoldHEN (TODO!!!! NOT FINISHED!!!!): Rename `libREMove.sprx` to `fps.prx` and copy to `/data/GoldHEN/`.
- For GoldHEN 2.2.5 and newer: Rename `libREMove.sprx` to `test.prx` and copy to `/data/GoldHEN/plugins`.
- Install the APK on your device.
- Open the app, go to Settings and set your Console IP, usually you do not need to touch the port.
- Run the game you wanted to patch, press "CONNECT" in the app, select your user, enjoy!
Expand Down
6 changes: 3 additions & 3 deletions REMoveAndroidApp/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.nkrapivindev.remove"
minSdk 25
targetSdk 33
versionCode 2
versionName "2.0"
versionCode 3
versionName "2.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
targetSdkVersion 33
Expand All @@ -32,7 +32,7 @@ android {

dependencies {

implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,12 @@ else if (act == MotionEvent.ACTION_UP || act == MotionEvent.ACTION_CANCEL) {
getSystemService(Context.VIBRATOR_MANAGER_SERVICE);
if (vibman != null) {
vib = vibman.getDefaultVibrator();
print("Using new vibration API");
}
}
else {
vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
print("Using old vibration API");
}

btnCross = findViewById(R.id.button_cross);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public void run() {
REMoveNetPacketHelloV2 hello = new REMoveNetPacketHelloV2();
int got;
REMoveApplicationData appData;
//long startTime;
long startTime;

log("Entering thread loop...");

while (running.get()) {
// initialize the socket:
Expand Down Expand Up @@ -95,6 +97,7 @@ public void run() {

// still negative? cancelled, kill us
if (myuserind < 0) {
log("User selection cancelled");
break;
}
else {
Expand All @@ -113,7 +116,7 @@ public void run() {
}

// main loop...
//startTime = System.nanoTime();
startTime = System.nanoTime();
if (app != null) {
appData = app.onProvideData();
if (appData != null) {
Expand All @@ -138,37 +141,37 @@ public void run() {
);

// obtain any update frames from the server:
got = sckIn.read(buff);
if (got != REMoveNetPacketToClientV2.EXPECTED_SIZEOF) {
throw new REMoveSizeOfException(
REMoveNetPacketToClientV2.EXPECTED_SIZEOF,
got
);
}
buffstream.rewind();
toUs.fromStream(buffstream);

if (app != null) {
if ((toUs.updateFlags
& REMoveNetPacketToClientV2.UPDATE_FLAG_SET_LIGHTSPHERE_COLOR) != 0) {
// we have color update data, send that
app.onColorUpdate(toUs.red, toUs.green, toUs.blue);
//if (sckIn.available() >= REMoveNetPacketToClientV2.EXPECTED_SIZEOF) {
got = sckIn.read(buff, 0, REMoveNetPacketToClientV2.EXPECTED_SIZEOF);
if (got != REMoveNetPacketToClientV2.EXPECTED_SIZEOF) {
throw new REMoveSizeOfException(
REMoveNetPacketToClientV2.EXPECTED_SIZEOF,
got
);
}
buffstream.rewind();
toUs.fromStream(buffstream);

if ((toUs.updateFlags
& REMoveNetPacketToClientV2.UPDATE_FLAG_SET_VIBRATION) != 0) {
// we have vibration data, send that
app.onMotorUpdate(toUs.motorValue);
if (app != null) {
if ((toUs.updateFlags
& REMoveNetPacketToClientV2.UPDATE_FLAG_SET_LIGHTSPHERE_COLOR) != 0) {
// we have color update data, send that
app.onColorUpdate(toUs.red, toUs.green, toUs.blue);
}

if ((toUs.updateFlags
& REMoveNetPacketToClientV2.UPDATE_FLAG_SET_VIBRATION) != 0) {
// we have vibration data, send that
app.onMotorUpdate(toUs.motorValue);
}
}
}
//}

/*
long estimatedTime = System.nanoTime() - startTime;

if ((System.currentTimeMillis() % 10000) < 10) {
log("Estimated time = " + (((double) estimatedTime) / 1000000) + "ms");
if ((System.currentTimeMillis() % 10000) < 100) {
log("Estimated time = " + (((double) estimatedTime) / 1000000.0) + "ms");
}
*/
}

log("The thread is requesting a close gracefully...");
Expand Down
35 changes: 17 additions & 18 deletions oobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

print("> Building libREMove for PS4 via OO")

LLVM_BIN_PATH = os.environ.get("OPENALPS4_LLVM_BIN_PATH")
LLVM_BIN_PATH = os.environ.get("OO_LLVM_BIN_PATH")

if LLVM_BIN_PATH is None:
LLVM_BIN_PATH = "D:\\SDK\\LLVM10\\bin"
LLVM_BIN_PATH = "D:/SDK/LLVM10/bin"

# only works with the latest nightly release of the OpenOrbis PS4 Toolchain
OO_PS4_TOOLCHAIN = os.environ.get("OO_PS4_TOOLCHAIN")
Expand All @@ -27,10 +27,10 @@
BUILD_FOLDER = os.path.join(ROOT_DIR, "build", BUILD_FOLDER_NAME)

# Dependencies: libunwind is auto-merged into libc++ in nightly OO builds for simplicity
LINK_WITH = "-lGoldHEN_Hook -lkernel -lc -lc++ -lSceUserService -lSceNet -lSceSysmodule"
LINK_WITH = "-lkernel -lc -lSceUserService -lSceNet"

SRC_FOLDER = os.path.join(ROOT_DIR, "remove")
GOLDHEN_PLUGIN_SDK = os.path.join(SRC_FOLDER, "goldhensdk")
GOLDHEN_PLUGIN_SDK = os.path.join(SRC_FOLDER, "goldhensdk", "include")

# name of the final output, must start with lib
FINAL_NAME = "libREMove"
Expand All @@ -44,25 +44,22 @@

COMPILER_WFLAGS = " -Wpedantic "

COMPILER_FFLAGS = " -fPIC -fvisibility=hidden -march=btver2 -O2 -c "
COMPILER_FFLAGS = " -fPIC -fvisibility=hidden -march=btver2 -mtune=btver2 -O2 -c "

COMPILER_CFLAGS = " -std=c99 "

COMPILER_PFLAGS = f" -std=c++14 -isystem \"{OO_PS4_TOOLCHAIN}/include/c++/v1\" "
COMPILER_CFLAGS = " -std=c11 "

COMPILER_IFLAGS = f" -isysroot \"{OO_PS4_TOOLCHAIN}\" -isystem \"{OO_PS4_TOOLCHAIN}/include\" " + \
f" -I\"{SRC_FOLDER}\" "
f" -I\"{SRC_FOLDER}\" -I\"{GOLDHEN_PLUGIN_SDK}\" "

# use freebsd12 target, define some generic ps4 defines, force exceptions to ON since we have to do that for now
COMPILER_FLAGS = f" --target=x86_64-pc-freebsd12-elf -fexceptions -funwind-tables -fuse-init-array " + \
f" {COMPILER_WFLAGS} {COMPILER_FFLAGS} {COMPILER_IFLAGS} {COMPILER_DEFINES} "

# link with PRX crtlib
LINKER_FLAGS = f" -m elf_x86_64 -pie --script \"{OO_PS4_TOOLCHAIN}/link.x\" " + \
f" --eh-frame-hdr --verbose -e _init -L\"{GOLDHEN_PLUGIN_SDK}\" -L\"{OO_PS4_TOOLCHAIN}/lib\" {LINK_WITH} -o \"{ELF_PATH}\" "
LINKER_FLAGS = f" -m elf_x86_64 --script \"{OO_PS4_TOOLCHAIN}/link.x\" " + \
f" --eh-frame-hdr --verbose -pie -e _init -L\"{OO_PS4_TOOLCHAIN}/lib\" {LINK_WITH} -o \"{ELF_PATH}\" "

C_COMPILER_EXE = os.path.join(LLVM_BIN_PATH, "clang")
CPP_COMPILER_EXE = os.path.join(LLVM_BIN_PATH, "clang++")
LINKER_EXE = os.path.join(LLVM_BIN_PATH, "ld.lld")
TOOL_EXE = os.path.join(OO_PS4_TOOLCHAIN, "bin", "windows", "create-fself")

Expand All @@ -71,7 +68,13 @@
remove/substitute.c
remove/remove_ctx.c
remove/remove_module.c
remove/remove_goldhen_glue.cpp
remove/goldhensdk/source/GoldHEN.c
remove/goldhensdk/source/Utilities.c
remove/goldhensdk/source/Syscall.c
remove/goldhensdk/source/HDE64.c
remove/goldhensdk/source/Patcher.c
remove/goldhensdk/source/Detour.c
"""

# quoted .o paths
Expand Down Expand Up @@ -107,11 +110,7 @@ def run_compiler_at(srcfile: str, objfile: str, params: str) -> int:
global OBJECTS

comp = C_COMPILER_EXE
if srcfile.endswith(".cpp") or srcfile.endswith(".cxx"):
params = COMPILER_PFLAGS + params
comp = CPP_COMPILER_EXE
else:
params = COMPILER_CFLAGS + params
params = COMPILER_CFLAGS + params

runargs = f"{params} -o \"{objfile}\" \"{srcfile}\""
fullline = f"{comp} {runargs}"
Expand Down
52 changes: 52 additions & 0 deletions remove/goldhensdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
55 changes: 0 additions & 55 deletions remove/goldhensdk/Detour.h

This file was deleted.

29 changes: 19 additions & 10 deletions remove/goldhensdk/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
# GoldHEN Plugin SDK Files
# GoldHEN Plugin SDK - a prx hook/patch sdk for Orbis OS

All files in this folder were provided by SiSTRo, the creator and maintainer of GoldHEN.
This is the GoldHEN Plugin SDK repository.

He permitted the REMove project to use these files so function hooks work in GoldHEN as well, not just Mira.
It requires OpenOrbis PS4 Toolchain and LLVM to be installed.

This requires very latest GoldHEN to be running.
## Including the SDK as source

If you're going to use these files in your project, I'd ask SiSTRo first.
It's better if you copy the SDK source files into your project and build the SDK from source *with* your project,
because there may be some compiler or OpenOrbis Toolchain bugfixes which would require rebuilding the GoldHEN SDK.

I still do not know why he didn't go the "pseudo-file" way like Mira did with it's `/dev/mira` ioctl-thing and made a static lib instead :/
Just build all files from `source/` as C source code, and include stuff from `include/`.

It's also in C++ and was most likely compiled with OpenOrbis, so it relies on a mostly-specific OpenOrbis Toolchain version.
## Including the SDK as a static library

The toolchain is evolving constantly, a custom LLVM for OpenOrbis is on it's way, which will most likely break things.
If you are sure you won't be rebuilding the GoldHEN SDK, then you can include stuff from `include/`,
run `build_static.bat` to build a static library `libGoldHEN_Hook.a` and then use it in your project for the implementation of the headers.

Since my code *is* portable (doesn't even require malloc! just a proper linker to import SceNet/SceUserService/libkernel!),
## Credits

I had to make an extern "C" glue which makes the thing even worse.
- OSM <https://github.com/OSM-Made>

- jocover <https://github.com/jocover>

- bucanero <https://github.com/bucanero>

- OpenOrbis Team <https://github.com/OpenOrbis>

- SiSTRo <https://github.com/SiSTR0>


Loading

0 comments on commit f864b60

Please sign in to comment.