Added projects from 2.0 though not the daemon as I will be re writing it. Kernel could also probably use some work to tidy it up.
This commit is contained in:
@@ -0,0 +1,176 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(KERNELDRIVER)
|
||||
#include <sys/ioccom.h>
|
||||
#else
|
||||
#include <sys/ioctl.h>
|
||||
#define IOC_VOID 0x20000000 /* no parameters */
|
||||
#define IOC_OUT 0x40000000 /* copy out parameters */
|
||||
#define IOC_IN 0x80000000 /* copy in parameters */
|
||||
#define IOC_INOUT (IOC_IN|IOC_OUT)
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
};
|
||||
#endif
|
||||
|
||||
enum KDriverCommands
|
||||
{
|
||||
/* ######## Proc Commands ####### */
|
||||
CMD_PROC_LIST,
|
||||
CMD_PROC_INFO,
|
||||
CMD_PROC_MODULE_LIST,
|
||||
CMD_PROC_READ_WRITE_MEMORY,
|
||||
CMD_PROC_ALLOC_MEMORY,
|
||||
CMD_PROC_FREE_MEMORY,
|
||||
CMD_PROC_SPRX,
|
||||
CMD_PROC_ELF,
|
||||
/* ############################## */
|
||||
|
||||
/* ###### Kernel Commands ####### */
|
||||
CMD_KERN_READ_WRITE_MEMORY,
|
||||
/* ############################## */
|
||||
|
||||
/* ###### KDriver Commands ###### */
|
||||
CMD_KDRIVER_INFO,
|
||||
/* ############################## */
|
||||
};
|
||||
|
||||
// Process Commands
|
||||
struct KDriver_ProcList
|
||||
{
|
||||
uint64_t UserlandAddr;
|
||||
size_t UserlandSize;
|
||||
int ProcCount;
|
||||
};
|
||||
|
||||
struct ProcInfo
|
||||
{
|
||||
int PID;
|
||||
bool Attached;
|
||||
char ProcName[32];
|
||||
char TitleID[10];
|
||||
uint64_t TextSegmentBase;
|
||||
uint64_t TextSegmentLen;
|
||||
uint64_t DataSegmentBase;
|
||||
uint64_t DataSegmentLen;
|
||||
};
|
||||
|
||||
struct KDriver_ProcSPRX
|
||||
{
|
||||
int CallType;
|
||||
char ProcName[32];
|
||||
int Handle;
|
||||
char Path[4096];
|
||||
bool CallEntryExit;
|
||||
};
|
||||
|
||||
struct KDriver_ProcInfo
|
||||
{
|
||||
int ProcessID;
|
||||
uint64_t UserlandAddr;
|
||||
size_t UserlandSize;
|
||||
int ThreadCount;
|
||||
};
|
||||
|
||||
struct ProcInfoExt
|
||||
{
|
||||
struct ThreadInfo
|
||||
{
|
||||
int ThreadId;
|
||||
char Name[36];
|
||||
int Errno;
|
||||
int RetVal;
|
||||
};
|
||||
|
||||
int ProcessID;
|
||||
int Attached;
|
||||
int Signal;
|
||||
int Code;
|
||||
int Stops;
|
||||
int StopType;
|
||||
char ProcName[32];
|
||||
char TitleID[10];
|
||||
char ElfPath[1024];
|
||||
char RandomizedPath[256];
|
||||
uint64_t TextSegmentBase;
|
||||
uint64_t TextSegmentLen;
|
||||
uint64_t DataSegmentBase;
|
||||
uint64_t DataSegmentLen;
|
||||
|
||||
int ThreadCount;
|
||||
ThreadInfo Threads[];
|
||||
};
|
||||
|
||||
struct KDriver_ModuleList
|
||||
{
|
||||
int ProcessID;
|
||||
uint64_t UserlandAddr;
|
||||
size_t UserlandSize;
|
||||
int ModuleCount;
|
||||
};
|
||||
|
||||
struct ModuleInfo
|
||||
{
|
||||
int Handle;
|
||||
char Name[36];
|
||||
char Path[256];
|
||||
uint64_t TextSegmentBase;
|
||||
uint64_t TextSegmentLen;
|
||||
uint64_t DataSegmentBase;
|
||||
uint64_t DataSegmentLen;
|
||||
};
|
||||
|
||||
struct KDriver_ReadWriteMemory
|
||||
{
|
||||
int ProcessID;
|
||||
bool IsRead;
|
||||
uint64_t ProcessAddress;
|
||||
uint64_t UserlandAddr;
|
||||
size_t Length;
|
||||
};
|
||||
|
||||
struct KDriver_AllocFreeMemory
|
||||
{
|
||||
int ProcessID;
|
||||
size_t Ammount;
|
||||
uint64_t ProcessAddress;
|
||||
};
|
||||
|
||||
struct KDriver_ProcELF
|
||||
{
|
||||
int ProcessID;
|
||||
uint64_t ELFAddress;
|
||||
size_t ELFSize;
|
||||
};
|
||||
|
||||
#define PROC_LIST _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_LIST), sizeof(KDriver_ProcList))
|
||||
#define PROC_INFO _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_INFO), sizeof(KDriver_ProcInfo))
|
||||
#define PROC_MODULE_LIST _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_MODULE_LIST), sizeof(KDriver_ModuleList))
|
||||
#define PROC_READ_WRITE_MEMORY _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_READ_WRITE_MEMORY), sizeof(KDriver_ReadWriteMemory))
|
||||
#define PROC_ALLOC_MEMORY _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_ALLOC_MEMORY), sizeof(KDriver_AllocFreeMemory))
|
||||
#define PROC_FREE_MEMORY _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_FREE_MEMORY), sizeof(KDriver_AllocFreeMemory))
|
||||
#define PROC_SPRX _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_SPRX), sizeof(KDriver_ProcSPRX))
|
||||
#define PROC_ELF _IOC(IOC_INOUT, 'P', (uint32_t)(KDriverCommands::CMD_PROC_ELF), sizeof(KDriver_ProcELF))
|
||||
|
||||
// Kernel Commands
|
||||
#define KERN_READ_WRITE_MEMORY _IOC(IOC_INOUT, 'K', (uint32_t)(KDriverCommands::CMD_KERN_READ_WRITE_MEMORY), sizeof(KDriver_ReadWriteMemory))
|
||||
|
||||
// Kdriver Commands
|
||||
struct KDriver_Info
|
||||
{
|
||||
int MajorVersion;
|
||||
int MinorVersion;
|
||||
int BuildVersion;
|
||||
bool Running;
|
||||
int(*Shutdown)();
|
||||
int(*Entry)(void* p);
|
||||
void* ELFBase;
|
||||
int Size;
|
||||
};
|
||||
|
||||
#define KDRIVER_INFO _IOC(IOC_OUT, 'D', (uint32_t)(KDriverCommands::CMD_KDRIVER_INFO), sizeof(KDriver_Info))
|
||||
@@ -0,0 +1,66 @@
|
||||
@echo off
|
||||
REM you need this to set and read a variable inside
|
||||
REM a parethetical structure such as a FOR loop
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM This is the file we are going to alter
|
||||
set filepath=%1
|
||||
set filename=%~n1%~x1
|
||||
|
||||
REM Use temp file
|
||||
REM delete if already exists
|
||||
REM so we can use append operator for all output
|
||||
if exist "%filepath%.temp" del "%filepath%.temp"
|
||||
|
||||
REM For each line in the file...
|
||||
REM ...using FOR alone to parse the file skips blank lines so we...
|
||||
REM ...parse the output (note single quotes) of...
|
||||
REM running TYPE on the file and piping the output through FINDSTR...
|
||||
REM ...with the /n switch (this adds a line number and a colon at the start of each line)
|
||||
REM the FINDSTR search string is ".*" (find any characters including cr/lf)
|
||||
REM Split into 2* tokens, the asterisk means %%R is the entire remainder of the line
|
||||
REM delimiter being the colon thus...
|
||||
REM The number is token 1, %%Q (discarded, along with the colon)
|
||||
REM The original source file line is token 2, %%R
|
||||
REM note we escape the pipe character with a caret ^ in the FOR dataset block
|
||||
for /f "tokens=1,2* delims=:" %%Q in ('type "%filepath%" ^| findstr /n ".*"') do (
|
||||
|
||||
REM if token 2 is null then the line is blank so we echo a blank line to the temp output file
|
||||
if "%%R"=="" echo. >> "%filepath%.temp"
|
||||
|
||||
REM This flag gets set to 1 if we have a line that needs changing
|
||||
set incflag=0
|
||||
|
||||
REM Split the line into 3 tokens with white space the delimiter
|
||||
for /f "tokens=1-3 delims= " %%A in ("%%R") do (
|
||||
|
||||
REM test if an increment needs to happen and set the flag if it does
|
||||
if "%%B"==%2 set incflag=1
|
||||
REM %%C is the number
|
||||
|
||||
REM If the line contains a number to increment...
|
||||
if !incflag! equ 1 (
|
||||
REM do it...
|
||||
set /a num=%%C+1
|
||||
|
||||
REM info msg to console
|
||||
echo Incrementing %%B from %%C to !num!
|
||||
|
||||
REM write the altered line to file
|
||||
echo %%A %%B !num! >>"%filepath%.temp"
|
||||
|
||||
REM the line is a nonblank one that simply needs copying
|
||||
) else (
|
||||
|
||||
echo %%R >> "%filepath%.temp"
|
||||
|
||||
REM Match those parentheses!
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
REM delete original file
|
||||
del "%filepath%"
|
||||
|
||||
REM rename temp file to original file name
|
||||
ren "%filepath%.temp" "%filename%"
|
||||
+61
-2
@@ -10,6 +10,10 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Playstation", "Playstation", "{8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{DBCE3AAD-373D-4EB6-8964-2A4BE1E9F575}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Misc\DriverDefinitions.h = Misc\DriverDefinitions.h
|
||||
Misc\Increment.bat = Misc\Increment.bat
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisNeighborHood", "Windows\OrbisNeighborHood\OrbisNeighborHood.csproj", "{81B068F7-776C-429F-BB7B-5563F75F1A39}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
@@ -18,45 +22,97 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisNeighborHood", "Window
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installer", "Installer", "{6046C772-BE17-4BC8-A362-AD8C77F9178E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrbisLib", "Windows\Libraries\OrbisLib\OrbisLib.csproj", "{6AE42BFE-1833-4804-96EB-38D323B6C28E}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisLib", "Windows\Libraries\OrbisLib\OrbisLib.csproj", "{6AE42BFE-1833-4804-96EB-38D323B6C28E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OrbisSuiteService", "Windows\OrbisSuiteService\OrbisSuiteService.csproj", "{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OrbisSuiteService", "Windows\OrbisSuiteService\OrbisSuiteService.csproj", "{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E} = {6AE42BFE-1833-4804-96EB-38D323B6C28E}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Daemon", "Playstation\Daemon\Daemon.vcxproj", "{88E11D06-FCB4-4707-A48E-B8D66966A154}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Orbis Toolbox", "Playstation\Orbis Toolbox\Orbis Toolbox.vcxproj", "{CED79D48-621A-4076-81E8-11F77DE1E41B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OrbisSuite", "Playstation\OrbisSuite\OrbisSuite.vcxproj", "{228AA300-11F5-49B1-A6B5-4986635C6D0B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x64.Build.0 = Release|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{81B068F7-776C-429F-BB7B-5563F75F1A39}.Release|x86.Build.0 = Release|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Release|x64.Build.0 = Release|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF}.Release|x86.Build.0 = Release|Any CPU
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Debug|x64.Build.0 = Debug|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Release|x64.ActiveCfg = Release|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Release|x64.Build.0 = Release|x64
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154}.Release|x86.ActiveCfg = Release|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|x64.Build.0 = Debug|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Debug|x86.Build.0 = Debug|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|Any CPU.Build.0 = Release|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|x64.ActiveCfg = Release|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|x64.Build.0 = Release|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|x86.ActiveCfg = Release|x64
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B}.Release|x86.Build.0 = Release|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Debug|x64.Build.0 = Debug|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Debug|x86.Build.0 = Debug|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Release|Any CPU.Build.0 = Release|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Release|x64.ActiveCfg = Release|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Release|x64.Build.0 = Release|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Release|x86.ActiveCfg = Release|x64
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B}.Release|x86.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -67,6 +123,9 @@ Global
|
||||
{6046C772-BE17-4BC8-A362-AD8C77F9178E} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
|
||||
{6AE42BFE-1833-4804-96EB-38D323B6C28E} = {72E29C1E-8723-4885-A5ED-BD3A929D81B6}
|
||||
{D7CFB2D5-FAC2-42D5-ABA7-81CE762575EF} = {8F0E1457-FB1E-47A4-9DA8-74A6B757CAA4}
|
||||
{88E11D06-FCB4-4707-A48E-B8D66966A154} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
|
||||
{CED79D48-621A-4076-81E8-11F77DE1E41B} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
|
||||
{228AA300-11F5-49B1-A6B5-4986635C6D0B} = {8E8E4C8D-E3E1-4CB9-BD78-7ADAB2F2CF45}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4B6EE1D0-5ADF-44A2-B6EE-E5C8E110EE47}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{88e11d06-fcb4-4707-a48e-b8d66966a154}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Makefile</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<NMakeOutput>eboot.bin</NMakeOutput>
|
||||
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
<NMakeBuildCommandLine>call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)"</NMakeBuildCommandLine>
|
||||
<NMakeReBuildCommandLine>del /s /q /f $(IntDir)\*.o
|
||||
del /s /q /f $(IntDir)\*.elf
|
||||
del /s /q /f $(IntDir)\*.oelf
|
||||
call build.bat $(IntDir) "$(TargetName)" "$(SolutionDir)"</NMakeReBuildCommandLine>
|
||||
<NMakeCleanCommandLine>del /s /q /f $(IntDir)\*.o
|
||||
del /s /q /f $(IntDir)\*.elf
|
||||
del /s /q /f $(IntDir)\*.oelf</NMakeCleanCommandLine>
|
||||
<OutDir>$(SolutionDir)</OutDir>
|
||||
<NMakeIncludeSearchPath>$(OO_PS4_TOOLCHAIN)\include;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<NMakeOutput>eboot.bin</NMakeOutput>
|
||||
<NMakePreprocessorDefinitions>NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="build.bat" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="build.bat" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,31 @@
|
||||
SETLOCAL EnableDelayedExpansion
|
||||
|
||||
Rem Libraries to link in
|
||||
set libraries=-lc -lkernel
|
||||
|
||||
Rem Read the script arguments into local vars
|
||||
set intdir=%1
|
||||
set targetname=%~2
|
||||
set outputPath=%3
|
||||
|
||||
set outputElf=%intdir%%targetname%.elf
|
||||
set outputOelf=%intdir%%targetname%.oelf
|
||||
|
||||
Rem Compile object files for all the source files
|
||||
for %%f in (*.cpp) do (
|
||||
clang++ -cc1 -triple x86_64-scei-ps4-elf -munwind-tables -I"%OO_PS4_TOOLCHAIN%\\include" -emit-obj -o %intdir%\%%~nf.o %%~nf.cpp
|
||||
)
|
||||
|
||||
Rem Get a list of object files for linking
|
||||
set obj_files=
|
||||
for %%f in (%1\\*.o) do set obj_files=!obj_files! .\%%f
|
||||
|
||||
Rem Link the input ELF
|
||||
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\crt1.o" %obj_files%
|
||||
|
||||
Rem Create the eboot
|
||||
%OO_PS4_TOOLCHAIN%\bin\windows\create-eboot.exe -in "%outputElf%" --out "%outputOelf%" --paid 0x3800000000000011
|
||||
|
||||
Rem Cleanup
|
||||
copy "eboot.bin" %outputPath%\eboot.bin
|
||||
del "eboot.bin"
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
// Your code here...
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PS4",
|
||||
"includePath": [
|
||||
"C:\\Users\\grego\\source\\repos\\Orbis-Suite-2.0\\Misc/**",
|
||||
"${workspaceFolder}/**",
|
||||
"E:\\Modding\\PS4\\Projects\\2020\\FreeBSD\\include/**"
|
||||
],
|
||||
"defines": [
|
||||
"_DEBUG",
|
||||
"UNICODE",
|
||||
"_UNICODE"
|
||||
],
|
||||
"windowsSdkVersion": "10.0.17763.0",
|
||||
"compilerPath": "/usr/bin/g++",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++17",
|
||||
"intelliSenseMode": "gcc-x64"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"cstring": "cpp",
|
||||
"system_error": "cpp",
|
||||
"xlocale": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"complex": "cpp",
|
||||
"functional": "cpp",
|
||||
"memory": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"xmemory0": "cpp",
|
||||
"xtr1common": "cpp",
|
||||
"xutility": "cpp",
|
||||
"array": "cpp",
|
||||
"cstdlib": "cpp"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
call "C:\Users\grego\source\repos\Orbis-Suite-2.0\Misc\Increment.bat" "C:\Users\grego\source\repos\Orbis-Suite-2.0\Playstation\Kernel\Kernel\source\Util\Settings.hpp" "KDRIVER_BUILD_VERSION"
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
|
||||
OUTPUT_ARCH(i386:x86-64)
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
PHDRS
|
||||
{
|
||||
code PT_LOAD FILEHDR PHDRS;
|
||||
headers PT_PHDR PHDRS;
|
||||
text PT_LOAD FILEHDR PHDRS;
|
||||
data PT_LOAD;
|
||||
bss PT_LOAD;
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text 0x500: { *(.text) } :code
|
||||
.rodata : {
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
*(.data)
|
||||
*(.data.*)
|
||||
} :text
|
||||
.data : {
|
||||
*(.data)
|
||||
} :data
|
||||
.bss : { *(.bss) }
|
||||
/DISCARD/ : { *(.eh_frame) }
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
CC := clang++
|
||||
AS := clang++
|
||||
OBJCOPY := objcopy
|
||||
ODIR := build
|
||||
SDIR := source
|
||||
RDIR := Resources
|
||||
IDIRS := -Iinclude -I$(FREEBSD_INCLUDES) -I../../../Misc
|
||||
CFLAGS := $(IDIRS) -O3 -s -w -std=gnu++11 -ffunction-sections -fdata-sections -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)
|
||||
LFLAGS := -Xlinker -T Linker -Wl,--build-id=none -mstackrealign -pie -Wl,--gc-sections
|
||||
SFLAGS := -nostartfiles -nostdlib -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=small
|
||||
CFILES := $(shell find $(SDIR) -name \*.cpp)
|
||||
SFILES := $(shell find $(SDIR) -name \*.s)
|
||||
RFILES := $(shell find $(RDIR) -name \*.bin)
|
||||
OBJS := $(patsubst $(SDIR)/%.c, $(ODIR)/%.o, $(CFILES)) $(patsubst $(SDIR)/%.s, $(ODIR)/%.o, $(SFILES)) $(patsubst $(RDIR)/%.bin, $(ODIR)/%.o, $(RFILES))
|
||||
|
||||
TARGET = $(shell basename "$(CURDIR)").elf
|
||||
|
||||
$(TARGET): $(ODIR) $(OBJS)
|
||||
$(CC) crt0.s $(OBJS) -o $(TARGET) $(CFLAGS) $(LFLAGS)
|
||||
|
||||
$(ODIR)/%.o: $(SDIR)/%.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
$(ODIR)/%.o: $(SDIR)/%.s
|
||||
$(AS) -c -o $@ $< $(SFLAGS)
|
||||
|
||||
$(ODIR)/%.o: $(RDIR)/%.bin
|
||||
mkdir -p $(dir $@)
|
||||
ld -r -b binary -o $@ $<
|
||||
# objdump -t $@
|
||||
|
||||
$(ODIR):
|
||||
@mkdir $@
|
||||
|
||||
.PHONY: copy
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(ODIR)/*.o
|
||||
|
||||
copy:
|
||||
cp $(shell basename "$(CURDIR)").elf ../../Build/pkg/Kernel/$(shell basename "$(CURDIR)").$(VERSION).ELF
|
||||
|
||||
echo open 192.168.0.55 2121> temp.txt
|
||||
echo user anonymous anonymous>> temp.txt
|
||||
echo put \"$(shell pwd)/$(shell basename "$(CURDIR)").elf\" \"/data/Orbis Suite/$(shell basename "$(CURDIR)").$(VERSION).ELF\">> temp.txt
|
||||
echo bye>> temp.txt
|
||||
|
||||
ftp -n < temp.txt
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
.intel_syntax noprefix
|
||||
.text
|
||||
.global _start
|
||||
_start:
|
||||
jmp _main
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "Util/Types.hpp"
|
||||
#include "Util/Settings.hpp"
|
||||
#include "Util/Resolver/Resolver.hpp"
|
||||
#include "Util/Kernel.hpp"
|
||||
#include "Util/kproc.hpp"
|
||||
#include "Util/ASM.h"
|
||||
#include "Util/Heap.hpp"
|
||||
|
||||
#include "OrbisLib/OrbisLib.hpp"
|
||||
#include "OrbisLib/KDriver/KDriver.hpp"
|
||||
|
||||
#include "DriverDefinitions.h"
|
||||
|
||||
class OrbisLib;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sys/param.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
|
||||
#include <sys/jail.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/ptrace.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/pcpu.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <vm/vm_map.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/elf_common.h>
|
||||
#include <sys/elf64.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <wait.h>
|
||||
#include <machine/reg.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "sys/mount.h"
|
||||
|
||||
#include <sys/conf.h>
|
||||
#include <fs/devfs/devfs.h>
|
||||
}
|
||||
|
||||
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
|
||||
#define LIST_FOREACH(var, head, field) \
|
||||
for ((var) = ((head)->lh_first); \
|
||||
(var); \
|
||||
(var) = ((var)->field.le_next))
|
||||
#define FOREACH_PROC_IN_SYSTEM(p) \
|
||||
LIST_FOREACH((p), _allproc, p_list)
|
||||
#define mtx_lock(m) _mtx_lock_flags((m), 0, __FILE__, __LINE__)
|
||||
#define PROC_LOCK(p) mtx_lock(&(p)->p_mtx)
|
||||
#define mtx_unlock(m) _mtx_unlock_flags((m), 0, __FILE__, __LINE__)
|
||||
#define PROC_UNLOCK(p) mtx_unlock(&(p)->p_mtx)
|
||||
#define Sleep(u) (pause("", u))
|
||||
|
||||
extern OrbisLib* OrbisLibInstance;
|
||||
extern KDriver_Info* KDriverInfo;
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "KDriver.hpp"
|
||||
#include "DriverDefinitions.h"
|
||||
|
||||
#include "Proc.hpp"
|
||||
#include "Kernel.hpp"
|
||||
|
||||
KDriver::KDriver()
|
||||
{
|
||||
m_DeviceSw.d_version = D_VERSION;
|
||||
m_DeviceSw.d_name = "OrbisSuite";
|
||||
m_DeviceSw.d_ioctl = OnIoctl;
|
||||
|
||||
int ret = make_dev_p(MAKEDEV_CHECKNAME | MAKEDEV_WAITOK,
|
||||
&m_Device,
|
||||
&m_DeviceSw,
|
||||
nullptr,
|
||||
UID_ROOT,
|
||||
GID_WHEEL,
|
||||
S_IRWXU | S_IRWXG | S_IRWXO,
|
||||
"OrbisSuite");
|
||||
|
||||
if (ret == 0)
|
||||
klog("device driver created successfully!");
|
||||
else if (ret == EEXIST)
|
||||
klog("could not create device driver, device driver already exists.");
|
||||
else
|
||||
klog("could not create device driver (%d).", ret);
|
||||
}
|
||||
|
||||
KDriver::~KDriver()
|
||||
{
|
||||
destroy_dev(m_Device);
|
||||
}
|
||||
|
||||
void KDriver::OnProcessStart(void *arg, struct proc *p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int KDriver::OnIoctl(cdev* dev, unsigned long cmd, caddr_t data, int fflag, thread* td)
|
||||
{
|
||||
cmd = cmd & 0xFFFFFFFF; // Clear the upper32
|
||||
auto group = IOCGROUP(cmd);
|
||||
|
||||
klog("Group: %c Cmd: %i", group, cmd);
|
||||
|
||||
switch (group)
|
||||
{
|
||||
case 'P':
|
||||
return Proc::OnIoctl(dev, cmd, data, fflag, td);
|
||||
|
||||
case 'K':
|
||||
return Kernel::OnIoctl(dev, cmd, data, fflag, td);
|
||||
|
||||
case 'D':
|
||||
switch (cmd)
|
||||
{
|
||||
case KDRIVER_INFO:
|
||||
return GetKDriverInfo(data);
|
||||
|
||||
default:
|
||||
klog("[KDriver] Not Implimented. :(");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
klog("[KDriver] Not Implimented. :(");
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int KDriver::GetKDriverInfo(caddr_t data)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if(KDriverInfo == nullptr)
|
||||
{
|
||||
klog("KDriverInfo pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
int res = copyout(KDriverInfo, data, sizeof(KDriver_Info));
|
||||
if(res != 0)
|
||||
{
|
||||
klog("Failed to copy out data.");
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
#include "../../Common.hpp"
|
||||
#include "DriverDefinitions.h"
|
||||
|
||||
class KDriver
|
||||
{
|
||||
private:
|
||||
cdev* m_Device;
|
||||
cdevsw m_DeviceSw;
|
||||
|
||||
static int GetKDriverInfo(caddr_t data);
|
||||
|
||||
public:
|
||||
KDriver();
|
||||
~KDriver();
|
||||
void OnProcessStart(void *arg, struct proc *p);
|
||||
static int OnIoctl(cdev* p_Device, unsigned long p_Command, caddr_t p_Data, int p_FFlag, thread* p_Thread);
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "Kernel.hpp"
|
||||
|
||||
#include "DriverDefinitions.h"
|
||||
#include "../../Util/System.hpp"
|
||||
|
||||
int Kernel::OnIoctl(cdev* dev, unsigned long cmd, caddr_t data, int fflag, thread* td)
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
|
||||
default:
|
||||
klog("Not Implimented. :(");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
class Kernel
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
static int OnIoctl(cdev* dev, unsigned long cmd, caddr_t data, int fflag, thread* td);
|
||||
};
|
||||
@@ -0,0 +1,289 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "Proc.hpp"
|
||||
|
||||
#include "DriverDefinitions.h"
|
||||
#include "../../Util/ShellCode/SPRXShellCode.hpp"
|
||||
#include "../../Util/System.hpp"
|
||||
|
||||
int Proc::OnIoctl(cdev* dev, unsigned long cmd, caddr_t data, int fflag, thread* td)
|
||||
{
|
||||
switch(cmd)
|
||||
{
|
||||
case PROC_LIST:
|
||||
return GetProccessList(data, td);
|
||||
|
||||
case PROC_INFO:
|
||||
return GetProccessInfo(data, td);
|
||||
|
||||
case PROC_MODULE_LIST:
|
||||
return GetProccessModuleList(data, td);
|
||||
|
||||
case PROC_READ_WRITE_MEMORY:
|
||||
return ProcessReadWrite(data, td);
|
||||
|
||||
case PROC_ALLOC_MEMORY:
|
||||
return ProcessAlloc(data, td);
|
||||
|
||||
case PROC_FREE_MEMORY:
|
||||
return ProcessFree(data);
|
||||
|
||||
case PROC_SPRX:
|
||||
return ProcessSPRX(data);
|
||||
|
||||
case PROC_ELF:
|
||||
return ProcessELF(data, td);
|
||||
|
||||
default:
|
||||
klog("[Proc] Not Implimented. :(");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int Proc::GetProccessList(caddr_t data, thread* td)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Input = (KDriver_ProcList*)data;
|
||||
auto Temp = (ProcInfo*)kmalloc(sizeof(ProcInfo) * Input->ProcCount);
|
||||
|
||||
klog("Itterating Processes!");
|
||||
int ProccessCount = 0;
|
||||
proc* CurrentProc = *(proc**)allproc;
|
||||
do
|
||||
{
|
||||
if(ProccessCount > Input->ProcCount)
|
||||
break;
|
||||
|
||||
klog("%s", CurrentProc->p_comm);
|
||||
|
||||
Temp[ProccessCount].PID = CurrentProc->p_pid;
|
||||
Temp[ProccessCount].Attached = ((CurrentProc->p_flag & 0x800) != 0);
|
||||
memcpy(&Temp[ProccessCount].ProcName, CurrentProc->p_comm, strlen(CurrentProc->p_comm) + 1);
|
||||
memcpy(&Temp[ProccessCount].TitleID, CurrentProc->titleId, 10);
|
||||
Temp[ProccessCount].TextSegmentBase = (uint64_t)CurrentProc->p_vmspace->vm_taddr;
|
||||
Temp[ProccessCount].TextSegmentLen = (uint64_t)(CurrentProc->p_vmspace->vm_tsize * PAGE_SIZE);
|
||||
Temp[ProccessCount].DataSegmentBase = (uint64_t)CurrentProc->p_vmspace->vm_daddr;
|
||||
Temp[ProccessCount].DataSegmentLen = (uint64_t)(CurrentProc->p_vmspace->vm_dsize * PAGE_SIZE);
|
||||
|
||||
ProccessCount++;
|
||||
CurrentProc = CurrentProc->p_list.le_next;
|
||||
} while (CurrentProc != nullptr);
|
||||
|
||||
Input->ProcCount = ProccessCount;
|
||||
|
||||
WriteProcessMemory(td->td_proc, (void*)Input->UserlandAddr, Temp, Input->UserlandSize);
|
||||
|
||||
kfree(Temp);
|
||||
|
||||
klog("done!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::GetProccessInfo(caddr_t data, thread* td)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Input = (KDriver_ProcInfo*)data;
|
||||
|
||||
proc* CurrentProc = FindProcessByPID(Input->ProcessID);
|
||||
|
||||
if(CurrentProc == nullptr)
|
||||
{
|
||||
klog("Failed to find Process with the pid %i\n", Input->ProcessID);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Temp = (ProcInfoExt*)kmalloc(sizeof(ProcInfoExt) + (sizeof(ProcInfoExt::ThreadInfo) * Input->ThreadCount));
|
||||
|
||||
Temp->ProcessID = CurrentProc->p_pid;
|
||||
Temp->Attached = ((CurrentProc->p_flag & 0x800) != 0);
|
||||
Temp->Signal = CurrentProc->p_sig;
|
||||
Temp->Code = CurrentProc->p_code;
|
||||
Temp->Stops = CurrentProc->p_stops;
|
||||
Temp->StopType = CurrentProc->p_stype;
|
||||
strcpy(Temp->ProcName, CurrentProc->p_comm);
|
||||
strcpy(Temp->TitleID, CurrentProc->titleId);
|
||||
strcpy(Temp->RandomizedPath, CurrentProc->p_elfpath);
|
||||
strcpy(Temp->RandomizedPath, CurrentProc->p_randomized_path);
|
||||
Temp->TextSegmentBase = (uint64_t)CurrentProc->p_vmspace->vm_taddr;
|
||||
Temp->TextSegmentLen = (uint64_t)(CurrentProc->p_vmspace->vm_tsize * PAGE_SIZE);
|
||||
Temp->DataSegmentBase = (uint64_t)CurrentProc->p_vmspace->vm_daddr;
|
||||
Temp->DataSegmentLen = (uint64_t)(CurrentProc->p_vmspace->vm_dsize * PAGE_SIZE);
|
||||
|
||||
//TODO: Threads...
|
||||
thread* CurrentThread = CurrentProc->p_threads.tqh_first;
|
||||
for (Temp->ThreadCount = 0; (Temp->ThreadCount < Input->ThreadCount) && CurrentThread != nullptr; Temp->ThreadCount++)
|
||||
{
|
||||
Temp->Threads[Temp->ThreadCount].ThreadId = CurrentThread->td_tid;
|
||||
strcpy(Temp->Threads[Temp->ThreadCount].Name, CurrentThread->td_name);
|
||||
Temp->Threads[Temp->ThreadCount].Errno = CurrentThread->td_errno;
|
||||
Temp->Threads[Temp->ThreadCount].RetVal = CurrentThread->td_retval[0];
|
||||
|
||||
CurrentThread = CurrentThread->td_plist.tqe_next;
|
||||
}
|
||||
|
||||
WriteProcessMemory(td->td_proc, (void*)Input->UserlandAddr, Temp, Input->UserlandSize);
|
||||
|
||||
kfree(Temp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::GetProccessModuleList(caddr_t data, thread* td)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Input = (KDriver_ModuleList*)data;
|
||||
|
||||
proc* CurrentProc = FindProcessByPID(Input->ProcessID);
|
||||
|
||||
if(CurrentProc == nullptr)
|
||||
{
|
||||
klog("Failed to find Process with the pid %i\n", Input->ProcessID);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Temp = (ModuleInfo*)kmalloc(sizeof(ModuleInfo) * Input->ModuleCount);
|
||||
|
||||
int ModuleCount = 0;
|
||||
auto CurrentModule = CurrentProc->p_dynlibptr->p_dynlib;
|
||||
while(CurrentModule != 0)
|
||||
{
|
||||
Temp[ModuleCount].Handle = CurrentModule->ModuleHandle;
|
||||
strcpy(Temp[ModuleCount].Name, (char*)basename(CurrentModule->ModulePath));
|
||||
strcpy(Temp[ModuleCount].Path, (char*)CurrentModule->ModulePath);
|
||||
Temp[ModuleCount].TextSegmentBase = (uint64_t)CurrentModule->codeBase;
|
||||
Temp[ModuleCount].TextSegmentLen = CurrentModule->codeSize;
|
||||
Temp[ModuleCount].DataSegmentBase = (uint64_t)CurrentModule->dataBase;
|
||||
Temp[ModuleCount].DataSegmentLen = CurrentModule->dataSize;
|
||||
|
||||
ModuleCount ++;
|
||||
CurrentModule = CurrentModule->dynlib_next;
|
||||
}
|
||||
|
||||
WriteProcessMemory(td->td_proc, (void*)Input->UserlandAddr, Temp, Input->UserlandSize);
|
||||
|
||||
kfree(Temp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::ProcessReadWrite(caddr_t data, thread* td)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Input = (KDriver_ReadWriteMemory*)data;
|
||||
|
||||
proc* CurrentProc = FindProcessByPID(Input->ProcessID);
|
||||
|
||||
if(CurrentProc == nullptr)
|
||||
{
|
||||
klog("Failed to find Process with the pid %i\n", Input->ProcessID);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
// TODO: Error handling.
|
||||
if (Input->IsRead)
|
||||
{
|
||||
auto Temp = (char*)kmalloc(Input->Length);
|
||||
|
||||
ReadProcessMemory(CurrentProc, (void*)Input->ProcessAddress, Temp, Input->Length);
|
||||
WriteProcessMemory(td->td_proc, (void*)Input->UserlandAddr, Temp, Input->Length);
|
||||
|
||||
kfree(Temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto Temp = (char*)kmalloc(Input->Length);
|
||||
|
||||
ReadProcessMemory(td->td_proc, (void*)Input->UserlandAddr, Temp, Input->Length);
|
||||
WriteProcessMemory(CurrentProc, (void*)Input->ProcessAddress, Temp, Input->Length);
|
||||
|
||||
kfree(Temp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::ProcessAlloc(caddr_t data, thread* td)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::ProcessFree(caddr_t data)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::ProcessSPRX(caddr_t data)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
auto Input = (KDriver_ProcSPRX*)data;
|
||||
|
||||
klog("DoSwitch");
|
||||
switch (Input->CallType)
|
||||
{
|
||||
case 0:
|
||||
LoadSPRX(Input->ProcName, Input->Path, Input->CallEntryExit);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
UnloadSPRX(Input->ProcName, Input->Path, Input->CallEntryExit);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
UnloadSPRX(Input->ProcName, Input->Handle, Input->CallEntryExit);
|
||||
break;
|
||||
|
||||
default:
|
||||
klog("ProcessSPRX: Invalid CallType %d.", Input->CallType);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Proc::ProcessELF(caddr_t data, thread* td)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
klog("Data pointer invalid...");
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
class Proc
|
||||
{
|
||||
private:
|
||||
static int GetProccessList(caddr_t data, thread* td);
|
||||
static int GetProccessInfo(caddr_t data, thread* td);
|
||||
static int GetProccessModuleList(caddr_t data, thread* td);
|
||||
static int ProcessReadWrite(caddr_t data, thread* td);
|
||||
static int ProcessAlloc(caddr_t data, thread* td);
|
||||
static int ProcessFree(caddr_t data);
|
||||
static int ProcessSPRX(caddr_t data);
|
||||
static int ProcessELF(caddr_t data, thread* td);
|
||||
|
||||
public:
|
||||
static int OnIoctl(cdev* dev, unsigned long cmd, caddr_t data, int fflag, thread* td);
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "../Common.hpp"
|
||||
#include "OrbisLib.hpp"
|
||||
#include "../Util/ShellCode/SPRXShellCode.hpp"
|
||||
#include "../Util/System.hpp"
|
||||
|
||||
void OrbisLib::OrbisLibKernelEntry(void* arg)
|
||||
{
|
||||
auto OrbisLibInstance = (OrbisLib*)arg;
|
||||
|
||||
proc_Jailbreak(curthread()->td_proc, &OrbisLibInstance->BackupJail);
|
||||
|
||||
//LoadSPRX("SceShellUI", "/data/Orbis Toolbox/Orbis Toolbox.sprx");
|
||||
|
||||
// Set up Kernel Instances...
|
||||
OrbisLibInstance->KDriverInstance = new KDriver();
|
||||
|
||||
// Block to keep alive.
|
||||
while(OrbisLibInstance->ShouldRun)
|
||||
{
|
||||
kthread_suspend_check();
|
||||
Sleep(100);
|
||||
}
|
||||
|
||||
kproc_exit(0);
|
||||
}
|
||||
|
||||
OrbisLib::OrbisLib()
|
||||
{
|
||||
// Set Initial Vars.
|
||||
ShouldRun = true;
|
||||
|
||||
// Start up Kernel Process.
|
||||
KprocInstance = new kproc(OrbisLibKernelEntry, this, "OrbisSuite Kernel", "ORBS00001", 0, 0);
|
||||
|
||||
// Register Events.
|
||||
SystemSuspendEvent = EVENTHANDLER_REGISTER(system_suspend_phase1, (void*)OnSystemSuspend, nullptr, EVENTHANDLER_PRI_FIRST);
|
||||
SystemResumeEvent = EVENTHANDLER_REGISTER(system_resume_phase1, (void*)OnSystemResume, nullptr, EVENTHANDLER_PRI_FIRST);
|
||||
ProcessStartEvent = EVENTHANDLER_REGISTER(process_exec_end, (void*)OnProcessStart, nullptr, EVENTHANDLER_PRI_ANY);
|
||||
ProcessExitEvent = EVENTHANDLER_REGISTER(process_exit, (void*)OnProcessExit, nullptr, EVENTHANDLER_PRI_ANY);
|
||||
|
||||
// Do the thing.
|
||||
DoShellUIMount(FindProcessByName("SceShellUI"), true);
|
||||
}
|
||||
|
||||
OrbisLib::~OrbisLib()
|
||||
{
|
||||
// Teardown Kernel Process.
|
||||
ShouldRun = false;
|
||||
|
||||
// De-Register Events.
|
||||
EVENTHANDLER_DEREGISTER(system_suspend_phase1, SystemSuspendEvent);
|
||||
EVENTHANDLER_DEREGISTER(system_resume_phase1, SystemResumeEvent);
|
||||
EVENTHANDLER_DEREGISTER(process_exec_end, ProcessStartEvent);
|
||||
EVENTHANDLER_DEREGISTER(process_exit, ProcessExitEvent);
|
||||
|
||||
// Clean up.
|
||||
delete KDriverInstance;
|
||||
}
|
||||
|
||||
void OrbisLib::OnSystemSuspend(void* arg)
|
||||
{
|
||||
klog("System is Suspending...");
|
||||
|
||||
}
|
||||
|
||||
void OrbisLib::OnSystemResume(void* arg)
|
||||
{
|
||||
klog("System is Resuming...");
|
||||
|
||||
}
|
||||
|
||||
void OrbisLib::OnProcessStart(void *arg, struct proc *p)
|
||||
{
|
||||
if(!p)
|
||||
return;
|
||||
|
||||
klog("OnProcessStart: %s(%s)", p->p_comm, p->titleId);
|
||||
|
||||
DoShellUIMount(p, true);
|
||||
}
|
||||
|
||||
void OrbisLib::OnProcessExit(void *arg, struct proc *p)
|
||||
{
|
||||
if(!p)
|
||||
return;
|
||||
|
||||
klog("OnProcessExit: %s(%s)", p->p_comm, p->titleId);
|
||||
|
||||
DoShellUIMount(p, false);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#include "../Common.hpp"
|
||||
#include "../Util/kproc.hpp"
|
||||
#include "../Util/Proc.hpp"
|
||||
|
||||
class kproc;
|
||||
class KDriver;
|
||||
|
||||
class OrbisLib
|
||||
{
|
||||
private:
|
||||
eventhandler_entry* SystemSuspendEvent;
|
||||
eventhandler_entry* SystemResumeEvent;
|
||||
eventhandler_entry* ProcessStartEvent;
|
||||
eventhandler_entry* ProcessExitEvent;
|
||||
Backup_Jail BackupJail;
|
||||
bool ShouldRun;
|
||||
|
||||
static void OrbisLibKernelEntry(void* arg);
|
||||
|
||||
static void OnSystemSuspend(void* arg);
|
||||
static void OnSystemResume(void* arg);
|
||||
static void OnProcessStart(void *arg, struct proc *p);
|
||||
static void OnProcessExit(void *arg, struct proc *p);
|
||||
|
||||
public:
|
||||
kproc* KprocInstance;
|
||||
KDriver* KDriverInstance;
|
||||
|
||||
OrbisLib();
|
||||
~OrbisLib();
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
#include "../Common.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern thread* curthread();
|
||||
extern uint64_t Readmsr(int Reg);
|
||||
extern void cpu_enable_wp();
|
||||
extern void cpu_disable_wp();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
.intel_syntax noprefix
|
||||
.text
|
||||
|
||||
.global curthread
|
||||
.global Readmsr
|
||||
.global cpu_enable_wp
|
||||
.global cpu_disable_wp
|
||||
|
||||
curthread:
|
||||
mov rax, gs:0
|
||||
ret
|
||||
|
||||
Readmsr:
|
||||
mov ecx, edi
|
||||
rdmsr
|
||||
shl rdx, 32
|
||||
or rax, rdx
|
||||
ret
|
||||
|
||||
cpu_enable_wp:
|
||||
mov rax, cr0
|
||||
or rax, 0x10000
|
||||
mov cr0, rax
|
||||
ret
|
||||
|
||||
cpu_disable_wp:
|
||||
mov rax, cr0
|
||||
and rax, ~0x10000
|
||||
mov cr0, rax
|
||||
ret
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "../Common.hpp"
|
||||
#include "Heap.hpp"
|
||||
|
||||
void* kmalloc(long unsigned int size) {
|
||||
return malloc(size, M_TEMP, 2);
|
||||
}
|
||||
|
||||
void kfree(void* addr)
|
||||
{
|
||||
if (addr == nullptr)
|
||||
return;
|
||||
|
||||
free(addr, M_TEMP);
|
||||
}
|
||||
|
||||
void* operator new(long unsigned int size)
|
||||
{
|
||||
if (size == 0)
|
||||
return nullptr;
|
||||
|
||||
return malloc(size, M_TEMP, M_ZERO | M_NOWAIT);
|
||||
}
|
||||
|
||||
void* operator new(long unsigned int size, void * addr)
|
||||
{
|
||||
return addr;
|
||||
}
|
||||
|
||||
void* operator new[] (long unsigned int size)
|
||||
{
|
||||
return ::operator new(size);
|
||||
}
|
||||
|
||||
void operator delete(void* addr) noexcept
|
||||
{
|
||||
if (addr == nullptr)
|
||||
return;
|
||||
|
||||
free(addr, M_TEMP);
|
||||
}
|
||||
|
||||
void operator delete[](void* addr) noexcept
|
||||
{
|
||||
::operator delete(addr);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
void* kmalloc(long unsigned int size);
|
||||
void kfree(void* addr);
|
||||
void* operator new(long unsigned int size);
|
||||
void* operator new(long unsigned int size, void * addr);
|
||||
void* operator new[] (long unsigned int size);
|
||||
void operator delete(void* addr) noexcept;
|
||||
void operator delete[](void* addr) noexcept;
|
||||
@@ -0,0 +1,128 @@
|
||||
#include "../Common.hpp"
|
||||
#include "Kernel.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/sysent.h>
|
||||
#include <sys/pcpu.h>
|
||||
#include <sys/proc.h>
|
||||
#include <vm/vm.h>
|
||||
|
||||
#include <sys/_iovec.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
}
|
||||
|
||||
|
||||
#ifndef MAP_FAILED
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
#endif
|
||||
|
||||
int kern_errorno = 0;
|
||||
|
||||
int ksetuid(uid_t uid, thread* td)
|
||||
{
|
||||
setuid_args uap;
|
||||
sysent* sysents = sysvec->sv_table;
|
||||
auto sys_setuid = (int(*)(thread*, setuid_args*))sysents[23].sy_call;
|
||||
|
||||
// clear errors
|
||||
td->td_retval[0] = 0;
|
||||
|
||||
// Set up Params
|
||||
uap.uid = uid;
|
||||
|
||||
// Call System call
|
||||
kern_errorno = sys_setuid(td, &uap);
|
||||
if(kern_errorno)
|
||||
return -kern_errorno;
|
||||
|
||||
// success
|
||||
return td->td_retval[0];
|
||||
}
|
||||
|
||||
void klog(char* fmt, ...)
|
||||
{
|
||||
char Buffer[0x2000];
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsprintf(Buffer, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
kprintf("%s\n", Buffer);
|
||||
}
|
||||
|
||||
caddr_t kmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos, struct thread* td)
|
||||
{
|
||||
struct mmap_args uap;
|
||||
sysent* sysents = sysvec->sv_table;
|
||||
auto sys_mmap = (int(*)(thread*, mmap_args*))sysents[477].sy_call;
|
||||
if (!sys_mmap)
|
||||
return (caddr_t)-1;
|
||||
|
||||
// clear errors
|
||||
td->td_retval[0] = 0;
|
||||
|
||||
// Set up Params
|
||||
uap.addr = addr;
|
||||
uap.len = len;
|
||||
uap.prot = prot;
|
||||
uap.flags = flags;
|
||||
uap.fd = fd;
|
||||
uap.pos = pos;
|
||||
|
||||
// Call System call
|
||||
kern_errorno = sys_mmap(td, &uap);
|
||||
if(kern_errorno)
|
||||
return (caddr_t)-kern_errorno;
|
||||
|
||||
// success
|
||||
return (caddr_t)td->td_retval[0];
|
||||
}
|
||||
|
||||
int kmunmap(void *addr, size_t len, struct thread* td)
|
||||
{
|
||||
munmap_args uap;
|
||||
sysent* sysents = sysvec->sv_table;
|
||||
auto sys_munmap = (int(*)(thread*, munmap_args*))sysents[73].sy_call;
|
||||
|
||||
// clear errors
|
||||
td->td_retval[0] = 0;
|
||||
|
||||
// Set up Params
|
||||
uap.addr = addr;
|
||||
uap.len = len;
|
||||
|
||||
// Call System call
|
||||
kern_errorno = sys_munmap(td, &uap);
|
||||
if(kern_errorno)
|
||||
return -kern_errorno;
|
||||
|
||||
// success
|
||||
return td->td_retval[0];
|
||||
}
|
||||
|
||||
int kunmount(const char* path, int flags, struct thread* td)
|
||||
{
|
||||
unmount_args uap;
|
||||
sysent* sysents = sysvec->sv_table;
|
||||
auto sys_unmount = (int(*)(thread*, unmount_args*))sysents[22].sy_call;
|
||||
|
||||
// clear errors
|
||||
td->td_retval[0] = 0;
|
||||
|
||||
// Set up Params
|
||||
uap.path = (char*)path;
|
||||
uap.flags = flags;
|
||||
|
||||
// Call System call
|
||||
kern_errorno = sys_unmount(td, &uap);
|
||||
if(kern_errorno)
|
||||
return -kern_errorno;
|
||||
|
||||
// success
|
||||
return td->td_retval[0];
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "../Common.hpp"
|
||||
|
||||
int ksetuid(uid_t uid, thread* td);
|
||||
void klog(char* fmt, ...);
|
||||
|
||||
caddr_t kmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos, struct thread* td);
|
||||
int kmunmap(void *addr, size_t len, struct thread* td);
|
||||
int kunmount(const char* path, int flags, struct thread* td);
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "../Resolver/Resolver.hpp"
|
||||
#include "Patches.hpp"
|
||||
|
||||
void Install_505()
|
||||
{
|
||||
uint8_t *kmem;
|
||||
|
||||
// Verbose Panics
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00171627];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x65;
|
||||
kmem[6] = 0x8B;
|
||||
kmem[7] = 0x34;
|
||||
|
||||
// Enable rwx mapping
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000FCD48];
|
||||
kmem[0] = 0x07;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000FCD56];
|
||||
kmem[0] = 0x07;
|
||||
|
||||
// Patch copyin/copyout to allow userland + kernel addresses in both params
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EA767];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EA682];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
// Patch copyinstr
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EAB93];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EABC3];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
// Patch memcpy stack
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EA53D];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// Enable *all* debugging logs (in vprintf)
|
||||
// Patch by: SiSTRo
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0043612A];
|
||||
kmem[0] = 0xEB;
|
||||
kmem[1] = 0x38;
|
||||
|
||||
// patch suword_lwpid
|
||||
// has a check to see if child_tid/parent_tid is in kernel memory, and it in so patch it
|
||||
// Patch by: JOGolden
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EA9D2];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001EA9E1];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
// Patch to remove vm_fault: fault on nofault entry, addr %llx
|
||||
kmem = (uint8_t *)&gpKernelBase[0x002A4EB3];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "../Resolver/Resolver.hpp"
|
||||
#include "Patches.hpp"
|
||||
|
||||
void Install_672()
|
||||
{
|
||||
uint8_t *kmem;
|
||||
|
||||
// Patch dynlib_dlsym
|
||||
kmem = (uint8_t*)&gpKernelBase[0x1D895A];
|
||||
kmem[0] = 0xE9;
|
||||
kmem[1] = 0xC7;
|
||||
kmem[2] = 0x01;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
|
||||
// Patch a function called by dynlib_dlsym
|
||||
kmem = (uint8_t*)&gpKernelBase[0x0041A2D0];
|
||||
kmem[0] = 0x31; // xor eax, eax
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0xC3; // ret
|
||||
|
||||
// Patch sys_mmap
|
||||
kmem = (uint8_t*)&gpKernelBase[0x000AB57A];
|
||||
kmem[0] = 0x37; // mov [rbp+var_61], 33h ; '3'
|
||||
kmem[3] = 0x37; // mov sil, 33h ; '3'
|
||||
|
||||
// patch sys_setuid
|
||||
kmem = (uint8_t*)&gpKernelBase[0x0010BED0]; // call priv_check_cred; overwrite with mov eax, 0
|
||||
kmem[0] = 0xB8; // mov eax, 0
|
||||
kmem[1] = 0x00;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
|
||||
// patch sys_mprotect
|
||||
kmem = (uint8_t*)&gpKernelBase[0x00451DB8]; // jnz loc_FFFFFFFF82652426; nop it out
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// Enable rwx mapping in kmem_alloc
|
||||
kmem = (uint8_t *)&gpKernelBase[0x002507F5];
|
||||
kmem[0] = 0x07; // set maxprot to RWX
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00250803];
|
||||
kmem[0] = 0x07; // set maxprot to RWX
|
||||
|
||||
// Patch copyin/copyout to allow userland + kernel addresses in both params
|
||||
// copyin
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C17F7];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C1803];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// copyout
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C1702];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C170E];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// Enable MAP_SELF
|
||||
|
||||
// Patches: sceSblACMgrHasMmapSelfCapability
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00233C40];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
// Patches: sceSblACMgrIsAllowedToMmapSelf
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00233C50];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
// Patches: call sceSblAuthMgrIsLoadable in vm_mmap2 (right above the only call to allowed to mmap self)
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000AD2E4]; // xor eax, eax; nop; nop;
|
||||
kmem[0] = 0x31;
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// Patch copyinstr
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C1CA3];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C1CAF];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// Patch memcpy stack
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003C15BD];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// ptrace patches
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0010F879];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// Enable debug rif's
|
||||
kmem = (uint8_t*)&gpKernelBase[0x66AEB0];
|
||||
kmem[0] = 0xB0;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0xC3;
|
||||
kmem[3] = 0x90;
|
||||
|
||||
// Enable debug rifs 2
|
||||
kmem = (uint8_t*)&gpKernelBase[0x66AEE0];
|
||||
kmem[0] = 0xB0;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0xC3;
|
||||
kmem[3] = 0x90;
|
||||
|
||||
// Disable pfs checks
|
||||
kmem = (uint8_t*)&gpKernelBase[0x6A8EB0];
|
||||
kmem[0] = 0x31;
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0xC3;
|
||||
kmem[3] = 0x90;
|
||||
|
||||
// Enable *all* debugging logs (in vprintf)
|
||||
// Patch by: SiSTRo
|
||||
kmem = (uint8_t*)&gpKernelBase[0x00123367];
|
||||
kmem[0] = 0xEB; // jmp +0x3D
|
||||
kmem[1] = 0x3B;
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "../Resolver/Resolver.hpp"
|
||||
#include "Patches.hpp"
|
||||
|
||||
void Install_702()
|
||||
{
|
||||
// Use "kmem" for all patches
|
||||
uint8_t *kmem;
|
||||
|
||||
// Enable UART
|
||||
kmem = (uint8_t *)&gpKernelBase[0x01A6EAA0];
|
||||
kmem[0] = 0x00;
|
||||
|
||||
// Verbose Panics
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0013A4AE];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// sceSblACMgrIsAllowedSystemLevelDebugging
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001CB060];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001CB880];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001CB8A0];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
// Enable rwx mapping
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001171BE];
|
||||
kmem[0] = 0x07;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001171C6];
|
||||
kmem[0] = 0x07;
|
||||
|
||||
// Patch copyin/copyout: Allow userland + kernel addresses in both params
|
||||
// copyin
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F287];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F293];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// copyout
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F192];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F19E];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// Enable MAP_SELF
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001CB8F0];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001CB910];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001D40BB];
|
||||
kmem[0] = 0x31;
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// Patch copyinstr
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F733];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F73F];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// Patch memcpy stack
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F04D];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// ptrace patches
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000448D5];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// second ptrace patch
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00044DAF];
|
||||
kmem[0] = 0xE9;
|
||||
kmem[1] = 0x7C;
|
||||
kmem[2] = 0x02;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
|
||||
// setlogin patch (for autolaunch check)
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0008A8EC];
|
||||
kmem[0] = 0x48;
|
||||
kmem[1] = 0x31;
|
||||
kmem[2] = 0xC0;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// Patch to remove vm_fault: fault on nofault entry, addr %llx
|
||||
kmem = (uint8_t *)&gpKernelBase[0x002BF756];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// Patch mprotect: Allow RWX (mprotect) mapping
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00264C08];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// flatz disable pfs signature check
|
||||
kmem = (uint8_t *)&gpKernelBase[0x006BE880];
|
||||
kmem[0] = 0x31;
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0xC3;
|
||||
|
||||
// flatz enable debug RIFs
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00668270];
|
||||
kmem[0] = 0xB0;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x006682A0];
|
||||
kmem[0] = 0xB0;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0xC3;
|
||||
|
||||
// Enable *all* debugging logs (in vprintf)
|
||||
// Patch by: SiSTRo
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000BC817];
|
||||
kmem[0] = 0xEB;
|
||||
kmem[1] = 0x3B;
|
||||
|
||||
// flatz allow mangled symbol in dynlib_do_dlsym
|
||||
kmem = (uint8_t *)&gpKernelBase[0x002F0367];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// Enable mount for unprivileged user
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0029636A];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// patch suword_lwpid
|
||||
// has a check to see if child_tid/parent_tid is in kernel memory, and it in so patch it
|
||||
// Patch by: JOGolden
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F552];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0002F561];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
// Patch debug setting errors
|
||||
kmem = (uint8_t *)&gpKernelBase[0x005016FA];
|
||||
kmem[0] = 0x00;
|
||||
kmem[1] = 0x00;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0050296C];
|
||||
kmem[0] = 0x00;
|
||||
kmem[1] = 0x00;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "../Resolver/Resolver.hpp"
|
||||
#include "Patches.hpp"
|
||||
|
||||
void Install_755()
|
||||
{
|
||||
// Use "kmem" for all patches
|
||||
uint8_t *kmem;
|
||||
|
||||
// Enable UART
|
||||
kmem = (uint8_t *)&gpKernelBase[0x01564910];
|
||||
kmem[0] = 0x00;
|
||||
|
||||
// Verbose Panics
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0046D11E];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// sceSblACMgrIsAllowedSystemLevelDebugging
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003644B0];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00364CD0];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00364CF0];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
// Enable rwx mapping
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001754AC];
|
||||
kmem[0] = 0x07;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x001754B4];
|
||||
kmem[0] = 0x07;
|
||||
|
||||
// Patch copyin/copyout: Allow userland + kernel addresses in both params
|
||||
// copyin
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028FA47];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028FA53];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// copyout
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028F952];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028F95E];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// Enable MAP_SELF
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00364D40];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00364D60];
|
||||
kmem[0] = 0xB8;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
kmem[5] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000DCED1];
|
||||
kmem[0] = 0x31;
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// Patch copyinstr
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028FEF3];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028FEFF];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
|
||||
// Patch memcpy stack
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028F80D];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// ptrace patches
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00361CF5];
|
||||
kmem[0] = 0xEB;
|
||||
|
||||
// second ptrace patch
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003621CF];
|
||||
kmem[0] = 0xE9;
|
||||
kmem[1] = 0x7C;
|
||||
kmem[2] = 0x02;
|
||||
kmem[3] = 0x00;
|
||||
kmem[4] = 0x00;
|
||||
|
||||
// setlogin patch (for autolaunch check)
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0037CF6C];
|
||||
kmem[0] = 0x48;
|
||||
kmem[1] = 0x31;
|
||||
kmem[2] = 0xC0;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
|
||||
// Patch to remove vm_fault: fault on nofault entry, addr %llx
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003DF2A6];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// Patch mprotect: Allow RWX (mprotect) mapping
|
||||
kmem = (uint8_t *)&gpKernelBase[0x003014C8];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// flatz disable pfs signature check
|
||||
kmem = (uint8_t *)&gpKernelBase[0x006DD9A0];
|
||||
kmem[0] = 0x31;
|
||||
kmem[1] = 0xC0;
|
||||
kmem[2] = 0xC3;
|
||||
|
||||
// flatz enable debug RIFs
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00668140];
|
||||
kmem[0] = 0xB0;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0xC3;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00668170];
|
||||
kmem[0] = 0xB0;
|
||||
kmem[1] = 0x01;
|
||||
kmem[2] = 0xC3;
|
||||
|
||||
// Enable *all* debugging logs (in vprintf)
|
||||
// Patch by: SiSTRo
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0026F827];
|
||||
kmem[0] = 0xEB;
|
||||
kmem[1] = 0x3B;
|
||||
|
||||
// flatz allow mangled symbol in dynlib_do_dlsym
|
||||
kmem = (uint8_t *)&gpKernelBase[0x000271A7];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// Enable mount for unprivileged user
|
||||
kmem = (uint8_t *)&gpKernelBase[0x00076385];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
kmem[2] = 0x90;
|
||||
kmem[3] = 0x90;
|
||||
kmem[4] = 0x90;
|
||||
kmem[5] = 0x90;
|
||||
|
||||
// patch suword_lwpid
|
||||
// has a check to see if child_tid/parent_tid is in kernel memory, and it in so patch it
|
||||
// Patch by: JOGolden
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028FD12];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0028FD21];
|
||||
kmem[0] = 0x90;
|
||||
kmem[1] = 0x90;
|
||||
|
||||
// Patch debug setting errors
|
||||
kmem = (uint8_t *)&gpKernelBase[0x004FF322];
|
||||
kmem[0] = 0x00;
|
||||
kmem[1] = 0x00;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
|
||||
kmem = (uint8_t *)&gpKernelBase[0x0050059C];
|
||||
kmem[0] = 0x00;
|
||||
kmem[1] = 0x00;
|
||||
kmem[2] = 0x00;
|
||||
kmem[3] = 0x00;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "../Resolver/Resolver.hpp"
|
||||
#include "Patches.hpp"
|
||||
|
||||
void Install_900()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "Patches.hpp"
|
||||
#include "../Resolver/Resolver.hpp"
|
||||
|
||||
//
|
||||
// Credits to Mira for the patches. Was just easier to slap them in :P
|
||||
//
|
||||
|
||||
void Install_Patches()
|
||||
{
|
||||
if(!gpKernelBase)
|
||||
return;
|
||||
|
||||
klog("Disable WP");
|
||||
cpu_disable_wp();
|
||||
|
||||
#if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA)
|
||||
klog("Patches 5.05");
|
||||
Install_505();
|
||||
#elif defined(SOFTWARE_VERSION_672)
|
||||
Install_672();
|
||||
#elif defined(SOFTWARE_VERSION_702)
|
||||
Install_702();
|
||||
#elif defined(SOFTWARE_VERSION_755)
|
||||
Install_755();
|
||||
#elif defined(SOFTWARE_VERSION_900)
|
||||
Install_900();
|
||||
#endif
|
||||
|
||||
klog("Enable WP");
|
||||
cpu_enable_wp();
|
||||
|
||||
klog("Install_Patches() -> Sucess!");
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
void Install_505();
|
||||
void Install_672();
|
||||
void Install_702();
|
||||
void Install_755();
|
||||
void Install_900();
|
||||
void Install_Patches();
|
||||
@@ -0,0 +1,248 @@
|
||||
#include "../Common.hpp"
|
||||
#include "Proc.hpp"
|
||||
|
||||
proc* GetCurrentGame()
|
||||
{
|
||||
proc *allproc = *(proc**)allproc;
|
||||
char TitleID[10];
|
||||
strcpy(TitleID, "N/A");
|
||||
|
||||
while (allproc != NULL)
|
||||
{
|
||||
if(strstr(allproc->titleId, "CUSA"))
|
||||
break;
|
||||
|
||||
allproc = allproc->p_list.le_next;
|
||||
}
|
||||
|
||||
return allproc;
|
||||
}
|
||||
|
||||
int get_proc_count()
|
||||
{
|
||||
int count = 0;
|
||||
proc *p = *(proc**)allproc;
|
||||
|
||||
do {
|
||||
count++;
|
||||
} while ((p = p->p_list.le_next));
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
proc *proc_find_by_name(const char *name)
|
||||
{
|
||||
if (!name) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
proc *p = *(proc**)allproc;
|
||||
|
||||
do {
|
||||
//klog("%s\n", p->p_comm);
|
||||
if (!memcmp(p->p_comm, name, strlen(name))) {
|
||||
return p;
|
||||
}
|
||||
} while ((p = p->p_list.le_next));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
proc *proc_find_by_pid(int pid)
|
||||
{
|
||||
proc *p = *(proc**)allproc;
|
||||
|
||||
do {
|
||||
if (p->p_pid == pid) {
|
||||
return p;
|
||||
}
|
||||
} while ((p = p->p_list.le_next));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int proc_rw_mem(proc *p, void *ptr, size_t size, void *data, size_t *n, int write)
|
||||
{
|
||||
thread *td = curthread();
|
||||
iovec iov;
|
||||
uio uio;
|
||||
int r = 0;
|
||||
|
||||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (size == 0) {
|
||||
if (n) {
|
||||
*n = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&iov, NULL, sizeof(iov));
|
||||
iov.iov_base = (void*)data;
|
||||
iov.iov_len = size;
|
||||
|
||||
memset(&uio, NULL, sizeof(uio));
|
||||
uio.uio_iov = &iov;
|
||||
uio.uio_iovcnt = 1;
|
||||
uio.uio_offset = (uint64_t)ptr;
|
||||
uio.uio_resid = (uint64_t)size;
|
||||
uio.uio_segflg = UIO_SYSSPACE;
|
||||
uio.uio_rw = write ? UIO_WRITE : UIO_READ;
|
||||
uio.uio_td = td;
|
||||
|
||||
r = proc_rwmem(p, &uio);
|
||||
|
||||
if (n) {
|
||||
*n = (size_t)((uint64_t)size - uio.uio_resid);
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int proc_read_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n)
|
||||
{
|
||||
return proc_rw_mem(p, ptr, size, data, n, 0);
|
||||
}
|
||||
|
||||
int proc_write_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n)
|
||||
{
|
||||
return proc_rw_mem(p, ptr, size, data, n, 1);
|
||||
}
|
||||
|
||||
int proc_allocate(struct proc *p, void **address, size_t size) {
|
||||
uint64_t addr = NULL;
|
||||
int r = 0;
|
||||
|
||||
if (!address)
|
||||
return 1;
|
||||
|
||||
vmspace *vm = p->p_vmspace;
|
||||
vm_map *map = &vm->vm_map;
|
||||
|
||||
vm_map_lock(map, __FILE__, __LINE__);
|
||||
|
||||
r = vm_map_findspace(map, NULL, size, &addr);
|
||||
if (r) {
|
||||
vm_map_unlock(map);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = vm_map_insert(map, NULL, NULL, addr, addr + size, VM_PROT_ALL, VM_PROT_ALL, 0);
|
||||
|
||||
vm_map_unlock(map);
|
||||
|
||||
if (r)
|
||||
return r;
|
||||
|
||||
if (address) {
|
||||
*address = (void *)addr;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int proc_deallocate(proc *p, void *address, size_t size) {
|
||||
int r = 0;
|
||||
|
||||
vmspace *vm = p->p_vmspace;
|
||||
vm_map *map = &vm->vm_map;
|
||||
|
||||
vm_map_lock(map, __FILE__, __LINE__);
|
||||
|
||||
r = vm_map_delete(map, (uint64_t)address, (uint64_t)address + size);
|
||||
|
||||
vm_map_unlock(map);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int proc_mprotect(proc *p, void *address, void *end, int new_prot) {
|
||||
int r = 0;
|
||||
|
||||
uint64_t addr = (uint64_t)address;
|
||||
uint64_t addrend = (uint64_t)end;
|
||||
|
||||
vmspace *vm = p->p_vmspace;
|
||||
vm_map *map = &vm->vm_map;
|
||||
|
||||
r = vm_map_protect(map, addr, addrend, new_prot, 1);
|
||||
r = vm_map_protect(map, addr, addrend, new_prot, 0);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
uint64_t proc_alloc_size(uint64_t p)
|
||||
{
|
||||
uint64_t ldrsize = p;
|
||||
ldrsize += (PAGE_SIZE - (ldrsize % PAGE_SIZE));
|
||||
return ldrsize;
|
||||
}
|
||||
|
||||
void proc_Jailbreak(proc* proc, Backup_Jail* jail)
|
||||
{
|
||||
if(proc)
|
||||
{
|
||||
ucred* cred = proc->p_ucred;
|
||||
filedesc* fd = proc->p_fd;
|
||||
|
||||
if(!cred || !fd)
|
||||
return;
|
||||
|
||||
if(jail)
|
||||
{
|
||||
jail->cr_prison = cred->cr_prison;
|
||||
jail->cr_uid = cred->cr_uid;
|
||||
jail->cr_ruid = cred->cr_ruid;
|
||||
jail->cr_rgid = cred->cr_rgid;
|
||||
jail->cr_groups = cred->cr_groups[0];
|
||||
|
||||
jail->fd_jdir = fd->fd_jdir;
|
||||
jail->fd_rdir = fd->fd_rdir;
|
||||
}
|
||||
|
||||
cred->cr_prison = *(prison**)prison0;
|
||||
|
||||
cred->cr_uid = 0;
|
||||
cred->cr_ruid = 0;
|
||||
cred->cr_rgid = 0;
|
||||
cred->cr_groups[0] = 0;
|
||||
|
||||
/*thread* Cur = proc->p_threads.tqh_first;
|
||||
while(Cur != nullptr)
|
||||
{
|
||||
Cur->td_ucred->cr_sceAuthID = 0x3801000000000013;
|
||||
Cur->td_ucred->cr_sceCaps[0] = 0xffffffffffffffff;
|
||||
Cur->td_ucred->cr_sceCaps[1] = 0xffffffffffffffff;
|
||||
Cur = Cur->td_plist.tqe_next;
|
||||
}*/
|
||||
|
||||
fd->fd_jdir = *(vnode**)rootvnode;
|
||||
fd->fd_rdir = *(vnode**)rootvnode;
|
||||
}
|
||||
}
|
||||
|
||||
void proc_RestoreJail(proc* proc, Backup_Jail jail)
|
||||
{
|
||||
if(proc)
|
||||
{
|
||||
ucred* cred = proc->p_ucred;
|
||||
filedesc* fd = proc->p_fd;
|
||||
|
||||
if(!cred || !fd)
|
||||
return;
|
||||
|
||||
cred->cr_prison = jail.cr_prison;
|
||||
cred->cr_uid = jail.cr_uid;
|
||||
cred->cr_ruid = jail.cr_ruid;
|
||||
cred->cr_rgid = jail.cr_rgid;
|
||||
cred->cr_groups[0] = jail.cr_groups;
|
||||
|
||||
fd->fd_jdir = jail.fd_jdir;
|
||||
fd->fd_rdir = jail.fd_rdir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sys/proc.h>
|
||||
}
|
||||
|
||||
proc* GetCurrentGame();
|
||||
int get_proc_count();
|
||||
proc *proc_find_by_name(const char *name);
|
||||
proc *proc_find_by_pid(int pid);
|
||||
|
||||
int proc_rw_mem(proc *p, void *ptr, size_t size, void *data, size_t *n, int write);
|
||||
int proc_read_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n);
|
||||
int proc_write_mem(struct proc *p, void *ptr, size_t size, void *data, size_t *n);
|
||||
int proc_allocate(struct proc *p, void **address, size_t size);
|
||||
int proc_deallocate(proc *p, void *address, size_t size);
|
||||
int proc_mprotect(proc *p, void *address, void *end, int new_prot);
|
||||
uint64_t proc_alloc_size(uint64_t p);
|
||||
|
||||
struct Backup_Jail
|
||||
{
|
||||
prison* cr_prison;
|
||||
uid_t cr_uid;
|
||||
uid_t cr_ruid;
|
||||
gid_t cr_rgid;
|
||||
gid_t cr_groups;
|
||||
|
||||
vnode* fd_jdir;
|
||||
vnode* fd_rdir;
|
||||
};
|
||||
|
||||
void proc_Jailbreak(proc* proc, Backup_Jail* jail);
|
||||
void proc_RestoreJail(proc* proc, Backup_Jail jail);
|
||||
@@ -0,0 +1,139 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef SOFTWARE_VERSION_505
|
||||
|
||||
/* Util */
|
||||
#define addr_Xfast_syscall 0x1C0
|
||||
#define addr_sysvec 0x19BBCD0
|
||||
#define addr_kernel_map 0x1AC60E0
|
||||
#define addr_prison0 0x10986A0
|
||||
#define addr_rootvnode 0x22C1A70
|
||||
#define addr_copyin 0x001EA710
|
||||
#define addr_copyout 0x1EA630
|
||||
|
||||
/* STD Lib */
|
||||
#define addr_M_TEMP 0x14B4110
|
||||
#define addr_M_MOUNT 0x19BF300
|
||||
#define addr_malloc 0x10E250
|
||||
#define addr_free 0x10E460
|
||||
#define addr_memcpy 0x1EA530
|
||||
#define addr_memset 0x3205C0
|
||||
#define addr_memcmp 0x50AC0
|
||||
#define addr_strlen 0x3B71A0
|
||||
#define addr_strcpy 0x8F250
|
||||
#define addr_strncpy 0x3C0B0
|
||||
#define addr_strcmp 0x1D0FD0
|
||||
#define addr_strncmp 0x001B8FE0
|
||||
#define addr_strstr 0x17DFB0
|
||||
#define addr_sprintf 0x436280
|
||||
#define addr_snprintf 0x436350
|
||||
#define addr_vsprintf 0x436310
|
||||
#define addr_vprintf 0x4360B0
|
||||
#define addr_sscanf 0x175900
|
||||
#define addr_strdup 0x1C1C30
|
||||
#define addr_realloc 0x10E590
|
||||
#define addr_kprintf 0x436040
|
||||
|
||||
/* Kproc */
|
||||
#define addr_kproc_create 0x137DF0
|
||||
#define addr_kproc_exit 0x138060
|
||||
#define addr_kproc_resume 0x1381B0
|
||||
#define addr_kproc_shutdown 0x10DCA0
|
||||
#define addr_kproc_start 0x137D70
|
||||
#define addr_kproc_suspend 0x138110
|
||||
#define addr_kproc_suspend_check 0x138240
|
||||
#define addr_kproc_kthread_add 0x138B70
|
||||
#define addr_pause 0x3FB920
|
||||
#define addr_kthread_add 0x138360
|
||||
#define addr_kthread_exit 0x138640
|
||||
#define addr_kthread_suspend 0x0
|
||||
#define addr_kthread_suspend_check 0x138A60
|
||||
#define addr_kthread_set_affinity 0x138CC0
|
||||
|
||||
/* Module Offsets */
|
||||
#define addr_thr_initial_libkernel 0x84C20
|
||||
#define addr_thr_initial_libkernel_web 0x84C20
|
||||
#define addr_thr_initial_libkernel_sys 0x89030
|
||||
|
||||
/* Proc */
|
||||
#define addr_allproc_lock 0x02382F98
|
||||
#define addr_allproc 0x2382FF8
|
||||
#define addr_proc_kill 0xD41C0
|
||||
#define addr_proc_rwmem 0x30D150
|
||||
#define addr_create_thread 0x1BE1F0
|
||||
|
||||
/* ptrace */
|
||||
#define addr_kptrace 0x30D8E0
|
||||
#define addr_kpsignal 0xD35F0
|
||||
#define addr_kwait 0x35590
|
||||
#define addr_kDelay 0x2A1C70
|
||||
|
||||
/* Virtual Memory */
|
||||
#define addr_vmspace_acquire_ref 0x19EF90
|
||||
#define addr_vmspace_free 0x19EDC0
|
||||
#define addr_vm_map_lock_read 0x19F140
|
||||
#define addr_vm_map_unlock_read 0x19F190
|
||||
#define addr_vm_map_lookup_entry 0x19F760
|
||||
#define addr_vm_map_findspace 0x1A1F60
|
||||
#define addr_vm_map_insert 0x1A0280
|
||||
#define addr_vm_map_lock 0x19EFF0
|
||||
#define addr_vm_map_unlock 0x19F060
|
||||
#define addr_vm_map_delete 0x1A19D0
|
||||
#define addr_vm_map_protect 0x1A3A50
|
||||
|
||||
/*Mutex Locks*/
|
||||
#define addr_mtx_init 0x402780
|
||||
#define addr_mtx_destroy 0x4027F0
|
||||
#define addr_mtx_lock_flags 0x401CD0
|
||||
#define addr_mtx_unlock_flags 0x401FA0
|
||||
|
||||
#define addr__sx_slock 0x000F5C30
|
||||
#define addr__sx_sunlock 0x000F5F10
|
||||
|
||||
/* Critical Sections */
|
||||
#define addr_EnterCriticalSection 0x28E7A0
|
||||
#define addr_ExitCriticalSection 0x28E7B0
|
||||
|
||||
/* Event Handling */
|
||||
#define addr_eventhandler_register 0x1EC400
|
||||
#define addr_eventhandler_deregister 0x1EC790
|
||||
#define addr_eventhandler_find_list 0x1EC980
|
||||
|
||||
/* Trap Hooks */
|
||||
#define addr_trapHook 0x170E80
|
||||
#define addr_trap_fatalHook 0x171580
|
||||
|
||||
/* FileIO */
|
||||
#define addr_kern_open 0x33B9B0
|
||||
#define addr_kern_mkdir 0x340B70
|
||||
|
||||
/* Registry Functions */
|
||||
#define addr_sceRegMgrGetStr 0x4FA550
|
||||
#define addr_sceRegMgrSetStr 0x4FA390
|
||||
#define addr_sceRegMgrGetInt 0x4F9E50
|
||||
#define addr_sceRegMgrSetInt 0x4F8D10
|
||||
#define addr_sceRegMgrGetBin 0x4FA6D0
|
||||
#define addr_sceRegMgrSetBin 0x4FA620
|
||||
|
||||
/* Flash & NVS */
|
||||
#define addr_icc_nvs_read 0x395830
|
||||
#define addr_icc_nvs_write 0x395670
|
||||
|
||||
/* Driver */
|
||||
#define addr_make_dev_p 0x1B9810
|
||||
#define addr_destroy_dev 0x1B9D50
|
||||
|
||||
/* kmem */
|
||||
#define addr_kmem_alloc 0xFCC80
|
||||
#define addr_kmem_free 0xFCE50
|
||||
#define addr_kernel_map 0x1AC60E0
|
||||
|
||||
/* File IO */
|
||||
#define addr_vn_fullpath 0xA11A0
|
||||
#define addr_kern_rmdir 0x340EE0
|
||||
#define addr_kern_mkdir 0x340B70
|
||||
#define addr_kern_open 0x33B9B0
|
||||
#define addr_kern_mount 0x1E1920
|
||||
#define addr_mount_argf 0x1E1780
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,135 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(SOFTWARE_VERSION_672)
|
||||
|
||||
/* Util */
|
||||
#define addr_Xfast_syscall 0x1C0
|
||||
#define addr_sysvec 0x1A8A398
|
||||
#define addr_kernel_map 0x220DFC0
|
||||
#define addr_prison0 0x113E518
|
||||
#define addr_rootvnode 0x2300320
|
||||
#define addr_copyin 0x3C17A0
|
||||
#define addr_copyout 0x3C16B0
|
||||
|
||||
/* STD Lib */
|
||||
#define addr_M_TEMP 0x1540EB0
|
||||
#define addr_M_MOUNT 0x1A90CA0
|
||||
#define addr_malloc 0xD7A0
|
||||
#define addr_free 0xD9A0
|
||||
#define addr_memcpy 0x3C15B0
|
||||
#define addr_memset 0x1687D0
|
||||
#define addr_memcmp 0x207E40
|
||||
#define addr_strlen 0x2433E0
|
||||
#define addr_strcpy 0x2390C0
|
||||
#define addr_strncpy 0x329010
|
||||
#define addr_strcmp 0x341810
|
||||
#define addr_strncmp 0x39B6E0
|
||||
#define addr_strstr 0x4817F0
|
||||
#define addr_sprintf 0x1234C0
|
||||
#define addr_snprintf 0x123590
|
||||
#define addr_vsprintf 0x123550
|
||||
#define addr_vprintf 0x1232F0
|
||||
#define addr_sscanf 0x243810
|
||||
#define addr_strdup 0x2504C0
|
||||
#define addr_realloc 0xDAD0
|
||||
#define addr_kprintf 0x123280
|
||||
|
||||
/* Kproc */
|
||||
#define addr_kproc_create 0x8A0A0
|
||||
#define addr_kproc_exit 0x8A310
|
||||
#define addr_kproc_resume 0x8A460
|
||||
#define addr_kproc_shutdown 0x207670
|
||||
#define addr_kproc_start 0x8A020
|
||||
#define addr_kproc_suspend 0x8A3C0
|
||||
#define addr_kproc_suspend_check 0x8A4F0
|
||||
#define addr_kproc_kthread_add 0x8AE20
|
||||
#define addr_pause 0x22A080
|
||||
#define addr_kthread_add 0x8A600
|
||||
#define addr_kthread_exit 0x8A8F0
|
||||
#define addr_kthread_suspend 0x8AA40
|
||||
#define addr_kthread_suspend_check 0x8AD10
|
||||
#define addr_kthread_set_affinity 0x8AF70
|
||||
|
||||
/* Module Offsets */
|
||||
#define addr_thr_initial_libkernel 0x435420
|
||||
#define addr_thr_initial_libkernel_web 0x435420
|
||||
#define addr_thr_initial_libkernel_sys 0x435830
|
||||
|
||||
/* Proc */
|
||||
#define addr_allproc_lock 0x0
|
||||
#define addr_allproc 0x22BBE80
|
||||
#define addr_proc_kill 0x2DC80
|
||||
#define addr_proc_rwmem 0x10EE10
|
||||
#define addr_create_thread 0x4A6FB0
|
||||
|
||||
/* ptrace */
|
||||
#define addr_kptrace 0x10F7A0
|
||||
#define addr_kpsignal 0x1CF510
|
||||
#define addr_kwait 0x406950
|
||||
#define addr_kDelay 0x2F9DE0
|
||||
|
||||
/* Virtual Memory */
|
||||
#define addr_vmspace_acquire_ref 0x44CB90
|
||||
#define addr_vmspace_free 0x44C9C0
|
||||
#define addr_vm_map_lock_read 0x44CD40
|
||||
#define addr_vm_map_unlock_read 0x44CD90
|
||||
#define addr_vm_map_lookup_entry 0x44D330
|
||||
#define addr_vm_map_findspace 0x44FE60
|
||||
#define addr_vm_map_insert 0x44DEF0
|
||||
#define addr_vm_map_lock 0x44CBF0
|
||||
#define addr_vm_map_unlock 0x44CC60
|
||||
#define addr_vm_map_delete 0x44F8A0
|
||||
#define addr_vm_map_protect 0x451BF0
|
||||
|
||||
/*Mutex Locks*/
|
||||
#define addr_mtx_init 0x00496FE0
|
||||
#define addr_mtx_destroy 0x00497050
|
||||
#define addr_mtx_lock_flags 0x00496540
|
||||
#define addr_mtx_unlock_flags 0x00496810
|
||||
|
||||
#define addr__sx_slock 0x0
|
||||
#define addr__sx_sunlock 0x0
|
||||
|
||||
/* Critical Sections */
|
||||
#define addr_EnterCriticalSection 0x2AA0A0
|
||||
#define addr_ExitCriticalSection 0x2AA0B0
|
||||
|
||||
/* Event Handling */
|
||||
#define addr_eventhandler_register 0x402E80
|
||||
#define addr_eventhandler_deregister 0x403220
|
||||
#define addr_eventhandler_find_list 0x403420
|
||||
|
||||
/* Trap Hooks */
|
||||
#define addr_trapHook 0
|
||||
#define addr_trap_fatalHook 0x2ED2E0
|
||||
|
||||
/* Registry */
|
||||
#define addr_sceRegMgrGetStr 0x509220
|
||||
#define addr_sceRegMgrSetStr 0x509060
|
||||
#define addr_sceRegMgrGetInt 0x508A60
|
||||
#define addr_sceRegMgrSetInt 0x5077D0
|
||||
#define addr_sceRegMgrGetBin 0x5093A0
|
||||
#define addr_sceRegMgrSetBin 0x5092F0
|
||||
|
||||
/* Flash & NVS */
|
||||
#define addr_icc_nvs_read 0x464450
|
||||
#define addr_icc_nvs_write 0x464290
|
||||
|
||||
/* Driver */
|
||||
#define addr_make_dev_p 0x0
|
||||
#define addr_destroy_dev 0x0
|
||||
|
||||
/* kmem */
|
||||
#define addr_kmem_alloc 0x0
|
||||
#define addr_kmem_free 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
|
||||
/* File IO */
|
||||
#define addr_vn_fullpath 0x2F0C40
|
||||
#define addr_kern_rmdir 0x4A3DF0
|
||||
#define addr_kern_mkdir 0x4A3A80
|
||||
#define addr_kern_open 0x49E990
|
||||
#define addr_kern_mount 0x442F90
|
||||
#define addr_mount_argf 0x442DE0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(SOFTWARE_VERSION_702)
|
||||
|
||||
/* Util */
|
||||
#define addr_Xfast_syscall 0x0
|
||||
#define addr_sysvec 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
#define addr_prison0 0x0
|
||||
#define addr_rootvnode 0x0
|
||||
#define addr_copyin 0x0
|
||||
#define addr_copyout 0x0
|
||||
|
||||
/* STD Lib */
|
||||
#define addr_M_TEMP 0x0
|
||||
#define addr_M_MOUNT 0x0
|
||||
#define addr_malloc 0x0
|
||||
#define addr_free 0x0
|
||||
#define addr_memcpy 0x0
|
||||
#define addr_memset 0x0
|
||||
#define addr_memcmp 0x0
|
||||
#define addr_strlen 0x0
|
||||
#define addr_strcpy 0x0
|
||||
#define addr_strncpy 0x0
|
||||
#define addr_strcmp 0x0
|
||||
#define addr_strncmp 0x0
|
||||
#define addr_strstr 0x0
|
||||
#define addr_sprintf 0x0
|
||||
#define addr_snprintf 0x0
|
||||
#define addr_vsprintf 0x0
|
||||
#define addr_vprintf 0x0
|
||||
#define addr_sscanf 0x0
|
||||
#define addr_strdup 0x0
|
||||
#define addr_realloc 0x0
|
||||
#define addr_kprintf 0x0
|
||||
|
||||
#define addr_kmem_alloc 0x0
|
||||
|
||||
/* Kproc */
|
||||
#define addr_kproc_create 0x0
|
||||
#define addr_kproc_exit 0x0
|
||||
#define addr_kproc_resume 0x0
|
||||
#define addr_kproc_shutdown 0x0
|
||||
#define addr_kproc_start 0x0
|
||||
#define addr_kproc_suspend 0x0
|
||||
#define addr_kproc_suspend_check 0x0
|
||||
#define addr_kproc_kthread_add 0x0
|
||||
#define addr_pause 0x0
|
||||
#define addr_kthread_add 0x0
|
||||
#define addr_kthread_exit 0x0
|
||||
#define addr_kthread_suspend 0x0
|
||||
#define addr_kthread_suspend_check 0x0
|
||||
#define addr_kthread_set_affinity 0x0
|
||||
|
||||
/* Module Offsets */
|
||||
#define addr_thr_initial_libkernel 0x8D420
|
||||
#define addr_thr_initial_libkernel_web 0x8D420
|
||||
#define addr_thr_initial_libkernel_sys 0x8D830
|
||||
|
||||
/* Proc */
|
||||
#define addr_allproc_lock 0x0
|
||||
#define addr_allproc 0x0
|
||||
#define addr_proc_kill 0x0
|
||||
#define addr_proc_rwmem 0x0
|
||||
#define addr_create_thread 0x0
|
||||
|
||||
/* ptrace */
|
||||
#define addr_kptrace 0x0
|
||||
#define addr_kpsignal 0x0
|
||||
#define addr_kwait 0x0
|
||||
#define addr_kDelay 0x0
|
||||
|
||||
/* Virtual Memory */
|
||||
#define addr_vmspace_acquire_ref 0x0
|
||||
#define addr_vmspace_free 0x0
|
||||
#define addr_vm_map_lock_read 0x0
|
||||
#define addr_vm_map_unlock_read 0x0
|
||||
#define addr_vm_map_lookup_entry 0x0
|
||||
#define addr_vm_map_findspace 0x0
|
||||
#define addr_vm_map_insert 0x0
|
||||
#define addr_vm_map_lock 0x0
|
||||
#define addr_vm_map_unlock 0x0
|
||||
#define addr_vm_map_delete 0x0
|
||||
#define addr_vm_map_protect 0x0
|
||||
|
||||
/*Mutex Locks*/
|
||||
#define addr_mtx_init 0x0
|
||||
#define addr_mtx_destroy 0x0
|
||||
#define addr_mtx_lock_flags 0x0
|
||||
#define addr_mtx_unlock_flags 0x0
|
||||
|
||||
#define addr__sx_slock 0x0
|
||||
#define addr__sx_sunlock 0x0
|
||||
|
||||
/* Critical Sections */
|
||||
#define addr_EnterCriticalSection 0x0
|
||||
#define addr_ExitCriticalSection 0x0
|
||||
|
||||
/* Event Handling */
|
||||
#define addr_eventhandler_register 0x0
|
||||
#define addr_eventhandler_deregister 0x0
|
||||
#define addr_eventhandler_find_list 0x0
|
||||
|
||||
/* Trap Hooks */
|
||||
#define addr_trapHook 0x0
|
||||
#define addr_trap_fatalHook 0x0
|
||||
|
||||
/* Registry Functions */
|
||||
#define addr_sceRegMgrGetStr 0x0
|
||||
#define addr_sceRegMgrSetStr 0x0
|
||||
#define addr_sceRegMgrGetInt 0x0
|
||||
#define addr_sceRegMgrSetInt 0x0
|
||||
#define addr_sceRegMgrGetBin 0x0
|
||||
#define addr_sceRegMgrSetBin 0x0
|
||||
|
||||
/* Flash & NVS */
|
||||
#define addr_icc_nvs_read 0x0
|
||||
#define addr_icc_nvs_write 0x0
|
||||
|
||||
/* Driver */
|
||||
#define addr_make_dev_p 0x0
|
||||
#define addr_destroy_dev 0x0
|
||||
|
||||
/* kmem */
|
||||
#define addr_kmem_alloc 0x0
|
||||
#define addr_kmem_free 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
|
||||
/* File IO */
|
||||
#define addr_vn_fullpath 0x15F470
|
||||
#define addr_kern_rmdir 0x35ADE0
|
||||
#define addr_kern_mkdir 0x35AA60
|
||||
#define addr_kern_open 0x355960
|
||||
#define addr_kern_mount 0x299080
|
||||
#define addr_mount_argf 0x298ED0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(SOFTWARE_VERSION_755)
|
||||
|
||||
/* Util */
|
||||
#define addr_Xfast_syscall 0x0
|
||||
#define addr_sysvec 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
#define addr_prison0 0x0
|
||||
#define addr_rootvnode 0x0
|
||||
#define addr_copyin 0x0
|
||||
#define addr_copyout 0x0
|
||||
|
||||
/* STD Lib */
|
||||
#define addr_M_TEMP 0x0
|
||||
#define addr_M_MOUNT 0x0
|
||||
#define addr_malloc 0x0
|
||||
#define addr_free 0x0
|
||||
#define addr_memcpy 0x0
|
||||
#define addr_memset 0x0
|
||||
#define addr_memcmp 0x0
|
||||
#define addr_strlen 0x0
|
||||
#define addr_strcpy 0x0
|
||||
#define addr_strncpy 0x0
|
||||
#define addr_strcmp 0x0
|
||||
#define addr_strncmp 0x0
|
||||
#define addr_strstr 0x0
|
||||
#define addr_sprintf 0x0
|
||||
#define addr_snprintf 0x0
|
||||
#define addr_vsprintf 0x0
|
||||
#define addr_vprintf 0x0
|
||||
#define addr_sscanf 0x0
|
||||
#define addr_strdup 0x0
|
||||
#define addr_realloc 0x0
|
||||
#define addr_kprintf 0x0
|
||||
|
||||
#define addr_kmem_alloc 0x0
|
||||
|
||||
/* Kproc */
|
||||
#define addr_kproc_create 0x0
|
||||
#define addr_kproc_exit 0x0
|
||||
#define addr_kproc_resume 0x0
|
||||
#define addr_kproc_shutdown 0x0
|
||||
#define addr_kproc_start 0x0
|
||||
#define addr_kproc_suspend 0x0
|
||||
#define addr_kproc_suspend_check 0x0
|
||||
#define addr_kproc_kthread_add 0x0
|
||||
#define addr_pause 0x0
|
||||
#define addr_kthread_add 0x0
|
||||
#define addr_kthread_exit 0x0
|
||||
#define addr_kthread_suspend 0x0
|
||||
#define addr_kthread_suspend_check 0x0
|
||||
#define addr_kthread_set_affinity 0x0
|
||||
|
||||
/* Module Offsets */
|
||||
#define addr_thr_initial_libkernel 0x8D420
|
||||
#define addr_thr_initial_libkernel_web 0x8D420
|
||||
#define addr_thr_initial_libkernel_sys 0x8D830
|
||||
|
||||
/* Proc */
|
||||
#define addr_allproc_lock 0x0
|
||||
#define addr_allproc 0x0
|
||||
#define addr_proc_kill 0x0
|
||||
#define addr_proc_rwmem 0x0
|
||||
#define addr_create_thread 0x0
|
||||
|
||||
/* ptrace */
|
||||
#define addr_kptrace 0x0
|
||||
#define addr_kpsignal 0x0
|
||||
#define addr_kwait 0x0
|
||||
#define addr_kDelay 0x0
|
||||
|
||||
/* Virtual Memory */
|
||||
#define addr_vmspace_acquire_ref 0x0
|
||||
#define addr_vmspace_free 0x0
|
||||
#define addr_vm_map_lock_read 0x0
|
||||
#define addr_vm_map_unlock_read 0x0
|
||||
#define addr_vm_map_lookup_entry 0x0
|
||||
#define addr_vm_map_findspace 0x0
|
||||
#define addr_vm_map_insert 0x0
|
||||
#define addr_vm_map_lock 0x0
|
||||
#define addr_vm_map_unlock 0x0
|
||||
#define addr_vm_map_delete 0x0
|
||||
#define addr_vm_map_protect 0x0
|
||||
|
||||
/*Mutex Locks*/
|
||||
#define addr_mtx_init 0x0
|
||||
#define addr_mtx_destroy 0x0
|
||||
#define addr_mtx_lock_flags 0x0
|
||||
#define addr_mtx_unlock_flags 0x0
|
||||
|
||||
#define addr__sx_slock 0x0
|
||||
#define addr__sx_sunlock 0x0
|
||||
|
||||
/* Critical Sections */
|
||||
#define addr_EnterCriticalSection 0x0
|
||||
#define addr_ExitCriticalSection 0x0
|
||||
|
||||
/* Event Handling */
|
||||
#define addr_eventhandler_register 0x0
|
||||
#define addr_eventhandler_deregister 0x0
|
||||
#define addr_eventhandler_find_list 0x0
|
||||
|
||||
/* Trap Hooks */
|
||||
#define addr_trapHook 0x0
|
||||
#define addr_trap_fatalHook 0x0
|
||||
|
||||
/* Registry Functions */
|
||||
#define addr_sceRegMgrGetStr 0x0
|
||||
#define addr_sceRegMgrSetStr 0x0
|
||||
#define addr_sceRegMgrGetInt 0x0
|
||||
#define addr_sceRegMgrSetInt 0x0
|
||||
#define addr_sceRegMgrGetBin 0x0
|
||||
#define addr_sceRegMgrSetBin 0x0
|
||||
|
||||
/* Flash & NVS */
|
||||
#define addr_icc_nvs_read 0x0
|
||||
#define addr_icc_nvs_write 0x0
|
||||
|
||||
/* Driver */
|
||||
#define addr_make_dev_p 0x0
|
||||
#define addr_destroy_dev 0x0
|
||||
|
||||
/* kmem */
|
||||
#define addr_kmem_alloc 0x0
|
||||
#define addr_kmem_free 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
|
||||
/* File IO */
|
||||
#define addr_vn_fullpath 0x2C3570
|
||||
#define addr_kern_rmdir 0xF9E90
|
||||
#define addr_kern_mkdir 0xF9B10
|
||||
#define addr_kern_open 0xF49E0
|
||||
#define addr_kern_mount 0x790D0
|
||||
#define addr_mount_argf 0x78F20
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,137 @@
|
||||
#pragma once
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(SOFTWARE_VERSION_900)
|
||||
|
||||
/* Util */
|
||||
#define addr_Xfast_syscall 0x000001C0
|
||||
#define addr_sysvec 0x01528E30
|
||||
#define addr_kernel_map 0x02268D48
|
||||
#define addr_prison0 0x0111F870
|
||||
#define addr_rootvnode 0x021EFF20
|
||||
#define addr_copyin 0x002716A0
|
||||
#define addr_copyout 0x002715B0
|
||||
|
||||
/* STD Lib */
|
||||
#define addr_M_TEMP 0x015621E0
|
||||
#define addr_M_MOUNT 0x015279F0
|
||||
#define addr_malloc 0x00301B20
|
||||
#define addr_free 0x00301CE0
|
||||
#define addr_memcpy 0x002714B0
|
||||
#define addr_memset 0x001496C0
|
||||
#define addr_memcmp 0x00271E20
|
||||
#define addr_strlen 0x0030F450
|
||||
#define addr_strcpy 0x00189F80
|
||||
#define addr_strncpy 0x0041E380
|
||||
#define addr_strcmp 0x0040E700
|
||||
#define addr_strncmp 0x00124750
|
||||
#define addr_strstr 0x00487AB0
|
||||
#define addr_sprintf 0x000B7C70
|
||||
#define addr_snprintf 0x000B7D30
|
||||
#define addr_vsprintf 0x000B7D00
|
||||
#define addr_vprintf 0x000B7AA0
|
||||
#define addr_sscanf 0x0026C8D0
|
||||
#define addr_strdup 0x00278540
|
||||
#define addr_realloc 0x00301DE0
|
||||
#define addr_kprintf 0x000B7A30
|
||||
|
||||
/* Kproc */
|
||||
#define addr_kproc_create 0x000969E0
|
||||
#define addr_kproc_exit 0x00096C50
|
||||
#define addr_kproc_resume 0x00096DA0
|
||||
#define addr_kproc_shutdown 0x0029AC80
|
||||
#define addr_kproc_start 0x00096960
|
||||
#define addr_kproc_suspend 0x00096D00
|
||||
#define addr_kproc_suspend_check 0x00096E30
|
||||
#define addr_kproc_kthread_add 0x00097750
|
||||
#define addr_pause 0x00453EA0
|
||||
#define addr_kthread_add 0x00096F40
|
||||
#define addr_kthread_exit 0x00097230
|
||||
#define addr_kthread_suspend 0x0
|
||||
#define addr_kthread_suspend_check 0x00097640
|
||||
#define addr_kthread_set_affinity 0x000978A0
|
||||
|
||||
/* Module Offsets */
|
||||
#define addr_thr_initial_libkernel 0x0008E430
|
||||
#define addr_thr_initial_libkernel_web 0x0008E430
|
||||
#define addr_thr_initial_libkernel_sys 0x0008E830
|
||||
|
||||
/* Proc */
|
||||
#define addr_allproc_lock 0x01B94680
|
||||
#define addr_allproc 0x01B946E0
|
||||
#define addr_proc_kill 0x00029780
|
||||
#define addr_proc_rwmem 0x0041EB00
|
||||
#define addr_create_thread 0x001ED670
|
||||
|
||||
/* ptrace */
|
||||
#define addr_kptrace 0x0041F410
|
||||
#define addr_kpsignal 0x002F9BA0
|
||||
#define addr_kwait 0x00174110
|
||||
#define addr_kDelay 0x0018A6B0
|
||||
|
||||
/* Virtual Memory */
|
||||
#define addr_vmspace_acquire_ref 0x0007B9E0
|
||||
#define addr_vmspace_free 0x0007B810
|
||||
#define addr_vm_map_lock_read 0x0007BB80
|
||||
#define addr_vm_map_unlock_read 0x0007BBD0
|
||||
#define addr_vm_map_lookup_entry 0x0007C1C0
|
||||
#define addr_vm_map_findspace 0x0007EC40
|
||||
#define addr_vm_map_insert 0x0007CD80
|
||||
#define addr_vm_map_lock 0x0007BA30
|
||||
#define addr_vm_map_unlock 0x0007BAA0
|
||||
#define addr_vm_map_delete 0x0007E680
|
||||
#define addr_vm_map_protect 0x000809C0
|
||||
|
||||
/*Mutex Locks*/
|
||||
#define addr_mtx_init 0x002EF960
|
||||
#define addr_mtx_destroy 0x002EF9D0
|
||||
#define addr_mtx_lock_flags 0x002EEEB0
|
||||
#define addr_mtx_unlock_flags 0x002EF170
|
||||
|
||||
#define addr__sx_slock 0x0043E1A0
|
||||
#define addr__sx_sunlock 0x0043E710
|
||||
|
||||
/* Critical Sections */
|
||||
#define addr_EnterCriticalSection 0x0
|
||||
#define addr_ExitCriticalSection 0x0
|
||||
|
||||
/* Event Handling */
|
||||
#define addr_eventhandler_register 0x000F8370
|
||||
#define addr_eventhandler_deregister 0x000F8700
|
||||
#define addr_eventhandler_find_list 0x000F88F0
|
||||
|
||||
/* Trap Hooks */
|
||||
#define addr_trapHook 0x0
|
||||
#define addr_trap_fatalHook 0x0
|
||||
|
||||
/* Registry Functions */
|
||||
#define addr_sceRegMgrGetStr 0x004EA5F0
|
||||
#define addr_sceRegMgrSetStr 0x004F65B5
|
||||
#define addr_sceRegMgrGetInt 0x004E9DD0
|
||||
#define addr_sceRegMgrSetInt 0x004E8B10
|
||||
#define addr_sceRegMgrGetBin 0x004EA770
|
||||
#define addr_sceRegMgrSetBin 0x004EA6C0
|
||||
|
||||
/* Flash & NVS */
|
||||
#define addr_icc_nvs_read 0x0010B310
|
||||
#define addr_icc_nvs_write 0x0
|
||||
|
||||
/* Driver */
|
||||
#define addr_make_dev_p 0x001EF590
|
||||
#define addr_destroy_dev 0x001EFAB0
|
||||
|
||||
/* kmem */
|
||||
#define addr_kmem_alloc 0x0037BE70
|
||||
#define addr_kmem_free 0x0037C040
|
||||
#define addr_kernel_map 0x02268D48
|
||||
|
||||
/* File IO */
|
||||
#define addr_vn_fullpath 0x002648C0
|
||||
#define addr_kern_rmdir 0x001DF3A0
|
||||
#define addr_kern_mkdir 0x001DF020
|
||||
#define addr_kern_open 0x001D9EE0
|
||||
#define addr_kern_mount 0x0004DF50
|
||||
#define addr_mount_argf 0x0004DDB0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,136 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(SOFTWARE_VERSION_NA)
|
||||
|
||||
/* Util */
|
||||
#define addr_Xfast_syscall 0x0
|
||||
#define addr_sysvec 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
#define addr_prison0 0x0
|
||||
#define addr_rootvnode 0x0
|
||||
#define addr_copyin 0x0
|
||||
#define addr_copyout 0x0
|
||||
|
||||
/* STD Lib */
|
||||
#define addr_M_TEMP 0x0
|
||||
#define addr_M_MOUNT 0x0
|
||||
#define addr_malloc 0x0
|
||||
#define addr_free 0x0
|
||||
#define addr_memcpy 0x0
|
||||
#define addr_memset 0x0
|
||||
#define addr_memcmp 0x0
|
||||
#define addr_strlen 0x0
|
||||
#define addr_strcpy 0x0
|
||||
#define addr_strncpy 0x0
|
||||
#define addr_strcmp 0x0
|
||||
#define addr_strstr 0x0
|
||||
#define addr_sprintf 0x0
|
||||
#define addr_snprintf 0x0
|
||||
#define addr_vsprintf 0x0
|
||||
#define addr_vprintf 0x0
|
||||
#define addr_sscanf 0x0
|
||||
#define addr_strdup 0x0
|
||||
#define addr_realloc 0x0
|
||||
#define addr_kprintf 0x0
|
||||
|
||||
#define addr_kmem_alloc 0x0
|
||||
|
||||
/* Kproc */
|
||||
#define addr_kproc_create 0x0
|
||||
#define addr_kproc_exit 0x0
|
||||
#define addr_kproc_resume 0x0
|
||||
#define addr_kproc_shutdown 0x0
|
||||
#define addr_kproc_start 0x0
|
||||
#define addr_kproc_suspend 0x0
|
||||
#define addr_kproc_suspend_check 0x0
|
||||
#define addr_kproc_kthread_add 0x0
|
||||
#define addr_pause 0x0
|
||||
#define addr_kthread_add 0x0
|
||||
#define addr_kthread_exit 0x0
|
||||
#define addr_kthread_suspend 0x0
|
||||
#define addr_kthread_suspend_check 0x0
|
||||
#define addr_kthread_set_affinity 0x0
|
||||
|
||||
/* Module Offsets */
|
||||
#define addr_thr_initial_libkernel 0x0
|
||||
#define addr_thr_initial_libkernel_web 0x0
|
||||
#define addr_thr_initial_libkernel_sys 0x0
|
||||
|
||||
/* Proc */
|
||||
#define addr_allproc_lock 0x0
|
||||
#define addr_allproc 0x0
|
||||
#define addr_proc_kill 0x0
|
||||
#define addr_proc_rwmem 0x0
|
||||
#define addr_create_thread 0x0
|
||||
|
||||
/* ptrace */
|
||||
#define addr_kptrace 0x0
|
||||
#define addr_kpsignal 0x0
|
||||
#define addr_kwait 0x0
|
||||
#define addr_kDelay 0x0
|
||||
|
||||
/* Virtual Memory */
|
||||
#define addr_vmspace_acquire_ref 0x0
|
||||
#define addr_vmspace_free 0x0
|
||||
#define addr_vm_map_lock_read 0x0
|
||||
#define addr_vm_map_unlock_read 0x0
|
||||
#define addr_vm_map_lookup_entry 0x0
|
||||
#define addr_vm_map_findspace 0x0
|
||||
#define addr_vm_map_insert 0x0
|
||||
#define addr_vm_map_lock 0x0
|
||||
#define addr_vm_map_unlock 0x0
|
||||
#define addr_vm_map_delete 0x0
|
||||
#define addr_vm_map_protect 0x0
|
||||
|
||||
/*Mutex Locks*/
|
||||
#define addr_mtx_init 0x0
|
||||
#define addr_mtx_destroy 0x0
|
||||
#define addr_mtx_lock_flags 0x0
|
||||
#define addr_mtx_unlock_flags 0x0
|
||||
|
||||
#define addr__sx_slock 0x0
|
||||
#define addr__sx_sunlock 0x0
|
||||
|
||||
/* Critical Sections */
|
||||
#define addr_EnterCriticalSection 0x0
|
||||
#define addr_ExitCriticalSection 0x0
|
||||
|
||||
/* Event Handling */
|
||||
#define addr_eventhandler_register 0x0
|
||||
#define addr_eventhandler_deregister 0x0
|
||||
#define addr_eventhandler_find_list 0x0
|
||||
|
||||
/* Trap Hooks */
|
||||
#define addr_trapHook 0x0
|
||||
#define addr_trap_fatalHook 0x0
|
||||
|
||||
/* Registry Functions */
|
||||
#define addr_sceRegMgrGetStr 0x0
|
||||
#define addr_sceRegMgrSetStr 0x0
|
||||
#define addr_sceRegMgrGetInt 0x0
|
||||
#define addr_sceRegMgrSetInt 0x0
|
||||
#define addr_sceRegMgrGetBin 0x0
|
||||
#define addr_sceRegMgrSetBin 0x0
|
||||
|
||||
/* Flash & NVS */
|
||||
#define addr_icc_nvs_read 0x0
|
||||
#define addr_icc_nvs_write 0x0
|
||||
|
||||
/* Driver */
|
||||
#define addr_make_dev_p 0x0
|
||||
#define addr_destroy_dev 0x0
|
||||
|
||||
/* kmem */
|
||||
#define addr_kmem_alloc 0x0
|
||||
#define addr_kmem_free 0x0
|
||||
#define addr_kernel_map 0x0
|
||||
|
||||
/* File IO */
|
||||
#define addr_vn_fullpath 0x0
|
||||
#define addr_kern_rmdir 0x0
|
||||
#define addr_kern_mkdir 0x0
|
||||
#define addr_kern_open 0x0
|
||||
#define addr_kern_mount 0x0
|
||||
#define addr_mount_argf 0x0
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,252 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "Resolver.hpp"
|
||||
#include "../ASM.h"
|
||||
|
||||
uint8_t* gpKernelBase = nullptr;
|
||||
|
||||
/* Util */
|
||||
sysentvec* sysvec = nullptr;
|
||||
prison* prison0 = nullptr;
|
||||
vnode* rootvnode = nullptr;
|
||||
int (*copyout)(const void *kaddr, void *udaddr, size_t len) = nullptr;
|
||||
int (*copyin)(const void *uaddr, void *kaddr, size_t len) = nullptr;
|
||||
|
||||
/* STD Lib */
|
||||
void *M_TEMP = nullptr;
|
||||
void* M_MOUNT = nullptr;
|
||||
void *(*malloc)(unsigned long size, void *type, int flags) = nullptr;
|
||||
void (*free)(void *addr, void *type) = nullptr;
|
||||
void (*memcpy)(void *dst, const void *src, size_t len) = nullptr;
|
||||
void *(*memset)(void *ptr, int value, size_t num) = nullptr;
|
||||
int (*memcmp)(const void *ptr1, const void *ptr2, size_t num) = nullptr;
|
||||
size_t (*strlen)(const char *str) = nullptr;
|
||||
int (*strcpy)(char * str1, char * str2) = nullptr;
|
||||
char* (*strncpy)(char *destination, const char *source, size_t num) = nullptr;
|
||||
int (*strcmp)(const char * str1, const char * str2) = nullptr;
|
||||
int (*strncmp)(const char * str1, const char * str2, size_t) = nullptr;
|
||||
char* (*strstr)(const char * str1, const char * str2) = nullptr;
|
||||
int (*sprintf)(char* dst, const char *fmt, ...) = nullptr;
|
||||
int (*snprintf)(char *str, size_t size, const char *format, ...) = nullptr;
|
||||
int (*vsprintf)(char* dst, const char* fmt, va_list ap) = nullptr;
|
||||
int (*vprintf)(const char *fmt, va_list arg) = nullptr;
|
||||
int(*sscanf)(const char *str, const char *format, ...) = nullptr;
|
||||
char *(*strdup)(const char *s, void* type) = nullptr;
|
||||
char *(*realloc)(void *addr, unsigned long size, void* mtp, int flags) = nullptr;
|
||||
void(*kprintf)(const char* fmt, ...) = nullptr;
|
||||
|
||||
/* Kproc */
|
||||
int (*kproc_create)(void (*func)(void *), void *arg, struct proc **newpp, int flags, int pages, const char *fmt, ...) = nullptr;
|
||||
int (*kproc_exit)(int code) = nullptr;
|
||||
//kproc_resume
|
||||
//kproc_shutdown
|
||||
//kproc_start
|
||||
//kproc_suspend
|
||||
//kproc_suspend_check
|
||||
int (*kproc_kthread_add)(void (*func)(void *), void *arg, struct proc **procptr, struct thread **tdptr, int flags, int pages, char * procname, const char *fmt, ...) = nullptr;
|
||||
void (*pause)(const char *wmesg, int timo) = nullptr;
|
||||
int (*kthread_add)(void (*func)(void *), void *arg, struct proc *procp, struct thread **newtdpp, int flags, int pages, const char *fmt, ...) = nullptr;
|
||||
void (*kthread_exit)(void) = nullptr;
|
||||
//void (*kthread_suspend)(thread *td, int timo);
|
||||
void (*kthread_suspend_check)(void) = nullptr;
|
||||
void (*kthread_set_affinity)(const char *tdname, uint64_t prio, uint64_t cpuset, uint64_t unknown) = nullptr;
|
||||
|
||||
/* Proc */
|
||||
sx* allproc_lock = nullptr;
|
||||
proc *allproc = nullptr;
|
||||
int (*proc_kill)(proc *p, char* why) = nullptr;
|
||||
int (*proc_rwmem)(proc *p, uio *uio) = nullptr;
|
||||
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) = nullptr;
|
||||
|
||||
/* ptrace */
|
||||
int (*kptrace)(thread * td, int req, int pid, void * addr, int data) = nullptr;
|
||||
int (*kpsignal)(proc* proc, int sig) = nullptr;
|
||||
int (*kwait)(thread *td, int wpid, int *status, int options, void *rusage) = nullptr;
|
||||
int (*kDelay)(uint64_t time) = nullptr;
|
||||
|
||||
/* Virtual memory */
|
||||
vmspace *(*vmspace_acquire_ref)(proc *p) = nullptr;
|
||||
void (*vmspace_free)(vmspace* vm) = nullptr;
|
||||
void (*vm_map_lock_read)(vm_map* map) = nullptr;
|
||||
void (*vm_map_unlock_read)(vm_map* map) = nullptr;
|
||||
int (*vm_map_lookup_entry)(vm_map* map, uint64_t address, vm_map_entry **entries) = nullptr;
|
||||
int (*vm_map_findspace)(vm_map* map, uint64_t start, uint64_t length, uint64_t *addr) = nullptr;
|
||||
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) = nullptr;
|
||||
void (*vm_map_lock)(vm_map* map, const char* file, int line) = nullptr;
|
||||
void (*vm_map_unlock)(vm_map* map) = nullptr;
|
||||
int (*vm_map_delete)(vm_map* map, uint64_t start, uint64_t end) = nullptr;
|
||||
int (*vm_map_protect)(vm_map* map, uint64_t start, uint64_t end, int new_prot, uint64_t set_max) = nullptr;
|
||||
|
||||
/*Mutex Locks*/
|
||||
void (*mtx_init)(mtx *m, const char *name, const char *type, int opts);
|
||||
void (*mtx_destroy)(mtx *mutex);
|
||||
void (*mtx_lock_flags)(mtx *mutex, int flags);
|
||||
void (*mtx_unlock_flags)(mtx *mutex, int flags);
|
||||
void (*_mtx_lock_flags)(mtx *mutex, int flags, const char *file, int line);
|
||||
void (*_mtx_unlock_flags)(mtx *mutex, int flags, const char *file, int line);
|
||||
|
||||
int (*_sx_slock)(sx *sx, int opts, const char *file, int line);
|
||||
void (*_sx_sunlock)(sx *sx, const char *file, int line);
|
||||
|
||||
/*Critical Sections*/
|
||||
void (*EnterCriticalSection)() = nullptr;
|
||||
void (*ExitCriticalSection)() = nullptr;
|
||||
|
||||
/* Event Handling */
|
||||
#if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA)
|
||||
eventhandler_tag (*eventhandler_register)(eventhandler_list *list, const char *name, void *func, void *arg, int priority) = nullptr;
|
||||
#endif
|
||||
#if defined(SOFTWARE_VERSION_672) || defined(SOFTWARE_VERSION_702) || defined(SOFTWARE_VERSION_755) || defined(SOFTWARE_VERSION_900) //5.5X -> 9.00
|
||||
eventhandler_tag (*eventhandler_register)(eventhandler_list *list, const char *name, void *func, const char* unk, void *arg, int priority) = nullptr;
|
||||
#endif
|
||||
void (*eventhandler_deregister)(eventhandler_list* a, eventhandler_entry* b) = nullptr;
|
||||
eventhandler_list* (*eventhandler_find_list)(const char *name) = nullptr;
|
||||
|
||||
/* Flash & NVS */
|
||||
int (*icc_nvs_read)(uint32_t block, uint32_t offset, uint32_t size, uint8_t* value) = nullptr;
|
||||
int (*icc_nvs_write)(uint32_t block, uint32_t offset, uint32_t size, uint8_t* value) = nullptr;
|
||||
|
||||
/* Registry */
|
||||
int (*sceRegMgrGetStr)(uint64_t RegID, char* Value, int len) = nullptr;
|
||||
int (*sceRegMgrSetStr)(uint64_t RegID, char* Value, int len) = nullptr;
|
||||
int (*sceRegMgrGetInt)(uint64_t RegID, int32_t* Value) = nullptr;
|
||||
int (*sceRegMgrSetInt)(uint64_t RegID, int32_t Value) = nullptr;
|
||||
int (*sceRegMgrGetBin)(uint64_t RegID, char* Value, int size) = nullptr;
|
||||
int (*sceRegMgrSetBin)(uint64_t RegID, char* Value, int size) = nullptr;
|
||||
|
||||
/* Driver */
|
||||
int(*make_dev_p)(int _flags, cdev **_cdev, cdevsw *_devsw, ucred *_cr, uid_t _uid, gid_t _gid, int _mode, const char *_fmt, ...) = nullptr;
|
||||
void(*destroy_dev)(cdev *_dev) = nullptr;
|
||||
|
||||
/* kmem */
|
||||
vm_offset_t(*kmem_alloc)(vm_map_t map, vm_size_t size) = nullptr;
|
||||
void(*kmem_free)(void* map, void* addr, size_t size) = nullptr;
|
||||
vm_map_t kernel_map;
|
||||
|
||||
/* FileIO */
|
||||
int (*vn_fullpath)(struct thread *td, struct vnode *vp, char **retbuf, char **freebuf) = nullptr;
|
||||
int (*kern_rmdir)(thread* td, char *path, int flags) = nullptr;
|
||||
int (*kern_mkdir)(thread* td, char *path, int pathseg, int mode) = nullptr;
|
||||
int (*kern_open)(thread* td, char *path, int pathseg, int flags, int mode) = nullptr;
|
||||
int (*kern_mount)(struct mntarg *ma, int flags) = nullptr;
|
||||
struct mntarg*(*mount_argf)(struct mntarg *ma, const char *name, const char *fmt, ...) = nullptr;
|
||||
|
||||
#define NATIVE_RESOLVE(_Ty) _Ty = (decltype(_Ty))(void*)((uint8_t *)&gpKernelBase[addr_ ## _Ty]);
|
||||
|
||||
void ResolveFunctions()
|
||||
{
|
||||
gpKernelBase = (uint8_t*)Readmsr(0xC0000082) - addr_Xfast_syscall;
|
||||
|
||||
/* Util */
|
||||
NATIVE_RESOLVE(sysvec);
|
||||
NATIVE_RESOLVE(prison0);
|
||||
NATIVE_RESOLVE(rootvnode);
|
||||
NATIVE_RESOLVE(copyin);
|
||||
NATIVE_RESOLVE(copyout);
|
||||
|
||||
/* STD Lib */
|
||||
NATIVE_RESOLVE(M_TEMP);
|
||||
NATIVE_RESOLVE(M_MOUNT);
|
||||
NATIVE_RESOLVE(malloc);
|
||||
NATIVE_RESOLVE(free);
|
||||
NATIVE_RESOLVE(memcpy);
|
||||
NATIVE_RESOLVE(memset);
|
||||
NATIVE_RESOLVE(memcmp);
|
||||
NATIVE_RESOLVE(strlen);
|
||||
NATIVE_RESOLVE(strcpy);
|
||||
NATIVE_RESOLVE(strncpy);
|
||||
NATIVE_RESOLVE(strcmp);
|
||||
NATIVE_RESOLVE(strncmp);
|
||||
NATIVE_RESOLVE(strstr);
|
||||
NATIVE_RESOLVE(sprintf);
|
||||
NATIVE_RESOLVE(snprintf);
|
||||
NATIVE_RESOLVE(vsprintf);
|
||||
NATIVE_RESOLVE(vprintf);
|
||||
NATIVE_RESOLVE(sscanf);
|
||||
NATIVE_RESOLVE(strdup);
|
||||
NATIVE_RESOLVE(realloc);
|
||||
NATIVE_RESOLVE(kprintf);
|
||||
|
||||
/* Kproc */
|
||||
NATIVE_RESOLVE(kproc_create);
|
||||
NATIVE_RESOLVE(kproc_exit);
|
||||
NATIVE_RESOLVE(kproc_kthread_add);
|
||||
NATIVE_RESOLVE(pause);
|
||||
NATIVE_RESOLVE(kthread_add);
|
||||
NATIVE_RESOLVE(kthread_exit);
|
||||
NATIVE_RESOLVE(kthread_suspend_check);
|
||||
NATIVE_RESOLVE(kthread_set_affinity);
|
||||
|
||||
/* Proc */
|
||||
NATIVE_RESOLVE(allproc_lock);
|
||||
NATIVE_RESOLVE(allproc);
|
||||
NATIVE_RESOLVE(proc_kill);
|
||||
NATIVE_RESOLVE(proc_rwmem);
|
||||
NATIVE_RESOLVE(create_thread);
|
||||
|
||||
/* ptrace */
|
||||
NATIVE_RESOLVE(kptrace);
|
||||
NATIVE_RESOLVE(kpsignal);
|
||||
NATIVE_RESOLVE(kwait);
|
||||
NATIVE_RESOLVE(kDelay);
|
||||
|
||||
/* Virtual Memory */
|
||||
NATIVE_RESOLVE(vmspace_acquire_ref);
|
||||
NATIVE_RESOLVE(vmspace_free);
|
||||
NATIVE_RESOLVE(vm_map_lock_read);
|
||||
NATIVE_RESOLVE(vm_map_unlock_read);
|
||||
NATIVE_RESOLVE(vm_map_lookup_entry);
|
||||
NATIVE_RESOLVE(vm_map_findspace);
|
||||
NATIVE_RESOLVE(vm_map_insert);
|
||||
NATIVE_RESOLVE(vm_map_lock);
|
||||
NATIVE_RESOLVE(vm_map_unlock);
|
||||
NATIVE_RESOLVE(vm_map_delete);
|
||||
NATIVE_RESOLVE(vm_map_protect);
|
||||
|
||||
/*Mutex Locks*/
|
||||
NATIVE_RESOLVE(mtx_init);
|
||||
NATIVE_RESOLVE(mtx_destroy);
|
||||
NATIVE_RESOLVE(mtx_lock_flags);
|
||||
NATIVE_RESOLVE(mtx_unlock_flags);
|
||||
|
||||
NATIVE_RESOLVE(_sx_slock);
|
||||
NATIVE_RESOLVE(_sx_sunlock);
|
||||
|
||||
/* Critical Sections */
|
||||
NATIVE_RESOLVE(EnterCriticalSection);
|
||||
NATIVE_RESOLVE(ExitCriticalSection);
|
||||
|
||||
/* Event Handling */
|
||||
NATIVE_RESOLVE(eventhandler_register);
|
||||
NATIVE_RESOLVE(eventhandler_deregister);
|
||||
NATIVE_RESOLVE(eventhandler_find_list);
|
||||
|
||||
/* Registry Functions */
|
||||
NATIVE_RESOLVE(sceRegMgrGetStr);
|
||||
NATIVE_RESOLVE(sceRegMgrSetStr);
|
||||
NATIVE_RESOLVE(sceRegMgrGetInt);
|
||||
NATIVE_RESOLVE(sceRegMgrSetInt);
|
||||
NATIVE_RESOLVE(sceRegMgrGetBin);
|
||||
NATIVE_RESOLVE(sceRegMgrSetBin);
|
||||
|
||||
/* Flash & NVS */
|
||||
NATIVE_RESOLVE(icc_nvs_read);
|
||||
NATIVE_RESOLVE(icc_nvs_write);
|
||||
|
||||
/* Driver */
|
||||
NATIVE_RESOLVE(make_dev_p);
|
||||
NATIVE_RESOLVE(destroy_dev);
|
||||
|
||||
/* kmem */
|
||||
NATIVE_RESOLVE(kmem_alloc);
|
||||
NATIVE_RESOLVE(kmem_free);
|
||||
NATIVE_RESOLVE(kernel_map);
|
||||
|
||||
/* FileIO */
|
||||
NATIVE_RESOLVE(vn_fullpath);
|
||||
NATIVE_RESOLVE(kern_rmdir);
|
||||
NATIVE_RESOLVE(kern_mkdir);
|
||||
NATIVE_RESOLVE(kern_open);
|
||||
NATIVE_RESOLVE(kern_mount);
|
||||
NATIVE_RESOLVE(mount_argf);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
#pragma once
|
||||
#include "../Settings.hpp"
|
||||
#include "../../Common.hpp"
|
||||
|
||||
#include "Offsets/Offsets-505.hpp"
|
||||
#include "Offsets/Offsets-672.hpp"
|
||||
#include "Offsets/Offsets-702.hpp"
|
||||
#include "Offsets/Offsets-755.hpp"
|
||||
#include "Offsets/Offsets-900.hpp"
|
||||
#include "Offsets/Offsets-NA.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include <sys/conf.h>
|
||||
#include <fs/devfs/devfs.h>
|
||||
}
|
||||
|
||||
extern uint8_t* gpKernelBase;
|
||||
|
||||
/* Util */
|
||||
extern sysentvec* sysvec;
|
||||
extern prison* prison0;
|
||||
extern vnode* rootvnode;
|
||||
extern int (*copyout)(const void *kaddr, void *udaddr, size_t len);
|
||||
extern int (*copyin)(const void *uaddr, void *kaddr, size_t len);
|
||||
|
||||
/* STD Lib */
|
||||
extern void *M_TEMP;
|
||||
extern void* M_MOUNT;
|
||||
extern void *(*malloc)(unsigned long size, void *type, int flags);
|
||||
extern void (*free)(void *addr, void *type);
|
||||
extern void (*memcpy)(void *dst, const void *src, size_t len);
|
||||
extern void *(*memset)(void *ptr, int value, size_t num);
|
||||
extern int (*memcmp)(const void *ptr1, const void *ptr2, size_t num);
|
||||
extern size_t (*strlen)(const char *str);
|
||||
extern int (*strcpy)(char * str1, char * str2);
|
||||
extern char* (*strncpy)(char *destination, const char *source, size_t num);
|
||||
extern int (*strcmp)(const char * str1, const char * str2);
|
||||
extern int (*strncmp)(const char * str1, const char * str2, size_t);
|
||||
extern char* (*strstr)(const char * str1, const char * str2);
|
||||
extern int (*sprintf)(char* dst, const char *fmt, ...);
|
||||
extern int (*snprintf)(char *str, size_t size, const char *format, ...);
|
||||
extern int (*vsprintf)(char* dst, const char* fmt, va_list ap);
|
||||
extern int (*vprintf)(const char *fmt, va_list arg);
|
||||
extern int(*sscanf)(const char *str, const char *format, ...);
|
||||
extern char *(*strdup)(const char *s, void* type);
|
||||
extern char *(*realloc)(void *addr, unsigned long size, void* mtp, int flags);
|
||||
extern void(*kprintf)(const char* fmt, ...);
|
||||
|
||||
/* Kproc */
|
||||
extern int (*kproc_create)(void (*func)(void *), void *arg, proc **newpp, int flags, int pages, const char *fmt, ...);
|
||||
extern int (*kproc_exit)(int code);
|
||||
extern int (*kproc_kthread_add)(void (*func)(void *), void *arg, proc **procptr, thread **tdptr, int flags, int pages, char * procname, const char *fmt, ...);
|
||||
extern void (*pause)(const char *wmesg, int timo);
|
||||
extern int (*kthread_add)(void (*func)(void *), void *arg, proc *procp, thread **newtdpp, int flags, int pages, const char *fmt, ...);
|
||||
extern void (*kthread_exit)(void);
|
||||
extern void (*kthread_suspend_check)(void);
|
||||
extern void (*kthread_set_affinity)(const char *tdname, uint64_t prio, uint64_t cpuset, uint64_t unknown);
|
||||
|
||||
/* Proc */
|
||||
LIST_HEAD(proclist, proc);
|
||||
extern sx* allproc_lock;
|
||||
extern proc *allproc;
|
||||
extern int (*proc_kill)(proc *p, char* why);
|
||||
extern int (*proc_rwmem)(proc *p, uio *uio);
|
||||
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);
|
||||
|
||||
/* ptrace */
|
||||
extern int (*kptrace)(thread * td, int req, int pid, void * addr, int data);
|
||||
extern int (*kpsignal)(proc* proc, int sig);
|
||||
extern int (*kwait)(thread *td, int wpid, int *status, int options, void *rusage);
|
||||
extern int (*kDelay)(uint64_t time);
|
||||
|
||||
/* Virtual Memory */
|
||||
extern vmspace *(*vmspace_acquire_ref)(proc* p);
|
||||
extern void (*vmspace_free)(vmspace* vm);
|
||||
extern void (*vm_map_lock_read)(vm_map* map);
|
||||
extern void (*vm_map_unlock_read)(vm_map* map);
|
||||
extern int (*vm_map_lookup_entry)(vm_map* map, uint64_t address, vm_map_entry **entries);
|
||||
extern int (*vm_map_findspace)(vm_map* map, uint64_t start, uint64_t length, uint64_t *addr);
|
||||
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);
|
||||
extern void (*vm_map_lock)(vm_map* map, const char* file, int line);
|
||||
extern void (*vm_map_unlock)(vm_map* map);
|
||||
extern int (*vm_map_delete)(vm_map* map, uint64_t start, uint64_t end);
|
||||
extern int (*vm_map_protect)(vm_map* map, uint64_t start, uint64_t end, int new_prot, uint64_t set_max);
|
||||
|
||||
/*Mutex Locks*/
|
||||
extern void (*mtx_init)(mtx *m, const char *name, const char *type, int opts);
|
||||
extern void (*mtx_destroy)(mtx *mutex);
|
||||
extern void (*mtx_lock_flags)(mtx *mutex, int flags);
|
||||
extern void (*mtx_unlock_flags)(mtx *mutex, int flags);
|
||||
extern void (*_mtx_lock_flags)(mtx *mutex, int flags, const char *file, int line);
|
||||
extern void (*_mtx_unlock_flags)(mtx *mutex, int flags, const char *file, int line);
|
||||
|
||||
extern int (*_sx_slock)(sx *sx, int opts, const char *file, int line);
|
||||
extern void (*_sx_sunlock)(sx *sx, const char *file, int line);
|
||||
|
||||
/* Critical Sections */
|
||||
extern void (*EnterCriticalSection)();
|
||||
extern void (*ExitCriticalSection)();
|
||||
|
||||
/* Event Resolving */
|
||||
#if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA)
|
||||
extern eventhandler_tag (*eventhandler_register)(eventhandler_list *list, const char *name, void *func, void *arg, int priority);
|
||||
#endif
|
||||
#if defined(SOFTWARE_VERSION_672) || defined(SOFTWARE_VERSION_702) || defined(SOFTWARE_VERSION_755) || defined(SOFTWARE_VERSION_900)
|
||||
extern eventhandler_tag (*eventhandler_register)(eventhandler_list *list, const char *name, void *func, const char* unk, void *arg, int priority);
|
||||
#endif
|
||||
extern void (*eventhandler_deregister)(eventhandler_list* a, eventhandler_entry* b);
|
||||
extern eventhandler_list* (*eventhandler_find_list)(const char *name);
|
||||
|
||||
#if defined(SOFTWARE_VERSION_505) || defined(SOFTWARE_VERSION_NA)
|
||||
#define EVENTHANDLER_REGISTER(name, func, arg, priority) \
|
||||
eventhandler_register(NULL, #name, func, arg, priority)
|
||||
#endif
|
||||
#if defined(SOFTWARE_VERSION_672) || defined(SOFTWARE_VERSION_702) || defined(SOFTWARE_VERSION_755) || defined(SOFTWARE_VERSION_900)
|
||||
#define EVENTHANDLER_REGISTER(name, func, arg, priority) \
|
||||
eventhandler_register(NULL, #name, func, "", arg, priority)
|
||||
#endif
|
||||
|
||||
#define EVENTHANDLER_DEREGISTER(name, tag) \
|
||||
do { \
|
||||
struct eventhandler_list *_el; \
|
||||
\
|
||||
if ((_el = eventhandler_find_list(#name)) != NULL) \
|
||||
eventhandler_deregister(_el, tag); \
|
||||
} while(0)
|
||||
|
||||
/* Flash & NVS */
|
||||
extern int (*icc_nvs_read)(uint32_t block, uint32_t offset, uint32_t size, uint8_t* value);
|
||||
extern int (*icc_nvs_write)(uint32_t block, uint32_t offset, uint32_t size, uint8_t* value);
|
||||
|
||||
/* Registry */
|
||||
extern int (*sceRegMgrGetStr)(uint64_t RegID, char* Value, int len);
|
||||
extern int (*sceRegMgrSetStr)(uint64_t RegID, char* Value, int len);
|
||||
extern int (*sceRegMgrGetInt)(uint64_t RegID, int32_t* Value);
|
||||
extern int (*sceRegMgrSetInt)(uint64_t RegID, int32_t Value);
|
||||
extern int (*sceRegMgrGetBin)(uint64_t RegID, char* Value, int size);
|
||||
extern int (*sceRegMgrSetBin)(uint64_t RegID, char* Value, int size);
|
||||
|
||||
/* Driver */
|
||||
extern int(*make_dev_p)(int _flags, cdev **_cdev, cdevsw *_devsw, ucred *_cr, uid_t _uid, gid_t _gid, int _mode, const char *_fmt, ...);
|
||||
extern void(*destroy_dev)(cdev *_dev);
|
||||
|
||||
/* kmem */
|
||||
extern vm_offset_t(*kmem_alloc)(vm_map_t map, vm_size_t size);
|
||||
extern void(*kmem_free)(void* map, void* addr, size_t size);
|
||||
extern vm_map_t kernel_map;
|
||||
|
||||
/* FileIO */
|
||||
extern int (*vn_fullpath)(struct thread *td, struct vnode *vp, char **retbuf, char **freebuf);
|
||||
extern int (*kern_rmdir)(thread* td, char *path, int flags);
|
||||
extern int (*kern_mkdir)(thread* td, char *path, int pathseg, int mode);
|
||||
extern int (*kern_open)(thread* td, char *path, int pathseg, int flags, int mode);
|
||||
extern int (*kern_mount)(struct mntarg *ma, int flags);
|
||||
extern struct mntarg*(*mount_argf)(struct mntarg *ma, const char *name, const char *fmt, ...);
|
||||
|
||||
void ResolveFunctions();
|
||||
@@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
#define KERNELDRIVER
|
||||
#define KDRIVER_MAJOR_VERSION 1
|
||||
#define KDRIVER_MINOR_VERSION 0
|
||||
#define KDRIVER_BUILD_VERSION 699
|
||||
//Which software version we want to compile for
|
||||
#define SOFTWARE_VERSION_NA
|
||||
#ifdef VERSION_505
|
||||
#define SOFTWARE_VERSION_STR "5.05"
|
||||
#define SOFTWARE_VERSION_505
|
||||
#undef SOFTWARE_VERSION_NA
|
||||
#endif
|
||||
#ifdef VERSION_672
|
||||
#define SOFTWARE_VERSION_STR "6.72"
|
||||
#define SOFTWARE_VERSION_672
|
||||
#undef SOFTWARE_VERSION_NA
|
||||
#endif
|
||||
#ifdef VERSION_702
|
||||
#define SOFTWARE_VERSION_STR "7.02"
|
||||
#define SOFTWARE_VERSION_702
|
||||
#undef SOFTWARE_VERSION_NA
|
||||
#endif
|
||||
#ifdef VERSION_755
|
||||
#define SOFTWARE_VERSION_STR "7.55"
|
||||
#define SOFTWARE_VERSION_755
|
||||
#undef SOFTWARE_VERSION_NA
|
||||
#endif
|
||||
#ifdef VERSION_900
|
||||
#define SOFTWARE_VERSION_STR "9.00"
|
||||
#define SOFTWARE_VERSION_900
|
||||
#undef SOFTWARE_VERSION_NA
|
||||
#endif
|
||||
@@ -0,0 +1,413 @@
|
||||
#include "../../Common.hpp"
|
||||
#include "SPRXShellCode.hpp"
|
||||
#include "../System.hpp"
|
||||
#include "../Proc.hpp"
|
||||
|
||||
extern char _binary_Resources_LoaderShellCode_bin_start[];
|
||||
extern char _binary_Resources_LoaderShellCode_bin_end[];
|
||||
|
||||
extern char _binary_Resources_UnLoaderShellCode_bin_start[];
|
||||
extern char _binary_Resources_UnLoaderShellCode_bin_end[];
|
||||
|
||||
int LoadSPRX(const char* ProcessName, const char* Path, bool ShouldCallEntry)
|
||||
{
|
||||
klog("LoadSPRX(%s, %s)", ProcessName, Path);
|
||||
|
||||
uint64_t thr_initial = 0;
|
||||
uint8_t ShellCodeComplete = 0;
|
||||
uint64_t ModuleHandle = 0;
|
||||
|
||||
auto Process = FindProcessByName(ProcessName);
|
||||
if(Process == nullptr)
|
||||
{
|
||||
klog("LoadSPRX(): Could not find process \"%s\".", ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ProcessThread = TAILQ_FIRST(&(Process)->p_threads);
|
||||
if(ProcessThread == nullptr)
|
||||
{
|
||||
klog("LoadSPRX(): Could not find thread on process \"%s\".", ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(Process->p_dynlibptr == nullptr)
|
||||
{
|
||||
klog("LoadSPRX(): p_dynlibptr returned nullptr.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Jailbreak the process.
|
||||
Backup_Jail bkJail;
|
||||
proc_Jailbreak(Process, &bkJail);
|
||||
|
||||
// Gets the Thread Initial for the shellcore thread. Also checking to make sure were not trying to load a prx already loaded.
|
||||
dynlib* m_library = Process->p_dynlibptr->p_dynlib;
|
||||
while(m_library != 0)
|
||||
{
|
||||
if(!strcmp(basename(m_library->ModulePath), basename(Path)))
|
||||
{
|
||||
klog("LoadSPRX(): Module %s is already loaded on proc %s...", basename(Path), Process->p_comm);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
return m_library->ModuleHandle;
|
||||
}
|
||||
|
||||
if(!strcmp(basename(m_library->ModulePath), "libkernel.sprx"))
|
||||
thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel;
|
||||
|
||||
if(!strcmp(basename(m_library->ModulePath), "libkernel_web.sprx"))
|
||||
thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel_web;
|
||||
|
||||
if(!strcmp(basename(m_library->ModulePath), "libkernel_sys.sprx"))
|
||||
thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel_sys;
|
||||
|
||||
m_library = m_library->dynlib_next;
|
||||
}
|
||||
|
||||
if(thr_initial == 0)
|
||||
{
|
||||
klog("LoadSPRX(): Failed to resolve thr_initial.");
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ShellCodeSize = (size_t)(_binary_Resources_LoaderShellCode_bin_end - _binary_Resources_LoaderShellCode_bin_start);
|
||||
|
||||
klog("Start: %llX\nEnd %llX\nSize: 0x%X",
|
||||
_binary_Resources_LoaderShellCode_bin_start,
|
||||
_binary_Resources_LoaderShellCode_bin_end,
|
||||
ShellCodeSize);
|
||||
|
||||
// Allocate space on the process for the shellcode and its threads stack.
|
||||
auto UserlandShellCode = kmap(nullptr, ShellCodeSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PREFAULT_READ, -1, 0, ProcessThread);
|
||||
if(UserlandShellCode == nullptr || (uint64_t)UserlandShellCode < 0)
|
||||
{
|
||||
klog("LoadSPRX(): Failed to allocate memory on process for ShellCode. Err: %d", UserlandShellCode);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
klog("LoadSPRX(): thr_initial = 0x%llX", thr_initial);
|
||||
klog("LoadSPRX(): ShellCodeSize = 0x%llX", ShellCodeSize);
|
||||
klog("LoadSPRX(): UserlandShellCode = 0x%llX", UserlandShellCode);
|
||||
klog("LoadSPRX(): UserlandShellCode = %d", UserlandShellCode);
|
||||
|
||||
auto ShellCodeHeader = (OrbisLoader_header*)_binary_Resources_LoaderShellCode_bin_start;
|
||||
ShellCodeHeader->ShellCodeComplete = 0;
|
||||
ShellCodeHeader->ModuleHandle = 0;
|
||||
ShellCodeHeader->ShouldCallEntry = ShouldCallEntry;
|
||||
ShellCodeHeader->thr_initial = thr_initial;
|
||||
strcpy(ShellCodeHeader->Path, (char*)Path);
|
||||
|
||||
// Write the shellcode to the allocated memory on the process.
|
||||
auto res = ReadWriteProcessMemory(Process, (void*)UserlandShellCode, (void*)_binary_Resources_LoaderShellCode_bin_start, ShellCodeSize, true);
|
||||
if(!res)
|
||||
{
|
||||
klog("LoadSPRX(): WriteProcessMemory failed with error %d.", res);
|
||||
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Allocate memory on process for the threads stack.
|
||||
auto StackMemory = kmap(nullptr, 0x80000, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PREFAULT_READ, -1, 0, ProcessThread);// AllocateProcessMemory(Process, 0x80000, VM_PROT_ALL);
|
||||
if(StackMemory == nullptr)
|
||||
{
|
||||
klog("LoadSPRX(): Failed to allocate memory on process for the Stack.");
|
||||
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Start a thread with the entry pointing to +0x4 in our shellcode because that holds the offset to the starting instructions.
|
||||
|
||||
klog("LoadSPRX(): Starting Shellcode Thread...");
|
||||
struct thread *thr = TAILQ_FIRST(&Process->p_threads);
|
||||
uint64_t ShellCodeEntry = (uint64_t)UserlandShellCode + ShellCodeHeader->entry;
|
||||
create_thread(thr, NULL, (void*)ShellCodeEntry, NULL, (char*)StackMemory, 0x80000, NULL, NULL, NULL, 0, NULL);
|
||||
|
||||
klog("LoadSPRX(): Thread Started!! Waiting for shellcode to complete...");
|
||||
|
||||
// Wait for the shellcode to complete by reading the byte that will be set to 1 on completion.
|
||||
while (!ShellCodeComplete)
|
||||
{
|
||||
auto err = ReadProcessMemory(Process, UserlandShellCode + offsetof(OrbisLoader_header, ShellCodeComplete), (void *)&ShellCodeComplete, sizeof(ShellCodeComplete));
|
||||
if(!err)
|
||||
{
|
||||
klog("LoadSPRX(): Failed to read ModuleHandle. %d", err);
|
||||
|
||||
kmunmap(StackMemory, 0x80000, ProcessThread);
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
pause("", 100);
|
||||
}
|
||||
|
||||
// Grab the Module handle from the shellcode to see if the loading was a sucess or not.
|
||||
auto err = ReadProcessMemory(Process, UserlandShellCode + offsetof(OrbisLoader_header, ModuleHandle), (void *)&ModuleHandle, sizeof(ModuleHandle));
|
||||
if(!err)
|
||||
{
|
||||
klog("LoadSPRX(): Failed to read ModuleHandle. %d", err);
|
||||
|
||||
kmunmap(StackMemory, 0x80000, ProcessThread);
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
klog("LoadSPRX(): Freeing Shellcode Memory...");
|
||||
kmunmap(StackMemory, 0x80000, ProcessThread);
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(Process, bkJail);
|
||||
|
||||
if(ModuleHandle > 0 && ModuleHandle < 0x80000000)
|
||||
klog("LoadSPRX(): Completed! Module Loaded with handle 0x%llX", ModuleHandle);
|
||||
else
|
||||
klog("LoadSPRX(): Failed with error 0x%llX", ModuleHandle);
|
||||
|
||||
return ModuleHandle;
|
||||
}
|
||||
|
||||
int UnloadSPRX(const char* ProcessName, int Handle, bool ShouldCallExit)
|
||||
{
|
||||
klog("UnloadSPRX(%s, %i)", ProcessName, Handle);
|
||||
|
||||
uint64_t thr_initial = 0;
|
||||
uint8_t ShellCodeComplete = 0;
|
||||
uint64_t Result = 0;
|
||||
|
||||
auto Process = FindProcessByName(ProcessName);
|
||||
if(Process == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): Could not find process \"%s\".", ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ProcessThread = TAILQ_FIRST(&(Process)->p_threads);
|
||||
if(ProcessThread == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): Could not find thread on process \"%s\".", ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(Process->p_dynlibptr == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): p_dynlibptr returned nullptr.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Gets the Thread Initial for the shellcore thread. Also checking to make sure were not trying to un load a prx that is not loaded.
|
||||
bool FoundModule = false;
|
||||
dynlib* m_library = Process->p_dynlibptr->p_dynlib;
|
||||
while(m_library != 0)
|
||||
{
|
||||
if(m_library->ModuleHandle == Handle)
|
||||
{
|
||||
klog("UnloadSPRX(): Found Module \"%s\" in Process \"%s\".", basename(m_library->ModulePath), ProcessName);
|
||||
|
||||
FoundModule = true;
|
||||
}
|
||||
|
||||
if(!strcmp(basename(m_library->ModulePath), "libkernel.sprx"))
|
||||
thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel;
|
||||
|
||||
if(!strcmp(basename(m_library->ModulePath), "libkernel_web.sprx"))
|
||||
thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel_web;
|
||||
|
||||
if(!strcmp(basename(m_library->ModulePath), "libkernel_sys.sprx"))
|
||||
thr_initial = (uint64_t)m_library->codeBase + addr_thr_initial_libkernel_sys;
|
||||
|
||||
m_library = m_library->dynlib_next;
|
||||
}
|
||||
|
||||
if(!FoundModule)
|
||||
{
|
||||
klog("UnloadSPRX(): Could not find Module %i on Process \"%s\".", Handle, ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(thr_initial == 0)
|
||||
{
|
||||
klog("UnloadSPRX(): Failed to resolve thr_initial.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
auto ShellCodeSize = (size_t)(_binary_Resources_UnLoaderShellCode_bin_end - _binary_Resources_UnLoaderShellCode_bin_start);
|
||||
|
||||
klog("Start: %llX\nEnd %llX\nSize: 0x%X",
|
||||
_binary_Resources_UnLoaderShellCode_bin_start,
|
||||
_binary_Resources_UnLoaderShellCode_bin_end,
|
||||
ShellCodeSize);
|
||||
|
||||
// Allocate space on the process for the shellcode and its threads stack.
|
||||
auto UserlandShellCode = kmap(nullptr, ShellCodeSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PREFAULT_READ, -1, 0, ProcessThread);// AllocateProcessMemory(Process, ShellCodeSize, VM_PROT_ALL);
|
||||
if(UserlandShellCode == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): Failed to allocate memory on process for ShellCode.");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
klog("UnloadSPRX(): thr_initial = 0x%llX", thr_initial);
|
||||
klog("UnloadSPRX(): UserlandShellCode = 0x%llX", UserlandShellCode);
|
||||
|
||||
auto ShellCodeHeader = (OrbisUnLoader_header*)_binary_Resources_UnLoaderShellCode_bin_start;
|
||||
ShellCodeHeader->thr_initial = thr_initial;
|
||||
ShellCodeHeader->ShellCodeComplete = 0;
|
||||
ShellCodeHeader->ShouldCallExit = ShouldCallExit;
|
||||
ShellCodeHeader->ModuleHandle = Handle;
|
||||
|
||||
// Write the shellcode to the allocated memory on the process.
|
||||
auto res = ReadWriteProcessMemory(Process, (void*)UserlandShellCode, (void*)_binary_Resources_UnLoaderShellCode_bin_start, ShellCodeSize, true);
|
||||
if(!res)
|
||||
{
|
||||
klog("UnloadSPRX(): copy out failed with error %d.", res);
|
||||
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Allocate memory on process for the threads stack.
|
||||
auto StackMemory = kmap(nullptr, 0x80000, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PREFAULT_READ, -1, 0, ProcessThread);// AllocateProcessMemory(Process, 0x80000, VM_PROT_ALL);
|
||||
if(StackMemory == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): Failed to allocate memory on process for the Stack.");
|
||||
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Start a thread with the entry pointing to +0x4 in our shellcode because that holds the offset to the starting instructions.
|
||||
|
||||
klog("UnloadSPRX(): Starting Shellcode Thread...");
|
||||
struct thread *thr = TAILQ_FIRST(&Process->p_threads);
|
||||
uint64_t ShellCodeEntry = (uint64_t)UserlandShellCode + ShellCodeHeader->entry;
|
||||
create_thread(thr, NULL, (void*)ShellCodeEntry, NULL, (char*)StackMemory, 0x80000, NULL, NULL, NULL, 0, NULL);
|
||||
|
||||
klog("UnloadSPRX(): Thread Started!! Waiting for shellcode to complete...");
|
||||
|
||||
// Wait for the shellcode to complete by reading the byte that will be set to 1 on completion.
|
||||
while (!ShellCodeComplete)
|
||||
{
|
||||
auto err = ReadProcessMemory(Process, UserlandShellCode + offsetof(OrbisUnLoader_header, ShellCodeComplete), (void *)&ShellCodeComplete, sizeof(ShellCodeComplete));
|
||||
if(!err)
|
||||
{
|
||||
klog("UnloadSPRX(): Failed to read ModuleHandle. %d", err);
|
||||
|
||||
kmunmap(StackMemory, 0x80000, ProcessThread);
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
pause("", 100);
|
||||
}
|
||||
|
||||
// Grab the Result from the shellcode to see if the Un Loading was a sucess or not.
|
||||
auto err = ReadProcessMemory(Process, UserlandShellCode + offsetof(OrbisUnLoader_header, Result), (void *)&Result, sizeof(Result));
|
||||
if(!err)
|
||||
{
|
||||
klog("UnloadSPRX(): Failed to read Result. %d", err);
|
||||
|
||||
kmunmap(StackMemory, 0x80000, ProcessThread);
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean up.
|
||||
klog("UnloadSPRX(): Freeing Shellcode Memory...");
|
||||
kmunmap(StackMemory, 0x80000, ProcessThread);
|
||||
kmunmap(UserlandShellCode, ShellCodeSize, ProcessThread);
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
int UnloadSPRX(const char* ProcessName, const char* Name, bool ShouldCallExit)
|
||||
{
|
||||
auto Process = FindProcessByName(ProcessName);
|
||||
if(Process == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): Could not find process \"%s\".", ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
klog("Found Process...\n");
|
||||
|
||||
auto ProcessThread = TAILQ_FIRST(&(Process)->p_threads);
|
||||
if(ProcessThread == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): Could not find thread on process \"%s\".", ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
klog("Found Thread...\n");
|
||||
|
||||
if(Process->p_dynlibptr == nullptr)
|
||||
{
|
||||
klog("UnloadSPRX(): p_dynlibptr returned nullptr.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
klog("Found Thread...\n");
|
||||
|
||||
int ModuleHandle = -1;
|
||||
dynlib* m_library = Process->p_dynlibptr->p_dynlib;
|
||||
while(m_library != 0)
|
||||
{
|
||||
if(!strcmp(basename(m_library->ModulePath), Name))
|
||||
{
|
||||
klog("UnloadSPRX(): Found Module \"%s\" in Process \"%s\".", Name, ProcessName);
|
||||
|
||||
ModuleHandle = m_library->ModuleHandle;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
m_library = m_library->dynlib_next;
|
||||
}
|
||||
|
||||
if(ModuleHandle == -1)
|
||||
{
|
||||
klog("UnloadSPRX(): Could not find Module \"%s\" on Process \"%s\".", Name, ProcessName);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return UnloadSPRX(ProcessName, ModuleHandle, ShouldCallExit);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
struct OrbisLoader_header
|
||||
{
|
||||
uint32_t magic;
|
||||
uint64_t entry;
|
||||
|
||||
uint64_t thr_initial;
|
||||
uint8_t ShellCodeComplete;
|
||||
uint8_t ShouldCallEntry;
|
||||
|
||||
char Path[100];
|
||||
uint64_t ModuleHandle;
|
||||
}__attribute__((packed));
|
||||
|
||||
struct OrbisUnLoader_header
|
||||
{
|
||||
uint32_t magic;
|
||||
uint64_t entry;
|
||||
|
||||
uint64_t thr_initial;
|
||||
uint8_t ShellCodeComplete;
|
||||
uint8_t ShouldCallExit;
|
||||
|
||||
uint64_t ModuleHandle;
|
||||
uint64_t Result;
|
||||
}__attribute__((packed));
|
||||
|
||||
int LoadSPRX(const char* ProcessName, const char* Path, bool ShouldCallEntry = true);
|
||||
int UnloadSPRX(const char* ProcessName, int Handle, bool ShouldCallExit = true);
|
||||
int UnloadSPRX(const char* ProcessName, const char* Name, bool ShouldCallExit = true);
|
||||
@@ -0,0 +1,402 @@
|
||||
#include "../Common.hpp"
|
||||
#include "System.hpp"
|
||||
#include "../Util/ShellCode/SPRXShellCode.hpp"
|
||||
|
||||
char* strrchr(const char *cp, int ch)
|
||||
{
|
||||
char *save;
|
||||
char c;
|
||||
|
||||
for (save = (char *) 0; (c = *cp); cp++) {
|
||||
if (c == ch)
|
||||
save = (char *) cp;
|
||||
}
|
||||
|
||||
return save;
|
||||
}
|
||||
|
||||
char* strchr(const char *s, int c)
|
||||
{
|
||||
do {
|
||||
if (*s == c)
|
||||
{
|
||||
return (char*)s;
|
||||
}
|
||||
} while (*s++);
|
||||
return (0);
|
||||
}
|
||||
|
||||
char* basename(const char *filename)
|
||||
{
|
||||
char *p = strrchr(filename, '/');
|
||||
return p ? p + 1 : (char *)filename;
|
||||
}
|
||||
|
||||
// Shamelessly yoinked from MIRA
|
||||
// Credits: flatz
|
||||
proc* FindProcessByName(const char* p_Name)
|
||||
{
|
||||
sx* allproclock = (sx*)allproc_lock;
|
||||
proclist* _allproc = (proclist*)*(uint64_t*)(allproc);
|
||||
|
||||
proc* s_FoundProc = nullptr;
|
||||
|
||||
if (!p_Name)
|
||||
return NULL;
|
||||
|
||||
_sx_slock(allproclock, 0, __FILE__, __LINE__);
|
||||
|
||||
do
|
||||
{
|
||||
proc* s_Proc = nullptr;
|
||||
|
||||
FOREACH_PROC_IN_SYSTEM(s_Proc)
|
||||
{
|
||||
//PROC_LOCK(s_Proc);
|
||||
|
||||
if (strncmp(p_Name, s_Proc->p_comm, strlen(p_Name)) == 0) {
|
||||
s_FoundProc = s_Proc;
|
||||
//PROC_UNLOCK(s_Proc);
|
||||
break;
|
||||
}
|
||||
|
||||
//PROC_UNLOCK(s_Proc);
|
||||
}
|
||||
} while (false);
|
||||
|
||||
_sx_sunlock(allproclock, __FILE__, __LINE__);
|
||||
|
||||
return s_FoundProc;
|
||||
}
|
||||
|
||||
proc* FindProcessByPID(pid_t pid)
|
||||
{
|
||||
sx* allproclock = (sx*)allproc_lock;
|
||||
proclist* _allproc = (proclist*)*(uint64_t*)(allproc);
|
||||
|
||||
proc* s_FoundProc = nullptr;
|
||||
|
||||
_sx_slock(allproclock, 0, __FILE__, __LINE__);
|
||||
|
||||
do
|
||||
{
|
||||
proc* s_Proc = nullptr;
|
||||
|
||||
FOREACH_PROC_IN_SYSTEM(s_Proc)
|
||||
{
|
||||
//PROC_LOCK(s_Proc);
|
||||
|
||||
if (s_Proc->p_pid == pid) {
|
||||
s_FoundProc = s_Proc;
|
||||
//PROC_UNLOCK(s_Proc);
|
||||
break;
|
||||
}
|
||||
|
||||
//PROC_UNLOCK(s_Proc);
|
||||
}
|
||||
} while (false);
|
||||
|
||||
_sx_sunlock(allproclock, __FILE__, __LINE__);
|
||||
|
||||
return s_FoundProc;
|
||||
}
|
||||
|
||||
uint8_t* AllocateProcessMemory(proc* Process, uint32_t Size, uint32_t Protection)
|
||||
{
|
||||
if (Process == nullptr)
|
||||
return nullptr;
|
||||
|
||||
klog("Requested Size: (%x).", Size);
|
||||
Size = round_page(Size);
|
||||
klog("Adjusted Size (%x).", Size);
|
||||
|
||||
vm_offset_t s_Address = 0;
|
||||
|
||||
// Get the vmspace
|
||||
auto s_VmSpace = Process->p_vmspace;
|
||||
if (s_VmSpace == nullptr)
|
||||
{
|
||||
klog("invalid vmspace.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Get the vmmap
|
||||
vm_map_t s_VmMap = &s_VmSpace->vm_map;
|
||||
|
||||
// Lock the vmmap
|
||||
vm_map_lock(s_VmMap, __FILE__, __LINE__);
|
||||
|
||||
do
|
||||
{
|
||||
// Find some free space to allocate memory
|
||||
auto s_Result = vm_map_findspace(s_VmMap, s_VmMap->header.start, Size, &s_Address);
|
||||
if (s_Result != 0)
|
||||
{
|
||||
klog("vm_map_findspace returned (%d).", s_Result);
|
||||
break;
|
||||
}
|
||||
|
||||
klog("_vm_map_findspace returned address (%p).", s_Address);
|
||||
|
||||
// Validate the address
|
||||
if (s_Address == 0)
|
||||
{
|
||||
klog("allocated address is invalid (%p).", s_Address);
|
||||
break;
|
||||
}
|
||||
|
||||
// Insert the new stuff map
|
||||
s_Result = vm_map_insert(s_VmMap, NULL, 0, s_Address, s_Address + Size, Protection, Protection, 0);
|
||||
if (s_Result != 0)
|
||||
{
|
||||
klog("vm_map_insert returned (%d).", s_Result);
|
||||
break;
|
||||
}
|
||||
|
||||
} while (false);
|
||||
|
||||
vm_map_unlock(s_VmMap);
|
||||
|
||||
return reinterpret_cast<uint8_t*>(s_Address);
|
||||
}
|
||||
|
||||
void FreeProcessMemory(struct proc* p_Process, void* p_Pointer, uint32_t p_Size)
|
||||
{
|
||||
struct vmspace* s_VmSpace = p_Process->p_vmspace;
|
||||
if (s_VmSpace == nullptr)
|
||||
{
|
||||
klog("could not get vmspace.");
|
||||
return;
|
||||
}
|
||||
|
||||
struct vm_map* s_VmMap = &s_VmSpace->vm_map;
|
||||
|
||||
vm_map_lock(s_VmMap, __FILE__, __LINE__);
|
||||
|
||||
auto s_Ret = vm_map_delete(s_VmMap, reinterpret_cast<uint64_t>(p_Pointer), p_Size);
|
||||
|
||||
vm_map_unlock(s_VmMap);
|
||||
|
||||
if (s_Ret != 0)
|
||||
klog("could not delete from vm map (%d).", s_Ret);
|
||||
}
|
||||
|
||||
bool ReadWriteProcessMemory(struct proc* p_TargetProcess, void* p_TargetAddress, void* p_Data, uint32_t p_DataLength, bool p_Write)
|
||||
{
|
||||
// Validate process
|
||||
if (p_TargetProcess == nullptr)
|
||||
{
|
||||
klog("invalid process.");
|
||||
return false;
|
||||
}
|
||||
|
||||
thread* s_ProcMainThread = p_TargetProcess->p_singlethread ? p_TargetProcess->p_singlethread : p_TargetProcess->p_threads.tqh_first;
|
||||
if (s_ProcMainThread == nullptr)
|
||||
{
|
||||
klog("could not get process main thread.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate the target address
|
||||
if (p_TargetAddress == nullptr)
|
||||
{
|
||||
klog("invalid target address.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Validate the data
|
||||
if (p_Data == nullptr ||
|
||||
p_DataLength == 0)
|
||||
{
|
||||
klog("invalid data.");
|
||||
return false;
|
||||
}
|
||||
|
||||
struct iovec s_Vec;
|
||||
memset(&s_Vec, 0, sizeof(s_Vec));
|
||||
s_Vec.iov_base = p_Data;
|
||||
s_Vec.iov_len = p_DataLength;
|
||||
|
||||
struct uio s_Uio;
|
||||
memset(&s_Uio, 0, sizeof(s_Uio));
|
||||
s_Uio.uio_iov = &s_Vec;
|
||||
s_Uio.uio_iovcnt = 1;
|
||||
s_Uio.uio_offset = (uint64_t)p_TargetAddress;
|
||||
s_Uio.uio_resid = (uint64_t)p_DataLength;
|
||||
s_Uio.uio_segflg = UIO_SYSSPACE;
|
||||
s_Uio.uio_rw = p_Write ? UIO_WRITE : UIO_READ;
|
||||
s_Uio.uio_td = s_ProcMainThread;
|
||||
|
||||
auto s_Ret = proc_rwmem(p_TargetProcess, &s_Uio);
|
||||
if (s_Ret != 0)
|
||||
{
|
||||
klog("could not proc_rwmem (%d).", s_Ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReadProcessMemory(struct proc* p_TargetProcess, void* p_TargetAddress, void* p_Data, uint32_t p_DataLength)
|
||||
{
|
||||
return ReadWriteProcessMemory(p_TargetProcess, p_TargetAddress, p_Data, p_DataLength, false);
|
||||
}
|
||||
|
||||
bool WriteProcessMemory(struct proc* p_TargetProcess, void* p_TargetAddress, void* p_Data, uint32_t p_DataLength)
|
||||
{
|
||||
return ReadWriteProcessMemory(p_TargetProcess, p_TargetAddress, p_Data, p_DataLength, true);
|
||||
}
|
||||
|
||||
int MountNullFS(char* where, char* what, int flags)
|
||||
{
|
||||
struct mntarg* ma = NULL;
|
||||
|
||||
ma = mount_argf(ma, "fstype", "%s", "nullfs");
|
||||
ma = mount_argf(ma, "fspath", "%s", where);
|
||||
ma = mount_argf(ma, "target", "%s", what);
|
||||
|
||||
if (ma == NULL) {
|
||||
klog("Something is wrong, ma value is null after argument\n");
|
||||
return 50;
|
||||
}
|
||||
|
||||
return kern_mount(ma, flags);
|
||||
}
|
||||
|
||||
bool MountDir(thread* td, char* Sandbox, char* what, int flags)
|
||||
{
|
||||
if(!td)
|
||||
{
|
||||
klog("Thread was NULL...");
|
||||
return false;
|
||||
}
|
||||
|
||||
char s_fulldir[0x200];
|
||||
snprintf(s_fulldir, sizeof(s_fulldir), "%s%s", Sandbox, what);
|
||||
|
||||
klog("Mount: %s -> %s", s_fulldir, what);
|
||||
|
||||
if(kern_mkdir(td, s_fulldir, 0, 0777) != 0)
|
||||
return false;
|
||||
|
||||
if(MountNullFS(s_fulldir, what, flags) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnMountDir(thread* td, char* Sandbox, char* what, int flags)
|
||||
{
|
||||
if(!td)
|
||||
{
|
||||
klog("Thread was NULL...");
|
||||
return false;
|
||||
}
|
||||
|
||||
char s_fulldir[0x200];
|
||||
snprintf(s_fulldir, sizeof(s_fulldir), "%s%s", Sandbox, what);
|
||||
|
||||
klog("Un-Mount: %s -> %s", s_fulldir, what);
|
||||
|
||||
if(kunmount(s_fulldir, flags, td) != 0)
|
||||
return false;
|
||||
|
||||
if(kern_rmdir(td, s_fulldir, 0) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MountShellUIDirs(proc* p, vnode* jdir, bool Mount)
|
||||
{
|
||||
klog("%s dirs { system, data, host, hostapp } on process %s", Mount ? "Mounting" : "Un-Mounting", p->p_comm);
|
||||
|
||||
//Get first thread in proc.
|
||||
thread* td = curthread();//p->p_threads.tqh_first;
|
||||
|
||||
//Get the sandbox path.
|
||||
char* s_SandboxPath = nullptr;
|
||||
char* s_Freepath = nullptr;
|
||||
vn_fullpath(td, jdir, &s_SandboxPath, &s_Freepath);
|
||||
klog("%s -> %s\n", p->p_comm, s_SandboxPath);
|
||||
|
||||
if(Mount)
|
||||
{
|
||||
if(!MountDir(td, s_SandboxPath, "/system", MNT_SYNCHRONOUS))
|
||||
{
|
||||
klog("Failed to Mount /System.");
|
||||
return false;
|
||||
}
|
||||
if(!MountDir(td, s_SandboxPath, "/data", MNT_SYNCHRONOUS))
|
||||
{
|
||||
klog("Failed to Mount /data.");
|
||||
return false;
|
||||
}
|
||||
if(!MountDir(td, s_SandboxPath, "/host", MNT_SYNCHRONOUS))
|
||||
{
|
||||
klog("Failed to Mount /host.");
|
||||
return false;
|
||||
}
|
||||
if(!MountDir(td, s_SandboxPath, "/hostapp", MNT_SYNCHRONOUS))
|
||||
{
|
||||
klog("Failed to Mount /hostapp.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!UnMountDir(td, s_SandboxPath, "/system", MNT_FORCE))
|
||||
{
|
||||
klog("Failed to Un-Mount /system.");
|
||||
return false;
|
||||
}
|
||||
if(!UnMountDir(td, s_SandboxPath, "/data", MNT_FORCE))
|
||||
{
|
||||
klog("Failed to Un-Mount /data.");
|
||||
return false;
|
||||
}
|
||||
if(!UnMountDir(td, s_SandboxPath, "/host", MNT_FORCE))
|
||||
{
|
||||
klog("Failed to Un-Mount /host.");
|
||||
return false;
|
||||
}
|
||||
if(!UnMountDir(td, s_SandboxPath, "/hostapp", MNT_FORCE))
|
||||
{
|
||||
klog("Failed to Un-Mount /hostapp.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool DoShellUIMount(proc* p, bool Mount)
|
||||
{
|
||||
if(!strcmp(p->titleId, "NPXS20001") && (!strcmp(p->p_comm, "SecureUIProcess.self") || !strcmp(p->p_comm, "SceShellUI")))
|
||||
{
|
||||
// Jailbreak the process.
|
||||
Backup_Jail bkJail;
|
||||
proc_Jailbreak(p, &bkJail);
|
||||
|
||||
// Un-Mount the dirs for ShellUI
|
||||
bool res = MountShellUIDirs(p, bkJail.fd_jdir, Mount);
|
||||
|
||||
// Restore previous jail.
|
||||
proc_RestoreJail(p, bkJail);
|
||||
|
||||
if(!strcmp(p->p_comm, "SecureUIProcess.self"))
|
||||
{
|
||||
while(FindProcessByName("SceShellUI") == nullptr) { Sleep(10); }
|
||||
|
||||
Sleep(3000);
|
||||
|
||||
LoadSPRX("SceShellUI", "/data/Orbis Toolbox/Orbis Toolbox.sprx");
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
char* basename(const char *filename);
|
||||
proc* FindProcessByName(const char* p_Name);
|
||||
proc* FindProcessByPID(pid_t pid) ;
|
||||
uint8_t* AllocateProcessMemory(proc* Process, uint32_t Size, uint32_t Protection);
|
||||
void FreeProcessMemory(struct proc* p_Process, void* p_Pointer, uint32_t p_Size);
|
||||
|
||||
bool ReadWriteProcessMemory(struct proc* p_TargetProcess, void* p_TargetAddress, void* p_Data, uint32_t p_DataLength, bool p_Write);
|
||||
bool ReadProcessMemory(struct proc* p_TargetProcess, void* p_TargetAddress, void* p_Data, uint32_t p_DataLength);
|
||||
bool WriteProcessMemory(struct proc* p_TargetProcess, void* p_TargetAddress, void* p_Data, uint32_t p_DataLength);
|
||||
|
||||
int MountNullFS(char* where, char* what, int flags);
|
||||
bool MountDir(thread* td, char* Sandbox, char* what, int flags);
|
||||
bool UnMountDir(thread* td, char* Sandbox, char* what, int flags);
|
||||
bool MountShellUIDirs(proc* p, vnode* jdir, bool Mount);
|
||||
bool DoShellUIMount(proc* p, bool Mount);
|
||||
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include "sys/types.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef true
|
||||
#define true 1
|
||||
#endif
|
||||
|
||||
#ifndef false
|
||||
#define false 0
|
||||
#endif
|
||||
|
||||
enum Auth_ID
|
||||
{
|
||||
JitBase = 0x3100000000000000,
|
||||
CoreDump = 0x3800000000000006,
|
||||
SysCore = 0x3800000000000007,
|
||||
ShellUI = 0x380000000000000F,
|
||||
Shell3D = 0x3800000000000009,
|
||||
ShellCore = 0x3800000000000010,
|
||||
DECID = 0x3800000000010003,
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "../Common.hpp"
|
||||
#include "kproc.hpp"
|
||||
|
||||
kproc::kproc(void(*Entry)(void*), void* Args, const char* Proc_Name, const char* Title_ID, int Flags, int Pages)
|
||||
{
|
||||
//Create new Process.
|
||||
int ret = kproc_create(Entry, Args, &this->Process, Flags, Pages, Proc_Name);
|
||||
if( ret != 0 || this->Process == nullptr )
|
||||
{
|
||||
kprintf("Failed to create new Process.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
//Copy Title ID Text.
|
||||
strcpy(this->Process->titleId, (char*)Title_ID);
|
||||
|
||||
//Help with graceful shutdown.
|
||||
Proc_Should_Run = true;
|
||||
|
||||
kprintf("Created New Process Sucessfully.\n%s(%i) %s", this->Process->p_comm, this->Process->p_pid, this->Process->titleId);
|
||||
}
|
||||
|
||||
kproc::~kproc()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
thread* kproc::Add_Thread(void(*Thread)(void*), void *Args, int Flags, int Pages, const char* Thread_Name)
|
||||
{
|
||||
thread* NewThread = nullptr;
|
||||
int ret = kproc_kthread_add(Thread, Args, &this->Process, &NewThread, Flags, Pages, this->Process->p_comm, Thread_Name);
|
||||
|
||||
if(ret != 0 || NewThread == nullptr)
|
||||
{
|
||||
kprintf("Failed to Create New Thread (%s) on Proc %s(%i) %s", Thread_Name, this->Process->p_comm, this->Process->p_pid, this->Process->titleId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
kprintf("New Thread (%s) on Proc %s(%i) %s", Thread_Name, this->Process->p_comm, this->Process->p_pid, this->Process->titleId);
|
||||
|
||||
return NewThread;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "../Common.hpp"
|
||||
|
||||
class kproc
|
||||
{
|
||||
private:
|
||||
bool Proc_Should_Run = false;
|
||||
|
||||
public:
|
||||
proc* Process = nullptr;
|
||||
thread* Main_Thread = nullptr;
|
||||
|
||||
kproc(void(*Entry)(void*), void* Args, const char* Proc_Name, const char* Title_ID, int Flags, int Pages);
|
||||
~kproc();
|
||||
|
||||
thread* Add_Thread(void(*Thread)(void*), void *Args, int Flags, int Pages, const char* Thread_Name);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "Common.hpp"
|
||||
#include "OrbisLib/OrbisLib.hpp"
|
||||
#include "Util/Patches/Patches.hpp"
|
||||
|
||||
KDriver_Info* KDriverInfo = nullptr;
|
||||
OrbisLib* OrbisLibInstance = nullptr;
|
||||
|
||||
extern "C" int _Shutdown()
|
||||
{
|
||||
klog("!!! SHUTDOWN SHUTDOWN SHUTDOWN !!!");
|
||||
|
||||
KDriverInfo->Running = false;
|
||||
|
||||
delete OrbisLibInstance;
|
||||
|
||||
Sleep(2000);
|
||||
|
||||
klog("!!! BYE !!!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int _main(uint64_t* p)
|
||||
{
|
||||
ResolveFunctions();
|
||||
Install_Patches();
|
||||
|
||||
KDriverInfo = new KDriver_Info();
|
||||
|
||||
// Copy in our start up info.
|
||||
if(p != nullptr)
|
||||
memcpy(KDriverInfo, p, sizeof(KDriver_Info));
|
||||
|
||||
// Set up Driver info.
|
||||
KDriverInfo->MajorVersion = KDRIVER_MAJOR_VERSION;
|
||||
KDriverInfo->MinorVersion = KDRIVER_MINOR_VERSION;
|
||||
KDriverInfo->BuildVersion = KDRIVER_BUILD_VERSION;
|
||||
KDriverInfo->Shutdown = &_Shutdown;
|
||||
|
||||
// Start up main Kdriver Class.
|
||||
OrbisLibInstance = new OrbisLib();
|
||||
|
||||
klog("Hello from Kernel\nKDriver %s v%d.%d.%d", SOFTWARE_VERSION_STR, KDRIVER_MAJOR_VERSION, KDRIVER_MINOR_VERSION, KDRIVER_BUILD_VERSION);
|
||||
|
||||
// Set our running state.
|
||||
KDriverInfo->Running = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
open 192.168.0.55 2121
|
||||
user anonymous anonymous
|
||||
put "/mnt/c/Users/grego/source/repos/Orbis-Suite-2.0/Playstation/Kernel/Kernel/Kernel.elf" "/data/Orbis Suite/Kernel.505.ELF"
|
||||
bye
|
||||
@@ -0,0 +1,42 @@
|
||||
SHELL=/bin/bash
|
||||
|
||||
none:
|
||||
printf "\e[1m\e[31mPlease Choose a firmware!! EG. \"make 505\" \033[37m\n"
|
||||
|
||||
build:
|
||||
cmd.exe /C Increment.bat
|
||||
|
||||
+$(MAKE) -C ShellCode clean
|
||||
+$(MAKE) -C ShellCode
|
||||
+$(MAKE) -C Kernel clean
|
||||
+$(MAKE) -C Kernel
|
||||
+$(MAKE) -C Kernel copy
|
||||
printf "\e[1m\e[32m[%0.2f Build Sucess!]\033[37m\n" "$$(($(VERSION) * 1))e-2"
|
||||
|
||||
505:
|
||||
+$(MAKE) build VERSION=505
|
||||
|
||||
672:
|
||||
+$(MAKE) build VERSION=672
|
||||
|
||||
702:
|
||||
+$(MAKE) build VERSION=702
|
||||
|
||||
755:
|
||||
+$(MAKE) build VERSION=755
|
||||
|
||||
900:
|
||||
+$(MAKE) build VERSION=900
|
||||
|
||||
all:
|
||||
+$(MAKE) build VERSION=505
|
||||
+$(MAKE) build VERSION=672
|
||||
+$(MAKE) build VERSION=702
|
||||
+$(MAKE) build VERSION=755
|
||||
+$(MAKE) build VERSION=900
|
||||
|
||||
@/bin/echo -e "\e[1m\e[32m[All Build Sucess!]\033[37m"
|
||||
|
||||
clean:
|
||||
+$(MAKE) -C ShellCode clean
|
||||
+$(MAKE) -C Kernel clean
|
||||
@@ -0,0 +1,3 @@
|
||||
# Orbis Suite Kernel Driver
|
||||
|
||||
This project is a bit of a mess since I never really have the time to hash out the build process. I will eventually upload the dependancies as another repo though even they are pretty hacked up to make things work :lol: dont judge I am lazy and just want things to do their things.
|
||||
@@ -0,0 +1,221 @@
|
||||
BITS 64
|
||||
DEFAULT REL
|
||||
|
||||
magic: db 'SHEL'
|
||||
entry: dq shellcode
|
||||
|
||||
thr_initial: dq 0
|
||||
ShellCodeComplete: db 0
|
||||
ShouldCallEntry: db 0
|
||||
|
||||
; sceKernelLoadStartModule Variables
|
||||
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
|
||||
ModuleHandle: dq 0
|
||||
|
||||
; Addresses / Misc
|
||||
sceKernelUsleep: dq 0
|
||||
asceKernelLoadStartModule: dq 0
|
||||
libkernel: dq 0
|
||||
str_libkernel: db 'libkernel.sprx', 0
|
||||
str_libkernelweb: db 'libkernel_web.sprx', 0
|
||||
str_libkernelsys: db 'libkernel_sys.sprx', 0
|
||||
str_sceKernelSleep: db 'sceKernelUsleep', 0
|
||||
str_sceKernelLoadStartModule: db 'sceKernelLoadStartModule', 0
|
||||
|
||||
str_scePthreadCreate: db 'scePthreadCreate', 0
|
||||
scePthreadCreate: dq 0
|
||||
str_scePthreadAttrSetstacksize: db 'scePthreadAttrSetstacksize', 0
|
||||
scePthreadAttrSetstacksize: dq 0
|
||||
str_scePthreadAttrInit: db 'scePthreadAttrInit', 0
|
||||
scePthreadAttrInit: dq 0
|
||||
|
||||
hthread: dq 0
|
||||
scePthreadAttr: dq 0
|
||||
str_threadName: db 'Orbis SPRX Loader', 0
|
||||
|
||||
; Work around for oosdk
|
||||
amodule_start: dq 0
|
||||
str_module_start: db 'module_start', 0
|
||||
|
||||
; Main shellcode function.
|
||||
shellcode:
|
||||
; load thread into fs
|
||||
mov rdi, qword [thr_initial]
|
||||
mov rsi, qword [rdi]
|
||||
mov rdi, qword [rsi + 0x1E0]
|
||||
call amd64_set_fsbase
|
||||
|
||||
; get libkernel handle
|
||||
mov rcx, 0
|
||||
lea rdx, [libkernel]
|
||||
mov rsi, 0
|
||||
lea rdi, [str_libkernel]
|
||||
call sys_dynlib_load_prx
|
||||
test rax, rax
|
||||
je resolve
|
||||
|
||||
mov rcx, 0
|
||||
lea rdx, [libkernel]
|
||||
mov rsi, 0
|
||||
lea rdi, [str_libkernelweb]
|
||||
call sys_dynlib_load_prx
|
||||
test rax, rax
|
||||
je resolve
|
||||
|
||||
mov rcx, 0
|
||||
lea rdx, [libkernel]
|
||||
mov rsi, 0
|
||||
lea rdi, [str_libkernelsys]
|
||||
call sys_dynlib_load_prx
|
||||
|
||||
resolve:
|
||||
; resolve sceKernelUsleep
|
||||
lea rdx, [sceKernelUsleep]
|
||||
lea rsi, [str_sceKernelSleep]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve sceKernelLoadStartModule
|
||||
lea rdx, [asceKernelLoadStartModule]
|
||||
lea rsi, [str_sceKernelLoadStartModule]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve scePthreadCreate
|
||||
lea rdx, [scePthreadCreate]
|
||||
lea rsi, [str_scePthreadCreate]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve scePthreadAttrSetstacksize
|
||||
lea rdx, [scePthreadAttrSetstacksize]
|
||||
lea rsi, [str_scePthreadAttrSetstacksize]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve scePthreadAttrInit
|
||||
lea rdx, [scePthreadAttrInit]
|
||||
lea rsi, [str_scePthreadAttrInit]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
call sceKernelLoadStartModule
|
||||
|
||||
; Check if the module loaded and if it did call the entry.
|
||||
cmp dword[ModuleHandle], 0
|
||||
jle didntload
|
||||
|
||||
; Check to see if we shouldnt call the entry manually.
|
||||
cmp byte[ShouldCallEntry], 0
|
||||
je didntload
|
||||
|
||||
; Manually calling Entry.
|
||||
call module_start
|
||||
|
||||
didntload:
|
||||
; Set the Flag we are done.
|
||||
mov byte [ShellCodeComplete], 1
|
||||
|
||||
; Shutdown the thread.
|
||||
mov rdi, 0
|
||||
call sys_thr_exit
|
||||
retn
|
||||
|
||||
|
||||
; Sub function
|
||||
module_start:
|
||||
lea rdx, [amodule_start]
|
||||
lea rsi, [str_module_start]
|
||||
mov rdi, qword [ModuleHandle]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
cmp dword[amodule_start], 0
|
||||
ja found_start
|
||||
|
||||
xor eax, eax
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
found_start:
|
||||
; create attr
|
||||
lea rdi, [scePthreadAttr]
|
||||
mov r12, qword [scePthreadAttrInit]
|
||||
call r12
|
||||
|
||||
; set stack size
|
||||
mov rsi, 0x80000 ; 512 kb
|
||||
lea rdi, [scePthreadAttr]
|
||||
mov r12, qword [scePthreadAttrSetstacksize]
|
||||
call r12
|
||||
|
||||
; create thread
|
||||
lea r8, [str_threadName]
|
||||
mov rcx, 0
|
||||
mov rdx, qword [amodule_start]
|
||||
lea rsi, [scePthreadAttr]
|
||||
lea rdi, [hthread]
|
||||
mov r12, qword [scePthreadCreate]
|
||||
call r12
|
||||
|
||||
xor eax, eax
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sceKernelLoadStartModule:
|
||||
xor r9, r9
|
||||
xor r8, r8
|
||||
xor rcx, rcx
|
||||
xor rdx, rdx
|
||||
xor rsi, rsi
|
||||
lea rdi, [ModulePath]
|
||||
mov r12, qword [asceKernelLoadStartModule]
|
||||
call r12
|
||||
mov qword [ModuleHandle], rax
|
||||
xor eax, eax
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_dynlib_load_prx:
|
||||
mov rax, 594
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_dynlib_dlsym:
|
||||
mov rax, 591
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_thr_exit:
|
||||
mov rax, 431
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_sysarch:
|
||||
mov rax, 165
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
amd64_set_fsbase:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
push rbx
|
||||
sub rsp, 0x18
|
||||
|
||||
mov [rbp - 0x18], rdi
|
||||
|
||||
lea rsi, [rbp - 0x18]
|
||||
mov edi, 129
|
||||
call sys_sysarch
|
||||
|
||||
add rsp, 0x18
|
||||
pop rbx
|
||||
pop rbp
|
||||
retn
|
||||
@@ -0,0 +1,18 @@
|
||||
LoaderShellCode = ../Kernel/Resources/LoaderShellCode.bin
|
||||
LoaderShellCodes = LoaderShellCode.s
|
||||
UnloaderShellCode = ../Kernel/Resources/UnLoaderShellCode.bin
|
||||
UnloaderShellCodes = UnLoaderShellCode.s
|
||||
|
||||
all: clean $(LoaderShellCode)
|
||||
all: clean $(UnloaderShellCode)
|
||||
|
||||
$(LoaderShellCode):
|
||||
nasm -f bin -o $(LoaderShellCode) $(LoaderShellCodes)
|
||||
|
||||
$(UnloaderShellCode):
|
||||
nasm -f bin -o $(UnloaderShellCode) $(UnloaderShellCodes)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f $(LoaderShellCode)
|
||||
rm -f $(UnloaderShellCode)
|
||||
@@ -0,0 +1,191 @@
|
||||
BITS 64
|
||||
DEFAULT REL
|
||||
|
||||
magic: db 'SHEL'
|
||||
entry: dq shellcode
|
||||
|
||||
thr_initial: dq 0
|
||||
ShellCodeComplete: db 0
|
||||
ShouldCallExit: db 0
|
||||
|
||||
ModuleHandle: dq 0
|
||||
Result: dq 0
|
||||
|
||||
; Addresses / Misc
|
||||
sceKernelUsleep: dq 0
|
||||
asceKernelStopUnloadModule: dq 0
|
||||
libkernel: dq 0
|
||||
str_libkernel: db 'libkernel.sprx', 0
|
||||
str_libkernelweb: db 'libkernel_web.sprx', 0
|
||||
str_libkernelsys: db 'libkernel_sys.sprx', 0
|
||||
str_sceKernelSleep: db 'sceKernelUsleep', 0
|
||||
str_sceKernelStopUnloadModule: db 'sceKernelStopUnloadModule', 0
|
||||
|
||||
str_scePthreadCreate: db 'scePthreadCreate', 0
|
||||
scePthreadCreate: dq 0
|
||||
str_scePthreadAttrSetstacksize: db 'scePthreadAttrSetstacksize', 0
|
||||
scePthreadAttrSetstacksize: dq 0
|
||||
str_scePthreadAttrInit: db 'scePthreadAttrInit', 0
|
||||
scePthreadAttrInit: dq 0
|
||||
|
||||
hthread: dq 0
|
||||
scePthreadAttr: dq 0
|
||||
str_threadName: db 'Orbis SPRX UnLoader', 0
|
||||
|
||||
; Work around for oosdk
|
||||
amodule_stop: dq 0
|
||||
str_module_stop: db 'module_stop', 0
|
||||
|
||||
; Main shellcode function.
|
||||
shellcode:
|
||||
; load thread into fs
|
||||
mov rdi, qword [thr_initial]
|
||||
mov rsi, qword [rdi]
|
||||
mov rdi, qword [rsi + 0x1E0]
|
||||
call amd64_set_fsbase
|
||||
|
||||
; get libkernel handle
|
||||
mov rcx, 0
|
||||
lea rdx, [libkernel]
|
||||
mov rsi, 0
|
||||
lea rdi, [str_libkernel]
|
||||
call sys_dynlib_load_prx
|
||||
test rax, rax
|
||||
je resolve
|
||||
|
||||
mov rcx, 0
|
||||
lea rdx, [libkernel]
|
||||
mov rsi, 0
|
||||
lea rdi, [str_libkernelweb]
|
||||
call sys_dynlib_load_prx
|
||||
test rax, rax
|
||||
je resolve
|
||||
|
||||
mov rcx, 0
|
||||
lea rdx, [libkernel]
|
||||
mov rsi, 0
|
||||
lea rdi, [str_libkernelsys]
|
||||
call sys_dynlib_load_prx
|
||||
|
||||
resolve:
|
||||
; resolve sceKernelUsleep
|
||||
lea rdx, [sceKernelUsleep]
|
||||
lea rsi, [str_sceKernelSleep]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve sceKernelStopUnloadModule
|
||||
lea rdx, [asceKernelStopUnloadModule]
|
||||
lea rsi, [str_sceKernelStopUnloadModule]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve scePthreadCreate
|
||||
lea rdx, [scePthreadCreate]
|
||||
lea rsi, [str_scePthreadCreate]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve scePthreadAttrSetstacksize
|
||||
lea rdx, [scePthreadAttrSetstacksize]
|
||||
lea rsi, [str_scePthreadAttrSetstacksize]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
; resolve scePthreadAttrInit
|
||||
lea rdx, [scePthreadAttrInit]
|
||||
lea rsi, [str_scePthreadAttrInit]
|
||||
mov rdi, qword [libkernel]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
call StopModule
|
||||
call sceKernelStopUnloadModule
|
||||
|
||||
; Set the Flag we are done.
|
||||
mov byte [ShellCodeComplete], 1
|
||||
|
||||
; Shutdown the thread.
|
||||
mov rdi, 0
|
||||
call sys_thr_exit
|
||||
retn
|
||||
|
||||
StopModule:
|
||||
; Check to see if we shouldnt call the exit manually.
|
||||
cmp byte[ShouldCallExit], 0
|
||||
je EndofModuleStop
|
||||
|
||||
; Manually calling Exit.
|
||||
lea rdx, [amodule_stop]
|
||||
lea rsi, [str_module_stop]
|
||||
mov rdi, qword [ModuleHandle]
|
||||
call sys_dynlib_dlsym
|
||||
|
||||
cmp dword[amodule_stop], 0
|
||||
jle EndofModuleStop
|
||||
|
||||
mov r12, qword [amodule_stop]
|
||||
call r12
|
||||
|
||||
EndofModuleStop:
|
||||
xor eax, eax
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sceKernelStopUnloadModule:
|
||||
xor r9, r9
|
||||
xor r8, r8
|
||||
xor rcx, rcx
|
||||
xor rdx, rdx
|
||||
xor rsi, rsi
|
||||
mov rdi, [ModuleHandle]
|
||||
mov r12, qword [asceKernelStopUnloadModule]
|
||||
call r12
|
||||
mov qword [Result], rax
|
||||
xor eax, eax
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_dynlib_load_prx:
|
||||
mov rax, 594
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_dynlib_dlsym:
|
||||
mov rax, 591
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_thr_exit:
|
||||
mov rax, 431
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
sys_sysarch:
|
||||
mov rax, 165
|
||||
mov r10, rcx
|
||||
syscall
|
||||
retn
|
||||
|
||||
; Sub function
|
||||
amd64_set_fsbase:
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
push rbx
|
||||
sub rsp, 0x18
|
||||
|
||||
mov [rbp - 0x18], rdi
|
||||
|
||||
lea rsi, [rbp - 0x18]
|
||||
mov edi, 129
|
||||
call sys_sysarch
|
||||
|
||||
add rsp, 0x18
|
||||
pop rbx
|
||||
pop rbp
|
||||
retn
|
||||
@@ -0,0 +1,46 @@
|
||||
#include "Common.h"
|
||||
#include "Build_Overlay.h"
|
||||
|
||||
bool Build_Overlay::Draw = false;
|
||||
Widget* Build_Overlay::Root_Widget = nullptr;
|
||||
|
||||
void Build_Overlay::Update()
|
||||
{
|
||||
if (Draw)
|
||||
{
|
||||
if (Root_Widget->Has_Child("BUILDPANEL"))
|
||||
return;
|
||||
|
||||
//Create new Label for the build string.
|
||||
Label* BuildLabel = new Label("BUILDLABEL", 20.0f, 36.0f, ORBIS_TOOLBOX_BUILDSTRING, 20, Label::fsItalic,
|
||||
Label::fwBold, Label::VerticalAlignment::vCenter, Label::HorizontalAlignment::hCenter, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
//Create new panel for the build Panel.
|
||||
Panel* BuildPanel = new Panel("BUILDPANEL", UI::Utilities::ScreenWidth() - (BuildLabel->Get_Text_Width() + 30.0f), 20.0f, 440.0f, 100.0f,
|
||||
0.92f, 0.2f, 0.16f, 0.8f, Panel::RenderingOrder::Last, UI::Utilities::Adjust_Content(Panel::Vertical, 4, 4, 4, 4));
|
||||
|
||||
//Append the Text to the Build Panel.
|
||||
BuildPanel->Append_Child("BUILDLABEL", BuildLabel);
|
||||
|
||||
//Append the Label to the root widget.
|
||||
Root_Widget->Append_Child("BUILDPANEL", BuildPanel);
|
||||
}
|
||||
else
|
||||
Root_Widget->Remove_Child("BUILDPANEL");
|
||||
}
|
||||
|
||||
void Build_Overlay::Init()
|
||||
{
|
||||
//Init the local widget class with our new root widget.
|
||||
Root_Widget = new Widget();
|
||||
Root_Widget->Instance = UI::Utilities::Get_root_Widget();
|
||||
}
|
||||
|
||||
void Build_Overlay::Term()
|
||||
{
|
||||
//Remove the build panel for destruction.
|
||||
Root_Widget->Remove_Child("BUILDPANEL");
|
||||
|
||||
//Clean up alocated classses.
|
||||
delete Root_Widget;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include "Common.h"
|
||||
#include "Widget.h"
|
||||
|
||||
class Build_Overlay
|
||||
{
|
||||
public:
|
||||
static bool Draw;
|
||||
|
||||
static void Update();
|
||||
static void Init();
|
||||
static void Term();
|
||||
|
||||
private:
|
||||
static Widget* Root_Widget;
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <errno.h>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <orbis/libkernel.h>
|
||||
#include <orbis/libmonovm.h>
|
||||
|
||||
#include "Version.h"
|
||||
#include "Utilities.h"
|
||||
#include "Mono.h"
|
||||
#include "Detour.h"
|
||||
#include "Patcher.h"
|
||||
#include "UI.h"
|
||||
#include "Menu.h"
|
||||
|
||||
#include "Widget.h"
|
||||
#include "Label.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#define ORBIS_TOOLBOX_NOTIFY ("Orbis Toolbox Alpha: " stringify(ORBIS_TOOLBOX_MAJOR) "." stringify(ORBIS_TOOLBOX_MINOR) " Loaded!")
|
||||
@@ -0,0 +1,266 @@
|
||||
#include "Common.h"
|
||||
#include "Config.h"
|
||||
|
||||
#include "Settings_Menu.h"
|
||||
#include "Debug_Features.h"
|
||||
#include "LncUtil.h"
|
||||
#include "Game_Overlay.h"
|
||||
#include "Build_Overlay.h"
|
||||
#include "Config.h"
|
||||
|
||||
/*bool Config::Parse(const char* File)
|
||||
{
|
||||
//Clear the previous data.
|
||||
Config_Data.clear();
|
||||
|
||||
//Check if file is already open.
|
||||
if (RFile_Handle.is_open())
|
||||
{
|
||||
RFile_Handle.close();
|
||||
|
||||
klog("Failed to open File (%s) - File already open\n", File);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Open file.
|
||||
RFile_Handle = std::fstream(File, std::ios::in);
|
||||
|
||||
//Make sure file actually opened.
|
||||
if (!RFile_Handle.is_open())
|
||||
{
|
||||
klog("Failed to open File (%s)\n", File);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Global Vars for parsing the config file.
|
||||
std::map<std::string, std::string> Current_Members;
|
||||
std::string Current_Line;
|
||||
std::string Current_Section;
|
||||
int Current_Line_Number = 0;
|
||||
|
||||
//Loop through all lines of file.
|
||||
while (std::getline(RFile_Handle, Current_Line))
|
||||
{
|
||||
//Increment Line count.
|
||||
Current_Line_Number++;
|
||||
|
||||
//If the line starts with the comment block or is an empty line ignore this line.
|
||||
if ((strstr((Current_Line.substr(0, 1)).c_str(), ";")) || Current_Line.empty()) {
|
||||
klog("Found Comment / Empty Line at %i\n", Current_Line_Number);
|
||||
continue;
|
||||
}
|
||||
|
||||
//If Line is a Section Block set current Section we are in.
|
||||
if (strstr((Current_Line.substr(0, 1)).c_str(), "["))
|
||||
{
|
||||
//If were entering a new section store the previous section to the map.
|
||||
if ((Current_Section.c_str() != NULL && Current_Section.empty() == false) && Config_Data.find(Current_Section.c_str()) == Config_Data.end()) {
|
||||
klog("Storing Section \"%s\" to map.\n", Current_Section.c_str());
|
||||
Config_Data.insert(std::make_pair(Current_Section, Current_Members));
|
||||
}
|
||||
|
||||
//clear the temporary stored data.
|
||||
Current_Members.clear();
|
||||
|
||||
//Get the index of the open and close delimiter and set the string between them as our current section.
|
||||
unsigned first = Current_Line.find('[') + 1;
|
||||
unsigned last = Current_Line.find(']');
|
||||
Current_Section = Current_Line.substr(first, last - first);
|
||||
|
||||
klog("Section \"%s\" Found at line %i\n", Current_Section.c_str(), Current_Line_Number);
|
||||
|
||||
//Go to next line to start parsing section.
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string Member_Name = "";
|
||||
std::string Member_Data = "";
|
||||
|
||||
//Parse member name from before '=' and the data to EOL after '='.
|
||||
Member_Name = Current_Line.substr(0, Current_Line.find('='));
|
||||
Member_Data = Current_Line.substr(Current_Line.find('=') + 1, (Current_Line.length() - (Current_Line.find('=') + 1) - 1));
|
||||
|
||||
//Insert member into temporary map.
|
||||
Current_Members.insert(std::make_pair(Member_Name, Member_Data));
|
||||
}
|
||||
|
||||
//Store The last Section.
|
||||
if (Config_Data.find(Current_Section.c_str()) == Config_Data.end()) {
|
||||
klog("Storing Section \"%s\" to map.\n", Current_Section.c_str());
|
||||
Config_Data.insert(std::make_pair(Current_Section, Current_Members));
|
||||
}
|
||||
|
||||
if (!RFile_Handle.is_open()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RFile_Handle.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Config::Does_Member_Exist(const char* Section, const char* Member)
|
||||
{
|
||||
if (Config_Data.find(Section) == Config_Data.end())
|
||||
{
|
||||
klog("Failed to find Section \"%s\".\n", Section);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Config_Data[Section].find(Member) == Config_Data[Section].end())
|
||||
{
|
||||
klog("Failed to find Member \"%s\" in Section \"%s\".\n", Member, Section);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Config::Read_Bool(const char* Section, const char* Member)
|
||||
{
|
||||
if (!Does_Member_Exist(Section, Member))
|
||||
return false;
|
||||
|
||||
std::string Data = Config_Data[Section][Member];
|
||||
|
||||
if (Data.compare("true") || Data.compare("yes") || Data.compare("1"))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int Config::Read_Int(const char* Section, const char* Member)
|
||||
{
|
||||
if (!Does_Member_Exist(Section, Member))
|
||||
return -1;
|
||||
|
||||
return atoi(Config_Data[Section][Member].c_str());
|
||||
}
|
||||
|
||||
float Config::Read_Float(const char* Section, const char* Member)
|
||||
{
|
||||
if (!Does_Member_Exist(Section, Member))
|
||||
return -1.0f;
|
||||
|
||||
return atof(Config_Data[Section][Member].c_str());
|
||||
}
|
||||
|
||||
std::string Config::Read_String(const char* Section, const char* Member)
|
||||
{
|
||||
if (!Does_Member_Exist(Section, Member))
|
||||
return "";
|
||||
|
||||
return Config_Data[Section][Member];
|
||||
}*/
|
||||
|
||||
Config::Data_s* Config::Data;
|
||||
#define CFG_VERSION 1
|
||||
|
||||
bool Config::Read(const char* File)
|
||||
{
|
||||
int fd = sceKernelOpen(File, SCE_KERNEL_O_RDONLY, 0511);
|
||||
|
||||
if (fd)
|
||||
{
|
||||
//Reade the data then close the file handle.
|
||||
sceKernelRead(fd, (void*)Data, sizeof(Data_s));
|
||||
sceKernelClose(fd);
|
||||
|
||||
//Make sure the version matches.
|
||||
if (Data->Version != CFG_VERSION)
|
||||
{
|
||||
klog("[Config] CFG Version miss match (%i != %i)...\nConfig Could be corrupt...\n", CFG_VERSION, Data->Version);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Could be a good idea to take a digest here to see if things have changed and compare with the digest at 0x4.
|
||||
|
||||
|
||||
klog("[Config] Read Config Sucessfully.\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
klog("[Config] File: %s Does not exist.\n", File);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Config::Parse(const char* File)
|
||||
{
|
||||
if (Read(File))
|
||||
{
|
||||
//Parse data out.
|
||||
Menu::Auto_Load_Settings = Data->Auto_Load_Settings;
|
||||
Debug_Feature::DebugTitleIdLabel::ShowLabels = Data->Show_DebugTitleIdLabel;
|
||||
Debug_Feature::DevkitPanel::ShowPanel = Data->Show_DevkitPanel;
|
||||
Debug_Feature::Custom_Content::Show_Debug_Settings = Data->Show_Debug_Settings;
|
||||
Debug_Feature::Custom_Content::Show_App_Home = Data->Show_App_Home;
|
||||
|
||||
Build_Overlay::Draw = Data->Show_Build_Overlay;
|
||||
|
||||
strcpy(Game_Overlay::Location, Data->Game_Overlay_Location);
|
||||
Game_Overlay::Show_CPU_Usage = Data->Show_CPU_Usage;
|
||||
Game_Overlay::Show_Thread_Count = Data->Show_Thread_Count;
|
||||
Game_Overlay::Show_ram = Data->Show_ram;
|
||||
Game_Overlay::Show_vram = Data->Show_vram;
|
||||
Game_Overlay::Show_CPU_Temp = Data->Show_CPU_Temp;
|
||||
Game_Overlay::Show_SOC_Temp = Data->Show_SOC_Temp;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Config::Write(const char* File)
|
||||
{
|
||||
int fd = sceKernelOpen(File, SCE_KERNEL_O_CREAT | SCE_KERNEL_O_WRONLY, 0777);
|
||||
|
||||
if (fd)
|
||||
{
|
||||
//Build new cfg file.
|
||||
Data->Version = CFG_VERSION;
|
||||
|
||||
Data->Auto_Load_Settings = Menu::Auto_Load_Settings;
|
||||
Data->Show_DebugTitleIdLabel = Debug_Feature::DebugTitleIdLabel::ShowLabels;
|
||||
Data->Show_DevkitPanel = Debug_Feature::DevkitPanel::ShowPanel;
|
||||
Data->Show_Debug_Settings = Debug_Feature::Custom_Content::Show_Debug_Settings;
|
||||
Data->Show_App_Home = Debug_Feature::Custom_Content::Show_App_Home;
|
||||
|
||||
Data->Show_Build_Overlay = Build_Overlay::Draw;
|
||||
|
||||
strcpy(Data->Game_Overlay_Location, Game_Overlay::Location);
|
||||
Data->Show_CPU_Usage = Game_Overlay::Show_CPU_Usage;
|
||||
Data->Show_Thread_Count = Game_Overlay::Show_Thread_Count;
|
||||
Data->Show_ram = Game_Overlay::Show_ram;
|
||||
Data->Show_vram = Game_Overlay::Show_vram;
|
||||
Data->Show_CPU_Temp = Game_Overlay::Show_CPU_Temp;
|
||||
Data->Show_SOC_Temp = Game_Overlay::Show_SOC_Temp;
|
||||
|
||||
//Take digest and write it.
|
||||
|
||||
//Write Data
|
||||
sceKernelWrite(fd, (void*)Data, sizeof(Data_s));
|
||||
sceKernelClose(fd);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
klog("[Config] File: %s Does not exist & Could not be created.\n", File);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Config::Init()
|
||||
{
|
||||
Data = new Data_s();
|
||||
}
|
||||
|
||||
void Config::Term()
|
||||
{
|
||||
delete Data;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
bool Parse(const char* File);
|
||||
|
||||
bool Read_Bool(const char* Section, const char* Member);
|
||||
int Read_Int(const char* Section, const char* Member);
|
||||
float Read_Float(const char* Section, const char* Member);
|
||||
std::string Read_String(const char* Section, const char* Member);
|
||||
|
||||
private:
|
||||
std::fstream RFile_Handle;
|
||||
std::fstream WFile_Handle;
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string>> Config_Data;
|
||||
|
||||
bool Does_Member_Exist(const char* Section, const char* Member);
|
||||
};*/
|
||||
#pragma once
|
||||
|
||||
class Config
|
||||
{
|
||||
private:
|
||||
struct Data_s
|
||||
{
|
||||
int Version;
|
||||
|
||||
bool Auto_Load_Settings;
|
||||
bool Show_DebugTitleIdLabel;
|
||||
bool Show_DevkitPanel;
|
||||
bool Show_Debug_Settings;
|
||||
bool Show_App_Home;
|
||||
|
||||
bool Show_Build_Overlay;
|
||||
|
||||
char Game_Overlay_Location[0x100];
|
||||
bool Show_CPU_Usage;
|
||||
bool Show_Thread_Count;
|
||||
bool Show_ram;
|
||||
bool Show_vram;
|
||||
bool Show_CPU_Temp;
|
||||
bool Show_SOC_Temp;
|
||||
};
|
||||
|
||||
public:
|
||||
static Data_s* Data;
|
||||
|
||||
static bool Read(const char* File);
|
||||
static bool Parse(const char* File);
|
||||
static bool Write(const char* File);
|
||||
|
||||
static void Init();
|
||||
static void Term();
|
||||
};
|
||||
@@ -0,0 +1,111 @@
|
||||
#include "Common.h"
|
||||
#include "Debug_Features.h"
|
||||
|
||||
Detour* Debug_Feature::Custom_Content::Detour_ExecuteSelectQuery = nullptr;
|
||||
Detour* Debug_Feature::Custom_Content::Detour_ExecuteCountQuery = nullptr;
|
||||
Detour* Debug_Feature::Custom_Content::Detour_StartDebugSettings = nullptr;
|
||||
Detour* Debug_Feature::Custom_Content::Detour_GetIconPath = nullptr;
|
||||
Detour* Debug_Feature::Custom_Content::Detour_IsInstalled = nullptr;
|
||||
|
||||
bool Debug_Feature::Custom_Content::Show_App_Home;
|
||||
bool Debug_Feature::Custom_Content::Show_Debug_Settings;
|
||||
|
||||
MonoObject* Debug_Feature::Custom_Content::ExecuteSelectQuery_Hook(MonoObject* Instance, int offset, int limit)
|
||||
{
|
||||
//System.Collections.Generic List
|
||||
MonoClass* List = Mono::Get_Class(Mono::mscorlib, "System.Collections.Generic", "List`1");
|
||||
|
||||
MonoObject* List_Instance = Detour_ExecuteSelectQuery->Stub<MonoObject*>(Instance, offset, limit);
|
||||
if (Mono::Get_Field<int>(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", Instance, "exclusionFilterTypeAppHome") == 0)
|
||||
{
|
||||
if (Show_Debug_Settings)
|
||||
Mono::Invoke<void>(Mono::Accessor_Db, List, List_Instance, "Insert", 0, UI::Utilities::AppBrowseItem("NPXS20993", "★Orbis Toolbox"));
|
||||
|
||||
if (Show_App_Home)
|
||||
{
|
||||
Mono::Invoke<void>(Mono::Accessor_Db, List, List_Instance, "Insert", 0, UI::Utilities::AppBrowseItem("NPXS29998", "★APP_HOME(data)"));
|
||||
Mono::Invoke<void>(Mono::Accessor_Db, List, List_Instance, "Insert", 0, UI::Utilities::AppBrowseItem("NPXS29999", "★APP_HOME(host)"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return List_Instance;
|
||||
}
|
||||
|
||||
int Debug_Feature::Custom_Content::ExecuteCountQuery_Hook(MonoObject* Instance)
|
||||
{
|
||||
int Count = Detour_ExecuteCountQuery->Stub<int>(Instance);
|
||||
|
||||
if (Mono::Get_Field<int>(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", Instance, "exclusionFilterTypeAppHome") == 0)
|
||||
{
|
||||
if (Show_Debug_Settings)
|
||||
Count += 1;
|
||||
|
||||
if (Show_App_Home)
|
||||
Count += 2;
|
||||
}
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
void Debug_Feature::Custom_Content::StartDebugSettings_Hook(MonoObject* Instance)
|
||||
{
|
||||
MonoClass* UIManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.Settings.Core", "UIManager");
|
||||
MonoClass* SettingsApplication = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI", "SettingsApplication");
|
||||
Mono::Invoke<void>(Mono::App_exe, UIManager, Mono::Get_Field<MonoObject*>(SettingsApplication, Instance, "uiManager"), "Push", Mono::New_String("orbis_toolbox.xml"), Mono::New_String("id_orbis_toolbox"), 3);
|
||||
}
|
||||
|
||||
MonoString* GetTexture(const char* texId)
|
||||
{
|
||||
// /Application/resource/Sce.Vsh.ShellUI.Base.rco
|
||||
return Mono::New_String("cxml://BasePlugin/%s", texId);
|
||||
}
|
||||
|
||||
MonoString* Debug_Feature::Custom_Content::GetIconPath_Hook(MonoObject* item, bool withTheme)
|
||||
{
|
||||
MonoString* IconPath = Detour_GetIconPath->Stub<MonoString*>(item, withTheme);
|
||||
|
||||
char* TitleId = mono_string_to_utf8(Mono::Get_Property<MonoString*>(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemLite", item, "TitleId"));
|
||||
if (!strcmp(TitleId, "NPXS29999"))
|
||||
return GetTexture("tex_app_home");
|
||||
else if (!strcmp(TitleId, "NPXS29998"))
|
||||
return GetTexture("tex_app_home_data");
|
||||
else if (!strcmp(TitleId, "NPXS20993"))
|
||||
return GetTexture("tex_debug_settings");
|
||||
else
|
||||
return IconPath;
|
||||
}
|
||||
|
||||
bool Debug_Feature::Custom_Content::IsInstalled_Hook(MonoString* titleId)
|
||||
{
|
||||
char* ctitleId = mono_string_to_utf8(titleId);
|
||||
|
||||
// Kinda ghetto but the detour stub was brokie.
|
||||
return strstr(ctitleId, "NPXS20") != nullptr || (!strcmp(ctitleId, "NPXS21008") || !strcmp(ctitleId, "NPXS27003")) || !strcmp(ctitleId, "NPXS27009") || !strcmp(ctitleId, "NPXS29998") || !strcmp(ctitleId, "NPXS29999");
|
||||
}
|
||||
|
||||
void Debug_Feature::Custom_Content::Init()
|
||||
{
|
||||
Detour_ExecuteSelectQuery = new Detour();
|
||||
Detour_ExecuteCountQuery = new Detour();
|
||||
Detour_StartDebugSettings = new Detour();
|
||||
Detour_GetIconPath = new Detour();
|
||||
Detour_IsInstalled = new Detour();
|
||||
|
||||
|
||||
|
||||
Detour_ExecuteSelectQuery->DetourMethod(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", "ExecuteSelectQuery", 2, (void*)ExecuteSelectQuery_Hook);
|
||||
Detour_ExecuteCountQuery->DetourMethod(Mono::Accessor_Db, "Sce.Vsh.Accessor.Db", "AppBrowseItemAccessor", "ExecuteCountQuery", 0, (void*)ExecuteCountQuery_Hook);
|
||||
Detour_StartDebugSettings->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI", "SettingsApplication", "StartDebugSettings", 0, (void*)StartDebugSettings_Hook);
|
||||
Detour_GetIconPath->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "AppBrowseItemMethodExteneder", "GetIconPath", 2, (void*)GetIconPath_Hook);
|
||||
Detour_IsInstalled->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.AppSystem", "ApplicationMonitor/AppConfig", "IsLaunchable", 1, (void*)IsInstalled_Hook);
|
||||
}
|
||||
|
||||
void Debug_Feature::Custom_Content::Term()
|
||||
{
|
||||
delete Detour_ExecuteSelectQuery;
|
||||
delete Detour_ExecuteCountQuery;
|
||||
delete Detour_StartDebugSettings;
|
||||
delete Detour_GetIconPath;
|
||||
delete Detour_IsInstalled;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
#include "Common.h"
|
||||
#include "Daemons.h"
|
||||
|
||||
#include "SysfileUtilWrapper.h"
|
||||
#include "LncUtil.h"
|
||||
|
||||
bool Start_Daemon(char* TitleId)
|
||||
{
|
||||
if (!Is_Daemon_Running(TitleId))
|
||||
{
|
||||
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None };
|
||||
LncUtil::LaunchApp(TitleId, 0, 0, &p);
|
||||
|
||||
if (!Is_Daemon_Running(TitleId))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Stop_Daemon(char* TitleId)
|
||||
{
|
||||
int AppId = LncUtil::GetAppId(TitleId);
|
||||
if (AppId > 0)
|
||||
{
|
||||
LncUtil::KillApp(AppId);
|
||||
|
||||
if (Is_Daemon_Running(TitleId))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Is_Daemon_Running(char* TitleId)
|
||||
{
|
||||
return (LncUtil::GetAppId(TitleId) > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
Will start or stop a Daemon depending on its state.
|
||||
|
||||
TitleId - A string representing the Daemons title Index usually in form of XXXX#####
|
||||
Restart - If the Daemon is already running will stop and restart it.
|
||||
*/
|
||||
bool Start_Stop_Daemon(char* TitleId, bool Restart)
|
||||
{
|
||||
int AppId = LncUtil::GetAppId(TitleId);
|
||||
if (AppId > 0)
|
||||
{
|
||||
LncUtil::KillApp(AppId);
|
||||
|
||||
if ((LncUtil::GetAppId(TitleId) <= 0) && Restart)
|
||||
return Start_Stop_Daemon(TitleId, false);
|
||||
else if (LncUtil::GetAppId(TitleId) <= 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None };
|
||||
LncUtil::LaunchApp(TitleId, 0, 0, &p);
|
||||
|
||||
return (LncUtil::GetAppId(TitleId) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Add_Daemon(char* dent)
|
||||
{
|
||||
char TitleId[10];
|
||||
char Id_Name[0x100];
|
||||
char Icon_Path[PATH_MAX];
|
||||
char SFO_Path[PATH_MAX];
|
||||
|
||||
strcpy(TitleId, dent);
|
||||
sprintf(Id_Name, "id_%s", TitleId);
|
||||
sprintf(Icon_Path, "file://system/vsh/app/%s/sce_sys/icon0.png", TitleId);
|
||||
sprintf(SFO_Path, "/system/vsh/app/%s/sce_sys/param.sfo", TitleId);
|
||||
|
||||
//Adds a custom button to the current drawing stack with the name and desc. of the daemon from the param.sfo
|
||||
UI::Utilities::AddMenuItem(UI::Utilities::ElementData(Id_Name, SysfileUtilWrapper::GetTitle(SFO_Path), SysfileUtilWrapper::GetDescription(SFO_Path), Icon_Path));
|
||||
|
||||
//Remove Menu Option if already Exists.
|
||||
if (Menu::Has_Option(Id_Name))
|
||||
Menu::Remove_Option(Id_Name);
|
||||
|
||||
//Add Menu Option with call back to load Daemon.
|
||||
Menu::Add_Option(Id_Name, [TitleId, Id_Name]() -> void {
|
||||
|
||||
int AppId = LncUtil::GetAppId(TitleId);
|
||||
if (AppId > 0) //App is Currently Running.
|
||||
{
|
||||
UI::Utilities::Set_Value(Id_Name, "Stopping");
|
||||
UI::Utilities::ResetMenuItem(Id_Name);
|
||||
|
||||
//Kill the app.
|
||||
LncUtil::KillApp(AppId);
|
||||
|
||||
//Check to see if it worked.
|
||||
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped");
|
||||
UI::Utilities::ResetMenuItem(Id_Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
UI::Utilities::Set_Value(Id_Name, "Starting");
|
||||
UI::Utilities::ResetMenuItem(Id_Name);
|
||||
|
||||
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None };
|
||||
LncUtil::LaunchApp(TitleId, 0, 0, &p);
|
||||
|
||||
//Check to see if it worked.
|
||||
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped");
|
||||
UI::Utilities::ResetMenuItem(Id_Name);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//Shows the current status of the daemon.
|
||||
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped");
|
||||
UI::Utilities::ResetMenuItem(Id_Name);
|
||||
}
|
||||
|
||||
void Remove_Daemon(char* dent)
|
||||
{
|
||||
char Id_Name[0x100];
|
||||
sprintf(Id_Name, "id_%s", dent);
|
||||
|
||||
UI::Utilities::RemoveMenuItem(Id_Name);
|
||||
Menu::Remove_Option(Id_Name);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
bool Start_Daemon(char* TitleId);
|
||||
bool Stop_Daemon(char* TitleId);
|
||||
bool Is_Daemon_Running(char* TitleId);
|
||||
bool Start_Stop_Daemon(char* TitleId, bool Restart = false);
|
||||
|
||||
void Add_Daemon(char* dent);
|
||||
void Remove_Daemon(char* dent);
|
||||
@@ -0,0 +1,130 @@
|
||||
#include "Common.h"
|
||||
#include "Debug_Features.h"
|
||||
|
||||
void(*Debug_Feature::DebugTitleIdLabel::CreateDebugTitleIdLabel)(MonoObject* Instance);
|
||||
Detour* Debug_Feature::DebugTitleIdLabel::Detour_ContentDecoratorBase_Constructor = nullptr;
|
||||
|
||||
Patcher* Debug_Feature::DebugTitleIdLabel::Patch_createDevKitPanel = nullptr;
|
||||
|
||||
bool Debug_Feature::DebugTitleIdLabel::ShowLabels = false;
|
||||
|
||||
uint64_t Debug_Feature::DebugTitleIdLabel::ContentDecoratorBase_Constructor_Hook(MonoObject* Instance, uint64_t param)
|
||||
{
|
||||
uint64_t res = Detour_ContentDecoratorBase_Constructor->Stub<uint64_t>(Instance, param);
|
||||
|
||||
if (ShowLabels)
|
||||
CreateDebugTitleIdLabel(Instance);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::AddTitleId(MonoObject* m_contentsGridList)
|
||||
{
|
||||
MonoClass* ReadOnlyCollection = Mono::Get_Class(Mono::mscorlib, "System.Collections.ObjectModel", "ReadOnlyCollection`1");
|
||||
|
||||
if (m_contentsGridList)
|
||||
{
|
||||
MonoObject* ActiveItems = Mono::Get_Property<MonoObject*>(Mono::UI_dll, Mono::PUI_UI2, "ListPanelBase", m_contentsGridList, "ActiveItems");
|
||||
|
||||
for (int i = 0; i < Mono::Get_Property<int>(ReadOnlyCollection, ActiveItems, "Count"); i++)
|
||||
{
|
||||
MonoObject* Member = Mono::Invoke<MonoObject*>(Mono::mscorlib, ReadOnlyCollection, ActiveItems, "get_Item", i);
|
||||
MonoObject* ListVisualizer = Mono::Get_Property<MonoObject*>(Mono::Vsh_Lx, "Sce.Vsh.Lx", "ListItem", Member, "ListVisualizer");
|
||||
MonoObject* m_decorator = Mono::Get_Field<MonoObject*>(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentVisualizer", ListVisualizer, "m_decorator");
|
||||
CreateDebugTitleIdLabel(m_decorator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::RemoveTitleId(MonoObject* m_contentsGridList)
|
||||
{
|
||||
MonoClass* ReadOnlyCollection = Mono::Get_Class(Mono::mscorlib, "System.Collections.ObjectModel", "ReadOnlyCollection`1");
|
||||
|
||||
if (m_contentsGridList)
|
||||
{
|
||||
MonoObject* ActiveItems = Mono::Get_Property<MonoObject*>(Mono::UI_dll, Mono::PUI_UI2, "ListPanelBase", m_contentsGridList, "ActiveItems");
|
||||
|
||||
for (int i = 0; i < Mono::Get_Property<int>(ReadOnlyCollection, ActiveItems, "Count"); i++)
|
||||
{
|
||||
MonoObject* Member = Mono::Invoke<MonoObject*>(Mono::mscorlib, ReadOnlyCollection, ActiveItems, "get_Item", i);
|
||||
MonoObject* ListVisualizer = Mono::Get_Property<MonoObject*>(Mono::Vsh_Lx, "Sce.Vsh.Lx", "ListItem", Member, "ListVisualizer");
|
||||
MonoObject* m_decorator = Mono::Get_Field<MonoObject*>(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentVisualizer", ListVisualizer, "m_decorator");
|
||||
MonoObject* m_iconImageBox = Mono::Get_Field<MonoObject*>(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", m_decorator, "m_iconImageBox");
|
||||
|
||||
if (m_iconImageBox)
|
||||
{
|
||||
MonoArray* Children = Mono::Invoke<MonoArray*>(Mono::App_exe, Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Node`1"), m_iconImageBox, "GetChildrenArray");
|
||||
|
||||
for (int i = 0; i < mono_array_length(Children); i++)
|
||||
{
|
||||
MonoObject* Instance = mono_array_get(Children, MonoObject*, i);
|
||||
|
||||
if (!Instance)
|
||||
continue;
|
||||
|
||||
if (!Instance->vtable)
|
||||
continue;
|
||||
|
||||
if (!Instance->vtable->klass)
|
||||
continue;
|
||||
|
||||
if (strcmp(Instance->vtable->klass->name, "Label"))
|
||||
continue;
|
||||
|
||||
Mono::Invoke<void>(Mono::App_exe, Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Widget"), Instance, "RemoveFromParent");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::Update()
|
||||
{
|
||||
Debug_Feature::DebugTitleIdLabel::ShowLabels ? Show() : Hide();
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::Show()
|
||||
{
|
||||
MonoClass* ContentsAreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentsAreaManager");
|
||||
MonoObject* m_scene = Mono::Get_Field<MonoObject*>(ContentsAreaManager, Mono::Get_Instance(ContentsAreaManager, "Instance"), "m_scene");
|
||||
MonoArray* m_contentsGridList = Mono::Get_Field<MonoArray*>(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentAreaScene", m_scene, "m_contentsGridList");
|
||||
|
||||
AddTitleId(mono_array_get(m_contentsGridList, MonoObject*, 0));
|
||||
AddTitleId(mono_array_get(m_contentsGridList, MonoObject*, 1));
|
||||
|
||||
ShowLabels = true;
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::Hide()
|
||||
{
|
||||
MonoClass* ContentsAreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentsAreaManager");
|
||||
MonoObject* m_scene = Mono::Get_Field<MonoObject*>(ContentsAreaManager, Mono::Get_Instance(ContentsAreaManager, "Instance"), "m_scene");
|
||||
MonoArray* m_contentsGridList = Mono::Get_Field<MonoArray*>(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "ContentAreaScene", m_scene, "m_contentsGridList");
|
||||
|
||||
RemoveTitleId(mono_array_get(m_contentsGridList, MonoObject*, 0));
|
||||
RemoveTitleId(mono_array_get(m_contentsGridList, MonoObject*, 1));
|
||||
|
||||
ShowLabels = false;
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::Init()
|
||||
{
|
||||
uint64_t CreateDebugTitleIdLabel_addr = Mono::Get_Address_of_Method(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", "CreateDebugTitleIdLabel", 0);
|
||||
CreateDebugTitleIdLabel = decltype(CreateDebugTitleIdLabel)(CreateDebugTitleIdLabel_addr);
|
||||
|
||||
//Patch RegMgr Check
|
||||
Patch_createDevKitPanel = new Patcher();
|
||||
Patch_createDevKitPanel->Install_Method_Patch(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", "CreateDebugTitleIdLabel", 0, 0x2C, "\x90\x90\x90\x90\x90\x90", 6);
|
||||
|
||||
Detour_ContentDecoratorBase_Constructor = new Detour();
|
||||
Detour_ContentDecoratorBase_Constructor->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.Library", "ContentDecoratorBase", ".ctor", 1, (void*)ContentDecoratorBase_Constructor_Hook);
|
||||
}
|
||||
|
||||
void Debug_Feature::DebugTitleIdLabel::Term()
|
||||
{
|
||||
//Clean up Patches
|
||||
delete Patch_createDevKitPanel;
|
||||
|
||||
//Clean up Detours
|
||||
delete Detour_ContentDecoratorBase_Constructor;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
class Debug_Feature
|
||||
{
|
||||
public:
|
||||
class Custom_Content
|
||||
{
|
||||
private:
|
||||
static Detour* Detour_ExecuteSelectQuery;
|
||||
static Detour* Detour_ExecuteCountQuery;
|
||||
static Detour* Detour_StartDebugSettings;
|
||||
static Detour* Detour_GetIconPath;
|
||||
static Detour* Detour_IsInstalled;
|
||||
|
||||
static MonoObject* ExecuteSelectQuery_Hook(MonoObject* Instance, int offset, int limit);
|
||||
static int ExecuteCountQuery_Hook(MonoObject* Instance);
|
||||
static void StartDebugSettings_Hook(MonoObject* Instance);
|
||||
static MonoString* GetIconPath_Hook(MonoObject* item, bool withTheme);
|
||||
static bool IsInstalled_Hook(MonoString* titleId);
|
||||
|
||||
public:
|
||||
static bool Show_App_Home;
|
||||
static bool Show_Debug_Settings;
|
||||
|
||||
static void Init();
|
||||
static void Term();
|
||||
};
|
||||
|
||||
class DebugTitleIdLabel
|
||||
{
|
||||
private:
|
||||
static void(*CreateDebugTitleIdLabel)(MonoObject* Instance);
|
||||
static Detour* Detour_ContentDecoratorBase_Constructor;
|
||||
static uint64_t ContentDecoratorBase_Constructor_Hook(MonoObject* Instance, uint64_t param);
|
||||
|
||||
static Patcher* Patch_createDevKitPanel;
|
||||
|
||||
static void AddTitleId(MonoObject* m_contentsGridList);
|
||||
static void RemoveTitleId(MonoObject* m_contentsGridList);
|
||||
|
||||
public:
|
||||
static bool ShowLabels;
|
||||
|
||||
static void Update();
|
||||
static void Show();
|
||||
static void Hide();
|
||||
static void Init();
|
||||
static void Term();
|
||||
};
|
||||
|
||||
class DevkitPanel
|
||||
{
|
||||
private:
|
||||
static void(*createDevKitPanel)(MonoObject* Instance);
|
||||
static Detour* Detour_AreaManager_Constructor;
|
||||
static uint64_t AreaManager_Constructor_Hook(MonoObject* Instance);
|
||||
|
||||
public:
|
||||
static bool ShowPanel;
|
||||
|
||||
static void Update();
|
||||
static void Show();
|
||||
static void Hide();
|
||||
static bool GetState();
|
||||
static void Init();
|
||||
static void Term();
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "Common.h"
|
||||
#include "Detour.h"
|
||||
#include "Mono.h"
|
||||
#include "hde64.h"
|
||||
|
||||
void Detour::WriteJump(void* Address, void* Destination)
|
||||
{
|
||||
uint8_t JumpInstructions[] = {
|
||||
0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // jmp QWORD PTR[Address]
|
||||
};
|
||||
|
||||
//Write the address of our hook to the instruction.
|
||||
*(uint64_t*)(JumpInstructions + 6) = (uint64_t)Destination;
|
||||
|
||||
sceKernelMprotect((void*)Address, sizeof(JumpInstructions), VM_PROT_ALL);
|
||||
memcpy(Address, JumpInstructions, sizeof(JumpInstructions));
|
||||
}
|
||||
|
||||
void* Detour::DetourFunction(uint64_t FunctionPtr, void* HookPtr)
|
||||
{
|
||||
if (FunctionPtr == NULL || HookPtr == NULL)
|
||||
{
|
||||
klog("[Detour] DetourFunction: FunctionPtr or HookPtr NULL (%llX -> %llX)\n", FunctionPtr, HookPtr);
|
||||
return (void*)0;
|
||||
}
|
||||
uint32_t InstructionSize = 0;
|
||||
|
||||
while (InstructionSize < 14)
|
||||
{
|
||||
hde64s hs;
|
||||
uint32_t temp = hde64_disasm((void*)(FunctionPtr + InstructionSize), &hs);
|
||||
|
||||
if (hs.flags & F_ERROR)
|
||||
return (void*)0;
|
||||
|
||||
InstructionSize += temp;
|
||||
}
|
||||
|
||||
klog("InstructionSize: %i\n", InstructionSize);
|
||||
|
||||
if (InstructionSize < 14)
|
||||
{
|
||||
klog("[Detour] DetourFunction: Hooking Requires a minimum of 14 bytes to write jump!\n");
|
||||
return (void*)0;
|
||||
}
|
||||
|
||||
//Save Pointers for later
|
||||
this->FunctionPtr = (void*)FunctionPtr;
|
||||
this->HookPtr = HookPtr;
|
||||
|
||||
//Set protection.
|
||||
sceKernelMprotect((void*)FunctionPtr, InstructionSize, VM_PROT_ALL);
|
||||
|
||||
//Allocate Executable memory for stub and write instructions to stub and a jump back to original execution.
|
||||
this->StubSize = (InstructionSize + 14);
|
||||
int res = sceKernelMmap(0, this->StubSize, VM_PROT_ALL, 0x1000 | 0x2, -1, 0, &this->StubPtr);
|
||||
if (res < 0 || this->StubPtr == 0)
|
||||
{
|
||||
klog("[Detour] sceKernelMmap Failed: 0x%llX\n", res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(StubPtr, (void*)FunctionPtr, InstructionSize);
|
||||
WriteJump((void*)((uint64_t)StubPtr + InstructionSize), (void*)(FunctionPtr + InstructionSize));
|
||||
|
||||
//Write jump from function to hook.
|
||||
WriteJump((void*)FunctionPtr, HookPtr);
|
||||
|
||||
klog("[Detour] DetourFunction: Detour (%llX -> %llX) Written Successfully!\n", FunctionPtr, this->HookPtr);
|
||||
|
||||
return this->StubPtr;
|
||||
}
|
||||
|
||||
void* Detour::DetourMethod(MonoImage* Assembly_Image, const char* Namespace, const char* Klass, const char* Method, int Param_Count, void* HookPtr)
|
||||
{
|
||||
uint64_t Method_addr = Mono::Get_Address_of_Method(Assembly_Image, Namespace, Klass, Method, Param_Count);
|
||||
|
||||
if (Method_addr == NULL)
|
||||
{
|
||||
klog("[Detour] DetourMethod: Method address returned null!\n");
|
||||
return (void*)0;
|
||||
}
|
||||
|
||||
return DetourFunction(Method_addr, HookPtr);
|
||||
}
|
||||
|
||||
void Detour::RestoreFunction()
|
||||
{
|
||||
if (this->StubPtr)
|
||||
{
|
||||
sceKernelMprotect((void*)this->FunctionPtr, this->StubSize - 14, VM_PROT_ALL);
|
||||
memcpy((void*)this->FunctionPtr, this->StubPtr, this->StubSize - 14);
|
||||
|
||||
klog("[Detour] RestoreFunction: (%llX) has been Restored Successfully!\n", this->FunctionPtr);
|
||||
}
|
||||
}
|
||||
|
||||
Detour::Detour()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Detour::~Detour()
|
||||
{
|
||||
RestoreFunction();
|
||||
|
||||
//Clean up
|
||||
sceKernelMunmap(this->StubPtr, this->StubSize);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
class Detour
|
||||
{
|
||||
private:
|
||||
|
||||
void* StubPtr = 0;
|
||||
size_t StubSize = 0;
|
||||
|
||||
void* FunctionPtr = 0;
|
||||
void* HookPtr = 0;
|
||||
|
||||
public:
|
||||
template <typename result, typename... Args>
|
||||
result Stub(Args... args)
|
||||
{
|
||||
result(*Stub_internal)(Args... args) = decltype(Stub_internal)(StubPtr);
|
||||
return Stub_internal(args...);
|
||||
}
|
||||
|
||||
void WriteJump(void* Address, void* Destination);
|
||||
void* DetourFunction(uint64_t FunctionPtr, void* HookPtr);
|
||||
void* DetourMethod(MonoImage* Assembly_Image, const char* Namespace, const char* Klass, const char* Method, int Param_Count, void* HookPtr);
|
||||
void RestoreFunction();
|
||||
|
||||
Detour();
|
||||
~Detour();
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "Common.h"
|
||||
#include "Debug_Features.h"
|
||||
|
||||
void(*Debug_Feature::DevkitPanel::createDevKitPanel)(MonoObject* Instance) = nullptr;
|
||||
Detour* Debug_Feature::DevkitPanel::Detour_AreaManager_Constructor = nullptr;
|
||||
|
||||
bool Debug_Feature::DevkitPanel::ShowPanel = false;
|
||||
|
||||
uint64_t Debug_Feature::DevkitPanel::AreaManager_Constructor_Hook(MonoObject* Instance)
|
||||
{
|
||||
uint64_t res = Detour_AreaManager_Constructor->Stub<uint64_t>(Instance);
|
||||
|
||||
if (ShowPanel)
|
||||
createDevKitPanel(Instance);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
void Debug_Feature::DevkitPanel::Update()
|
||||
{
|
||||
Debug_Feature::DevkitPanel::ShowPanel ? Show() : Hide();
|
||||
}
|
||||
|
||||
void Debug_Feature::DevkitPanel::Show()
|
||||
{
|
||||
MonoClass* AreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager");
|
||||
MonoObject* AreaManager_Instance = Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance");
|
||||
MonoObject* m_devKitPanel = Mono::Get_Field<MonoObject*>(AreaManager, AreaManager_Instance, "m_devKitPanel");
|
||||
MonoClass* Widget = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "Widget");
|
||||
|
||||
// AreaManager.Instance.m_devKitPanel
|
||||
// If m_devKitPanel is null we must create the panel first.
|
||||
if (!m_devKitPanel)
|
||||
{
|
||||
createDevKitPanel(Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance"));
|
||||
}
|
||||
else
|
||||
{
|
||||
MonoClass* UITimer = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UITimer");
|
||||
MonoObject* m_updatePanelTimer = Mono::Get_Field<MonoObject*>(AreaManager, AreaManager_Instance, "m_updatePanelTimer");
|
||||
|
||||
// AreaManager.Instance.m_updatePanelTimer.Start()
|
||||
// If the m_updatePanelTimer is initialized start the timer.
|
||||
if (m_updatePanelTimer)
|
||||
Mono::Invoke<void>(Mono::UI_dll, UITimer, m_updatePanelTimer, "Start");
|
||||
|
||||
// AreaManager.Instance.m_devKitPanel.Show()
|
||||
// Show the panel.
|
||||
MonoClass* UINode = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UINode");
|
||||
Mono::Invoke<void>(Mono::UI_dll, UINode, m_devKitPanel, "Show");
|
||||
}
|
||||
|
||||
ShowPanel = true;
|
||||
}
|
||||
|
||||
void Debug_Feature::DevkitPanel::Hide()
|
||||
{
|
||||
MonoClass* AreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager");
|
||||
MonoObject* AreaManager_Instance = Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance");
|
||||
|
||||
MonoClass* UITimer = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UITimer");
|
||||
MonoObject* m_updatePanelTimer = Mono::Get_Field<MonoObject*>(AreaManager, AreaManager_Instance, "m_updatePanelTimer");
|
||||
|
||||
// AreaManager.Instance.m_updatePanelTimer.Stop()
|
||||
// If the m_updatePanelTimer is initialized stop the timer.
|
||||
if (m_updatePanelTimer)
|
||||
Mono::Invoke<void>(Mono::UI_dll, UITimer, m_updatePanelTimer, "Stop");
|
||||
|
||||
// AreaManager.Instance.m_devKitPanel.Hide()
|
||||
// Hide the panel.
|
||||
MonoObject* m_devKitPanel = Mono::Get_Field<MonoObject*>(AreaManager, AreaManager_Instance, "m_devKitPanel");
|
||||
if (m_devKitPanel)
|
||||
{
|
||||
MonoClass* UINode = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "UINode");
|
||||
Mono::Invoke<void>(Mono::UI_dll, UINode, m_devKitPanel, "Hide");
|
||||
}
|
||||
|
||||
ShowPanel = false;
|
||||
}
|
||||
|
||||
bool Debug_Feature::DevkitPanel::GetState()
|
||||
{
|
||||
MonoClass* FrameTask = Mono::Get_Class(Mono::UI_dll, Mono::PUI, "FrameTask");
|
||||
MonoClass* AreaManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager");
|
||||
MonoObject* AreaManager_Instance = Mono::Get_Instance(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "Instance");
|
||||
MonoObject* m_devKitPanel = Mono::Get_Field<MonoObject*>(AreaManager, AreaManager_Instance, "m_devKitPanel");
|
||||
MonoObject* m_updatePanelTimer = Mono::Get_Field<MonoObject*>(AreaManager, AreaManager_Instance, "m_updatePanelTimer");
|
||||
|
||||
if (m_devKitPanel && m_updatePanelTimer)
|
||||
return !Mono::Get_Property<bool>(FrameTask, m_updatePanelTimer, "IsStopped");
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void Debug_Feature::DevkitPanel::Init()
|
||||
{
|
||||
//Get Method to make devkit panel
|
||||
uint64_t createDevKitPanel_addr = Mono::Get_Address_of_Method(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", "createDevKitPanel", 0);
|
||||
createDevKitPanel = decltype(createDevKitPanel)(createDevKitPanel_addr);
|
||||
|
||||
//Hook AreaManager Constructor
|
||||
Detour_AreaManager_Constructor = new Detour();
|
||||
Detour_AreaManager_Constructor->DetourMethod(Mono::App_exe, "Sce.Vsh.ShellUI.TopMenu", "AreaManager", ".ctor", 0, (void*)AreaManager_Constructor_Hook);
|
||||
}
|
||||
|
||||
void Debug_Feature::DevkitPanel::Term()
|
||||
{
|
||||
delete Detour_AreaManager_Constructor;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
.section .rodata
|
||||
.global settings_root
|
||||
.type settings_root, @object
|
||||
.align 4
|
||||
.global orbis_toolbox
|
||||
.type orbis_toolbox, @object
|
||||
.align 4
|
||||
.global external_hdd
|
||||
.type external_hdd, @object
|
||||
.align 4
|
||||
|
||||
settings_root:
|
||||
.incbin "settings_root.xml"
|
||||
settings_root_End:
|
||||
.global settings_root_Size
|
||||
.type settings_root_Size, @object
|
||||
.align 4
|
||||
settings_root_Size:
|
||||
.int settings_root_End - settings_root
|
||||
|
||||
orbis_toolbox:
|
||||
.incbin "orbis_toolbox.xml"
|
||||
orbis_toolbox_End:
|
||||
.global orbis_toolbox_Size
|
||||
.type orbis_toolbox_Size, @object
|
||||
.align 4
|
||||
orbis_toolbox_Size:
|
||||
.int orbis_toolbox_End - orbis_toolbox
|
||||
|
||||
external_hdd:
|
||||
.incbin "external_hdd.xml"
|
||||
external_hdd_End:
|
||||
.global external_hdd_Size
|
||||
.type external_hdd_Size, @object
|
||||
.align 4
|
||||
external_hdd_Size:
|
||||
.int external_hdd_End - external_hdd
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "Common.h"
|
||||
#include "GamePad.h"
|
||||
|
||||
bool GamePad::IsDown(int button)
|
||||
{
|
||||
return Mono::Invoke<bool>(Mono::App_exe, Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.DebugSystem", "KeyMonitorTask"), NULL, "IsButtonDown", button);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
class GamePad
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
enum Buttons
|
||||
{
|
||||
Left = 1U,
|
||||
Up,
|
||||
Right = 4U,
|
||||
Down = 8U,
|
||||
Square = 16U,
|
||||
Triangle = 32U,
|
||||
Circle = 64U,
|
||||
Cross = 128U,
|
||||
Start = 256U,
|
||||
Select = 512U,
|
||||
L = 1024U,
|
||||
R = 2048U,
|
||||
L2 = 4096U,
|
||||
R2 = 8192U,
|
||||
L3 = 16384U,
|
||||
R3 = 32768U,
|
||||
Enter = 65536U,
|
||||
Back = 131072U
|
||||
};
|
||||
|
||||
static bool IsDown(int button);
|
||||
};
|
||||
@@ -0,0 +1,259 @@
|
||||
#include "Common.h"
|
||||
#include "Game_Overlay.h"
|
||||
#include "System_Monitor.h"
|
||||
|
||||
float Game_Overlay::X, Game_Overlay::Y;
|
||||
bool Game_Overlay::Show_CPU_Usage = false;
|
||||
bool Game_Overlay::Show_Thread_Count = false;
|
||||
bool Game_Overlay::Show_ram = false;
|
||||
bool Game_Overlay::Show_vram = false;
|
||||
bool Game_Overlay::Show_CPU_Temp = false;
|
||||
bool Game_Overlay::Show_SOC_Temp = false;
|
||||
char Game_Overlay::Location[0x100] = { "Left" };
|
||||
|
||||
float Game_Overlay::Text_Height = 0.0f;
|
||||
Widget* Game_Overlay::Game_Widget = nullptr;
|
||||
std::map<const char*, CALL_BACK_TYPE>* Game_Overlay::Updater;
|
||||
bool Game_Overlay::Shutdown = false;
|
||||
|
||||
/*
|
||||
Init_Overlay(const char* Name, CALL_BACK_TYPE_D)
|
||||
This will push each of our labels made and their call backs for data updates
|
||||
to a std::map. Currently it has issues with ordering **Needs refactor**.
|
||||
*/
|
||||
|
||||
void Game_Overlay::Init_Overlay(const char* Name, CALL_BACK_TYPE_D)
|
||||
{
|
||||
Label* Temp = new Label(Name, 10.0f, 10.0f, "", 20, Label::fsNormal, Label::fwMedium, Label::vBottom, Label::hLeft, 1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Game_Widget->Append_Child(Name, Temp);
|
||||
Text_Height = Temp->Get_Text_Height();
|
||||
|
||||
Updater->insert(Updater->begin(), std::make_pair(Name, CallBack));
|
||||
}
|
||||
|
||||
/*
|
||||
Update_Location()
|
||||
This will update the global vars for X and Y depending on where the user
|
||||
decides to draw the overlay which is stored in the text Location.
|
||||
|
||||
Currenttly supporting Left, Right and Center. May Impliment a vertical
|
||||
location to this in the future.
|
||||
*/
|
||||
|
||||
void Game_Overlay::Update_Location()
|
||||
{
|
||||
if (!strcmp(Location, "Left"))
|
||||
{
|
||||
X = 10.0f, Y = 5.0f;
|
||||
for (std::map<const char*, CALL_BACK_TYPE>::iterator it = Updater->begin(); it != Updater->end(); it++)
|
||||
{
|
||||
Label* Instance = (Label*)Game_Widget->Get_Child(it->first);
|
||||
Instance->hAlign = Label::hLeft;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(Location, "Right"))
|
||||
{
|
||||
X = UI::Utilities::ScreenWidth() - 10.0f, Y = 5.0f;
|
||||
for (std::map<const char*, CALL_BACK_TYPE>::iterator it = Updater->begin(); it != Updater->end(); it++)
|
||||
{
|
||||
Label* Instance = (Label*)Game_Widget->Get_Child(it->first);
|
||||
Instance->hAlign = Label::hRight;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(Location, "Center"))
|
||||
{
|
||||
X = UI::Utilities::ScreenWidth() / 2.0f, Y = 5.0f;
|
||||
for (std::map<const char*, CALL_BACK_TYPE>::iterator it = Updater->begin(); it != Updater->end(); it++)
|
||||
{
|
||||
Label* Instance = (Label*)Game_Widget->Get_Child(it->first);
|
||||
Instance->hAlign = Label::hCenter;
|
||||
}
|
||||
}
|
||||
|
||||
Update();
|
||||
}
|
||||
|
||||
/*
|
||||
OnRender()
|
||||
Anything called in this function will be called in the main mono render
|
||||
loop.
|
||||
|
||||
Checks for Game_Widget pointer and boolean Shutdown for safety.
|
||||
|
||||
Here we will iterate through all of the overlays supported and decide
|
||||
which to draw and their location.
|
||||
*/
|
||||
|
||||
void Game_Overlay::OnRender()
|
||||
{
|
||||
if (!Game_Widget || Shutdown)
|
||||
return;
|
||||
|
||||
static int Waiter = 0;
|
||||
|
||||
if (Waiter <= 0)
|
||||
{
|
||||
for (std::map<const char*, CALL_BACK_TYPE>::iterator it = Updater->begin(); it != Updater->end(); it++)
|
||||
{
|
||||
Label* Instance = (Label*)Game_Widget->Get_Child(it->first);
|
||||
it->second(Instance);
|
||||
}
|
||||
|
||||
Waiter = 100;
|
||||
}
|
||||
else
|
||||
Waiter--;
|
||||
}
|
||||
|
||||
void inline Game_Overlay::Update_Label(int* Location, const char* Name)
|
||||
{
|
||||
Label* Instance = (Label*)Game_Widget->Get_Child(Name);
|
||||
if ((*Updater)[Name](Instance))
|
||||
{
|
||||
Instance->Set_Location(X, Y + (*Location * 25.0f));
|
||||
Instance->Set_Colour(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
*Location += 1;
|
||||
}
|
||||
else
|
||||
Instance->Set_Colour(1.0f, 1.0f, 1.0f, 0.0f);
|
||||
}
|
||||
|
||||
void Game_Overlay::Update()
|
||||
{
|
||||
klog("Update...\n");
|
||||
|
||||
int Count = 0;
|
||||
Update_Label(&Count, "CPUUSAGE");
|
||||
Update_Label(&Count, "CPUUSAGEAVG");
|
||||
Update_Label(&Count, "THREADCOUNT");
|
||||
Update_Label(&Count, "RAMUSAGE");
|
||||
Update_Label(&Count, "VRAMUSAGE");
|
||||
Update_Label(&Count, "CPUTEMP");
|
||||
Update_Label(&Count, "SOCTEMP");
|
||||
}
|
||||
|
||||
void Game_Overlay::Init()
|
||||
{
|
||||
//Get Relevent Classes.
|
||||
MonoClass* LayerManager = Mono::Get_Class(Mono::App_exe, "Sce.Vsh.ShellUI.AppSystem", "LayerManager");
|
||||
MonoClass* ContainerScene = Mono::Get_Class(Mono::UI_dll, Mono::PUI_UI2, "ContainerScene");
|
||||
|
||||
//Initialize Game Scene widget
|
||||
Game_Widget = new Widget();
|
||||
MonoObject* Game = Mono::Invoke<MonoObject*>(Mono::App_exe, LayerManager, nullptr, "FindContainerSceneByPath", Mono::New_String("Game"));
|
||||
Game_Widget->Instance = Mono::Get_Property<MonoObject*>(Mono::UI_dll, Mono::PUI_UI2, "Scene", Game, "RootWidget");
|
||||
|
||||
//Set location to left.
|
||||
strcpy(Location, "Left");
|
||||
X = 10.0f, Y = 5.0f;
|
||||
|
||||
//Init map: For somereason doesnt work with out being allocated.
|
||||
Updater = new std::map<const char*, CALL_BACK_TYPE>();
|
||||
|
||||
//Initialize call back for updating overlay types.
|
||||
Init_Overlay("CPUTEMP", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_CPU_Temp)
|
||||
{
|
||||
Instance->Set_Text("CPU Temp: %i C", System_Monitor::CPU_Temp);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
Init_Overlay("SOCTEMP", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_SOC_Temp)
|
||||
{
|
||||
Instance->Set_Text("SOC Temp: %i C", System_Monitor::SOC_Temp);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
Init_Overlay("THREADCOUNT", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_Thread_Count)
|
||||
{
|
||||
Instance->Set_Text("Thread Count: %i", System_Monitor::Thread_Count);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
Init_Overlay("CPUUSAGE", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_CPU_Usage)
|
||||
{
|
||||
Instance->Set_Text("CPU Usage: %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%% %2.0f%%",
|
||||
System_Monitor::Usage[0], System_Monitor::Usage[1], System_Monitor::Usage[2], System_Monitor::Usage[3],
|
||||
System_Monitor::Usage[4], System_Monitor::Usage[5], System_Monitor::Usage[6], System_Monitor::Usage[7]);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
|
||||
Init_Overlay("CPUUSAGEAVG", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_CPU_Usage)
|
||||
{
|
||||
Instance->Set_Text("CPU Usage Average: %2.0f%%", System_Monitor::Average_Usage);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
Init_Overlay("RAMUSAGE", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_ram)
|
||||
{
|
||||
Instance->Set_Text("RAM: %2.0f%% %u MB / %u MB", System_Monitor::RAM.Percentage, System_Monitor::RAM.Used, System_Monitor::RAM.Total);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
Init_Overlay("VRAMUSAGE", [](Label* Instance) -> bool {
|
||||
|
||||
if (Show_vram)
|
||||
{
|
||||
Instance->Set_Text("VRAM: %2.0f%% %u MB / %u MB", System_Monitor::VRAM.Percentage, System_Monitor::VRAM.Used, System_Monitor::VRAM.Total);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
void Game_Overlay::Term()
|
||||
{
|
||||
Shutdown = true;
|
||||
|
||||
if (Game_Widget)
|
||||
{
|
||||
for (std::map<const char*, CALL_BACK_TYPE>::iterator it = Updater->begin(); it != Updater->end(); it++)
|
||||
Game_Widget->Remove_Child(it->first);
|
||||
|
||||
delete Game_Widget;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
#include "Widget.h"
|
||||
#include "Common.h"
|
||||
|
||||
#define CALL_BACK_TYPE bool(*)(Label*)
|
||||
#define CALL_BACK_TYPE_D bool(*CallBack)(Label*)
|
||||
|
||||
class Game_Overlay
|
||||
{
|
||||
public:
|
||||
static bool Show_CPU_Usage;
|
||||
static bool Show_Thread_Count;
|
||||
static bool Show_ram;
|
||||
static bool Show_vram;
|
||||
static bool Show_CPU_Temp;
|
||||
static bool Show_SOC_Temp;
|
||||
static char Location[0x100];
|
||||
|
||||
static void Update_Location();
|
||||
static void OnRender();
|
||||
|
||||
static void Update();
|
||||
static void Init();
|
||||
static void Term();
|
||||
|
||||
private:
|
||||
static float X, Y;
|
||||
static float Text_Height;
|
||||
static Widget* Game_Widget;
|
||||
|
||||
static std::map<const char*, CALL_BACK_TYPE>* Updater;
|
||||
static bool Shutdown;
|
||||
|
||||
static void Update_Label(int* Location, const char* Name);
|
||||
static void Init_Overlay(const char* Name, CALL_BACK_TYPE_D);
|
||||
};
|
||||
@@ -0,0 +1,66 @@
|
||||
echo off
|
||||
REM you need this to set and read a variable inside
|
||||
REM a parethetical structure such as a FOR loop
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM This is the file we are going to alter
|
||||
set filepath=%1
|
||||
set filename=%~n1%~x1
|
||||
|
||||
REM Use temp file
|
||||
REM delete if already exists
|
||||
REM so we can use append operator for all output
|
||||
if exist "%filepath%.temp" del "%filepath%.temp"
|
||||
|
||||
REM For each line in the file...
|
||||
REM ...using FOR alone to parse the file skips blank lines so we...
|
||||
REM ...parse the output (note single quotes) of...
|
||||
REM running TYPE on the file and piping the output through FINDSTR...
|
||||
REM ...with the /n switch (this adds a line number and a colon at the start of each line)
|
||||
REM the FINDSTR search string is ".*" (find any characters including cr/lf)
|
||||
REM Split into 2* tokens, the asterisk means %%R is the entire remainder of the line
|
||||
REM delimiter being the colon thus...
|
||||
REM The number is token 1, %%Q (discarded, along with the colon)
|
||||
REM The original source file line is token 2, %%R
|
||||
REM note we escape the pipe character with a caret ^ in the FOR dataset block
|
||||
for /f "tokens=1,2* delims=:" %%Q in ('type "%filepath%" ^| findstr /n ".*"') do (
|
||||
|
||||
REM if token 2 is null then the line is blank so we echo a blank line to the temp output file
|
||||
if "%%R"=="" echo. >> "%filepath%.temp"
|
||||
|
||||
REM This flag gets set to 1 if we have a line that needs changing
|
||||
set incflag=0
|
||||
|
||||
REM Split the line into 3 tokens with white space the delimiter
|
||||
for /f "tokens=1-3 delims= " %%A in ("%%R") do (
|
||||
|
||||
REM test if an increment needs to happen and set the flag if it does
|
||||
if "%%B"==%2 set incflag=1
|
||||
REM %%C is the number
|
||||
|
||||
REM If the line contains a number to increment...
|
||||
if !incflag! equ 1 (
|
||||
REM do it...
|
||||
set /a num=%%C+1
|
||||
|
||||
REM info msg to console
|
||||
echo Incrementing %%B from %%C to !num!
|
||||
|
||||
REM write the altered line to file
|
||||
echo %%A %%B !num! >>"%filepath%.temp"
|
||||
|
||||
REM the line is a nonblank one that simply needs copying
|
||||
) else (
|
||||
|
||||
echo %%R >> "%filepath%.temp"
|
||||
|
||||
REM Match those parentheses!
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
REM delete original file
|
||||
del "%filepath%"
|
||||
|
||||
REM rename temp file to original file name
|
||||
ren "%filepath%.temp" "%filename%"
|
||||
@@ -0,0 +1,147 @@
|
||||
#include "Common.h"
|
||||
#include "KDriver.h"
|
||||
|
||||
bool KDriver::TestDriver()
|
||||
{
|
||||
int fd = sceKernelOpen("/dev/OrbisSuite", SCE_KERNEL_O_RDONLY, 0);
|
||||
if (fd > 0)
|
||||
{
|
||||
klog("Driver Installed...\n");
|
||||
sceKernelClose(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
klog("Driver Not Installed...\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KDriver::GetDriverInfo(KDriver_Info* Info)
|
||||
{
|
||||
int fd = sceKernelOpen("/dev/OrbisSuite", 0, 0);
|
||||
if (fd > 0)
|
||||
{
|
||||
int res = ioctl(fd, KDRIVER_INFO, Info);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
klog("KDRIVER_INFO failed with %d\n", res);
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
klog("Where kernel??\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int KDriver::GetProcessList(int ProcessCount, ProcInfo* ProcList)
|
||||
{
|
||||
auto fd = sceKernelOpen("/dev/OrbisSuite", 0, 0);
|
||||
if (fd > 0)
|
||||
{
|
||||
auto Info = new KDriver_ProcList();
|
||||
Info->UserlandAddr = (uint64_t)ProcList;
|
||||
Info->UserlandSize = ((sizeof(ProcInfo) * ProcessCount));
|
||||
Info->ProcCount = ProcessCount;
|
||||
|
||||
auto res = ioctl(fd, PROC_LIST, Info);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
delete Info;
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
delete Info;
|
||||
|
||||
return Info->ProcCount;
|
||||
}
|
||||
else
|
||||
klog("Where kernel??\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int KDriver::LoadSPRX(const char* ProccessName, const char* Path, bool ShouldCallEntry)
|
||||
{
|
||||
klog("OrbisDriver::LoadSPRX\n");
|
||||
auto fd = sceKernelOpen("/dev/OrbisSuite", 0, 0);
|
||||
if (fd > 0)
|
||||
{
|
||||
KDriver_ProcSPRX ProcSPRX;
|
||||
ProcSPRX.CallType = 0;
|
||||
strcpy(ProcSPRX.ProcName, ProccessName);
|
||||
strcpy(ProcSPRX.Path, Path);
|
||||
ProcSPRX.CallEntryExit = ShouldCallEntry;
|
||||
|
||||
auto res = ioctl(fd, PROC_SPRX, &ProcSPRX);
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
klog("Where kernel??\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int KDriver::UnLoadSPRX(const char* ProccessName, const char* Name, bool ShouldCallExit)
|
||||
{
|
||||
klog("OrbisDriver::UnLoadSPRX\n");
|
||||
auto fd = sceKernelOpen("/dev/OrbisSuite", 0, 0);
|
||||
if (fd > 0)
|
||||
{
|
||||
KDriver_ProcSPRX ProcSPRX;
|
||||
ProcSPRX.CallType = 1;
|
||||
strcpy(ProcSPRX.ProcName, ProccessName);
|
||||
strcpy(ProcSPRX.Path, Name);
|
||||
ProcSPRX.CallEntryExit = ShouldCallExit;
|
||||
|
||||
auto res = ioctl(fd, PROC_SPRX, &ProcSPRX);
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
klog("Where kernel??\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int KDriver::UnLoadSPRX(const char* ProccessName, int ModuleHandle, bool ShouldCallExit)
|
||||
{
|
||||
klog("OrbisDriver::UnLoadSPRX\n");
|
||||
auto fd = sceKernelOpen("/dev/OrbisSuite", 0, 0);
|
||||
if (fd > 0)
|
||||
{
|
||||
KDriver_ProcSPRX ProcSPRX;
|
||||
ProcSPRX.CallType = 2;
|
||||
strcpy(ProcSPRX.ProcName, ProccessName);
|
||||
ProcSPRX.Handle = ModuleHandle;
|
||||
ProcSPRX.CallEntryExit = ShouldCallExit;
|
||||
|
||||
auto res = ioctl(fd, PROC_SPRX, &ProcSPRX);
|
||||
|
||||
sceKernelClose(fd);
|
||||
|
||||
return res;
|
||||
}
|
||||
else
|
||||
klog("Where kernel??\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user