PS2SDK
PS2 Homebrew Libraries
xmodload.h
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2001-2004, ps2dev - http://www.ps2dev.org
7 # Licenced under Academic Free License version 2.0
8 # Review ps2sdk README & LICENSE files for further details.
9 */
10 
16 #ifndef __XMODLOAD_H__
17 #define __XMODLOAD_H__
18 
19 #include <modload.h>
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 // The following was introduced in export version 1.3 (around SDK 2.3)
26 extern int GetModuleIdList(int *readbuf, int readbufsize, int *modulecount);
27 
28 typedef struct {
29  char name[56];
30  u16 version;
31  u16 flags;
32  int id;
33  u32 entry_addr;
34  u32 gp_value;
35  u32 text_addr;
36  u32 text_size;
37  u32 data_size;
38  u32 bss_size;
39  u32 lreserve[2];
40 } ModuleStatus;
41 
42 extern int ReferModuleStatus(int modid, ModuleStatus *status);
43 extern int GetModuleIdListByName(const char *name, int *readbuf, int readbufsize, int *modulecount);
44 
45 typedef struct {
46  int (*beforeOpen)(void *opt, const char *filename, int flag);
47  int (*afterOpen)(void *opt, int fd);
48  int (*close)(void *opt, int fd);
49  int (*setBufSize)(void *opt, int fd, size_t nbyte);
50  int (*beforeRead)(void *opt, int fd, size_t nbyte);
51  int (*read)(void *opt, int fd, void *buf, size_t nbyte);
52  int (*lseek)(void *opt, int fd, long offset, int whence);
53  int (*getfsize)(void *opt, int fd);
54 } LDfilefunc;
55 
56 typedef struct {
57  char position;
58  char access;
59  char creserved[2];
60  void *distaddr;
61  int distoffset;
62  LDfilefunc *functable;
63  void *funcopt;
64  int ireserved[3];
65 } LMWOoption;
66 
67 extern int LoadModuleWithOption(const char *filename, const LMWOoption *option);
68 extern int StopModule(int modid, int arglen, const char *args, int *result);
69 extern int UnloadModule(int modid);
70 extern int SearchModuleByName(const char *name);
71 extern int SearchModuleByAddress(const void *addr);
72 extern int SelfStopModule(int arglen, const char *args, int *result);
73 extern void SelfUnloadModule(void);
74 
75 // The following was introduced in export version 1.5 (around SDK 2.3.4)
76 extern void *AllocLoadMemory(int type, unsigned int size, void *addr);
77 extern int FreeLoadMemory(void *area);
78 
79 // The following was introduced in export version 1.6 (around SDK 2.5)
80 extern int SetModuleFlags(int modid, int flag);
81 
82 #define xmodload_IMPORTS_start DECLARE_IMPORT_TABLE(modload, 1, 7)
83 #define xmodload_IMPORTS_end END_IMPORT_TABLE
84 
85 #define I_GetModuleIdList DECLARE_IMPORT(16, GetModuleIdList)
86 #define I_ReferModuleStatus DECLARE_IMPORT(17, ReferModuleStatus)
87 #define I_GetModuleIdListByName DECLARE_IMPORT(18, GetModuleIdListByName)
88 #define I_LoadModuleWithOption DECLARE_IMPORT(19, LoadModuleWithOption)
89 #define I_StopModule DECLARE_IMPORT(20, StopModule)
90 #define I_UnloadModule DECLARE_IMPORT(21, UnloadModule)
91 #define I_SearchModuleByName DECLARE_IMPORT(22, SearchModuleByName)
92 #define I_SearchModuleByAddress DECLARE_IMPORT(23, SearchModuleByAddress)
93 #define I_SelfStopModule DECLARE_IMPORT(26, SelfStopModule)
94 #define I_SelfUnloadModule DECLARE_IMPORT(27, SelfUnloadModule)
95 #define I_AllocLoadMemory DECLARE_IMPORT(28, AllocLoadMemory)
96 #define I_FreeLoadMemory DECLARE_IMPORT(29, FreeLoadMemory)
97 #define I_SetModuleFlags DECLARE_IMPORT(30, SetModuleFlags)
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* __XMODLOAD_H__ */
LDfilefunc
Definition: xmodload.h:45
ModuleStatus
Definition: xmodload.h:28
LMWOoption
Definition: xmodload.h:56
modload.h
version
unsigned int version
Definition: fileXio.h:5