├── .clang-format ├── .dockerignore ├── .github └── main.workflow ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── api ├── .clang-format ├── .gitignore ├── .gitrepo ├── CMakeLists.txt ├── compile_commands.json ├── include │ └── stone-api │ │ ├── Blacklist.h │ │ ├── Chat.h │ │ ├── Command.h │ │ ├── Core.h │ │ ├── Script.h │ │ └── apid.hpp └── src │ ├── cli.cpp │ ├── log.cpp │ └── ping.cpp ├── cmake ├── GetGitRevisionDescription.cmake ├── GetGitRevisionDescription.cmake.in └── cotire.cmake ├── deps ├── arg-parser │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── LICENSE │ └── include │ │ ├── argparser.h │ │ └── argparser │ │ ├── arg.h │ │ ├── arg_list.h │ │ └── arg_parser.h ├── base64 │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── LICENSE │ ├── include │ │ └── base64.h │ └── src │ │ └── base64.cpp ├── file-util │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── LICENSE │ ├── include │ │ ├── EnvPathUtil.h │ │ └── FileUtil.h │ └── src │ │ ├── EnvPathUtil.cpp │ │ ├── EnvPathUtil_MacOS.mm │ │ └── FileUtil.cpp ├── libhybris │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── LICENSE │ ├── include │ │ └── hybris │ │ │ ├── binding.h │ │ │ ├── dlfcn.h │ │ │ ├── floating_point_abi.h │ │ │ ├── hook.h │ │ │ ├── jb │ │ │ └── linker.h │ │ │ └── properties.h │ └── src │ │ ├── bionic │ │ ├── arch-x86 │ │ │ └── setjmp.S │ │ ├── bionic_asm.h │ │ ├── bionic_asm_x86.h │ │ └── setjmp_cookie.c │ │ ├── cache.c │ │ ├── ctype.c │ │ ├── ctype.h │ │ ├── dlfcn.c │ │ ├── hooks.c │ │ ├── hooks_darwin_pthread_once.cpp │ │ ├── hooks_darwin_pthread_once.h │ │ ├── hooks_dirent.c │ │ ├── hooks_io.c │ │ ├── hooks_list.c │ │ ├── hooks_list.h │ │ ├── hooks_net.c │ │ ├── hooks_net.h │ │ ├── hooks_net_darwin.c │ │ ├── hooks_pthread.c │ │ ├── hooks_shm.c │ │ ├── hooks_shm.h │ │ ├── jb │ │ ├── arch │ │ │ ├── arm │ │ │ │ └── begin.S │ │ │ └── x86 │ │ │ │ └── begin.S │ │ ├── debugger.c │ │ ├── dlfcn.c │ │ ├── linker.c │ │ ├── linker_debug.h │ │ ├── linker_environ.c │ │ ├── linker_environ.h │ │ ├── linker_format.c │ │ ├── linker_format.h │ │ └── rt.c │ │ ├── logging.c │ │ ├── logging.h │ │ ├── properties.c │ │ ├── properties_p.h │ │ ├── strlcpy.c │ │ └── sysconf.c ├── mcpelauncher-common │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── include │ │ └── mcpelauncher │ │ │ └── path_helper.h │ └── src │ │ ├── openssl_multithread.cpp │ │ ├── openssl_multithread.h │ │ ├── path_helper.cpp │ │ └── path_helper_osx.mm ├── mcpelauncher-core │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── include │ │ └── mcpelauncher │ │ │ ├── app_platform.h │ │ │ ├── crash_handler.h │ │ │ ├── hook.h │ │ │ ├── hybris_utils.h │ │ │ ├── minecraft_utils.h │ │ │ ├── minecraft_version.h │ │ │ ├── mod_loader.h │ │ │ └── patch_utils.h │ └── src │ │ ├── app_platform.cpp │ │ ├── crash_handler.cpp │ │ ├── hook.cpp │ │ ├── hybris_utils.cpp │ │ ├── minecraft_utils.cpp │ │ ├── mod_loader.cpp │ │ └── patch_utils.cpp ├── mcpelauncher-just │ ├── .gitrepo │ ├── CMakeLists.txt │ └── src │ │ └── main.cpp ├── minecraft-imported-symbols │ ├── .gitrepo │ ├── CMakeLists.txt │ └── include │ │ └── minecraft │ │ └── imported │ │ ├── android_symbols.h │ │ ├── egl_symbols.h │ │ ├── fmod_symbols.h │ │ └── libm_symbols.h ├── minecraft-symbols │ ├── .clang-format │ ├── .gitignore │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── src │ │ └── minecraft │ │ │ ├── Actor.h │ │ │ ├── Api.h │ │ │ ├── App.h │ │ │ ├── AppPlatform.h │ │ │ ├── AppResourceLoader.h │ │ │ ├── AutoComplete.h │ │ │ ├── AutomationClient.h │ │ │ ├── AutomationPlayerCommandOrigin.h │ │ │ ├── Blacklist.h │ │ │ ├── Block.h │ │ │ ├── BlockSource.h │ │ │ ├── Command.h │ │ │ ├── CommandMessage.h │ │ │ ├── CommandOrigin.h │ │ │ ├── CommandOutput.h │ │ │ ├── CommandOutputSender.h │ │ │ ├── CommandRegistry.h │ │ │ ├── CommandSelector.h │ │ │ ├── CommandUtils.h │ │ │ ├── Common.h │ │ │ ├── ContentIdentity.h │ │ │ ├── Crypto.h │ │ │ ├── EventResult.h │ │ │ ├── ExtendedCertificate.h │ │ │ ├── ExternalFileLevelStorageSource.h │ │ │ ├── FilePathManager.h │ │ │ ├── FilePickerSettings.h │ │ │ ├── GameControllerManager.h │ │ │ ├── GameMode.h │ │ │ ├── I18n.h │ │ │ ├── IMinecraftApp.h │ │ │ ├── ImagePickingCallback.h │ │ │ ├── ItemInstance.h │ │ │ ├── Keyboard.h │ │ │ ├── Level.h │ │ │ ├── LevelSettings.h │ │ │ ├── MessagingCommand.h │ │ │ ├── Minecraft.h │ │ │ ├── MinecraftCommands.h │ │ │ ├── MinecraftEventing.h │ │ │ ├── MinecraftGame.h │ │ │ ├── ModalForm.h │ │ │ ├── Mouse.h │ │ │ ├── MultiplayerService.h │ │ │ ├── Multitouch.h │ │ │ ├── NetworkIdentifier.h │ │ │ ├── Options.h │ │ │ ├── Packet.h │ │ │ ├── PermissionsFile.h │ │ │ ├── Player.h │ │ │ ├── Resource.h │ │ │ ├── ResourcePack.h │ │ │ ├── ResourcePackStack.h │ │ │ ├── SaveTransactionManager.h │ │ │ ├── Scheduler.h │ │ │ ├── ScriptApi.h │ │ │ ├── ServerCommandOrigin.h │ │ │ ├── ServerInstance.h │ │ │ ├── ServerNetworkHandler.h │ │ │ ├── SharedConstants.h │ │ │ ├── Tag.h │ │ │ ├── TextPacket.h │ │ │ ├── TransferPacket.h │ │ │ ├── UUID.h │ │ │ ├── UserManager.h │ │ │ ├── V8.h │ │ │ ├── V8Internals.h │ │ │ ├── Whitelist.h │ │ │ ├── fix.h │ │ │ ├── gl.h │ │ │ ├── json.h │ │ │ ├── legacy │ │ │ ├── App.h │ │ │ ├── AppPlatform.h │ │ │ ├── MinecraftGame.h │ │ │ └── Xbox.h │ │ │ ├── std │ │ │ ├── function.h │ │ │ ├── shared_ptr.h │ │ │ ├── string.h │ │ │ ├── string_darwin.cpp │ │ │ ├── string_darwin.h │ │ │ ├── string_linux.cpp │ │ │ └── string_linux.h │ │ │ ├── symbols.cpp │ │ │ ├── symbols.h │ │ │ └── types.h │ └── tools │ │ ├── cppheaderparser │ │ ├── CppHeaderParser.py │ │ └── __init__.py │ │ └── process_headers.py └── properties-parser │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── LICENSE │ └── include │ └── properties │ ├── property.h │ └── property_list.h ├── docker-compose.yml ├── exts └── sqlite3 │ ├── .gitignore │ ├── .gitrepo │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── appveyor.yml │ └── src │ ├── shell.c │ ├── sqlite3.c │ ├── sqlite3.h │ └── sqlite3ext.h ├── interface ├── CMakeLists.txt └── include │ └── interface │ ├── base_interface.h │ ├── blacklist.h │ ├── chat.h │ ├── event_emitter.h │ ├── locator.hpp │ ├── modal_form.h │ ├── player_list.h │ ├── policy.h │ └── tick.h ├── lib32.txt ├── logger ├── CMakeLists.txt ├── include │ └── log.h └── src │ └── log.cpp ├── stone ├── CMakeLists.txt └── src │ ├── ExtAPI │ ├── actorInfo.cpp │ ├── broadcastExternalEvent.cpp │ ├── broadcastMessage.cpp │ ├── changeDimension.cpp │ ├── checks.cpp │ ├── common.cpp │ ├── common.h │ ├── invokeCommand.cpp │ ├── invokeConsoleCommand.cpp │ ├── invokePrivilegedCommand.cpp │ ├── log.cpp │ ├── muteChat.cpp │ ├── openModalForm.cpp │ ├── registerCommand.cpp │ ├── registerSoftEnum.cpp │ ├── serverInfo.cpp │ ├── stop.cpp │ ├── transferPlayer.cpp │ ├── updateSoftEnum.cpp │ └── worldInfo.cpp │ ├── GlobalAPI │ ├── SQLite3.cpp │ ├── checkApiLevel.cpp │ ├── common.cpp │ └── common.h │ ├── blacklist_mgr.hpp │ ├── custom_command.h │ ├── custom_command.hpp │ ├── dependency.cpp │ ├── dumper.cpp │ ├── dumper.h │ ├── main.cpp │ ├── operators.h │ ├── patched.cpp │ ├── patched.h │ ├── patched │ ├── Ability.cpp │ ├── Bind.cpp │ ├── Common.cpp │ ├── Education.cpp │ ├── Encryption.cpp │ ├── Flags.h │ ├── FlatWorldGeneratorOptions.cpp │ ├── HardcodedOffsets.h │ ├── Level.cpp │ ├── ModalForm.cpp │ ├── PlayerCommandOrigin.cpp │ ├── ScriptEngine.cpp │ ├── ScriptEventCoordinator.cpp │ ├── ScriptInterface.h │ ├── ServerCommandOrigin.cpp │ ├── ServerLevelEventCoordinator.cpp │ ├── ServerMetrics.cpp │ ├── ServerNetworkHandler.cpp │ ├── SpawnParticle.cpp │ ├── TextPacket.cpp │ └── v8.cpp │ ├── server_minecraft_app.h │ ├── server_properties.h │ ├── stub_key_provider.h │ ├── v8_platform.cpp │ ├── v8_platform.h │ ├── v8_utils.hpp │ └── whitelist_mgr.hpp ├── utils ├── CMakeLists.txt ├── include │ └── stone │ │ ├── hook_helper.h │ │ ├── magic_func.h │ │ ├── operator.h │ │ ├── server_hook.h │ │ ├── symbol.h │ │ └── utils.h └── src │ ├── server_hook.cpp │ └── utils.cpp └── version ├── include └── stone │ └── version.h └── src └── version.c /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | --- 4 | Language: Cpp 5 | # AlignAfterOpenBracket: AlwaysBreak 6 | ColumnLimit: 150 7 | AlignConsecutiveAssignments: true 8 | AlignOperands: true 9 | AlignTrailingComments: true 10 | AllowAllParametersOfDeclarationOnNextLine: false 11 | AllowShortBlocksOnASingleLine: true 12 | AllowShortCaseLabelsOnASingleLine: true 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: true 15 | AllowShortLoopsOnASingleLine: true 16 | AlwaysBreakBeforeMultilineStrings: true 17 | BinPackArguments: true 18 | BinPackParameters: true 19 | BreakBeforeTernaryOperators: false 20 | BreakConstructorInitializers: BeforeComma 21 | Cpp11BracedListStyle: false 22 | FixNamespaceComments: true 23 | IndentCaseLabels: false 24 | IndentWrappedFunctionNames: false -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | build 2 | .vscode 3 | .ccls-cache 4 | compile_commands.json -------------------------------------------------------------------------------- /.github/main.workflow: -------------------------------------------------------------------------------- 1 | workflow "Build" { 2 | on = "push" 3 | resolves = ["appleboy/telegram-action@master"] 4 | } 5 | 6 | action "login" { 7 | uses = "actions/docker/login@c08a5fc9e0286844156fefff2c141072048141f6" 8 | secrets = ["DOCKER_PASSWORD", "DOCKER_USERNAME"] 9 | } 10 | 11 | action "build" { 12 | uses = "codehz/StoneActions/build@master" 13 | } 14 | 15 | action "package" { 16 | uses = "codehz/StoneActions/package@master" 17 | needs = ["build"] 18 | } 19 | 20 | action "push" { 21 | uses = "actions/docker/cli@c08a5fc9e0286844156fefff2c141072048141f6" 22 | needs = ["package", "login"] 23 | args = "push codehz/stoneserver:latest" 24 | } 25 | 26 | action "appleboy/telegram-action@master" { 27 | uses = "appleboy/telegram-action@master" 28 | needs = ["push"] 29 | secrets = [ 30 | "TELEGRAM_TOKEN", 31 | "TELEGRAM_TO", 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .vscode 3 | .ccls-cache 4 | compile_commands.json -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "exts/wsrpc"] 2 | path = exts/wsrpc 3 | url = http://github.com/CodeHz/wsrpc 4 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.3) 2 | 3 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) 4 | set(CMAKE_ROOT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 5 | set(CMAKE_THREAD_PREFER_PTHREAD TRUE) 6 | set(CMAKE_SKIP_RPATH TRUE) 7 | 8 | option(USE_COTIRE ON) 9 | 10 | include(cotire) 11 | 12 | include(GetGitRevisionDescription) 13 | git_describe(VERSION --always --tags --dirty=-modified --long --abbrev=40) 14 | 15 | add_library(build_version version/src/version.c) 16 | target_include_directories(build_version PUBLIC version/include) 17 | target_compile_definitions(build_version PRIVATE BUILD_VERSION=\"${VERSION}\") 18 | 19 | set(CMAKE_CXX_FLAGS_RELEASE "-Os -s -fvisibility=hidden") 20 | 21 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 22 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -Wno-odr -g -rdynamic") 23 | 24 | if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4) 25 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") 26 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") 27 | endif() 28 | 29 | string(TIMESTAMP BUILD_TIMESTAMP "%Y%m%d-%H%M%S" UTC) 30 | 31 | add_subdirectory(utils EXCLUDE_FROM_ALL) 32 | add_subdirectory(logger EXCLUDE_FROM_ALL) 33 | add_subdirectory(interface) 34 | add_subdirectory(api) 35 | 36 | file(GLOB DEPS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/deps/*) 37 | file(GLOB EXTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/exts/*) 38 | 39 | foreach(dep ${DEPS}) 40 | message("Found DEP: " ${dep}) 41 | add_subdirectory(${dep} EXCLUDE_FROM_ALL) 42 | endforeach() 43 | foreach(ext ${EXTS}) 44 | message("Found EXT: " ${ext}) 45 | add_subdirectory(${ext} EXCLUDE_FROM_ALL) 46 | endforeach() 47 | 48 | add_subdirectory(stone) -------------------------------------------------------------------------------- /api/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | --- 4 | Language: Cpp 5 | # AlignAfterOpenBracket: AlwaysBreak 6 | ColumnLimit: 150 7 | AlignConsecutiveAssignments: true 8 | AlignOperands: true 9 | AlignTrailingComments: true 10 | AllowAllParametersOfDeclarationOnNextLine: false 11 | AllowShortBlocksOnASingleLine: true 12 | AllowShortCaseLabelsOnASingleLine: true 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: true 15 | AllowShortLoopsOnASingleLine: true 16 | AlwaysBreakBeforeMultilineStrings: true 17 | BinPackArguments: true 18 | BinPackParameters: true 19 | BreakBeforeTernaryOperators: false 20 | BreakConstructorInitializers: BeforeComma 21 | Cpp11BracedListStyle: false 22 | FixNamespaceComments: true 23 | IndentCaseLabels: false 24 | IndentWrappedFunctionNames: false -------------------------------------------------------------------------------- /api/.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | .ccls-cache 3 | build -------------------------------------------------------------------------------- /api/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = git@github.com:codehz/StoneAPI.git 8 | branch = master 9 | commit = 0ebbfad65fcac5b83f9d27bf5a937b9f34e48261 10 | method = rebase 11 | cmdver = 0.4.0 12 | parent = f4ed016c6a3a7fc1977ad465aa4971d12c59184e 13 | -------------------------------------------------------------------------------- /api/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.0) 2 | 3 | project(stone-api) 4 | 5 | add_library(stone-api INTERFACE) 6 | file(GLOB src "include/stone-api/*") 7 | target_sources(stone-api INTERFACE ${src}) 8 | target_link_libraries(stone-api INTERFACE rpcws) 9 | target_include_directories(stone-api INTERFACE "include") 10 | 11 | 12 | if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 13 | set(STONE_API_STANDALONE ON) 14 | option(STONE_API_BUILD_BINARY ON) 15 | else() 16 | option(STONE_API_BUILD_BINARY OFF) 17 | endif() 18 | 19 | if (STONE_API_STANDALONE) 20 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 21 | include(ExternalProject) 22 | 23 | ExternalProject_Add(rpc-websocket 24 | PREFIX rpc-websocket 25 | GIT_REPOSITORY https://github.com/CodeHz/wsrpc 26 | UPDATE_COMMAND "" 27 | PATCH_COMMAND "" 28 | CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=" 29 | ) 30 | 31 | ExternalProject_Get_property(rpc-websocket INSTALL_DIR) 32 | 33 | include_directories(${INSTALL_DIR}/include) 34 | link_directories(${INSTALL_DIR}/lib) 35 | endif() 36 | if (STONE_API_BUILD_BINARY) 37 | add_executable(stone-ping src/ping.cpp) 38 | target_link_libraries(stone-ping stone-api rpcws rpc ws minsec) 39 | set_property(TARGET stone-ping PROPERTY CXX_STANDARD 17) 40 | 41 | add_executable(stone-cli src/cli.cpp) 42 | target_link_libraries(stone-cli stone-api rpcws rpc ws minsec pthread readline) 43 | set_property(TARGET stone-cli PROPERTY CXX_STANDARD 20) 44 | 45 | add_executable(stone-log src/log.cpp) 46 | target_link_libraries(stone-log stone-api rpcws rpc ws minsec) 47 | set_property(TARGET stone-log PROPERTY CXX_STANDARD 20) 48 | 49 | if (STONE_API_STANDALONE) 50 | add_dependencies(stone-ping rpc-websocket) 51 | add_dependencies(stone-cli rpc-websocket) 52 | add_dependencies(stone-log rpc-websocket) 53 | endif() 54 | 55 | install(TARGETS stone-ping RUNTIME DESTINATION bin) 56 | install(TARGETS stone-cli RUNTIME DESTINATION bin) 57 | install(TARGETS stone-log RUNTIME DESTINATION bin) 58 | endif() -------------------------------------------------------------------------------- /api/compile_commands.json: -------------------------------------------------------------------------------- 1 | build/compile_commands.json -------------------------------------------------------------------------------- /api/include/stone-api/Blacklist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "apid.hpp" 4 | #include 5 | 6 | namespace api { 7 | 8 | template struct BlacklistOP { std::string type, content; }; 9 | 10 | template <> struct BlacklistOP { std::string type, content, reason; }; 11 | 12 | template inline void to_json(rpc::json &j, const BlacklistOP &i) { 13 | j[i.type] = i.content; 14 | if constexpr (reason) j["reason"] = i.reason; 15 | } 16 | 17 | template inline void from_json(const rpc::json &j, BlacklistOP &i) { 18 | try { 19 | if (j.contains("name")) { 20 | i.type = "name"; 21 | i.content = j["name"]; 22 | } else if (j.contains("uuid")) { 23 | i.type = "uuid"; 24 | i.content = j["uuid"]; 25 | } else if (j.contains("xuid")) { 26 | i.type = "xuid"; 27 | i.content = j["xuid"]; 28 | } else { 29 | i.type = "error"; 30 | } 31 | } catch (...) { i.type = "error"; } 32 | 33 | if constexpr (reason) j.at("reason").get_to(i.reason); 34 | } 35 | 36 | struct BlacklistService : Service { 37 | Action> add{ "add" }; 38 | Action> remove{ "remove" }; 39 | Action> kick{ "kick" }; 40 | Method>, Empty> fetch{ "fetch" }; 41 | Action save{ "save" }; 42 | Action reload{ "reload" }; 43 | 44 | BlacklistService() 45 | : Service("blacklist") { 46 | $(add); 47 | $(remove); 48 | $(kick); 49 | $(fetch); 50 | $(save); 51 | $(reload); 52 | } 53 | }; 54 | 55 | } // namespace api -------------------------------------------------------------------------------- /api/include/stone-api/Chat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "apid.hpp" 4 | #include 5 | 6 | namespace api { 7 | 8 | struct NormalMessage { 9 | std::string sender, content; 10 | }; 11 | 12 | inline void to_json(rpc::json &j, const NormalMessage &i) { 13 | j["sender"] = i.sender; 14 | j["content"] = i.content; 15 | } 16 | 17 | inline void from_json(const rpc::json &j, NormalMessage &i) { 18 | j.at("sender").get_to(i.sender); 19 | j.at("content").get_to(i.content); 20 | } 21 | 22 | struct ChatService : Service { 23 | Action send{ "send" }; 24 | Broadcast recv{ "recv" }; 25 | Action raw{ "raw" }; 26 | 27 | ChatService() 28 | : Service("chat") { 29 | $(send); 30 | $(recv); 31 | $(raw); 32 | } 33 | }; 34 | 35 | } // namespace api -------------------------------------------------------------------------------- /api/include/stone-api/Command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "apid.hpp" 4 | #include 5 | 6 | namespace api { 7 | 8 | struct CommandRequest { 9 | std::string sender, content; 10 | }; 11 | 12 | inline void to_json(rpc::json &j, const CommandRequest &i) { 13 | j["sender"] = i.sender; 14 | j["content"] = i.content; 15 | } 16 | 17 | inline void from_json(const rpc::json &j, CommandRequest &i) { 18 | j.at("sender").get_to(i.sender); 19 | j.at("content").get_to(i.content); 20 | } 21 | 22 | struct CommandAutoCompleteRequest { 23 | std::string content; 24 | int position; 25 | }; 26 | 27 | inline void to_json(rpc::json &j, const CommandAutoCompleteRequest &i) { 28 | j["content"] = i.content; 29 | j["position"] = i.position; 30 | } 31 | 32 | inline void from_json(const rpc::json &j, CommandAutoCompleteRequest &i) { 33 | j.at("content").get_to(i.content); 34 | j.at("position").get_to(i.position); 35 | } 36 | 37 | struct AutoCompleteOption { 38 | std::string source, title, desc; 39 | int offset, length, item; 40 | }; 41 | 42 | inline void to_json(rpc::json &j, const AutoCompleteOption &i) { 43 | j["source"] = i.source; 44 | j["title"] = i.title; 45 | j["desc"] = i.desc; 46 | j["offset"] = i.offset; 47 | j["length"] = i.length; 48 | j["item"] = i.item; 49 | } 50 | 51 | inline void from_json(const rpc::json &j, AutoCompleteOption &i) { 52 | j.at("source").get_to(i.source); 53 | j.at("title").get_to(i.title); 54 | j.at("desc").get_to(i.desc); 55 | j.at("offset").get_to(i.offset); 56 | j.at("length").get_to(i.length); 57 | j.at("item").get_to(i.item); 58 | } 59 | 60 | struct CommandService : Service { 61 | Method execute{ "execute" }; 62 | CommandService() 63 | : Service("command") { 64 | $(execute); 65 | } 66 | }; 67 | 68 | } // namespace api -------------------------------------------------------------------------------- /api/include/stone-api/Core.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "apid.hpp" 4 | #include 5 | 6 | namespace api { 7 | 8 | struct LogEntry { 9 | std::string tag; 10 | int level; 11 | std::string content; 12 | }; 13 | 14 | inline void to_json(rpc::json &j, const LogEntry &i) { 15 | j["tag"] = i.tag; 16 | j["level"] = i.level; 17 | j["content"] = i.content; 18 | } 19 | 20 | inline void from_json(const rpc::json &j, LogEntry &i) { 21 | j.at("tag").get_to(i.tag); 22 | j.at("level").get_to(i.level); 23 | j.at("content").get_to(i.content); 24 | } 25 | 26 | struct PlayerInfo { 27 | std::string name, uuid, xuid; 28 | }; 29 | 30 | inline void to_json(rpc::json &j, const PlayerInfo &i) { 31 | j["name"] = i.name; 32 | j["uuid"] = i.uuid; 33 | j["xuid"] = i.xuid; 34 | } 35 | 36 | inline void from_json(const rpc::json &j, PlayerInfo &i) { 37 | j.at("name").get_to(i.name); 38 | j.at("uuid").get_to(i.uuid); 39 | j.at("xuid").get_to(i.xuid); 40 | } 41 | 42 | struct CoreService : Service { 43 | Action stop{ "stop" }; 44 | Method ping{ "ping" }; 45 | Method tps{ "tps" }; 46 | Method config{ "config" }; 47 | Broadcast log{ "log" }; 48 | Method, Empty> online_players{ "online_players" }; 49 | Broadcast player_join{ "player_join" }; 50 | Broadcast player_left{ "player_left" }; 51 | 52 | CoreService() 53 | : Service("core") { 54 | $(stop); 55 | $(ping); 56 | $(tps); 57 | $(config); 58 | $(log); 59 | $(online_players); 60 | $(player_join); 61 | $(player_left); 62 | } 63 | }; 64 | 65 | } // namespace api 66 | -------------------------------------------------------------------------------- /api/include/stone-api/Script.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "apid.hpp" 4 | #include 5 | 6 | namespace api { 7 | 8 | struct EventData { 9 | std::string name, data; 10 | }; 11 | 12 | inline void to_json(rpc::json &j, const EventData &i) { 13 | j["name"] = i.name; 14 | j["data"] = i.data; 15 | } 16 | 17 | inline void from_json(const rpc::json &j, EventData &i) { 18 | j.at("name").get_to(i.name); 19 | j.at("data").get_to(i.data); 20 | } 21 | 22 | struct ScriptService : Service { 23 | Action emit{ "emit" }; 24 | Broadcast broadcast{ "broadcast" }; 25 | 26 | ScriptService() 27 | : Service("script") { 28 | $(emit); 29 | $(broadcast); 30 | } 31 | }; 32 | 33 | } // namespace api -------------------------------------------------------------------------------- /api/src/log.cpp: -------------------------------------------------------------------------------- 1 | #define API_MODE 1 2 | #include "../include/stone-api/Command.h" 3 | #include "../include/stone-api/Core.h" 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | std::string GetEnvironmentVariableOrDefault(const std::string &variable_name, const std::string &default_value) { 12 | const char *value = getenv(variable_name.c_str()); 13 | return value ? value : default_value; 14 | } 15 | 16 | #define LOAD_ENV(env, def) static const auto env = GetEnvironmentVariableOrDefault(#env, def) 17 | 18 | LOAD_ENV(API_ENDPOINT, "ws+unix://data/api.socket"); 19 | 20 | std::string_view print_level(int level) { 21 | switch (level) { 22 | case 0: return "T"; 23 | case 1: return "D"; 24 | case 2: return "I"; 25 | case 3: return "W"; 26 | case 4: return "E"; 27 | default: return "U"; 28 | } 29 | } 30 | 31 | int main() { 32 | using namespace rpcws; 33 | using namespace api; 34 | 35 | static const auto ep = std::make_shared(); 36 | endpoint() = std::make_unique(std::make_unique(API_ENDPOINT, ep)); 37 | 38 | CoreService core; 39 | 40 | endpoint() 41 | ->start() 42 | .then([&] { core.log >> [](auto entry) { std::cout << print_level(entry.level) << " " << entry.content << std::endl; }; }) 43 | .fail([&](auto) { 44 | endpoint()->stop(); 45 | ep->shutdown(); 46 | }); 47 | } -------------------------------------------------------------------------------- /api/src/ping.cpp: -------------------------------------------------------------------------------- 1 | #define API_MODE 1 2 | #include "../include/stone-api/Core.h" 3 | #include 4 | 5 | std::string GetEnvironmentVariableOrDefault(const std::string &variable_name, const std::string &default_value) { 6 | const char *value = getenv(variable_name.c_str()); 7 | return value ? value : default_value; 8 | } 9 | 10 | #define LOAD_ENV(env, def) static const auto env = GetEnvironmentVariableOrDefault(#env, def) 11 | 12 | LOAD_ENV(API_ENDPOINT, "ws+unix://data/api.socket"); 13 | 14 | int main() { 15 | using namespace rpcws; 16 | using namespace api; 17 | 18 | static const auto ep = std::make_shared(); 19 | endpoint() = std::make_unique(std::make_unique(API_ENDPOINT, ep)); 20 | 21 | CoreService core; 22 | 23 | endpoint() 24 | ->start() 25 | .then>([&] { 26 | std::cout << "connected!" << std::endl; 27 | return core.ping({}); 28 | }) 29 | .then([](auto) { 30 | std::cout << "pong!" << std::endl; 31 | endpoint()->stop(); 32 | ep->shutdown(); 33 | }) 34 | .fail([](std::exception_ptr ex) { 35 | try { 36 | if (ex) std::rethrow_exception(ex); 37 | } catch (RemoteException const &ex) { std::cout << ex.full << std::endl; } catch (std::exception const &ex) { 38 | std::cout << ex.what() << std::endl; 39 | } 40 | endpoint()->stop(); 41 | ep->shutdown(); 42 | }); 43 | ep->wait(); 44 | } -------------------------------------------------------------------------------- /cmake/GetGitRevisionDescription.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Internal file for GetGitRevisionDescription.cmake 3 | # 4 | # Requires CMake 2.6 or newer (uses the 'function' command) 5 | # 6 | # Original Author: 7 | # 2009-2010 Ryan Pavlik 8 | # http://academic.cleardefinition.com 9 | # Iowa State University HCI Graduate Program/VRAC 10 | # 11 | # Copyright Iowa State University 2009-2010. 12 | # Distributed under the Boost Software License, Version 1.0. 13 | # (See accompanying file LICENSE_1_0.txt or copy at 14 | # http://www.boost.org/LICENSE_1_0.txt) 15 | 16 | set(HEAD_HASH) 17 | 18 | file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) 19 | 20 | string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) 21 | if(HEAD_CONTENTS MATCHES "ref") 22 | # named branch 23 | string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") 24 | if(EXISTS "@GIT_DIR@/${HEAD_REF}") 25 | configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 26 | elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") 27 | configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) 28 | set(HEAD_HASH "${HEAD_REF}") 29 | endif() 30 | else() 31 | # detached HEAD 32 | configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) 33 | endif() 34 | 35 | if(NOT HEAD_HASH) 36 | file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) 37 | string(STRIP "${HEAD_HASH}" HEAD_HASH) 38 | endif() 39 | -------------------------------------------------------------------------------- /deps/arg-parser/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/arg-parser 8 | branch = master 9 | commit = 96c5e2412fed0e8968aed77f630daae521f613ce 10 | parent = 24c27f8bf4706e5721a2820d70ae7dddc8164b67 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/arg-parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(argparser LANGUAGES CXX) 4 | 5 | add_library(argparser INTERFACE) 6 | target_include_directories(argparser INTERFACE include/) -------------------------------------------------------------------------------- /deps/arg-parser/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /deps/arg-parser/include/argparser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include -------------------------------------------------------------------------------- /deps/arg-parser/include/argparser/arg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "arg_parser.h" 6 | 7 | namespace argparser { 8 | 9 | template 10 | class arg { 11 | 12 | private: 13 | T value; 14 | 15 | void handle_value(arg_list& list); 16 | 17 | public: 18 | arg(arg_parser& parser, std::string const& name, std::string const& shortname, std::string const& desc, T def = T()) 19 | : value(def) { 20 | parser.add_arg(name, shortname, desc, std::bind(&arg::handle_value, this, std::placeholders::_1)); 21 | } 22 | 23 | T const& get() const { 24 | return value; 25 | } 26 | 27 | operator T const&() const { 28 | return value; 29 | } 30 | 31 | }; 32 | 33 | template <> 34 | void arg::handle_value(arg_list& list) { 35 | value = list.next(); 36 | } 37 | 38 | template <> 39 | void arg::handle_value(arg_list& list) { 40 | value = std::stoi(list.next()); 41 | } 42 | 43 | template <> 44 | void arg::handle_value(arg_list& list) { 45 | value = std::stof(list.next()); 46 | } 47 | 48 | template <> 49 | void arg::handle_value(arg_list& list) { 50 | const char* v = list.next_value_or_null(); 51 | if (v == nullptr || 52 | strcmp(v, "1") == 0 || strcasecmp(v, "true") == 0 || strcasecmp(v, "on") == 0 || strcasecmp(v, "yes") == 0) 53 | value = true; 54 | else if (strcmp(v, "0") == 0 || strcasecmp(v, "false") == 0 || strcasecmp(v, "off") == 0 || strcasecmp(v, "no") == 0) 55 | value = false; 56 | else 57 | throw std::invalid_argument("Invalid boolean value"); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /deps/arg-parser/include/argparser/arg_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace argparser { 7 | 8 | class arg_list { 9 | 10 | private: 11 | int argc; 12 | const char** argv; 13 | 14 | public: 15 | arg_list(int argc, const char** argv) : argc(argc), argv(argv) { 16 | } 17 | 18 | const char* peek() { 19 | if (argc <= 0) 20 | return nullptr; 21 | return *(argv + 1); 22 | } 23 | 24 | const char* next_or_null() { 25 | if (argc <= 0) 26 | return nullptr; 27 | argc--; 28 | return *(argv++); 29 | } 30 | 31 | const char* next() { 32 | const char* val = next_or_null(); 33 | if (val == nullptr) 34 | throw std::out_of_range("Missing argument"); 35 | return val; 36 | } 37 | 38 | const char* next_value_or_null() { 39 | const char* val = peek(); 40 | if (val == nullptr || val[0] == '-') 41 | return nullptr; 42 | return next(); 43 | } 44 | 45 | const char* next_value() { 46 | const char* val = next_value_or_null(); 47 | if (val == nullptr) 48 | throw std::out_of_range("Missing argument"); 49 | return val; 50 | } 51 | 52 | }; 53 | 54 | } -------------------------------------------------------------------------------- /deps/arg-parser/include/argparser/arg_parser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "arg_list.h" 8 | 9 | namespace argparser { 10 | 11 | class arg_parser { 12 | 13 | public: 14 | using handler = std::function; 15 | 16 | private: 17 | struct help_entry { 18 | std::string name, shortname, desc; 19 | }; 20 | std::unordered_map handlers; 21 | std::vector help_entries; 22 | 23 | public: 24 | arg_parser() { 25 | help_entries.push_back({"--help", "-h", "Show this help information"}); 26 | } 27 | 28 | bool parse(int argc, const char** argv) { 29 | arg_list list (argc, argv); 30 | if (list.next_or_null() == nullptr) 31 | return false; 32 | const char* key; 33 | while ((key = list.next_or_null()) != nullptr) { 34 | auto handler = handlers.find(key); 35 | if (handler == handlers.end()) { 36 | if (strcmp(key, "-h") == 0 || strcmp(key, "--help") == 0) { 37 | print_help(); 38 | return false; 39 | } 40 | printf("Unknown argument: %s\n", key); 41 | return false; 42 | } 43 | try { 44 | handler->second(list); 45 | } catch (std::exception& e) { 46 | printf("Invalid argument value for %s: %s", key, e.what()); 47 | return false; 48 | } 49 | } 50 | return true; 51 | } 52 | 53 | void add_arg(std::string const& name, std::string const& shortname, std::string const& desc, handler h) { 54 | handlers[name] = handlers[shortname] = h; 55 | help_entries.push_back({name, shortname, desc}); 56 | } 57 | 58 | void print_help() { 59 | printf("Program Help\n"); 60 | for (auto const& e : help_entries) 61 | printf("%-2s %-15s %s\n", e.shortname.c_str(), e.name.c_str(), e.desc.c_str()); 62 | } 63 | 64 | }; 65 | 66 | } -------------------------------------------------------------------------------- /deps/base64/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/base64 8 | branch = master 9 | commit = 1cf21f742e7fda79ff34b60c5d156e290ca7b6c6 10 | parent = fc74d23a7d24c129cdd36eb5e0ce45be30423ab3 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/base64/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(base64 LANGUAGES CXX) 4 | 5 | add_library(base64 include/base64.h src/base64.cpp) 6 | target_include_directories(base64 PUBLIC include/) -------------------------------------------------------------------------------- /deps/base64/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /deps/base64/include/base64.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Base64 { 6 | 7 | private: 8 | 9 | static char table[65]; 10 | static unsigned char reverseTable[256]; 11 | static bool reverseTableInitialized; 12 | 13 | static void initReverseTable(); 14 | 15 | public: 16 | 17 | static std::string encode(const std::string& input); 18 | 19 | static std::string decode(const std::string& input, const char* skipChars = "\r\n"); 20 | 21 | }; -------------------------------------------------------------------------------- /deps/file-util/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/file-util 8 | branch = master 9 | commit = 2e0d2f911144cae16e8f59e8ca63064dac6c8997 10 | parent = c9f41a3846e7f1f7df1c08be6091d4e6c30f30ae 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/file-util/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | set(CMAKE_CXX_STANDARD 11) 4 | 5 | project(file-util LANGUAGES CXX) 6 | 7 | add_library(file-util include/FileUtil.h src/FileUtil.cpp include/EnvPathUtil.h src/EnvPathUtil.cpp) 8 | if (APPLE) 9 | target_sources(file-util PRIVATE src/EnvPathUtil_MacOS.mm) 10 | endif() 11 | target_include_directories(file-util PUBLIC include/) 12 | if (APPLE) 13 | target_link_libraries(file-util "-framework Foundation") 14 | endif() -------------------------------------------------------------------------------- /deps/file-util/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /deps/file-util/include/EnvPathUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class EnvPathUtil { 6 | 7 | public: 8 | static std::string getAppDir(); 9 | 10 | static std::string getWorkingDir(); 11 | 12 | static std::string getHomeDir(); 13 | 14 | static std::string getDataHome(); 15 | 16 | static bool findInPath(std::string const& what, std::string& result, const char* path = nullptr, 17 | const char* cwd = nullptr); 18 | 19 | }; -------------------------------------------------------------------------------- /deps/file-util/include/FileUtil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class FileUtil { 6 | 7 | public: 8 | static std::string getParent(std::string const& path); 9 | 10 | static bool exists(std::string const& path); 11 | 12 | static bool isDirectory(std::string const& path); 13 | 14 | static void mkdirRecursive(std::string const& path); 15 | 16 | }; -------------------------------------------------------------------------------- /deps/file-util/src/EnvPathUtil_MacOS.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #import 3 | 4 | std::string EnvPathUtil::getDataHome() { 5 | NSFileManager* fm = [NSFileManager defaultManager]; 6 | NSArray* appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]; 7 | for (NSURL* url in appSupportDir) { 8 | if (![url isFileURL]) 9 | continue; 10 | NSString* dirPathNS = [url path]; 11 | return std::string ([dirPathNS UTF8String], [dirPathNS lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); 12 | } 13 | return std::string(); 14 | } -------------------------------------------------------------------------------- /deps/file-util/src/FileUtil.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | bool FileUtil::exists(std::string const& path) { 7 | return access(path.c_str(), F_OK) == 0; 8 | } 9 | 10 | bool FileUtil::isDirectory(std::string const& path) { 11 | struct stat s; 12 | stat(path.c_str(), &s); 13 | return S_ISDIR(s.st_mode); 14 | } 15 | 16 | std::string FileUtil::getParent(std::string const& path) { 17 | auto iof = path.rfind('/'); 18 | if (iof == std::string::npos) 19 | return std::string(); 20 | while (iof > 0 && path[iof - 1] == '/') 21 | iof--; 22 | return path.substr(0, iof); 23 | } 24 | 25 | void FileUtil::mkdirRecursive(std::string const& path) { 26 | if (isDirectory(path)) 27 | return; 28 | if (exists(path)) 29 | throw std::runtime_error(std::string("File exists and is not a directory: ") + path); 30 | mkdirRecursive(getParent(path)); 31 | if (mkdir(path.c_str(), 0744) != 0) 32 | throw std::runtime_error(std::string("mkdir failed, path = ") + path); 33 | } -------------------------------------------------------------------------------- /deps/libhybris/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/libhybris 8 | branch = gdb-support 9 | commit = a541ddc21e81912ae195843b85e3369fc8de5a44 10 | parent = 1b7d7cfc5e5e742fe9180bcbb0b8d74416dbac3d 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/libhybris/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.1) 2 | 3 | project(hybris LANGUAGES C ASM) 4 | 5 | set(THREADS_PREFER_PTHREAD_FLAG ON) 6 | find_package(Threads REQUIRED) 7 | 8 | set(HYBRIS_SOURCES src/cache.c src/dlfcn.c src/hooks.c src/hooks_shm.c src/logging.c src/properties.c src/ctype.c src/sysconf.c src/jb/dlfcn.c src/jb/linker.c src/jb/linker_environ.c src/jb/linker_format.c src/jb/rt.c src/hooks_pthread.c src/hooks_dirent.c src/hooks_io.c src/hooks_net.c src/hooks_list.c) 9 | set(HYBRIS_EXTRA_DEFS ) 10 | if(APPLE) 11 | set(HYBRIS_SOURCES ${HYBRIS_SOURCES} src/hooks_net_darwin.c src/hooks_darwin_pthread_once.cpp) 12 | set(HYBRIS_SOURCES ${HYBRIS_SOURCES} src/bionic/arch-x86/setjmp.S src/bionic/setjmp_cookie.c) 13 | set(HYBRIS_EXTRA_DEFS ${HYBRIS_EXTRA_DEFS} USE_BIONIC_SETJMP) 14 | else() 15 | set(HYBRIS_SOURCES ${HYBRIS_SOURCES} src/strlcpy.c src/hooks_list.c src/hooks_list.h) 16 | endif() 17 | 18 | add_library(hybris ${HYBRIS_SOURCES}) 19 | target_include_directories(hybris PUBLIC include/) 20 | target_link_libraries(hybris Threads::Threads) 21 | 22 | target_compile_definitions(hybris PRIVATE ${HYBRIS_EXTRA_DEFS}) 23 | if (${IS_ARM_BUILD}) 24 | target_compile_definitions(hybris PRIVATE HAVE_ARM_TLS_REGISTER ANDROID_ARM_LINKER _GNU_SOURCE LINKER_TEXT_BASE=0xB0000100 LINKER_AREA_SIZE=0x01000000 LINKER_DEBUG=1) 25 | if (${IS_ARMHF_BUILD}) 26 | target_compile_definitions(hybris PRIVATE AVOID_FLOAT_POINT_HOOKS) 27 | endif() 28 | else() 29 | target_compile_definitions(hybris PRIVATE ANDROID_X86_LINKER _GNU_SOURCE LINKER_TEXT_BASE=0xB0000100 LINKER_AREA_SIZE=0x01000000 LINKER_DEBUG=1) 30 | endif() 31 | 32 | if(APPLE) 33 | target_link_libraries(hybris epoll-shim osx-elf-header) 34 | else() 35 | target_link_libraries(hybris rt) 36 | endif() 37 | -------------------------------------------------------------------------------- /deps/libhybris/include/hybris/dlfcn.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #ifndef _HYBRIS_DLFCN_H_ 19 | #define _HYBRIS_DLFCN_H_ 20 | 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | void *hybris_dlopen(const char *filename, int flag); 28 | void *hybris_dlsym(void *handle, const char *symbol); 29 | int hybris_dlclose(void *handle); 30 | int hybris_dladdr(const void *addr, Dl_info *info); 31 | const char *hybris_dlerror(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // _HYBRIS_DLFCN_H_ 38 | 39 | // vim: noai:ts=4:sw=4:ss=4:expandtab 40 | -------------------------------------------------------------------------------- /deps/libhybris/include/hybris/floating_point_abi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Jolla Ltd. 3 | * Contact: Thomas Perl 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | #ifndef HYBRIS_FLOATING_POINT_ABI_H_ 19 | #define HYBRIS_FLOATING_POINT_ABI_H_ 20 | 21 | /** 22 | * Make sure to use FP_ATTRIB on all functions that are loaded from 23 | * Android (bionic libc) libraries to make sure floating point arguments 24 | * are passed the right way. 25 | * 26 | * See: http://wiki.debian.org/ArmHardFloatPort/VfpComparison 27 | * http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html 28 | * 29 | * It doesn't hurt to have it added for non-floating point arguments and 30 | * return types, even though it does not really have any effect. 31 | * 32 | * If you use the convenience macros in hybris/common/binding.h, your 33 | * wrapper functions will automatically make use of this attribute. 34 | **/ 35 | 36 | #ifdef __ARM_PCS_VFP 37 | # define FP_ATTRIB __attribute__((pcs("aapcs"))) 38 | #else 39 | # define FP_ATTRIB 40 | #endif 41 | 42 | #endif /* HYBRIS_FLOATING_POINT_ABI_H_ */ 43 | -------------------------------------------------------------------------------- /deps/libhybris/include/hybris/hook.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #ifndef _HYBRIS_HOOK_H_ 19 | #define _HYBRIS_HOOK_H_ 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | struct _hook { 26 | const char *name; 27 | void *func; 28 | }; 29 | 30 | void hybris_hook(const char *name, void* func); 31 | void hybris_register_hooks(struct _hook *hooks); 32 | 33 | void *get_hooked_symbol(const char *sym); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // _HYBRIS_HOOK_H_ 40 | 41 | // vim: noai:ts=4:sw=4:ss=4:expandtab 42 | -------------------------------------------------------------------------------- /deps/libhybris/include/hybris/properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Carsten Munk 3 | * 2013 Simon Busch 4 | * 2008 The Android Open Source Project 5 | * 2013 Canonical Ltd 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | */ 20 | 21 | #ifndef PROPERTIES_H_ 22 | #define PROPERTIES_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | /* Based on Android */ 29 | #define PROP_SERVICE_NAME "property_service" 30 | 31 | #define PROP_NAME_MAX 32 32 | #define PROP_VALUE_MAX 92 33 | 34 | /* Only SETPROP is defined by Android, for GETPROP and LISTPROP to work 35 | * an extended Android init service needs to be in place */ 36 | #define PROP_MSG_SETPROP 1 37 | #define PROP_MSG_GETPROP 2 38 | #define PROP_MSG_LISTPROP 3 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef struct prop_msg_s { 45 | unsigned cmd; 46 | char name[PROP_NAME_MAX]; 47 | char value[PROP_VALUE_MAX]; 48 | } prop_msg_t; 49 | 50 | int property_set(const char *key, const char *value); 51 | int property_get(const char *key, char *value, const char *default_value); 52 | int property_list(void (*propfn)(const char *key, const char *value, void *cookie), void *cookie); 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif // PROPERTIES_H_ 59 | -------------------------------------------------------------------------------- /deps/libhybris/src/bionic/bionic_asm_x86.h: -------------------------------------------------------------------------------- 1 | /* $NetBSD: asm.h,v 1.40 2011/06/16 13:16:20 joerg Exp $ */ 2 | 3 | /*- 4 | * Copyright (c) 1990 The Regents of the University of California. 5 | * All rights reserved. 6 | * 7 | * This code is derived from software contributed to Berkeley by 8 | * William Jolitz. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the University nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | * 34 | * @(#)asm.h 5.5 (Berkeley) 5/7/91 35 | */ 36 | 37 | #pragma once 38 | 39 | #define PIC_PROLOGUE \ 40 | pushl %ebx; \ 41 | call 666f; \ 42 | 666: \ 43 | popl %ebx; \ 44 | // addl $_GLOBAL_OFFSET_TABLE_+(.-666b), %ebx - HACK: currently unused, so we delete it as it causes issues on OS X 45 | #define PIC_EPILOGUE \ 46 | popl %ebx 47 | #define PIC_PLT(x) x@PLT 48 | #define PIC_GOT(x) x@GOT(%ebx) 49 | #define PIC_GOTOFF(x) x@GOTOFF(%ebx) 50 | 51 | #define __bionic_asm_align 16 52 | -------------------------------------------------------------------------------- /deps/libhybris/src/ctype.h: -------------------------------------------------------------------------------- 1 | #ifndef CTYPE_H_ 2 | #define CTYPE_H_ 3 | 4 | extern const char *_hybris_ctype_; 5 | extern const short *_hybris_tolower_tab_; 6 | extern const short *_hybris_toupper_tab_; 7 | 8 | int 9 | hybris_isalnum(int c); 10 | 11 | int 12 | hybris_isalpha(int c); 13 | 14 | int 15 | hybris_isblank(int c); 16 | 17 | int 18 | hybris_iscntrl(int c); 19 | 20 | int 21 | hybris_isdigit(int c); 22 | 23 | int 24 | hybris_isgraph(int c); 25 | 26 | int 27 | hybris_islower(int c); 28 | 29 | int 30 | hybris_isprint(int c); 31 | 32 | int 33 | hybris_ispunct(int c); 34 | 35 | int 36 | hybris_isspace(int c); 37 | 38 | int 39 | hybris_isupper(int c); 40 | 41 | int 42 | hybris_isxdigit(int c); 43 | 44 | #endif -------------------------------------------------------------------------------- /deps/libhybris/src/dlfcn.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Intel Corporation 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #include "../include/hybris/dlfcn.h" 19 | #include "../include/hybris/binding.h" 20 | 21 | void *hybris_dlopen(const char *filename, int flag) 22 | { 23 | return android_dlopen(filename,flag); 24 | } 25 | 26 | 27 | void *hybris_dlsym(void *handle, const char *symbol) 28 | { 29 | return android_dlsym(handle,symbol); 30 | } 31 | 32 | 33 | int hybris_dlclose(void *handle) 34 | { 35 | return android_dlclose(handle); 36 | } 37 | 38 | 39 | int hybris_dladdr(const void *addr, Dl_info *info) 40 | { 41 | return android_dladdr(addr, info); 42 | } 43 | 44 | 45 | const char *hybris_dlerror(void) 46 | { 47 | return android_dlerror(); 48 | } 49 | 50 | // vim: noai:ts=4:sw=4:ss=4:expandtab 51 | -------------------------------------------------------------------------------- /deps/libhybris/src/hooks_darwin_pthread_once.cpp: -------------------------------------------------------------------------------- 1 | #include "hooks_darwin_pthread_once.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | void* _pthread_once_done; 8 | std::mutex _pthread_once_mutex; 9 | 10 | extern "C" int darwin_my_pthread_once(void *once_control, void (*init_routine)(void)) { 11 | std::atomic* atm = (std::atomic*) once_control; 12 | std::unique_lock lock (_pthread_once_mutex); 13 | void* ldval = atm->load(); 14 | if (ldval == (void*) &_pthread_once_done) 15 | return 0; 16 | 17 | if (ldval == nullptr) { 18 | std::shared_ptr* once_control_r = new std::shared_ptr(new pthread_once_t()); 19 | **once_control_r = PTHREAD_ONCE_INIT; 20 | atm->store(once_control_r); 21 | lock.unlock(); 22 | pthread_once((*once_control_r).get(), init_routine); 23 | lock.lock(); 24 | atm->store((void*) &_pthread_once_done); 25 | delete once_control_r; // this will delete the pointer as well after all references are gone 26 | } else { 27 | std::shared_ptr once_control_r = *((std::shared_ptr*) ldval); // deref it so we get a copy of the pointer and hold a ref 28 | lock.unlock(); 29 | pthread_once(once_control_r.get(), init_routine); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /deps/libhybris/src/hooks_darwin_pthread_once.h: -------------------------------------------------------------------------------- 1 | #ifndef HOOKS_DARWIN_PTHREAD_ONCE_H_ 2 | #define HOOKS_DARWIN_PTHREAD_ONCE_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | int darwin_my_pthread_once(void *once_control, void (*init_routine)(void)); 8 | #ifdef __cplusplus 9 | } 10 | #endif 11 | 12 | #endif /* HOOKS_DARWIN_PTHREAD_ONCE_H_ */ 13 | -------------------------------------------------------------------------------- /deps/libhybris/src/hooks_list.c: -------------------------------------------------------------------------------- 1 | #include "hooks_list.h" 2 | #include 3 | 4 | extern struct _hook main_hooks[]; 5 | extern struct _hook dirent_hooks[]; 6 | extern struct _hook io_hooks[]; 7 | extern struct _hook net_hooks[]; 8 | extern struct _hook pthread_hooks[]; 9 | #ifdef __APPLE__ 10 | extern struct _hook net_darwin_hooks[]; 11 | #endif 12 | 13 | void hybris_register_default_hooks() { 14 | hybris_register_hooks(main_hooks); 15 | hybris_register_hooks(dirent_hooks); 16 | hybris_register_hooks(io_hooks); 17 | hybris_register_hooks(net_hooks); 18 | hybris_register_hooks(pthread_hooks); 19 | 20 | #ifdef __APPLE__ 21 | hybris_register_hooks(net_darwin_hooks); 22 | #endif 23 | } -------------------------------------------------------------------------------- /deps/libhybris/src/hooks_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void hybris_register_default_hooks(); -------------------------------------------------------------------------------- /deps/libhybris/src/hooks_net.h: -------------------------------------------------------------------------------- 1 | #ifndef HOOKS_NET_H 2 | #define HOOKS_NET_H 3 | 4 | int convert_getnameinfo_flags(int flags); 5 | 6 | #endif /* HOOKS_NET_H */ 7 | -------------------------------------------------------------------------------- /deps/libhybris/src/hooks_shm.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012 Carsten Munk 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #ifndef HOOKS_SHM_H_ 19 | #define HOOKS_SHM_H_ 20 | 21 | #include 22 | 23 | typedef unsigned int hybris_shm_pointer_t; 24 | 25 | /* 26 | * Allocate a space in the shared memory region of hybris 27 | */ 28 | hybris_shm_pointer_t hybris_shm_alloc(size_t size); 29 | /* 30 | * Test if the pointers points to the shm region 31 | */ 32 | int hybris_is_pointer_in_shm(void *ptr); 33 | /* 34 | * Convert an offset pointer to the shared memory to an absolute pointer that can be used in user space 35 | * This function will return a NULL pointer if the handle does not actually point to the shm region 36 | */ 37 | void *hybris_get_shmpointer(hybris_shm_pointer_t handle); 38 | 39 | #endif 40 | 41 | // vim:ts=4:sw=4:noexpandtab 42 | -------------------------------------------------------------------------------- /deps/libhybris/src/jb/arch/arm/begin.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | .text 30 | .align 4 31 | .type _start,#function 32 | .globl _start 33 | 34 | _start: 35 | mov r0, sp 36 | mov r1, #0 37 | bl __linker_init 38 | 39 | /* linker init returns the _entry address in the main image */ 40 | mov pc, r0 41 | 42 | .section .ctors, "wa" 43 | .globl __CTOR_LIST__ 44 | __CTOR_LIST__: 45 | .long -1 46 | -------------------------------------------------------------------------------- /deps/libhybris/src/jb/arch/x86/begin.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | .text 30 | .align 4 31 | .type _start, @function 32 | .globl _start 33 | 34 | _start: 35 | /* save the elfdata ptr to %eax, AND push it onto the stack */ 36 | mov %esp, %eax 37 | pushl %esp 38 | 39 | pushl %eax 40 | call __linker_init 41 | 42 | /* linker init returns (%eax) the _entry address in the main image */ 43 | /* entry point expects sp to point to elfdata */ 44 | popl %esp 45 | jmp *%eax 46 | 47 | -------------------------------------------------------------------------------- /deps/libhybris/src/jb/linker_format.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * * Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * * Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in 12 | * the documentation and/or other materials provided with the 13 | * distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | #ifndef _LINKER_FORMAT_H 29 | #define _LINKER_FORMAT_H 30 | 31 | #include 32 | #include 33 | 34 | /* Formatting routines for the dynamic linker's debug traces */ 35 | /* We want to avoid dragging the whole C library fprintf() */ 36 | /* implementation into the dynamic linker since this creates */ 37 | /* issues (it uses malloc()/free()) and increases code size */ 38 | 39 | int format_buffer(char *buffer, size_t bufsize, const char *format, ...); 40 | 41 | #endif /* _LINKER_FORMAT_H */ 42 | -------------------------------------------------------------------------------- /deps/libhybris/src/properties_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013 Jolla Ltd. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | #ifndef HYBRIS_PROPERTIES 19 | #define HYBRIS_PROPERTIES 20 | 21 | typedef void (*hybris_propcache_list_cb)(const char *key, const char *value, void *cookie); 22 | 23 | void hybris_propcache_list(hybris_propcache_list_cb cb, void *cookie); 24 | char *hybris_propcache_find(const char *key); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /deps/libhybris/src/strlcpy.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ 2 | 3 | /* 4 | * Copyright (c) 1998 Todd C. Miller 5 | * 6 | * Permission to use, copy, modify, and distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | 19 | #include 20 | #include 21 | 22 | /* 23 | * Copy src to string dst of size siz. At most siz-1 characters 24 | * will be copied. Always NUL terminates (unless siz == 0). 25 | * Returns strlen(src); if retval >= siz, truncation occurred. 26 | */ 27 | size_t 28 | strlcpy(char *dst, const char *src, size_t siz) 29 | { 30 | char *d = dst; 31 | const char *s = src; 32 | size_t n = siz; 33 | 34 | /* Copy as many bytes as will fit */ 35 | if (n != 0) { 36 | while (--n != 0) { 37 | if ((*d++ = *s++) == '\0') 38 | break; 39 | } 40 | } 41 | 42 | /* Not enough room in dst, add NUL and traverse rest of src */ 43 | if (n == 0) { 44 | if (siz != 0) 45 | *d = '\0'; /* NUL-terminate dst */ 46 | while (*s++) 47 | ; 48 | } 49 | 50 | return(s - src - 1); /* count does not include NUL */ 51 | } 52 | -------------------------------------------------------------------------------- /deps/mcpelauncher-common/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/mcpelauncher-common 8 | branch = master 9 | commit = 1709aef9c417f03e03587ef9840a1c5617bfa584 10 | parent = 7ea974d91fbb99ca1123e0a7871fb5188090363e 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/mcpelauncher-common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(mcpelauncher-common LANGUAGES CXX) 4 | 5 | find_library(OpenSSL OPTIONAL) 6 | 7 | set(MCPELAUNCHER_COMMON_SOURCES include/mcpelauncher/path_helper.h src/path_helper.cpp) 8 | if (OPENSSL_FOUND) 9 | set(MCPELAUNCHER_COMMON_SOURCES ${MCPELAUNCHER_COMMON_SOURCES} src/openssl_multithread.h src/openssl_multithread.cpp) 10 | endif() 11 | if (APPLE) 12 | set(MCPELAUNCHER_COMMON_SOURCES ${MCPELAUNCHER_COMMON_SOURCES} src/path_helper_osx.mm) 13 | endif() 14 | 15 | add_library(mcpelauncher-common ${MCPELAUNCHER_COMMON_SOURCES}) 16 | target_include_directories(mcpelauncher-common PUBLIC include/) 17 | if (OPENSSL_FOUND) 18 | target_link_libraries(mcpelauncher-common ${OPENSSL_CRYPTO_LIBRARY}) 19 | endif() 20 | if (APPLE) 21 | target_link_libraries(mcpelauncher-common "-framework Foundation") 22 | endif() 23 | -------------------------------------------------------------------------------- /deps/mcpelauncher-common/src/openssl_multithread.cpp: -------------------------------------------------------------------------------- 1 | #include "openssl_multithread.h" 2 | 3 | #include 4 | #include 5 | 6 | OpenSSLMultithreadHelper OpenSSLMultithreadHelper::instance; 7 | 8 | OpenSSLMultithreadHelper::OpenSSLMultithreadHelper() { 9 | mutexes = std::vector(CRYPTO_num_locks()); 10 | CRYPTO_set_id_callback([]() { 11 | return (unsigned long) pthread_self(); 12 | }); 13 | CRYPTO_set_locking_callback([](int mode, int n, const char*, int) { 14 | if (mode & CRYPTO_LOCK) 15 | pthread_mutex_lock(&instance.mutexes[n].mutex); 16 | else 17 | pthread_mutex_unlock(&instance.mutexes[n].mutex); 18 | }); 19 | } -------------------------------------------------------------------------------- /deps/mcpelauncher-common/src/openssl_multithread.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct OpenSSLMultithreadHelper { 8 | 9 | private: 10 | struct PThreadMutex { 11 | pthread_mutex_t mutex; 12 | 13 | PThreadMutex() { 14 | mutex = PTHREAD_MUTEX_INITIALIZER; 15 | pthread_mutex_init(&mutex, nullptr); 16 | } 17 | ~PThreadMutex() { 18 | pthread_mutex_destroy(&mutex); 19 | } 20 | }; 21 | 22 | static OpenSSLMultithreadHelper instance; 23 | 24 | std::vector mutexes; 25 | 26 | public: 27 | OpenSSLMultithreadHelper(); 28 | 29 | }; -------------------------------------------------------------------------------- /deps/mcpelauncher-common/src/path_helper_osx.mm: -------------------------------------------------------------------------------- 1 | #include 2 | #import 3 | 4 | void PathHelper::PathInfo::findAppleDirectories() { 5 | NSFileManager* fm = [NSFileManager defaultManager]; 6 | NSArray* appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask]; 7 | for (NSURL* url in appSupportDir) { 8 | if (![url isFileURL]) 9 | continue; 10 | NSString* dirPathNS = [url path]; 11 | std::string dirPath ([dirPathNS UTF8String], [dirPathNS lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); 12 | if (dataHome.empty()) 13 | dataHome = dirPath; 14 | else 15 | dataDirs.push_back(dirPath); 16 | } 17 | NSBundle* bundle = [NSBundle mainBundle]; 18 | NSString* resPathNS = [bundle resourcePath]; 19 | std::string resPath ([resPathNS UTF8String], [resPathNS lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); 20 | dataDirs.push_back(resPath); 21 | appSupportDir = [fm URLsForDirectory:NSApplicationSupportDirectory inDomains:NSLocalDomainMask]; 22 | for (NSURL* url in appSupportDir) { 23 | if (![url isFileURL]) 24 | continue; 25 | NSString* dirPathNS = [url path]; 26 | std::string dirPath ([dirPathNS UTF8String], [dirPathNS lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); 27 | dataDirs.push_back(dirPath); 28 | } 29 | NSArray* cachesDir = [fm URLsForDirectory:NSCachesDirectory inDomains:NSUserDomainMask]; 30 | for (NSURL* url in cachesDir) { 31 | if (![url isFileURL]) 32 | continue; 33 | NSString* dirPathNS = [url path]; 34 | std::string dirPath ([dirPathNS UTF8String], [dirPathNS lengthOfBytesUsingEncoding:NSUTF8StringEncoding]); 35 | cacheHome = dirPath; 36 | break; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /deps/mcpelauncher-core/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/mcpelauncher-core 8 | branch = master 9 | commit = 9c26578f09f96287cab2068eeb19ca4a2f51a555 10 | parent = 95bd11ff37079a65fff49e8393fb047fb2961f90 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/mcpelauncher-core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(mcpelauncher-core LANGUAGES CXX) 4 | 5 | add_library(mcpelauncher-core include/mcpelauncher/app_platform.h include/mcpelauncher/hook.h include/mcpelauncher/mod_loader.h include/mcpelauncher/hybris_utils.h include/mcpelauncher/patch_utils.h include/mcpelauncher/crash_handler.h include/mcpelauncher/minecraft_utils.h src/app_platform.cpp src/hook.cpp src/mod_loader.cpp src/hybris_utils.cpp src/crash_handler.cpp src/patch_utils.cpp src/minecraft_utils.cpp include/mcpelauncher/minecraft_version.h) 6 | target_include_directories(mcpelauncher-core PUBLIC include/) 7 | target_link_libraries(mcpelauncher-core mcpelauncher-common logger hybris minecraft-symbols minecraft-imported-symbols ${CMAKE_DL_LIBS}) 8 | 9 | if(APPLE) 10 | target_link_libraries(mcpelauncher-core osx-elf-header) 11 | endif() 12 | 13 | if (IS_ARMHF_BUILD) 14 | target_compile_definitions(mcpelauncher-core PRIVATE USE_BIONIC_LIBC) 15 | endif() -------------------------------------------------------------------------------- /deps/mcpelauncher-core/include/mcpelauncher/crash_handler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CrashHandler { 4 | 5 | private: 6 | static bool hasCrashed; 7 | 8 | static void handleSignal(int signal, void* aptr); 9 | 10 | public: 11 | static void registerCrashHandler(); 12 | 13 | }; -------------------------------------------------------------------------------- /deps/mcpelauncher-core/include/mcpelauncher/hybris_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class HybrisUtils { 6 | 7 | private: 8 | static const char* TAG; 9 | 10 | public: 11 | static bool loadLibrary(std::string path); 12 | static void* loadLibraryOS(std::string path, const char** symbols); 13 | 14 | static void stubSymbols(const char** symbols, void* stubfunc); 15 | 16 | private: 17 | friend class MinecraftUtils; 18 | 19 | static void hookAndroidLog(); 20 | 21 | }; -------------------------------------------------------------------------------- /deps/mcpelauncher-core/include/mcpelauncher/minecraft_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MinecraftUtils { 6 | 7 | private: 8 | static void* loadLibM(); 9 | 10 | static void setupHookApi(); 11 | 12 | public: 13 | static void workaroundLocaleBug(); 14 | 15 | static void setMallocZero(); 16 | 17 | static void setupHybris(); 18 | 19 | static void* loadMinecraftLib(std::string const& path = PathHelper::findGameFile("libs/libminecraftpe.so")); 20 | 21 | static void* loadFMod(); 22 | static void stubFMod(); 23 | 24 | static void setupForHeadless(); 25 | 26 | static unsigned int getLibraryBase(void* handle); 27 | 28 | static void initSymbolBindings(void* handle); 29 | 30 | static void workaroundShutdownCrash(void* handle); 31 | 32 | }; 33 | -------------------------------------------------------------------------------- /deps/mcpelauncher-core/include/mcpelauncher/minecraft_version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class MinecraftVersion { 6 | 7 | public: 8 | static bool isAtLeast(int major, int minor, int patch = -1, int revision = -1) { 9 | return *SharedConstants::MajorVersion > major || (*SharedConstants::MajorVersion == major && 10 | (*SharedConstants::MinorVersion > minor || (*SharedConstants::MinorVersion == minor && 11 | (*SharedConstants::PatchVersion > patch || (*SharedConstants::PatchVersion == patch && 12 | *SharedConstants::RevisionVersion >= revision))))); 13 | } 14 | 15 | static bool isExactly(int major, int minor, int patch, int revision) { 16 | return *SharedConstants::MajorVersion == major && *SharedConstants::MinorVersion == minor && 17 | *SharedConstants::RevisionVersion == revision && *SharedConstants::PatchVersion == patch; 18 | } 19 | 20 | }; -------------------------------------------------------------------------------- /deps/mcpelauncher-core/include/mcpelauncher/mod_loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class MinecraftGame; 8 | class ServerInstance; 9 | 10 | class ModLoader { 11 | 12 | private: 13 | std::vector mods; 14 | 15 | std::vector getModDependencies(std::string const& path); 16 | 17 | void loadModMulti(std::string const& path, std::string const& fileName, std::set& otherMods); 18 | 19 | public: 20 | void* loadMod(std::string const& path); 21 | 22 | void loadModsFromDirectory(std::string const& path); 23 | 24 | void onGameInitialized(MinecraftGame* game); 25 | 26 | void onServerInstanceInitialized(ServerInstance* server); 27 | 28 | }; -------------------------------------------------------------------------------- /deps/mcpelauncher-core/include/mcpelauncher/patch_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class PatchUtils { 6 | 7 | private: 8 | static const char* TAG; 9 | 10 | public: 11 | class VtableReplaceHelper { 12 | 13 | private: 14 | void* lib; 15 | void** vtable; 16 | void** referenceVtable; 17 | 18 | public: 19 | VtableReplaceHelper(void* lib, void** vtable, void** referenceVtable) : lib(lib), vtable(vtable), 20 | referenceVtable(referenceVtable) {} 21 | 22 | void replace(void* sym, void* replacement); 23 | 24 | void replace(const char* name, void* replacement); 25 | 26 | template 27 | void replace(void* sym, T replacement) { 28 | replace(sym, memberFuncCast(replacement)); 29 | } 30 | 31 | template 32 | void replace(const char* name, T replacement) { 33 | replace(name, memberFuncCast(replacement)); 34 | } 35 | 36 | }; 37 | 38 | static void patchCallInstruction(void* patchOff, void* func, bool jump); 39 | 40 | static size_t getVtableSize(void** vtable); 41 | 42 | template 43 | static void* memberFuncCast(T func) { 44 | union { 45 | T func; 46 | void* ptr; 47 | } u; 48 | u.func = func; 49 | return u.ptr; 50 | } 51 | 52 | }; -------------------------------------------------------------------------------- /deps/mcpelauncher-core/src/hybris_utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | const char* HybrisUtils::TAG = "HybrisUtils"; 8 | 9 | 10 | bool HybrisUtils::loadLibrary(std::string path) { 11 | void* handle = hybris_dlopen(PathHelper::findDataFile("libs/hybris/" + path).c_str(), RTLD_LAZY); 12 | if (handle == nullptr) { 13 | Log::error(TAG, "Failed to load hybris library %s: %s", path.c_str(), hybris_dlerror()); 14 | return false; 15 | } 16 | return true; 17 | } 18 | 19 | void* HybrisUtils::loadLibraryOS(std::string path, const char** symbols) { 20 | void* handle = dlopen(path.c_str(), RTLD_LAZY); 21 | if (handle == nullptr) { 22 | Log::error(TAG, "Failed to load OS library %s", path.c_str()); 23 | return nullptr; 24 | } 25 | Log::trace(TAG, "Loaded OS library %s", path.c_str()); 26 | int i = 0; 27 | while (true) { 28 | const char* sym = symbols[i]; 29 | if (sym == nullptr) 30 | break; 31 | void* ptr = dlsym(handle, sym); 32 | hybris_hook(sym, ptr); 33 | i++; 34 | } 35 | return handle; 36 | } 37 | 38 | void HybrisUtils::stubSymbols(const char** symbols, void* stubfunc) { 39 | int i = 0; 40 | while (true) { 41 | const char* sym = symbols[i]; 42 | if (sym == nullptr) 43 | break; 44 | hybris_hook(sym, stubfunc); 45 | i++; 46 | } 47 | } -------------------------------------------------------------------------------- /deps/mcpelauncher-core/src/patch_utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | const char* PatchUtils::TAG = "Patch"; 9 | 10 | void PatchUtils::patchCallInstruction(void* patchOff, void* func, bool jump) { 11 | unsigned char* data = (unsigned char*) patchOff; 12 | #ifdef __arm__ 13 | if (!jump) 14 | throw std::runtime_error("Non-jump patches not supported in ARM mode"); 15 | bool thumb = ((size_t) patchOff) & 1; 16 | if (thumb) 17 | data--; 18 | Log::trace(TAG, "Patching - original: %i %i %i %i %i", data[0], data[1], data[2], data[3], data[4]); 19 | if (thumb) { 20 | unsigned char patch[4] = {0xdf, 0xf8, 0x00, 0xf0}; 21 | memcpy(data, patch, 4); 22 | } else { 23 | unsigned char patch[4] = {0x04, 0xf0, 0x1f, 0xe5}; 24 | memcpy(data, patch, 4); 25 | } 26 | memcpy(&data[4], &func, sizeof(int)); 27 | Log::trace(TAG, "Patching - result: %i %i %i %i %i", data[0], data[1], data[2], data[3], data[4]); 28 | #else 29 | Log::trace(TAG, "Patching - original: %i %i %i %i %i", data[0], data[1], data[2], data[3], data[4]); 30 | data[0] = (unsigned char) (jump ? 0xe9 : 0xe8); 31 | int ptr = ((int) func) - (int) patchOff - 5; 32 | memcpy(&data[1], &ptr, sizeof(int)); 33 | Log::trace(TAG, "Patching - result: %i %i %i %i %i", data[0], data[1], data[2], data[3], data[4]); 34 | #endif 35 | } 36 | 37 | void PatchUtils::VtableReplaceHelper::replace(const char* name, void* replacement) { 38 | replace(hybris_dlsym(lib, name), replacement); 39 | } 40 | 41 | void PatchUtils::VtableReplaceHelper::replace(void* sym, void* replacement) { 42 | for (int i = 0; ; i++) { 43 | if (referenceVtable[i] == nullptr) 44 | break; 45 | if (referenceVtable[i] == sym) { 46 | vtable[i] = replacement; 47 | return; 48 | } 49 | } 50 | } 51 | 52 | size_t PatchUtils::getVtableSize(void** vtable) { 53 | for (size_t size = 2; ; size++) { 54 | if (vtable[size] == nullptr) 55 | return size; 56 | } 57 | } -------------------------------------------------------------------------------- /deps/mcpelauncher-just/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/mcpelauncher-just 8 | branch = master 9 | commit = 96a6b59d1f73abff8bdb3af04a6f7ecbd34cac4f 10 | parent = 60b560b11fac512ce35385722c01b4612f846972 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/mcpelauncher-just/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(mcpelauncher-just LANGUAGES CXX) 4 | 5 | add_executable(mcpelauncher-just src/main.cpp) 6 | target_link_libraries(mcpelauncher-just logger mcpelauncher-core properties-parser) 7 | -------------------------------------------------------------------------------- /deps/mcpelauncher-just/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int argc, char *argv[]) { 9 | CrashHandler::registerCrashHandler(); 10 | MinecraftUtils::workaroundLocaleBug(); 11 | PathHelper::setGameDir(argv[1]); 12 | 13 | MinecraftUtils::setupForHeadless(); 14 | 15 | Log::trace("Launcher", "Loading Minecraft library"); 16 | void* handle = MinecraftUtils::loadMinecraftLib(); 17 | Log::info("Launcher", "Loaded Minecraft library"); 18 | Log::debug("Launcher", "Minecraft is at offset 0x%x", MinecraftUtils::getLibraryBase(handle)); 19 | 20 | MinecraftUtils::initSymbolBindings(handle); 21 | Log::info("Launcher", "Game version: %s", Common::getGameVersionStringNet().c_str()); 22 | 23 | Log::trace("Launcher", "Loading user library"); 24 | void* userHandle = hybris_dlopen(argv[2], RTLD_LAZY); 25 | Log::debug("Launcher", "User library is at offset 0x%x", MinecraftUtils::getLibraryBase(userHandle)); 26 | 27 | Log::trace("Launcher", "Initializing AppPlatform (vtable)"); 28 | LauncherAppPlatform::initVtable(handle); 29 | Log::trace("Launcher", "Initializing AppPlatform (create instance)"); 30 | LauncherAppPlatform* appPlatform = new LauncherAppPlatform(); 31 | Log::trace("Launcher", "Initializing AppPlatform (initialize call)"); 32 | appPlatform->initialize(); 33 | 34 | void (*mcmain)(void*) = (void (*)(void*)) hybris_dlsym(userHandle, "mcmain"); 35 | mcmain(appPlatform); 36 | 37 | MinecraftUtils::workaroundShutdownCrash(handle); 38 | return 0; 39 | } -------------------------------------------------------------------------------- /deps/minecraft-imported-symbols/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/minecraft-imported-symbols 8 | branch = master 9 | commit = efbf38ea130ab5a1cf3e5bdf5e3b87cafd9a2ac0 10 | parent = 4383ee5086679bed0d2246964ff401d8aaf1e4a9 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/minecraft-imported-symbols/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(minecraft-imported-symbols LANGUAGES CXX) 4 | 5 | add_library(minecraft-imported-symbols INTERFACE) 6 | target_include_directories(minecraft-imported-symbols INTERFACE include/) -------------------------------------------------------------------------------- /deps/minecraft-imported-symbols/include/minecraft/imported/android_symbols.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | const char* android_symbols[] = { 4 | "ANativeWindow_setBuffersGeometry", 5 | "AAssetManager_open", 6 | "AAsset_getLength", 7 | "AAsset_getBuffer", 8 | "AAsset_close", 9 | "AAsset_read", 10 | "AAsset_seek64", 11 | "AAsset_getLength64", 12 | "AAsset_getRemainingLength64", 13 | "ALooper_pollAll", 14 | "ANativeActivity_finish", 15 | "AInputQueue_getEvent", 16 | "AKeyEvent_getKeyCode", 17 | "AInputQueue_preDispatchEvent", 18 | "AInputQueue_finishEvent", 19 | "AKeyEvent_getAction", 20 | "AMotionEvent_getAxisValue", 21 | "AKeyEvent_getRepeatCount", 22 | "AKeyEvent_getMetaState", 23 | "AInputEvent_getDeviceId", 24 | "AInputEvent_getType", 25 | "AInputEvent_getSource", 26 | "AMotionEvent_getAction", 27 | "AMotionEvent_getPointerId", 28 | "AMotionEvent_getX", 29 | "AMotionEvent_getRawX", 30 | "AMotionEvent_getY", 31 | "AMotionEvent_getRawY", 32 | "AMotionEvent_getPointerCount", 33 | "AConfiguration_new", 34 | "AConfiguration_fromAssetManager", 35 | "AConfiguration_getLanguage", 36 | "AConfiguration_getCountry", 37 | "ALooper_prepare", 38 | "ALooper_addFd", 39 | "AInputQueue_detachLooper", 40 | "AConfiguration_delete", 41 | "AInputQueue_attachLooper", 42 | "AAssetManager_openDir", 43 | "AAssetDir_getNextFileName", 44 | "AAssetDir_close", 45 | nullptr 46 | }; -------------------------------------------------------------------------------- /deps/minecraft-imported-symbols/include/minecraft/imported/egl_symbols.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | const char* egl_symbols[] = { 4 | "eglChooseConfig", 5 | "eglGetError", 6 | "eglCreateWindowSurface", 7 | "eglGetConfigAttrib", 8 | "eglCreateContext", 9 | "eglDestroySurface", 10 | "eglSwapBuffers", 11 | "eglMakeCurrent", 12 | "eglDestroyContext", 13 | "eglTerminate", 14 | "eglGetDisplay", 15 | "eglInitialize", 16 | "eglQuerySurface", 17 | "eglSwapInterval", 18 | "eglQueryString", 19 | nullptr 20 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | BasedOnStyle: LLVM 3 | --- 4 | Language: Cpp 5 | # AlignAfterOpenBracket: AlwaysBreak 6 | ColumnLimit: 1000 7 | AlignConsecutiveAssignments: true 8 | AlignOperands: true 9 | AlignTrailingComments: true 10 | AllowAllParametersOfDeclarationOnNextLine: false 11 | AllowShortBlocksOnASingleLine: true 12 | AllowShortCaseLabelsOnASingleLine: true 13 | AllowShortFunctionsOnASingleLine: All 14 | AllowShortIfStatementsOnASingleLine: true 15 | AllowShortLoopsOnASingleLine: true 16 | AlwaysBreakBeforeMultilineStrings: true 17 | BinPackArguments: true 18 | BinPackParameters: true 19 | BreakBeforeTernaryOperators: false 20 | BreakConstructorInitializers: BeforeComma 21 | Cpp11BracedListStyle: false 22 | FixNamespaceComments: false 23 | IndentCaseLabels: false 24 | IndentWrappedFunctionNames: false -------------------------------------------------------------------------------- /deps/minecraft-symbols/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = git@github.com:codehz/minecraft-symbols.git 8 | branch = stone 9 | commit = 2df9f5655f6ff2f3bc4660e97bfb1e7f24161421 10 | parent = 5e14e52c1f86da9c086cdc8ab4732249d4bf131d 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(minecraft-symbols LANGUAGES CXX) 4 | 5 | set(MINECRAFT_SYMBOLS_SOURCES src/minecraft/symbols.cpp) 6 | 7 | if (APPLE) 8 | set(MINECRAFT_SYMBOLS_SOURCES ${MINECRAFT_SYMBOLS_SOURCES} src/minecraft/std/string_darwin.cpp) 9 | else() 10 | set(MINECRAFT_SYMBOLS_SOURCES ${MINECRAFT_SYMBOLS_SOURCES} src/minecraft/std/string_linux.cpp) 11 | endif() 12 | 13 | add_library(minecraft-symbols ${MINECRAFT_SYMBOLS_SOURCES}) 14 | set_property(TARGET minecraft-symbols PROPERTY CXX_STANDARD 17) 15 | target_include_directories(minecraft-symbols PUBLIC src/) 16 | target_link_libraries(minecraft-symbols logger hybris) -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Actor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include "types.h" 5 | #include 6 | 7 | class ActorDefinitionIdentifier { 8 | public: 9 | mcpe::string getFullName() const; 10 | }; 11 | 12 | struct CompoundTag; 13 | struct BlockSource; 14 | struct ItemInstance; 15 | enum ArmorSlot {}; 16 | 17 | class Actor { 18 | public: 19 | void **vtable; 20 | 21 | ActorDefinitionIdentifier &getActorIdentifier() const; 22 | int64_t &getUniqueID() const; 23 | 24 | Vec3 &getPos() const; 25 | Vec2 getRotation() const; 26 | BlockSource &getRegion() const; 27 | mcpe::string const &getNameTag() const; 28 | std::tuple getDimensionId() const; 29 | int getVariant() const; 30 | short getAirSupply() const; 31 | short getTotalAirSupply() const; 32 | int getStrength() const; 33 | int getStrengthMax() const; 34 | int getHealth() const; 35 | int getMaxHealth() const; 36 | Actor *getRide() const; 37 | Actor *getRideRoot() const; 38 | Actor *getTarget() const; 39 | ItemInstance &getArmor(ArmorSlot slot) const; 40 | 41 | /// @vtable ServerPlayer _ZN12ServerPlayer15changeDimensionE11AutomaticIDI9DimensioniEb 42 | void changeDimension(int id, bool show); 43 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Api.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | namespace minecraft { 6 | namespace api { 7 | 8 | class Api { 9 | 10 | public: 11 | 12 | void** vtable; 13 | mcpe::string envPath; 14 | void** playerIfaceVtable; 15 | void** entityIfaceVtable; 16 | void** networkIfaceVtable; 17 | void** playerInteractionsIfaceVtable; 18 | 19 | }; 20 | 21 | } 22 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/App.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class AppPlatform; 6 | struct AppContext { 7 | char filler[0x10]; 8 | AppPlatform* platform; 9 | bool doRender; 10 | }; 11 | 12 | class App { 13 | 14 | public: 15 | void** vtable; 16 | 17 | void init(AppContext& ctx); 18 | 19 | /// @vtable App _ZN3App4quitERKSsS1_ 20 | void quit(mcpe::string const&, mcpe::string const&); 21 | 22 | /// @vtable App _ZN3App10wantToQuitEv 23 | bool wantToQuit(); 24 | 25 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/AppPlatform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include "fix.h" 5 | #include "types.h" 6 | 7 | class AppPlatform { 8 | 9 | public: 10 | /// @symbol _ZTV11AppPlatform 11 | static XPointer myVtable; 12 | 13 | /// @symbol _ZN14ServiceLocatorI11AppPlatformE15mDefaultServiceE 14 | static AppPlatform** instance; 15 | 16 | void** vtable; 17 | char filler[0xA0 - sizeof(void**)]; 18 | // A0 19 | int hardwareTier; 20 | char filler2[0x1000]; 21 | 22 | AppPlatform(); 23 | 24 | void _fireAppFocusGained(); 25 | 26 | void initialize(); 27 | 28 | void teardown(); 29 | 30 | void showKeyboard(mcpe::string const&, int, bool, bool, bool, int, Vec2 const&); 31 | 32 | void hideKeyboard(); 33 | 34 | bool isKeyboardVisible(); 35 | 36 | }; 37 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/AppResourceLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | 6 | #include "Resource.h" 7 | 8 | class AppResourceLoader : public ResourceLoader { 9 | 10 | private: 11 | char filler[0x14]; 12 | 13 | public: 14 | /// @symbol _ZN17AppResourceLoaderC2ESt8functionIFSsvEE 15 | AppResourceLoader(std::function); 16 | 17 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/AutoComplete.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | 6 | struct CommandItem { 7 | int flag, id; 8 | }; 9 | 10 | struct AutoCompleteOption { 11 | mcpe::string source, title, description; 12 | int offset, length, tail; 13 | CommandItem item; 14 | bool flag; 15 | }; 16 | 17 | struct AutoCompleteInformation { 18 | std::vector list; 19 | }; 20 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/AutomationClient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class IMinecraftApp; 4 | 5 | namespace Automation { 6 | 7 | class AutomationClient { 8 | 9 | public: 10 | 11 | char filler[0x500]; 12 | 13 | AutomationClient(IMinecraftApp& a); 14 | 15 | 16 | }; 17 | 18 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/AutomationPlayerCommandOrigin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CommandOrigin.h" 4 | #include "std/string.h" 5 | 6 | class Minecraft; 7 | 8 | class AutomationPlayerCommandOrigin : public CommandOrigin { 9 | char filler[0x100]; 10 | 11 | public: 12 | AutomationPlayerCommandOrigin(mcpe::string const &, Player &); 13 | 14 | void setPermissionLevel(int level) { 15 | *((int *)this + 10) = level; 16 | } 17 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Blacklist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UUID.h" 4 | #include "std/string.h" 5 | 6 | #include 7 | #include 8 | 9 | struct Blacklist { 10 | struct Entry { 11 | mce::UUID uuid; 12 | mcpe::string name; 13 | mcpe::string reason; 14 | int duration; 15 | }; 16 | 17 | std::vector vec; 18 | std::mutex mtx; 19 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Block.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Tag.h" 4 | 5 | struct Block { 6 | char filler[12]; 7 | CompoundTag tag; 8 | CompoundTag tag2; 9 | char filler2[0x200]; 10 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/BlockSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "types.h" 4 | 5 | struct Biome; 6 | struct Block; 7 | 8 | struct BlockSource { 9 | Biome *getBiome(BlockPos const &); 10 | Block *getBlock(BlockPos const &) const; 11 | Block *getExtraBlock(BlockPos const &) const; 12 | void setBlock(int x, int y, int z, Block const &block, int sub); 13 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CommandOrigin; 4 | class CommandOutput; 5 | 6 | struct Command { 7 | char filler[0x20]; 8 | virtual ~Command(); 9 | /// @skipped 10 | virtual void execute(CommandOrigin &orig, CommandOutput &outp) = 0; 11 | Command(); 12 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/CommandMessage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CommandRegistry.h" 4 | #include "CommandUtils.h" 5 | #include "std/string.h" 6 | 7 | class CommandMessage { 8 | char filler[0x10]; 9 | 10 | public: 11 | mcpe::string getMessage(CommandOrigin const &) const; 12 | /// @symbol _ZN14CommandMessageC2Ev 13 | static CDT constructor; 14 | /// @symbol _ZN14CommandMessageD2Ev 15 | static CDT destructor; 16 | /// @symbol _ZZ7type_idI15CommandRegistry14CommandMessageE8typeid_tIT_EvE2id 17 | static typeid_t *tid; 18 | /// @symbol _ZNK15CommandRegistry5parseI14CommandMessageEEbPvRKNS_10ParseTokenERK13CommandOriginiRSsRSt6vectorISsSaISsEE 19 | static Parser parser; 20 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/CommandOrigin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UUID.h" 4 | #include "std/string.h" 5 | #include "types.h" 6 | #include 7 | #include 8 | 9 | enum class CommandOriginType { 10 | Player = 0, 11 | Block = 1, 12 | MinecartBlock = 2, 13 | DevConsole = 3, 14 | Test = 4, 15 | AutomationPlayer = 5, 16 | ClientAutomation = 6, 17 | DedicatedServer = 7, 18 | Actor = 8, 19 | Virtual = 9, 20 | GameArgument = 10, 21 | ActorServer = 11, 22 | }; 23 | 24 | struct Actor; 25 | 26 | class CommandOrigin { 27 | public: 28 | void **vtable; 29 | mce::UUID uuid; 30 | 31 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin7getNameEv 32 | mcpe::string getName(); 33 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin16getBlockPositionEv 34 | BlockPos getBlockPosition(); 35 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin16getWorldPositionEv 36 | Vec3 getWorldPosition(); 37 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin5cloneEv 38 | std::unique_ptr clone(); 39 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin13getOriginTypeEv 40 | CommandOriginType getOriginType(); 41 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin9getEntityEv 42 | Actor *getEntity(); 43 | /// @vtable PlayerCommandOrigin _ZNK19PlayerCommandOrigin19getPermissionsLevelEv 44 | unsigned char getPermissionLevel(); 45 | 46 | mce::UUID const &getUUID() const; 47 | }; 48 | 49 | struct Player; 50 | 51 | class PlayerCommandOrigin : public CommandOrigin { 52 | char filler[0x50]; 53 | 54 | public: 55 | PlayerCommandOrigin(Player &); 56 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/CommandOutput.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | 6 | class CommandOutputMessage { 7 | 8 | public: 9 | int type; 10 | mcpe::string messageId; 11 | std::vector params; 12 | }; 13 | 14 | class CommandOutputParameter; 15 | 16 | enum class CommandOutputMessageType { 17 | SUCCESS = 0, 18 | FAILED = 1, 19 | }; 20 | 21 | class CommandOutput { 22 | 23 | public: 24 | std::vector const &getMessages() const; 25 | 26 | /// @symbol _ZN13CommandOutput10addMessageERKSsRKSt6vectorI22CommandOutputParameterSaIS3_EE24CommandOutputMessageType 27 | void addMessage(mcpe::string const &, std::vector const &, CommandOutputMessageType); 28 | 29 | /// @symbol _ZN13CommandOutput5errorERKSsRKSt6vectorI22CommandOutputParameterSaIS3_EE 30 | void error(mcpe::string const &, std::vector const &); 31 | 32 | /// @symbol _ZN13CommandOutput7successERKSsRKSt6vectorI22CommandOutputParameterSaIS3_EE 33 | void success(mcpe::string const &, std::vector const &); 34 | 35 | void success(); 36 | }; 37 | 38 | class CommandOutputParameter { 39 | 40 | private: 41 | mcpe::string str; 42 | int type; 43 | 44 | public: 45 | CommandOutputParameter(mcpe::string const &); 46 | CommandOutputParameter(int); 47 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/CommandOutputSender.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "std/string.h" 5 | 6 | class CommandOrigin; 7 | class CommandOutput; 8 | namespace Automation { class AutomationClient; } 9 | 10 | class CommandOutputSender { 11 | 12 | public: 13 | 14 | static std::vector translate(std::vector const& v); 15 | 16 | /// @symbol _ZN19CommandOutputSenderC2ERN10Automation16AutomationClientE 17 | CommandOutputSender(Automation::AutomationClient& automationClient); 18 | 19 | virtual ~CommandOutputSender(); 20 | 21 | virtual void send(CommandOrigin const& origin, CommandOutput const& output); 22 | 23 | /// @symbol _ZN19CommandOutputSender22registerOutputCallbackERKSt8functionIFvR19AutomationCmdOutputEE 24 | virtual void registerOutputCallback(); 25 | 26 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/CommandSelector.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CommandRegistry.h" 4 | #include 5 | #include 6 | 7 | struct Actor; 8 | struct Player; 9 | class CommandOrigin; 10 | 11 | struct CommandSelectorBase { 12 | char filler[0x100]; 13 | CommandSelectorBase(bool); 14 | ~CommandSelectorBase(); 15 | 16 | std::shared_ptr> newResults(CommandOrigin const &) const; 17 | }; 18 | 19 | struct CommandActorSelector : CommandSelectorBase { 20 | CommandActorSelector() 21 | : CommandSelectorBase(false) {} 22 | /// @symbol _ZZ7type_idI15CommandRegistry15CommandSelectorI5ActorEE8typeid_tIT_EvE2id 23 | static typeid_t *tid; 24 | /// @symbol _ZNK15CommandRegistry5parseI15CommandSelectorI5ActorEEEbPvRKNS_10ParseTokenERK13CommandOriginiRSsRSt6vectorISsSaISsEE 25 | static Parser parser; 26 | }; 27 | 28 | struct CommandPlayerSelector : CommandSelectorBase { 29 | CommandPlayerSelector() 30 | : CommandSelectorBase(true) {} 31 | /// @symbol _ZZ7type_idI15CommandRegistry15CommandSelectorI6PlayerEE8typeid_tIT_EvE2id 32 | static typeid_t *tid; 33 | /// @symbol _ZNK15CommandRegistry5parseI15CommandSelectorI6PlayerEEEbPvRKNS_10ParseTokenERK13CommandOriginiRSsRSt6vectorISsSaISsEE 34 | static Parser parser; 35 | }; 36 | 37 | template struct CommandSelector; 38 | 39 | template <> struct CommandSelector : CommandActorSelector {}; 40 | template <> struct CommandSelector : CommandPlayerSelector {}; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class Common { 6 | 7 | public: 8 | static mcpe::string getGameVersionStringNet(); 9 | static mcpe::string getGameDevVersionString(); 10 | 11 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ContentIdentity.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UUID.h" 4 | 5 | struct ContentIdentity { 6 | mce::UUID uuid; 7 | bool b = false; 8 | 9 | static ContentIdentity* EMPTY; 10 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Crypto.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UUID.h" 4 | 5 | namespace Crypto { 6 | 7 | namespace Random { 8 | 9 | mce::UUID generateUUID(); 10 | 11 | } 12 | 13 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/EventResult.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class EventResult : char {}; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ExtendedCertificate.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class Certificate; 6 | 7 | struct ExtendedCertificate { 8 | static mcpe::string getXuid(Certificate const&); 9 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ExternalFileLevelStorageSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "std/string.h" 5 | #include "SaveTransactionManager.h" 6 | #include "ContentIdentity.h" 7 | class FilePathManager; 8 | class Scheduler; 9 | class IContentKeyProvider; 10 | 11 | class LevelStorage { 12 | public: 13 | virtual ~LevelStorage() = 0; 14 | }; 15 | 16 | struct ExternalFileLevelStorageSource { 17 | 18 | public: 19 | char filler[0x10]; 20 | 21 | ExternalFileLevelStorageSource(FilePathManager*, std::shared_ptr); 22 | 23 | /// @symbol _ZN30ExternalFileLevelStorageSource18createLevelStorageER9SchedulerRKSsRK15ContentIdentityRK19IContentKeyProvider 24 | std::unique_ptr createLevelStorage(Scheduler&, mcpe::string const&, ContentIdentity const&, IContentKeyProvider const&); 25 | 26 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/FilePathManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class FilePathManager { 6 | 7 | public: 8 | 9 | char filler[0x20]; 10 | 11 | FilePathManager(mcpe::string, bool); 12 | 13 | mcpe::string getRootPath() const; 14 | 15 | mcpe::string getUserDataPath() const; 16 | 17 | mcpe::string getWorldsPath() const; 18 | 19 | void setPackagePath(mcpe::string); 20 | mcpe::string getPackagePath() const; 21 | 22 | void setSettingsPath(mcpe::string); 23 | mcpe::string getSettingsPath() const; 24 | 25 | 26 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/FilePickerSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | #include 6 | 7 | struct FilePickerSettings { 8 | 9 | enum class PickerType { 10 | NONE, OPEN, SAVE 11 | }; 12 | struct FileDescription { 13 | mcpe::string ext, desc; 14 | }; 15 | 16 | char filler [0x10]; // 10 17 | std::function cancelCallback; // 20 18 | std::function pickedCallback; // 30 19 | std::vector fileDescriptions; // 3c 20 | int filler3; // 40 21 | PickerType type; // 44 22 | mcpe::string defaultFileName; // 48 23 | mcpe::string pickerTitle; // 52 24 | 25 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/GameControllerManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class GameControllerStickState; 4 | enum class GameControllerButtonState { 5 | RELEASED, PRESSED 6 | }; 7 | 8 | struct GameControllerManager { 9 | 10 | public: 11 | 12 | static GameControllerManager* sGamePadManager; 13 | 14 | void setGameControllerConnected(int, bool); 15 | 16 | void feedButton(int, int, GameControllerButtonState, bool); 17 | 18 | void feedStick(int, int, GameControllerStickState, float, float); 19 | 20 | void feedTrigger(int, int, float); 21 | 22 | void feedJoinGame(int, bool); 23 | 24 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/GameMode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fix.h" 4 | #include "Player.h" 5 | #include "types.h" 6 | 7 | struct GameMode { 8 | /// @symbol _ZTV8GameMode 9 | static XPointer vtable; 10 | Player *player; 11 | char filler[0x100]; 12 | 13 | virtual ~GameMode(); 14 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/I18n.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "std/string.h" 5 | 6 | class ResourcePackManager; 7 | 8 | enum class ResourceLoadType; 9 | 10 | class ResourceLoadManager{ 11 | char filler[0x36]; 12 | public: 13 | ResourceLoadManager(); 14 | void sync(ResourceLoadType); 15 | }; 16 | 17 | class I18n { 18 | 19 | public: 20 | static mcpe::string get(mcpe::string const&, std::vector const&); 21 | static void chooseLanguage(mcpe::string const&); 22 | static void loadLanguages(ResourcePackManager&, ResourceLoadManager&, mcpe::string const&); 23 | 24 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/IMinecraftApp.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Minecraft; 4 | 5 | namespace Automation { 6 | class AutomationClient; 7 | } 8 | 9 | class IMinecraftApp { 10 | 11 | public: 12 | 13 | virtual ~IMinecraftApp() { } 14 | virtual Minecraft* getPrimaryMinecraft() = 0; 15 | virtual Automation::AutomationClient* getAutomationClient() = 0; 16 | virtual bool isEduMode() = 0; 17 | virtual bool isDedicatedServer() = 0; 18 | virtual int getDefaultNetworkMaxPlayers() = 0; 19 | virtual void onNetworkMaxPlayersChanged(unsigned int) = 0; 20 | 21 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ImagePickingCallback.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class ImagePickingCallback { 6 | 7 | public: 8 | virtual ~ImagePickingCallback() = 0; 9 | virtual void onImagePickingSuccess(const mcpe::string&) = 0; 10 | virtual void onImagePickingCanceled() = 0; 11 | 12 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ItemInstance.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | #include 6 | #include 7 | 8 | struct Enchant { 9 | static std::vector> *mEnchants; 10 | void **vtable; 11 | mcpe::string &getDescriptionId() const; 12 | 13 | /// @vtable Enchant _ZNK7Enchant11getMaxLevelEv 14 | int getMaxLevel(); 15 | }; 16 | 17 | struct EnchantmentInstance { 18 | uint type; 19 | int level; 20 | }; 21 | 22 | struct ItemEnchants { 23 | char filler[0x28]; 24 | 25 | std::vector getEnchants(int slot) const; 26 | }; 27 | 28 | struct ItemInstance { 29 | char filler[0x100]; 30 | 31 | bool isNull() const; 32 | int getId() const; 33 | mcpe::string getName() const; 34 | mcpe::string getRawNameId() const; 35 | mcpe::string getCustomName() const; 36 | 37 | ItemEnchants getEnchantsFromUserData() const; 38 | }; 39 | 40 | struct ItemStack { 41 | char filler[0x100]; 42 | 43 | bool isNull() const; 44 | int getId() const; 45 | mcpe::string getName() const; 46 | mcpe::string getRawNameId() const; 47 | mcpe::string getCustomName() const; 48 | 49 | ItemEnchants getEnchantsFromUserData() const; 50 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Keyboard.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | 6 | class Keyboard { 7 | 8 | public: 9 | 10 | static void feed(unsigned char, int); 11 | static void feedText(mcpe::string const&, bool, unsigned char); 12 | 13 | static int* _states; 14 | static std::vector* _inputCaretLocation; 15 | 16 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/LevelSettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class LevelSettings { 6 | 7 | public: 8 | int seed; // 4 9 | int gametype; // 8 10 | int difficulty; // c 11 | bool forceGameType; // 10 12 | int generator; // 14 13 | bool achievementsDisabled; // 18 14 | int dimension; // 1c 15 | int time; // 20 16 | bool edu, eduFeatures, immutableWorld; // 21, 22, 23 17 | float rainLevel, lightningLevel; // 28, 2c 18 | bool xblBroadcastIntent, mpGame, lanBroadcast, xblBroadcast; // 2d, 2e, 2f, 2e 19 | int xblLanBroadcastMode; // 34 20 | int platformBroadcastIntent; // 38 21 | bool commandsEnabled; // 39 22 | bool texturepacksRequired; // 3A 23 | bool hasLockedBehaviorPack; // 3B 24 | bool hasLockedResourcePack; // 3C 25 | bool fromLockedTemplate; // 3D 26 | bool msaGamertagsOnly; // 3E 27 | bool overrideSavedSettings; // 3F 28 | bool bonusChestEnabled, startWithMap; // 40, 41 29 | unsigned serverChunkTickRange; // 48 30 | bool experimentalGameplay; // 4C 31 | char filler[0x94 - 0x4C]; 32 | int defaultSpawnX, defaultSpawnY, defaultSpawnZ; 33 | char filler2[0x300]; 34 | 35 | LevelSettings(); 36 | LevelSettings(LevelSettings const &org); 37 | 38 | ~LevelSettings(); 39 | 40 | static int parseSeedString(mcpe::string const &, unsigned int); 41 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/MessagingCommand.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CommandOrigin; 4 | class CommandOutput; 5 | 6 | class MessagingCommand { 7 | char fill[20]; 8 | public: 9 | bool checkChatPermissions(CommandOrigin const &, CommandOutput &) const; 10 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Minecraft.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class MinecraftCommands; 4 | class Level; 5 | 6 | class Minecraft { 7 | 8 | public: 9 | 10 | MinecraftCommands* getCommands(); 11 | Level *getLevel() const; 12 | void activateWhitelist(); 13 | 14 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/MinecraftCommands.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "std/string.h" 5 | 6 | class CommandOrigin; 7 | class CommandOutputSender; 8 | class CommandRegistry; 9 | 10 | enum class MCCATEGORY : unsigned char { 11 | // 12 | }; 13 | 14 | struct MCRESULT { 15 | bool success; 16 | MCCATEGORY category; 17 | unsigned short code; 18 | }; 19 | 20 | class MinecraftCommands { 21 | 22 | public: 23 | 24 | void setOutputSender(std::unique_ptr sender); 25 | 26 | MCRESULT requestCommandExecution(std::unique_ptr o, mcpe::string const& s, int i, bool b) const; 27 | 28 | CommandRegistry &getRegistry(); 29 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/MinecraftEventing.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | class IPackTelemetry {}; 6 | 7 | class IMinecraftEventing : public IPackTelemetry { 8 | public: 9 | }; 10 | 11 | class MinecraftEventing : public IMinecraftEventing { 12 | 13 | public: 14 | 15 | char filler[0x100]; 16 | 17 | MinecraftEventing(mcpe::string const& str); 18 | 19 | void init(); 20 | 21 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/MinecraftGame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "std/function.h" 5 | #include "App.h" 6 | 7 | class Options; 8 | class ClientInstance; 9 | 10 | class MinecraftGame : public App { 11 | 12 | public: 13 | 14 | char filler [0x4000]; 15 | 16 | MinecraftGame(int carg, char** args); 17 | 18 | ~MinecraftGame(); 19 | 20 | bool isInGame() const; 21 | 22 | void requestLeaveGame(bool, bool); 23 | 24 | void update(); 25 | 26 | void setRenderingSize(int, int); 27 | 28 | void setUISizeAndScale(int, int, float); 29 | 30 | std::shared_ptr getPrimaryUserOptions(); 31 | 32 | ClientInstance* getPrimaryClientInstance(); 33 | 34 | void startLeaveGame(); 35 | 36 | void continueLeaveGame(); 37 | 38 | void setTextboxText(mcpe::string const&, int); 39 | 40 | }; 41 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ModalForm.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "std/string.h" 5 | 6 | struct ModalFormRequestPacket : Packet { 7 | /// @symbol _ZTV22ModalFormRequestPacket 8 | static void *myVtable; 9 | unsigned request_id; 10 | mcpe::string content; 11 | 12 | ModalFormRequestPacket(unsigned request_id, mcpe::string content) 13 | : request_id(request_id) 14 | , content(content) { 15 | vtable = (void **)myVtable + 2; 16 | unk4 = 2; 17 | unk2 = 1; 18 | subId = 0; 19 | } 20 | }; 21 | 22 | struct ModalFormResponsePacket : Packet { 23 | /// @symbol _ZTV23ModalFormResponsePacket 24 | static void *myVtable; 25 | unsigned request_id; 26 | mcpe::string content; 27 | 28 | ModalFormResponsePacket(unsigned request_id, mcpe::string content) 29 | : request_id(request_id) 30 | , content(content) { 31 | vtable = (void **)myVtable + 2; 32 | unk4 = 2; 33 | unk2 = 1; 34 | subId = 0; 35 | } 36 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Mouse.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Mouse { 4 | 5 | public: 6 | static void feed(char button, char type, short x, short y, short dx, short dy); 7 | 8 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/MultiplayerService.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Social { 6 | 7 | struct MultiplayerService { 8 | char filler[0x134]; 9 | }; 10 | 11 | struct MultiplayerXBL : public MultiplayerService, public std::enable_shared_from_this { 12 | 13 | char filler[0x200]; 14 | 15 | MultiplayerXBL(); 16 | 17 | }; 18 | 19 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Multitouch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Multitouch { 4 | 5 | public: 6 | static void feed(char, char, short, short, int); 7 | 8 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/NetworkIdentifier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | struct NetworkIdentifier { 7 | char filler[144]; 8 | int getHash() const; 9 | bool equalsTypeData(NetworkIdentifier const &) const; 10 | inline bool operator==(NetworkIdentifier const &addr) const { return equalsTypeData(addr); } 11 | }; 12 | 13 | namespace std { 14 | template <> struct hash { 15 | std::size_t operator()(NetworkIdentifier const &s) const noexcept { return s.getHash(); } 16 | }; 17 | } // namespace std 18 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Options.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class Options { 4 | 5 | public: 6 | bool getFullscreen() const; 7 | void setFullscreen(bool b); 8 | 9 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Packet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fix.h" 4 | 5 | struct Packet { 6 | /// @symbol _ZTV6Packet 7 | static XPointer myVtable; 8 | /// @symbol _ZTV29ServerToClientHandshakePacket 9 | static XPointer vt_serverToClientHandshake; 10 | void **vtable; // 0 11 | int unk4, unk2; // 4, 8 12 | unsigned char subId; // 12 13 | void *handleChunk; // 16 14 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/PermissionsFile.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | struct PermissionsFile { 6 | 7 | char filler[0x20]; 8 | 9 | PermissionsFile(mcpe::string const &); 10 | 11 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Player.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Actor.h" 4 | #include "std/string.h" 5 | #include 6 | 7 | class Certificate; 8 | 9 | class Packet; 10 | 11 | struct ItemInstance; 12 | 13 | class Player : public Actor { 14 | public: 15 | explicit Player(Player const &) = delete; 16 | 17 | mcpe::string *getPlatformOnlineId() const; 18 | 19 | Certificate *getCertificate() const; 20 | 21 | /// @symbol _ZNK5Actor10isCreativeEv 22 | bool isCreative(); 23 | 24 | float getLevelProgress() const; 25 | 26 | /// @symbol _ZNK12ServerPlayer17sendNetworkPacketER6Packet 27 | void sendNetworkPacket(Packet &) const; 28 | 29 | bool canUseAbility(mcpe::string const &); 30 | 31 | unsigned char getCommandPermissionLevel() const; 32 | 33 | BlockPos getSpawnPosition(); 34 | 35 | ItemInstance &getSelectedItem() const; 36 | 37 | int getSleepTimer() const; 38 | 39 | float getLuck(); 40 | 41 | int getAttackDamage(); 42 | 43 | Actor *getAgent() const; 44 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Resource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Resource.h" 5 | 6 | enum class ResourceFileSystem; 7 | 8 | class ResourceLoader { 9 | }; 10 | 11 | class ResourceLoaders { 12 | 13 | public: 14 | static void registerLoader(ResourceFileSystem, std::unique_ptr); 15 | 16 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ResourcePack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | #include 6 | #include "Resource.h" 7 | #include "UUID.h" 8 | class IMinecraftEventing; 9 | class IPackTelemetry; 10 | class FilePathManager; 11 | class Options; 12 | class ResourcePack; 13 | class ResourcePackStack; 14 | enum class ResourcePackStackType; 15 | 16 | class IContentAccessibilityProvider { 17 | // 18 | }; 19 | class IContentKeyProvider { 20 | // 21 | }; 22 | 23 | class SkinPackKeyProvider : public IContentAccessibilityProvider, public IContentKeyProvider { 24 | 25 | public: 26 | 27 | int filler; 28 | 29 | SkinPackKeyProvider(); 30 | 31 | 32 | }; 33 | 34 | class PackManifestFactory { 35 | 36 | public: 37 | 38 | char filler[4]; 39 | 40 | PackManifestFactory(IPackTelemetry&); 41 | 42 | }; 43 | 44 | class PackSourceFactory { 45 | 46 | public: 47 | 48 | char filler[0x100]; 49 | 50 | PackSourceFactory(Options*); 51 | 52 | }; 53 | 54 | class ResourcePackRepository { 55 | 56 | public: 57 | 58 | char filler[0x2C]; 59 | ResourcePack* vanillaPack; 60 | char filler2[0x100]; 61 | 62 | ResourcePackRepository(IMinecraftEventing&, PackManifestFactory&, IContentAccessibilityProvider&, FilePathManager*, PackSourceFactory&, bool); 63 | 64 | void addWorldResourcePacks(mcpe::string const&); 65 | 66 | void refreshPacks(); 67 | 68 | }; 69 | 70 | struct ContentTierManager { 71 | 72 | public: 73 | 74 | int filler; 75 | 76 | ContentTierManager(); 77 | 78 | }; 79 | 80 | class ResourcePackManager : public ResourceLoader { 81 | 82 | public: 83 | 84 | char filler[0x100]; 85 | 86 | /// @symbol _ZN19ResourcePackManagerC2ESt8functionIFSsvEERK18ContentTierManagerb 87 | ResourcePackManager(std::function const&, ContentTierManager const&, bool); 88 | 89 | void setExperimental(bool); 90 | 91 | void setStack(std::unique_ptr, ResourcePackStackType, bool); 92 | 93 | void onLanguageChanged(); 94 | 95 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ResourcePackStack.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "fix.h" 5 | 6 | class ResourcePack; 7 | class ResourcePackRepository; 8 | class PackSettings; 9 | 10 | struct PackInstance { 11 | 12 | char filler[0x6C]; 13 | 14 | PackInstance(ResourcePack*, int, bool, PackSettings*); 15 | 16 | }; 17 | 18 | struct ResourcePackStack { 19 | 20 | /// @symbol _ZTV17ResourcePackStack 21 | static XPointer vtable_sym; 22 | 23 | void** vtable; 24 | char filler[0x10]; 25 | 26 | ResourcePackStack() { 27 | vtable = vtable_sym + 2; 28 | memset(filler, 0, sizeof(filler)); 29 | } 30 | 31 | /// @symbol _ZN17ResourcePackStack3addE12PackInstanceRK22ResourcePackRepositoryb 32 | void add(PackInstance const& i, ResourcePackRepository const& r, bool b); 33 | 34 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/SaveTransactionManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class SaveTransactionManager { 6 | 7 | public: 8 | char filler[0x10]; 9 | 10 | /// @symbol _ZN22SaveTransactionManagerC2ESt8functionIFvbEE 11 | SaveTransactionManager(std::function); 12 | 13 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Scheduler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct Scheduler { 6 | 7 | public: 8 | /// @symbol _ZN9Scheduler17processCoroutinesENSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEE 9 | void processCoroutines(std::chrono::duration); 10 | 11 | 12 | }; 13 | 14 | struct MinecraftScheduler { 15 | 16 | static Scheduler* client(); 17 | 18 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ServerCommandOrigin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "CommandOrigin.h" 4 | #include "Level.h" 5 | #include "UUID.h" 6 | #include "std/string.h" 7 | #include 8 | 9 | class Minecraft; 10 | using ServerLevel = Level; 11 | 12 | class ServerCommandOrigin : public CommandOrigin { 13 | 14 | public: 15 | ServerLevel *mc; 16 | mcpe::string name; 17 | 18 | ServerCommandOrigin(mcpe::string const &s, ServerLevel &level); 19 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/ServerNetworkHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "NetworkIdentifier.h" 4 | #include "UUID.h" 5 | 6 | #include 7 | 8 | struct NetworkStats { 9 | int32_t filler, ping, avgping, maxbps; 10 | float packetloss, avgpacketloss; 11 | }; 12 | 13 | struct NetworkPeer { 14 | void **vtable; 15 | 16 | /// @vtable LocalNetworkPeer _ZN16LocalNetworkPeer16getNetworkStatusEv 17 | NetworkStats getNetworkStatus(); 18 | }; 19 | 20 | struct ClientToServerHandshakePacket; 21 | 22 | class ServerNetworkHandler { 23 | public: 24 | /// @symbol _ZN20ServerNetworkHandler14addToBlacklistERKN3mce4UUIDERKSs 25 | void addToBlacklist(mce::UUID const &uuid, mcpe::string const &xuid); 26 | /// @symbol _ZN20ServerNetworkHandler14addToBlacklistERKN3mce4UUIDERKSsS5_RKN9Blacklist8DurationE 27 | void addToBlacklist(mce::UUID const &uuid, mcpe::string const &xuid, mcpe::string const &reason, int const &duration); 28 | /// @symbol _ZN20ServerNetworkHandler19removeFromBlacklistERKN3mce4UUIDERKSs 29 | void removeFromBlacklist(mce::UUID const &uuid, mcpe::string const &xuid); 30 | 31 | void disconnectClient(NetworkIdentifier const &id, std::string const &reason, bool flag); 32 | 33 | /// @symbol _ZN14NetworkHandler14getPeerForUserERK17NetworkIdentifier 34 | NetworkPeer *getPeerForUser(NetworkIdentifier const &); 35 | 36 | void handle(NetworkIdentifier const &, ClientToServerHandshakePacket const &); 37 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/SharedConstants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class SharedConstants { 4 | 5 | public: 6 | static int* MajorVersion; 7 | static int* MinorVersion; 8 | static int* PatchVersion; 9 | static int* RevisionVersion; 10 | 11 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/TextPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "std/string.h" 5 | #include 6 | 7 | enum struct TextPacketType : unsigned char { 8 | 9 | }; 10 | 11 | struct TextPacket : Packet { 12 | TextPacketType type; // 16 13 | mcpe::string name, message; // 20, 24 14 | std::vector vec; // 32 15 | bool translated; // 40 16 | mcpe::string xuid, unk48; // 44, 48 17 | 18 | /// @symbol _ZN10TextPacketC2E14TextPacketTypeRKSsS2_RKSt6vectorISsSaISsEEbS2_S2_ 19 | TextPacket(TextPacketType, mcpe::string const &, mcpe::string const &, std::vector const &, bool, mcpe::string const &, 20 | mcpe::string const &); 21 | 22 | /// @symbol _ZN10TextPacket9createRawERKSs 23 | static TextPacket createRaw(mcpe::string const &); 24 | /// @symbol _ZN10TextPacket18createJukeboxPopupERKSs 25 | static TextPacket createJukeboxPopup(mcpe::string const &); 26 | /// @symbol _ZN10TextPacket19createSystemMessageERKSs 27 | static TextPacket createSystemMessage(mcpe::string const &); 28 | /// @symbol _ZN10TextPacket10createChatERKSsS1_S1_S1_ 29 | static TextPacket createChat(mcpe::string const &, mcpe::string const &, mcpe::string const &, mcpe::string const &); 30 | /// @symbol _ZN10TextPacket20createTranslatedChatERKSsS1_S1_S1_ 31 | static TextPacket createTranslatedChat(mcpe::string const &, mcpe::string const &, mcpe::string const &, mcpe::string const &); 32 | /// @symbol _ZN10TextPacket28createTranslatedAnnouncementERKSsS1_S1_S1_ 33 | static TextPacket createTranslatedAnnouncement(mcpe::string const &, mcpe::string const &, mcpe::string const &, mcpe::string const &); 34 | /// @symbol _ZN10TextPacket13createWhisperERKSsS1_S1_S1_ 35 | static TextPacket createWhisper(mcpe::string const &, mcpe::string const &, mcpe::string const &, mcpe::string const &); 36 | /// @symbol _ZN10TextPacket16createTranslatedERKSsRKSt6vectorISsSaISsEE 37 | static TextPacket createTranslated(mcpe::string const &, std::vector const &); 38 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/TransferPacket.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "std/string.h" 5 | 6 | struct TransferPacket : Packet { 7 | /// @symbol _ZTV14TransferPacket 8 | static void *myVtable; 9 | mcpe::string host; 10 | short port; 11 | TransferPacket(mcpe::string host, short port) 12 | : host(host) 13 | , port(port) { 14 | vtable = (void **)myVtable + 2; 15 | unk4 = 2; 16 | unk2 = 1; 17 | subId = 0; 18 | } 19 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/UUID.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | namespace mce { 6 | 7 | class UUID { 8 | 9 | public: 10 | static mce::UUID *EMPTY; 11 | static mce::UUID fromString(mcpe::string const &); 12 | uint64_t high, low; 13 | mcpe::string asString() const; 14 | bool isEmpty() const; 15 | inline bool operator==(mce::UUID const &rhs) { return high == rhs.high && low == rhs.low; } 16 | }; 17 | 18 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/UserManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace Social { 6 | class UserManager { 7 | 8 | public: 9 | 10 | static std::unique_ptr CreateUserManager(); 11 | 12 | 13 | }; 14 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/Whitelist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "UUID.h" 4 | #include "json.h" 5 | #include "std/string.h" 6 | #include "std/function.h" 7 | #include 8 | 9 | struct WhitelistEntry { 10 | char filler[0x20]; 11 | 12 | /// @symbol _ZN14WhitelistEntryC2ESsN3mce4UUIDESsb 13 | WhitelistEntry(mcpe::string name, mce::UUID uuid, mcpe::string xuid, bool ignoresPlayerLimit); 14 | }; 15 | 16 | struct Whitelist { 17 | char filler[0x100]; 18 | 19 | /// @symbol _ZN9WhitelistC2ESt8functionIFvvEE 20 | Whitelist(mcpe::function fn); 21 | 22 | /// @symbol _ZN9WhitelistD2Ev 23 | ~Whitelist(); 24 | 25 | /// @symbol _ZN9Whitelist11deserializeERN4Json5ValueE 26 | void deserialize(Json::Value &); 27 | /// @symbol _ZN9Whitelist9serializeERN4Json5ValueE 28 | void serialize(Json::Value &); 29 | void removeByName(mcpe::string const&); 30 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/fix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct XPointer { 6 | void *ptr; 7 | 8 | template constexpr operator T() const { 9 | union CVT { 10 | T target; 11 | void *source; 12 | CVT(void *source) 13 | : source(source) {} 14 | } cvt{ ptr }; 15 | return cvt.target; 16 | } 17 | 18 | template constexpr bool operator==(T const &rhs) { 19 | union { 20 | T source; 21 | void *target; 22 | } cvt; 23 | cvt.source = rhs; 24 | return cvt.target == ptr; 25 | } 26 | 27 | constexpr bool operator==(std::nullptr_t nptr) { return ptr == nullptr; } 28 | 29 | constexpr bool operator==(void *rhs) { return ptr == rhs; } 30 | 31 | constexpr void **operator+(std::intptr_t off) { return ((void **)*this) + off; } 32 | 33 | constexpr void *&operator[](std::intptr_t off) { return ((void **)*this)[off]; } 34 | }; -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/gl.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | 5 | struct gl { 6 | static mcpe::string getOpenGLVendor(); 7 | static mcpe::string getOpenGLRenderer(); 8 | static mcpe::string getOpenGLVersion(); 9 | static mcpe::string getOpenGLExtensions(); 10 | }; 11 | 12 | namespace mce { 13 | 14 | namespace Platform { 15 | 16 | struct OGL { 17 | 18 | static void InitBindings(); 19 | 20 | }; 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/json.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "std/string.h" 4 | #include 5 | 6 | namespace Json { 7 | 8 | struct Value; 9 | 10 | struct Reader { 11 | char filler[0x100]; 12 | 13 | Reader(); 14 | 15 | /// @symbol _ZN4Json6Reader5parseERSiRNS_5ValueEb 16 | bool parse(std::istream &is, Json::Value &root, bool collectComments); 17 | }; 18 | 19 | struct StyledWriter { 20 | char filler[0x100]; 21 | StyledWriter(); 22 | ~StyledWriter(); 23 | 24 | /// @symbol _ZN4Json12StyledWriter5writeERKNS_5ValueE 25 | mcpe::string write(Json::Value const &root); 26 | }; 27 | 28 | struct FastWriter { 29 | char filler[0x100]; 30 | FastWriter(); 31 | ~FastWriter(); 32 | 33 | /// @symbol _ZN4Json10FastWriter5writeERKNS_5ValueE 34 | mcpe::string write(Json::Value const &root); 35 | }; 36 | 37 | enum ValueType { 38 | nullValue = 0, ///< 'null' value 39 | intValue, ///< signed integer value 40 | uintValue, ///< unsigned integer value 41 | realValue, ///< double value 42 | stringValue, ///< UTF-8 string value 43 | booleanValue, ///< bool value 44 | arrayValue, ///< array value (ordered list) 45 | objectValue ///< object value (collection of name/value pairs). 46 | }; 47 | 48 | struct Value { 49 | char filler[0x10]; 50 | 51 | /// @symbol _ZN4Json5ValueC2ENS_9ValueTypeE 52 | Value(Json::ValueType type = nullValue); 53 | 54 | /// @symbol _ZN4Json5ValueD2Ev 55 | ~Value(); 56 | }; 57 | 58 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/legacy/App.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Legacy { 4 | 5 | namespace Pre_1_8 { 6 | 7 | class App { 8 | 9 | public: 10 | void** vtable; 11 | 12 | /* Pre 1.8 */ 13 | /// @vtable App _ZN3App4quitEv 14 | void quit(); 15 | 16 | }; 17 | 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/legacy/AppPlatform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../std/string.h" 4 | 5 | namespace Legacy { 6 | 7 | namespace Pre_1_2_10 { 8 | 9 | class AppPlatform { 10 | 11 | public: 12 | /* Pre 1.2.10 */ 13 | /// @symbol _ZN11AppPlatform12showKeyboardERKSsibbbRK4Vec2 14 | void showKeyboard(mcpe::string const&, int, bool, bool, bool, Vec2 const&); 15 | 16 | 17 | }; 18 | 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/legacy/MinecraftGame.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../std/string.h" 4 | 5 | namespace Legacy { 6 | 7 | namespace Pre_1_2_10 { 8 | 9 | class MinecraftGame { 10 | 11 | public: 12 | /* Pre 1.2.10 */ 13 | /// @symbol _ZN13MinecraftGame14setTextboxTextERKSs 14 | void setTextboxText(mcpe::string const&); 15 | 16 | }; 17 | 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/legacy/Xbox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "../std/string.h" 6 | 7 | namespace Legacy { 8 | 9 | namespace Beta_1_8 { 10 | 11 | namespace xbox { 12 | namespace services { 13 | 14 | struct local_config { 15 | 16 | void** vtable; 17 | 18 | /// @vtable xbox::services::local_config _ZN4xbox8services12local_config28get_value_from_local_storageERKSsS3_S3_ 19 | mcpe::string get_value_from_local_storage(mcpe::string const& value, mcpe::string const& u1 = mcpe::string(), mcpe::string const& u2 = mcpe::string()); 20 | 21 | }; 22 | 23 | } 24 | } 25 | 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/std/string.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef __APPLE__ 4 | #include "string_darwin.h" 5 | #else 6 | #include "string_linux.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/std/string_darwin.cpp: -------------------------------------------------------------------------------- 1 | #include "string.h" 2 | #include 3 | 4 | mcpe::string* mcpe::string::empty; 5 | 6 | mcpe::string::_Rep* mcpe::string::createRep(const char* data, size_t length, size_t capacity) { 7 | if (capacity < length) 8 | capacity = length; 9 | _Rep* rp = (_Rep*) malloc(sizeof(mcpe::string::_Rep) + capacity + 1); 10 | rp->length = length; 11 | rp->capacity = capacity; 12 | rp->refcount = -1; 13 | char* rp_data = (char*) (rp + 1); 14 | memcpy((void*) rp_data, data, length); 15 | rp_data[length] = '\0'; 16 | return rp; 17 | } 18 | 19 | mcpe::string::string() { 20 | ptr = empty->ptr; 21 | } 22 | mcpe::string::string(const char *str, size_t len) { 23 | if (len == 0) { 24 | ptr = empty->ptr; 25 | } else { 26 | initRep(createRep(str, len)); 27 | } 28 | } 29 | mcpe::string::string(const string &str) { 30 | if (str.ptr == empty->ptr) { 31 | ptr = empty->ptr; 32 | } else { 33 | initRep(str.getRep()); 34 | } 35 | } 36 | mcpe::string::~string() { 37 | if (ptr == empty->ptr) 38 | return; 39 | getRep()->removeRef(); 40 | } 41 | 42 | size_t mcpe::string::length() const { 43 | if (ptr == empty->ptr) 44 | return 0; 45 | return getRep()->length; 46 | } 47 | 48 | mcpe::string& mcpe::string::operator=(const mcpe::string &str) { 49 | assignRep(str.getRep()); 50 | return *this; 51 | } 52 | 53 | const char *mcpe::string::c_str() const { 54 | return (char*) ptr; 55 | } 56 | 57 | std::ostream& operator<< (std::ostream& os, const mcpe::string& obj) { 58 | os << obj.std(); 59 | return os; 60 | } 61 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/std/string_darwin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace mcpe { 8 | 9 | struct string { 10 | 11 | private: 12 | struct _Rep { 13 | size_t length; 14 | size_t capacity; 15 | std::atomic refcount; 16 | 17 | void addRef() { 18 | refcount++; 19 | } 20 | void removeRef() { 21 | if (refcount.fetch_sub(1) == 0) 22 | delete this; 23 | } 24 | }; 25 | 26 | void* ptr; 27 | 28 | static _Rep* createRep(const char* data, size_t length, size_t capacity = 0); 29 | 30 | _Rep* getRep() const { 31 | return (_Rep*) ptr - 1; 32 | } 33 | 34 | void initRep(_Rep* rep) { 35 | rep->addRef(); 36 | ptr = (void*) (rep + 1); 37 | } 38 | 39 | void assignRep(_Rep* rep) { 40 | if (rep != empty->getRep()) 41 | rep->addRef(); 42 | if (ptr != empty->ptr) 43 | getRep()->removeRef(); 44 | ptr = (void*) (rep + 1); 45 | } 46 | 47 | public: 48 | static mcpe::string* empty; 49 | 50 | string(); 51 | string(const char *str, size_t len); 52 | string(const string &str); 53 | inline string(const char *str) : string(str, strlen(str)) { } 54 | inline string(const std::string &str) : string(str.c_str(), str.length()) {} 55 | ~string(); 56 | 57 | string &operator=(const string &str); 58 | 59 | size_t length() const; 60 | const char *c_str() const; 61 | 62 | //string operator+(const string &str); 63 | 64 | bool operator==(const string &s) const { 65 | if (s.ptr == ptr) 66 | return true; 67 | if (s.length() != length()) 68 | return false; 69 | return (memcmp(c_str(), s.c_str(), length()) == 0); 70 | } 71 | 72 | bool operator<(const string& s) const { 73 | int d = memcmp(c_str(), s.c_str(), std::min(length(), s.length())); 74 | if (d < 0) return true; 75 | if (d == 0) return length() < s.length(); 76 | return false; 77 | } 78 | 79 | inline std::string std() const { 80 | return std::string(c_str(), length()); 81 | } 82 | 83 | }; 84 | 85 | } 86 | 87 | std::ostream& operator<<(std::ostream&, const mcpe::string&); 88 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/std/string_linux.cpp: -------------------------------------------------------------------------------- 1 | #define _GLIBCXX_USE_CXX11_ABI 0 2 | #include "string.h" 3 | 4 | mcpe::string* mcpe::string::empty; 5 | 6 | mcpe::string::string() { 7 | ptr = empty->ptr; 8 | } 9 | mcpe::string::string(const char *str) { 10 | if (str[0] == '\0') { 11 | ptr = empty->ptr; 12 | } else { 13 | new (this)std::string(str); 14 | } 15 | } 16 | mcpe::string::string(const char *str, size_t len) { 17 | if (len == 0) { 18 | ptr = empty->ptr; 19 | } else { 20 | new (this)std::string(str, len); 21 | } 22 | } 23 | mcpe::string::string(const string &str) { 24 | if (str.ptr == empty->ptr) { 25 | ptr = empty->ptr; 26 | } else { 27 | new (this)std::string(*((const std::string *) &str)); 28 | } 29 | } 30 | mcpe::string::~string() { 31 | if (ptr == empty->ptr) 32 | return; 33 | ((std::string*) this)->~basic_string(); 34 | } 35 | 36 | size_t mcpe::string::length() const { 37 | if (ptr == empty->ptr) 38 | return 0; 39 | return ((std::string*) this)->length(); 40 | } 41 | 42 | mcpe::string mcpe::string::operator+(const string &str) { 43 | return *((std::string*) this) + *((std::string*) &str); 44 | } 45 | 46 | mcpe::string& mcpe::string::operator=(const mcpe::string &str) { 47 | if (ptr != empty->ptr) { 48 | if (str.ptr == empty->ptr) { 49 | ((std::string*) this)->~basic_string(); 50 | new (this)std::string(*((std::string*)&str)); 51 | } else { 52 | *((std::string*) this) = *((const std::string*) &str); 53 | } 54 | } else { 55 | new (this)std::string(*((std::string*)&str)); 56 | } 57 | return *this; 58 | } 59 | 60 | const char *mcpe::string::c_str() const { 61 | if (ptr == empty->ptr) 62 | return ""; 63 | return ((std::string*) this)->c_str(); 64 | } 65 | 66 | std::ostream& operator<< (std::ostream& os, const mcpe::string& obj) { 67 | os << *((std::string const*) &obj); 68 | return os; 69 | } -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/std/string_linux.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace mcpe { 7 | 8 | struct string { 9 | 10 | private: 11 | void* ptr; 12 | 13 | public: 14 | static mcpe::string* empty; 15 | 16 | string(); 17 | string(const char *str); 18 | string(const char *str, size_t len); 19 | string(const string &str); 20 | inline string(const std::string &str) : string(str.c_str(), str.length()) {} 21 | ~string(); 22 | 23 | string &operator=(const string &str); 24 | 25 | size_t length() const; 26 | const char *c_str() const; 27 | 28 | string operator+(const string &str); 29 | 30 | bool operator==(const string &s) const { 31 | if (s.ptr == ptr) 32 | return true; 33 | if (s.length() != length()) 34 | return false; 35 | return (memcmp(c_str(), s.c_str(), length()) == 0); 36 | } 37 | 38 | bool operator<(const string& s) const { 39 | int d = memcmp(c_str(), s.c_str(), std::min(length(), s.length())); 40 | if (d < 0) return true; 41 | if (d == 0) return length() < s.length(); 42 | return false; 43 | } 44 | 45 | inline std::string std() const { 46 | return std::string(c_str(), length()); 47 | } 48 | 49 | }; 50 | 51 | } 52 | 53 | std::ostream& operator<<(std::ostream&, const mcpe::string&); 54 | -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/symbols.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void minecraft_symbols_init(void* handle); -------------------------------------------------------------------------------- /deps/minecraft-symbols/src/minecraft/types.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | using BlockPos = std::array; 6 | using Vec3 = std::array; 7 | using Vec2 = std::array; -------------------------------------------------------------------------------- /deps/minecraft-symbols/tools/cppheaderparser/__init__.py: -------------------------------------------------------------------------------- 1 | # CppHeaderParser package 2 | # Author: Jashua Cloutier (contact via sourceforge username:senexcanis) 3 | 4 | from .CppHeaderParser import * 5 | 6 | #__all__ = ['CppHeaderParser'] 7 | -------------------------------------------------------------------------------- /deps/properties-parser/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/minecraft-linux/properties-parser 8 | branch = master 9 | commit = 192f77636099ed1c19b98aa5e7d36ebe6b660883 10 | parent = 1017198b7ded9e8cfc71cd3ffde8a6177df0c2b3 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /deps/properties-parser/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(properties-parser LANGUAGES CXX) 4 | 5 | add_library(properties-parser INTERFACE) 6 | target_include_directories(properties-parser INTERFACE include/) -------------------------------------------------------------------------------- /deps/properties-parser/LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /deps/properties-parser/include/properties/property_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace properties { 8 | 9 | class property_list { 10 | 11 | private: 12 | struct property_def { 13 | std::function parse_value; 14 | std::function serialize_value; 15 | }; 16 | 17 | std::unordered_map prop; 18 | std::unordered_map unknown_props; 19 | 20 | public: 21 | property_list() {} 22 | 23 | void register_property(std::string name, std::function parse_value, 24 | std::function serialize_value) { 25 | this->prop.insert({name, {parse_value, serialize_value}}); 26 | } 27 | 28 | void set_property(std::string const& name, std::string const& value) { 29 | auto it = prop.find(name); 30 | if (it == prop.end()) { 31 | unknown_props[name] = value; 32 | } else { 33 | it->second.parse_value(value); 34 | } 35 | } 36 | 37 | void load(std::istream& stream) { 38 | std::string line; 39 | while (std::getline(stream, line)) { 40 | if (line.length() > 0 && line[0] == '#') 41 | continue; 42 | size_t i = line.find('='); 43 | if (i == std::string::npos) 44 | continue; 45 | set_property(line.substr(0, i), line.substr(i + 1)); 46 | } 47 | } 48 | 49 | void save(std::ostream& stream) { 50 | for (auto const& p : prop) 51 | stream << p.first << '=' << p.second.serialize_value() << '\n'; 52 | } 53 | 54 | }; 55 | 56 | } -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | redis: 4 | image: redis 5 | volumes: 6 | - ./data:/data:rw 7 | command: redis-server --port 0 --unixsocket /data/apid.socket --save "" 8 | server: 9 | image: codehz/stoneserver 10 | volumes: 11 | - ./game:/run/game:ro 12 | - ./data:/run/data:rw 13 | environment: 14 | - APID=unix:/run/data/apid.socket 15 | - STONE_DEBUG=1 16 | links: 17 | - redis 18 | ports: 19 | - "19132:19132/udp" 20 | - "19133:19133/udp" 21 | depends_on: 22 | - redis 23 | restart: always -------------------------------------------------------------------------------- /exts/sqlite3/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | Makefile 4 | cmake_install.cmake 5 | install_manifest.txt 6 | *.exe 7 | *.exp 8 | *.manifest 9 | *.lib 10 | build 11 | -------------------------------------------------------------------------------- /exts/sqlite3/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = https://github.com/alex85k/sqlite3-cmake 8 | branch = master 9 | commit = 34d366c60267322a196333ec69997d81ecb1eaa4 10 | parent = d6f84dbb5800a2bb4e97b913b48b2bb1fee1fc23 11 | method = merge 12 | cmdver = 0.4.0 13 | -------------------------------------------------------------------------------- /exts/sqlite3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | PROJECT(sqlite3) 2 | cmake_minimum_required(VERSION 3.3) 3 | 4 | include_directories(${CMAKE_SOURCE_DIR}/src) 5 | add_library(sqlite3 STATIC src/sqlite3.c src/sqlite3.h src/sqlite3ext.h) 6 | 7 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_ENABLE_RTREE) 8 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_ENABLE_FTS4) 9 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_ENABLE_FTS5) 10 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_ENABLE_JSON1) 11 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_ENABLE_RBU) 12 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_ENABLE_STAT4) 13 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_DEFAULT_FOREIGN_KEYS=1) 14 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_DEFAULT_SYNCHRONOUS=0) 15 | target_compile_definitions(sqlite3 PRIVATE -DSQLITE_THREADSAFE=0) 16 | 17 | install(FILES src/sqlite3.h src/sqlite3ext.h DESTINATION include) 18 | install(TARGETS sqlite3 LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) 19 | -------------------------------------------------------------------------------- /exts/sqlite3/README.md: -------------------------------------------------------------------------------- 1 | sqlite3-cmake 2 | ============= 3 | 4 | Simplest CMake script + full sqlite3 amalgamation distibution to build with different compilers 5 | 6 | Build examples: 7 | 8 | On Windows from Visual Studio command prompt 9 | ``` 10 | cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=d:/libs 11 | nmake install 12 | ``` 13 | 14 | On Windows from Visual Studio IDE 15 | ``` 16 | cmake -G "Visual Studio 12 Win64" -DCMAKE_INSTALL_PREFIX=d:/libs 17 | < open and build sqlite3.sln > 18 | ``` 19 | 20 | On Linux/FreeBSD without root access 21 | ``` 22 | cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/home/student/libs 23 | make install 24 | ``` -------------------------------------------------------------------------------- /exts/sqlite3/appveyor.yml: -------------------------------------------------------------------------------- 1 | environment: 2 | P: "c:/projects/libs" 3 | ACCOUNT: 4 | secure: F8Xu4syZJRRLmTnPDOUjr5bG7Lk6UburldIUuxZ/OJQ= 5 | githubtk: 6 | secure: qrVq5CxwKaOg2SohTmLQL6H6llxcxg1IJbF4r7Cx0Q7xxOsCPc49l2DzmlQIkui8 7 | 8 | # branches to build 9 | branches: 10 | # whitelist 11 | only: 12 | - master 13 | 14 | # Operating system (build VM template) 15 | os: Visual Studio 2015 16 | 17 | # scripts that are called at very beginning, before repo cloning 18 | init: 19 | - git config --global core.autocrlf input 20 | 21 | 22 | # clone directory 23 | clone_folder: c:\projects\sqlite 24 | 25 | platform: x64 26 | configuration: Release 27 | 28 | install: 29 | # by default, all script lines are interpreted as batch 30 | 31 | build: 32 | project: INSTALL.vcxproj # path to Visual Studio solution or project 33 | 34 | # scripts to run before build 35 | before_build: 36 | - echo Running cmake... 37 | - cd c:\projects\sqlite 38 | - cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=%P% 39 | 40 | # scripts to run after build 41 | after_build: 42 | - cd %P% 43 | - 7z a c:\projects\sqlite\sqlite.zip * -tzip 44 | - cd c:\projects\sqlite 45 | 46 | artifacts: 47 | - path: sqlite.zip 48 | name: sqlite.zip 49 | 50 | #@deploy_script: 51 | # - cd c:\projects\sqlite 52 | # - curl -T sqlite.zip --user %ACCOUNT% https://webdav.yandex.ru/libs/sqlite.zip 53 | 54 | deploy: 55 | release: sqlite-v$(appveyor_build_version) 56 | description: 'Automatic release by Appveyor.com' 57 | provider: GitHub 58 | auth_token: 59 | secure: qrVq5CxwKaOg2SohTmLQL6H6llxcxg1IJbF4r7Cx0Q7xxOsCPc49l2DzmlQIkui8 60 | artifact: /.*\.zip/ # upload all NuGet packages to release assets 61 | draft: false 62 | prerelease: false 63 | on: 64 | branch: master # release from master branch only 65 | appveyor_repo_tag: true # deploy on tag push only 66 | -------------------------------------------------------------------------------- /interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(interface LANGUAGES CXX) 4 | 5 | add_library(interface INTERFACE) 6 | file(GLOB src "include/interface/*") 7 | target_sources(interface INTERFACE ${src}) 8 | target_include_directories(interface INTERFACE "include" ${CMAKE_ROOT_SOURCE_DIR}/deps/minecraft-symbols/src) -------------------------------------------------------------------------------- /interface/include/interface/base_interface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "locator.hpp" 4 | 5 | #include 6 | #include 7 | 8 | namespace interface { 9 | struct BaseInterface { 10 | BaseInterface() {}; 11 | BaseInterface(BaseInterface const &) = delete; 12 | BaseInterface(BaseInterface &&) = delete; 13 | BaseInterface &operator=(BaseInterface const &) = delete; 14 | BaseInterface &operator=(BaseInterface &&) = delete; 15 | inline virtual ~BaseInterface(){}; 16 | }; 17 | 18 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/blacklist.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include "base_interface.h" 9 | #include "event_emitter.h" 10 | 11 | namespace interface { 12 | 13 | struct Blacklist : BaseInterface { 14 | virtual void add(mce::UUID const &, std::string const &) = 0; 15 | virtual void add(std::string const &, std::string const &) = 0; 16 | virtual void remove(mce::UUID const &) = 0; 17 | virtual void remove(std::string const &) = 0; 18 | virtual void kick(NetworkIdentifier const &, std::string const &) = 0; 19 | virtual void forEach(std::function const &, std::string const &)> const &fn) = 0; 20 | }; 21 | 22 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/chat.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "base_interface.h" 6 | #include "event_emitter.h" 7 | 8 | namespace interface { 9 | 10 | struct Chat : BaseInterface { 11 | bool intercept; 12 | 13 | EventEmitter onPlayerChat; 14 | EventEmitter onChat; 15 | virtual void sendChat(std::string const &, std::string const &) = 0; 16 | virtual void sendAnnouncement(std::string const &) = 0; 17 | }; 18 | 19 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/event_emitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace interface { 8 | 9 | template class EventEmitter { 10 | std::list>...)>> handlers; 11 | 12 | public: 13 | inline EventEmitter() {} 14 | EventEmitter(EventEmitter const &) = delete; 15 | EventEmitter(EventEmitter &&) = delete; 16 | 17 | EventEmitter &operator=(EventEmitter const &) = delete; 18 | EventEmitter &operator=(EventEmitter &&) = delete; 19 | 20 | void operator()(std::add_lvalue_reference_t>... params) const { 21 | for (auto handler : handlers) handler(params...); 22 | } 23 | 24 | void operator>>(std::function>...)> handler) { 25 | handlers.push_back(handler); 26 | } 27 | }; 28 | 29 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/modal_form.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "base_interface.h" 7 | #include "event_emitter.h" 8 | 9 | namespace interface { 10 | 11 | struct ModalForm : BaseInterface { 12 | EventEmitter recv; 13 | virtual void send(Player *, unsigned, std::string const &) = 0; 14 | }; 15 | 16 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/player_list.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "base_interface.h" 7 | #include "event_emitter.h" 8 | 9 | namespace interface { 10 | 11 | struct PlayerList : BaseInterface { 12 | std::set set; 13 | EventEmitter onPlayerAdded; 14 | EventEmitter onPlayerRemoved; 15 | }; 16 | 17 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/policy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "base_interface.h" 8 | #include "event_emitter.h" 9 | 10 | namespace interface { 11 | 12 | struct Policy : BaseInterface { 13 | EventEmitter checkAbility; 14 | EventEmitter checkDestroy; 15 | EventEmitter checkBuild; 16 | EventEmitter checkUse; 17 | EventEmitter checkUseOn; 18 | EventEmitter checkInteract; 19 | EventEmitter checkAttack; 20 | EventEmitter checkUseBlock; 21 | }; 22 | 23 | } // namespace interface -------------------------------------------------------------------------------- /interface/include/interface/tick.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "event_emitter.h" 4 | #include "base_interface.h" 5 | 6 | namespace interface { 7 | 8 | struct Tick : BaseInterface { 9 | float tps; 10 | 11 | EventEmitter<> tick; 12 | }; 13 | 14 | } // namespace interface -------------------------------------------------------------------------------- /lib32.txt: -------------------------------------------------------------------------------- 1 | libc.so.6 2 | libdl.so.2 3 | libgcc_s.so.1 4 | libm.so.6 5 | libnss_compat.so.2 6 | libnss_files.so.2 7 | libnss_db.so.2 8 | libnss_dns.so.2 9 | libresolv.so.2 10 | libpthread.so.0 11 | librt.so.1 -------------------------------------------------------------------------------- /logger/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 2.6) 2 | 3 | project(logger LANGUAGES CXX) 4 | 5 | add_library(logger include/log.h src/log.cpp) 6 | target_link_libraries(logger) 7 | target_include_directories(logger PUBLIC include/) -------------------------------------------------------------------------------- /logger/include/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #define LogFuncDef(name, logLevel) \ 9 | static void name(const char *tag, const char *text, ...) __attribute__((format(printf, 2, 3))) { \ 10 | va_list args; \ 11 | va_start(args, text); \ 12 | vlog(logLevel, tag, text, args); \ 13 | va_end(args); \ 14 | } 15 | 16 | enum class LogLevel { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_MAX }; 17 | 18 | class Log { 19 | static std::vector> hooks; 20 | 21 | public: 22 | static LogLevel MIN_LEVEL; 23 | static inline void addHook(std::function fn) { hooks.push_back(fn); } 24 | static inline void clearHooks() { hooks.clear(); } 25 | 26 | static inline const char *getLogLevelString(LogLevel lvl) { 27 | static char const *lvmap[] = { "Trace", "Debug", "Info ", "Warn ", "Error" }; 28 | if (lvl >= LogLevel::LOG_MAX) return "?"; 29 | return lvmap[(int)lvl]; 30 | } 31 | 32 | static void vlog(LogLevel level, const char *tag, const char *text, va_list args); 33 | 34 | static void log(LogLevel level, const char *tag, const char *text, ...) { 35 | va_list args; 36 | va_start(args, text); 37 | vlog(level, tag, text, args); 38 | va_end(args); 39 | } 40 | 41 | // clang-format off 42 | LogFuncDef(trace, LogLevel::LOG_TRACE) 43 | LogFuncDef(debug, LogLevel::LOG_DEBUG) 44 | LogFuncDef(info, LogLevel::LOG_INFO) 45 | LogFuncDef(warn, LogLevel::LOG_WARN) 46 | LogFuncDef(error, LogLevel::LOG_ERROR) 47 | // clang-format on 48 | }; 49 | 50 | #undef LogFuncDef 51 | -------------------------------------------------------------------------------- /logger/src/log.cpp: -------------------------------------------------------------------------------- 1 | #include "../include/log.h" 2 | #include 3 | #include 4 | 5 | LogLevel Log::MIN_LEVEL = LogLevel::LOG_INFO; 6 | 7 | void Log::vlog(LogLevel level, const char *tag, const char *text, va_list args) { 8 | char *buffer; 9 | vasprintf(&buffer, text, args); 10 | 11 | char tbuf[16]; 12 | tbuf[0] = '\0'; 13 | 14 | time_t t = time(nullptr); 15 | tm tm; 16 | localtime_r(&t, &tm); 17 | strftime(tbuf, sizeof(tbuf), "%H:%M:%S", &tm); 18 | 19 | for (auto hook : hooks) hook(static_cast(level), tag, buffer); 20 | 21 | if (static_cast(level) < static_cast(MIN_LEVEL)) { 22 | free(buffer); 23 | return; 24 | } 25 | 26 | printf("%s %s [%s] %s\n", tbuf, getLogLevelString(level), tag, buffer); 27 | fflush(stdout); 28 | free(buffer); 29 | } 30 | 31 | std::vector> Log::hooks; -------------------------------------------------------------------------------- /stone/src/ExtAPI/broadcastExternalEvent.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | namespace ExtAPI { 6 | using namespace interface; 7 | using namespace api; 8 | 9 | static void broadcastExternalEventCallback(FunctionCallbackInfo const &info) { 10 | auto iso = info.GetIsolate(); 11 | Isolate::Scope isos{ iso }; 12 | if (info.Length() != 2) { 13 | iso->ThrowException(Exception::TypeError(ToJS(strformat("broadcastExternalEvent requires 2 arguments(current: %d)", info.Length())))); 14 | return; 15 | } 16 | if (!info[0]->IsString() || !info[1]->IsString()) { 17 | iso->ThrowException(Exception::TypeError(ToJS("broadcastExternalEvent requires (string, string)"))); 18 | return; 19 | } 20 | auto identify = fromJS(iso, info[0]); 21 | auto content = fromJS(iso, info[1]); 22 | Locator()->broadcast << EventData{ identify, content }; 23 | } 24 | 25 | static Register reg{ "registerComponent", "broadcastExternalEvent", &broadcastExternalEventCallback }; 26 | 27 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/broadcastMessage.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | 4 | namespace ExtAPI { 5 | using namespace interface; 6 | 7 | static void broadcastMessageCallback(FunctionCallbackInfo const &info) { 8 | auto iso = info.GetIsolate(); 9 | Isolate::Scope isos{ iso }; 10 | if (info.Length() != 1) { 11 | iso->ThrowException(Exception::TypeError(ToJS(strformat("broadcastMessage requires 1 arguments(current: %d)", info.Length())))); 12 | return; 13 | } 14 | if (!info[0]->IsString()) { 15 | iso->ThrowException(Exception::TypeError(ToJS("broadcastMessage requires (string)"))); 16 | return; 17 | } 18 | auto content = fromJS(iso, info[0]); 19 | Locator()->sendAnnouncement(content); 20 | } 21 | 22 | static Register reg{ "registerComponent", "broadcastMessage", &broadcastMessageCallback }; 23 | 24 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/changeDimension.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | namespace ExtAPI { 4 | using namespace patched; 5 | 6 | static void changeDimensionCallback(FunctionCallbackInfo const &info) { 7 | auto iso = info.GetIsolate(); 8 | Isolate::Scope isos{ iso }; 9 | if (info.Length() != 2) { 10 | iso->ThrowException(Exception::TypeError(ToJS(strformat("changeDimension requires 2 arguments(current: %d)", info.Length())))); 11 | return; 12 | } 13 | if (!info[0]->IsObject() || !info[1]->IsNumber()) { 14 | iso->ThrowException(Exception::TypeError(ToJS("changeDimension requires (object, number)"))); 15 | return; 16 | } 17 | Actor *actor = fromJS(iso, info[0]); 18 | if (!actor) { 19 | iso->ThrowException(Exception::TypeError(ToJS("changeDimension requires (actor, number)"))); 20 | return; 21 | } 22 | actor->changeDimension(fromJS(iso, info[1]), false); 23 | } 24 | static Register reg{ "registerComponent", "changeDimension", &changeDimensionCallback }; 25 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/common.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | namespace ExtAPI { 4 | std::map const &)>>> Register::registry; 5 | std::set Register::injecteds; 6 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../operators.h" 7 | #include "../patched.h" 8 | #include "../v8_utils.hpp" 9 | #include "log.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace ExtAPI { 16 | using namespace v8; 17 | 18 | struct Register { 19 | static std::map>> registry; 20 | static std::set injecteds; 21 | inline Register(char const *injection_point, char const *name, v8::FunctionCallback func) { registry[injection_point].insert({ name, func }); } 22 | inline Register(char const *injection_point, char const *name, v8::FunctionCallback func, 23 | void (*injected)(Isolate *)) { 24 | registry[injection_point].insert({ name, func }); 25 | injecteds.emplace(injected); 26 | } 27 | }; 28 | 29 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/invokeCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | #include "../custom_command.h" 6 | 7 | namespace ExtAPI { 8 | using namespace interface; 9 | 10 | static void invokeCommandCallback(FunctionCallbackInfo const &info) { 11 | auto iso = info.GetIsolate(); 12 | Isolate::Scope isos{ iso }; 13 | if (info.Length() == 1) { 14 | if (!info[0]->IsString()) { 15 | iso->ThrowException(Exception::TypeError(ToJS("invokeCommand requires (string)"))); 16 | return; 17 | } 18 | if (!current_orig) { 19 | iso->ThrowException(Exception::ReferenceError(ToJS("invokeCommand need be invoked inside custom command execution context"))); 20 | return; 21 | } 22 | auto command = fromJS(iso, info[0]); 23 | auto commandOrigin = current_orig->clone(); 24 | Locator()->requestCommandExecution(std::move(commandOrigin), command, 4, true); 25 | } else if (info.Length() == 2) { 26 | if (!info[0]->IsObject() || !info[1]->IsString()) { 27 | iso->ThrowException(Exception::TypeError(ToJS("invokeCommand requires (object, string)"))); 28 | return; 29 | } 30 | auto actor = fromJS(iso, info[0]); 31 | auto command = fromJS(iso, info[1]); 32 | if (!actor || *(void **)actor != BUILD_HELPER(GetAddress, void, 0x8, "_ZTV12ServerPlayer").Address()) { 33 | iso->ThrowException(Exception::TypeError(ToJS("invokeCommand requires (player, string)"))); 34 | return; 35 | } 36 | auto origin = std::make_unique((Player &)*actor); 37 | auto result = patched::withCommandOutput([&] { Locator()->requestCommandExecution(std::move(origin), command, 4, true); }); 38 | info.GetReturnValue().Set(ToJS(result)); 39 | } else { 40 | iso->ThrowException(Exception::TypeError(ToJS(strformat("invokeCommand requires 1 or 2 arguments(current: %d)", info.Length())))); 41 | return; 42 | } 43 | } 44 | 45 | static Register reg{ "registerComponent", "invokeCommand", &invokeCommandCallback }; 46 | 47 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/invokeConsoleCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "../custom_command.h" 8 | 9 | namespace ExtAPI { 10 | using namespace interface; 11 | 12 | static void invokeConsoleCommandCallback(FunctionCallbackInfo const &info) { 13 | auto iso = info.GetIsolate(); 14 | Isolate::Scope isos{ iso }; 15 | if (info.Length() != 2) { 16 | iso->ThrowException(Exception::TypeError(ToJS(strformat("invokeConsoleCommand requires 2 arguments(current: %d)", info.Length())))); 17 | return; 18 | } 19 | if (!info[0]->IsString() || !info[1]->IsString()) { 20 | iso->ThrowException(Exception::TypeError(ToJS("invokeConsoleCommand requires (string, string)"))); 21 | return; 22 | } 23 | auto orig = fromJS(iso, info[0]); 24 | auto command = fromJS(iso, info[1]); 25 | auto result = patched::withCommandOutput([&] { 26 | auto commandOrigin = std::make_unique(orig, *Locator()); 27 | Locator()->requestCommandExecution(std::move(commandOrigin), command, 4, true); 28 | }); 29 | info.GetReturnValue().Set(ToJS(result)); 30 | } 31 | 32 | static Register reg{ "registerComponent", "invokeConsoleCommand", &invokeConsoleCommandCallback }; 33 | 34 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/invokePrivilegedCommand.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched/Flags.h" 2 | #include "common.h" 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ExtAPI { 8 | using namespace interface; 9 | 10 | static void invokePrivilegedCommandCallback(FunctionCallbackInfo const &info) { 11 | auto iso = info.GetIsolate(); 12 | Isolate::Scope isos{ iso }; 13 | if (info.Length() != 2) { 14 | iso->ThrowException(Exception::TypeError(ToJS(strformat("invokePrivilegedCommand requires 2 arguments(current: %d)", info.Length())))); 15 | return; 16 | } 17 | 18 | if (!info[0]->IsObject() || !info[1]->IsString()) { 19 | iso->ThrowException(Exception::TypeError(ToJS("invokePrivilegedCommand requires (object, string)"))); 20 | return; 21 | } 22 | auto actor = fromJS(iso, info[0]); 23 | auto command = fromJS(iso, info[1]); 24 | if (!actor || *(void **)actor != BUILD_HELPER(GetAddress, void, 0x8, "_ZTV12ServerPlayer").Address()) { 25 | iso->ThrowException(Exception::TypeError(ToJS("invokePrivilegedCommand requires (player, string)"))); 26 | return; 27 | } 28 | auto origin = std::make_unique((Player &)*actor); 29 | patched::flags::CommandPrivileged = true; 30 | auto result = patched::withCommandOutput([&] { Locator()->requestCommandExecution(std::move(origin), command, 4, true); }); 31 | patched::flags::CommandPrivileged = false; 32 | info.GetReturnValue().Set(ToJS(result)); 33 | } 34 | 35 | static Register reg{ "registerComponent", "invokePrivilegedCommand", &invokePrivilegedCommandCallback }; 36 | 37 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/log.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | namespace ExtAPI { 4 | 5 | static void logCallback(FunctionCallbackInfo const &info) { 6 | auto iso = info.GetIsolate(); 7 | std::stringstream ss; 8 | const auto max = info.Length(); 9 | for (auto i = 0;; i++) { 10 | auto current = info[i]; 11 | Local str = current->IsString() ? Local(current) : current->ToString(iso); 12 | ss << V8Str(str); 13 | if (i < max - 1) { 14 | ss << ", "; 15 | } else { 16 | break; 17 | } 18 | } 19 | Log::info("Scripting", "log: %s", ss.str().c_str()); 20 | } 21 | 22 | static Register reg{ "registerComponent", "log", &logCallback }; 23 | 24 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/muteChat.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | 4 | #include "../custom_command.h" 5 | 6 | namespace ExtAPI { 7 | using namespace interface; 8 | 9 | static void muteChatCallback(FunctionCallbackInfo const &info) { 10 | Locator()->intercept = !(info.Length() > 0 && info[0]->IsFalse()); 11 | } 12 | 13 | static Register reg{ "registerComponent", "muteChat", &muteChatCallback }; 14 | 15 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/registerSoftEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "../custom_command.h" 2 | #include "common.h" 3 | 4 | namespace ExtAPI { 5 | using namespace interface; 6 | 7 | static void registerSoftEnumCallback(FunctionCallbackInfo const &info) { 8 | auto iso = info.GetIsolate(); 9 | Isolate::Scope isos{ iso }; 10 | if (info.Length() != 2) { 11 | iso->ThrowException(Exception::TypeError(ToJS(strformat("registerSoftEnum requires 2 arguments(current: %d)", info.Length())))); 12 | return; 13 | } 14 | if (!info[0]->IsString() || !info[1]->IsArray()) { 15 | iso->ThrowException(Exception::TypeError(ToJS("registerSoftEnum requires (string, Array)"))); 16 | return; 17 | } 18 | auto name = info[0] >> V8Str; 19 | auto arr = Local(info[1]); 20 | std::vector vec; 21 | 22 | for (unsigned i = 0; i < arr->Length(); i++) { 23 | auto it = arr->Get(i); 24 | if (!it->IsString()) { 25 | iso->ThrowException(Exception::TypeError(ToJS("registerSoftEnum requires (string, string[])"))); 26 | return; 27 | } 28 | vec.push_back(it >> V8Str); 29 | } 30 | 31 | registerCustomEnum(name, vec); 32 | } 33 | 34 | static Register reg{ "registerComponent", "registerSoftEnum", ®isterSoftEnumCallback }; 35 | 36 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/serverInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "../custom_command.h" 2 | #include "common.h" 3 | #include 4 | 5 | namespace ExtAPI { 6 | using namespace interface; 7 | using namespace patched; 8 | 9 | static void severInfoCallback(FunctionCallbackInfo const &info) { 10 | auto iso = info.GetIsolate(); 11 | Isolate::Scope isos{ iso }; 12 | 13 | auto temp = Object::New(iso); 14 | auto strTPS = ToJS("tps"); 15 | temp->Set(strTPS, ToJS(Locator()->tps)); 16 | info.GetReturnValue().Set(temp); 17 | } 18 | 19 | static Register reg{ "registerComponent", "severInfo", &severInfoCallback }; 20 | 21 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/stop.cpp: -------------------------------------------------------------------------------- 1 | #include "../custom_command.h" 2 | #include "common.h" 3 | #include 4 | #include 5 | #include 6 | 7 | namespace ExtAPI { 8 | using namespace interface; 9 | using namespace patched; 10 | 11 | static void stopCallback(FunctionCallbackInfo const &info) { 12 | auto iso = info.GetIsolate(); 13 | Isolate::Scope isos{ iso }; 14 | kill(getpid(), SIGTERM); 15 | info.GetReturnValue().Set(Undefined(iso)); 16 | } 17 | 18 | static Register reg{ "registerComponent", "stop", &stopCallback }; 19 | 20 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/transferPlayer.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | #include 4 | 5 | namespace ExtAPI { 6 | using namespace interface; 7 | 8 | static void transferPlayerCallback(FunctionCallbackInfo const &info) { 9 | auto iso = info.GetIsolate(); 10 | Isolate::Scope isos{ iso }; 11 | if (info.Length() != 3) { 12 | iso->ThrowException(Exception::TypeError(ToJS(strformat("transferPlayer requires 3 arguments(current: %d)", info.Length())))); 13 | return; 14 | } 15 | if (!info[0]->IsObject() || !info[1]->IsString() || !info[2]->IsInt32()) { 16 | iso->ThrowException(Exception::TypeError(ToJS("transferPlayer requires (object, string, integer)"))); 17 | return; 18 | } 19 | Actor *actor = fromJS(iso, info[0]); 20 | if (!actor || *(void **)actor != BUILD_HELPER(GetAddress, void, 0x8, "_ZTV12ServerPlayer").Address()) { 21 | iso->ThrowException(Exception::TypeError(ToJS("transferPlayer requires (player, string, integer)"))); 22 | return; 23 | } 24 | Player *player = (Player *)actor; 25 | 26 | TransferPacket packet{ fromJS(iso, info[1]), fromJS(iso, info[2]) }; 27 | player->sendNetworkPacket(packet); 28 | } 29 | 30 | static Register reg{ "registerComponent", "transferPlayer", &transferPlayerCallback }; 31 | 32 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/updateSoftEnum.cpp: -------------------------------------------------------------------------------- 1 | #include "../custom_command.h" 2 | #include "common.h" 3 | 4 | namespace ExtAPI { 5 | using namespace interface; 6 | 7 | static void updateSoftEnumCallback(FunctionCallbackInfo const &info) { 8 | auto iso = info.GetIsolate(); 9 | Isolate::Scope isos{ iso }; 10 | if (info.Length() != 2) { 11 | iso->ThrowException(Exception::TypeError(ToJS(strformat("updateSoftEnum requires 2 arguments(current: %d)", info.Length())))); 12 | return; 13 | } 14 | if (!info[0]->IsString() || !info[1]->IsArray()) { 15 | iso->ThrowException(Exception::TypeError(ToJS("updateSoftEnum requires (string, Array)"))); 16 | return; 17 | } 18 | auto name = info[0] >> V8Str; 19 | auto arr = Local(info[1]); 20 | std::vector vec; 21 | 22 | for (unsigned i = 0; i < arr->Length(); i++) { 23 | auto it = arr->Get(i); 24 | if (!it->IsString()) { 25 | iso->ThrowException(Exception::TypeError(ToJS("updateSoftEnum requires (string, string[])"))); 26 | return; 27 | } 28 | vec.push_back(it >> V8Str); 29 | } 30 | 31 | updateCustomEnum(name, vec); 32 | } 33 | 34 | static Register reg{ "registerComponent", "updateSoftEnum", &updateSoftEnumCallback }; 35 | 36 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/ExtAPI/worldInfo.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include 3 | 4 | namespace ExtAPI { 5 | using namespace patched; 6 | 7 | static void worldInfoCallback(FunctionCallbackInfo const &info) { 8 | auto iso = info.GetIsolate(); 9 | Isolate::Scope isos{ iso }; 10 | 11 | auto temp = Object::New(iso); 12 | auto strSpawnPoint = ToJS("spawnPoint"); 13 | temp->Set(strSpawnPoint, ToJS(Locator()->getDefaultSpawn())); 14 | info.GetReturnValue().Set(temp); 15 | } 16 | 17 | static Register reg{ "registerComponent", "worldInfo", &worldInfoCallback }; 18 | 19 | } // namespace ExtAPI -------------------------------------------------------------------------------- /stone/src/GlobalAPI/checkApiLevel.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | constexpr auto API_LEVEL = 1; 4 | 5 | namespace GlobalAPI { 6 | 7 | static void check_api_level(FunctionCallbackInfo const &info) { 8 | auto iso = info.GetIsolate(); 9 | Isolate::Scope isos{ iso }; 10 | if (info.Length() != 1 or !info[0]->IsNumber()) iso->ThrowException(Exception::TypeError(ToJS("usage: checkApiLevel(level: number)"))); 11 | if (fromJS(iso, info[0]) != API_LEVEL) iso->ThrowException(Exception::TypeError(ToJS("API version mismatch"))); 12 | return; 13 | } 14 | 15 | static Register reg([](Local &obj, Isolate *iso) { 16 | auto tmp_check = FunctionTemplate::New(iso, check_api_level, 1); 17 | tmp_check->SetClassName(ToJS("SQLite3")); 18 | obj->Set(ToJS("checkApiLevel"), tmp_check); 19 | }); 20 | } // namespace GlobalAPI -------------------------------------------------------------------------------- /stone/src/GlobalAPI/common.cpp: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | 3 | namespace GlobalAPI { 4 | std::vector &, Isolate *)> Register::registry; 5 | } -------------------------------------------------------------------------------- /stone/src/GlobalAPI/common.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | #include "../operators.h" 7 | #include "../patched.h" 8 | #include "../v8_utils.hpp" 9 | #include "log.h" 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace GlobalAPI { 16 | using namespace v8; 17 | 18 | struct Register { 19 | static std::vector &, Isolate *)> registry; 20 | inline Register(void (*func)(Local &, Isolate *)) { registry.emplace_back(func); } 21 | }; 22 | 23 | } // namespace GlobalAPI -------------------------------------------------------------------------------- /stone/src/blacklist_mgr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | struct BlacklistManager { 13 | const std::string path; 14 | 15 | inline BlacklistManager(std::string const &path) 16 | : path(path) { 17 | using namespace interface; 18 | Locator() >> [this](auto &) { reload(); }; 19 | } 20 | 21 | inline void reload() { 22 | using namespace interface; 23 | using namespace nlohmann; 24 | std::ifstream ifs{ path }; 25 | if (!ifs) return; 26 | try { 27 | for (auto item : json::parse(ifs)) { 28 | auto reason = item.at("reason").get(); 29 | if (item.contains("uuid")) { 30 | Locator()->add(mce::UUID::fromString(item.at("uuid").get()), reason); 31 | } else if (item.contains("xuid")) { 32 | Locator()->add(item.at("xuid").get(), reason); 33 | } 34 | } 35 | } catch (...) { 36 | Log::error("Blacklist", "Failed to load %s", path.c_str()); 37 | return; 38 | } 39 | } 40 | 41 | inline void save() { 42 | using namespace interface; 43 | using namespace nlohmann; 44 | Log::info("Blacklist", "Saving to %s", path.c_str()); 45 | json arr = json::array(); 46 | Locator()->forEach([&](std::variant const &value, std::string reason) { 47 | json obj = json::object({ { "reason", reason } }); 48 | if (auto puuid = std::get_if(&value); puuid) 49 | obj["uuid"] = puuid->asString().std(); 50 | else if (auto pxuid = std::get_if(&value); pxuid) 51 | obj["xuid"] = *pxuid; 52 | arr.push_back(obj); 53 | }); 54 | std::ofstream ofs{ path }; 55 | ofs << arr; 56 | } 57 | 58 | inline ~BlacklistManager() { 59 | using namespace interface; 60 | if (Locator()) save(); 61 | } 62 | }; -------------------------------------------------------------------------------- /stone/src/custom_command.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | extern CommandOrigin *current_orig; 7 | 8 | void registerCustomEnum(mcpe::string name, std::vector list); 9 | void updateCustomEnum(mcpe::string name, std::vector list); -------------------------------------------------------------------------------- /stone/src/dumper.cpp: -------------------------------------------------------------------------------- 1 | #include "dumper.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | void dump_backtrace() { 9 | void *array[200]; 10 | int count = backtrace(array, 200); 11 | char **symbols = backtrace_symbols(array, count); 12 | char *nameBuf = (char *)malloc(256); 13 | size_t nameBufLen = 256; 14 | for (int i = 2; i < count; i++) { 15 | if (symbols[i] == nullptr) { 16 | printf("#%i unk [0x%04x]\n", i, (int)array[i]); 17 | continue; 18 | } 19 | if (symbols[i][0] == '[') { // unknown symbol 20 | Dl_info symInfo; 21 | if (hybris_dladdr(array[i], &symInfo)) { 22 | int status = 0; 23 | nameBuf = abi::__cxa_demangle(symInfo.dli_sname, nameBuf, &nameBufLen, &status); 24 | printf("#%i HYBRIS %s(%s)+%i in %s+0x%04x [0x%04x]\n", i, nameBuf, symInfo.dli_sname, 25 | (unsigned int)array[i] - (unsigned int)symInfo.dli_saddr, symInfo.dli_fname, (unsigned int)array[i] - (unsigned int)symInfo.dli_fbase, 26 | (int)array[i]); 27 | continue; 28 | } 29 | } 30 | printf("#%i %s\n", i, symbols[i]); 31 | } 32 | free(nameBuf); 33 | } -------------------------------------------------------------------------------- /stone/src/dumper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void dump_backtrace(); -------------------------------------------------------------------------------- /stone/src/operators.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "patched/HardcodedOffsets.h" 17 | 18 | template struct deletable_facet : Facet { 19 | template 20 | deletable_facet(Args &&... args) 21 | : Facet(std::forward(args)...) {} 22 | ~deletable_facet() {} 23 | }; 24 | 25 | inline static const auto UUIDStr = utils::makeOperator(&mce::UUID::asString); 26 | inline static const auto StdStr = utils::makeOperator(&mcpe::string::std); 27 | inline static const auto V8Str = utils::makeOperator(+[](v8::Local const &str) { 28 | unsigned short buffer[str->Length() + 1]; 29 | str->Write(buffer); 30 | std::wstring_convert>, char16_t> cvt; 31 | return cvt.to_bytes((char16_t *)buffer); 32 | }); 33 | inline static const auto CStr = utils::makeOperator(&mcpe::string::c_str); 34 | inline static const auto StdCStr = utils::makeOperator(&std::string::c_str); 35 | inline static const auto FloatToDouble = utils::makeOperator(+[](float const &x) -> double { return x; }); 36 | template inline static constexpr auto EqualsTo(T target) { 37 | return utils::makeOperator>([&](auto source) { return source == target; }); 38 | } 39 | inline static const auto FindPlayerByNetworkID = utils::makeOperator(+[](NetworkIdentifier const &id) -> Player & { 40 | using namespace interface; 41 | for (auto pplayer : Locator()->set) { 42 | auto &player = *pplayer; 43 | if (patched::PlayerNetworkID[player] == id) { return player; } 44 | } 45 | throw "not found"; 46 | }); -------------------------------------------------------------------------------- /stone/src/patched.cpp: -------------------------------------------------------------------------------- 1 | #include "patched.h" 2 | 3 | namespace patched { 4 | 5 | std::vector init_fns; 6 | std::vector dest_fns; 7 | 8 | namespace details { 9 | RegisterPatchInit::RegisterPatchInit(void (*fn)(), void (*dest_fn)()) { 10 | if (fn) init_fns.push_back(fn); 11 | if (dest_fn) dest_fns.push_back(dest_fn); 12 | } 13 | } // namespace details 14 | 15 | void init() { 16 | for (auto fn : init_fns) fn(); 17 | } 18 | 19 | void dest() { 20 | for (auto fn : dest_fns) fn(); 21 | } 22 | 23 | } // namespace patched -------------------------------------------------------------------------------- /stone/src/patched.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace patched { 10 | 11 | template std::string withCommandOutput(F f) { 12 | using namespace std; 13 | struct __attribute__((__packed__)) mov { 14 | char ins_mov = 0xB8; 15 | ostream *stream; 16 | char nop = 0x90; 17 | }; 18 | static_assert(sizeof(mov) == 6); 19 | stringstream ss; 20 | auto patch = BUILD_HELPER(TempReplace, mov, 68, "_ZN19CommandOutputSender4sendERK13CommandOriginRK13CommandOutput")(mov{ .stream = &ss }); 21 | f(); 22 | return ss.str(); 23 | } 24 | 25 | namespace details { 26 | struct RegisterPatchInit { 27 | RegisterPatchInit(void (*)(), void (*)() = nullptr); 28 | }; 29 | } 30 | 31 | void init(); 32 | void dest(); 33 | 34 | } // namespace patched -------------------------------------------------------------------------------- /stone/src/patched/Bind.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "../server_properties.h" 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | namespace { 11 | 12 | using namespace interface; 13 | 14 | SHook(int, bind, int sockfd, const struct sockaddr *addr, socklen_t addrlen) { 15 | if (addr->sa_family == AF_INET) { 16 | addrinfo hints = { 17 | .ai_flags = AI_PASSIVE, 18 | .ai_family = AF_INET, 19 | .ai_socktype = SOCK_DGRAM, 20 | }; 21 | addrinfo *list; 22 | if (getaddrinfo(Locator()->ip.get().c_str(), "1", &hints, &list) == 0) { 23 | ((sockaddr_in*)list->ai_addr)->sin_port = ((sockaddr_in*)addr)->sin_port; 24 | auto ret = original(sockfd, list->ai_addr, list->ai_addrlen); 25 | freeaddrinfo(list); 26 | return ret; 27 | } 28 | } 29 | if (addr->sa_family == AF_INET6) { 30 | addrinfo hints = { 31 | .ai_flags = AI_PASSIVE, 32 | .ai_family = AF_INET6, 33 | .ai_socktype = SOCK_DGRAM, 34 | }; 35 | addrinfo *list; 36 | if (getaddrinfo(Locator()->ipv6.get().c_str(), "1", &hints, &list) == 0) { 37 | ((sockaddr_in6*)list->ai_addr)->sin6_port = ((sockaddr_in6*)addr)->sin6_port; 38 | auto ret = original(sockfd, list->ai_addr, list->ai_addrlen); 39 | freeaddrinfo(list); 40 | return ret; 41 | } 42 | } 43 | auto ret = original(sockfd, addr, addrlen); 44 | return ret; 45 | } 46 | 47 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/Common.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | namespace { 8 | 9 | SStaticHook(mcpe::string, _ZN6Common23getGameVersionStringNetEv, Common) { 10 | return original() + "." + getGameDevVersionString(); 11 | } 12 | 13 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/Education.cpp: -------------------------------------------------------------------------------- 1 | #include "../dumper.h" 2 | #include "../patched.h" 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include "../server_properties.h" 9 | 10 | namespace { 11 | using namespace interface; 12 | 13 | SHook(bool, _ZN16EducationOptions24isBaseCodeBuilderEnabledEv) { return true; } 14 | SHook(bool, _ZN16EducationOptions18isChemistryEnabledEv) { return true; } 15 | SHook(bool, _ZN16EducationOptions20isCodeBuilderEnabledEv) { return true; } 16 | SHook(bool, _ZNK6Social4User11isConnectedEv) { return true; } 17 | SHook(bool, _ZNK11AppPlatform9isEduModeEv) { return true; } 18 | 19 | struct IsExperimentalDescription { 20 | void *vtable; 21 | bool isExperimental; 22 | }; 23 | 24 | SInstanceHook(bool, _ZN25IsExperimentalDescription5parseERN4Json5ValueE, IsExperimentalDescription, void *json) { 25 | this->isExperimental = Locator()->experimentMode ? false : original(this, json); 26 | return true; 27 | } 28 | 29 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/Encryption.cpp: -------------------------------------------------------------------------------- 1 | #include "../dumper.h" 2 | #include "../patched.h" 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace { 11 | 12 | SClasslessInstanceHook(void, _ZN20EncryptedNetworkPeer16enableEncryptionERKSs) {} 13 | SInstanceHook(void, _ZN20ServerNetworkHandler6handleERK17NetworkIdentifierRK11LoginPacket, ServerNetworkHandler, NetworkIdentifier const &netId, 14 | void *packet) { 15 | original(this, netId, packet); 16 | ClientToServerHandshakePacket *whateverhonestly = nullptr; 17 | this->handle(netId, *whateverhonestly); 18 | } 19 | 20 | static patched::details::RegisterPatchInit pinit([] { 21 | BUILD_HELPER(DirectPatch, uint16_t, 0x12B5, "_ZN20ServerNetworkHandler6handleERK17NetworkIdentifierRK11LoginPacket").VerifiedPatch(0xD1FF, 0x9090); 22 | }); 23 | 24 | // !! Safe but slow 25 | // SClasslessInstanceHook(void, _ZN20LoopbackPacketSender12sendToClientERK17NetworkIdentifierRK6Packeth, NetworkIdentifier const &netId, Packet 26 | // *packet, 27 | // unsigned char ch) { 28 | // if (packet->vtable != Packet::vt_serverToClientHandshake + 2) original(this, netId, packet, ch); 29 | // else dump_backtrace(); 30 | // } 31 | 32 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/Flags.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace patched::flags { 4 | extern bool CommandPrivileged; 5 | } -------------------------------------------------------------------------------- /stone/src/patched/FlatWorldGeneratorOptions.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace { 10 | 11 | SHook(Json::Value &, _ZN25FlatWorldGeneratorOptions10getDefaultEv) { 12 | auto &ret = original(); 13 | Json::Reader reader; 14 | auto path = PathHelper::getPrimaryDataDirectory() + "flat_world_generator.json"; 15 | std::ifstream ifs(path); 16 | if (!ifs) { 17 | Json::StyledWriter writer; 18 | std::ofstream ofs(path); 19 | ofs << writer.write(ret); 20 | return ret; 21 | } 22 | reader.parse(ifs, ret, false); 23 | return ret; 24 | } 25 | 26 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/HardcodedOffsets.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace patched { 19 | using namespace utils; 20 | using namespace interface; 21 | using namespace std; 22 | 23 | #define OFF(name) inline static const auto name [[maybe_unused]] 24 | 25 | OFF(PlayerName) = StaticFieldAccessor{}; 26 | OFF(PlayerUUID) = StaticFieldAccessor{}; 27 | OFF(PlayerNetworkID) = StaticFieldAccessor{}; 28 | OFF(PlayerXUID) = makeOperator(+[](Player const &player) { return ExtendedCertificate::getXuid(*player.getCertificate()); }); 29 | OFF(PlayerBasicInfo) = makeOperator(+[](Player const &player) { 30 | return make_tuple(PlayerName[player].std(), PlayerUUID[player].asString().std(), PlayerXUID(player).std()); 31 | }); 32 | OFF(PlayerPos) = makeOperator(&Player::getPos); 33 | OFF(PlayerRot) = makeOperator(&Player::getRotation); 34 | OFF(PlayerLvl) = makeOperator(&Player::getLevelProgress); 35 | OFF(PlayerStats) = makeOperator(+[](Player const &player) { 36 | return Locator()->getPeerForUser(PlayerNetworkID[player])->getNetworkStatus(); 37 | }); 38 | OFF(ItemInstanceCount) = StaticFieldAccessor{}; 39 | OFF(ItemStackCount) = StaticFieldAccessor{}; 40 | 41 | OFF(MinecraftFromServerInstance) = StaticFieldAccessor{}; 42 | 43 | OFF(BlacklistFromNetworkHandler) = StaticFieldAccessor{}; 44 | 45 | } // namespace patched 46 | -------------------------------------------------------------------------------- /stone/src/patched/Level.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "../server_properties.h" 11 | 12 | #include 13 | 14 | namespace { 15 | using namespace interface; 16 | 17 | SInstanceHook(int, _ZN11ServerLevel10initializeERKSsRK13LevelSettingsP9LevelData, ServerLevel, void *a, void *b, void *c) { 18 | Locator() = this; 19 | return original(this, a, b, c); 20 | } 21 | 22 | SInstanceHook(void, _ZN5Level4tickEv, Level) { 23 | using namespace std::chrono; 24 | using hrc = std::chrono::high_resolution_clock; 25 | static auto start = hrc::now(); 26 | auto end = hrc::now(); 27 | long int frametime_us = (std::chrono::duration_cast(end - start).count()); 28 | start = end; 29 | Locator()->tick(); 30 | Locator()->tps = (float)duration_cast(1s).count() / frametime_us; 31 | original(this); 32 | } 33 | 34 | static patched::details::RegisterPatchInit pinit([] { Locator().generate(); }); 35 | 36 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/ModalForm.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #include "ScriptInterface.h" 12 | #include "HardcodedOffsets.h" 13 | 14 | #include 15 | 16 | namespace { 17 | using namespace patched; 18 | using namespace interface; 19 | 20 | struct ModalFormImpl : interface::ModalForm { 21 | void send(Player *player, unsigned id, std::string const &content) { 22 | ModalFormRequestPacket packet{ id, content }; 23 | player->sendNetworkPacket(packet); 24 | } 25 | }; 26 | 27 | SHook(void, _ZN20ServerNetworkHandler6handleERK17NetworkIdentifierRK23ModalFormResponsePacket, void *, NetworkIdentifier const &id, 28 | ModalFormResponsePacket const &packet) { 29 | for (auto player : Locator()->set) { 30 | if (PlayerNetworkID[*player] == id) { 31 | auto content = packet.content.std(); 32 | Locator()->recv(packet.request_id, player, content); 33 | return; 34 | } 35 | } 36 | } 37 | 38 | static patched::details::RegisterPatchInit pinit([] { Locator() = new ModalFormImpl(); }); 39 | 40 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/PlayerCommandOrigin.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include "../server_properties.h" 9 | 10 | namespace patched::flags { 11 | bool CommandPrivileged = false; 12 | } 13 | 14 | namespace { 15 | 16 | using namespace patched::flags; 17 | 18 | SClasslessInstanceHook(int, _ZNK19PlayerCommandOrigin19getPermissionsLevelEv) { 19 | if (CommandPrivileged) return 4; 20 | return original(this); 21 | } 22 | 23 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/ScriptEngine.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | #include "../server_properties.h" 3 | #include "../dumper.h" 4 | #include 5 | 6 | extern bool GlobalExperimentMode; 7 | 8 | namespace { 9 | 10 | using namespace interface; 11 | using namespace patched; 12 | 13 | SHook(bool, _ZN12ScriptEngine18isScriptingEnabledEv, void *) { return Locator()->experimentMode; } 14 | 15 | SHook(void, _ZN2v88internal7Isolate6DeinitEv, void *self) {} 16 | 17 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/ScriptEventCoordinator.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace { 8 | 9 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator24sendScriptBroadcastEventERKSs16RegistrationTypeb, mcpe::string const &event, int type, 10 | bool flag) { 11 | Log::trace("Scripting", "event: %s %d %d", event.c_str(), type, flag); 12 | original(this, event, type, flag); 13 | } 14 | 15 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator22sendScriptGetComponentERKSs16RegistrationTypeb, mcpe::string const &component, int type, 16 | bool flag) { 17 | Log::trace("Scripting", "component: %s %d %d", component.c_str(), type, flag); 18 | original(this, component, type, flag); 19 | } 20 | 21 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator15sendScriptErrorERKSsS1_, mcpe::string const &source, mcpe::string const &content) { 22 | Log::error("Scripting", "%s: %s", source.c_str(), content.c_str()); 23 | original(this, source, content); 24 | } 25 | 26 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator23sendScriptInternalErrorERKSs, mcpe::string const &content) { 27 | Log::error("Scripting", "internal error: %s", content.c_str()); 28 | original(this, content); 29 | } 30 | 31 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator24sendScriptListenForEventERKSs, mcpe::string const &event) { 32 | Log::debug("Scripting", "listen: %s", event.c_str()); 33 | original(this, event); 34 | } 35 | 36 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator16sendScriptLoadedERKSsy, mcpe::string const &name, unsigned long long unk) { 37 | Log::debug("Scripting", "loaded: %s %llu", name.c_str(), unk); 38 | original(this, name, unk); 39 | } 40 | 41 | SClasslessInstanceHook(void, _ZN22ScriptEventCoordinator13sendScriptRanERKSsS1_b, mcpe::string const &source, mcpe::string const &content) { 42 | Log::debug("Scripting", "running %s", source.c_str()); 43 | original(this, source, content); 44 | } 45 | 46 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/ScriptInterface.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace patched { 9 | using namespace utils; 10 | 11 | inline static const auto V8Isolate [[maybe_unused]] = StaticFieldAccessor{}; 12 | inline static const auto V8Context [[maybe_unused]] = StaticFieldAccessor>{}; 13 | 14 | } -------------------------------------------------------------------------------- /stone/src/patched/ServerCommandOrigin.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | #include "../server_properties.h" 9 | 10 | namespace { 11 | 12 | SInstanceHook(mcpe::string, _ZNK19ServerCommandOrigin7getNameEv, ServerCommandOrigin) { return name; } 13 | 14 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/ServerLevelEventCoordinator.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace { 14 | using namespace interface; 15 | 16 | SInstanceHook(void, _ZN27ServerLevelEventCoordinator20sendLevelAddedPlayerER5LevelR6Player, ServerLevelEventCoordinator, Level *level, 17 | Player *player) { 18 | using namespace interface; 19 | Locator()->onPlayerAdded(*player); 20 | original(this, level, player); 21 | } 22 | 23 | SHook(void, _ZN12ServerPlayerD2Ev, Player *player) { 24 | Locator()->onPlayerRemoved(*player); 25 | original(player); 26 | } 27 | 28 | static patched::details::RegisterPatchInit pinit([] { Locator().generate<>(); }); 29 | 30 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/ServerMetrics.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | #include 3 | #include 4 | 5 | namespace { 6 | 7 | SHook(void, _ZN16EducationOptions4initERK9LevelData, void *self, void *data) { 8 | printf("%p %p\n", self, data); 9 | asm("int3"); 10 | original(self, data); 11 | } 12 | 13 | SInstanceHook(void, _ZN13ServerMetrics21sendLatencyTimepointsENSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEES4_RKSs, ServerMetrics, 14 | std::chrono::duration> dur1, 15 | std::chrono::duration> dur2, mcpe::string const &xuid) { 16 | printf("delay: %lld\n", std::chrono::duration_cast(dur1).count()); 17 | return; 18 | } 19 | 20 | SInstanceHook(void, _ZN13ServerMetrics18sendServerTickTimeENSt6chrono8durationIxSt5ratioILx1ELx1000000000EEEE, ServerMetrics, 21 | std::chrono::duration> tick) { 22 | printf("tick time: %lld\n", std::chrono::duration_cast(tick).count()); 23 | return; 24 | } 25 | 26 | static_assert(sizeof(std::function) == 16); 27 | 28 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/SpawnParticle.cpp: -------------------------------------------------------------------------------- 1 | #include "../patched.h" 2 | 3 | #include "../dumper.h" 4 | #include 5 | #include 6 | 7 | namespace { 8 | 9 | SHook(void, _ZN5Level19spawnParticleEffectERKSsRK4Vec3P9Dimension, Level *self, mcpe::string const &name, Vec3 const &pos, void *dim) { 10 | if (self && dim) return original(self, name, pos, dim); 11 | } 12 | 13 | } // namespace -------------------------------------------------------------------------------- /stone/src/patched/TextPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "../operators.h" 2 | #include "../patched.h" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace { 13 | using namespace interface; 14 | 15 | SHook(void, _ZN20ServerNetworkHandler6handleERK17NetworkIdentifierRK10TextPacket, void *handler, NetworkIdentifier const &id, 16 | TextPacket const &packet) { 17 | using namespace interface; 18 | auto &chat = Locator(); 19 | chat->onPlayerChat(id >> FindPlayerByNetworkID, packet.message >> StdStr); 20 | if (!chat->intercept) original(handler, id, packet); 21 | } 22 | 23 | struct ChatImpl : Chat { 24 | void sendChat(std::string const &sender, std::string const &content) override { 25 | TextPacket text = TextPacket::createTranslatedAnnouncement(sender, mcpe::string("[") + sender + "] " + content, "", "1"); 26 | Locator()->onChat(sender, content); 27 | for (auto pplayer : Locator()->set) { 28 | auto &player = *pplayer; 29 | if (player.canUseAbility("mute")) continue; 30 | player.sendNetworkPacket(text); 31 | } 32 | } 33 | void sendAnnouncement(std::string const &content) override { 34 | TextPacket text = TextPacket::createTranslatedAnnouncement("", content, "", "1"); 35 | for (auto pplayer : Locator()->set) { 36 | auto &player = *pplayer; 37 | player.sendNetworkPacket(text); 38 | } 39 | } 40 | }; 41 | 42 | static patched::details::RegisterPatchInit pinit([] { Locator() = new ChatImpl(); }); 43 | 44 | } // namespace -------------------------------------------------------------------------------- /stone/src/server_minecraft_app.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class DedicatedServerMinecraftApp : public IMinecraftApp { 6 | public: 7 | Automation::AutomationClient *automationClient; 8 | 9 | virtual Minecraft *getPrimaryMinecraft() { return nullptr; } 10 | virtual Automation::AutomationClient *getAutomationClient() { return automationClient; } 11 | virtual bool isEduMode() { return false; } 12 | virtual bool isDedicatedServer() { return true; } 13 | virtual int getDefaultNetworkMaxPlayers() { return 20; } 14 | virtual void onNetworkMaxPlayersChanged(unsigned int max) {} 15 | }; -------------------------------------------------------------------------------- /stone/src/stub_key_provider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class StubKeyProvider : public IContentKeyProvider { 9 | 10 | public: 11 | virtual ~StubKeyProvider() {} 12 | virtual mcpe::string getContentKey(mce::UUID const &) { return mcpe::string(); } 13 | virtual mcpe::string getAlternativeContentKey(mce::UUID const &) { return mcpe::string(); } 14 | virtual void setTempContentKeys(std::unordered_map const &) {} 15 | virtual void clearTempContentKeys() {} 16 | }; -------------------------------------------------------------------------------- /stone/src/v8_platform.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class LauncherV8Platform { 6 | 7 | private: 8 | static void **myVtable; 9 | 10 | void *vtable; 11 | char filler[0x100]; 12 | 13 | public: 14 | static void initVtable(void *lib); 15 | 16 | LauncherV8Platform(); 17 | 18 | void CallOnBackgroundThread(v8::Task *task, v8::ExpectedRuntime expected_runtime); 19 | void CallOnForegroundThread(v8::Isolate *isolate, v8::Task *task); 20 | void CallDelayedOnForegroundThread(v8::Isolate *isolate, v8::Task *task, double delay_in_seconds); 21 | void CallIdleOnForegroundThread(v8::Isolate *isolate, v8::IdleTask *task); 22 | bool IdleTasksEnabled(v8::Isolate *); 23 | // double MonotonicallyIncreasingTime(); 24 | }; -------------------------------------------------------------------------------- /stone/src/whitelist_mgr.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct WhitelistManager { 8 | const std::string path; 9 | Whitelist list; 10 | inline WhitelistManager(std::string const &path) 11 | : path(path) 12 | , list([] {}) { 13 | reload(); 14 | save(); 15 | } 16 | 17 | inline void reload() { 18 | Json::Reader reader; 19 | Json::Value value; 20 | std::ifstream ifs(path); 21 | if (!ifs) return; 22 | reader.parse(ifs, value, false); 23 | list.deserialize(value); 24 | } 25 | 26 | inline void save() { 27 | Json::StyledWriter writer; 28 | Json::Value value; 29 | std::ofstream ofs(path); 30 | list.serialize(value); 31 | ofs << writer.write(value); 32 | } 33 | }; -------------------------------------------------------------------------------- /utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | 3 | project(utils LANGUAGES CXX) 4 | 5 | add_library(utils 6 | "src/utils.cpp" 7 | "src/server_hook.cpp" 8 | "include/stone/utils.h" 9 | "include/stone/server_hook.h" 10 | "include/stone/magic_func.h" 11 | "include/stone/symbol.h" 12 | "include/stone/hook_helper.h" 13 | "include/stone/operator.h" 14 | ) 15 | 16 | set_property(TARGET utils PROPERTY CXX_STANDARD 17) 17 | 18 | target_include_directories(utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) 19 | target_link_libraries(utils minecraft-symbols mcpelauncher-core interface hybris) -------------------------------------------------------------------------------- /utils/include/stone/symbol.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | template struct Symbol { 6 | static constexpr char data[] = { X..., 0 }; 7 | static constexpr std::size_t length = sizeof...(X); 8 | }; 9 | 10 | template Symbol operator""_symbol() { return {}; } -------------------------------------------------------------------------------- /utils/include/stone/utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void *&MinecraftHandle(); 14 | 15 | namespace utils_internal { 16 | inline static std::mutex mtx; 17 | inline static std::condition_variable cv; 18 | } // namespace utils_internal 19 | 20 | std::string GetEnvironmentVariableOrDefault(const std::string &variable_name, const std::string &default_value); 21 | template inline static std::invoke_result_t EvalInServerThread(F fn) { 22 | using namespace utils_internal; 23 | using namespace interface; 24 | volatile bool done = false; 25 | std::invoke_result_t ret; 26 | Locator()->queueForServerThread([&] { 27 | std::lock_guard guard(mtx); 28 | ret = fn(); 29 | done = true; 30 | cv.notify_one(); 31 | }); 32 | std::unique_lock lk(mtx); 33 | cv.wait(lk, [&] { return done; }); 34 | return ret; 35 | } 36 | 37 | template inline static void QueueForServerThread(F fn) { 38 | using namespace interface; 39 | Locator()->queueForServerThread(fn); 40 | } 41 | 42 | template __attribute__((format(printf, 1, 2))) inline std::string strformat(const char *temp, ...) { 43 | char result[buffer]; 44 | va_list args; 45 | va_start(args, temp); 46 | vsnprintf(result, buffer, temp, args); 47 | va_end(args); 48 | return result; 49 | } 50 | 51 | template struct FailGuard { 52 | Func fn; 53 | bool canceled; 54 | inline FailGuard(Func fn) 55 | : fn(fn) 56 | , canceled(false) {} 57 | inline void cancel() { canceled = true; } 58 | inline ~FailGuard() { 59 | if (!canceled) fn(); 60 | } 61 | }; 62 | 63 | void dump_vtable(XPointer vtable, int size); -------------------------------------------------------------------------------- /utils/src/server_hook.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::vector> &GetServerHookRegistry() { 4 | static std::vector> registry; 5 | return registry; 6 | } -------------------------------------------------------------------------------- /utils/src/utils.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | void *&MinecraftHandle() { 8 | static void *address; 9 | return address; 10 | } 11 | 12 | std::string GetEnvironmentVariableOrDefault(const std::string &variable_name, const std::string &default_value) { 13 | const char *value = getenv(variable_name.c_str()); 14 | return value ? value : default_value; 15 | } 16 | 17 | void dump_vtable(XPointer vtable, int size) { 18 | for (int i = 0; i < size; i++) { 19 | auto target = vtable[i]; 20 | printf("%2d: %p\t", i, target); 21 | Dl_info info; 22 | if (target && hybris_dladdr(target, &info)) { 23 | size_t bufferlen = 256; 24 | char buffer[256]; 25 | int status = 0; 26 | abi::__cxa_demangle(info.dli_sname, buffer, &bufferlen, &status); 27 | printf("%s\n", buffer); 28 | } else { 29 | printf("\n"); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /version/include/stone/version.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern char const *build_version; -------------------------------------------------------------------------------- /version/src/version.c: -------------------------------------------------------------------------------- 1 | #ifndef BUILD_VERSION 2 | #define BUILD_VERSION "UNKNOWN VERSION" 3 | #endif 4 | 5 | char const *build_version = BUILD_VERSION; --------------------------------------------------------------------------------