├── .gitignore ├── LICENSE ├── README.md ├── source ├── cobra_mamba.c └── ps3mapi_ps3_lib.c ├── Makefile └── include └── ps3mapi_ps3_lib.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Damián Parrino 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PS3 Manager API (PS3MAPI) 2 | 3 | PS3 Manager API aka PS3M_API is an API similar to TMAPI or CCAPI, compatible with CEX and DEX consoles. It includes a lot of new features (see below) which can be used in any PS3 plugins (vsh plugin, game plugin, ...), homebrew and it can be used remotely with any PC tools (and Android, iOS, ... is open source so anyone can port the PC library to any other platform) or with the webUI (any device with an internet navigator). 4 | 5 | Developer: _NzV_ 6 | 7 | # PS3MAPI Library 8 | 9 | This is a [PSL1GHT](https://github.com/ps3dev/PSL1GHT/) library that allows any PS3 homebrew developer to use PS3MAPI features from within their apps. 10 | 11 | ## Installation 12 | 13 | To install the library, just clone the repository and execute: 14 | 15 | ```bash 16 | make install 17 | ``` 18 | 19 | ## PS3M_API FEATURES 20 | 21 | ### PROCESS 22 | 23 | - Get all process pid. 24 | - Get process name by pid. 25 | - Get process by pid. 26 | - Get current process. 27 | 28 | ### MEMORY 29 | 30 | - Make all memory writable for any process. 31 | - Set process memory. 32 | - Get process memory. 33 | 34 | ### MODULES 35 | 36 | - Get all process module prxid. 37 | - Get module name by prxid. 38 | - Get module filename by prxid. 39 | - Load a process module. 40 | - Unload a process module. 41 | 42 | ### VSH Plugins 43 | 44 | - Unload plugins by name. 45 | - Get plugins info by slot (name and filename). 46 | 47 | ### SYSCALL 48 | 49 | - Disable any syscall. 50 | - Partial disable syscall8. 51 | - Check any syscall. 52 | 53 | ### EXTRA 54 | 55 | - Remove cobra/mamba hook. 56 | - Get and set IDPS/PSID anytime. 57 | 58 | ## License 59 | 60 | `ps3mapi-lib` is released under the [MIT License](LICENSE). 61 | -------------------------------------------------------------------------------- /source/cobra_mamba.c: -------------------------------------------------------------------------------- 1 | /* COBRA/MAMBA PSL1GHT 2 | * Copyright (c) 2020 Bucanero (www.bucanero.com.ar) 3 | * 4 | * It may be used for any purpose as long as this notice remains intact on all 5 | * source code distributions. 6 | */ 7 | 8 | #include 9 | #include "ps3mapi_ps3_lib.h" 10 | 11 | //---------------------------------------- 12 | //COBRA/MAMBA 13 | //---------------------------------------- 14 | 15 | int sys8_get_version(uint32_t *version) 16 | { 17 | lv2syscall2(8, SYSCALL8_OPCODE_GET_VERSION, (uint64_t)version); 18 | return_to_user_prog(int); 19 | } 20 | 21 | int sys8_get_mamba(void) 22 | { 23 | lv2syscall1(8, SYSCALL8_OPCODE_GET_MAMBA); 24 | return_to_user_prog(int); 25 | } 26 | 27 | int sys8_get_hen(void) 28 | { 29 | lv2syscall1(8, SYSCALL8_OPCODE_IS_HEN); 30 | return_to_user_prog(int); 31 | } 32 | 33 | int sys8_get_hen_version(void) 34 | { 35 | lv2syscall1(8, SYSCALL8_OPCODE_HEN_REV); 36 | return_to_user_prog(int); 37 | } 38 | 39 | int has_cobra_mamba(void) 40 | { 41 | u32 version = 0x99999999; 42 | if (sys8_get_version(&version) < 0) 43 | return 0; 44 | 45 | return (version != 0x99999999); 46 | } 47 | 48 | int is_cobra(void) 49 | { 50 | return (has_cobra_mamba() && (sys8_get_mamba() != 0x666)); 51 | } 52 | 53 | int is_mamba(void) 54 | { 55 | return (has_cobra_mamba() && (sys8_get_mamba() == 0x666)); 56 | } 57 | 58 | int is_ps3hen(void) 59 | { 60 | return (sys8_get_hen() == 0x1337); 61 | } 62 | 63 | int cobra_mamba_load_prx_module(uint32_t slot, char * path, void * arg, uint32_t arg_size) 64 | { 65 | lv2syscall5(8, SYSCALL8_OPCODE_LOAD_VSH_PLUGIN, (uint64_t)slot, (uint64_t)path, (uint64_t)arg, (uint64_t)arg_size); 66 | return_to_user_prog(int); 67 | } 68 | 69 | int cobra_mamba_unload_prx_module(uint32_t slot) 70 | { 71 | lv2syscall2(8, SYSCALL8_OPCODE_UNLOAD_VSH_PLUGIN, (uint64_t)slot); 72 | return_to_user_prog(int); 73 | } 74 | 75 | int cobra_mamba_stealth_test(void) 76 | { 77 | lv2syscall1(8, SYSCALL8_OPCODE_STEALTH_TEST); 78 | return_to_user_prog(int); 79 | } 80 | 81 | int cobra_mamba_stealth_activate(void) 82 | { 83 | lv2syscall1(8, SYSCALL8_OPCODE_STEALTH_ACTIVATE); 84 | return_to_user_prog(int); 85 | } 86 | 87 | uint64_t lv2_peek(uint64_t addr) 88 | { 89 | lv2syscall1(6, (uint64_t) addr >> 0ULL); 90 | return_to_user_prog(uint64_t); 91 | } 92 | 93 | int lv2_poke(uint64_t addr, uint64_t value) 94 | { 95 | lv2syscall2(7, (uint64_t) addr, (uint64_t) value); 96 | return_to_user_prog(int); 97 | } 98 | 99 | int lv2_poke32(uint64_t addr, uint32_t val) 100 | { 101 | if(addr==0) return (-1); 102 | uint32_t next = lv2_peek(addr) & 0xffffffff; 103 | return lv2_poke(addr, (((uint64_t) val) << 32) | next); 104 | } 105 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | 7 | ifeq ($(strip $(PSL1GHT)),) 8 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 9 | endif 10 | 11 | include $(PSL1GHT)/ppu_rules 12 | 13 | 14 | 15 | #--------------------------------------------------------------------------------- 16 | ifeq ($(strip $(PLATFORM)),) 17 | #--------------------------------------------------------------------------------- 18 | export BASEDIR := $(CURDIR) 19 | export DEPS := $(BASEDIR)/deps 20 | export LIBS := $(BASEDIR)/lib 21 | 22 | #--------------------------------------------------------------------------------- 23 | else 24 | #--------------------------------------------------------------------------------- 25 | 26 | export LIBDIR := $(LIBS)/$(PLATFORM) 27 | export DEPSDIR := $(DEPS)/$(PLATFORM) 28 | 29 | #--------------------------------------------------------------------------------- 30 | endif 31 | #--------------------------------------------------------------------------------- 32 | 33 | TARGET := libps3mapi 34 | BUILD := build 35 | SOURCE := source 36 | INCLUDE := include 37 | DATA := data 38 | LIBS := 39 | 40 | MACHDEP := -DBIGENDIAN 41 | CFLAGS += -O2 -Wall -mcpu=cell $(MACHDEP) -fno-strict-aliasing $(INCLUDES) 42 | 43 | LD := ppu-ld 44 | 45 | ifneq ($(BUILD),$(notdir $(CURDIR))) 46 | 47 | export OUTPUT := $(CURDIR)/$(TARGET) 48 | export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ 49 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 50 | export BUILDDIR := $(CURDIR)/$(BUILD) 51 | export DEPSDIR := $(BUILDDIR) 52 | 53 | CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) 54 | CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) 55 | SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) 56 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 57 | 58 | 59 | export OFILES := $(CFILES:.c=.o) \ 60 | $(CXXFILES:.cpp=.o) \ 61 | $(SFILES:.S=.o) \ 62 | $(BINFILES:.bin=.bin.o) 63 | 64 | export BINFILES := $(BINFILES:.bin=.bin.h) 65 | 66 | export INCLUDES = $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ 67 | -I$(CURDIR)/$(BUILD) -I$(PSL1GHT)/ppu/include -I$(PORTLIBS)/include 68 | 69 | .PHONY: $(BUILD) install clean shader 70 | 71 | $(BUILD): 72 | @[ -d $@ ] || mkdir -p $@ 73 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 74 | 75 | install: $(BUILD) 76 | @echo Copying... 77 | @cp include/ps3mapi_ps3_lib.h $(PORTLIBS)/include/ps3mapi.h 78 | @cp *.a $(PORTLIBS)/lib 79 | @echo Done! 80 | 81 | clean: 82 | @echo Clean... 83 | @rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).a 84 | 85 | else 86 | 87 | DEPENDS := $(OFILES:.o=.d) 88 | 89 | $(OUTPUT).a: $(OFILES) 90 | $(OFILES): $(BINFILES) $(VCGFILES) $(VSAFILES) 91 | 92 | -include $(DEPENDS) 93 | 94 | endif 95 | -------------------------------------------------------------------------------- /include/ps3mapi_ps3_lib.h: -------------------------------------------------------------------------------- 1 | /*PS3 MANAGER API 2 | * Copyright (c) 2014 _NzV_. 3 | * Updated in 2020 by Bucanero (www.bucanero.com.ar) 4 | * 5 | * This code is written by _NzV_ . 6 | * It may be used for any purpose as long as this notice remains intact on all 7 | * source code distributions. 8 | */ 9 | 10 | #ifndef __PS3MAPI_H__ 11 | #define __PS3MAPI_H__ 12 | 13 | #define process_id_t uint32_t 14 | #define sys_prx_id_t int32_t 15 | 16 | #define SYSCALL8_OPCODE_PS3MAPI 0x7777 17 | 18 | #define PS3MAPI_PS3_LIB_VERSION 0x0120 19 | 20 | #define PS3MAPI_CORE_MINVERSION 0x0120 21 | 22 | //----------------------------------------------- 23 | //CORE 24 | //----------------------------------------------- 25 | 26 | #define PS3MAPI_OPCODE_GET_CORE_VERSION 0x0011 27 | #define PS3MAPI_OPCODE_GET_CORE_MINVERSION 0x0012 28 | #define PS3MAPI_OPCODE_GET_FW_TYPE 0x0013 29 | #define PS3MAPI_OPCODE_GET_FW_VERSION 0x0014 30 | 31 | int ps3mapi_get_core_version(void); 32 | int ps3mapi_get_core_minversion(void); 33 | int ps3mapi_get_fw_type(char *fw); 34 | int ps3mapi_get_fw_version(void); 35 | int has_ps3mapi(void); 36 | 37 | //----------------------------------------------- 38 | //PROCESSES 39 | //----------------------------------------------- 40 | 41 | #define PS3MAPI_OPCODE_GET_ALL_PROC_PID 0x0021 42 | #define PS3MAPI_OPCODE_GET_PROC_NAME_BY_PID 0x0022 43 | #define PS3MAPI_OPCODE_GET_PROC_BY_PID 0x0023 44 | #define PS3MAPI_OPCODE_GET_CURRENT_PROC 0x0024 45 | #define PS3MAPI_OPCODE_GET_CURRENT_PROC_CRIT 0x0025 46 | 47 | typedef struct 48 | { 49 | void *unk_00; // 0 50 | char name[24]; // 8 51 | // ... 52 | } __attribute__((packed)) UnkProcessStruct; 53 | 54 | typedef struct _process_t 55 | { 56 | void *syscall_table; // 0 57 | uint64_t unk_8[4]; // 8 58 | uint32_t pid; // 0x28 59 | int status; // 0x2C 60 | void *mem_object; // 0x30 61 | UnkProcessStruct *unk_38; // 0x38 62 | uint64_t unk_40; // 0x40 63 | void *first_thread; // 0x48 64 | uint64_t unk_50; // 0x50 65 | uint64_t unk_58; // 0x58 66 | void *unk_60; // 0x60 67 | void *unk_68; // 0x68 vshprocess -> mios2_SPU_Service.elf 68 | void *unk_70; // 0x70 vshprocess -> mios2_SPU_Service.elf 69 | uint64_t unk_78; // 0x78 70 | uint64_t unk_80; // 0x80 71 | uint64_t unk_88[4]; // 0x88 72 | uint64_t unk_A8; // 0xA8 user address? 73 | struct _process_t *parent; // 0xB0 74 | struct _process_t *first_child; // 0xB8 75 | struct _process_t *next_sibling; // 0xC0 76 | uint64_t num_children; // 0xC8 77 | void *unk_D0; // 0xD0 78 | uint64_t unk_D8; // 0xD8 79 | uint64_t unk_E0; // 0xE0 80 | uint64_t unk_E8; // 0xE8 81 | uint64_t unk_F0[2]; // 0xF0 82 | uint64_t unk_100; // 0x100 83 | uint64_t unk_108; // 0x108 84 | void *unk_110; // 0x110 85 | void *unk_118; // 0x118 vshprocess -> pointer to unk_D0 86 | uint64_t unk_120; // 0x120 87 | void *unk_128; // 0x128 only on vshprocess -> same as first_thread 88 | void *unk_130; // 0x130 only on vsh process -> same as first thread 89 | uint64_t unk_138; // 0x138 90 | uint64_t unk_140[4]; // 0x140 91 | char *process_image; // 0x160 92 | void *unk_168; // 0x168 93 | uint64_t unk_170; // 0x170 94 | uint64_t unk_178; // 0x178 95 | uint64_t unk_180; // 0x180 96 | uint64_t unk_188[4]; // 0x188 97 | uint64_t unk_1A8; // 0x1A8 98 | uint64_t unk_1B0; // 0x1B0 99 | uint64_t unk_1B8; // 0x1B8 100 | uint64_t unk_1C0; // 0x1C0 101 | uint64_t unk_1C8; // 0x1C8 102 | uint64_t unk_1D0; // 0x1D0 103 | uint64_t unk_1D8; // 0x1D8 104 | uint64_t unk_1E0; // 0x1E0 105 | uint64_t unk_1E8[4]; // 0x1E8 106 | void *object_table; // 0x208 waiting for a better name... 107 | // ...? 108 | // 0x26C -> sdk version 32bits 109 | } __attribute__((packed)) *process_t; 110 | 111 | int ps3mapi_get_all_processes_pid(process_id_t *pid_list); 112 | int ps3mapi_get_process_name_by_pid(process_id_t pid, char *name); 113 | int ps3mapi_get_process_by_pid(process_id_t pid, process_t process); 114 | int ps3mapi_get_current_process_critical(process_t process); 115 | int ps3mapi_get_current_process(process_t process); 116 | 117 | //----------------------------------------------- 118 | //MEMORY 119 | //----------------------------------------------- 120 | 121 | #define PS3MAPI_OPCODE_GET_PROC_MEM 0x0031 122 | #define PS3MAPI_OPCODE_SET_PROC_MEM 0x0032 123 | #define PS3MAPI_OPCODE_PROC_PAGE_ALLOCATE 0x0033 124 | #define PS3MAPI_OPCODE_PROC_PAGE_FREE 0x0034 125 | 126 | int set_process_mem(process_id_t pid, uint64_t addr, char * buf, int size, int isDEX, int isCCAPI); 127 | int get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size, int isDEX, int isCCAPI); 128 | int dex_set_process_mem(process_id_t pid, uint64_t addr, char *buf, int size); 129 | int ccapi_set_process_mem(process_id_t pid, uint64_t addr, char *buf, int size); 130 | int ps3mapi_set_process_mem(process_id_t pid, uint64_t addr, char *buf, int size); 131 | int ps3mapi_get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size); 132 | int dex_get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size); 133 | int ccapi_get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size); 134 | int ps3mapi_process_page_allocate(process_id_t pid, uint64_t size, uint64_t page_size, uint64_t flags, uint64_t is_executable, uint64_t *page_table); 135 | int ps3mapi_process_page_free(process_id_t pid, uint64_t flags, uint64_t *page_table); 136 | 137 | //----------------------------------------------- 138 | //DYNAREC 139 | //----------------------------------------------- 140 | #define PAGE_SIZE_AUTO 0 141 | 142 | #define NOP __asm__("nop") // a nop is 4 bytes 143 | 144 | #define DYN8B(a) a;a 145 | #define DYN16B(a) a;a;a;a 146 | #define DYN24B(a) a;a;a;a;a;a 147 | #define DYN32B(a) a;a;a;a;a;a;a;a 148 | #define DYN40B(a) a;a;a;a;a;a;a;a;a;a 149 | #define DYN48B(a) a;a;a;a;a;a;a;a;a;a;a;a 150 | #define DYN56B(a) a;a;a;a;a;a;a;a;a;a;a;a;a;a 151 | #define DYN64B(a) a;a;a;a;a;a;a;a;a;a;a;a;a;a;a;a 152 | #define DYN128B(a) DYN32B(DYN16B(a)) // 32 nop 153 | #define DYN256B(a) DYN64B(DYN16B(a)) // 64 nop 154 | #define DYN512B(a) DYN64B(DYN32B(a)) // 128 nop 155 | #define DYN1K(a) DYN128B(DYN32B(a)) // 256 nop 156 | #define DYN2K(a) DYN256B(DYN32B(a)) // 512 nop 157 | #define DYN4K(a) DYN512B(DYN32B(a)) // 1024 nop 158 | #define DYN8K(a) DYN1K(DYN32B(a)) // 2048 nop 159 | #define DYN16K(a) DYN2K(DYN32B(a)) // 4096 nop 160 | #define DYN32K(a) DYN4K(DYN32B(a)) // 8192 nop 161 | #define DYN64K(a) DYN8K(DYN32B(a)) // 16384 nop 162 | #define DYN128K(a) DYN16K(DYN32B(a)) // 32768 nop 163 | #define DYN256K(a) DYN32K(DYN32B(a)) // 65536 nop 164 | #define DYN512K(a) DYN64K(DYN32B(a)) // 131072 nop 165 | #define DYN1M(a) DYN128K(DYN32B(a)) // 262144 nop 166 | #define DYN2M(a) DYN256K(DYN32B(a)) // 524288 nop 167 | #define DYN4M(a) DYN512K(DYN32B(a)) // 1048576 nop 168 | 169 | #define DYNAREC_ADDRESS_SHIFT 12 170 | 171 | #ifdef DYN_SIZE 172 | void DYN_SIZE_FAKEFUN(void) 173 | { 174 | DYN_SIZE(NOP); 175 | } 176 | #endif 177 | 178 | int ps3mapi_dynarec_init(void *fakefun, void **start_dyn_buff, int *len_dyn_buff); 179 | int ps3mapi_dynarec_write_bytecode(void *start_dyn_buff, int len_dyn_buff, int offset, char *buff, int len); 180 | 181 | //----------------------------------------------- 182 | //MODULES 183 | //----------------------------------------------- 184 | 185 | #define PS3MAPI_OPCODE_GET_ALL_PROC_MODULE_PID 0x0041 186 | #define PS3MAPI_OPCODE_GET_PROC_MODULE_NAME 0x0042 187 | #define PS3MAPI_OPCODE_GET_PROC_MODULE_FILENAME 0x0043 188 | #define PS3MAPI_OPCODE_LOAD_PROC_MODULE 0x0044 189 | #define PS3MAPI_OPCODE_UNLOAD_PROC_MODULE 0x0045 190 | #define PS3MAPI_OPCODE_UNLOAD_VSH_PLUGIN 0x0046 191 | #define PS3MAPI_OPCODE_GET_VSH_PLUGIN_INFO 0x0047 192 | #define PS3MAPI_OPCODE_GET_PROC_MODULE_INFO 0x0048 193 | 194 | typedef struct 195 | { 196 | uint64_t size; /* struct size, ignored in kernel version of the function */ 197 | char name[30]; 198 | char version[2]; 199 | uint32_t modattribute; 200 | uint32_t start_entry; 201 | uint32_t stop_entry; 202 | uint32_t all_segments_num; 203 | uint32_t filename; /* User: user pointer to receive filename; Kernel: ignored */ 204 | uint32_t filename_size; 205 | uint32_t segments; /* User: user pointer to receive segments; Kernel: ignored */ 206 | uint32_t segments_num; 207 | } __attribute__((packed)) sys_prx_module_info_t; 208 | 209 | int ps3mapi_get_all_process_modules_prx_id(process_id_t pid, sys_prx_id_t *prx_id_list); 210 | int ps3mapi_get_process_module_name_by_prx_id(process_id_t pid, sys_prx_id_t prx_id, char *name); 211 | int ps3mapi_get_process_module_filename_by_prx_id(process_id_t pid, sys_prx_id_t prx_id, char *filename); 212 | int ps3mapi_get_process_module_info(process_id_t pid, sys_prx_id_t prx_id, sys_prx_module_info_t *info); 213 | int ps3mapi_load_process_modules(process_id_t pid, char *path, void *arg, uint32_t arg_size); 214 | int ps3mapi_unload_process_modules(process_id_t pid, sys_prx_id_t prx_id); 215 | int ps3mapi_unload_vsh_plugin(char *name); 216 | int ps3mapi_get_vsh_plugin_info(unsigned int slot, char *name, char *filename); 217 | int ps3mapi_get_vsh_plugin_slot_by_name(const char *name); 218 | int ps3mapi_get_vsh_plugin_slot_by_filename(const char *filename); 219 | int ps3mapi_get_vsh_plugin_free_slot(void); 220 | 221 | //----------------------------------------------- 222 | //THREAD 223 | //----------------------------------------------- 224 | 225 | #define SYSCALL8_OPCODE_PROC_CREATE_THREAD 0x6E03 // not enough params for PS3MAPI_OPCODE 226 | 227 | typedef struct 228 | { 229 | void *unk_0; // ptr to some funcs 230 | uint64_t unk_8; 231 | uint32_t unk_10; 232 | uint32_t unk_14; 233 | void *unk_18; 234 | void *unk_20; // same as unk_18? :S 235 | uint64_t unk_28[3]; 236 | void *unk_40; // same as unk_0? 237 | // ... 238 | } *thread_t; 239 | 240 | int ps3mapi_create_process_thread(process_id_t pid, thread_t *thread, void *entry, uint64_t arg, int prio, size_t stacksize, char *threadname); 241 | 242 | //----------------------------------------------- 243 | //CLEAN SYSCALL 244 | //----------------------------------------------- 245 | 246 | #define PS3MAPI_OPCODE_CHECK_SYSCALL 0x0091 247 | #define PS3MAPI_OPCODE_DISABLE_SYSCALL 0x0092 248 | #define PS3MAPI_OPCODE_PDISABLE_SYSCALL8 0x0093 249 | #define PS3MAPI_OPCODE_PCHECK_SYSCALL8 0x0094 250 | 251 | int ps3mapi_check_syscall(int num); 252 | int ps3mapi_disable_syscall(int num); 253 | int ps3mapi_pdisable_syscall8(int mode); 254 | int ps3mapi_pcheck_syscall8(void); 255 | 256 | //----------------------------------------------- 257 | //PSID/IDPS 258 | //----------------------------------------------- 259 | 260 | #define PS3MAPI_OPCODE_GET_IDPS 0x0081 261 | #define PS3MAPI_OPCODE_SET_IDPS 0x0082 262 | #define PS3MAPI_OPCODE_GET_PSID 0x0083 263 | #define PS3MAPI_OPCODE_SET_PSID 0x0084 264 | 265 | int ps3mapi_get_idps(uint64_t *idps); 266 | int ps3mapi_set_idps(uint64_t part1, uint64_t part2); 267 | int ps3mapi_get_psid(uint64_t *psid); 268 | int ps3mapi_set_psid(uint64_t part1, uint64_t part2); 269 | 270 | //----------------------------------------------- 271 | //REMOVE COBRA/MAMBA HOOK 272 | //----------------------------------------------- 273 | 274 | #define PS3MAPI_OPCODE_REMOVE_HOOK 0x0101 275 | 276 | int ps3mapi_remove_hook(void); 277 | 278 | //----------------------------------------------- 279 | //PEEK & POKE 280 | //----------------------------------------------- 281 | 282 | #define PS3MAPI_OPCODE_SUPPORT_SC8_PEEK_POKE 0x1000 283 | #define PS3MAPI_OPCODE_SUPPORT_SC8_PEEK_POKE_OK 0x6789 284 | #define PS3MAPI_OPCODE_LV2_PEEK 0x1006 285 | #define PS3MAPI_OPCODE_LV2_POKE 0x1007 286 | #define PS3MAPI_OPCODE_LV1_PEEK 0x1008 287 | #define PS3MAPI_OPCODE_LV1_POKE 0x1009 288 | 289 | int ps3mapi_support_sc8_peek_poke(void); 290 | int ps3mapi_lv1_poke(uint64_t addr, uint64_t value); 291 | int ps3mapi_lv2_poke(uint64_t addr, uint64_t value); 292 | uint64_t ps3mapi_lv1_peek(uint64_t addr); 293 | uint64_t ps3mapi_lv2_peek(uint64_t addr); 294 | 295 | //----------------------------------------------- 296 | //SECURITY 297 | //----------------------------------------------- 298 | 299 | #define PS3MAPI_OPCODE_SET_ACCESS_KEY 0x2000 300 | #define PS3MAPI_OPCODE_REQUEST_ACCESS 0x2001 301 | 302 | int ps3mapi_set_access_key(uint64_t key); 303 | int ps3mapi_request_access(uint64_t key); 304 | 305 | //----------------------------------------------- 306 | //EXTRA 307 | //----------------------------------------------- 308 | 309 | #define LED_COLOR_RED 0 310 | #define LED_COLOR_GREEN 1 311 | #define LED_COLOR_YELLOW 2 312 | 313 | #define LED_MODE_OFF 0 314 | #define LED_MODE_ON 1 315 | #define LED_MODE_BLINK 2 316 | 317 | int led(uint64_t color, uint64_t mode); 318 | int ps3_shutdown(void); 319 | int ps3_quick_restart(void); 320 | int ps3_hard_restart(void); 321 | int ps3_soft_restart(void); 322 | int ring_buzzer_simple(void); 323 | int ring_buzzer_double(void); 324 | int ring_buzzer_triple(void); 325 | int get_temperature_celcius(uint32_t *cpu_temp, uint32_t *rsx_temp); 326 | 327 | //---------------------------------------- 328 | //COBRA/MAMBA 329 | //---------------------------------------- 330 | 331 | #define SYSCALL8_OPCODE_GET_VERSION 0x7000 332 | #define SYSCALL8_OPCODE_GET_MAMBA 0x7FFF 333 | #define SYSCALL8_OPCODE_IS_HEN 0x1337 334 | #define SYSCALL8_OPCODE_HEN_REV 0x1339 335 | #define SYSCALL8_OPCODE_LOAD_VSH_PLUGIN 0x1EE7 336 | #define SYSCALL8_OPCODE_UNLOAD_VSH_PLUGIN 0x364F 337 | #define SYSCALL8_OPCODE_STEALTH_TEST 0x3993 338 | #define SYSCALL8_OPCODE_STEALTH_ACTIVATE 0x3995 339 | #define SYSCALL8_STEALTH_OK 0x5555 340 | 341 | int sys8_get_version(uint32_t *version); 342 | int sys8_get_hen_version(void); 343 | int has_cobra_mamba(void); 344 | int is_cobra(void); 345 | int is_mamba(void); 346 | int is_ps3hen(void); 347 | int cobra_mamba_load_prx_module(uint32_t slot, char * path, void * arg, uint32_t arg_size); 348 | int cobra_mamba_unload_prx_module(uint32_t slot); 349 | int cobra_mamba_stealth_test(void); 350 | int cobra_mamba_stealth_activate(void); 351 | int lv2_poke(uint64_t addr, uint64_t value); 352 | int lv2_poke32(uint64_t addr, uint32_t value); 353 | uint64_t lv2_peek(uint64_t addr); 354 | 355 | #endif /* __PS3MAPI_H__ */ 356 | -------------------------------------------------------------------------------- /source/ps3mapi_ps3_lib.c: -------------------------------------------------------------------------------- 1 | /*PS3 MANAGER API 2 | * Copyright (c) 2014 _NzV_. 3 | * Updated in 2020 by Bucanero (www.bucanero.com.ar) 4 | * 5 | * This code is written by _NzV_ . 6 | * It may be used for any purpose as long as this notice remains intact on all 7 | * source code distributions. 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "ps3mapi_ps3_lib.h" 15 | 16 | #define KB 1024ULL 17 | 18 | //----------------------------------------------- 19 | //CORE 20 | //----------------------------------------------- 21 | 22 | int ps3mapi_get_core_version(void) 23 | { 24 | lv2syscall2(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_CORE_VERSION); 25 | return_to_user_prog(int); 26 | } 27 | 28 | int ps3mapi_get_core_minversion(void) 29 | { 30 | lv2syscall2(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_CORE_MINVERSION); 31 | return_to_user_prog(int); 32 | } 33 | 34 | int ps3mapi_get_fw_type(char *fw) 35 | { 36 | lv2syscall3(8, (uint64_t)SYSCALL8_OPCODE_PS3MAPI, (uint64_t)PS3MAPI_OPCODE_GET_FW_TYPE, (uint64_t)fw); 37 | return_to_user_prog(int); 38 | } 39 | 40 | int ps3mapi_get_fw_version(void) 41 | { 42 | lv2syscall2(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_FW_VERSION); 43 | return_to_user_prog(int); 44 | } 45 | 46 | int has_ps3mapi(void) 47 | { 48 | return (ps3mapi_get_core_version() >= PS3MAPI_CORE_MINVERSION); 49 | } 50 | 51 | //----------------------------------------------- 52 | //PROCESSES 53 | //----------------------------------------------- 54 | 55 | int ps3mapi_get_all_processes_pid(process_id_t *pid_list) 56 | { 57 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_ALL_PROC_PID, (uint64_t)pid_list); 58 | return_to_user_prog(int); 59 | } 60 | 61 | int ps3mapi_get_process_name_by_pid(process_id_t pid, char *name) 62 | { 63 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_NAME_BY_PID, (uint64_t)pid, (uint64_t)name); 64 | return_to_user_prog(int); 65 | } 66 | 67 | int ps3mapi_get_process_by_pid(process_id_t pid, process_t process) 68 | { 69 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_BY_PID, (uint64_t)pid, (uint64_t)process); 70 | return_to_user_prog(int); 71 | } 72 | 73 | int ps3mapi_get_current_process_critical(process_t process) 74 | { 75 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_CURRENT_PROC_CRIT, (uint64_t)process); 76 | return_to_user_prog(int); 77 | } 78 | 79 | int ps3mapi_get_current_process(process_t process) 80 | { 81 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_CURRENT_PROC, (uint64_t)process); 82 | return_to_user_prog(int); 83 | } 84 | 85 | //----------------------------------------------- 86 | //MEMORY 87 | //----------------------------------------------- 88 | 89 | int set_process_mem(process_id_t pid, uint64_t addr, char * buf, int size, int isDEX, int isCCAPI) 90 | { 91 | if (isDEX) 92 | { 93 | return dex_set_process_mem(pid, addr, buf, size); 94 | } 95 | else if (isCCAPI) 96 | { 97 | return ccapi_set_process_mem(pid, addr, buf, size); 98 | } 99 | 100 | return ps3mapi_set_process_mem(pid, addr, buf, size); 101 | } 102 | 103 | int get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size, int isDEX, int isCCAPI) 104 | { 105 | if (isDEX) 106 | { 107 | return dex_get_process_mem(pid, addr, buf, size); 108 | } 109 | else if (isCCAPI) 110 | { 111 | return ccapi_get_process_mem(pid, addr, buf, size); 112 | } 113 | 114 | return ps3mapi_get_process_mem(pid, addr, buf, size); 115 | } 116 | 117 | int ps3mapi_set_process_mem(process_id_t pid, uint64_t addr, char *buf, int size ) 118 | { 119 | lv2syscall6(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_SET_PROC_MEM, (uint64_t)pid, (uint64_t)addr, (uint64_t)buf, (uint64_t)size); 120 | return_to_user_prog(int); 121 | } 122 | 123 | int dex_set_process_mem(process_id_t pid, uint64_t addr, char *buf, int size ) 124 | { 125 | lv2syscall4(905, (uint64_t)pid, (uint64_t)addr, (uint64_t)size, (uint64_t)buf); 126 | return_to_user_prog(int); 127 | } 128 | 129 | int ccapi_set_process_mem(process_id_t pid, uint64_t addr, char *buf, int size ) 130 | { 131 | lv2syscall4(201, (uint64_t)pid, (uint64_t)addr, (uint64_t)size, (uint64_t)buf); 132 | return_to_user_prog(int); 133 | } 134 | 135 | int ps3mapi_get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size) 136 | { 137 | lv2syscall6(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_MEM, (uint64_t)pid, (uint64_t)addr, (uint64_t)buf, (uint64_t)size); 138 | return_to_user_prog(int); 139 | } 140 | 141 | int dex_get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size) 142 | { 143 | lv2syscall4(904, (uint64_t)pid, (uint64_t)addr, (uint64_t)size, (uint64_t)buf); 144 | return_to_user_prog(int); 145 | } 146 | 147 | int ccapi_get_process_mem(process_id_t pid, uint64_t addr, char *buf, int size) 148 | { 149 | lv2syscall4(200, (uint64_t)pid, (uint64_t)addr, (uint64_t)size, (uint64_t)buf); 150 | return_to_user_prog(int); 151 | } 152 | 153 | int ps3mapi_process_page_allocate(process_id_t pid, uint64_t size, uint64_t page_size, uint64_t flags, uint64_t is_executable, uint64_t *page_table) 154 | { 155 | lv2syscall8(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_PROC_PAGE_ALLOCATE, (uint64_t)pid, (uint64_t)size, (uint64_t)page_size, (uint64_t)flags, (uint64_t)is_executable, (uint64_t)page_table); 156 | return_to_user_prog(int); 157 | } 158 | 159 | int ps3mapi_process_page_free(process_id_t pid, uint64_t flags, uint64_t *page_table) 160 | { 161 | lv2syscall5(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_PROC_PAGE_FREE, (uint64_t)pid, (uint64_t)flags, (uint64_t)page_table); 162 | return_to_user_prog(int); 163 | } 164 | 165 | //----------------------------------------------- 166 | //DYNAREC 167 | //----------------------------------------------- 168 | 169 | int ps3mapi_dynarec_write_bytecode(void *start_dyn_buff, int len_dyn_buff, int offset, char *buff, int len) 170 | { 171 | if (offset + len > len_dyn_buff || offset < 0 || !buff || offset%4) 172 | return(-1); 173 | 174 | char *tmp = (char*)malloc(len+DYNAREC_ADDRESS_SHIFT); 175 | if(!tmp) 176 | return(-1); 177 | 178 | *(uint64_t *)tmp = (uint64_t)start_dyn_buff + offset + DYNAREC_ADDRESS_SHIFT; 179 | *(uint32_t *)(tmp+sizeof(uint64_t)) = 0; 180 | 181 | memcpy((void*)(tmp+DYNAREC_ADDRESS_SHIFT), buff, len); 182 | 183 | int result = ps3mapi_set_process_mem(sysProcessGetPid(), (uint64_t)start_dyn_buff + offset, tmp, len); 184 | free(tmp); 185 | 186 | return (result); 187 | } 188 | 189 | void _FAKE_DYN4K_FUN(void) 190 | { 191 | DYN4K(NOP); 192 | } 193 | 194 | int ps3mapi_dynarec_init(void *fakefun, void **start_dyn_buff, int *len_dyn_buff) 195 | { 196 | *start_dyn_buff = (void*)*(uint64_t*)(fakefun ? fakefun : _FAKE_DYN4K_FUN); 197 | 198 | uint32_t *toffset = (uint32_t*)(*start_dyn_buff); 199 | *len_dyn_buff = 0; 200 | 201 | while (*toffset != 0x4e800020) //Search for blr 202 | { 203 | toffset++; 204 | *len_dyn_buff += 4; 205 | 206 | if (*len_dyn_buff == 0x7FFFFFFC) 207 | return(-1); 208 | } 209 | 210 | *len_dyn_buff += 4; //Dynarec buffer length; 211 | return 0; 212 | } 213 | 214 | //----------------------------------------------- 215 | //MODULES 216 | //----------------------------------------------- 217 | 218 | int ps3mapi_get_all_process_modules_prx_id(process_id_t pid, sys_prx_id_t *prx_id_list) 219 | { 220 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_ALL_PROC_MODULE_PID, (uint64_t)pid, (uint64_t)prx_id_list); 221 | return_to_user_prog(int); 222 | } 223 | 224 | int ps3mapi_get_process_module_name_by_prx_id(process_id_t pid, sys_prx_id_t prx_id, char *name) 225 | { 226 | lv2syscall5(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_MODULE_NAME, (uint64_t)pid, (uint64_t)prx_id, (uint64_t)name); 227 | return_to_user_prog(int); 228 | } 229 | 230 | int ps3mapi_get_process_module_filename_by_prx_id(process_id_t pid, sys_prx_id_t prx_id, char *filename) 231 | { 232 | lv2syscall5(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_MODULE_FILENAME, (uint64_t)pid, (uint64_t)prx_id, (uint64_t)filename); 233 | return_to_user_prog(int); 234 | } 235 | 236 | int ps3mapi_load_process_modules(process_id_t pid, char *path, void *arg, uint32_t arg_size) 237 | { 238 | lv2syscall6(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_LOAD_PROC_MODULE, (uint64_t)pid, (uint64_t)path, (uint64_t)arg, (uint64_t)arg_size); 239 | return_to_user_prog(int); 240 | } 241 | 242 | int ps3mapi_unload_process_modules(process_id_t pid, sys_prx_id_t prx_id) 243 | { 244 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_UNLOAD_PROC_MODULE, (uint64_t)pid, (uint64_t)prx_id); 245 | return_to_user_prog(int); 246 | } 247 | 248 | int ps3mapi_unload_vsh_plugin(char *name) 249 | { 250 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_UNLOAD_VSH_PLUGIN, (uint64_t)name); 251 | return_to_user_prog(int); 252 | } 253 | 254 | int ps3mapi_get_vsh_plugin_info(unsigned int slot, char *name, char *filename) 255 | { 256 | lv2syscall5(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_VSH_PLUGIN_INFO, (uint64_t)slot, (uint64_t)name, (uint64_t)filename); 257 | return_to_user_prog(int); 258 | } 259 | 260 | int ps3mapi_get_process_module_info(process_id_t pid, sys_prx_id_t prx_id, sys_prx_module_info_t *info) 261 | { 262 | lv2syscall5(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PROC_MODULE_INFO, (uint64_t)pid, (uint64_t)prx_id, (uint64_t)info); 263 | return_to_user_prog(int); 264 | } 265 | 266 | int ps3mapi_get_vsh_plugin_slot_by_name(const char *name) 267 | { 268 | char tmp_name[30]; 269 | char tmp_filename[256]; 270 | unsigned int slot; 271 | 272 | for (slot = 1; slot < 7; slot++) 273 | { 274 | memset(tmp_name, 0, sizeof(tmp_name)); 275 | memset(tmp_filename, 0, sizeof(tmp_filename)); 276 | ps3mapi_get_vsh_plugin_info(slot, tmp_name, tmp_filename); 277 | if(strcmp(tmp_name, name) == 0) 278 | return slot; 279 | } 280 | 281 | return 0; 282 | } 283 | 284 | int ps3mapi_get_vsh_plugin_slot_by_filename(const char *filename) 285 | { 286 | char tmp_name[30]; 287 | char tmp_filename[256]; 288 | unsigned int slot; 289 | 290 | for (slot = 1; slot < 7; slot++) 291 | { 292 | memset(tmp_name, 0, sizeof(tmp_name)); 293 | memset(tmp_filename, 0, sizeof(tmp_filename)); 294 | ps3mapi_get_vsh_plugin_info(slot, tmp_name, tmp_filename); 295 | if(strcmp(tmp_filename, filename) == 0) 296 | return slot; 297 | } 298 | 299 | return 0; 300 | } 301 | 302 | int ps3mapi_get_vsh_plugin_free_slot(void) 303 | { 304 | char tmp_name[30]; 305 | char tmp_filename[256]; 306 | unsigned int slot; 307 | 308 | for (slot = 1; slot < 7; slot++) 309 | { 310 | memset(tmp_name, 0, sizeof(tmp_name)); 311 | memset(tmp_filename, 0, sizeof(tmp_filename)); 312 | ps3mapi_get_vsh_plugin_info(slot, tmp_name, tmp_filename); 313 | if(strlen(tmp_filename) == 0 && strlen(tmp_name) == 0) 314 | return slot; 315 | } 316 | 317 | return 0; 318 | } 319 | 320 | //----------------------------------------------- 321 | //THREAD 322 | //----------------------------------------------- 323 | 324 | int ps3mapi_create_process_thread(process_id_t pid, thread_t *thread, void *entry, uint64_t arg, int prio, size_t stacksize, char *threadname) 325 | { 326 | lv2syscall8(8, SYSCALL8_OPCODE_PROC_CREATE_THREAD, (uint64_t)pid, (uint64_t)thread, (uint64_t)entry, (uint64_t)arg, (uint64_t)prio, (uint64_t)stacksize, (uint64_t)threadname); 327 | return_to_user_prog(int); 328 | } 329 | 330 | //----------------------------------------------- 331 | //CLEAN SYSCALL 332 | //----------------------------------------------- 333 | 334 | int ps3mapi_check_syscall(int num) 335 | { 336 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_CHECK_SYSCALL, (uint64_t)num); 337 | return_to_user_prog(int); 338 | } 339 | 340 | int ps3mapi_disable_syscall(int num) 341 | { 342 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_DISABLE_SYSCALL, (uint64_t)num); 343 | return_to_user_prog(int); 344 | } 345 | 346 | int ps3mapi_pdisable_syscall8(int mode) 347 | { 348 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_PDISABLE_SYSCALL8, (uint64_t)mode); 349 | return_to_user_prog(int); 350 | } 351 | 352 | int ps3mapi_pcheck_syscall8() 353 | { 354 | lv2syscall2(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_PCHECK_SYSCALL8); 355 | return_to_user_prog(int); 356 | } 357 | 358 | //----------------------------------------------- 359 | //PSID/IDPS 360 | //----------------------------------------------- 361 | 362 | int ps3mapi_get_idps(uint64_t *idps) 363 | { 364 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_IDPS, (uint64_t)idps); 365 | return_to_user_prog(int); 366 | } 367 | 368 | int ps3mapi_set_idps(uint64_t part1, uint64_t part2) 369 | { 370 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_SET_IDPS, (uint64_t)part1, (uint64_t)part2); 371 | return_to_user_prog(int); 372 | } 373 | 374 | int ps3mapi_get_psid(uint64_t *psid) 375 | { 376 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_GET_PSID, (uint64_t)psid); 377 | return_to_user_prog(int); 378 | } 379 | 380 | int ps3mapi_set_psid(uint64_t part1, uint64_t part2) 381 | { 382 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_SET_PSID, (uint64_t)part1, (uint64_t)part2); 383 | return_to_user_prog(int); 384 | } 385 | 386 | //----------------------------------------------- 387 | //DISABLE COBRA/MAMBA 388 | //----------------------------------------------- 389 | 390 | int ps3mapi_remove_hook(void) 391 | { 392 | lv2syscall2(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_REMOVE_HOOK); 393 | return_to_user_prog(int); 394 | } 395 | 396 | //----------------------------------------------- 397 | //PEEK & POKE 398 | //----------------------------------------------- 399 | 400 | int ps3mapi_support_sc8_peek_poke(void) 401 | { 402 | lv2syscall2(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_SUPPORT_SC8_PEEK_POKE); 403 | return_to_user_prog(int); 404 | } 405 | 406 | uint64_t ps3mapi_lv1_peek(uint64_t addr) 407 | { 408 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_LV1_PEEK, (uint64_t)addr); 409 | return_to_user_prog(uint64_t); 410 | } 411 | 412 | uint64_t ps3mapi_lv2_peek(uint64_t addr) 413 | { 414 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_LV2_PEEK, (uint64_t)addr); 415 | return_to_user_prog(uint64_t); 416 | } 417 | 418 | int ps3mapi_lv1_poke(uint64_t addr, uint64_t value) 419 | { 420 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_LV1_POKE, (uint64_t)addr, (uint64_t)value); 421 | return_to_user_prog(int); 422 | } 423 | 424 | int ps3mapi_lv2_poke(uint64_t addr, uint64_t value) 425 | { 426 | lv2syscall4(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_LV2_POKE, (uint64_t)addr, (uint64_t)value); 427 | return_to_user_prog(int); 428 | } 429 | 430 | //----------------------------------------------- 431 | //SECURITY 432 | //----------------------------------------------- 433 | 434 | int ps3mapi_set_access_key(uint64_t key) 435 | { 436 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_SET_ACCESS_KEY, (uint64_t)key); 437 | return_to_user_prog(int); 438 | } 439 | 440 | int ps3mapi_request_access(uint64_t key) 441 | { 442 | lv2syscall3(8, SYSCALL8_OPCODE_PS3MAPI, PS3MAPI_OPCODE_REQUEST_ACCESS, (uint64_t)key); 443 | return_to_user_prog(int); 444 | } 445 | 446 | //----------------------------------------------- 447 | //EXTRA (NO PS3 MANAGER SYSCALL) 448 | //----------------------------------------------- 449 | 450 | int ps3_shutdown(void) 451 | { 452 | sysLv2FsUnlink((char*)"/dev_hdd0/tmp/turnoff"); 453 | lv2syscall4(379, 0x1100, 0, 0, 0); 454 | return_to_user_prog(int); 455 | } 456 | 457 | int ps3_quick_restart(void) 458 | { 459 | sysLv2FsUnlink((char*)"/dev_hdd0/tmp/turnoff"); 460 | lv2syscall3(379, 0x8201 , 0, 0); 461 | return_to_user_prog(int); 462 | } 463 | 464 | int ps3_hard_restart(void) 465 | { 466 | sysLv2FsUnlink((char*)"/dev_hdd0/tmp/turnoff"); 467 | lv2syscall3(379, 0x1200 , 0, 0); 468 | return_to_user_prog(int); 469 | } 470 | 471 | int ps3_soft_restart(void) 472 | { 473 | sysLv2FsUnlink((char*)"/dev_hdd0/tmp/turnoff"); 474 | lv2syscall3(379, 0x200 , 0, 0); 475 | return_to_user_prog(int); 476 | } 477 | 478 | int led(uint64_t color, uint64_t mode) 479 | { 480 | lv2syscall2(386, (uint64_t)color, (uint64_t)mode); 481 | return_to_user_prog(int); 482 | } 483 | 484 | int ring_buzzer_simple(void) 485 | { 486 | lv2syscall3(392, 0x1004, 0x4, 0x6); 487 | return_to_user_prog(int); 488 | } 489 | 490 | int ring_buzzer_double(void) 491 | { 492 | lv2syscall3(392, 0x1004, 0x7, 0x36); 493 | return_to_user_prog(int); 494 | } 495 | 496 | int ring_buzzer_triple(void) 497 | { 498 | lv2syscall3(392, 0x1004, 0xa, 0x1b6); 499 | return_to_user_prog(int); 500 | } 501 | 502 | int sys_game_get_temperature(uint32_t _dev, uint32_t *temperature) 503 | { 504 | lv2syscall2(383, (uint64_t)_dev, (uint64_t)temperature); 505 | return_to_user_prog(int); 506 | } 507 | 508 | int get_temperature_celcius(uint32_t *cpu_temp, uint32_t *rsx_temp) 509 | { 510 | sys_game_get_temperature(0, cpu_temp); 511 | sys_game_get_temperature(1, rsx_temp); 512 | *cpu_temp>>=24; 513 | *rsx_temp>>=24; 514 | return 0; 515 | } 516 | --------------------------------------------------------------------------------