wut
v1.7.0
Wii U Toolchain
|
Controls a memory area that can switch between writable and executable states, allowing dynamic code generation. More...
Typedefs | |
typedef enum OSCodegenSecMode | OSCodegenSecMode |
The memory permissions for the codegen area. More... | |
Enumerations | |
enum | OSCodegenSecMode { CODEGEN_RW_ = 0 , CODEGEN_R_X = 1 } |
The memory permissions for the codegen area. More... | |
Functions | |
void | OSGetCodegenVirtAddrRange (void **outVirtualAddress, uint32_t *outSize) |
Gets the location and size of codegen memory, if available. More... | |
uint32_t | OSGetCodegenCore () |
Gets the CPU core that's allowed to use codegen. More... | |
uint32_t | OSGetCodegenMode () |
BOOL | OSSwitchSecCodeGenMode (OSCodegenSecMode mode) |
Switches the permissions on the codegen memory area. More... | |
uint32_t | OSGetSecCodeGenMode () |
BOOL | OSCodegenCopy (void *dst, void *src, size_t size) |
Copies data from normal memory into the codegen area, leaving the area in CODEGEN_R_X mode. More... | |
Controls a memory area that can switch between writable and executable states, allowing dynamic code generation.
For some applications, a codegen area is avilable for things like JIT or otherwise generating CPU instructions on the fly. Enabled apps can use OSCodegenGetVirtAddrRange to discover this area, then use OSSwitchSecCodeGenMode or OSCodegenCopy to move instructions in and out before executing them. Codegen can only be used from a specific, predetermined CPU core - see OSGetCodegenCore. Codegen can only be used when enabled in an app's cos.xml.
typedef enum OSCodegenSecMode OSCodegenSecMode |
The memory permissions for the codegen area.
enum OSCodegenSecMode |
void OSGetCodegenVirtAddrRange | ( | void ** | outVirtualAddress, |
uint32_t * | outSize | ||
) |
Gets the location and size of codegen memory, if available.
outVirtualAddress | Pointer to write the virtual address of the codegen area to. Will write 0 if codegen isn't available. |
outSize | Pointer to write the size of the codegen area to. Will write 0 if codegen isn't available. |
uint32_t OSGetCodegenCore | ( | ) |
Gets the CPU core that's allowed to use codegen.
uint32_t OSGetCodegenMode | ( | ) |
BOOL OSSwitchSecCodeGenMode | ( | OSCodegenSecMode | mode | ) |
Switches the permissions on the codegen memory area.
Use this function to move between writing code and executing it.
mode | The memory permission mode to use - one of OSCodegenSecMode. |
true
on success, or false
on a failure, such as codegen not being available for this app or CPU core. uint32_t OSGetSecCodeGenMode | ( | ) |
BOOL OSCodegenCopy | ( | void * | dst, |
void * | src, | ||
size_t | size | ||
) |
Copies data from normal memory into the codegen area, leaving the area in CODEGEN_R_X mode.
This function copies into the codegen area regardless of the current permission status by switching modes as required for the copy.
dst | The starting virtual address of the area in codegen memory to copy to. Must be a valid pointer |
src | The starting virtual address of the source to copy from. Must be a valid pointer. |
size | The size of the data to copy. Must not be 0, and must be small enough such that dst + size does not pass the end of the codegen area (see OSCodegenGetVirtAddrRange). |
TRUE
on success, indicating the codegen area is now in CODEGEN_R_X, or FALSE
on an error, such as invalid pointers or codegen not being available.