Skip to content

Commit

Permalink
Update project to 1.40
Browse files Browse the repository at this point in the history
- Removed taiHEN dependency.
- Update get ctrl function.
  So can load vmass.skprx from low boot level
  • Loading branch information
Princess-of-Sleeping committed Feb 11, 2021
1 parent ff62992 commit 27b6313
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 189 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")
add_executable(vmass
src/main.c
src/vmass.c
src/vmass_sysevent.c
src/fat.c
)

target_link_libraries(vmass
SceCpuForDriver_stub
SceCtrlForDriver_stub
SceDebugForDriver_stub
SceDmacmgrForDriver_stub
SceDisplayForDriver_stub
SceIofilemgrForDriver_stub
SceThreadmgrForDriver_stub
SceModulemgrForDriver_stub
SceSysconForDriver_stub
SceSysmemForDriver_stub
SceSysclibForDriver_stub
SceKernelSuspendForDriver_stub
taihenForKernel_stub
)

set_target_properties(vmass
Expand Down
9 changes: 9 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

if [ ! -d build ]; then
mkdir build
fi

cd build
cmake ../
make
cd ..
17 changes: 10 additions & 7 deletions exports.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
vmass:
attributes: 0
attributes: 7
version:
major: 0x1
minor: 0x31
minor: 0x40
main:
start: module_start
stop: module_stop
modules:
VmassForDriver:
SceUsbMassForDriver:
syscall: false
nid: 0x15243EC5
functions:
- vmassGetDevInfo
- vmassReadSector
- vmassWriteSector
- vmassGetDevInfo: 0xD989A9F6
- vmassReadSector: 0xB80D1DF8
- vmassWriteSector: 0x081CA197
- sceUsbMassIntrHandler: 0xF2BAB182
- SceUsbMassForDriver_3C821E99: 0x3C821E99
- SceUsbMassForDriver_7833D935: 0x7833D935
94 changes: 2 additions & 92 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,84 +16,10 @@
#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 <string.h>
#include <psp2kern/kernel/sysclib.h>
#include <psp2kern/kernel/iofilemgr.h>
#include "vmass.h"

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

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

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

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

SceUID hook[6];

tai_hook_ref_t sceUsbMassGetDevInfo_ref;
tai_hook_ref_t sceUsbMassWriteSector_ref;
tai_hook_ref_t sceUsbMassReadSector_ref;
tai_hook_ref_t sceUsbMassIntrHandler_ref;
tai_hook_ref_t SceUsbMassForDriver_3C821E99_ref;
tai_hook_ref_t SceUsbMassForDriver_7833D935_ref;

int sceUsbMassGetDevInfo_patch(SceUsbMassDevInfo *info){
return vmassGetDevInfo(info);
}

int sceUsbMassWriteSector_patch(SceSize sector_pos, const void *data, SceSize sector_num){
return vmassWriteSector(sector_pos, data, sector_num);
}

int sceUsbMassReadSector_patch(SceSize sector_pos, void *data, SceSize sector_num){
return vmassReadSector(sector_pos, data, sector_num);
}

int sceUsbMassIntrHandler_patch(int intr_code, void *userCtx){

if(intr_code != 0xF)
return 0x80010016;

return -1;
}

int SceUsbMassForDriver_3C821E99_patch(int a1, int a2){

if(a1 != 0xF)
return 0x80010016;

return 0;
}

int SceUsbMassForDriver_7833D935_patch(int a1, int a2){

if(a1 != 0xF)
return 0x80010016;

return 0;
}

tai_hook_ref_t ksceIoOpen_ref;
SceUID ksceIoOpen_patch(const char *file, int flags, SceMode mode){

SceUID fd;

fd = TAI_CONTINUE(SceUID, ksceIoOpen_ref, file, flags, mode);

if((fd > 0) && (strcmp(file, "tty0:") == 0 || strcmp(file, "tty1:") == 0 || strcmp(file, "tty7:") == 0)){
ksceIoClose(fd);
fd = TAI_CONTINUE(SceUID, ksceIoOpen_ref, "uma0:log.txt", SCE_O_WRONLY | SCE_O_RDONLY | SCE_O_CREAT | SCE_O_APPEND, 0666);
}

return fd;
}

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

Expand Down Expand Up @@ -121,23 +47,7 @@ int module_start(SceSize args, void *argp){

ksceKernelFreeHeapMemory(0x1000B, data);

hook[0] = HookImport("SceSdstor", 0x15243ec5, 0xd989a9f6, sceUsbMassGetDevInfo);
hook[1] = HookImport("SceSdstor", 0x15243ec5, 0xb80d1df8, sceUsbMassReadSector);
hook[2] = HookImport("SceSdstor", 0x15243ec5, 0x081ca197, sceUsbMassWriteSector);
hook[3] = HookImport("SceSdstor", 0x15243ec5, 0xf2bab182, sceUsbMassIntrHandler);
hook[4] = HookImport("SceSdstor", 0x15243ec5, 0x3c821e99, SceUsbMassForDriver_3C821E99);
hook[5] = HookImport("SceSdstor", 0x15243ec5, 0x7833d935, SceUsbMassForDriver_7833D935);

ksceIoMount(0xF00, NULL, 2, 0, 0, 0);

/*
* redirect sceClibPrintf out to uma0:log.txt
*/
// HookImport("SceProcessmgr", 0x40fd29c7, 0x75192972, ksceIoOpen);

return SCE_KERNEL_START_SUCCESS;
}

int module_stop(SceSize args, void *argp){
return SCE_KERNEL_STOP_CANCEL;
}
28 changes: 28 additions & 0 deletions src/sysevent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* \kernelgroup{SceSysEvent}
* \usage{psp2kern/kernel/sysevent.h,SceKernelSuspendForDriver_stub}
*/

#ifndef _PSP2_KERNEL_SYSEVENT_H_
#define _PSP2_KERNEL_SYSEVENT_H_

#include <psp2kern/types.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef int (* SceSysEventCallback)(int resume, int eventid, void *args, void *opt);

SceUID ksceKernelRegisterSysEventHandler(const char *name, SceSysEventCallback cb, void *argp);
int ksceKernelUnregisterSysEventHandler(SceUID id);

#define SCE_SYS_EVENT_STATE_SUSPEND (0)
#define SCE_SYS_EVENT_STATE_POWEROFF (1)
#define SCE_SYS_EVENT_STATE_REBOOT (2)

#ifdef __cplusplus
}
#endif

#endif /* _PSP2_KERNEL_SYSEVENT_H_ */
Loading

0 comments on commit 27b6313

Please sign in to comment.