64-bit proxy mode for Linux

This commit is contained in:
acidicoala
2025-09-24 22:37:53 +05:00
parent 81a8ef42ab
commit 59d45c9dab
7 changed files with 33 additions and 19 deletions

View File

@@ -1,7 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="exports_generator [32] [linux]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="FALSE libsteam_api_o $ProjectFileDir$/res/steamworks/*/binaries/linux32/libsteam_api.so $CMakeCurrentGenerationDir$/generated/libsteam_api_exports.cpp" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="exports_generator">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="exports_generator [64] [win]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="FALSE steam_api64_o $ProjectFileDir$/res/steamworks/*/binaries/steam_api64.dll $CMakeCurrentGenerationDir$/generated/linker_exports_for_steam_api.h" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="exports_generator">
<configuration default="false" name="exports_generator [64] [win]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="FALSE steam_api64_o $ProjectFileDir$/res/steamworks/*/binaries/steam_api64.dll $CMakeCurrentGenerationDir$/generated/linker_exports_for_steam_api.h" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="exports_generator" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="exports_generator">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>

View File

@@ -0,0 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="linux_exports_generator [64]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="--input_libs_glob $ProjectFileDir$/res/steamworks/*/binaries/linux64/libsteam_api.so --output_path $CMakeCurrentGenerationDir$/generated/proxy_exports" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="linux_exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="linux_exports_generator">
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>

View File

@@ -53,7 +53,6 @@ if(WIN32)
list(APPEND SMOKE_API_SOURCES src/main_win.cpp)
else()
set_32_and_64(LINUX_DIR linux32 linux64)
set(STEAM_API_MODULE libsteam_api)
set(STEAMCLIENT_DLL steamclient)
@@ -133,11 +132,10 @@ if(WIN32)
# Ignore linker warnings regarding COM-related private exports
set_target_properties(SmokeAPI PROPERTIES LINK_FLAGS "/ignore:4104")
else()
# configure_linker_exports(
# TARGET SmokeAPI
# HEADER_NAME "libsteam_api_exports.cpp"
# FORWARDED_DLL "${STEAM_API_MODULE}_o.so"
# DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so"
# INPUT_SOURCES_DIR ""
# )
set_32_and_64(LINUX_DIR linux32 linux64)
configure_proxy_exports(
TARGET SmokeAPI
INPUT_LIBS_GLOB "${CMAKE_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/libsteam_api.so"
OUTPUT_NAME "proxy_exports"
)
endif()

View File

@@ -13,12 +13,15 @@
#include "smoke_api.hpp"
#include <polyhook2/MemProtector.hpp>
#include "smoke_api/config.hpp"
#include "smoke_api/steamclient/steamclient.hpp"
#include "steam_api/steam_interfaces.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
#include "build_config.h"
#include "proxy_exports.hpp"
#ifdef KB_WIN
#include "koalabox/win.hpp"
@@ -208,6 +211,20 @@ namespace smoke_api {
const auto self_path = kb::paths::get_self_dir();
original_steamapi_handle = kb::lib::load_original_library(self_path, STEAM_API_MODULE);
#ifdef KB_LINUX
// We need to enable writing into the instruction memory
// TODO: Move to generated file
const auto code_section = kb::lib::get_section_or_throw(module_handle, kb::lib::CODE_SECTION);
PLH::MemAccessor mem_accessor;
PLH::MemoryProtector const protector(
reinterpret_cast<uint64_t>(code_section.start_address),
code_section.size,
PLH::ProtFlag::RWX,
mem_accessor
);
proxy_exports::init(original_steamapi_handle);
#endif
}
LOG_INFO("Initialization complete");

View File

@@ -9,12 +9,11 @@ constexpr auto STEAM_USER = "SteamUser";
constexpr auto STEAM_INVENTORY = "STEAMINVENTORY_INTERFACE_V";
constexpr auto STEAM_GAME_SERVER = "SteamGameServer";
// IMPORTANT: DLL_EXPORT is hardcoded in exports_generator.cpp,
// IMPORTANT: DLL_EXPORT is hardcoded in windows_exports_generator.cpp & linux_exports_generator.cpp,
// so any name changes here must be reflected there as well.
#define DLL_EXPORT(TYPE) extern "C" [[maybe_unused]] __declspec(dllexport) TYPE __cdecl
namespace smoke_api {
void init(void* module_handle);
void shutdown();