├── .gitignore ├── .idea ├── .gitignore ├── .name ├── compiler.xml ├── deploymentTargetDropDown.xml ├── gradle.xml ├── migrations.xml ├── misc.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── cipher │ │ └── userlib │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── cpp │ │ ├── CMakeLists.txt │ │ ├── config.json │ │ ├── icon.bmp │ │ ├── include │ │ │ ├── Cipher │ │ │ │ ├── Cipher.h │ │ │ │ ├── CipherArm64.h │ │ │ │ └── CipherUtils.h │ │ │ ├── KittyMemory │ │ │ │ ├── KittyArm64.hpp │ │ │ │ ├── KittyInclude.hpp │ │ │ │ ├── KittyMemory.hpp │ │ │ │ ├── KittyScanner.hpp │ │ │ │ ├── KittyUtils.hpp │ │ │ │ ├── MemoryBackup.hpp │ │ │ │ ├── MemoryPatch.hpp │ │ │ │ └── writeData.hpp │ │ │ ├── fileselector │ │ │ │ └── fileselector.h │ │ │ ├── iconloader │ │ │ │ └── IconLoader.h │ │ │ ├── imgui │ │ │ │ ├── androidbk.h │ │ │ │ ├── imconfig.h │ │ │ │ ├── imgui.h │ │ │ │ ├── imgui_impl_opengl3.h │ │ │ │ ├── imgui_impl_opengl3_loader.h │ │ │ │ ├── imgui_internal.h │ │ │ │ ├── imstb_rectpack.h │ │ │ │ ├── imstb_textedit.h │ │ │ │ └── imstb_truetype.h │ │ │ ├── misc │ │ │ │ └── Logger.h │ │ │ └── nlohmann │ │ │ │ ├── json.hpp │ │ │ │ └── json_fwd.hpp │ │ ├── main.cpp │ │ └── main.h │ ├── java │ │ └── com │ │ │ └── cipher │ │ │ └── userlib │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── com │ └── cipher │ └── userlib │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | userlib -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/migrations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Userlib-SML 2 | A userlib template for the SML 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 34 7 | 8 | defaultConfig { 9 | applicationId "com.cipher.userlib" 10 | minSdk 26 11 | targetSdk 34 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | externalNativeBuild { 17 | cmake { 18 | cppFlags '-std=c++17' 19 | abiFilters "arm64-v8a" 20 | } 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | externalNativeBuild { 35 | cmake { 36 | path file('src/main/cpp/CMakeLists.txt') 37 | version '3.22.1' 38 | } 39 | } 40 | buildFeatures { 41 | viewBinding true 42 | } 43 | android { 44 | namespace 'com.cipher.userlib' 45 | } 46 | } 47 | 48 | dependencies { 49 | 50 | implementation 'androidx.appcompat:appcompat:1.6.1' 51 | implementation 'com.google.android.material:material:1.12.0' 52 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 53 | testImplementation 'junit:junit:4.13.2' 54 | androidTestImplementation 'androidx.test.ext:junit:1.1.5' 55 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' 56 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/cipher/userlib/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.cipher.userlib; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.cipher.userlib", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.19.0) 2 | 3 | set(CIPHER_URL https://github.com/lukas0x1/Userlib-SML/releases/latest/download/libciphered.so) 4 | set(CIPHER_PATH ${CMAKE_BINARY_DIR}/libciphered.so) 5 | file(DOWNLOAD ${CIPHER_URL} ${CIPHER_PATH} STATUS LIBCIPHER_DOWNLOAD_STATUS) 6 | 7 | 8 | project("userlib") 9 | 10 | 11 | #set(CMAKE_BUILD_TYPE Debug) 12 | set(CMAKE_BUILD_TYPE Release) 13 | 14 | if(CMAKE_BUILD_TYPE STREQUAL "Release") 15 | set(CMAKE_C_VISIBILITY_PRESET hidden) 16 | set(CMAKE_CXX_VISIBILITY_PRESET hidden) 17 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -O3") 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -O3") 19 | endif() 20 | 21 | 22 | file(READ ${CMAKE_HOME_DIRECTORY}/config.json MY_JSON_STRING) #reads soname from config 23 | string(JSON CUR_NAME GET ${MY_JSON_STRING} name) 24 | string(LENGTH ${CUR_NAME} CUR_NAME_LEN) 25 | string(SUBSTRING ${CUR_NAME} 3 ${CUR_NAME_LEN} CUR_NAME) #ugly but there's no lazy regex support 26 | string(REPLACE ".so" "" CUR_NAME ${CUR_NAME}) 27 | 28 | add_library( # Sets the name of the library. 29 | ${CUR_NAME} 30 | SHARED 31 | main.cpp 32 | ) 33 | 34 | target_include_directories( 35 | ${CUR_NAME} PUBLIC ${CMAKE_SOURCE_DIR}/include 36 | ) 37 | 38 | find_library( 39 | log-lib 40 | log 41 | ) 42 | 43 | target_link_libraries( 44 | ${CUR_NAME} 45 | "${CIPHER_PATH}" 46 | ${log-lib} 47 | ) 48 | 49 | add_custom_command( 50 | TARGET ${CUR_NAME} 51 | POST_BUILD 52 | COMMAND ${CMAKE_OBJCOPY} 53 | ARGS --add-section .config=${CMAKE_HOME_DIRECTORY}/config.json --set-section-flags .config=readonly,contents,data $ 54 | ) 55 | 56 | add_custom_command( 57 | TARGET ${CUR_NAME} 58 | POST_BUILD 59 | COMMAND ${CMAKE_OBJCOPY} 60 | ARGS --add-section .icon=${CMAKE_HOME_DIRECTORY}/icon.bmp --set-section-flags .icon=readonly,contents,data $ 61 | ) -------------------------------------------------------------------------------- /app/src/main/cpp/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "libmodlib.so", 3 | "author": "author's name", 4 | "displayName": "Demo mod", 5 | "description": "this is a simple demo mod for sml", 6 | "majorVersion": 1, 7 | "minorVersion": 0, 8 | "patchVersion": 0, 9 | "displaysUI": true, 10 | "selfManagedUI": false, 11 | "githubReleasesUrl": "", 12 | "dependencies": [ 13 | 14 | ] 15 | } -------------------------------------------------------------------------------- /app/src/main/cpp/icon.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/cpp/icon.bmp -------------------------------------------------------------------------------- /app/src/main/cpp/include/Cipher/Cipher.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | 7 | enum Section { 8 | BOOTLOADER_ROD = 0, 9 | BOOTLOADER_RWP, 10 | BOOTLOADER_RXP, 11 | }; 12 | 13 | /** 14 | * @brief Provides an API for Canvas like memory scanning within the game's library. 15 | * 16 | * This class offers methods for obtaining game version information, detecting beta status, 17 | * retrieving library base addresses, scanning memory regions for specific patterns, 18 | * and accessing configuration paths and asset data. It serves as an API for the mod loader. 19 | */ 20 | class Cipher { 21 | public: 22 | /** 23 | * @brief Retrieves the game version. 24 | * @return The game version as a 32-bit unsigned integer. 25 | */ 26 | static std::uint32_t getGameVersion(); 27 | 28 | /** 29 | * @brief Checks if the game is the beta build. 30 | * @return True if the game is in beta, false otherwise. 31 | */ 32 | static bool isGameBeta(); 33 | 34 | /** 35 | * @brief Retrieves the base address of the game's library. 36 | * @return The base address of the game library as an std::uintptr_t. 37 | */ 38 | static std::uintptr_t get_libBase(); 39 | 40 | /** 41 | * @brief Retrieves the name of the game's library. 42 | * @return A string containing the name of the game library. 43 | */ 44 | static const char *get_libName(); 45 | 46 | /** 47 | * @brief Scans the game's library for a specific byte array using wildcard masking. 48 | * @param _bytes The byte array to search for. 49 | * @param _mask The _mask specifying which bytes to compare in the _bytes. 50 | * @return The address of the first occurrence of the bytes. 51 | */ 52 | static std::uintptr_t CipherScan(const char *_bytes, const char *_mask); //librange 53 | 54 | /** 55 | * @brief Scans a specified memory region for a specific byte array using wildcard masking. 56 | * @param _start The start address of the memory region to scan. 57 | * @param _size The size of the memory region to scan. 58 | * @param _bytes The byte bytes to search for. 59 | * @param _mask The mask specifying which bytes to compare in the _bytes. 60 | * @return The address of the first occurrence of the bytes. 61 | */ 62 | static std::uintptr_t CipherScan(std::uintptr_t _start, const size_t _size, const char *_bytes, const char *_mask); 63 | 64 | /** 65 | * @brief Scans the game's library for all occurrences of a specific byte array using wildcard masking. 66 | * @param _bytes The byte bytes to search for. 67 | * @param _mask The mask specifying which bytes to compare in the bytes. 68 | * @return A vector containing the addresses of all occurrences of the bytes. 69 | */ 70 | static std::vector CipherScanAll(const char *_bytes, const char *_mask); //librange 71 | 72 | /** 73 | * @brief Scans a specified memory region for all occurrences of a specific byte array using wildcard masking. 74 | * @param _start The start address of the memory region to scan. 75 | * @param _end The end address of the memory region to scan. 76 | * @param _bytes The bytes to search for. 77 | * @param _mask The mask specifying which bytes to compare in the bytes. 78 | * @return A vector containing the addresses of all occurrences of the bytes. 79 | */ 80 | static std::vector CipherScanAll(std::uintptr_t _start, std::uintptr_t _end, const char *_bytes, const char *_mask); 81 | 82 | /** 83 | * @brief Scans a specified memory section for a specific byte array using wildcard masking. 84 | * @param _bytes The bytes to search for. 85 | * @param _mask The mask specifying which bytes to compare in the bytes. 86 | * @param _section The section of memory to scan (default is BOOTLOADER_RXP). 87 | * @return The address of the first occurrence of the bytes within the specified memory section. 88 | */ 89 | static std::uintptr_t CipherScanSegments(const char *_bytes, const char *_mask, const Section &_section = BOOTLOADER_RXP); 90 | 91 | /** 92 | * @brief Scans the game's library for a specific pattern using IDA-style pattern format. 93 | * @param _pattern The IDA-style pattern to search for. 94 | * @return The address of the first occurrence of the pattern. 95 | */ 96 | static std::uintptr_t CipherScanIdaPattern(const std::string &_pattern); //librange 97 | 98 | /** 99 | * @brief Scans a specified memory region for a specific pattern using IDA-style pattern format. 100 | * @param _start The start address of the memory region to scan. 101 | * @param _end The end address of the memory region to scan. 102 | * @param _pattern The IDA-style pattern to search for. 103 | * @return The address of the first occurrence of the pattern. 104 | */ 105 | static uintptr_t CipherScanIdaPattern(const std::uintptr_t _start, const std::uintptr_t _end, const std::string &_pattern); 106 | 107 | /** 108 | * @brief Scans the game's library for all occurrences of a specific pattern using IDA-style pattern format. 109 | * @param _pattern The IDA-style pattern to search for. 110 | * @return A vector containing the addresses of all occurrences of the pattern. 111 | */ 112 | static std::vector CipherScanIdaPatternAll(const std::string &_pattern); //librange 113 | 114 | /** 115 | * @brief Scans a specified memory region for all occurrences of a specific pattern using IDA-style pattern format. 116 | * @param _start The start address of the memory region to scan. 117 | * @param _end The end address of the memory region to scan. 118 | * @param _pattern The IDA-style pattern to search for. 119 | * @return A vector containing the addresses of all occurrences of the pattern. 120 | */ 121 | static std::vector CipherScanIdaPatternAll(const std::uintptr_t _start, const std::uintptr_t _end, const std::string &_pattern); 122 | 123 | /** 124 | * @brief Retrieves the path to the mod's configuration file. 125 | * @return A pointer to a string containing the path to the configuration file. 126 | */ 127 | static const char *getConfigPath(); 128 | 129 | /** 130 | * @brief Reads asset data from a specified path. 131 | * @param _assetPath The path to the asset. 132 | * @return A pointer to a char array containing the asset data. 133 | */ 134 | static char* read_asset(char* _assetPath); 135 | }; 136 | 137 | enum Types { 138 | e_patch, 139 | e_hook 140 | }; 141 | 142 | /** 143 | * @brief Base class for cipher implementations. 144 | */ 145 | class CipherBase { 146 | public: 147 | /** 148 | * @brief Constructor for CipherBase class. 149 | */ 150 | CipherBase(); 151 | /** 152 | * @brief Destructor for CipherBase class (pure virtual). 153 | */ 154 | virtual ~CipherBase() = 0; 155 | 156 | /** 157 | * @brief Set the name of the associated library. 158 | * @param _libName Name of the library. 159 | * @return Pointer to the current CipherBase chatInfo. 160 | */ 161 | CipherBase* set_libName(const char* _libName); 162 | /** 163 | * @brief Set the address of the cipher using a symbol name. 164 | * @param _symbol Symbol name to set the address. 165 | * @return Pointer to the current CipherBase chatInfo. 166 | */ 167 | CipherBase* set_Address(const char* _symbol); 168 | /** 169 | * @brief Set the address of the cipher. 170 | * @param _address Address to set. 171 | * @param _isLocal Flag indicating if the address is local to the library. 172 | * @return Pointer to the current CipherBase chatInfo. 173 | */ 174 | CipherBase* set_Address(std::uintptr_t _address, bool _isLocal = true); 175 | /** 176 | * @brief Set the address of the cipher using bytes and a mask. 177 | * @param _bytes Bytes representing the address. 178 | * @param _mask Mask to apply to the bytes. 179 | * @return Pointer to the current CipherBase chatInfo. 180 | */ 181 | CipherBase* set_Address(const char* _bytes, const char* _mask); 182 | 183 | /** 184 | * @brief Set the lock status of the cipher. 185 | * @param _isLocked Lock status to set. 186 | * @return Pointer to the current CipherBase chatInfo. 187 | */ 188 | CipherBase* set_Lock(bool _isLocked); 189 | /** 190 | * @brief Trigger the cipher. 191 | * @return Pointer to the triggered CipherBase chatInfo. 192 | */ 193 | virtual CipherBase* Fire() = 0; 194 | /** 195 | * @brief Restore the cipher. 196 | */ 197 | virtual void Restore() = 0; 198 | }; 199 | 200 | 201 | /** 202 | * @brief Represents a hook applied to the game's memory. 203 | * Inherits from CipherBase. 204 | */ 205 | class CipherHook : public CipherBase { 206 | public: 207 | /** 208 | * @brief Constructs a new CipherHook object. 209 | */ 210 | CipherHook(); 211 | 212 | /** 213 | * @brief Destroys the CipherHook object and restores the hook. 214 | */ 215 | ~CipherHook() override; 216 | 217 | /** 218 | * @brief Sets the address of the hook function. 219 | * @param _hook The address of the hook function. 220 | * @return A pointer to the current CipherHook object. 221 | */ 222 | CipherHook* set_Hook(std::uintptr_t _hook); 223 | 224 | /** 225 | * @brief Sets the address of the callback function. 226 | * @param _callback The address of the callback function. 227 | * @return A pointer to the current CipherHook object. 228 | */ 229 | CipherHook* set_Callback(std::uintptr_t _callback); 230 | 231 | /** 232 | * @brief Applies the hook to the game's memory. 233 | * @return A pointer to the current CipherHook object. 234 | */ 235 | CipherHook* Fire() override; 236 | 237 | /** 238 | * @brief Restores the hook. 239 | */ 240 | void Restore() override; 241 | }; 242 | 243 | /** 244 | * @brief Represents a patch applied to the game's memory. 245 | * Inherits from CipherBase. 246 | */ 247 | class CipherPatch : public CipherBase { 248 | public: 249 | /** 250 | * @brief Constructs a new CipherPatch object. 251 | */ 252 | CipherPatch(); 253 | 254 | /** 255 | * @brief Destroys the CipherPatch object and restores the patch. 256 | */ 257 | ~CipherPatch() override; 258 | 259 | /** 260 | * @brief Applies the patch to the game's memory. 261 | * @return A pointer to the current CipherPatch object. 262 | */ 263 | CipherPatch* Fire() override; 264 | 265 | /** 266 | * @brief Sets the opcode for the patch. 267 | * @param _hex The opcode in hexadecimal format. 268 | * @return A pointer to the current CipherPatch object. 269 | */ 270 | CipherPatch* set_Opcode(std::string _hex); 271 | 272 | /** 273 | * @brief Restores the patch. 274 | */ 275 | void Restore() override; 276 | }; 277 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/Cipher/CipherArm64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace CipherArm64 8 | { 9 | 10 | int32_t bit_from(uint32_t insn, int pos); 11 | 12 | int32_t bits_from(uint32_t insn, int pos, int l); 13 | 14 | bool is_insn_adr(uint32_t insn); 15 | 16 | bool is_insn_adrp(uint32_t insn); 17 | 18 | bool decode_adr_imm(uint32_t insn, int64_t *imm); 19 | 20 | int32_t decode_addsub_imm(uint32_t insn); 21 | 22 | bool is_insn_ld(uint32_t insn); 23 | 24 | bool is_insn_ldst(uint32_t insn); 25 | 26 | bool is_insn_ldst_uimm(uint32_t insn); 27 | 28 | bool decode_ldrstr_uimm(uint32_t insn, int32_t *offset); 29 | 30 | } -------------------------------------------------------------------------------- /app/src/main/cpp/include/Cipher/CipherUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | /** 7 | * @brief Struct representing device information. 8 | */ 9 | struct DeviceInfo { 10 | float xdpi; /**< X-axis dots per inch (dpi) of the device screen. */ 11 | float ydpi; /**< Y-axis dots per inch (dpi) of the device screen. */ 12 | float density; /**< Pixel density of the device screen. */ 13 | std::string deviceName; /**< Name of the device. */ 14 | std::string deviceManufacturer; /**< Manufacturer of the device. */ 15 | std::string deviceModel; /**< Model of the device. */ 16 | }; 17 | 18 | /** 19 | * @brief Specifies the type of the game. 20 | */ 21 | enum GameType { 22 | Live = 0, /**< Represents the live version of the game. */ 23 | Beta, /**< Represents the beta version of the game. */ 24 | Huawei /**< Represents the Huawei version of the game. */ 25 | }; 26 | 27 | /** 28 | * @brief Specifies memory segment permissions. 29 | */ 30 | enum Flags { 31 | ReadOnly = 10, /**< Read-only segment (rodata). */ 32 | ReadAndWrite, /**< Read-write segment (bss). */ 33 | ReadAndExecute, /**< Read-execute segment (text). */ 34 | Any /**< Any segment. */ 35 | }; 36 | 37 | enum HapticFeedbackType { 38 | TYPE_SUCCESS = 0, /**< Success feedback. */ 39 | TYPE_SUCCESS_STRONG = 1, /**< Strong success feedback. */ 40 | TYPE_WARNING = 2, /**< Warning feedback. */ 41 | TYPE_ERROR = 3, /**< Error feedback. */ 42 | TYPE_SELECTION = 4, /**< Selection feedback. */ 43 | TYPE_IMPACT_LIGHT = 5, /**< Light impact feedback. */ 44 | TYPE_IMPACT = 6, /**< Impact feedback. */ 45 | TYPE_IMPACT_HEAVY = 7 /**< Heavy impact feedback. */ 46 | }; 47 | 48 | /** 49 | * @brief Provides functionalities for interacting with game memory, scanning patterns, and accessing game information. 50 | */ 51 | class CipherUtils { 52 | public: 53 | /** 54 | * @brief Retrieves the game version. 55 | * @return The game version as a 32-bit unsigned integer. 56 | */ 57 | static std::uint32_t get_GameVersion(); 58 | 59 | /** 60 | * @brief Retrieves the game type. 61 | * @return The game type. 62 | * 63 | * Possible return values: 64 | * - GameType::Live: Represents the live version of the game. 65 | * - GameType::Beta: Represents the beta version of the game. 66 | * - GameType::Huawei: Represents the Huawei version of the game. 67 | */ 68 | static GameType get_GameType(); 69 | 70 | /** 71 | * @brief Retrieves the name of the library. 72 | * @return The name of the library. 73 | */ 74 | static const char *get_libName(); 75 | 76 | /** 77 | * @brief Retrieves the base address of the library. 78 | * @return The base address of the library. 79 | */ 80 | static std::uintptr_t get_libBase(); 81 | 82 | /** 83 | * @brief Retrieves the path for mod configurations. 84 | * @return The path for mod configurations. 85 | */ 86 | static const char *get_ConfigsPath(); 87 | 88 | /** 89 | * @brief Reads an asset from the given asset path. 90 | * @param _assetPath The path of the asset to read. 91 | * @return A pointer to the buffer containing the asset data. 92 | */ 93 | static char *readAsset(const char *_assetPath); 94 | 95 | /** 96 | * @brief Adds a listener for keyboard events. 97 | * @param _listener The listener function to be added. 98 | */ 99 | static void addOnKeyboardCompleteListener(void (*_listener)(std::string _message)); 100 | 101 | /** 102 | * @brief Adds a message to the user's chat. 103 | * @param _message The string to be added. 104 | */ 105 | static DeviceInfo get_DeviceInfo(); 106 | 107 | /** 108 | * @brief Perform haptic feedback of the specified type 109 | * @param type The type of haptic feedback 110 | */ 111 | static void performHapticFeedback(HapticFeedbackType _type); 112 | 113 | public: 114 | /** 115 | * @brief Converts a pattern string into bytes and a mask for memory scanning. 116 | * @param _pattern The pattern string to convert. 117 | * @param _bytesBuffer The buffer to store the converted bytes. 118 | * @param _maskBuffer The buffer to store the mask. 119 | */ 120 | static void patternToBytes(const std::string _pattern, char *_bytesBuffer, std::string &_maskBuffer); 121 | 122 | /** 123 | * @brief Scans memory for a specific pattern within a given range. 124 | * @param _start The start address of the memory range to scan. 125 | * @param _end The end address of the memory range to scan. 126 | * @param _bytes The pattern bytes to search for. 127 | * @param _mask The mask corresponding to the pattern bytes. 128 | * @return The address of the found pattern, or 0 if not found. 129 | */ 130 | static std::uintptr_t CipherScan(const std::uintptr_t _start, const std::uintptr_t _end, const char *_bytes, const char *_mask); 131 | 132 | /** 133 | * @brief Scans memory for a specific pattern within a specific memory segment in the lib range. 134 | * @param _bytes The pattern bytes to search for. 135 | * @param _mask The mask corresponding to the pattern bytes. 136 | * @param _flag The flag indicating the memory segment type to search in. 137 | * @param _start The start address of the scan in the specified memory segment. 138 | * @param _libName The name of the library to scan. 139 | * @return The address of the found pattern, or 0 if not found. 140 | */ 141 | static std::uintptr_t CipherScan(const char *_bytes, const char *_mask, const Flags &_flag = Flags::Any, const std::uintptr_t &_start = 0x0, const char *_libName = nullptr); 142 | 143 | /** 144 | * @brief Scans memory for all occurrences of a specific pattern within a given range. 145 | * @param _start The start address of the memory range to scan. 146 | * @param _end The end address of the memory range to scan. 147 | * @param _bytes The pattern bytes to search for. 148 | * @param _mask The mask corresponding to the pattern bytes. 149 | * @return A vector containing the addresses of all found patterns. 150 | */ 151 | static std::vector CipherScanAll(const std::uintptr_t _start, const std::uintptr_t _end, const char *_bytes, const char *_mask); 152 | 153 | /** 154 | * @brief Scans memory for all occurrences of a specific pattern within a specific memory segment. 155 | * @param _bytes The pattern bytes to search for. 156 | * @param _mask The mask corresponding to the pattern bytes. 157 | * @param _flag The flag indicating the memory segment type to search in. 158 | * @param _start The start address of the memory segment to scan. 159 | * @param _libName The name of the library to scan. 160 | * @return A vector containing the addresses of all found patterns. 161 | */ 162 | static std::vector CipherScanAll(const char *_bytes, const char *_mask, const Flags &_flag = Flags::Any, const std::uintptr_t &_start = 0x0, const char *_libName = nullptr); 163 | 164 | /** 165 | * @brief Scans memory for a pattern defined as a string within a given range or within a specific memory segment. 166 | * @param _start The start address of the memory range to scan. 167 | * @param _end The end address of the memory range to scan. 168 | * @param _pattern The pattern string to search for. 169 | * @return The address of the found pattern, or 0 if not found. 170 | */ 171 | static std::uintptr_t CipherScanPattern(const std::uintptr_t _start, const std::uintptr_t _end, const char *_pattern); 172 | 173 | /** 174 | * @brief Scans memory for a pattern defined as a string within a specific memory segment. 175 | * @param _pattern The pattern string to search for. 176 | * @param _flag The flag indicating the memory segment type to search in. 177 | * @param _start The start address of the memory segment to scan. 178 | * @param _libName The name of the library to scan. 179 | * @return The address of the found pattern, or 0 if not found. 180 | */ 181 | static std::uintptr_t CipherScanPattern(const char *_pattern, const Flags &_flag = Flags::Any, const std::uintptr_t &_start = 0x0, const char *_libName = nullptr); 182 | 183 | /** 184 | * @brief Scans memory for all occurrences of a pattern defined as a string within a given range or within a specific memory segment. 185 | * @param _start The start address of the memory range to scan. 186 | * @param _end The end address of the memory range to scan. 187 | * @param _pattern The pattern string to search for. 188 | * @return A vector containing the addresses of all found patterns. 189 | */ 190 | static std::vector CipherScanPatternAll(const std::uintptr_t _start, const std::uintptr_t _end, const char *_pattern); 191 | 192 | /** 193 | * @brief Scans memory for all occurrences of a pattern defined as a string within a specific memory segment. 194 | * @param _pattern The pattern string to search for. 195 | * @param _flag The flag indicating the memory segment type to search in. 196 | * @param _start The start address of the memory segment to scan. 197 | * @param _libName The name of the library to scan. 198 | * @return A vector containing the addresses of all found patterns. 199 | */ 200 | static std::vector CipherScanPatternAll(const char *_pattern, const Flags &_flag = Flags::Any, const std::uintptr_t &_start = 0x0, const char *_libName = nullptr); 201 | }; 202 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/KittyArm64.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace KittyArm64 8 | { 9 | 10 | int32_t bit_from(uint32_t insn, int pos); 11 | 12 | int32_t bits_from(uint32_t insn, int pos, int l); 13 | 14 | bool is_insn_adr(uint32_t insn); 15 | 16 | bool is_insn_adrp(uint32_t insn); 17 | 18 | bool decode_adr_imm(uint32_t insn, int64_t *imm); 19 | 20 | int32_t decode_addsub_imm(uint32_t insn); 21 | 22 | bool is_insn_ld(uint32_t insn); 23 | 24 | bool is_insn_ldst(uint32_t insn); 25 | 26 | bool is_insn_ldst_uimm(uint32_t insn); 27 | 28 | bool decode_ldrstr_uimm(uint32_t insn, int32_t *offset); 29 | 30 | } 31 | 32 | namespace KittyArm 33 | { 34 | int32_t decode_ldr_literal(uint32_t insn); 35 | } -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/KittyInclude.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "KittyUtils.hpp" 4 | #include "KittyMemory.hpp" 5 | #include "MemoryPatch.hpp" 6 | #include "KittyScanner.hpp" 7 | #include "KittyArm64.hpp" 8 | 9 | #ifdef __ANDROID__ 10 | using KittyMemory::ProcMap; 11 | using KittyScanner::RegisterNativeFn; 12 | using KittyScanner::ElfScanner; 13 | 14 | #elif __APPLE__ 15 | #include "writeData.hpp" 16 | using KittyMemory::seg_data_t; 17 | using KittyMemory::MemoryFileInfo; 18 | #endif -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/KittyMemory.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // KittyMemory.hpp 3 | // 4 | // Created by MJ (Ruit) on 1/1/19. 5 | // 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef __APPLE__ 16 | #include 17 | #include 18 | #include 19 | #include 20 | #endif 21 | 22 | #include "KittyUtils.hpp" 23 | 24 | #define KT_PAGE_SIZE (sysconf(_SC_PAGE_SIZE)) 25 | 26 | #define KT_PAGE_START(x) (uintptr_t(x) & ~(KT_PAGE_SIZE - 1)) 27 | #define KT_PAGE_END(x) (KT_PAGE_START(uintptr_t(x) + KT_PAGE_SIZE - 1)) 28 | #define KT_PAGE_OFFSET(x) (uintptr_t(x) - KT_PAGE_START(x)) 29 | #define KT_PAGE_LEN(x) (size_t(KT_PAGE_SIZE - KT_PAGE_OFFSET(x))) 30 | 31 | #define KT_PAGE_END2(x, len) (KT_PAGE_START(uintptr_t(x) + len - 1)) 32 | #define KT_PAGE_LEN2(x, len) (KT_PAGE_END2(x, len) - KT_PAGE_START(x) + KT_PAGE_SIZE) 33 | 34 | #define _PROT_RWX_ (PROT_READ | PROT_WRITE | PROT_EXEC) 35 | #define _PROT_RX_ (PROT_READ | PROT_EXEC) 36 | #define _PROT_RW_ (PROT_READ | PROT_WRITE) 37 | 38 | #define KITTY_LOG_TAG "KittyMemory" 39 | 40 | #ifdef __ANDROID__ 41 | #include 42 | 43 | #ifdef kITTYMEMORY_DEBUG 44 | #define KITTY_LOGD(fmt, ...) ((void)__android_log_print(ANDROID_LOG_DEBUG, KITTY_LOG_TAG, fmt, ##__VA_ARGS__)) 45 | #else 46 | #define KITTY_LOGD(fmt, ...) do {} while(0) 47 | #endif 48 | 49 | #define KITTY_LOGI(fmt, ...) ((void)__android_log_print(ANDROID_LOG_INFO, KITTY_LOG_TAG, fmt, ##__VA_ARGS__)) 50 | #define KITTY_LOGE(fmt, ...) ((void)__android_log_print(ANDROID_LOG_ERROR, KITTY_LOG_TAG, fmt, ##__VA_ARGS__)) 51 | 52 | #elif __APPLE__ 53 | #include 54 | 55 | #ifdef kITTYMEMORY_DEBUG 56 | #define KITTY_LOGD(fmt, ...) os_log(OS_LOG_DEFAULT, "D " KITTY_LOG_TAG ": " fmt, ##__VA_ARGS__) 57 | #else 58 | #define KITTY_LOGD(fmt, ...) do {} while(0) 59 | #endif 60 | 61 | #define KITTY_LOGI(fmt, ...) os_log(OS_LOG_DEFAULT, "I " KITTY_LOG_TAG ": " fmt, ##__VA_ARGS__) 62 | #define KITTY_LOGE(fmt, ...) os_log_error(OS_LOG_DEFAULT, "E " KITTY_LOG_TAG ": " fmt, ##__VA_ARGS__) 63 | 64 | #endif 65 | 66 | namespace KittyMemory 67 | { 68 | 69 | /* 70 | * mprotect wrapper 71 | */ 72 | int setAddressProtection(const void *address, size_t length, int protection); 73 | 74 | /* 75 | * Reads an address content into a buffer 76 | */ 77 | bool memRead(const void *address, void *buffer, size_t len); 78 | 79 | #ifdef __ANDROID__ 80 | 81 | class ProcMap { 82 | public: 83 | unsigned long long startAddress; 84 | unsigned long long endAddress; 85 | size_t length; 86 | int protection; 87 | bool readable, writeable, executable, is_private, is_shared, is_ro, is_rw, is_rx; 88 | unsigned long long offset; 89 | std::string dev; 90 | unsigned long inode; 91 | std::string pathname; 92 | 93 | ProcMap() : startAddress(0), endAddress(0), length(0), protection(0), 94 | readable(false), writeable(false), executable(false), 95 | is_private(false), is_shared(false), 96 | is_ro(false), is_rw(false), is_rx(false), 97 | offset(0), inode(0) {} 98 | 99 | inline bool isValid() const { return (startAddress && endAddress && length); } 100 | inline bool isUnknown() const { return pathname.empty(); } 101 | inline bool isValidELF() const { return isValid() && length > 4 && readable && memcmp((const void *) startAddress, "\177ELF", 4) == 0; } 102 | inline bool contains(uintptr_t address) const { return address >= startAddress && address < endAddress; } 103 | inline std::string toString() 104 | { 105 | return KittyUtils::String::Fmt("%llx-%llx %c%c%c%c %llx %s %lu %s", 106 | startAddress, endAddress, 107 | readable ? 'r' : '-', writeable ? 'w' : '-', executable ? 'x' : '-', is_private ? 'p' : 's', 108 | offset, dev.c_str(), inode, pathname.c_str()); 109 | } 110 | }; 111 | 112 | /* 113 | * Writes buffer content to an address 114 | */ 115 | bool memWrite(void *address, const void *buffer, size_t len); 116 | 117 | /* 118 | * /proc/self/cmdline 119 | */ 120 | std::string getProcessName(); 121 | 122 | /* 123 | * Gets info of all maps in current process 124 | */ 125 | std::vector getAllMaps(); 126 | 127 | /* 128 | * Gets info of all maps which pathname equals @name in current process 129 | */ 130 | std::vector getMapsEqual(const std::vector &maps, const std::string& name); 131 | 132 | /* 133 | * Gets info of all maps which pathname contains @name in current process 134 | */ 135 | std::vector getMapsContain(const std::vector &maps, const std::string& name); 136 | 137 | /* 138 | * Gets info of all maps which pathname ends with @name in current process 139 | */ 140 | std::vector getMapsEndWith(const std::vector &maps, const std::string& name); 141 | 142 | /* 143 | * Gets map info of an address in self process 144 | */ 145 | ProcMap getAddressMap(const std::vector &maps, const void *address); 146 | 147 | /* 148 | * Gets info of all maps which pathname equals @name in current process 149 | */ 150 | inline std::vector getMapsEqual(const std::string& name) { return getMapsEqual(getAllMaps(), name); } 151 | 152 | /* 153 | * Gets info of all maps which pathname contains @name in current process 154 | */ 155 | inline std::vector getMapsContain(const std::string& name) { return getMapsContain(getAllMaps(), name); } 156 | 157 | /* 158 | * Gets info of all maps which pathname ends with @name in current process 159 | */ 160 | inline std::vector getMapsEndWith(const std::string& name) { return getMapsEndWith(getAllMaps(), name); } 161 | 162 | /* 163 | * Gets map info of an address in self process 164 | */ 165 | inline ProcMap getAddressMap(const void *address) { return getAddressMap(getAllMaps(), address); } 166 | 167 | /* 168 | * Gets the base map of a loaded shared object 169 | */ 170 | ProcMap getElfBaseMap(const std::string& name); 171 | 172 | #elif __APPLE__ 173 | 174 | enum Memory_Status { 175 | KMS_FAILED = 0, 176 | KMS_SUCCESS, 177 | KMS_INV_ADDR, 178 | KMS_INV_LEN, 179 | KMS_INV_BUF, 180 | KMS_ERR_PROT, 181 | KMS_ERR_GET_PAGEINFO, 182 | KMS_ERR_MMAP, 183 | KMS_ERR_REMAP, 184 | KMS_ERR_VMCOPY, 185 | }; 186 | 187 | struct seg_data_t { 188 | uintptr_t start, end; 189 | unsigned long size; 190 | seg_data_t() : start(0), end(0), size(0) {} 191 | }; 192 | 193 | class MemoryFileInfo { 194 | public: 195 | uint32_t index; 196 | #ifdef __LP64__ 197 | const mach_header_64 *header; 198 | #else 199 | const mach_header *header; 200 | #endif 201 | const char *name; 202 | intptr_t address; 203 | 204 | MemoryFileInfo() : index(0), header(nullptr), name(nullptr), address(0) {} 205 | 206 | inline seg_data_t getSegment(const char *seg_name) const 207 | { 208 | seg_data_t data {}; 209 | if (!header || !seg_name) return data; 210 | data.start = uintptr_t(getsegmentdata(header, seg_name, &data.size)); 211 | data.end = data.start + data.size; 212 | return data; 213 | } 214 | 215 | inline seg_data_t getSection(const char *seg_name, const char *sect_name) const 216 | { 217 | seg_data_t data {}; 218 | if (!header || !seg_name || !sect_name) return data; 219 | data.start = uintptr_t(getsectiondata(header, seg_name, sect_name, &data.size)); 220 | data.end = data.start + data.size; 221 | return data; 222 | } 223 | }; 224 | 225 | /* 226 | * Writes buffer content to an address 227 | */ 228 | Memory_Status memWrite(void *address, const void *buffer, size_t len); 229 | 230 | /* 231 | * vm_region_recurse_64 wrapper 232 | */ 233 | kern_return_t getPageInfo(void *page_start, vm_region_submap_short_info_64 *info_out); 234 | 235 | /* 236 | * returns base executable info 237 | */ 238 | MemoryFileInfo getBaseInfo(); 239 | 240 | /* 241 | * find in memory file info by checking if target loaded object file ends with @fileName 242 | */ 243 | MemoryFileInfo getMemoryFileInfo(const std::string& fileName); 244 | 245 | /* 246 | * returns the absolue address of a relative offset of a file in memory or NULL as fileName for base executable 247 | */ 248 | uintptr_t getAbsoluteAddress(const char *fileName, uintptr_t address); 249 | 250 | #endif 251 | 252 | } 253 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/KittyScanner.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "KittyMemory.hpp" 9 | 10 | namespace KittyScanner 11 | { 12 | /** 13 | * Search for bytes within a memory range and return all results 14 | * 15 | * @start: search start address 16 | * @end: search end address 17 | * @bytes: bytes to search 18 | * @mask: bytes mask x/? 19 | * 20 | * @return vector list of all found bytes addresses 21 | */ 22 | std::vector findBytesAll(const uintptr_t start, const uintptr_t end, const char *bytes, const std::string& mask); 23 | 24 | /** 25 | * Search for bytes within a memory range and return first result 26 | * 27 | * @start: search start address 28 | * @end: search end address 29 | * @bytes: bytes to search 30 | * @mask: bytes mask x/? 31 | * 32 | * @return first found bytes address 33 | */ 34 | uintptr_t findBytesFirst(const uintptr_t start, const uintptr_t end, const char *bytes, const std::string& mask); 35 | 36 | /** 37 | * Search for hex within a memory range and return all results 38 | * 39 | * @start: search start address 40 | * @end: search end address 41 | * @hex: hex to search 42 | * @mask: hex mask x/? 43 | * 44 | * @return vector list of all found hex addresses 45 | */ 46 | std::vector findHexAll(const uintptr_t start, const uintptr_t end, std::string hex, const std::string& mask); 47 | 48 | /** 49 | * Search for hex within a memory range and return first result 50 | * 51 | * @start: search start address 52 | * @end: search end address 53 | * @hex: hex to search 54 | * @mask: hex mask x/? 55 | * 56 | * @return first found hex address 57 | */ 58 | uintptr_t findHexFirst(const uintptr_t start, const uintptr_t end, std::string hex, const std::string& mask); 59 | 60 | /** 61 | * Search for ida pattern within a memory range and return all results 62 | * 63 | * @param start: search start address 64 | * @param end: search end address 65 | * @param pattern: hex bytes and wildcard "?" ( FF DD ? 99 CC ? 00 ) 66 | * 67 | * @return vector list of all found pattern addresses 68 | */ 69 | std::vector findIdaPatternAll(const uintptr_t start, const uintptr_t end, const std::string& pattern); 70 | 71 | /** 72 | * Search for ida pattern within a memory range and return first result 73 | * 74 | * @param start: search start address 75 | * @param end: search end address 76 | * @param pattern: hex bytes and wildcard "?" ( FF DD ? 99 CC ? 00 ) 77 | * 78 | * @return first found pattern address 79 | */ 80 | uintptr_t findIdaPatternFirst(const uintptr_t start, const uintptr_t end, const std::string& pattern); 81 | 82 | /** 83 | * Search for data within a memory range and return all results 84 | * 85 | * @start: search start address 86 | * @end: search end address 87 | * @data: data to search 88 | * @size: data size 89 | * 90 | * @return vector list of all found data addresses 91 | */ 92 | std::vector findDataAll(const uintptr_t start, const uintptr_t end, const void *data, size_t size); 93 | 94 | 95 | /** 96 | * Search for data within a memory range and return first result 97 | * 98 | * @start: search start address 99 | * @end: search end address 100 | * @data: data to search 101 | * @size: data size 102 | * 103 | * @return first found data address 104 | */ 105 | uintptr_t findDataFirst(const uintptr_t start, const uintptr_t end, const void *data, size_t size); 106 | 107 | #ifdef __ANDROID__ 108 | 109 | class RegisterNativeFn 110 | { 111 | public: 112 | char *name; 113 | char *signature; 114 | void *fnPtr; 115 | 116 | RegisterNativeFn() : name(nullptr), signature(nullptr), fnPtr(nullptr) {} 117 | inline bool isValid() const { return (name != nullptr && signature != nullptr && fnPtr != nullptr); } 118 | }; 119 | 120 | /** 121 | * search for string "name" references to find the JNINativeMethod array 122 | */ 123 | RegisterNativeFn findRegisterNativeFn(const class ElfScanner &elf, const std::string &name); 124 | 125 | class ElfScanner 126 | { 127 | private: 128 | uintptr_t _elfBase; 129 | ElfW_(Ehdr) _ehdr; 130 | uintptr_t _phdr; 131 | std::vector _phdrs; 132 | int _loads; 133 | uintptr_t _loadBias, _loadSize; 134 | uintptr_t _bss; 135 | size_t _bssSize; 136 | uintptr_t _dynamic; 137 | std::vector _dynamics; 138 | uintptr_t _stringTable, _symbolTable, _elfHashTable, _gnuHashTable; 139 | size_t _strsz, _syment; 140 | KittyMemory::ProcMap _base_segment; 141 | std::vector _segments; 142 | 143 | public: 144 | ElfScanner() 145 | : _elfBase(0) 146 | , _phdr(0) 147 | , _loads(0) 148 | , _loadBias(0) 149 | , _loadSize(0) 150 | , _bss(0) 151 | , _bssSize(0) 152 | , _dynamic(0) 153 | , _stringTable(0) 154 | , _symbolTable(0) 155 | , _elfHashTable(0) 156 | , _gnuHashTable(0) 157 | , _strsz(0) 158 | , _syment(0) 159 | { 160 | } 161 | 162 | ElfScanner(uintptr_t elfBase, const std::vector &maps); 163 | ElfScanner(uintptr_t elfBase) : ElfScanner(elfBase, KittyMemory::getAllMaps()) {} 164 | 165 | static inline ElfScanner createWithBase(uintptr_t elfBase) 166 | { 167 | return ElfScanner(elfBase); 168 | } 169 | static inline ElfScanner createWithMap(const KittyMemory::ProcMap& map) 170 | { 171 | return ElfScanner(map.startAddress); 172 | } 173 | static inline ElfScanner createWithPath(const std::string &path) 174 | { 175 | return ElfScanner(KittyMemory::getElfBaseMap(path).startAddress); 176 | } 177 | 178 | inline bool isValid() const 179 | { 180 | return _loads && !_phdrs.empty() && _loadBias && _loadSize && !_dynamics.empty() && _stringTable && _symbolTable && _strsz && _syment; 181 | } 182 | 183 | inline uintptr_t base() const { return _elfBase; } 184 | 185 | inline uintptr_t end() const { return _elfBase + _loadSize; } 186 | 187 | inline ElfW_(Ehdr) header() const { return _ehdr; } 188 | 189 | inline uintptr_t phdr() const { return _phdr; } 190 | 191 | inline std::vector programHeaders() const { return _phdrs; } 192 | 193 | inline int loads() const { return _loads; } 194 | 195 | inline uintptr_t loadBias() const { return _loadBias; } 196 | 197 | inline uintptr_t loadSize() const { return _loadSize; } 198 | 199 | inline uintptr_t bss() const { return _bss; } 200 | 201 | inline size_t bssSize() const { return _bssSize; } 202 | 203 | inline uintptr_t dynamic() const { return _dynamic; } 204 | 205 | inline std::vector dynamics() const { return _dynamics; } 206 | 207 | inline uintptr_t stringTable() const { return _stringTable; } 208 | 209 | inline uintptr_t symbolTable() const { return _symbolTable; } 210 | 211 | inline uintptr_t elfHashTable() const { return _elfHashTable; } 212 | 213 | inline uintptr_t gnuHashTable() const { return _gnuHashTable; } 214 | 215 | inline size_t stringTableSize() const { return _strsz; } 216 | 217 | inline size_t symbolEntrySize() const { return _syment; } 218 | 219 | /** 220 | * lookup symbol name in current ELF 221 | * @return absolute address of symbol 222 | */ 223 | uintptr_t findSymbol(const std::string& symbolName) const; 224 | 225 | inline KittyMemory::ProcMap baseSegment() const { return _base_segment; } 226 | 227 | inline std::vector segments() const { return _segments; } 228 | 229 | inline std::string filePath() const { return _base_segment.pathname; } 230 | 231 | static std::vector getAllELFs(); 232 | 233 | /** 234 | * lookup symbol name in all loaded ELFs 235 | * @return a vector of symbol absolute address and the ELF where the symbol was found in 236 | */ 237 | static std::vector> findSymbolAll(const std::string& symbolName); 238 | }; 239 | 240 | #endif // __ANDROID__ 241 | 242 | } -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/KittyUtils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef __ANDROID__ 14 | 15 | #include 16 | #ifdef __LP64__ 17 | #define ELFCLASS_BITS_ 64 18 | #define ELF_EICLASS_ 2 19 | #define ElfW_(x) Elf64_##x 20 | #define ELFW_(x) ELF64_##x 21 | #else 22 | #define ELFCLASS_BITS_ 32 23 | #define ELF_EICLASS_ 1 24 | #define ElfW_(x) Elf32_##x 25 | #define ELFW_(x) ELF32_##x 26 | #endif 27 | 28 | #endif // __ANDROID__ 29 | 30 | namespace KittyUtils { 31 | 32 | #ifdef __ANDROID__ 33 | std::string getExternalStorage(); 34 | int getAndroidVersion(); 35 | int getAndroidSDK(); 36 | #endif 37 | 38 | std::string fileNameFromPath(const std::string &filePath); 39 | std::string fileDirectory(const std::string &filePath); 40 | std::string fileExtension(const std::string &filePath); 41 | 42 | namespace String 43 | { 44 | static inline bool StartsWith(const std::string &str, const std::string &str2) 45 | { 46 | return str.length() >= str2.length() && str.compare(0, str2.length(), str2) == 0; 47 | } 48 | 49 | static inline bool Contains(const std::string &str, const std::string &str2) 50 | { 51 | return str.length() >= str2.length() && str.find(str2) != std::string::npos; 52 | } 53 | 54 | static inline bool EndsWith(const std::string &str, const std::string &str2) 55 | { 56 | return str.length() >= str2.length() && str.compare(str.length() - str2.length(), str2.length(), str2) == 0; 57 | } 58 | 59 | void Trim(std::string &str); 60 | 61 | bool ValidateHex(std::string &hex); 62 | 63 | std::string Fmt(const char *fmt, ...); 64 | 65 | std::string Random(size_t length); 66 | } // namespace String 67 | 68 | template 69 | T randInt(T min, T max) 70 | { 71 | using param_type = typename std::uniform_int_distribution::param_type; 72 | 73 | thread_local static std::mt19937 gen{std::random_device{}()}; 74 | thread_local static std::uniform_int_distribution dist; 75 | 76 | return dist(gen, param_type{min, max}); 77 | } 78 | 79 | template std::string data2Hex(const T &data) 80 | { 81 | const auto *byteData = reinterpret_cast(&data); 82 | std::stringstream hexStringStream; 83 | 84 | hexStringStream << std::hex << std::setfill('0'); 85 | for (size_t index = 0; index < sizeof(T); ++index) 86 | hexStringStream << std::setw(2) << static_cast(byteData[index]); 87 | 88 | return hexStringStream.str(); 89 | } 90 | 91 | std::string data2Hex(const void *data, const size_t dataLength); 92 | void dataFromHex(const std::string &in, void *data); 93 | 94 | template 95 | std::string HexDump(const void *address, size_t len) 96 | { 97 | if (!address || len == 0 || rowSize == 0) 98 | return ""; 99 | 100 | const unsigned char *data = static_cast(address); 101 | 102 | std::stringstream ss; 103 | ss << std::hex << std::uppercase << std::setfill('0'); 104 | 105 | size_t i, j; 106 | 107 | for (i = 0; i < len; i += rowSize) 108 | { 109 | // offset 110 | ss << std::setw(8) << i << ": "; 111 | 112 | // row bytes 113 | for (j = 0; (j < rowSize) && ((i + j) < len); j++) 114 | ss << std::setw(2) << static_cast(data[i + j]) << " "; 115 | 116 | // fill row empty space 117 | for (; j < rowSize; j++) 118 | ss << " "; 119 | 120 | // ASCII 121 | if (showASCII) 122 | { 123 | ss << " "; 124 | 125 | for (j = 0; (j < rowSize) && ((i + j) < len); j++) 126 | { 127 | if (std::isprint(data[i + j])) 128 | ss << data[i + j]; 129 | else 130 | ss << '.'; 131 | } 132 | } 133 | 134 | ss << std::endl; 135 | } 136 | 137 | return ss.str(); 138 | } 139 | 140 | #ifdef __ANDROID__ 141 | 142 | namespace Elf { 143 | namespace ElfHash { 144 | /** 145 | * Lookup symbol by name in hash table 146 | * 147 | * @elfhash: DT_HASH hash table address 148 | * @symtab: DT_SYMTAB symbol table address 149 | * @strtab: DT_STRTAB string table address 150 | * @syment: DT_SYMENT symbol table entry size address 151 | * @syment: DT_STRSZ string table size 152 | * 153 | * @return ElfSym pointer 154 | */ 155 | const ElfW_(Sym) *LookupByName(uintptr_t elfhash, 156 | uintptr_t symtab, 157 | uintptr_t strtab, 158 | size_t syment, 159 | size_t strsz, 160 | const char *symbol_name); 161 | } 162 | 163 | namespace GnuHash { 164 | /** 165 | * Lookup symbol by name in gnu hash table 166 | * 167 | * @elfhash: DT_GNU_HASH gnu hash table address 168 | * @symtab: DT_SYMTAB symbol table address 169 | * @strtab: DT_STRTAB string table address 170 | * @syment: DT_SYMENT symbol table entry size address 171 | * @syment: DT_STRSZ string table size 172 | * 173 | * @return ElfSym pointer 174 | */ 175 | const ElfW_(Sym) *LookupByName(uintptr_t gnuhash, 176 | uintptr_t symtab, 177 | uintptr_t strtab, 178 | size_t syment, 179 | size_t strsz, 180 | const char *symbol_name); 181 | } 182 | } 183 | 184 | #endif // __ANDROID__ 185 | 186 | } -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/MemoryBackup.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // MemoryBackup.h 3 | // 4 | // Created by MJ (Ruit) on 4/19/20. 5 | // 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "KittyMemory.hpp" 14 | 15 | 16 | class MemoryBackup 17 | { 18 | private: 19 | uintptr_t _address; 20 | size_t _size; 21 | 22 | std::vector _orig_code; 23 | 24 | public: 25 | MemoryBackup(); 26 | ~MemoryBackup(); 27 | 28 | static MemoryBackup createBackup(uintptr_t absolute_address, size_t backup_size); 29 | 30 | #ifdef __ANDROID__ 31 | static MemoryBackup createBackup(const KittyMemory::ProcMap &map, uintptr_t address, size_t backup_size); 32 | #elif __APPLE__ 33 | static MemoryBackup createBackup(const char *fileName, uintptr_t address, size_t backup_size); 34 | #endif 35 | 36 | bool isValid() const; 37 | size_t get_BackupSize() const; 38 | uintptr_t get_TargetAddress() const; 39 | 40 | /* 41 | * Restores backup code 42 | */ 43 | bool Restore(); 44 | 45 | /* 46 | * Returns hex string of the current target address bytes 47 | */ 48 | std::string get_CurrBytes() const; 49 | 50 | /* 51 | * Returns hex string of the original bytes 52 | */ 53 | std::string get_OrigBytes() const; 54 | }; 55 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/MemoryPatch.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // MemoryPatch.h 3 | // 4 | // Created by MJ (Ruit) on 1/1/19. 5 | // 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include "KittyMemory.hpp" 14 | 15 | enum MP_ASM_ARCH { 16 | MP_ASM_ARM32 = 0, 17 | MP_ASM_ARM64, 18 | MP_ASM_x86, 19 | MP_ASM_x86_64, 20 | }; 21 | 22 | class MemoryPatch 23 | { 24 | private: 25 | uintptr_t _address; 26 | size_t _size; 27 | 28 | std::vector _orig_code; 29 | std::vector _patch_code; 30 | 31 | public: 32 | MemoryPatch(); 33 | ~MemoryPatch(); 34 | 35 | static MemoryPatch createWithBytes(uintptr_t absolute_address, const void *patch_code, size_t patch_size); 36 | static MemoryPatch createWithHex(uintptr_t absolute_address, std::string hex); 37 | 38 | #ifndef kNO_KEYSTONE 39 | /** 40 | * Keystone assembler 41 | */ 42 | static MemoryPatch createWithAsm(uintptr_t absolute_address, MP_ASM_ARCH asm_arch, const std::string &asm_code, uintptr_t asm_address=0); 43 | #endif 44 | 45 | #ifdef __ANDROID__ 46 | 47 | static MemoryPatch createWithBytes(const KittyMemory::ProcMap &map, uintptr_t address, const void *patch_code, size_t patch_size); 48 | static MemoryPatch createWithHex(const KittyMemory::ProcMap &map, uintptr_t address, const std::string &hex); 49 | 50 | #ifndef kNO_KEYSTONE 51 | /** 52 | * Keystone assembler 53 | */ 54 | static MemoryPatch createWithAsm(const KittyMemory::ProcMap &map, uintptr_t address, MP_ASM_ARCH asm_arch, const std::string &asm_code, uintptr_t asm_address=0); 55 | #endif 56 | 57 | #elif __APPLE__ 58 | 59 | static MemoryPatch createWithBytes(const char *fileName, uintptr_t address, const void *patch_code, size_t patch_size); 60 | static MemoryPatch createWithHex(const char *fileName, uintptr_t address, const std::string &hex); 61 | 62 | #ifndef kNO_KEYSTONE 63 | /** 64 | * Keystone assembler 65 | */ 66 | static MemoryPatch createWithAsm(const char *fileName, uintptr_t address, MP_ASM_ARCH asm_arch, const std::string &asm_code, uintptr_t asm_address=0); 67 | #endif 68 | 69 | #endif 70 | 71 | 72 | bool isValid() const; 73 | size_t get_PatchSize() const; 74 | uintptr_t get_TargetAddress() const; 75 | 76 | /* 77 | * Restores the patch to the original value 78 | */ 79 | bool Restore(); 80 | 81 | /* 82 | * Applies patch modifications to the target address 83 | */ 84 | bool Modify(); 85 | 86 | /* 87 | * Returns hex string of the current target address bytes 88 | */ 89 | std::string get_CurrBytes() const; 90 | 91 | /* 92 | * Returns hex string of the original bytes 93 | */ 94 | std::string get_OrigBytes() const; 95 | 96 | /* 97 | * Returns hex string of the patch bytes 98 | */ 99 | std::string get_PatchBytes() const; 100 | }; 101 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/KittyMemory/writeData.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | This is an alternative for the old writeData that was made by HackJack & Razzile 3 | */ 4 | 5 | #pragma once 6 | 7 | #ifdef __APPLE__ 8 | 9 | #include 10 | #include 11 | 12 | #include "MemoryPatch.hpp" 13 | #include 14 | 15 | /* 16 | * expects file name and relative offset, you can pass NULL as filename for base executable 17 | */ 18 | static inline bool writeData8(const char *fileName, uintptr_t offset, uint8_t data) 19 | { 20 | return MemoryPatch::createWithBytes(fileName, offset, &data, 1).Modify(); 21 | } 22 | 23 | static inline bool writeData8(uintptr_t address, uint8_t data) 24 | { 25 | return MemoryPatch::createWithBytes(address, &data, 1).Modify(); 26 | } 27 | 28 | /* 29 | * expects file name and relative offset, you can pass NULL as filename for base executable 30 | */ 31 | static inline bool writeData16(const char *fileName, uintptr_t offset, uint16_t data) 32 | { 33 | uint16_t tmp_data = _OSSwapInt16(data); 34 | return MemoryPatch::createWithBytes(fileName, offset, &tmp_data, 2).Modify(); 35 | } 36 | 37 | static inline bool writeData16(uintptr_t address, uint16_t data) 38 | { 39 | uint16_t tmp_data = _OSSwapInt16(data); 40 | return MemoryPatch::createWithBytes(address, &tmp_data, 2).Modify(); 41 | } 42 | 43 | /* 44 | * expects file name and relative offset, you can pass NULL as filename for base executable 45 | */ 46 | static inline bool writeData32(const char *fileName, uintptr_t offset, uint32_t data) 47 | { 48 | uint32_t tmp_data = _OSSwapInt32(data); 49 | return MemoryPatch::createWithBytes(fileName, offset, &tmp_data, 4).Modify(); 50 | } 51 | 52 | static inline bool writeData32(uintptr_t address, uint32_t data) 53 | { 54 | uint32_t tmp_data = _OSSwapInt32(data); 55 | return MemoryPatch::createWithBytes(address, &tmp_data, 4).Modify(); 56 | } 57 | 58 | /* 59 | * expects file name and relative offset, you can pass NULL as filename for base executable 60 | */ 61 | static inline bool writeData64(const char *fileName, uintptr_t offset, uint64_t data) 62 | { 63 | uint64_t tmp_data = _OSSwapInt64(data); 64 | return MemoryPatch::createWithBytes(fileName, offset, &tmp_data, 8).Modify(); 65 | } 66 | 67 | static inline bool writeData64(uintptr_t address, uint64_t data) 68 | { 69 | uint64_t tmp_data = _OSSwapInt64(data); 70 | return MemoryPatch::createWithBytes(address, &tmp_data, 8).Modify(); 71 | } 72 | 73 | #endif -------------------------------------------------------------------------------- /app/src/main/cpp/include/fileselector/fileselector.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by maks on 11.12.2022. 3 | // 4 | 5 | #ifndef SKY_MODLOADER_FILESELECTOR_H 6 | #define SKY_MODLOADER_FILESELECTOR_H 7 | 8 | #include 9 | 10 | /** 11 | * Callback function for requestFile 12 | * fd - the file descriptor 13 | * You need to close it yourself 14 | */ 15 | typedef void (*callback_function)(int fd); 16 | 17 | /** 18 | * Request a file from the user 19 | * mime_type - the MIME type that you want to select 20 | * callback - the callback function that will be called when a file is selected 21 | * save - whether you need to save (true) or load (false) a file with the selector 22 | * Returns: 23 | * true if the file selection was requested 24 | * false if the selector is already busy 25 | */ 26 | bool requestFile(const char* mime_type, callback_function callback, bool save); 27 | 28 | #endif //SKY_MODLOADER_FILESELECTOR_H 29 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/iconloader/IconLoader.h: -------------------------------------------------------------------------------- 1 | #ifndef SKY_MODLOADER_ICONLOADER_H 2 | #define SKY_MODLOADER_ICONLOADER_H 3 | #include "../imgui/imgui.h" 4 | 5 | #define IL_NO_TEXTURE (ImTextureID)-1 6 | 7 | class SkyImage { 8 | public: 9 | ImTextureID textureId; 10 | ImVec2 size; 11 | }; 12 | 13 | class UIIcon { 14 | public: 15 | ImTextureID textureId; 16 | ImVec2 uv0; 17 | ImVec2 uv1; 18 | }; 19 | 20 | class IconLoader { 21 | public: 22 | /** 23 | * Gets an image under the name "name" from Data/Images/bin/ETC2/.ktx, ready to be drawn using ImGui::Image or ImGui::ImageButton if it was loaded successfully 24 | * Returns: a SkyImage object 25 | * If the image fails to load for some reason, the textureId would be equal to IL_NO_TEXTURE, and must not be drawn by your code. 26 | */ 27 | static SkyImage& getImage(const std::string& name); 28 | /** 29 | * Draws an icon, loaded by its name from UiPackedAtlas.lua, with the specified name and size in pixels 30 | */ 31 | static void icon(const std::string& name, const float& size, const ImVec4& color = ImVec4(1,1,1,1)); 32 | /** 33 | * Creates a button with an icon, loaded by its name from UiPackedAtlas.lua, with the specified name and size in pixels 34 | */ 35 | static bool iconButton(const std::string& name, const float& size, const ImVec4& color = ImVec4(1,1,1,1)); 36 | /** 37 | * Gets the required parameters for an icon, loaded by its name from UiPackedAtlas.lua, with the specified name 38 | * If icon->textureId is IL_NO_TEXTURE, the icon data is not valid and it shouldn't be drawn. 39 | * Note: you should not store the result of this function outside of your draw function's scope 40 | */ 41 | static void getUIIcon(const std::string &name, UIIcon* icon); 42 | }; 43 | 44 | 45 | #endif //SKY_MODLOADER_ICONLOADER_H 46 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/imgui/androidbk.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by winter on 12/07/2022. 3 | // 4 | 5 | #ifndef SKY_MODLOADER_ANDROIDBK_H 6 | #define SKY_MODLOADER_ANDROIDBK_H 7 | 8 | void set_ImguiDrawFunc(void (*)()); 9 | 10 | #endif //SKY_MODLOADER_ANDROIDBK_H 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // DEAR IMGUI COMPILE-TIME OPTIONS 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp file to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | // DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions() 25 | // for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details. 26 | //#define IMGUI_API __declspec( dllexport ) 27 | //#define IMGUI_API __declspec( dllimport ) 28 | 29 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names. 30 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 31 | //#define IMGUI_DISABLE_OBSOLETE_KEYIO // 1.87+ disable legacy io.KeyMap[]+io.KeysDown[] in favor io.AddKeyEvent(). This is automatically done by IMGUI_DISABLE_OBSOLETE_FUNCTIONS. 32 | 33 | //---- Disable all of Dear ImGui or don't implement standard windows/tools. 34 | // It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp. 35 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 36 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. 37 | //#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIDStackToolWindow() will be empty. 38 | 39 | //---- Don't implement some functions to reduce linkage requirements. 40 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. (user32.lib/.a, kernel32.lib/.a) 41 | //#define IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with Visual Studio] Implement default IME handler (require imm32.lib/.a, auto-link for Visual Studio, -limm32 on command-line for MinGW) 42 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] [Default with non-Visual Studio compilers] Don't implement default IME handler (won't require imm32.lib/.a) 43 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, IME). 44 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 45 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 46 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 47 | //#define IMGUI_DISABLE_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle at all (replace them with dummies) 48 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite and ImFileHandle so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 49 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 50 | //#define IMGUI_DISABLE_SSE // Disable use of SSE intrinsics even if available 51 | 52 | //---- Include imgui_user.h at the end of imgui.h as a convenience 53 | // May be convenient for some users to only explicitly include vanilla imgui.h and have extra stuff included. 54 | //#define IMGUI_INCLUDE_IMGUI_USER_H 55 | //#define IMGUI_USER_H_FILENAME "my_folder/my_imgui_user.h" 56 | 57 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 58 | //#define IMGUI_USE_BGRA_PACKED_COLOR 59 | 60 | //---- Use 32-bit for ImWchar (default is 16-bit) to support Unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 61 | //#define IMGUI_USE_WCHAR32 62 | 63 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 64 | // By default the embedded implementations are declared static and not available outside of Dear ImGui sources files. 65 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 66 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 67 | //#define IMGUI_STB_SPRINTF_FILENAME "my_folder/stb_sprintf.h" // only used if IMGUI_USE_STB_SPRINTF is defined. 68 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 69 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 70 | //#define IMGUI_DISABLE_STB_SPRINTF_IMPLEMENTATION // only disabled if IMGUI_USE_STB_SPRINTF is defined. 71 | 72 | //---- Use stb_sprintf.h for a faster implementation of vsnprintf instead of the one from libc (unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined) 73 | // Compatibility checks of arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by stb_sprintf.h. 74 | //#define IMGUI_USE_STB_SPRINTF 75 | 76 | //---- Use FreeType to build and rasterize the font atlas (instead of stb_truetype which is embedded by default in Dear ImGui) 77 | // Requires FreeType headers to be available in the include path. Requires program to be compiled with 'misc/freetype/imgui_freetype.cpp' (in this repository) + the FreeType library (not provided). 78 | // On Windows you may use vcpkg with 'vcpkg install freetype --triplet=x64-windows' + 'vcpkg integrate install'. 79 | //#define IMGUI_ENABLE_FREETYPE 80 | 81 | //---- Use FreeType+lunasvg library to render OpenType SVG fonts (SVGinOT) 82 | // Requires lunasvg headers to be available in the include path + program to be linked with the lunasvg library (not provided). 83 | // Only works in combination with IMGUI_ENABLE_FREETYPE. 84 | // (implementation is based on Freetype's rsvg-port.c which is licensed under CeCILL-C Free Software License Agreement) 85 | //#define IMGUI_ENABLE_FREETYPE_LUNASVG 86 | 87 | //---- Use stb_truetype to build and rasterize the font atlas (default) 88 | // The only purpose of this define is if you want force compilation of the stb_truetype backend ALONG with the FreeType backend. 89 | //#define IMGUI_ENABLE_STB_TRUETYPE 90 | 91 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 92 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 93 | /* 94 | #define IM_VEC2_CLASS_EXTRA \ 95 | constexpr ImVec2(const MyVec2& f) : x(f.x), y(f.y) {} \ 96 | operator MyVec2() const { return MyVec2(x,y); } 97 | 98 | #define IM_VEC4_CLASS_EXTRA \ 99 | constexpr ImVec4(const MyVec4& f) : x(f.x), y(f.y), z(f.z), w(f.w) {} \ 100 | operator MyVec4() const { return MyVec4(x,y,z,w); } 101 | */ 102 | //---- ...Or use Dear ImGui's own very basic math operators. 103 | //#define IMGUI_DEFINE_MATH_OPERATORS 104 | 105 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 106 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 107 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 108 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 109 | //#define ImDrawIdx unsigned int 110 | 111 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 112 | //struct ImDrawList; 113 | //struct ImDrawCmd; 114 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 115 | //#define ImDrawCallback MyImDrawCallback 116 | 117 | //---- Debug Tools: Macro to break in Debugger (we provide a default implementation of this in the codebase) 118 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 119 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 120 | //#define IM_DEBUG_BREAK __debugbreak() 121 | 122 | //---- Debug Tools: Enable slower asserts 123 | //#define IMGUI_DEBUG_PARANOID 124 | 125 | //---- Tip: You can add extra functions within the ImGui:: namespace from anywhere (e.g. your own sources/header files) 126 | /* 127 | namespace ImGui 128 | { 129 | void MyFunction(const char* name, MyMatrix44* mtx); 130 | } 131 | */ 132 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/imgui/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for modern OpenGL with shaders / programmatic pipeline 2 | // - Desktop GL: 2.x 3.x 4.x 3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) 4 | // This needs to be used along with a Platform Backend (e.g. GLFW, SDL, Win32, custom..) 5 | 6 | // Implemented features: 7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! 8 | // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit indices. 9 | 10 | // You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 11 | // Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need. 12 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 13 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 14 | 15 | // About GLSL version: 16 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 17 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 18 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 19 | 20 | #pragma once 21 | #include "imgui.h" // IMGUI_IMPL_API 22 | 23 | // Backend API 24 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 25 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 26 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 27 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 28 | 29 | // (Optional) Called by Init/NewFrame/Shutdown 30 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 31 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 32 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 33 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 34 | 35 | // Specific OpenGL ES versions 36 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten 37 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android 38 | 39 | // You can explicitly select GLES2 or GLES3 API by using one of the '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. 40 | #if !defined(IMGUI_IMPL_OPENGL_ES2) \ 41 | && !defined(IMGUI_IMPL_OPENGL_ES3) 42 | 43 | // Try to detect GLES on matching platforms 44 | #if defined(__APPLE__) 45 | #include 46 | #endif 47 | #if (defined(__APPLE__) && (TARGET_OS_IOS || TARGET_OS_TV)) || (defined(__ANDROID__)) 48 | #define IMGUI_IMPL_OPENGL_ES3 // iOS, Android -> GL ES 3, "#version 300 es" 49 | #elif defined(__EMSCRIPTEN__) || defined(__amigaos4__) 50 | #define IMGUI_IMPL_OPENGL_ES2 // Emscripten -> GL ES 2, "#version 100" 51 | #else 52 | // Otherwise imgui_impl_opengl3_loader.h will be used. 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/imgui/imgui_impl_opengl3_loader.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // About imgui_impl_opengl3_loader.h: 3 | // 4 | // We embed our own OpenGL loader to not require user to provide their own or to have to use ours, 5 | // which proved to be endless problems for users. 6 | // Our loader is custom-generated, based on gl3w but automatically filtered to only include 7 | // enums/functions that we use in our imgui_impl_opengl3.cpp source file in order to be small. 8 | // 9 | // YOU SHOULD NOT NEED TO INCLUDE/USE THIS DIRECTLY. THIS IS USED BY imgui_impl_opengl3.cpp ONLY. 10 | // THE REST OF YOUR APP SHOULD USE A DIFFERENT GL LOADER: ANY GL LOADER OF YOUR CHOICE. 11 | // 12 | // Regenerate with: 13 | // python gl3w_gen.py --output ../imgui/backends/imgui_impl_opengl3_loader.h --ref ../imgui/backends/imgui_impl_opengl3.cpp ./extra_symbols.txt 14 | // 15 | // More info: 16 | // https://github.com/dearimgui/gl3w_stripped 17 | // https://github.com/ocornut/imgui/issues/4445 18 | //----------------------------------------------------------------------------- 19 | 20 | /* 21 | * This file was generated with gl3w_gen.py, part of imgl3w 22 | * (hosted at https://github.com/dearimgui/gl3w_stripped) 23 | * 24 | * This is free and unencumbered software released into the public domain. 25 | * 26 | * Anyone is free to copy, modify, publish, use, compile, sell, or 27 | * distribute this software, either in source code form or as a compiled 28 | * binary, for any purpose, commercial or non-commercial, and by any 29 | * means. 30 | * 31 | * In jurisdictions that recognize copyright laws, the author or authors 32 | * of this software dedicate any and all copyright interest in the 33 | * software to the public domain. We make this dedication for the benefit 34 | * of the public at large and to the detriment of our heirs and 35 | * successors. We intend this dedication to be an overt act of 36 | * relinquishment in perpetuity of all present and future rights to this 37 | * software under copyright law. 38 | * 39 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 40 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 41 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 42 | * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 43 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 44 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 45 | * OTHER DEALINGS IN THE SOFTWARE. 46 | */ 47 | 48 | #ifndef __gl3w_h_ 49 | #define __gl3w_h_ 50 | 51 | // Adapted from KHR/khrplatform.h to avoid including entire file. 52 | #ifndef __khrplatform_h_ 53 | typedef float khronos_float_t; 54 | typedef signed char khronos_int8_t; 55 | typedef unsigned char khronos_uint8_t; 56 | typedef signed short int khronos_int16_t; 57 | typedef unsigned short int khronos_uint16_t; 58 | #ifdef _WIN64 59 | typedef signed long long int khronos_intptr_t; 60 | typedef signed long long int khronos_ssize_t; 61 | #else 62 | typedef signed long int khronos_intptr_t; 63 | typedef signed long int khronos_ssize_t; 64 | #endif 65 | 66 | #if defined(_MSC_VER) && !defined(__clang__) 67 | typedef signed __int64 khronos_int64_t; 68 | typedef unsigned __int64 khronos_uint64_t; 69 | #elif (defined(__clang__) || defined(__GNUC__)) && (__cplusplus < 201100) 70 | #include 71 | typedef int64_t khronos_int64_t; 72 | typedef uint64_t khronos_uint64_t; 73 | #else 74 | typedef signed long long khronos_int64_t; 75 | typedef unsigned long long khronos_uint64_t; 76 | #endif 77 | #endif // __khrplatform_h_ 78 | 79 | #ifndef __gl_glcorearb_h_ 80 | #define __gl_glcorearb_h_ 1 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | /* 85 | ** Copyright 2013-2020 The Khronos Group Inc. 86 | ** SPDX-License-Identifier: MIT 87 | ** 88 | ** This header is generated from the Khronos OpenGL / OpenGL ES XML 89 | ** API Registry. The current version of the Registry, generator scripts 90 | ** used to make the header, and the header can be found at 91 | ** https://github.com/KhronosGroup/OpenGL-Registry 92 | */ 93 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) 94 | #ifndef WIN32_LEAN_AND_MEAN 95 | #define WIN32_LEAN_AND_MEAN 1 96 | #endif 97 | #include 98 | #endif 99 | #ifndef APIENTRY 100 | #define APIENTRY 101 | #endif 102 | #ifndef APIENTRYP 103 | #define APIENTRYP APIENTRY * 104 | #endif 105 | #ifndef GLAPI 106 | #define GLAPI extern 107 | #endif 108 | /* glcorearb.h is for use with OpenGL core profile implementations. 109 | ** It should should be placed in the same directory as gl.h and 110 | ** included as . 111 | ** 112 | ** glcorearb.h includes only APIs in the latest OpenGL core profile 113 | ** implementation together with APIs in newer ARB extensions which 114 | ** can be supported by the core profile. It does not, and never will 115 | ** include functionality removed from the core profile, such as 116 | ** fixed-function vertex and fragment processing. 117 | ** 118 | ** Do not #include both and either of or 119 | ** in the same source file. 120 | */ 121 | /* Generated C header for: 122 | * API: gl 123 | * Profile: core 124 | * Versions considered: .* 125 | * Versions emitted: .* 126 | * Default extensions included: glcore 127 | * Additional extensions included: _nomatch_^ 128 | * Extensions removed: _nomatch_^ 129 | */ 130 | #ifndef GL_VERSION_1_0 131 | typedef void GLvoid; 132 | typedef unsigned int GLenum; 133 | 134 | typedef khronos_float_t GLfloat; 135 | typedef int GLint; 136 | typedef int GLsizei; 137 | typedef unsigned int GLbitfield; 138 | typedef double GLdouble; 139 | typedef unsigned int GLuint; 140 | typedef unsigned char GLboolean; 141 | typedef khronos_uint8_t GLubyte; 142 | #define GL_COLOR_BUFFER_BIT 0x00004000 143 | #define GL_FALSE 0 144 | #define GL_TRUE 1 145 | #define GL_TRIANGLES 0x0004 146 | #define GL_ONE 1 147 | #define GL_SRC_ALPHA 0x0302 148 | #define GL_ONE_MINUS_SRC_ALPHA 0x0303 149 | #define GL_FRONT_AND_BACK 0x0408 150 | #define GL_POLYGON_MODE 0x0B40 151 | #define GL_CULL_FACE 0x0B44 152 | #define GL_DEPTH_TEST 0x0B71 153 | #define GL_STENCIL_TEST 0x0B90 154 | #define GL_VIEWPORT 0x0BA2 155 | #define GL_BLEND 0x0BE2 156 | #define GL_SCISSOR_BOX 0x0C10 157 | #define GL_SCISSOR_TEST 0x0C11 158 | #define GL_UNPACK_ROW_LENGTH 0x0CF2 159 | #define GL_PACK_ALIGNMENT 0x0D05 160 | #define GL_TEXTURE_2D 0x0DE1 161 | #define GL_UNSIGNED_BYTE 0x1401 162 | #define GL_UNSIGNED_SHORT 0x1403 163 | #define GL_UNSIGNED_INT 0x1405 164 | #define GL_FLOAT 0x1406 165 | #define GL_RGBA 0x1908 166 | #define GL_FILL 0x1B02 167 | #define GL_VENDOR 0x1F00 168 | #define GL_RENDERER 0x1F01 169 | #define GL_VERSION 0x1F02 170 | #define GL_EXTENSIONS 0x1F03 171 | #define GL_LINEAR 0x2601 172 | #define GL_TEXTURE_MAG_FILTER 0x2800 173 | #define GL_TEXTURE_MIN_FILTER 0x2801 174 | typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode); 175 | typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); 176 | typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); 177 | typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); 178 | typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); 179 | typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 180 | typedef void (APIENTRYP PFNGLDISABLEPROC) (GLenum cap); 181 | typedef void (APIENTRYP PFNGLENABLEPROC) (GLenum cap); 182 | typedef void (APIENTRYP PFNGLFLUSHPROC) (void); 183 | typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); 184 | typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); 185 | typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void); 186 | typedef void (APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); 187 | typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); 188 | typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); 189 | typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); 190 | #ifdef GL_GLEXT_PROTOTYPES 191 | GLAPI void APIENTRY glPolygonMode (GLenum face, GLenum mode); 192 | GLAPI void APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); 193 | GLAPI void APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); 194 | GLAPI void APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); 195 | GLAPI void APIENTRY glClear (GLbitfield mask); 196 | GLAPI void APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); 197 | GLAPI void APIENTRY glDisable (GLenum cap); 198 | GLAPI void APIENTRY glEnable (GLenum cap); 199 | GLAPI void APIENTRY glFlush (void); 200 | GLAPI void APIENTRY glPixelStorei (GLenum pname, GLint param); 201 | GLAPI void APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); 202 | GLAPI GLenum APIENTRY glGetError (void); 203 | GLAPI void APIENTRY glGetIntegerv (GLenum pname, GLint *data); 204 | GLAPI const GLubyte *APIENTRY glGetString (GLenum name); 205 | GLAPI GLboolean APIENTRY glIsEnabled (GLenum cap); 206 | GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); 207 | #endif 208 | #endif /* GL_VERSION_1_0 */ 209 | #ifndef GL_VERSION_1_1 210 | typedef khronos_float_t GLclampf; 211 | typedef double GLclampd; 212 | #define GL_TEXTURE_BINDING_2D 0x8069 213 | typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); 214 | typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); 215 | typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); 216 | typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); 217 | #ifdef GL_GLEXT_PROTOTYPES 218 | GLAPI void APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); 219 | GLAPI void APIENTRY glBindTexture (GLenum target, GLuint texture); 220 | GLAPI void APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); 221 | GLAPI void APIENTRY glGenTextures (GLsizei n, GLuint *textures); 222 | #endif 223 | #endif /* GL_VERSION_1_1 */ 224 | #ifndef GL_VERSION_1_3 225 | #define GL_TEXTURE0 0x84C0 226 | #define GL_ACTIVE_TEXTURE 0x84E0 227 | typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); 228 | #ifdef GL_GLEXT_PROTOTYPES 229 | GLAPI void APIENTRY glActiveTexture (GLenum texture); 230 | #endif 231 | #endif /* GL_VERSION_1_3 */ 232 | #ifndef GL_VERSION_1_4 233 | #define GL_BLEND_DST_RGB 0x80C8 234 | #define GL_BLEND_SRC_RGB 0x80C9 235 | #define GL_BLEND_DST_ALPHA 0x80CA 236 | #define GL_BLEND_SRC_ALPHA 0x80CB 237 | #define GL_FUNC_ADD 0x8006 238 | typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); 239 | typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); 240 | #ifdef GL_GLEXT_PROTOTYPES 241 | GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); 242 | GLAPI void APIENTRY glBlendEquation (GLenum mode); 243 | #endif 244 | #endif /* GL_VERSION_1_4 */ 245 | #ifndef GL_VERSION_1_5 246 | typedef khronos_ssize_t GLsizeiptr; 247 | typedef khronos_intptr_t GLintptr; 248 | #define GL_ARRAY_BUFFER 0x8892 249 | #define GL_ELEMENT_ARRAY_BUFFER 0x8893 250 | #define GL_ARRAY_BUFFER_BINDING 0x8894 251 | #define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 252 | #define GL_STREAM_DRAW 0x88E0 253 | typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); 254 | typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); 255 | typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); 256 | typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); 257 | typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); 258 | #ifdef GL_GLEXT_PROTOTYPES 259 | GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); 260 | GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); 261 | GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); 262 | GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); 263 | GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); 264 | #endif 265 | #endif /* GL_VERSION_1_5 */ 266 | #ifndef GL_VERSION_2_0 267 | typedef char GLchar; 268 | typedef khronos_int16_t GLshort; 269 | typedef khronos_int8_t GLbyte; 270 | typedef khronos_uint16_t GLushort; 271 | #define GL_BLEND_EQUATION_RGB 0x8009 272 | #define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 273 | #define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 274 | #define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 275 | #define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 276 | #define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 277 | #define GL_BLEND_EQUATION_ALPHA 0x883D 278 | #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A 279 | #define GL_FRAGMENT_SHADER 0x8B30 280 | #define GL_VERTEX_SHADER 0x8B31 281 | #define GL_COMPILE_STATUS 0x8B81 282 | #define GL_LINK_STATUS 0x8B82 283 | #define GL_INFO_LOG_LENGTH 0x8B84 284 | #define GL_CURRENT_PROGRAM 0x8B8D 285 | #define GL_UPPER_LEFT 0x8CA2 286 | typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); 287 | typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); 288 | typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); 289 | typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); 290 | typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); 291 | typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); 292 | typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); 293 | typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); 294 | typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); 295 | typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); 296 | typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); 297 | typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); 298 | typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 299 | typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); 300 | typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 301 | typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); 302 | typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); 303 | typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); 304 | typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); 305 | typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); 306 | typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); 307 | typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); 308 | typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 309 | typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); 310 | #ifdef GL_GLEXT_PROTOTYPES 311 | GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); 312 | GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); 313 | GLAPI void APIENTRY glCompileShader (GLuint shader); 314 | GLAPI GLuint APIENTRY glCreateProgram (void); 315 | GLAPI GLuint APIENTRY glCreateShader (GLenum type); 316 | GLAPI void APIENTRY glDeleteProgram (GLuint program); 317 | GLAPI void APIENTRY glDeleteShader (GLuint shader); 318 | GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); 319 | GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); 320 | GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); 321 | GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); 322 | GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); 323 | GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 324 | GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); 325 | GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); 326 | GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); 327 | GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); 328 | GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); 329 | GLAPI void APIENTRY glLinkProgram (GLuint program); 330 | GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); 331 | GLAPI void APIENTRY glUseProgram (GLuint program); 332 | GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); 333 | GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); 334 | GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); 335 | #endif 336 | #endif /* GL_VERSION_2_0 */ 337 | #ifndef GL_VERSION_3_0 338 | typedef khronos_uint16_t GLhalf; 339 | #define GL_MAJOR_VERSION 0x821B 340 | #define GL_MINOR_VERSION 0x821C 341 | #define GL_NUM_EXTENSIONS 0x821D 342 | #define GL_FRAMEBUFFER_SRGB 0x8DB9 343 | #define GL_VERTEX_ARRAY_BINDING 0x85B5 344 | typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); 345 | typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); 346 | typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); 347 | typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); 348 | typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); 349 | typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); 350 | #ifdef GL_GLEXT_PROTOTYPES 351 | GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); 352 | GLAPI void APIENTRY glBindVertexArray (GLuint array); 353 | GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); 354 | GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); 355 | #endif 356 | #endif /* GL_VERSION_3_0 */ 357 | #ifndef GL_VERSION_3_1 358 | #define GL_VERSION_3_1 1 359 | #define GL_PRIMITIVE_RESTART 0x8F9D 360 | #endif /* GL_VERSION_3_1 */ 361 | #ifndef GL_VERSION_3_2 362 | #define GL_VERSION_3_2 1 363 | typedef struct __GLsync *GLsync; 364 | typedef khronos_uint64_t GLuint64; 365 | typedef khronos_int64_t GLint64; 366 | typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); 367 | typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); 368 | #ifdef GL_GLEXT_PROTOTYPES 369 | GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); 370 | #endif 371 | #endif /* GL_VERSION_3_2 */ 372 | #ifndef GL_VERSION_3_3 373 | #define GL_VERSION_3_3 1 374 | #define GL_SAMPLER_BINDING 0x8919 375 | typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); 376 | #ifdef GL_GLEXT_PROTOTYPES 377 | GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); 378 | #endif 379 | #endif /* GL_VERSION_3_3 */ 380 | #ifndef GL_VERSION_4_1 381 | typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); 382 | typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); 383 | #endif /* GL_VERSION_4_1 */ 384 | #ifndef GL_VERSION_4_3 385 | typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); 386 | #endif /* GL_VERSION_4_3 */ 387 | #ifndef GL_VERSION_4_5 388 | #define GL_CLIP_ORIGIN 0x935C 389 | typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); 390 | typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); 391 | #endif /* GL_VERSION_4_5 */ 392 | #ifndef GL_ARB_bindless_texture 393 | typedef khronos_uint64_t GLuint64EXT; 394 | #endif /* GL_ARB_bindless_texture */ 395 | #ifndef GL_ARB_cl_event 396 | struct _cl_context; 397 | struct _cl_event; 398 | #endif /* GL_ARB_cl_event */ 399 | #ifndef GL_ARB_clip_control 400 | #define GL_ARB_clip_control 1 401 | #endif /* GL_ARB_clip_control */ 402 | #ifndef GL_ARB_debug_output 403 | typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); 404 | #endif /* GL_ARB_debug_output */ 405 | #ifndef GL_EXT_EGL_image_storage 406 | typedef void *GLeglImageOES; 407 | #endif /* GL_EXT_EGL_image_storage */ 408 | #ifndef GL_EXT_direct_state_access 409 | typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); 410 | typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); 411 | typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); 412 | typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); 413 | typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); 414 | #endif /* GL_EXT_direct_state_access */ 415 | #ifndef GL_NV_draw_vulkan_image 416 | typedef void (APIENTRY *GLVULKANPROCNV)(void); 417 | #endif /* GL_NV_draw_vulkan_image */ 418 | #ifndef GL_NV_gpu_shader5 419 | typedef khronos_int64_t GLint64EXT; 420 | #endif /* GL_NV_gpu_shader5 */ 421 | #ifndef GL_NV_vertex_buffer_unified_memory 422 | typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); 423 | #endif /* GL_NV_vertex_buffer_unified_memory */ 424 | #ifdef __cplusplus 425 | } 426 | #endif 427 | #endif 428 | 429 | #ifndef GL3W_API 430 | #define GL3W_API 431 | #endif 432 | 433 | #ifndef __gl_h_ 434 | #define __gl_h_ 435 | #endif 436 | 437 | #ifdef __cplusplus 438 | extern "C" { 439 | #endif 440 | 441 | #define GL3W_OK 0 442 | #define GL3W_ERROR_INIT -1 443 | #define GL3W_ERROR_LIBRARY_OPEN -2 444 | #define GL3W_ERROR_OPENGL_VERSION -3 445 | 446 | typedef void (*GL3WglProc)(void); 447 | typedef GL3WglProc (*GL3WGetProcAddressProc)(const char *proc); 448 | 449 | /* gl3w api */ 450 | GL3W_API int imgl3wInit(void); 451 | GL3W_API int imgl3wInit2(GL3WGetProcAddressProc proc); 452 | GL3W_API int imgl3wIsSupported(int major, int minor); 453 | GL3W_API GL3WglProc imgl3wGetProcAddress(const char *proc); 454 | 455 | /* gl3w internal state */ 456 | union GL3WProcs { 457 | GL3WglProc ptr[58]; 458 | struct { 459 | PFNGLACTIVETEXTUREPROC ActiveTexture; 460 | PFNGLATTACHSHADERPROC AttachShader; 461 | PFNGLBINDBUFFERPROC BindBuffer; 462 | PFNGLBINDSAMPLERPROC BindSampler; 463 | PFNGLBINDTEXTUREPROC BindTexture; 464 | PFNGLBINDVERTEXARRAYPROC BindVertexArray; 465 | PFNGLBLENDEQUATIONPROC BlendEquation; 466 | PFNGLBLENDEQUATIONSEPARATEPROC BlendEquationSeparate; 467 | PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate; 468 | PFNGLBUFFERDATAPROC BufferData; 469 | PFNGLBUFFERSUBDATAPROC BufferSubData; 470 | PFNGLCLEARPROC Clear; 471 | PFNGLCLEARCOLORPROC ClearColor; 472 | PFNGLCOMPILESHADERPROC CompileShader; 473 | PFNGLCREATEPROGRAMPROC CreateProgram; 474 | PFNGLCREATESHADERPROC CreateShader; 475 | PFNGLDELETEBUFFERSPROC DeleteBuffers; 476 | PFNGLDELETEPROGRAMPROC DeleteProgram; 477 | PFNGLDELETESHADERPROC DeleteShader; 478 | PFNGLDELETETEXTURESPROC DeleteTextures; 479 | PFNGLDELETEVERTEXARRAYSPROC DeleteVertexArrays; 480 | PFNGLDETACHSHADERPROC DetachShader; 481 | PFNGLDISABLEPROC Disable; 482 | PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray; 483 | PFNGLDRAWELEMENTSPROC DrawElements; 484 | PFNGLDRAWELEMENTSBASEVERTEXPROC DrawElementsBaseVertex; 485 | PFNGLENABLEPROC Enable; 486 | PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; 487 | PFNGLFLUSHPROC Flush; 488 | PFNGLGENBUFFERSPROC GenBuffers; 489 | PFNGLGENTEXTURESPROC GenTextures; 490 | PFNGLGENVERTEXARRAYSPROC GenVertexArrays; 491 | PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; 492 | PFNGLGETERRORPROC GetError; 493 | PFNGLGETINTEGERVPROC GetIntegerv; 494 | PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; 495 | PFNGLGETPROGRAMIVPROC GetProgramiv; 496 | PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; 497 | PFNGLGETSHADERIVPROC GetShaderiv; 498 | PFNGLGETSTRINGPROC GetString; 499 | PFNGLGETSTRINGIPROC GetStringi; 500 | PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; 501 | PFNGLGETVERTEXATTRIBPOINTERVPROC GetVertexAttribPointerv; 502 | PFNGLGETVERTEXATTRIBIVPROC GetVertexAttribiv; 503 | PFNGLISENABLEDPROC IsEnabled; 504 | PFNGLLINKPROGRAMPROC LinkProgram; 505 | PFNGLPIXELSTOREIPROC PixelStorei; 506 | PFNGLPOLYGONMODEPROC PolygonMode; 507 | PFNGLREADPIXELSPROC ReadPixels; 508 | PFNGLSCISSORPROC Scissor; 509 | PFNGLSHADERSOURCEPROC ShaderSource; 510 | PFNGLTEXIMAGE2DPROC TexImage2D; 511 | PFNGLTEXPARAMETERIPROC TexParameteri; 512 | PFNGLUNIFORM1IPROC Uniform1i; 513 | PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; 514 | PFNGLUSEPROGRAMPROC UseProgram; 515 | PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; 516 | PFNGLVIEWPORTPROC Viewport; 517 | } gl; 518 | }; 519 | 520 | GL3W_API extern union GL3WProcs imgl3wProcs; 521 | 522 | /* OpenGL functions */ 523 | #define glActiveTexture imgl3wProcs.gl.ActiveTexture 524 | #define glAttachShader imgl3wProcs.gl.AttachShader 525 | #define glBindBuffer imgl3wProcs.gl.BindBuffer 526 | #define glBindSampler imgl3wProcs.gl.BindSampler 527 | #define glBindTexture imgl3wProcs.gl.BindTexture 528 | #define glBindVertexArray imgl3wProcs.gl.BindVertexArray 529 | #define glBlendEquation imgl3wProcs.gl.BlendEquation 530 | #define glBlendEquationSeparate imgl3wProcs.gl.BlendEquationSeparate 531 | #define glBlendFuncSeparate imgl3wProcs.gl.BlendFuncSeparate 532 | #define glBufferData imgl3wProcs.gl.BufferData 533 | #define glBufferSubData imgl3wProcs.gl.BufferSubData 534 | #define glClear imgl3wProcs.gl.Clear 535 | #define glClearColor imgl3wProcs.gl.ClearColor 536 | #define glCompileShader imgl3wProcs.gl.CompileShader 537 | #define glCreateProgram imgl3wProcs.gl.CreateProgram 538 | #define glCreateShader imgl3wProcs.gl.CreateShader 539 | #define glDeleteBuffers imgl3wProcs.gl.DeleteBuffers 540 | #define glDeleteProgram imgl3wProcs.gl.DeleteProgram 541 | #define glDeleteShader imgl3wProcs.gl.DeleteShader 542 | #define glDeleteTextures imgl3wProcs.gl.DeleteTextures 543 | #define glDeleteVertexArrays imgl3wProcs.gl.DeleteVertexArrays 544 | #define glDetachShader imgl3wProcs.gl.DetachShader 545 | #define glDisable imgl3wProcs.gl.Disable 546 | #define glDisableVertexAttribArray imgl3wProcs.gl.DisableVertexAttribArray 547 | #define glDrawElements imgl3wProcs.gl.DrawElements 548 | #define glDrawElementsBaseVertex imgl3wProcs.gl.DrawElementsBaseVertex 549 | #define glEnable imgl3wProcs.gl.Enable 550 | #define glEnableVertexAttribArray imgl3wProcs.gl.EnableVertexAttribArray 551 | #define glFlush imgl3wProcs.gl.Flush 552 | #define glGenBuffers imgl3wProcs.gl.GenBuffers 553 | #define glGenTextures imgl3wProcs.gl.GenTextures 554 | #define glGenVertexArrays imgl3wProcs.gl.GenVertexArrays 555 | #define glGetAttribLocation imgl3wProcs.gl.GetAttribLocation 556 | #define glGetError imgl3wProcs.gl.GetError 557 | #define glGetIntegerv imgl3wProcs.gl.GetIntegerv 558 | #define glGetProgramInfoLog imgl3wProcs.gl.GetProgramInfoLog 559 | #define glGetProgramiv imgl3wProcs.gl.GetProgramiv 560 | #define glGetShaderInfoLog imgl3wProcs.gl.GetShaderInfoLog 561 | #define glGetShaderiv imgl3wProcs.gl.GetShaderiv 562 | #define glGetString imgl3wProcs.gl.GetString 563 | #define glGetStringi imgl3wProcs.gl.GetStringi 564 | #define glGetUniformLocation imgl3wProcs.gl.GetUniformLocation 565 | #define glGetVertexAttribPointerv imgl3wProcs.gl.GetVertexAttribPointerv 566 | #define glGetVertexAttribiv imgl3wProcs.gl.GetVertexAttribiv 567 | #define glIsEnabled imgl3wProcs.gl.IsEnabled 568 | #define glLinkProgram imgl3wProcs.gl.LinkProgram 569 | #define glPixelStorei imgl3wProcs.gl.PixelStorei 570 | #define glPolygonMode imgl3wProcs.gl.PolygonMode 571 | #define glReadPixels imgl3wProcs.gl.ReadPixels 572 | #define glScissor imgl3wProcs.gl.Scissor 573 | #define glShaderSource imgl3wProcs.gl.ShaderSource 574 | #define glTexImage2D imgl3wProcs.gl.TexImage2D 575 | #define glTexParameteri imgl3wProcs.gl.TexParameteri 576 | #define glUniform1i imgl3wProcs.gl.Uniform1i 577 | #define glUniformMatrix4fv imgl3wProcs.gl.UniformMatrix4fv 578 | #define glUseProgram imgl3wProcs.gl.UseProgram 579 | #define glVertexAttribPointer imgl3wProcs.gl.VertexAttribPointer 580 | #define glViewport imgl3wProcs.gl.Viewport 581 | 582 | #ifdef __cplusplus 583 | } 584 | #endif 585 | 586 | #endif 587 | 588 | #ifdef IMGL3W_IMPL 589 | #ifdef __cplusplus 590 | extern "C" { 591 | #endif 592 | 593 | #include 594 | 595 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 596 | 597 | #if defined(_WIN32) 598 | #ifndef WIN32_LEAN_AND_MEAN 599 | #define WIN32_LEAN_AND_MEAN 1 600 | #endif 601 | #include 602 | 603 | static HMODULE libgl; 604 | typedef PROC(__stdcall* GL3WglGetProcAddr)(LPCSTR); 605 | static GL3WglGetProcAddr wgl_get_proc_address; 606 | 607 | static int open_libgl(void) 608 | { 609 | libgl = LoadLibraryA("opengl32.dll"); 610 | if (!libgl) 611 | return GL3W_ERROR_LIBRARY_OPEN; 612 | wgl_get_proc_address = (GL3WglGetProcAddr)GetProcAddress(libgl, "wglGetProcAddress"); 613 | return GL3W_OK; 614 | } 615 | 616 | static void close_libgl(void) { FreeLibrary(libgl); } 617 | static GL3WglProc get_proc(const char *proc) 618 | { 619 | GL3WglProc res; 620 | res = (GL3WglProc)wgl_get_proc_address(proc); 621 | if (!res) 622 | res = (GL3WglProc)GetProcAddress(libgl, proc); 623 | return res; 624 | } 625 | #elif defined(__APPLE__) 626 | #include 627 | 628 | static void *libgl; 629 | static int open_libgl(void) 630 | { 631 | libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL", RTLD_LAZY | RTLD_LOCAL); 632 | if (!libgl) 633 | return GL3W_ERROR_LIBRARY_OPEN; 634 | return GL3W_OK; 635 | } 636 | 637 | static void close_libgl(void) { dlclose(libgl); } 638 | 639 | static GL3WglProc get_proc(const char *proc) 640 | { 641 | GL3WglProc res; 642 | *(void **)(&res) = dlsym(libgl, proc); 643 | return res; 644 | } 645 | #else 646 | #include 647 | 648 | static void *libgl; 649 | static GL3WglProc (*glx_get_proc_address)(const GLubyte *); 650 | 651 | static int open_libgl(void) 652 | { 653 | libgl = dlopen("libGL.so.1", RTLD_LAZY | RTLD_LOCAL); 654 | if (!libgl) 655 | return GL3W_ERROR_LIBRARY_OPEN; 656 | *(void **)(&glx_get_proc_address) = dlsym(libgl, "glXGetProcAddressARB"); 657 | return GL3W_OK; 658 | } 659 | 660 | static void close_libgl(void) { dlclose(libgl); } 661 | 662 | static GL3WglProc get_proc(const char *proc) 663 | { 664 | GL3WglProc res; 665 | res = glx_get_proc_address((const GLubyte *)proc); 666 | if (!res) 667 | *(void **)(&res) = dlsym(libgl, proc); 668 | return res; 669 | } 670 | #endif 671 | 672 | static struct { int major, minor; } version; 673 | 674 | static int parse_version(void) 675 | { 676 | if (!glGetIntegerv) 677 | return GL3W_ERROR_INIT; 678 | glGetIntegerv(GL_MAJOR_VERSION, &version.major); 679 | glGetIntegerv(GL_MINOR_VERSION, &version.minor); 680 | if (version.major < 3) 681 | return GL3W_ERROR_OPENGL_VERSION; 682 | return GL3W_OK; 683 | } 684 | 685 | static void load_procs(GL3WGetProcAddressProc proc); 686 | 687 | int imgl3wInit(void) 688 | { 689 | int res = open_libgl(); 690 | if (res) 691 | return res; 692 | atexit(close_libgl); 693 | return imgl3wInit2(get_proc); 694 | } 695 | 696 | int imgl3wInit2(GL3WGetProcAddressProc proc) 697 | { 698 | load_procs(proc); 699 | return parse_version(); 700 | } 701 | 702 | int imgl3wIsSupported(int major, int minor) 703 | { 704 | if (major < 3) 705 | return 0; 706 | if (version.major == major) 707 | return version.minor >= minor; 708 | return version.major >= major; 709 | } 710 | 711 | GL3WglProc imgl3wGetProcAddress(const char *proc) { return get_proc(proc); } 712 | 713 | static const char *proc_names[] = { 714 | "glActiveTexture", 715 | "glAttachShader", 716 | "glBindBuffer", 717 | "glBindSampler", 718 | "glBindTexture", 719 | "glBindVertexArray", 720 | "glBlendEquation", 721 | "glBlendEquationSeparate", 722 | "glBlendFuncSeparate", 723 | "glBufferData", 724 | "glBufferSubData", 725 | "glClear", 726 | "glClearColor", 727 | "glCompileShader", 728 | "glCreateProgram", 729 | "glCreateShader", 730 | "glDeleteBuffers", 731 | "glDeleteProgram", 732 | "glDeleteShader", 733 | "glDeleteTextures", 734 | "glDeleteVertexArrays", 735 | "glDetachShader", 736 | "glDisable", 737 | "glDisableVertexAttribArray", 738 | "glDrawElements", 739 | "glDrawElementsBaseVertex", 740 | "glEnable", 741 | "glEnableVertexAttribArray", 742 | "glFlush", 743 | "glGenBuffers", 744 | "glGenTextures", 745 | "glGenVertexArrays", 746 | "glGetAttribLocation", 747 | "glGetError", 748 | "glGetIntegerv", 749 | "glGetProgramInfoLog", 750 | "glGetProgramiv", 751 | "glGetShaderInfoLog", 752 | "glGetShaderiv", 753 | "glGetString", 754 | "glGetStringi", 755 | "glGetUniformLocation", 756 | "glGetVertexAttribPointerv", 757 | "glGetVertexAttribiv", 758 | "glIsEnabled", 759 | "glLinkProgram", 760 | "glPixelStorei", 761 | "glPolygonMode", 762 | "glReadPixels", 763 | "glScissor", 764 | "glShaderSource", 765 | "glTexImage2D", 766 | "glTexParameteri", 767 | "glUniform1i", 768 | "glUniformMatrix4fv", 769 | "glUseProgram", 770 | "glVertexAttribPointer", 771 | "glViewport", 772 | }; 773 | 774 | GL3W_API union GL3WProcs imgl3wProcs; 775 | 776 | static void load_procs(GL3WGetProcAddressProc proc) 777 | { 778 | size_t i; 779 | for (i = 0; i < ARRAY_SIZE(proc_names); i++) 780 | imgl3wProcs.ptr[i] = proc(proc_names[i]); 781 | } 782 | 783 | #ifdef __cplusplus 784 | } 785 | #endif 786 | #endif 787 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.01. 3 | // Grep for [DEAR IMGUI] to find the changes. 4 | // 5 | // stb_rect_pack.h - v1.01 - public domain - rectangle packing 6 | // Sean Barrett 2014 7 | // 8 | // Useful for e.g. packing rectangular textures into an atlas. 9 | // Does not do rotation. 10 | // 11 | // Before #including, 12 | // 13 | // #define STB_RECT_PACK_IMPLEMENTATION 14 | // 15 | // in the file that you want to have the implementation. 16 | // 17 | // Not necessarily the awesomest packing method, but better than 18 | // the totally naive one in stb_truetype (which is primarily what 19 | // this is meant to replace). 20 | // 21 | // Has only had a few tests run, may have issues. 22 | // 23 | // More docs to come. 24 | // 25 | // No memory allocations; uses qsort() and assert() from stdlib. 26 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 27 | // 28 | // This library currently uses the Skyline Bottom-Left algorithm. 29 | // 30 | // Please note: better rectangle packers are welcome! Please 31 | // implement them to the same API, but with a different init 32 | // function. 33 | // 34 | // Credits 35 | // 36 | // Library 37 | // Sean Barrett 38 | // Minor features 39 | // Martins Mozeiko 40 | // github:IntellectualKitty 41 | // 42 | // Bugfixes / warning fixes 43 | // Jeremy Jaussaud 44 | // Fabian Giesen 45 | // 46 | // Version history: 47 | // 48 | // 1.01 (2021-07-11) always use large rect mode, expose STBRP__MAXVAL in public section 49 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 50 | // 0.99 (2019-02-07) warning fixes 51 | // 0.11 (2017-03-03) return packing success/fail result 52 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 53 | // 0.09 (2016-08-27) fix compiler warnings 54 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 55 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 56 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 57 | // 0.05: added STBRP_ASSERT to allow replacing assert 58 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 59 | // 0.01: initial release 60 | // 61 | // LICENSE 62 | // 63 | // See end of file for license information. 64 | 65 | ////////////////////////////////////////////////////////////////////////////// 66 | // 67 | // INCLUDE SECTION 68 | // 69 | 70 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 71 | #define STB_INCLUDE_STB_RECT_PACK_H 72 | 73 | #define STB_RECT_PACK_VERSION 1 74 | 75 | #ifdef STBRP_STATIC 76 | #define STBRP_DEF static 77 | #else 78 | #define STBRP_DEF extern 79 | #endif 80 | 81 | #ifdef __cplusplus 82 | extern "C" { 83 | #endif 84 | 85 | typedef struct stbrp_context stbrp_context; 86 | typedef struct stbrp_node stbrp_node; 87 | typedef struct stbrp_rect stbrp_rect; 88 | 89 | typedef int stbrp_coord; 90 | 91 | #define STBRP__MAXVAL 0x7fffffff 92 | // Mostly for internal use, but this is the maximum supported coordinate value. 93 | 94 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 95 | // Assign packed locations to rectangles. The rectangles are of type 96 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 97 | // are 'num_rects' many of them. 98 | // 99 | // Rectangles which are successfully packed have the 'was_packed' flag 100 | // set to a non-zero value and 'x' and 'y' store the minimum location 101 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 102 | // if you imagine y increasing downwards). Rectangles which do not fit 103 | // have the 'was_packed' flag set to 0. 104 | // 105 | // You should not try to access the 'rects' array from another thread 106 | // while this function is running, as the function temporarily reorders 107 | // the array while it executes. 108 | // 109 | // To pack into another rectangle, you need to call stbrp_init_target 110 | // again. To continue packing into the same rectangle, you can call 111 | // this function again. Calling this multiple times with multiple rect 112 | // arrays will probably produce worse packing results than calling it 113 | // a single time with the full rectangle array, but the option is 114 | // available. 115 | // 116 | // The function returns 1 if all of the rectangles were successfully 117 | // packed and 0 otherwise. 118 | 119 | struct stbrp_rect 120 | { 121 | // reserved for your use: 122 | int id; 123 | 124 | // input: 125 | stbrp_coord w, h; 126 | 127 | // output: 128 | stbrp_coord x, y; 129 | int was_packed; // non-zero if valid packing 130 | 131 | }; // 16 bytes, nominally 132 | 133 | 134 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 135 | // Initialize a rectangle packer to: 136 | // pack a rectangle that is 'width' by 'height' in dimensions 137 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 138 | // 139 | // You must call this function every time you start packing into a new target. 140 | // 141 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 142 | // the following stbrp_pack_rects() call (or calls), but can be freed after 143 | // the call (or calls) finish. 144 | // 145 | // Note: to guarantee best results, either: 146 | // 1. make sure 'num_nodes' >= 'width' 147 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 148 | // 149 | // If you don't do either of the above things, widths will be quantized to multiples 150 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 151 | // 152 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 153 | // may run out of temporary storage and be unable to pack some rectangles. 154 | 155 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 156 | // Optionally call this function after init but before doing any packing to 157 | // change the handling of the out-of-temp-memory scenario, described above. 158 | // If you call init again, this will be reset to the default (false). 159 | 160 | 161 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 162 | // Optionally select which packing heuristic the library should use. Different 163 | // heuristics will produce better/worse results for different data sets. 164 | // If you call init again, this will be reset to the default. 165 | 166 | enum 167 | { 168 | STBRP_HEURISTIC_Skyline_default=0, 169 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 170 | STBRP_HEURISTIC_Skyline_BF_sortHeight 171 | }; 172 | 173 | 174 | ////////////////////////////////////////////////////////////////////////////// 175 | // 176 | // the details of the following structures don't matter to you, but they must 177 | // be visible so you can handle the memory allocations for them 178 | 179 | struct stbrp_node 180 | { 181 | stbrp_coord x,y; 182 | stbrp_node *next; 183 | }; 184 | 185 | struct stbrp_context 186 | { 187 | int width; 188 | int height; 189 | int align; 190 | int init_mode; 191 | int heuristic; 192 | int num_nodes; 193 | stbrp_node *active_head; 194 | stbrp_node *free_head; 195 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 196 | }; 197 | 198 | #ifdef __cplusplus 199 | } 200 | #endif 201 | 202 | #endif 203 | 204 | ////////////////////////////////////////////////////////////////////////////// 205 | // 206 | // IMPLEMENTATION SECTION 207 | // 208 | 209 | #ifdef STB_RECT_PACK_IMPLEMENTATION 210 | #ifndef STBRP_SORT 211 | #include 212 | #define STBRP_SORT qsort 213 | #endif 214 | 215 | #ifndef STBRP_ASSERT 216 | #include 217 | #define STBRP_ASSERT assert 218 | #endif 219 | 220 | #ifdef _MSC_VER 221 | #define STBRP__NOTUSED(v) (void)(v) 222 | #define STBRP__CDECL __cdecl 223 | #else 224 | #define STBRP__NOTUSED(v) (void)sizeof(v) 225 | #define STBRP__CDECL 226 | #endif 227 | 228 | enum 229 | { 230 | STBRP__INIT_skyline = 1 231 | }; 232 | 233 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 234 | { 235 | switch (context->init_mode) { 236 | case STBRP__INIT_skyline: 237 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 238 | context->heuristic = heuristic; 239 | break; 240 | default: 241 | STBRP_ASSERT(0); 242 | } 243 | } 244 | 245 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 246 | { 247 | if (allow_out_of_mem) 248 | // if it's ok to run out of memory, then don't bother aligning them; 249 | // this gives better packing, but may fail due to OOM (even though 250 | // the rectangles easily fit). @TODO a smarter approach would be to only 251 | // quantize once we've hit OOM, then we could get rid of this parameter. 252 | context->align = 1; 253 | else { 254 | // if it's not ok to run out of memory, then quantize the widths 255 | // so that num_nodes is always enough nodes. 256 | // 257 | // I.e. num_nodes * align >= width 258 | // align >= width / num_nodes 259 | // align = ceil(width/num_nodes) 260 | 261 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 262 | } 263 | } 264 | 265 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 266 | { 267 | int i; 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | context->extra[1].y = (1<<30); 287 | context->extra[1].next = NULL; 288 | } 289 | 290 | // find minimum y position if it starts at x1 291 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 292 | { 293 | stbrp_node *node = first; 294 | int x1 = x0 + width; 295 | int min_y, visited_width, waste_area; 296 | 297 | STBRP__NOTUSED(c); 298 | 299 | STBRP_ASSERT(first->x <= x0); 300 | 301 | #if 0 302 | // skip in case we're past the node 303 | while (node->next->x <= x0) 304 | ++node; 305 | #else 306 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 307 | #endif 308 | 309 | STBRP_ASSERT(node->x <= x0); 310 | 311 | min_y = 0; 312 | waste_area = 0; 313 | visited_width = 0; 314 | while (node->x < x1) { 315 | if (node->y > min_y) { 316 | // raise min_y higher. 317 | // we've accounted for all waste up to min_y, 318 | // but we'll now add more waste for everything we've visted 319 | waste_area += visited_width * (node->y - min_y); 320 | min_y = node->y; 321 | // the first time through, visited_width might be reduced 322 | if (node->x < x0) 323 | visited_width += node->next->x - x0; 324 | else 325 | visited_width += node->next->x - node->x; 326 | } else { 327 | // add waste area 328 | int under_width = node->next->x - node->x; 329 | if (under_width + visited_width > width) 330 | under_width = width - visited_width; 331 | waste_area += under_width * (min_y - node->y); 332 | visited_width += under_width; 333 | } 334 | node = node->next; 335 | } 336 | 337 | *pwaste = waste_area; 338 | return min_y; 339 | } 340 | 341 | typedef struct 342 | { 343 | int x,y; 344 | stbrp_node **prev_link; 345 | } stbrp__findresult; 346 | 347 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 348 | { 349 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 350 | stbrp__findresult fr; 351 | stbrp_node **prev, *node, *tail, **best = NULL; 352 | 353 | // align to multiple of c->align 354 | width = (width + c->align - 1); 355 | width -= width % c->align; 356 | STBRP_ASSERT(width % c->align == 0); 357 | 358 | // if it can't possibly fit, bail immediately 359 | if (width > c->width || height > c->height) { 360 | fr.prev_link = NULL; 361 | fr.x = fr.y = 0; 362 | return fr; 363 | } 364 | 365 | node = c->active_head; 366 | prev = &c->active_head; 367 | while (node->x + width <= c->width) { 368 | int y,waste; 369 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 370 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 371 | // bottom left 372 | if (y < best_y) { 373 | best_y = y; 374 | best = prev; 375 | } 376 | } else { 377 | // best-fit 378 | if (y + height <= c->height) { 379 | // can only use it if it first vertically 380 | if (y < best_y || (y == best_y && waste < best_waste)) { 381 | best_y = y; 382 | best_waste = waste; 383 | best = prev; 384 | } 385 | } 386 | } 387 | prev = &node->next; 388 | node = node->next; 389 | } 390 | 391 | best_x = (best == NULL) ? 0 : (*best)->x; 392 | 393 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 394 | // 395 | // e.g, if fitting 396 | // 397 | // ____________________ 398 | // |____________________| 399 | // 400 | // into 401 | // 402 | // | | 403 | // | ____________| 404 | // |____________| 405 | // 406 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 407 | // 408 | // This makes BF take about 2x the time 409 | 410 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 411 | tail = c->active_head; 412 | node = c->active_head; 413 | prev = &c->active_head; 414 | // find first node that's admissible 415 | while (tail->x < width) 416 | tail = tail->next; 417 | while (tail) { 418 | int xpos = tail->x - width; 419 | int y,waste; 420 | STBRP_ASSERT(xpos >= 0); 421 | // find the left position that matches this 422 | while (node->next->x <= xpos) { 423 | prev = &node->next; 424 | node = node->next; 425 | } 426 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 427 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 428 | if (y + height <= c->height) { 429 | if (y <= best_y) { 430 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 431 | best_x = xpos; 432 | //STBRP_ASSERT(y <= best_y); [DEAR IMGUI] 433 | best_y = y; 434 | best_waste = waste; 435 | best = prev; 436 | } 437 | } 438 | } 439 | tail = tail->next; 440 | } 441 | } 442 | 443 | fr.prev_link = best; 444 | fr.x = best_x; 445 | fr.y = best_y; 446 | return fr; 447 | } 448 | 449 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 450 | { 451 | // find best position according to heuristic 452 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 453 | stbrp_node *node, *cur; 454 | 455 | // bail if: 456 | // 1. it failed 457 | // 2. the best node doesn't fit (we don't always check this) 458 | // 3. we're out of memory 459 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 460 | res.prev_link = NULL; 461 | return res; 462 | } 463 | 464 | // on success, create new node 465 | node = context->free_head; 466 | node->x = (stbrp_coord) res.x; 467 | node->y = (stbrp_coord) (res.y + height); 468 | 469 | context->free_head = node->next; 470 | 471 | // insert the new node into the right starting point, and 472 | // let 'cur' point to the remaining nodes needing to be 473 | // stiched back in 474 | 475 | cur = *res.prev_link; 476 | if (cur->x < res.x) { 477 | // preserve the existing one, so start testing with the next one 478 | stbrp_node *next = cur->next; 479 | cur->next = node; 480 | cur = next; 481 | } else { 482 | *res.prev_link = node; 483 | } 484 | 485 | // from here, traverse cur and free the nodes, until we get to one 486 | // that shouldn't be freed 487 | while (cur->next && cur->next->x <= res.x + width) { 488 | stbrp_node *next = cur->next; 489 | // move the current node to the free list 490 | cur->next = context->free_head; 491 | context->free_head = cur; 492 | cur = next; 493 | } 494 | 495 | // stitch the list back in 496 | node->next = cur; 497 | 498 | if (cur->x < res.x + width) 499 | cur->x = (stbrp_coord) (res.x + width); 500 | 501 | #ifdef _DEBUG 502 | cur = context->active_head; 503 | while (cur->x < context->width) { 504 | STBRP_ASSERT(cur->x < cur->next->x); 505 | cur = cur->next; 506 | } 507 | STBRP_ASSERT(cur->next == NULL); 508 | 509 | { 510 | int count=0; 511 | cur = context->active_head; 512 | while (cur) { 513 | cur = cur->next; 514 | ++count; 515 | } 516 | cur = context->free_head; 517 | while (cur) { 518 | cur = cur->next; 519 | ++count; 520 | } 521 | STBRP_ASSERT(count == context->num_nodes+2); 522 | } 523 | #endif 524 | 525 | return res; 526 | } 527 | 528 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 529 | { 530 | const stbrp_rect *p = (const stbrp_rect *) a; 531 | const stbrp_rect *q = (const stbrp_rect *) b; 532 | if (p->h > q->h) 533 | return -1; 534 | if (p->h < q->h) 535 | return 1; 536 | return (p->w > q->w) ? -1 : (p->w < q->w); 537 | } 538 | 539 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 540 | { 541 | const stbrp_rect *p = (const stbrp_rect *) a; 542 | const stbrp_rect *q = (const stbrp_rect *) b; 543 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 544 | } 545 | 546 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 547 | { 548 | int i, all_rects_packed = 1; 549 | 550 | // we use the 'was_packed' field internally to allow sorting/unsorting 551 | for (i=0; i < num_rects; ++i) { 552 | rects[i].was_packed = i; 553 | } 554 | 555 | // sort according to heuristic 556 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 557 | 558 | for (i=0; i < num_rects; ++i) { 559 | if (rects[i].w == 0 || rects[i].h == 0) { 560 | rects[i].x = rects[i].y = 0; // empty rect needs no space 561 | } else { 562 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 563 | if (fr.prev_link) { 564 | rects[i].x = (stbrp_coord) fr.x; 565 | rects[i].y = (stbrp_coord) fr.y; 566 | } else { 567 | rects[i].x = rects[i].y = STBRP__MAXVAL; 568 | } 569 | } 570 | } 571 | 572 | // unsort 573 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 574 | 575 | // set was_packed flags and all_rects_packed status 576 | for (i=0; i < num_rects; ++i) { 577 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 578 | if (!rects[i].was_packed) 579 | all_rects_packed = 0; 580 | } 581 | 582 | // return the all_rects_packed status 583 | return all_rects_packed; 584 | } 585 | #endif 586 | 587 | /* 588 | ------------------------------------------------------------------------------ 589 | This software is available under 2 licenses -- choose whichever you prefer. 590 | ------------------------------------------------------------------------------ 591 | ALTERNATIVE A - MIT License 592 | Copyright (c) 2017 Sean Barrett 593 | Permission is hereby granted, free of charge, to any person obtaining a copy of 594 | this software and associated documentation files (the "Software"), to deal in 595 | the Software without restriction, including without limitation the rights to 596 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 597 | of the Software, and to permit persons to whom the Software is furnished to do 598 | so, subject to the following conditions: 599 | The above copyright notice and this permission notice shall be included in all 600 | copies or substantial portions of the Software. 601 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 602 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 603 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 604 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 605 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 606 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 607 | SOFTWARE. 608 | ------------------------------------------------------------------------------ 609 | ALTERNATIVE B - Public Domain (www.unlicense.org) 610 | This is free and unencumbered software released into the public domain. 611 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 612 | software, either in source code form or as a compiled binary, for any purpose, 613 | commercial or non-commercial, and by any means. 614 | In jurisdictions that recognize copyright laws, the author or authors of this 615 | software dedicate any and all copyright interest in the software to the public 616 | domain. We make this dedication for the benefit of the public at large and to 617 | the detriment of our heirs and successors. We intend this dedication to be an 618 | overt act of relinquishment in perpetuity of all present and future rights to 619 | this software under copyright law. 620 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 621 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 622 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 623 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 624 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 625 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 626 | ------------------------------------------------------------------------------ 627 | */ 628 | -------------------------------------------------------------------------------- /app/src/main/cpp/include/misc/Logger.h: -------------------------------------------------------------------------------- 1 | // 2 | // Logger.h 3 | 4 | #ifndef Logger_h 5 | #define Logger_h 6 | 7 | #include 8 | #include 9 | 10 | enum LogType { 11 | oDEBUG = 3, 12 | oERROR = 6, 13 | oINFO = 4, 14 | oWARN = 5 15 | }; 16 | 17 | #define TAG "Cipher" 18 | 19 | #define LOGD(...) ((void)__android_log_print(oDEBUG, TAG, __VA_ARGS__)) 20 | #define LOGE(...) ((void)__android_log_print(oERROR, TAG, __VA_ARGS__)) 21 | #define LOGI(...) ((void)__android_log_print(oINFO, TAG, __VA_ARGS__)) 22 | #define LOGW(...) ((void)__android_log_print(oWARN, TAG, __VA_ARGS__)) 23 | 24 | #endif /* Logger_h */ -------------------------------------------------------------------------------- /app/src/main/cpp/include/nlohmann/json_fwd.hpp: -------------------------------------------------------------------------------- 1 | // __ _____ _____ _____ 2 | // __| | __| | | | JSON for Modern C++ 3 | // | | |__ | | | | | | version 3.11.2 4 | // |_____|_____|_____|_|___| https://github.com/nlohmann/json 5 | // 6 | // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann 7 | // SPDX-License-Identifier: MIT 8 | 9 | #ifndef INCLUDE_NLOHMANN_JSON_FWD_HPP_ 10 | #define INCLUDE_NLOHMANN_JSON_FWD_HPP_ 11 | 12 | #include // int64_t, uint64_t 13 | #include // map 14 | #include // allocator 15 | #include // string 16 | #include // vector 17 | 18 | // #include 19 | // __ _____ _____ _____ 20 | // __| | __| | | | JSON for Modern C++ 21 | // | | |__ | | | | | | version 3.11.2 22 | // |_____|_____|_____|_|___| https://github.com/nlohmann/json 23 | // 24 | // SPDX-FileCopyrightText: 2013-2022 Niels Lohmann 25 | // SPDX-License-Identifier: MIT 26 | 27 | 28 | 29 | // This file contains all macro definitions affecting or depending on the ABI 30 | 31 | #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK 32 | #if defined(NLOHMANN_JSON_VERSION_MAJOR) && defined(NLOHMANN_JSON_VERSION_MINOR) && defined(NLOHMANN_JSON_VERSION_PATCH) 33 | #if NLOHMANN_JSON_VERSION_MAJOR != 3 || NLOHMANN_JSON_VERSION_MINOR != 11 || NLOHMANN_JSON_VERSION_PATCH != 2 34 | #warning "Already included a different version of the library!" 35 | #endif 36 | #endif 37 | #endif 38 | 39 | #define NLOHMANN_JSON_VERSION_MAJOR 3 // NOLINT(modernize-macro-to-enum) 40 | #define NLOHMANN_JSON_VERSION_MINOR 11 // NOLINT(modernize-macro-to-enum) 41 | #define NLOHMANN_JSON_VERSION_PATCH 2 // NOLINT(modernize-macro-to-enum) 42 | 43 | #ifndef JSON_DIAGNOSTICS 44 | #define JSON_DIAGNOSTICS 0 45 | #endif 46 | 47 | #ifndef JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 48 | #define JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 0 49 | #endif 50 | 51 | #if JSON_DIAGNOSTICS 52 | #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS _diag 53 | #else 54 | #define NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS 55 | #endif 56 | 57 | #if JSON_USE_LEGACY_DISCARDED_VALUE_COMPARISON 58 | #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON _ldvcmp 59 | #else 60 | #define NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON 61 | #endif 62 | 63 | #ifndef NLOHMANN_JSON_NAMESPACE_NO_VERSION 64 | #define NLOHMANN_JSON_NAMESPACE_NO_VERSION 0 65 | #endif 66 | 67 | // Construct the namespace ABI tags component 68 | #define NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) json_abi ## a ## b 69 | #define NLOHMANN_JSON_ABI_TAGS_CONCAT(a, b) \ 70 | NLOHMANN_JSON_ABI_TAGS_CONCAT_EX(a, b) 71 | 72 | #define NLOHMANN_JSON_ABI_TAGS \ 73 | NLOHMANN_JSON_ABI_TAGS_CONCAT( \ 74 | NLOHMANN_JSON_ABI_TAG_DIAGNOSTICS, \ 75 | NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON) 76 | 77 | // Construct the namespace version component 78 | #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) \ 79 | _v ## major ## _ ## minor ## _ ## patch 80 | #define NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(major, minor, patch) \ 81 | NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT_EX(major, minor, patch) 82 | 83 | #if NLOHMANN_JSON_NAMESPACE_NO_VERSION 84 | #define NLOHMANN_JSON_NAMESPACE_VERSION 85 | #else 86 | #define NLOHMANN_JSON_NAMESPACE_VERSION \ 87 | NLOHMANN_JSON_NAMESPACE_VERSION_CONCAT(NLOHMANN_JSON_VERSION_MAJOR, \ 88 | NLOHMANN_JSON_VERSION_MINOR, \ 89 | NLOHMANN_JSON_VERSION_PATCH) 90 | #endif 91 | 92 | // Combine namespace components 93 | #define NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) a ## b 94 | #define NLOHMANN_JSON_NAMESPACE_CONCAT(a, b) \ 95 | NLOHMANN_JSON_NAMESPACE_CONCAT_EX(a, b) 96 | 97 | #ifndef NLOHMANN_JSON_NAMESPACE 98 | #define NLOHMANN_JSON_NAMESPACE \ 99 | nlohmann::NLOHMANN_JSON_NAMESPACE_CONCAT( \ 100 | NLOHMANN_JSON_ABI_TAGS, \ 101 | NLOHMANN_JSON_NAMESPACE_VERSION) 102 | #endif 103 | 104 | #ifndef NLOHMANN_JSON_NAMESPACE_BEGIN 105 | #define NLOHMANN_JSON_NAMESPACE_BEGIN \ 106 | namespace nlohmann \ 107 | { \ 108 | inline namespace NLOHMANN_JSON_NAMESPACE_CONCAT( \ 109 | NLOHMANN_JSON_ABI_TAGS, \ 110 | NLOHMANN_JSON_NAMESPACE_VERSION) \ 111 | { 112 | #endif 113 | 114 | #ifndef NLOHMANN_JSON_NAMESPACE_END 115 | #define NLOHMANN_JSON_NAMESPACE_END \ 116 | } /* namespace (inline namespace) NOLINT(readability/namespace) */ \ 117 | } // namespace nlohmann 118 | #endif 119 | 120 | 121 | /*! 122 | @brief namespace for Niels Lohmann 123 | @see https://github.com/nlohmann 124 | @since version 1.0.0 125 | */ 126 | NLOHMANN_JSON_NAMESPACE_BEGIN 127 | 128 | /*! 129 | @brief default JSONSerializer template argument 130 | 131 | This serializer ignores the template arguments and uses ADL 132 | ([argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl)) 133 | for serialization. 134 | */ 135 | template 136 | struct adl_serializer; 137 | 138 | /// a class to store JSON values 139 | /// @sa https://json.nlohmann.me/api/basic_json/ 140 | template class ObjectType = 141 | std::map, 142 | template class ArrayType = std::vector, 143 | class StringType = std::string, class BooleanType = bool, 144 | class NumberIntegerType = std::int64_t, 145 | class NumberUnsignedType = std::uint64_t, 146 | class NumberFloatType = double, 147 | template class AllocatorType = std::allocator, 148 | template class JSONSerializer = 149 | adl_serializer, 150 | class BinaryType = std::vector, // cppcheck-suppress syntaxError 151 | class CustomBaseClass = void> 152 | class basic_json; 153 | 154 | /// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document 155 | /// @sa https://json.nlohmann.me/api/json_pointer/ 156 | template 157 | class json_pointer; 158 | 159 | /*! 160 | @brief default specialization 161 | @sa https://json.nlohmann.me/api/json/ 162 | */ 163 | using json = basic_json<>; 164 | 165 | /// @brief a minimal map-like container that preserves insertion order 166 | /// @sa https://json.nlohmann.me/api/ordered_map/ 167 | template 168 | struct ordered_map; 169 | 170 | /// @brief specialization that maintains the insertion order of object keys 171 | /// @sa https://json.nlohmann.me/api/ordered_json/ 172 | using ordered_json = basic_json; 173 | 174 | NLOHMANN_JSON_NAMESPACE_END 175 | 176 | #endif // INCLUDE_NLOHMANN_JSON_FWD_HPP_ 177 | -------------------------------------------------------------------------------- /app/src/main/cpp/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lukas on 22/07/2022. 3 | // 4 | 5 | #include "main.h" 6 | #include "include/Cipher/Cipher.h" 7 | #include "include/imgui/imgui.h" 8 | #include "include/misc/Logger.h" 9 | 10 | 11 | 12 | // UI related functions 13 | void Menu(bool *_pOpen) { // _pOpen is passed by canvas. Used to close and open the mod locally 14 | ImGui::Checkbox("Close me!", (bool *)(_pOpen)); 15 | } 16 | 17 | // Called in a later stage of game initialisation 18 | void InitLate() { 19 | 20 | } 21 | 22 | // Called at the start of the game 23 | void Init() { 24 | 25 | } -------------------------------------------------------------------------------- /app/src/main/cpp/main.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Lukas on 01/08/2022. 3 | // 4 | 5 | #ifndef USERLIB_MAIN_H 6 | #define USERLIB_MAIN_H 7 | 8 | typedef void (*func)(bool*); 9 | void Menu(bool *_pOpen); 10 | void Init(); 11 | extern "C" void __attribute__((visibility("default"))) InitLate(); 12 | 13 | extern "C" func __attribute__((visibility ("default"))) Start() { 14 | Init(); 15 | return &Menu; 16 | } 17 | 18 | 19 | #endif //USERLIB_MAIN_H 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/cipher/userlib/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.cipher.userlib; 2 | 3 | import androidx.appcompat.app.AppCompatActivity; 4 | 5 | import android.os.Bundle; 6 | import android.widget.TextView; 7 | 8 | import com.cipher.userlib.databinding.ActivityMainBinding; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | // Used to load the 'userlib' library on application startup. 13 | static { 14 | System.loadLibrary("userlib"); 15 | } 16 | 17 | private ActivityMainBinding binding; 18 | 19 | @Override 20 | protected void onCreate(Bundle savedInstanceState) { 21 | super.onCreate(savedInstanceState); 22 | 23 | binding = ActivityMainBinding.inflate(getLayoutInflater()); 24 | setContentView(binding.getRoot()); 25 | 26 | // Example of a call to a native method 27 | TextView tv = binding.sampleText; 28 | tv.setText("test"); 29 | } 30 | 31 | /** 32 | * A native method that is implemented by the 'userlib' native library, 33 | * which is packaged with this application. 34 | */ 35 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | userlib 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /app/src/test/java/com/cipher/userlib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.cipher.userlib; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | plugins { 3 | id 'com.android.application' version '8.3.1' apply false 4 | id 'com.android.library' version '8.3.1' apply false 5 | } 6 | 7 | tasks.register('clean', Delete) { 8 | delete rootProject.buildDir 9 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukas0x1/Userlib-SML/479723f64be3884ba30226929d3446686acb5fe9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Jul 21 17:05:35 CEST 2022 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-rc-1-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | } 7 | } 8 | dependencyResolutionManagement { 9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 10 | repositories { 11 | google() 12 | mavenCentral() 13 | } 14 | } 15 | rootProject.name = "userlib" 16 | include ':app' 17 | --------------------------------------------------------------------------------