├── .gitignore ├── .gitmodules ├── .github ├── FUNDING.yml └── workflows │ └── main.yml ├── README.md ├── source ├── main.cpp └── gui_main.cpp ├── include └── gui_main.hpp ├── .vscode ├── settings.json └── c_cpp_properties.json ├── Makefile └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | build/ 3 | 4 | *.ovl 5 | 6 | *.elf 7 | 8 | *.nacp 9 | 10 | *.nro 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/libultrahand"] 2 | path = libs/libultrahand 3 | url = https://github.com/ppkantorski/libultrahand 4 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | patreon: werwolv 4 | custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KP7XRJAND9KWU&source=url 5 | github: WerWolv 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ovlSysmodule 2 | 3 | An Ultrahand / Tesla overlay that allows you to toggle sysmodules on the fly 4 | 5 | ## Installation 6 | 7 | Download the latest ovlSysmodules.ovl from the release page and drop it into the /switch/.overlays folder on your Switch's SD card 8 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: ci 3 | 4 | on: 5 | push: 6 | branches: 7 | - master 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | container: devkitpro/devkita64 13 | 14 | steps: 15 | - name: Checkout project 16 | uses: actions/checkout@v3 17 | with: 18 | submodules: recursive 19 | 20 | - name: Build project 21 | run: make 22 | 23 | - name: Upload artifacts 24 | uses: actions/upload-artifact@v3 25 | with: 26 | path: ovlSysmodules.ovl 27 | -------------------------------------------------------------------------------- /source/main.cpp: -------------------------------------------------------------------------------- 1 | #define TESLA_INIT_IMPL 2 | #include "gui_main.hpp" 3 | 4 | class OverlaySysmodules : public tsl::Overlay { 5 | public: 6 | OverlaySysmodules() {} 7 | ~OverlaySysmodules() {} 8 | 9 | void initServices() override { 10 | pmshellInitialize(); 11 | } 12 | 13 | void exitServices() override { 14 | pmshellExit(); 15 | } 16 | 17 | std::unique_ptr loadInitialGui() override { 18 | return std::make_unique(); 19 | } 20 | }; 21 | 22 | int main(int argc, char** argv) { 23 | return tsl::loop(argc, argv); 24 | } -------------------------------------------------------------------------------- /include/gui_main.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | struct SystemModule { 10 | tsl::elm::ListItem *listItem; 11 | u64 programId; 12 | bool needReboot; 13 | char flagPath[FS_MAX_PATH]; // Cached flag file path 14 | char folderPath[FS_MAX_PATH]; // Cached flags folder path 15 | std::string displayName; // Store original name + version 16 | std::string titleIdStr; // Store formatted title ID 17 | }; 18 | 19 | class GuiMain : public tsl::Gui { 20 | private: 21 | std::vector m_sysmoduleListItems; 22 | bool m_scanned = false; 23 | bool m_isActive = true; 24 | bool m_showTitleIds = false; // Toggle state 25 | 26 | public: 27 | GuiMain(); 28 | ~GuiMain(); 29 | 30 | virtual tsl::elm::Element *createUI(); 31 | virtual void update() override; 32 | virtual bool handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState leftJoyStick, HidAnalogStickState rightJoyStick) override; 33 | 34 | private: 35 | void updateStatus(const SystemModule &module); 36 | bool hasFlag(const SystemModule &module); 37 | bool isRunning(const SystemModule &module); 38 | void toggleTitleIdDisplay(); 39 | }; -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "chrono": "cpp", 4 | "string_view": "cpp", 5 | "array": "cpp", 6 | "atomic": "cpp", 7 | "bit": "cpp", 8 | "*.tcc": "cpp", 9 | "cctype": "cpp", 10 | "clocale": "cpp", 11 | "cmath": "cpp", 12 | "cstdarg": "cpp", 13 | "cstddef": "cpp", 14 | "cstdint": "cpp", 15 | "cstdio": "cpp", 16 | "cstdlib": "cpp", 17 | "cstring": "cpp", 18 | "ctime": "cpp", 19 | "cwchar": "cpp", 20 | "cwctype": "cpp", 21 | "deque": "cpp", 22 | "unordered_map": "cpp", 23 | "vector": "cpp", 24 | "exception": "cpp", 25 | "algorithm": "cpp", 26 | "functional": "cpp", 27 | "iterator": "cpp", 28 | "memory": "cpp", 29 | "memory_resource": "cpp", 30 | "numeric": "cpp", 31 | "optional": "cpp", 32 | "random": "cpp", 33 | "ratio": "cpp", 34 | "string": "cpp", 35 | "system_error": "cpp", 36 | "tuple": "cpp", 37 | "type_traits": "cpp", 38 | "utility": "cpp", 39 | "fstream": "cpp", 40 | "initializer_list": "cpp", 41 | "iosfwd": "cpp", 42 | "istream": "cpp", 43 | "limits": "cpp", 44 | "new": "cpp", 45 | "ostream": "cpp", 46 | "sstream": "cpp", 47 | "stdexcept": "cpp", 48 | "streambuf": "cpp", 49 | "thread": "cpp", 50 | "cinttypes": "cpp", 51 | "typeinfo": "cpp", 52 | "codecvt": "cpp", 53 | "condition_variable": "cpp", 54 | "iomanip": "cpp", 55 | "mutex": "cpp", 56 | "forward_list": "cpp", 57 | "list": "cpp", 58 | "map": "cpp", 59 | "valarray": "cpp" 60 | } 61 | } -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "DKP Aarch64 Windows", 5 | "includePath": [ 6 | "C:/devkitPro/devkitA64/aarch64-none-elf/include/**", 7 | "C:/devkitPro/devkitA64/lib/gcc/aarch64-none-elf/8.3.0/include/**", 8 | "C:/devkitPro/libnx/include/**", 9 | "C:/devkitPro/portlibs/switch/include/**", 10 | "C:/devkitPro/portlibs/switch/include/freetype2/**", 11 | "${workspaceFolder}/include/**", 12 | "${workspaceFolder}/libtesla/include/**" 13 | ], 14 | "defines": [ 15 | "SWITCH", 16 | "__SWITCH__", 17 | "__aarch64__", 18 | "VERSION=\"\"" 19 | ], 20 | "compilerPath": "C:/devkitPro/devkitA64/bin/aarch64-none-elf-g++", 21 | "cStandard": "c11", 22 | "cppStandard": "c++17", 23 | "intelliSenseMode": "gcc-x64" 24 | }, 25 | { 26 | "name": "DKP Aarch64 Linux", 27 | "includePath": [ 28 | "/opt/devkitpro/devkitA64/aarch64-none-elf/include/**", 29 | "/opt/devkitpro/devkitA64/lib/gcc/aarch64-none-elf/8.3.0/include/**", 30 | "/opt/devkitpro/libnx/include/**", 31 | "/opt/devkitpro/portlibs/switch/include/**", 32 | "/opt/devkitpro/portlibs/switch/include/**", 33 | "/opt/devkitpro/portlibs/switch/include/freetype2/**", 34 | "${workspaceFolder}/include/**", 35 | "${workspaceFolder}/libs/libtesla/include/**" 36 | ], 37 | "defines": [ 38 | "SWITCH", 39 | "__SWITCH__", 40 | "__aarch64__", 41 | "VERSION=\"\"" 42 | ], 43 | "compilerPath": "/opt/devkitpro/devkitA64/bin/aarch64-none-elf-g++", 44 | "cStandard": "c11", 45 | "cppStandard": "c++17", 46 | "intelliSenseMode": "gcc-x64" 47 | } 48 | ], 49 | "version": 4 50 | } -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITPRO)),) 6 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") 7 | endif 8 | 9 | TOPDIR ?= $(CURDIR) 10 | include $(DEVKITPRO)/libnx/switch_rules 11 | 12 | #--------------------------------------------------------------------------------- 13 | # TARGET is the name of the output 14 | # BUILD is the directory where object files & intermediate files will be placed 15 | # SOURCES is a list of directories containing source code 16 | # DATA is a list of directories containing data files 17 | # INCLUDES is a list of directories containing header files 18 | # ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional) 19 | # 20 | # NO_ICON: if set to anything, do not use icon. 21 | # NO_NACP: if set to anything, no .nacp file is generated. 22 | # APP_TITLE is the name of the app stored in the .nacp file (Optional) 23 | # APP_AUTHOR is the author of the app stored in the .nacp file (Optional) 24 | # APP_VERSION is the version of the app stored in the .nacp file (Optional) 25 | # APP_TITLEID is the titleID of the app stored in the .nacp file (Optional) 26 | # ICON is the filename of the icon (.jpg), relative to the project folder. 27 | # If not set, it attempts to use one of the following (in this order): 28 | # - .jpg 29 | # - icon.jpg 30 | # - /default_icon.jpg 31 | # 32 | # CONFIG_JSON is the filename of the NPDM config file (.json), relative to the project folder. 33 | # If not set, it attempts to use one of the following (in this order): 34 | # - .json 35 | # - config.json 36 | # If a JSON file is provided or autodetected, an ExeFS PFS0 (.nsp) is built instead 37 | # of a homebrew executable (.nro). This is intended to be used for sysmodules. 38 | # NACP building is skipped as well. 39 | #--------------------------------------------------------------------------------- 40 | APP_TITLE := Sysmodules 41 | APP_VERSION := 1.4.6 42 | 43 | TARGET := ovlSysmodules 44 | BUILD := build 45 | SOURCES := source 46 | DATA := data 47 | INCLUDES := include 48 | 49 | # This location should reflect where you place the libultrahand directory (lib can vary between projects). 50 | include ${TOPDIR}/libs/libultrahand/ultrahand.mk 51 | 52 | 53 | #ifeq ($(RELEASE),) 54 | # APP_VERSION := $(APP_VERSION)-$(shell git describe --dirty --always) 55 | #endif 56 | 57 | NO_ICON := 1 58 | 59 | #--------------------------------------------------------------------------------- 60 | # options for code generation 61 | #--------------------------------------------------------------------------------- 62 | ARCH := -march=armv8-a+simd+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE 63 | 64 | CFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -flto -fuse-linker-plugin -fomit-frame-pointer -finline-small-functions \ 65 | -fno-strict-aliasing -frename-registers -falign-functions=16 \ 66 | $(ARCH) $(DEFINES) 67 | 68 | CFLAGS += $(INCLUDE) -D__SWITCH__ -DAPP_VERSION="\"$(APP_VERSION)\"" -DVERSION="\"$(APP_VERSION)\"" -D_FORTIFY_SOURCE=2 69 | 70 | # Enable appearance overriding 71 | UI_OVERRIDE_PATH := /config/sys-modules/ 72 | CFLAGS += -DUI_OVERRIDE_PATH="\"$(UI_OVERRIDE_PATH)\"" 73 | 74 | 75 | CXXFLAGS := $(CFLAGS) -std=c++26 -Wno-dangling-else -ffast-math 76 | 77 | ASFLAGS := $(ARCH) 78 | LDFLAGS += -specs=$(DEVKITPRO)/libnx/switch.specs $(ARCH) -Wl,-Map,$(notdir $*.map) 79 | 80 | LIBS := -lcurl -lz -lzzip -lmbedtls -lmbedx509 -lmbedcrypto -lnx 81 | 82 | CXXFLAGS += -fno-exceptions -ffunction-sections -fdata-sections -fno-rtti 83 | LDFLAGS += -Wl,--gc-sections -Wl,--as-needed 84 | 85 | # For Ensuring Parallel LTRANS Jobs w/ GCC, make -j6 86 | CXXFLAGS += -flto -fuse-linker-plugin -flto=6 87 | LDFLAGS += -flto=6 88 | 89 | 90 | #--------------------------------------------------------------------------------- 91 | # list of directories containing libraries, this must be the top level containing 92 | # include and lib 93 | #--------------------------------------------------------------------------------- 94 | LIBDIRS := $(PORTLIBS) $(LIBNX) 95 | 96 | 97 | #--------------------------------------------------------------------------------- 98 | # no real need to edit anything past this point unless you need to add additional 99 | # rules for different file extensions 100 | #--------------------------------------------------------------------------------- 101 | ifneq ($(BUILD),$(notdir $(CURDIR))) 102 | #--------------------------------------------------------------------------------- 103 | 104 | export OUTPUT := $(CURDIR)/$(TARGET) 105 | export TOPDIR := $(CURDIR) 106 | 107 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 109 | 110 | export DEPSDIR := $(CURDIR)/$(BUILD) 111 | 112 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 113 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 114 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 115 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 116 | 117 | #--------------------------------------------------------------------------------- 118 | # use CXX for linking C++ projects, CC for standard C 119 | #--------------------------------------------------------------------------------- 120 | ifeq ($(strip $(CPPFILES)),) 121 | #--------------------------------------------------------------------------------- 122 | export LD := $(CC) 123 | #--------------------------------------------------------------------------------- 124 | else 125 | #--------------------------------------------------------------------------------- 126 | export LD := $(CXX) 127 | #--------------------------------------------------------------------------------- 128 | endif 129 | #--------------------------------------------------------------------------------- 130 | 131 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 132 | export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 133 | export OFILES := $(OFILES_BIN) $(OFILES_SRC) 134 | export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) 135 | 136 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 137 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 138 | -I$(CURDIR)/$(BUILD) 139 | 140 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 141 | 142 | ifeq ($(strip $(CONFIG_JSON)),) 143 | jsons := $(wildcard *.json) 144 | ifneq (,$(findstring $(TARGET).json,$(jsons))) 145 | export APP_JSON := $(TOPDIR)/$(TARGET).json 146 | else 147 | ifneq (,$(findstring config.json,$(jsons))) 148 | export APP_JSON := $(TOPDIR)/config.json 149 | endif 150 | endif 151 | else 152 | export APP_JSON := $(TOPDIR)/$(CONFIG_JSON) 153 | endif 154 | 155 | ifeq ($(strip $(ICON)),) 156 | icons := $(wildcard *.jpg) 157 | ifneq (,$(findstring $(TARGET).jpg,$(icons))) 158 | export APP_ICON := $(TOPDIR)/$(TARGET).jpg 159 | else 160 | ifneq (,$(findstring icon.jpg,$(icons))) 161 | export APP_ICON := $(TOPDIR)/icon.jpg 162 | endif 163 | endif 164 | else 165 | export APP_ICON := $(TOPDIR)/$(ICON) 166 | endif 167 | 168 | ifeq ($(strip $(NO_ICON)),) 169 | export NROFLAGS += --icon=$(APP_ICON) 170 | endif 171 | 172 | ifeq ($(strip $(NO_NACP)),) 173 | export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp 174 | endif 175 | 176 | ifneq ($(APP_TITLEID),) 177 | export NACPFLAGS += --titleid=$(APP_TITLEID) 178 | endif 179 | 180 | ifneq ($(ROMFS),) 181 | export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS) 182 | endif 183 | 184 | .PHONY: $(BUILD) clean all 185 | 186 | #--------------------------------------------------------------------------------- 187 | all: $(BUILD) 188 | 189 | 190 | $(BUILD): 191 | @[ -d $@ ] || mkdir -p $@ 192 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 193 | 194 | #--------------------------------------------------------------------------------- 195 | clean: 196 | @rm -fr $(BUILD) $(TARGET).ovl $(TARGET).nro $(TARGET).nacp $(TARGET).elf 197 | 198 | 199 | #--------------------------------------------------------------------------------- 200 | else 201 | .PHONY: all 202 | 203 | DEPENDS := $(OFILES:.o=.d) 204 | 205 | #--------------------------------------------------------------------------------- 206 | # main targets 207 | #--------------------------------------------------------------------------------- 208 | all : $(OUTPUT).ovl 209 | 210 | $(OUTPUT).ovl: $(OUTPUT).elf $(OUTPUT).nacp 211 | @elf2nro $< $@ $(NROFLAGS) 212 | @echo "built ... $(notdir $(OUTPUT).ovl)" 213 | @printf 'ULTR' >> $@ 214 | @printf "Ultrahand signature has been added.\n" 215 | 216 | $(OUTPUT).elf : $(OFILES) 217 | 218 | $(OFILES_SRC) : $(HFILES_BIN) 219 | 220 | #--------------------------------------------------------------------------------- 221 | # you need a rule like this for each extension you use as binary data 222 | #--------------------------------------------------------------------------------- 223 | %.bin.o %_bin.h : %.bin 224 | #--------------------------------------------------------------------------------- 225 | @echo $(notdir $<) 226 | @$(bin2o) 227 | 228 | -include $(DEPENDS) 229 | 230 | #--------------------------------------------------------------------------------------- 231 | endif 232 | #--------------------------------------------------------------------------------------- 233 | -------------------------------------------------------------------------------- /source/gui_main.cpp: -------------------------------------------------------------------------------- 1 | #include "gui_main.hpp" 2 | 3 | constexpr const char* const amsContentsPath = "/atmosphere/contents"; 4 | constexpr const char* const boot2FlagFormat = "/atmosphere/contents/%016lX/flags/boot2.flag"; 5 | constexpr const char* const boot2FlagFolder = "/atmosphere/contents/%016lX/flags"; 6 | 7 | static char pathBuffer[FS_MAX_PATH]; 8 | 9 | constexpr const char* const descriptions[2][2] = { 10 | [0] = { 11 | [0] = "Off", 12 | [1] = "Off", 13 | }, 14 | [1] = { 15 | [0] = "On", 16 | [1] = "On", 17 | }, 18 | }; 19 | 20 | // Pre-allocate buffer for file reading to avoid repeated allocations 21 | static char fileBuffer[4096]; 22 | 23 | GuiMain::GuiMain() { 24 | // Pre-allocate vector for typical number of modules (avoids reallocations) 25 | m_sysmoduleListItems.reserve(32); 26 | 27 | DIR* dir = opendir(amsContentsPath); 28 | if (!dir) 29 | return; 30 | 31 | SystemModule module; 32 | std::string listItemText; 33 | listItemText.reserve(64); 34 | 35 | struct dirent* entry; 36 | /* Iterate over contents folder. */ 37 | while ((entry = readdir(dir)) != nullptr) { 38 | // Skip . and .. entries 39 | if (entry->d_name[0] == '.') 40 | continue; 41 | 42 | // Only process directories 43 | if (entry->d_type != DT_DIR) 44 | continue; 45 | 46 | // Fast path filtering using pointer comparison 47 | if (*(uint32_t*)entry->d_name == *(uint32_t*)&"0100" && *(uint64_t*)(&entry->d_name[4]) != *(uint64_t*)&"00000000") 48 | continue; 49 | 50 | // Build toolbox.json path 51 | std::snprintf(pathBuffer, FS_MAX_PATH, "/atmosphere/contents/%s/toolbox.json", entry->d_name); 52 | 53 | // Use FILE* for file reading 54 | FILE* fp = std::fopen(pathBuffer, "rb"); 55 | if (!fp) 56 | continue; 57 | 58 | // Get file size 59 | std::fseek(fp, 0, SEEK_END); 60 | const long size = std::ftell(fp); 61 | if (size <= 0 || size > 4096) { // Sanity check 62 | std::fclose(fp); 63 | continue; 64 | } 65 | std::fseek(fp, 0, SEEK_SET); 66 | 67 | // Read directly into static buffer - no allocation 68 | const size_t bytesRead = std::fread(fileBuffer, 1, size, fp); 69 | std::fclose(fp); 70 | 71 | if (bytesRead != static_cast(size)) 72 | continue; 73 | 74 | // Null-terminate for cJSON 75 | fileBuffer[size] = '\0'; 76 | 77 | // Parse JSON using cJSON - parse directly from static buffer 78 | cJSON* toolboxFileContent = cJSON_ParseWithLength(fileBuffer, size); 79 | if (!toolboxFileContent) 80 | continue; 81 | 82 | // Get tid field 83 | cJSON* tidItem = cJSON_GetObjectItem(toolboxFileContent, "tid"); 84 | if (!tidItem || !cJSON_IsString(tidItem)) { 85 | cJSON_Delete(toolboxFileContent); 86 | continue; 87 | } 88 | 89 | const u64 sysmoduleProgramId = std::strtoul(tidItem->valuestring, nullptr, 16); 90 | 91 | /* Let's not allow Tesla to be killed with this. */ 92 | if (sysmoduleProgramId == 0x420000000007E51AULL) { 93 | cJSON_Delete(toolboxFileContent); 94 | continue; 95 | } 96 | 97 | // Get name field 98 | cJSON* nameItem = cJSON_GetObjectItem(toolboxFileContent, "name"); 99 | if (!nameItem || !cJSON_IsString(nameItem)) { 100 | cJSON_Delete(toolboxFileContent); 101 | continue; 102 | } 103 | 104 | // Get requires_reboot field 105 | cJSON* rebootItem = cJSON_GetObjectItem(toolboxFileContent, "requires_reboot"); 106 | if (!rebootItem || !cJSON_IsBool(rebootItem)) { 107 | cJSON_Delete(toolboxFileContent); 108 | continue; 109 | } 110 | 111 | // Build list item text efficiently - assign directly without clearing 112 | listItemText.assign(nameItem->valuestring); 113 | 114 | cJSON* versionItem = cJSON_GetObjectItem(toolboxFileContent, "version"); 115 | if (versionItem && cJSON_IsString(versionItem)) { 116 | listItemText += ""; 117 | listItemText += versionItem->valuestring; 118 | } 119 | 120 | // Create formatted title ID string 121 | char titleIdBuffer[32]; 122 | std::snprintf(titleIdBuffer, sizeof(titleIdBuffer), "%016lX", sysmoduleProgramId); 123 | 124 | module = { 125 | .listItem = new tsl::elm::ListItem(listItemText), 126 | .programId = sysmoduleProgramId, 127 | .needReboot = static_cast(cJSON_IsTrue(rebootItem)), 128 | .displayName = listItemText, 129 | .titleIdStr = titleIdBuffer, 130 | }; 131 | 132 | cJSON_Delete(toolboxFileContent); 133 | 134 | // Pre-build and cache the flag path 135 | std::snprintf(module.flagPath, FS_MAX_PATH, boot2FlagFormat, module.programId); 136 | 137 | // Pre-build and cache the folder path 138 | std::snprintf(module.folderPath, FS_MAX_PATH, boot2FlagFolder, module.programId); 139 | 140 | module.listItem->setClickListener([this, module](u64 click) -> bool { 141 | if (module.needReboot) { 142 | module.listItem->isLocked = true; 143 | } 144 | 145 | if (click & KEY_A && !module.needReboot) { 146 | if (this->isRunning(module)) { 147 | /* Kill process. */ 148 | pmshellTerminateProgram(module.programId); 149 | } else { 150 | /* Start process. */ 151 | const NcmProgramLocation programLocation{ 152 | .program_id = module.programId, 153 | .storageID = NcmStorageId_None, 154 | }; 155 | u64 pid = 0; 156 | pmshellLaunchProgram(0, &programLocation, &pid); 157 | } 158 | return true; 159 | } 160 | 161 | if (click & KEY_Y) { 162 | // Use cached paths 163 | if (this->hasFlag(module)) { 164 | /* Remove boot2 flag file. */ 165 | std::remove(module.flagPath); 166 | } else { 167 | /* Create flags directory if needed (cached path). */ 168 | mkdir(module.folderPath, 0777); 169 | 170 | /* Create boot2 flag file. */ 171 | FILE* flagFile = std::fopen(module.flagPath, "wb"); 172 | if (flagFile) 173 | std::fclose(flagFile); 174 | } 175 | triggerRumbleClick.store(true, std::memory_order_release); 176 | triggerSettingsSound.store(true, std::memory_order_release); 177 | return true; 178 | } 179 | 180 | return false; 181 | }); 182 | this->m_sysmoduleListItems.push_back(std::move(module)); 183 | } 184 | 185 | closedir(dir); 186 | 187 | /* Sort modules alphabetically by name using std::sort (faster than list::sort) */ 188 | std::sort(this->m_sysmoduleListItems.begin(), this->m_sysmoduleListItems.end(), 189 | [](const SystemModule &a, const SystemModule &b) { 190 | return a.listItem->getText() < b.listItem->getText(); 191 | }); 192 | 193 | this->m_scanned = true; 194 | } 195 | 196 | GuiMain::~GuiMain() { 197 | // Signal that we're shutting down to skip any pending updates 198 | m_isActive = false; 199 | 200 | // Fast cleanup - vector destructor handles the rest 201 | //m_sysmoduleListItems.clear(); 202 | } 203 | 204 | // Method to draw available RAM only 205 | inline void drawMemoryWidget(auto renderer) { 206 | static char ramString[24]; 207 | static tsl::Color ramColor = {0,0,0,0}; 208 | static u64 lastUpdateTick = 0; 209 | const u64 ticksPerSecond = armGetSystemTickFreq(); 210 | 211 | const u64 currentTick = armGetSystemTick(); 212 | 213 | // Update every second 214 | if (lastUpdateTick == 0 || currentTick - lastUpdateTick >= ticksPerSecond) { 215 | u64 RAM_Used_system_u, RAM_Total_system_u; 216 | svcGetSystemInfo(&RAM_Used_system_u, 1, INVALID_HANDLE, 2); 217 | svcGetSystemInfo(&RAM_Total_system_u, 0, INVALID_HANDLE, 2); 218 | 219 | const u64 freeRamBytes = RAM_Total_system_u - RAM_Used_system_u; 220 | 221 | float value; 222 | const char* unit; 223 | 224 | if (freeRamBytes >= 1024ULL * 1024 * 1024) { 225 | value = static_cast(freeRamBytes) / (1024.0f * 1024.0f * 1024.0f); 226 | unit = "GB"; 227 | } else { 228 | value = static_cast(freeRamBytes) / (1024.0f * 1024.0f); 229 | unit = "MB"; 230 | } 231 | 232 | int decimalPlaces; 233 | if (value >= 1000.0f) { 234 | decimalPlaces = 0; 235 | } else if (value >= 100.0f) { 236 | decimalPlaces = 1; 237 | } else if (value >= 10.0f) { 238 | decimalPlaces = 2; 239 | } else { 240 | decimalPlaces = 3; 241 | } 242 | 243 | std::snprintf(ramString, sizeof(ramString), "%.*f %s %s", decimalPlaces, value, unit, ult::FREE.c_str()); 244 | 245 | const float freeRamMB = static_cast(freeRamBytes) / (1024.0f * 1024.0f); 246 | 247 | if (freeRamMB >= 9.0f){ 248 | ramColor = tsl::healthyRamTextColor; 249 | } else if (freeRamMB >= 3.0f) { 250 | ramColor = tsl::neutralRamTextColor; 251 | } else { 252 | ramColor = tsl::badRamTextColor; 253 | } 254 | 255 | lastUpdateTick = currentTick; 256 | } 257 | 258 | renderer->drawRect(239, 15, 1, 66, renderer->aWithOpacity(tsl::separatorColor)); 259 | 260 | if (!ult::hideWidgetBackdrop) { 261 | renderer->drawUniformRoundedRect(247, 15, (ult::extendedWidgetBackdrop) ? tsl::cfg::FramebufferWidth - 255 : tsl::cfg::FramebufferWidth - 255 + 40, 66, renderer->a(tsl::widgetBackdropColor)); 262 | } 263 | 264 | const int backdropCenterX = 247 + ((tsl::cfg::FramebufferWidth - 255) >> 1); 265 | 266 | // First line: "System" label 267 | size_t y_offset = 44 + 2 - 1; // Same as the clock y_offset in the reference code 268 | const char* systemLabel = ult::SYSTEM_RAM.c_str(); 269 | 270 | if (ult::centerWidgetAlignment) { 271 | const int labelWidth = renderer->getTextDimensions(systemLabel, false, 20).first; 272 | renderer->drawString(systemLabel, false, backdropCenterX - (labelWidth >> 1), y_offset, 20, tsl::headerTextColor); 273 | } else { 274 | const int labelWidth = renderer->getTextDimensions(systemLabel, false, 20).first; 275 | renderer->drawString(systemLabel, false, tsl::cfg::FramebufferWidth - labelWidth - 25, y_offset, 20, tsl::headerTextColor); 276 | } 277 | 278 | // Second line: RAM info 279 | y_offset += 22; // Same spacing as in the reference code 280 | 281 | if (ult::centerWidgetAlignment) { 282 | const int ramWidth = renderer->getTextDimensions(ramString, false, 20).first; 283 | const int currentX = backdropCenterX - (ramWidth >> 1); 284 | renderer->drawString(ramString, false, currentX, y_offset, 20, ramColor); 285 | } else { 286 | const s32 ramWidth = renderer->getTextDimensions(ramString, false, 20).first; 287 | renderer->drawString(ramString, false, tsl::cfg::FramebufferWidth - ramWidth - 25, y_offset, 20, ramColor); 288 | } 289 | } 290 | 291 | tsl::elm::Element* GuiMain::createUI() { 292 | auto* rootFrame = new tsl::elm::HeaderOverlayFrame(97); 293 | rootFrame->setHeader(new tsl::elm::CustomDrawer([this](tsl::gfx::Renderer* renderer, s32 x, s32 y, s32 w, s32 h) { 294 | renderer->drawString("Sysmodules", false, 20, 52, 32, tsl::defaultOverlayColor); 295 | renderer->drawString(VERSION, false, 20, 75, 15, tsl::bannerVersionTextColor); 296 | 297 | drawMemoryWidget(renderer); 298 | })); 299 | 300 | if (this->m_sysmoduleListItems.size() == 0) { 301 | const char* description = this->m_scanned ? "No sysmodules found!" : "Scan failed!"; 302 | 303 | auto* warning = new tsl::elm::CustomDrawer([description](tsl::gfx::Renderer* renderer, s32 x, s32 y, s32 w, s32 h) { 304 | renderer->drawString("\uE150", false, 180, 250, 90, tsl::headerTextColor); 305 | renderer->drawString(description, false, 110, 340, 25, tsl::headerTextColor); 306 | }); 307 | 308 | rootFrame->setContent(warning); 309 | } else { 310 | tsl::elm::List* sysmoduleList = new tsl::elm::List(); 311 | 312 | sysmoduleList->addItem(new tsl::elm::CategoryHeader("Dynamic   Auto Start   Toggle", true)); 313 | sysmoduleList->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer* renderer, s32 x, s32 y, s32 w, s32 h) { 314 | renderer->drawString(" These sysmodules can be toggled at any time.", false, x + 5, y + 13, 15, tsl::warningTextColor); 315 | }), 30); 316 | for (const auto& module : this->m_sysmoduleListItems) { 317 | if (!module.needReboot) 318 | sysmoduleList->addItem(module.listItem); 319 | } 320 | 321 | sysmoduleList->addItem(new tsl::elm::CategoryHeader("Static   Auto Start", true)); 322 | sysmoduleList->addItem(new tsl::elm::CustomDrawer([](tsl::gfx::Renderer* renderer, s32 x, s32 y, s32 w, s32 h) { 323 | renderer->drawString(" These sysmodules need a reboot to work.", false, x + 5, y + 13, 15, tsl::warningTextColor); 324 | }), 30); 325 | for (const auto& module : this->m_sysmoduleListItems) { 326 | if (module.needReboot) { 327 | module.listItem->disableClickAnimation(); 328 | sysmoduleList->addItem(module.listItem); 329 | } 330 | } 331 | rootFrame->setContent(sysmoduleList); 332 | } 333 | 334 | return rootFrame; 335 | } 336 | 337 | void GuiMain::update() { 338 | // Early exit if shutting down - avoids unnecessary work during cleanup 339 | if (!m_isActive) 340 | return; 341 | 342 | static u32 counter = 0; 343 | 344 | // Check every 30 frames (~0.5 seconds at 60fps) 345 | if (counter++ % 30 != 0) 346 | return; 347 | 348 | for (const auto& module : this->m_sysmoduleListItems) { 349 | this->updateStatus(module); 350 | } 351 | } 352 | 353 | bool GuiMain::handleInput(u64 keysDown, u64 keysHeld, const HidTouchState &touchPos, HidAnalogStickState leftJoyStick, HidAnalogStickState rightJoyStick) { 354 | if (keysDown & KEY_MINUS) { 355 | toggleTitleIdDisplay(); 356 | return true; 357 | } 358 | 359 | // Side-note: Not sure why it is needed, but for some reason the Overlay handleInput is being canabolized. Added to ensnsure behavior. 360 | // Navigational boundary cases for handling wrapping 361 | static bool lastDirectionPressed = true; 362 | const bool directionPressed = ((keysHeld & KEY_UP) || (keysHeld & KEY_DOWN) || (keysHeld & KEY_LEFT) || (keysHeld & KEY_RIGHT)); 363 | 364 | if (!directionPressed && lastDirectionPressed) 365 | tsl::elm::s_directionalKeyReleased.store(true, std::memory_order_release); 366 | else if (directionPressed && lastDirectionPressed) 367 | tsl::elm::s_directionalKeyReleased.store(false, std::memory_order_release); 368 | 369 | lastDirectionPressed = directionPressed; 370 | 371 | return false; 372 | } 373 | 374 | void GuiMain::toggleTitleIdDisplay() { 375 | m_showTitleIds = !m_showTitleIds; 376 | 377 | // Update all list items with either title ID or display name 378 | for (auto& module : this->m_sysmoduleListItems) { 379 | if (m_showTitleIds) { 380 | module.listItem->setText(module.titleIdStr); 381 | } else { 382 | module.listItem->setText(module.displayName); 383 | } 384 | } 385 | 386 | // Trigger feedback 387 | triggerRumbleClick.store(true, std::memory_order_release); 388 | triggerSettingsSound.store(true, std::memory_order_release); 389 | } 390 | 391 | void GuiMain::updateStatus(const SystemModule &module) { 392 | const bool running = this->isRunning(module); 393 | const bool hasFlag = this->hasFlag(module); 394 | 395 | const char* desc = descriptions[running][hasFlag]; 396 | module.listItem->setValue(desc, !running); 397 | } 398 | 399 | bool GuiMain::hasFlag(const SystemModule &module) { 400 | // Use access() for fastest file existence check 401 | return access(module.flagPath, F_OK) == 0; 402 | } 403 | 404 | bool GuiMain::isRunning(const SystemModule &module) { 405 | u64 pid = 0; 406 | return R_SUCCEEDED(pmdmntGetProcessId(&pid, module.programId)) && pid > 0; 407 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------