From da4c060278d4e2a97a0c7625cee91cf75b9cdf62 Mon Sep 17 00:00:00 2001 From: friedkeenan Date: Sat, 13 Jul 2019 14:09:28 -0500 Subject: [PATCH] Add a bunch of GetServiceSession functions (#305) * Add a bunch of GetServiceSession functions --- nx/include/switch/services/acc.h | 2 +- nx/include/switch/services/apm.h | 2 ++ nx/include/switch/services/auddev.h | 2 ++ nx/include/switch/services/audren.h | 2 ++ nx/include/switch/services/bpc.h | 2 ++ nx/include/switch/services/bsd.h | 2 ++ nx/include/switch/services/capssc.h | 1 + nx/include/switch/services/capssu.h | 1 + nx/include/switch/services/clkrst.h | 1 + nx/include/switch/services/csrng.h | 2 ++ nx/include/switch/services/fsldr.h | 1 + nx/include/switch/services/fspr.h | 1 + nx/include/switch/services/gpio.h | 1 + nx/include/switch/services/hid.h | 2 +- nx/include/switch/services/hiddbg.h | 1 + nx/include/switch/services/hidsys.h | 1 + nx/include/switch/services/i2c.h | 1 + nx/include/switch/services/irs.h | 2 +- nx/include/switch/services/lbl.h | 2 ++ nx/include/switch/services/lr.h | 1 + nx/include/switch/services/ncm.h | 1 + nx/include/switch/services/pcv.h | 2 ++ nx/include/switch/services/pdm.h | 1 + nx/include/switch/services/pl.h | 1 + nx/include/switch/services/psc.h | 1 + nx/include/switch/services/psm.h | 1 + nx/include/switch/services/ro.h | 3 +++ nx/include/switch/services/set.h | 3 +++ nx/include/switch/services/spl.h | 6 +++++ nx/include/switch/services/spsm.h | 2 ++ nx/include/switch/services/time.h | 2 +- nx/include/switch/services/usbds.h | 1 + nx/include/switch/services/usbhs.h | 1 + nx/include/switch/services/wlaninf.h | 1 + nx/source/services/acc.c | 2 +- nx/source/services/apm.c | 4 ++++ nx/source/services/auddev.c | 4 ++++ nx/source/services/audren.c | 4 ++++ nx/source/services/bpc.c | 4 ++++ nx/source/services/bsd.c | 4 ++++ nx/source/services/capssc.c | 4 ++++ nx/source/services/capssu.c | 4 ++++ nx/source/services/clkrst.c | 4 ++++ nx/source/services/csrng.c | 4 ++++ nx/source/services/fsldr.c | 4 ++++ nx/source/services/fspr.c | 4 ++++ nx/source/services/gpio.c | 4 ++++ nx/source/services/hid.c | 2 +- nx/source/services/hiddbg.c | 4 ++++ nx/source/services/hidsys.c | 4 ++++ nx/source/services/i2c.c | 4 ++++ nx/source/services/irs.c | 2 +- nx/source/services/lbl.c | 4 ++++ nx/source/services/lr.c | 4 ++++ nx/source/services/ncm.c | 4 ++++ nx/source/services/pcv.c | 4 ++++ nx/source/services/pdm.c | 4 ++++ nx/source/services/pl.c | 4 ++++ nx/source/services/psc.c | 4 ++++ nx/source/services/psm.c | 4 ++++ nx/source/services/ro.c | 12 ++++++++++ nx/source/services/set.c | 8 +++++++ nx/source/services/spl.c | 34 ++++++++++++++++++++++++++++ nx/source/services/spsm.c | 4 ++++ nx/source/services/time.c | 2 +- nx/source/services/usbds.c | 4 ++++ nx/source/services/usbhs.c | 4 ++++ nx/source/services/wlaninf.c | 4 ++++ 68 files changed, 218 insertions(+), 8 deletions(-) diff --git a/nx/include/switch/services/acc.h b/nx/include/switch/services/acc.h index 7a48003e..9d0fd556 100644 --- a/nx/include/switch/services/acc.h +++ b/nx/include/switch/services/acc.h @@ -33,7 +33,7 @@ typedef struct Result accountInitialize(void); void accountExit(void); -Service* accountGetService(void); +Service* accountGetServiceSession(void); /// Get the total number of user profiles Result accountGetUserCount(s32* user_count); diff --git a/nx/include/switch/services/apm.h b/nx/include/switch/services/apm.h index 611c01aa..6e5e44b3 100644 --- a/nx/include/switch/services/apm.h +++ b/nx/include/switch/services/apm.h @@ -6,6 +6,7 @@ */ #pragma once #include "../types.h" +#include "../services/sm.h" /// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates. typedef enum { @@ -16,6 +17,7 @@ typedef enum { Result apmInitialize(void); void apmExit(void); +Service* apmGetServiceSession(void); Result apmSetPerformanceConfiguration(u32 PerformanceMode, u32 PerformanceConfiguration); Result apmGetPerformanceConfiguration(u32 PerformanceMode, u32 *PerformanceConfiguration); diff --git a/nx/include/switch/services/auddev.h b/nx/include/switch/services/auddev.h index 6dccabec..ba58e7a4 100644 --- a/nx/include/switch/services/auddev.h +++ b/nx/include/switch/services/auddev.h @@ -7,9 +7,11 @@ #pragma once #include "../audio/audio.h" +#include "../services/sm.h" Result auddevInitialize(void); void auddevExit(void); +Service* auddevGetServiceSession(void); Result auddevListAudioDeviceName(AudioDeviceName *DeviceNames, s32 max_names, s32 *total_names); Result auddevSetAudioDeviceOutputVolume(const AudioDeviceName *DeviceName, float volume); diff --git a/nx/include/switch/services/audren.h b/nx/include/switch/services/audren.h index 521d6463..8a2d3215 100644 --- a/nx/include/switch/services/audren.h +++ b/nx/include/switch/services/audren.h @@ -7,6 +7,7 @@ #pragma once #include "../audio/audio.h" +#include "../services/sm.h" #if __cplusplus >= 201402L #define AUDREN_CONSTEXPR constexpr @@ -321,6 +322,7 @@ AUDREN_CONSTEXPR size_t audrenGetOutputParamSize(const AudioRendererConfig* conf Result audrenInitialize(const AudioRendererConfig* config); void audrenExit(void); +Service* audrenGetServiceSession(void); void audrenWaitFrame(void); Result audrenGetState(u32* out_state); Result audrenRequestUpdateAudioRenderer(const void* in_param_buf, size_t in_param_buf_size, void* out_param_buf, size_t out_param_buf_size, void* perf_buf, size_t perf_buf_size); diff --git a/nx/include/switch/services/bpc.h b/nx/include/switch/services/bpc.h index 52100985..4426fec7 100644 --- a/nx/include/switch/services/bpc.h +++ b/nx/include/switch/services/bpc.h @@ -6,6 +6,7 @@ */ #pragma once #include "../types.h" +#include "../services/sm.h" typedef enum { BpcSleepButtonState_Held = 0, @@ -14,6 +15,7 @@ typedef enum { Result bpcInitialize(void); void bpcExit(void); +Service* bpcGetServiceSession(void); Result bpcShutdownSystem(void); Result bpcRebootSystem(void); diff --git a/nx/include/switch/services/bsd.h b/nx/include/switch/services/bsd.h index 857490f1..ab14a295 100644 --- a/nx/include/switch/services/bsd.h +++ b/nx/include/switch/services/bsd.h @@ -12,6 +12,7 @@ #include "../types.h" #include "../kernel/tmem.h" +#include "../services/sm.h" /// Configuration structure for bsdInitalize typedef struct { @@ -37,6 +38,7 @@ const BsdInitConfig *bsdGetDefaultInitConfig(void); Result bsdInitialize(const BsdInitConfig *config); /// Deinitialize the BSD service. void bsdExit(void); +Service* bsdGetServiceSession(void); /// Creates a socket. int bsdSocket(int domain, int type, int protocol); diff --git a/nx/include/switch/services/capssc.h b/nx/include/switch/services/capssc.h index df6c21ba..ae3d6e82 100644 --- a/nx/include/switch/services/capssc.h +++ b/nx/include/switch/services/capssc.h @@ -12,6 +12,7 @@ /// Initialize caps:sc. Only available on 2.0.0+. Result capsscInitialize(void); void capsscExit(void); +Service* capsscGetServiceSession(void); /** * @brief This takes a screenshot, with the screenshot being written into the output buffer. diff --git a/nx/include/switch/services/capssu.h b/nx/include/switch/services/capssu.h index 9d9ed6fe..449c632a 100644 --- a/nx/include/switch/services/capssu.h +++ b/nx/include/switch/services/capssu.h @@ -12,6 +12,7 @@ /// Initialize caps:su. Only available on 4.0.0+. Result capssuInitialize(void); void capssuExit(void); +Service* capssuGetServiceSession(void); /// Same as \ref capssuSaveScreenShotEx0, except this uses an all-zero CapsScreenShotAttribute where the first u32 is set to attr_val. attr_val can be zero. Result capssuSaveScreenShot(const void* buffer, size_t size, u32 unk, u32 attr_val, CapsApplicationAlbumEntry *out); diff --git a/nx/include/switch/services/clkrst.h b/nx/include/switch/services/clkrst.h index 7755331f..02054176 100644 --- a/nx/include/switch/services/clkrst.h +++ b/nx/include/switch/services/clkrst.h @@ -15,6 +15,7 @@ typedef struct { Result clkrstInitialize(void); void clkrstExit(void); +Service* clkrstGetServiceSession(void); /// Opens a ClkrstSession for the requested PcvModuleId, unk is set to 3 in official sysmodules. Result clkrstOpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32 unk); diff --git a/nx/include/switch/services/csrng.h b/nx/include/switch/services/csrng.h index b97b11b1..af45e7a8 100644 --- a/nx/include/switch/services/csrng.h +++ b/nx/include/switch/services/csrng.h @@ -6,8 +6,10 @@ */ #pragma once #include "../types.h" +#include "../services/sm.h" Result csrngInitialize(void); void csrngExit(void); +Service* csrngGetServiceSession(void); Result csrngGetRandomBytes(void *out, size_t out_size); diff --git a/nx/include/switch/services/fsldr.h b/nx/include/switch/services/fsldr.h index 12d7ab3f..bd471517 100644 --- a/nx/include/switch/services/fsldr.h +++ b/nx/include/switch/services/fsldr.h @@ -11,6 +11,7 @@ Result fsldrInitialize(void); void fsldrExit(void); +Service* fsldrGetServiceSession(void); Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out); Result fsldrIsArchivedProgram(u64 pid, bool *out); diff --git a/nx/include/switch/services/fspr.h b/nx/include/switch/services/fspr.h index 7809beec..c22496e1 100644 --- a/nx/include/switch/services/fspr.h +++ b/nx/include/switch/services/fspr.h @@ -11,6 +11,7 @@ Result fsprInitialize(void); void fsprExit(void); +Service* fsprGetServiceSession(void); Result fsprRegisterProgram(u64 pid, u64 titleID, FsStorageId storageID, const void *fs_access_header, size_t fah_size, const void *fs_access_control, size_t fac_size); Result fsprUnregisterProgram(u64 pid); diff --git a/nx/include/switch/services/gpio.h b/nx/include/switch/services/gpio.h index d9de71ef..63749f73 100644 --- a/nx/include/switch/services/gpio.h +++ b/nx/include/switch/services/gpio.h @@ -30,6 +30,7 @@ typedef enum { Result gpioInitialize(void); void gpioExit(void); +Service* gpioGetServiceSession(void); Result gpioOpenSession(GpioPadSession *out, GpioPadName name); diff --git a/nx/include/switch/services/hid.h b/nx/include/switch/services/hid.h index 1ecad286..8d34305b 100644 --- a/nx/include/switch/services/hid.h +++ b/nx/include/switch/services/hid.h @@ -656,7 +656,7 @@ Result hidInitialize(void); void hidExit(void); void hidReset(void); -Service* hidGetSessionService(void); +Service* hidGetServiceSession(void); void* hidGetSharedmemAddr(void); void hidSetControllerLayout(HidControllerID id, HidControllerLayoutType layoutType); diff --git a/nx/include/switch/services/hiddbg.h b/nx/include/switch/services/hiddbg.h index b711124b..c82b0779 100644 --- a/nx/include/switch/services/hiddbg.h +++ b/nx/include/switch/services/hiddbg.h @@ -78,6 +78,7 @@ typedef struct { Result hiddbgInitialize(void); void hiddbgExit(void); +Service* hiddbgGetServiceSession(void); /// Writes the input RGB colors to the spi-flash for the specified controller (offset 0x6050 size 0x6). See hidsys.h for UniquePadId. Only available with [3.0.0+]. Result hiddbgUpdateControllerColor(u32 colorBody, u32 colorButtons, u64 UniquePadId); diff --git a/nx/include/switch/services/hidsys.h b/nx/include/switch/services/hidsys.h index 280aa3cb..850f6177 100644 --- a/nx/include/switch/services/hidsys.h +++ b/nx/include/switch/services/hidsys.h @@ -34,6 +34,7 @@ typedef struct { Result hidsysInitialize(void); void hidsysExit(void); +Service* hidsysGetServiceSession(void); Result hidsysEnableAppletToGetInput(bool enable); diff --git a/nx/include/switch/services/i2c.h b/nx/include/switch/services/i2c.h index b45705a7..a36044c3 100644 --- a/nx/include/switch/services/i2c.h +++ b/nx/include/switch/services/i2c.h @@ -57,6 +57,7 @@ typedef enum { Result i2cInitialize(void); void i2cExit(void); +Service* i2cGetServiceSession(void); Result i2cOpenSession(I2cSession *out, I2cDevice dev); diff --git a/nx/include/switch/services/irs.h b/nx/include/switch/services/irs.h index eee8bf48..2dc6764b 100644 --- a/nx/include/switch/services/irs.h +++ b/nx/include/switch/services/irs.h @@ -55,7 +55,7 @@ Result irsInitialize(void); /// Exit irs. void irsExit(void); -Service* irsGetSessionService(void); +Service* irsGetServiceSession(void); void* irsGetSharedmemAddr(void); /// (De)activate the IR sensor, this is automatically used by \ref irsExit. Must be called after irsInitialize() to activate the IR sensor. diff --git a/nx/include/switch/services/lbl.h b/nx/include/switch/services/lbl.h index b9ff7cd6..02a954f8 100644 --- a/nx/include/switch/services/lbl.h +++ b/nx/include/switch/services/lbl.h @@ -6,9 +6,11 @@ */ #pragma once #include "../types.h" +#include "../services/sm.h" Result lblInitialize(void); void lblExit(void); +Service* lblGetServiceSession(void); Result lblSwitchBacklightOn(u64 fade_time); Result lblSwitchBacklightOff(u64 fade_time); diff --git a/nx/include/switch/services/lr.h b/nx/include/switch/services/lr.h index da5f83f9..6e7c19c8 100644 --- a/nx/include/switch/services/lr.h +++ b/nx/include/switch/services/lr.h @@ -19,6 +19,7 @@ typedef struct { Result lrInitialize(void); void lrExit(void); +Service* lrGetServiceSession(void); Result lrOpenLocationResolver(FsStorageId storage, LrLocationResolver* out); Result lrOpenRegisteredLocationResolver(LrRegisteredLocationResolver* out); diff --git a/nx/include/switch/services/ncm.h b/nx/include/switch/services/ncm.h index 139cc74f..7f572d9b 100644 --- a/nx/include/switch/services/ncm.h +++ b/nx/include/switch/services/ncm.h @@ -76,6 +76,7 @@ typedef struct { Result ncmInitialize(void); void ncmExit(void); +Service* ncmGetServiceSession(void); Result ncmOpenContentStorage(FsStorageId storage, NcmContentStorage* out); Result ncmOpenContentMetaDatabase(FsStorageId storage, NcmContentMetaDatabase* out); diff --git a/nx/include/switch/services/pcv.h b/nx/include/switch/services/pcv.h index 477757c6..d426f25b 100644 --- a/nx/include/switch/services/pcv.h +++ b/nx/include/switch/services/pcv.h @@ -6,6 +6,7 @@ */ #pragma once #include "../types.h" +#include "../services/sm.h" typedef enum { PcvModule_CpuBus = 0, @@ -192,6 +193,7 @@ typedef enum { Result pcvInitialize(void); void pcvExit(void); +Service* pcvGetServiceSession(void); Result pcvGetModuleId(PcvModuleId *module_id, PcvModule module); diff --git a/nx/include/switch/services/pdm.h b/nx/include/switch/services/pdm.h index 6a51493b..329a2b54 100644 --- a/nx/include/switch/services/pdm.h +++ b/nx/include/switch/services/pdm.h @@ -161,6 +161,7 @@ typedef struct { Result pdmqryInitialize(void); void pdmqryExit(void); +Service* pdmqueryGetServiceSession(void); /** * @brief Gets a list of \ref PdmApplicationEvent. diff --git a/nx/include/switch/services/pl.h b/nx/include/switch/services/pl.h index e2735b74..a7c6ac32 100644 --- a/nx/include/switch/services/pl.h +++ b/nx/include/switch/services/pl.h @@ -27,6 +27,7 @@ typedef struct { Result plInitialize(void); void plExit(void); +Service* plGetServiceSession(void); void* plGetSharedmemAddr(void); ///< Gets a specific shared-font via SharedFontType, see \ref PlSharedFontType. diff --git a/nx/include/switch/services/psc.h b/nx/include/switch/services/psc.h index d0e457d0..781bd941 100644 --- a/nx/include/switch/services/psc.h +++ b/nx/include/switch/services/psc.h @@ -26,6 +26,7 @@ typedef struct { Result pscInitialize(void); void pscExit(void); +Service* pscGetServiceSession(void); Result pscGetPmModule(PscPmModule *out, u16 module_id, const u16 *dependencies, size_t dependency_count, bool autoclear); diff --git a/nx/include/switch/services/psm.h b/nx/include/switch/services/psm.h index 5a3f5cb2..1113e25b 100644 --- a/nx/include/switch/services/psm.h +++ b/nx/include/switch/services/psm.h @@ -30,6 +30,7 @@ typedef struct { Result psmInitialize(void); void psmExit(void); +Service* psmGetServiceSession(void); Result psmGetBatteryChargePercentage(u32 *out); Result psmGetChargerType(ChargerType *out); diff --git a/nx/include/switch/services/ro.h b/nx/include/switch/services/ro.h index 5ed0c307..492ed929 100644 --- a/nx/include/switch/services/ro.h +++ b/nx/include/switch/services/ro.h @@ -11,12 +11,15 @@ Result ldrRoInitialize(void); void ldrRoExit(void); +Service* ldrRoGetServiceSession(void); Result ro1Initialize(void); void ro1Exit(void); +Service* ro1GetServiceSession(void); Result roDmntInitialize(void); void roDmntExit(void); +Service* roDmntGetServiceSession(void); Result ldrRoLoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); Result ldrRoUnloadNro(u64 nro_address); diff --git a/nx/include/switch/services/set.h b/nx/include/switch/services/set.h index 57b9a2b4..9e150519 100644 --- a/nx/include/switch/services/set.h +++ b/nx/include/switch/services/set.h @@ -9,6 +9,7 @@ #pragma once #include "../result.h" #include "../kernel/event.h" +#include "../services/sm.h" #define SET_MAX_NAME_SIZE 0x48 #define SET_MAX_NICKNAME_SIZE 0x80 @@ -86,6 +87,7 @@ typedef struct { Result setInitialize(void); void setExit(void); +Service* setGetServiceSession(void); /// Converts LanguageCode to Language. Result setMakeLanguage(u64 LanguageCode, s32 *Language); @@ -114,6 +116,7 @@ Result setGetRegionCode(SetRegion *out); Result setsysInitialize(void); void setsysExit(void); +Service* setsysGetServiceSession(void); /// Gets the current system theme. Result setsysGetColorSetId(ColorSetId *out); diff --git a/nx/include/switch/services/spl.h b/nx/include/switch/services/spl.h index de4b3874..4f897d8e 100644 --- a/nx/include/switch/services/spl.h +++ b/nx/include/switch/services/spl.h @@ -36,21 +36,27 @@ typedef enum { Result splInitialize(void); void splExit(void); +Service* splGetServiceSession(void); Result splCryptoInitialize(void); void splCryptoExit(void); +Service* splCryptoGetServiceSession(void); Result splSslInitialize(void); void splSslExit(void); +Service* splSslGetServiceSession(void); Result splEsInitialize(void); void splEsExit(void); +Service* splEsGetServiceSession(void); Result splFsInitialize(void); void splFsExit(void); +Service* splFsGetServiceSession(void); Result splManuInitialize(void); void splManuExit(void); +Service* splManuGetServiceSession(void); Result splGetConfig(SplConfigItem config_item, u64 *out_config); Result splUserExpMod(const void *input, const void *modulus, const void *exp, size_t exp_size, void *dst); diff --git a/nx/include/switch/services/spsm.h b/nx/include/switch/services/spsm.h index 3f69c72c..67037f78 100644 --- a/nx/include/switch/services/spsm.h +++ b/nx/include/switch/services/spsm.h @@ -6,9 +6,11 @@ */ #pragma once #include "../types.h" +#include "../services/sm.h" Result spsmInitialize(void); void spsmExit(void); +Service* spsmGetServiceSession(void); Result spsmShutdown(bool reboot); Result spsmPutErrorState(void); diff --git a/nx/include/switch/services/time.h b/nx/include/switch/services/time.h index 98f20a30..da3d644f 100644 --- a/nx/include/switch/services/time.h +++ b/nx/include/switch/services/time.h @@ -46,7 +46,7 @@ typedef struct { Result timeInitialize(void); void timeExit(void); -Service* timeGetSessionService(void); +Service* timeGetServiceSession(void); Result timeGetCurrentTime(TimeType type, u64 *timestamp); diff --git a/nx/include/switch/services/usbds.h b/nx/include/switch/services/usbds.h index a2f2a594..1beb9ef0 100644 --- a/nx/include/switch/services/usbds.h +++ b/nx/include/switch/services/usbds.h @@ -64,6 +64,7 @@ typedef enum { Result usbDsInitialize(void); /// Closes the usb:ds session. Any interfaces/endpoints which are left open are automatically closed, since otherwise usb-sysmodule won't fully reset usb:ds to defaults. void usbDsExit(void); +Service* usbDsGetServiceSession(void); /// Helpers Result usbDsWaitReady(u64 timeout); diff --git a/nx/include/switch/services/usbhs.h b/nx/include/switch/services/usbhs.h index cfd076eb..c8ba0bea 100644 --- a/nx/include/switch/services/usbhs.h +++ b/nx/include/switch/services/usbhs.h @@ -104,6 +104,7 @@ typedef struct { /// Initialize/exit usb:hs. Result usbHsInitialize(void); void usbHsExit(void); +Service* usbHsGetServiceSession(void); /// Returns the Event loaded during init with autoclear=false. /// Signaled when a device was removed. diff --git a/nx/include/switch/services/wlaninf.h b/nx/include/switch/services/wlaninf.h index d012f29e..b3eb0006 100644 --- a/nx/include/switch/services/wlaninf.h +++ b/nx/include/switch/services/wlaninf.h @@ -18,6 +18,7 @@ typedef enum { Result wlaninfInitialize(void); void wlaninfExit(void); +Service* wlaninfGetServiceSession(void); Result wlaninfGetState(WlanInfState* out); diff --git a/nx/source/services/acc.c b/nx/source/services/acc.c index 68d136ef..c58dcd8f 100644 --- a/nx/source/services/acc.c +++ b/nx/source/services/acc.c @@ -30,7 +30,7 @@ void accountExit(void) serviceClose(&g_accSrv); } -Service* accountGetService(void) { +Service* accountGetServiceSession(void) { return &g_accSrv; } diff --git a/nx/source/services/apm.c b/nx/source/services/apm.c index d22ed6d4..155cd3a1 100644 --- a/nx/source/services/apm.c +++ b/nx/source/services/apm.c @@ -41,6 +41,10 @@ void apmExit(void) } } +Service* apmGetServiceSession(void) { + return &g_apmSrv; +} + static Result _apmGetSession(Service* srv, Service* srv_out, u64 cmd_id) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/auddev.c b/nx/source/services/auddev.c index af81e630..38a448ae 100644 --- a/nx/source/services/auddev.c +++ b/nx/source/services/auddev.c @@ -47,6 +47,10 @@ void auddevExit(void) { } } +Service* auddevGetServiceSession(void) { + return &g_auddevIAudioDevice; +} + static Result _auddevGetAudioDeviceService(Service* srv, Service* out_srv, u64 aruid) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/audren.c b/nx/source/services/audren.c index a03f8124..58f2a003 100644 --- a/nx/source/services/audren.c +++ b/nx/source/services/audren.c @@ -129,6 +129,10 @@ void audrenExit(void) tmemClose(&g_audrenWorkBuf); } +Service* audrenGetServiceSession(void) { + return &g_audrenIAudioRenderer; +} + void audrenWaitFrame(void) { eventWait(&g_audrenEvent, U64_MAX); diff --git a/nx/source/services/bpc.c b/nx/source/services/bpc.c index b9804609..f1f663bc 100644 --- a/nx/source/services/bpc.c +++ b/nx/source/services/bpc.c @@ -29,6 +29,10 @@ void bpcExit(void) serviceClose(&g_bpcSrv); } +Service* bpcGetServiceSession(void) { + return &g_bpcSrv; +} + Result bpcShutdownSystem(void) { IpcCommand c; diff --git a/nx/source/services/bsd.c b/nx/source/services/bsd.c index 7102c578..62ac7f3c 100644 --- a/nx/source/services/bsd.c +++ b/nx/source/services/bsd.c @@ -277,6 +277,10 @@ void bsdExit(void) { tmemClose(&g_bsdTmem); } +Service* bsdGetServiceSession(void) { + return &g_bsdSrv; +} + int bsdSocket(int domain, int type, int protocol) { return _bsdSocketCreationCommand(2, domain, type, protocol); } diff --git a/nx/source/services/capssc.c b/nx/source/services/capssc.c index fa449f10..10eedc6a 100644 --- a/nx/source/services/capssc.c +++ b/nx/source/services/capssc.c @@ -33,6 +33,10 @@ void capsscExit(void) { serviceClose(&g_capsscSrv); } +Service* capsscGetServiceSession(void) { + return &g_capsscSrv; +} + Result capsscCaptureScreenshot(void* buf, size_t size, u32 inval, u64 width, u64 height, s64 buffer_count, s64 buffer_index, u64 timeout) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/capssu.c b/nx/source/services/capssu.c index 554090ec..6cd109cd 100644 --- a/nx/source/services/capssu.c +++ b/nx/source/services/capssu.c @@ -35,6 +35,10 @@ void capssuExit(void) { serviceClose(&g_capssuSrv); } +Service* capssuGetServiceSession(void) { + return &g_capssuSrv; +} + static Result _capssuSaveScreenShotEx0(const void* buffer, size_t size, CapsScreenShotAttribute *attr, u32 unk, CapsApplicationAlbumEntry *out) { u64 AppletResourceUserId = 0; appletGetAppletResourceUserId(&AppletResourceUserId); diff --git a/nx/source/services/clkrst.c b/nx/source/services/clkrst.c index 5a0a3576..1840b151 100644 --- a/nx/source/services/clkrst.c +++ b/nx/source/services/clkrst.c @@ -37,6 +37,10 @@ void clkrstExit(void) { } } +Service* clkrstGetServiceSession(void) { + return &g_clkrstSrv; +} + Result clkrstOpenSession(ClkrstSession* session_out, PcvModuleId module_id, u32 unk) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/csrng.c b/nx/source/services/csrng.c index 8ab34f32..ac1220d7 100644 --- a/nx/source/services/csrng.c +++ b/nx/source/services/csrng.c @@ -25,6 +25,10 @@ void csrngExit(void) { serviceClose(&g_csrngSrv); } +Service* csrngGetServiceSession(void) { + return &g_csrngSrv; +} + Result csrngGetRandomBytes(void *out, size_t out_size) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/fsldr.c b/nx/source/services/fsldr.c index e698e176..8d9fa85c 100644 --- a/nx/source/services/fsldr.c +++ b/nx/source/services/fsldr.c @@ -39,6 +39,10 @@ void fsldrExit(void) { serviceClose(&g_fsldrSrv); } +Service* fsldrGetServiceSession(void) { + return &g_fsldrSrv; +} + Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out) { char send_path[FS_MAX_PATH+1] = {0}; IpcCommand c; diff --git a/nx/source/services/fspr.c b/nx/source/services/fspr.c index 2fc7077b..6800e0bf 100644 --- a/nx/source/services/fspr.c +++ b/nx/source/services/fspr.c @@ -39,6 +39,10 @@ void fsprExit(void) { serviceClose(&g_fsprSrv); } +Service* fsprGetServiceSession(void) { + return &g_fsprSrv; +} + Result fsprRegisterProgram(u64 pid, u64 titleID, FsStorageId storageID, const void *fs_access_header, size_t fah_size, const void *fs_access_control, size_t fac_size) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/gpio.c b/nx/source/services/gpio.c index 5e8b28a3..2091a815 100644 --- a/nx/source/services/gpio.c +++ b/nx/source/services/gpio.c @@ -29,6 +29,10 @@ void gpioExit(void) { } } +Service* gpioGetServiceSession(void) { + return &g_gpioSrv; +} + Result gpioOpenSession(GpioPadSession *out, GpioPadName name) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/hid.c b/nx/source/services/hid.c index c6620dd4..9c74a5cb 100644 --- a/nx/source/services/hid.c +++ b/nx/source/services/hid.c @@ -167,7 +167,7 @@ void hidReset(void) rwlockWriteUnlock(&g_hidLock); } -Service* hidGetSessionService(void) { +Service* hidGetServiceSession(void) { return &g_hidSrv; } diff --git a/nx/source/services/hiddbg.c b/nx/source/services/hiddbg.c index 937af615..925db2d4 100644 --- a/nx/source/services/hiddbg.c +++ b/nx/source/services/hiddbg.c @@ -37,6 +37,10 @@ void hiddbgExit(void) { } } +Service* hiddbgGetServiceSession(void) { + return &g_hiddbgSrv; +} + static Result _hiddbgCmdNoIO(u64 cmd_id) { Result rc; diff --git a/nx/source/services/hidsys.c b/nx/source/services/hidsys.c index ad8df5fe..72041798 100644 --- a/nx/source/services/hidsys.c +++ b/nx/source/services/hidsys.c @@ -38,6 +38,10 @@ void hidsysExit(void) { } } +Service* hidsysGetServiceSession(void) { + return &g_hidsysSrv; +} + Result hidsysEnableAppletToGetInput(bool enable) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/i2c.c b/nx/source/services/i2c.c index 78cab905..75dae96d 100644 --- a/nx/source/services/i2c.c +++ b/nx/source/services/i2c.c @@ -33,6 +33,10 @@ void i2cExit(void) { } } +Service* i2cGetServiceSession(void) { + return &g_i2cSrv; +} + Result i2cOpenSession(I2cSession *out, I2cDevice dev) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/irs.c b/nx/source/services/irs.c index d673acd0..98cc7408 100644 --- a/nx/source/services/irs.c +++ b/nx/source/services/irs.c @@ -135,7 +135,7 @@ static void _IrsCameraEntryFree(IrsCameraEntry *entry) { memset(entry, 0, sizeof(IrsCameraEntry)); } -Service* irsGetSessionService(void) { +Service* irsGetServiceSession(void) { return &g_irsSrv; } diff --git a/nx/source/services/lbl.c b/nx/source/services/lbl.c index 46e0a649..4d66757e 100644 --- a/nx/source/services/lbl.c +++ b/nx/source/services/lbl.c @@ -29,6 +29,10 @@ void lblExit(void) { } } +Service* lblGetServiceSession(void) { + return &g_lblSrv; +} + static Result _lblCmdNoIO(u64 cmd_id) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/lr.c b/nx/source/services/lr.c index d1499b7d..6d26185e 100644 --- a/nx/source/services/lr.c +++ b/nx/source/services/lr.c @@ -27,6 +27,10 @@ void lrExit(void) { } } +Service* lrGetServiceSession(void) { + return &g_managerSrv; +} + Result lrOpenLocationResolver(FsStorageId storage, LrLocationResolver* out) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/ncm.c b/nx/source/services/ncm.c index 100cfb6c..217c1ebb 100644 --- a/nx/source/services/ncm.c +++ b/nx/source/services/ncm.c @@ -20,6 +20,10 @@ void ncmExit(void) { } } +Service* ncmGetServiceSession(void) { + return &g_ncmSrv; +} + Result ncmOpenContentStorage(FsStorageId storage, NcmContentStorage* out) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/pcv.c b/nx/source/services/pcv.c index 4ebd1ef0..f2f6d1ee 100644 --- a/nx/source/services/pcv.c +++ b/nx/source/services/pcv.c @@ -30,6 +30,10 @@ void pcvExit(void) { } } +Service* pcvGetServiceSession(void) { + return &g_pcvSrv; +} + Result pcvGetModuleId(PcvModuleId *module_id, PcvModule module) { static const PcvModuleId s_moduleIdMap[PcvModule_Count] = { PcvModuleId_CpuBus, PcvModuleId_GPU, PcvModuleId_I2S1, PcvModuleId_I2S2, diff --git a/nx/source/services/pdm.c b/nx/source/services/pdm.c index c7faa592..fac7823d 100644 --- a/nx/source/services/pdm.c +++ b/nx/source/services/pdm.c @@ -29,6 +29,10 @@ void pdmqryExit(void) { serviceClose(&g_pdmqrySrv); } +Service* pdmqryGetServiceSession(void) { + return &g_pdmqrySrv; +} + static Result _pdmqryQueryEvent(u64 cmd_id, u32 entryindex, void* events, size_t entrysize, s32 count, s32 *total_out) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/pl.c b/nx/source/services/pl.c index 6592af95..b142454f 100644 --- a/nx/source/services/pl.c +++ b/nx/source/services/pl.c @@ -53,6 +53,10 @@ void plExit(void) } } +Service* plGetServiceSession(void) { + return &g_plSrv; +} + void* plGetSharedmemAddr(void) { return shmemGetAddr(&g_plSharedmem); } diff --git a/nx/source/services/psc.c b/nx/source/services/psc.c index 57dbf8bf..2b854a52 100644 --- a/nx/source/services/psc.c +++ b/nx/source/services/psc.c @@ -45,6 +45,10 @@ void pscExit(void) { } } +Service* pscGetServiceSession(void) { + return &g_pscSrv; +} + Result pscGetPmModule(PscPmModule *out, u16 module_id, const u16 *dependencies, size_t dependency_count, bool autoclear) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/psm.c b/nx/source/services/psm.c index 1bf259ee..cb982ce1 100644 --- a/nx/source/services/psm.c +++ b/nx/source/services/psm.c @@ -37,6 +37,10 @@ void psmExit(void) { } } +Service* psmGetServiceSession(void) { + return &g_psmSrv; +} + static Result _psmGetOutU32(u64 cmd_id, u32 *out) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/ro.c b/nx/source/services/ro.c index 186a9bae..79903a11 100644 --- a/nx/source/services/ro.c +++ b/nx/source/services/ro.c @@ -37,6 +37,10 @@ void ldrRoExit(void) { serviceClose(&g_roSrv); } +Service* ldrRoGetServiceSession(void) { + return &g_roSrv; +} + Result ro1Initialize(void) { if (hosversionBefore(7,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -59,6 +63,10 @@ void ro1Exit(void) { serviceClose(&g_ro1Srv); } +Service* ro1GetServiceSession(void) { + return &g_ro1Srv; +} + Result roDmntInitialize(void) { if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); @@ -75,6 +83,10 @@ void roDmntExit(void) { serviceClose(&g_dmntSrv); } +Service* roDmntGetServiceSession(void) { + return &g_dmntSrv; +} + Result _rosrvInitialize(Service* srv) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/set.c b/nx/source/services/set.c index ad45633e..38381549 100644 --- a/nx/source/services/set.c +++ b/nx/source/services/set.c @@ -45,6 +45,10 @@ void setExit(void) } } +Service* setGetServiceSession(void) { + return &g_setSrv; +} + Result setsysInitialize(void) { atomicIncrement64(&g_refCntSys); @@ -62,6 +66,10 @@ void setsysExit(void) } } +Service* setsysGetSessionService(void) { + return &g_setsysSrv; +} + static Result setInitializeLanguageCodesCache(void) { if (g_setLanguageCodesInitialized) return 0; Result rc = 0; diff --git a/nx/source/services/spl.c b/nx/source/services/spl.c index c275b412..b51168e2 100644 --- a/nx/source/services/spl.c +++ b/nx/source/services/spl.c @@ -18,6 +18,8 @@ static Service* _splGetRsaSrv(void); static Service* _splGetEsSrv(void); static Service* _splGetFsSrv(void); +static Service* _splGetSslSrv(void); +static Service* _splGetManuSrv(void); Service* _splGetGeneralSrv(void) { if (hosversionBefore(4,0,0)) { @@ -71,6 +73,14 @@ Service* _splGetFsSrv(void) { return hosversionAtLeast(4,0,0) ? &g_splFsSrv : &g_splSrv; } +Service* _splGetSslSrv(void) { + return hosversionAtLeast(4,0,0) ? &g_splSslSrv : &g_splSrv; +} + +Service* _splGetManuSrv(void) { + return hosversionAtLeast(4,0,0) ? &g_splManuSrv : &g_splSrv; +} + /* There are like six services, so these helpers will initialize/exit the relevant services. */ static Result _splSrvInitialize(Service* srv, u64 *refcnt, const char *name) { atomicIncrement64(refcnt); @@ -94,6 +104,10 @@ void splExit(void) { return _splSrvExit(&g_splSrv, &g_splRefCnt); } +Service* splGetServiceSession(void) { + return _splGetGeneralSrv(); +} + Result splCryptoInitialize(void) { if (hosversionAtLeast(4,0,0)) { return _splSrvInitialize(&g_splCryptoSrv, &g_splCryptoRefCnt, "spl:mig"); @@ -110,6 +124,10 @@ void splCryptoExit(void) { } } +Service* splCryptoGetServiceSession(void) { + return _splGetCryptoSrv(); +} + Result splSslInitialize(void) { if (hosversionAtLeast(4,0,0)) { return _splSrvInitialize(&g_splSslSrv, &g_splSslRefCnt, "spl:ssl"); @@ -126,6 +144,10 @@ void splSslExit(void) { } } +Service* splSslGetServiceSession(void) { + return _splGetSslSrv(); +} + Result splEsInitialize(void) { if (hosversionAtLeast(4,0,0)) { return _splSrvInitialize(&g_splEsSrv, &g_splEsRefCnt, "spl:es"); @@ -142,6 +164,10 @@ void splEsExit(void) { } } +Service* splEsGetServiceSession(void) { + return _splGetEsSrv(); +} + Result splFsInitialize(void) { if (hosversionAtLeast(4,0,0)) { return _splSrvInitialize(&g_splFsSrv, &g_splFsRefCnt, "spl:fs"); @@ -158,6 +184,10 @@ void splFsExit(void) { } } +Service* splFsGetServiceSession(void) { + return _splGetFsSrv(); +} + Result splManuInitialize(void) { return _splSrvInitialize(&g_splManuSrv, &g_splManuRefCnt, "spl:manu"); } @@ -166,6 +196,10 @@ void splManuExit(void) { return _splSrvExit(&g_splManuSrv, &g_splManuRefCnt); } +Service* splManuGetServiceSession(void) { + return _splGetManuSrv(); +} + /* SPL IGeneralService functionality. */ Result splGetConfig(SplConfigItem config_item, u64 *out_config) { diff --git a/nx/source/services/spsm.c b/nx/source/services/spsm.c index 2a7d2f77..7f47569d 100644 --- a/nx/source/services/spsm.c +++ b/nx/source/services/spsm.c @@ -29,6 +29,10 @@ void spsmExit(void) { } } +Service* spsmGetServiceSession(void) { + return &g_spsmSrv; +} + Result spsmShutdown(bool reboot) { IpcCommand c; ipcInitialize(&c); diff --git a/nx/source/services/time.c b/nx/source/services/time.c index 320416ce..4e18c4d3 100644 --- a/nx/source/services/time.c +++ b/nx/source/services/time.c @@ -60,7 +60,7 @@ void timeExit(void) } } -Service* timeGetSessionService(void) { +Service* timeGetServiceSession(void) { return &g_timeSrv; } diff --git a/nx/source/services/usbds.c b/nx/source/services/usbds.c index 14d74452..a6050102 100644 --- a/nx/source/services/usbds.c +++ b/nx/source/services/usbds.c @@ -78,6 +78,10 @@ void usbDsExit(void) serviceClose(&g_usbDsSrv); } +Service* usbDsGetServiceSession(void) { + return &g_usbDsSrv; +} + Event* usbDsGetStateChangeEvent(void) { return &g_usbDsStateChangeEvent; diff --git a/nx/source/services/usbhs.c b/nx/source/services/usbhs.c index 56116e78..09630586 100644 --- a/nx/source/services/usbhs.c +++ b/nx/source/services/usbhs.c @@ -52,6 +52,10 @@ void usbHsExit(void) { serviceClose(&g_usbHsSrv); } +Service* usbHsGetServiceSession(void) { + return &g_usbHsSrv; +} + Event* usbHsGetInterfaceStateChangeEvent(void) { return &g_usbHsInterfaceStateChangeEvent; } diff --git a/nx/source/services/wlaninf.c b/nx/source/services/wlaninf.c index 51999c00..1eb0d854 100644 --- a/nx/source/services/wlaninf.c +++ b/nx/source/services/wlaninf.c @@ -36,6 +36,10 @@ void wlaninfExit(void) { } } +Service* wlaninfGetServiceSession(void) { + return &g_wlaninfSrv; +} + Result wlaninfGetState(WlanInfState* out) { IpcCommand c; ipcInitialize(&c);