11#ifndef __MUTEKI_LOADER_H__
12#define __MUTEKI_LOADER_H__
148 size_t mapped_offset;
168 size_t bestape_code_size;
169 size_t bestape_data_size;
170 size_t bestape_bss_size;
171 size_t bestape_total_raw_size;
172 size_t bestape_total_size;
173 size_t bestape_header_size;
174 unsigned int bestape_checksum;
175 unsigned int unk_0x1c;
176 unsigned char unk_0x20[24];
189 unsigned char *(*dlopen)(
char *);
399extern 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
Low-level and built-in high-level file operation API.
struct loader_impl_s loader_impl_t
Loader implementation vtable.
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.
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.
int ExecuteProgram(loader_loaded_t *applet, int subroutine, const void *applet_arg1, const void *applet_arg2)
Invoke a specific subroutine of the loaded applet with arguments.
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:25
@ APPLET_SUBROUTINE_RESET_STATES
Definition loader.h:29
@ APPLET_SUBROUTINE_MAIN
Definition loader.h:27
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:37
char * dospath
Definition loader.h:39
void ** applet_arg1
Definition loader.h:43
void ** applet_arg2
Definition loader.h:45
int * subroutine
Definition loader.h:41
Basic info on a loaded applet.
Definition loader.h:267
unsigned short rom_type
Type field inside the ROM spec.
Definition loader.h:279
unsigned short unused_0x4
Unknown, seems unused.
Definition loader.h:283
unsigned short unused_0x2
Unknown, seems unused.
Definition loader.h:275
unsigned char unused_0x10[0x74]
Unknown, seems unused.
Definition loader.h:296
size_t exe_raw_size
File size of the executable.
Definition loader.h:292
unsigned short rom_magic
Magic bytes of ROM spec.
Definition loader.h:271
unsigned int exe_checksum
Checksum of the executable file.
Definition loader.h:288
Cart file descriptor.
Definition loader.h:52
unsigned char unk_0x16
Unknown.
Definition loader.h:84
unsigned int unk_0xc
Unknown.
Definition loader.h:68
unsigned char size_high_8
High 8 bits of the capacity of the cart.
Definition loader.h:80
void * unk_0x10
Unknown.
Definition loader.h:72
unsigned char unk_0x17
Unknown.
Definition loader.h:88
unsigned int unk_0x1c
Unknown.
Definition loader.h:96
unsigned int unk_0x4
Unknown.
Definition loader.h:60
unsigned int unk_0x18
Unknown.
Definition loader.h:92
size_t size_low_32
Low 32 bits of the capacity of the cart.
Definition loader.h:64
unsigned int unk_0x0
Unknown.
Definition loader.h:56
unsigned char unk_0x14
Unknown.
Definition loader.h:76
File descriptor specific to loader.
Definition loader.h:102
loader_cart_descriptor_t * cart
ROM cart descriptor.
Definition loader.h:106
size_t size
Base offset of this sub-file, within parent_fd.
Definition loader.h:119
size_t subfile_offset
Current ftell offset of this sub-file.
Definition loader.h:123
void * parent_fd
Parent file descriptor.
Definition loader.h:111
unsigned int unk_0x1c
Unknown.
Definition loader.h:139
size_t subfile_base
Base offset of the sub-file.
Definition loader.h:115
short unk_0x16
Unknown.
Definition loader.h:131
unsigned int unk_0x18
Unknown.
Definition loader.h:135
short unk_0x14
Unknown. Seems to be unused.
Definition loader.h:127
Executable image info.
Definition loader.h:167
Loader implementation vtable.
Definition loader.h:183
Loaded applet executable.
Definition loader.h:203
unsigned char * mapped_executable
Mapped executable.
Definition loader.h:223
short unk_0x64
Unknown.
Definition loader.h:231
unsigned char unk_0x78[28]
Unknown.
Definition loader.h:256
char path[80]
DOS 8.3 path to executable file.
Definition loader.h:207
loader_file_descriptor_t * asset_file
Assets bundle file descriptor.
Definition loader.h:248
unsigned int rom_spec_offset_0xc
Unknown.
Definition loader.h:240
int active_refcount
Reference counter for currently active (running) instances.
Definition loader.h:219
int refcount
Reference counter.
Definition loader.h:215
void * path_lfn
LFN path.
Definition loader.h:244
loader_file_descriptor_t * ldrfd
Executable file descriptors.
Definition loader.h:252
short type
Executable type.
Definition loader.h:235
void * posixfd_rom
POSIX file descriptor of the executable.
Definition loader.h:261
loader_impl_t * loader
Loader implementation being used to load this applet.
Definition loader.h:227
int id
Numerical ID of loaded applet.
Definition loader.h:211
Resource descriptor.
Definition loader.h:146
Resource descriptor subfile request.
Definition loader.h:158