mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-06 05:25:43 -05:00
Full support for 64-bit Linux
This commit is contained in:
7
.idea/dictionaries/project.xml
generated
7
.idea/dictionaries/project.xml
generated
@@ -6,6 +6,8 @@
|
|||||||
<w>ajaxgetdlclist</w>
|
<w>ajaxgetdlclist</w>
|
||||||
<w>dlmopen</w>
|
<w>dlmopen</w>
|
||||||
<w>dlopen</w>
|
<w>dlopen</w>
|
||||||
|
<w>dlsym</w>
|
||||||
|
<w>endfor</w>
|
||||||
<w>indicies</w>
|
<w>indicies</w>
|
||||||
<w>inlinentd</w>
|
<w>inlinentd</w>
|
||||||
<w>isteamapps</w>
|
<w>isteamapps</w>
|
||||||
@@ -16,10 +18,15 @@
|
|||||||
<w>koality</w>
|
<w>koality</w>
|
||||||
<w>koaloader</w>
|
<w>koaloader</w>
|
||||||
<w>libgtk</w>
|
<w>libgtk</w>
|
||||||
|
<w>libsteam</w>
|
||||||
|
<w>memcpy</w>
|
||||||
<w>phnt</w>
|
<w>phnt</w>
|
||||||
<w>polyhook</w>
|
<w>polyhook</w>
|
||||||
|
<w>rtld</w>
|
||||||
<w>simplecpp</w>
|
<w>simplecpp</w>
|
||||||
|
<w>steamapi</w>
|
||||||
<w>steamapps</w>
|
<w>steamapps</w>
|
||||||
|
<w>steamclient</w>
|
||||||
<w>wstr</w>
|
<w>wstr</w>
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
|||||||
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@@ -20,4 +20,5 @@
|
|||||||
<option name="useRustfmt" value="true" />
|
<option name="useRustfmt" value="true" />
|
||||||
<option name="version" value="2" />
|
<option name="version" value="2" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="WestSettings"><![CDATA[{}]]></component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<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">
|
<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 [64]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="linux_exports_generator">
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="steamworks_downloader [prompt]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="$Prompt$" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$ProjectFileDir$/res" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="steamworks_downloader" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="steamworks_downloader">
|
<configuration default="false" name="steamworks_downloader [prompt]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="$Prompt$" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://$ProjectFileDir$/res" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="steamworks_downloader" CONFIG_NAME="Debug [64]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="steamworks_downloader">
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" name="windows_exports_generator [64]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="--forwarded_dll_name "steam_api64_o" --lib_files_glob "$ProjectFileDir$\res\steamworks\*\binaries\steam_api64.dll" --output_file_path "$CMakeCurrentGenerationDir$\generated\linker_exports_for_steam_api.h" --sources_input_path """ REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="windows_exports_generator" CONFIG_NAME="Debug [32]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="windows_exports_generator">
|
<configuration default="false" name="windows_exports_generator [64]" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="--forwarded_dll_name "steam_api64_o" --lib_files_glob "$ProjectFileDir$\res\steamworks\*\binaries\steam_api64.dll" --output_file_path "$CMakeCurrentGenerationDir$\generated\linker_exports_for_steam_api.h" --sources_input_path """ REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SmokeAPI" TARGET_NAME="windows_exports_generator" CONFIG_NAME="Debug [64]" RUN_TARGET_PROJECT_NAME="SmokeAPI" RUN_TARGET_NAME="windows_exports_generator">
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
|
|||||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: ba3171fd28...c59f49ac00
@@ -316,9 +316,10 @@ This project makes use of the following open source projects:
|
|||||||
- [microsoft/wil](https://github.com/microsoft/wil)
|
- [microsoft/wil](https://github.com/microsoft/wil)
|
||||||
- [p-ranav/glob](https://github.com/p-ranav/glob)
|
- [p-ranav/glob](https://github.com/p-ranav/glob)
|
||||||
- [pantor/inja](https://github.com/pantor/inja)
|
- [pantor/inja](https://github.com/pantor/inja)
|
||||||
|
- [jarro2783/cxxopts](https://github.com/jarro2783/cxxopts)
|
||||||
|
- [serge1/ELFIO](https://github.com/serge1/ELFIO)
|
||||||
- [bshoshany/thread-pool](https://github.com/bshoshany/thread-pool)
|
- [bshoshany/thread-pool](https://github.com/bshoshany/thread-pool)
|
||||||
- [batterycenter/embed](https://github.com/batterycenter/embed)
|
- [batterycenter/embed](https://github.com/batterycenter/embed)
|
||||||
- [serge1/ELFIO](https://github.com/serge1/ELFIO)
|
|
||||||
|
|
||||||
## 📄 License
|
## 📄 License
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,5 @@ They will be added to the list of missing DLC IDs to facilitate config-less oper
|
|||||||
{% block extra_oss_libs %}
|
{% block extra_oss_libs %}
|
||||||
- [bshoshany/thread-pool](https://github.com/bshoshany/thread-pool)
|
- [bshoshany/thread-pool](https://github.com/bshoshany/thread-pool)
|
||||||
- [batterycenter/embed](https://github.com/batterycenter/embed)
|
- [batterycenter/embed](https://github.com/batterycenter/embed)
|
||||||
- [serge1/ELFIO](https://github.com/serge1/ELFIO)
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
#include <regex>
|
#include <regex>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include <koalabox/config.hpp>
|
#include <glob/glob.h>
|
||||||
#include <koalabox/lib_monitor.hpp>
|
|
||||||
#include <koalabox/globals.hpp>
|
|
||||||
#include <koalabox/hook.hpp>
|
|
||||||
#include <koalabox/logger.hpp>
|
|
||||||
#include <koalabox/lib.hpp>
|
|
||||||
#include <koalabox/path.hpp>
|
|
||||||
#include <koalabox/paths.hpp>
|
|
||||||
#include <koalabox/util.hpp>
|
|
||||||
|
|
||||||
#include "smoke_api.hpp"
|
|
||||||
|
|
||||||
#include <polyhook2/MemProtector.hpp>
|
#include <polyhook2/MemProtector.hpp>
|
||||||
|
|
||||||
|
#include <koalabox/config.hpp>
|
||||||
|
#include <koalabox/globals.hpp>
|
||||||
|
#include <koalabox/hook.hpp>
|
||||||
|
#include <koalabox/lib.hpp>
|
||||||
|
#include <koalabox/lib_monitor.hpp>
|
||||||
|
#include <koalabox/logger.hpp>
|
||||||
|
#include <koalabox/path.hpp>
|
||||||
|
#include <koalabox/paths.hpp>
|
||||||
|
#include <koalabox/platform.hpp>
|
||||||
|
#include <koalabox/util.hpp>
|
||||||
|
|
||||||
|
// static
|
||||||
#include "smoke_api/config.hpp"
|
#include "smoke_api/config.hpp"
|
||||||
#include "smoke_api/steamclient/steamclient.hpp"
|
#include "smoke_api/steamclient/steamclient.hpp"
|
||||||
|
|
||||||
|
#include "smoke_api.hpp"
|
||||||
#include "steam_api/steam_interfaces.hpp"
|
#include "steam_api/steam_interfaces.hpp"
|
||||||
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
@@ -73,8 +76,8 @@ namespace {
|
|||||||
return versions;
|
return versions;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warn_if_late_injection(const std::string& steamclient_version) {
|
|
||||||
#ifdef KB_WIN
|
#ifdef KB_WIN
|
||||||
|
void warn_if_late_injection(const std::string& steamclient_version) {
|
||||||
if(kb::util::is_wine_env()) {
|
if(kb::util::is_wine_env()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -86,8 +89,8 @@ namespace {
|
|||||||
"Probable cause: SmokeAPI was injected too late. If possible, try injecting it earlier."
|
"Probable cause: SmokeAPI was injected too late. If possible, try injecting it earlier."
|
||||||
);
|
);
|
||||||
LOG_WARN("NOTE: You can safely ignore this warning if running under Proton or native Linux");
|
LOG_WARN("NOTE: You can safely ignore this warning if running under Proton or native Linux");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// ReSharper disable once CppDFAConstantFunctionResult
|
// ReSharper disable once CppDFAConstantFunctionResult
|
||||||
bool on_steamclient_loaded(void* steamclient_handle) {
|
bool on_steamclient_loaded(void* steamclient_handle) {
|
||||||
@@ -107,7 +110,9 @@ namespace {
|
|||||||
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
||||||
for(const auto& steamclient_version : steamclient_versions) {
|
for(const auto& steamclient_version : steamclient_versions) {
|
||||||
if(CreateInterface$(steamclient_version.c_str(), nullptr)) {
|
if(CreateInterface$(steamclient_version.c_str(), nullptr)) {
|
||||||
|
#ifdef KB_WIN
|
||||||
warn_if_late_injection(steamclient_version);
|
warn_if_late_injection(steamclient_version);
|
||||||
|
#endif
|
||||||
|
|
||||||
steam_interfaces::hook_steamclient_interface(steamclient_handle, steamclient_version);
|
steam_interfaces::hook_steamclient_interface(steamclient_handle, steamclient_version);
|
||||||
} else {
|
} else {
|
||||||
@@ -120,7 +125,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_lib_monitor() {
|
void init_lib_monitor() {
|
||||||
|
#if defined(KB_WIN) || defined(KB_64)
|
||||||
kb::lib_monitor::init_listener({{STEAMCLIENT_DLL, on_steamclient_loaded}});
|
kb::lib_monitor::init_listener({{STEAMCLIENT_DLL, on_steamclient_loaded}});
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<AppId_t> get_app_id_from_env() noexcept {
|
std::optional<AppId_t> get_app_id_from_env() noexcept {
|
||||||
@@ -168,12 +175,49 @@ namespace {
|
|||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void init_hook_mode(void* self_module_handle) {
|
||||||
|
is_hook_mode = true;
|
||||||
|
#ifdef KB_LINUX
|
||||||
|
// Because we got injected via LD_PRELOAD,
|
||||||
|
// Linux loader will resolve all SteamAPI exports in unlocker instead of original library.
|
||||||
|
// Hence, we need to patch the stubs even in hook mode.
|
||||||
|
|
||||||
|
const std::string lib_name = STEAM_API_MODULE ".so";
|
||||||
|
for(const auto& lib_path : glob::rglob({"./" + lib_name, "**/" + lib_name})) {
|
||||||
|
if(const auto lib_bitness = kb::lib::get_bitness(lib_path)) {
|
||||||
|
if(static_cast<uint8_t>(*lib_bitness) == kb::platform::bitness) {
|
||||||
|
if(const auto lib_handle = kb::lib::load_library(lib_path)) {
|
||||||
|
LOG_INFO("Found original library: {}", kb::path::to_str(lib_path));
|
||||||
|
|
||||||
|
original_steamapi_handle = *lib_handle;
|
||||||
|
proxy_exports::init(self_module_handle, original_steamapi_handle);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!original_steamapi_handle) {
|
||||||
|
kb::util::panic("Failed to find original " + lib_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_proxy_mode(void* self_module_handle) {
|
||||||
|
is_hook_mode = true;
|
||||||
|
|
||||||
|
original_steamapi_handle = kb::lib::load_original_library(kb::paths::get_self_dir(), STEAM_API_MODULE);
|
||||||
|
#ifdef KB_LINUX
|
||||||
|
proxy_exports::init(self_module_handle, original_steamapi_handle);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace smoke_api {
|
namespace smoke_api {
|
||||||
void init(void* module_handle) {
|
void init(void* self_module_handle) {
|
||||||
try {
|
try {
|
||||||
kb::globals::init_globals(module_handle, PROJECT_NAME);
|
kb::globals::init_globals(self_module_handle, PROJECT_NAME);
|
||||||
|
|
||||||
config::instance = kb::config::parse<config::Config>();
|
config::instance = kb::config::parse<config::Config>();
|
||||||
|
|
||||||
@@ -189,8 +233,8 @@ namespace smoke_api {
|
|||||||
const auto exe_path = kb::lib::get_fs_path(nullptr);
|
const auto exe_path = kb::lib::get_fs_path(nullptr);
|
||||||
const auto exe_name = kb::path::to_str(exe_path.filename());
|
const auto exe_name = kb::path::to_str(exe_path.filename());
|
||||||
|
|
||||||
LOG_DEBUG("Process name: '{}' [{}-bit]", exe_name, kb::util::BITNESS);
|
LOG_DEBUG("Process name: '{}' [{}-bit]", exe_name, kb::platform::bitness);
|
||||||
LOG_DEBUG("Self name: '{}'", kb::path::to_str(kb::lib::get_fs_path(module_handle).filename()));
|
LOG_DEBUG("Self name: '{}'", kb::path::to_str(kb::lib::get_fs_path(self_module_handle).filename()));
|
||||||
|
|
||||||
#ifdef KB_WIN
|
#ifdef KB_WIN
|
||||||
kb::win::check_self_duplicates();
|
kb::win::check_self_duplicates();
|
||||||
@@ -199,25 +243,16 @@ namespace smoke_api {
|
|||||||
// We need to hook functions in either mode
|
// We need to hook functions in either mode
|
||||||
kb::hook::init(true);
|
kb::hook::init(true);
|
||||||
|
|
||||||
if(kb::hook::is_hook_mode(module_handle, STEAM_API_MODULE)) {
|
if(kb::hook::is_hook_mode(self_module_handle, STEAM_API_MODULE)) {
|
||||||
LOG_INFO("Detected hook mode");
|
LOG_INFO("Detected hook mode");
|
||||||
|
init_hook_mode(self_module_handle);
|
||||||
is_hook_mode = true;
|
|
||||||
init_lib_monitor();
|
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Detected proxy mode");
|
LOG_INFO("Detected proxy mode");
|
||||||
|
init_proxy_mode(self_module_handle);
|
||||||
is_hook_mode = true;
|
|
||||||
init_lib_monitor();
|
|
||||||
|
|
||||||
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
|
|
||||||
proxy_exports::init(module_handle, original_steamapi_handle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_lib_monitor();
|
||||||
|
|
||||||
LOG_INFO("Initialization complete");
|
LOG_INFO("Initialization complete");
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
kb::util::panic(std::format("Initialization error: {}", e.what()));
|
kb::util::panic(std::format("Initialization error: {}", e.what()));
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#define DLL_EXPORT(TYPE) extern "C" [[maybe_unused]] __declspec(dllexport) TYPE __cdecl
|
#define DLL_EXPORT(TYPE) extern "C" [[maybe_unused]] __declspec(dllexport) TYPE __cdecl
|
||||||
|
|
||||||
namespace smoke_api {
|
namespace smoke_api {
|
||||||
void init(void* module_handle);
|
void init(void* self_module_handle);
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
AppId_t get_app_id();
|
AppId_t get_app_id();
|
||||||
|
|||||||
Reference in New Issue
Block a user