uofw/include/iofilemgr_kernel.h
Felix-Dev b0146f24a2
Add Module Manager (#69)
* src/modulemgr: sceKernelQueryModuleInfo(): Improved documentation

* src/modulemgr: Fixed various incorrect SDK versions

* src/modulemgr.c: sceKernelQueryModuleInfo(): Fixed two syntax errors.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleWithBlockOffset().

* src/modulemgr/modulemgr.c: Fixed wrong handling of various sceIoIoctl() status values.

* src/modulemgr/modulemgr.c: Added missing sysmem_kernel.h include.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleByIDWithBlockOffset().

* src/modulemgr/modulemgr.c: Fixed register K1 permission checks in various user-exported loadModule() functions.

* src/modulemgr/modulemgr.c: sceKernelLoadModuleForUser(): Fixed handling of parameter "opt" when being NULL.

* src/modulemgr/modulemgr.c: Fixed sdkVersion return codes in various LoadModule() functions.

* include/iofilemgr_kernel.h: Added back SCE_O_UNKNOWN0.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleDNAS().

* src/modulemgr: Updated and added documentation

- Added documentation for sceKernelLoadModuleById(),
sceKernelLoadModuleWithBlockOffset(), and sceKernelLoadModuleDNAS
- Updated documentation of ModuleMgrForKernel_2B7FC10D(),
sceKernelLoadModule(), sceKernelGetModuleIdList(),
sceKernelQueryModuleInfo(), sceKernelGetModuleId(),
sceKernelGetModuleIdByAddress(), and sceKernelGetModuleGPByAddress()

* src/modulemgr: Updated documentation: case when SCE_ERROR_KERNEL_ILLEGAL_ADDRESS is returned

Affects sceKernelLoadModuleWithBlockOffset() and
sceKernelLoadModuleByIDWithBlockOffset().

* src/modulemgr: sceKernelLoadModuleDNAS(): Forgot a word in documentation

* src/modulemgr: sceKernelLoadModuleDNAS(): Forgot quotation marks in documentation

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleNpDrm().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleMs().

* src/modulemgr/modulemgr.c: Added sceKernelSelfStopUnloadModule().

* src/modulemgr/modulemgr.c: Added sceKernelStopModule().

* src/modulemgr: sceKernelLoadModuleNpDrm(): Fixed a pointer issue

* include/common/memory.h: Added pspClearMemory*() functions. These functions should be used as an alternative to corresponding memset calls.

* src/modulemgr/modulemgr.c: Replaced the variable <modParams> clearing-for-loops with the pspClearMemory32() function.

* src/modulemgr: sceKernelLoadModuleNpDrm(): Added documentation

* src/modulemgr: Added sceKernelLoadModuleBufferUsbWlan()

* src/modulemgr: sceKernelLoadModuleBufferUsbWlan(): Fixed return type

* src/modulemgr: Added _LoadModuleByBufferID()

* src/modulemgr: Added _start_exe_thread()

* src/modulemgr: Added sub_00007620()

* src/modulemgr: Added sub_00007698()

* src/modulemgr: Rename sub_00007620() to _CheckOption()

* src/modulemgr: _CheckOption(): Fix return type

* src/modulemgr: Added _SelfStopUnloadModule()

* src/modulemgr/: Added loadModuleChecks_inline.h containing commonly used checks in loadModule() functions. The check functions introduced there should be used in loadModule() functions.

* src/modulemgr/modulemgr.c: Preparations for the use of _check functions().

* src/modulemgr/modulemgr.c: Removed _CheckOptions(). Its equivalent function is _checkLMOptionConditions() defined in loadModuleChecks_inline.h.

* src/modulemgr/modulemgr.c: loadModule _check() functions are now being used.

* src/modulemgr/loadModuleChecks_inline.h: Removed _setupChecks() and _terminateChecks().

* src/modulemgr/modulemgr.c: Fixed _SelfStopUnloadModule().

* src/modulemgr/modulemgr.c: Forgot to fix pointer errors in _SelfStopUnloadModule() in previous commit.

* src/modulemgr/modulemgr.c: Added _EpilogueModule().

* src/modulemgr: Added sub_000077F0()

* src/modulemgr: _EpilogueModule(): Replaced hardcoded size by sizeof()

* modulemgr: renamed sub_000077F0 to _StopUnloadSelfModuleWithStatus()

* src/modulemgr/modulemgr.c: Added _ModuleReleaseLibraries().

* src/modulemgr: Added _checkSMOptionConditions() and fixed small issues in _StopUnloadSelfModuleWithStatus().

* src/modulemgr/modulemgr.c: Added sceKernelStartModule().

* include/threadman_kernel: Added more thread attribute values.

* src/modulemgr/modulemgr.c: Added sceKernelRebootBeforeForUser().

* src/modulemgr/modulemgr.c: Added sceKernelRebootPhaseForKernel().

* src/modulemgr/modulemgr.c: Added sceKernelRebootBeforeForKernel().

* include/modulemgr_user.h: Added documentation for sceKernelLoadModuleMs().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDisc().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDiscUpdater().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDiscDebug().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDiscEmu().

* src/modulemgr/modulemgr.c: Added ModuleMgrForKernel_C2A5E6CA().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs1().

* added current work from months ago

* src/modulemgr: Cleaned modulemgr directory and added first code.

* src/modulemgr: Finished ModuleMgrInit().

* src/modulemgr: ModuleMgrInit(): Added ChunkInit() call.

* src/modulemgr: Added _ModuleMgrRebootBefore().

* include/threadman_kernel.h: Added sceKernelSuspendThread().

* src\modulemgr\modulemgr.c: Added functions to reverse

* src/modulemgr: Fixed ModuleMgrRebootBefore prefix

ModuleMgrRebootBefore was prefixed with _ although it's not an internal
function

* src/modulmgr: Added ModuleMgrRebootPhase().

* src/modulemgr: Added exe_thread().

* src/modulemgr: Added_UnloadModule().

* src/modulemgr: Fixed a mistake in_UnloadModule().

* src/modulemgr: Added sceKernelGetModuleId().

* src/modulemgr: sceKernelGetModuleId(): Clarified variable name and type.

* src/modulemgr: sceKernelGetModuleId(): Changed return type (forgot it in last commit) for clarification reasons.

* src/modulemgr: sceKernelGetModuleId(): Fixed K1 register handling.

* include/iofilemgr_kernel.h: Added more sceIoOpen() flags.

* src/modulemgr: Added sceKernelGetModuleIdByAddress()

* src/modulemgr: Documentation for sceKernelGetModuleId()

* src/modulemgr: sceKernelGetModuleIdByAddress():  Fixed pspK1PtrOk() argument

* src/modulemgr: Added sceKernelGetModuleGPByAddress()

* src/modulemgr: Fixed missing const statement in arguments

* include/iofilemgr_kernel.h: Added sceKernelLoadModuleForLoadExecForUser().

* src/modulemgr.c: sceKernelGetModuleGPByAddress(): Added retVal declaration.

* src/modulemgr.c: sceKernelLoadModuleForLoadExecForUser(): Added back SCeUID fd declaration (it was eaten by some ghosts I guess).

* src/modulemgr: Added sceKernelGetModuleIdList()

* src/modulemgr: Added sceKernelLoadModule()

* src/modulemgr: sceKernelLoadModuleForLoadExecForUser(): Fixed pointer issues, added some comments

* src/modulemgr: sceKernelLoadModule(): Fixed missing structure field set

* src/modulemgr: sceKernelLoadModuleForLoadExecForUser() and sceKernelLoadModule(): Added documentation

* src/modulemgr: struct SceKernelLMOption: Added documentation

* src/modulemgr: sceKernelLoadModule(): Fixed return value

* src/modulemgr.c: Removed SceKernelLMOption declaration (it is already declared in include/modulemgr_options.h).

* include/modulemgr_options.h: Added back the doxygen documentation for SceKernelLMOption.

* src/modulemgr.c: Added sceKernelLoadModuleByID().

* src/modulemgr.c: sceKernelLoadModule(): Fixed ioctl command.

* src/modulemgr.c: Renamed sceKernelLoadModule() -> sceKernelLoadModuleForUser().

* src/modulemgr.c: sceKernelLoadModuleForUser(): Fixed ioctl command (another one).

* src/modulemgr: Added sceKernelQueryModuleInfo()

* src/modulemgr: sceKernelQueryModuleInfo(): Improved documentation

* src/modulemgr: Fixed various incorrect SDK versions

* src/modulemgr.c: sceKernelQueryModuleInfo(): Fixed two syntax errors.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleWithBlockOffset().

* src/modulemgr/modulemgr.c: Fixed wrong handling of various sceIoIoctl() status values.

* src/modulemgr/modulemgr.c: Added missing sysmem_kernel.h include.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleByIDWithBlockOffset().

* src/modulemgr/modulemgr.c: Fixed register K1 permission checks in various user-exported loadModule() functions.

* src/modulemgr/modulemgr.c: sceKernelLoadModuleForUser(): Fixed handling of parameter "opt" when being NULL.

* src/modulemgr/modulemgr.c: Fixed sdkVersion return codes in various LoadModule() functions.

* include/iofilemgr_kernel.h: Added back SCE_O_UNKNOWN0.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleDNAS().

* src/modulemgr: Updated and added documentation

- Added documentation for sceKernelLoadModuleById(),
sceKernelLoadModuleWithBlockOffset(), and sceKernelLoadModuleDNAS
- Updated documentation of ModuleMgrForKernel_2B7FC10D(),
sceKernelLoadModule(), sceKernelGetModuleIdList(),
sceKernelQueryModuleInfo(), sceKernelGetModuleId(),
sceKernelGetModuleIdByAddress(), and sceKernelGetModuleGPByAddress()

* src/modulemgr: Updated documentation: case when SCE_ERROR_KERNEL_ILLEGAL_ADDRESS is returned

Affects sceKernelLoadModuleWithBlockOffset() and
sceKernelLoadModuleByIDWithBlockOffset().

* src/modulemgr: sceKernelLoadModuleDNAS(): Forgot a word in documentation

* src/modulemgr: sceKernelLoadModuleDNAS(): Forgot quotation marks in documentation

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleNpDrm().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleMs().

* src/modulemgr/modulemgr.c: Added sceKernelSelfStopUnloadModule().

* src/modulemgr/modulemgr.c: Added sceKernelStopModule().

* src/modulemgr: sceKernelLoadModuleNpDrm(): Fixed a pointer issue

* include/common/memory.h: Added pspClearMemory*() functions. These functions should be used as an alternative to corresponding memset calls.

* src/modulemgr/modulemgr.c: Replaced the variable <modParams> clearing-for-loops with the pspClearMemory32() function.

* src/modulemgr: sceKernelLoadModuleNpDrm(): Added documentation

* src/modulemgr: Added sceKernelLoadModuleBufferUsbWlan()

* src/modulemgr: sceKernelLoadModuleBufferUsbWlan(): Fixed return type

* src/modulemgr: Added _LoadModuleByBufferID()

* src/modulemgr: Added _start_exe_thread()

* src/modulemgr: Added sub_00007620()

* src/modulemgr: Added sub_00007698()

* src/modulemgr: Rename sub_00007620() to _CheckOption()

* src/modulemgr: _CheckOption(): Fix return type

* src/modulemgr: Added _SelfStopUnloadModule()

* src/modulemgr/: Added loadModuleChecks_inline.h containing commonly used checks in loadModule() functions. The check functions introduced there should be used in loadModule() functions.

* src/modulemgr/modulemgr.c: Preparations for the use of _check functions().

* src/modulemgr/modulemgr.c: Removed _CheckOptions(). Its equivalent function is _checkLMOptionConditions() defined in loadModuleChecks_inline.h.

* src/modulemgr/modulemgr.c: loadModule _check() functions are now being used.

* src/modulemgr/loadModuleChecks_inline.h: Removed _setupChecks() and _terminateChecks().

* src/modulemgr/modulemgr.c: Fixed _SelfStopUnloadModule().

* src/modulemgr/modulemgr.c: Forgot to fix pointer errors in _SelfStopUnloadModule() in previous commit.

* src/modulemgr/modulemgr.c: Added _EpilogueModule().

* src/modulemgr: Added sub_000077F0()

* src/modulemgr: _EpilogueModule(): Replaced hardcoded size by sizeof()

* modulemgr: renamed sub_000077F0 to _StopUnloadSelfModuleWithStatus()

* src/modulemgr/modulemgr.c: Added _ModuleReleaseLibraries().

* src/modulemgr: Added _checkSMOptionConditions() and fixed small issues in _StopUnloadSelfModuleWithStatus().

* src/modulemgr/modulemgr.c: Added sceKernelStartModule().

* include/threadman_kernel: Added more thread attribute values.

* src/modulemgr/modulemgr.c: Added sceKernelRebootBeforeForUser().

* src/modulemgr/modulemgr.c: Added sceKernelRebootPhaseForKernel().

* src/modulemgr/modulemgr.c: Added sceKernelRebootBeforeForKernel().

* include/modulemgr_user.h: Added documentation for sceKernelLoadModuleMs().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDisc().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDiscUpdater().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDiscDebug().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHDiscEmu().

* src/modulemgr/modulemgr.c: Added ModuleMgrForKernel_C2A5E6CA().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs1().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs2().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs3().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs4().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs5().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecVSHMs6().

* src/modulemgr/modulemgr.c: Added ModuleMgrForKernel_8DD336D4().

* src/modulemgr: Simplified ModuleMgrRebootBefore(()

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForLoadExecNpDrm().

* src/modulemgr/modulemgr.c: Minor line indentation corrections.

* src/modulemgr/modulemgr.c: option-> pOpt name change in several functions.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleVSH().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleVSHByID().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleForKernel().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleByIDForKernel().

* src/modulemgr/modulemgr.c: Added more functions.

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleBufferForExitGame() and sceKernelLoadModuleBufferMs().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleBufferApp().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleBufferForLoadExecBufferVSHUsbWlan().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleBufferForLoadExecBufferVSHUsbWlanDebug().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleBufferVSH().

* src/modulemgr/modulemgr.c: Added sceKernelLoadModuleBufferForExitVSHVSH().

* src/modulemgr/modulemgr.c: Added more functions.

* src/modulemgr/modulemgr.c: Added sceKernelUnloadModule().

* src/modulemgr/modulemgr.c: Added sceKernelSearchModuleByName().

* src/modulemgr/modulemgr.c: Added sceKernelSearchModuleByAddress().

* src/modulemgr/modulemgr.c: Added sceKernelSetNpDrmGetModuleKeyFunction().

* src/modulemgr/modulemgr.c: Added sceKernelNpDrmGetModuleKey().

* src/modulemgr/modulemgr.c: Added sceKernelModuleMgrMode().

* src/modulemgr/modulemgr.c: Added _StartModule().

* src/modulemgr/modulemgr.c: Added __StopModule().

* src/modulemgr/modulemgr.c: Added _PrologueModule().

* src/modulemgr/modulemgr.c: Added _ModuleRegisterLibraries().

* src/modulemgr/modulemgr.c: Fixed error in _ModuleReleaseLibraries().

* Moved NID_MODULE_* NIDs from src/loadcore/nid.h -> include/modulemgr_nids.h.

* src/modulemgr/modulemgr.c: Added _ProcessModuleExportEnt().

* include/loadcore.h: Renamed SceLoadCoreExecFileInfo.unk104 -> SceLoadCoreExecFileInfo.secureInstallId.

* include/sysmem_user.h: SceSysMemBlockType: Added more members.

* src/modulemgr/modulemgr.c: Added _LoadModule().

* src/modulemgr/modulemgr.c: Added _PartitionCheck().

* src/modulemgr/modulemgr.c: Added _CheckSkipPbpHeader().

* src/modulemgr/modulemgr.c: Fixes and reduced use of magic numbers

* src/modulemgr/modulemgr.c: Fixes and reduced use of magic numbers (2)

* src/modulemgr/modulemgr.c: Fixed mistake in sceKernelQueryModuleInfo().

* src/modulemgr/modulemgr.c: More small fixes and code cleanup.

* Modulemgr: Remove already reverse-engineered function

* src/modulemgr/modulemgr.c: Fixed a few compilation issues.

* src/modulemgr: Broke up modulemgr.c into several .c files.

* modulemgr: Reverse _CheckOverride()

- Move _CheckOverride() into a separate file

- Reverse _CheckOverride()

- Add the rules for overriding modules' file descriptors

* src/modulemgr/modulemgr.c: Fixed _CheckSkipPbpHeader.

* src/modulemgr/override.c: Fixed syntax errors.

* modulemgr: Fix more mistakes in override

* src/modulemgr: Added pbp.h ( .PBP header description).

* src/modulemgr/modulemgr.c: Added _RelocateModule().

* src/modulemgr/modulemgr.c: Fixed mistake in ModuleRegisterLibraries().

* include/sysmem_kernel.h: Updated prototype of sceKernelGetId().

* src/modulemgr/modulemgr.c: Added ModuleMgrForUser_CDE1C1FE().

* src/modulemgr/modulemgr.c: Added allocate_module_block().

* src/modulemgr/override.c: Fixed mistakes in _CheckOverride() and added more documentation about its purpose.

* modulemgr/rebootModule: Replace hexa with constant

* modulemgr/modulemgr: ModuleMgrForUser_CDE1C1FE(): s32 -> SceBool

* modulemgr: Fixes, re-writes, improved naming, added some documentation. It does not compile yet!

* modulemgr: Make it compilable.

* Removed include/modulemgr.h.

* src/modulemgr: Added missing Makefile.

* modulemgr: Updated its static libraries to reflect name changes of its exported functions.

* modulemgr: Made Loadcore and Loadexec compilable again. They were broken after changes have been made for modulemgr.

* modulemgr: Fixed a few mistakes.

* modulemgr: More fixes and updated some documentation.

* modulemgr: Added .PBP file layout and PARAM.SFO information.

* include/modulemgr_init.h: Added more SCE_EXEC_FILE_* members.

* include/common/errors.h: Added error-value format description.

* modulemgr: More fixes. Also added debug code for modulemgr (dbg.c). It will be removed before merging into 'master'.

* modulemgr: Added missing debug code.

* src/modulemgr: Fixed more errors.

* update .gitignore with version on master

* update .gitignore

* update .gitignore

* Module manager: Remove debug code

* Revert changes made to debug header.

* Add modulemgr to global makefile.

Co-authored-by: devnoname120 <devnoname120@gmail.com>
Co-authored-by: Felix-Dev <FelixDev91.gmail.com>
Co-authored-by: Kern Walster <wals0323@umn.edu>
Co-authored-by: Martin Charles <martincharles07@gmail.com>
Co-authored-by: devnoname120 <devnoname120+gh@gmail.com>
2021-01-02 16:30:44 +01:00

307 lines
11 KiB
C

/* Copyright (C) 2011, 2012 The uOFW team
See the file COPYING for copying permission.
*/
#include "common_header.h"
/* flags */
#define SCE_FREAD (0x0001) /* readable */
#define SCE_FWRITE (0x0002) /* writable */
#define SCE_FNBLOCK (0x0004) /* Reserved: non-blocking reads */
#define SCE_FDIRO (0x0008) /* internal use for dopen */
#define SCE_FRLOCK (0x0010) /* Reserved: read locked (non-shared) */
#define SCE_FWLOCK (0x0020) /* Reserved: write locked (non-shared) */
#define SCE_FAPPEND (0x0100) /* append on each write */
#define SCE_FCREAT (0x0200) /* create if nonexistant */
#define SCE_FTRUNC (0x0400) /* truncate to zero length */
#define SCE_EXCL (0x0800) /* exclusive create */
#define SCE_FSCAN (0x1000) /* Reserved: scan type */
#define SCE_FRCOM (0x2000) /* Reserved: remote command entry */
#define SCE_FNBUF (0x4000) /* Reserved: no ring buf. and console interrupt */
#define SCE_FASYNC (0x8000) /* Reserved: asyncronous i/o */
#define SCE_FFDEXCL (0x01000000) /* exclusive access */
#define SCE_FPWLOCK (0x02000000) /* power control lock */
#define SCE_FENCRYPTED (0x04000000)
#define SCE_FGAMEDATA (0x40000000)
/* flags for sceIoOpen() */
#define SCE_O_RDONLY (SCE_FREAD) /* readable */
#define SCE_O_WRONLY (SCE_FWRITE) /* writable */
#define SCE_O_RDWR (SCE_FREAD|SCE_FWRITE) /* readable & writable */
#define SCE_O_NBLOCK (SCE_FNBLOCK) /* Reserved: Non-Blocking I/O */
#define SCE_O_APPEND (SCE_FAPPEND) /* append (writes guaranteed at the end) */
#define SCE_O_CREAT (SCE_FCREAT) /* open with file create */
#define SCE_O_TRUNC (SCE_FTRUNC) /* open with truncation */
#define SCE_O_EXCL (SCE_EXCL) /* exclusive create */
#define SCE_O_NOBUF (SCE_FNBUF) /* Reserved: no device buffer and console interrupt */
#define SCE_O_NOWAIT (SCE_FASYNC) /* Reserved: asyncronous i/o */
#define SCE_O_FDEXCL (SCE_FFDEXCL) /* exclusive access */
#define SCE_O_PWLOCK (SCE_FPWLOCK) /* power control lock */
#define SCE_O_ENCRYPTED (SCE_FENCRYPTED) /* encrypted file (uses Kernel/DNAS/NPDRM-encryption) */
#define SCE_O_FGAMEDATA (SCE_FGAMEDATA)
/* sceIoOpen().mode permission bits */
#define SCE_STM_RWXU 00700 /* user read/write/execute permission. */
#define SCE_STM_RUSR 00400 /* user read permission. */
#define SCE_STM_WUSR 00200 /* user write permission. */
#define SCE_STM_XUSR 00100 /* user execute permission. */
#define SCE_STM_RWXG 00070 /* group read/write/execute permission. */
#define SCE_STM_RGRP 00040 /* group read permission. */
#define SCE_STM_WGRP 00020 /* group write permission. */
#define SCE_STM_XGRP 00010 /* group execute permission. */
#define SCE_STM_RWXO 00007 /* other read/write/execute permission. */
#define SCE_STM_ROTH 00004 /* other read permission. */
#define SCE_STM_WOTH 00002 /* other write permission. */
#define SCE_STM_XOTH 00001 /* other execute permission. */
#define SCE_STM_RWXUGO (SCE_STM_RWXU|SCE_STM_RWXG|SCE_STM_RWXO) /* user/group/other - read/write/execute. */
#define SCE_STM_RUGO (SCE_STM_RUSR|SCE_STM_RGRP|SCE_STM_ROTH) /* user/group/other - read. */
#define SCE_STM_WUGO (SCE_STM_WUSR|SCE_STM_WGRP|SCE_STM_WOTH) /* user/group/other - write. */
#define SCE_STM_XUGO (SCE_STM_XUSR|SCE_STM_XGRP|SCE_STM_XOTH) /* user/group/other - execute. */
/* flags for sceIoLseek().whence */
#define SCE_SEEK_SET 0 /* Offset is the distance from the start of the file. */
#define SCE_SEEK_CUR 1 /* Offset is the relative distance from the current position in the file. */
#define SCE_SEEK_END 2 /* Offset is the distance from the end of the file. */
typedef struct ScePspDateTime {
u16 year;
u16 month;
u16 day;
u16 hour;
u16 minute;
u16 second;
u32 microsecond;
} ScePspDateTime;
struct SceIoDeviceArg;
typedef struct SceIoDeviceArg SceIoDeviceArg;
struct SceIoIob;
typedef struct SceIoIob SceIoIob;
typedef struct
{
SceMode st_mode;
u32 st_attr;
SceOff st_size;
ScePspDateTime st_ctime;
ScePspDateTime st_atime;
ScePspDateTime st_mtime;
u32 st_private[6];
} SceIoStat;
typedef struct
{
SceIoStat d_stat;
char d_name[256];
void *d_private;
int dummy;
} SceIoDirent;
typedef struct
{
int (*IoInit)(SceIoDeviceArg *dev);
int (*IoExit)(SceIoDeviceArg *dev);
int (*IoOpen)(SceIoIob *iob, char *file, int flags, SceMode mode);
int (*IoClose)(SceIoIob *iob);
int (*IoRead)(SceIoIob *iob, char *data, int len);
int (*IoWrite)(SceIoIob *iob, const char *data, int len);
SceOff (*IoLseek)(SceIoIob *iob, SceOff ofs, int whence);
int (*IoIoctl)(SceIoIob *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int (*IoRemove)(SceIoIob *iob, const char *name);
int (*IoMkdir)(SceIoIob *iob, const char *name, SceMode mode);
int (*IoRmdir)(SceIoIob *iob, const char *name);
int (*IoDopen)(SceIoIob *iob, const char *dirname);
int (*IoDclose)(SceIoIob *iob);
int (*IoDread)(SceIoIob *iob, SceIoDirent *dir);
int (*IoGetstat)(SceIoIob *iob, const char *file, SceIoStat *stat);
int (*IoChstat)(SceIoIob *iob, const char *file, SceIoStat *stat, int bits);
int (*IoRename)(SceIoIob *iob, const char *oldname, const char *newname);
int (*IoChdir)(SceIoIob *iob, const char *dir);
int (*IoMount)(SceIoIob *iob, const char *fs, const char *blockDev, int mode, void *unk1, int unk2);
int (*IoUmount)(SceIoIob *iob, const char *blockDev);
int (*IoDevctl)(SceIoIob *iob, const char *devname, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int (*IoCancel)(SceIoIob *iob);
} SceIoDrvFuncs;
typedef struct
{
const char *name;
u32 dev_type;
u32 unk2;
const char *name2;
SceIoDrvFuncs *funcs;
} SceIoDrv;
struct SceIoDeviceArg
{
SceIoDrv *drv;
void *argp;
int openedFiles;
};
struct SceIoHookType;
typedef struct SceIoHookType SceIoHookType;
struct SceIoHook;
typedef struct SceIoHook SceIoHook;
typedef struct
{
void (*Add)(SceIoHookType **hook);
int unused4;
int (*Preobe)(SceIoHook *hook, char *file, int flags, SceMode mode);
int (*Open)(SceIoHook *hook, char *file, int flags, SceMode mode);
int (*Close)(SceIoHook *hook);
int (*Read)(SceIoHook *hook, void *data, SceSize size);
int (*Write)(SceIoHook *hook, const void *data, SceSize size);
SceOff (*Lseek)(SceIoHook *hook, SceOff ofs, int whence);
int (*Ioctl)(SceIoHook *iob, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
} SceIoHookFuncs;
struct SceIoHookType
{
char *name;
int unk4;
int unk8;
char *name2;
SceIoHookFuncs *funcs;
};
typedef struct
{
int size; // 0
char name[32]; // 4
int attribute; // 36
int unk40; // 40
const char *drvName; // 44
int fsNum; // 48
char *newPath; // 52
int retAddr; // 56
int curThread; // 60
int asyncThread; // 64
int isAsync; // 68
int asyncCmd; // 72
SceIoIob *iob; // 76
int unk80; // 80
int unk84; // 84
} SceIoFdDebugInfo;
typedef struct
{
SceIoHookType *hook;
void *argp;
} SceIoHookArg;
struct SceIoHook
{
SceIoHookArg *arg;
SceIoIob *iob;
SceIoDrvFuncs *funcs;
};
struct SceIoIob
{
int unk000; // some ID
int fsNum; // 4
SceIoDeviceArg *dev; // 8
int dev_type; // 12
int unk016; // 16
int unk020; // 20
int unk024; // 24
int unk028; // 28
int unk032; // 32
int unk036; // 36
int unk040; // 40
SceUID curThread; // 44
char userMode; // 48
char powerLocked; // 49
char unk050;
char asyncPrio; // 51
SceUID asyncThread; // 52
SceUID asyncSema; // 56
SceUID asyncEvFlag; // 60
SceUID asyncCb; // 64
void *asyncCbArgp; // 68
int unused72; // 72
int k1; // 76
s64 asyncRet; // 80
int asyncArgs[6]; // 88
int asyncCmd; // 112
int userLevel; // 116
SceIoHook hook; // 120
int unk132; // 132
char *newPath; // 136
int retAddr; // 140
};
int sceIoChangeAsyncPriority(int fd, int prio);
void sceIoCloseAll();
int sceIoReopen(const char *file, int flags, SceMode mode, int fd);
SceUID sceIoDopen(const char *dirname);
int sceIoDread(int fd, SceIoDirent *dir);
int sceIoDclose(int fd);
int sceIoRemove(const char *file);
int sceIoRename(const char *oldname, const char *newname);
int sceIoDevctl(const char *dev, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
/* IO-Assign mount mode flags. */
#define SCE_MT_RDWR 0x00 /** Mount as read/write enabled. */
#define SCE_MT_RDONLY 0x01 /** Mount as read-only. */
#define SCE_MT_ROBUST 0x02 /** Mount in ROBUST mode. */
#define SCE_MT_ERRCHECK 0x04 /** Set an error if there is anything abnormal in the file system when mounting. */
int sceIoAssign(const char *dev, const char *blockDev, const char *fs, int mode, void* unk1, int unk2);
int sceIoUnassign(const char *dev);
int sceIoChangeThreadCwd(SceUID threadId, const char *path);
int sceIoCancel(int fd);
int sceIoGetFdList(SceUID *fds, int numFd, int *count);
int sceIoGetFdDebugInfo(int fd, SceIoFdDebugInfo *outInfo);
int sceIoAddDrv(SceIoDrv *drv);
int sceIoDelDrv(const char *drv);
int sceIoGetUID(int fd);
int sceIoPollAsync(SceUID fd, SceInt64 *res);
int sceIoWaitAsync(SceUID fd, SceInt64 *res);
int sceIoWaitAsyncCB(SceUID fd, SceInt64 *res);
int sceIoGetAsyncStat(SceUID fd, int poll, SceInt64 *res);
int sceIoSetAsyncCallback(SceUID fd, SceUID cb, void *argp);
int sceIoValidateFd(SceUID fd, int arg1);
int sceIoClose(SceUID fd);
int sceIoCloseAsync(SceUID fd);
SceUID sceIoOpen(const char *file, int flags, SceMode mode);
SceUID sceIoOpenAsync(const char *file, int flags, SceMode mode);
int sceIoRead(SceUID fd, void *data, SceSize size);
int sceIoReadAsync(SceUID fd, void *data, SceSize size);
int sceIoWrite(SceUID fd, const void *data, SceSize size);
int sceIoWriteAsync(SceUID fd, const void *data, SceSize size);
SceOff sceIoLseek(SceUID fd, SceOff offset, int whence);
SceOff sceIoLseekAsync(SceUID fd, SceOff offset, int whence);
int sceIoLseek32(SceUID fd, int offset, int whence);
int sceIoLseek32Async(SceUID fd, int offset, int whence);
/* IOCTL */
/* ioctl commands */
#define SCE_GAMEDATA_SET_SECURE_INSTALL_ID (0x04100001)
int sceIoIoctl(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
int sceIoIoctlAsync(SceUID fd, unsigned int cmd, void *indata, int inlen, void *outdata, int outlen);
/* Directory functions */
int sceIoMkdir(const char *path, SceMode mode);
int sceIoRmdir(const char *path);
int sceIoChdir(const char *path);
int sceIoGetstat(const char *file, SceIoStat *stat);
int sceIoChstat(const char *file, SceIoStat *stat, int bits);
int sceIoSync(const char *device, unsigned int unk);
int sceIoGetDevType(SceUID fd);
int sceIoGetThreadCwd(SceUID uid, char *dir, int len);
int sceIoTerminateFd(char *drive);
int sceIoAddHook(SceIoHookType *hook);
int sceIoGetIobUserLevel(SceIoIob *iob);