11#ifndef __MUTEKI_LOADER_H__
12#define __MUTEKI_LOADER_H__
147 size_t mapped_offset;
167 size_t bestape_code_size;
168 size_t bestape_data_size;
169 size_t bestape_bss_size;
170 size_t bestape_total_raw_size;
171 size_t bestape_total_size;
172 size_t bestape_header_size;
173 unsigned int bestape_checksum;
174 unsigned int unk_0x1c;
175 unsigned char unk_0x20[24];
180 unsigned int ordinal;
203 int (*
exec)(
void *module,
int subroutine,
void *arg1,
void *arg2);
211 void *(*dlopen)(
char *pathname);
219 void *(*dlsym)(
void *module, loader_symbol_id_t symbol_or_ordinal);
229 void *(*get_module)(
const char *pathname);
243 const UTF16 *res_type,
244 const UTF16 *res_name,
452extern int RunApplicationA(
const char *pathname,
int subroutine,
void *applet_arg1,
void *applet_arg2);
Common include file for all muteki-shims headers.
#define UTF16
"Portable" Besta UTF-16 type used by other headers.
Definition common.h:54
struct loader_impl_s loader_impl_t
Loader implementation function table.
loader_file_descriptor_t * _OpenFile(const char *pathname, const char *mode_or_subfile)
Open a loader file descriptor from a file.
int GetApplicationHeadInfoW(const UTF16 *pathname, loader_applet_info_t *info)
Obtain information on loaded applet by its LFN pathname.
struct loader_file_descriptor_s loader_file_descriptor_t
File descriptor specific to loader.
int UnStayResidentProgramW(const UTF16 *pathname)
Unmark a loaded applet as stay resident by its LFN pathname.
loader_loaded_t * LoadHFileProgramA(loader_file_descriptor_t *ldrfd, const char *pathname)
Load an applet executable from a loader file descriptor.
int StayResidentProgramW(const UTF16 *pathname)
Mark a loaded applet as stay resident by its LFN pathname.
struct loader_cart_descriptor_s loader_cart_descriptor_t
Cart file descriptor.
const UTF16 * GetCurrentPathW(void)
Get the path to the current running executable (argv[0]). (UTF-16 variant).
loader_file_descriptor_t * _OpenSubFile(loader_file_descriptor_t *parent, size_t base, size_t max_size)
Open a sub-file from a parent loader file descriptor.
const char * GetCurrentPathA(void)
Get the path to the current running executable (argv[0]).
loader_loaded_t * ProgramIsRunningA(const char *pathname)
Return the instance of a running applet by its DOS 8.3 path name.
int RunApplicationW(const UTF16 *pathname, int subroutine, void *applet_arg1, void *applet_arg2)
Load and execute an applet by its LFN pathname.
loader_loaded_t * LoadProgramA(const char *pathname)
Load an applet executable.
struct loader_resource_subfile_request_s loader_resource_subfile_request_t
Resource descriptor subfile request.
struct loader_loaded_s loader_loaded_t
Loaded applet executable.
loader_loaded_t * GetApplicationProcA(const char *pathname)
Search and return the applet instance by DOS 8.3 pathname.
int _FseekFile(loader_file_descriptor_t *ldrfd, size_t offset, int whence)
Seek to a specific position in an opened sub-file.
int StayResidentProgramA(const char *pathname)
Mark a loaded applet as stay resident by its DOS 8.3 pathname.
size_t _ReadFile(loader_file_descriptor_t *ldrfd, void *buf, size_t size)
Read data from a loader file descriptor.
int _CloseFile(loader_file_descriptor_t *ldrfd)
Close a loader file descriptor.
loader_file_descriptor_t * _OpenFileW(const UTF16 *pathname, const void *mode_or_subfile)
Open a loader file descriptor from a file (LFN path).
struct applet_args_v4_s applet_args_v4_t
Applet argument passing V4 struct.
loader_loaded_t * LoadHFileProgramW(loader_file_descriptor_t *ldrfd, const UTF16 *pathname)
Load an applet executable from a loader file descriptor.
loader_loaded_t * GetApplicationProcW(const UTF16 *pathname)
Search and return the applet instance by LFN.
int ExecuteProgram(loader_loaded_t *applet, int subroutine, void *applet_arg1, void *applet_arg2)
Invoke a specific subroutine of the loaded applet with arguments.
ssize_t _TellFile(loader_file_descriptor_t *ldrfd)
Get the current offset of sub-file.
size_t GetApplicationNameA(const char *pathname, UTF16 *out_name, size_t max_size)
Get the title name of the ROM file.
int FreeProgram(loader_loaded_t *applet)
Unload a loaded applet.
int GetApplicationHeadInfoA(const char *pathname, loader_applet_info_t *info)
Obtain information on loaded applet by its DOS 8.3 pathname.
int CheckProgramIsStayResident(loader_loaded_t *applet)
Check if an loaded applet has been set to stay resident.
loader_loaded_t * ProgramIsRunningW(const UTF16 *pathname)
Return the instance of a running applet by its LFN.
int UnStayResidentProgramA(const char *pathname)
Unmark a loaded applet as stay resident by its DOS 8.3 pathname.
struct loader_image_info_s loader_image_info_t
Executable image info.
applet_subroutine_e
Definition loader.h:24
@ APPLET_SUBROUTINE_RESET_STATES
Definition loader.h:28
@ APPLET_SUBROUTINE_MAIN
Definition loader.h:26
int RunApplicationA(const char *pathname, int subroutine, void *applet_arg1, void *applet_arg2)
Load and execute an applet by its DOS 8.3 pathname.
loader_loaded_t * LoadProgramW(const UTF16 *pathname)
Load an applet executable. (UTF-16 variant).
struct loader_resource_descriptor_s loader_resource_descriptor_t
Resource descriptor.
size_t GetApplicationNameW(const UTF16 *pathname, UTF16 *out_name, size_t max_size)
Get the title name of the ROM file (LFN path).
struct loader_applet_info_s loader_applet_info_t
Basic info on a loaded applet.
ssize_t _FileSize(loader_file_descriptor_t *ldrfd)
Get the size of sub-file.
Applet argument passing V4 struct.
Definition loader.h:36
char * dospath
Definition loader.h:38
void ** applet_arg1
Definition loader.h:42
void ** applet_arg2
Definition loader.h:44
int * subroutine
Definition loader.h:40
Basic info on a loaded applet.
Definition loader.h:320
unsigned short rom_type
Type field inside the ROM spec.
Definition loader.h:332
unsigned short unused_0x4
Unknown, seems unused.
Definition loader.h:336
unsigned short unused_0x2
Unknown, seems unused.
Definition loader.h:328
unsigned char unused_0x10[0x74]
Unknown, seems unused.
Definition loader.h:349
size_t exe_raw_size
File size of the executable.
Definition loader.h:345
unsigned short rom_magic
Magic bytes of ROM spec.
Definition loader.h:324
unsigned int exe_checksum
Checksum of the executable file.
Definition loader.h:341
Cart file descriptor.
Definition loader.h:51
unsigned char unk_0x16
Unknown.
Definition loader.h:83
unsigned int unk_0xc
Unknown.
Definition loader.h:67
unsigned char size_high_8
High 8 bits of the capacity of the cart.
Definition loader.h:79
void * unk_0x10
Unknown.
Definition loader.h:71
unsigned char unk_0x17
Unknown.
Definition loader.h:87
unsigned int unk_0x1c
Unknown.
Definition loader.h:95
unsigned int unk_0x4
Unknown.
Definition loader.h:59
unsigned int unk_0x18
Unknown.
Definition loader.h:91
size_t size_low_32
Low 32 bits of the capacity of the cart.
Definition loader.h:63
unsigned int unk_0x0
Unknown.
Definition loader.h:55
unsigned char unk_0x14
Unknown.
Definition loader.h:75
File descriptor specific to loader.
Definition loader.h:101
loader_cart_descriptor_t * cart
ROM cart descriptor.
Definition loader.h:105
size_t size
Base offset of this sub-file, within parent_fd.
Definition loader.h:118
size_t subfile_offset
Current ftell offset of this sub-file.
Definition loader.h:122
void * parent_fd
Parent file descriptor.
Definition loader.h:110
unsigned int unk_0x1c
Unknown.
Definition loader.h:138
size_t subfile_base
Base offset of the sub-file.
Definition loader.h:114
short unk_0x16
Unknown.
Definition loader.h:130
unsigned int unk_0x18
Unknown.
Definition loader.h:134
short unk_0x14
Unknown. Seems to be unused.
Definition loader.h:126
Executable image info.
Definition loader.h:166
Loader implementation function table.
Definition loader.h:186
void(*) unload(void *module)
Unload a module.
Definition loader.h:198
int(*) probe(loader_file_descriptor_t *ldrfd)
Probe a ldrfd for the.
Definition loader.h:207
int(*) collect_image_info(loader_file_descriptor_t *ldrfd, loader_image_info_t *info)
Collect information from a module file opened as ldrfd .
Definition loader.h:250
int(*) get_resource(loader_resource_descriptor_t *res, const UTF16 *res_type, const UTF16 *res_name, loader_resource_subfile_request_t *out_subfile)
Find resource entry (optional).
Definition loader.h:241
int(*) exec(void *module, int subroutine, void *arg1, void *arg2)
Execute a registered subroutine in the module.
Definition loader.h:203
size_t(*) get_module_filename(void *module, char *out_filename, size_t size)
Get the filename of a loaded module.
Definition loader.h:223
void(*) close_resource_descriptor(loader_resource_descriptor_t *res)
Close the resource descriptor of a module (optional).
Definition loader.h:237
void(*) dlclose(void *module)
Close a previously opened shared module/DLL.
Definition loader.h:215
Loaded applet executable.
Definition loader.h:256
unsigned char * mapped_executable
Mapped executable.
Definition loader.h:276
short unk_0x64
Unknown.
Definition loader.h:284
unsigned char unk_0x78[28]
Unknown.
Definition loader.h:309
char path[80]
DOS 8.3 path to executable file.
Definition loader.h:260
loader_file_descriptor_t * asset_file
Assets bundle file descriptor.
Definition loader.h:301
unsigned int rom_spec_offset_0xc
Unknown.
Definition loader.h:293
int active_refcount
Reference counter for currently active (running) instances.
Definition loader.h:272
int refcount
Reference counter.
Definition loader.h:268
void * path_lfn
LFN path.
Definition loader.h:297
loader_file_descriptor_t * ldrfd
Executable file descriptors.
Definition loader.h:305
short type
Executable type.
Definition loader.h:288
void * posixfd_rom
POSIX file descriptor of the executable.
Definition loader.h:314
loader_impl_t * loader
Loader implementation being used to load this applet.
Definition loader.h:280
int id
Numerical ID of loaded applet.
Definition loader.h:264
Resource descriptor.
Definition loader.h:145
Resource descriptor subfile request.
Definition loader.h:157