mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-12-23 12:20:00 +00:00
first commit
This commit is contained in:
40
src/sdk/Makefile.am
Normal file
40
src/sdk/Makefile.am
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
libdir = @PSPSDK_LIBDIR@
|
||||
|
||||
CC = @PSP_CC@
|
||||
CCAS = $(CC)
|
||||
AR = @PSP_AR@
|
||||
RANLIB = @PSP_RANLIB@
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/src/base \
|
||||
-I$(top_srcdir)/src/kernel \
|
||||
-I$(top_srcdir)/src/user \
|
||||
-I$(top_srcdir)/src/net \
|
||||
-I$(top_srcdir)/src/utility \
|
||||
-I$(top_srcdir)/src/debug
|
||||
CFLAGS = @PSPSDK_CFLAGS@
|
||||
CCASFLAGS = $(CFLAGS) $(INCLUDES)
|
||||
|
||||
libpspsdkincludedir = @PSPSDK_INCLUDEDIR@
|
||||
libpspsdkinclude_HEADERS = pspsdk.h
|
||||
|
||||
lib_LIBRARIES = libpspsdk.a
|
||||
|
||||
MODULEMGR_PATCHES_OBJS = \
|
||||
InstallNoDeviceCheckPatch.o \
|
||||
InstallNoPlainModuleCheckPatch.o \
|
||||
InstallKernelLoadModulePatch.o
|
||||
|
||||
INETHELPER_OBJS = pspSdkLoadInetModules.o pspSdkInetInit.o pspSdkInetTerm.o
|
||||
|
||||
MULT_SRCS = modulemgr_patches.c inethelper.c
|
||||
MULT_OBJS = $(MODULEMGR_PATCHES_OBJS) $(INETHELPER_OBJS)
|
||||
|
||||
libpspsdk_a_SOURCES = query_mod.c loadmodule.c fixup.c threadutils.c interrupt.S k1set.S fpu.S $(MULT_SRCS)
|
||||
libpspsdk_a_LIBADD = $(MULT_OBJS)
|
||||
|
||||
$(MODULEMGR_PATCHES_OBJS): modulemgr_patches.c
|
||||
$(COMPILE) -DF_$* $< -c -o $@
|
||||
|
||||
$(INETHELPER_OBJS): inethelper.c
|
||||
$(COMPILE) -DF_$* $< -c -o $@
|
||||
113
src/sdk/fixup.c
Normal file
113
src/sdk/fixup.c
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* fixup.c - Code to manually fixup late binding modules
|
||||
*
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
*
|
||||
* $Id: fixup.c 1888 2006-05-01 08:47:04Z tyranid $
|
||||
*/
|
||||
|
||||
#include <pspkernel.h>
|
||||
#include <string.h>
|
||||
|
||||
struct SceLibStubEntry{
|
||||
char *moduleName;
|
||||
unsigned short version;
|
||||
unsigned short attr;
|
||||
unsigned char structsz; // 0x5
|
||||
unsigned char numVars;
|
||||
unsigned short numFuncs;
|
||||
u32* nidList;
|
||||
u32* stubs;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct PspModuleExport
|
||||
{
|
||||
const char* name;
|
||||
u32 flags;
|
||||
u8 unk;
|
||||
u8 v_count;
|
||||
u16 f_count;
|
||||
u32 *exports;
|
||||
} __attribute__((packed));
|
||||
|
||||
extern SceModuleInfo module_info;
|
||||
|
||||
static void *pspSdkFindExport(SceModule *modInfo, const char *exportName, u32 nid) {
|
||||
void *pRet = NULL;
|
||||
struct PspModuleExport *export;
|
||||
if (modInfo == NULL)
|
||||
return NULL;
|
||||
|
||||
export = modInfo->ent_top;
|
||||
|
||||
while(export < (struct PspModuleExport *)(modInfo->ent_top+modInfo->ent_size)) {
|
||||
if (export->name != NULL && strcmp(exportName, export->name) == 0) {
|
||||
u32 *nidlist;
|
||||
int i;
|
||||
int t_count;
|
||||
|
||||
t_count = export->f_count + export->v_count;
|
||||
nidlist = export->exports;
|
||||
|
||||
for(i = 0; i < t_count; i++) {
|
||||
if(nidlist[i] == nid) {
|
||||
pRet = (void *) nidlist[i+t_count];
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
export++;
|
||||
}
|
||||
|
||||
return pRet;
|
||||
}
|
||||
|
||||
void pspSdkFixupImports(int modId)
|
||||
{
|
||||
struct SceLibStubEntry* stubEntry = module_info.stub_top;
|
||||
int i;
|
||||
u32 *nid, *stub;
|
||||
void* addr;
|
||||
SceModule *modInfo;
|
||||
|
||||
modInfo = sceKernelFindModuleByUID(modId);
|
||||
if (modInfo == NULL) {
|
||||
Kprintf("Could not find module with id 0x%08X\n", modId);
|
||||
return;
|
||||
}
|
||||
|
||||
while (stubEntry < (struct SceLibStubEntry*)module_info.stub_end) {
|
||||
if (stubEntry->attr == 9) { //check to ensure this is a delayed import library
|
||||
/*Kprintf("Fixing up imports for '%s'...\n", stubEntry->moduleName);*/
|
||||
for (i = 0; i < stubEntry->numVars+stubEntry->numFuncs; i++) {
|
||||
stub = stubEntry->stubs;
|
||||
stub += i * 2; // since each stub is 8 bytes
|
||||
nid = stubEntry->nidList;
|
||||
nid += i;
|
||||
|
||||
//get addr of NID from library
|
||||
addr = pspSdkFindExport(modInfo, stubEntry->moduleName, *nid);
|
||||
if (addr != NULL) {
|
||||
//fixup stub
|
||||
//Kprintf("addr is 0x%08X\n", addr);
|
||||
*stub = ((u32)addr & 0x03FFFFFF) >> 2 | 0x0A000000; //j addr
|
||||
stub += 1;
|
||||
*stub = 0; // nop
|
||||
/* Okay if we fix up at least one function set attribute to 1 */
|
||||
stubEntry->attr = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stubEntry += 1;
|
||||
}
|
||||
//clear caches
|
||||
sceKernelDcacheWritebackAll();
|
||||
sceKernelIcacheClearAll();
|
||||
}
|
||||
15
src/sdk/fpu.S
Normal file
15
src/sdk/fpu.S
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
|
||||
.global pspSdkDisableFPUExceptions
|
||||
.ent pspSdkDisableFPUExceptions
|
||||
|
||||
pspSdkDisableFPUExceptions:
|
||||
cfc1 $2, $31
|
||||
lui $8, 0x80
|
||||
and $8, $2, $8 # Mask off all bits except for 23 of FCR
|
||||
ctc1 $8, $31
|
||||
jr $31
|
||||
nop
|
||||
.end pspSdkDisableFPUExceptions
|
||||
104
src/sdk/inethelper.c
Normal file
104
src/sdk/inethelper.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* inethelper.c - Helper functions for internet related modules.
|
||||
*
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
*
|
||||
* $Id: inethelper.c 2432 2008-09-17 19:44:47Z jim $
|
||||
*/
|
||||
|
||||
#include <pspkernel.h>
|
||||
#include <pspsdk.h>
|
||||
#include <pspnet.h>
|
||||
#include <pspnet_inet.h>
|
||||
#include <pspnet_resolver.h>
|
||||
#include <pspnet_apctl.h>
|
||||
//#include <pspNetApDialogDummy.h>
|
||||
|
||||
#ifdef F_pspSdkLoadInetModules
|
||||
int pspSdkLoadInetModules()
|
||||
{
|
||||
int modID;
|
||||
|
||||
modID = pspSdkLoadStartModule("flash0:/kd/ifhandle.prx", PSP_MEMORY_PARTITION_KERNEL);
|
||||
if (modID < 0)
|
||||
return modID;
|
||||
|
||||
modID = pspSdkLoadStartModule("flash0:/kd/pspnet.prx", PSP_MEMORY_PARTITION_USER);
|
||||
if (modID < 0)
|
||||
return modID;
|
||||
else
|
||||
pspSdkFixupImports(modID);
|
||||
|
||||
modID = pspSdkLoadStartModule("flash0:/kd/pspnet_inet.prx", PSP_MEMORY_PARTITION_USER);
|
||||
if (modID < 0)
|
||||
return modID;
|
||||
else
|
||||
pspSdkFixupImports(modID);
|
||||
|
||||
modID = pspSdkLoadStartModule("flash0:/kd/pspnet_apctl.prx", PSP_MEMORY_PARTITION_USER);
|
||||
if (modID < 0)
|
||||
return modID;
|
||||
else
|
||||
pspSdkFixupImports(modID);
|
||||
/*
|
||||
modID = loadModule("flash0:/kd/pspnet_ap_dialog_dummy.prx", PSP_MEMORY_PARTITION_USER);
|
||||
if (modID < 0)
|
||||
return modID;
|
||||
else
|
||||
fixupImports(modID);
|
||||
*/
|
||||
modID = pspSdkLoadStartModule("flash0:/kd/pspnet_resolver.prx", PSP_MEMORY_PARTITION_USER);
|
||||
if (modID < 0)
|
||||
return modID;
|
||||
else
|
||||
pspSdkFixupImports(modID);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef F_pspSdkInetInit
|
||||
int pspSdkInetInit()
|
||||
{
|
||||
u32 retVal;
|
||||
|
||||
retVal = sceNetInit(0x20000, 0x20, 0x1000, 0x20, 0x1000);
|
||||
if (retVal != 0)
|
||||
return retVal;
|
||||
|
||||
retVal = sceNetInetInit();
|
||||
if (retVal != 0)
|
||||
return retVal;
|
||||
|
||||
retVal = sceNetResolverInit();
|
||||
if (retVal != 0)
|
||||
return retVal;
|
||||
|
||||
retVal = sceNetApctlInit(0x1600, 0x42);
|
||||
if (retVal != 0)
|
||||
return retVal;
|
||||
|
||||
/*
|
||||
retVal = sceNetApDialogDummyInit();
|
||||
if(retVal != 0)
|
||||
return retVal;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef F_pspSdkInetTerm
|
||||
void pspSdkInetTerm()
|
||||
{
|
||||
//sceNetApDialogDummyTerm();
|
||||
sceNetApctlTerm();
|
||||
sceNetResolverTerm();
|
||||
sceNetInetTerm();
|
||||
sceNetTerm();
|
||||
}
|
||||
#endif
|
||||
66
src/sdk/interrupt.S
Normal file
66
src/sdk/interrupt.S
Normal file
@@ -0,0 +1,66 @@
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
|
||||
.global pspSdkDisableInterrupts
|
||||
.ent pspSdkDisableInterrupts
|
||||
|
||||
pspSdkDisableInterrupts:
|
||||
mfic $v0, $0
|
||||
mtic $0, $0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
jr $ra
|
||||
nop
|
||||
|
||||
.end pspSdkDisableInterrupts
|
||||
|
||||
.global pspSdkEnableInterrupts
|
||||
.ent pspSdkEnableInterrupts
|
||||
|
||||
pspSdkEnableInterrupts:
|
||||
mtic $a0, $0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
jr $ra
|
||||
nop
|
||||
|
||||
.end pspSdkEnableInterrupts
|
||||
22
src/sdk/k1set.S
Normal file
22
src/sdk/k1set.S
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
.set noreorder
|
||||
.set noat
|
||||
|
||||
.global pspSdkSetK1
|
||||
.ent pspSdkSetK1
|
||||
|
||||
pspSdkSetK1:
|
||||
move $v0, $k1
|
||||
jr $ra
|
||||
move $k1, $a0
|
||||
|
||||
.end pspSdkSetK1
|
||||
|
||||
.global pspSdkGetK1
|
||||
.ent pspSdkGetK1
|
||||
|
||||
pspSdkGetK1:
|
||||
jr $ra
|
||||
move $v0, $k1
|
||||
|
||||
.end pspSdkGetK1
|
||||
66
src/sdk/loadmodule.c
Normal file
66
src/sdk/loadmodule.c
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* loadmodule.c - Routines to simplify module loading and unloading.
|
||||
*
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
*
|
||||
* $Id: loadmodule.c 1737 2006-01-22 12:54:08Z tyranid $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <pspuser.h>
|
||||
|
||||
#define MAX_ARGS 2048
|
||||
|
||||
SceUID pspSdkLoadStartModuleWithArgs(const char *filename, int mpid, int argc, char * const argv[])
|
||||
{
|
||||
SceKernelLMOption option;
|
||||
SceUID modid = 0;
|
||||
int retVal = 0, mresult;
|
||||
char args[MAX_ARGS];
|
||||
int argpos = 0;
|
||||
int i;
|
||||
|
||||
memset(args, 0, MAX_ARGS);
|
||||
strcpy(args, filename);
|
||||
argpos += strlen(args) + 1;
|
||||
for(i = 0; (i < argc) && (argpos < MAX_ARGS); i++)
|
||||
{
|
||||
int len;
|
||||
|
||||
snprintf(&args[argpos], MAX_ARGS-argpos, "%s", argv[i]);
|
||||
len = strlen(&args[argpos]);
|
||||
argpos += len + 1;
|
||||
}
|
||||
|
||||
memset(&option, 0, sizeof(option));
|
||||
option.size = sizeof(option);
|
||||
option.mpidtext = mpid;
|
||||
option.mpiddata = mpid;
|
||||
option.position = 0;
|
||||
option.access = 1;
|
||||
|
||||
retVal = sceKernelLoadModule(filename, 0, &option);
|
||||
if(retVal < 0){
|
||||
return retVal;
|
||||
}
|
||||
|
||||
modid = retVal;
|
||||
|
||||
retVal = sceKernelStartModule(modid, argpos, args, &mresult, NULL);
|
||||
if(retVal < 0){
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return modid;
|
||||
}
|
||||
|
||||
SceUID pspSdkLoadStartModule(const char *filename, int mpid)
|
||||
{
|
||||
return pspSdkLoadStartModuleWithArgs(filename, mpid, 0, NULL);
|
||||
}
|
||||
145
src/sdk/modulemgr_patches.c
Normal file
145
src/sdk/modulemgr_patches.c
Normal file
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* modulemgr_patches.c - Patches for sceModuleManager libraries.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: modulemgr_patches.c 2166 2007-02-04 10:52:49Z tyranid $
|
||||
*/
|
||||
|
||||
#include <psptypes.h>
|
||||
#include <psploadcore.h>
|
||||
#include <pspkerror.h>
|
||||
#include <psputils.h>
|
||||
#include <pspsdk.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MM_MODNAME "sceModuleManager"
|
||||
|
||||
#ifdef F_InstallNoDeviceCheckPatch
|
||||
|
||||
#define IOFILEMGR_LIBNAME "IoFileMgrForKernel"
|
||||
#define IOCTL_NID 0x63632449
|
||||
#define JR_RA_INSN 0x03e00008
|
||||
#define MOVE_V0_0_INSN 0x00001021
|
||||
|
||||
/* Nullify sceModuleMangager's LoadDeviceCheck() (and related calls). */
|
||||
int pspSdkInstallNoDeviceCheckPatch(void)
|
||||
{
|
||||
SceModule *mm_module;
|
||||
SceLibraryStubTable *libstubtable;
|
||||
int found, i;
|
||||
|
||||
mm_module = sceKernelFindModuleByName(MM_MODNAME);
|
||||
if (mm_module == NULL) {
|
||||
return SCE_KERNEL_ERROR_UNKNOWN_MODULE;
|
||||
}
|
||||
|
||||
libstubtable = (SceLibraryStubTable *) mm_module->stub_top;
|
||||
found = 0;
|
||||
/* Find the stub entry table for IoFileMgrForKernel. */
|
||||
while ((u32) libstubtable < ((u32) mm_module->stub_top + mm_module->stub_size)) {
|
||||
if (strcmp(libstubtable->libname, IOFILEMGR_LIBNAME) == 0) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
libstubtable = (SceLibraryStubTable *) ((u32) libstubtable + (libstubtable->len * 4));
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return SCE_KERNEL_ERROR_LIBRARY_NOTFOUND;
|
||||
}
|
||||
|
||||
/* Find the NID for sceIoIoctl, and it's offset within the function stub table. */
|
||||
for (i = 0; i < libstubtable->stubcount; i++) {
|
||||
if (libstubtable->nidtable[i] == IOCTL_NID) {
|
||||
/* Found it, so patch the stub to return 0 so that all device checks pass. */
|
||||
u32 *ioctl_stub = (u32 *) ((u32) libstubtable->stubtable + (i * 8));
|
||||
|
||||
ioctl_stub[0] = JR_RA_INSN;
|
||||
ioctl_stub[1] = MOVE_V0_0_INSN;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* We couldn't find the stub entry. */
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
}
|
||||
#endif /* F_InstallNoDeviceCheckPatch */
|
||||
|
||||
#ifdef F_InstallNoPlainModuleCheckPatch
|
||||
|
||||
#define LOAD_EXEC_PLAIN_CHECK 0x4000B000 /* mfc0 *, $22 */
|
||||
#define LOAD_EXEC_PLAIN_PATCH 0x34000001 /* li *, 1 */
|
||||
|
||||
|
||||
extern u32 sceKernelProbeExecutableObject;
|
||||
extern u32 sceKernelCheckPspConfig;
|
||||
|
||||
int pspSdkInstallNoPlainModuleCheckPatch(void)
|
||||
{
|
||||
u32 *addr;
|
||||
int i;
|
||||
|
||||
addr = (u32*) (0x80000000 | ((sceKernelProbeExecutableObject & 0x03FFFFFF) << 2));
|
||||
//printf("sceKernelProbeExecutableObject %p\n", addr);
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
if((addr[i] & 0xFFE0FFFF) == LOAD_EXEC_PLAIN_CHECK)
|
||||
{
|
||||
//printf("Found instruction %p\n", &addr[i]);
|
||||
addr[i] = (LOAD_EXEC_PLAIN_PATCH | (addr[i] & ~0xFFE0FFFF));
|
||||
}
|
||||
}
|
||||
|
||||
addr = (u32*) (0x80000000 | ((sceKernelCheckPspConfig & 0x03FFFFFF) << 2));
|
||||
//printf("sceCheckPspConfig %p\n", addr);
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
if((addr[i] & 0xFFE0FFFF) == LOAD_EXEC_PLAIN_CHECK)
|
||||
{
|
||||
//printf("Found instruction %p\n", &addr[i]);
|
||||
addr[i] = (LOAD_EXEC_PLAIN_PATCH | (addr[i] & ~0xFFE0FFFF));
|
||||
}
|
||||
}
|
||||
|
||||
sceKernelDcacheWritebackAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* F_InstallNoPlainModuleCheckPatch */
|
||||
|
||||
#ifdef F_InstallKernelLoadModulePatch
|
||||
|
||||
#define LOAD_MODULE_KERN_CHECK 0x001BDC02 /* srl $k1, 16 */
|
||||
#define LOAD_MODULE_KERN_PATCH 0x0000d821 /* move $k1, $0 */
|
||||
|
||||
extern u32 sceKernelLoadModuleWithApitype;
|
||||
void sceKernelIcacheInvalidateAll();
|
||||
|
||||
int pspSdkInstallKernelLoadModulePatch(void)
|
||||
{
|
||||
u32 *addr;
|
||||
int i;
|
||||
|
||||
addr = (u32*) (0x80000000 | ((sceKernelLoadModuleWithApitype & 0x03FFFFFF) << 2));
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
if(addr[i] == LOAD_MODULE_KERN_CHECK)
|
||||
{
|
||||
addr[i] = LOAD_MODULE_KERN_PATCH;
|
||||
}
|
||||
}
|
||||
|
||||
sceKernelDcacheWritebackInvalidateAll();
|
||||
sceKernelIcacheInvalidateAll();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
296
src/sdk/pspsdk.h
Normal file
296
src/sdk/pspsdk.h
Normal file
@@ -0,0 +1,296 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* pspsdk.h - Interface to the PSPSDK utility library.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: pspsdk.h 2433 2008-10-15 10:00:27Z iwn $
|
||||
*/
|
||||
|
||||
#ifndef PSPSDK_H
|
||||
#define PSPSDK_H
|
||||
|
||||
#include <pspkerneltypes.h>
|
||||
#include <pspmodulemgr.h>
|
||||
#include <pspmoduleinfo.h>
|
||||
#include <pspthreadman.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @defgroup PSPSDK PSPSDK Utility Library */
|
||||
|
||||
/** @addtogroup PSPSDK */
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* Query a modules information from its uid.
|
||||
* @note this is a replacement function for the broken kernel sceKernelQueryModuleInfo in v1.0 firmware
|
||||
* DO NOT use on a anything above that version. This also needs kernel mode access where
|
||||
* the normal one has a user mode stub.
|
||||
*
|
||||
* @param uid - The UID of the module to query.
|
||||
* @param modinfo - Pointer a module SceKernelModuleInfo structure.
|
||||
*
|
||||
* @return < 0 on error.
|
||||
*/
|
||||
int pspSdkQueryModuleInfoV1(SceUID uid, SceKernelModuleInfo *modinfo);
|
||||
|
||||
/**
|
||||
* Get the list of module IDs.
|
||||
* @note This is a replacement function for the missing v1.5 sceKernelGetModuleIdList
|
||||
* on v1.0 firmware. DO NOT use on anything above that version.
|
||||
*
|
||||
* @param readbuf - Buffer to store the module list.
|
||||
* @param readbufsize - Number of elements in the readbuffer.
|
||||
* @param idcount - Returns the number of module ids
|
||||
*
|
||||
* @return >= 0 on success
|
||||
*/
|
||||
int pspSdkGetModuleIdList(SceUID *readbuf, int readbufsize, int *idcount);
|
||||
|
||||
/**
|
||||
* Patch the sceModuleManager module to nullify LoadDeviceCheck() calls.
|
||||
*
|
||||
* @return 0 on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*
|
||||
* @note This function must be called while running in kernel mode. The program
|
||||
* must also be linked against the pspkernel library.
|
||||
*/
|
||||
int pspSdkInstallNoDeviceCheckPatch(void);
|
||||
|
||||
/**
|
||||
* Patch sceLoadCore module to remove loading plain module checks
|
||||
*
|
||||
* @note This function must be called while running in kernel mode.
|
||||
*
|
||||
* @return 0 on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkInstallNoPlainModuleCheckPatch(void);
|
||||
|
||||
/**
|
||||
* Patch sceLoadModuleWithApiType to remove the kernel check in loadmodule allowing all modules to load
|
||||
*
|
||||
* @note This function must be called while running in kernel mode
|
||||
*
|
||||
* @return 0 on success
|
||||
*/
|
||||
int pspSdkInstallKernelLoadModulePatch(void);
|
||||
|
||||
/**
|
||||
* Load a module and start it.
|
||||
*
|
||||
* @param filename - Path to the module.
|
||||
* @param mpid - Memory parition ID to use to load the module int.
|
||||
*
|
||||
* @return - The UID of the module on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
SceUID pspSdkLoadStartModule(const char *filename, int mpid);
|
||||
|
||||
/**
|
||||
* Load a module and start it with arguments
|
||||
*
|
||||
* @param filename - Path to the module.
|
||||
* @param mpid - Memory parition ID to use to load the module int.
|
||||
* @param argc - Number of arguments to pass to start module
|
||||
* @param argv - Array of arguments
|
||||
*
|
||||
* @return - The UID of the module on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
SceUID pspSdkLoadStartModuleWithArgs(const char *filename, int mpid, int argc, char * const argv[]);
|
||||
|
||||
/**
|
||||
* Manually fixup library imports for late binding modules.
|
||||
*
|
||||
* @param moduleId - Id of the module to fixup
|
||||
*/
|
||||
void pspSdkFixupImports(int moduleId);
|
||||
|
||||
/**
|
||||
* Load Inet related modules.
|
||||
* @note You must be in kernel mode to execute this function.
|
||||
*
|
||||
* @return - 0 on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkLoadInetModules();
|
||||
|
||||
/**
|
||||
* Initialize Inet related modules.
|
||||
*
|
||||
* @return - 0 on success, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkInetInit();
|
||||
|
||||
/**
|
||||
* Terminate Inet related modules.
|
||||
*/
|
||||
void pspSdkInetTerm();
|
||||
|
||||
/**
|
||||
* Search for a thread with the given name and retrieve it's ::SceKernelThreadInfo struct.
|
||||
*
|
||||
* @param name - The name of the thread to search for.
|
||||
* @param pUID - If the thread with the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the thread with the given name is found, it's ::SceKernelThreadInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferThreadStatusByName(const char *name, SceUID *pUID, SceKernelThreadInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a semaphore with the given name and retrieve it's ::SceKernelSemaInfo struct.
|
||||
*
|
||||
* @param name - The name of the sema to search for.
|
||||
* @param pUID - If the sema with the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the sema with the given name is found, it's ::SceKernelSemaInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferSemaStatusByName(const char *name, SceUID *pUID, SceKernelSemaInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for an event flag with the given name and retrieve it's ::SceKernelEventFlagInfo struct.
|
||||
*
|
||||
* @param name - The name of the event flag to search for.
|
||||
* @param pUID - If the event flag with the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the event flag with the given name is found, it's ::SceKernelEventFlagInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferEventFlagStatusByName(const char *name, SceUID *pUID, SceKernelEventFlagInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a message box with the given name and retrieve it's ::SceKernelMbxInfo struct.
|
||||
*
|
||||
* @param name - The name of the message box to search for.
|
||||
* @param pUID - If the message box with the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the message box with the given name is found, it's ::SceKernelMbxInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferMboxStatusByName(const char *name, SceUID *pUID, SceKernelMbxInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a VPL with the given name and retrieve it's ::SceKernelVplInfo struct.
|
||||
*
|
||||
* @param name - The name of to search for.
|
||||
* @param pUID - If the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the given name is found, it's ::SceKernelVplInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferVplStatusByName(const char *name, SceUID *pUID, SceKernelVplInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a FPL with the given name and retrieve it's ::SceKernelFplInfo struct.
|
||||
*
|
||||
* @param name - The name of to search for.
|
||||
* @param pUID - If the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the given name is found, it's ::SceKernelFplInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferFplStatusByName(const char *name, SceUID *pUID, SceKernelFplInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a message pipe with the given name and retrieve it's ::SceKernelMppInfo struct.
|
||||
*
|
||||
* @param name - The name of to search for.
|
||||
* @param pUID - If the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the given name is found, it's ::SceKernelMppInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferMppStatusByName(const char *name, SceUID *pUID, SceKernelMppInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a callback with the given name and retrieve it's ::SceKernelCallbackInfo struct.
|
||||
*
|
||||
* @param name - The name of to search for.
|
||||
* @param pUID - If the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the given name is found, it's ::SceKernelMppInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferCallbackStatusByName(const char *name, SceUID *pUID, SceKernelCallbackInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a vtimer with the given name and retrieve it's ::SceKernelVTimerInfo struct.
|
||||
*
|
||||
* @param name - The name of to search for.
|
||||
* @param pUID - If the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the given name is found, it's ::SceKernelVTimerInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferVTimerStatusByName(const char *name, SceUID *pUID, SceKernelVTimerInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Search for a thread event handler with the given name and retrieve it's ::SceKernelThreadEventHandlerInfo struct.
|
||||
*
|
||||
* @param name - The name of to search for.
|
||||
* @param pUID - If the given name is found, it's ::SceUID is stored here.
|
||||
* @param pInfo - If the given name is found, it's ::SceKernelThreadEventHandlerInfo data is stored here.
|
||||
*
|
||||
* @return 0 if successful, otherwise one of ::PspKernelErrorCodes.
|
||||
*/
|
||||
int pspSdkReferThreadEventHandlerStatusByName(const char *name, SceUID *pUID, SceKernelThreadEventHandlerInfo *pInfo);
|
||||
|
||||
/**
|
||||
* Disable interrupts
|
||||
*
|
||||
* @note Do not disable interrupts for too long otherwise the watchdog will get you.
|
||||
*
|
||||
* @return The previous state of the interrupt enable bit (should be passed back to ::pspSdkEnableInterrupts)
|
||||
*/
|
||||
unsigned int pspSdkDisableInterrupts(void);
|
||||
|
||||
/**
|
||||
* Enable interrupts
|
||||
*
|
||||
* @param istate - The interrupt state as returned from ::pspSdkDisableInterrupts
|
||||
*/
|
||||
void pspSdkEnableInterrupts(unsigned int istate);
|
||||
|
||||
/**
|
||||
* Set the processors K1 register to a known value
|
||||
*
|
||||
* @note This function is for use in kernel mode syscall exports. The kernel
|
||||
* sets the k1 register to indicate what mode called the function, i.e.
|
||||
* whether it was directly called, was called via a syscall from a kernel
|
||||
* thread or called via a syscall from a user thread. By setting k1 to 0
|
||||
* before doing anything in your code you can make the other functions think
|
||||
* you are calling from a kernel thread and therefore disable numerous
|
||||
* protections.
|
||||
*
|
||||
* @param k1 - The k1 value to set
|
||||
*
|
||||
* @return The previous value of k1
|
||||
*/
|
||||
unsigned int pspSdkSetK1(unsigned int k1);
|
||||
|
||||
/**
|
||||
* Get the current value of the processors K1 register
|
||||
*
|
||||
* @return The current value of K1
|
||||
*/
|
||||
unsigned int pspSdkGetK1(void);
|
||||
|
||||
/**
|
||||
* Disable the CPUs FPU exceptions
|
||||
*/
|
||||
void pspSdkDisableFPUExceptions(void);
|
||||
|
||||
/*@}*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PSPSDK_H */
|
||||
57
src/sdk/query_mod.c
Normal file
57
src/sdk/query_mod.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* query_mod.c - Replacement for some missing modulemgr functions for v1.0 units.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
|
||||
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
|
||||
*
|
||||
* $Id: query_mod.c 1148 2005-10-12 19:08:27Z tyranid $
|
||||
*/
|
||||
|
||||
#include <pspkerneltypes.h>
|
||||
#include <psploadcore.h>
|
||||
#include <pspmodulemgr.h>
|
||||
#include <pspmodulemgr_kernel.h>
|
||||
#include <pspsdk.h>
|
||||
#include <string.h>
|
||||
|
||||
int pspSdkGetModuleIdList(SceUID *readbuf, int readbufsize, int *idcount)
|
||||
{
|
||||
sceKernelGetModuleList(readbufsize / sizeof(SceUID), readbuf);
|
||||
*idcount = sceKernelModuleCount();
|
||||
|
||||
return *idcount;
|
||||
}
|
||||
|
||||
int pspSdkQueryModuleInfoV1(SceUID uid, SceKernelModuleInfo *modinfo)
|
||||
{
|
||||
SceModule *mod;
|
||||
|
||||
mod = sceKernelFindModuleByUID(uid);
|
||||
if(mod != NULL)
|
||||
{
|
||||
memcpy(modinfo->name, mod->modname, sizeof(mod->modname) + 1);
|
||||
modinfo->attribute = mod->attribute;
|
||||
modinfo->version[0] = mod->version[0];
|
||||
modinfo->version[1] = mod->version[1];
|
||||
modinfo->nsegment = (unsigned char )mod->nsegment;
|
||||
modinfo->entry_addr = mod->entry_addr;
|
||||
modinfo->gp_value = mod->gp_value;
|
||||
modinfo->text_addr = mod->text_addr;
|
||||
modinfo->text_size = mod->text_size;
|
||||
modinfo->data_size = mod->data_size;
|
||||
modinfo->bss_size = mod->bss_size;
|
||||
memcpy(modinfo->segmentaddr, mod->segmentaddr, sizeof(unsigned int) * 4);
|
||||
memcpy(modinfo->segmentsize, mod->segmentsize, sizeof(unsigned int) * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
343
src/sdk/threadutils.c
Normal file
343
src/sdk/threadutils.c
Normal file
@@ -0,0 +1,343 @@
|
||||
/*
|
||||
* PSP Software Development Kit - http://www.pspdev.org
|
||||
* -----------------------------------------------------------------------
|
||||
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
|
||||
*
|
||||
* threadutils.c - Thread manager extensions.
|
||||
*
|
||||
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
|
||||
*
|
||||
* $Id: threadutils.c 1658 2006-01-07 15:27:56Z tyranid $
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "pspthreadman.h"
|
||||
#include "pspsdk.h"
|
||||
|
||||
#define MAX_UIDS 256
|
||||
|
||||
/* TODO: Generalize this for all thread primatives that have names. */
|
||||
|
||||
struct _ThreadInfoSkel
|
||||
{
|
||||
SceSize size;
|
||||
char name[32];
|
||||
};
|
||||
|
||||
typedef int (*ReferFunc)(SceUID, struct _ThreadInfoSkel*);
|
||||
|
||||
static int _pspSdkReferInternal(const char *name, enum SceKernelIdListType type,
|
||||
struct _ThreadInfoSkel *pInfo, int size, ReferFunc pRefer)
|
||||
{
|
||||
int uid_count = 0;
|
||||
|
||||
/* First determine the number of threads we have. */
|
||||
int res = sceKernelGetThreadmanIdList(type, NULL, 0, &uid_count);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
if (uid_count == 0) {
|
||||
return -1; /* XXX: Should we return a kernel errorcode here? */
|
||||
}
|
||||
|
||||
/* Grab UIDs for all of the threads. */
|
||||
SceUID uid_buf[uid_count];
|
||||
res = sceKernelGetThreadmanIdList(type, uid_buf, uid_count, NULL);
|
||||
if (res < 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int i;
|
||||
for (i = 0; i < uid_count; i++) {
|
||||
memset(pInfo, 0, size);
|
||||
pInfo->size = size;
|
||||
|
||||
res = pRefer(uid_buf[i], pInfo);
|
||||
if (res < 0) {
|
||||
/* If we got an error than we probably don't have enough privileges
|
||||
to access the thread's info. */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pInfo->name[0] != '\0' && strcmp(pInfo->name, name) == 0) {
|
||||
/* Found it. */
|
||||
return uid_buf[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Unable to find the thread (or insufficient access to retrieve it's info). */
|
||||
return -1; /* XXX: Should we return a kernel errorcode here? */
|
||||
}
|
||||
|
||||
int pspSdkReferSemaStatusByName(const char *name, SceUID *pUID, SceKernelSemaInfo *pInfo)
|
||||
{
|
||||
SceKernelSemaInfo intSema;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Semaphore, (struct _ThreadInfoSkel *) &intSema,
|
||||
sizeof(intSema), (ReferFunc) sceKernelReferSemaStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intSema, sizeof(intSema));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferEventFlagStatusByName(const char *name, SceUID *pUID, SceKernelEventFlagInfo *pInfo)
|
||||
{
|
||||
SceKernelEventFlagInfo intEvent;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_EventFlag, (struct _ThreadInfoSkel *) &intEvent,
|
||||
sizeof(intEvent), (ReferFunc) sceKernelReferEventFlagStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intEvent, sizeof(intEvent));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferThreadStatusByName(const char *name, SceUID *pUID, SceKernelThreadInfo *pInfo)
|
||||
{
|
||||
SceKernelThreadInfo intThread;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Thread, (struct _ThreadInfoSkel *) &intThread,
|
||||
sizeof(intThread), (ReferFunc) sceKernelReferThreadStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intThread, sizeof(intThread));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferMboxStatusByName(const char *name, SceUID *pUID, SceKernelMbxInfo *pInfo)
|
||||
{
|
||||
SceKernelMbxInfo intMbx;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Mbox, (struct _ThreadInfoSkel *) &intMbx,
|
||||
sizeof(intMbx), (ReferFunc) sceKernelReferMbxStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intMbx, sizeof(intMbx));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pspSdkReferVplStatusByName(const char *name, SceUID *pUID, SceKernelVplInfo *pInfo)
|
||||
{
|
||||
SceKernelVplInfo intVpl;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Vpl, (struct _ThreadInfoSkel *) &intVpl,
|
||||
sizeof(intVpl), (ReferFunc) sceKernelReferVplStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intVpl, sizeof(intVpl));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferFplStatusByName(const char *name, SceUID *pUID, SceKernelFplInfo *pInfo)
|
||||
{
|
||||
SceKernelVplInfo intFpl;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Fpl, (struct _ThreadInfoSkel *) &intFpl,
|
||||
sizeof(intFpl), (ReferFunc) sceKernelReferFplStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intFpl, sizeof(intFpl));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int pspSdkReferMppStatusByName(const char *name, SceUID *pUID, SceKernelMppInfo *pInfo)
|
||||
{
|
||||
SceKernelMppInfo intMpp;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Mpipe, (struct _ThreadInfoSkel *) &intMpp,
|
||||
sizeof(intMpp), (ReferFunc) sceKernelReferMsgPipeStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intMpp, sizeof(intMpp));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferCallbackStatusByName(const char *name, SceUID *pUID, SceKernelCallbackInfo *pInfo)
|
||||
{
|
||||
SceKernelCallbackInfo intCB;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_Callback, (struct _ThreadInfoSkel *) &intCB,
|
||||
sizeof(intCB), (ReferFunc) sceKernelReferCallbackStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intCB, sizeof(intCB));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferVTimerStatusByName(const char *name, SceUID *pUID, SceKernelVTimerInfo *pInfo)
|
||||
{
|
||||
SceKernelVTimerInfo intVT;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_VTimer, (struct _ThreadInfoSkel *) &intVT,
|
||||
sizeof(intVT), (ReferFunc) sceKernelReferVTimerStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intVT, sizeof(intVT));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pspSdkReferThreadEventHandlerStatusByName(const char *name, SceUID *pUID, SceKernelThreadEventHandlerInfo *pInfo)
|
||||
{
|
||||
SceKernelThreadEventHandlerInfo intEH;
|
||||
SceUID uid;
|
||||
|
||||
uid = _pspSdkReferInternal(name, SCE_KERNEL_TMID_ThreadEventHandler, (struct _ThreadInfoSkel *) &intEH,
|
||||
sizeof(intEH), (ReferFunc) sceKernelReferThreadEventHandlerStatus);
|
||||
if(uid > 0)
|
||||
{
|
||||
if(pUID != NULL)
|
||||
{
|
||||
*pUID = uid;
|
||||
}
|
||||
|
||||
if(pInfo != NULL)
|
||||
{
|
||||
memcpy(pInfo, &intEH, sizeof(intEH));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user