Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cuevavirus committed May 30, 2020
0 parents commit 0acb2ce
Show file tree
Hide file tree
Showing 14 changed files with 1,838 additions and 0 deletions.
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Sysident

Playstation Vita plugin to show system information in the settings app.

Made by Princess of Sleeping.
44 changes: 44 additions & 0 deletions SysidentKernel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 2.8)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()

project(SysidentKernel)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -fno-inline")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")

enable_language(C ASM)

add_executable(SysidentKernel
src/main.c
)

target_link_libraries(SysidentKernel
SceDebugForDriver_stub
SceIofilemgrForDriver_stub
SceSblSsMgrForDriver_stub
SceSysclibForDriver_stub
SceSysmemForDriver_stub
SceThreadmgrForDriver_stub
taihenForKernel_stub
taihenModuleUtils_stub
)

set_target_properties(SysidentKernel
PROPERTIES LINK_FLAGS "-nostdlib"
COMPILE_FLAGS "-D__VITA_KERNEL__"
)

vita_create_self(sysident.skprx SysidentKernel
CONFIG exports.yml
UNSAFE
)

vita_create_stubs(stubs SysidentKernel ${CMAKE_SOURCE_DIR}/exports.yml KERNEL)
13 changes: 13 additions & 0 deletions SysidentKernel/exports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SysidentKernel:
attributes: 0
version:
major: 1
minor: 0
main:
start: module_start
stop: module_stop
modules:
SysidentForUser:
syscall: true
functions:
- sysidentGetBootloaderRevision
76 changes: 76 additions & 0 deletions SysidentKernel/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Sysident Kernel
* Copyright (C) 2020, 浅倉麗子, sysie, Princess of Sleeping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <psp2kern/kernel/cpu.h>
#include <psp2kern/kernel/modulemgr.h>
#include <psp2kern/kernel/threadmgr.h>
#include <psp2kern/kernel/sysmem.h>
#include <psp2kern/io/fcntl.h>
#include <psp2kern/io/stat.h>
#include <taihen.h>

#include "sysident_helper.h"
#include "sysroot.h"

#define HookExport(module_name, library_nid, func_nid, func_name) taiHookFunctionExportForKernel(0x10005, &func_name ## _ref, module_name, library_nid, func_nid, func_name ## _patched)
#define HookImport(module_name, library_nid, func_nid, func_name) taiHookFunctionImportForKernel(0x10005, &func_name ## _ref, module_name, library_nid, func_nid, func_name ## _patched)
#define HookOffset(modid, offset, thumb, func_name) taiHookFunctionOffsetForKernel(0x10005, &func_name ## _ref, modid, 0, offset, thumb, func_name ## _patched)

#define HookRelease(hook_uid, hook_func_name) ({ \
(hook_uid > 0) ? taiHookReleaseForKernel(hook_uid, hook_func_name ## _ref) : -1; \
})

int module_get_export_func(SceUID pid, const char *modname, unsigned int lib_nid, unsigned int func_nid, uintptr_t *func);

#define GetExport(modname, lib_nid, func_nid, func) module_get_export_func(KERNEL_PID, modname, lib_nid, func_nid, (uintptr_t *)func)

// #define printf ksceDebugPrintf
#define printf(...)

// old name is sceKernelGetSysrootBuffer
SceBootArgs *(* sceKernelSysrootGetKblParam)(void);

int sysidentGetBootloaderRevision(int *pRev){

int state, res;

ENTER_SYSCALL(state);

if(pRev == NULL){
res = 0x80020006;
}else{
res = ksceKernelMemcpyKernelToUser((uintptr_t)pRev, (const void *)&sceKernelSysrootGetKblParam()->bootldr_revision, 4);
}

EXIT_SYSCALL(state);

return res;
}

void _start() __attribute__ ((weak, alias ("module_start")));
int module_start(SceSize argc, const void *args){

if(GetExport("SceSysmem", 0x3691DA45, 0x9DB56D1F, &sceKernelSysrootGetKblParam) < 0)
return SCE_KERNEL_START_NO_RESIDENT;

return SCE_KERNEL_START_SUCCESS;
}

__attribute__((noinline))
int module_stop(SceSize argc, const void *args){
return SCE_KERNEL_STOP_SUCCESS;
}
23 changes: 23 additions & 0 deletions SysidentKernel/src/sysident_helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Sysident Helper header
* Copyright (C) 2020, 浅倉麗子, sysie, Princess of Sleeping
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#ifndef _SYSIDENT_KERNEL_H_
#define _SYSIDENT_KERNEL_H_

int sysidentGetBootloaderRevision(int *rev);

#endif // _SYSIDENT_KERNEL_H_
61 changes: 61 additions & 0 deletions SysidentKernel/src/sysroot.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

#ifndef _PSP2_KERNEL_SYSROOT_H_
#define _PSP2_KERNEL_SYSROOT_H_

#include <psp2kern/types.h>

typedef struct SceBootArgs {
unsigned short version;
unsigned short size;
int current_fw_version;
int factory_fw_version;
uint8_t unk_C[0x14];
uint8_t qa_flags[0x10];
uint8_t boot_flags[0x10];

// Begin Dipsw
uint32_t devkit_cp_timestamp_1;
uint16_t devkit_cp_version;
uint16_t devkit_cp_build_id;
uint32_t devkit_cp_timestamp_2;
uint32_t aslr_seed;
uint32_t devkit_boot_parameters;
uint32_t unk_54;
uint32_t devkit_unk_flags;
uint32_t devkit_flags_3;
// End Dipsw

unsigned int dram_base;
SceSize dram_size;
uint32_t unk_68;
uint32_t boot_type_indicator_1;
uint8_t open_psid[0x10];

unsigned int secure_kernel_enp_addr;
SceSize secure_kernel_enp_size;
unsigned int context_auth_sm_self_addr;
SceSize context_auth_sm_self_size;
unsigned int kprx_auth_sm_self_addr;
SceSize kprx_auth_sm_self_size;
unsigned int prog_rvk_srvk_addr;
SceSize prog_rvk_srvk_size;

uint8_t pscode[0x8];
uint8_t unk_A8[0x8];
uint8_t session_id[0x10];
uint32_t unk_C0;
uint32_t wakeup_factor;
uint32_t unk_C8;
uint32_t unk_CC;
unsigned int resume_context_addr;
uint32_t hardware_info;
uint32_t boot_type_indicator_2;
uint8_t unk_DC[0xC];
uint8_t hardware_flags[0x10];
uint32_t bootldr_revision;
uint32_t magic;
uint8_t session_key[0x20];
uint8_t unused[0xE0];
} __attribute__((packed)) SceBootArgs;

#endif // _PSP2_KERNEL_SYSROOT_H_
52 changes: 52 additions & 0 deletions SysidentUser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 2.8)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()

project(SysidentUser)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -fno-inline")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions")

enable_language(C ASM)

include_directories(
)

link_directories(
${CMAKE_CURRENT_BINARY_DIR}
)

add_executable(SysidentUser
src/main.c
src/taihen_min.c
src/i2f.S
)

target_link_libraries(SysidentUser
SceLibKernel_stub
SceSblSsMgr_stub
SceSblPostSsMgr_stub
SceKernelModulemgr_stub
SceKernelThreadMgr_stub
SceSysmem_stub
SceVshBridge_stub
taihen_stub
${CMAKE_CURRENT_BINARY_DIR}/../SysidentKernel/libSysidentKernel_stub_weak.a
)

set_target_properties(SysidentUser
PROPERTIES LINK_FLAGS "-nostdlib"
)

vita_create_self(sysident.suprx SysidentUser
CONFIG exports.yml
UNSAFE
)

8 changes: 8 additions & 0 deletions SysidentUser/exports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SysidentUser:
attributes: 0
version:
major: 1
minor: 0
main:
start: module_start
stop: module_stop
32 changes: 32 additions & 0 deletions SysidentUser/src/i2f.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

.align 4
.text
.cpu cortex-a9
.arch armv7-a
.syntax unified
.thumb
.thumb_func
.fpu neon

.global i2f
.type i2f, %function

@ int i2f(float *dst, uint32_t val);

i2f:
// 1024
movs r3, #0
movt r3, #0x4480

vmov s0, r3

vmov s1, r1
vcvt.f32.u32 s1, s1

vdiv.f32 s0, s1, s0

vstr s0, [r0]

bx lr

.data
Loading

0 comments on commit 0acb2ce

Please sign in to comment.