├── .gitattributes ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── Icons ├── icon_daemon.png ├── icon_payload.png ├── icon_pkg.png ├── icon_plugin.png ├── icon_reboot.png ├── icon_reload_ui.png ├── icon_shutdown.png ├── icon_suspend.png ├── icon_system_settings.png └── icon_toolbox.png ├── Loader ├── .vscode │ ├── c_cpp_properties.json │ └── settings.json ├── Common │ └── Settings.h ├── Kernel │ ├── Linker │ ├── Makefile │ ├── crt0.s │ ├── include │ │ ├── Common.hpp │ │ ├── Loader.hpp │ │ ├── Resolver │ │ │ ├── Resolver-505.hpp │ │ │ ├── Resolver-672.hpp │ │ │ ├── Resolver-702.hpp │ │ │ ├── Resolver-755.hpp │ │ │ ├── Resolver-900.hpp │ │ │ └── Resolver.hpp │ │ ├── Util │ │ │ ├── Proc.hpp │ │ │ └── Util.hpp │ │ └── kproc.hpp │ └── source │ │ ├── Loader.cpp │ │ ├── Main.cpp │ │ ├── Resolver │ │ └── Resolver.cpp │ │ ├── Util │ │ ├── Proc.cpp │ │ └── Util.cpp │ │ ├── embed.s │ │ └── kproc.cpp ├── Makefile ├── ShellCode │ ├── LoaderShellCode.s │ ├── Makefile │ └── test.s └── Userland │ ├── Linkfile │ ├── Makefile │ ├── crt0.s │ ├── include │ ├── Common.h │ ├── ELF.h │ ├── Resolver │ │ ├── Patches.h │ │ ├── Resolver-505.h │ │ ├── Resolver-672.h │ │ ├── Resolver-702.h │ │ ├── Resolver-755.h │ │ ├── Resolver-900.h │ │ └── Resolver.h │ ├── Util │ │ ├── Resources.h │ │ ├── Types.h │ │ └── Utils.h │ └── syscall.h │ └── source │ ├── ELF.c │ ├── Resolver │ ├── Patches-505.c │ ├── Patches-672.c │ ├── Patches-702.c │ ├── Patches-755.c │ ├── Patches-900.c │ ├── Patches.c │ └── Resolver.c │ ├── Util │ ├── Resources.c │ └── Utils.c │ ├── embed.s │ ├── main.c │ └── syscall.s ├── Orbis Toolbox.sln ├── Orbis Toolbox ├── Build_Overlay.cpp ├── Build_Overlay.h ├── Common.h ├── Config.cpp ├── Config.h ├── Custom_Content.cpp ├── Daemons.cpp ├── Daemons.h ├── DebugTitleIdLabel.cpp ├── Debug_Features.h ├── Detour.cpp ├── Detour.h ├── DevkitPanel.cpp ├── Embed.s ├── GamePad.cpp ├── GamePad.h ├── Game_Overlay.cpp ├── Game_Overlay.h ├── Increment.bat ├── Label.cpp ├── Label.h ├── LncUtil.cpp ├── LncUtil.h ├── Menu.cpp ├── Menu.h ├── Mono.cpp ├── Mono.h ├── Orbis Toolbox.vcxproj ├── Orbis Toolbox.vcxproj.filters ├── Orbis_Toolbox.cpp ├── Panel.cpp ├── Panel.h ├── Patcher.cpp ├── Patcher.h ├── Settings_Menu.cpp ├── Settings_Menu.h ├── SysfileUtilWrapper.cpp ├── SysfileUtilWrapper.h ├── System_Monitor.cpp ├── System_Monitor.h ├── UI.h ├── UI_Utilities.cpp ├── UI_Utilities.h ├── Utilities.cpp ├── Utilities.h ├── Version.h ├── Widget.cpp ├── Widget.h ├── build.bat ├── external_hdd.xml ├── hde64.cpp ├── hde64.h ├── orbis_toolbox.xml ├── settings_root.xml └── table64.h └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Debug Log** 27 | Please Include a Debug Log with the bug to make debugging it easier if not replicable. 28 | 29 | **System Info (please complete the following information):** 30 | - Firmware: [e.g. 5.05] 31 | - Console Type [e.g. Pro] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: Feature 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | *.bin 10 | *.elf 11 | *.oelf 12 | *.prx 13 | *.sprx 14 | *.o 15 | 16 | # User-specific files (MonoDevelop/Xamarin Studio) 17 | *.userprefs 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | bld/ 27 | [Bb]in/ 28 | [Oo]bj/ 29 | [Ll]og/ 30 | 31 | # Visual Studio 2015 cache/options directory 32 | .vs/ 33 | # Uncomment if you have tasks that create the project's static files in wwwroot 34 | #wwwroot/ 35 | 36 | # MSTest test Results 37 | [Tt]est[Rr]esult*/ 38 | [Bb]uild[Ll]og.* 39 | 40 | # NUNIT 41 | *.VisualState.xml 42 | TestResult.xml 43 | 44 | # Build Results of an ATL Project 45 | [Dd]ebugPS/ 46 | [Rr]eleasePS/ 47 | dlldata.c 48 | 49 | # DNX 50 | project.lock.json 51 | project.fragment.lock.json 52 | artifacts/ 53 | 54 | *_i.c 55 | *_p.c 56 | *_i.h 57 | *.ilk 58 | *.meta 59 | *.obj 60 | *.pch 61 | *.pdb 62 | *.pgc 63 | *.pgd 64 | *.rsp 65 | *.sbr 66 | *.tlb 67 | *.tli 68 | *.tlh 69 | *.tmp 70 | *.tmp_proj 71 | *.log 72 | *.vspscc 73 | *.vssscc 74 | .builds 75 | *.pidb 76 | *.svclog 77 | *.scc 78 | 79 | # Chutzpah Test files 80 | _Chutzpah* 81 | 82 | # Visual C++ cache files 83 | ipch/ 84 | *.aps 85 | *.ncb 86 | *.opendb 87 | *.opensdf 88 | *.sdf 89 | *.cachefile 90 | *.VC.db 91 | *.VC.VC.opendb 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | *.sap 98 | 99 | # TFS 2012 Local Workspace 100 | $tf/ 101 | 102 | # Guidance Automation Toolkit 103 | *.gpState 104 | 105 | # ReSharper is a .NET coding add-in 106 | _ReSharper*/ 107 | *.[Rr]e[Ss]harper 108 | *.DotSettings.user 109 | 110 | # JustCode is a .NET coding add-in 111 | .JustCode 112 | 113 | # TeamCity is a build add-in 114 | _TeamCity* 115 | 116 | # DotCover is a Code Coverage Tool 117 | *.dotCover 118 | 119 | # NCrunch 120 | _NCrunch_* 121 | .*crunch*.local.xml 122 | nCrunchTemp_* 123 | 124 | # MightyMoose 125 | *.mm.* 126 | AutoTest.Net/ 127 | 128 | # Web workbench (sass) 129 | .sass-cache/ 130 | 131 | # Installshield output folder 132 | [Ee]xpress/ 133 | 134 | # DocProject is a documentation generator add-in 135 | DocProject/buildhelp/ 136 | DocProject/Help/*.HxT 137 | DocProject/Help/*.HxC 138 | DocProject/Help/*.hhc 139 | DocProject/Help/*.hhk 140 | DocProject/Help/*.hhp 141 | DocProject/Help/Html2 142 | DocProject/Help/html 143 | 144 | # Click-Once directory 145 | publish/ 146 | 147 | # Publish Web Output 148 | *.[Pp]ublish.xml 149 | *.azurePubxml 150 | # TODO: Comment the next line if you want to checkin your web deploy settings 151 | # but database connection strings (with potential passwords) will be unencrypted 152 | #*.pubxml 153 | *.publishproj 154 | 155 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 156 | # checkin your Azure Web App publish settings, but sensitive information contained 157 | # in these scripts will be unencrypted 158 | PublishScripts/ 159 | 160 | # NuGet Packages 161 | *.nupkg 162 | # The packages folder can be ignored because of Package Restore 163 | **/packages/* 164 | # except build/, which is used as an MSBuild target. 165 | !**/packages/build/ 166 | # Uncomment if necessary however generally it will be regenerated when needed 167 | #!**/packages/repositories.config 168 | # NuGet v3's project.json files produces more ignoreable files 169 | *.nuget.props 170 | *.nuget.targets 171 | 172 | # Microsoft Azure Build Output 173 | csx/ 174 | *.build.csdef 175 | 176 | # Microsoft Azure Emulator 177 | ecf/ 178 | rcf/ 179 | 180 | # Windows Store app package directories and files 181 | AppPackages/ 182 | BundleArtifacts/ 183 | Package.StoreAssociation.xml 184 | _pkginfo.txt 185 | 186 | # Visual Studio cache files 187 | # files ending in .cache can be ignored 188 | *.[Cc]ache 189 | # but keep track of directories ending in .cache 190 | !*.[Cc]ache/ 191 | 192 | # Others 193 | ClientBin/ 194 | ~$* 195 | *~ 196 | *.dbmdl 197 | *.dbproj.schemaview 198 | *.jfm 199 | *.pfx 200 | *.publishsettings 201 | node_modules/ 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | 223 | # Business Intelligence projects 224 | *.rdl.data 225 | *.bim.layout 226 | *.bim_*.settings 227 | 228 | # Microsoft Fakes 229 | FakesAssemblies/ 230 | 231 | # GhostDoc plugin setting file 232 | *.GhostDoc.xml 233 | 234 | # Node.js Tools for Visual Studio 235 | .ntvs_analysis.dat 236 | 237 | # Visual Studio 6 build log 238 | *.plg 239 | 240 | # Visual Studio 6 workspace options file 241 | *.opt 242 | 243 | # Visual Studio LightSwitch build output 244 | **/*.HTMLClient/GeneratedArtifacts 245 | **/*.DesktopClient/GeneratedArtifacts 246 | **/*.DesktopClient/ModelManifest.xml 247 | **/*.Server/GeneratedArtifacts 248 | **/*.Server/ModelManifest.xml 249 | _Pvt_Extensions 250 | 251 | # Paket dependency manager 252 | .paket/paket.exe 253 | paket-files/ 254 | 255 | # FAKE - F# Make 256 | .fake/ 257 | 258 | # JetBrains Rider 259 | .idea/ 260 | *.sln.iml 261 | 262 | # CodeRush 263 | .cr/ 264 | 265 | # Python Tools for Visual Studio (PTVS) 266 | __pycache__/ 267 | *.pyc 268 | -------------------------------------------------------------------------------- /Icons/icon_daemon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_daemon.png -------------------------------------------------------------------------------- /Icons/icon_payload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_payload.png -------------------------------------------------------------------------------- /Icons/icon_pkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_pkg.png -------------------------------------------------------------------------------- /Icons/icon_plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_plugin.png -------------------------------------------------------------------------------- /Icons/icon_reboot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_reboot.png -------------------------------------------------------------------------------- /Icons/icon_reload_ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_reload_ui.png -------------------------------------------------------------------------------- /Icons/icon_shutdown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_shutdown.png -------------------------------------------------------------------------------- /Icons/icon_suspend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_suspend.png -------------------------------------------------------------------------------- /Icons/icon_system_settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_system_settings.png -------------------------------------------------------------------------------- /Icons/icon_toolbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSM-Made/Orbis-Toolbox/1d9a1baa91f9d12f1a6a7a646af1a3d77ebab7d1/Icons/icon_toolbox.png -------------------------------------------------------------------------------- /Loader/.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "E:\\Modding\\PS4\\Projects\\2020\\FreeBSD\\include/**", 8 | ], 9 | "defines": [ 10 | "_DEBUG", 11 | "UNICODE", 12 | "_UNICODE" 13 | ], 14 | "windowsSdkVersion": "10.0.17763.0", 15 | "compilerPath": "/usr/bin/gcc", 16 | "cStandard": "c11", 17 | "intelliSenseMode": "gcc-x64" 18 | } 19 | ], 20 | "version": 4 21 | } -------------------------------------------------------------------------------- /Loader/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "typeinfo": "cpp", 4 | "cstdarg": "cpp", 5 | "common.h": "c", 6 | "ptrace.h": "c", 7 | "utils.h": "c", 8 | "resolver.h": "c", 9 | "patches.h": "c" 10 | } 11 | } -------------------------------------------------------------------------------- /Loader/Common/Settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define MAJOR_VERSION 1 4 | #define MINOR_VERSION 0 5 | 6 | //Which software version we want to compile for 7 | #define SOFTWARE_VERSION_NA 8 | #ifdef VERSION_505 9 | #define VERSION_NUM 505 10 | #define SOFTWARE_VERSION_505 11 | #undef SOFTWARE_VERSION_NA 12 | #endif 13 | #ifdef VERSION_672 14 | #define VERSION_NUM 672 15 | #define SOFTWARE_VERSION_672 16 | #undef SOFTWARE_VERSION_NA 17 | #endif 18 | #ifdef VERSION_702 19 | #define VERSION_NUM 702 20 | #define SOFTWARE_VERSION_702 21 | #undef SOFTWARE_VERSION_NA 22 | #endif 23 | #ifdef VERSION_755 24 | #define VERSION_NUM 755 25 | #define SOFTWARE_VERSION_755 26 | #undef SOFTWARE_VERSION_NA 27 | #endif 28 | #ifdef VERSION_900 29 | #define VERSION_NUM 900 30 | #define SOFTWARE_VERSION_900 31 | #undef SOFTWARE_VERSION_NA 32 | #endif -------------------------------------------------------------------------------- /Loader/Kernel/Linker: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 2 | OUTPUT_ARCH(i386:x86-64) 3 | 4 | ENTRY(_start) 5 | 6 | PHDRS 7 | { 8 | code PT_LOAD FILEHDR PHDRS; 9 | headers PT_PHDR PHDRS; 10 | text PT_LOAD FILEHDR PHDRS; 11 | data PT_LOAD; 12 | bss PT_LOAD; 13 | } 14 | 15 | SECTIONS 16 | { 17 | .text 0x500: { *(.text) } :code 18 | .rodata : { 19 | *(.rodata) 20 | *(.rodata.*) 21 | *(.data) 22 | *(.data.*) 23 | } :text 24 | .data : { 25 | *(.data) 26 | } :data 27 | .bss : { *(.bss) } 28 | /DISCARD/ : { *(.eh_frame) } 29 | } 30 | -------------------------------------------------------------------------------- /Loader/Kernel/Makefile: -------------------------------------------------------------------------------- 1 | CC := g++ 2 | AS := g++ 3 | OBJCOPY := objcopy 4 | ODIR := build 5 | SDIR := source 6 | IDIRS := -Iinclude -I$(FREEBSD_INCLUDES) 7 | CFLAGS := $(IDIRS) -O3 -s -w -std=gnu++11 -fno-builtin -fno-exceptions -fno-asynchronous-unwind-tables -nostartfiles -nostdlib -w -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=small -mstackrealign -fPIE -DVERSION_$(VERSION) 8 | LFLAGS := -Xlinker -T Linker -Wl,--build-id=none -mstackrealign -pie 9 | SFLAGS := -nostartfiles -nostdlib -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=small 10 | CFILES := $(shell find $(SDIR) -name \*.cpp) 11 | SFILES := $(shell find $(SDIR) -name \*.s) 12 | OBJS := $(patsubst $(SDIR)/%,$(ODIR)/%,$(CFILES:.cpp=.o)) $(patsubst $(SDIR)/%,$(ODIR)/%,$(SFILES:.s=.o)) 13 | 14 | TARGET = $(shell basename "$(CURDIR)").ELF 15 | 16 | $(TARGET): $(ODIR) $(OBJS) 17 | $(CC) crt0.s $(OBJS) -o $(TARGET) $(CFLAGS) $(LFLAGS) 18 | 19 | $(ODIR)/%.o: $(SDIR)/%.cpp 20 | mkdir -p $(dir $@) 21 | $(CC) -c -o $@ $< $(CFLAGS) 22 | 23 | $(ODIR)/%.o: $(SDIR)/%.s 24 | $(AS) -c -o $@ $< $(SFLAGS) 25 | 26 | $(ODIR): 27 | @mkdir $@ 28 | 29 | .PHONY: clean 30 | 31 | clean: 32 | rm -rf -v $(TARGET) $(ODIR)/* -------------------------------------------------------------------------------- /Loader/Kernel/crt0.s: -------------------------------------------------------------------------------- 1 | .intel_syntax noprefix 2 | .text 3 | .global _start 4 | _start: 5 | jmp _main -------------------------------------------------------------------------------- /Loader/Kernel/include/Common.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sys/types.h" 3 | 4 | #ifndef NULL 5 | #define NULL 0 6 | #endif 7 | 8 | #ifndef true 9 | #define true 1 10 | #endif 11 | 12 | #ifndef false 13 | #define false 0 14 | #endif 15 | 16 | #include 17 | #include 18 | 19 | #include "../../Common/Settings.h" 20 | 21 | extern "C" 22 | { 23 | #include 24 | //#include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | //#include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | #include "sys/mount.h" 49 | } 50 | 51 | #include "Util/Util.hpp" 52 | #include "Resolver/Resolver.hpp" 53 | 54 | #define SPRX_PATH "/data/Orbis Toolbox/Orbis Toolbox.sprx" -------------------------------------------------------------------------------- /Loader/Kernel/include/Loader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct OrbisLoader_header 4 | { 5 | uint32_t magic; 6 | uint64_t entry; 7 | 8 | uint64_t thr_initial; 9 | uint8_t ShellCodeComplete; 10 | 11 | char SPRXPath[100]; 12 | uint64_t ModuleHandle; 13 | }__attribute__((packed)); 14 | 15 | bool Load_SPRX(proc* proc, const char* File); 16 | -------------------------------------------------------------------------------- /Loader/Kernel/include/Resolver/Resolver-505.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_sysvec 0x19BBCD0 8 | #define addr_prison0 0x10986A0 9 | #define addr_rootvnode 0x22C1A70 10 | 11 | /* STD Lib */ 12 | #define addr_M_TEMP 0x14B4110 13 | #define addr_M_MOUNT 0x19BF300 14 | #define addr_malloc 0x10E250 15 | #define addr_free 0x10E460 16 | #define addr_memcpy 0x1EA530 17 | #define addr_memset 0x3205C0 18 | #define addr_memcmp 0x50AC0 19 | #define addr_strlen 0x3B71A0 20 | #define addr_strcpy 0x8F250 21 | #define addr_strncpy 0x3C0B0 22 | #define addr_strcmp 0x1D0FD0 23 | #define addr_strstr 0x17DFB0 24 | #define addr_sprintf 0x436280 25 | #define addr_snprintf 0x436350 26 | #define addr_vsprintf 0x436310 27 | #define addr_vprintf 0x4360B0 28 | #define addr_sscanf 0x175900 29 | #define addr_strdup 0x1C1C30 30 | #define addr_realloc 0x10E590 31 | #define addr_kprintf 0x436040 32 | 33 | /* File IO */ 34 | #define addr_vn_fullpath 0xA11A0 35 | #define addr_kern_rmdir 0x340EE0 36 | #define addr_kern_mkdir 0x340B70 37 | #define addr_kern_open 0x33B9B0 38 | #define addr_kern_mount 0x1E1920 39 | #define addr_mount_argf 0x1E1780 40 | 41 | /* Event Handling */ 42 | #define addr_eventhandler_register 0x1EC400 43 | #define addr_eventhandler_deregister 0x1EC790 44 | #define addr_eventhandler_find_list 0x1EC980 45 | 46 | /* Proc */ 47 | #define addr_allproc 0x2382FF8 48 | #define addr_proc_kill 0xD41C0 49 | #define addr_proc_rwmem 0x30D150 50 | #define addr_create_thread 0x1BE1F0 51 | 52 | /* Kproc */ 53 | #define addr_kproc_create 0x137DF0 54 | #define addr_kproc_exit 0x138060 55 | #define addr_kproc_kthread_add 0x138B70 56 | #define addr_kthread_exit 0x138640 57 | #define addr_kthread_suspend_check 0x138A60 58 | #define addr_pause 0x3FB920 59 | 60 | /* Module Offsets */ 61 | #define addr_thr_initial_libkernel 0x84C20 62 | #define addr_thr_initial_libkernel_web 0x84C20 63 | #define addr_thr_initial_libkernel_sys 0x89030 64 | 65 | /* Virtual Memory */ 66 | #define addr_vmspace_acquire_ref 0x19EF90 67 | #define addr_vmspace_free 0x19EDC0 68 | #define addr_vm_map_lock_read 0x19F140 69 | #define addr_vm_map_unlock_read 0x19F190 70 | #define addr_vm_map_lookup_entry 0x19F760 71 | #define addr_vm_map_findspace 0x1A1F60 72 | #define addr_vm_map_insert 0x1A0280 73 | #define addr_vm_map_lock 0x19EFF0 74 | #define addr_vm_map_unlock 0x19F060 75 | #define addr_vm_map_delete 0x1A19D0 76 | #define addr_vm_map_protect 0x1A3A50 77 | 78 | #endif -------------------------------------------------------------------------------- /Loader/Kernel/include/Resolver/Resolver-672.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_672) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_sysvec 0x1A8A398 8 | #define addr_prison0 0x113E518 9 | #define addr_rootvnode 0x2300320 10 | 11 | /* STD Lib */ 12 | #define addr_M_TEMP 0x1540EB0 13 | #define addr_M_MOUNT 0x1A90CA0 14 | #define addr_malloc 0xD7A0 15 | #define addr_free 0xD9A0 16 | #define addr_memcpy 0x3C15B0 17 | #define addr_memset 0x1687D0 18 | #define addr_memcmp 0x207E40 19 | #define addr_strlen 0x2433E0 20 | #define addr_strcpy 0x2390C0 21 | #define addr_strncpy 0x329010 22 | #define addr_strcmp 0x341810 23 | #define addr_strstr 0x4817F0 24 | #define addr_sprintf 0x1234C0 25 | #define addr_snprintf 0x123590 26 | #define addr_vsprintf 0x123550 27 | #define addr_vprintf 0x1232F0 28 | #define addr_sscanf 0x243810 29 | #define addr_strdup 0x2504C0 30 | #define addr_realloc 0xDAD0 31 | #define addr_kprintf 0x123280 32 | 33 | /* File IO */ 34 | #define addr_vn_fullpath 0x2F0C40 35 | #define addr_kern_rmdir 0x4A3DF0 36 | #define addr_kern_mkdir 0x4A3A80 37 | #define addr_kern_open 0x49E990 38 | #define addr_kern_mount 0x442F90 39 | #define addr_mount_argf 0x442DE0 40 | 41 | /* Event Handling */ 42 | #define addr_eventhandler_register 0x402E80 43 | #define addr_eventhandler_deregister 0x403220 44 | #define addr_eventhandler_find_list 0x403420 45 | 46 | /* Proc */ 47 | #define addr_allproc 0x22BBE80 48 | #define addr_proc_kill 0x2DC80 49 | #define addr_proc_rwmem 0x10EE10 50 | #define addr_create_thread 0x4A6FB0 51 | 52 | /* Kproc */ 53 | #define addr_kproc_create 0x8A0A0 54 | #define addr_kproc_exit 0x8A310 55 | #define addr_kproc_kthread_add 0x8AE20 56 | #define addr_kthread_exit 0x8A8F0 57 | #define addr_kthread_suspend_check 0x8AD10 58 | #define addr_pause 0x22A080 59 | 60 | /* Module Offsets */ 61 | #define addr_thr_initial_libkernel 0x435420 62 | #define addr_thr_initial_libkernel_web 0x435420 63 | #define addr_thr_initial_libkernel_sys 0x435830 64 | 65 | /* Virtual Memory */ 66 | #define addr_vmspace_acquire_ref 0x44CB90 67 | #define addr_vmspace_free 0x44C9C0 68 | #define addr_vm_map_lock_read 0x44CD40 69 | #define addr_vm_map_unlock_read 0x44CD90 70 | #define addr_vm_map_lookup_entry 0x44D330 71 | #define addr_vm_map_findspace 0x44FE60 72 | #define addr_vm_map_insert 0x44DEF0 73 | #define addr_vm_map_lock 0x44CBF0 74 | #define addr_vm_map_unlock 0x44CC60 75 | #define addr_vm_map_delete 0x44F8A0 76 | #define addr_vm_map_protect 0x451BF0 77 | 78 | #endif -------------------------------------------------------------------------------- /Loader/Kernel/include/Resolver/Resolver-702.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_702) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_sysvec 0x1A4F460 8 | #define addr_prison0 0x113E398 9 | #define addr_rootvnode 0x22C5750 10 | 11 | /* STD Lib */ 12 | #define addr_M_TEMP 0x1A7AE50 13 | #define addr_M_MOUNT 0x1A71A70 14 | #define addr_malloc 0x301840 15 | #define addr_free 0x301A40 16 | #define addr_memcpy 0x2F040 17 | #define addr_memset 0x2DFC20 18 | #define addr_memcmp 0x207500 19 | #define addr_strlen 0x93FF0 20 | #define addr_strcpy 0x2CC70 21 | #define addr_strncpy 0xF9E40 22 | #define addr_strcmp 0x43B5F0 23 | #define addr_strstr 0x5740 24 | #define addr_sprintf 0xBC970 25 | #define addr_snprintf 0xBCA30 26 | #define addr_vsprintf 0xBCA00 27 | #define addr_vprintf 0xBC7A0 28 | #define addr_sscanf 0x2077A0 29 | #define addr_strdup 0x382B0 30 | #define addr_realloc 0x301B70 31 | #define addr_kprintf 0xBC730 32 | 33 | /* File IO */ 34 | #define addr_vn_fullpath 0x15F470 35 | #define addr_kern_rmdir 0x35ADE0 36 | #define addr_kern_mkdir 0x35AA60 37 | #define addr_kern_open 0x355960 38 | #define addr_kern_mount 0x299080 39 | #define addr_mount_argf 0x298ED0 40 | 41 | /* Event Handling */ 42 | #define addr_eventhandler_register 0x483810 43 | #define addr_eventhandler_deregister 0x483BB0 44 | #define addr_eventhandler_find_list 0x483DB0 45 | 46 | /* Proc */ 47 | #define addr_allproc 0x1B48318 48 | #define addr_proc_kill 0x313B90 49 | #define addr_proc_rwmem 0x43E80 50 | #define addr_create_thread 0x842E0 51 | 52 | /* Kproc */ 53 | #define addr_kproc_create 0xC4170 54 | #define addr_kproc_exit 0xC43E0 55 | #define addr_kproc_kthread_add 0xC4EE0 56 | #define addr_kthread_exit 0xC49C0 57 | #define addr_kthread_suspend_check 0xC4DD0 58 | #define addr_pause 0x16EEE0 59 | 60 | /* Module Offsets */ 61 | #define addr_thr_initial_libkernel 0x8D420 62 | #define addr_thr_initial_libkernel_web 0x8D420 63 | #define addr_thr_initial_libkernel_sys 0x8D830 64 | 65 | /* Virtual Memory */ 66 | #define addr_vmspace_acquire_ref 0x25F9F0 67 | #define addr_vmspace_free 0x25F820 68 | #define addr_vm_map_lock_read 0x25FB90 69 | #define addr_vm_map_unlock_read 0x25FBE0 70 | #define addr_vm_map_lookup_entry 0x260190 71 | #define addr_vm_map_findspace 0x262CC0 72 | #define addr_vm_map_insert 0x260D60 73 | #define addr_vm_map_lock 0x25FA50 74 | #define addr_vm_map_unlock 0x25FAB0 75 | #define addr_vm_map_delete 0x262700 76 | #define addr_vm_map_protect 0x264A50 77 | 78 | #endif -------------------------------------------------------------------------------- /Loader/Kernel/include/Resolver/Resolver-755.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_755) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_sysvec 0x1564E80 8 | #define addr_prison0 0x113B728 9 | #define addr_rootvnode 0x1B463E0 10 | 11 | /* STD Lib */ 12 | #define addr_M_TEMP 0x1556DA0 13 | #define addr_M_MOUNT 0x1543A60 14 | #define addr_malloc 0x1D6680 15 | #define addr_free 0x2FC0C0 16 | #define addr_memcpy 0x28F800 17 | #define addr_memset 0x8D6F0 18 | #define addr_memcmp 0x31D250 19 | #define addr_strlen 0x2E8BC0 20 | #define addr_strcpy 0x46B0B0 21 | #define addr_strncpy 0x21B800 22 | #define addr_strcmp 0x104BA0 23 | #define addr_strstr 0x3B0250 24 | #define addr_sprintf 0x26F980 25 | #define addr_snprintf 0x26FA40 26 | #define addr_vsprintf 0x26FA10 27 | #define addr_vprintf 0x26F7B0 28 | #define addr_sscanf 0x1C4840 29 | #define addr_strdup 0x110FA0 30 | #define addr_realloc 0x1D69A0 31 | #define addr_kprintf 0x26F740 32 | 33 | /* File IO */ 34 | #define addr_vn_fullpath 0x2C3570 35 | #define addr_kern_rmdir 0xF9E90 36 | #define addr_kern_mkdir 0xF9B10 37 | #define addr_kern_open 0xF49E0 38 | #define addr_kern_mount 0x790D0 39 | #define addr_mount_argf 0x78F20 40 | 41 | /* Event Handling */ 42 | #define addr_eventhandler_register 0xD3670 43 | #define addr_eventhandler_deregister 0xD3A00 44 | #define addr_eventhandler_find_list 0xD3C00 45 | 46 | /* Proc */ 47 | #define addr_allproc 0x213C828 48 | #define addr_proc_kill 0x45FF30 49 | #define addr_proc_rwmem 0x361310 50 | #define addr_create_thread 0x47AB60 51 | 52 | /* Kproc */ 53 | #define addr_kproc_create 0xD8F0 54 | #define addr_kproc_exit 0xDB60 55 | #define addr_kproc_kthread_add 0xE670 56 | #define addr_kthread_exit 0xE140 57 | #define addr_kthread_suspend_check 0xE550 58 | #define addr_pause 0x86E80 59 | 60 | /* Module Offsets */ 61 | #define addr_thr_initial_libkernel 0x8D420 62 | #define addr_thr_initial_libkernel_web 0x8D420 63 | #define addr_thr_initial_libkernel_sys 0x8D830 64 | 65 | /* Virtual Memory */ 66 | #define addr_vmspace_acquire_ref 0x2FC290 67 | #define addr_vmspace_free 0x2FC0C0 68 | #define addr_vm_map_lock_read 0x2FC430 69 | #define addr_vm_map_unlock_read 0x2FC480 70 | #define addr_vm_map_lookup_entry 0x2FCA70 71 | #define addr_vm_map_findspace 0x2FF560 72 | #define addr_vm_map_insert 0x2FD640 73 | #define addr_vm_map_lock 0x2FC2E0 74 | #define addr_vm_map_unlock 0x2FC350 75 | #define addr_vm_map_delete 0x2FEFA0 76 | #define addr_vm_map_protect 0x3012F0 77 | 78 | #endif -------------------------------------------------------------------------------- /Loader/Kernel/include/Resolver/Resolver-900.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_900) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x000001C0 7 | #define addr_sysvec 0x01528E30 8 | #define addr_prison0 0x0111F870 9 | #define addr_rootvnode 0x021EFF20 10 | 11 | /* STD Lib */ 12 | #define addr_M_TEMP 0x015621E0 13 | #define addr_M_MOUNT 0x015279F0 14 | #define addr_malloc 0x00301B20 15 | #define addr_free 0x00301CE0 16 | #define addr_memcpy 0x002714B0 17 | #define addr_memset 0x001496C0 18 | #define addr_memcmp 0x00271E20 19 | #define addr_strlen 0x0030F450 20 | #define addr_strcpy 0x00189F80 21 | #define addr_strncpy 0x0041E380 22 | #define addr_strcmp 0x0040E700 23 | #define addr_strstr 0x00487AB0 24 | #define addr_sprintf 0x000B7C70 25 | #define addr_snprintf 0x000B7D30 26 | #define addr_vsprintf 0x000B7D00 27 | #define addr_vprintf 0x000B7AA0 28 | #define addr_sscanf 0x0026C8D0 29 | #define addr_strdup 0x00278540 30 | #define addr_realloc 0x00301DE0 31 | #define addr_kprintf 0x000B7A30 32 | 33 | /* File IO */ 34 | #define addr_vn_fullpath 0x002648C0 35 | #define addr_kern_rmdir 0x001DF3A0 36 | #define addr_kern_mkdir 0x001DF020 37 | #define addr_kern_open 0x001D9EE0 38 | #define addr_kern_mount 0x0004DF50 39 | #define addr_mount_argf 0x0004DDB0 40 | 41 | /* Event Handling */ 42 | #define addr_eventhandler_register 0x000F8370 43 | #define addr_eventhandler_deregister 0x000F8700 44 | #define addr_eventhandler_find_list 0x000F88F0 45 | 46 | /* Proc */ 47 | #define addr_allproc 0x01B946E0 48 | #define addr_proc_kill 0x00029780 49 | #define addr_proc_rwmem 0x0041EB00 50 | #define addr_create_thread 0x001ED670 51 | 52 | /* Kproc */ 53 | #define addr_kproc_create 0x000969E0 54 | #define addr_kproc_exit 0x00096C50 55 | #define addr_kproc_kthread_add 0x00097750 56 | #define addr_kthread_exit 0x00097230 57 | #define addr_kthread_suspend_check 0x00097640 58 | #define addr_pause 0x00453EA0 59 | 60 | /* Module Offsets */ 61 | #define addr_thr_initial_libkernel 0x0008E430 62 | #define addr_thr_initial_libkernel_web 0x0008E430 63 | #define addr_thr_initial_libkernel_sys 0x0008E830 64 | 65 | /* Virtual Memory */ 66 | #define addr_vmspace_acquire_ref 0x0007B9E0 67 | #define addr_vmspace_free 0x0007B810 68 | #define addr_vm_map_lock_read 0x0007BB80 69 | #define addr_vm_map_unlock_read 0x0007BBD0 70 | #define addr_vm_map_lookup_entry 0x0007C1C0 71 | #define addr_vm_map_findspace 0x0007EC40 72 | #define addr_vm_map_insert 0x0007CD80 73 | #define addr_vm_map_lock 0x0007BA30 74 | #define addr_vm_map_unlock 0x0007BAA0 75 | #define addr_vm_map_delete 0x0007E680 76 | #define addr_vm_map_protect 0x000809C0 77 | 78 | #endif -------------------------------------------------------------------------------- /Loader/Kernel/include/Resolver/Resolver.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../Common/Settings.h" 3 | 4 | #include "Resolver-505.hpp" 5 | #include "Resolver-672.hpp" 6 | #include "Resolver-702.hpp" 7 | #include "Resolver-755.hpp" 8 | #include "Resolver-900.hpp" 9 | 10 | /* Util */ 11 | extern struct sysentvec* sysvec; 12 | extern struct prison* prison0; 13 | extern struct vnode* rootvnode; 14 | 15 | /* STD Lib */ 16 | extern void *M_TEMP; 17 | extern void* M_MOUNT; 18 | extern void *(*malloc)(unsigned long size, void *type, int flags); 19 | extern void (*free)(void *addr, void *type); 20 | extern void (*memcpy)(void *dst, const void *src, size_t len); 21 | extern void *(*memset)(void *ptr, int value, size_t num); 22 | extern int (*memcmp)(const void *ptr1, const void *ptr2, size_t num); 23 | extern size_t (*strlen)(const char *str); 24 | extern int (*strcpy)(char * str1, char * str2); 25 | extern char* (*strncpy)(char *destination, const char *source, size_t num); 26 | extern int (*strcmp)(const char * str1, const char * str2); 27 | extern char* (*strstr)(const char * str1, const char * str2); 28 | extern int (*sprintf)(char* dst, const char *fmt, ...); 29 | extern int (*snprintf)(char *str, size_t size, const char *format, ...); 30 | extern int (*vsprintf)(char* dst, const char* fmt, va_list ap); 31 | extern int (*vprintf)(const char *fmt, va_list arg); 32 | extern int(*sscanf)(const char *str, const char *format, ...); 33 | extern char *(*strdup)(const char *s, void* type); 34 | extern char *(*realloc)(void *addr, unsigned long size, void* mtp, int flags); 35 | extern void(*kprintf)(const char* fmt, ...); 36 | 37 | /* FileIO */ 38 | extern int (*vn_fullpath)(struct thread *td, struct vnode *vp, char **retbuf, char **freebuf); 39 | extern int (*kern_rmdir)(thread* td, char *path, int flags); 40 | extern int (*kern_mkdir)(thread* td, char *path, int pathseg, int mode); 41 | extern int (*kern_open)(thread* td, char *path, int pathseg, int flags, int mode); 42 | extern int (*kern_mount)(struct mntarg *ma, int flags); 43 | extern struct mntarg*(*mount_argf)(struct mntarg *ma, const char *name, const char *fmt, ...); 44 | 45 | /* Event Handling */ 46 | #ifdef SOFTWARE_VERSION_505 || SOFTWARE_VERSION_NA 47 | extern eventhandler_tag (*eventhandler_register)(eventhandler_list *list, const char *name, void *func, void *arg, int priority); 48 | #endif 49 | #if defined(SOFTWARE_VERSION_672) || defined(SOFTWARE_VERSION_702) || defined(SOFTWARE_VERSION_755) || defined(SOFTWARE_VERSION_900) 50 | extern eventhandler_tag (*eventhandler_register)(eventhandler_list *list, const char *name, void *func, const char* unk, void *arg, int priority); 51 | #endif 52 | extern void (*eventhandler_deregister)(eventhandler_list* a, eventhandler_entry* b); 53 | extern eventhandler_list* (*eventhandler_find_list)(const char *name); 54 | 55 | /* 56 | process_exec 57 | process_exit 58 | 59 | system_suspend_phase1 60 | system_resume_phase1 61 | shutdown_pre_sync 62 | */ 63 | 64 | #ifdef SOFTWARE_VERSION_505 65 | #define EVENTHANDLER_REGISTER(name, func, arg, priority) \ 66 | eventhandler_register(NULL, #name, func, arg, priority) 67 | #endif 68 | #if defined(SOFTWARE_VERSION_672) || defined(SOFTWARE_VERSION_702) || defined(SOFTWARE_VERSION_755) || defined(SOFTWARE_VERSION_900) 69 | #define EVENTHANDLER_REGISTER(name, func, arg, priority) \ 70 | eventhandler_register(NULL, #name, func, "", arg, priority) 71 | #endif 72 | 73 | 74 | #define EVENTHANDLER_DEREGISTER(name, tag) \ 75 | do { \ 76 | struct eventhandler_list *_el; \ 77 | \ 78 | if ((_el = eventhandler_find_list(#name)) != NULL) \ 79 | eventhandler_deregister(_el, tag); \ 80 | } while(0) 81 | 82 | /* Proc */ 83 | extern proc *allproc; 84 | extern int (*proc_kill)(proc *p, char* why); 85 | extern int (*proc_rwmem)(proc *p, uio *uio); 86 | extern int (*create_thread)(thread * td, uint64_t ctx, void* start_func, void *arg, char *stack_base, size_t stack_size, char *tls_base, long * child_tid, long * parent_tid, uint64_t flags, uint64_t rtp); 87 | 88 | /* kproc */ 89 | extern int (*kproc_create)(void (*func)(void *), void *arg, proc **newpp, int flags, int pages, const char *fmt, ...); 90 | extern int (*kproc_exit)(int code); 91 | extern int (*kproc_kthread_add)(void (*func)(void *), void *arg, proc **procptr, thread **tdptr, int flags, int pages, char * procname, const char *fmt, ...); 92 | extern void (*kthread_exit)(void); 93 | extern void (*kthread_suspend_check)(void); 94 | extern void (*pause)(const char *wmesg, int timo); 95 | 96 | /* Virtual Memory */ 97 | extern vmspace *(*vmspace_acquire_ref)(proc* p); 98 | extern void (*vmspace_free)(vmspace* vm); 99 | extern void (*vm_map_lock_read)(vm_map* map); 100 | extern void (*vm_map_unlock_read)(vm_map* map); 101 | extern int (*vm_map_lookup_entry)(vm_map* map, uint64_t address, vm_map_entry **entries); 102 | extern int (*vm_map_findspace)(vm_map* map, uint64_t start, uint64_t length, uint64_t *addr); 103 | extern int (*vm_map_insert)(vm_map* map, uint64_t object, uint64_t offset, uint64_t start, uint64_t end, int prot, int max, int cow); 104 | extern void (*vm_map_lock)(vm_map* map); 105 | extern void (*vm_map_unlock)(vm_map* map); 106 | extern int (*vm_map_delete)(vm_map* map, uint64_t start, uint64_t end); 107 | extern int (*vm_map_protect)(vm_map* map, uint64_t start, uint64_t end, int new_prot, uint64_t set_max); 108 | 109 | void Resolve(uint64_t Kernel_Base); -------------------------------------------------------------------------------- /Loader/Kernel/include/Util/Proc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern "C" 4 | { 5 | #include 6 | } 7 | 8 | proc* GetCurrentGame(); 9 | int get_proc_count(); 10 | proc *proc_find_by_name(const char *name); 11 | proc *proc_find_by_pid(int pid); 12 | 13 | int proc_rw_mem(proc *p, void *ptr, size_t size, void *data, size_t *n, int write); 14 | int proc_read_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n); 15 | int proc_write_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n); 16 | int proc_allocate(struct proc *p, void **address, size_t size); 17 | int proc_deallocate(proc *p, void *address, size_t size); 18 | int proc_mprotect(proc *p, void *address, void *end, int new_prot); 19 | uint64_t proc_alloc_size(uint64_t p); 20 | -------------------------------------------------------------------------------- /Loader/Kernel/include/Util/Util.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define offsetof(st, m) ((size_t)((char *)&((st *)(0))->m - (char *)0)) 4 | #define COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x]))))) 5 | 6 | static inline thread *curthread(void) { 7 | struct thread* td; 8 | __asm__ __volatile__ ( 9 | "mov %0, %%gs:0" 10 | : "=r"(td) 11 | ); 12 | 13 | return td; 14 | } 15 | 16 | static inline __attribute__((always_inline)) uint64_t __readmsr(uint32_t __register) { 17 | uint32_t __edx, __eax; 18 | 19 | __asm__ volatile ( 20 | "rdmsr" 21 | : "=d"(__edx), 22 | "=a"(__eax) 23 | : "c"(__register) 24 | ); 25 | 26 | return (((uint64_t)__edx) << 32) | (uint64_t)__eax; 27 | } 28 | 29 | static inline __attribute__((always_inline)) uint64_t __readcr0(void) { 30 | uint64_t cr0; 31 | 32 | __asm__ volatile ( 33 | "movq %0, %%cr0" 34 | : "=r" (cr0) 35 | : : "memory" 36 | ); 37 | 38 | return cr0; 39 | } 40 | static inline __attribute__((always_inline)) void __writecr0(uint64_t cr0) { 41 | __asm__ volatile ( 42 | "movq %%cr0, %0" 43 | : : "r" (cr0) 44 | : "memory" 45 | ); 46 | } 47 | 48 | bool MountDir(thread* td, char* Sandbox, char* what, int flags); 49 | bool UnMountDir(thread* td, char* Sandbox, char* what, int flags); 50 | bool Mount_Dirs(proc* p, vnode* jdir, bool Mount); 51 | 52 | char* strrchr(const char *cp, int ch); 53 | char* strchr(const char *s, int c); 54 | char* basename(const char *filename); 55 | 56 | struct Backup_Jail 57 | { 58 | prison* cr_prison; 59 | uid_t cr_uid; 60 | uid_t cr_ruid; 61 | gid_t cr_rgid; 62 | gid_t cr_groups; 63 | 64 | vnode* fd_jdir; 65 | vnode* fd_rdir; 66 | }; 67 | 68 | void Jailbreak(proc* proc, Backup_Jail* jail); 69 | void RestoreJail(proc* proc, Backup_Jail jail); 70 | 71 | int klog(char* fmt, ...); 72 | int sys_unmount(const char *dir, int flags); -------------------------------------------------------------------------------- /Loader/Kernel/include/kproc.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //Event Handlers 4 | extern eventhandler_entry* ProcessStartEvent; 5 | extern eventhandler_entry* ProcessExitEvent; 6 | 7 | void kproc_Init(); 8 | void kproc_Term(); 9 | -------------------------------------------------------------------------------- /Loader/Kernel/source/Loader.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.hpp" 2 | #include "Loader.hpp" 3 | #include "Util/Proc.hpp" 4 | #include "Util/Util.hpp" 5 | 6 | void* gShellCodePtr = NULL; 7 | void* gStackPtr = NULL; 8 | size_t gShellCodeSize = 0; 9 | bool ShellCodeLoaded = false; 10 | char ProcName[0x20] = { }; 11 | 12 | extern uint8_t LoaderShellCode[]; 13 | extern int32_t LoaderShellCodeSize; 14 | 15 | bool Load_SPRX(proc* proc, const char* File) 16 | { 17 | klog("Load_SPRX(): \"%s\"", File); 18 | 19 | size_t n; 20 | int err = 0; 21 | uint64_t thr_initial = 0; 22 | uint8_t ShellCodeComplete = 0; 23 | uint64_t ModuleHandle = 0; 24 | 25 | if(!proc) 26 | { 27 | klog("Load_SPRX(): proc pointer was null."); 28 | return false; 29 | } 30 | 31 | if(proc->p_dynlibptr == NULL) 32 | { 33 | klog("Load_SPRX(): p_dynlibptr is NULL."); 34 | return false; 35 | } 36 | 37 | /* 38 | Gets the Thread Initial for the shellcore thread. Also checking to make sure were not trying to load a prx already loaded. 39 | */ 40 | 41 | dynlib* m_library = proc->p_dynlibptr->p_dynlib; 42 | while(m_library != 0) 43 | { 44 | if(!strcmp(basename(m_library->ModulePath), basename(File))) 45 | { 46 | klog("Load_SPRX(): Module %s is already loaded on proc %s...", basename(File), proc->p_comm); 47 | return false; 48 | } 49 | 50 | if(!strcmp(basename(m_library->ModulePath), "libkernel.sprx")) 51 | thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel; 52 | 53 | if(!strcmp(basename(m_library->ModulePath), "libkernel_web.sprx")) 54 | thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel_web; 55 | 56 | if(!strcmp(basename(m_library->ModulePath), "libkernel_sys.sprx")) 57 | thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel_sys; 58 | 59 | m_library = m_library->dynlib_next; 60 | } 61 | 62 | if(thr_initial == 0) 63 | { 64 | klog("Load_SPRX(): Failed to resolve thr_initial."); 65 | 66 | return false; 67 | } 68 | 69 | /* 70 | Allocate some memory on the heap to temporarily store the shellcode while we set our data. 71 | */ 72 | char* Loader_Temp = (char*)malloc(LoaderShellCodeSize, M_TEMP, 2); 73 | if(!Loader_Temp) 74 | { 75 | klog("Load_SPRX(): Failed to allocate heap space to store temp shellcode data..."); 76 | 77 | return false; 78 | } 79 | 80 | //Setting the shellcode instructions 81 | memcpy(Loader_Temp, LoaderShellCode, LoaderShellCodeSize); 82 | 83 | //Setting thread initial and sprx path. 84 | *(uint64_t*)(Loader_Temp + offsetof(OrbisLoader_header, thr_initial)) = thr_initial; 85 | strcpy(Loader_Temp + offsetof(OrbisLoader_header, SPRXPath), (char*)File); 86 | 87 | /* 88 | Allocate space on the process for the shellcode and its threads stack. 89 | */ 90 | gShellCodeSize = LoaderShellCodeSize; 91 | gShellCodeSize += (PAGE_SIZE - (gShellCodeSize % PAGE_SIZE)); 92 | if(proc_allocate(proc, &gShellCodePtr, gShellCodeSize)) 93 | { 94 | klog("Load_SPRX(): Failed to allocate ShellCode Memory."); 95 | 96 | free(Loader_Temp, M_TEMP); 97 | 98 | return false; 99 | } 100 | 101 | klog("Load_SPRX(): thr_initial = %llX", thr_initial); 102 | klog("Load_SPRX(): gShellCodePtr = %llX", gShellCodePtr); 103 | 104 | size_t StackSize = 0x80000; 105 | if(proc_allocate(proc, &gStackPtr, StackSize)) { 106 | klog("Load_SPRX(): Failed to allocate Stack Memory."); 107 | 108 | if (gShellCodePtr) 109 | proc_deallocate(proc, gShellCodePtr, gShellCodeSize); 110 | 111 | free(Loader_Temp, M_TEMP); 112 | 113 | return false; 114 | } 115 | 116 | /* 117 | Write the shellcode to the allocated memory on the process. 118 | */ 119 | err = proc_rw_mem(proc, gShellCodePtr, LoaderShellCodeSize, (void *)Loader_Temp, &n, 1); 120 | if(err) 121 | { 122 | klog("Load_SPRX(): Failed to write Shellcode to Memory. Error: %d.", err); 123 | 124 | if (gShellCodePtr) 125 | proc_deallocate(proc, gShellCodePtr, gShellCodeSize); 126 | 127 | if (gStackPtr) 128 | proc_deallocate(proc, gStackPtr, 0x80000); 129 | 130 | free(Loader_Temp, M_TEMP); 131 | 132 | return false; 133 | } 134 | 135 | /* 136 | Free up the heap space for the temp shellcode as we dont need it anymore. 137 | */ 138 | free(Loader_Temp, M_TEMP); 139 | 140 | /* 141 | Start a thread with the entry pointing to +0x4 in our shellcode because that holds the offset to the starting instructions. 142 | */ 143 | klog("Load_SPRX(): Starting Shellcode Thread..."); 144 | struct thread *thr = TAILQ_FIRST(&proc->p_threads); 145 | uint64_t ShellCodeEntry = (uint64_t)gShellCodePtr + *(uint64_t *)(LoaderShellCode + 4); 146 | create_thread(thr, NULL, (void*)ShellCodeEntry, NULL, (char*)gStackPtr, StackSize, NULL, NULL, NULL, 0, NULL); 147 | 148 | klog("Load_SPRX(): Thread Started!! Waiting for shellcode to complete..."); 149 | 150 | /* 151 | Wait for the shellcode to complete by reading the byte that will be set to 1 on completion. 152 | */ 153 | while (!ShellCodeComplete) 154 | { 155 | err = proc_rw_mem(proc, gShellCodePtr + offsetof(OrbisLoader_header, ShellCodeComplete), sizeof(ShellCodeComplete), (void *)&ShellCodeComplete, &n, 0); 156 | if(err) 157 | { 158 | klog("Load_SPRX(): Failed to read ShellCodeComplete."); 159 | return false; 160 | } 161 | 162 | //klog("Waiting for ShellCode to compelete!\n"); 163 | pause("", 100); 164 | } 165 | 166 | /* 167 | Grab the Module handle from the shellcode to see if the loading was a sucess or not. 168 | */ 169 | err = proc_rw_mem(proc, gShellCodePtr + offsetof(OrbisLoader_header, ModuleHandle), sizeof(ModuleHandle), (void *)&ModuleHandle, &n, 0); 170 | if(err) 171 | { 172 | klog("Load_SPRX(): Failed to read ModuleHandle."); 173 | return false; 174 | } 175 | 176 | /* 177 | Clean up. 178 | */ 179 | klog("Load_SPRX(): Freeing Shellcode Memory..."); 180 | if (gShellCodePtr) 181 | proc_deallocate(proc, gShellCodePtr, gShellCodeSize); 182 | 183 | if (gStackPtr) 184 | proc_deallocate(proc, gStackPtr, 0x80000); 185 | 186 | gShellCodePtr = NULL; 187 | gStackPtr = NULL; 188 | 189 | if(ModuleHandle > 0 && ModuleHandle < 0x80000000) 190 | { 191 | klog("Load_SPRX(): Completed! Module Loaded with handle 0x%llX", ModuleHandle); 192 | return true; 193 | } 194 | else 195 | { 196 | klog("Load_SPRX(): Failed with error 0x%llX", ModuleHandle); 197 | return false; 198 | } 199 | } -------------------------------------------------------------------------------- /Loader/Kernel/source/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.hpp" 2 | #include "kproc.hpp" 3 | #include "Loader.hpp" 4 | #include "Util/Proc.hpp" 5 | 6 | extern "C" int _main(uint64_t arg) 7 | { 8 | //Get kernel base address. 9 | uint64_t KernelBase = (__readmsr(0xC0000082) - addr_Xfast_syscall); 10 | 11 | if(!KernelBase) 12 | return 1; 13 | 14 | //Use kernel base address to resolve function addresses. 15 | Resolve(KernelBase); 16 | 17 | klog("!!! HELLO HELLO FROM KERNEL !!!"); 18 | 19 | //Init kernel process. 20 | kproc_Init(); 21 | 22 | return 0; 23 | } -------------------------------------------------------------------------------- /Loader/Kernel/source/Util/Proc.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.hpp" 2 | #include "Util/Proc.hpp" 3 | 4 | proc* GetCurrentGame() 5 | { 6 | proc *allproc = *(proc**)allproc; 7 | char TitleID[10]; 8 | strcpy(TitleID, "N/A"); 9 | 10 | while (allproc != NULL) 11 | { 12 | if(strstr(allproc->titleId, "CUSA")) 13 | break; 14 | 15 | allproc = allproc->p_list.le_next; 16 | } 17 | 18 | return allproc; 19 | } 20 | 21 | int get_proc_count() 22 | { 23 | int count = 0; 24 | proc *p = *(proc**)allproc; 25 | 26 | do { 27 | count++; 28 | } while ((p = p->p_list.le_next)); 29 | 30 | return count; 31 | } 32 | 33 | proc *proc_find_by_name(const char *name) 34 | { 35 | if (!name) { 36 | return NULL; 37 | } 38 | 39 | proc *p = *(proc**)allproc; 40 | 41 | do { 42 | //klog("%s\n", p->p_comm); 43 | if (!memcmp(p->p_comm, name, strlen(name))) { 44 | return p; 45 | } 46 | } while ((p = p->p_list.le_next)); 47 | 48 | return NULL; 49 | } 50 | 51 | proc *proc_find_by_pid(int pid) 52 | { 53 | proc *p = *(proc**)allproc; 54 | 55 | do { 56 | if (p->p_pid == pid) { 57 | return p; 58 | } 59 | } while ((p = p->p_list.le_next)); 60 | 61 | return NULL; 62 | } 63 | 64 | int proc_rw_mem(proc *p, void *ptr, size_t size, void *data, size_t *n, int write) 65 | { 66 | thread *td = curthread(); 67 | iovec iov; 68 | uio uio; 69 | int r = 0; 70 | 71 | if (!p) { 72 | return 1; 73 | } 74 | 75 | if (size == 0) { 76 | if (n) { 77 | *n = 0; 78 | } 79 | 80 | return 0; 81 | } 82 | 83 | memset(&iov, NULL, sizeof(iov)); 84 | iov.iov_base = (void*)data; 85 | iov.iov_len = size; 86 | 87 | memset(&uio, NULL, sizeof(uio)); 88 | uio.uio_iov = &iov; 89 | uio.uio_iovcnt = 1; 90 | uio.uio_offset = (uint64_t)ptr; 91 | uio.uio_resid = (uint64_t)size; 92 | uio.uio_segflg = UIO_SYSSPACE; 93 | uio.uio_rw = write ? UIO_WRITE : UIO_READ; 94 | uio.uio_td = td; 95 | 96 | r = proc_rwmem(p, &uio); 97 | 98 | if (n) { 99 | *n = (size_t)((uint64_t)size - uio.uio_resid); 100 | } 101 | 102 | return r; 103 | } 104 | 105 | int proc_read_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n) 106 | { 107 | return proc_rw_mem(p, ptr, size, data, n, 0); 108 | } 109 | 110 | int proc_write_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n) 111 | { 112 | return proc_rw_mem(p, ptr, size, data, n, 1); 113 | } 114 | 115 | int proc_allocate(struct proc *p, void **address, size_t size) { 116 | uint64_t addr = NULL; 117 | int r = 0; 118 | 119 | if (!address) 120 | return 1; 121 | 122 | vmspace *vm = p->p_vmspace; 123 | vm_map *map = &vm->vm_map; 124 | 125 | vm_map_lock(map); 126 | 127 | r = vm_map_findspace(map, NULL, size, &addr); 128 | if (r) { 129 | vm_map_unlock(map); 130 | return r; 131 | } 132 | 133 | r = vm_map_insert(map, NULL, NULL, addr, addr + size, VM_PROT_ALL, VM_PROT_ALL, 0); 134 | 135 | vm_map_unlock(map); 136 | 137 | if (r) 138 | return r; 139 | 140 | if (address) { 141 | *address = (void *)addr; 142 | } 143 | 144 | return r; 145 | } 146 | 147 | int proc_deallocate(proc *p, void *address, size_t size) { 148 | int r = 0; 149 | 150 | vmspace *vm = p->p_vmspace; 151 | vm_map *map = &vm->vm_map; 152 | 153 | vm_map_lock(map); 154 | 155 | r = vm_map_delete(map, (uint64_t)address, (uint64_t)address + size); 156 | 157 | vm_map_unlock(map); 158 | 159 | return r; 160 | } 161 | 162 | int proc_mprotect(proc *p, void *address, void *end, int new_prot) { 163 | int r = 0; 164 | 165 | uint64_t addr = (uint64_t)address; 166 | uint64_t addrend = (uint64_t)end; 167 | 168 | vmspace *vm = p->p_vmspace; 169 | vm_map *map = &vm->vm_map; 170 | 171 | r = vm_map_protect(map, addr, addrend, new_prot, 1); 172 | r = vm_map_protect(map, addr, addrend, new_prot, 0); 173 | 174 | return r; 175 | } 176 | 177 | 178 | uint64_t proc_alloc_size(uint64_t p) 179 | { 180 | uint64_t ldrsize = p; 181 | ldrsize += (PAGE_SIZE - (ldrsize % PAGE_SIZE)); 182 | return ldrsize; 183 | } -------------------------------------------------------------------------------- /Loader/Kernel/source/embed.s: -------------------------------------------------------------------------------- 1 | .section .rodata 2 | 3 | .global LoaderShellCode 4 | .type LoaderShellCode, @object 5 | .align 4 6 | 7 | LoaderShellCode: 8 | .incbin "../ShellCode/LoaderShellCode.bin" 9 | 10 | LoaderShellCodeEnd: 11 | .global LoaderShellCodeSize 12 | .type LoaderShellCodeSize, @object 13 | .align 4 14 | 15 | LoaderShellCodeSize: 16 | .int LoaderShellCodeEnd - LoaderShellCode 17 | -------------------------------------------------------------------------------- /Loader/Kernel/source/kproc.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.hpp" 2 | #include "kproc.hpp" 3 | #include "Loader.hpp" 4 | #include "Util/Proc.hpp" 5 | 6 | #define SHOULD_LOAD 7 | #define RESUME_WAIT 17000 8 | bool IsSystemResuming = false; 9 | 10 | //Event Handlers 11 | eventhandler_entry* SystemSuspendEvent; 12 | eventhandler_entry* SystemResumeEvent; 13 | eventhandler_entry* ProcessStartEvent; 14 | eventhandler_entry* ProcessExitEvent; 15 | 16 | void test_thread(void* arg) 17 | { 18 | proc* p = (proc*)arg; 19 | 20 | klog("Hello From thread.."); 21 | 22 | if(IsSystemResuming) 23 | pause("", 20000); 24 | else 25 | { 26 | //pause the thread for 20 seconds. 27 | #if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA) 28 | pause("", 17000); 29 | #else 30 | pause("", 20000); 31 | #endif 32 | } 33 | 34 | //Jailbreak the process. 35 | Backup_Jail bkJail; 36 | Jailbreak(p, &bkJail); 37 | 38 | //Mount the dirs for ShellUI 39 | Mount_Dirs(p, bkJail.fd_jdir, true); 40 | 41 | #if defined(SHOULD_LOAD) 42 | klog("****Launching Toolbox...****"); 43 | if(Load_SPRX(p, SPRX_PATH)) 44 | klog("Launched Toolbox..."); 45 | else 46 | klog("Failed to Launch Toolbox... Maybe you forgot to load HEN??"); 47 | #endif 48 | 49 | //Restore previous jail. 50 | RestoreJail(p, bkJail); 51 | 52 | IsSystemResuming = false; 53 | 54 | kthread_exit(); 55 | } 56 | 57 | void OnSystemSuspend(void* arg) 58 | { 59 | klog("System is Suspending..."); 60 | IsSystemResuming = true; 61 | } 62 | 63 | void OnSystemResume(void* arg) 64 | { 65 | klog("System is Resuming..."); 66 | IsSystemResuming = true; 67 | } 68 | 69 | void OnProcessStart(void *arg, struct proc *p) 70 | { 71 | if(!p) 72 | return; 73 | 74 | klog("OnProcessStart: %s(%s)", p->p_comm, p->titleId); 75 | 76 | if(!strcmp(p->titleId, "NPXS20001") && (!strcmp(p->p_comm, "SceShellUI") || !strcmp(p->p_comm, "eboot.bin"))) 77 | { 78 | proc* kernel = proc_find_by_name("kernel"); 79 | if(kernel) 80 | kproc_kthread_add(test_thread, p, &kernel, NULL, NULL, 0, "kernel", "Loader Thread"); 81 | } 82 | } 83 | 84 | void OnProcessExit(void *arg, struct proc *p) 85 | { 86 | if(!p) 87 | return; 88 | 89 | klog("OnProcessExit: %s(%s)", p->p_comm, p->titleId); 90 | 91 | //In the event of ui crash or reloading the ui unmount the file paths. 92 | if(!strcmp(p->titleId, "NPXS20001") && !strcmp(p->p_comm, "SceShellUI")) 93 | { 94 | //Jailbreak the process. 95 | Backup_Jail bkJail; 96 | Jailbreak(p, &bkJail); 97 | 98 | //Un-Mount the dirs for ShellUI 99 | Mount_Dirs(p, bkJail.fd_jdir, false); 100 | 101 | //Restore previous jail. 102 | RestoreJail(p, bkJail); 103 | } 104 | } 105 | 106 | void test2_thread(void* arg) 107 | { 108 | klog("Hello From thread.."); 109 | 110 | proc* p = proc_find_by_name("SceShellUI"); 111 | 112 | if(!p) 113 | { 114 | kthread_exit(); 115 | return; 116 | } 117 | 118 | //Jailbreak the process. 119 | Backup_Jail bkJail; 120 | Jailbreak(p, &bkJail); 121 | 122 | //Mount the dirs for ShellUI 123 | Mount_Dirs(p, bkJail.fd_jdir, true); 124 | 125 | #if defined(SHOULD_LOAD) 126 | klog("****Launching Toolbox...****"); 127 | if(Load_SPRX(p, SPRX_PATH)) 128 | { 129 | klog("Launched Toolbox Sucessfully."); 130 | #endif 131 | 132 | klog("Registering Events..."); 133 | //SystemSuspendEvent = EVENTHANDLER_REGISTER(system_suspend_phase1, (void*)OnSystemSuspend, nullptr, EVENTHANDLER_PRI_FIRST); 134 | //SystemResumeEvent = EVENTHANDLER_REGISTER(system_resume_phase1, (void*)OnSystemResume, nullptr, EVENTHANDLER_PRI_FIRST); 135 | ProcessStartEvent = EVENTHANDLER_REGISTER(process_exec_end, (void*)OnProcessStart, nullptr, EVENTHANDLER_PRI_ANY); 136 | ProcessExitEvent = EVENTHANDLER_REGISTER(process_exit, (void*)OnProcessExit, nullptr, EVENTHANDLER_PRI_ANY); 137 | klog("Events Registered Sucessfully."); 138 | 139 | #if defined(SHOULD_LOAD) 140 | } 141 | else 142 | klog("Failed to Launch Toolbox... Maybe you forgot to load HEN??"); 143 | #endif 144 | 145 | //Restore previous jail. 146 | RestoreJail(p, bkJail); 147 | 148 | kthread_exit(); 149 | } 150 | 151 | void kproc_Init() 152 | { 153 | klog("kproc_Init()"); 154 | 155 | proc* kernel = proc_find_by_name("kernel"); 156 | if(kernel) 157 | { 158 | klog("Found Kernel Process...\n"); 159 | kproc_kthread_add(test2_thread, nullptr, &kernel, NULL, NULL, 0, "kernel", "Loader Thread"); 160 | } 161 | 162 | klog("kproc_Init() -> Sucess!"); 163 | } 164 | 165 | void kproc_Term() 166 | { 167 | EVENTHANDLER_DEREGISTER(system_suspend_phase1, SystemSuspendEvent); 168 | EVENTHANDLER_DEREGISTER(system_resume_phase1, SystemResumeEvent); 169 | EVENTHANDLER_DEREGISTER(process_exec_end, ProcessStartEvent); 170 | EVENTHANDLER_DEREGISTER(process_exit, ProcessExitEvent); 171 | } -------------------------------------------------------------------------------- /Loader/Makefile: -------------------------------------------------------------------------------- 1 | SHELL=/bin/bash 2 | PDIR := ../Icons 3 | PFILES := $(shell find $(PDIR) -name \*.png) 4 | 5 | none: 6 | printf "\e[1m\e[31m[Please Choose a firmware!! EG. \"make 505\" \033[37m\n" 7 | 8 | build: 9 | +$(MAKE) -C ShellCode clean 10 | +$(MAKE) -C ShellCode 11 | +$(MAKE) -C Kernel clean 12 | +$(MAKE) -C Kernel 13 | +$(MAKE) -C Userland clean 14 | +$(MAKE) -C Userland pack_resources 15 | +$(MAKE) -C Userland 16 | 17 | objcopy -O binary Userland/Userland.elf ../Build/Orbis-Toolbox-$(VERSION).bin 18 | 19 | printf "\e[1m\e[32m[%0.2f Build Sucess!]\033[37m\n" "$$(($(VERSION) * 1))e-2" 20 | 21 | 505: 22 | +$(MAKE) build VERSION=505 23 | 24 | 672: 25 | +$(MAKE) build VERSION=672 26 | 27 | 702: 28 | +$(MAKE) build VERSION=702 29 | 30 | 755: 31 | +$(MAKE) build VERSION=755 32 | 33 | 900: 34 | +$(MAKE) build VERSION=900 35 | 36 | all: 37 | +$(MAKE) build VERSION=505 38 | +$(MAKE) build VERSION=672 39 | +$(MAKE) build VERSION=702 40 | +$(MAKE) build VERSION=755 41 | +$(MAKE) build VERSION=900 42 | 43 | @/bin/echo -e "\e[1m\e[32m[All Build Sucess!]\033[37m" 44 | 45 | clean: 46 | +$(MAKE) -C ShellCode clean 47 | +$(MAKE) -C Kernel clean 48 | +$(MAKE) -C Userland clean 49 | -------------------------------------------------------------------------------- /Loader/ShellCode/LoaderShellCode.s: -------------------------------------------------------------------------------- 1 | BITS 64 2 | DEFAULT REL 3 | 4 | magic: db 'SHEL' 5 | entry: dq shellcode 6 | 7 | thr_initial: dq 0 8 | ShellCodeComplete: db 0 9 | 10 | ;sceKernelLoadStartModule Variables 11 | ModulePath: db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 12 | ModuleHandle: dq 0 13 | 14 | ;Addresses 15 | sceKernelUsleep: dq 0 16 | asceKernelLoadStartModule: dq 0 17 | libkernel: dq 0 18 | str_libkernel: db 'libkernel.sprx', 0 19 | str_libkernelweb: db 'libkernel_web.sprx', 0 20 | str_libkernelsys: db 'libkernel_sys.sprx', 0 21 | str_sceKernelSleep: db 'sceKernelUsleep', 0 22 | str_sceKernelLoadStartModule: db 'sceKernelLoadStartModule', 0 23 | 24 | str_scePthreadCreate: db 'scePthreadCreate', 0 25 | scePthreadCreate: dq 0 26 | str_scePthreadAttrSetstacksize: db 'scePthreadAttrSetstacksize', 0 27 | scePthreadAttrSetstacksize: dq 0 28 | str_scePthreadAttrInit: db 'scePthreadAttrInit', 0 29 | scePthreadAttrInit: dq 0 30 | 31 | hthread: dq 0 32 | scePthreadAttr: dq 0 33 | str_threadName: db 'Orbis Toolbox SPRX Loader', 0 34 | 35 | ; Work around for oosdk 36 | amodule_start: dq 0 37 | str_module_start: db 'module_start', 0 38 | 39 | shellcode: 40 | ; load thread into fs 41 | mov rdi, qword [thr_initial] 42 | mov rsi, qword [rdi] 43 | mov rdi, qword [rsi + 0x1E0] 44 | call amd64_set_fsbase 45 | 46 | ; get libkernel handle 47 | mov rcx, 0 48 | lea rdx, [libkernel] 49 | mov rsi, 0 50 | lea rdi, [str_libkernel] 51 | call sys_dynlib_load_prx 52 | test rax, rax 53 | je resolve 54 | 55 | mov rcx, 0 56 | lea rdx, [libkernel] 57 | mov rsi, 0 58 | lea rdi, [str_libkernelweb] 59 | call sys_dynlib_load_prx 60 | test rax, rax 61 | je resolve 62 | 63 | mov rcx, 0 64 | lea rdx, [libkernel] 65 | mov rsi, 0 66 | lea rdi, [str_libkernelsys] 67 | call sys_dynlib_load_prx 68 | 69 | resolve: 70 | ; resolve sceKernelUsleep 71 | lea rdx, [sceKernelUsleep] 72 | lea rsi, [str_sceKernelSleep] 73 | mov rdi, qword [libkernel] 74 | call sys_dynlib_dlsym 75 | 76 | ; resolve sceKernelLoadStartModule 77 | lea rdx, [asceKernelLoadStartModule] 78 | lea rsi, [str_sceKernelLoadStartModule] 79 | mov rdi, qword [libkernel] 80 | call sys_dynlib_dlsym 81 | 82 | ; resolve scePthreadCreate 83 | lea rdx, [scePthreadCreate] 84 | lea rsi, [str_scePthreadCreate] 85 | mov rdi, qword [libkernel] 86 | call sys_dynlib_dlsym 87 | 88 | ; resolve scePthreadAttrSetstacksize 89 | lea rdx, [scePthreadAttrSetstacksize] 90 | lea rsi, [str_scePthreadAttrSetstacksize] 91 | mov rdi, qword [libkernel] 92 | call sys_dynlib_dlsym 93 | 94 | ; resolve scePthreadAttrInit 95 | lea rdx, [scePthreadAttrInit] 96 | lea rsi, [str_scePthreadAttrInit] 97 | mov rdi, qword [libkernel] 98 | call sys_dynlib_dlsym 99 | 100 | call sceKernelLoadStartModule 101 | 102 | ; Check if the module loaded and if it did call the entry. 103 | cmp dword[ModuleHandle], 0 104 | jle didntload 105 | 106 | call module_start 107 | 108 | didntload: 109 | mov byte [ShellCodeComplete], 1 110 | 111 | mov rdi, 0 112 | call sys_thr_exit 113 | retn 114 | 115 | module_start: 116 | lea rdx, [amodule_start] 117 | lea rsi, [str_module_start] 118 | mov rdi, qword [ModuleHandle] 119 | call sys_dynlib_dlsym 120 | 121 | cmp dword[amodule_start], 0 122 | ja found_start 123 | xor eax, eax 124 | retn 125 | 126 | found_start: 127 | ; create attr 128 | lea rdi, [scePthreadAttr] 129 | mov r12, qword [scePthreadAttrInit] 130 | call r12 131 | 132 | ; set stack size 133 | mov rsi, 0x80000 ; 512 kb 134 | lea rdi, [scePthreadAttr] 135 | mov r12, qword [scePthreadAttrSetstacksize] 136 | call r12 137 | 138 | ; create thread 139 | lea r8, [str_threadName] 140 | mov rcx, 0 141 | mov rdx, qword [amodule_start] 142 | lea rsi, [scePthreadAttr] 143 | lea rdi, [hthread] 144 | mov r12, qword [scePthreadCreate] 145 | call r12 146 | 147 | xor eax, eax 148 | retn 149 | 150 | sceKernelLoadStartModule: 151 | xor r9, r9 152 | xor r8, r8 153 | xor rcx, rcx 154 | xor rdx, rdx 155 | xor rsi, rsi 156 | lea rdi, [ModulePath] 157 | mov r12, qword [asceKernelLoadStartModule] 158 | call r12 159 | mov qword [ModuleHandle], rax 160 | xor eax, eax 161 | retn 162 | 163 | sys_dynlib_load_prx: 164 | mov rax, 594 165 | mov r10, rcx 166 | syscall 167 | retn 168 | 169 | sys_dynlib_dlsym: 170 | mov rax, 591 171 | mov r10, rcx 172 | syscall 173 | retn 174 | 175 | sys_thr_exit: 176 | mov rax, 431 177 | mov r10, rcx 178 | syscall 179 | retn 180 | 181 | sys_sysarch: 182 | mov rax, 165 183 | mov r10, rcx 184 | syscall 185 | retn 186 | 187 | amd64_set_fsbase: 188 | push rbp 189 | mov rbp, rsp 190 | push rbx 191 | sub rsp, 0x18 192 | 193 | mov [rbp - 0x18], rdi 194 | 195 | lea rsi, [rbp - 0x18] 196 | mov edi, 129 197 | call sys_sysarch 198 | 199 | add rsp, 0x18 200 | pop rbx 201 | pop rbp 202 | retn -------------------------------------------------------------------------------- /Loader/ShellCode/Makefile: -------------------------------------------------------------------------------- 1 | ShellCode = LoaderShellCode.bin 2 | ShellCodes = LoaderShellCode.s 3 | 4 | all: clean $(ShellCode) 5 | 6 | $(ShellCode): 7 | nasm -f bin -o $(ShellCode) $(ShellCodes) 8 | 9 | .PHONY: clean 10 | clean: 11 | rm -f $(ShellCode) -------------------------------------------------------------------------------- /Loader/Userland/Linkfile: -------------------------------------------------------------------------------- 1 | OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64") 2 | OUTPUT_ARCH(i386:x86-64) 3 | 4 | ENTRY(_start) 5 | 6 | PHDRS 7 | { 8 | code_seg PT_LOAD; 9 | rdata_seg PT_LOAD; 10 | data_seg PT_LOAD; 11 | bss_seg PT_LOAD; 12 | } 13 | 14 | SECTIONS 15 | { 16 | . = 0x926200000; 17 | .text : { 18 | *(.text.start) 19 | *(.text*) 20 | } : code_seg 21 | .rodata : { 22 | *(.rodata) 23 | *(.rodata*) 24 | } : rdata_seg 25 | .data : { *(.data) } : data_seg 26 | .bss : { *(.bss) } : bss_seg 27 | /DISCARD/ : { 28 | *(.comment) 29 | *(.note.GNU-stack) 30 | *(.eh_frame) 31 | } 32 | } -------------------------------------------------------------------------------- /Loader/Userland/Makefile: -------------------------------------------------------------------------------- 1 | CC := gcc 2 | AS := gcc 3 | OBJCOPY := objcopy 4 | ODIR := build 5 | SDIR := source 6 | RDIR := Resources 7 | IDIRS := -Iinclude -I$(FREEBSD_INCLUDES) 8 | CFLAGS := $(IDIRS) -O3 -s -w -std=gnu11 -fno-builtin -fno-exceptions -fno-asynchronous-unwind-tables -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=small -fpie -DVERSION_$(VERSION) 9 | SFLAGS := -nostartfiles -nostdlib -march=btver2 -mtune=btver2 10 | LFLAGS := -Xlinker -T linkfile -Wl,--build-id=none -Wl,--gc-sections 11 | CFILES := $(shell find $(SDIR) -name \*.c) 12 | SFILES := $(shell find $(SDIR) -name \*.s) 13 | RFILES := $(shell find $(RDIR) -name \*.bin) 14 | OBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(CFILES)) $(patsubst $(SDIR)/%.s, $(ODIR)/%.o, $(SFILES)) $(patsubst $(RDIR)/%.bin, $(ODIR)/%.o, $(RFILES)) 15 | 16 | TARGET = $(shell basename "$(CURDIR)").elf 17 | 18 | $(TARGET): $(ODIR) $(OBJS) 19 | $(CC) crt0.s $(OBJS) -o $(TARGET) $(CFLAGS) $(LFLAGS) 20 | 21 | $(ODIR)/%.o: $(SDIR)/%.c 22 | mkdir -p $(dir $@) 23 | $(CC) -c -o $@ $< $(CFLAGS) 24 | 25 | $(ODIR)/%.o: $(SDIR)/%.s 26 | $(AS) -c -o $@ $< $(SFLAGS) 27 | 28 | $(ODIR)/%.o: $(RDIR)/%.bin 29 | mkdir -p $(dir $@) 30 | ld -r -b binary -o $@ $< 31 | # objdump -t $@ 32 | 33 | $(ODIR): 34 | @mkdir $@ 35 | 36 | .PHONY: clean 37 | 38 | pack_resources: 39 | cp '../../Orbis Toolbox.sprx' '$(RDIR)/Orbis_Toolbox.bin' 40 | cp '../Kernel/Kernel.ELF' '$(RDIR)/Kernel.bin' 41 | 42 | clean: 43 | rm -rf -v $(TARGET) $(ODIR)/* -------------------------------------------------------------------------------- /Loader/Userland/crt0.s: -------------------------------------------------------------------------------- 1 | .intel_syntax noprefix 2 | .text 3 | 4 | .global _start 5 | _start: 6 | jmp _main 7 | -------------------------------------------------------------------------------- /Loader/Userland/include/Common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sys/types.h" 3 | 4 | #ifndef NULL 5 | #define NULL 0 6 | #endif 7 | 8 | #ifndef true 9 | #define true 1 10 | #endif 11 | 12 | #ifndef false 13 | #define false 0 14 | #endif 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "../../Common/Settings.h" 31 | #include "Resolver/Resolver.h" 32 | #include "Resolver/Patches.h" 33 | #include "syscall.h" 34 | #include "ELF.h" 35 | #include "Util/Utils.h" 36 | 37 | extern uint8_t* gKernelBase; -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Patches.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Install_505(); 4 | void Install_672(); 5 | void Install_702(); 6 | void Install_755(); 7 | void Install_900(); 8 | void Install_Patches(); 9 | -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Resolver-505.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_ksysvec 0x19BBCD0 8 | #define addr_kprison0 0x10986A0 9 | #define addr_krootvnode 0x22C1A70 10 | 11 | /* STD Lib */ 12 | #define addr_kmemcpy 0x1EA530 13 | #define addr_kmemset 0x3205C0 14 | #define addr_kmemcmp 0x50AC0 15 | #define addr_ksprintf 0x436280 16 | #define addr_kvsprintf 0x436310 17 | #define addr_kprintf 0x436040 18 | 19 | #define addr_kmem_alloc 0xFCC80 20 | #define addr_kernel_map 0x1AC60E0 21 | 22 | #endif -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Resolver-672.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_672) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_ksysvec 0x1A8A398 8 | #define addr_kprison0 0x113E518 9 | #define addr_krootvnode 0x2300320 10 | 11 | /* STD Lib */ 12 | #define addr_kmemcpy 0x3C15B0 13 | #define addr_kmemset 0x1687D0 14 | #define addr_kmemcmp 0x207E40 15 | #define addr_ksprintf 0x1234C0 16 | #define addr_kvsprintf 0x123550 17 | #define addr_kprintf 0x123280 18 | 19 | #define addr_kmem_alloc 0x250730 20 | #define addr_kernel_map 0x220DFC0 21 | 22 | #endif -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Resolver-702.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_702) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_ksysvec 0x1A4F460 8 | #define addr_kprison0 0x113E398 9 | #define addr_krootvnode 0x22C5750 10 | 11 | /* STD Lib */ 12 | #define addr_kmemcpy 0x2F040 13 | #define addr_kmemset 0x2DFC20 14 | #define addr_kmemcmp 0x207500 15 | #define addr_ksprintf 0xBC970 16 | #define addr_kvsprintf 0xBCA00 17 | #define addr_kprintf 0xBC730 18 | 19 | #define addr_kmem_alloc 0x1170F0 20 | #define addr_kernel_map 0x21C8EE0 21 | 22 | #endif -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Resolver-755.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_755) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x1C0 7 | #define addr_ksysvec 0x1564E80 8 | #define addr_kprison0 0x113B728 9 | #define addr_krootvnode 0x1B463E0 10 | 11 | /* STD Lib */ 12 | #define addr_kmemcpy 0x28F800 13 | #define addr_kmemset 0x8D6F0 14 | #define addr_kmemcmp 0x31D250 15 | #define addr_ksprintf 0x26F980 16 | #define addr_kvsprintf 0x26FA10 17 | #define addr_kprintf 0x26F740 18 | 19 | #define addr_kmem_alloc 0x1753E0 20 | #define addr_kernel_map 0x21405B8 21 | 22 | #endif -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Resolver-900.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(SOFTWARE_VERSION_900) 4 | 5 | /* Util */ 6 | #define addr_Xfast_syscall 0x000001C0 7 | #define addr_ksysvec 0x01528E30 8 | #define addr_kprison0 0x0111F870 9 | #define addr_krootvnode 0x021EFF20 10 | 11 | /* STD Lib */ 12 | #define addr_kmemcpy 0x002714B0 13 | #define addr_kmemset 0x001496C0 14 | #define addr_kmemcmp 0x00271E20 15 | #define addr_ksprintf 0x000B7C70 16 | #define addr_kvsprintf 0x000B7D00 17 | #define addr_kprintf 0x000B7A30 18 | 19 | #define addr_kmem_alloc 0x0037BE70 20 | #define addr_kernel_map 0x02268D48 21 | 22 | #endif -------------------------------------------------------------------------------- /Loader/Userland/include/Resolver/Resolver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Resolver-505.h" 4 | #include "Resolver-672.h" 5 | #include "Resolver-702.h" 6 | #include "Resolver-755.h" 7 | #include "Resolver-900.h" 8 | 9 | /* Util */ 10 | extern struct sysentvec* ksysvec; 11 | extern struct prison* kprison0; 12 | extern struct vnode* krootvnode; 13 | 14 | /* STD Lib */ 15 | void (*kmemcpy)(void *dst, const void *src, size_t len); 16 | void *(*kmemset)(void * ptr, int value, size_t num); 17 | int (*kmemcmp)(const void * ptr1, const void * ptr2, size_t num); 18 | int (*ksprintf)(char* dst, const char *fmt, ...); 19 | int (*kvsprintf)(char* dst, const char* fmt, va_list ap); 20 | void(*kprintf)(const char* fmt, ...); 21 | 22 | void Kern_Resolve(); 23 | 24 | //Kernel 25 | int(*sceKernelDebugOutText)(int dbg_channel, const char* text); 26 | int(*sceKernelMkdir)(const char *path, mode_t mode); 27 | int(*sceKernelOpen)(const char* path, int flags, mode_t mode); 28 | int(*sceKernelWrite)(int fd, void *data, size_t len); 29 | int(*sceKernelClose)(int fd); 30 | 31 | //libc 32 | void *(*malloc)(size_t size); 33 | void(*free)(void *ptr); 34 | void *(*calloc)(size_t num, size_t size); 35 | void *(*realloc)(void* ptr, size_t size); 36 | void *(*memset)(void *destination, int value, size_t num); 37 | void *(*memcpy)(void *destination, const void *source, size_t num); 38 | int(*memcmp)(const void *s1, const void *s2, size_t n); 39 | char *(*strcpy)(char *destination, const char *source); 40 | char *(*strncpy)(char *destination, const char *source, size_t num); 41 | char *(*strcat)(char *dest, const char *src); 42 | char *(*strncat)(char *dest, const char *src, size_t n); 43 | size_t(*strlen)(const char *s); 44 | int(*strcmp)(const char *s1, const char *s2); 45 | int(*strncmp)(const char *s1, const char *s2, size_t n); 46 | int(*sprintf)(char *str, const char *format, ...); 47 | int(*snprintf)(char *str, size_t size, const char *format, ...); 48 | int(*vsprintf)(char * s, const char * format, va_list arg); 49 | int(*sscanf)(const char *str, const char *format, ...); 50 | char *(*strchr)(const char *s, int c); 51 | char *(*strrchr)(const char *s, int c); 52 | char *(*strstr)(char *str1, char *str2); 53 | int(*atoi)(const char * str); 54 | double(*atof)(const char * str); 55 | double(*sin)(double x); 56 | double(*cos)(double x); 57 | double(*atan2)(double x, double y); 58 | double(*sqrt)(double vec); 59 | char *(*strdup)(const char *s); 60 | 61 | void Userland_Resolve(); -------------------------------------------------------------------------------- /Loader/Userland/include/Util/Resources.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void Install_Resources(); -------------------------------------------------------------------------------- /Loader/Userland/include/Util/Types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "sys/types.h" 3 | 4 | #ifndef NULL 5 | #define NULL 0 6 | #endif 7 | 8 | #ifndef true 9 | #define true 1 10 | #endif 11 | 12 | #ifndef false 13 | #define false 0 14 | #endif -------------------------------------------------------------------------------- /Loader/Userland/include/Util/Utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | static inline struct thread *curthread(void) { 16 | struct thread* td; 17 | __asm__ __volatile__ ( 18 | "mov %0, %%gs:0" 19 | : "=r"(td) 20 | ); 21 | 22 | return td; 23 | } 24 | 25 | static inline __attribute__((always_inline)) uint64_t __readmsr(uint32_t __register) { 26 | uint32_t __edx, __eax; 27 | 28 | __asm__ volatile ( 29 | "rdmsr" 30 | : "=d"(__edx), 31 | "=a"(__eax) 32 | : "c"(__register) 33 | ); 34 | 35 | return (((uint64_t)__edx) << 32) | (uint64_t)__eax; 36 | } 37 | 38 | #define CR0_WP (1 << 16) // write protect 39 | 40 | static inline __attribute__((always_inline)) uint64_t __readcr0(void) { 41 | uint64_t cr0; 42 | 43 | __asm__ volatile ( 44 | "movq %0, %%cr0" 45 | : "=r" (cr0) 46 | : : "memory" 47 | ); 48 | 49 | return cr0; 50 | } 51 | static inline __attribute__((always_inline)) void __writecr0(uint64_t cr0) { 52 | __asm__ volatile ( 53 | "movq %%cr0, %0" 54 | : : "r" (cr0) 55 | : "memory" 56 | ); 57 | } 58 | 59 | struct Backup_Jail 60 | { 61 | struct prison* cr_prison; 62 | uid_t cr_uid; 63 | uid_t cr_ruid; 64 | gid_t cr_rgid; 65 | gid_t cr_groups; 66 | 67 | struct vnode* fd_jdir; 68 | struct vnode* fd_rdir; 69 | }; 70 | 71 | void Jailbreak(struct proc* proc, struct Backup_Jail* jail); 72 | void RestoreJail(struct proc* proc, struct Backup_Jail jail); 73 | int klog(char* fmt, ...); 74 | void Log(char* fmt, ...); -------------------------------------------------------------------------------- /Loader/Userland/include/syscall.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | unsigned long syscall(unsigned long n, ...); -------------------------------------------------------------------------------- /Loader/Userland/source/ELF.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "ELF.h" 3 | #include "Resolver/Resolver.h" 4 | 5 | // thank you osdev for some help 6 | static inline struct Elf64_Phdr *elf_pheader(struct Elf64_Ehdr *hdr) { 7 | if (!hdr->e_phoff) { 8 | return NULL; 9 | } 10 | 11 | return (struct Elf64_Phdr *)((uint64_t)hdr + hdr->e_phoff); 12 | } 13 | static inline struct Elf64_Phdr *elf_segment(struct Elf64_Ehdr *hdr, int idx) { 14 | uint64_t addr = (uint64_t)elf_pheader(hdr); 15 | if (!addr) { 16 | return NULL; 17 | } 18 | 19 | return (struct Elf64_Phdr *)(addr + (hdr->e_phentsize * idx)); 20 | } 21 | static inline struct Elf64_Shdr *elf_sheader(struct Elf64_Ehdr *hdr) { 22 | if (!hdr->e_shoff) { 23 | return NULL; 24 | } 25 | 26 | return (struct Elf64_Shdr *)((uint64_t)hdr + hdr->e_shoff); 27 | } 28 | static inline struct Elf64_Shdr *elf_section(struct Elf64_Ehdr *hdr, int idx) { 29 | uint64_t addr = (uint64_t)elf_sheader(hdr); 30 | if (!addr) { 31 | return NULL; 32 | } 33 | 34 | return (struct Elf64_Shdr *)(addr + (hdr->e_shentsize * idx)); 35 | } 36 | 37 | int elf_mapped_size(void *elf, size_t *msize) { 38 | struct Elf64_Ehdr *ehdr = (struct Elf64_Ehdr *)elf; 39 | 40 | // check magic 41 | if (memcmp(ehdr->e_ident, ElfMagic, 4)) { 42 | return LDR_INVALID_ELF; 43 | } 44 | 45 | size_t s = 0; 46 | 47 | struct Elf64_Phdr *phdr = elf_pheader(ehdr); 48 | if (phdr) { 49 | // use segments 50 | for (int i = 0; i < ehdr->e_phnum; i++) { 51 | struct Elf64_Phdr *phdr = elf_segment(ehdr, i); 52 | 53 | uint64_t delta = phdr->p_paddr + phdr->p_memsz; 54 | if (delta > s) { 55 | s = delta; 56 | } 57 | } 58 | } else { 59 | // use sections 60 | for (int i = 0; i < ehdr->e_shnum; i++) { 61 | struct Elf64_Shdr *shdr = elf_section(ehdr, i); 62 | 63 | uint64_t delta = shdr->sh_addr + shdr->sh_size; 64 | if (delta > s) { 65 | s = delta; 66 | } 67 | } 68 | } 69 | 70 | if (msize) { 71 | *msize = s; 72 | } 73 | 74 | return LDR_SUCCESS; 75 | } 76 | 77 | int map_elf(void *elf, void *exec) { 78 | struct Elf64_Ehdr *ehdr = (struct Elf64_Ehdr *)elf; 79 | 80 | struct Elf64_Phdr *phdr = elf_pheader(ehdr); 81 | if (phdr) { 82 | // use segments 83 | for (int i = 0; i < ehdr->e_phnum; i++) { 84 | struct Elf64_Phdr *phdr = elf_segment(ehdr, i); 85 | 86 | if (phdr->p_filesz) { 87 | memcpy((uint8_t *)exec + phdr->p_paddr, (uint8_t *)elf + phdr->p_offset, phdr->p_filesz); 88 | } 89 | 90 | if (phdr->p_memsz - phdr->p_filesz) { 91 | memset((uint8_t *)exec + phdr->p_paddr + phdr->p_filesz, NULL, phdr->p_memsz - phdr->p_filesz); 92 | } 93 | } 94 | } else { 95 | // use sections 96 | for (int i = 0; i < ehdr->e_shnum; i++) { 97 | struct Elf64_Shdr *shdr = elf_section(ehdr, i); 98 | 99 | if (!(shdr->sh_flags & SHF_ALLOC)) { 100 | continue; 101 | } 102 | 103 | if (shdr->sh_size) { 104 | memcpy((uint8_t *)exec + shdr->sh_addr, (uint8_t *)elf + shdr->sh_offset, shdr->sh_size); 105 | } 106 | } 107 | } 108 | 109 | return LDR_SUCCESS; 110 | } 111 | 112 | int relocate_elf(void *elf, void *exec) { 113 | struct Elf64_Ehdr *ehdr = (struct Elf64_Ehdr *)elf; 114 | 115 | for (int i = 0; i < ehdr->e_shnum; i++) { 116 | struct Elf64_Shdr *shdr = elf_section(ehdr, i); 117 | 118 | // check table 119 | if (shdr->sh_type == SHT_REL) { 120 | // process each entry in the table 121 | for (int j = 0; j < shdr->sh_size / shdr->sh_entsize; j++) { 122 | struct Elf64_Rela *reltab = &((struct Elf64_Rela *)((uint64_t)ehdr + shdr->sh_offset))[j]; 123 | uint8_t **ref = (uint8_t **)((uint8_t *)exec + reltab->r_offset); 124 | 125 | switch (ELF64_R_TYPE(reltab->r_info)) { 126 | case R_X86_64_RELATIVE: 127 | *ref = (uint8_t *)exec + reltab->r_addend; 128 | break; 129 | case R_X86_64_64: 130 | case R_X86_64_JUMP_SLOT: 131 | case R_X86_64_GLOB_DAT: 132 | // TODO: relocations 133 | break; 134 | } 135 | } 136 | } 137 | } 138 | 139 | return LDR_SUCCESS; 140 | } 141 | 142 | int load_elf(void *elf, size_t size, void *exec, size_t msize, void **entry) { 143 | size_t s = 0; 144 | 145 | if (!elf || !exec || !size || !msize) 146 | return LDR_INVALID_ELF; 147 | 148 | struct Elf64_Ehdr *ehdr = (struct Elf64_Ehdr *)elf; 149 | 150 | if (memcmp(ehdr->e_ident, ElfMagic, 4)) 151 | return LDR_INVALID_ELF; 152 | 153 | if (elf_mapped_size(elf, &s)) 154 | return LDR_SIZE_ERROR; 155 | 156 | if (s > msize) 157 | return LDR_SIZE_ERROR; 158 | 159 | if (map_elf(elf, exec)) 160 | return LDR_MAP_ERROR; 161 | 162 | if (relocate_elf(elf, exec)) 163 | return LDR_RELOC_ERROR; 164 | 165 | *entry = (void *)((uint64_t)exec + ehdr->e_entry); 166 | 167 | return LDR_SUCCESS; 168 | } 169 | -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Patches-505.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Patches.h" 3 | 4 | void Install_505() 5 | { 6 | uint8_t *kmem; 7 | 8 | // Verbose Panics 9 | kmem = (uint8_t *)&gKernelBase[0x00171627]; 10 | kmem[0] = 0x90; 11 | kmem[1] = 0x90; 12 | kmem[2] = 0x90; 13 | kmem[3] = 0x90; 14 | kmem[4] = 0x90; 15 | kmem[5] = 0x65; 16 | kmem[6] = 0x8B; 17 | kmem[7] = 0x34; 18 | 19 | // Enable rwx mapping 20 | kmem = (uint8_t *)&gKernelBase[0x000FCD48]; 21 | kmem[0] = 0x07; 22 | 23 | kmem = (uint8_t *)&gKernelBase[0x000FCD56]; 24 | kmem[0] = 0x07; 25 | 26 | // Patch copyin/copyout to allow userland + kernel addresses in both params 27 | kmem = (uint8_t *)&gKernelBase[0x001EA767]; 28 | kmem[0] = 0x90; 29 | kmem[1] = 0x90; 30 | 31 | kmem = (uint8_t *)&gKernelBase[0x001EA682]; 32 | kmem[0] = 0x90; 33 | kmem[1] = 0x90; 34 | 35 | // Patch copyinstr 36 | kmem = (uint8_t *)&gKernelBase[0x001EAB93]; 37 | kmem[0] = 0x90; 38 | kmem[1] = 0x90; 39 | 40 | kmem = (uint8_t *)&gKernelBase[0x001EABC3]; 41 | kmem[0] = 0x90; 42 | kmem[1] = 0x90; 43 | 44 | // Patch memcpy stack 45 | kmem = (uint8_t *)&gKernelBase[0x001EA53D]; 46 | kmem[0] = 0xEB; 47 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Patches-672.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Patches.h" 3 | 4 | void Install_672() 5 | { 6 | uint8_t *kmem; 7 | 8 | // Patch dynlib_dlsym 9 | kmem = (uint8_t*)&gKernelBase[0x1D895A]; 10 | kmem[0] = 0xE9; 11 | kmem[1] = 0xC7; 12 | kmem[2] = 0x01; 13 | kmem[3] = 0x00; 14 | kmem[4] = 0x00; 15 | 16 | // Patch a function called by dynlib_dlsym 17 | kmem = (uint8_t*)&gKernelBase[0x0041A2D0]; 18 | kmem[0] = 0x31; // xor eax, eax 19 | kmem[1] = 0xC0; 20 | kmem[2] = 0xC3; // ret 21 | 22 | // Patch sys_mmap 23 | kmem = (uint8_t*)&gKernelBase[0x000AB57A]; 24 | kmem[0] = 0x37; // mov [rbp+var_61], 33h ; '3' 25 | kmem[3] = 0x37; // mov sil, 33h ; '3' 26 | 27 | // patch sys_setuid 28 | kmem = (uint8_t*)&gKernelBase[0x0010BED0]; // call priv_check_cred; overwrite with mov eax, 0 29 | kmem[0] = 0xB8; // mov eax, 0 30 | kmem[1] = 0x00; 31 | kmem[2] = 0x00; 32 | kmem[3] = 0x00; 33 | kmem[4] = 0x00; 34 | 35 | // patch sys_mprotect 36 | kmem = (uint8_t*)&gKernelBase[0x00451DB8]; // jnz loc_FFFFFFFF82652426; nop it out 37 | kmem[0] = 0x90; 38 | kmem[1] = 0x90; 39 | kmem[2] = 0x90; 40 | kmem[3] = 0x90; 41 | kmem[4] = 0x90; 42 | kmem[5] = 0x90; 43 | 44 | // Enable rwx mapping in kmem_alloc 45 | kmem = (uint8_t *)&gKernelBase[0x002507F5]; 46 | kmem[0] = 0x07; // set maxprot to RWX 47 | 48 | kmem = (uint8_t *)&gKernelBase[0x00250803]; 49 | kmem[0] = 0x07; // set maxprot to RWX 50 | 51 | // Patch copyin/copyout to allow userland + kernel addresses in both params 52 | // copyin 53 | kmem = (uint8_t *)&gKernelBase[0x003C17F7]; 54 | kmem[0] = 0x90; 55 | kmem[1] = 0x90; 56 | 57 | kmem = (uint8_t *)&gKernelBase[0x003C1803]; 58 | kmem[0] = 0x90; 59 | kmem[1] = 0x90; 60 | kmem[2] = 0x90; 61 | 62 | // copyout 63 | kmem = (uint8_t *)&gKernelBase[0x003C1702]; 64 | kmem[0] = 0x90; 65 | kmem[1] = 0x90; 66 | 67 | kmem = (uint8_t *)&gKernelBase[0x003C170E]; 68 | kmem[0] = 0x90; 69 | kmem[1] = 0x90; 70 | kmem[2] = 0x90; 71 | 72 | // Enable MAP_SELF 73 | 74 | // Patches: sceSblACMgrHasMmapSelfCapability 75 | kmem = (uint8_t *)&gKernelBase[0x00233C40]; 76 | kmem[0] = 0xB8; 77 | kmem[1] = 0x01; 78 | kmem[2] = 0x00; 79 | kmem[3] = 0x00; 80 | kmem[4] = 0x00; 81 | kmem[5] = 0xC3; 82 | 83 | // Patches: sceSblACMgrIsAllowedToMmapSelf 84 | kmem = (uint8_t *)&gKernelBase[0x00233C50]; 85 | kmem[0] = 0xB8; 86 | kmem[1] = 0x01; 87 | kmem[2] = 0x00; 88 | kmem[3] = 0x00; 89 | kmem[4] = 0x00; 90 | kmem[5] = 0xC3; 91 | 92 | // Patches: call sceSblAuthMgrIsLoadable in vm_mmap2 (right above the only call to allowed to mmap self) 93 | kmem = (uint8_t *)&gKernelBase[0x000AD2E4]; // xor eax, eax; nop; nop; 94 | kmem[0] = 0x31; 95 | kmem[1] = 0xC0; 96 | kmem[2] = 0x90; 97 | kmem[3] = 0x90; 98 | kmem[4] = 0x90; 99 | 100 | // Patch copyinstr 101 | kmem = (uint8_t *)&gKernelBase[0x003C1CA3]; 102 | kmem[0] = 0x90; 103 | kmem[1] = 0x90; 104 | 105 | kmem = (uint8_t *)&gKernelBase[0x003C1CAF]; 106 | kmem[0] = 0x90; 107 | kmem[1] = 0x90; 108 | kmem[2] = 0x90; 109 | 110 | // Patch memcpy stack 111 | kmem = (uint8_t *)&gKernelBase[0x003C15BD]; 112 | kmem[0] = 0xEB; 113 | 114 | // ptrace patches 115 | kmem = (uint8_t *)&gKernelBase[0x0010F879]; 116 | kmem[0] = 0xEB; 117 | 118 | // Enable debug rif's 119 | kmem = (uint8_t*)&gKernelBase[0x66AEB0]; 120 | kmem[0] = 0xB0; 121 | kmem[1] = 0x01; 122 | kmem[2] = 0xC3; 123 | kmem[3] = 0x90; 124 | 125 | // Enable debug rifs 2 126 | kmem = (uint8_t*)&gKernelBase[0x66AEE0]; 127 | kmem[0] = 0xB0; 128 | kmem[1] = 0x01; 129 | kmem[2] = 0xC3; 130 | kmem[3] = 0x90; 131 | 132 | // Disable pfs checks 133 | kmem = (uint8_t*)&gKernelBase[0x6A8EB0]; 134 | kmem[0] = 0x31; 135 | kmem[1] = 0xC0; 136 | kmem[2] = 0xC3; 137 | kmem[3] = 0x90; 138 | 139 | // Enable *all* debugging logs (in vprintf) 140 | // Patch by: SiSTRo 141 | kmem = (uint8_t*)&gKernelBase[0x00123367]; 142 | kmem[0] = 0xEB; // jmp +0x3D 143 | kmem[1] = 0x3B; 144 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Patches-702.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Patches.h" 3 | 4 | void Install_702() 5 | { 6 | // Use "kmem" for all patches 7 | uint8_t *kmem; 8 | 9 | // Enable UART 10 | kmem = (uint8_t *)&gKernelBase[0x01A6EAA0]; 11 | kmem[0] = 0x00; 12 | 13 | // Verbose Panics 14 | kmem = (uint8_t *)&gKernelBase[0x0013A4AE]; 15 | kmem[0] = 0x90; 16 | kmem[1] = 0x90; 17 | kmem[2] = 0x90; 18 | kmem[3] = 0x90; 19 | kmem[4] = 0x90; 20 | 21 | // sceSblACMgrIsAllowedSystemLevelDebugging 22 | kmem = (uint8_t *)&gKernelBase[0x001CB060]; 23 | kmem[0] = 0xB8; 24 | kmem[1] = 0x01; 25 | kmem[2] = 0x00; 26 | kmem[3] = 0x00; 27 | kmem[4] = 0x00; 28 | kmem[5] = 0xC3; 29 | 30 | kmem = (uint8_t *)&gKernelBase[0x001CB880]; 31 | kmem[0] = 0xB8; 32 | kmem[1] = 0x01; 33 | kmem[2] = 0x00; 34 | kmem[3] = 0x00; 35 | kmem[4] = 0x00; 36 | kmem[5] = 0xC3; 37 | 38 | kmem = (uint8_t *)&gKernelBase[0x001CB8A0]; 39 | kmem[0] = 0xB8; 40 | kmem[1] = 0x01; 41 | kmem[2] = 0x00; 42 | kmem[3] = 0x00; 43 | kmem[4] = 0x00; 44 | kmem[5] = 0xC3; 45 | 46 | // Enable rwx mapping 47 | kmem = (uint8_t *)&gKernelBase[0x001171BE]; 48 | kmem[0] = 0x07; 49 | 50 | kmem = (uint8_t *)&gKernelBase[0x001171C6]; 51 | kmem[0] = 0x07; 52 | 53 | // Patch copyin/copyout: Allow userland + kernel addresses in both params 54 | // copyin 55 | kmem = (uint8_t *)&gKernelBase[0x0002F287]; 56 | kmem[0] = 0x90; 57 | kmem[1] = 0x90; 58 | 59 | kmem = (uint8_t *)&gKernelBase[0x0002F293]; 60 | kmem[0] = 0x90; 61 | kmem[1] = 0x90; 62 | kmem[2] = 0x90; 63 | 64 | // copyout 65 | kmem = (uint8_t *)&gKernelBase[0x0002F192]; 66 | kmem[0] = 0x90; 67 | kmem[1] = 0x90; 68 | 69 | kmem = (uint8_t *)&gKernelBase[0x0002F19E]; 70 | kmem[0] = 0x90; 71 | kmem[1] = 0x90; 72 | kmem[2] = 0x90; 73 | 74 | // Enable MAP_SELF 75 | kmem = (uint8_t *)&gKernelBase[0x001CB8F0]; 76 | kmem[0] = 0xB8; 77 | kmem[1] = 0x01; 78 | kmem[2] = 0x00; 79 | kmem[3] = 0x00; 80 | kmem[4] = 0x00; 81 | kmem[5] = 0xC3; 82 | 83 | kmem = (uint8_t *)&gKernelBase[0x001CB910]; 84 | kmem[0] = 0xB8; 85 | kmem[1] = 0x01; 86 | kmem[2] = 0x00; 87 | kmem[3] = 0x00; 88 | kmem[4] = 0x00; 89 | kmem[5] = 0xC3; 90 | 91 | kmem = (uint8_t *)&gKernelBase[0x001D40BB]; 92 | kmem[0] = 0x31; 93 | kmem[1] = 0xC0; 94 | kmem[2] = 0x90; 95 | kmem[3] = 0x90; 96 | kmem[4] = 0x90; 97 | 98 | // Patch copyinstr 99 | kmem = (uint8_t *)&gKernelBase[0x0002F733]; 100 | kmem[0] = 0x90; 101 | kmem[1] = 0x90; 102 | 103 | kmem = (uint8_t *)&gKernelBase[0x0002F73F]; 104 | kmem[0] = 0x90; 105 | kmem[1] = 0x90; 106 | kmem[2] = 0x90; 107 | 108 | // Patch memcpy stack 109 | kmem = (uint8_t *)&gKernelBase[0x0002F04D]; 110 | kmem[0] = 0xEB; 111 | 112 | // ptrace patches 113 | kmem = (uint8_t *)&gKernelBase[0x000448D5]; 114 | kmem[0] = 0xEB; 115 | 116 | // second ptrace patch 117 | kmem = (uint8_t *)&gKernelBase[0x00044DAF]; 118 | kmem[0] = 0xE9; 119 | kmem[1] = 0x7C; 120 | kmem[2] = 0x02; 121 | kmem[3] = 0x00; 122 | kmem[4] = 0x00; 123 | 124 | // setlogin patch (for autolaunch check) 125 | kmem = (uint8_t *)&gKernelBase[0x0008A8EC]; 126 | kmem[0] = 0x48; 127 | kmem[1] = 0x31; 128 | kmem[2] = 0xC0; 129 | kmem[3] = 0x90; 130 | kmem[4] = 0x90; 131 | 132 | // Patch to remove vm_fault: fault on nofault entry, addr %llx 133 | kmem = (uint8_t *)&gKernelBase[0x002BF756]; 134 | kmem[0] = 0x90; 135 | kmem[1] = 0x90; 136 | kmem[2] = 0x90; 137 | kmem[3] = 0x90; 138 | kmem[4] = 0x90; 139 | kmem[5] = 0x90; 140 | 141 | // Patch mprotect: Allow RWX (mprotect) mapping 142 | kmem = (uint8_t *)&gKernelBase[0x00264C08]; 143 | kmem[0] = 0x90; 144 | kmem[1] = 0x90; 145 | kmem[2] = 0x90; 146 | kmem[3] = 0x90; 147 | kmem[4] = 0x90; 148 | kmem[5] = 0x90; 149 | 150 | // flatz disable pfs signature check 151 | kmem = (uint8_t *)&gKernelBase[0x006BE880]; 152 | kmem[0] = 0x31; 153 | kmem[1] = 0xC0; 154 | kmem[2] = 0xC3; 155 | 156 | // flatz enable debug RIFs 157 | kmem = (uint8_t *)&gKernelBase[0x00668270]; 158 | kmem[0] = 0xB0; 159 | kmem[1] = 0x01; 160 | kmem[2] = 0xC3; 161 | 162 | kmem = (uint8_t *)&gKernelBase[0x006682A0]; 163 | kmem[0] = 0xB0; 164 | kmem[1] = 0x01; 165 | kmem[2] = 0xC3; 166 | 167 | // Enable *all* debugging logs (in vprintf) 168 | // Patch by: SiSTRo 169 | kmem = (uint8_t *)&gKernelBase[0x000BC817]; 170 | kmem[0] = 0xEB; 171 | kmem[1] = 0x3B; 172 | 173 | // flatz allow mangled symbol in dynlib_do_dlsym 174 | kmem = (uint8_t *)&gKernelBase[0x002F0367]; 175 | kmem[0] = 0x90; 176 | kmem[1] = 0x90; 177 | kmem[2] = 0x90; 178 | kmem[3] = 0x90; 179 | kmem[4] = 0x90; 180 | kmem[5] = 0x90; 181 | 182 | // Enable mount for unprivileged user 183 | kmem = (uint8_t *)&gKernelBase[0x0029636A]; 184 | kmem[0] = 0x90; 185 | kmem[1] = 0x90; 186 | kmem[2] = 0x90; 187 | kmem[3] = 0x90; 188 | kmem[4] = 0x90; 189 | kmem[5] = 0x90; 190 | 191 | // patch suword_lwpid 192 | // has a check to see if child_tid/parent_tid is in kernel memory, and it in so patch it 193 | // Patch by: JOGolden 194 | kmem = (uint8_t *)&gKernelBase[0x0002F552]; 195 | kmem[0] = 0x90; 196 | kmem[1] = 0x90; 197 | 198 | kmem = (uint8_t *)&gKernelBase[0x0002F561]; 199 | kmem[0] = 0x90; 200 | kmem[1] = 0x90; 201 | 202 | // Patch debug setting errors 203 | kmem = (uint8_t *)&gKernelBase[0x005016FA]; 204 | kmem[0] = 0x00; 205 | kmem[1] = 0x00; 206 | kmem[2] = 0x00; 207 | kmem[3] = 0x00; 208 | 209 | kmem = (uint8_t *)&gKernelBase[0x0050296C]; 210 | kmem[0] = 0x00; 211 | kmem[1] = 0x00; 212 | kmem[2] = 0x00; 213 | kmem[3] = 0x00; 214 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Patches-755.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Patches.h" 3 | 4 | void Install_755() 5 | { 6 | // Use "kmem" for all patches 7 | uint8_t *kmem; 8 | 9 | // Enable UART 10 | kmem = (uint8_t *)&gKernelBase[0x01564910]; 11 | kmem[0] = 0x00; 12 | 13 | // Verbose Panics 14 | kmem = (uint8_t *)&gKernelBase[0x0046D11E]; 15 | kmem[0] = 0x90; 16 | kmem[1] = 0x90; 17 | kmem[2] = 0x90; 18 | kmem[3] = 0x90; 19 | kmem[4] = 0x90; 20 | 21 | // sceSblACMgrIsAllowedSystemLevelDebugging 22 | kmem = (uint8_t *)&gKernelBase[0x003644B0]; 23 | kmem[0] = 0xB8; 24 | kmem[1] = 0x01; 25 | kmem[2] = 0x00; 26 | kmem[3] = 0x00; 27 | kmem[4] = 0x00; 28 | kmem[5] = 0xC3; 29 | 30 | kmem = (uint8_t *)&gKernelBase[0x00364CD0]; 31 | kmem[0] = 0xB8; 32 | kmem[1] = 0x01; 33 | kmem[2] = 0x00; 34 | kmem[3] = 0x00; 35 | kmem[4] = 0x00; 36 | kmem[5] = 0xC3; 37 | 38 | kmem = (uint8_t *)&gKernelBase[0x00364CF0]; 39 | kmem[0] = 0xB8; 40 | kmem[1] = 0x01; 41 | kmem[2] = 0x00; 42 | kmem[3] = 0x00; 43 | kmem[4] = 0x00; 44 | kmem[5] = 0xC3; 45 | 46 | // Enable rwx mapping 47 | kmem = (uint8_t *)&gKernelBase[0x001754AC]; 48 | kmem[0] = 0x07; 49 | 50 | kmem = (uint8_t *)&gKernelBase[0x001754B4]; 51 | kmem[0] = 0x07; 52 | 53 | // Patch copyin/copyout: Allow userland + kernel addresses in both params 54 | // copyin 55 | kmem = (uint8_t *)&gKernelBase[0x0028FA47]; 56 | kmem[0] = 0x90; 57 | kmem[1] = 0x90; 58 | 59 | kmem = (uint8_t *)&gKernelBase[0x0028FA53]; 60 | kmem[0] = 0x90; 61 | kmem[1] = 0x90; 62 | kmem[2] = 0x90; 63 | 64 | // copyout 65 | kmem = (uint8_t *)&gKernelBase[0x0028F952]; 66 | kmem[0] = 0x90; 67 | kmem[1] = 0x90; 68 | 69 | kmem = (uint8_t *)&gKernelBase[0x0028F95E]; 70 | kmem[0] = 0x90; 71 | kmem[1] = 0x90; 72 | kmem[2] = 0x90; 73 | 74 | // Enable MAP_SELF 75 | kmem = (uint8_t *)&gKernelBase[0x00364D40]; 76 | kmem[0] = 0xB8; 77 | kmem[1] = 0x01; 78 | kmem[2] = 0x00; 79 | kmem[3] = 0x00; 80 | kmem[4] = 0x00; 81 | kmem[5] = 0xC3; 82 | 83 | kmem = (uint8_t *)&gKernelBase[0x00364D60]; 84 | kmem[0] = 0xB8; 85 | kmem[1] = 0x01; 86 | kmem[2] = 0x00; 87 | kmem[3] = 0x00; 88 | kmem[4] = 0x00; 89 | kmem[5] = 0xC3; 90 | 91 | kmem = (uint8_t *)&gKernelBase[0x000DCED1]; 92 | kmem[0] = 0x31; 93 | kmem[1] = 0xC0; 94 | kmem[2] = 0x90; 95 | kmem[3] = 0x90; 96 | kmem[4] = 0x90; 97 | 98 | // Patch copyinstr 99 | kmem = (uint8_t *)&gKernelBase[0x0028FEF3]; 100 | kmem[0] = 0x90; 101 | kmem[1] = 0x90; 102 | 103 | kmem = (uint8_t *)&gKernelBase[0x0028FEFF]; 104 | kmem[0] = 0x90; 105 | kmem[1] = 0x90; 106 | kmem[2] = 0x90; 107 | 108 | // Patch memcpy stack 109 | kmem = (uint8_t *)&gKernelBase[0x0028F80D]; 110 | kmem[0] = 0xEB; 111 | 112 | // ptrace patches 113 | kmem = (uint8_t *)&gKernelBase[0x00361CF5]; 114 | kmem[0] = 0xEB; 115 | 116 | // second ptrace patch 117 | kmem = (uint8_t *)&gKernelBase[0x003621CF]; 118 | kmem[0] = 0xE9; 119 | kmem[1] = 0x7C; 120 | kmem[2] = 0x02; 121 | kmem[3] = 0x00; 122 | kmem[4] = 0x00; 123 | 124 | // setlogin patch (for autolaunch check) 125 | kmem = (uint8_t *)&gKernelBase[0x0037CF6C]; 126 | kmem[0] = 0x48; 127 | kmem[1] = 0x31; 128 | kmem[2] = 0xC0; 129 | kmem[3] = 0x90; 130 | kmem[4] = 0x90; 131 | 132 | // Patch to remove vm_fault: fault on nofault entry, addr %llx 133 | kmem = (uint8_t *)&gKernelBase[0x003DF2A6]; 134 | kmem[0] = 0x90; 135 | kmem[1] = 0x90; 136 | kmem[2] = 0x90; 137 | kmem[3] = 0x90; 138 | kmem[4] = 0x90; 139 | kmem[5] = 0x90; 140 | 141 | // Patch mprotect: Allow RWX (mprotect) mapping 142 | kmem = (uint8_t *)&gKernelBase[0x003014C8]; 143 | kmem[0] = 0x90; 144 | kmem[1] = 0x90; 145 | kmem[2] = 0x90; 146 | kmem[3] = 0x90; 147 | kmem[4] = 0x90; 148 | kmem[5] = 0x90; 149 | 150 | // flatz disable pfs signature check 151 | kmem = (uint8_t *)&gKernelBase[0x006DD9A0]; 152 | kmem[0] = 0x31; 153 | kmem[1] = 0xC0; 154 | kmem[2] = 0xC3; 155 | 156 | // flatz enable debug RIFs 157 | kmem = (uint8_t *)&gKernelBase[0x00668140]; 158 | kmem[0] = 0xB0; 159 | kmem[1] = 0x01; 160 | kmem[2] = 0xC3; 161 | 162 | kmem = (uint8_t *)&gKernelBase[0x00668170]; 163 | kmem[0] = 0xB0; 164 | kmem[1] = 0x01; 165 | kmem[2] = 0xC3; 166 | 167 | // Enable *all* debugging logs (in vprintf) 168 | // Patch by: SiSTRo 169 | kmem = (uint8_t *)&gKernelBase[0x0026F827]; 170 | kmem[0] = 0xEB; 171 | kmem[1] = 0x3B; 172 | 173 | // flatz allow mangled symbol in dynlib_do_dlsym 174 | kmem = (uint8_t *)&gKernelBase[0x000271A7]; 175 | kmem[0] = 0x90; 176 | kmem[1] = 0x90; 177 | kmem[2] = 0x90; 178 | kmem[3] = 0x90; 179 | kmem[4] = 0x90; 180 | kmem[5] = 0x90; 181 | 182 | // Enable mount for unprivileged user 183 | kmem = (uint8_t *)&gKernelBase[0x00076385]; 184 | kmem[0] = 0x90; 185 | kmem[1] = 0x90; 186 | kmem[2] = 0x90; 187 | kmem[3] = 0x90; 188 | kmem[4] = 0x90; 189 | kmem[5] = 0x90; 190 | 191 | // patch suword_lwpid 192 | // has a check to see if child_tid/parent_tid is in kernel memory, and it in so patch it 193 | // Patch by: JOGolden 194 | kmem = (uint8_t *)&gKernelBase[0x0028FD12]; 195 | kmem[0] = 0x90; 196 | kmem[1] = 0x90; 197 | 198 | kmem = (uint8_t *)&gKernelBase[0x0028FD21]; 199 | kmem[0] = 0x90; 200 | kmem[1] = 0x90; 201 | 202 | // Patch debug setting errors 203 | kmem = (uint8_t *)&gKernelBase[0x004FF322]; 204 | kmem[0] = 0x00; 205 | kmem[1] = 0x00; 206 | kmem[2] = 0x00; 207 | kmem[3] = 0x00; 208 | 209 | kmem = (uint8_t *)&gKernelBase[0x0050059C]; 210 | kmem[0] = 0x00; 211 | kmem[1] = 0x00; 212 | kmem[2] = 0x00; 213 | kmem[3] = 0x00; 214 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Patches-900.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Patches.h" 3 | 4 | void Install_900() 5 | { 6 | // Use "kmem" for all patches 7 | uint8_t *kmem; 8 | 9 | // Enable UART 10 | kmem = (uint8_t *)&gKernelBase[0x0152BF5D]; 11 | kmem[0] = 0x00; 12 | kmem[1] = 0x00; 13 | kmem[2] = 0x00; 14 | kmem[3] = 0x00; 15 | 16 | // Patch sys_dynlib_dlsym: Allow from anywhere 17 | kmem = (uint8_t *)&gKernelBase[0x0023B67F]; 18 | kmem[0] = 0xEB; 19 | kmem[1] = 0x4C; 20 | 21 | kmem = (uint8_t *)&gKernelBase[0x00221B40]; 22 | kmem[0] = 0x31; 23 | kmem[1] = 0xC0; 24 | kmem[2] = 0xC3; 25 | 26 | // Patch sys_mmap: Allow RWX (read-write-execute) mapping 27 | kmem = (uint8_t *)&gKernelBase[0x0016632A]; 28 | kmem[0] = 0x37; 29 | kmem[3] = 0x37; 30 | 31 | // Patch setuid: Don't run kernel exploit more than once/privilege escalation 32 | kmem = (uint8_t *)&gKernelBase[0x000019FF]; 33 | kmem[0] = 0xB8; 34 | kmem[1] = 0x00; 35 | kmem[2] = 0x00; 36 | kmem[3] = 0x00; 37 | kmem[4] = 0x00; 38 | 39 | // Enable RWX (kmem_alloc) mapping 40 | kmem = (uint8_t *)&gKernelBase[0x0037BF3C]; 41 | kmem[0] = 0x07; 42 | 43 | kmem = (uint8_t *)&gKernelBase[0x0037BF44]; 44 | kmem[0] = 0x07; 45 | 46 | // Patch copyin/copyout: Allow userland + kernel addresses in both params 47 | // copyin 48 | kmem = (uint8_t *)&gKernelBase[0x002716F7]; 49 | kmem[0] = 0x90; 50 | kmem[1] = 0x90; 51 | 52 | kmem = (uint8_t *)&gKernelBase[0x00271703]; 53 | kmem[0] = 0x90; 54 | kmem[1] = 0x90; 55 | kmem[2] = 0x90; 56 | 57 | // copyout 58 | kmem = (uint8_t *)&gKernelBase[0x00271602]; 59 | kmem[0] = 0x90; 60 | kmem[1] = 0x90; 61 | 62 | kmem = (uint8_t *)&gKernelBase[0x0027160E]; 63 | kmem[0] = 0x90; 64 | kmem[1] = 0x90; 65 | kmem[2] = 0x90; 66 | 67 | // Patch copyinstr 68 | kmem = (uint8_t *)&gKernelBase[0x00271BA3]; 69 | kmem[0] = 0x90; 70 | kmem[1] = 0x90; 71 | 72 | kmem = (uint8_t *)&gKernelBase[0x00271BAF]; 73 | kmem[0] = 0x90; 74 | kmem[1] = 0x90; 75 | kmem[2] = 0x90; 76 | 77 | kmem = (uint8_t *)&gKernelBase[0x00271BE0]; 78 | kmem[0] = 0x90; 79 | kmem[1] = 0x90; 80 | 81 | // Patch memcpy stack 82 | kmem = (uint8_t *)&gKernelBase[0x002714BD]; 83 | kmem[0] = 0xEB; 84 | 85 | // Patch mprotect: Allow RWX (mprotect) mapping 86 | kmem = (uint8_t *)&gKernelBase[0x00080B8B]; 87 | kmem[0] = 0x90; 88 | kmem[1] = 0x90; 89 | kmem[2] = 0x90; 90 | kmem[3] = 0x90; 91 | kmem[4] = 0x90; 92 | kmem[5] = 0x90; 93 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Patches.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Patches.h" 3 | #include "../../Common/Settings.h" 4 | 5 | // 6 | // Credits to Mira for the patches. Was just easier to slap them in :P 7 | // 8 | 9 | void Install_Patches() 10 | { 11 | if(!gKernelBase) 12 | return; 13 | 14 | uint64_t CR0 = __readcr0(); 15 | __writecr0(CR0 & ~CR0_WP); 16 | 17 | #if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA) 18 | Install_505(); 19 | #elif defined(SOFTWARE_VERSION_672) 20 | Install_672(); 21 | #elif defined(SOFTWARE_VERSION_702) 22 | Install_702(); 23 | #elif defined(SOFTWARE_VERSION_755) 24 | Install_755(); 25 | #elif defined(SOFTWARE_VERSION_900) 26 | Install_900(); 27 | #endif 28 | 29 | __writecr0(CR0); 30 | 31 | klog("Install_Patches() -> Sucess!"); 32 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Resolver/Resolver.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Resolver/Resolver.h" 3 | 4 | /* Util */ 5 | struct sysentvec* ksysvec = 0; 6 | struct prison* kprison0 = 0; 7 | struct vnode* krootvnode = 0; 8 | 9 | /* STD Lib */ 10 | void (*kmemcpy)(void *dst, const void *src, size_t len) = 0; 11 | void *(*kmemset)(void * ptr, int value, size_t num) = 0; 12 | int (*kmemcmp)(const void * ptr1, const void * ptr2, size_t num) = 0; 13 | int (*ksprintf)(char* dst, const char *fmt, ...) = 0; 14 | int (*kvsprintf)(char* dst, const char* fmt, va_list ap) = 0; 15 | void(*kprintf)(const char* fmt, ...) = 0; 16 | 17 | #define NATIVE_RESOLVE(_Ty) _Ty = (void*)((uint8_t *)&gKernelBase[addr_ ## _Ty]); 18 | 19 | void Kern_Resolve() 20 | { 21 | /* Util */ 22 | NATIVE_RESOLVE(ksysvec); 23 | NATIVE_RESOLVE(kprison0); 24 | NATIVE_RESOLVE(krootvnode); 25 | 26 | /* STD Lib */ 27 | NATIVE_RESOLVE(kmemcpy); 28 | NATIVE_RESOLVE(kmemset); 29 | NATIVE_RESOLVE(kmemcmp); 30 | NATIVE_RESOLVE(ksprintf); 31 | NATIVE_RESOLVE(kvsprintf); 32 | NATIVE_RESOLVE(kprintf); 33 | 34 | //klog("Kern_Resolve() -> Sucess!"); 35 | } 36 | 37 | int sys_dynlib_dlsym(int loadedModuleID, const char *name, void *destination) { 38 | return syscall(591, loadedModuleID, name, destination); 39 | } 40 | 41 | int sys_dynlib_load_prx(const char *name, int *idDestination) { 42 | return syscall(594, name, 0, idDestination, 0); 43 | } 44 | 45 | //kernel 46 | int(*sceKernelDebugOutText)(int dbg_channel, const char* text); 47 | int(*sceKernelMkdir)(const char *path, mode_t mode); 48 | int(*sceKernelOpen)(const char* path, int flags, mode_t mode); 49 | int(*sceKernelWrite)(int fd, void *data, size_t len); 50 | int(*sceKernelClose)(int fd); 51 | 52 | //libc 53 | void *(*malloc)(size_t size); 54 | void(*free)(void *ptr); 55 | void *(*calloc)(size_t num, size_t size); 56 | void *(*realloc)(void* ptr, size_t size); 57 | void *(*memset)(void *destination, int value, size_t num); 58 | void *(*memcpy)(void *destination, const void *source, size_t num); 59 | int(*memcmp)(const void *s1, const void *s2, size_t n); 60 | char *(*strcpy)(char *destination, const char *source); 61 | char *(*strncpy)(char *destination, const char *source, size_t num); 62 | char *(*strcat)(char *dest, const char *src); 63 | char *(*strncat)(char *dest, const char *src, size_t n); 64 | size_t(*strlen)(const char *s); 65 | int(*strcmp)(const char *s1, const char *s2); 66 | int(*strncmp)(const char *s1, const char *s2, size_t n); 67 | int(*sprintf)(char *str, const char *format, ...); 68 | int(*snprintf)(char *str, size_t size, const char *format, ...); 69 | int(*vsprintf)(char * s, const char * format, va_list arg); 70 | int(*sscanf)(const char *str, const char *format, ...); 71 | char *(*strchr)(const char *s, int c); 72 | char *(*strrchr)(const char *s, int c); 73 | char *(*strstr)(char *str1, char *str2); 74 | int(*atoi)(const char * str); 75 | double(*atof)(const char * str); 76 | double(*sin)(double x); 77 | double(*cos)(double x); 78 | double(*atan2)(double x, double y); 79 | double(*sqrt)(double vec); 80 | char *(*strdup)(const char *s); 81 | 82 | void Userland_Resolve() 83 | { 84 | int Libkernel_library = 0; 85 | if (sys_dynlib_load_prx("libkernel.sprx", &Libkernel_library)) 86 | if (sys_dynlib_load_prx("libkernel_web.sprx", &Libkernel_library)) 87 | sys_dynlib_load_prx("libkernel_sys.sprx", &Libkernel_library); 88 | 89 | sys_dynlib_dlsym(Libkernel_library, "sceKernelDebugOutText", &sceKernelDebugOutText); 90 | sys_dynlib_dlsym(Libkernel_library, "sceKernelMkdir", &sceKernelMkdir); 91 | sys_dynlib_dlsym(Libkernel_library, "sceKernelOpen", &sceKernelOpen); 92 | sys_dynlib_dlsym(Libkernel_library, "sceKernelWrite", &sceKernelWrite); 93 | sys_dynlib_dlsym(Libkernel_library, "sceKernelClose", &sceKernelClose); 94 | 95 | int Libc_Library = 0; 96 | sys_dynlib_load_prx("libSceLibcInternal.sprx", &Libc_Library); 97 | sys_dynlib_dlsym(Libc_Library, "malloc", &malloc); 98 | sys_dynlib_dlsym(Libc_Library, "free", &free); 99 | sys_dynlib_dlsym(Libc_Library, "calloc", &calloc); 100 | sys_dynlib_dlsym(Libc_Library, "realloc", &realloc); 101 | sys_dynlib_dlsym(Libc_Library, "memset", &memset); 102 | sys_dynlib_dlsym(Libc_Library, "memcpy", &memcpy); 103 | sys_dynlib_dlsym(Libc_Library, "memcmp", &memcmp); 104 | sys_dynlib_dlsym(Libc_Library, "strcpy", &strcpy); 105 | sys_dynlib_dlsym(Libc_Library, "strncpy", &strncpy); 106 | sys_dynlib_dlsym(Libc_Library, "strcat", &strcat); 107 | sys_dynlib_dlsym(Libc_Library, "strncat", &strncat); 108 | sys_dynlib_dlsym(Libc_Library, "strlen", &strlen); 109 | sys_dynlib_dlsym(Libc_Library, "strcmp", &strcmp); 110 | sys_dynlib_dlsym(Libc_Library, "strncmp", &strncmp); 111 | sys_dynlib_dlsym(Libc_Library, "sprintf", &sprintf); 112 | sys_dynlib_dlsym(Libc_Library, "snprintf", &snprintf); 113 | sys_dynlib_dlsym(Libc_Library, "vsprintf", &vsprintf); 114 | sys_dynlib_dlsym(Libc_Library, "sscanf", &sscanf); 115 | sys_dynlib_dlsym(Libc_Library, "strchr", &strchr); 116 | sys_dynlib_dlsym(Libc_Library, "strrchr", &strrchr); 117 | sys_dynlib_dlsym(Libc_Library, "strstr", &strstr); 118 | sys_dynlib_dlsym(Libc_Library, "atoi", &atoi); 119 | sys_dynlib_dlsym(Libc_Library, "atof", &atof); 120 | sys_dynlib_dlsym(Libc_Library, "sin", &sin); 121 | sys_dynlib_dlsym(Libc_Library, "cos", &cos); 122 | sys_dynlib_dlsym(Libc_Library, "atan2", &atan2); 123 | sys_dynlib_dlsym(Libc_Library, "sqrt", &sqrt); 124 | sys_dynlib_dlsym(Libc_Library, "strdup", &strdup); 125 | 126 | Log("Userland_Resolve() -> Sucess!"); 127 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Util/Resources.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Util/Resources.h" 3 | 4 | //SPRX File 5 | extern char _binary_Resources_Orbis_Toolbox_bin_start[]; 6 | extern char _binary_Resources_Orbis_Toolbox_bin_end[]; 7 | 8 | //Icons 9 | extern char _binary_Resources_icon_daemon_bin_start[]; 10 | extern char _binary_Resources_icon_daemon_bin_end[]; 11 | 12 | extern char _binary_Resources_icon_payload_bin_start[]; 13 | extern char _binary_Resources_icon_payload_bin_end[]; 14 | 15 | extern char _binary_Resources_icon_pkg_bin_start[]; 16 | extern char _binary_Resources_icon_pkg_bin_end[]; 17 | 18 | extern char _binary_Resources_icon_plugin_bin_start[]; 19 | extern char _binary_Resources_icon_plugin_bin_end[]; 20 | 21 | extern char _binary_Resources_icon_reboot_bin_start[]; 22 | extern char _binary_Resources_icon_reboot_bin_end[]; 23 | 24 | extern char _binary_Resources_icon_reload_ui_bin_start[]; 25 | extern char _binary_Resources_icon_reload_ui_bin_end[]; 26 | 27 | extern char _binary_Resources_icon_shutdown_bin_start[]; 28 | extern char _binary_Resources_icon_shutdown_bin_end[]; 29 | 30 | extern char _binary_Resources_icon_suspend_bin_start[]; 31 | extern char _binary_Resources_icon_suspend_bin_end[]; 32 | 33 | extern char _binary_Resources_icon_system_settings_bin_start[]; 34 | extern char _binary_Resources_icon_system_settings_bin_end[]; 35 | 36 | extern char _binary_Resources_icon_toolbox_bin_start[]; 37 | extern char _binary_Resources_icon_toolbox_bin_end[]; 38 | 39 | /* 40 | PLDR00000 41 | */ 42 | extern char _binary_Resources_PLDR00000_eboot_bin_start[]; 43 | extern char _binary_Resources_PLDR00000_eboot_bin_end[]; 44 | 45 | extern char _binary_Resources_PLDR00000_param_bin_start[]; 46 | extern char _binary_Resources_PLDR00000_param_bin_end[]; 47 | 48 | extern char _binary_Resources_PLDR00000_icon0_bin_start[]; 49 | extern char _binary_Resources_PLDR00000_icon0_bin_end[]; 50 | 51 | extern char _binary_Resources_PLDR00000_libjbc_bin_start[]; 52 | extern char _binary_Resources_PLDR00000_libjbc_bin_end[]; 53 | 54 | #define _Write_File(File, Start, End) Write_File(File, Start, (size_t)(End - Start)) 55 | 56 | int Write_File(const char* File, char* Data, size_t size) 57 | { 58 | int fd = sceKernelOpen(File, 0x200 | 0x0002, 0777); 59 | if(fd) 60 | { 61 | Log("Writing File \"%s\" %i...", File, size); 62 | 63 | sceKernelWrite(fd, Data, size); 64 | 65 | sceKernelClose(fd); 66 | 67 | return 1; 68 | } 69 | else 70 | { 71 | Log("Failed to make file \"%s\"\n", File); 72 | return 0; 73 | } 74 | } 75 | 76 | int MakeDir(char* Dir, ...) 77 | { 78 | char buffer[0x400] = { 0 }; 79 | va_list args; 80 | va_start(args, Dir); 81 | vsprintf(buffer, Dir, args); 82 | va_end(args); 83 | 84 | Log("Creating Directory \"%s\"...", buffer); 85 | return sceKernelMkdir(buffer, 0777); 86 | } 87 | 88 | void Install_Daemon(const char* TitleId, char* Eboot_start, char* Eboot_end, char* Param_sfo_start, char* Param_sfo_end, char* Icon_start, char* Icon_end) 89 | { 90 | Log("Installing Daemon %s", TitleId); 91 | 92 | Log("Creating Directories..."); 93 | MakeDir("/system/vsh/app/%s", TitleId); 94 | MakeDir("/system/vsh/app/%s/sce_module", TitleId); 95 | MakeDir("/system/vsh/app/%s/sce_sys", TitleId); 96 | 97 | Log("Writing Files..."); 98 | char Eboot_Dir[PATH_MAX], Param_sfo_Dir[PATH_MAX], Icon_Dir[PATH_MAX]; 99 | sprintf(Eboot_Dir, "/system/vsh/app/%s/eboot.bin", TitleId); 100 | sprintf(Param_sfo_Dir, "/system/vsh/app/%s/sce_sys/param.sfo", TitleId); 101 | sprintf(Icon_Dir, "/system/vsh/app/%s/sce_sys/icon0.png", TitleId); 102 | 103 | _Write_File(Eboot_Dir, Eboot_start, Eboot_end); 104 | _Write_File(Param_sfo_Dir, Param_sfo_start, Param_sfo_end); 105 | _Write_File(Icon_Dir, Icon_start, Icon_end); 106 | 107 | Log("Installing Daemon %s Complete!", TitleId); 108 | } 109 | 110 | void Install_Resources() 111 | { 112 | Log("Making Directories..."); 113 | MakeDir("/data/Orbis Toolbox"); 114 | MakeDir("/data/Orbis Toolbox/Plugins"); 115 | MakeDir("/data/Orbis Toolbox/Icons"); 116 | MakeDir("/data/Orbis Toolbox/Payloads"); 117 | 118 | Log("Writing Files..."); 119 | 120 | //Main Toolbox Module 121 | _Write_File("/data/Orbis Toolbox/Orbis Toolbox.sprx", _binary_Resources_Orbis_Toolbox_bin_start, _binary_Resources_Orbis_Toolbox_bin_end); 122 | 123 | //Toolbox Supporting Assets. 124 | _Write_File("/data/Orbis Toolbox/Icons/icon_daemon.png", _binary_Resources_icon_daemon_bin_start, _binary_Resources_icon_daemon_bin_end); 125 | _Write_File("/data/Orbis Toolbox/Icons/icon_payload.png", _binary_Resources_icon_payload_bin_start, _binary_Resources_icon_payload_bin_end); 126 | _Write_File("/data/Orbis Toolbox/Icons/icon_pkg.png", _binary_Resources_icon_pkg_bin_start, _binary_Resources_icon_pkg_bin_end); 127 | _Write_File("/data/Orbis Toolbox/Icons/icon_plugin.png", _binary_Resources_icon_plugin_bin_start, _binary_Resources_icon_plugin_bin_end); 128 | _Write_File("/data/Orbis Toolbox/Icons/icon_reboot.png", _binary_Resources_icon_reboot_bin_start, _binary_Resources_icon_reboot_bin_end); 129 | _Write_File("/data/Orbis Toolbox/Icons/icon_reload_ui.png", _binary_Resources_icon_reload_ui_bin_start, _binary_Resources_icon_reload_ui_bin_end); 130 | _Write_File("/data/Orbis Toolbox/Icons/icon_shutdown.png", _binary_Resources_icon_shutdown_bin_start, _binary_Resources_icon_shutdown_bin_end); 131 | _Write_File("/data/Orbis Toolbox/Icons/icon_suspend.png", _binary_Resources_icon_suspend_bin_start, _binary_Resources_icon_suspend_bin_end); 132 | _Write_File("/data/Orbis Toolbox/Icons/icon_system_settings.png", _binary_Resources_icon_system_settings_bin_start, _binary_Resources_icon_system_settings_bin_end); 133 | _Write_File("/data/Orbis Toolbox/Icons/icon_toolbox.png", _binary_Resources_icon_toolbox_bin_start, _binary_Resources_icon_toolbox_bin_end); 134 | 135 | Log("Installing Daemons..."); 136 | Install_Daemon("PLDR00000", //Payload Loacer Daemon 137 | _binary_Resources_PLDR00000_eboot_bin_start, _binary_Resources_PLDR00000_eboot_bin_end, 138 | _binary_Resources_PLDR00000_param_bin_start, _binary_Resources_PLDR00000_param_bin_end, 139 | _binary_Resources_PLDR00000_icon0_bin_start, _binary_Resources_PLDR00000_icon0_bin_end); 140 | _Write_File("/system/vsh/app/PLDR00000/sce_module/libjbc.sprx", _binary_Resources_PLDR00000_libjbc_bin_start, _binary_Resources_PLDR00000_libjbc_bin_end); 141 | 142 | Log("Install_Resources() -> Sucess!"); 143 | } -------------------------------------------------------------------------------- /Loader/Userland/source/Util/Utils.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Util/Utils.h" 3 | 4 | void Jailbreak(struct proc* proc, struct Backup_Jail* jail) 5 | { 6 | if(proc) 7 | { 8 | struct ucred* cred = proc->p_ucred; 9 | struct filedesc* fd = proc->p_fd; 10 | 11 | if(!cred || !fd) 12 | return; 13 | 14 | if(jail) 15 | { 16 | jail->cr_prison = cred->cr_prison; 17 | jail->cr_uid = cred->cr_uid; 18 | jail->cr_ruid = cred->cr_ruid; 19 | jail->cr_rgid = cred->cr_rgid; 20 | jail->cr_groups = cred->cr_groups[0]; 21 | 22 | jail->fd_jdir = fd->fd_jdir; 23 | jail->fd_rdir = fd->fd_rdir; 24 | } 25 | 26 | cred->cr_prison = *(struct prison**)kprison0; 27 | 28 | cred->cr_uid = 0; 29 | cred->cr_ruid = 0; 30 | cred->cr_rgid = 0; 31 | cred->cr_groups[0] = 0; 32 | 33 | 34 | fd->fd_jdir = *(struct vnode**)krootvnode; 35 | fd->fd_rdir = *(struct vnode**)krootvnode; 36 | } 37 | } 38 | 39 | void RestoreJail(struct proc* proc, struct Backup_Jail jail) 40 | { 41 | if(proc) 42 | { 43 | struct ucred* cred = proc->p_ucred; 44 | struct filedesc* fd = proc->p_fd; 45 | 46 | if(!cred || !fd) 47 | return; 48 | 49 | cred->cr_prison = jail.cr_prison; 50 | cred->cr_uid = jail.cr_uid; 51 | cred->cr_ruid = jail.cr_ruid; 52 | cred->cr_rgid = jail.cr_rgid; 53 | cred->cr_groups[0] = jail.cr_groups; 54 | 55 | fd->fd_jdir = jail.fd_jdir; 56 | fd->fd_rdir = jail.fd_rdir; 57 | } 58 | } 59 | 60 | int klog(char* fmt, ...) 61 | { 62 | char buffer[0x400] = { 0 }; 63 | va_list args; 64 | va_start(args, fmt); 65 | kvsprintf(buffer, fmt, args); 66 | va_end(args); 67 | 68 | char buffer2[0x400] = { 0 }; 69 | ksprintf(buffer2, "[Orbis Toolbox] %s\n", buffer); 70 | 71 | #if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA) 72 | 73 | struct thread *td = curthread(); 74 | 75 | struct sys_read_args { 76 | uint64_t unk; 77 | uint64_t msg; 78 | uint64_t unk2; 79 | }; 80 | 81 | struct sysent* sysents = ksysvec->sv_table; 82 | 83 | int(*sys_read)(struct thread * td, struct sys_read_args * uap) = (void*)sysents[601].sy_call; 84 | 85 | td->td_retval[0] = 0; 86 | 87 | struct sys_read_args uap; 88 | uap.unk = 7; 89 | uap.msg = (uint64_t)buffer2; 90 | uap.unk2 = 0; 91 | 92 | int errorno = sys_read(td, &uap); 93 | 94 | if(errorno) 95 | return -errorno; 96 | 97 | return (int)td->td_retval[0]; 98 | 99 | #endif 100 | 101 | #if defined(SOFTWARE_VERSION_672) || defined(SOFTWARE_VERSION_702) || defined(SOFTWARE_VERSION_755) 102 | 103 | kprintf(buffer2); 104 | 105 | return 0; 106 | 107 | #endif 108 | } 109 | 110 | void Log(char* fmt, ...) 111 | { 112 | if(sceKernelDebugOutText) 113 | { 114 | char buffer[0x400] = { 0 }; 115 | va_list args; 116 | va_start(args, fmt); 117 | vsprintf(buffer, fmt, args); 118 | va_end(args); 119 | 120 | char buffer2[0x400] = { 0 }; 121 | sprintf(buffer2, "[Orbis Toolbox] %s\n", buffer); 122 | 123 | sceKernelDebugOutText(0, buffer2); 124 | } 125 | } -------------------------------------------------------------------------------- /Loader/Userland/source/embed.s: -------------------------------------------------------------------------------- 1 | .global LibraryFile 2 | .type LibraryFile, @object 3 | .align 4 4 | 5 | LibraryFile: 6 | .incbin "../../Orbis Toolbox.sprx" 7 | LibraryFileEnd: 8 | 9 | .global LibraryFileSize 10 | .type LibraryFileSize, @object 11 | .align 4 12 | 13 | LibraryFileSize: 14 | .int LibraryFileEnd - LibraryFile 15 | -------------------------------------------------------------------------------- /Loader/Userland/source/main.c: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | 3 | extern char _binary_Resources_Kernel_bin_start[]; 4 | extern char _binary_Resources_Kernel_bin_end[]; 5 | struct Backup_Jail bkJail; 6 | uint8_t* gKernelBase; 7 | 8 | int install_elf(struct thread *td) 9 | { 10 | //Get kernel Base. 11 | uint8_t* KernelBase = (uint8_t*)(__readmsr(0xC0000082) - addr_Xfast_syscall); 12 | 13 | if(!KernelBase) 14 | return 0; 15 | 16 | size_t msize = 0; 17 | if (elf_mapped_size(_binary_Resources_Kernel_bin_start, &msize)) { 18 | return 1; 19 | } 20 | 21 | uint64_t (*kmem_alloc)(vm_map_t map, uint64_t size) = (void *)(KernelBase + addr_kmem_alloc); 22 | vm_map_t kernel_map = *(vm_map_t *)(KernelBase + addr_kernel_map); 23 | 24 | int s = (msize + 0x3FFFull) & ~0x3FFFull; 25 | void *payloadbase = (void*)kmem_alloc(kernel_map, s); 26 | if (!payloadbase) { 27 | return 1; 28 | } 29 | 30 | klog("Kernel ELF:\nBase -> 0x%llX\nSize: -> %llX", _binary_Resources_Kernel_bin_start, (size_t)(_binary_Resources_Kernel_bin_end - _binary_Resources_Kernel_bin_start)); 31 | 32 | int r = 0; 33 | int (*payload_entry)(uint64_t kernelbase); 34 | 35 | if ((r = load_elf(_binary_Resources_Kernel_bin_start, (size_t)(_binary_Resources_Kernel_bin_end - _binary_Resources_Kernel_bin_start), payloadbase, msize, (void **)&payload_entry))) { 36 | return r; 37 | } 38 | 39 | if (payload_entry(KernelBase)) { 40 | return 1; 41 | } 42 | 43 | klog("Loaded Kernel ELF Sucess!"); 44 | 45 | //Restore the original jail for the current Process. 46 | RestoreJail(td->td_proc, bkJail); 47 | 48 | klog("RestoreJail() -> Sucess!"); 49 | 50 | return 0; 51 | } 52 | 53 | int jailbreak_proc(struct thread *td) 54 | { 55 | //Get kernel Base. 56 | gKernelBase = (uint8_t*)(__readmsr(0xC0000082) - addr_Xfast_syscall); 57 | 58 | if(!gKernelBase) 59 | return 0; 60 | 61 | //Resolve Function Addresses and install Patches. 62 | Kern_Resolve(); 63 | Install_Patches(); 64 | 65 | klog("KernBase: 0x%llX", gKernelBase); 66 | 67 | //Jailbreak current Process. 68 | Jailbreak(td->td_proc, &bkJail); 69 | 70 | klog("Jailbreak() -> Sucess!"); 71 | 72 | return 0; 73 | } 74 | 75 | int _main(void) 76 | { 77 | syscall(601, 7, "Hello World.\n", 0); 78 | 79 | //Jailbreak the current proc to write to root. 80 | syscall(11, jailbreak_proc); 81 | 82 | //Resolve userland Functions 83 | Userland_Resolve(); 84 | 85 | //Copy Resources. 86 | Install_Resources(); 87 | 88 | //load kernel elf. 89 | syscall(11, install_elf); 90 | 91 | Log("Loading Completed."); 92 | 93 | return 0; 94 | } -------------------------------------------------------------------------------- /Loader/Userland/source/syscall.s: -------------------------------------------------------------------------------- 1 | .intel_syntax noprefix 2 | .text 3 | 4 | .globl syscall 5 | syscall: 6 | xor rax, rax 7 | mov r10, rcx 8 | syscall 9 | ret 10 | -------------------------------------------------------------------------------- /Orbis Toolbox.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.1433 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Orbis Toolbox", "Orbis Toolbox\Orbis Toolbox.vcxproj", "{CED79D48-621A-4076-81E8-11F77DE1E41B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|x64.ActiveCfg = Debug|x64 15 | {CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|x64.Build.0 = Debug|x64 16 | {CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|x64.ActiveCfg = Release|x64 17 | {CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {5B7CC1AD-4112-45C6-BE51-4CBDE8471492} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Orbis Toolbox/Build_Overlay.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Build_Overlay.h" 3 | 4 | bool Build_Overlay::Draw = false; 5 | Widget* Build_Overlay::Root_Widget = nullptr; 6 | 7 | void Build_Overlay::Update() 8 | { 9 | if (Draw) 10 | { 11 | if (Root_Widget->Has_Child("BUILDPANEL")) 12 | return; 13 | 14 | //Create new Label for the build string. 15 | Label* BuildLabel = new Label("BUILDLABEL", 20.0f, 36.0f, ORBIS_TOOLBOX_BUILDSTRING, 20, Label::fsItalic, 16 | Label::fwBold, Label::VerticalAlignment::vCenter, Label::HorizontalAlignment::hCenter, 1.0f, 1.0f, 1.0f, 1.0f); 17 | 18 | //Create new panel for the build Panel. 19 | Panel* BuildPanel = new Panel("BUILDPANEL", UI::Utilities::ScreenWidth() - (BuildLabel->Get_Text_Width() + 30.0f), 20.0f, 440.0f, 100.0f, 20 | 0.92f, 0.2f, 0.16f, 0.8f, Panel::RenderingOrder::Last, UI::Utilities::Adjust_Content(Panel::Vertical, 4, 4, 4, 4)); 21 | 22 | //Append the Text to the Build Panel. 23 | BuildPanel->Append_Child("BUILDLABEL", BuildLabel); 24 | 25 | //Append the Label to the root widget. 26 | Root_Widget->Append_Child("BUILDPANEL", BuildPanel); 27 | } 28 | else 29 | Root_Widget->Remove_Child("BUILDPANEL"); 30 | } 31 | 32 | void Build_Overlay::Init() 33 | { 34 | //Init the local widget class with our new root widget. 35 | Root_Widget = new Widget(); 36 | Root_Widget->Instance = UI::Utilities::Get_root_Widget(); 37 | } 38 | 39 | void Build_Overlay::Term() 40 | { 41 | //Remove the build panel for destruction. 42 | Root_Widget->Remove_Child("BUILDPANEL"); 43 | 44 | //Clean up alocated classses. 45 | delete Root_Widget; 46 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Build_Overlay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Common.h" 3 | #include "Widget.h" 4 | 5 | class Build_Overlay 6 | { 7 | public: 8 | static bool Draw; 9 | 10 | static void Update(); 11 | static void Init(); 12 | static void Term(); 13 | 14 | private: 15 | static Widget* Root_Widget; 16 | }; 17 | -------------------------------------------------------------------------------- /Orbis Toolbox/Common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "Version.h" 18 | #include "Utilities.h" 19 | #include "Mono.h" 20 | #include "Detour.h" 21 | #include "Patcher.h" 22 | #include "UI.h" 23 | #include "Menu.h" 24 | 25 | #include "Widget.h" 26 | #include "Label.h" 27 | #include "Panel.h" 28 | 29 | #define ORBIS_TOOLBOX_NOTIFY ("Orbis Toolbox Alpha: " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) " Loaded!") -------------------------------------------------------------------------------- /Orbis Toolbox/Config.h: -------------------------------------------------------------------------------- 1 | /*#pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class Config 10 | { 11 | public: 12 | bool Parse(const char* File); 13 | 14 | bool Read_Bool(const char* Section, const char* Member); 15 | int Read_Int(const char* Section, const char* Member); 16 | float Read_Float(const char* Section, const char* Member); 17 | std::string Read_String(const char* Section, const char* Member); 18 | 19 | private: 20 | std::fstream RFile_Handle; 21 | std::fstream WFile_Handle; 22 | 23 | std::map> Config_Data; 24 | 25 | bool Does_Member_Exist(const char* Section, const char* Member); 26 | };*/ 27 | #pragma once 28 | 29 | class Config 30 | { 31 | private: 32 | struct Data_s 33 | { 34 | int Version; 35 | 36 | bool Auto_Load_Settings; 37 | bool Show_DebugTitleIdLabel; 38 | bool Show_DevkitPanel; 39 | bool Show_Debug_Settings; 40 | bool Show_App_Home; 41 | 42 | bool Show_Build_Overlay; 43 | 44 | char Game_Overlay_Location[0x100]; 45 | bool Show_CPU_Usage; 46 | bool Show_Thread_Count; 47 | bool Show_ram; 48 | bool Show_vram; 49 | bool Show_CPU_Temp; 50 | bool Show_SOC_Temp; 51 | }; 52 | 53 | public: 54 | static Data_s* Data; 55 | 56 | static bool Read(const char* File); 57 | static bool Parse(const char* File); 58 | static bool Write(const char* File); 59 | 60 | static void Init(); 61 | static void Term(); 62 | }; 63 | -------------------------------------------------------------------------------- /Orbis Toolbox/Custom_Content.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Debug_Features.h" 3 | 4 | Detour* Debug_Feature::Custom_Content::Detour_ExecuteSelectQuery = nullptr; 5 | Detour* Debug_Feature::Custom_Content::Detour_ExecuteCountQuery = nullptr; 6 | Detour* Debug_Feature::Custom_Content::Detour_StartDebugSettings = nullptr; 7 | Detour* Debug_Feature::Custom_Content::Detour_GetIconPath = nullptr; 8 | 9 | bool Debug_Feature::Custom_Content::Show_App_Home; 10 | bool Debug_Feature::Custom_Content::Show_Debug_Settings; 11 | 12 | MonoObject* Debug_Feature::Custom_Content::ExecuteSelectQuery_Hook(MonoObject* Instance, int offset, int limit) 13 | { 14 | //System.Collections.Generic List 15 | MonoClass* List = Mono::Get_Class(Mono::mscorlib, "System.Collections.Generic", "List`1"); 16 | 17 | MonoObject* List_Instance = Detour_ExecuteSelectQuery->Stub(Instance, offset, limit); 18 | if (Mono::Get_Field(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", Instance, "exclusionFilterTypeAppHome") == 0) 19 | { 20 | if (Show_Debug_Settings) 21 | Mono::Invoke(Mono::Accessor_Db, List, List_Instance, "Insert", 0, UI::Utilities::AppBrowseItem("NPXS20993", "★Orbis Toolbox")); 22 | 23 | if (Show_App_Home) 24 | { 25 | Mono::Invoke(Mono::Accessor_Db, List, List_Instance, "Insert", 0, UI::Utilities::AppBrowseItem("NPXS29998", "★APP_HOME(data)")); 26 | Mono::Invoke(Mono::Accessor_Db, List, List_Instance, "Insert", 0, UI::Utilities::AppBrowseItem("NPXS29999", "★APP_HOME(host)")); 27 | } 28 | 29 | } 30 | 31 | return List_Instance; 32 | } 33 | 34 | int Debug_Feature::Custom_Content::ExecuteCountQuery_Hook(MonoObject* Instance) 35 | { 36 | int Count = Detour_ExecuteCountQuery->Stub(Instance); 37 | 38 | if (Mono::Get_Field(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", Instance, "exclusionFilterTypeAppHome") == 0) 39 | { 40 | if (Show_Debug_Settings) 41 | Count += 1; 42 | 43 | if (Show_App_Home) 44 | Count += 2; 45 | } 46 | 47 | return Count; 48 | } 49 | 50 | void Debug_Feature::Custom_Content::StartDebugSettings_Hook(MonoObject* Instance) 51 | { 52 | MonoClass* UIManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.Settings.Core", "UIManager"); 53 | MonoClass* SettingsApplication = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI", "SettingsApplication"); 54 | Mono::Invoke(Mono::App_exe, UIManager, Mono::Get_Field(SettingsApplication, Instance, "uiManager"), "Push", Mono::New_String("orbis_toolbox.xml"), Mono::New_String("id_orbis_toolbox"), 3); 55 | } 56 | 57 | MonoString* GetTexture(const char* texId) 58 | { 59 | // /Application/resource/Sce.Vsh.ShellUI.Base.rco 60 | return Mono::New_String("cxml://BasePlugin/%s", texId); 61 | } 62 | 63 | MonoString* Debug_Feature::Custom_Content::GetIconPath_Hook(MonoObject* item, bool withTheme) 64 | { 65 | MonoString* IconPath = Detour_GetIconPath->Stub(item, withTheme); 66 | 67 | char* TitleId = mono_string_to_utf8(Mono::Get_Property(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemLite", item, "TitleId")); 68 | if (!strcmp(TitleId, "NPXS29999")) 69 | return GetTexture("tex_app_home"); 70 | else if (!strcmp(TitleId, "NPXS29998")) 71 | return GetTexture("tex_app_home_data"); 72 | else if (!strcmp(TitleId, "NPXS20993")) 73 | return GetTexture("tex_debug_settings"); 74 | else 75 | return IconPath; 76 | } 77 | 78 | void Debug_Feature::Custom_Content::Init() 79 | { 80 | Detour_ExecuteSelectQuery = new Detour(); 81 | Detour_ExecuteCountQuery = new Detour(); 82 | Detour_StartDebugSettings = new Detour(); 83 | Detour_GetIconPath = new Detour(); 84 | 85 | Detour_ExecuteSelectQuery->DetourMethod(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", "ExecuteSelectQuery", 2, (void*)ExecuteSelectQuery_Hook); 86 | Detour_ExecuteCountQuery->DetourMethod(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", "ExecuteCountQuery", 0, (void*)ExecuteCountQuery_Hook); 87 | Detour_StartDebugSettings->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI", "SettingsApplication", "StartDebugSettings", 0, (void*)StartDebugSettings_Hook); 88 | Detour_GetIconPath->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "AppBrowseItemMethodExteneder", "GetIconPath", 2, (void*)GetIconPath_Hook); 89 | } 90 | 91 | void Debug_Feature::Custom_Content::Term() 92 | { 93 | delete Detour_ExecuteSelectQuery; 94 | delete Detour_ExecuteCountQuery; 95 | delete Detour_StartDebugSettings; 96 | delete Detour_GetIconPath; 97 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Daemons.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Daemons.h" 3 | 4 | #include "SysfileUtilWrapper.h" 5 | #include "LncUtil.h" 6 | 7 | bool Start_Daemon(char* TitleId) 8 | { 9 | if (!Is_Daemon_Running(TitleId)) 10 | { 11 | LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None }; 12 | LncUtil::LaunchApp(TitleId, 0, 0, &p); 13 | 14 | if (!Is_Daemon_Running(TitleId)) 15 | return false; 16 | } 17 | 18 | return true; 19 | } 20 | 21 | bool Stop_Daemon(char* TitleId) 22 | { 23 | int AppId = LncUtil::GetAppId(TitleId); 24 | if (AppId > 0) 25 | { 26 | LncUtil::KillApp(AppId); 27 | 28 | if (Is_Daemon_Running(TitleId)) 29 | return false; 30 | } 31 | 32 | return true; 33 | } 34 | 35 | bool Is_Daemon_Running(char* TitleId) 36 | { 37 | return (LncUtil::GetAppId(TitleId) > 0); 38 | } 39 | 40 | /* 41 | Will start or stop a Daemon depending on its state. 42 | 43 | TitleId - A string representing the Daemons title Index usually in form of XXXX##### 44 | Restart - If the Daemon is already running will stop and restart it. 45 | */ 46 | bool Start_Stop_Daemon(char* TitleId, bool Restart) 47 | { 48 | int AppId = LncUtil::GetAppId(TitleId); 49 | if (AppId > 0) 50 | { 51 | LncUtil::KillApp(AppId); 52 | 53 | if ((LncUtil::GetAppId(TitleId) <= 0) && Restart) 54 | return Start_Stop_Daemon(TitleId, false); 55 | else if (LncUtil::GetAppId(TitleId) <= 0) 56 | return true; 57 | else 58 | return false; 59 | } 60 | else 61 | { 62 | LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None }; 63 | LncUtil::LaunchApp(TitleId, 0, 0, &p); 64 | 65 | return (LncUtil::GetAppId(TitleId) > 0); 66 | } 67 | } 68 | 69 | void Add_Daemon(char* dent) 70 | { 71 | char TitleId[10]; 72 | char Id_Name[0x100]; 73 | char Icon_Path[PATH_MAX]; 74 | char SFO_Path[PATH_MAX]; 75 | 76 | strcpy(TitleId, dent); 77 | sprintf(Id_Name, "id_%s", TitleId); 78 | sprintf(Icon_Path, "file://system/vsh/app/%s/sce_sys/icon0.png", TitleId); 79 | sprintf(SFO_Path, "/system/vsh/app/%s/sce_sys/param.sfo", TitleId); 80 | 81 | //Adds a custom button to the current drawing stack with the name and desc. of the daemon from the param.sfo 82 | UI::Utilities::AddMenuItem(UI::Utilities::ElementData(Id_Name, SysfileUtilWrapper::GetTitle(SFO_Path), SysfileUtilWrapper::GetDescription(SFO_Path), Icon_Path)); 83 | 84 | //Remove Menu Option if already Exists. 85 | if (Menu::Has_Option(Id_Name)) 86 | Menu::Remove_Option(Id_Name); 87 | 88 | //Add Menu Option with call back to load Daemon. 89 | Menu::Add_Option(Id_Name, [TitleId, Id_Name]() -> void { 90 | 91 | int AppId = LncUtil::GetAppId(TitleId); 92 | if (AppId > 0) //App is Currently Running. 93 | { 94 | UI::Utilities::Set_Value(Id_Name, "Stopping"); 95 | UI::Utilities::ResetMenuItem(Id_Name); 96 | 97 | //Kill the app. 98 | LncUtil::KillApp(AppId); 99 | 100 | //Check to see if it worked. 101 | UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped"); 102 | UI::Utilities::ResetMenuItem(Id_Name); 103 | } 104 | else 105 | { 106 | UI::Utilities::Set_Value(Id_Name, "Starting"); 107 | UI::Utilities::ResetMenuItem(Id_Name); 108 | 109 | LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None }; 110 | LncUtil::LaunchApp(TitleId, 0, 0, &p); 111 | 112 | //Check to see if it worked. 113 | UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped"); 114 | UI::Utilities::ResetMenuItem(Id_Name); 115 | } 116 | 117 | }); 118 | 119 | //Shows the current status of the daemon. 120 | UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped"); 121 | UI::Utilities::ResetMenuItem(Id_Name); 122 | } 123 | 124 | void Remove_Daemon(char* dent) 125 | { 126 | char Id_Name[0x100]; 127 | sprintf(Id_Name, "id_%s", dent); 128 | 129 | UI::Utilities::RemoveMenuItem(Id_Name); 130 | Menu::Remove_Option(Id_Name); 131 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Daemons.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | bool Start_Daemon(char* TitleId); 3 | bool Stop_Daemon(char* TitleId); 4 | bool Is_Daemon_Running(char* TitleId); 5 | bool Start_Stop_Daemon(char* TitleId, bool Restart = false); 6 | 7 | void Add_Daemon(char* dent); 8 | void Remove_Daemon(char* dent); -------------------------------------------------------------------------------- /Orbis Toolbox/DebugTitleIdLabel.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Debug_Features.h" 3 | 4 | void(*Debug_Feature::DebugTitleIdLabel::CreateDebugTitleIdLabel)(MonoObject* Instance); 5 | Detour* Debug_Feature::DebugTitleIdLabel::Detour_ContentDecoratorBase_Constructor = nullptr; 6 | 7 | Patcher* Debug_Feature::DebugTitleIdLabel::Patch_createDevKitPanel = nullptr; 8 | 9 | bool Debug_Feature::DebugTitleIdLabel::ShowLabels = false; 10 | 11 | uint64_t Debug_Feature::DebugTitleIdLabel::ContentDecoratorBase_Constructor_Hook(MonoObject* Instance, uint64_t param) 12 | { 13 | uint64_t res = Detour_ContentDecoratorBase_Constructor->Stub(Instance, param); 14 | 15 | if (ShowLabels) 16 | CreateDebugTitleIdLabel(Instance); 17 | 18 | return res; 19 | } 20 | 21 | void Debug_Feature::DebugTitleIdLabel::AddTitleId(MonoObject* m_contentsGridList) 22 | { 23 | MonoClass* ReadOnlyCollection = Mono::Get_Class(Mono::mscorlib, "System.Collections.ObjectModel", "ReadOnlyCollection`1"); 24 | 25 | if (m_contentsGridList) 26 | { 27 | MonoObject* ActiveItems = Mono::Get_Property(Mono::UI_dll, Mono::PUI_UI2, "ListPanelBase", m_contentsGridList, "ActiveItems"); 28 | 29 | for (int i = 0; i < Mono::Get_Property(ReadOnlyCollection, ActiveItems, "Count"); i++) 30 | { 31 | MonoObject* Member = Mono::Invoke(Mono::mscorlib, ReadOnlyCollection, ActiveItems, "get_Item", i); 32 | MonoObject* ListVisualizer = Mono::Get_Property(Mono::Vsh_Lx, "Sce.Vsh.Lx", "ListItem", Member, "ListVisualizer"); 33 | MonoObject* m_decorator = Mono::Get_Field(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentVisualizer", ListVisualizer, "m_decorator"); 34 | CreateDebugTitleIdLabel(m_decorator); 35 | } 36 | } 37 | } 38 | 39 | void Debug_Feature::DebugTitleIdLabel::RemoveTitleId(MonoObject* m_contentsGridList) 40 | { 41 | MonoClass* ReadOnlyCollection = Mono::Get_Class(Mono::mscorlib, "System.Collections.ObjectModel", "ReadOnlyCollection`1"); 42 | 43 | if (m_contentsGridList) 44 | { 45 | MonoObject* ActiveItems = Mono::Get_Property(Mono::UI_dll, Mono::PUI_UI2, "ListPanelBase", m_contentsGridList, "ActiveItems"); 46 | 47 | for (int i = 0; i < Mono::Get_Property(ReadOnlyCollection, ActiveItems, "Count"); i++) 48 | { 49 | MonoObject* Member = Mono::Invoke(Mono::mscorlib, ReadOnlyCollection, ActiveItems, "get_Item", i); 50 | MonoObject* ListVisualizer = Mono::Get_Property(Mono::Vsh_Lx, "Sce.Vsh.Lx", "ListItem", Member, "ListVisualizer"); 51 | MonoObject* m_decorator = Mono::Get_Field(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentVisualizer", ListVisualizer, "m_decorator"); 52 | MonoObject* m_iconImageBox = Mono::Get_Field(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", m_decorator, "m_iconImageBox"); 53 | 54 | if (m_iconImageBox) 55 | { 56 | MonoArray* Children = Mono::Invoke(Mono::App_exe, Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Node`1"), m_iconImageBox, "GetChildrenArray"); 57 | 58 | for (int i = 0; i < mono_array_length(Children); i++) 59 | { 60 | MonoObject* Instance = mono_array_get(Children, MonoObject*, i); 61 | 62 | if (!Instance) 63 | continue; 64 | 65 | if (!Instance->vtable) 66 | continue; 67 | 68 | if (!Instance->vtable->klass) 69 | continue; 70 | 71 | if (strcmp(Instance->vtable->klass->name, "Label")) 72 | continue; 73 | 74 | Mono::Invoke(Mono::App_exe, Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Widget"), Instance, "RemoveFromParent"); 75 | } 76 | } 77 | } 78 | } 79 | } 80 | 81 | void Debug_Feature::DebugTitleIdLabel::Update() 82 | { 83 | Debug_Feature::DebugTitleIdLabel::ShowLabels ? Show() : Hide(); 84 | } 85 | 86 | void Debug_Feature::DebugTitleIdLabel::Show() 87 | { 88 | MonoClass* ContentsAreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentsAreaManager"); 89 | MonoObject* m_scene = Mono::Get_Field(ContentsAreaManager, Mono::Get_Instance(ContentsAreaManager, "Instance"), "m_scene"); 90 | MonoArray* m_contentsGridList = Mono::Get_Field(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentAreaScene", m_scene, "m_contentsGridList"); 91 | 92 | AddTitleId(mono_array_get(m_contentsGridList, MonoObject*, 0)); 93 | AddTitleId(mono_array_get(m_contentsGridList, MonoObject*, 1)); 94 | 95 | ShowLabels = true; 96 | } 97 | 98 | void Debug_Feature::DebugTitleIdLabel::Hide() 99 | { 100 | MonoClass* ContentsAreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentsAreaManager"); 101 | MonoObject* m_scene = Mono::Get_Field(ContentsAreaManager, Mono::Get_Instance(ContentsAreaManager, "Instance"), "m_scene"); 102 | MonoArray* m_contentsGridList = Mono::Get_Field(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentAreaScene", m_scene, "m_contentsGridList"); 103 | 104 | RemoveTitleId(mono_array_get(m_contentsGridList, MonoObject*, 0)); 105 | RemoveTitleId(mono_array_get(m_contentsGridList, MonoObject*, 1)); 106 | 107 | ShowLabels = false; 108 | } 109 | 110 | void Debug_Feature::DebugTitleIdLabel::Init() 111 | { 112 | uint64_t CreateDebugTitleIdLabel_addr = Mono::Get_Address_of_Method(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", "CreateDebugTitleIdLabel", 0); 113 | CreateDebugTitleIdLabel = decltype(CreateDebugTitleIdLabel)(CreateDebugTitleIdLabel_addr); 114 | 115 | //Patch RegMgr Check 116 | Patch_createDevKitPanel = new Patcher(); 117 | Patch_createDevKitPanel->Install_Method_Patch(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", "CreateDebugTitleIdLabel", 0, 0x2C, "\x90\x90\x90\x90\x90\x90", 6); 118 | 119 | Detour_ContentDecoratorBase_Constructor = new Detour(); 120 | Detour_ContentDecoratorBase_Constructor->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", ".ctor", 1, (void*)ContentDecoratorBase_Constructor_Hook); 121 | } 122 | 123 | void Debug_Feature::DebugTitleIdLabel::Term() 124 | { 125 | //Clean up Patches 126 | delete Patch_createDevKitPanel; 127 | 128 | //Clean up Detours 129 | delete Detour_ContentDecoratorBase_Constructor; 130 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Debug_Features.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Debug_Feature 4 | { 5 | public: 6 | class Custom_Content 7 | { 8 | private: 9 | static Detour* Detour_ExecuteSelectQuery; 10 | static Detour* Detour_ExecuteCountQuery; 11 | static Detour* Detour_StartDebugSettings; 12 | static Detour* Detour_GetIconPath; 13 | 14 | static MonoObject* ExecuteSelectQuery_Hook(MonoObject* Instance, int offset, int limit); 15 | static int ExecuteCountQuery_Hook(MonoObject* Instance); 16 | static void StartDebugSettings_Hook(MonoObject* Instance); 17 | static MonoString* GetIconPath_Hook(MonoObject* item, bool withTheme); 18 | 19 | public: 20 | static bool Show_App_Home; 21 | static bool Show_Debug_Settings; 22 | 23 | static void Init(); 24 | static void Term(); 25 | }; 26 | 27 | class DebugTitleIdLabel 28 | { 29 | private: 30 | static void(*CreateDebugTitleIdLabel)(MonoObject* Instance); 31 | static Detour* Detour_ContentDecoratorBase_Constructor; 32 | static uint64_t ContentDecoratorBase_Constructor_Hook(MonoObject* Instance, uint64_t param); 33 | 34 | static Patcher* Patch_createDevKitPanel; 35 | 36 | static void AddTitleId(MonoObject* m_contentsGridList); 37 | static void RemoveTitleId(MonoObject* m_contentsGridList); 38 | 39 | public: 40 | static bool ShowLabels; 41 | 42 | static void Update(); 43 | static void Show(); 44 | static void Hide(); 45 | static void Init(); 46 | static void Term(); 47 | }; 48 | 49 | class DevkitPanel 50 | { 51 | private: 52 | static void(*createDevKitPanel)(MonoObject* Instance); 53 | static Detour* Detour_AreaManager_Constructor; 54 | static uint64_t AreaManager_Constructor_Hook(MonoObject* Instance); 55 | 56 | public: 57 | static bool ShowPanel; 58 | 59 | static void Update(); 60 | static void Show(); 61 | static void Hide(); 62 | static bool GetState(); 63 | static void Init(); 64 | static void Term(); 65 | }; 66 | 67 | private: 68 | 69 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/Detour.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Detour.h" 3 | #include "Mono.h" 4 | #include "hde64.h" 5 | 6 | void Detour::WriteJump(void* Address, void* Destination) 7 | { 8 | uint8_t JumpInstructions[] = { 9 | 0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // jmp QWORD PTR[Address] 10 | }; 11 | 12 | //Write the address of our hook to the instruction. 13 | *(uint64_t*)(JumpInstructions + 6) = (uint64_t)Destination; 14 | 15 | sceKernelMprotect((void*)Address, sizeof(JumpInstructions), VM_PROT_ALL); 16 | memcpy(Address, JumpInstructions, sizeof(JumpInstructions)); 17 | } 18 | 19 | void* Detour::DetourFunction(uint64_t FunctionPtr, void* HookPtr) 20 | { 21 | if (FunctionPtr == NULL || HookPtr == NULL) 22 | { 23 | klog("[Detour] DetourFunction: FunctionPtr or HookPtr NULL (%llX -> %llX)\n", FunctionPtr, HookPtr); 24 | return (void*)0; 25 | } 26 | uint32_t InstructionSize = 0; 27 | 28 | while (InstructionSize < 14) 29 | { 30 | hde64s hs; 31 | uint32_t temp = hde64_disasm((void*)(FunctionPtr + InstructionSize), &hs); 32 | 33 | if (hs.flags & F_ERROR) 34 | return (void*)0; 35 | 36 | InstructionSize += temp; 37 | } 38 | 39 | klog("InstructionSize: %i\n", InstructionSize); 40 | 41 | if (InstructionSize < 14) 42 | { 43 | klog("[Detour] DetourFunction: Hooking Requires a minimum of 14 bytes to write jump!\n"); 44 | return (void*)0; 45 | } 46 | 47 | //Save Pointers for later 48 | this->FunctionPtr = (void*)FunctionPtr; 49 | this->HookPtr = HookPtr; 50 | 51 | //Set protection. 52 | sceKernelMprotect((void*)FunctionPtr, InstructionSize, VM_PROT_ALL); 53 | 54 | //Allocate Executable memory for stub and write instructions to stub and a jump back to original execution. 55 | this->StubSize = (InstructionSize + 14); 56 | int res = sceKernelMmap(0, this->StubSize, VM_PROT_ALL, 0x1000 | 0x2, -1, 0, &this->StubPtr); 57 | if (res < 0 || this->StubPtr == 0) 58 | { 59 | klog("[Detour] sceKernelMmap Failed: 0x%llX\n", res); 60 | return 0; 61 | } 62 | 63 | memcpy(StubPtr, (void*)FunctionPtr, InstructionSize); 64 | WriteJump((void*)((uint64_t)StubPtr + InstructionSize), (void*)(FunctionPtr + InstructionSize)); 65 | 66 | //Write jump from function to hook. 67 | WriteJump((void*)FunctionPtr, HookPtr); 68 | 69 | klog("[Detour] DetourFunction: Detour (%llX -> %llX) Written Successfully!\n", FunctionPtr, this->HookPtr); 70 | 71 | return this->StubPtr; 72 | } 73 | 74 | void* Detour::DetourMethod(MonoImage* Assembly_Image, const char* Namespace, const char* Klass, const char* Method, int Param_Count, void* HookPtr) 75 | { 76 | uint64_t Method_addr = Mono::Get_Address_of_Method(Assembly_Image, Namespace, Klass, Method, Param_Count); 77 | 78 | if (Method_addr == NULL) 79 | { 80 | klog("[Detour] DetourMethod: Method address returned null!\n"); 81 | return (void*)0; 82 | } 83 | 84 | return DetourFunction(Method_addr, HookPtr); 85 | } 86 | 87 | void Detour::RestoreFunction() 88 | { 89 | if (this->StubPtr) 90 | { 91 | sceKernelMprotect((void*)this->FunctionPtr, this->StubSize - 14, VM_PROT_ALL); 92 | memcpy((void*)this->FunctionPtr, this->StubPtr, this->StubSize - 14); 93 | 94 | klog("[Detour] RestoreFunction: (%llX) has been Restored Successfully!\n", this->FunctionPtr); 95 | } 96 | } 97 | 98 | Detour::Detour() 99 | { 100 | 101 | } 102 | 103 | Detour::~Detour() 104 | { 105 | RestoreFunction(); 106 | 107 | //Clean up 108 | sceKernelMunmap(this->StubPtr, this->StubSize); 109 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Detour.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Detour 4 | { 5 | private: 6 | 7 | void* StubPtr = 0; 8 | size_t StubSize = 0; 9 | 10 | void* FunctionPtr = 0; 11 | void* HookPtr = 0; 12 | 13 | public: 14 | template 15 | result Stub(Args... args) 16 | { 17 | result(*Stub_internal)(Args... args) = decltype(Stub_internal)(StubPtr); 18 | return Stub_internal(args...); 19 | } 20 | 21 | void WriteJump(void* Address, void* Destination); 22 | void* DetourFunction(uint64_t FunctionPtr, void* HookPtr); 23 | void* DetourMethod(MonoImage* Assembly_Image, const char* Namespace, const char* Klass, const char* Method, int Param_Count, void* HookPtr); 24 | void RestoreFunction(); 25 | 26 | Detour(); 27 | ~Detour(); 28 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/DevkitPanel.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Debug_Features.h" 3 | 4 | void(*Debug_Feature::DevkitPanel::createDevKitPanel)(MonoObject* Instance) = nullptr; 5 | Detour* Debug_Feature::DevkitPanel::Detour_AreaManager_Constructor = nullptr; 6 | 7 | bool Debug_Feature::DevkitPanel::ShowPanel = false; 8 | 9 | uint64_t Debug_Feature::DevkitPanel::AreaManager_Constructor_Hook(MonoObject* Instance) 10 | { 11 | uint64_t res = Detour_AreaManager_Constructor->Stub(Instance); 12 | 13 | if (ShowPanel) 14 | createDevKitPanel(Instance); 15 | 16 | return res; 17 | } 18 | 19 | void Debug_Feature::DevkitPanel::Update() 20 | { 21 | Debug_Feature::DevkitPanel::ShowPanel ? Show() : Hide(); 22 | } 23 | 24 | void Debug_Feature::DevkitPanel::Show() 25 | { 26 | MonoClass* AreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager"); 27 | MonoObject* AreaManager_Instance = Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance"); 28 | MonoObject* m_devKitPanel = Mono::Get_Field(AreaManager, AreaManager_Instance, "m_devKitPanel"); 29 | MonoClass* Widget = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Widget"); 30 | 31 | // AreaManager.Instance.m_devKitPanel 32 | // If m_devKitPanel is null we must create the panel first. 33 | if (!m_devKitPanel) 34 | { 35 | createDevKitPanel(Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance")); 36 | } 37 | else 38 | { 39 | MonoClass* UITimer = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UITimer"); 40 | MonoObject* m_updatePanelTimer = Mono::Get_Field(AreaManager, AreaManager_Instance, "m_updatePanelTimer"); 41 | 42 | // AreaManager.Instance.m_updatePanelTimer.Start() 43 | // If the m_updatePanelTimer is initialized start the timer. 44 | if (m_updatePanelTimer) 45 | Mono::Invoke(Mono::UI_dll, UITimer, m_updatePanelTimer, "Start"); 46 | 47 | // AreaManager.Instance.m_devKitPanel.Show() 48 | // Show the panel. 49 | MonoClass* UINode = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UINode"); 50 | Mono::Invoke(Mono::UI_dll, UINode, m_devKitPanel, "Show"); 51 | } 52 | 53 | ShowPanel = true; 54 | } 55 | 56 | void Debug_Feature::DevkitPanel::Hide() 57 | { 58 | MonoClass* AreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager"); 59 | MonoObject* AreaManager_Instance = Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance"); 60 | 61 | MonoClass* UITimer = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UITimer"); 62 | MonoObject* m_updatePanelTimer = Mono::Get_Field(AreaManager, AreaManager_Instance, "m_updatePanelTimer"); 63 | 64 | // AreaManager.Instance.m_updatePanelTimer.Stop() 65 | // If the m_updatePanelTimer is initialized stop the timer. 66 | if (m_updatePanelTimer) 67 | Mono::Invoke(Mono::UI_dll, UITimer, m_updatePanelTimer, "Stop"); 68 | 69 | // AreaManager.Instance.m_devKitPanel.Hide() 70 | // Hide the panel. 71 | MonoObject* m_devKitPanel = Mono::Get_Field(AreaManager, AreaManager_Instance, "m_devKitPanel"); 72 | if (m_devKitPanel) 73 | { 74 | MonoClass* UINode = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UINode"); 75 | Mono::Invoke(Mono::UI_dll, UINode, m_devKitPanel, "Hide"); 76 | } 77 | 78 | ShowPanel = false; 79 | } 80 | 81 | bool Debug_Feature::DevkitPanel::GetState() 82 | { 83 | MonoClass* FrameTask = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "FrameTask"); 84 | MonoClass* AreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager"); 85 | MonoObject* AreaManager_Instance = Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance"); 86 | MonoObject* m_devKitPanel = Mono::Get_Field(AreaManager, AreaManager_Instance, "m_devKitPanel"); 87 | MonoObject* m_updatePanelTimer = Mono::Get_Field(AreaManager, AreaManager_Instance, "m_updatePanelTimer"); 88 | 89 | if (m_devKitPanel && m_updatePanelTimer) 90 | return !Mono::Get_Property(FrameTask, m_updatePanelTimer, "IsStopped"); 91 | else 92 | return false; 93 | } 94 | 95 | void Debug_Feature::DevkitPanel::Init() 96 | { 97 | //Get Method to make devkit panel 98 | uint64_t createDevKitPanel_addr = Mono::Get_Address_of_Method(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "createDevKitPanel", 0); 99 | createDevKitPanel = decltype(createDevKitPanel)(createDevKitPanel_addr); 100 | 101 | //Hook AreaManager Constructor 102 | Detour_AreaManager_Constructor = new Detour(); 103 | Detour_AreaManager_Constructor->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", ".ctor", 0, (void*)AreaManager_Constructor_Hook); 104 | } 105 | 106 | void Debug_Feature::DevkitPanel::Term() 107 | { 108 | delete Detour_AreaManager_Constructor; 109 | } 110 | -------------------------------------------------------------------------------- /Orbis Toolbox/Embed.s: -------------------------------------------------------------------------------- 1 | .section .rodata 2 | .global settings_root 3 | .type settings_root, @object 4 | .align 4 5 | .global orbis_toolbox 6 | .type orbis_toolbox, @object 7 | .align 4 8 | .global external_hdd 9 | .type external_hdd, @object 10 | .align 4 11 | 12 | settings_root: 13 | .incbin "settings_root.xml" 14 | settings_root_End: 15 | .global settings_root_Size 16 | .type settings_root_Size, @object 17 | .align 4 18 | settings_root_Size: 19 | .int settings_root_End - settings_root 20 | 21 | orbis_toolbox: 22 | .incbin "orbis_toolbox.xml" 23 | orbis_toolbox_End: 24 | .global orbis_toolbox_Size 25 | .type orbis_toolbox_Size, @object 26 | .align 4 27 | orbis_toolbox_Size: 28 | .int orbis_toolbox_End - orbis_toolbox 29 | 30 | external_hdd: 31 | .incbin "external_hdd.xml" 32 | external_hdd_End: 33 | .global external_hdd_Size 34 | .type external_hdd_Size, @object 35 | .align 4 36 | external_hdd_Size: 37 | .int external_hdd_End - external_hdd -------------------------------------------------------------------------------- /Orbis Toolbox/GamePad.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "GamePad.h" 3 | 4 | bool GamePad::IsDown(int button) 5 | { 6 | return Mono::Invoke(Mono::App_exe, Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.DebugSystem", "KeyMonitorTask"), NULL, "IsButtonDown", button); 7 | } -------------------------------------------------------------------------------- /Orbis Toolbox/GamePad.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class GamePad 4 | { 5 | private: 6 | 7 | public: 8 | enum Buttons 9 | { 10 | Left = 1U, 11 | Up, 12 | Right = 4U, 13 | Down = 8U, 14 | Square = 16U, 15 | Triangle = 32U, 16 | Circle = 64U, 17 | Cross = 128U, 18 | Start = 256U, 19 | Select = 512U, 20 | L = 1024U, 21 | R = 2048U, 22 | L2 = 4096U, 23 | R2 = 8192U, 24 | L3 = 16384U, 25 | R3 = 32768U, 26 | Enter = 65536U, 27 | Back = 131072U 28 | }; 29 | 30 | static bool IsDown(int button); 31 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/Game_Overlay.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Widget.h" 3 | #include "Common.h" 4 | 5 | #define CALL_BACK_TYPE bool(*)(Label*) 6 | #define CALL_BACK_TYPE_D bool(*CallBack)(Label*) 7 | 8 | class Game_Overlay 9 | { 10 | public: 11 | static bool Show_CPU_Usage; 12 | static bool Show_Thread_Count; 13 | static bool Show_ram; 14 | static bool Show_vram; 15 | static bool Show_CPU_Temp; 16 | static bool Show_SOC_Temp; 17 | static char Location[0x100]; 18 | 19 | static void Update_Location(); 20 | static void OnRender(); 21 | 22 | static void Update(); 23 | static void Init(); 24 | static void Term(); 25 | 26 | private: 27 | static float X, Y; 28 | static float Text_Height; 29 | static Widget* Game_Widget; 30 | 31 | static std::map* Updater; 32 | static bool Shutdown; 33 | 34 | static void Update_Label(int* Location, const char* Name); 35 | static void Init_Overlay(const char* Name, CALL_BACK_TYPE_D); 36 | }; 37 | -------------------------------------------------------------------------------- /Orbis Toolbox/Increment.bat: -------------------------------------------------------------------------------- 1 | echo off 2 | REM you need this to set and read a variable inside 3 | REM a parethetical structure such as a FOR loop 4 | setlocal enabledelayedexpansion 5 | 6 | REM This is the file we are going to alter 7 | set filepath=%1 8 | set filename=%~n1%~x1 9 | 10 | REM Use temp file 11 | REM delete if already exists 12 | REM so we can use append operator for all output 13 | if exist "%filepath%.temp" del "%filepath%.temp" 14 | 15 | REM For each line in the file... 16 | REM ...using FOR alone to parse the file skips blank lines so we... 17 | REM ...parse the output (note single quotes) of... 18 | REM running TYPE on the file and piping the output through FINDSTR... 19 | REM ...with the /n switch (this adds a line number and a colon at the start of each line) 20 | REM the FINDSTR search string is ".*" (find any characters including cr/lf) 21 | REM Split into 2* tokens, the asterisk means %%R is the entire remainder of the line 22 | REM delimiter being the colon thus... 23 | REM The number is token 1, %%Q (discarded, along with the colon) 24 | REM The original source file line is token 2, %%R 25 | REM note we escape the pipe character with a caret ^ in the FOR dataset block 26 | for /f "tokens=1,2* delims=:" %%Q in ('type "%filepath%" ^| findstr /n ".*"') do ( 27 | 28 | REM if token 2 is null then the line is blank so we echo a blank line to the temp output file 29 | if "%%R"=="" echo. >> "%filepath%.temp" 30 | 31 | REM This flag gets set to 1 if we have a line that needs changing 32 | set incflag=0 33 | 34 | REM Split the line into 3 tokens with white space the delimiter 35 | for /f "tokens=1-3 delims= " %%A in ("%%R") do ( 36 | 37 | REM test if an increment needs to happen and set the flag if it does 38 | if "%%B"==%2 set incflag=1 39 | REM %%C is the number 40 | 41 | REM If the line contains a number to increment... 42 | if !incflag! equ 1 ( 43 | REM do it... 44 | set /a num=%%C+1 45 | 46 | REM info msg to console 47 | echo Incrementing %%B from %%C to !num! 48 | 49 | REM write the altered line to file 50 | echo %%A %%B !num! >>"%filepath%.temp" 51 | 52 | REM the line is a nonblank one that simply needs copying 53 | ) else ( 54 | 55 | echo %%R >> "%filepath%.temp" 56 | 57 | REM Match those parentheses! 58 | ) 59 | ) 60 | ) 61 | 62 | REM delete original file 63 | del "%filepath%" 64 | 65 | REM rename temp file to original file name 66 | ren "%filepath%.temp" "%filename%" -------------------------------------------------------------------------------- /Orbis Toolbox/Label.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "UI.h" 3 | #include "Widget.h" 4 | #include "Label.h" 5 | 6 | void Label::Set_Location(float X, float Y) 7 | { 8 | this->X = X; this->Y = Y; 9 | 10 | if (hAlign == HorizontalAlignment::hRight) 11 | X -= Get_Text_Width(); 12 | else if (hAlign == HorizontalAlignment::hCenter) 13 | X -= (Get_Text_Width() / 2.0f); 14 | 15 | Mono::Set_Property(Label_Class, Instance, "X", X); 16 | Mono::Set_Property(Label_Class, Instance, "Y", Y); 17 | } 18 | 19 | void Label::Set_Font(int Size, FontStyle Style, FontWeight Weight) 20 | { 21 | Mono::Set_Property_Invoke(Label_Class, Instance, "Font", UI::Utilities::IUFont(Size, Style, Weight)); 22 | } 23 | 24 | void Label::Set_Alignment(VerticalAlignment Vertical_Align, HorizontalAlignment Horizontal_Align) 25 | { 26 | vAlign = Vertical_Align; 27 | hAlign = Horizontal_Align; 28 | Set_Location(X, Y); 29 | 30 | Mono::Set_Property(Label_Class, Instance, "VerticalAlignment", Vertical_Align); 31 | Mono::Set_Property(Label_Class, Instance, "HorizontalAlignment", Horizontal_Align); 32 | } 33 | 34 | void Label::Set_Colour(float R, float G, float B, float A) 35 | { 36 | if (this->R == R && this->G == G && this->B == B && this->A == A) 37 | return; 38 | 39 | this->R = R; this->G = G; this->B = B; this->A = A; 40 | Mono::Set_Property_Invoke(Label_Class, Instance, "TextColor", UI::Utilities::UIColor(R, G, B, A)); 41 | } 42 | 43 | float Label::Get_Text_Width() 44 | { 45 | return Mono::Invoke(Mono::App_exe, Label_Class, Instance, "GetTextWidth"); 46 | } 47 | 48 | float Label::Get_Text_Height() 49 | { 50 | return Mono::Invoke(Mono::App_exe, Label_Class, Instance, "GetTextHeight"); 51 | } 52 | 53 | Label::Label(const char* Name) 54 | { 55 | Label_Class = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Label"); 56 | 57 | //Allocates memory for our new instance of a class. 58 | Instance = Mono::New_Object(Label_Class); 59 | 60 | //Call Constructor. 61 | mono_runtime_object_init(Instance); 62 | 63 | //Set Panel Name 64 | Mono::Set_Property(Label_Class, Instance, "Name", Mono::New_String(Name)); 65 | } 66 | 67 | MonoObject* NewTextShadowSettings(float R, float G, float B) 68 | { 69 | MonoClass* TextShadowSettings = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "TextShadowSettings"); 70 | 71 | MonoObject* TextShadow_Instance = Mono::New_Object(TextShadowSettings); 72 | mono_runtime_object_init(TextShadow_Instance); 73 | Mono::Set_Property_Invoke(TextShadowSettings, TextShadow_Instance, "Color", UI::Utilities::UIColor(R, G, B)); 74 | 75 | return TextShadow_Instance; 76 | } 77 | 78 | Label::Label(const char* Name, float X, float Y, const char* Text, int Size, FontStyle Style, FontWeight Weight, VerticalAlignment Vertical_Align, HorizontalAlignment Horizontal_Align, float R, float G, float B, float A) 79 | { 80 | Label_Class = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Label"); 81 | //TODO: Add checks to see if it got the class. 82 | 83 | //Allocates memory for our new instance of a class. 84 | Instance = Mono::New_Object(Label_Class); 85 | 86 | //Call Constructor. 87 | mono_runtime_object_init(Instance); 88 | 89 | //Set Panel Name 90 | Mono::Set_Property(Label_Class, Instance, "Name", Mono::New_String(Name)); 91 | 92 | //Set Values 93 | Set_Location(X, Y); 94 | Set_Text(Text); 95 | Set_Font(Size, Style, Weight); 96 | Set_Alignment(Vertical_Align, Horizontal_Align); 97 | Set_Colour(R, G, B, A); 98 | Mono::Set_Property(Label_Class, Instance, "FitWidthToText", true); 99 | Mono::Set_Property(Label_Class, Instance, "FitHeightToText", true); 100 | 101 | Mono::Set_Property(Label_Class, Instance, "TextShadow", NewTextShadowSettings(0.0f, 0.0f, 0.0f)); 102 | } 103 | 104 | Label::~Label() 105 | { 106 | 107 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Label.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Label : public Widget 4 | { 5 | public: 6 | enum VerticalAlignment 7 | { 8 | vTop, 9 | vBottom, 10 | vCenter 11 | }; 12 | 13 | enum HorizontalAlignment 14 | { 15 | hLeft, 16 | hCenter, 17 | hRight 18 | }; 19 | 20 | enum FontStyle 21 | { 22 | fsNormal, 23 | fsItalic = 2U 24 | }; 25 | 26 | enum FontWeight 27 | { 28 | fwNormal, //Obsolete: This value is not used for Orbis. Use 'Light' or 'Medium'. 29 | fwBold, //Obsolete: Use 'Medium' instead of Bold. 30 | fwLight, 31 | fwMedium, 32 | fwLegacyBold = 1000U //Obsolete: This value is for GLS. Use 'Medium' instead of LegacyBold. 33 | }; 34 | 35 | void Set_Location(float X, float Y); 36 | template 37 | void Set_Text(const char* Text, pack... Args) 38 | { 39 | Mono::Set_Property(Label_Class, Instance, "Text", Mono::New_String(Text, Args...)); 40 | Set_Location(X, Y); 41 | } 42 | void Set_Font(int Size, FontStyle Style, FontWeight Weight); 43 | void Set_Alignment(VerticalAlignment Vertical_Align, HorizontalAlignment Horizontal_Align); 44 | void Set_Colour(float R, float G, float B, float A); 45 | 46 | float X, Y; 47 | VerticalAlignment vAlign; 48 | HorizontalAlignment hAlign; 49 | float R, G, B, A; 50 | float Get_Text_Width(); 51 | float Get_Text_Height(); 52 | 53 | Label(const char* Name); 54 | Label(const char* Name, float X, float Y, const char* Text, int Size, FontStyle Style, FontWeight Weight, VerticalAlignment Vertical_Align, HorizontalAlignment Horizontal_Align, float R, float G, float B, float A); 55 | ~Label(); 56 | 57 | private: 58 | MonoClass* Label_Class; 59 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/LncUtil.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "LncUtil.h" 3 | 4 | int LncUtil::GetAppStatus(AppStatus* Status) 5 | { 6 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 7 | MonoClass* AppStatus = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil/AppStatus"); 8 | 9 | MonoObject* AppStatus_Instance = Mono::New_Object(AppStatus); 10 | if (AppStatus_Instance) 11 | { 12 | Mono::Invoke(Mono::platform_dll, AppStatus, (MonoObject*)mono_object_unbox(AppStatus_Instance), ".ctor", Status->appId, Status->launchRequestAppId, Status->appType); 13 | 14 | int res = Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "GetAppStatus", mono_object_unbox(AppStatus_Instance)); 15 | 16 | memcpy(Status, (void*)mono_object_unbox(AppStatus_Instance), sizeof(AppStatus)); 17 | 18 | return res; 19 | } 20 | 21 | return 0; 22 | } 23 | 24 | //int SuspendApp(int appId, Flag flag = Flag_None); 25 | //int ResumeApp(int appId, Flag flag = Flag_None); 26 | 27 | //static int SetControllerFocus(int appId); 28 | //static int SetAppFocus(int appId, Flag flag = Flag_None); 29 | 30 | int LncUtil::GetAppId(const char* titleId) 31 | { 32 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 33 | return Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "GetAppId", Mono::New_String(titleId)); 34 | } 35 | 36 | int LncUtil::LaunchApp(const char* titleId, char* args, int argsSize, LaunchAppParam* param) 37 | { 38 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 39 | 40 | // 41 | // Init Launch Param 42 | // 43 | MonoClass* LaunchAppParam_class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil/LaunchAppParam"); 44 | 45 | MonoObject* LaunchAppParam_Instance = Mono::New_Object(LaunchAppParam_class); 46 | MonoObject* LaunchAppParam_Instance_real = (MonoObject*)mono_object_unbox(LaunchAppParam_Instance); 47 | 48 | Mono::Set_Field(LaunchAppParam_Instance, "size", param->size); 49 | Mono::Set_Field(LaunchAppParam_Instance, "userId", param->userId); 50 | Mono::Set_Field(LaunchAppParam_Instance, "appAttr", param->appAttr); 51 | Mono::Set_Field(LaunchAppParam_Instance, "enableCrashReport", param->enableCrashReport); 52 | Mono::Set_Field(LaunchAppParam_Instance, "checkFlag", param->checkFlag); 53 | 54 | //LaunchAppParam* p = (LaunchAppParam*)mono_object_unbox(LaunchAppParam_Instance); 55 | //memcpy(p, param, sizeof(LaunchAppParam)); 56 | 57 | // 58 | // Init Byte Class. 59 | // 60 | MonoArray* Array = Mono::New_Array(mono_get_byte_class(), argsSize); 61 | char* Array_addr = mono_array_addr_with_size(Array, sizeof(char), 0); 62 | 63 | if(args && argsSize > 0) 64 | memcpy(Array_addr, args, argsSize); 65 | 66 | klog("Calling Launch...\n"); 67 | 68 | return Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "LaunchApp", Mono::New_String(titleId), Array, argsSize, LaunchAppParam_Instance_real); 69 | } 70 | 71 | int LncUtil::KillApp(int appId, int userId) 72 | { 73 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 74 | return Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "KillApp", appId, userId, 0, 0); 75 | } 76 | 77 | //static int ForceKillApp(int appId, int userId = -1); 78 | //static int KillLocalProcess(int appId, int appLocalPid); 79 | 80 | void LncUtil::SystemShutdown(Boot flag) 81 | { 82 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 83 | Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "SystemShutdown", flag); 84 | } 85 | 86 | void LncUtil::SystemReboot() 87 | { 88 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 89 | Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "SystemReboot"); 90 | } 91 | 92 | void LncUtil::SystemSuspend() 93 | { 94 | MonoClass* LncUtil_Class = Mono::Get_Class(Mono::platform_dll, "Sce.Vsh.ShellUI.Lnc", "LncUtil"); 95 | Mono::Invoke(Mono::platform_dll, LncUtil_Class, nullptr, "SystemSuspend"); 96 | } 97 | 98 | -------------------------------------------------------------------------------- /Orbis Toolbox/LncUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class LncUtil 4 | { 5 | public: 6 | enum Boot 7 | { 8 | None = 0, 9 | Eap = 1 10 | }; 11 | 12 | enum Flag : unsigned long 13 | { 14 | Flag_None = 0UL, 15 | SkipLaunchCheck = 1UL, 16 | SkipResumeCheck = 1UL, 17 | SkipSystemUpdateCheck = 2UL, 18 | RebootPatchInstall = 4UL, 19 | VRMode = 8UL, 20 | NonVRMode = 16UL 21 | }; 22 | 23 | struct LaunchAppParam 24 | { 25 | unsigned int size; 26 | int userId; 27 | int appAttr; 28 | int enableCrashReport; 29 | Flag checkFlag; 30 | }; 31 | 32 | enum AppType 33 | { 34 | Invalid = -1, 35 | Unknown, 36 | ShellUI, 37 | Daemon, 38 | CDLG, 39 | MiniApp, 40 | BigApp, 41 | ShellCore, 42 | ShellApp 43 | }; 44 | 45 | struct AppStatus 46 | { 47 | int appId; 48 | int launchRequestAppId; 49 | char appType; 50 | }; 51 | 52 | static int GetAppStatus(AppStatus* Status); 53 | static int SuspendApp(int appId, Flag flag = Flag_None); 54 | static int ResumeApp(int appId, Flag flag = Flag_None); 55 | 56 | static int SetControllerFocus(int appId); 57 | static int SetAppFocus(int appId, Flag flag = Flag_None); 58 | 59 | static int GetAppId(const char* titleId); 60 | static int LaunchApp(const char* titleId, char* args, int argsSize, LaunchAppParam* param); 61 | static int KillApp(int appId, int userId = -1); 62 | static int ForceKillApp(int appId, int userId = -1); 63 | static int KillLocalProcess(int appId, int appLocalPid); 64 | 65 | static void SystemShutdown(Boot flag); 66 | static void SystemReboot(); 67 | static void SystemSuspend(); 68 | 69 | private: 70 | 71 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/Menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Common.h" 3 | 4 | enum Data_Type 5 | { 6 | Type_None, 7 | Type_Boolean, 8 | Type_Integer, 9 | Type_Float, 10 | Type_String, 11 | }; 12 | 13 | class MenuOption 14 | { 15 | public: 16 | char Id[0x100]; 17 | Data_Type Type; 18 | uint64_t* Data; 19 | bool Visible; 20 | std::function OnPreCreate; 21 | std::function OnPageActivating; 22 | std::function OnPress; 23 | 24 | MenuOption() { } 25 | ~MenuOption() { } 26 | 27 | private: 28 | 29 | }; 30 | 31 | struct CompareFirst { 32 | template 33 | bool operator()(T const& t, U const& u) const { return !strcmp(t.first, u.first); } 34 | }; 35 | 36 | class Menu 37 | { 38 | public: 39 | template 40 | static MenuOption* Add_Option(const char* Option_Id, Value* Data, Data_Type Type, std::function OnPress = nullptr, std::function OnPreCreate = nullptr, std::function OnPageActivating = nullptr) 41 | { 42 | //klog("Add_Option(): %s\n", Option_Id); 43 | MenuOption* Temp = new MenuOption(); 44 | strcpy(Temp->Id, Option_Id); 45 | Temp->Data = (uint64_t*)Data; 46 | Temp->Type = Type; 47 | Temp->Visible = true; 48 | Temp->OnPreCreate = OnPreCreate; 49 | Temp->OnPageActivating = OnPageActivating; 50 | Temp->OnPress = OnPress; 51 | 52 | Options->insert(std::pair(Temp->Id, Temp)); 53 | 54 | return Temp; 55 | } 56 | 57 | static MenuOption* Add_Option(const char* Option_Id, std::function OnPress = nullptr, std::function OnPreCreate = nullptr, std::function OnPageActivating = nullptr) 58 | { 59 | //klog("Add_Option(): %s\n", Option_Id); 60 | MenuOption* Temp = new MenuOption(); 61 | strcpy(Temp->Id, Option_Id); 62 | Temp->Type = Type_None; 63 | Temp->Visible = true; 64 | Temp->OnPreCreate = OnPreCreate; 65 | Temp->OnPageActivating = OnPageActivating; 66 | Temp->OnPress = OnPress; 67 | 68 | Options->insert(std::pair(Temp->Id, Temp)); 69 | 70 | return Temp; 71 | } 72 | 73 | static bool Has_Option(char* Option_Id) 74 | { 75 | return std::find_if(Options->begin(), Options->end(), [Option_Id](auto a1) -> bool { return !strcmp(a1.first, Option_Id); }) != Options->end(); 76 | } 77 | 78 | static MenuOption* Get_Option(char* Option_Id) 79 | { 80 | std::map::iterator it = std::find_if(Options->begin(), Options->end(), [Option_Id](auto a1) -> bool { return !strcmp(a1.first, Option_Id); }); 81 | if (it != Options->end()) 82 | return it->second; 83 | else 84 | { 85 | klog("[Menu] Get_Option(): Option \"%s\" Does not exist.\n", Option_Id); 86 | return nullptr; 87 | } 88 | } 89 | 90 | static void Remove_Option(char* Option_Id) 91 | { 92 | std::map::iterator it = std::find_if(Options->begin(), Options->end(), [Option_Id](auto a1) -> bool { return !strcmp(a1.first, Option_Id); }); 93 | if (it != Options->end()) 94 | { 95 | Options->erase(it); 96 | 97 | klog("[Menu] Remove_Option(): Removed Option \"%s\"\n", Option_Id); 98 | } 99 | else 100 | klog("[Menu] Remove_Option(): Option \"%s\" Does not exist.\n", Option_Id); 101 | } 102 | 103 | static std::map* Options; 104 | static bool Auto_Load_Settings; 105 | 106 | static void Init(); 107 | static void Term(); 108 | 109 | private: 110 | 111 | }; 112 | 113 | #define DAEMON_DIR "/system/vsh/app/" 114 | #define PLUGIN_DIR "/user/data/Orbis Toolbox/Plugins" 115 | #define SETTIN_DIR "/user/data/Orbis Toolbox/Settings.cfg" 116 | #define PAYLOAD_DIR "/user/data/Orbis Toolbox/Payloads" 117 | #define PAYLOAD_DAEMON (char*)"PLDR00000" 118 | -------------------------------------------------------------------------------- /Orbis Toolbox/Orbis Toolbox.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 15.0 15 | {ced79d48-621a-4076-81e8-11f77de1e41b} 16 | Win32Proj 17 | 10.0 18 | 19 | 20 | 21 | Makefile 22 | true 23 | v143 24 | 25 | 26 | Makefile 27 | false 28 | v143 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | WIN32;_DEBUG;$(NMakePreprocessorDefinitions) 44 | 45 | 46 | _DEBUG;$(NMakePreprocessorDefinitions) 47 | call Increment.bat "Version.h" "ORBIS_TOOLBOX_BUILDVERSION" 48 | call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)" 49 | 50 | 51 | del /s /q /f $(IntDir)\*.o 52 | del /s /q /f $(IntDir)\*.elf 53 | del /s /q /f $(IntDir)\*.oelf 54 | $(SolutionDir) 55 | $(OO_PS4_TOOLCHAIN)\include;$(NMakeIncludeSearchPath) 56 | C:\OpenOrbis\PS4Toolchain\include\c++\v1;$(IncludePath) 57 | 58 | 59 | WIN32;NDEBUG;$(NMakePreprocessorDefinitions) 60 | 61 | 62 | NDEBUG;$(NMakePreprocessorDefinitions) 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | Designer 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /Orbis Toolbox/Orbis_Toolbox.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Settings_Menu.h" 3 | #include "System_Monitor.h" 4 | #include "GamePad.h" 5 | 6 | extern "C" 7 | { 8 | int module_start() 9 | { 10 | klog("!! Hello World !!\n"); 11 | 12 | Mono::Init(); 13 | 14 | if (GamePad::IsDown(GamePad::Buttons::Left | GamePad::Buttons::Triangle)) 15 | { 16 | Notify("Orbis Toolbox: Aborting Launch!!"); 17 | return 0; 18 | } 19 | 20 | //Sce.PlayStation.Core.Runtime DiagnosticsNative GetGraphicsMemoryStatistics 21 | //TODO: Get Address and offset take a look in IDA see if it calls imports. 22 | 23 | System_Monitor::Init(); 24 | Settings_Menu::Init(); 25 | //Title_Menu::Init(); 26 | 27 | Notify(ORBIS_TOOLBOX_NOTIFY); 28 | 29 | return 0; 30 | } 31 | 32 | int module_stop() 33 | { 34 | klog("!! BYE !!\n"); 35 | 36 | Settings_Menu::Term(); 37 | System_Monitor::Term(); 38 | //Title_Menu::Term(); 39 | 40 | sceKernelSleep(4); 41 | 42 | return 0; 43 | } 44 | 45 | void _start() 46 | { 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Panel.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "UI.h" 3 | #include "Widget.h" 4 | #include "Panel.h" 5 | 6 | void Panel::Set_Position(float X, float Y) 7 | { 8 | Mono::Set_Property(Panel_Class, Instance, "X", X); 9 | Mono::Set_Property(Panel_Class, Instance, "Y", Y); 10 | } 11 | 12 | void Panel::Set_Size(float Width, float Height) 13 | { 14 | Mono::Set_Property(Panel_Class, Instance, "Width", Width); 15 | Mono::Set_Property(Panel_Class, Instance, "Height", Height); 16 | } 17 | 18 | void Panel::Set_Colour(float R, float G, float B, float A) 19 | { 20 | Mono::Set_Property_Invoke(Panel_Class, Instance, "BackgroundColor", UI::Utilities::UIColor(R, G, B, A)); 21 | } 22 | 23 | void Panel::Set_Rendering_Order(RenderingOrder Order) 24 | { 25 | Mono::Set_Property(Panel_Class, Instance, "RenderingOrder", Order); 26 | } 27 | 28 | void Panel::Set_Layout_Rule(MonoObject* Rule) 29 | { 30 | Mono::Set_Property(Panel_Class, Instance, "LayoutRule", Rule); 31 | } 32 | 33 | Panel::Panel(const char* Name) 34 | { 35 | Panel_Class = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Panel"); 36 | 37 | //Allocates memory for our new instance of a class. 38 | Instance = Mono::New_Object(Panel_Class); 39 | 40 | //Call Constructor. 41 | mono_runtime_object_init(Instance); 42 | 43 | //Set Panel Name 44 | Mono::Set_Property(Panel_Class, Instance, "Name", Mono::New_String(Name)); 45 | } 46 | 47 | Panel::Panel(const char* Name, float X, float Y, float Width, float Height, float R, float G, float B, float A, RenderingOrder Order, MonoObject* Rule) 48 | { 49 | Panel_Class = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Panel"); 50 | 51 | //Allocates memory for our new instance of a class. 52 | Instance = Mono::New_Object(Panel_Class); 53 | 54 | //Call Constructor. 55 | mono_runtime_object_init(Instance); 56 | 57 | //Set Panel Name 58 | Mono::Set_Property(Panel_Class, Instance, "Name", Mono::New_String(Name)); 59 | 60 | //Set Values 61 | Set_Position(X, Y); 62 | Set_Size(Width, Height); 63 | Set_Colour(R, G, B, A); 64 | Set_Rendering_Order(Order); 65 | Set_Layout_Rule(Rule); 66 | } 67 | 68 | Panel::~Panel() 69 | { 70 | 71 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Panel.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Widget.h" 3 | 4 | class Panel : public Widget 5 | { 6 | public: 7 | enum Orientation 8 | { 9 | Horizontal, 10 | Vertical 11 | }; 12 | 13 | enum RenderingOrder 14 | { 15 | First = -1, 16 | DontCare, 17 | Last 18 | }; 19 | 20 | void Set_Position(float X, float Y); 21 | void Set_Size(float Width, float Height); 22 | void Set_Colour(float R, float G, float B, float A); 23 | void Set_Rendering_Order(RenderingOrder Order); 24 | void Set_Layout_Rule(MonoObject* Rule); 25 | 26 | Panel(const char* Name); 27 | Panel(const char* Name, float X, float Y, float W, float H, float R, float G, float B, float A, RenderingOrder Order, MonoObject* Rule); 28 | ~Panel(); 29 | 30 | private: 31 | MonoClass* Panel_Class; 32 | 33 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/Patcher.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Patcher.h" 3 | 4 | void Patcher::Install_Patch(uint64_t Address, const void* Data, size_t Length) 5 | { 6 | //Backup Params. 7 | this->Address = Address; 8 | this->Length = Length; 9 | 10 | //Set protection to all 11 | sceKernelMprotect((void*)Address, Length, VM_PROT_ALL); 12 | 13 | //Backup data. 14 | int res = sceKernelMmap(0, Length, VM_PROT_ALL, 0x1000 | 0x2, -1, 0, &OriginalData); 15 | if (res < 0) 16 | { 17 | klog("[Patcher] sceKernelMmap Failed: 0x%llX\n", res); 18 | return; 19 | } 20 | memcpy(OriginalData, Data, Length); 21 | 22 | //Write Patch. 23 | memcpy((void*)Address, Data, Length); 24 | 25 | klog("[Patcher] Install_Patch: Patch (%llX) Written Successfully!\n", Address); 26 | } 27 | 28 | void Patcher::Install_Method_Patch(MonoImage* Assembly_Image, const char* Namespace, const char* Klass, const char* Method, int Param_Count, size_t Offset, const void* Data, size_t Length) 29 | { 30 | uint64_t Method_Address = Mono::Get_Address_of_Method(Assembly_Image, Namespace, Klass, Method, Param_Count); 31 | 32 | if (Method_Address == NULL) 33 | { 34 | klog("[Patcher] Install_Method_Patch: Method address returned null!\n"); 35 | return; 36 | } 37 | 38 | Install_Patch(Method_Address + Offset, Data, Length); 39 | } 40 | 41 | void Patcher::Restore_Patch() 42 | { 43 | if (this->OriginalData) 44 | { 45 | //Set protection to all 46 | sceKernelMprotect((void*)this->Address, this->Length, VM_PROT_ALL); 47 | 48 | //Write original Data back. 49 | memcpy((void*)this->Address, this->OriginalData, this->Length); 50 | 51 | klog("[Patcher] Restore_Patch: Patch (%llX) Restored Successfully!\n", this->Address); 52 | } 53 | else 54 | klog("[Patcher] Patch not installed.\n"); 55 | } 56 | 57 | Patcher::Patcher() 58 | { 59 | 60 | } 61 | 62 | Patcher::~Patcher() 63 | { 64 | Restore_Patch(); 65 | 66 | //Clean up 67 | sceKernelMunmap(this->OriginalData, this->Length); 68 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Patcher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Patcher 4 | { 5 | public: 6 | void Install_Patch(uint64_t Address, const void* Data, size_t Length); 7 | void Install_Method_Patch(MonoImage* Assembly_Image, const char* Namespace, const char* Klass, const char* Method, int Param_Count, size_t Offset, const void* Data, size_t Length); 8 | void Restore_Patch(); 9 | 10 | Patcher(); 11 | ~Patcher(); 12 | 13 | private: 14 | uint64_t Address; 15 | void* OriginalData; 16 | size_t Length; 17 | }; 18 | -------------------------------------------------------------------------------- /Orbis Toolbox/Settings_Menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Widget.h" 3 | class Widget; 4 | 5 | class Settings_Menu 6 | { 7 | private: 8 | //Detours 9 | static Detour* Detour_GetManifestResourceStream; 10 | static Detour* Detour_OnCheckVisible; 11 | static Detour* Detour_OnPreCreate; 12 | static Detour* Detour_OnPageActivating; 13 | static Detour* Detour_OnPress; 14 | static Detour* Detour_OnRender; 15 | 16 | static uint64_t GetManifestResourceStream_Hook(uint64_t inst, MonoString* FileName); 17 | static void OnCheckVisible_Hook(MonoObject* Instance, MonoObject* element, MonoObject* e); 18 | static void OnPreCreate_Hook(MonoObject* Instance, MonoObject* element, MonoObject* e); 19 | static void OnPageActivating_Hook(MonoObject* Instance, MonoObject* page, MonoObject* e); 20 | static void OnPress_Hook(MonoObject* Instance, MonoObject* element, MonoObject* e); 21 | static void OnRender_Hook(MonoObject* Instance); 22 | 23 | //Patches 24 | static Patcher* Patch_IsDevkit; 25 | static Patcher* Patch_IsDebugMenuEnable; 26 | static Patcher* Patch_AllowDebugMenu; 27 | static Patcher* Patch_MainThreadCheck; 28 | 29 | public: 30 | static void Log(const char* fmt, ...); 31 | static void Init(); 32 | static void Term(); 33 | 34 | }; 35 | -------------------------------------------------------------------------------- /Orbis Toolbox/SysfileUtilWrapper.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "SysfileUtilWrapper.h" 3 | 4 | void Print_Bytes(char* Bytes, size_t len) 5 | { 6 | int Counter = 0; 7 | for (size_t n = 0; n < len; n++) 8 | { 9 | printf("%02X ", Bytes[n]); 10 | 11 | if (Counter >= 20) 12 | { 13 | printf("\n"); 14 | Counter = 0; 15 | } 16 | 17 | Counter++; 18 | } 19 | printf("\n"); 20 | } 21 | 22 | char* SysfileUtilWrapper::GetString(const char* FilePath, const char* Key, unsigned int Size) 23 | { 24 | int fd = sceKernelOpen(FilePath, 0, 0511); 25 | if (!fd) 26 | { 27 | klog("File doesnt exist %s\n", FilePath); 28 | return (char*)""; 29 | } 30 | else 31 | { 32 | MonoClass* SysfileUtilWrapper_Util = Mono::Get_Class(Mono::SysfileUtilWrapper, "Sce.Vsh", "SysfileUtilWrapper/Util"); 33 | 34 | MonoString* str = Mono::Invoke(Mono::SysfileUtilWrapper, SysfileUtilWrapper_Util, nullptr, "GetString", Mono::New_String(FilePath), Mono::New_String(Key), Size); 35 | 36 | if (str) 37 | return mono_string_to_utf8(str); 38 | else 39 | return (char*)""; 40 | } 41 | } 42 | 43 | int SysfileUtilWrapper::GetAttribute(const char* FilePath) 44 | { 45 | MonoClass* SysfileUtilWrapper_Util = Mono::Get_Class(Mono::SysfileUtilWrapper, "Sce.Vsh", "SysfileUtilWrapper/Util"); 46 | 47 | return Mono::Invoke(Mono::SysfileUtilWrapper, SysfileUtilWrapper_Util, nullptr, "GetAttribute", Mono::New_String(FilePath)); 48 | } 49 | 50 | char* SysfileUtilWrapper::GetTitleId(const char* FilePath) 51 | { 52 | return GetString(FilePath, "TITLE_ID", 12U); 53 | } 54 | 55 | char* SysfileUtilWrapper::GetContentId(const char* FilePath) 56 | { 57 | return GetString(FilePath, "CONTENT_ID", 48U); 58 | } 59 | 60 | char* SysfileUtilWrapper::GetTitle(const char* FilePath) 61 | { 62 | return GetString(FilePath, "TITLE", 128U); 63 | } 64 | 65 | char* SysfileUtilWrapper::GetDescription(const char* FilePath) 66 | { 67 | return GetString(FilePath, "PROVIDER", 128U); 68 | } -------------------------------------------------------------------------------- /Orbis Toolbox/SysfileUtilWrapper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SysfileUtilWrapper 4 | { 5 | public: 6 | static char* GetString(const char* FilePath, const char* Key, unsigned int Size); 7 | 8 | static int GetAttribute(const char* FilePath); 9 | static char* GetTitleId(const char* FilePath); 10 | static char* GetContentId(const char* FilePath); 11 | static char* GetTitle(const char* FilePath); 12 | static char* GetDescription(const char* FilePath); 13 | 14 | private: 15 | 16 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/System_Monitor.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "System_Monitor.h" 3 | #include "Game_Overlay.h" 4 | 5 | int System_Monitor::Thread_Count = 0; 6 | float System_Monitor::Usage[8] = { 0 }; 7 | float System_Monitor::Average_Usage; 8 | int System_Monitor::CPU_Temp; 9 | int System_Monitor::SOC_Temp; 10 | System_Monitor::Memory System_Monitor::RAM; 11 | System_Monitor::Memory System_Monitor::VRAM; 12 | 13 | bool System_Monitor::Should_Run_Thread = true; 14 | Proc_Stats System_Monitor::Stat_Data[3072]; 15 | System_Monitor::thread_usages System_Monitor::gThread_Data[2]; 16 | 17 | void System_Monitor::calc_usage(unsigned int idle_tid[8], thread_usages* cur, thread_usages* prev, float usage_out[8]) 18 | { 19 | if (cur->Thread_Count <= 0 || prev->Thread_Count <= 0) //Make sure our banks have threads 20 | return; 21 | 22 | //Calculate the Current time difference from the last bank to the current bank. 23 | float Current_Time_Total = ((prev->current_time.tv_sec + (prev->current_time.tv_nsec / 1000000000.0f)) - (cur->current_time.tv_sec + (cur->current_time.tv_nsec / 1000000000.0f))); 24 | 25 | //Here this could use to be improved but essetially what its doing is finding the thread information for the idle threads using their thread Index stored from before. 26 | struct Data_s 27 | { 28 | Proc_Stats* Cur; 29 | Proc_Stats* Prev; 30 | }Data[8]; 31 | 32 | for (int i = 0; i < cur->Thread_Count; i++) 33 | { 34 | for (int j = 0; j < 8; j++) 35 | { 36 | if (idle_tid[j] == cur->Threads[i].td_tid) 37 | Data[j].Cur = &cur->Threads[i]; 38 | } 39 | } 40 | 41 | for (int i = 0; i < prev->Thread_Count; i++) 42 | { 43 | for (int j = 0; j < 8; j++) 44 | { 45 | if (idle_tid[j] == prev->Threads[i].td_tid) 46 | Data[j].Prev = &prev->Threads[i]; 47 | } 48 | } 49 | 50 | //Here we loop through each core to calculate the total usage time as its split into user/sustem 51 | for (int i = 0; i < 8; i++) 52 | { 53 | float Prev_Usage_Time = (Data[i].Prev->system_cpu_usage_time.tv_sec + (Data[i].Prev->system_cpu_usage_time.tv_nsec / 1000000.0f)); 54 | Prev_Usage_Time += (Data[i].Prev->user_cpu_usage_time.tv_sec + (Data[i].Prev->user_cpu_usage_time.tv_nsec / 1000000.0f)); 55 | 56 | float Cur_Usage_Time = (Data[i].Cur->system_cpu_usage_time.tv_sec + (Data[i].Cur->system_cpu_usage_time.tv_nsec / 1000000.0f)); 57 | Cur_Usage_Time += (Data[i].Cur->user_cpu_usage_time.tv_sec + (Data[i].Cur->user_cpu_usage_time.tv_nsec / 1000000.0f)); 58 | 59 | //We calculate the usage using usage time difference between the two samples divided by the current time difference. 60 | float Idle_Usage = ((Prev_Usage_Time - Cur_Usage_Time) / Current_Time_Total); 61 | 62 | if (Idle_Usage > 1.0f) 63 | Idle_Usage = 1.0f; 64 | 65 | if (Idle_Usage < 0.0f) 66 | Idle_Usage = 0.0f; 67 | 68 | //Get inverse of idle percentage and express in percent. 69 | usage_out[i] = (1.0f - Idle_Usage) * 100.0f; 70 | } 71 | } 72 | 73 | void* System_Monitor::Monitor_Thread(void* args) 74 | { 75 | //klog("[System Monitor] Thread Started\n"); 76 | 77 | unsigned int Idle_Thread_ID[8]; 78 | 79 | int Thread_Count = 3072; 80 | if (!sceKernelGetCpuUsage((Proc_Stats*)&Stat_Data, (int*)&Thread_Count) && Thread_Count > 0) 81 | { 82 | char Thread_Name[0x40]; 83 | int Core_Count = 0; 84 | for (int i = 0; i < Thread_Count; i++) 85 | { 86 | if (!sceKernelGetThreadName(Stat_Data[i].td_tid, Thread_Name) && sscanf(Thread_Name, "SceIdleCpu%d", &Core_Count) == 1 && Core_Count <= 7) 87 | { 88 | //klog("[System Monitor][SceIdleCpu%d] -> %i\n", Core_Count, Stat_Data[i].td_tid); 89 | 90 | Idle_Thread_ID[Core_Count] = Stat_Data[i].td_tid; 91 | } 92 | } 93 | } 94 | 95 | //klog("[System Monitor] Starting Monitor...\n"); 96 | int Current_Bank = 0; 97 | while (Should_Run_Thread) 98 | { 99 | //klog("Getting Bank %i\n", Current_Bank); 100 | if (Game_Overlay::Show_CPU_Usage || Game_Overlay::Show_Thread_Count) 101 | { 102 | //grab thread data with max threads of 3072. 103 | gThread_Data[Current_Bank].Thread_Count = 3072; 104 | if (!sceKernelGetCpuUsage((Proc_Stats*)&gThread_Data[Current_Bank].Threads, &gThread_Data[Current_Bank].Thread_Count)) 105 | { 106 | //Store the thread count. 107 | System_Monitor::Thread_Count = gThread_Data[Current_Bank].Thread_Count; 108 | 109 | //klog("ThreadCount[%i] = %i\n", Current_Bank, gThread_Data[Current_Bank].Thread_Count); 110 | 111 | //Set the current time. 112 | sceKernelClockGettime(4, &gThread_Data[Current_Bank].current_time); 113 | 114 | //flip to other bank. 115 | Current_Bank = !Current_Bank; 116 | 117 | //make sure bank has threads 118 | if (gThread_Data[Current_Bank].Thread_Count <= 0) 119 | continue; 120 | 121 | //Calculate usage using thread data. 122 | calc_usage(Idle_Thread_ID, &gThread_Data[!Current_Bank], &gThread_Data[Current_Bank], Usage); 123 | 124 | /*klog("CPU Utilization: %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%%\n", 125 | Usage[0], Usage[1], Usage[2], Usage[3], 126 | Usage[4], Usage[5], Usage[6], Usage[7]);*/ 127 | 128 | System_Monitor::Average_Usage = ((Usage[0] + Usage[1] + Usage[2] + Usage[3] + Usage[4] + Usage[5] + Usage[6] + Usage[7]) / 8.0f); 129 | } 130 | } 131 | 132 | if (Game_Overlay::Show_CPU_Temp) 133 | { 134 | sceKernelGetCpuTemperature(&CPU_Temp); 135 | } 136 | 137 | if (Game_Overlay::Show_SOC_Temp) 138 | { 139 | sceKernelGetSocSensorTemperature(0, &SOC_Temp); 140 | } 141 | 142 | if (Game_Overlay::Show_ram) 143 | { 144 | Get_Page_Table_Stats(1, 1, &RAM.Used, &RAM.Free, &RAM.Total); 145 | RAM.Percentage = (((float)RAM.Used / (float)RAM.Total) * 100.0f); 146 | } 147 | 148 | if (Game_Overlay::Show_vram) 149 | { 150 | Get_Page_Table_Stats(1, 2, &VRAM.Used, &VRAM.Free, &VRAM.Total); 151 | VRAM.Percentage = (((float)VRAM.Used / (float)VRAM.Total) * 100.0f); 152 | } 153 | 154 | sceKernelSleep(2); 155 | } 156 | 157 | Should_Run_Thread = true; 158 | klog("[System Monitor] Thread Shutdown.\n"); 159 | void* res; 160 | scePthreadExit(res); 161 | return res; 162 | } 163 | 164 | void System_Monitor::Init() 165 | { 166 | klog("[System Monitor] Starting System Monitor Thread...\n"); 167 | 168 | OrbisPthreadAttr attr; 169 | scePthreadAttrInit(&attr); 170 | 171 | scePthreadAttrSetstacksize(&attr, 0x80000); 172 | 173 | OrbisPthread* id; 174 | scePthreadCreate(&id, &attr, Monitor_Thread, NULL, "System Monitor Thread"); 175 | } 176 | 177 | void System_Monitor::Term() 178 | { 179 | Should_Run_Thread = false; 180 | while (!Should_Run_Thread) { sceKernelUsleep(1000 * 10); } 181 | } -------------------------------------------------------------------------------- /Orbis Toolbox/System_Monitor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Common.h" 3 | 4 | class System_Monitor 5 | { 6 | public: 7 | struct Memory 8 | { 9 | int Used; 10 | int Free; 11 | int Total; 12 | float Percentage; 13 | }; 14 | 15 | static int Thread_Count; 16 | static float Usage[8]; 17 | static float Average_Usage; 18 | static int CPU_Temp; 19 | static int SOC_Temp; 20 | static Memory RAM; 21 | static Memory VRAM; 22 | 23 | static void Init(); 24 | static void Term(); 25 | 26 | private: 27 | struct thread_usages 28 | { 29 | OrbisKernelTimespec current_time; //0x00 30 | int Thread_Count; //0x10 31 | char padding0[0x4]; //0x14 32 | Proc_Stats Threads[3072]; //0x18 33 | }; 34 | 35 | static bool Should_Run_Thread; 36 | static Proc_Stats Stat_Data[3072]; 37 | static thread_usages gThread_Data[2]; 38 | 39 | static void calc_usage(unsigned int idle_tid[8], thread_usages* cur, thread_usages* prev, float usage_out[8]); 40 | static void* Monitor_Thread(void* args); 41 | 42 | }; 43 | -------------------------------------------------------------------------------- /Orbis Toolbox/UI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UI_Utilities.h" 4 | 5 | #include "Widget.h" 6 | #include "Label.h" 7 | #include "Panel.h" -------------------------------------------------------------------------------- /Orbis Toolbox/UI_Utilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace UI 4 | { 5 | class Utilities 6 | { 7 | public: 8 | static char* Get_Version_String(); 9 | static void SetVersionString(const char* str); 10 | static void ReloadItemList(); 11 | static MonoObject* AppBrowseItem(const char* TitleId, const char* TitleName); 12 | static MonoObject* Get_Top_Scene(); 13 | static MonoObject* Get_root_Widget(); 14 | static MonoObject* Adjust_Content(int AlignOrientation, float PaddingLeft, float PaddingRight, float PaddingTop, float PaddingBottom); 15 | static MonoObject* Fit_To_Children(); 16 | static MonoObject* IUFont(int size, int style, int weight); 17 | static MonoObject* MemoryStream(void* Buffer, int Buffer_Size); 18 | static void ResetMenuItem(const char* Menu); 19 | static void RemoveMenuItem(const char* Menu); 20 | static MonoObject* GetElement(const char* Id); 21 | static void Set_Value(const char* Id, const char* Value); 22 | static void AddMenuItem(MonoObject* ElementData); 23 | static MonoObject* ElementData(const char* Id, const char* Title, const char* Title2, const char* Icon); 24 | static MonoObject* UIColor(float R, float G, float B, float A); 25 | static MonoObject* UIColor(float R, float G, float B); 26 | static float ScreenHeight(); 27 | static float ScreenWidth(); 28 | static bool IsAppRunning(const char* TitleId); 29 | private: 30 | 31 | }; 32 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Utilities.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "Utilities.h" 3 | 4 | void klog(const char* fmt, ...) 5 | { 6 | char Buffer[0x200]; 7 | 8 | //Create full string from va list. 9 | va_list args; 10 | va_start(args, fmt); 11 | vsprintf(Buffer, fmt, args); 12 | va_end(args); 13 | 14 | sceKernelDebugOutText(0, Buffer); 15 | } 16 | 17 | void Notify(const char* MessageFMT, ...) 18 | { 19 | NotifyBuffer Buffer; 20 | 21 | //Create full string from va list. 22 | va_list args; 23 | va_start(args, MessageFMT); 24 | vsprintf(Buffer.Message, MessageFMT, args); 25 | va_end(args); 26 | 27 | //Populate the notify buffer. 28 | Buffer.Type = NotifyType::NotificationRequest; //this one is just a standard one and will print what ever is stored at the buffer.Message. 29 | Buffer.unk3 = 0; 30 | Buffer.UseIconImageUri = 1; //Bool to use a custom uri. 31 | Buffer.TargetId = -1; //Not sure if name is correct but is always set to -1. 32 | strcpy(Buffer.Uri, "https://i.imgur.com/SJPIBGG.png"); //Copy the uri to the buffer. 33 | 34 | //From user land we can call int64_t sceKernelSendNotificationRequest(int64_t unk1, char* Buffer, size_t size, int64_t unk2) which is a libkernel import. 35 | sceKernelSendNotificationRequest(0, (char*)&Buffer, 3120, 0); 36 | 37 | //What sceKernelSendNotificationRequest is doing is opening the device "/dev/notification0" or "/dev/notification1" 38 | // and writing the NotifyBuffer we created to it. Somewhere in ShellUI it is read and parsed into a json which is where 39 | // I found some clues on how to build the buffer. 40 | } 41 | 42 | struct Myiovec 43 | { 44 | void* iov_base; 45 | size_t iov_len; 46 | }; 47 | 48 | void build_iovec(Myiovec** iov, int* iovlen, const char* name, const void* val, size_t len) 49 | { 50 | int i; 51 | 52 | if (*iovlen < 0) 53 | return; 54 | 55 | i = *iovlen; 56 | *iov = (Myiovec*)realloc(*iov, sizeof **iov * (i + 2)); 57 | if (*iov == NULL) { 58 | *iovlen = -1; 59 | return; 60 | } 61 | 62 | (*iov)[i].iov_base = strdup(name); 63 | (*iov)[i].iov_len = strlen(name) + 1; 64 | ++i; 65 | 66 | (*iov)[i].iov_base = (void*)val; 67 | if (len == (size_t)-1) { 68 | if (val != NULL) 69 | len = strlen((const char*)val) + 1; 70 | else 71 | len = 0; 72 | } 73 | (*iov)[i].iov_len = (int)len; 74 | 75 | *iovlen = ++i; 76 | } 77 | 78 | 79 | /* 80 | 81 | vm: 82 | 1 - Seems to be system 83 | 2 - seems to be app specific. 84 | 85 | type: 86 | 1 - System, 87 | 2 - VRAM 88 | 89 | System, 90 | Video, 91 | SharedVideoSystemAsset, 92 | SharedVideoHighResoAsset 93 | */ 94 | 95 | void Get_Page_Table_Stats(int vm, int type, int* Used, int* Free, int* Total) 96 | { 97 | int _Total = 0, _Free = 0; 98 | 99 | if (get_page_table_stats(vm, type, &_Total, &_Free) == -1) { 100 | klog("get_page_table_stats() Failed.\n"); 101 | return; 102 | } 103 | 104 | if (Used) 105 | *Used = (_Total - _Free); 106 | 107 | if (Free) 108 | *Free = _Free; 109 | 110 | if (Total) 111 | *Total = _Total; 112 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Utilities.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum NotifyType 4 | { 5 | NotificationRequest = 0, 6 | SystemNotification = 1, 7 | SystemNotificationWithUserId = 2, 8 | SystemNotificationWithDeviceId = 3, 9 | SystemNotificationWithDeviceIdRelatedToUser = 4, 10 | SystemNotificationWithText = 5, 11 | SystemNotificationWithTextRelatedToUser = 6, 12 | SystemNotificationWithErrorCode = 7, 13 | SystemNotificationWithAppId = 8, 14 | SystemNotificationWithAppName = 9, 15 | SystemNotificationWithAppInfo = 9, 16 | SystemNotificationWithAppNameRelatedToUser = 10, 17 | SystemNotificationWithParams = 11, 18 | SendSystemNotificationWithUserName = 12, 19 | SystemNotificationWithUserNameInfo = 13, 20 | SendAddressingSystemNotification = 14, 21 | AddressingSystemNotificationWithDeviceId = 15, 22 | AddressingSystemNotificationWithUserName = 16, 23 | AddressingSystemNotificationWithUserId = 17, 24 | 25 | UNK_1 = 100, 26 | TrcCheckNotificationRequest = 101, 27 | NpDebugNotificationRequest = 102, 28 | UNK_2 = 102, 29 | }; 30 | 31 | struct NotifyBuffer 32 | { //Naming may be incorrect. 33 | NotifyType Type; //0x00 34 | int ReqId; //0x04 35 | int Priority; //0x08 36 | int MsgId; //0x0C 37 | int TargetId; //0x10 38 | int UserId; //0x14 39 | int unk1; //0x18 40 | int unk2; //0x1C 41 | int AppId; //0x20 42 | int ErrorNum; //0x24 43 | int unk3; //0x28 44 | char UseIconImageUri; //0x2C 45 | char Message[1024]; //0x2D 46 | char Uri[1024]; //0x42D 47 | char unkstr[1024]; //0x82D 48 | }; //Size = 0xC30 49 | 50 | #define ARRAY_COUNT(arry) sizeof(arry) / sizeof(arry[0]) 51 | 52 | typedef unsigned char vm_prot_t; /* protection codes */ 53 | 54 | #define VM_PROT_NONE ((vm_prot_t) 0x00) 55 | #define VM_PROT_READ ((vm_prot_t) 0x01) 56 | #define VM_PROT_WRITE ((vm_prot_t) 0x02) 57 | #define VM_PROT_EXECUTE ((vm_prot_t) 0x04) 58 | #define VM_PROT_COPY ((vm_prot_t) 0x08) /* copy-on-read */ 59 | 60 | #define VM_PROT_ALL (VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE) 61 | #define VM_PROT_RW (VM_PROT_READ|VM_PROT_WRITE) 62 | #define VM_PROT_DEFAULT VM_PROT_ALL 63 | 64 | #define MNT_UPDATE 0x0000000000010000ULL /* not real mount, just update */ 65 | 66 | void klog(const char* fmt, ...); 67 | void Notify(const char* MessageFMT, ...); 68 | 69 | void Get_Page_Table_Stats(int vm, int type, int* Used, int* Free, int* Total); -------------------------------------------------------------------------------- /Orbis Toolbox/Widget.cpp: -------------------------------------------------------------------------------- 1 | #include "Common.h" 2 | #include "UI.h" 3 | #include "Panel.h" 4 | #include "Label.h" 5 | #include "Widget.h" 6 | 7 | void Widget::Remove_Child(const char* Child_Name) 8 | { 9 | if (Instance) 10 | { 11 | if (Has_Child(Child_Name)) 12 | { 13 | MonoObject* ChildWidget = Mono::Invoke(Mono::App_exe, Widget_Class, Instance, "FindWidgetByName", Mono::New_String(Child_Name)); 14 | Mono::Invoke(Mono::App_exe, Widget_Class, ChildWidget, "RemoveFromParent"); 15 | 16 | Children.erase(Children.find(Child_Name)); 17 | } 18 | else 19 | klog("[Widget] %s(): Child \"%s\" does not exist in Family.\n", __FUNCTION__, Child_Name); 20 | } 21 | else 22 | klog("[Widget] %s(): Instance is not set.\n", __FUNCTION__); 23 | } 24 | 25 | void* Widget::Get_Child(const char* Child_Name) 26 | { 27 | if (Has_Child(Child_Name)) 28 | { 29 | Children[Child_Name]->Instance = Mono::Invoke(Mono::App_exe, Widget_Class, this->Instance, "FindWidgetByName", Mono::New_String(Child_Name)); 30 | return Children[Child_Name]; 31 | } 32 | else 33 | klog("[Widget] %s(): Child \"%s\" Does not exist on Parent.\n", __FUNCTION__, Child_Name); 34 | return 0; 35 | } 36 | 37 | bool Widget::Has_Child(const char* Child_Name) 38 | { 39 | return (Children.find(Child_Name) != Children.end()); 40 | } 41 | 42 | void Widget::Set_Clip_Children(bool Value) 43 | { 44 | if (Instance) 45 | Mono::Set_Property(Widget_Class, Instance, "ClipChildren", Value); 46 | else 47 | klog("[Widget] %s(): Instance is not set.\n", __FUNCTION__); 48 | } 49 | 50 | Widget::Widget() 51 | { 52 | this->Widget_Class = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Widget"); 53 | } 54 | 55 | Widget::~Widget() 56 | { 57 | 58 | } -------------------------------------------------------------------------------- /Orbis Toolbox/Widget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | class Panel; 3 | class Label; 4 | 5 | class Widget 6 | { 7 | protected: 8 | 9 | 10 | public: 11 | MonoObject* Instance; 12 | std::map Children; 13 | 14 | template 15 | void Append_Child(const char* Child_Name, ChildClass* Child_Class) 16 | { 17 | if (Instance) 18 | { 19 | if (Children.find(Child_Name) == Children.end()) 20 | { 21 | Children.insert(std::pair(Child_Name, (Widget*)Child_Class)); 22 | 23 | Mono::Invoke(Mono::App_exe, Widget_Class, Instance, "AppendChild", Child_Class->Instance); 24 | } 25 | else 26 | klog("[Widget] %s(): Child \"%s\" already exists in Family.\n", __FUNCTION__, Child_Name); 27 | } 28 | else 29 | klog("[Widget] %s(): Instance is not set.\n", __FUNCTION__); 30 | } 31 | void Remove_Child(const char* Child_Name); 32 | void* Get_Child(const char* Child_Name); 33 | bool Has_Child(const char* Child_Name); 34 | void Set_Clip_Children(bool Value); 35 | 36 | Widget(); 37 | ~Widget(); 38 | 39 | private: 40 | MonoClass* Widget_Class; 41 | }; -------------------------------------------------------------------------------- /Orbis Toolbox/build.bat: -------------------------------------------------------------------------------- 1 | SETLOCAL EnableDelayedExpansion 2 | 3 | Rem Libraries to link in 4 | set libraries=-lSceLibcInternal -lSceLibcInternalExt -lkernel -lmonosgen -lSceSystemService -lSceLncUtil 5 | 6 | Rem Read the script arguments into local vars 7 | set intdir=%1 8 | set targetname=%~2 9 | set outputPath=%~3 10 | 11 | set outputElf=%intdir%%targetname%.elf 12 | set outputOelf=%intdir%%targetname%.oelf 13 | set outputPrx=%intdir%%targetname%.prx 14 | set outputStub=%intdir%%targetname%_stub.so 15 | 16 | Rem Compile object files for all the source files -DORBIS_TOOLBOX_DEBUG 17 | for %%f in (*.cpp) do ( 18 | clang++ -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -I"%OO_PS4_TOOLCHAIN%\include" -I"%OO_PS4_TOOLCHAIN%\\include\\c++\\v1" -emit-obj -o %intdir%\%%~nf.o %%~nf.cpp 19 | ) 20 | 21 | Rem Compile object files for all the assembly files 22 | for %%f in (*.s) do ( 23 | clang -m64 -nodefaultlibs -nostdlib --target=x86_64-scei-ps4-elf -c -o %intdir%\%%~nf.o %%~nf.s 24 | ) 25 | 26 | Rem Get a list of object files for linking 27 | set obj_files= 28 | for %%f in (%intdir%\\*.o) do set obj_files=!obj_files! .\%%f 29 | 30 | Rem Link the input ELF 31 | ld.lld -m elf_x86_64 -pie --script "%OO_PS4_TOOLCHAIN%\link.x" --eh-frame-hdr -o "%outputElf%" "-L%OO_PS4_TOOLCHAIN%\lib" %libraries% --verbose "%OO_PS4_TOOLCHAIN%\lib\crtlib.o" %obj_files% 32 | 33 | Rem Create stub shared libraries 34 | for %%f in (*.cpp) do ( 35 | clang++ -target x86_64-pc-linux-gnu -ffreestanding -nostdlib -fno-builtin -fPIC -c -I"%OO_PS4_TOOLCHAIN%\include" -I"%OO_PS4_TOOLCHAIN%\\include\\c++\\v1" -o %intdir%\%%~nf.o.stub %%~nf.cpp 36 | ) 37 | 38 | set stub_obj_files= 39 | for %%f in (%intdir%\\*.o.stub) do set stub_obj_files=!stub_obj_files! .\%%f 40 | 41 | clang++ -target x86_64-pc-linux-gnu -shared -fuse-ld=lld -ffreestanding -nostdlib -fno-builtin "-L%OO_PS4_TOOLCHAIN%\lib" %libraries% %stub_obj_files% -o "%outputStub%" 42 | 43 | Rem Create the prx 44 | %OO_PS4_TOOLCHAIN%\bin\windows\create-lib.exe -in "%outputElf%" --out "%outputOelf%" --paid 0x3800000000010003 45 | 46 | Rem Cleanup 47 | copy "%outputPrx%" "%outputPath%\%targetname%.sprx" 48 | del "%outputPrx%" 49 | 50 | REM Generate the script. Will overwrite any existing temp.txt 51 | REM echo open 192.168.0.54 6904> temp.txt 52 | echo open 192.168.0.54 1337> temp.txt 53 | echo anonymous>> temp.txt 54 | echo anonymous>> temp.txt 55 | echo cd /mnt/usb0/>> temp.txt 56 | echo send "%outputPath%%targetname%.sprx">> temp.txt 57 | echo quit>> temp.txt 58 | 59 | REM Launch FTP and pass it the script 60 | ftp -s:temp.txt 61 | 62 | REM Clean up. 63 | del temp.txt 64 | -------------------------------------------------------------------------------- /Orbis Toolbox/external_hdd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |