├── .github └── FUNDING.yml ├── .gitmodules ├── LICENSE ├── Makefile ├── Overlay ├── Makefile ├── include │ ├── UnityQuality.hpp │ ├── UnityScalableBufferManager.hpp │ ├── UnityScreen.hpp │ ├── Utils.hpp │ ├── dmntchtRead.hpp │ ├── dmntchtWrite.hpp │ └── readFiles.hpp └── source │ ├── UnityQuality.cpp │ ├── UnityScalableBufferManager.cpp │ ├── UnityScreen.cpp │ ├── Utils.cpp │ ├── dmntchtRead.cpp │ ├── dmntchtWrite.cpp │ ├── main.cpp │ └── readFiles.cpp ├── Plugin ├── Makefile ├── include │ ├── QualitySettings.hpp │ ├── ScalableBufferManagerSettings.hpp │ ├── ScreenSettings.hpp │ ├── Utils.hpp │ ├── saltysd │ │ ├── saltysd_core.h │ │ ├── saltysd_dynamic.h │ │ └── saltysd_ipc.h │ └── useful │ │ └── useful.h ├── lib │ └── libnx_min │ │ ├── CODESTYLE.md │ │ ├── Changelog.md │ │ ├── LICENSE.md │ │ ├── Makefile │ │ ├── README.md │ │ └── nx │ │ ├── default_icon.jpg │ │ ├── include │ │ ├── switch_min.h │ │ └── switch_min │ │ │ ├── applets │ │ │ ├── error.h │ │ │ ├── libapplet.h │ │ │ ├── pctlauth.h │ │ │ └── swkbd.h │ │ │ ├── arm │ │ │ ├── atomics.h │ │ │ ├── cache.h │ │ │ ├── counter.h │ │ │ ├── thread_context.h │ │ │ └── tls.h │ │ │ ├── audio │ │ │ ├── audio.h │ │ │ └── driver.h │ │ │ ├── crypto │ │ │ ├── aes.h │ │ │ ├── aes_cbc.h │ │ │ ├── aes_ctr.h │ │ │ ├── aes_xts.h │ │ │ ├── cmac.h │ │ │ ├── crc.h │ │ │ ├── hmac.h │ │ │ ├── sha1.h │ │ │ └── sha256.h │ │ │ ├── kernel │ │ │ ├── barrier.h │ │ │ ├── condvar.h │ │ │ ├── detect.h │ │ │ ├── event.h │ │ │ ├── ipc.h │ │ │ ├── jit.h │ │ │ ├── mutex.h │ │ │ ├── random.h │ │ │ ├── rwlock.h │ │ │ ├── semaphore.h │ │ │ ├── shmem.h │ │ │ ├── svc.h │ │ │ ├── thread.h │ │ │ ├── tmem.h │ │ │ ├── uevent.h │ │ │ ├── utimer.h │ │ │ ├── virtmem.h │ │ │ └── wait.h │ │ │ ├── nacp.h │ │ │ ├── nro.h │ │ │ ├── result.h │ │ │ ├── runtime │ │ │ ├── devices │ │ │ │ ├── console.h │ │ │ │ ├── fs_dev.h │ │ │ │ ├── romfs_dev.h │ │ │ │ └── socket.h │ │ │ ├── env.h │ │ │ ├── hosversion.h │ │ │ ├── threadvars.h │ │ │ └── util │ │ │ │ └── utf.h │ │ │ ├── services │ │ │ ├── acc.h │ │ │ ├── apm.h │ │ │ ├── applet.h │ │ │ ├── bsd.h │ │ │ ├── fatal.h │ │ │ ├── fs.h │ │ │ ├── fsldr.h │ │ │ ├── fspr.h │ │ │ ├── hid.h │ │ │ ├── hiddbg.h │ │ │ ├── hidsys.h │ │ │ ├── irs.h │ │ │ ├── lbl.h │ │ │ ├── ldr.h │ │ │ ├── ncm.h │ │ │ ├── nfc.h │ │ │ ├── nifm.h │ │ │ ├── ns.h │ │ │ ├── pctl.h │ │ │ ├── pl.h │ │ │ ├── pm.h │ │ │ ├── psc.h │ │ │ ├── psm.h │ │ │ ├── ro.h │ │ │ ├── set.h │ │ │ ├── sfdnsres.h │ │ │ ├── sm.h │ │ │ ├── smm.h │ │ │ ├── spsm.h │ │ │ ├── time.h │ │ │ └── wlaninf.h │ │ │ └── types.h │ │ ├── lib │ │ ├── libnx_min.a │ │ └── libnx_mind.a │ │ ├── switch.ld │ │ ├── switch.specs │ │ └── switch_rules ├── source │ ├── QualitySettings.cpp │ ├── ScalableBufferManagerSettings.cpp │ ├── ScreenSettings.cpp │ ├── Utils.cpp │ └── main.cpp ├── switch.ld └── switch.specs ├── README.md └── Screen.jpg /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: masagrator 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Overlay/libs/Atmosphere-libs"] 2 | path = Overlay/libs/Atmosphere-libs 3 | url = https://github.com/Atmosphere-NX/Atmosphere-libs 4 | [submodule "Overlay/libs/libtesla"] 5 | path = Overlay/libs/libtesla 6 | url = https://github.com/WerWolv/libtesla 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: all clean 3 | 4 | all: 5 | @$(MAKE) -C Plugin/ 6 | @$(MAKE) -C Overlay/ 7 | @mkdir -p Out/SaltySD/plugins/ 8 | @mkdir -p Out/switch/.overlays 9 | @cp Overlay/UnityGraphics-ovl.ovl Out/switch/.overlays/UnityGraphics-ovl.ovl 10 | @cp Plugin/UnityGraphics.elf Out/SaltySD/plugins/UnityGraphics.elf 11 | 12 | clean: 13 | @$(MAKE) -C Plugin/ clean 14 | @$(MAKE) -C Overlay/ clean 15 | @rm -r -f Out -------------------------------------------------------------------------------- /Overlay/include/UnityScalableBufferManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "dmntcht.h" 5 | #include "dmntchtRead.hpp" 6 | #include "dmntchtWrite.hpp" 7 | #include "Utils.hpp" 8 | 9 | 10 | class ResizeBuffers : public tsl::Gui { 11 | public: 12 | ResizeBuffers() {} 13 | ~ResizeBuffers() {} 14 | 15 | virtual tsl::elm::Element *createUI() override; 16 | 17 | virtual void update() override; 18 | }; 19 | 20 | class ScalableBufferManagerSettings : public tsl::Gui { 21 | public: 22 | ScalableBufferManagerSettings(); 23 | ~ScalableBufferManagerSettings() {} 24 | 25 | virtual tsl::elm::Element *createUI() override; 26 | 27 | virtual void update() override; 28 | }; -------------------------------------------------------------------------------- /Overlay/include/UnityScreen.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "dmntcht.h" 5 | #include "dmntchtRead.hpp" 6 | #include "dmntchtWrite.hpp" 7 | #include "Utils.hpp" 8 | 9 | 10 | class SetResolution : public tsl::Gui { 11 | public: 12 | SetResolution() {} 13 | ~SetResolution() {} 14 | 15 | virtual tsl::elm::Element *createUI() override; 16 | 17 | virtual void update() override; 18 | }; 19 | 20 | class ScreenSettings : public tsl::Gui { 21 | public: 22 | ScreenSettings(); 23 | ~ScreenSettings() {} 24 | 25 | virtual tsl::elm::Element *createUI() override; 26 | 27 | virtual void update() override; 28 | }; -------------------------------------------------------------------------------- /Overlay/include/Utils.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dmntcht.h" 3 | #include "dmntchtRead.hpp" 4 | #include "dmntchtWrite.hpp" 5 | 6 | namespace Utils { 7 | 8 | extern uint64_t PID; 9 | extern bool dmnt_cht; 10 | extern bool PluginRunning; 11 | extern bool closed; 12 | extern bool threadexit; 13 | extern char OptionsChar[64]; 14 | extern bool check; 15 | extern bool Quality_read; 16 | extern bool notsupported; 17 | extern bool Screen_read; 18 | extern bool ScalableBufferManager_read; 19 | extern bool Camera_read; 20 | 21 | extern uint32_t MAGIC; 22 | 23 | extern float denominator; 24 | 25 | bool CheckPort (); 26 | bool isServiceRunning(const char *serviceName); 27 | 28 | extern const std::string overlayName; 29 | extern std::string version; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /Overlay/include/dmntchtRead.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dmntcht.h" 3 | #include "readFiles.hpp" 4 | 5 | namespace dmntcht { 6 | void Read(); 7 | } -------------------------------------------------------------------------------- /Overlay/include/dmntchtWrite.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dmntcht.h" 3 | #include "readFiles.hpp" 4 | 5 | namespace dmntcht { 6 | ///Quality 7 | void write_pixelLightCount(); 8 | void write_shadows(); 9 | void write_shadowProjection(); 10 | void write_shadowCascades(); 11 | void write_shadowDistance(); 12 | void write_shadowResolution(); 13 | void write_shadowmaskMode(); 14 | void write_shadowNearPlaneOffset(); 15 | void write_shadowCascade2Split(); 16 | void write_lodBias(); 17 | void write_anisotropicFiltering(); 18 | void write_masterTextureLimit(); 19 | void write_maximumLODLevel(); 20 | void write_particleRaycastBudget(); 21 | void write_softParticles(); 22 | void write_softVegetation(); 23 | void write_vSyncCount(); 24 | void write_antiAliasing(); 25 | void write_asyncUploadTimeSlice(); 26 | void write_asyncUploadBufferSize(); 27 | void write_asyncUploadPersistentBuffer(); 28 | void write_realtimeReflectionProbes(); 29 | void write_billboardsFaceCameraPosition(); 30 | void write_resolutionScalingFixedDPIFactor(); 31 | void write_blendWeights(); 32 | void write_streamingMipmapsActive(); 33 | void write_streamingMipmapsMemoryBudget(); 34 | void write_streamingMipmapsMaxLevelReduction(); 35 | void write_streamingMipmapsAddAllCameras(); 36 | void write_streamingMipmapsMaxFileIORequests(); 37 | void write_maxQueuedFrames(); 38 | 39 | ///Screen 40 | void write_SetResolution(); 41 | 42 | ///ScalableBufferManager 43 | void write_ResizeBuffers(); 44 | } -------------------------------------------------------------------------------- /Overlay/include/readFiles.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "dmntcht.h" 3 | #include 4 | 5 | namespace nullify { 6 | 7 | void Quality(uint8_t nullcase); 8 | } 9 | 10 | namespace Utils { 11 | 12 | extern uint8_t switchcase; 13 | extern uint8_t settings; 14 | 15 | extern DmntCheatProcessMetadata dmnt_metadata; 16 | 17 | extern uintptr_t switchcase_address; 18 | extern uintptr_t settings_address; 19 | extern uintptr_t base_nso_address; 20 | extern uintptr_t MAGIC_address; 21 | 22 | extern uintptr_t pixelLightCount_address; 23 | extern uintptr_t ShadowQuality_address; 24 | extern uintptr_t ShadowProjection_address; 25 | extern uintptr_t shadowCascades_address; 26 | extern uintptr_t shadowDistance_address; 27 | extern uintptr_t ShadowResolution_address; 28 | extern uintptr_t ShadowmaskMode_address; 29 | extern uintptr_t shadowNearPlaneOffset_address; 30 | extern uintptr_t shadowCascade2Split_address; 31 | extern uintptr_t lodBias_address; 32 | extern uintptr_t AnisotropicFiltering_address; 33 | extern uintptr_t masterTextureLimit_address; 34 | extern uintptr_t maximumLODLevel_address; 35 | extern uintptr_t particleRaycastBudget_address; 36 | extern uintptr_t softParticles_address; 37 | extern uintptr_t softVegetation_address; 38 | extern uintptr_t vSyncCount_address; 39 | extern uintptr_t antiAliasing_address; 40 | extern uintptr_t asyncUploadTimeSlice_address; 41 | extern uintptr_t asyncUploadBufferSize_address; 42 | extern uintptr_t asyncUploadPersistentBuffer_address; 43 | extern uintptr_t realtimeReflectionProbes_address; 44 | extern uintptr_t billboardsFaceCameraPosition_address; 45 | extern uintptr_t resolutionScalingFixedDPIFactor_address; 46 | extern uintptr_t BlendWeights_address; 47 | extern uintptr_t streamingMipmapsActive_address; 48 | extern uintptr_t streamingMipmapsMemoryBudget_address; 49 | extern uintptr_t streamingMipmapsRenderersPerFrame_address; 50 | extern uintptr_t streamingMipmapsMaxLevelReduction_address; 51 | extern uintptr_t streamingMipmapsAddAllCameras_address; 52 | extern uintptr_t streamingMipmapsMaxFileIORequests_address; 53 | extern uintptr_t maxQueuedFrames_address; 54 | 55 | extern uintptr_t width_address; 56 | extern uintptr_t height_address; 57 | 58 | extern uintptr_t widthScaleFactor_address; 59 | extern uintptr_t heightScaleFactor_address; 60 | 61 | extern uint32_t pixelLightCount; 62 | extern uint32_t ShadowQuality; 63 | extern uint32_t ShadowProjection; 64 | extern uint32_t shadowCascades; 65 | extern float shadowDistance; 66 | extern uint32_t ShadowResolution; 67 | extern uint32_t ShadowmaskMode; 68 | extern float shadowNearPlaneOffset; 69 | extern float shadowCascade2Split; 70 | extern float lodBias; 71 | extern uint32_t AnisotropicFiltering; 72 | extern uint32_t masterTextureLimit; 73 | extern uint32_t maximumLODLevel; 74 | extern uint32_t particleRaycastBudget; 75 | extern bool softParticles; 76 | extern bool softVegetation; 77 | extern uint32_t vSyncCount; 78 | extern uint32_t antiAliasing; 79 | extern uint32_t asyncUploadTimeSlice; 80 | extern uint32_t asyncUploadBufferSize; 81 | extern bool asyncUploadPersistentBuffer; 82 | extern bool realtimeReflectionProbes; 83 | extern bool billboardsFaceCameraPosition; 84 | extern float resolutionScalingFixedDPIFactor; 85 | extern uint32_t BlendWeights; 86 | extern bool streamingMipmapsActive; 87 | extern float streamingMipmapsMemoryBudget; 88 | extern uint32_t streamingMipmapsMaxLevelReduction; 89 | extern bool streamingMipmapsAddAllCameras; 90 | extern uint32_t streamingMipmapsMaxFileIORequests; 91 | extern int32_t maxQueuedFrames; 92 | 93 | extern uint32_t width; 94 | extern uint32_t height; 95 | 96 | extern float widthScaleFactor; 97 | extern float heightScaleFactor; 98 | 99 | extern char BID_File[192]; 100 | extern char BID_File2[196]; 101 | 102 | void readFiles(); 103 | } 104 | -------------------------------------------------------------------------------- /Overlay/source/UnityScalableBufferManager.cpp: -------------------------------------------------------------------------------- 1 | #include "UnityScalableBufferManager.hpp" 2 | 3 | ///* ScalableBufferManager Settings Options 4 | /// 5 | /// 6 | // 7 | ///////////////////////////////////////////////////////////////////////////////// 8 | 9 | tsl::elm::Element *ResizeBuffers::createUI() { 10 | auto *Frame2 = new tsl::elm::OverlayFrame(Utils::overlayName, Utils::version); 11 | 12 | auto list2 = new tsl::elm::List(); 13 | 14 | list2->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *renderer, s32 x, s32 y, s32 w, s32 h) { 15 | renderer->drawString(Utils::OptionsChar, false, x, y+20, 20, renderer->a(0xFFFF)); 16 | }), 25); 17 | 18 | list2->addItem(new tsl::elm::CategoryHeader("Options")); 19 | auto *clickableListItem1 = new tsl::elm::ListItem("25%"); 20 | clickableListItem1->setClickListener([](u64 keys) { 21 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 22 | Utils::widthScaleFactor = 0.25; 23 | Utils::heightScaleFactor = 0.25; 24 | dmntcht::write_ResizeBuffers(); 25 | return true; 26 | } 27 | 28 | return false; 29 | }); 30 | 31 | list2->addItem(clickableListItem1); 32 | 33 | auto *clickableListItem2 = new tsl::elm::ListItem("33%"); 34 | clickableListItem2->setClickListener([](u64 keys) { 35 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 36 | Utils::widthScaleFactor = 0.33; 37 | Utils::heightScaleFactor = 0.33; 38 | dmntcht::write_ResizeBuffers(); 39 | return true; 40 | } 41 | 42 | return false; 43 | }); 44 | 45 | list2->addItem(clickableListItem2); 46 | 47 | auto *clickableListItem3 = new tsl::elm::ListItem("50%"); 48 | clickableListItem3->setClickListener([](u64 keys) { 49 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 50 | Utils::widthScaleFactor = 0.5; 51 | Utils::heightScaleFactor = 0.5; 52 | dmntcht::write_ResizeBuffers(); 53 | return true; 54 | } 55 | 56 | return false; 57 | }); 58 | 59 | list2->addItem(clickableListItem3); 60 | 61 | auto *clickableListItem4 = new tsl::elm::ListItem("75%"); 62 | clickableListItem4->setClickListener([](u64 keys) { 63 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 64 | Utils::widthScaleFactor = 0.75; 65 | Utils::heightScaleFactor = 0.75; 66 | dmntcht::write_ResizeBuffers(); 67 | return true; 68 | } 69 | 70 | return false; 71 | }); 72 | 73 | list2->addItem(clickableListItem4); 74 | 75 | auto *clickableListItem5 = new tsl::elm::ListItem("100%"); 76 | clickableListItem5->setClickListener([](u64 keys) { 77 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 78 | Utils::widthScaleFactor = 1.0; 79 | Utils::heightScaleFactor = 1.0; 80 | dmntcht::write_ResizeBuffers(); 81 | return true; 82 | } 83 | 84 | return false; 85 | }); 86 | 87 | list2->addItem(clickableListItem5); 88 | 89 | Frame2->setContent(list2); 90 | 91 | return Frame2; 92 | } 93 | 94 | void ResizeBuffers::update() { 95 | if (R_FAILED(pmdmntGetApplicationProcessId(&Utils::PID))) { 96 | remove("sdmc:/SaltySD/UnityGraphics.hex"); 97 | Utils::PluginRunning = false; 98 | Utils::check = false; 99 | Utils::closed = true; 100 | } 101 | dmntchtReadCheatProcessMemory(Utils::widthScaleFactor_address, &Utils::widthScaleFactor, 0x4); 102 | dmntchtReadCheatProcessMemory(Utils::heightScaleFactor_address, &Utils::heightScaleFactor, 0x4); 103 | sprintf(Utils::OptionsChar, "Width: %.2f%s, Height: %.2f%s", Utils::widthScaleFactor * (float)100, "%", Utils::heightScaleFactor * (float)100, "%"); 104 | } 105 | 106 | ///* Screen Settings Menu 107 | /// 108 | /// 109 | // 110 | ///////////////////////////////////////////////////////////////////////////////// 111 | 112 | ScalableBufferManagerSettings::ScalableBufferManagerSettings() { 113 | if (Utils::ScalableBufferManager_read == false) { 114 | for (uint8_t i = 1; i <= 2; i++) { 115 | Utils::switchcase = i; 116 | Utils::settings = 3; 117 | dmntchtWriteCheatProcessMemory(Utils::settings_address, &Utils::settings, 0x1); 118 | dmntchtWriteCheatProcessMemory(Utils::switchcase_address, &Utils::switchcase, 0x1); 119 | svcSleepThread(34'000'000); 120 | } 121 | Utils::settings = 0; 122 | Utils::switchcase = 0; 123 | dmntcht::Read(); 124 | Utils::ScalableBufferManager_read = true; 125 | } 126 | } 127 | 128 | 129 | tsl::elm::Element *ScalableBufferManagerSettings::createUI() { 130 | 131 | auto *frame = new tsl::elm::OverlayFrame(Utils::overlayName, Utils::version); 132 | 133 | auto list = new tsl::elm::List(); 134 | 135 | if (Utils::MAGIC == 0x16BA7E38 && Utils::notsupported == false) { 136 | list->addItem(new tsl::elm::CategoryHeader("ScalableBufferManager Settings")); 137 | 138 | if (Utils::widthScaleFactor_address != 0 && Utils::heightScaleFactor_address != 0) { 139 | auto *ResizeBuffersauto = new tsl::elm::ListItem("ResizeBuffers", "enum"); 140 | ResizeBuffersauto->setClickListener([](u64 keys) { 141 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 142 | tsl::changeTo(); 143 | return true; 144 | } 145 | return false; 146 | }); 147 | 148 | list->addItem(ResizeBuffersauto); 149 | } 150 | 151 | } 152 | 153 | // Add the list to the frame for it to be drawn 154 | frame->setContent(list); 155 | 156 | // Return the frame to have it become the top level element of this Gui 157 | return frame; 158 | 159 | } 160 | 161 | void ScalableBufferManagerSettings::update() { 162 | if (R_FAILED(pmdmntGetApplicationProcessId(&Utils::PID))) { 163 | remove("sdmc:/SaltySD/UnityGraphics.hex"); 164 | Utils::PluginRunning = false; 165 | Utils::check = false; 166 | Utils::closed = true; 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /Overlay/source/UnityScreen.cpp: -------------------------------------------------------------------------------- 1 | #include "UnityScreen.hpp" 2 | 3 | ///* Screen Settings Options 4 | /// 5 | /// 6 | // 7 | ///////////////////////////////////////////////////////////////////////////////// 8 | 9 | tsl::elm::Element *SetResolution::createUI() { 10 | auto *Frame2 = new tsl::elm::OverlayFrame(Utils::overlayName, Utils::version); 11 | 12 | auto list2 = new tsl::elm::List(); 13 | 14 | list2->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer *renderer, s32 x, s32 y, s32 w, s32 h) { 15 | renderer->drawString(Utils::OptionsChar, false, x, y+20, 20, renderer->a(0xFFFF)); 16 | }), 25); 17 | 18 | list2->addItem(new tsl::elm::CategoryHeader("Options")); 19 | auto *clickableListItem1 = new tsl::elm::ListItem("640x360"); 20 | clickableListItem1->setClickListener([](u64 keys) { 21 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 22 | Utils::width = 640; 23 | Utils::height = 360; 24 | dmntcht::write_SetResolution(); 25 | return true; 26 | } 27 | 28 | return false; 29 | }); 30 | 31 | list2->addItem(clickableListItem1); 32 | 33 | auto *clickableListItem2 = new tsl::elm::ListItem("960x540"); 34 | clickableListItem2->setClickListener([](u64 keys) { 35 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 36 | Utils::width = 960; 37 | Utils::height = 540; 38 | dmntcht::write_SetResolution(); 39 | return true; 40 | } 41 | 42 | return false; 43 | }); 44 | 45 | list2->addItem(clickableListItem2); 46 | 47 | auto *clickableListItem3 = new tsl::elm::ListItem("1280x720"); 48 | clickableListItem3->setClickListener([](u64 keys) { 49 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 50 | Utils::width = 1280; 51 | Utils::height = 720; 52 | dmntcht::write_SetResolution(); 53 | return true; 54 | } 55 | 56 | return false; 57 | }); 58 | 59 | list2->addItem(clickableListItem3); 60 | 61 | auto *clickableListItem4 = new tsl::elm::ListItem("1600x900"); 62 | clickableListItem4->setClickListener([](u64 keys) { 63 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 64 | Utils::width = 1600; 65 | Utils::height = 900; 66 | dmntcht::write_SetResolution(); 67 | return true; 68 | } 69 | 70 | return false; 71 | }); 72 | 73 | list2->addItem(clickableListItem4); 74 | 75 | auto *clickableListItem5 = new tsl::elm::ListItem("1920x1080"); 76 | clickableListItem5->setClickListener([](u64 keys) { 77 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 78 | Utils::width = 1920; 79 | Utils::height = 1080; 80 | dmntcht::write_SetResolution(); 81 | return true; 82 | } 83 | 84 | return false; 85 | }); 86 | 87 | list2->addItem(clickableListItem5); 88 | 89 | Frame2->setContent(list2); 90 | 91 | return Frame2; 92 | } 93 | 94 | void SetResolution::update() { 95 | if (R_FAILED(pmdmntGetApplicationProcessId(&Utils::PID))) { 96 | remove("sdmc:/SaltySD/UnityGraphics.hex"); 97 | Utils::PluginRunning = false; 98 | Utils::check = false; 99 | Utils::closed = true; 100 | } 101 | dmntchtReadCheatProcessMemory(Utils::width_address, &Utils::width, 0x4); 102 | dmntchtReadCheatProcessMemory(Utils::height_address, &Utils::height, 0x4); 103 | sprintf(Utils::OptionsChar, "Resolution: %u" "x%u", Utils::width, Utils::height); 104 | } 105 | 106 | ///* Screen Settings Menu 107 | /// 108 | /// 109 | // 110 | ///////////////////////////////////////////////////////////////////////////////// 111 | 112 | ScreenSettings::ScreenSettings() { 113 | if (Utils::Screen_read == false) { 114 | for (uint8_t i = 1; i <= 3; i++) { 115 | if (i == 3) i = 16; 116 | Utils::switchcase = i; 117 | Utils::settings = 2; 118 | dmntchtWriteCheatProcessMemory(Utils::settings_address, &Utils::settings, 0x1); 119 | dmntchtWriteCheatProcessMemory(Utils::switchcase_address, &Utils::switchcase, 0x1); 120 | svcSleepThread(34'000'000); 121 | } 122 | Utils::settings = 0; 123 | Utils::switchcase = 0; 124 | dmntcht::Read(); 125 | Utils::Screen_read = true; 126 | } 127 | } 128 | 129 | 130 | tsl::elm::Element *ScreenSettings::createUI() { 131 | 132 | auto *frame = new tsl::elm::OverlayFrame(Utils::overlayName, Utils::version); 133 | 134 | auto list = new tsl::elm::List(); 135 | 136 | if (Utils::MAGIC == 0x16BA7E38 && Utils::notsupported == false) { 137 | list->addItem(new tsl::elm::CategoryHeader("Screen Settings")); 138 | 139 | if (Utils::width_address != 0 && Utils::height_address != 0) { 140 | auto *SetResolutionauto = new tsl::elm::ListItem("SetResolution", "enum"); 141 | SetResolutionauto->setClickListener([](u64 keys) { 142 | if ((keys & HidNpadButton_A) && Utils::PluginRunning == true && Utils::dmnt_cht == true) { 143 | tsl::changeTo(); 144 | return true; 145 | } 146 | return false; 147 | }); 148 | 149 | list->addItem(SetResolutionauto); 150 | } 151 | 152 | } 153 | 154 | // Add the list to the frame for it to be drawn 155 | frame->setContent(list); 156 | 157 | // Return the frame to have it become the top level element of this Gui 158 | return frame; 159 | 160 | } 161 | 162 | void ScreenSettings::update() { 163 | if (R_FAILED(pmdmntGetApplicationProcessId(&Utils::PID))) { 164 | remove("sdmc:/SaltySD/UnityGraphics.hex"); 165 | Utils::PluginRunning = false; 166 | Utils::check = false; 167 | Utils::closed = true; 168 | } 169 | } 170 | -------------------------------------------------------------------------------- /Overlay/source/Utils.cpp: -------------------------------------------------------------------------------- 1 | #include "Utils.hpp" 2 | 3 | namespace Utils { 4 | uint64_t PID = 0; 5 | bool PluginRunning = false; 6 | bool dmnt_cht = false; 7 | bool closed = false; 8 | bool threadexit = false; 9 | char OptionsChar[64]; 10 | bool check = false; 11 | bool Quality_read = false; 12 | bool notsupported = false; 13 | bool Screen_read = false; 14 | bool ScalableBufferManager_read = false; 15 | 16 | const std::string overlayName = APP_TITLE; 17 | std::string version = APP_VERSION; 18 | 19 | uint32_t MAGIC = 0x0; 20 | 21 | float denominator = 3; 22 | 23 | bool CheckPort () { 24 | Handle saltysd; 25 | for (int i = 0; i < 34; i++) { 26 | if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) { 27 | svcCloseHandle(saltysd); 28 | break; 29 | } 30 | else { 31 | if (i == 33) return false; 32 | svcSleepThread(1'000'000); 33 | } 34 | } 35 | for (int i = 0; i < 34; i++) { 36 | if (R_SUCCEEDED(svcConnectToNamedPort(&saltysd, "InjectServ"))) { 37 | svcCloseHandle(saltysd); 38 | return true; 39 | } 40 | else svcSleepThread(1'000'000); 41 | } 42 | return false; 43 | } 44 | 45 | bool isServiceRunning(const char *serviceName) { 46 | Handle handle; 47 | SmServiceName service_name = smEncodeName(serviceName); 48 | if (R_FAILED(smRegisterService(&handle, service_name, false, 1))) return true; 49 | else { 50 | svcCloseHandle(handle); 51 | smUnregisterService(service_name); 52 | return false; 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Overlay/source/dmntchtRead.cpp: -------------------------------------------------------------------------------- 1 | #include "dmntchtRead.hpp" 2 | 3 | namespace dmntcht { 4 | 5 | void Read() { 6 | dmntchtReadCheatProcessMemory(Utils::pixelLightCount_address, &Utils::pixelLightCount, 0x4); 7 | dmntchtReadCheatProcessMemory(Utils::ShadowQuality_address, &Utils::ShadowQuality, 0x4); 8 | dmntchtReadCheatProcessMemory(Utils::ShadowProjection_address, &Utils::ShadowProjection, 0x4); 9 | dmntchtReadCheatProcessMemory(Utils::shadowCascades_address, &Utils::shadowCascades, 0x4); 10 | dmntchtReadCheatProcessMemory(Utils::shadowDistance_address, &Utils::shadowDistance, 0x4); 11 | dmntchtReadCheatProcessMemory(Utils::ShadowResolution_address, &Utils::ShadowResolution, 0x4); 12 | dmntchtReadCheatProcessMemory(Utils::ShadowmaskMode_address, &Utils::ShadowmaskMode, 0x4); 13 | dmntchtReadCheatProcessMemory(Utils::shadowNearPlaneOffset_address, &Utils::shadowNearPlaneOffset, 0x4); 14 | dmntchtReadCheatProcessMemory(Utils::shadowCascade2Split_address, &Utils::shadowCascade2Split, 0x4); 15 | dmntchtReadCheatProcessMemory(Utils::lodBias_address, &Utils::lodBias, 0x4); 16 | dmntchtReadCheatProcessMemory(Utils::AnisotropicFiltering_address, &Utils::AnisotropicFiltering, 0x4); 17 | dmntchtReadCheatProcessMemory(Utils::masterTextureLimit_address, &Utils::masterTextureLimit, 0x4); 18 | dmntchtReadCheatProcessMemory(Utils::maximumLODLevel_address, &Utils::maximumLODLevel, 0x4); 19 | dmntchtReadCheatProcessMemory(Utils::particleRaycastBudget_address, &Utils::particleRaycastBudget, 0x4); 20 | dmntchtReadCheatProcessMemory(Utils::softParticles_address, &Utils::softParticles, 0x1); 21 | dmntchtReadCheatProcessMemory(Utils::softVegetation_address, &Utils::softVegetation, 0x1); 22 | dmntchtReadCheatProcessMemory(Utils::vSyncCount_address, &Utils::vSyncCount, 0x4); 23 | dmntchtReadCheatProcessMemory(Utils::antiAliasing_address, &Utils::antiAliasing, 0x4); 24 | dmntchtReadCheatProcessMemory(Utils::asyncUploadTimeSlice_address, &Utils::asyncUploadTimeSlice, 0x4); 25 | dmntchtReadCheatProcessMemory(Utils::asyncUploadBufferSize_address, &Utils::asyncUploadBufferSize, 0x4); 26 | dmntchtReadCheatProcessMemory(Utils::asyncUploadPersistentBuffer_address, &Utils::asyncUploadPersistentBuffer, 0x1); 27 | dmntchtReadCheatProcessMemory(Utils::realtimeReflectionProbes_address, &Utils::realtimeReflectionProbes, 0x1); 28 | dmntchtReadCheatProcessMemory(Utils::billboardsFaceCameraPosition_address, &Utils::billboardsFaceCameraPosition, 0x1); 29 | dmntchtReadCheatProcessMemory(Utils::resolutionScalingFixedDPIFactor_address, &Utils::resolutionScalingFixedDPIFactor, 0x4); 30 | dmntchtReadCheatProcessMemory(Utils::BlendWeights_address, &Utils::BlendWeights, 0x4); 31 | dmntchtReadCheatProcessMemory(Utils::streamingMipmapsActive_address, &Utils::streamingMipmapsActive, 0x1); 32 | dmntchtReadCheatProcessMemory(Utils::streamingMipmapsMemoryBudget_address, &Utils::streamingMipmapsMemoryBudget, 0x4); 33 | dmntchtReadCheatProcessMemory(Utils::streamingMipmapsMaxLevelReduction_address, &Utils::streamingMipmapsMaxLevelReduction, 0x4); 34 | dmntchtReadCheatProcessMemory(Utils::streamingMipmapsAddAllCameras_address, &Utils::streamingMipmapsAddAllCameras, 0x1); 35 | dmntchtReadCheatProcessMemory(Utils::streamingMipmapsMaxFileIORequests_address, &Utils::streamingMipmapsMaxFileIORequests, 0x4); 36 | dmntchtReadCheatProcessMemory(Utils::maxQueuedFrames_address, &Utils::maxQueuedFrames, 0x4); 37 | 38 | dmntchtReadCheatProcessMemory(Utils::width_address, &Utils::width, 0x4); 39 | dmntchtReadCheatProcessMemory(Utils::height_address, &Utils::height, 0x4); 40 | 41 | dmntchtReadCheatProcessMemory(Utils::widthScaleFactor_address, &Utils::widthScaleFactor, 0x4); 42 | dmntchtReadCheatProcessMemory(Utils::heightScaleFactor_address, &Utils::heightScaleFactor, 0x4); 43 | 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Plugin/include/ScalableBufferManagerSettings.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | #include 5 | 6 | namespace UnitySettings { namespace ScalableBufferManager { 7 | 8 | extern uintptr_t ptr_get_widthScaleFactor; 9 | extern float widthScaleFactor; 10 | 11 | extern uintptr_t ptr_get_heightScaleFactor; 12 | extern float heightScaleFactor; 13 | 14 | extern uintptr_t ptr_ResizeBuffers; 15 | 16 | void Change (uint8_t m_switchcase); 17 | } 18 | } -------------------------------------------------------------------------------- /Plugin/include/ScreenSettings.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | #include 5 | 6 | namespace UnitySettings { namespace Screen { 7 | 8 | extern uintptr_t ptr_get_width; 9 | extern uint32_t width; 10 | 11 | extern uintptr_t ptr_get_height; 12 | extern uint32_t height; 13 | 14 | extern uintptr_t ptr_SetResolution; 15 | 16 | void Change (uint8_t m_switchcase); 17 | } 18 | } -------------------------------------------------------------------------------- /Plugin/include/Utils.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "QualitySettings.hpp" 3 | #include "ScreenSettings.hpp" 4 | #include "ScalableBufferManagerSettings.hpp" 5 | #include "saltysd/SaltySD_core.h" 6 | #include "saltysd/SaltySD_ipc.h" 7 | #include "saltysd/SaltySD_dynamic.h" 8 | 9 | namespace Utils { 10 | extern uint8_t switchcase; 11 | extern uint32_t MAGIC; 12 | 13 | enum Settings { 14 | None = 0, 15 | Quality = 1, 16 | Screen = 2, 17 | ScalableBufferManager = 3 18 | }; 19 | 20 | extern Settings _settings; 21 | 22 | void writeFile(); 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Plugin/include/saltysd/saltysd_core.h: -------------------------------------------------------------------------------- 1 | #ifndef SALTYSD_CORE_H 2 | #define SALTYSD_CORE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "useful/useful.h" 8 | 9 | extern "C" { 10 | u64 SaltySDCore_getCodeStart() LINKABLE; 11 | u64 SaltySDCore_getCodeSize() LINKABLE; 12 | u64 SaltySDCore_findCode(u8* code, size_t size) LINKABLE; 13 | FILE* SaltySDCore_fopen(const char* filename, const char* mode) LINKABLE; 14 | int SaltySDCore_fclose(FILE* stream) LINKABLE; 15 | int SaltySDCore_mkdir(const char* dirname, mode_t mode) LINKABLE; 16 | size_t SaltySDCore_fwrite(const void *ptr, size_t size, size_t count, FILE *stream) LINKABLE; 17 | int SaltySDCore_remove(const char* filename) LINKABLE; 18 | size_t SaltySDCore_fread(void* ptr, size_t size, size_t count, FILE* stream) LINKABLE; 19 | DIR* SaltySDCore_opendir(const char* dirname) LINKABLE; 20 | int SaltySDCore_closedir(DIR *dirp) LINKABLE; 21 | } 22 | 23 | #endif // SALTYSD_CORE_H 24 | -------------------------------------------------------------------------------- /Plugin/include/saltysd/saltysd_dynamic.h: -------------------------------------------------------------------------------- 1 | #ifndef SALTYSD_DYNAMIC_H 2 | #define SALTYSD_DYNAMIC_H 3 | 4 | #include 5 | 6 | #include "useful/useful.h" 7 | 8 | extern "C" { 9 | uint64_t SaltySDCore_GetSymbolAddr(void* base, char* name) LINKABLE; 10 | uint64_t SaltySDCore_FindSymbol(char* name) LINKABLE; 11 | uint64_t SaltySDCore_FindSymbolBuiltin(char* name) LINKABLE; 12 | void SaltySDCore_RegisterModule(void* base) LINKABLE; 13 | void SaltySDCore_RegisterBuiltinModule(void* base) LINKABLE; 14 | void SaltySDCore_DynamicLinkModule(void* base) LINKABLE; 15 | void SaltySDCore_ReplaceModuleImport(void* base, char* name, void* new_replace) LINKABLE; 16 | void SaltySDCore_ReplaceImport(char* name, void* new_replace) LINKABLE; 17 | } 18 | 19 | #endif // SALTYSD_DYNAMIC_H 20 | -------------------------------------------------------------------------------- /Plugin/include/saltysd/saltysd_ipc.h: -------------------------------------------------------------------------------- 1 | #ifndef SALTYSD_IPC_H 2 | #define SALTYSD_IPC_H 3 | 4 | #include 5 | 6 | #include "useful/useful.h" 7 | 8 | extern "C" { 9 | void SaltySD_Init() LINKABLE; 10 | Result SaltySD_Deinit() LINKABLE; 11 | Result SaltySD_Term() LINKABLE; 12 | Result SaltySD_Restore() LINKABLE; 13 | Result SaltySD_LoadELF(u64 heap, u64* elf_addr, u64* elf_size, char* name) LINKABLE; 14 | Result SaltySD_Memcpy(u64 to, u64 from, u64 size) LINKABLE; 15 | Result SaltySD_GetSDCard(Handle *retrieve) LINKABLE; 16 | Result SaltySD_printf(const char* format, ...) LINKABLE; 17 | } 18 | 19 | #endif //SALTYSD_IPC_H 20 | -------------------------------------------------------------------------------- /Plugin/include/useful/useful.h: -------------------------------------------------------------------------------- 1 | #ifndef USEFUL_H 2 | #define USEFUL_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define LOAD64 *(u64 *) 9 | 10 | #define LINKABLE __attribute__ ((weak)) 11 | 12 | #define debug_log(...) \ 13 | {char log_buf[0x200]; snprintf(log_buf, 0x200, __VA_ARGS__); \ 14 | svcOutputDebugString(log_buf, strlen(log_buf));} 15 | 16 | typedef struct Hash40 { 17 | uint64_t hash : 40; 18 | } Hash40; 19 | 20 | typedef struct Vector2f { 21 | float x; 22 | float y; 23 | } Vector2f; 24 | 25 | typedef struct Vector3f { 26 | float x; 27 | float y; 28 | float z; 29 | } Vector3f; 30 | 31 | typedef struct Vector4f { 32 | float x; 33 | float y; 34 | float z; 35 | float w; 36 | }Vector4f; 37 | 38 | #endif // USEFUL_H 39 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/CODESTYLE.md: -------------------------------------------------------------------------------- 1 | # Code Style 2 | 3 | ## Types 4 | `TypesAreCapitalizedLikeThis` 5 | 6 | ## Enums 7 | `EnumType_EnumName` 8 | 9 | ## Struct members 10 | `like_this` 11 | 12 | `notlikethis` 13 | 14 | ## Local variables 15 | `like_this` 16 | 17 | `notlikethis` 18 | 19 | ## Global variables (or global statics) 20 | `g_variableName` 21 | 22 | ## Functions 23 | `modulenameFunctionName` 24 | 25 | ### Submodule function naming 26 | Singletons use names like smInitialize/smExit 27 | 28 | Objects use names like tmemCreate/tmemClose 29 | 30 | ## Macros 31 | `LIKE_THIS` 32 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright 2017-2018 libnx Authors 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | 5 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | $(MAKE) -C nx/ 3 | 4 | install: 5 | $(MAKE) -C nx/ install 6 | 7 | clean: 8 | $(MAKE) -C nx/ clean 9 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/README.md: -------------------------------------------------------------------------------- 1 | # Nintendo Switch AArch64-only userland library. 2 | Based on libctru. 3 | 4 | [![Build status](https://doozer.io/badge/switchbrew/libnx/buildstatus/master)](https://doozer.io/switchbrew/libnx) 5 | 6 | # Install instructions 7 | See [Switchbrew](https://switchbrew.org/wiki/Setting_up_Development_Environment). 8 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/default_icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/masagrator/UnityGraphics/7566e366906b436a9d6ab1359bba71d014617753/Plugin/lib/libnx_min/nx/default_icon.jpg -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file switch_min.h 3 | * @brief Central Switch header. Includes all others. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | #include "switch_min/types.h" 13 | #include "switch_min/result.h" 14 | 15 | #include "switch_min/nro.h" 16 | #include "switch_min/nacp.h" 17 | 18 | #include "switch_min/arm/tls.h" 19 | #include "switch_min/arm/cache.h" 20 | #include "switch_min/arm/atomics.h" 21 | #include "switch_min/arm/counter.h" 22 | 23 | #include "switch_min/kernel/svc.h" 24 | #include "switch_min/kernel/wait.h" 25 | #include "switch_min/kernel/tmem.h" 26 | #include "switch_min/kernel/shmem.h" 27 | #include "switch_min/kernel/mutex.h" 28 | #include "switch_min/kernel/event.h" 29 | #include "switch_min/kernel/uevent.h" 30 | #include "switch_min/kernel/utimer.h" 31 | #include "switch_min/kernel/rwlock.h" 32 | #include "switch_min/kernel/condvar.h" 33 | #include "switch_min/kernel/thread.h" 34 | #include "switch_min/kernel/semaphore.h" 35 | #include "switch_min/kernel/virtmem.h" 36 | #include "switch_min/kernel/detect.h" 37 | #include "switch_min/kernel/random.h" 38 | #include "switch_min/kernel/jit.h" 39 | #include "switch_min/kernel/ipc.h" 40 | #include "switch_min/kernel/barrier.h" 41 | 42 | #include "switch_min/services/sm.h" 43 | #include "switch_min/services/smm.h" 44 | #include "switch_min/services/fs.h" 45 | #include "switch_min/services/fsldr.h" 46 | #include "switch_min/services/fspr.h" 47 | #include "switch_min/services/acc.h" 48 | #include "switch_min/services/apm.h" 49 | #include "switch_min/services/applet.h" 50 | #include "switch_min/services/lbl.h" 51 | #include "switch_min/services/psm.h" 52 | #include "switch_min/services/spsm.h" 53 | //#include "switch_min/services/bsd.h" Use switch_min/runtime/devices/socket.h instead 54 | #include "switch_min/services/fatal.h" 55 | #include "switch_min/services/time.h" 56 | #include "switch_min/services/hid.h" 57 | #include "switch_min/services/hiddbg.h" 58 | #include "switch_min/services/hidsys.h" 59 | #include "switch_min/services/irs.h" 60 | #include "switch_min/services/pl.h" 61 | #include "switch_min/services/nifm.h" 62 | #include "switch_min/services/ns.h" 63 | #include "switch_min/services/ldr.h" 64 | #include "switch_min/services/ro.h" 65 | #include "switch_min/services/pm.h" 66 | #include "switch_min/services/set.h" 67 | #include "switch_min/services/ncm.h" 68 | #include "switch_min/services/psc.h" 69 | #include "switch_min/services/nfc.h" 70 | #include "switch_min/services/wlaninf.h" 71 | #include "switch_min/services/pctl.h" 72 | 73 | #include "switch_min/applets/libapplet.h" 74 | #include "switch_min/applets/pctlauth.h" 75 | #include "switch_min/applets/error.h" 76 | #include "switch_min/applets/swkbd.h" 77 | 78 | #include "switch_min/runtime/env.h" 79 | #include "switch_min/runtime/hosversion.h" 80 | 81 | #include "switch_min/runtime/util/utf.h" 82 | 83 | #include "switch_min/runtime/devices/console.h" 84 | #include "switch_min/runtime/devices/fs_dev.h" 85 | #include "switch_min/runtime/devices/romfs_dev.h" 86 | #include "switch_min/runtime/devices/socket.h" 87 | 88 | #include "switch_min/crypto/aes.h" 89 | #include "switch_min/crypto/aes_cbc.h" 90 | #include "switch_min/crypto/aes_ctr.h" 91 | #include "switch_min/crypto/aes_xts.h" 92 | #include "switch_min/crypto/cmac.h" 93 | 94 | #include "switch_min/crypto/sha256.h" 95 | #include "switch_min/crypto/sha1.h" 96 | #include "switch_min/crypto/hmac.h" 97 | 98 | #include "switch_min/crypto/crc.h" 99 | 100 | #ifdef __cplusplus 101 | } 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/applets/libapplet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file libapplet.h 3 | * @brief LibraryApplet wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/applet.h" 10 | 11 | /// CommonArguments 12 | typedef struct { 13 | u32 CommonArgs_version; 14 | u32 CommonArgs_size; 15 | 16 | u32 LaVersion; ///< LibraryApplet API version 17 | s32 ExpectedThemeColor; ///< Set to the output from \ref appletGetThemeColorType by \ref libappletArgsCreate. 18 | u8 PlayStartupSound; ///< bool flag, default is false. 19 | u8 pad[7]; 20 | u64 tick; 21 | } LibAppletArgs; 22 | 23 | /** 24 | * @brief Creates a LibAppletArgs struct. 25 | * @param a LibAppletArgs struct. 26 | * @param version LaVersion for \ref LibAppletArgs. 27 | */ 28 | void libappletArgsCreate(LibAppletArgs* a, u32 version); 29 | 30 | /** 31 | * @brief Sets the PlayStartupSound field in \ref LibAppletArgs. 32 | * @param a LibAppletArgs struct. 33 | * @param flag Value for \ref LibAppletArgs PlayStartupSound. 34 | */ 35 | void libappletArgsSetPlayStartupSound(LibAppletArgs* a, bool flag); 36 | 37 | /** 38 | * @brief Creates an AppletStorage with the specified size and writes the buffer contents to that storage at offset 0. 39 | * @param[out] s Storage object. 40 | * @param buffer Input buffer. 41 | * @param size Size to write. 42 | */ 43 | Result libappletCreateWriteStorage(AppletStorage* s, const void* buffer, size_t size); 44 | 45 | /** 46 | * @brief Reads data from offset 0 from the specified storage into the buffer. If the storage-size is smaller than the size param, the storage-size is used instead. 47 | * @param s Storage object. 48 | * @param buffer Output buffer. 49 | * @param size Size to read. 50 | * @param transfer_size Optional output size field for the actual size used for the read, can be NULL. 51 | */ 52 | Result libappletReadStorage(AppletStorage* s, void* buffer, size_t size, size_t *transfer_size); 53 | 54 | /** 55 | * @brief Sets the tick field in LibAppletArgs, then creates a storage with it which is pushed to the AppletHolder via \ref appletHolderPushInData. 56 | * @param a LibAppletArgs struct. 57 | * @param h AppletHolder object. 58 | */ 59 | Result libappletArgsPush(LibAppletArgs* a, AppletHolder *h); 60 | 61 | /** 62 | * @brief Creates a storage using the input buffer which is pushed to the AppletHolder via \ref appletHolderPushInData. 63 | * @param h AppletHolder object. 64 | * @param buffer Input data buffer. 65 | * @param size Input data size. 66 | */ 67 | Result libappletPushInData(AppletHolder *h, const void* buffer, size_t size); 68 | 69 | /** 70 | * @brief Pops a storage via \ref appletHolderPopOutData, uses \ref libappletReadStorage, then closes the storage. 71 | * @param h AppletHolder object. 72 | * @param buffer Output buffer. 73 | * @param size Size to read. 74 | * @param transfer_size Optional output size field for the actual size used for the read, can be NULL. 75 | */ 76 | Result libappletPopOutData(AppletHolder *h, void* buffer, size_t size, size_t *transfer_size); 77 | 78 | /** 79 | * @brief Starts the applet and waits for it to finish, then checks the \ref LibAppletExitReason. 80 | * @note Uses \ref appletHolderStart and \ref appletHolderJoin. 81 | * @param h AppletHolder object. 82 | */ 83 | Result libappletStart(AppletHolder *h); 84 | 85 | /** 86 | * @brief Creates a LibraryApplet with the specified input storage data, uses \ref libappletStart, and reads the output storage reply data via \ref libappletPopOutData. 87 | * @param id \ref AppletId 88 | * @param commonargs \ref LibAppletArgs struct. 89 | * @param arg Input storage data buffer. Optional, can be NULL. 90 | * @param arg_size Size of the arg buffer. 91 | * @param reply Output storage data buffer. Optional, can be NULL. 92 | * @param reply_size Size to read for the reply buffer. 93 | * @param out_reply_size Actual read reply data size, see \ref libappletPopOutData. 94 | */ 95 | Result libappletLaunch(AppletId id, LibAppletArgs *commonargs, const void* arg, size_t arg_size, void* reply, size_t reply_size, size_t *out_reply_size); 96 | 97 | /// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this. 98 | /// Returns to the main Home Menu, equivalent to pressing the HOME button. 99 | Result libappletRequestHomeMenu(void); 100 | 101 | /// Wrapper for \ref appletPushToGeneralChannel, see appletPushToGeneralChannel regarding the requirements for using this. 102 | /// Equivalent to entering "System Update" under System Settings. When leaving this, it returns to the main Home Menu. 103 | Result libappletRequestJumpToSystemUpdate(void); 104 | 105 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/applets/pctlauth.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pctlauth.h 3 | * @brief Wrapper for using the Parental Controls authentication LibraryApplet. This applet is used by qlaunch. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// Type values for PctlAuthArg::type. 11 | typedef enum { 12 | PctlAuthType_Show = 0, ///< ShowParentalAuthentication 13 | PctlAuthType_RegisterPasscode = 1, ///< RegisterParentalPasscode 14 | PctlAuthType_ChangePasscode = 2, ///< ChangeParentalPasscode 15 | } PctlAuthType; 16 | 17 | /// Input arg storage for the applet. 18 | typedef struct { 19 | u32 unk_x0; ///< Always set to 0 by the user-process. 20 | PctlAuthType type; ///< \ref PctlAuthType 21 | u8 arg0; ///< Arg0 22 | u8 arg1; ///< Arg1 23 | u8 arg2; ///< Arg2 24 | u8 pad; ///< Padding 25 | } PctlAuthArg; 26 | 27 | /** 28 | * @brief Launches the applet. 29 | * @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled. 30 | * @param flag Input flag. false = temporarily disable Parental Controls. true = validate the input PIN. 31 | */ 32 | Result pctlauthShow(bool flag); 33 | 34 | /** 35 | * @brief Launches the applet. Only available with [4.0.0+]. 36 | * @param arg0 Value for PctlAuthArg.arg0. 37 | * @param arg1 Value for PctlAuthArg.arg1. 38 | * @param arg2 Value for PctlAuthArg.arg2. 39 | */ 40 | Result pctlauthShowEx(u8 arg0, u8 arg1, u8 arg2); 41 | 42 | /** 43 | * @brief Just calls: pctlauthShowEx(1, 0, 1). Launches the applet for checking the PIN, used when changing system-settings. 44 | * @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled. 45 | */ 46 | Result pctlauthShowForConfiguration(void); 47 | 48 | /** 49 | * @brief Launches the applet for registering the Parental Controls PIN. 50 | */ 51 | Result pctlauthRegisterPasscode(void); 52 | 53 | /** 54 | * @brief Launches the applet for changing the Parental Controls PIN. 55 | * @note Should not be used if a PIN is not already registered. See \ref pctlIsRestrictionEnabled. 56 | */ 57 | Result pctlauthChangePasscode(void); 58 | 59 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/arm/atomics.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file atomics.h 3 | * @brief AArch64 atomic operations. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// Atomically increments a 32-bit value. 11 | static inline u32 atomicIncrement32(u32* p) { 12 | return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST); 13 | } 14 | 15 | /// Atomically decrements a 32-bit value. 16 | static inline u32 atomicDecrement32(u32* p) { 17 | return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST); 18 | } 19 | 20 | /// Atomically increments a 64-bit value. 21 | static inline u64 atomicIncrement64(u64* p) { 22 | return __atomic_fetch_add(p, 1, __ATOMIC_SEQ_CST); 23 | } 24 | 25 | /// Atomically decrements a 64-bit value. 26 | static inline u64 atomicDecrement64(u64* p) { 27 | return __atomic_sub_fetch(p, 1, __ATOMIC_SEQ_CST); 28 | } 29 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/arm/cache.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cache.h 3 | * @brief AArch64 cache operations. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /** 11 | * @brief Performs a data cache flush on the specified buffer. 12 | * @param addr Address of the buffer. 13 | * @param size Size of the buffer, in bytes. 14 | * @remarks Cache flush is defined as Clean + Invalidate. 15 | * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). 16 | */ 17 | void armDCacheFlush(void* addr, size_t size); 18 | 19 | /** 20 | * @brief Performs a data cache clean on the specified buffer. 21 | * @param addr Address of the buffer. 22 | * @param size Size of the buffer, in bytes. 23 | * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). 24 | */ 25 | void armDCacheClean(void* addr, size_t size); 26 | 27 | /** 28 | * @brief Performs an instruction cache invalidation clean on the specified buffer. 29 | * @param addr Address of the buffer. 30 | * @param size Size of the buffer, in bytes. 31 | * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). 32 | */ 33 | void armICacheInvalidate(void* addr, size_t size); 34 | 35 | /** 36 | * @brief Performs a data cache zeroing operation on the specified buffer. 37 | * @param addr Address of the buffer. 38 | * @param size Size of the buffer, in bytes. 39 | * @note The start and end addresses of the buffer are forcibly rounded to cache line boundaries (read from CTR_EL0 system register). 40 | */ 41 | void armDCacheZero(void* addr, size_t size); 42 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/arm/counter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file counter.h 3 | * @brief AArch64 system counter-timer. 4 | * @author fincs 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /** 11 | * @brief Gets the current system tick. 12 | * @return The current system tick. 13 | */ 14 | static inline u64 armGetSystemTick(void) { 15 | u64 ret; 16 | __asm__ __volatile__ ("mrs %x[data], cntpct_el0" : [data] "=r" (ret)); 17 | return ret; 18 | } 19 | 20 | /** 21 | * @brief Gets the system counter-timer frequency 22 | * @return The system counter-timer frequency, in Hz. 23 | */ 24 | static inline u64 armGetSystemTickFreq(void) { 25 | u64 ret; 26 | __asm__ ("mrs %x[data], cntfrq_el0" : [data] "=r" (ret)); 27 | return ret; 28 | } 29 | 30 | /** 31 | * @brief Converts from nanoseconds to CPU ticks unit. 32 | * @param ns Time in nanoseconds. 33 | * @return Time in CPU ticks. 34 | */ 35 | static inline u64 armNsToTicks(u64 ns) { 36 | return (ns * 12) / 625; 37 | } 38 | 39 | /** 40 | * @brief Converts from CPU ticks unit to nanoseconds. 41 | * @param tick Time in ticks. 42 | * @return Time in nanoseconds. 43 | */ 44 | static inline u64 armTicksToNs(u64 tick) { 45 | return (tick * 625) / 12; 46 | } 47 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/arm/thread_context.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file thread_context.h 3 | * @brief AArch64 register dump format and related definitions. 4 | * @author TuxSH 5 | * @copyright libnx Authors 6 | */ 7 | 8 | #pragma once 9 | #include "../types.h" 10 | 11 | /// Armv8 CPU register. 12 | typedef union { 13 | u64 x; ///< 64-bit AArch64 register view. 14 | u32 w; ///< 32-bit AArch64 register view. 15 | u32 r; ///< AArch32 register view. 16 | } CpuRegister; 17 | 18 | /// Armv8 NEON register. 19 | typedef union { 20 | u128 v; ///< 128-bit vector view. 21 | double d; ///< 64-bit double-precision view. 22 | float s; ///< 32-bit single-precision view. 23 | } FpuRegister; 24 | 25 | /// Armv8 register group. @ref svcGetThreadContext3 uses @ref RegisterGroup_All. 26 | typedef enum { 27 | RegisterGroup_CpuGprs = BIT(0), ///< General-purpose CPU registers (x0..x28 or r0..r10,r12). 28 | RegisterGroup_CpuSprs = BIT(1), ///< Special-purpose CPU registers (fp, lr, sp, pc, PSTATE or cpsr, TPIDR_EL0). 29 | RegisterGroup_FpuGprs = BIT(2), ///< General-purpose NEON registers. 30 | RegisterGroup_FpuSprs = BIT(3), ///< Special-purpose NEON registers. 31 | 32 | RegisterGroup_CpuAll = RegisterGroup_CpuGprs | RegisterGroup_CpuSprs, ///< All CPU registers. 33 | RegisterGroup_FpuAll = RegisterGroup_FpuGprs | RegisterGroup_FpuSprs, ///< All NEON registers. 34 | RegisterGroup_All = RegisterGroup_CpuAll | RegisterGroup_FpuAll, ///< All registers. 35 | } RegisterGroup; 36 | 37 | /// This is for \ref ThreadExceptionDump error_desc. 38 | typedef enum { 39 | ThreadExceptionDesc_InstructionAbort = 0x100, ///< Instruction abort 40 | ThreadExceptionDesc_MisalignedPC = 0x102, ///< Misaligned PC 41 | ThreadExceptionDesc_MisalignedSP = 0x103, ///< Misaligned SP 42 | ThreadExceptionDesc_SError = 0x106, ///< SError [not in 1.0.0?] 43 | ThreadExceptionDesc_BadSVC = 0x301, ///< Bad SVC 44 | ThreadExceptionDesc_Trap = 0x104, ///< Uncategorized, CP15RTTrap, CP15RRTTrap, CP14RTTrap, CP14RRTTrap, IllegalState, SystemRegisterTrap 45 | ThreadExceptionDesc_Other = 0x101, ///< None of the above, EC <= 0x34 and not a breakpoint 46 | } ThreadExceptionDesc; 47 | 48 | /// Thread context structure (register dump) 49 | typedef struct { 50 | CpuRegister cpu_gprs[29]; ///< GPRs 0..28. Note: also contains AArch32 SPRs. 51 | u64 fp; ///< Frame pointer (x29) (AArch64). For AArch32, check r11. 52 | u64 lr; ///< Link register (x30) (AArch64). For AArch32, check r14. 53 | u64 sp; ///< Stack pointer (AArch64). For AArch32, check r13. 54 | CpuRegister pc; ///< Program counter. 55 | u32 psr; ///< PSTATE or cpsr. 56 | 57 | FpuRegister fpu_gprs[32]; ///< 32 general-purpose NEON registers. 58 | u32 fpcr; ///< Floating-point control register. 59 | u32 fpsr; ///< Floating-point status register. 60 | 61 | u64 tpidr; ///< EL0 Read/Write Software Thread ID Register. 62 | } ThreadContext; 63 | 64 | /// Thread exception dump structure. 65 | typedef struct { 66 | u32 error_desc; ///< See \ref ThreadExceptionDesc. 67 | u32 pad[3]; 68 | 69 | CpuRegister cpu_gprs[29]; ///< GPRs 0..28. Note: also contains AArch32 registers. 70 | CpuRegister fp; ///< Frame pointer. 71 | CpuRegister lr; ///< Link register. 72 | CpuRegister sp; ///< Stack pointer. 73 | CpuRegister pc; ///< Program counter (elr_el1). 74 | 75 | u64 padding; 76 | 77 | FpuRegister fpu_gprs[32]; ///< 32 general-purpose NEON registers. 78 | 79 | u32 pstate; ///< pstate & 0xFF0FFE20 80 | u32 afsr0; 81 | u32 afsr1; 82 | u32 esr; 83 | 84 | CpuRegister far; ///< Fault Address Register. 85 | } ThreadExceptionDump; 86 | 87 | typedef struct { 88 | u64 cpu_gprs[9]; ///< GPRs 0..8. 89 | u64 lr; 90 | u64 sp; 91 | u64 elr_el1; 92 | u32 pstate; ///< pstate & 0xFF0FFE20 93 | u32 afsr0; 94 | u32 afsr1; 95 | u32 esr; 96 | u64 far; 97 | } ThreadExceptionFrameA64; 98 | 99 | typedef struct { 100 | u32 cpu_gprs[8]; ///< GPRs 0..7. 101 | u32 sp; 102 | u32 lr; 103 | u32 elr_el1; 104 | u32 tpidr_el0; ///< tpidr_el0 = 1 105 | u32 cpsr; ///< cpsr & 0xFF0FFE20 106 | u32 afsr0; 107 | u32 afsr1; 108 | u32 esr; 109 | u32 far; 110 | } ThreadExceptionFrameA32; 111 | 112 | /** 113 | * @brief Determines whether a thread context belong to an AArch64 process based on the PSR. 114 | * @param[in] ctx Thread context to which PSTATE/cspr has been dumped to. 115 | * @return true if and only if the thread context belongs to an AArch64 process. 116 | */ 117 | static inline bool threadContextIsAArch64(const ThreadContext *ctx) 118 | { 119 | return (ctx->psr & 0x10) == 0; 120 | } 121 | 122 | /** 123 | * @brief Determines whether a ThreadExceptionDump belongs to an AArch64 process based on the PSTATE. 124 | * @param[in] ctx ThreadExceptionDump. 125 | * @return true if and only if the ThreadExceptionDump belongs to an AArch64 process. 126 | */ 127 | static inline bool threadExceptionIsAArch64(const ThreadExceptionDump *ctx) 128 | { 129 | return (ctx->pstate & 0x10) == 0; 130 | } 131 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/arm/tls.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tls.h 3 | * @brief AArch64 thread local storage. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /** 11 | * @brief Gets the thread local storage buffer. 12 | * @return The thread local storage buffer. 13 | */ 14 | static inline void* armGetTls(void) { 15 | void* ret; 16 | __asm__ ("mrs %x[data], tpidrro_el0" : [data] "=r" (ret)); 17 | return ret; 18 | } 19 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/audio/audio.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file audio.h 3 | * @brief Global audio service. 4 | * @author hexkyz 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | 9 | #include "../types.h" 10 | 11 | typedef enum { 12 | PcmFormat_Invalid = 0, 13 | PcmFormat_Int8 = 1, 14 | PcmFormat_Int16 = 2, 15 | PcmFormat_Int24 = 3, 16 | PcmFormat_Int32 = 4, 17 | PcmFormat_Float = 5, 18 | PcmFormat_Adpcm = 6, 19 | } PcmFormat; 20 | 21 | typedef struct { 22 | char name[0x100]; 23 | } AudioDeviceName; 24 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/audio/driver.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file driver.h 3 | * @brief Audio driver (audren wrapper). 4 | * @author fincs 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../services/audren.h" 9 | 10 | typedef struct AudioDriverEtc AudioDriverEtc; 11 | 12 | typedef struct { 13 | AudioDriverEtc* etc; 14 | AudioRendererConfig config; 15 | AudioRendererMemPoolInfoIn* in_mempools; 16 | AudioRendererChannelInfoIn* in_channels; 17 | AudioRendererVoiceInfoIn* in_voices; 18 | AudioRendererMixInfoIn* in_mixes; 19 | AudioRendererSinkInfoIn* in_sinks; 20 | } AudioDriver; 21 | 22 | Result audrvCreate(AudioDriver* d, const AudioRendererConfig* config, int num_final_mix_channels); 23 | Result audrvUpdate(AudioDriver* d); 24 | void audrvClose(AudioDriver* d); 25 | 26 | //----------------------------------------------------------------------------- 27 | 28 | int audrvMemPoolAdd(AudioDriver* d, void* buffer, size_t size); 29 | bool audrvMemPoolRemove(AudioDriver* d, int id); 30 | bool audrvMemPoolAttach(AudioDriver* d, int id); 31 | bool audrvMemPoolDetach(AudioDriver* d, int id); 32 | 33 | //----------------------------------------------------------------------------- 34 | 35 | typedef enum { 36 | AudioDriverWaveBufState_Free, 37 | AudioDriverWaveBufState_Waiting, 38 | AudioDriverWaveBufState_Queued, 39 | AudioDriverWaveBufState_Playing, 40 | AudioDriverWaveBufState_Done, 41 | } AudioDriverWaveBufState; 42 | 43 | typedef struct AudioDriverWaveBuf AudioDriverWaveBuf; 44 | 45 | struct AudioDriverWaveBuf { 46 | union { 47 | s16* data_pcm16; 48 | u8* data_adpcm; 49 | const void* data_raw; 50 | }; 51 | u64 size; 52 | s32 start_sample_offset; 53 | s32 end_sample_offset; 54 | const void* context_addr; 55 | u64 context_sz; 56 | AudioDriverWaveBufState state : 8; 57 | bool is_looping; 58 | u32 sequence_id; 59 | AudioDriverWaveBuf* next; 60 | }; 61 | 62 | bool audrvVoiceInit(AudioDriver* d, int id, int num_channels, PcmFormat format, int sample_rate); 63 | void audrvVoiceDrop(AudioDriver* d, int id); 64 | void audrvVoiceStop(AudioDriver* d, int id); 65 | bool audrvVoiceIsPlaying(AudioDriver* d, int id); 66 | bool audrvVoiceAddWaveBuf(AudioDriver* d, int id, AudioDriverWaveBuf* wavebuf); 67 | u32 audrvVoiceGetWaveBufSeq(AudioDriver* d, int id); 68 | u32 audrvVoiceGetPlayedSampleCount(AudioDriver* d, int id); 69 | u32 audrvVoiceGetVoiceDropsCount(AudioDriver* d, int id); 70 | void audrvVoiceSetBiquadFilter(AudioDriver* d, int id, int biquad_id, float a0, float a1, float a2, float b0, float b1, float b2); 71 | 72 | static inline void audrvVoiceSetExtraParams(AudioDriver* d, int id, const void* params, size_t params_size) 73 | { 74 | d->in_voices[id].extra_params_ptr = params; 75 | d->in_voices[id].extra_params_sz = params_size; 76 | } 77 | 78 | static inline void audrvVoiceSetDestinationMix(AudioDriver* d, int id, int mix_id) 79 | { 80 | d->in_voices[id].dest_mix_id = mix_id; 81 | d->in_voices[id].dest_splitter_id = AUDREN_UNUSED_SPLITTER_ID; 82 | } 83 | 84 | static inline void audrvVoiceSetMixFactor(AudioDriver* d, int id, float factor, int src_channel_id, int dest_channel_id) 85 | { 86 | int channel_id = d->in_voices[id].channel_ids[src_channel_id]; 87 | d->in_channels[channel_id].mix[dest_channel_id] = factor; 88 | } 89 | 90 | static inline void audrvVoiceSetVolume(AudioDriver* d, int id, float volume) 91 | { 92 | d->in_voices[id].volume = volume; 93 | } 94 | 95 | static inline void audrvVoiceSetPitch(AudioDriver* d, int id, float pitch) 96 | { 97 | d->in_voices[id].pitch = pitch; 98 | } 99 | 100 | static inline void audrvVoiceSetPriority(AudioDriver* d, int id, int priority) 101 | { 102 | d->in_voices[id].priority = priority; 103 | } 104 | 105 | static inline void audrvVoiceClearBiquadFilter(AudioDriver* d, int id, int biquad_id) 106 | { 107 | d->in_voices[id].biquads[biquad_id].enable = false; 108 | } 109 | 110 | static inline void audrvVoiceSetPaused(AudioDriver* d, int id, bool paused) 111 | { 112 | d->in_voices[id].state = paused ? AudioRendererVoicePlayState_Paused : AudioRendererVoicePlayState_Started; 113 | } 114 | 115 | static inline void audrvVoiceStart(AudioDriver* d, int id) 116 | { 117 | audrvVoiceSetPaused(d, id, false); 118 | } 119 | 120 | //----------------------------------------------------------------------------- 121 | 122 | int audrvMixAdd(AudioDriver* d, int sample_rate, int num_channels); 123 | void audrvMixRemove(AudioDriver* d, int id); 124 | 125 | static inline void audrvMixSetDestinationMix(AudioDriver* d, int id, int mix_id) 126 | { 127 | d->in_mixes[id].dest_mix_id = mix_id; 128 | d->in_mixes[id].dest_splitter_id = AUDREN_UNUSED_SPLITTER_ID; 129 | } 130 | 131 | static inline void audrvMixSetMixFactor(AudioDriver* d, int id, float factor, int src_channel_id, int dest_channel_id) 132 | { 133 | d->in_mixes[id].mix[src_channel_id][dest_channel_id] = factor; 134 | } 135 | 136 | static inline void audrvMixSetVolume(AudioDriver* d, int id, float volume) 137 | { 138 | d->in_mixes[id].volume = volume; 139 | } 140 | 141 | //----------------------------------------------------------------------------- 142 | 143 | int audrvDeviceSinkAdd(AudioDriver* d, const char* device_name, int num_channels, const u8* channel_ids); 144 | void audrvSinkRemove(AudioDriver* d, int id); 145 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/aes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file aes.h 3 | * @brief Hardware accelerated AES-ECB implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "../types.h" 8 | 9 | #ifndef AES_BLOCK_SIZE 10 | #define AES_BLOCK_SIZE 0x10 11 | #endif 12 | #ifndef AES_128_KEY_SIZE 13 | #define AES_128_KEY_SIZE 0x10 14 | #endif 15 | #ifndef AES_128_U32_PER_KEY 16 | #define AES_128_U32_PER_KEY (AES_128_KEY_SIZE / sizeof(u32)) 17 | #endif 18 | #ifndef AES_128_NUM_ROUNDS 19 | #define AES_128_NUM_ROUNDS 10 20 | #endif 21 | #ifndef AES_192_KEY_SIZE 22 | #define AES_192_KEY_SIZE 0x18 23 | #endif 24 | #ifndef AES_192_U32_PER_KEY 25 | #define AES_192_U32_PER_KEY (AES_192_KEY_SIZE / sizeof(u32)) 26 | #endif 27 | #ifndef AES_192_NUM_ROUNDS 28 | #define AES_192_NUM_ROUNDS 12 29 | #endif 30 | #ifndef AES_256_KEY_SIZE 31 | #define AES_256_KEY_SIZE 0x20 32 | #endif 33 | #ifndef AES_256_U32_PER_KEY 34 | #define AES_256_U32_PER_KEY (AES_256_KEY_SIZE / sizeof(u32)) 35 | #endif 36 | #ifndef AES_256_NUM_ROUNDS 37 | #define AES_256_NUM_ROUNDS 14 38 | #endif 39 | 40 | /// Context for AES-128 operations. 41 | typedef struct { 42 | u8 round_keys[AES_128_NUM_ROUNDS+1][AES_BLOCK_SIZE]; 43 | } Aes128Context; 44 | 45 | /// Context for AES-192 operations. 46 | typedef struct { 47 | u8 round_keys[AES_192_NUM_ROUNDS+1][AES_BLOCK_SIZE]; 48 | } Aes192Context; 49 | 50 | /// Context for AES-256 operations. 51 | typedef struct { 52 | u8 round_keys[AES_256_NUM_ROUNDS+1][AES_BLOCK_SIZE]; 53 | } Aes256Context; 54 | 55 | /// Initialize a 128-bit AES context. 56 | void aes128ContextCreate(Aes128Context *out, const void *key, bool is_encryptor); 57 | /// Encrypt using an AES context (Requires is_encryptor when initializing) 58 | void aes128EncryptBlock(const Aes128Context *ctx, void *dst, const void *src); 59 | /// Decrypt using an AES context (Requires !is_encryptor when initializing) 60 | void aes128DecryptBlock(const Aes128Context *ctx, void *dst, const void *src); 61 | 62 | /// Initialize a 192-bit AES context. 63 | void aes192ContextCreate(Aes192Context *out, const void *key, bool is_encryptor); 64 | /// Encrypt using an AES context (Requires is_encryptor when initializing) 65 | void aes192EncryptBlock(const Aes192Context *ctx, void *dst, const void *src); 66 | /// Decrypt using an AES context (Requires !is_encryptor when initializing) 67 | void aes192DecryptBlock(const Aes192Context *ctx, void *dst, const void *src); 68 | 69 | /// Initialize a 256-bit AES context. 70 | void aes256ContextCreate(Aes256Context *out, const void *key, bool is_encryptor); 71 | /// Encrypt using an AES context (Requires is_encryptor when initializing) 72 | void aes256EncryptBlock(const Aes256Context *ctx, void *dst, const void *src); 73 | /// Decrypt using an AES context (Requires !is_encryptor when initializing) 74 | void aes256DecryptBlock(const Aes256Context *ctx, void *dst, const void *src); 75 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/aes_cbc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file aes_cbc.h 3 | * @brief Hardware accelerated AES-CBC implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "aes.h" 8 | 9 | /// Context for AES-128 CBC. 10 | typedef struct { 11 | Aes128Context aes_ctx; 12 | u8 iv[AES_BLOCK_SIZE]; 13 | u8 buffer[AES_BLOCK_SIZE]; 14 | size_t num_buffered; 15 | } Aes128CbcContext; 16 | 17 | /// Context for AES-192 CBC. 18 | typedef struct { 19 | Aes192Context aes_ctx; 20 | u8 iv[AES_BLOCK_SIZE]; 21 | u8 buffer[AES_BLOCK_SIZE]; 22 | size_t num_buffered; 23 | } Aes192CbcContext; 24 | 25 | /// Context for AES-256 CBC. 26 | typedef struct { 27 | Aes256Context aes_ctx; 28 | u8 iv[AES_BLOCK_SIZE]; 29 | u8 buffer[AES_BLOCK_SIZE]; 30 | size_t num_buffered; 31 | } Aes256CbcContext; 32 | 33 | /// 128-bit CBC API. 34 | void aes128CbcContextCreate(Aes128CbcContext *out, const void *key, const void *iv, bool is_encryptor); 35 | void aes128CbcContextResetIv(Aes128CbcContext *ctx, const void *iv); 36 | size_t aes128CbcEncrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size); 37 | size_t aes128CbcDecrypt(Aes128CbcContext *ctx, void *dst, const void *src, size_t size); 38 | 39 | /// 192-bit CBC API. 40 | void aes192CbcContextCreate(Aes192CbcContext *out, const void *key, const void *iv, bool is_encryptor); 41 | void aes192CbcContextResetIv(Aes192CbcContext *ctx, const void *iv); 42 | size_t aes192CbcEncrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size); 43 | size_t aes192CbcDecrypt(Aes192CbcContext *ctx, void *dst, const void *src, size_t size); 44 | 45 | /// 256-bit CBC API. 46 | void aes256CbcContextCreate(Aes256CbcContext *out, const void *key, const void *iv, bool is_encryptor); 47 | void aes256CbcContextResetIv(Aes256CbcContext *ctx, const void *iv); 48 | size_t aes256CbcEncrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size); 49 | size_t aes256CbcDecrypt(Aes256CbcContext *ctx, void *dst, const void *src, size_t size); 50 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/aes_ctr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file aes_ctr.h 3 | * @brief Hardware accelerated AES-CTR implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "aes.h" 8 | 9 | /// Context for AES-128 CTR. 10 | typedef struct { 11 | Aes128Context aes_ctx; 12 | u8 ctr[AES_BLOCK_SIZE]; 13 | u8 enc_ctr_buffer[AES_BLOCK_SIZE]; 14 | size_t buffer_offset; 15 | } Aes128CtrContext; 16 | 17 | /// Context for AES-192 CTR. 18 | typedef struct { 19 | Aes192Context aes_ctx; 20 | u8 ctr[AES_BLOCK_SIZE]; 21 | u8 enc_ctr_buffer[AES_BLOCK_SIZE]; 22 | size_t buffer_offset; 23 | } Aes192CtrContext; 24 | 25 | /// Context for AES-256 CTR. 26 | typedef struct { 27 | Aes256Context aes_ctx; 28 | u8 ctr[AES_BLOCK_SIZE]; 29 | u8 enc_ctr_buffer[AES_BLOCK_SIZE]; 30 | size_t buffer_offset; 31 | } Aes256CtrContext; 32 | 33 | /// 128-bit CTR API. 34 | void aes128CtrContextCreate(Aes128CtrContext *out, const void *key, const void *ctr); 35 | void aes128CtrContextResetCtr(Aes128CtrContext *ctx, const void *ctr); 36 | void aes128CtrCrypt(Aes128CtrContext *ctx, void *dst, const void *src, size_t size); 37 | 38 | /// 192-bit CTR API. 39 | void aes192CtrContextCreate(Aes192CtrContext *out, const void *key, const void *ctr); 40 | void aes192CtrContextResetCtr(Aes192CtrContext *ctx, const void *ctr); 41 | void aes192CtrCrypt(Aes192CtrContext *ctx, void *dst, const void *src, size_t size); 42 | 43 | /// 256-bit CTR API. 44 | void aes256CtrContextCreate(Aes256CtrContext *out, const void *key, const void *ctr); 45 | void aes256CtrContextResetCtr(Aes256CtrContext *ctx, const void *ctr); 46 | void aes256CtrCrypt(Aes256CtrContext *ctx, void *dst, const void *src, size_t size); 47 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/aes_xts.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file aes_xts.h 3 | * @brief Hardware accelerated AES-XTS implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "aes.h" 8 | 9 | /// Context for AES-128 XTS. 10 | typedef struct { 11 | Aes128Context aes_ctx; 12 | Aes128Context tweak_ctx; 13 | u8 tweak[AES_BLOCK_SIZE]; 14 | u8 buffer[AES_BLOCK_SIZE]; 15 | size_t num_buffered; 16 | } Aes128XtsContext; 17 | 18 | /// Context for AES-192 XTS. 19 | typedef struct { 20 | Aes192Context aes_ctx; 21 | Aes192Context tweak_ctx; 22 | u8 tweak[AES_BLOCK_SIZE]; 23 | u8 buffer[AES_BLOCK_SIZE]; 24 | size_t num_buffered; 25 | } Aes192XtsContext; 26 | 27 | /// Context for AES-256 XTS. 28 | typedef struct { 29 | Aes256Context aes_ctx; 30 | Aes256Context tweak_ctx; 31 | u8 tweak[AES_BLOCK_SIZE]; 32 | u8 buffer[AES_BLOCK_SIZE]; 33 | size_t num_buffered; 34 | } Aes256XtsContext; 35 | 36 | /// 128-bit XTS API. 37 | void aes128XtsContextCreate(Aes128XtsContext *out, const void *key0, const void *key1, bool is_encryptor); 38 | void aes128XtsContextResetTweak(Aes128XtsContext *ctx, const void *tweak); 39 | void aes128XtsContextResetSector(Aes128XtsContext *ctx, uint64_t sector, bool is_nintendo); 40 | size_t aes128XtsEncrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size); 41 | size_t aes128XtsDecrypt(Aes128XtsContext *ctx, void *dst, const void *src, size_t size); 42 | 43 | /// 192-bit XTS API. 44 | void aes192XtsContextCreate(Aes192XtsContext *out, const void *key0, const void *key1, bool is_encryptor); 45 | void aes192XtsContextResetTweak(Aes192XtsContext *ctx, const void *tweak); 46 | void aes192XtsContextResetSector(Aes192XtsContext *ctx, uint64_t sector, bool is_nintendo); 47 | size_t aes192XtsEncrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size); 48 | size_t aes192XtsDecrypt(Aes192XtsContext *ctx, void *dst, const void *src, size_t size); 49 | 50 | /// 256-bit XTS API. 51 | void aes256XtsContextCreate(Aes256XtsContext *out, const void *key0, const void *key1, bool is_encryptor); 52 | void aes256XtsContextResetTweak(Aes256XtsContext *ctx, const void *tweak); 53 | void aes256XtsContextResetSector(Aes256XtsContext *ctx, uint64_t sector, bool is_nintendo); 54 | size_t aes256XtsEncrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size); 55 | size_t aes256XtsDecrypt(Aes256XtsContext *ctx, void *dst, const void *src, size_t size); 56 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/cmac.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file cmac.h 3 | * @brief Hardware accelerated AES-CMAC implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "aes.h" 8 | 9 | /// Context for AES-128 CMAC. 10 | typedef struct { 11 | Aes128Context ctx; 12 | u8 subkey[AES_BLOCK_SIZE]; 13 | u8 mac[AES_BLOCK_SIZE]; 14 | u8 buffer[AES_BLOCK_SIZE]; 15 | size_t num_buffered; 16 | bool finalized; 17 | } Aes128CmacContext; 18 | 19 | /// Context for AES-192 CMAC. 20 | typedef struct { 21 | Aes192Context ctx; 22 | u8 subkey[AES_BLOCK_SIZE]; 23 | u8 mac[AES_BLOCK_SIZE]; 24 | u8 buffer[AES_BLOCK_SIZE]; 25 | size_t num_buffered; 26 | bool finalized; 27 | } Aes192CmacContext; 28 | 29 | /// Context for AES-256 CMAC. 30 | typedef struct { 31 | Aes256Context ctx; 32 | u8 subkey[AES_BLOCK_SIZE]; 33 | u8 mac[AES_BLOCK_SIZE]; 34 | u8 buffer[AES_BLOCK_SIZE]; 35 | size_t num_buffered; 36 | bool finalized; 37 | } Aes256CmacContext; 38 | 39 | /// Initialize an AES-128-CMAC context. 40 | void cmacAes128ContextCreate(Aes128CmacContext *out, const void *key); 41 | /// Updates AES-128-CMAC context with data to hash 42 | void cmacAes128ContextUpdate(Aes128CmacContext *ctx, const void *src, size_t size); 43 | /// Gets the context's output mac, finalizes the context. 44 | void cmacAes128ContextGetMac(Aes128CmacContext *ctx, void *dst); 45 | 46 | /// Simple all-in-one AES-128-CMAC calculator. 47 | void cmacAes128CalculateMac(void *dst, const void *key, const void *src, size_t size); 48 | 49 | /// Initialize an AES-192-CMAC context. 50 | void cmacAes192ContextCreate(Aes192CmacContext *out, const void *key); 51 | /// Updates AES-192-CMAC context with data to hash 52 | void cmacAes192ContextUpdate(Aes192CmacContext *ctx, const void *src, size_t size); 53 | /// Gets the context's output mac, finalizes the context. 54 | void cmacAes192ContextGetMac(Aes192CmacContext *ctx, void *dst); 55 | 56 | /// Simple all-in-one AES-192-CMAC calculator. 57 | void cmacAes192CalculateMac(void *dst, const void *key, const void *src, size_t size); 58 | 59 | /// Initialize an AES-256-CMAC context. 60 | void cmacAes256ContextCreate(Aes256CmacContext *out, const void *key); 61 | /// Updates AES-256-CMAC context with data to hash 62 | void cmacAes256ContextUpdate(Aes256CmacContext *ctx, const void *src, size_t size); 63 | /// Gets the context's output mac, finalizes the context. 64 | void cmacAes256ContextGetMac(Aes256CmacContext *ctx, void *dst); 65 | 66 | /// Simple all-in-one AES-256-CMAC calculator. 67 | void cmacAes256CalculateMac(void *dst, const void *key, const void *src, size_t size); 68 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/crc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file crc.h 3 | * @brief Hardware accelerated CRC32 implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include 8 | #include "../types.h" 9 | 10 | #define _CRC_ALIGN(sz, insn) \ 11 | do { \ 12 | if (((uintptr_t)src_u8 & sizeof(sz)) && (u64)len >= sizeof(sz)) { \ 13 | crc = __crc32##insn(crc, *((const sz *)src_u8)); \ 14 | src_u8 += sizeof(sz); \ 15 | len -= sizeof(sz); \ 16 | } \ 17 | } while (0) 18 | 19 | #define _CRC_REMAINDER(sz, insn) \ 20 | do { \ 21 | if (len & sizeof(sz)) { \ 22 | crc = __crc32##insn(crc, *((const sz *)src_u8)); \ 23 | src_u8 += sizeof(sz); \ 24 | } \ 25 | } while (0) 26 | 27 | /// Calculate a CRC32 over data. 28 | static inline u32 crc32Calculate(const void *src, size_t size) { 29 | const u8 *src_u8 = (const u8 *)src; 30 | 31 | u32 crc = 0xFFFFFFFF; 32 | s64 len = size; 33 | 34 | _CRC_ALIGN(u8, b); 35 | _CRC_ALIGN(u16, h); 36 | _CRC_ALIGN(u32, w); 37 | 38 | while ((len -= sizeof(u64)) >= 0) { 39 | crc = __crc32d(crc, *((const u64 *)src_u8)); 40 | src_u8 += sizeof(u64); 41 | } 42 | 43 | _CRC_REMAINDER(u32, w); 44 | _CRC_REMAINDER(u16, h); 45 | _CRC_REMAINDER(u8, b); 46 | 47 | return crc ^ 0xFFFFFFFF; 48 | } 49 | 50 | /// Calculate a CRC32C over data. 51 | static inline u32 crc32cCalculate(const void *src, size_t size) { 52 | const u8 *src_u8 = (const u8 *)src; 53 | 54 | u32 crc = 0xFFFFFFFF; 55 | s64 len = size; 56 | 57 | _CRC_ALIGN(u8, cb); 58 | _CRC_ALIGN(u16, ch); 59 | _CRC_ALIGN(u32, cw); 60 | 61 | while ((len -= sizeof(u64)) >= 0) { 62 | crc = __crc32cd(crc, *((const u64 *)src_u8)); 63 | src_u8 += sizeof(u64); 64 | } 65 | 66 | _CRC_REMAINDER(u32, cw); 67 | _CRC_REMAINDER(u16, ch); 68 | _CRC_REMAINDER(u8, cb); 69 | 70 | return crc ^ 0xFFFFFFFF; 71 | } 72 | 73 | #undef _CRC_REMAINDER 74 | #undef _CRC_ALIGN 75 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/hmac.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hmac.h 3 | * @brief Hardware accelerated HMAC-SHA(1, 256) implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "sha1.h" 8 | #include "sha256.h" 9 | 10 | /// Context for HMAC-SHA1 operations. 11 | typedef struct { 12 | Sha1Context sha_ctx; 13 | u32 key[SHA1_BLOCK_SIZE / sizeof(u32)]; 14 | u32 mac[SHA1_HASH_SIZE / sizeof(u32)]; 15 | bool finalized; 16 | } HmacSha1Context; 17 | 18 | /// Context for HMAC-SHA256 operations. 19 | typedef struct { 20 | Sha256Context sha_ctx; 21 | u32 key[SHA256_BLOCK_SIZE / sizeof(u32)]; 22 | u32 mac[SHA256_HASH_SIZE / sizeof(u32)]; 23 | bool finalized; 24 | } HmacSha256Context; 25 | 26 | #ifndef HMAC_SHA1_KEY_MAX 27 | #define HMAC_SHA1_KEY_MAX (sizeof(((HmacSha1Context *)NULL)->key)) 28 | #endif 29 | #ifndef HMAC_SHA256_KEY_MAX 30 | #define HMAC_SHA256_KEY_MAX (sizeof(((HmacSha256Context *)NULL)->key)) 31 | #endif 32 | 33 | /// Initialize a HMAC-SHA256 context. 34 | void hmacSha256ContextCreate(HmacSha256Context *out, const void *key, size_t key_size); 35 | /// Updates HMAC-SHA256 context with data to hash 36 | void hmacSha256ContextUpdate(HmacSha256Context *ctx, const void *src, size_t size); 37 | /// Gets the context's output mac, finalizes the context. 38 | void hmacSha256ContextGetMac(HmacSha256Context *ctx, void *dst); 39 | 40 | /// Simple all-in-one HMAC-SHA256 calculator. 41 | void hmacSha256CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size); 42 | 43 | /// Initialize a HMAC-SHA1 context. 44 | void hmacSha1ContextCreate(HmacSha1Context *out, const void *key, size_t key_size); 45 | /// Updates HMAC-SHA1 context with data to hash 46 | void hmacSha1ContextUpdate(HmacSha1Context *ctx, const void *src, size_t size); 47 | /// Gets the context's output mac, finalizes the context. 48 | void hmacSha1ContextGetMac(HmacSha1Context *ctx, void *dst); 49 | 50 | /// Simple all-in-one HMAC-SHA1 calculator. 51 | void hmacSha1CalculateMac(void *dst, const void *key, size_t key_size, const void *src, size_t size); 52 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/sha1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sha1.h 3 | * @brief Hardware accelerated SHA1 implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "../types.h" 8 | 9 | #ifndef SHA1_HASH_SIZE 10 | #define SHA1_HASH_SIZE 0x14 11 | #endif 12 | 13 | #ifndef SHA1_BLOCK_SIZE 14 | #define SHA1_BLOCK_SIZE 0x40 15 | #endif 16 | 17 | /// Context for SHA1 operations. 18 | typedef struct { 19 | u32 intermediate_hash[SHA1_HASH_SIZE / sizeof(u32)]; 20 | u8 buffer[SHA1_BLOCK_SIZE]; 21 | u64 bits_consumed; 22 | size_t num_buffered; 23 | bool finalized; 24 | } Sha1Context; 25 | 26 | /// Initialize a SHA1 context. 27 | void sha1ContextCreate(Sha1Context *out); 28 | /// Updates SHA1 context with data to hash 29 | void sha1ContextUpdate(Sha1Context *ctx, const void *src, size_t size); 30 | /// Gets the context's output hash, finalizes the context. 31 | void sha1ContextGetHash(Sha1Context *ctx, void *dst); 32 | 33 | /// Simple all-in-one SHA1 calculator. 34 | void sha1CalculateHash(void *dst, const void *src, size_t size); 35 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/crypto/sha256.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sha256.h 3 | * @brief Hardware accelerated SHA256 implementation. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | #include "../types.h" 8 | 9 | 10 | #ifndef SHA256_HASH_SIZE 11 | #define SHA256_HASH_SIZE 0x20 12 | #endif 13 | 14 | #ifndef SHA256_BLOCK_SIZE 15 | #define SHA256_BLOCK_SIZE 0x40 16 | #endif 17 | 18 | /// Context for SHA256 operations. 19 | typedef struct { 20 | u32 intermediate_hash[SHA256_HASH_SIZE / sizeof(u32)]; 21 | u8 buffer[SHA256_BLOCK_SIZE]; 22 | u64 bits_consumed; 23 | size_t num_buffered; 24 | bool finalized; 25 | } Sha256Context; 26 | 27 | /// Initialize a SHA256 context. 28 | void sha256ContextCreate(Sha256Context *out); 29 | /// Updates SHA256 context with data to hash 30 | void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size); 31 | /// Gets the context's output hash, finalizes the context. 32 | void sha256ContextGetHash(Sha256Context *ctx, void *dst); 33 | 34 | /// Simple all-in-one SHA256 calculator. 35 | void sha256CalculateHash(void *dst, const void *src, size_t size); 36 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/barrier.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file barrier.h 3 | * @brief Multi-threading Barrier 4 | * @author tatehaga 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "mutex.h" 9 | #include "condvar.h" 10 | 11 | /// Barrier structure. 12 | typedef struct Barrier { 13 | u64 count; ///< Number of threads to reach the barrier. 14 | u64 total; ///< Number of threads to wait on. 15 | Mutex mutex; 16 | CondVar condvar; 17 | } Barrier; 18 | 19 | /** 20 | * @brief Initializes a barrier and the number of threads to wait on. 21 | * @param b Barrier object. 22 | * @param thread_count Initial value for the number of threads the barrier must wait for. 23 | */ 24 | void barrierInit(Barrier *b, u64 thread_count); 25 | 26 | /** 27 | * @brief Forces threads to wait until all threads have called barrierWait. 28 | * @param b Barrier object. 29 | */ 30 | void barrierWait(Barrier *b); 31 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/condvar.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file condvar.h 3 | * @brief Condition variable synchronization primitive. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../kernel/svc.h" 10 | #include "../kernel/mutex.h" 11 | 12 | /// Condition variable. 13 | typedef u32 CondVar; 14 | 15 | /** 16 | * @brief Initializes a condition variable. 17 | * @param[in] c Condition variable object. 18 | */ 19 | static inline void condvarInit(CondVar* c) 20 | { 21 | *c = 0; 22 | } 23 | 24 | /** 25 | * @brief Waits on a condition variable with a timeout. 26 | * @param[in] c Condition variable object. 27 | * @param[in] m Mutex object to use inside the condition variable. 28 | * @param[in] timeout Timeout in nanoseconds. 29 | * @return Result code (0xEA01 on timeout). 30 | * @remark On function return, the underlying mutex is acquired. 31 | */ 32 | Result condvarWaitTimeout(CondVar* c, Mutex* m, u64 timeout); 33 | 34 | /** 35 | * @brief Waits on a condition variable. 36 | * @param[in] c Condition variable object. 37 | * @param[in] m Mutex object to use inside the condition variable. 38 | * @return Result code. 39 | * @remark On function return, the underlying mutex is acquired. 40 | */ 41 | static inline Result condvarWait(CondVar* c, Mutex* m) 42 | { 43 | return condvarWaitTimeout(c, m, U64_MAX); 44 | } 45 | 46 | /** 47 | * @brief Wakes up up to the specified number of threads waiting on a condition variable. 48 | * @param[in] c Condition variable object. 49 | * @param[in] num Maximum number of threads to wake up (or -1 to wake them all up). 50 | * @return Result code. 51 | */ 52 | static inline Result condvarWake(CondVar* c, int num) 53 | { 54 | return svcSignalProcessWideKey(c, num); 55 | } 56 | 57 | /** 58 | * @brief Wakes up a single thread waiting on a condition variable. 59 | * @param[in] c Condition variable object. 60 | * @return Result code. 61 | */ 62 | static inline Result condvarWakeOne(CondVar* c) 63 | { 64 | return condvarWake(c, 1); 65 | } 66 | 67 | /** 68 | * @brief Wakes up all thread waiting on a condition variable. 69 | * @param[in] c Condition variable object. 70 | * @return Result code. 71 | */ 72 | static inline Result condvarWakeAll(CondVar* c) 73 | { 74 | return condvarWake(c, -1); 75 | } 76 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/detect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file detect.h 3 | * @brief Kernel capability detection 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// Returns the kernel version that can be detected by checking kernel capabilities. This only goes from 1 (representing 1.0.0) up to 6 (representing 6.0.0 and above). Generally, \ref hosversionGet should be used instead of this function. 11 | int detectKernelVersion(void); 12 | /// Returns true if the process has a debugger attached. 13 | bool detectDebugger(void); 14 | /// Returns true if the kernel is patched to allow self-process-jit. 15 | bool detectJitKernelPatch(void); 16 | /// After this has been called, libnx will ignore the self-process-jit kernel patch. For testing purposes only. 17 | void detectIgnoreJitKernelPatch(void); 18 | 19 | /// Returns true if the kernel version is equal to or above 2.0.0. Generally, \ref hosversionAtLeast should be used instead of this function. 20 | static inline bool kernelAbove200(void) { 21 | return detectKernelVersion() >= 2; 22 | } 23 | 24 | /// Returns true if the kernel version is equal to or above 3.0.0. Generally, \ref hosversionAtLeast should be used instead of this function. 25 | static inline bool kernelAbove300(void) { 26 | return detectKernelVersion() >= 3; 27 | } 28 | 29 | /// Returns true if the kernel version is equal to or above 4.0.0. Generally, \ref hosversionAtLeast should be used instead of this function. 30 | static inline bool kernelAbove400(void) { 31 | return detectKernelVersion() >= 4; 32 | } 33 | 34 | /// Returns true if the kernel version is equal to or above 5.0.0. Generally, \ref hosversionAtLeast should be used instead of this function. 35 | static inline bool kernelAbove500(void) { 36 | return detectKernelVersion() >= 5; 37 | } 38 | 39 | /// Returns true if the kernel version is equal to or above 6.0.0. Generally, \ref hosversionAtLeast should be used instead of this function. 40 | static inline bool kernelAbove600(void) { 41 | return detectKernelVersion() >= 6; 42 | } 43 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/event.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file event.h 3 | * @brief Kernel-mode event synchronization primitive. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../result.h" 10 | #include "wait.h" 11 | 12 | /// Kernel-mode event structure. 13 | typedef struct { 14 | Handle revent; ///< Read-only event handle 15 | Handle wevent; ///< Write-only event handle 16 | bool autoclear; ///< Autoclear flag 17 | } Event; 18 | 19 | /// Creates a \ref Waiter for a kernel-mode event. 20 | static inline Waiter waiterForEvent(Event* t) 21 | { 22 | Waiter wait_obj; 23 | wait_obj.type = t->autoclear ? WaiterType_HandleWithClear : WaiterType_Handle; 24 | wait_obj.handle = t->revent; 25 | return wait_obj; 26 | } 27 | 28 | /** 29 | * @brief Creates a kernel-mode event. 30 | * @param[out] t Pointer to \ref Event structure. 31 | * @param[in] autoclear Autoclear flag. 32 | * @return Result code. 33 | * @warning This is a privileged operation; in normal circumstances applications shouldn't use this function. 34 | */ 35 | Result eventCreate(Event* t, bool autoclear); 36 | 37 | /** 38 | * @brief Loads a kernel-mode event obtained from IPC. 39 | * @param[out] t Pointer to \ref Event structure. 40 | * @param[in] handle Read-only event handle. 41 | * @param[in] autoclear Autoclear flag. 42 | */ 43 | void eventLoadRemote(Event* t, Handle handle, bool autoclear); 44 | 45 | /** 46 | * @brief Closes a kernel-mode event. 47 | * @param[in] t Pointer to \ref Event structure. 48 | */ 49 | void eventClose(Event* t); 50 | 51 | /** 52 | * @brief Returns whether an \ref Event is initialized. 53 | * @param[in] t Pointer to \ref Event structure. 54 | * @return Initialization status. 55 | */ 56 | static inline bool eventActive(Event* t) 57 | { 58 | return t->revent != INVALID_HANDLE; 59 | } 60 | 61 | /** 62 | * @brief Waits on a kernel-mode event. 63 | * @param[in] t Pointer to \ref Event structure. 64 | * @param[in] timeout Timeout in nanoseconds (pass UINT64_MAX to wait indefinitely). 65 | * @return Result code. 66 | */ 67 | Result eventWait(Event* t, u64 timeout); 68 | 69 | /** 70 | * @brief Signals a kernel-mode event. 71 | * @param[in] t Pointer to \ref Event structure. 72 | * @return Result code. 73 | * @note This function only works for events initialized with \ref eventCreate, it doesn't work with events initialized with \ref eventLoadRemote. 74 | * @warning This is a privileged operation; in normal circumstances applications shouldn't use this function. 75 | */ 76 | Result eventFire(Event* t); 77 | 78 | /** 79 | * @brief Clears a kernel-mode event. 80 | * @param[in] t Pointer to \ref Event structure. 81 | * @return Result code. 82 | * @note This function shouldn't be used on autoclear events. 83 | */ 84 | Result eventClear(Event* t); 85 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/jit.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file jit.h 3 | * @brief Just-in-time compilation support. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// JIT implementation type. 11 | typedef enum { 12 | JitType_CodeMemory, ///< JIT supported using svcSetProcessMemoryPermission 13 | JitType_JitMemory, ///< JIT supported using 4.0.0+ code-memory syscalls (this isn't usable on 5.0.0+ so JitType_CodeMemory is used instead). 14 | } JitType; 15 | 16 | /// JIT buffer object. 17 | typedef struct { 18 | JitType type; 19 | size_t size; 20 | void* src_addr; 21 | void* rx_addr; 22 | void* rw_addr; 23 | bool is_executable; 24 | Handle handle; 25 | } Jit; 26 | 27 | /** 28 | * @brief Creates a JIT buffer. 29 | * @param j JIT buffer. 30 | * @param size Size of the JIT buffer. 31 | * @return Result code. 32 | */ 33 | Result jitCreate(Jit* j, size_t size); 34 | 35 | /** 36 | * @brief Transition a JIT buffer to have writable permission. 37 | * @param j JIT buffer. 38 | * @return Result code. 39 | */ 40 | Result jitTransitionToWritable(Jit* j); 41 | 42 | /** 43 | * @brief Transition a JIT buffer to have executable permission. 44 | * @param j JIT buffer. 45 | * @return Result code. 46 | */ 47 | Result jitTransitionToExecutable(Jit* j); 48 | 49 | /** 50 | * @brief Destroys a JIT buffer. 51 | * @param j JIT buffer. 52 | * @return Result code. 53 | */ 54 | Result jitClose(Jit* j); 55 | 56 | /** 57 | * @brief Gets the address of the writable memory alias of a JIT buffer. 58 | * @param j JIT buffer. 59 | * @return Pointer to alias of the JIT buffer that can be written to. 60 | */ 61 | void* jitGetRwAddr(Jit* j); 62 | 63 | /** 64 | * @brief Gets the address of the executable memory alias of a JIT buffer. 65 | * @param j JIT buffer. 66 | * @return Pointer to alias of the JIT buffer that can be executed. 67 | */ 68 | void* jitGetRxAddr(Jit* j); 69 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/mutex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file mutex.h 3 | * @brief Mutex synchronization primitive. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include 9 | #include "../types.h" 10 | 11 | /// Mutex datatype, defined in newlib. 12 | typedef _LOCK_T Mutex; 13 | /// Recursive mutex datatype, defined in newlib. 14 | typedef _LOCK_RECURSIVE_T RMutex; 15 | 16 | /** 17 | * @brief Initializes a mutex. 18 | * @param m Mutex object. 19 | * @note A mutex can also be statically initialized by assigning 0 to it. 20 | */ 21 | static inline void mutexInit(Mutex* m) 22 | { 23 | *m = 0; 24 | } 25 | 26 | /** 27 | * @brief Locks a mutex. 28 | * @param m Mutex object. 29 | */ 30 | void mutexLock(Mutex* m); 31 | 32 | /** 33 | * @brief Attempts to lock a mutex without waiting. 34 | * @param m Mutex object. 35 | * @return 1 if the mutex has been acquired successfully, and 0 on contention. 36 | */ 37 | bool mutexTryLock(Mutex* m); 38 | 39 | /** 40 | * @brief Unlocks a mutex. 41 | * @param m Mutex object. 42 | */ 43 | void mutexUnlock(Mutex* m); 44 | 45 | /** 46 | * @brief Initializes a recursive mutex. 47 | * @param m Recursive mutex object. 48 | * @note A recursive mutex can also be statically initialized by assigning {0,0,0} to it. 49 | */ 50 | static inline void rmutexInit(RMutex* m) 51 | { 52 | m->lock = 0; 53 | m->thread_tag = 0; 54 | m->counter = 0; 55 | } 56 | 57 | /** 58 | * @brief Locks a recursive mutex. 59 | * @param m Recursive mutex object. 60 | */ 61 | void rmutexLock(RMutex* m); 62 | 63 | /** 64 | * @brief Attempts to lock a recursive mutex without waiting. 65 | * @param m Recursive mutex object. 66 | * @return 1 if the mutex has been acquired successfully, and 0 on contention. 67 | */ 68 | bool rmutexTryLock(RMutex* m); 69 | 70 | /** 71 | * @brief Unlocks a recursive mutex. 72 | * @param m Recursive mutex object. 73 | */ 74 | void rmutexUnlock(RMutex* m); 75 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/random.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file random.h 3 | * @brief OS-seeded pseudo-random number generation support (ChaCha algorithm). 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /** 11 | * @brief Fills a buffer with random data. 12 | * @param buf Pointer to the buffer. 13 | * @param len Size of the buffer in bytes. 14 | */ 15 | void randomGet(void* buf, size_t len); 16 | 17 | /** 18 | * @brief Returns a random 64-bit value. 19 | * @return Random value. 20 | */ 21 | u64 randomGet64(void); 22 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/rwlock.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file rwlock.h 3 | * @brief Read/write lock synchronization primitive. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../kernel/mutex.h" 9 | #include "../kernel/condvar.h" 10 | 11 | /// Read/write lock structure. 12 | typedef struct { 13 | Mutex mutex; 14 | CondVar condvar_readers; 15 | CondVar condvar_writer; 16 | u32 readers : 31; 17 | bool writer : 1; 18 | } RwLock; 19 | 20 | /** 21 | * @brief Initializes the read/write lock. 22 | * @param r Read/write lock object. 23 | */ 24 | void rwlockInit(RwLock* r); 25 | 26 | /** 27 | * @brief Locks the read/write lock for reading. 28 | * @param r Read/write lock object. 29 | */ 30 | void rwlockReadLock(RwLock* r); 31 | 32 | /** 33 | * @brief Unlocks the read/write lock for reading. 34 | * @param r Read/write lock object. 35 | */ 36 | void rwlockReadUnlock(RwLock* r); 37 | 38 | /** 39 | * @brief Locks the read/write lock for writing. 40 | * @param r Read/write lock object. 41 | */ 42 | void rwlockWriteLock(RwLock* r); 43 | 44 | /** 45 | * @brief Unlocks the read/write lock for writing. 46 | * @param r Read/write lock object. 47 | */ 48 | void rwlockWriteUnlock(RwLock* r); 49 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/semaphore.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file semaphore.h 3 | * @brief Thread synchronization based on Mutex. 4 | * @author SciresM & Kevoot 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | 9 | #include "mutex.h" 10 | #include "condvar.h" 11 | 12 | /// Semaphore structure. 13 | typedef struct Semaphore 14 | { 15 | CondVar condvar; ///< Condition variable object. 16 | Mutex mutex; ///< Mutex object. 17 | u64 count; ///< Internal counter. 18 | } Semaphore; 19 | 20 | /** 21 | * @brief Initializes a semaphore and its internal counter. 22 | * @param s Semaphore object. 23 | * @param initial_count initial value for internal counter (typically the # of free resources). 24 | */ 25 | void semaphoreInit(Semaphore *s, u64 initial_count); 26 | 27 | /** 28 | * @brief Increments the Semaphore to allow other threads to continue. 29 | * @param s Semaphore object. 30 | */ 31 | void semaphoreSignal(Semaphore *s); 32 | 33 | /** 34 | * @brief Decrements Semaphore and waits if 0. 35 | * @param s Semaphore object. 36 | */ 37 | void semaphoreWait(Semaphore *s); 38 | 39 | /** 40 | * @brief Attempts to get lock without waiting. 41 | * @param s Semaphore object. 42 | * @return true if no wait and successful lock, false otherwise. 43 | */ 44 | bool semaphoreTryWait(Semaphore *s); 45 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/shmem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file shmem.h 3 | * @brief Shared memory object handling 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | * @remark Shared memory differs from transfer memory in the fact that the kernel (as opposed to the user process) allocates and owns its backing memory. 7 | */ 8 | #pragma once 9 | #include "../types.h" 10 | 11 | /// Shared memory information structure. 12 | typedef struct { 13 | Handle handle; ///< Kernel object handle. 14 | size_t size; ///< Size of the shared memory object. 15 | Permission perm; ///< Permissions. 16 | void* map_addr; ///< Address to which the shared memory object is mapped. 17 | } SharedMemory; 18 | 19 | /** 20 | * @brief Creates a shared memory object. 21 | * @param s Shared memory information structure which will be filled in. 22 | * @param size Size of the shared memory object to create. 23 | * @param local_perm Permissions with which the shared memory object will be mapped in the local process. 24 | * @param remote_perm Permissions with which the shared memory object will be mapped in the remote process (can be Perm_DontCare). 25 | * @return Result code. 26 | * @warning This is a privileged operation; in normal circumstances applications cannot use this function. 27 | */ 28 | Result shmemCreate(SharedMemory* s, size_t size, Permission local_perm, Permission remote_perm); 29 | 30 | /** 31 | * @brief Loads a shared memory object coming from a remote process. 32 | * @param s Shared memory information structure which will be filled in. 33 | * @param handle Handle of the shared memory object. 34 | * @param size Size of the shared memory object that is being loaded. 35 | * @param perm Permissions with which the shared memory object will be mapped in the local process. 36 | */ 37 | void shmemLoadRemote(SharedMemory* s, Handle handle, size_t size, Permission perm); 38 | 39 | /** 40 | * @brief Maps a shared memory object. 41 | * @param s Shared memory information structure. 42 | * @return Result code. 43 | */ 44 | Result shmemMap(SharedMemory* s); 45 | 46 | /** 47 | * @brief Unmaps a shared memory object. 48 | * @param s Shared memory information structure. 49 | * @return Result code. 50 | */ 51 | Result shmemUnmap(SharedMemory* s); 52 | 53 | /** 54 | * @brief Retrieves the mapped address of a shared memory object. 55 | * @param s Shared memory information structure. 56 | * @return Mapped address of the shared memory object. 57 | */ 58 | static inline void* shmemGetAddr(SharedMemory* s) { 59 | return s->map_addr; 60 | } 61 | 62 | /** 63 | * @brief Frees up resources used by a shared memory object, unmapping and closing handles, etc. 64 | * @param s Shared memory information structure. 65 | * @return Result code. 66 | */ 67 | Result shmemClose(SharedMemory* s); 68 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/thread.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file thread.h 3 | * @brief Multi-threading support 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../arm/thread_context.h" 10 | #include "wait.h" 11 | 12 | /// Thread information structure. 13 | typedef struct Thread { 14 | Handle handle; ///< Thread handle. 15 | void* stack_mem; ///< Pointer to stack memory. 16 | void* stack_mirror; ///< Pointer to stack memory mirror. 17 | size_t stack_sz; ///< Stack size. 18 | void** tls_array; 19 | struct Thread* next; 20 | struct Thread** prev_next; 21 | } Thread; 22 | 23 | /// Creates a \ref Waiter for a \ref Thread. 24 | static inline Waiter waiterForThread(Thread* t) 25 | { 26 | return waiterForHandle(t->handle); 27 | } 28 | 29 | /** 30 | * @brief Creates a thread. 31 | * @param t Thread information structure which will be filled in. 32 | * @param entry Entrypoint of the thread. 33 | * @param arg Argument to pass to the entrypoint. 34 | * @param stack_sz Stack size (rounded up to page alignment). 35 | * @param prio Thread priority (0x00~0x3F); 0x2C is the usual priority of the main thread, 0x3B is a special priority on cores 0..2 that enables preemptive multithreading (0x3F on core 3). 36 | * @param cpuid ID of the core on which to create the thread (0~3); or -2 to use the default core for the current process. 37 | * @return Result code. 38 | */ 39 | Result threadCreate( 40 | Thread* t, ThreadFunc entry, void* arg, size_t stack_sz, int prio, 41 | int cpuid); 42 | 43 | /** 44 | * @brief Starts the execution of a thread. 45 | * @param t Thread information structure. 46 | * @return Result code. 47 | */ 48 | Result threadStart(Thread* t); 49 | 50 | /** 51 | * @brief Exits the current thread immediately. 52 | */ 53 | void NORETURN threadExit(void); 54 | 55 | /** 56 | * @brief Waits for a thread to finish executing. 57 | * @param t Thread information structure. 58 | * @return Result code. 59 | */ 60 | Result threadWaitForExit(Thread* t); 61 | 62 | /** 63 | * @brief Frees up resources associated with a thread. 64 | * @param t Thread information structure. 65 | * @return Result code. 66 | */ 67 | Result threadClose(Thread* t); 68 | 69 | /** 70 | * @brief Pauses the execution of a thread. 71 | * @param t Thread information structure. 72 | * @return Result code. 73 | */ 74 | Result threadPause(Thread* t); 75 | 76 | /** 77 | * @brief Resumes the execution of a thread, after having been paused. 78 | * @param t Thread information structure. 79 | * @return Result code. 80 | */ 81 | Result threadResume(Thread* t); 82 | 83 | /** 84 | * @brief Dumps the registers of a thread paused by @ref threadPause (register groups: all). 85 | * @param[out] ctx Output thread context (register dump). 86 | * @param t Thread information structure. 87 | * @return Result code. 88 | * @warning Official kernel will not dump x0..x18 if the thread is currently executing a system call, and prior to 6.0.0 doesn't dump TPIDR_EL0. 89 | */ 90 | Result threadDumpContext(ThreadContext* ctx, Thread* t); 91 | 92 | /** 93 | * @brief Gets the raw handle to the current thread. 94 | * @return The current thread's handle. 95 | */ 96 | Handle threadGetCurHandle(void); 97 | 98 | /** 99 | * @brief Allocates a TLS slot. 100 | * @param destructor Function to run automatically when a thread exits. 101 | * @return TLS slot ID on success, or a negative value on failure. 102 | */ 103 | s32 threadTlsAlloc(void (* destructor)(void*)); 104 | 105 | /** 106 | * @brief Retrieves the value stored in a TLS slot. 107 | * @param slot_id TLS slot ID. 108 | * @return Value. 109 | */ 110 | void* threadTlsGet(s32 slot_id); 111 | 112 | /** 113 | * @brief Stores the specified value into a TLS slot. 114 | * @param slot_id TLS slot ID. 115 | * @param value Value. 116 | */ 117 | void threadTlsSet(s32 slot_id, void* value); 118 | 119 | /** 120 | * @brief Frees a TLS slot. 121 | * @param slot_id TLS slot ID. 122 | */ 123 | void threadTlsFree(s32 slot_id); 124 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/tmem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file tmem.h 3 | * @brief Transfer memory handling 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | * @remark Transfer memory differs from shared memory in the fact that the user process (as opposed to the kernel) allocates and owns its backing memory. 7 | */ 8 | #pragma once 9 | #include "../types.h" 10 | #include "../kernel/svc.h" 11 | 12 | /// Transfer memory information structure. 13 | typedef struct { 14 | Handle handle; ///< Kernel object handle. 15 | size_t size; ///< Size of the transfer memory object. 16 | Permission perm; ///< Permissions of the transfer memory object. 17 | void* src_addr; ///< Address of the source backing memory. 18 | void* map_addr; ///< Address to which the transfer memory object is mapped. 19 | } TransferMemory; 20 | 21 | /** 22 | * @brief Creates a transfer memory object. 23 | * @param t Transfer memory information structure that will be filled in. 24 | * @param size Size of the transfer memory object to create. 25 | * @param perm Permissions with which to protect the transfer memory in the local process. 26 | * @return Result code. 27 | */ 28 | Result tmemCreate(TransferMemory* t, size_t size, Permission perm); 29 | 30 | /** 31 | * @brief Creates a transfer memory object from existing memory. 32 | * @param t Transfer memory information structure that will be filled in. 33 | * @param buf Pointer to a page-aligned buffer. 34 | * @param size Size of the transfer memory object to create. 35 | * @param perm Permissions with which to protect the transfer memory in the local process. 36 | * @return Result code. 37 | */ 38 | Result tmemCreateFromMemory(TransferMemory* t, void* buf, size_t size, Permission perm); 39 | 40 | /** 41 | * @brief Loads a transfer memory object coming from a remote process. 42 | * @param t Transfer memory information structure which will be filled in. 43 | * @param handle Handle of the transfer memory object. 44 | * @param size Size of the transfer memory object that is being loaded. 45 | * @param perm Permissions which the transfer memory is expected to have in the process that owns the memory. 46 | * @warning This is a privileged operation; in normal circumstances applications shouldn't use this function. 47 | */ 48 | void tmemLoadRemote(TransferMemory* t, Handle handle, size_t size, Permission perm); 49 | 50 | /** 51 | * @brief Maps a transfer memory object. 52 | * @param t Transfer memory information structure. 53 | * @return Result code. 54 | * @warning This is a privileged operation; in normal circumstances applications cannot use this function. 55 | */ 56 | Result tmemMap(TransferMemory* t); 57 | 58 | /** 59 | * @brief Unmaps a transfer memory object. 60 | * @param t Transfer memory information structure. 61 | * @return Result code. 62 | * @warning This is a privileged operation; in normal circumstances applications cannot use this function. 63 | */ 64 | Result tmemUnmap(TransferMemory* t); 65 | 66 | /** 67 | * @brief Retrieves the mapped address of a transfer memory object. 68 | * @param t Transfer memory information structure. 69 | * @return Mapped address of the transfer memory object. 70 | */ 71 | static inline void* tmemGetAddr(TransferMemory* t){ 72 | return t->map_addr; 73 | } 74 | 75 | /** 76 | * @brief Frees up resources used by a transfer memory object, unmapping and closing handles, etc. 77 | * @param t Transfer memory information structure. 78 | * @return Result code. 79 | */ 80 | Result tmemClose(TransferMemory* t); 81 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/uevent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file uevent.h 3 | * @brief User-mode event synchronization primitive. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "wait.h" 9 | 10 | typedef struct UEvent UEvent; 11 | 12 | /// User-mode event object. 13 | struct UEvent { 14 | Waitable waitable; 15 | bool signal; 16 | bool auto_clear; 17 | }; 18 | 19 | /// Creates a waiter for a user-mode event. 20 | static inline Waiter waiterForUEvent(UEvent* e) 21 | { 22 | Waiter wait_obj; 23 | wait_obj.type = WaiterType_Waitable; 24 | wait_obj.waitable = &e->waitable; 25 | return wait_obj; 26 | } 27 | 28 | /** 29 | * @brief Creates a user-mode event. 30 | * @param[out] e UEvent object. 31 | * @param[in] auto_clear Whether to automatically clear the event. 32 | * @note It is safe to wait on this event with several threads simultaneously. 33 | * @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees. 34 | */ 35 | void ueventCreate(UEvent* e, bool auto_clear); 36 | 37 | /** 38 | * @brief Clears the event signal. 39 | * @param[in] e UEvent object. 40 | */ 41 | void ueventClear(UEvent* e); 42 | 43 | /** 44 | * @brief Signals the event. 45 | * @param[in] e UEvent object. 46 | */ 47 | void ueventSignal(UEvent* e); 48 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/utimer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file utimer.h 3 | * @brief User-mode timer synchronization primitive. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "wait.h" 9 | 10 | typedef struct UTimer UTimer; 11 | 12 | /// Valid types for a user-mode timer. 13 | typedef enum { 14 | TimerType_OneShot, ///< Timers of this kind fire once and then stop automatically. 15 | TimerType_Repeating, ///< Timers of this kind fire periodically. 16 | } TimerType; 17 | 18 | /// User-mode timer object. 19 | struct UTimer { 20 | Waitable waitable; 21 | TimerType type : 8; 22 | bool started : 1; 23 | u64 next_tick; 24 | u64 interval; 25 | }; 26 | 27 | /// Creates a waiter for a user-mode timer. 28 | static inline Waiter waiterForUTimer(UTimer* t) 29 | { 30 | Waiter wait_obj; 31 | wait_obj.type = WaiterType_Waitable; 32 | wait_obj.waitable = &t->waitable; 33 | return wait_obj; 34 | } 35 | 36 | /** 37 | * @brief Creates a user-mode timer. 38 | * @param[out] t UTimer object. 39 | * @param[in] interval Interval (in nanoseconds). 40 | * @param[in] type Type of timer to create (see \ref TimerType). 41 | * @note The timer is stopped when it is created. Use \ref utimerStart to start it. 42 | * @note It is safe to wait on this timer with several threads simultaneously. 43 | * @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees. 44 | * @note For a repeating timer: If the timer triggers twice before you wait on it, you will only get one signal. 45 | */ 46 | void utimerCreate(UTimer* t, u64 interval, TimerType type); 47 | 48 | /** 49 | * @brief Starts the timer. 50 | * @param[in] t UTimer object. 51 | */ 52 | void utimerStart(UTimer* t); 53 | 54 | /** 55 | * @brief Stops the timer. 56 | * @param[in] t UTimer object. 57 | */ 58 | void utimerStop(UTimer* t); 59 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/virtmem.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file virtmem.h 3 | * @brief Virtual memory mapping utilities 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /** 11 | * @brief Reserves a slice of general purpose address space. 12 | * @param size The size of the slice of address space that will be reserved (rounded up to page alignment). 13 | * @return Pointer to the slice of address space, or NULL on failure. 14 | */ 15 | void* virtmemReserve(size_t size); 16 | 17 | /** 18 | * @brief Relinquishes a slice of address space reserved with virtmemReserve (currently no-op). 19 | * @param addr Pointer to the slice. 20 | * @param size Size of the slice. 21 | */ 22 | void virtmemFree(void* addr, size_t size); 23 | 24 | /** 25 | * @brief Reserves a slice of address space inside the stack memory mapping region (for use with svcMapMemory). 26 | * @param size The size of the slice of address space that will be reserved (rounded up to page alignment). 27 | * @return Pointer to the slice of address space, or NULL on failure. 28 | */ 29 | void* virtmemReserveStack(size_t size); 30 | 31 | /** 32 | * @brief Relinquishes a slice of address space reserved with virtmemReserveStack (currently no-op). 33 | * @param addr Pointer to the slice. 34 | * @param size Size of the slice. 35 | */ 36 | void virtmemFreeStack(void* addr, size_t size); 37 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/kernel/wait.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wait.h 3 | * @brief User mode synchronization primitive waiting operations. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "mutex.h" 9 | 10 | // Implementation details. 11 | 12 | typedef struct Waitable Waitable; 13 | typedef struct WaitableMethods WaitableMethods; 14 | typedef struct WaitableNode WaitableNode; 15 | 16 | struct WaitableNode { 17 | WaitableNode* prev; 18 | WaitableNode* next; 19 | }; 20 | 21 | struct Waitable { 22 | const WaitableMethods* vt; 23 | WaitableNode list; 24 | Mutex mutex; 25 | }; 26 | 27 | typedef enum { 28 | WaiterType_Handle, 29 | WaiterType_HandleWithClear, 30 | WaiterType_Waitable, 31 | } WaiterType; 32 | 33 | // User-facing API starts here. 34 | 35 | /// Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user-mode. 36 | typedef struct { 37 | WaiterType type; 38 | 39 | union { 40 | Handle handle; 41 | Waitable* waitable; 42 | }; 43 | } Waiter; 44 | 45 | /// Creates a \ref Waiter for a kernel-mode \ref Handle. 46 | static inline Waiter waiterForHandle(Handle h) 47 | { 48 | Waiter wait_obj; 49 | wait_obj.type = WaiterType_Handle; 50 | wait_obj.handle = h; 51 | return wait_obj; 52 | } 53 | 54 | /** 55 | * @brief Waits for an arbitrary number of generic waitable synchronization objects, optionally with a timeout. 56 | * @param[out] idx_out Variable that will received the index of the signalled object. 57 | * @param[in] objects Array containing \ref Waiter structures. 58 | * @param[in] num_objects Number of objects in the array. 59 | * @param[in] timeout Timeout (in nanoseconds). 60 | * @return Result code. 61 | * @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. 62 | */ 63 | Result waitObjects(s32* idx_out, const Waiter* objects, s32 num_objects, u64 timeout); 64 | 65 | /** 66 | * @brief Waits for an arbitrary number of kernel synchronization objects, optionally with a timeout. This function replaces \ref svcWaitSynchronization. 67 | * @param[out] idx_out Variable that will received the index of the signalled object. 68 | * @param[in] handles Array containing handles. 69 | * @param[in] num_handles Number of handles in the array. 70 | * @param[in] timeout Timeout (in nanoseconds). 71 | * @return Result code. 72 | * @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. 73 | */ 74 | Result waitHandles(s32* idx_out, const Handle* handles, s32 num_handles, u64 timeout); 75 | 76 | /** 77 | * @brief Helper macro for \ref waitObjects that accepts \ref Waiter structures as variadic arguments instead of as an array. 78 | * @param[out] idx_out The index of the signalled waiter. 79 | * @param[in] timeout Timeout (in nanoseconds). 80 | * @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. 81 | */ 82 | #define waitMulti(idx_out, timeout, ...) ({ \ 83 | Waiter __objects[] = { __VA_ARGS__ }; \ 84 | waitObjects((idx_out), __objects, sizeof(__objects) / sizeof(Waiter), (timeout)); \ 85 | }) 86 | 87 | /** 88 | * @brief Helper macro for \ref waitHandles that accepts handles as variadic arguments instead of as an array. 89 | * @param[out] idx_out The index of the signalled handle. 90 | * @param[in] timeout Timeout (in nanoseconds). 91 | * @note The number of objects must not be greater than \ref MAX_WAIT_OBJECTS. This is a Horizon kernel limitation. 92 | */ 93 | #define waitMultiHandle(idx_out, timeout, ...) ({ \ 94 | Handle __handles[] = { __VA_ARGS__ }; \ 95 | waitHandles((idx_out), __handles, sizeof(__handles) / sizeof(Handle), (timeout)); \ 96 | }) 97 | 98 | /** 99 | * @brief Waits on a single generic waitable synchronization object, optionally with a timeout. 100 | * @param[in] w \ref Waiter structure. 101 | * @param[in] timeout Timeout (in nanoseconds). 102 | */ 103 | static inline Result waitSingle(Waiter w, u64 timeout) 104 | { 105 | s32 idx; 106 | return waitObjects(&idx, &w, 1, timeout); 107 | } 108 | 109 | /** 110 | * @brief Waits for a single kernel synchronization object, optionally with a timeout. 111 | * @param[in] h \ref Handle of the object. 112 | * @param[in] timeout Timeout (in nanoseconds). 113 | */ 114 | static inline Result waitSingleHandle(Handle h, u64 timeout) 115 | { 116 | s32 idx; 117 | return waitHandles(&idx, &h, 1, timeout); 118 | } 119 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/nacp.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nacp.h 3 | * @brief Control.nacp structure / related code for nacp. 4 | * @copyright libnx Authors 5 | */ 6 | 7 | #pragma once 8 | 9 | /// Language entry. These strings are UTF-8. 10 | typedef struct { 11 | char name[0x200]; 12 | char author[0x100]; 13 | } NacpLanguageEntry; 14 | 15 | typedef struct { 16 | NacpLanguageEntry lang[16]; 17 | 18 | u8 x3000_unk[0x24];////Normally all-zero? 19 | u32 x3024_unk; 20 | u32 x3028_unk; 21 | u32 x302C_unk; 22 | u32 x3030_unk; 23 | u32 x3034_unk; 24 | u64 titleID0; 25 | 26 | u8 x3040_unk[0x20]; 27 | char version[0x10]; 28 | 29 | u64 titleID_DlcBase; 30 | u64 titleID1; 31 | 32 | u32 x3080_unk; 33 | u32 x3084_unk; 34 | u32 x3088_unk; 35 | u8 x308C_unk[0x24];//zeros? 36 | 37 | u64 titleID2; 38 | u64 titleIDs[7];//"Array of application titleIDs, normally the same as the above app-titleIDs. Only set for game-updates?" 39 | 40 | u32 x30F0_unk; 41 | u32 x30F4_unk; 42 | 43 | u64 titleID3;//"Application titleID. Only set for game-updates?" 44 | 45 | char bcatPassphrase[0x40]; 46 | u8 x3140_unk[0xEC0];//Normally all-zero? 47 | } NacpStruct; 48 | 49 | /// Get the NacpLanguageEntry from the input nacp corresponding to the current system language (this may fallback to other languages when needed). Output langentry is NULL if none found / content of entry is empty. 50 | Result nacpGetLanguageEntry(NacpStruct* nacp, NacpLanguageEntry** langentry); 51 | 52 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/nro.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nro.h 3 | * @brief NRO headers. 4 | * @copyright libnx Authors 5 | */ 6 | 7 | #pragma once 8 | 9 | #define NROHEADER_MAGIC 0x304f524e 10 | 11 | #define NROASSETHEADER_MAGIC 0x54455341 12 | #define NROASSETHEADER_VERSION 0 13 | 14 | /// Entry for each segment in the codebin. 15 | typedef struct { 16 | u32 file_off; 17 | u32 size; 18 | } NroSegment; 19 | 20 | /// Offset 0x0 in the NRO. 21 | typedef struct { 22 | u32 unused; 23 | u32 mod_offset; 24 | u8 padding[8]; 25 | } NroStart; 26 | 27 | /// This follows NroStart, the actual nro-header. 28 | typedef struct { 29 | u32 magic; 30 | u32 unk1; 31 | u32 size; 32 | u32 unk2; 33 | NroSegment segments[3]; 34 | u32 bss_size; 35 | u32 unk3; 36 | u8 build_id[0x20]; 37 | u8 padding[0x20]; 38 | } NroHeader; 39 | 40 | /// Custom asset section. 41 | typedef struct { 42 | u64 offset; 43 | u64 size; 44 | } NroAssetSection; 45 | 46 | /// Custom asset header. 47 | typedef struct { 48 | u32 magic; 49 | u32 version; 50 | NroAssetSection icon; 51 | NroAssetSection nacp; 52 | NroAssetSection romfs; 53 | } NroAssetHeader; 54 | 55 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/devices/fs_dev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fs_dev.h 3 | * @brief FS driver, using devoptab. 4 | * @author yellows8 5 | * @author mtheall 6 | * @copyright libnx Authors 7 | */ 8 | #pragma once 9 | 10 | #include 11 | #include "../../services/fs.h" 12 | 13 | #define FSDEV_DIRITER_MAGIC 0x66736476 ///< "fsdv" 14 | 15 | /// Open directory struct 16 | typedef struct 17 | { 18 | u32 magic; ///< "fsdv" 19 | FsDir fd; ///< File descriptor 20 | ssize_t index; ///< Current entry index 21 | size_t size; ///< Current batch size 22 | FsDirectoryEntry entry_data[32]; ///< Temporary storage for reading entries 23 | } fsdev_dir_t; 24 | 25 | /// Initializes and mounts the sdmc device if accessible. Also initializes current working directory to point to the folder containing the path to the executable (argv[0]), if it is provided by the environment. 26 | Result fsdevMountSdmc(void); 27 | 28 | /// Mounts the input fs with the specified device name. fsdev will handle closing the fs when required, including when fsdevMountDevice() fails. 29 | /// Returns -1 when any errors occur. 30 | int fsdevMountDevice(const char *name, FsFileSystem fs); 31 | 32 | /// Unmounts the specified device. 33 | int fsdevUnmountDevice(const char *name); 34 | 35 | /// Uses fsFsCommit() with the specified device. This must be used after any savedata-write operations(not just file-write). This should be used after each file-close where file-writing was done. 36 | /// This is not used automatically at device unmount. 37 | Result fsdevCommitDevice(const char *name); 38 | 39 | /// Returns the FsFileSystem for the specified device. Returns NULL when the specified device isn't found. 40 | FsFileSystem* fsdevGetDeviceFileSystem(const char *name); 41 | 42 | /// Returns the FsFileSystem for the default device (SD card), if mounted. Used internally by romfs_dev. 43 | FsFileSystem* fsdevGetDefaultFileSystem(void); 44 | 45 | /// Writes the FS-path to outpath (which has buffer size FS_MAX_PATH), for the input path (as used in stdio). The FsFileSystem is also written to device when not NULL. 46 | int fsdevTranslatePath(const char *path, FsFileSystem** device, char *outpath); 47 | 48 | /// This calls fsFsSetArchiveBit on the filesystem specified by the input path (as used in stdio). 49 | Result fsdevSetArchiveBit(const char *path); 50 | 51 | /// This calls fsFsCreateFile on the filesystem specified by the input path (as used in stdio). 52 | Result fsdevCreateFile(const char* path, size_t size, int flags); 53 | 54 | /// Recursively deletes the directory specified by the input path (as used in stdio). 55 | Result fsdevDeleteDirectoryRecursively(const char *path); 56 | 57 | /// Unmounts all devices and cleans up any resources used by the FS driver. 58 | Result fsdevUnmountAll(void); 59 | 60 | /// Retrieves the last native result code generated during a failed fsdev operation. 61 | Result fsdevGetLastResult(void); 62 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/devices/romfs_dev.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file romfs_dev.h 3 | * @brief RomFS driver. 4 | * @author yellows8 5 | * @author mtheall 6 | * @author fincs 7 | * @copyright libnx Authors 8 | */ 9 | #pragma once 10 | 11 | #include "../../types.h" 12 | #include "../../services/fs.h" 13 | 14 | /// RomFS header. 15 | typedef struct 16 | { 17 | u64 headerSize; ///< Size of the header. 18 | u64 dirHashTableOff; ///< Offset of the directory hash table. 19 | u64 dirHashTableSize; ///< Size of the directory hash table. 20 | u64 dirTableOff; ///< Offset of the directory table. 21 | u64 dirTableSize; ///< Size of the directory table. 22 | u64 fileHashTableOff; ///< Offset of the file hash table. 23 | u64 fileHashTableSize; ///< Size of the file hash table. 24 | u64 fileTableOff; ///< Offset of the file table. 25 | u64 fileTableSize; ///< Size of the file table. 26 | u64 fileDataOff; ///< Offset of the file data. 27 | } romfs_header; 28 | 29 | /// RomFS directory. 30 | typedef struct 31 | { 32 | u32 parent; ///< Offset of the parent directory. 33 | u32 sibling; ///< Offset of the next sibling directory. 34 | u32 childDir; ///< Offset of the first child directory. 35 | u32 childFile; ///< Offset of the first file. 36 | u32 nextHash; ///< Directory hash table pointer. 37 | u32 nameLen; ///< Name length. 38 | uint8_t name[]; ///< Name. (UTF-8) 39 | } romfs_dir; 40 | 41 | /// RomFS file. 42 | typedef struct 43 | { 44 | u32 parent; ///< Offset of the parent directory. 45 | u32 sibling; ///< Offset of the next sibling file. 46 | u64 dataOff; ///< Offset of the file's data. 47 | u64 dataSize; ///< Length of the file's data. 48 | u32 nextHash; ///< File hash table pointer. 49 | u32 nameLen; ///< Name length. 50 | uint8_t name[]; ///< Name. (UTF-8) 51 | } romfs_file; 52 | 53 | /** 54 | * @brief Mounts the Application's RomFS. 55 | * @param name Device mount name. 56 | */ 57 | Result romfsMount(const char *name); 58 | static inline Result romfsInit(void) 59 | { 60 | return romfsMount("romfs"); 61 | } 62 | 63 | /** 64 | * @brief Mounts RomFS from an open file. 65 | * @param file FsFile of the RomFS image. 66 | * @param offset Offset of the RomFS within the file. 67 | * @param name Device mount name. 68 | */ 69 | Result romfsMountFromFile(FsFile file, u64 offset, const char *name); 70 | static inline Result romfsInitFromFile(FsFile file, u64 offset) 71 | { 72 | return romfsMountFromFile(file, offset, "romfs"); 73 | } 74 | 75 | /** 76 | * @brief Mounts RomFS from an open storage. 77 | * @param storage FsStorage of the RomFS image. 78 | * @param offset Offset of the RomFS within the storage. 79 | * @param name Device mount name. 80 | */ 81 | Result romfsMountFromStorage(FsStorage storage, u64 offset, const char *name); 82 | static inline Result romfsInitFromStorage(FsStorage storage, u64 offset) 83 | { 84 | return romfsMountFromStorage(storage, offset, "romfs"); 85 | } 86 | 87 | /** 88 | * @brief Mounts RomFS using the current process host title RomFS. 89 | * @param name Device mount name. 90 | */ 91 | Result romfsMountFromCurrentProcess(const char *name); 92 | 93 | /** 94 | * @brief Mounts RomFS from a file path in a mounted fsdev device. 95 | * @param path File path. 96 | * @param offset Offset of the RomFS within the file. 97 | * @param name Device mount name. 98 | */ 99 | Result romfsMountFromFsdev(const char *path, u64 offset, const char *name); 100 | 101 | /** 102 | * @brief Mounts RomFS from a system data archive. 103 | * @param dataId Title ID of system data archive to mount. 104 | * @param storageId Storage ID to mount from. 105 | * @param name Device mount name. 106 | */ 107 | Result romfsMountFromDataArchive(u64 dataId, FsStorageId storageId, const char *name); 108 | 109 | /// Unmounts the RomFS device. 110 | Result romfsUnmount(const char *name); 111 | static inline Result romfsExit(void) 112 | { 113 | return romfsUnmount("romfs"); 114 | } 115 | 116 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/devices/socket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "../../types.h" 3 | 4 | /// Configuration structure for socketInitalize 5 | typedef struct { 6 | u32 bsdsockets_version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0. 7 | 8 | u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed). 9 | u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed). 10 | u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value. 11 | u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value. 12 | 13 | u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes). 14 | u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes). 15 | 16 | u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8). 17 | 18 | size_t serialized_out_addrinfos_max_size; ///< For getaddrinfo. 19 | size_t serialized_out_hostent_max_size; ///< For gethostbyname/gethostbyaddr. 20 | bool bypass_nsd; ///< For name gethostbyname/getaddrinfo: bypass the Name Server Daemon. 21 | int dns_timeout; ///< For DNS requests: timeout or 0. 22 | } SocketInitConfig; 23 | 24 | /// Fetch the default configuration for the socket driver. 25 | const SocketInitConfig *socketGetDefaultInitConfig(void); 26 | /// Initalize the socket driver. 27 | Result socketInitialize(const SocketInitConfig *config); 28 | /// Fetch the last bsd:u/s Switch result code (thread-local). 29 | Result socketGetLastBsdResult(void); 30 | /// Fetch the last sfdnsres Switch result code (thread-local). 31 | Result socketGetLastSfdnsresResult(void); 32 | /// Deinitialize the socket driver. 33 | void socketExit(void); 34 | 35 | /// Initalize the socket driver using the default configuration. 36 | static inline Result socketInitializeDefault(void) { 37 | return socketInitialize(socketGetDefaultInitConfig()); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/env.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file env.h 3 | * @brief Homebrew environment definitions and utilities. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// Structure representing an entry in the homebrew environment configuration. 11 | typedef struct { 12 | u32 Key; ///< Type of entry 13 | u32 Flags; ///< Entry flags 14 | u64 Value[2]; ///< Entry arguments (type-specific) 15 | } ConfigEntry; 16 | 17 | /// Entry flags 18 | enum { 19 | EntryFlag_IsMandatory = BIT(0), ///< Specifies that the entry **must** be processed by the homebrew application. 20 | }; 21 | 22 | ///< Types of entry 23 | enum { 24 | EntryType_EndOfList=0, ///< Entry list terminator. 25 | EntryType_MainThreadHandle=1, ///< Provides the handle to the main thread. 26 | EntryType_NextLoadPath=2, ///< Provides a buffer containing information about the next homebrew application to load. 27 | EntryType_OverrideHeap=3, ///< Provides heap override information. 28 | EntryType_OverrideService=4, ///< Provides service override information. 29 | EntryType_Argv=5, ///< Provides argv. 30 | EntryType_SyscallAvailableHint=6, ///< Provides syscall availability hints. 31 | EntryType_AppletType=7, ///< Provides APT applet type. 32 | EntryType_AppletWorkaround=8, ///< Indicates that APT is broken and should not be used. 33 | EntryType_Reserved9=9, ///< Unused/reserved entry type, formerly used by StdioSockets. 34 | EntryType_ProcessHandle=10, ///< Provides the process handle. 35 | EntryType_LastLoadResult=11, ///< Provides the last load result. 36 | EntryType_RandomSeed=14, ///< Provides random data used to seed the pseudo-random number generator. 37 | }; 38 | 39 | enum { 40 | EnvAppletFlags_ApplicationOverride = BIT(0) ///< Use AppletType_Application instead of AppletType_SystemApplication. 41 | }; 42 | 43 | /// Loader return function. 44 | typedef void NORETURN (*LoaderReturnFn)(int result_code); 45 | 46 | /** 47 | * @brief Parses the homebrew loader environment block (internally called). 48 | * @param ctx Reserved. 49 | * @param main_thread Reserved. 50 | * @param saved_lr Reserved. 51 | */ 52 | void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr); 53 | 54 | /// Retrieves the handle to the main thread. 55 | Handle envGetMainThreadHandle(void); 56 | /// Returns true if the application is running as NSO, otherwise NRO. 57 | bool envIsNso(void); 58 | 59 | /// Returns true if the environment has a heap override. 60 | bool envHasHeapOverride(void); 61 | /// Returns the address of the overriden heap. 62 | void* envGetHeapOverrideAddr(void); 63 | /// Returns the size of the overriden heap. 64 | u64 envGetHeapOverrideSize(void); 65 | 66 | /// Returns true if the environment has an argv array. 67 | bool envHasArgv(void); 68 | /// Returns the pointer to the argv array. 69 | void* envGetArgv(void); 70 | 71 | /** 72 | * @brief Returns whether a syscall is hinted to be available. 73 | * @param svc Syscall number to test. 74 | * @returns true if the syscall is available. 75 | */ 76 | bool envIsSyscallHinted(u8 svc); 77 | 78 | /// Returns the handle to the running homebrew process. 79 | Handle envGetOwnProcessHandle(void); 80 | 81 | /// Returns the loader's return function, to be called on program exit. 82 | LoaderReturnFn envGetExitFuncPtr(void); 83 | 84 | /// Sets the return function to be called on program exit. 85 | void envSetExitFuncPtr(LoaderReturnFn addr); 86 | 87 | /** 88 | * @brief Configures the next homebrew application to load. 89 | * @param path Path to the next homebrew application to load (.nro). 90 | * @param argv Argument string to pass. 91 | */ 92 | Result envSetNextLoad(const char* path, const char* argv); 93 | 94 | /// Returns true if the environment supports envSetNextLoad. 95 | bool envHasNextLoad(void); 96 | 97 | /// Returns the Result from the last NRO. 98 | Result envGetLastLoadResult(void); 99 | 100 | /// Returns true if the environment provides a random seed. 101 | bool envHasRandomSeed(void); 102 | 103 | /** 104 | * @brief Retrieves the random seed provided by the environment. 105 | * @param out Pointer to a u64[2] buffer which will contain the random seed on return. 106 | */ 107 | void envGetRandomSeed(u64 out[2]); 108 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/hosversion.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hosversion.h 3 | * @brief Horizon OS (HOS) version detection utilities. 4 | * @author fincs 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// Builds a HOS version value from its constituent components. 11 | #define MAKEHOSVERSION(_major,_minor,_micro) (((u32)(_major) << 16) | ((u32)(_minor) << 8) | (u32)(_micro)) 12 | 13 | /// Extracts the major number from a HOS version value. 14 | #define HOSVER_MAJOR(_version) (((_version) >> 16) & 0xFF) 15 | 16 | /// Extracts the minor number from a HOS version value. 17 | #define HOSVER_MINOR(_version) (((_version) >> 8) & 0xFF) 18 | 19 | /// Extracts the micro number from a HOS version value. 20 | #define HOSVER_MICRO(_version) ( (_version) & 0xFF) 21 | 22 | /// Returns the current HOS version that was previously set with \ref hosversionSet. If version initialization fails during startup (such as in the case set:sys is not available), this function returns zero. 23 | u32 hosversionGet(void); 24 | 25 | /// Sets or overrides the current HOS version. This function is normally called automatically by libnx on startup with the version info obtained with \ref setsysGetFirmwareVersion. 26 | void hosversionSet(u32 version); 27 | 28 | /// Returns true if the current HOS version is equal to or above the specified major/minor/micro version. 29 | static inline bool hosversionAtLeast(u8 major, u8 minor, u8 micro) { 30 | return hosversionGet() >= MAKEHOSVERSION(major,minor,micro); 31 | } 32 | 33 | /// Returns true if the current HOS version is earlier than the specified major/minor/micro version. 34 | static inline bool hosversionBefore(u8 major, u8 minor, u8 micro) { 35 | return !hosversionAtLeast(major, minor, micro); 36 | } 37 | 38 | /// Returns true if the current HOS version is between the two specified major versions, i.e. [major1, major2). 39 | static inline bool hosversionBetween(u8 major1, u8 major2) { 40 | u32 ver = hosversionGet(); 41 | return ver >= MAKEHOSVERSION(major1,0,0) && ver < MAKEHOSVERSION(major2,0,0); 42 | } 43 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/threadvars.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "switch_min/types.h" 3 | #include "switch_min/arm/tls.h" 4 | #include "switch_min/kernel/thread.h" 5 | 6 | #define THREADVARS_MAGIC 0x21545624 // !TV$ 7 | 8 | // This structure is exactly 0x28 bytes 9 | typedef struct { 10 | // Magic value used to check if the struct is initialized 11 | u32 magic; 12 | 13 | // Thread handle, for mutexes 14 | Handle handle; 15 | 16 | // Pointer to the current thread (if exists) 17 | Thread* thread_ptr; 18 | 19 | // Pointer to this thread's newlib state 20 | struct _reent* reent; 21 | 22 | // Pointer to this thread's thread-local segment 23 | void* tls_tp; // !! Offset needs to be TLS+0x1F0 for __aarch64_read_tp !! 24 | 25 | void* nintendo_context; 26 | } ThreadVars; 27 | 28 | static inline ThreadVars* getThreadVars(void) { 29 | return (ThreadVars*)((u8*)armGetTls() + 0x200 - sizeof(ThreadVars)); 30 | } 31 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/runtime/util/utf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file utf.h 3 | * @brief UTF conversion functions. 4 | * @author mtheall 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include 9 | #include "../../types.h" 10 | 11 | /** Convert a UTF-8 sequence into a UTF-32 codepoint 12 | * 13 | * @param[out] out Output codepoint 14 | * @param[in] in Input sequence 15 | * 16 | * @returns number of input code units consumed 17 | * @returns -1 for error 18 | */ 19 | ssize_t decode_utf8 (uint32_t *out, const uint8_t *in); 20 | 21 | /** Convert a UTF-16 sequence into a UTF-32 codepoint 22 | * 23 | * @param[out] out Output codepoint 24 | * @param[in] in Input sequence 25 | * 26 | * @returns number of input code units consumed 27 | * @returns -1 for error 28 | */ 29 | ssize_t decode_utf16(uint32_t *out, const uint16_t *in); 30 | 31 | /** Convert a UTF-32 codepoint into a UTF-8 sequence 32 | * 33 | * @param[out] out Output sequence 34 | * @param[in] in Input codepoint 35 | * 36 | * @returns number of output code units produced 37 | * @returns -1 for error 38 | * 39 | * @note \a out must be able to store 4 code units 40 | */ 41 | ssize_t encode_utf8 (uint8_t *out, uint32_t in); 42 | 43 | /** Convert a UTF-32 codepoint into a UTF-16 sequence 44 | * 45 | * @param[out] out Output sequence 46 | * @param[in] in Input codepoint 47 | * 48 | * @returns number of output code units produced 49 | * @returns -1 for error 50 | * 51 | * @note \a out must be able to store 2 code units 52 | */ 53 | ssize_t encode_utf16(uint16_t *out, uint32_t in); 54 | 55 | /** Convert a UTF-8 sequence into a UTF-16 sequence 56 | * 57 | * Fills the output buffer up to \a len code units. 58 | * Returns the number of code units that the input would produce; 59 | * if it returns greater than \a len, the output has been 60 | * truncated. 61 | * 62 | * @param[out] out Output sequence 63 | * @param[in] in Input sequence (null-terminated) 64 | * @param[in] len Output length 65 | * 66 | * @returns number of output code units produced 67 | * @returns -1 for error 68 | * 69 | * @note \a out is not null-terminated 70 | */ 71 | ssize_t utf8_to_utf16(uint16_t *out, const uint8_t *in, size_t len); 72 | 73 | /** Convert a UTF-8 sequence into a UTF-32 sequence 74 | * 75 | * Fills the output buffer up to \a len code units. 76 | * Returns the number of code units that the input would produce; 77 | * if it returns greater than \a len, the output has been 78 | * truncated. 79 | * 80 | * @param[out] out Output sequence 81 | * @param[in] in Input sequence (null-terminated) 82 | * @param[in] len Output length 83 | * 84 | * @returns number of output code units produced 85 | * @returns -1 for error 86 | * 87 | * @note \a out is not null-terminated 88 | */ 89 | ssize_t utf8_to_utf32(uint32_t *out, const uint8_t *in, size_t len); 90 | 91 | /** Convert a UTF-16 sequence into a UTF-8 sequence 92 | * 93 | * Fills the output buffer up to \a len code units. 94 | * Returns the number of code units that the input would produce; 95 | * if it returns greater than \a len, the output has been 96 | * truncated. 97 | * 98 | * @param[out] out Output sequence 99 | * @param[in] in Input sequence (null-terminated) 100 | * @param[in] len Output length 101 | * 102 | * @returns number of output code units produced 103 | * @returns -1 for error 104 | * 105 | * @note \a out is not null-terminated 106 | */ 107 | ssize_t utf16_to_utf8(uint8_t *out, const uint16_t *in, size_t len); 108 | 109 | /** Convert a UTF-16 sequence into a UTF-32 sequence 110 | * 111 | * Fills the output buffer up to \a len code units. 112 | * Returns the number of code units that the input would produce; 113 | * if it returns greater than \a len, the output has been 114 | * truncated. 115 | * 116 | * @param[out] out Output sequence 117 | * @param[in] in Input sequence (null-terminated) 118 | * @param[in] len Output length 119 | * 120 | * @returns number of output code units produced 121 | * @returns -1 for error 122 | * 123 | * @note \a out is not null-terminated 124 | */ 125 | ssize_t utf16_to_utf32(uint32_t *out, const uint16_t *in, size_t len); 126 | 127 | /** Convert a UTF-32 sequence into a UTF-8 sequence 128 | * 129 | * Fills the output buffer up to \a len code units. 130 | * Returns the number of code units that the input would produce; 131 | * if it returns greater than \a len, the output has been 132 | * truncated. 133 | * 134 | * @param[out] out Output sequence 135 | * @param[in] in Input sequence (null-terminated) 136 | * @param[in] len Output length 137 | * 138 | * @returns number of output code units produced 139 | * @returns -1 for error 140 | * 141 | * @note \a out is not null-terminated 142 | */ 143 | ssize_t utf32_to_utf8(uint8_t *out, const uint32_t *in, size_t len); 144 | 145 | /** Convert a UTF-32 sequence into a UTF-16 sequence 146 | * 147 | * @param[out] out Output sequence 148 | * @param[in] in Input sequence (null-terminated) 149 | * @param[in] len Output length 150 | * 151 | * @returns number of output code units produced 152 | * @returns -1 for error 153 | * 154 | * @note \a out is not null-terminated 155 | */ 156 | ssize_t utf32_to_utf16(uint16_t *out, const uint32_t *in, size_t len); 157 | 158 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/acc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file acc.h 3 | * @brief Account (acc:*) service IPC wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "sm.h" 10 | 11 | #define ACC_USER_LIST_SIZE 8 12 | 13 | typedef struct { 14 | Service s; 15 | } AccountProfile; 16 | 17 | typedef struct 18 | { 19 | u32 unk_x0; 20 | u32 iconID; ///< Icon ID. 0 = Mii, the rest are character icon IDs. 21 | u8 iconBackgroundColorID; ///< Profile icon background color ID 22 | u8 unk_x9[0x7]; 23 | u8 miiID[0x10]; ///< Some ID related to the Mii? All zeros when a character icon is used. 24 | u8 unk_x20[0x60]; ///< Usually zeros? 25 | } PACKED AccountUserData; 26 | 27 | typedef struct 28 | { 29 | u128 userID; 30 | u64 lastEditTimestamp; ///< POSIX UTC timestamp, for the last account edit. 31 | char username[0x20]; ///< UTF-8 Username. 32 | } PACKED AccountProfileBase; 33 | 34 | Result accountInitialize(void); 35 | void accountExit(void); 36 | Service* accountGetService(void); 37 | 38 | /// Get the total number of user profiles 39 | Result accountGetUserCount(s32* user_count); 40 | 41 | /** 42 | * @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE. 43 | * @param userIDs Pointer to array of user IDs. 44 | * @param max_userIDs Maximum number of user IDs to return. 45 | * @param actual_total The actual total number of user IDs found. 46 | */ 47 | Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total); 48 | 49 | /// Get the userID for the currently active user. The output userID is only valid when the output account_selected==1, otherwise no user is currently selected. 50 | /// An user is only selected when the user-account selection applet was used to select an user at least once before. 51 | Result accountGetActiveUser(u128 *userID, bool *account_selected); 52 | 53 | /// Get an AccountProfile for the specified userID. 54 | Result accountGetProfile(AccountProfile* out, u128 userID); 55 | 56 | /// Get \ref AccountUserData and \ref AccountProfileBase for the specified profile, userdata is optional (can be NULL). 57 | Result accountProfileGet(AccountProfile* profile, AccountUserData* userdata, AccountProfileBase* profilebase); 58 | 59 | /// Get the icon image size. 60 | Result accountProfileGetImageSize(AccountProfile* profile, size_t* image_size); 61 | 62 | /// Load the JPEG profile icon, valid for both Miis and character icons. The output image_size is the same as the one from \ref accountProfileGetImageSize. 63 | Result accountProfileLoadImage(AccountProfile* profile, void* buf, size_t len, size_t* image_size); 64 | 65 | void accountProfileClose(AccountProfile* profile); 66 | 67 | /// Gets the userID which was selected by the profile-selector applet (if any), prior to launching the currently running Application title. This can only be used once under the current process, under an Application title. 68 | Result accountGetPreselectedUser(u128 *userID); 69 | 70 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/apm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file apm.h 3 | * @brief Performance management (apm) service IPC wrapper. This is used internally by applet with __nx_applet_PerformanceConfiguration, however if you prefer non-init/exit can be used manually. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// CpuBoostMode. With \ref appletSetCpuBoostMode, only values 0/1 are available. This allows using higher clock rates. 11 | typedef enum { 12 | ApmCpuBoostMode_Disabled = 0, ///< Default, use normal PerformanceConfiguration. 13 | ApmCpuBoostMode_Type1 = 1, ///< Use performance configurations 0x92220009 (Docked) and 0x9222000A (Handheld), or 0x9222000B and 0x9222000C. All of these use the normal GPU clock rate for Docked-mode. The latter pair uses the normal CPU clock rate, while the former pair uses the maximum TX1 CPU clock rate. Memory clock rate is the same as normal. 14 | ApmCpuBoostMode_Type2 = 2, ///< Use performance configurations 0x9222000B and 0x9222000C. 15 | } ApmCpuBoostMode; 16 | 17 | Result apmInitialize(void); 18 | void apmExit(void); 19 | 20 | Result apmSetPerformanceConfiguration(u32 PerformanceMode, u32 PerformanceConfiguration); 21 | Result apmGetPerformanceConfiguration(u32 PerformanceMode, u32 *PerformanceConfiguration); 22 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/bsd.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file bsd.h 3 | * @brief BSD sockets (bsd:u/s) service IPC wrapper. Please use socket.c instead. 4 | * @author plutoo 5 | * @author TuxSH 6 | * @copyright libnx Authors 7 | */ 8 | #pragma once 9 | #include // for socklen_t 10 | #include // for fd_set 11 | #include // for struct pollfd, ndfs_t 12 | 13 | #include "../types.h" 14 | #include "../kernel/tmem.h" 15 | 16 | /// Configuration structure for bsdInitalize 17 | typedef struct { 18 | u32 version; ///< Observed 1 on 2.0 LibAppletWeb, 2 on 3.0. 19 | 20 | u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed). 21 | u32 tcp_rx_buf_size; ///< Size of the TCP recieve buffer (initial or fixed). 22 | u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value. 23 | u32 tcp_rx_buf_max_size; ///< Maximum size of the TCP receive buffer. If it is 0, the size of the buffer is fixed to its initial value. 24 | 25 | u32 udp_tx_buf_size; ///< Size of the UDP transfer (send) buffer (typically 0x2400 bytes). 26 | u32 udp_rx_buf_size; ///< Size of the UDP receive buffer (typically 0xA500 bytes). 27 | 28 | u32 sb_efficiency; ///< Number of buffers for each socket (standard values range from 1 to 8). 29 | } BsdInitConfig; 30 | 31 | extern __thread Result g_bsdResult; ///< Last Switch "result", per-thread 32 | extern __thread int g_bsdErrno; ///< Last errno, per-thread 33 | 34 | /// Fetch the default configuration for bsdInitialize. 35 | const BsdInitConfig *bsdGetDefaultInitConfig(void); 36 | /// Initialize the BSD service. 37 | Result bsdInitialize(const BsdInitConfig *config); 38 | /// Deinitialize the BSD service. 39 | void bsdExit(void); 40 | 41 | /// Creates a socket. 42 | int bsdSocket(int domain, int type, int protocol); 43 | /// Like @ref bsdSocket but the newly created socket is immediately shut down. 44 | int bsdSocketExempt(int domain, int type, int protocol); 45 | int bsdOpen(const char *pathname, int flags); 46 | int bsdSelect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); 47 | int bsdPoll(struct pollfd *fds, nfds_t nfds, int timeout); 48 | int bsdSysctl(const int *name, unsigned int namelen, void *oldp, size_t *oldlenp, const void *newp, size_t newlen); 49 | ssize_t bsdRecv(int sockfd, void *buf, size_t len, int flags); 50 | ssize_t bsdRecvFrom(int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen); 51 | ssize_t bsdSend(int sockfd, const void* buf, size_t len, int flags); 52 | ssize_t bsdSendTo(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen); 53 | int bsdAccept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); 54 | int bsdBind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 55 | int bsdConnect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); 56 | int bsdGetPeerName(int sockfd, struct sockaddr *addr, socklen_t *addrlen); 57 | int bsdGetSockName(int sockfd, struct sockaddr *addr, socklen_t *addrlen); 58 | int bsdGetSockOpt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); 59 | int bsdListen(int sockfd, int backlog); 60 | /// Made non-variadic for convenience. 61 | int bsdIoctl(int fd, int request, void *data); 62 | /// Made non-variadic for convenience. 63 | int bsdFcntl(int fd, int cmd, int flags); 64 | int bsdSetSockOpt(int sockfd, int level, int optname, const void *optval, socklen_t optlen); 65 | int bsdShutdown(int sockfd, int how); 66 | int bsdShutdownAllSockets(int how); 67 | ssize_t bsdWrite(int fd, const void *buf, size_t count); 68 | ssize_t bsdRead(int fd, void *buf, size_t count); 69 | int bsdClose(int fd); 70 | /// Duplicate a socket (bsd:s). 71 | int bsdDuplicateSocket(int sockfd); 72 | 73 | // TODO: Reverse-engineer GetResourceStatistics. Implement sendmmsg/recvmmsg (custom (un)serialization) 74 | 75 | /// Initialize the BSD service using the default configuration. 76 | static inline Result bsdInitializeDefault(void) { 77 | return bsdInitialize(bsdGetDefaultInitConfig()); 78 | } 79 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/fatal.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fatal.h 3 | * @brief Fatal error (fatal:u) service IPC wrapper. 4 | * @author plutoo 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | /// Type of thrown fatal error. 11 | typedef enum { 12 | FatalType_ErrorReportAndErrorScreen = 0, 13 | FatalType_ErrorReport = 1, 14 | FatalType_ErrorScreen = 2 ///< Only available with 3.0.0+. If specified, FatalType_ErrorReportAndErrorScreen will be used instead on pre-3.0.0. 15 | } FatalType; 16 | 17 | /// Struct for fatal Cpu context, 64-bit. 18 | typedef struct { 19 | union { 20 | u64 x[32]; 21 | struct { 22 | u64 _x[29]; 23 | u64 fp; 24 | u64 lr; 25 | u64 sp; 26 | u64 pc; 27 | }; 28 | }; 29 | u64 pstate; 30 | u64 afsr0; 31 | u64 afsr1; 32 | u64 esr; 33 | u64 far; 34 | 35 | u64 stack_trace[32]; 36 | u64 start_address; ///< Address of first NSO loaded (generally, process entrypoint). 37 | u64 register_set_flags; ///< Bitmask, bit i indicates GPR i has a value. 38 | u32 stack_trace_size; 39 | } FatalAarch64Context; 40 | 41 | /// Struct for fatal Cpu context, 32-bit. 42 | typedef struct { 43 | union { 44 | u32 r[16]; 45 | struct { 46 | u32 _r[11]; 47 | u32 fp; 48 | u32 ip; 49 | u32 sp; 50 | u32 lr; 51 | u32 pc; 52 | }; 53 | }; 54 | u32 pstate; 55 | u32 afsr0; 56 | u32 afsr1; 57 | u32 esr; 58 | u32 far; 59 | 60 | u32 stack_trace[32]; 61 | u32 stack_trace_size; 62 | u32 start_address; ///< Address of first NSO loaded (generally, process entrypoint). 63 | u32 register_set_flags; ///< Bitmask, bit i indicates GPR i has a value. 64 | } FatalAarch32Context; 65 | 66 | typedef struct { 67 | union { 68 | FatalAarch64Context aarch64_ctx; 69 | FatalAarch32Context aarch32_ctx; 70 | }; 71 | 72 | bool is_aarch32; 73 | u32 type; 74 | } FatalContext; 75 | 76 | /** 77 | * @brief Triggers a system fatal error. 78 | * @param[in] err Result code to throw. 79 | * @note This function does not return. 80 | * @note This uses \ref fatalWithType with \ref FatalType_ErrorScreen internally. 81 | */ 82 | void NORETURN fatalSimple(Result err); 83 | 84 | /** 85 | * @brief Triggers a system fatal error with a custom \ref FatalType. 86 | * @param[in] err Result code to throw. 87 | * @param[in] type Type of fatal error to throw. 88 | * @note This function may not return, depending on \ref FatalType. 89 | */ 90 | void fatalWithType(Result err, FatalType type); 91 | 92 | /** 93 | * @brief Triggers a system fatal error with a custom \ref FatalType and \ref FatalContext. 94 | * @param[in] err Result code to throw. 95 | * @param[in] type Type of fatal error to throw. 96 | * @param[in] ctx Cpu context for fatal error to throw. 97 | * @note This function may not return, depending on \ref FatalType. 98 | */ 99 | void fatalWithContext(Result err, FatalType type, FatalContext *ctx); 100 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/fsldr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fsldr.h 3 | * @brief FilesystemProxy-ForLoader (fsp-ldr) service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/sm.h" 10 | #include "../services/fs.h" 11 | 12 | Result fsldrInitialize(void); 13 | void fsldrExit(void); 14 | 15 | Result fsldrOpenCodeFileSystem(u64 tid, const char *path, FsFileSystem* out); 16 | Result fsldrIsArchivedProgram(u64 pid, bool *out); 17 | Result fsldrSetCurrentProcess(void); -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/fspr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file fspr.h 3 | * @brief FilesystemProxy-ProgramRegistry (fsp-pr) service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/sm.h" 10 | #include "../services/fs.h" 11 | 12 | Result fsprInitialize(void); 13 | void fsprExit(void); 14 | 15 | 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); 16 | Result fsprUnregisterProgram(u64 pid); 17 | Result fsprSetCurrentProcess(void); 18 | Result fsprSetEnabledProgramVerification(bool enabled); 19 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/hidsys.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file hidsys.h 3 | * @brief hid:sys service IPC wrapper. 4 | * @author exelix, yellows8 5 | */ 6 | #pragma once 7 | #include "../types.h" 8 | #include "../kernel/event.h" 9 | #include "../services/hid.h" 10 | #include "../services/sm.h" 11 | 12 | /// Mini Cycle struct for \ref HidsysNotificationLedPattern. 13 | typedef struct { 14 | u8 ledIntensity; ///< Mini Cycle X LED Intensity. 15 | u8 transitionSteps; ///< Fading Transition Steps to Mini Cycle X (Uses PWM). Value 0x0: Instant. Each step duration is based on HidsysNotificationLedPattern::baseMiniCycleDuration. 16 | u8 finalStepDuration; ///< Final Step Duration Multiplier of Mini Cycle X. Value 0x0: 12.5ms, 0x1 - xF: 1x - 15x. Value is a Multiplier of HidsysNotificationLedPattern::baseMiniCycleDuration. 17 | u8 pad; 18 | } HidsysNotificationLedPatternCycle; 19 | 20 | /// Structure for \ref hidsysSetNotificationLedPattern. 21 | /// See also: https://switchbrew.org/wiki/HID_services#NotificationLedPattern 22 | /// Only the low 4bits of each used byte in this struct is used. 23 | typedef struct { 24 | u8 baseMiniCycleDuration; ///< Mini Cycle Base Duration. Value 0x1-0xF: 12.5ms - 187.5ms. Value 0x0 = 0ms/OFF. 25 | u8 totalMiniCycles; ///< Number of Mini Cycles + 1. Value 0x0-0xF: 1 - 16 mini cycles. 26 | u8 totalFullCycles; ///< Number of Full Cycles. Value 0x1-0xF: 1 - 15 full cycles. Value 0x0 is repeat forever, but if baseMiniCycleDuration is set to 0x0, it does the 1st Mini Cycle with a 12.5ms step duration and then the LED stays on with startIntensity. 27 | u8 startIntensity; ///< LED Start Intensity. Value 0x0=0% - 0xF=100%. 28 | 29 | HidsysNotificationLedPatternCycle miniCycles[16]; ///< Mini Cycles 30 | 31 | u8 unk_x44[0x2]; ///< Unknown 32 | u8 pad_x46[0x2]; ///< Padding 33 | } HidsysNotificationLedPattern; 34 | 35 | Result hidsysInitialize(void); 36 | void hidsysExit(void); 37 | 38 | Result hidsysEnableAppletToGetInput(bool enable); 39 | 40 | /** 41 | * @brief Returns an event that fires when the home button is pressed, this will prevent the home menu from opening when the button is pressed. This event does not auto clear. 42 | **/ 43 | Result hidsysAcquireHomeButtonEventHandle(Event* event_out); 44 | 45 | Result hidsysActivateHomeButton(void); 46 | Result hidsysActivateSleepButton(void); 47 | Result hidsysActivateCaptureButton(void); 48 | 49 | /** 50 | * @brief Gets the UniquePadIds for the specified controller. 51 | * @note Only available on [3.0.0+]. 52 | * @param id Controller ID. Must not be CONTROLLER_P1_AUTO. 53 | * @param UniquePadIds Output array of UniquePadIds. 54 | * @param Max number of entries for the UniquePadIds array. 55 | * @param total_entries Total output array entries. Optional, can be NULL. 56 | */ 57 | Result hidsysGetUniquePadsFromNpad(HidControllerID id, u64 *UniquePadIds, size_t count, size_t *total_entries); 58 | 59 | /** 60 | * @brief Gets a list of all UniquePadIds. 61 | * @param UniquePadIds Output array of UniquePadIds. 62 | * @param Max number of entries for the UniquePadIds array. 63 | * @param total_entries Total output array entries. Optional, can be NULL. 64 | */ 65 | Result hidsysGetUniquePadIds(u64 *UniquePadIds, size_t count, size_t *total_entries); 66 | 67 | /** 68 | * @brief Sets the HOME-button notification LED pattern, for the specified controller. 69 | * @param pattern \ref HidsysNotificationLedPattern 70 | * @param UniquePadId UniquePadId for the controller. 71 | */ 72 | Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *pattern, u64 UniquePadId); 73 | 74 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/irs.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file irs.h 3 | * @brief HID IR sensor (irs) service IPC wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | 9 | #include "../types.h" 10 | #include "../services/sm.h" 11 | #include "../services/hid.h" 12 | 13 | typedef struct { 14 | u64 unk_x0; 15 | u8 unk_x8; 16 | u8 unk_x9; 17 | u8 unk_xa; 18 | u8 pad[5]; 19 | u16 unk_x10; 20 | u32 unk_x12; 21 | u16 unk_x16; 22 | u32 unk_constant;//offset 0x18 23 | u8 unk_x1c; 24 | u8 unk_x1d; 25 | u8 pad2[2]; 26 | } PACKED IrsPackedMomentProcessorConfig; 27 | 28 | typedef struct { 29 | u64 exposure; ///< IR Sensor exposure time in nanoseconds. 30 | u32 ir_leds; ///< Controls the IR leds. 0: All leds, 1: Bright group, 2: Dim group, 3: None. 31 | u32 digital_gain; ///< IR sensor signal's digital gain. 32 | u8 color_invert; ///< Inverts the colors of the captured image. 0: Normal image, 1: Negative image. 33 | u8 pad[7]; 34 | u32 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80. 35 | } IrsImageTransferProcessorConfig; 36 | 37 | typedef struct { 38 | u64 exposure; ///< IR Sensor exposure time in nanoseconds. 39 | u8 ir_leds; ///< Controls the IR leds. 0: All leds, 1: Bright group, 2: Dim group, 3: None. 40 | u8 digital_gain; ///< IR sensor signal's digital gain. 41 | u8 color_invert; ///< Inverts the colors of the captured image. 0: Normal image, 1: Negative image. 42 | u8 pad[5]; 43 | u32 unk_constant;//offset 0x10 44 | u8 sensor_res; ///< IR Sensor resolution. 0: 240x320, 1: 120x160, 2: 60x80. 45 | u8 pad2[3]; 46 | } IrsPackedImageTransferProcessorConfig; 47 | 48 | typedef struct { 49 | u8 unk_x0[0x10]; 50 | } PACKED IrsImageTransferProcessorState; 51 | 52 | /// Initialize irs. 53 | Result irsInitialize(void); 54 | 55 | /// Exit irs. 56 | void irsExit(void); 57 | 58 | Service* irsGetSessionService(void); 59 | void* irsGetSharedmemAddr(void); 60 | 61 | /// (De)activate the IR sensor, this is automatically used by \ref irsExit. Must be called after irsInitialize() to activate the IR sensor. 62 | Result irsActivateIrsensor(bool activate); 63 | 64 | Result irsGetIrCameraHandle(u32 *IrCameraHandle, HidControllerID id); 65 | 66 | /** 67 | * @brief Start ImageTransferProcessor. 68 | * @param[in] IrCameraHandle Camera handle. 69 | * @param[in] config Input config. 70 | * @param[in] size Work-buffer size, must be 0x1000-byte aligned. 71 | * @note Do not use if already started. 72 | */ 73 | Result irsRunImageTransferProcessor(u32 IrCameraHandle, IrsImageTransferProcessorConfig *config, size_t size); 74 | 75 | Result irsGetImageTransferProcessorState(u32 IrCameraHandle, void* buffer, size_t size, IrsImageTransferProcessorState *state); 76 | 77 | /// Stop ImageTransferProcessor. Do not use if already stopped. 78 | /// \ref irsExit calls this with all IrCameraHandles which were not already used with \ref irsStopImageProcessor. 79 | Result irsStopImageProcessor(u32 IrCameraHandle); 80 | 81 | /// "Suspend" ImageTransferProcessor. 82 | /// TODO: What does this really do? 83 | Result irsSuspendImageProcessor(u32 IrCameraHandle); 84 | 85 | /** 86 | * Gets the default configuration for Image Transfer mode. 87 | * Defaults are exposure 300us, IR LEDs all ON, 8x digital gain, normal image and resolution 240 x 320. 88 | */ 89 | void irsGetDefaultImageTransferProcessorConfig(IrsImageTransferProcessorConfig *config); 90 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/lbl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file lbl.h 3 | * @brief LBL service IPC wrapper. 4 | * @author SciresM, exelix 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | Result lblInitialize(void); 11 | void lblExit(void); 12 | 13 | Result lblSwitchBacklightOn(u64 fade_time); 14 | Result lblSwitchBacklightOff(u64 fade_time); 15 | 16 | /** 17 | * @note The brightness goes from 0 to 1.0. 18 | */ 19 | Result lblSetCurrentBrightnessSetting(float brightness); 20 | Result lblGetCurrentBrightnessSetting(float *out_value); 21 | 22 | Result lblEnableAutoBrightnessControl(void); 23 | Result lblDisableAutoBrightnessControl(void); 24 | Result lblIsAutoBrightnessControlEnabled(bool *out_value); 25 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/ldr.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ldr.h 3 | * @brief Loader (ldr*) service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/sm.h" 10 | #include "../services/fs.h" 11 | 12 | typedef struct { 13 | u8 main_thread_priority; 14 | u8 default_cpu_id; 15 | u16 application_type; 16 | u32 main_thread_stack_size; 17 | u64 title_id; 18 | u32 acid_sac_size; 19 | u32 aci0_sac_size; 20 | u32 acid_fac_size; 21 | u32 aci0_fah_size; 22 | u8 ac_buffer[0x3E0]; 23 | } LoaderProgramInfo; 24 | 25 | typedef struct { 26 | u8 build_id[0x20]; 27 | u64 base_address; 28 | u64 size; 29 | } LoaderModuleInfo; 30 | 31 | Result ldrShellInitialize(void); 32 | void ldrShellExit(void); 33 | 34 | Service* ldrShellGetServiceSession(void); 35 | 36 | Result ldrDmntInitialize(void); 37 | void ldrDmntExit(void); 38 | 39 | Service* ldrDmntGetServiceSession(void); 40 | 41 | Result ldrPmInitialize(void); 42 | void ldrPmExit(void); 43 | 44 | Service* ldrPmGetServiceSession(void); 45 | 46 | Result ldrShellAddTitleToLaunchQueue(u64 tid, const void *args, size_t args_size); 47 | Result ldrShellClearLaunchQueue(void); 48 | 49 | Result ldrDmntAddTitleToLaunchQueue(u64 tid, const void *args, size_t args_size); 50 | Result ldrDmntClearLaunchQueue(void); 51 | Result ldrDmntGetModuleInfos(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, u32 *num_out); 52 | 53 | Result ldrPmCreateProcess(u64 flags, u64 launch_index, Handle reslimit_h, Handle *out_process_h); 54 | Result ldrPmGetProgramInfo(u64 title_id, FsStorageId storage_id, LoaderProgramInfo *out_program_info); 55 | Result ldrPmRegisterTitle(u64 title_id, FsStorageId storage_id, u64 *out_index); 56 | Result ldrPmUnregisterTitle(u64 launch_index); 57 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/ncm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ncm.h 3 | * @brief Content Manager (ncm) service IPC wrapper. 4 | * @author zhuowei & Adubbz 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/fs.h" 10 | #include "../services/sm.h" 11 | 12 | typedef enum { 13 | NcmContentType_CNMT = 0, 14 | NcmContentType_Program = 1, 15 | NcmContentType_Data = 2, 16 | NcmContentType_Icon = 3, 17 | NcmContentType_Doc = 4, 18 | NcmContentType_Info = 5, 19 | } NcmContentType; 20 | 21 | typedef enum { 22 | NcmContentMetaType_SystemProgram = 0x01, 23 | NcmContentMetaType_SystemData = 0x02, 24 | NcmContentMetaType_SystemUpdate = 0x03, 25 | NcmContentMetaType_BootImagePackage = 0x04, 26 | NcmContentMetaType_BootImagePackageSafe = 0x05, 27 | NcmContentMetaType_Application = 0x80, 28 | NcmContentMetaType_Patch = 0x81, 29 | NcmContentMetaType_AddOnContent = 0x82, 30 | NcmContentMetaType_Delta = 0x83, 31 | } NcmContentMetaType; 32 | 33 | typedef enum { 34 | NcmContentMetaAttribute_Exfat = (1 << 0), 35 | NcmContentMetaAttribute_Rebootless = (1 << 1), 36 | } NcmContentMetaAttribute; 37 | 38 | typedef struct { 39 | Service s; 40 | } NcmContentStorage; 41 | 42 | typedef struct { 43 | Service s; 44 | } NcmContentMetaDatabase; 45 | 46 | typedef struct { 47 | u8 c[0x10]; 48 | } NcmNcaId; 49 | 50 | typedef struct { 51 | u64 titleId; 52 | u32 version; 53 | u8 type; 54 | u8 flags; 55 | u8 padding[2]; 56 | } NcmMetaRecord; 57 | 58 | typedef struct { 59 | NcmNcaId ncaId; 60 | u8 size[0x6]; 61 | u8 type; 62 | u8 padding; 63 | } NcmContentRecord; 64 | 65 | typedef struct { 66 | u16 numExtraBytes; ///< Size of optional struct that comes after this one. 67 | u16 numContentRecords; ///< Number of NcmContentRecord entries after the extra bytes. 68 | u16 numMetaRecords; ///< Number of NcmMetaRecord entries that come after the NcmContentRecords. 69 | u16 padding; ///< Always zero. 70 | } NcmContentMetaRecordsHeader; 71 | 72 | typedef struct { 73 | NcmMetaRecord metaRecord; 74 | u64 baseTitleId; 75 | } NcmApplicationContentMetaKey; 76 | 77 | Result ncmInitialize(void); 78 | void ncmExit(void); 79 | 80 | Result ncmOpenContentStorage(FsStorageId storage, NcmContentStorage* out); 81 | Result ncmOpenContentMetaDatabase(FsStorageId storage, NcmContentMetaDatabase* out); 82 | 83 | Result ncmContentStorageGeneratePlaceHolderId(NcmContentStorage* cs, NcmNcaId* outputId); 84 | Result ncmContentStorageCreatePlaceHolder(NcmContentStorage* cs, const NcmNcaId* registeredId, const NcmNcaId* placeholderId, u64 size); 85 | Result ncmContentStorageDeletePlaceHolder(NcmContentStorage* cs, const NcmNcaId* placeholderId); 86 | Result ncmContentStorageWritePlaceHolder(NcmContentStorage* cs, const NcmNcaId* placeholderId, u64 offset, const void* srcData, size_t srcDataSize); 87 | Result ncmContentStorageRegister(NcmContentStorage* cs, const NcmNcaId* registeredId, const NcmNcaId* placeholderId); 88 | Result ncmContentStorageDelete(NcmContentStorage* cs, const NcmNcaId* registeredId); 89 | Result ncmContentStorageHas(NcmContentStorage* cs, const NcmNcaId* ncaId, bool* out); 90 | Result ncmContentStorageGetPath(NcmContentStorage* cs, const NcmNcaId* ncaId, char* out, size_t outSize); 91 | Result ncmContentStorageGetPlaceHolderPath(NcmContentStorage* cs, const NcmNcaId* ncaId, char* out, size_t outSize); 92 | Result ncmContentStorageCleanupAllPlaceHolder(NcmContentStorage* cs); 93 | Result ncmContentStorageGetSize(NcmContentStorage* cs, const NcmNcaId* ncaId, u64* out); 94 | Result ncmContentStorageDisableForcibly(NcmContentStorage* cs); 95 | Result ncmContentStorageReadContentIdFile(NcmContentStorage* cs, const NcmNcaId* ncaId, u64 offset, void* outBuf, size_t bufSize); 96 | Result ncmContentStorageGetRightsIdFromContentId(NcmContentStorage* cs, const NcmNcaId* ncaId, FsRightsId* rightsIdOut, u32* keyGenerationOut); 97 | 98 | Result ncmContentMetaDatabaseSet(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u64 inDataSize, const NcmContentMetaRecordsHeader* srcRecordsData); 99 | Result ncmContentMetaDatabaseGet(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u64 outDataSize, NcmContentMetaRecordsHeader* outRecordsData, u64* sizeRead); 100 | Result ncmContentMetaDatabaseRemove(NcmContentMetaDatabase* db, const NcmMetaRecord *record); 101 | Result ncmContentMetaDatabaseGetContentIdByType(NcmContentMetaDatabase* db, NcmContentType contentType, const NcmMetaRecord* record, NcmNcaId* out); 102 | Result ncmContentMetaDatabaseListContentInfo(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u32 index, NcmContentRecord* contentRecordsOut, size_t contentRecordsBufSize, u32* numEntriesRead); 103 | Result ncmContentMetaDatabaseList(NcmContentMetaDatabase* db, u32 titleType, u64 titleIdExact, u64 titleIdLow, u64 titleIdHigh, NcmMetaRecord* metaRecordsOut, size_t metaRecordsBufSize, u32* numEntriesWritten, u32* numEntriesTotal); 104 | Result ncmContentMetaDatabaseGetLatestContentMetaKey(NcmContentMetaDatabase* db, u64 titleId, NcmMetaRecord* out); 105 | Result ncmContentMetaDatabaseListApplication(NcmContentMetaDatabase* db, u8 filter, NcmApplicationContentMetaKey* outBuf, size_t outBufSize, u32* numEntriesWritten, u32* numEntriesTotal); 106 | Result ncmContentMetaDatabaseHas(NcmContentMetaDatabase* db, const NcmMetaRecord* record, bool* out); 107 | Result ncmContentMetaDatabaseDisableForcibly(NcmContentMetaDatabase* db); 108 | Result ncmContentMetaDatabaseCommit(NcmContentMetaDatabase* db); 109 | Result ncmContentMetaDatabaseGetAttributes(NcmContentMetaDatabase* db, const NcmMetaRecord* record, u8* out); 110 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/nfc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nfc.h 3 | * @brief Nintendo Figurine (amiibo) Platform (nfp:user) service IPC wrapper. 4 | * @author averne 5 | * @copyright libnx Authors 6 | */ 7 | 8 | #pragma once 9 | #include "../types.h" 10 | #include "../services/hid.h" 11 | 12 | typedef struct { 13 | u8 uuid[10]; 14 | u8 uuid_length; 15 | u8 reserved1[0x15]; 16 | u32 protocol; 17 | u32 tag_type; 18 | u8 reserved2[0x30]; 19 | } PACKED NfpuTagInfo; 20 | 21 | typedef struct { 22 | u16 last_write_year; 23 | u8 last_write_month; 24 | u8 last_write_day; 25 | u16 write_counter; 26 | u16 version; 27 | u32 application_area_size; 28 | u8 reserved[0x34]; 29 | } PACKED NfpuCommonInfo; 30 | 31 | typedef struct { 32 | u8 amiibo_id[0x8]; 33 | u8 reserved[0x38]; 34 | } PACKED NfpuModelInfo; 35 | 36 | typedef struct { 37 | u8 unk_x0[0x10]; // Hash? 38 | u16 mii_name[10+1]; ///< utf-16be, null-terminated 39 | u8 unk_x26; 40 | u8 mii_color; 41 | u8 mii_sex; 42 | u8 mii_height; 43 | u8 mii_width; 44 | u8 unk_x2b[2]; 45 | u8 mii_face_shape; 46 | u8 mii_face_color; 47 | u8 mii_wrinkles_style; 48 | u8 mii_makeup_style; 49 | u8 mii_hair_style; 50 | u8 mii_hair_color; 51 | u8 mii_has_hair_flipped; 52 | u8 mii_eye_style; 53 | u8 mii_eye_color; 54 | u8 mii_eye_size; 55 | u8 mii_eye_thickness; 56 | u8 mii_eye_angle; 57 | u8 mii_eye_pos_x; 58 | u8 mii_eye_pos_y; 59 | u8 mii_eyebrow_style; 60 | u8 mii_eyebrow_color; 61 | u8 mii_eyebrow_size; 62 | u8 mii_eyebrow_thickness; 63 | u8 mii_eyebrow_angle; 64 | u8 mii_eyebrow_pos_x; 65 | u8 mii_eyebrow_pos_y; 66 | u8 mii_nose_style; 67 | u8 mii_nose_size; 68 | u8 mii_nose_pos; 69 | u8 mii_mouth_style; 70 | u8 mii_mouth_color; 71 | u8 mii_mouth_size; 72 | u8 mii_mouth_thickness; 73 | u8 mii_mouth_pos; 74 | u8 mii_facial_hair_color; 75 | u8 mii_beard_style; 76 | u8 mii_mustache_style; 77 | u8 mii_mustache_size; 78 | u8 mii_mustache_pos; 79 | u8 mii_glasses_style; 80 | u8 mii_glasses_color; 81 | u8 mii_glasses_size; 82 | u8 mii_glasses_pos; 83 | u8 mii_has_mole; 84 | u8 mii_mole_size; 85 | u8 mii_mole_pos_x; 86 | u8 mii_mole_pos_y; 87 | u8 unk_x57; 88 | } PACKED NfpuMiiCharInfo; 89 | 90 | typedef struct { 91 | NfpuMiiCharInfo mii; 92 | u16 first_write_year; 93 | u8 first_write_month; 94 | u8 first_write_day; 95 | char amiibo_name[10+1]; ///< utf-8, null-terminated 96 | u8 reserved[0x99]; 97 | } PACKED NfpuRegisterInfo; 98 | 99 | typedef struct { 100 | u64 unk1; 101 | u64 reserved1[3]; 102 | u64 unk2; 103 | u64 reserved2[3]; 104 | } NfpuInitConfig; 105 | 106 | typedef enum { 107 | NfpuState_NonInitialized = 0, 108 | NfpuState_Initialized = 1, 109 | } NfpuState; 110 | 111 | typedef enum { 112 | NfpuDeviceState_Initialized = 0, 113 | NfpuDeviceState_SearchingForTag = 1, 114 | NfpuDeviceState_TagFound = 2, 115 | NfpuDeviceState_TagRemoved = 3, 116 | NfpuDeviceState_TagMounted = 4, 117 | NfpuDeviceState_Unavailable = 5, 118 | NfpuDeviceState_Finalized = 6, 119 | } NfpuDeviceState; 120 | 121 | typedef enum { 122 | NfpuDeviceType_Amiibo = 0, 123 | } NfpuDeviceType; 124 | 125 | typedef enum { 126 | NfpuMountTarget_Rom = 1, 127 | NfpuMountTarget_Ram = 2, 128 | NfpuMountTarget_All = 3, 129 | } NfpuMountTarget; 130 | 131 | Result nfpuInitialize(const NfpuInitConfig *config); 132 | void nfpuExit(void); 133 | Service* nfpuGetInterface(void); 134 | 135 | Result nfpuStartDetection(HidControllerID id); 136 | Result nfpuStopDetection(HidControllerID id); 137 | 138 | /// Returned event will have autoclear off. 139 | Result nfpuAttachActivateEvent(HidControllerID id, Event *out); 140 | /// Returned event will have autoclear off. 141 | Result nfpuAttachDeactivateEvent(HidControllerID id, Event *out); 142 | /// Returned event will have autoclear on. 143 | Result nfpuAttachAvailabilityChangeEvent(Event *out); 144 | 145 | Result nfpuGetState(NfpuState *out); 146 | Result nfpuGetDeviceState(HidControllerID id, NfpuDeviceState *out); 147 | Result nfpuListDevices(u32 *count, HidControllerID *out, size_t num_elements); 148 | Result nfpuGetNpadId(HidControllerID id, u32 *out); 149 | 150 | Result nfpuMount(HidControllerID id, NfpuDeviceType device_type, NfpuMountTarget mount_target); 151 | Result nfpuUnmount(HidControllerID id); 152 | 153 | Result nfpuGetTagInfo(HidControllerID id, NfpuTagInfo *out); 154 | Result nfpuGetRegisterInfo(HidControllerID id, NfpuRegisterInfo *out); 155 | Result nfpuGetCommonInfo(HidControllerID id, NfpuCommonInfo *out); 156 | Result nfpuGetModelInfo(HidControllerID id, NfpuModelInfo *out); 157 | 158 | Result nfpuOpenApplicationArea(HidControllerID id, u32 app_id, u32 *npad_id); 159 | Result nfpuGetApplicationArea(HidControllerID id, void* buf, size_t buf_size); 160 | Result nfpuSetApplicationArea(HidControllerID id, const void* buf, size_t buf_size); 161 | Result nfpuCreateApplicationArea(HidControllerID id, u32 app_id, const void* buf, size_t buf_size); 162 | 163 | Result nfpuFlush(HidControllerID id); 164 | Result nfpuRestore(HidControllerID id); 165 | 166 | /// Calls nfc:user. 167 | Result nfpuIsNfcEnabled(bool *out); 168 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/nifm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file nifm.h 3 | * @brief Network interface service IPC wrapper. 4 | * @author shadowninja108, shibboleet, exelix 5 | * @copyright libnx Authors 6 | */ 7 | 8 | #pragma once 9 | #include "../kernel/ipc.h" 10 | #include "../services/sm.h" 11 | 12 | typedef enum { 13 | NifmServiceType_NotInitialized = 0, ///< Initializes nifm:u. 14 | NifmServiceType_User = 1, ///< Initializes nifm:u. 15 | NifmServiceType_System = 2, ///< Initializes nifm:s. 16 | NifmServiceType_Admin = 3, ///< Initializes nifm:a. 17 | } NifmServiceType; 18 | 19 | typedef enum { 20 | NifmInternetConnectionType_WiFi = 1, ///< Wi-Fi connection is used. 21 | NifmInternetConnectionType_Ethernet = 2, ///< Ethernet connection is used. 22 | } NifmInternetConnectionType; 23 | 24 | typedef enum { 25 | NifmInternetConnectionStatus_ConnectingUnknown1 = 0, ///< Unknown internet connection status 1. 26 | NifmInternetConnectionStatus_ConnectingUnknown2 = 1, ///< Unknown internet connection status 2. 27 | NifmInternetConnectionStatus_ConnectingUnknown3 = 2, ///< Unknown internet connection status 3 (conntest?). 28 | NifmInternetConnectionStatus_ConnectingUnknown4 = 3, ///< Unknown internet connection status 4. 29 | NifmInternetConnectionStatus_Connected = 4, ///< Internet is connected. 30 | } NifmInternetConnectionStatus; 31 | 32 | /** 33 | * @brief Sets the \ref NifmServiceType for initialization. Call this function before \ref nifmInitialize. 34 | * @note By default nifm:u will be used. 35 | */ 36 | void nifmSetServiceType(NifmServiceType serviceType); 37 | 38 | Result nifmInitialize(void); 39 | void nifmExit(void); 40 | 41 | Result nifmGetCurrentIpAddress(u32* out); 42 | 43 | Result nifmIsWirelessCommunicationEnabled(bool* out); 44 | 45 | /** 46 | * @note Works only if called from nifm:a or nifm:s. 47 | */ 48 | Result nifmSetWirelessCommunicationEnabled(bool enable); 49 | 50 | /** 51 | * @note Will fail with 0xd46ed if Internet is neither connecting or connected (airplane mode or no known network in reach). 52 | * @param wifiStrength Strength of the Wi-Fi signal in number of bars from 0 to 3. 53 | */ 54 | Result nifmGetInternetConnectionStatus(NifmInternetConnectionType* connectionType, u32* wifiStrength, NifmInternetConnectionStatus* connectionStatus); 55 | 56 | Result nifmIsEthernetCommunicationEnabled(bool* out); 57 | Result nifmIsAnyForegroundRequestAccepted(bool* out); 58 | Result nifmPutToSleep(void); 59 | Result nifmWakeUp(void); 60 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/ns.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ns.h 3 | * @brief NS service IPC wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../nacp.h" 10 | #include "../services/fs.h" 11 | #include "../kernel/event.h" 12 | 13 | typedef struct { 14 | NacpStruct nacp; 15 | u8 icon[0x20000];//JPEG 16 | } NsApplicationControlData; 17 | 18 | typedef struct 19 | { 20 | u8 title_type; 21 | u8 storageID; 22 | u8 unk_x02; 23 | u8 padding; 24 | u32 title_version; 25 | u64 titleID; 26 | } NsApplicationContentMetaStatus; 27 | 28 | typedef struct 29 | { 30 | u64 titleID; 31 | u8 type; 32 | u8 unk_x09; 33 | u8 unk_x0A[6]; 34 | u8 unk_x10; 35 | u8 unk_x11[7]; 36 | } NsApplicationRecord; 37 | 38 | typedef struct { 39 | u64 titleID; 40 | u32 version; 41 | u8 storageID; 42 | u8 index; 43 | u8 is_application; 44 | } NsLaunchProperties; 45 | 46 | typedef enum { 47 | NsShellEvent_None = 0, 48 | NsShellEvent_Exit = 1, 49 | NsShellEvent_Start = 2, 50 | NsShellEvent_Crash = 3, 51 | NsShellEvent_Debug = 4, 52 | } NsShellEvent; 53 | 54 | typedef struct { 55 | NsShellEvent event; 56 | u64 process_id; 57 | } NsShellEventInfo; 58 | 59 | Result nsInitialize(void); 60 | void nsExit(void); 61 | 62 | Result nsListApplicationRecord(NsApplicationRecord* buffer, size_t size, size_t entry_offset, size_t* out_entrycount); 63 | Result nsListApplicationContentMetaStatus(u64 titleID, u32 index, NsApplicationContentMetaStatus* buffer, size_t size, size_t* out_entrycount); 64 | Result nsGetApplicationControlData(u8 flag, u64 titleID, NsApplicationControlData* buffer, size_t size, size_t* actual_size); 65 | 66 | /** 67 | * @brief Returns the total storage capacity (used + free) from content manager services. 68 | * @param storage_id Specified FsStorageId. (Must be FsStorageId_SdCard) 69 | * @param size Pointer to output the total storage size to. 70 | */ 71 | Result nsGetTotalSpaceSize(FsStorageId storage_id, u64 *size); 72 | 73 | /** 74 | * @brief Returns the available storage capacity from content manager services. 75 | * @param storage_id Specified FsStorageId. (Must be FsStorageId_SdCard) 76 | * @param size Pointer to output the free storage size to. 77 | */ 78 | Result nsGetFreeSpaceSize(FsStorageId storage_id, u64 *size); 79 | 80 | Result nsvmInitialize(void); 81 | void nsvmExit(void); 82 | 83 | Result nsvmNeedsUpdateVulnerability(bool *out); 84 | Result nsvmGetSafeSystemVersion(u16 *out); 85 | 86 | /* ns:dev */ 87 | Result nsdevInitialize(void); 88 | void nsdevExit(void); 89 | 90 | Result nsdevLaunchProgram(u64* out_pid, const NsLaunchProperties* properties, u32 flags); 91 | Result nsdevTerminateProcess(u64 pid); 92 | Result nsdevTerminateProgram(u64 tid); 93 | Result nsdevGetShellEvent(Event* out); // Autoclear for nsdevShellEvent is always true. 94 | Result nsdevGetShellEventInfo(NsShellEventInfo* out); 95 | Result nsdevTerminateApplication(void); 96 | Result nsdevPrepareLaunchProgramFromHost(NsLaunchProperties* out, const char* path, size_t path_len); 97 | Result nsdevLaunchApplication(u64* out_pid, u64 app_title_id, u32 flags); 98 | Result nsdevLaunchApplicationWithStorageId(u64* out_pid, u64 app_title_id, u32 flags, u8 app_storage_id, u8 patch_storage_id); 99 | Result nsdevIsSystemMemoryResourceLimitBoosted(bool* out); 100 | Result nsdevGetRunningApplicationProcessId(u64* out_pid); 101 | Result nsdevSetCurrentApplicationRightsEnvironmentCanBeActive(bool can_be_active); 102 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/pctl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pctl.h 3 | * @brief Parental Controls service IPC wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | 8 | #pragma once 9 | #include "../kernel/ipc.h" 10 | #include "../services/sm.h" 11 | 12 | Result pctlInitialize(void); 13 | void pctlExit(void); 14 | 15 | /// Confirm whether VrMode is allowed. Only available with [4.0.0+]. 16 | Result pctlConfirmStereoVisionPermission(void); 17 | 18 | /// Gets whether Parental Controls are enabled. 19 | Result pctlIsRestrictionEnabled(bool *flag); 20 | 21 | /// Reset the confirmation done by \ref pctlConfirmStereoVisionPermission. Only available with [5.0.0+]. 22 | Result pctlResetConfirmedStereoVisionPermission(void); 23 | 24 | /// Gets whether VrMode is allowed. Only available with [5.0.0+]. 25 | Result pctlIsStereoVisionPermitted(bool *flag); 26 | 27 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/pl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pl.h 3 | * @brief pl:u service IPC wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | typedef enum 11 | { 12 | PlSharedFontType_Standard = 0, ///< Japan, US and Europe 13 | PlSharedFontType_ChineseSimplified = 1, ///< Chinese Simplified 14 | PlSharedFontType_ExtChineseSimplified = 2, ///< Extended Chinese Simplified 15 | PlSharedFontType_ChineseTraditional = 3, ///< Chinese Traditional 16 | PlSharedFontType_KO = 4, ///< Korean (Hangul) 17 | PlSharedFontType_NintendoExt = 5, ///< Nintendo Extended. This font only has the special Nintendo-specific characters, which aren't available with the other fonts. 18 | PlSharedFontType_Total, ///< Total fonts supported by this enum. 19 | } PlSharedFontType; 20 | 21 | typedef struct { 22 | u32 type; 23 | u32 offset; 24 | u32 size; 25 | void* address; 26 | } PlFontData; 27 | 28 | Result plInitialize(void); 29 | void plExit(void); 30 | void* plGetSharedmemAddr(void); 31 | 32 | ///< Gets a specific shared-font via SharedFontType, see \ref PlSharedFontType. 33 | Result plGetSharedFontByType(PlFontData* font, u32 SharedFontType); 34 | 35 | ///< Gets shared font(s). 36 | Result plGetSharedFont(u64 LanguageCode, PlFontData* fonts, size_t max_fonts, size_t* total_fonts); 37 | 38 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/pm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file pm.h 3 | * @brief Process management (pm*) service IPC wrapper. 4 | * @author plutoo 5 | * @author yellows8 6 | * @author mdbell 7 | * @copyright libnx Authors 8 | */ 9 | #pragma once 10 | #include "../types.h" 11 | #include "../kernel/event.h" 12 | #include "../services/sm.h" 13 | 14 | typedef enum { 15 | PmLaunchFlag_None = 0, 16 | 17 | ///< PmLaunchFlag_* should be used on 5.0.0+. 18 | PmLaunchFlag_SignalOnExit = (1 << 0), 19 | PmLaunchFlag_SignalOnStart = (1 << 1), 20 | PmLaunchFlag_SignalOnCrash = (1 << 2), 21 | PmLaunchFlag_SignalOnDebug = (1 << 3), 22 | PmLaunchFlag_StartSuspended = (1 << 4), 23 | PmLaunchFlag_DisableAslr = (1 << 5), 24 | 25 | ///< PmLaunchFlagOld_* should be used on 1.0.0-4.1.0. 26 | PmLaunchFlagOld_SignalOnExit = (1 << 0), 27 | PmLaunchFlagOld_StartSuspended = (1 << 1), 28 | PmLaunchFlagOld_SignalOnCrash = (1 << 2), 29 | PmLaunchFlagOld_DisableAslr = (1 << 3), 30 | PmLaunchFlagOld_SignalOnDebug = (1 << 4), 31 | ///< PmLaunchFlagOld_SignalOnStart was added in 2.0.0. 32 | PmLaunchFlagOld_SignalOnStart = (1 << 5), 33 | } PmLaunchFlag; 34 | 35 | typedef enum { 36 | PmProcessEvent_None = 0, 37 | PmProcessEvent_Exit = 1, 38 | PmProcessEvent_Start = 2, 39 | PmProcessEvent_Crash = 3, 40 | PmProcessEvent_DebugStart = 4, 41 | PmProcessEvent_DebugBreak = 5, 42 | } PmProcessEvent; 43 | 44 | typedef struct { 45 | PmProcessEvent event; 46 | u64 process_id; 47 | } PmProcessEventInfo; 48 | 49 | typedef enum { 50 | PmBootMode_Normal = 0, 51 | PmBootMode_Maintenance = 1, 52 | PmBootMode_SafeMode = 2, 53 | } PmBootMode; 54 | 55 | Result pmdmntInitialize(void); 56 | void pmdmntExit(void); 57 | 58 | Service* pmdmntGetServiceSession(void); 59 | 60 | Result pminfoInitialize(void); 61 | void pminfoExit(void); 62 | 63 | Service* pminfoGetServiceSession(void); 64 | 65 | Result pmshellInitialize(void); 66 | void pmshellExit(void); 67 | 68 | Service* pmshellGetServiceSession(void); 69 | 70 | Result pmbmInitialize(); 71 | void pmbmExit(); 72 | 73 | Service* pmbmGetServiceSession(void); 74 | 75 | Result pmdmntGetDebugProcesses(u32* out_count, u64* out_pids, size_t max_pids); 76 | Result pmdmntStartProcess(u64 pid); 77 | Result pmdmntGetTitlePid(u64* pid_out, u64 title_id); 78 | Result pmdmntEnableDebugForTitleId(Handle* handle_out, u64 title_id); 79 | Result pmdmntGetApplicationPid(u64* pid_out); 80 | Result pmdmntEnableDebugForApplication(Handle* handle_out); 81 | Result pmdmntDisableDebug(void); 82 | 83 | Result pminfoGetTitleId(u64* title_id_out, u64 pid); 84 | 85 | Result pmshellLaunchProcess(u32 launch_flags, u64 titleID, u64 storageID, u64 *pid); 86 | Result pmshellTerminateProcessByProcessId(u64 processID); 87 | Result pmshellTerminateProcessByTitleId(u64 titleID); 88 | Result pmshellGetProcessEvent(Event* out); // Autoclear for pmshellProcessEvent is always true. 89 | Result pmshellGetProcessEventInfo(PmProcessEventInfo* out); 90 | Result pmshellFinalizeDeadProcess(u64 pid); 91 | Result pmshellClearProcessExceptionOccurred(u64 pid); 92 | Result pmshellNotifyBootFinished(void); 93 | Result pmshellGetApplicationPid(u64* pid_out); 94 | Result pmshellBoostSystemMemoryResourceLimit(u64 boost_size); 95 | Result pmshellBoostSystemThreadResourceLimit(void); 96 | 97 | Result pmbmGetBootMode(PmBootMode *out); 98 | Result pmbmSetMaintenanceBoot(void); 99 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/psc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file psc.h 3 | * @brief PSC service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../kernel/event.h" 10 | #include "../services/sm.h" 11 | 12 | typedef enum { 13 | PscPmState_Awake = 0, ///< Everything is awake. 14 | PscPmState_ReadyAwaken = 1, ///< Preparing to transition to awake. 15 | PscPmState_ReadySleep = 2, ///< Preparing to transition to sleep. 16 | PscPmState_ReadySleepCritical = 3, ///< Critical services are ready to sleep. 17 | PscPmState_ReadyAwakenCritical = 4, ///< Critical services are ready to wake up. 18 | PscPmState_ReadyShutdown = 5, ///< Preparing to transition to shutdown. 19 | } PscPmState; 20 | 21 | typedef struct { 22 | Event event; 23 | Service srv; 24 | u16 module_id; 25 | } PscPmModule; 26 | 27 | Result pscInitialize(void); 28 | void pscExit(void); 29 | 30 | Result pscGetPmModule(PscPmModule *out, u16 module_id, const u16 *dependencies, size_t dependency_count, bool autoclear); 31 | 32 | Result pscPmModuleGetRequest(PscPmModule *module, PscPmState *out_state, u32 *out_flags); 33 | Result pscPmModuleAcknowledge(PscPmModule *module, PscPmState state); 34 | Result pscPmModuleFinalize(PscPmModule *module); 35 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/psm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file psm.h 3 | * @brief PSM service IPC wrapper. 4 | * @author XorTroll, endrift, and yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/sm.h" 10 | #include "../kernel/event.h" 11 | 12 | typedef enum { 13 | ChargerType_None = 0, ///< No charger 14 | ChargerType_Charger = 1, ///< Official charger or dock 15 | ChargerType_Usb = 2 ///< Other USB-C chargers 16 | } ChargerType; 17 | 18 | typedef enum { 19 | PsmBatteryVoltageState_NeedsShutdown = 0, ///< Power state should transition to shutdown 20 | PsmBatteryVoltageState_NeedsSleep = 1, ///< Power state should transition to sleep 21 | PsmBatteryVoltageState_NoPerformanceBoost = 2, ///< Performance boost modes cannot be entered 22 | PsmBatteryVoltageState_Normal = 3, ///< Everything is normal 23 | } PsmBatteryVoltageState; 24 | 25 | /// IPsmSession 26 | typedef struct { 27 | Service s; 28 | Event StateChangeEvent; ///< autoclear=false 29 | } PsmSession; 30 | 31 | Result psmInitialize(void); 32 | void psmExit(void); 33 | 34 | Result psmGetBatteryChargePercentage(u32 *out); 35 | Result psmGetChargerType(ChargerType *out); 36 | Result psmGetBatteryVoltageState(PsmBatteryVoltageState *out); 37 | 38 | /** 39 | * @brief Wrapper func which opens a PsmSession and handles event setup. 40 | * @note Uses the actual BindStateChangeEvent cmd internally. 41 | * @note The event is not signalled on BatteryChargePercentage changes. 42 | * @param[out] s PsmSession object. 43 | * @param[in] ChargerType Passed to SetChargerTypeChangeEventEnabled. 44 | * @param[in] PowerSupply Passed to SetPowerSupplyChangeEventEnabled. 45 | * @param[in] BatteryVoltage Passed to SetBatteryVoltageStateChangeEventEnabled. 46 | */ 47 | Result psmBindStateChangeEvent(PsmSession* s, bool ChargerType, bool PowerSupply, bool BatteryVoltage); 48 | 49 | /// Wait on the Event setup by \ref psmBindStateChangeEvent. 50 | Result psmWaitStateChangeEvent(PsmSession* s, u64 timeout); 51 | 52 | /// Cleanup version of \ref psmBindStateChangeEvent. Must be called by the user once the PsmSession is done being used. 53 | Result psmUnbindStateChangeEvent(PsmSession* s); 54 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/ro.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file ro.h 3 | * @brief Relocatable Objects (ro) service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/sm.h" 10 | #include "../services/ldr.h" 11 | 12 | Result ldrRoInitialize(void); 13 | void ldrRoExit(void); 14 | 15 | Result ro1Initialize(void); 16 | void ro1Exit(void); 17 | 18 | Result roDmntInitialize(void); 19 | void roDmntExit(void); 20 | 21 | Result ldrRoLoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); 22 | Result ldrRoUnloadNro(u64 nro_address); 23 | Result ldrRoLoadNrr(u64 nrr_address, u64 nrr_size); 24 | Result ldrRoUnloadNrr(u64 nrr_address); 25 | Result ldrRoLoadNrrEx(u64 nrr_address, u64 nrr_size); 26 | 27 | Result ro1LoadNro(u64* out_address, u64 nro_address, u64 nro_size, u64 bss_address, u64 bss_size); 28 | Result ro1UnloadNro(u64 nro_address); 29 | Result ro1LoadNrr(u64 nrr_address, u64 nrr_size); 30 | Result ro1UnloadNrr(u64 nrr_address); 31 | Result ro1LoadNrrEx(u64 nrr_address, u64 nrr_size); 32 | 33 | Result roDmntGetModuleInfos(u64 pid, LoaderModuleInfo *out_module_infos, size_t max_out_modules, u32 *num_out); 34 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/sfdnsres.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file sfdnsres.h 3 | * @brief Domain name resolution service IPC wrapper. Please use socket.c instead. 4 | * @author TuxSH 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | #include // For socklen_t, etc. 11 | 12 | /// Configuration structure for sfdnsres. 13 | typedef struct { 14 | size_t serialized_out_addrinfos_max_size; ///< For getaddrinfo. 15 | size_t serialized_out_hostent_max_size; ///< For gethostbyname/gethostbyaddr. 16 | bool bypass_nsd; ///< For name gethostbyname/getaddrinfo: bypass the Name Server Daemon. 17 | int timeout; ///< For DNS requests: timeout or 0. 18 | } SfdnsresConfig; 19 | 20 | /// Result values returned by the DNS request commands. 21 | typedef struct { 22 | int ret; ///< Return value (error code). 23 | int errno_; ///< Errno. 24 | ssize_t out_serialized_size; ///< Size of the serialized output buffer or -1 (?). 25 | } SfdnsresRequestResults; 26 | 27 | // SetDnsAddressesPrivate & GetDnsAddressPrivate are stubbed 28 | 29 | Result sfdnsresGetHostByName(SfdnsresRequestResults *ret, const SfdnsresConfig *config, void *out_he_serialized, const char *name); 30 | Result sfdnsresGetHostByAddr(SfdnsresRequestResults *ret, const SfdnsresConfig *config, void *out_he_serialized, const void *addr, socklen_t len, int type); 31 | 32 | Result sfdnsresGetHostStringError(int err, char *str, size_t str_size); 33 | Result sfdnsresGetGaiStringError(int err, char *str, size_t str_size); 34 | 35 | Result sfdnsresGetAddrInfo(SfdnsresRequestResults *ret, const SfdnsresConfig *config, const char *node, const char *service, 36 | const void *hints_serialized, size_t hints_serialized_size, void *res_serialized); 37 | Result sfdnsresGetNameInfo(SfdnsresRequestResults *ret, const SfdnsresConfig *config, 38 | const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, 39 | char *serv, size_t servlen, int flags); 40 | 41 | /// Requests an handle for use with @ref sfdnsresCancelSocketCall. 42 | Result sfdnsresRequestCancelHandle(u32 *out_handle); 43 | /// Cancels a DNS request (how? which requests?). Bug: always sets errno? 44 | Result sfdnsresCancelSocketCall(SfdnsresRequestResults *ret, u32 handle); 45 | /// Cancels all DNS requests made by the current process (how? which requests?). Bug: always sets errno? 46 | Result sfdnsresCancelAllSocketCalls(SfdnsresRequestResults *ret); 47 | /// Clears up to 4 DNS server IPs registered by bsdcfg (DHCP client, etc.). 48 | Result sfdnsresClearDnsIpServerAddressArray(void); 49 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/smm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file smm.h 3 | * @brief ServiceManager-IManager (sm:m) service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | #include "../services/sm.h" 10 | #include "../services/fs.h" 11 | 12 | Result smManagerInitialize(void); 13 | void smManagerExit(void); 14 | 15 | Service* smManagerGetServiceSession(void); 16 | 17 | Result smManagerRegisterProcess(u64 pid, const void *acid_sac, size_t acid_sac_size, const void *aci0_sac, size_t aci0_sac_size); 18 | Result smManagerUnregisterProcess(u64 pid); 19 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/spsm.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file spsm.h 3 | * @brief SPSM service IPC wrapper. 4 | * @author SciresM 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | #include "../types.h" 9 | 10 | Result spsmInitialize(void); 11 | void spsmExit(void); 12 | 13 | Result spsmShutdown(bool reboot); 14 | Result spsmPutErrorState(void); 15 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file time.h 3 | * @brief Time services IPC wrapper. 4 | * @author yellows8 5 | * @copyright libnx Authors 6 | */ 7 | #pragma once 8 | 9 | #include "../types.h" 10 | #include "../services/sm.h" 11 | 12 | /// Time clock type. 13 | typedef enum { 14 | TimeType_UserSystemClock, 15 | TimeType_NetworkSystemClock, 16 | TimeType_LocalSystemClock, 17 | TimeType_Default = TimeType_UserSystemClock, 18 | } TimeType; 19 | 20 | typedef struct { 21 | u16 year; 22 | u8 month; 23 | u8 day; 24 | u8 hour; 25 | u8 minute; 26 | u8 second; 27 | u8 pad; 28 | } TimeCalendarTime; 29 | 30 | typedef struct { 31 | u32 wday; ///< 0-based day-of-week. 32 | u32 yday; ///< 0-based day-of-year. 33 | char timezoneName[8]; ///< Timezone name string. 34 | u32 DST; ///< 0 = no DST, 1 = DST. 35 | s32 offset; ///< Seconds relative to UTC for this timezone. 36 | } TimeCalendarAdditionalInfo; 37 | 38 | Result timeInitialize(void); 39 | void timeExit(void); 40 | 41 | Service* timeGetSessionService(void); 42 | 43 | Result timeGetCurrentTime(TimeType type, u64 *timestamp); 44 | 45 | /** 46 | * @brief Sets the time for the specified clock. 47 | * @param[in] type Clock to use. 48 | * @param[in] timestamp POSIX UTC timestamp. 49 | * @return Result code. 50 | */ 51 | Result timeSetCurrentTime(TimeType type, u64 timestamp); 52 | 53 | Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info); 54 | 55 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/services/wlaninf.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file wlaninf.h 3 | * @brief WLAN InfraManager service IPC wrapper. 4 | * @author natinusala 5 | * @copyright libnx Authors 6 | */ 7 | 8 | #pragma once 9 | #include "../kernel/ipc.h" 10 | #include "../services/sm.h" 11 | 12 | /// WLAN State. 13 | typedef enum { 14 | WlanInfState_NotConnected = 1, ///< WLAN is disabled or enabled and not connected. 15 | WlanInfState_Connecting, ///< WLAN is connecting. 16 | WlanInfState_Connected, ///< WLAN is connected. 17 | } WlanInfState; 18 | 19 | Result wlaninfInitialize(void); 20 | void wlaninfExit(void); 21 | 22 | Result wlaninfGetState(WlanInfState* out); 23 | 24 | /// Value goes from -30 (really good signal) to -90 (barely enough to stay connected) 25 | /// on a logarithmic scale 26 | Result wlaninfGetRSSI(s32* out); 27 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/include/switch_min/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file switch/types.h 3 | * @brief Various system types. 4 | * @copyright libnx Authors 5 | */ 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | /// The maximum value of a u64. 14 | #define U64_MAX UINT64_MAX 15 | 16 | #ifndef SSIZE_MAX 17 | #ifdef SIZE_MAX 18 | #define SSIZE_MAX ((SIZE_MAX) >> 1) 19 | #endif 20 | #endif 21 | 22 | typedef uint8_t u8; ///< 8-bit unsigned integer. 23 | typedef uint16_t u16; ///< 16-bit unsigned integer. 24 | typedef uint32_t u32; ///< 32-bit unsigned integer. 25 | typedef uint64_t u64; ///< 64-bit unsigned integer. 26 | typedef __uint128_t u128; ///< 128-bit unsigned integer. 27 | 28 | typedef int8_t s8; ///< 8-bit signed integer. 29 | typedef int16_t s16; ///< 16-bit signed integer. 30 | typedef int32_t s32; ///< 32-bit signed integer. 31 | typedef int64_t s64; ///< 64-bit signed integer. 32 | typedef __int128_t s128; ///< 128-bit unsigned integer. 33 | 34 | typedef volatile u8 vu8; ///< 8-bit volatile unsigned integer. 35 | typedef volatile u16 vu16; ///< 16-bit volatile unsigned integer. 36 | typedef volatile u32 vu32; ///< 32-bit volatile unsigned integer. 37 | typedef volatile u64 vu64; ///< 64-bit volatile unsigned integer. 38 | typedef volatile u128 vu128; ///< 128-bit volatile unsigned integer. 39 | 40 | typedef volatile s8 vs8; ///< 8-bit volatile signed integer. 41 | typedef volatile s16 vs16; ///< 16-bit volatile signed integer. 42 | typedef volatile s32 vs32; ///< 32-bit volatile signed integer. 43 | typedef volatile s64 vs64; ///< 64-bit volatile signed integer. 44 | typedef volatile s128 vs128; ///< 128-bit volatile signed integer. 45 | 46 | typedef u32 Handle; ///< Kernel object handle. 47 | typedef u32 Result; ///< Function error code result type. 48 | typedef void (*ThreadFunc)(void *); ///< Thread entrypoint function. 49 | typedef void (*VoidFn)(void); ///< Function without arguments nor return value. 50 | 51 | /// Creates a bitmask from a bit number. 52 | #ifndef BIT 53 | #define BIT(n) (1U<<(n)) 54 | #endif 55 | 56 | /// Packs a struct so that it won't include padding bytes. 57 | #ifndef PACKED 58 | #define PACKED __attribute__((packed)) 59 | #endif 60 | 61 | /// Marks a function as not returning, for the purposes of compiler optimization. 62 | #ifndef NORETURN 63 | #define NORETURN __attribute__((noreturn)) 64 | #endif 65 | 66 | /// Performs a dummy operation on the specified argument in order to silence compiler warnings about unused arguments. 67 | #ifndef IGNORE_ARG 68 | #define IGNORE_ARG(x) (void)(x) 69 | #endif 70 | 71 | /// Flags a function as deprecated. 72 | #ifndef DEPRECATED 73 | #ifndef LIBNX_NO_DEPRECATION 74 | #define DEPRECATED __attribute__ ((deprecated)) 75 | #else 76 | #define DEPRECATED 77 | #endif 78 | #endif 79 | 80 | /// Invalid handle. 81 | #define INVALID_HANDLE ((Handle) 0) 82 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/lib/libnx_min.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/masagrator/UnityGraphics/7566e366906b436a9d6ab1359bba71d014617753/Plugin/lib/libnx_min/nx/lib/libnx_min.a -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/lib/libnx_mind.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/masagrator/UnityGraphics/7566e366906b436a9d6ab1359bba71d014617753/Plugin/lib/libnx_min/nx/lib/libnx_mind.a -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/switch.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(aarch64) 2 | ENTRY(_start) 3 | 4 | PHDRS 5 | { 6 | code PT_LOAD FLAGS(5) /* Read | Execute */; 7 | rodata PT_LOAD FLAGS(4) /* Read */; 8 | data PT_LOAD FLAGS(6) /* Read | Write */; 9 | dyn PT_DYNAMIC; 10 | } 11 | 12 | SECTIONS 13 | { 14 | /* =========== CODE section =========== */ 15 | PROVIDE(__start__ = 0x0); 16 | . = __start__; 17 | __code_start = . ; 18 | 19 | .crt0 : 20 | { 21 | KEEP (*(.crt0)) 22 | . = ALIGN(8); 23 | } :code 24 | 25 | .init : 26 | { 27 | KEEP( *(.init) ) 28 | . = ALIGN(8); 29 | } :code 30 | 31 | .plt : 32 | { 33 | *(.plt) 34 | *(.iplt) 35 | . = ALIGN(8); 36 | } :code 37 | 38 | .text : 39 | { 40 | *(.text.unlikely .text.*_unlikely .text.unlikely.*) 41 | *(.text.exit .text.exit.*) 42 | *(.text.startup .text.startup.*) 43 | *(.text.hot .text.hot.*) 44 | *(.text .stub .text.* .gnu.linkonce.t.*) 45 | . = ALIGN(8); 46 | } :code 47 | 48 | .fini : 49 | { 50 | KEEP( *(.fini) ) 51 | . = ALIGN(8); 52 | } :code 53 | 54 | /* =========== RODATA section =========== */ 55 | . = ALIGN(0x1000); 56 | __rodata_start = . ; 57 | 58 | .nx-module-name : { KEEP (*(.nx-module-name)) } :rodata 59 | 60 | .rodata : 61 | { 62 | *(.rodata .rodata.* .gnu.linkonce.r.*) 63 | . = ALIGN(8); 64 | } :rodata 65 | 66 | .eh_frame_hdr : { __eh_frame_hdr_start = .; *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) __eh_frame_hdr_end = .; } :rodata 67 | .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rodata 68 | .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } :rodata 69 | .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } : rodata 70 | 71 | .dynamic : { *(.dynamic) } :rodata :dyn 72 | .dynsym : { *(.dynsym) } :rodata 73 | .dynstr : { *(.dynstr) } :rodata 74 | .rela.dyn : { *(.rela.*) } :rodata 75 | .interp : { *(.interp) } :rodata 76 | .hash : { *(.hash) } :rodata 77 | .gnu.hash : { *(.gnu.hash) } :rodata 78 | .gnu.version : { *(.gnu.version) } :rodata 79 | .gnu.version_d : { *(.gnu.version_d) } :rodata 80 | .gnu.version_r : { *(.gnu.version_r) } :rodata 81 | .note.gnu.build-id : { *(.note.gnu.build-id) } :rodata 82 | 83 | /* =========== DATA section =========== */ 84 | . = ALIGN(0x1000); 85 | __data_start = . ; 86 | 87 | .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :data 88 | .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } :data 89 | .gnu_extab : ONLY_IF_RW { *(.gnu_extab*) } : data 90 | .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } :data 91 | 92 | .tdata ALIGN(8) : 93 | { 94 | __tdata_lma = .; 95 | *(.tdata .tdata.* .gnu.linkonce.td.*) 96 | . = ALIGN(8); 97 | __tdata_lma_end = .; 98 | } :data 99 | 100 | .tbss ALIGN(8) : 101 | { 102 | *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) 103 | . = ALIGN(8); 104 | } :data 105 | 106 | .preinit_array ALIGN(8) : 107 | { 108 | PROVIDE (__preinit_array_start = .); 109 | KEEP (*(.preinit_array)) 110 | PROVIDE (__preinit_array_end = .); 111 | } :data 112 | 113 | .init_array ALIGN(8) : 114 | { 115 | PROVIDE (__init_array_start = .); 116 | KEEP (*(SORT(.init_array.*))) 117 | KEEP (*(.init_array)) 118 | PROVIDE (__init_array_end = .); 119 | } :data 120 | 121 | .fini_array ALIGN(8) : 122 | { 123 | PROVIDE (__fini_array_start = .); 124 | KEEP (*(.fini_array)) 125 | KEEP (*(SORT(.fini_array.*))) 126 | PROVIDE (__fini_array_end = .); 127 | } :data 128 | 129 | .ctors ALIGN(8) : 130 | { 131 | KEEP (*crtbegin.o(.ctors)) /* MUST be first -- GCC requires it */ 132 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 133 | KEEP (*(SORT(.ctors.*))) 134 | KEEP (*(.ctors)) 135 | } :data 136 | 137 | .dtors ALIGN(8) : 138 | { 139 | KEEP (*crtbegin.o(.dtors)) 140 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 141 | KEEP (*(SORT(.dtors.*))) 142 | KEEP (*(.dtors)) 143 | } :data 144 | 145 | __got_start__ = .; 146 | 147 | .got : { *(.got) *(.igot) } :data 148 | .got.plt : { *(.got.plt) *(.igot.plt) } :data 149 | 150 | __got_end__ = .; 151 | 152 | .data ALIGN(8) : 153 | { 154 | *(.data .data.* .gnu.linkonce.d.*) 155 | SORT(CONSTRUCTORS) 156 | } :data 157 | 158 | __bss_start__ = .; 159 | .bss ALIGN(8) : 160 | { 161 | *(.dynbss) 162 | *(.bss .bss.* .gnu.linkonce.b.*) 163 | *(COMMON) 164 | . = ALIGN(8); 165 | 166 | /* Reserve space for the TLS segment of the main thread */ 167 | __tls_start = .; 168 | . += + SIZEOF(.tdata) + SIZEOF(.tbss); 169 | __tls_end = .; 170 | } : data 171 | __bss_end__ = .; 172 | 173 | __end__ = ABSOLUTE(.) ; 174 | 175 | . = ALIGN(0x1000); 176 | __argdata__ = ABSOLUTE(.) ; 177 | 178 | /* ================== 179 | ==== Metadata ==== 180 | ================== */ 181 | 182 | /* Discard sections that difficult post-processing */ 183 | /DISCARD/ : { *(.group .comment .note) } 184 | 185 | /* Stabs debugging sections. */ 186 | .stab 0 : { *(.stab) } 187 | .stabstr 0 : { *(.stabstr) } 188 | .stab.excl 0 : { *(.stab.excl) } 189 | .stab.exclstr 0 : { *(.stab.exclstr) } 190 | .stab.index 0 : { *(.stab.index) } 191 | .stab.indexstr 0 : { *(.stab.indexstr) } 192 | 193 | /* DWARF debug sections. 194 | Symbols in the DWARF debugging sections are relative to the beginning 195 | of the section so we begin them at 0. */ 196 | 197 | /* DWARF 1 */ 198 | .debug 0 : { *(.debug) } 199 | .line 0 : { *(.line) } 200 | 201 | /* GNU DWARF 1 extensions */ 202 | .debug_srcinfo 0 : { *(.debug_srcinfo) } 203 | .debug_sfnames 0 : { *(.debug_sfnames) } 204 | 205 | /* DWARF 1.1 and DWARF 2 */ 206 | .debug_aranges 0 : { *(.debug_aranges) } 207 | .debug_pubnames 0 : { *(.debug_pubnames) } 208 | 209 | /* DWARF 2 */ 210 | .debug_info 0 : { *(.debug_info) } 211 | .debug_abbrev 0 : { *(.debug_abbrev) } 212 | .debug_line 0 : { *(.debug_line) } 213 | .debug_frame 0 : { *(.debug_frame) } 214 | .debug_str 0 : { *(.debug_str) } 215 | .debug_loc 0 : { *(.debug_loc) } 216 | .debug_macinfo 0 : { *(.debug_macinfo) } 217 | } 218 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/switch.specs: -------------------------------------------------------------------------------- 1 | %rename link old_link 2 | 3 | *link: 4 | %(old_link) -T %:getenv(DEVKITPRO /libnx/switch.ld) -pie --gc-sections -z text -z nodynamic-undefined-weak --build-id=sha1 --nx-module-name 5 | 6 | *startfile: 7 | crti%O%s crtbegin%O%s 8 | 9 | -------------------------------------------------------------------------------- /Plugin/lib/libnx_min/nx/switch_rules: -------------------------------------------------------------------------------- 1 | ifeq ($(strip $(DEVKITPRO)),) 2 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro) 3 | endif 4 | 5 | include $(DEVKITPRO)/devkitA64/base_rules 6 | 7 | PORTLIBS := $(PORTLIBS_PATH)/switch 8 | PATH := $(PORTLIBS)/bin:$(PATH) 9 | 10 | LIBNX ?= $(DEVKITPRO)/libnx 11 | 12 | ifeq ($(strip $(APP_TITLE)),) 13 | APP_TITLE := $(notdir $(OUTPUT)) 14 | endif 15 | 16 | ifeq ($(strip $(APP_AUTHOR)),) 17 | APP_AUTHOR := Unspecified Author 18 | endif 19 | 20 | ifeq ($(strip $(APP_VERSION)),) 21 | APP_VERSION := 1.0.0 22 | endif 23 | 24 | ifeq ($(strip $(APP_ICON)),) 25 | APP_ICON := $(LIBNX)/default_icon.jpg 26 | endif 27 | 28 | #--------------------------------------------------------------------------------- 29 | %.nacp: $(MAKEFILE_LIST) 30 | @nacptool --create "$(APP_TITLE)" "$(APP_AUTHOR)" "$(APP_VERSION)" $@ $(NACPFLAGS) 31 | @echo built ... $(notdir $@) 32 | 33 | #--------------------------------------------------------------------------------- 34 | %.npdm: $(APP_JSON) 35 | @npdmtool $< $@ 36 | @echo built ... $(notdir $@) 37 | 38 | #--------------------------------------------------------------------------------- 39 | define make_pfs0 40 | @mkdir -p exefs 41 | @[ $(BUILD_EXEFS_SRC) ] && [ -d $(BUILD_EXEFS_SRC) ] && cp -R $(BUILD_EXEFS_SRC)/* exefs || echo > /dev/null 42 | @cp $*.nso exefs/main 43 | @[ $(APP_JSON) ] && cp $*.npdm exefs/main.npdm || echo > /dev/null 44 | @build_pfs0 exefs $@ 45 | @echo built ... $(notdir $@) 46 | endef 47 | 48 | ifeq ($(strip $(APP_JSON)),) 49 | %.pfs0: %.nso 50 | else 51 | %.pfs0: %.nso %.npdm 52 | endif 53 | $(make_pfs0) 54 | 55 | ifeq ($(strip $(APP_JSON)),) 56 | %.nsp: %.nso 57 | else 58 | %.nsp: %.nso %.npdm 59 | endif 60 | $(make_pfs0) 61 | 62 | #--------------------------------------------------------------------------------- 63 | %.nso: %.elf 64 | @elf2nso $< $@ 65 | @echo built ... $(notdir $@) 66 | 67 | #--------------------------------------------------------------------------------- 68 | %.nro: %.elf 69 | @elf2nro $< $@ $(NROFLAGS) 70 | @echo built ... $(notdir $@) 71 | 72 | #--------------------------------------------------------------------------------- 73 | %.kip: %.elf 74 | @elf2kip $< $(APP_JSON) $@ 75 | @echo built ... $(notdir $@) 76 | 77 | #--------------------------------------------------------------------------------- 78 | %.elf: 79 | @echo linking $(notdir $@) 80 | @$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ 81 | @$(NM) -CSn $@ > $(notdir $*.lst) 82 | -------------------------------------------------------------------------------- /Plugin/source/ScalableBufferManagerSettings.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | #include "ScalableBufferManagerSettings.hpp" 5 | 6 | namespace UnitySettings { namespace ScalableBufferManager { 7 | 8 | typedef float (*get_widthScaleFactor)(); 9 | uintptr_t ptr_get_widthScaleFactor = 0; 10 | float widthScaleFactor = 0; 11 | 12 | typedef float (*get_heightScaleFactor)(); 13 | uintptr_t ptr_get_heightScaleFactor = 0; 14 | float heightScaleFactor = 0; 15 | 16 | typedef void (*ResizeBuffers)(float f_widthScaleFactor, float f_heightScaleFactor); 17 | uintptr_t ptr_ResizeBuffers = 0; 18 | 19 | void Change (uint8_t m_switchcase) { 20 | switch(m_switchcase) { 21 | 22 | //"UnityEngine.ScalableBufferManager::get_widthScaleFactor" 23 | case 1: 24 | if (ptr_get_widthScaleFactor != 0) widthScaleFactor = ((get_widthScaleFactor)(ptr_get_widthScaleFactor))(); 25 | break; 26 | 27 | //"UnityEngine.ScalableBufferManager::get_heightScaleFactor" 28 | case 2: 29 | if (ptr_get_heightScaleFactor != 0) heightScaleFactor = ((get_heightScaleFactor)(ptr_get_heightScaleFactor))(); 30 | break; 31 | 32 | //"UnityEngine.ScalableBufferManager::ResizeBuffers" 33 | case 3: 34 | if (ptr_ResizeBuffers != 0) ((ResizeBuffers)(ptr_ResizeBuffers))(widthScaleFactor, heightScaleFactor); 35 | break; 36 | 37 | 38 | default: 39 | break; 40 | } 41 | } 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Plugin/source/ScreenSettings.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // 4 | #include "ScreenSettings.hpp" 5 | 6 | namespace UnitySettings { namespace Screen { 7 | 8 | typedef uint32_t (*get_width)(); 9 | uintptr_t ptr_get_width = 0; 10 | uint32_t width = 0; 11 | 12 | typedef uint32_t (*get_height)(); 13 | uintptr_t ptr_get_height = 0; 14 | uint32_t height = 0; 15 | 16 | uintptr_t ptr_get_dpi = 0; 17 | uintptr_t ptr_RequestOrientation = 0; 18 | uintptr_t ptr_GetScreenOrientation = 0; 19 | uintptr_t ptr_get_sleepTimeout = 0; 20 | uintptr_t ptr_set_sleepTimeout = 0; 21 | uintptr_t ptr_IsOrientationEnabled = 0; 22 | uintptr_t ptr_SetOrientationEnabled = 0; 23 | uintptr_t ptr_get_currentResolution_Injected = 0; 24 | uintptr_t ptr_get_fullScreen = 0; 25 | uintptr_t ptr_set_fullScreen = 0; 26 | uintptr_t ptr_get_fullScreenMode = 0; 27 | uintptr_t ptr_set_fullScreenMode = 0; 28 | uintptr_t ptr_get_safeArea_Injected = 0; 29 | 30 | typedef void (*SetResolution)(uint32_t v_width, uint32_t v_height, uint32_t v_fullScreenMode, uint32_t v_preferredRefreshRate); 31 | uintptr_t ptr_SetResolution = 0; 32 | 33 | uintptr_t ptr_get_resolutions = 0; 34 | 35 | void Change (uint8_t m_switchcase) { 36 | switch(m_switchcase) { 37 | 38 | //"UnityEngine.Screen::get_width" 39 | case 1: 40 | if (ptr_get_width != 0) width = ((get_width)(ptr_get_width))(); 41 | break; 42 | 43 | //"UnityEngine.Screen::get_height" 44 | case 2: 45 | if (ptr_get_height != 0) height = ((get_height)(ptr_get_height))(); 46 | break; 47 | 48 | //"UnityEngine.Screen::get_dpi" 49 | case 3: 50 | break; 51 | 52 | //"UnityEngine.Screen::RequestOrientation" 53 | case 4: 54 | break; 55 | 56 | //"UnityEngine.Screen::GetScreenOrientation" 57 | case 5: 58 | break; 59 | 60 | //"UnityEngine.Screen::get_sleepTimeout" 61 | case 6: 62 | break; 63 | 64 | //"UnityEngine.Screen::set_sleepTimeout" 65 | case 7: 66 | break; 67 | 68 | //"UnityEngine.Screen::IsOrientationEnabled" 69 | case 8: 70 | break; 71 | 72 | //"UnityEngine.Screen::SetOrientationEnabled" 73 | case 9: 74 | break; 75 | 76 | //"UnityEngine.Screen::get_currentResolution_Injected" 77 | case 10: 78 | break; 79 | 80 | //"UnityEngine.Screen::get_fullScreen" 81 | case 11: 82 | break; 83 | 84 | //"UnityEngine.Screen::set_fullScreen" 85 | case 12: 86 | break; 87 | 88 | //"UnityEngine.Screen::get_fullScreenMode" 89 | case 13: 90 | break; 91 | 92 | //"UnityEngine.Screen::set_fullScreenMode" 93 | case 14: 94 | break; 95 | 96 | //"UnityEngine.Screen::get_safeArea_Injected" 97 | case 15: 98 | break; 99 | 100 | //"UnityEngine.Screen::SetResolution" 101 | case 16: 102 | if (ptr_SetResolution != 0) ((SetResolution)(ptr_SetResolution))(width, height, 0, 0); 103 | break; 104 | 105 | //"UnityEngine.Screen::get_resolutions" 106 | case 17: 107 | break; 108 | 109 | default: 110 | break; 111 | } 112 | } 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /Plugin/source/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "saltysd/SaltySD_core.h" 4 | #include "saltysd/SaltySD_ipc.h" 5 | #include "saltysd/SaltySD_dynamic.h" 6 | #include "Utils.hpp" 7 | #include 8 | #include 9 | #include 10 | 11 | extern "C" { 12 | extern u32 __start__; 13 | 14 | static char g_heap[0x8000]; 15 | 16 | void __libnx_init(void* ctx, Handle main_thread, void* saved_lr); 17 | void __attribute__((weak)) NORETURN __libnx_exit(int rc); 18 | void __nx_exit(int, void*); 19 | void __libc_fini_array(void); 20 | void __libc_init_array(void); 21 | extern void _ZN2nn2os11SleepThreadENS_8TimeSpanE(void* unk) LINKABLE; 22 | } 23 | 24 | u32 __nx_applet_type = AppletType_None; 25 | 26 | Handle orig_main_thread; 27 | void* orig_ctx; 28 | void* orig_saved_lr; 29 | const char* ver = "0.1.1"; 30 | 31 | const char* CheckTitleID() { 32 | char* titleid = (char*)malloc(0x20); 33 | uint64_t titid = 0; 34 | svcGetInfo(&titid, 18, CUR_PROCESS_HANDLE, 0); 35 | snprintf(titleid, 0x20, "%016" PRIx64, titid); 36 | return titleid; 37 | } 38 | 39 | void __libnx_init(void* ctx, Handle main_thread, void* saved_lr) { 40 | extern char* fake_heap_start; 41 | extern char* fake_heap_end; 42 | 43 | fake_heap_start = &g_heap[0]; 44 | fake_heap_end = &g_heap[sizeof g_heap]; 45 | 46 | orig_ctx = ctx; 47 | orig_main_thread = main_thread; 48 | orig_saved_lr = saved_lr; 49 | 50 | // Call constructors. 51 | //void __libc_init_array(void); 52 | __libc_init_array(); 53 | } 54 | 55 | void __attribute__((weak)) NORETURN __libnx_exit(int rc) { 56 | // Call destructors. 57 | //void __libc_fini_array(void); 58 | __libc_fini_array(); 59 | 60 | SaltySD_printf("SaltySD Plugin: jumping to %p\n", orig_saved_lr); 61 | 62 | __nx_exit(0, orig_saved_lr); 63 | while (true); 64 | } 65 | 66 | void SleepThread(void* unknown) { 67 | if (Utils::switchcase == 0) return _ZN2nn2os11SleepThreadENS_8TimeSpanE(unknown); 68 | switch(Utils::_settings) { 69 | case Utils::Quality: 70 | UnitySettings::Quality::Change(Utils::switchcase); 71 | break; 72 | 73 | case Utils::Screen: 74 | UnitySettings::Screen::Change(Utils::switchcase); 75 | break; 76 | 77 | case Utils::ScalableBufferManager: 78 | UnitySettings::ScalableBufferManager::Change(Utils::switchcase); 79 | break; 80 | 81 | default: 82 | break; 83 | } 84 | 85 | Utils::switchcase = 0; 86 | 87 | return _ZN2nn2os11SleepThreadENS_8TimeSpanE(unknown); 88 | } 89 | 90 | int main(int argc, char *argv[]) { 91 | SaltySD_printf("SaltySD UnityGraphics %s: alive\n", ver); 92 | char path[128]; 93 | const char* tid_check = CheckTitleID(); 94 | sprintf(path, "sdmc:/SaltySD/plugins/UnityGraphics/%s/", tid_check); 95 | DIR* checkDir; 96 | if (checkDir = SaltySDCore_opendir(path)) { 97 | SaltySDCore_closedir(checkDir); 98 | Utils::writeFile(); 99 | SaltySDCore_ReplaceImport("_ZN2nn2os11SleepThreadENS_8TimeSpanE", (void*)SleepThread); 100 | } 101 | 102 | SaltySD_printf("SaltySD UnityGraphics %s: injection finished\n", ver); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /Plugin/switch.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(aarch64) 2 | ENTRY(_start) 3 | 4 | PHDRS 5 | { 6 | code PT_LOAD FLAGS(5) /* Read | Execute */; 7 | rodata PT_LOAD FLAGS(4) /* Read */; 8 | data PT_LOAD FLAGS(6) /* Read | Write */; 9 | dyn PT_DYNAMIC; 10 | } 11 | 12 | SECTIONS 13 | { 14 | /* =========== CODE section =========== */ 15 | PROVIDE(__start__ = 0x0); 16 | . = __start__; 17 | 18 | .crt0 : 19 | { 20 | KEEP (*(.crt0)) 21 | . = ALIGN(8); 22 | } :code 23 | 24 | .init : 25 | { 26 | KEEP( *(.init) ) 27 | . = ALIGN(8); 28 | } :code 29 | 30 | .plt : 31 | { 32 | *(.plt) 33 | *(.iplt) 34 | . = ALIGN(8); 35 | } :code 36 | 37 | .text : 38 | { 39 | *(.text.unlikely .text.*_unlikely .text.unlikely.*) 40 | *(.text.exit .text.exit.*) 41 | *(.text.startup .text.startup.*) 42 | *(.text.hot .text.hot.*) 43 | *(.text .stub .text.* .gnu.linkonce.t.*) 44 | . = ALIGN(8); 45 | } :code 46 | 47 | .fini : 48 | { 49 | KEEP( *(.fini) ) 50 | . = ALIGN(8); 51 | } :code 52 | 53 | /* =========== RODATA section =========== */ 54 | . = ALIGN(0x1000); 55 | 56 | .rodata : 57 | { 58 | *(.rodata .rodata.* .gnu.linkonce.r.*) 59 | . = ALIGN(8); 60 | } :rodata 61 | 62 | .eh_frame_hdr : { __eh_frame_hdr_start = .; *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) __eh_frame_hdr_end = .; } :rodata 63 | .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) } :rodata 64 | .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) } :rodata 65 | .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) } : rodata 66 | 67 | .dynamic : { *(.dynamic) } :rodata :dyn 68 | .dynsym : { *(.dynsym) } :rodata 69 | .dynstr : { *(.dynstr) } :rodata 70 | .rela.dyn : { *(.rela.*) } :rodata 71 | .interp : { *(.interp) } :rodata 72 | .hash : { *(.hash) } :rodata 73 | .gnu.hash : { *(.gnu.hash) } :rodata 74 | .gnu.version : { *(.gnu.version) } :rodata 75 | .gnu.version_d : { *(.gnu.version_d) } :rodata 76 | .gnu.version_r : { *(.gnu.version_r) } :rodata 77 | .note.gnu.build-id : { *(.note.gnu.build-id) } :rodata 78 | 79 | /* =========== DATA section =========== */ 80 | . = ALIGN(0x1000); 81 | 82 | .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) } :data 83 | .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) } :data 84 | .gnu_extab : ONLY_IF_RW { *(.gnu_extab*) } : data 85 | .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) } :data 86 | 87 | .tdata ALIGN(8) : 88 | { 89 | __tdata_lma = .; 90 | *(.tdata .tdata.* .gnu.linkonce.td.*) 91 | . = ALIGN(8); 92 | __tdata_lma_end = .; 93 | } :data 94 | 95 | .tbss ALIGN(8) : 96 | { 97 | *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) 98 | . = ALIGN(8); 99 | } :data 100 | 101 | .preinit_array ALIGN(8) : 102 | { 103 | PROVIDE (__preinit_array_start = .); 104 | KEEP (*(.preinit_array)) 105 | PROVIDE (__preinit_array_end = .); 106 | } :data 107 | 108 | .init_array ALIGN(8) : 109 | { 110 | PROVIDE (__init_array_start = .); 111 | KEEP (*(SORT(.init_array.*))) 112 | KEEP (*(.init_array)) 113 | PROVIDE (__init_array_end = .); 114 | } :data 115 | 116 | .fini_array ALIGN(8) : 117 | { 118 | PROVIDE (__fini_array_start = .); 119 | KEEP (*(.fini_array)) 120 | KEEP (*(SORT(.fini_array.*))) 121 | PROVIDE (__fini_array_end = .); 122 | } :data 123 | 124 | .ctors ALIGN(8) : 125 | { 126 | KEEP (*crtbegin.o(.ctors)) /* MUST be first -- GCC requires it */ 127 | KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) 128 | KEEP (*(SORT(.ctors.*))) 129 | KEEP (*(.ctors)) 130 | } :data 131 | 132 | .dtors ALIGN(8) : 133 | { 134 | KEEP (*crtbegin.o(.dtors)) 135 | KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) 136 | KEEP (*(SORT(.dtors.*))) 137 | KEEP (*(.dtors)) 138 | } :data 139 | 140 | __got_start__ = .; 141 | 142 | .got : { *(.got) *(.igot) } :data 143 | .got.plt : { *(.got.plt) *(.igot.plt) } :data 144 | 145 | __got_end__ = .; 146 | 147 | .data ALIGN(8) : 148 | { 149 | *(.data .data.* .gnu.linkonce.d.*) 150 | SORT(CONSTRUCTORS) 151 | } :data 152 | 153 | __bss_start__ = .; 154 | .bss ALIGN(8) : 155 | { 156 | *(.dynbss) 157 | *(.bss .bss.* .gnu.linkonce.b.*) 158 | *(COMMON) 159 | . = ALIGN(8); 160 | 161 | /* Reserve space for the TLS segment of the main thread */ 162 | __tls_start = .; 163 | . += + SIZEOF(.tdata) + SIZEOF(.tbss); 164 | __tls_end = .; 165 | } : data 166 | __bss_end__ = .; 167 | 168 | __end__ = ABSOLUTE(.) ; 169 | 170 | . = ALIGN(0x1000); 171 | __argdata__ = ABSOLUTE(.) ; 172 | 173 | /* ================== 174 | ==== Metadata ==== 175 | ================== */ 176 | 177 | /* Discard sections that difficult post-processing */ 178 | /DISCARD/ : { *(.group .comment .note) } 179 | 180 | /* Stabs debugging sections. */ 181 | .stab 0 : { *(.stab) } 182 | .stabstr 0 : { *(.stabstr) } 183 | .stab.excl 0 : { *(.stab.excl) } 184 | .stab.exclstr 0 : { *(.stab.exclstr) } 185 | .stab.index 0 : { *(.stab.index) } 186 | .stab.indexstr 0 : { *(.stab.indexstr) } 187 | 188 | /* DWARF debug sections. 189 | Symbols in the DWARF debugging sections are relative to the beginning 190 | of the section so we begin them at 0. */ 191 | 192 | /* DWARF 1 */ 193 | .debug 0 : { *(.debug) } 194 | .line 0 : { *(.line) } 195 | 196 | /* GNU DWARF 1 extensions */ 197 | .debug_srcinfo 0 : { *(.debug_srcinfo) } 198 | .debug_sfnames 0 : { *(.debug_sfnames) } 199 | 200 | /* DWARF 1.1 and DWARF 2 */ 201 | .debug_aranges 0 : { *(.debug_aranges) } 202 | .debug_pubnames 0 : { *(.debug_pubnames) } 203 | 204 | /* DWARF 2 */ 205 | .debug_info 0 : { *(.debug_info) } 206 | .debug_abbrev 0 : { *(.debug_abbrev) } 207 | .debug_line 0 : { *(.debug_line) } 208 | .debug_frame 0 : { *(.debug_frame) } 209 | .debug_str 0 : { *(.debug_str) } 210 | .debug_loc 0 : { *(.debug_loc) } 211 | .debug_macinfo 0 : { *(.debug_macinfo) } 212 | } 213 | -------------------------------------------------------------------------------- /Plugin/switch.specs: -------------------------------------------------------------------------------- 1 | %rename link old_link 2 | 3 | *link: 4 | %(old_link) -T %:getenv(TOPDIR /switch.ld) -pie --gc-sections -z text --build-id=sha1 5 | 6 | *startfile: 7 | crti%O%s crtbegin%O%s 8 | 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityGraphics 2 | 3 | This is a combination of SaltyNX plugin and Tesla overlay that allows to modify in real time graphics settings in games using Unity engine. 4 | 5 | ![screen](https://github.com/masagrator/UnityGraphics/blob/master/Screen.jpg?raw=true) 6 | 7 | Requirements: 8 | - Atmosphere (This is related to dmnt:cht that allows homebrews for reading build_id of running games. SX OS doesn't provide this info). Not tested on ReinX 9 | - Tesla environment 10 | - SaltyNX 11 | - File with offsets dedicated to game (you can find storage here: https://github.com/masagrator/UnityGraphicsWarehouse) 12 | 13 | --- 14 | 15 | For now UnityGraphics supports only: 16 | - Quality category excluding: 17 | 18 | -- `shadowCascade4Split_Injected` (requires using Vector3 struct) 19 | 20 | -- `QualityLevel` (they are just profiles and cannot be used to bring default settings, so I don't bother with implementing it). 21 | 22 | - SetResolution from Screen category 23 | 24 | - Games made with Unity 2017.1 and newer 25 | 26 | I'm not implementing functions that doesn't have "set" counterpart. 27 | 28 | 29 | To learn what each setting does read Unity documentation. Be aware that game may use different Unity version. You can change version in left upper corner. 30 | 31 | https://docs.unity3d.com/2019.3/Documentation/Manual/class-QualitySettings.html 32 | 33 | You can disable plugin when no game is running. Just open overlay and deactivate plugin. It is recommended to deactivate it when not running Unity game as some games can crash at boot for some unknown reason (f.e. Paper Mario). 34 | 35 | --- 36 | 37 | # This tool is for advanced users. 38 | 39 | # Changing any setting can result in crashing game or showing unexpected bugs. 40 | 41 | # I don't take any responsibility for damage it can provide. 42 | 43 | # You're using it at your own risk. 44 | -------------------------------------------------------------------------------- /Screen.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/masagrator/UnityGraphics/7566e366906b436a9d6ab1359bba71d014617753/Screen.jpg --------------------------------------------------------------------------------