wut  v1.7.0
Wii U Toolchain
Data Structures | Typedefs | Enumerations | Functions
Dynamic Loading
Collaboration diagram for Dynamic Loading:

Data Structures

struct  OSDynLoad_NotifyData
 
struct  OSDynLoad_LoaderHeapStatistics
 
struct  OSDynLoad_LoaderUserFileInfo
 
struct  OSDynLoad_LoaderSectionInfo
 
struct  OSDynLoad_InternalData
 
union  OSDynLoad_LoaderSectionInfo.__unnamed5__
 

Typedefs

typedef struct OSDynLoad_NotifyData OSDynLoad_NotifyData
 
typedef struct OSDynLoad_LoaderHeapStatistics OSDynLoad_LoaderHeapStatistics
 
typedef void * OSDynLoad_Module
 
typedef struct OSDynLoad_LoaderUserFileInfo OSDynLoad_LoaderUserFileInfo
 
typedef struct OSDynLoad_LoaderSectionInfo OSDynLoad_LoaderSectionInfo
 
typedef struct OSDynLoad_InternalData OSDynLoad_InternalData
 
typedef enum OSDynLoad_Error OSDynLoad_Error
 
typedef OSDynLoad_Error(* OSDynLoadAllocFn) (int32_t size, int32_t align, void **outAddr)
 
typedef void(* OSDynLoadFreeFn) (void *addr)
 
typedef enum OSDynLoad_ExportType OSDynLoad_ExportType
 
typedef enum OSDynLoad_EntryReason OSDynLoad_EntryReason
 
typedef enum OSDynLoad_NotifyReason OSDynLoad_NotifyReason
 
typedef void(* OSDynLoadNotifyFunc) (OSDynLoad_Module module, void *userContext, OSDynLoad_NotifyReason notifyReason, OSDynLoad_NotifyData *infos)
 

Enumerations

enum  OSDynLoad_Error {
  OS_DYNLOAD_OK = 0 ,
  OS_DYNLOAD_OUT_OF_MEMORY = 0xBAD10002 ,
  OS_DYNLOAD_INVALID_NOTIFY_PTR = 0xBAD1000E ,
  OS_DYNLOAD_INVALID_MODULE_NAME_PTR = 0xBAD1000F ,
  OS_DYNLOAD_INVALID_MODULE_NAME = 0xBAD10010 ,
  OS_DYNLOAD_INVALID_ACQUIRE_PTR = 0xBAD10011 ,
  OS_DYNLOAD_EMPTY_MODULE_NAME = 0xBAD10012 ,
  OS_DYNLOAD_INVALID_ALLOCATOR_PTR = 0xBAD10017 ,
  OS_DYNLOAD_OUT_OF_SYSTEM_MEMORY = 0xBAD1002F ,
  OS_DYNLOAD_TLS_ALLOCATOR_LOCKED = 0xBAD10031 ,
  OS_DYNLOAD_MODULE_NOT_FOUND = 0xFFFFFFFA
}
 
enum  OSDynLoad_ExportType {
  OS_DYNLOAD_EXPORT_FUNC = 0 ,
  OS_DYNLOAD_EXPORT_DATA = 1
}
 
enum  OSDynLoad_EntryReason {
  OS_DYNLOAD_LOADED = 1 ,
  OS_DYNLOAD_UNLOADED = 2
}
 
enum  OSDynLoad_NotifyReason {
  OS_DYNLOAD_NOTIFY_UNLOADED = 0 ,
  OS_DYNLOAD_NOTIFY_LOADED = 1
}
 

Functions

OSDynLoad_Error OSDynLoad_Acquire (char const *name, OSDynLoad_Module *outModule)
 Load a module. More...
 
OSDynLoad_Error OSDynLoad_FindExport (OSDynLoad_Module module, OSDynLoad_ExportType exportType, char const *name, void **outAddr)
 Retrieve the address of a function or data export from a module. More...
 
void OSDynLoad_Release (OSDynLoad_Module module)
 Free a module handle returned from OSDynLoad_Acquire. More...
 
OSDynLoad_Error OSDynLoad_SetAllocator (OSDynLoadAllocFn allocFn, OSDynLoadFreeFn freeFn)
 Set the allocator functions to use for dynamic loading. More...
 
OSDynLoad_Error OSDynLoad_GetAllocator (OSDynLoadAllocFn *outAllocFn, OSDynLoadFreeFn *outFreeFn)
 Get the allocator functions used for dynamic loading. More...
 
OSDynLoad_Error OSDynLoad_SetTLSAllocator (OSDynLoadAllocFn allocFn, OSDynLoadFreeFn freeFn)
 Set the allocator functions to use for thread local storage. More...
 
OSDynLoad_Error OSDynLoad_GetTLSAllocator (OSDynLoadAllocFn *outAllocFn, OSDynLoadFreeFn *outFreeFn)
 Get the allocator functions used for thread local storage. More...
 
OSDynLoad_Error OSDynLoad_GetLoaderHeapStatistics (OSDynLoad_LoaderHeapStatistics *outLoaderHeapStatistics)
 Get loader heap statistics. More...
 
OSDynLoad_Error OSDynLoad_GetModuleName (OSDynLoad_Module module, char *nameBuf, int32_t *nameBufSize)
 Gets the name for a given module handle. More...
 
int32_t OSDynLoad_GetNumberOfRPLs ()
 Gets the number of currently loaded RPLs. More...
 
BOOL OSDynLoad_GetRPLInfo (uint32_t first, uint32_t count, OSDynLoad_NotifyData *outInfos)
 Get information about the currently loaded RPLs. More...
 
OSDynLoad_Error OSDynLoad_IsModuleLoaded (char const *name, OSDynLoad_Module *outModule)
 Checks if a module is already loaded. More...
 
OSDynLoad_Error OSDynLoad_AddNotifyCallback (OSDynLoadNotifyFunc notifyFn, void *userContext)
 Registers a callback that's called whenever a new .rpl is loaded or unloaded. More...
 
OSDynLoad_Error OSDynLoad_DelNotifyCallback (OSDynLoadNotifyFunc notifyFn, void *userContext)
 Removes a previously added a callback. More...
 
int rpl_entry (OSDynLoad_Module module, OSDynLoad_EntryReason reason)
 The prototype for an RPL entry point. More...
 

Detailed Description


Data Structure Documentation

◆ OSDynLoad_NotifyData

struct OSDynLoad_NotifyData

Definition at line 53 of file dynload.h.

Data Fields
char * name
uint32_t textAddr
uint32_t textOffset
uint32_t textSize
uint32_t dataAddr
uint32_t dataOffset
uint32_t dataSize
uint32_t readAddr
uint32_t readOffset
uint32_t readSize

◆ OSDynLoad_LoaderHeapStatistics

struct OSDynLoad_LoaderHeapStatistics

Definition at line 81 of file dynload.h.

Data Fields
uint32_t codeHeapUsed
uint32_t unk_0x04
uint32_t codeHeapFree
uint32_t codeHeapLargestFree
uint32_t dataHeapUsed
uint32_t unk_0x14

◆ OSDynLoad_LoaderUserFileInfo

struct OSDynLoad_LoaderUserFileInfo

Definition at line 98 of file dynload.h.

Data Fields
uint32_t size
uint32_t magic
uint32_t pathStringLength
char * pathString
uint32_t fileInfoFlags
int16_t tlsModuleIndex
int16_t tlsAlignShift
void * tlsAddressStart
uint32_t tlsSectionSize
uint32_t shstrndx
uint32_t titleLocation

◆ OSDynLoad_LoaderSectionInfo

struct OSDynLoad_LoaderSectionInfo

Definition at line 127 of file dynload.h.

Data Fields
uint32_t type
uint32_t flags
void * address
union OSDynLoad_LoaderSectionInfo __unnamed__

◆ OSDynLoad_InternalData

struct OSDynLoad_InternalData

Definition at line 149 of file dynload.h.

Data Fields
uint32_t handle
void * loaderHandle
char * moduleName
uint32_t moduleNameLen
uint32_t sectionInfoCount
OSDynLoad_LoaderSectionInfo * sectionInfo
OSDynLoad_InternalData ** importModules
uint32_t importModuleCount
uint32_t userFileInfoSize
OSDynLoad_LoaderUserFileInfo * userFileInfo
OSDynLoad_NotifyData * notifyData
void * entryPoint
uint32_t dataSectionSize
void * dataSection
uint32_t loadSectionSize
void * loadSection
OSDynLoadFreeFn dynLoadFreeFn
void * codeExports
uint32_t numCodeExports
void * dataExports
uint32_t numDataExports
OSDynLoad_InternalData * next

◆ OSDynLoad_LoaderSectionInfo.__unnamed5__

union OSDynLoad_LoaderSectionInfo.__unnamed5__

Definition at line 133 of file dynload.h.

Data Fields
uint32_t size Size of the section, set when type != SHT_RPL_IMPORTS.
uint32_t name Name offset of the section, set when type == SHT_RPL_IMPORTS.

Typedef Documentation

◆ OSDynLoad_NotifyData

Definition at line 1 of file dynload.h.

◆ OSDynLoad_LoaderHeapStatistics

Definition at line 1 of file dynload.h.

◆ OSDynLoad_Module

typedef void* OSDynLoad_Module

Definition at line 18 of file dynload.h.

◆ OSDynLoad_LoaderUserFileInfo

Definition at line 18 of file dynload.h.

◆ OSDynLoad_LoaderSectionInfo

Definition at line 18 of file dynload.h.

◆ OSDynLoad_InternalData

Definition at line 18 of file dynload.h.

◆ OSDynLoad_Error

◆ OSDynLoadAllocFn

typedef OSDynLoad_Error(* OSDynLoadAllocFn) (int32_t size, int32_t align, void **outAddr)

Definition at line 39 of file dynload.h.

◆ OSDynLoadFreeFn

typedef void(* OSDynLoadFreeFn) (void *addr)

Definition at line 40 of file dynload.h.

◆ OSDynLoad_ExportType

◆ OSDynLoad_EntryReason

◆ OSDynLoad_NotifyReason

◆ OSDynLoadNotifyFunc

typedef void(* OSDynLoadNotifyFunc) (OSDynLoad_Module module, void *userContext, OSDynLoad_NotifyReason notifyReason, OSDynLoad_NotifyData *infos)

Definition at line 205 of file dynload.h.

Enumeration Type Documentation

◆ OSDynLoad_Error

Enumerator
OS_DYNLOAD_OK 
OS_DYNLOAD_OUT_OF_MEMORY 
OS_DYNLOAD_INVALID_NOTIFY_PTR 
OS_DYNLOAD_INVALID_MODULE_NAME_PTR 
OS_DYNLOAD_INVALID_MODULE_NAME 
OS_DYNLOAD_INVALID_ACQUIRE_PTR 
OS_DYNLOAD_EMPTY_MODULE_NAME 
OS_DYNLOAD_INVALID_ALLOCATOR_PTR 
OS_DYNLOAD_OUT_OF_SYSTEM_MEMORY 
OS_DYNLOAD_TLS_ALLOCATOR_LOCKED 
OS_DYNLOAD_MODULE_NOT_FOUND 

Definition at line 24 of file dynload.h.

◆ OSDynLoad_ExportType

Enumerator
OS_DYNLOAD_EXPORT_FUNC 
OS_DYNLOAD_EXPORT_DATA 

Definition at line 42 of file dynload.h.

◆ OSDynLoad_EntryReason

Enumerator
OS_DYNLOAD_LOADED 
OS_DYNLOAD_UNLOADED 

Definition at line 47 of file dynload.h.

◆ OSDynLoad_NotifyReason

Enumerator
OS_DYNLOAD_NOTIFY_UNLOADED 
OS_DYNLOAD_NOTIFY_LOADED 

Definition at line 199 of file dynload.h.

Function Documentation

◆ OSDynLoad_Acquire()

OSDynLoad_Error OSDynLoad_Acquire ( char const *  name,
OSDynLoad_Module outModule 
)

Load a module.

If the module is already loaded, increase reference count. Similar to LoadLibrary on Windows.

◆ OSDynLoad_FindExport()

OSDynLoad_Error OSDynLoad_FindExport ( OSDynLoad_Module  module,
OSDynLoad_ExportType  exportType,
char const *  name,
void **  outAddr 
)

Retrieve the address of a function or data export from a module.

Similar to GetProcAddress on Windows.

◆ OSDynLoad_Release()

void OSDynLoad_Release ( OSDynLoad_Module  module)

Free a module handle returned from OSDynLoad_Acquire.

Will decrease reference count and only unload the module if count reaches 0. Similar to FreeLibrary on Windows.

◆ OSDynLoad_SetAllocator()

OSDynLoad_Error OSDynLoad_SetAllocator ( OSDynLoadAllocFn  allocFn,
OSDynLoadFreeFn  freeFn 
)

Set the allocator functions to use for dynamic loading.

◆ OSDynLoad_GetAllocator()

OSDynLoad_Error OSDynLoad_GetAllocator ( OSDynLoadAllocFn outAllocFn,
OSDynLoadFreeFn outFreeFn 
)

Get the allocator functions used for dynamic loading.

◆ OSDynLoad_SetTLSAllocator()

OSDynLoad_Error OSDynLoad_SetTLSAllocator ( OSDynLoadAllocFn  allocFn,
OSDynLoadFreeFn  freeFn 
)

Set the allocator functions to use for thread local storage.

◆ OSDynLoad_GetTLSAllocator()

OSDynLoad_Error OSDynLoad_GetTLSAllocator ( OSDynLoadAllocFn outAllocFn,
OSDynLoadFreeFn outFreeFn 
)

Get the allocator functions used for thread local storage.

◆ OSDynLoad_GetLoaderHeapStatistics()

OSDynLoad_Error OSDynLoad_GetLoaderHeapStatistics ( OSDynLoad_LoaderHeapStatistics outLoaderHeapStatistics)

Get loader heap statistics.

◆ OSDynLoad_GetModuleName()

OSDynLoad_Error OSDynLoad_GetModuleName ( OSDynLoad_Module  module,
char *  nameBuf,
int32_t *  nameBufSize 
)

Gets the name for a given module handle.

Using the value "-1" as module handle gets the name of the running main rpl

◆ OSDynLoad_GetNumberOfRPLs()

int32_t OSDynLoad_GetNumberOfRPLs ( )

Gets the number of currently loaded RPLs.

Always returns 0 on release versions of CafeOS. Requires OSGetSecurityLevel() > 0.

◆ OSDynLoad_GetRPLInfo()

BOOL OSDynLoad_GetRPLInfo ( uint32_t  first,
uint32_t  count,
OSDynLoad_NotifyData outInfos 
)

Get information about the currently loaded RPLs.

Parameters
firstthe index of the first RPL to retrieve info for.
countthe number of RPLs to retrieve info for
outInfosbuffer of RPL info to be filled, should be an array of at least count size.

Always returns FALSE on release versions of CafeOS. Requires OSGetSecurityLevel() > 0.

◆ OSDynLoad_IsModuleLoaded()

OSDynLoad_Error OSDynLoad_IsModuleLoaded ( char const *  name,
OSDynLoad_Module outModule 
)

Checks if a module is already loaded.

Does not load any modules.

Returns OS_DYNLOAD_OK on success.

◆ OSDynLoad_AddNotifyCallback()

OSDynLoad_Error OSDynLoad_AddNotifyCallback ( OSDynLoadNotifyFunc  notifyFn,
void *  userContext 
)

Registers a callback that's called whenever a new .rpl is loaded or unloaded.

◆ OSDynLoad_DelNotifyCallback()

OSDynLoad_Error OSDynLoad_DelNotifyCallback ( OSDynLoadNotifyFunc  notifyFn,
void *  userContext 
)

Removes a previously added a callback.

◆ rpl_entry()

int rpl_entry ( OSDynLoad_Module  module,
OSDynLoad_EntryReason  reason 
)

The prototype for an RPL entry point.

Use this instead of main when creating .rpl files