libnx  v4.8.0
Data Structures | Typedefs | Enumerations | Functions
env.h File Reference

Homebrew environment definitions and utilities. More...

#include "../types.h"
#include "../services/acc.h"

Go to the source code of this file.

Data Structures

struct  ConfigEntry
 Structure representing an entry in the homebrew environment configuration. More...
 

Typedefs

typedef void(* LoaderReturnFn) (int result_code)
 Loader return function.
 

Enumerations

enum  { EntryFlag_IsMandatory = (1U<<( 0 )) }
 Entry flags. More...
 
enum  {
  EntryType_EndOfList =0 ,
  EntryType_MainThreadHandle =1 ,
  EntryType_NextLoadPath =2 ,
  EntryType_OverrideHeap =3 ,
  EntryType_OverrideService =4 ,
  EntryType_Argv =5 ,
  EntryType_SyscallAvailableHint =6 ,
  EntryType_AppletType =7 ,
  EntryType_AppletWorkaround =8 ,
  EntryType_Reserved9 =9 ,
  EntryType_ProcessHandle =10 ,
  EntryType_LastLoadResult =11 ,
  EntryType_RandomSeed =14 ,
  EntryType_UserIdStorage =15 ,
  EntryType_HosVersion =16 ,
  EntryType_SyscallAvailableHint2 =17
}
 
enum  { EnvAppletFlags_ApplicationOverride = (1U<<( 0 )) }
 

Functions

void envSetup (void *ctx, Handle main_thread, LoaderReturnFn saved_lr)
 Parses the homebrew loader environment block (internally called). More...
 
const char * envGetLoaderInfo (void)
 Returns information text about the loader, if present.
 
u64 envGetLoaderInfoSize (void)
 Returns the size of the loader information text.
 
Handle envGetMainThreadHandle (void)
 Retrieves the handle to the main thread.
 
bool envIsNso (void)
 Returns true if the application is running as NSO, otherwise NRO.
 
bool envHasHeapOverride (void)
 Returns true if the environment has a heap override.
 
void * envGetHeapOverrideAddr (void)
 Returns the address of the overriden heap.
 
u64 envGetHeapOverrideSize (void)
 Returns the size of the overriden heap.
 
bool envHasArgv (void)
 Returns true if the environment has an argv array.
 
void * envGetArgv (void)
 Returns the pointer to the argv array.
 
bool envIsSyscallHinted (unsigned svc)
 Returns whether a syscall is hinted to be available. More...
 
Handle envGetOwnProcessHandle (void)
 Returns the handle to the running homebrew process.
 
LoaderReturnFn envGetExitFuncPtr (void)
 Returns the loader's return function, to be called on program exit.
 
void envSetExitFuncPtr (LoaderReturnFn addr)
 Sets the return function to be called on program exit.
 
Result envSetNextLoad (const char *path, const char *argv)
 Configures the next homebrew application to load. More...
 
bool envHasNextLoad (void)
 Returns true if the environment supports envSetNextLoad.
 
Result envGetLastLoadResult (void)
 Returns the Result from the last NRO.
 
bool envHasRandomSeed (void)
 Returns true if the environment provides a random seed.
 
void envGetRandomSeed (u64 out[2])
 Retrieves the random seed provided by the environment. More...
 
AccountUidenvGetUserIdStorage (void)
 Returns a pointer to the user id storage area (if present).
 

Detailed Description

Homebrew environment definitions and utilities.

Author
plutoo

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Entry flags.

Enumerator
EntryFlag_IsMandatory 

Specifies that the entry must be processed by the homebrew application.

◆ anonymous enum

anonymous enum
Enumerator
EntryType_EndOfList 

Entry list terminator.

EntryType_MainThreadHandle 

Provides the handle to the main thread.

EntryType_NextLoadPath 

Provides a buffer containing information about the next homebrew application to load.

EntryType_OverrideHeap 

Provides heap override information.

EntryType_OverrideService 

Provides service override information.

EntryType_Argv 

Provides argv.

EntryType_SyscallAvailableHint 

Provides syscall availability hints (SVCs 0x00..0x7F).

EntryType_AppletType 

Provides APT applet type.

EntryType_AppletWorkaround 

Indicates that APT is broken and should not be used.

EntryType_Reserved9 

Unused/reserved entry type, formerly used by StdioSockets.

EntryType_ProcessHandle 

Provides the process handle.

EntryType_LastLoadResult 

Provides the last load result.

EntryType_RandomSeed 

Provides random data used to seed the pseudo-random number generator.

EntryType_UserIdStorage 

Provides persistent storage for the preselected user id.

EntryType_HosVersion 

Provides the currently running Horizon OS version.

EntryType_SyscallAvailableHint2 

Provides syscall availability hints (SVCs 0x80..0xBF).

◆ anonymous enum

anonymous enum
Enumerator
EnvAppletFlags_ApplicationOverride 

Use AppletType_Application instead of AppletType_SystemApplication.

Function Documentation

◆ envGetRandomSeed()

void envGetRandomSeed ( u64  out[2])

Retrieves the random seed provided by the environment.

Parameters
outPointer to a u64[2] buffer which will contain the random seed on return.

◆ envIsSyscallHinted()

bool envIsSyscallHinted ( unsigned  svc)

Returns whether a syscall is hinted to be available.

Parameters
svcSyscall number to test.
Returns
true if the syscall is available.

◆ envSetNextLoad()

Result envSetNextLoad ( const char *  path,
const char *  argv 
)

Configures the next homebrew application to load.

Parameters
pathPath to the next homebrew application to load (.nro).
argvArgument string to pass.

◆ envSetup()

void envSetup ( void *  ctx,
Handle  main_thread,
LoaderReturnFn  saved_lr 
)

Parses the homebrew loader environment block (internally called).

Parameters
ctxReserved.
main_threadReserved.
saved_lrReserved.