1
0
mirror of https://github.com/0O0o0oOoO00/Alas.git synced 2026-05-14 08:59:25 +08:00

fix: fix Luohook's protobuf support

This commit is contained in:
LA_DI_DA
2025-03-27 17:27:39 +08:00
parent 78a252791a
commit e7d8660ff1
38 changed files with 137 additions and 13 deletions

3
.gitignore vendored
View File

@@ -275,4 +275,5 @@ blcrack/out/
blcrack/tolua/
bin/hook/
blcrack/patchelf/build/
blcrack/test/
blcrack/test/
blcrack/cracker/pb/

View File

@@ -5,6 +5,8 @@ add_library(${TOLUA} SHARED ${CMAKE_CURRENT_LIST_DIR}/tolua.c)
set(CRACKER cracker)
file(GLOB CRACKER_PROTOS ${CMAKE_CURRENT_LIST_DIR}/proto/*.proto)
file(GLOB CRACKER_SRCS
${CMAKE_CURRENT_LIST_DIR}/*.hpp
${CMAKE_CURRENT_LIST_DIR}/*.cpp
@@ -16,8 +18,23 @@ target_link_options(${CRACKER} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_LIST
target_link_libraries(${CRACKER}
PRIVATE httplib::httplib spdlog::spdlog JsonCpp::JsonCpp
PRIVATE ${TOLUA} ${IL2CPP}
PRIVATE protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite
)
target_compile_definitions(${CRACKER}
PRIVATE ${SPDLOG_DEFINES} SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE
PRIVATE SOL_USE_LUA_HPP
)
)
set(CRACKER_PB_DIR ${CMAKE_CURRENT_LIST_DIR}/pb)
if (NOT EXISTS ${CRACKER_PB_DIR})
file(MAKE_DIRECTORY ${CRACKER_PB_DIR})
endif()
protobuf_generate(
TARGET ${CRACKER}
LANGUAGE cpp
PROTOS ${CRACKER_PROTOS}
IMPORT_DIRS ${CMAKE_CURRENT_LIST_DIR}/proto
PROTOC_OUT_DIR ${CRACKER_PB_DIR}
)

View File

@@ -476,6 +476,28 @@ void Cracker::print_table_field(std::vector<std::string>& path) {
Utils::Lua::print_table_fields_type(t);
}
void Cracker::print_value(std::vector<std::string>& path) {
Lua::Table t = m_state.globals();
for (auto it = path.begin(); it != path.end() - 1; ++it) {
t = t[*it];
}
std::string key = path.back();
Lua::Object value = t[key];
auto type = value.get_type();
if (type == sol::type::number) {
SPDLOG_INFO("value: {}", value.as<double>());
} else if (type == sol::type::string) {
SPDLOG_INFO("value: {}", value.as<std::string>());
} else if (type == sol::type::boolean) {
SPDLOG_INFO("value: {}", value.as<bool>());
} else if (type == sol::type::nil) {
SPDLOG_INFO("value: nil");
} else if (type == sol::type::table) {
Lua::Table table = value.as<Lua::Table>();
Utils::Lua::print_table_fields_type(table);
}
}
void Cracker::enable_flag(FunctionId id) {
m_functions[id] = true;
}

View File

@@ -136,6 +136,7 @@ public:
bool is_disabled(FunctionId id);
void print_table_field(std::vector<std::string>& path);
void print_value(std::vector<std::string>& path);
private:
void enable_flag(FunctionId id);

View File

@@ -189,6 +189,7 @@ IMPORT_MAP = {
"p64": ["common.proto"],
}
NO_PACKAGE = ["common.proto", "guild.proto"]
def gen_proto_file(lua_file_path, proto_file_path):
print(f"Parse {lua_file_path} generate {proto_file_path}")
@@ -264,6 +265,8 @@ def gen_proto_file(lua_file_path, proto_file_path):
with open(str(proto_file_path), mode="w", encoding="utf-8") as f:
f.write("syntax = \"proto2\";\n\n")
if proto_file_path.name not in NO_PACKAGE:
f.write(f"package {proto_file_path.stem};\n\n")
file_path = Path(lua_file_path)
proto_name = file_path.stem.replace("_pb", "")

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p10;
message CS_10001 {
required string account = 1;

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p11;
import "common.proto";
message SC_11000 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p12;
import "common.proto";
message SC_12001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p13;
import "common.proto";
message SC_13000 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p14;
import "common.proto";
message SC_14001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p15;
import "common.proto";
message SC_15001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p16;
import "common.proto";
message CS_16001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p17;
message SC_17001 {
repeated uint32 finish_list = 1;

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p18;
import "common.proto";
message CS_18001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p19;
message SC_19001 {
required uint32 lv = 1;

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p20;
import "common.proto";
message SC_20001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p22;
import "common.proto";
message SC_22001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p24;
import "common.proto";
message CS_24002 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p25;
import "common.proto";
message SC_25001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p26;
import "common.proto";
message SC_26001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p27;
message CS_27000 {
required uint32 type = 1;

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p28;
import "common.proto";
message SC_28000 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p29;
import "common.proto";
message CS_29001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p30;
import "common.proto";
message SC_30001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p33;
import "common.proto";
message CS_33000 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p34;
import "common.proto";
message CS_34001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p40;
import "common.proto";
message CS_40001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p50;
import "common.proto";
message SC_50000 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p60;
import "common.proto";
import "guild.proto";

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p61;
import "common.proto";
message CS_61001 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p62;
import "common.proto";
import "guild.proto";

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p63;
import "common.proto";
message SC_63000 {

View File

@@ -1,5 +1,7 @@
syntax = "proto2";
package p64;
import "common.proto";
message SC_64000 {

View File

@@ -120,6 +120,18 @@ CrackerServer::CrackerServer() {
res.status = 200;
});
Post("/print_value", [](const httplib::Request& req, httplib::Response& res) {
Json::Reader reader;
Json::Value j;
reader.parse(req.body, j);
std::vector<std::string> path;
for (auto& key : j["path"]) {
path.push_back(key.asString());
}
Cracker::Instance().print_value(path);
res.status = 200;
});
Post("/enable_fake_player", [](const httplib::Request& req, httplib::Response& res) {
Cracker::Instance().enable_fake_player();
res.status = 200;

View File

@@ -10,6 +10,7 @@ call :install_all_platforms cpp-httplib
call :install_all_platforms jsoncpp
call :install_all_platforms spdlog
call :install_all_platforms cxxopts
call :install_all_platforms protobuf
call :install cpp-httplib x64-windows-static
call :install jsoncpp x64-windows-static

View File

@@ -4,6 +4,7 @@ else ()
set(ARCH ${ANDROID_ABI})
endif ()
set(VCPKGS_SHARE ${VCPKG_ROOT}/${ARCH}-android/share)
set(VCPKGS_TOOLS ${VCPKG_ROOT}/${ARCH}-android/tools)
set(unofficial-brotli_DIR ${VCPKGS_SHARE}/unofficial-brotli)
set(httplib_DIR ${VCPKGS_SHARE}/httplib)
@@ -18,4 +19,14 @@ find_package(spdlog CONFIG REQUIRED)
set(SPDLOG_DEFINES SPDLOG_COMPILED_LIB)
set(cxxopts_DIR ${VCPKGS_SHARE}/cxxopts)
find_package(cxxopts CONFIG REQUIRED)
find_package(cxxopts CONFIG REQUIRED)
set(OpenSSL_DIR ${VCPKGS_SHARE}/openssl)
set(Z_VCPKG_OPENSSL_USE_SINGLE_CONFIG ON)
find_package(OpenSSL CONFIG REQUIRED)
set(absl_DIR ${VCPKGS_SHARE}/absl)
set(utf8_range_DIR ${VCPKGS_SHARE}/utf8_range)
set(protobuf_DIR ${VCPKGS_SHARE}/protobuf)
set(Protobuf_PROTOC_EXECUTABLE ${VCPKGS_TOOLS}/protobuf/protoc)
find_package(protobuf CONFIG REQUIRED)

View File

@@ -2,12 +2,12 @@ set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_ENV_PASSTHROUGH LINUX_CROSS_COMPILE_ROOT_DIR LINUX_CROSS_COMPILE_PREFIX PATH)
set(VCPKG_ENV_PASSTHROUGH LINUX_CROSS_COMPILER_ROOT_DIR LINUX_CROSS_COMPILER_PREFIX PATH)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/x64-linux-static.toolchain.cmake)
set(PATCHELF ${CMAKE_CURRENT_LIST_DIR}/../vcpkgs/x64-linux-static/tools/patchelf.exe)
set(PATCHELF D:/patchelf/patchelf.exe)
if (NOT EXISTS ${PATCHELF})
message(STATUS "patchelf not found, building it")

View File

@@ -1,13 +1,13 @@
if (NOT DEFINED ENV{LINUX_CROSS_COMPILE_ROOT_DIR})
message(FATAL_ERROR "LINUX_CROSS_COMPILE_ROOT_DIR is not defined. Please set it to the root directory of your cross-compile toolchain.")
if (NOT DEFINED ENV{LINUX_CROSS_COMPILER_ROOT_DIR})
message(FATAL_ERROR "LINUX_CROSS_COMPILER_ROOT_DIR is not defined. Please set it to the root directory of your cross-compile toolchain.")
endif ()
message(STATUS "Using cross: $ENV{LINUX_CROSS_COMPILE_ROOT_DIR}")
message(STATUS "Using cross: $ENV{LINUX_CROSS_COMPILER_ROOT_DIR}")
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x64)
set(CMAKE_C_COMPILER $ENV{LINUX_CROSS_COMPILE_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILE_PREFIX}gcc.exe)
set(CMAKE_CXX_COMPILER $ENV{LINUX_CROSS_COMPILE_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILE_PREFIX}g++.exe)
set(CMAKE_AR $ENV{LINUX_CROSS_COMPILE_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILE_PREFIX}ar.exe)
set(CMAKE_RANLIB $ENV{LINUX_CROSS_COMPILE_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILE_PREFIX}ranlib.exe)
set(CMAKE_STRIP $ENV{LINUX_CROSS_COMPILE_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILE_PREFIX}strip.exe)
set(CMAKE_C_COMPILER $ENV{LINUX_CROSS_COMPILER_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILER_PREFIX}gcc.exe)
set(CMAKE_CXX_COMPILER $ENV{LINUX_CROSS_COMPILER_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILER_PREFIX}g++.exe)
set(CMAKE_AR $ENV{LINUX_CROSS_COMPILER_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILER_PREFIX}ar.exe)
set(CMAKE_RANLIB $ENV{LINUX_CROSS_COMPILER_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILER_PREFIX}ranlib.exe)
set(CMAKE_STRIP $ENV{LINUX_CROSS_COMPILER_ROOT_DIR}/bin/$ENV{LINUX_CROSS_COMPILER_PREFIX}strip.exe)