2016-01-07 13:07:13 +01:00
|
|
|
#pragma once
|
|
|
|
#include <wut.h>
|
|
|
|
#include "thread.h"
|
|
|
|
#include "time.h"
|
|
|
|
|
2016-01-07 17:02:54 +01:00
|
|
|
/**
|
|
|
|
* \defgroup coreinit_dynload Dynamic Loading
|
|
|
|
* \ingroup coreinit
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2016-01-07 15:09:43 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2016-01-07 13:07:13 +01:00
|
|
|
|
2018-05-30 14:10:38 +02:00
|
|
|
typedef 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,
|
|
|
|
} OSDynLoad_Error;
|
|
|
|
|
2016-01-07 13:07:13 +01:00
|
|
|
typedef void *OSDynLoadModule;
|
|
|
|
|
2018-05-30 14:10:38 +02:00
|
|
|
typedef OSDynLoad_Error (*OSDynLoadAllocFn)(int32_t size, int32_t align, void **outAddr);
|
2016-01-07 13:07:13 +01:00
|
|
|
typedef void (*OSDynLoadFreeFn)(void *addr);
|
|
|
|
|
2016-01-07 17:02:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a module.
|
|
|
|
*
|
|
|
|
* If the module is already loaded, increase reference count.
|
|
|
|
* Similar to LoadLibrary on Windows.
|
|
|
|
*/
|
2018-05-30 14:10:38 +02:00
|
|
|
OSDynLoad_Error
|
2016-01-07 13:07:13 +01:00
|
|
|
OSDynLoad_Acquire(char const *name,
|
|
|
|
OSDynLoadModule *outModule);
|
|
|
|
|
2016-01-07 17:02:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve the address of a function or data export from a module.
|
|
|
|
*
|
|
|
|
* Similar to GetProcAddress on Windows.
|
|
|
|
*/
|
2018-05-30 14:10:38 +02:00
|
|
|
OSDynLoad_Error
|
2016-01-07 13:07:13 +01:00
|
|
|
OSDynLoad_FindExport(OSDynLoadModule module,
|
2017-05-10 18:22:37 +02:00
|
|
|
BOOL isData,
|
2016-01-07 13:07:13 +01:00
|
|
|
char const *name,
|
|
|
|
void **outAddr);
|
|
|
|
|
2016-01-07 17:02:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2016-01-07 13:07:13 +01:00
|
|
|
void
|
|
|
|
OSDynLoad_Release(OSDynLoadModule module);
|
|
|
|
|
2018-05-30 14:10:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the allocator functions to use for dynamic loading.
|
|
|
|
*/
|
|
|
|
OSDynLoad_Error
|
|
|
|
OSDynLoad_SetAllocator(OSDynLoadAllocFn allocFn,
|
|
|
|
OSDynLoadFreeFn freeFn);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the allocator functions used for dynamic loading.
|
|
|
|
*/
|
|
|
|
OSDynLoad_Error
|
|
|
|
OSDynLoad_GetAllocator(OSDynLoadAllocFn *outAllocFn,
|
|
|
|
OSDynLoadFreeFn *outFreeFn);
|
|
|
|
|
2018-05-30 14:10:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the allocator functions to use for thread local storage.
|
|
|
|
*/
|
|
|
|
OSDynLoad_Error
|
|
|
|
OSDynLoad_SetTLSAllocator(OSDynLoadAllocFn allocFn,
|
|
|
|
OSDynLoadFreeFn freeFn);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the allocator functions used for thread local storage.
|
|
|
|
*/
|
|
|
|
OSDynLoad_Error
|
|
|
|
OSDynLoad_GetTLSAllocator(OSDynLoadAllocFn *outAllocFn,
|
|
|
|
OSDynLoadFreeFn *outFreeFn);
|
|
|
|
|
2016-01-07 15:09:43 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2016-01-07 17:02:54 +01:00
|
|
|
|
|
|
|
/** @} */
|