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

7.00 -> 7.02 Port #143

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
43 changes: 43 additions & 0 deletions .github/workflows/Orbis702.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Orbis702

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
# Checkout the repository
- uses: actions/checkout@v2
# Install required stuff needed to build Mira
- name: preinstall
run: sudo apt install build-essential git clang lldb clang-tidy clang-tools cppcheck
# Handle loader crap
- name: create loader directories
run: cd loader; make create
- name: clean loader
run: cd loader; make clean
- name: create mira directories
run: cd kernel; make create
- name: clean mira
run: cd kernel; make clean
# 7.02 Support
- name: make 7.02 loader
run: cd loader; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_702 MIRA_CHECKS=TRUE make
- name: make 7.02 elf
run: cd kernel; MIRA_PLATFORM=MIRA_PLATFORM_ORBIS_BSD_702 ADD_GIT_HASH=TRUE MIRA_CHECKS=TRUE make
- name: Upload 7.02 loader
uses: actions/upload-artifact@v2
with:
name: MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_702.bin
path: loader/build/MiraLoader_Orbis_MIRA_PLATFORM_ORBIS_BSD_702.bin
- name: Upload 7.02 elf
uses: actions/upload-artifact@v2
with:
name: Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_702.elf
path: kernel/build/Mira_Orbis_MIRA_PLATFORM_ORBIS_BSD_702.elf
3 changes: 3 additions & 0 deletions kernel/src/Boot/Patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void Patches::install_prePatches()
case MIRA_PLATFORM_ORBIS_BSD_672:
install_prerunPatches_672();
break;
case MIRA_PLATFORM_ORBIS_BSD_702:
install_prerunPatches_702();
break;
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions kernel/src/Boot/Patches.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Mira
static void install_prerunPatches_620();
static void install_prerunPatches_650();
static void install_prerunPatches_672();
static void install_prerunPatches_702();
// static void install_prerunPatches_SteamLink(); // got both versions booting off the same code
static void install_prerunPatches_SteamLink2();
};
Expand Down
227 changes: 227 additions & 0 deletions kernel/src/Boot/Patches/Patches702.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include <Boot/Patches.hpp>

/*
Please, please, please!
Keep patches consistent with the used patch style for readability.
*/
void Mira::Boot::Patches::install_prerunPatches_702()
{
#if MIRA_PLATFORM == MIRA_PLATFORM_ORBIS_BSD_702
// You must assign the kernel base pointer before anything is done
if (!gKernelBase)
return;

// Use "kmem" for all patches
uint8_t *kmem;

// Enable UART
kmem = (uint8_t *)&gKernelBase[0x01A6EAA0];
kmem[0] = 0x00;

// Verbose Panics
kmem = (uint8_t *)&gKernelBase[0x0013A4AE];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;
kmem[3] = 0x90;
kmem[4] = 0x90;

// sceSblACMgrIsAllowedSystemLevelDebugging
kmem = (uint8_t *)&gKernelBase[0x001CB060];
kmem[0] = 0xB8;
kmem[1] = 0x01;
kmem[2] = 0x00;
kmem[3] = 0x00;
kmem[4] = 0x00;
kmem[5] = 0xC3;

kmem = (uint8_t *)&gKernelBase[0x001CB880];
kmem[0] = 0xB8;
kmem[1] = 0x01;
kmem[2] = 0x00;
kmem[3] = 0x00;
kmem[4] = 0x00;
kmem[5] = 0xC3;

kmem = (uint8_t *)&gKernelBase[0x001CB8A0];
kmem[0] = 0xB8;
kmem[1] = 0x01;
kmem[2] = 0x00;
kmem[3] = 0x00;
kmem[4] = 0x00;
kmem[5] = 0xC3;

// Enable rwx mapping
kmem = (uint8_t *)&gKernelBase[0x001171BE];
kmem[0] = 0x07;

kmem = (uint8_t *)&gKernelBase[0x001171C6];
kmem[0] = 0x07;

// Patch copyin/copyout: Allow userland + kernel addresses in both params
// copyin
kmem = (uint8_t *)&gKernelBase[0x0002F287];
kmem[0] = 0x90;
kmem[1] = 0x90;

kmem = (uint8_t *)&gKernelBase[0x0002F293];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;

// copyout
kmem = (uint8_t *)&gKernelBase[0x0002F192];
kmem[0] = 0x90;
kmem[1] = 0x90;

kmem = (uint8_t *)&gKernelBase[0x0002F19E];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;

// Enable MAP_SELF
kmem = (uint8_t *)&gKernelBase[0x001CB8F0];
kmem[0] = 0xB8;
kmem[1] = 0x01;
kmem[2] = 0x00;
kmem[3] = 0x00;
kmem[4] = 0x00;
kmem[5] = 0xC3;

kmem = (uint8_t *)&gKernelBase[0x001CB910];
kmem[0] = 0xB8;
kmem[1] = 0x01;
kmem[2] = 0x00;
kmem[3] = 0x00;
kmem[4] = 0x00;
kmem[5] = 0xC3;

kmem = (uint8_t *)&gKernelBase[0x001D40BB];
kmem[0] = 0x31;
kmem[1] = 0xC0;
kmem[2] = 0x90;
kmem[3] = 0x90;
kmem[4] = 0x90;

// Patch copyinstr
kmem = (uint8_t *)&gKernelBase[0x0002F733];
kmem[0] = 0x90;
kmem[1] = 0x90;

kmem = (uint8_t *)&gKernelBase[0x0002F73F];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;

// Patch memcpy stack
kmem = (uint8_t *)&gKernelBase[0x0002F04D];
kmem[0] = 0xEB;

// ptrace patches
kmem = (uint8_t *)&gKernelBase[0x000448D5];
kmem[0] = 0xEB;

// second ptrace patch
kmem = (uint8_t *)&gKernelBase[0x00044DAF];
kmem[0] = 0xE9;
kmem[1] = 0x7C;
kmem[2] = 0x02;
kmem[3] = 0x00;
kmem[4] = 0x00;

// setlogin patch (for autolaunch check)
kmem = (uint8_t *)&gKernelBase[0x0008A8EC];
kmem[0] = 0x48;
kmem[1] = 0x31;
kmem[2] = 0xC0;
kmem[3] = 0x90;
kmem[4] = 0x90;

// Patch to remove vm_fault: fault on nofault entry, addr %llx
kmem = (uint8_t *)&gKernelBase[0x002BF756];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;
kmem[3] = 0x90;
kmem[4] = 0x90;
kmem[5] = 0x90;

// Patch mprotect: Allow RWX (mprotect) mapping
kmem = (uint8_t *)&gKernelBase[0x00264C08];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;
kmem[3] = 0x90;
kmem[4] = 0x90;
kmem[5] = 0x90;

// flatz disable pfs signature check
kmem = (uint8_t *)&gKernelBase[0x006BE880];
kmem[0] = 0x31;
kmem[1] = 0xC0;
kmem[2] = 0xC3;

// flatz enable debug RIFs
kmem = (uint8_t *)&gKernelBase[0x00668270];
kmem[0] = 0xB0;
kmem[1] = 0x01;
kmem[2] = 0xC3;

kmem = (uint8_t *)&gKernelBase[0x006682A0];
kmem[0] = 0xB0;
kmem[1] = 0x01;
kmem[2] = 0xC3;

// Enable *all* debugging logs (in vprintf)
// Patch by: SiSTRo
kmem = (uint8_t *)&gKernelBase[0x000BC817];
kmem[0] = 0xEB;
kmem[1] = 0x3B;

// flatz allow mangled symbol in dynlib_do_dlsym
kmem = (uint8_t *)&gKernelBase[0x002F0367];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;
kmem[3] = 0x90;
kmem[4] = 0x90;
kmem[5] = 0x90;

// Enable mount for unprivileged user
kmem = (uint8_t *)&gKernelBase[0x0029636A];
kmem[0] = 0x90;
kmem[1] = 0x90;
kmem[2] = 0x90;
kmem[3] = 0x90;
kmem[4] = 0x90;
kmem[5] = 0x90;

// patch suword_lwpid
// has a check to see if child_tid/parent_tid is in kernel memory, and it in so patch it
// Patch by: JOGolden
kmem = (uint8_t *)&gKernelBase[0x0002F552];
kmem[0] = 0x90;
kmem[1] = 0x90;

kmem = (uint8_t *)&gKernelBase[0x0002F561];
kmem[0] = 0x90;
kmem[1] = 0x90;

// Patch debug setting errors
kmem = (uint8_t *)&gKernelBase[0x005016FA];
kmem[0] = 0x00;
kmem[1] = 0x00;
kmem[2] = 0x00;
kmem[3] = 0x00;

kmem = (uint8_t *)&gKernelBase[0x0050296C];
kmem[0] = 0x00;
kmem[1] = 0x00;
kmem[2] = 0x00;
kmem[3] = 0x00;

#endif
}
2 changes: 1 addition & 1 deletion kernel/src/Plugins/RemotePlayEnabler/RemotePlayEnabler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool RemotePlayEnabler::ShellUIPatch()
#elif MIRA_PLATFORM == MIRA_PLATFORM_ORBIS_BSD_620
// `/system_ex/app/NPXS20001/psm/Application/app.exe.sprx`
s_Ret = Utilities::ProcessReadWriteMemory(s_Process, (void*)(s_ShellUIAppTextStart + ssu_remote_play_menu_patch), 5, (void*)"\xE9\xB8\x02\x00\x00", nullptr, true);
#elif MIRA_PLATFORM == MIRA_PLATFORM_ORBIS_BSD_672
#elif MIRA_PLATFORM >= MIRA_PLATFORM_ORBIS_BSD_672 && MIRA_PLATFORM <= MIRA_PLATFORM_ORBIS_BSD_702
// `/system_ex/app/NPXS20001/psm/Application/app.exe.sprx`
s_Ret = Utilities::ProcessReadWriteMemory(s_Process, (void*)(s_ShellUIAppTextStart + ssu_remote_play_menu_patch), 5, (void*)"\xE9\xBA\x02\x00\x00", nullptr, true);
#else
Expand Down
2 changes: 2 additions & 0 deletions kernel/src/Utils/Kdlsym.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extern "C" {
#include "Kdlsym/Orbis650.hpp"
#elif MIRA_PLATFORM==MIRA_PLATFORM_ORBIS_BSD_672
#include "Kdlsym/Orbis672.hpp"
#elif MIRA_PLATFORM==MIRA_PLATFORM_ORBIS_BSD_702
#include "Kdlsym/Orbis702.hpp"
#endif

// Kernel base address, this must be filled out on-startup (normally done in oni_initializeKernel)
Expand Down
Loading