mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-05 21:15:39 -05:00
Fixed late hooking
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
|
||||
project(SmokeAPI VERSION 3.1.3)
|
||||
project(SmokeAPI VERSION 3.1.5)
|
||||
|
||||
include(KoalaBox/cmake/KoalaBox.cmake)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: 44be3bf94f...183184cf5b
@@ -82,7 +82,7 @@ If that didn't work, refer to the _Troubleshooting_ section below.
|
||||
### 🪝 Hook mode
|
||||
|
||||
- Download the [latest SmokeAPI release zip].
|
||||
- From this downloaded zip extract `SmokeAPI32.dll` or `SmokeAPI64.dll`, depending on a game's bitness.
|
||||
- From this downloaded zip extract `smoke_api32.dll` or `smoke_api64.dll`, depending on a game's bitness.
|
||||
- Rename the unzipped DLL to `version.dll`.
|
||||
- Place this `version.dll` next to the game's `.exe` file.
|
||||
|
||||
@@ -99,8 +99,8 @@ For example, assuming that the game loads `winmm.dll`:
|
||||
- Place `winmm.dll` next to the game's `.exe` file.
|
||||
- Install SmokeAPI
|
||||
- Download the [latest SmokeAPI release zip].
|
||||
- From this downloaded zip extract `SmokeAPI32.dll` or `SmokeAPI64.dll`, depending on a game's bitness.
|
||||
- Place `SmokeAPI32.dll` or `SmokeAPI64.dll` next to the game's `.exe` file.
|
||||
- From this downloaded zip extract `smoke_api32.dll` or `smoke_api64.dll`, depending on a game's bitness.
|
||||
- Place `smoke_api32.dll` or `smoke_api64.dll` next to the game's `.exe` file.
|
||||
|
||||
#### 🪝 Hook mode with Special K
|
||||
|
||||
@@ -111,7 +111,7 @@ In such cases, it might be worth trying [Special K], which can inject SmokeAPI a
|
||||
|
||||
- Find a `steam_api.dll` or `steam_api64.dll` file in game directory, and rename it to `steam_api_o.dll` or `steam_api64_o.dll`.
|
||||
- Download the [latest SmokeAPI release zip].
|
||||
- From this downloaded zip extract `SmokeAPI32.dll` or `SmokeAPI64.dll`, depending on a game's bitness.
|
||||
- From this downloaded zip extract `smoke_api32.dll` or `smoke_api64.dll`, depending on a game's bitness.
|
||||
- Rename this extracted DLL to `steam_api.dll` or `steam_api64.dll`, depending on a game's bitness.
|
||||
- Place this renamed unlocker DLL next to the `steam_api_o.dll` or `steam_api64_o.dll` file.
|
||||
|
||||
@@ -309,6 +309,7 @@ This project makes use of the following open source projects:
|
||||
- [pantor/inja](https://github.com/pantor/inja)
|
||||
- [bshoshany/thread-pool](https://github.com/bshoshany/thread-pool)
|
||||
- [batterycenter/embed](https://github.com/batterycenter/embed)
|
||||
- [serge1/ELFIO](https://github.com/serge1/ELFIO)
|
||||
|
||||
## 📄 License
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ namespace {
|
||||
namespace kb = koalabox;
|
||||
|
||||
void* original_steamapi_handle = nullptr;
|
||||
bool is_hook_mode;
|
||||
|
||||
std::set<std::string> find_steamclient_versions(void* steamapi_handle) {
|
||||
if(!steamapi_handle) {
|
||||
@@ -80,13 +81,19 @@ namespace {
|
||||
#endif
|
||||
}
|
||||
|
||||
// ReSharper disable once CppDFAConstantFunctionResult
|
||||
bool on_steamclient_loaded(void* steamclient_handle) {
|
||||
static const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
||||
KB_HOOK_DETOUR_MODULE(CreateInterface, steamclient_handle);
|
||||
|
||||
auto* steamapi_handle = original_steamapi_handle
|
||||
? original_steamapi_handle
|
||||
: kb::lib::get_library_handle(STEAM_API_MODULE);
|
||||
if(steamapi_handle) {
|
||||
if(!is_hook_mode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for late hooking
|
||||
|
||||
static const auto CreateInterface$ = KB_LIB_GET_FUNC(steamclient_handle, CreateInterface);
|
||||
|
||||
if(auto* steamapi_handle = kb::lib::get_library_handle(STEAM_API_MODULE)) {
|
||||
// SteamAPI might have been initialized.
|
||||
// Hence, we need to query SteamClient interfaces and hook them if needed.
|
||||
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
||||
@@ -101,15 +108,11 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
KB_HOOK_DETOUR_MODULE(CreateInterface, steamclient_handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void init_lib_monitor() {
|
||||
kb::lib_monitor::init_listener(
|
||||
{{STEAMCLIENT_DLL, on_steamclient_loaded}}
|
||||
);
|
||||
kb::lib_monitor::init_listener({{STEAMCLIENT_DLL, on_steamclient_loaded}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +136,7 @@ namespace smoke_api {
|
||||
const auto exe_name = kb::path::to_str(exe_path.filename());
|
||||
|
||||
LOG_DEBUG("Process name: '{}' [{}-bit]", exe_name, kb::util::BITNESS);
|
||||
LOG_DEBUG("Self handle: {}", module_handle);
|
||||
LOG_DEBUG("Self name: '{}'", kb::path::to_str(kb::lib::get_fs_path(module_handle).filename()));
|
||||
|
||||
// We need to hook functions in either mode
|
||||
kb::hook::init(true);
|
||||
@@ -141,17 +144,16 @@ namespace smoke_api {
|
||||
if(kb::hook::is_hook_mode(module_handle, STEAM_API_MODULE)) {
|
||||
LOG_INFO("Detected hook mode");
|
||||
|
||||
is_hook_mode = true;
|
||||
init_lib_monitor();
|
||||
} else {
|
||||
LOG_INFO("Detected proxy mode");
|
||||
|
||||
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
|
||||
);
|
||||
original_steamapi_handle = kb::lib::load_original_library(self_path, STEAM_API_MODULE);
|
||||
}
|
||||
|
||||
LOG_INFO("Initialization complete");
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace steam_interfaces {
|
||||
// Map virtual hook map to a set of keys
|
||||
const auto prefixes = std::views::keys(virtual_hook_map) | std::ranges::to<std::set>();
|
||||
|
||||
const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
||||
const auto CreateInterface$ = KB_LIB_GET_FUNC(steamclient_handle, CreateInterface);
|
||||
|
||||
DECLARE_ARGS();
|
||||
THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"sdk_dll_names": "`steam_api.dll` or `steam_api64.dll`",
|
||||
"sdk_dll_orig_names": "`steam_api_o.dll` or `steam_api64_o.dll`",
|
||||
"show_3rd_party_point": true,
|
||||
"unlocker_dll_names": "`SmokeAPI32.dll` or `SmokeAPI64.dll`",
|
||||
"unlocker_dll_names": "`smoke_api32.dll` or `smoke_api64.dll`",
|
||||
"config_filename": "SmokeAPI.config.json",
|
||||
"github_repo_url": "https://github.com/acidicoala/SmokeAPI",
|
||||
"forum_topic_url": "https://cs.rin.ru/forum/viewtopic.php?p=2597932#p2597932",
|
||||
|
||||
Reference in New Issue
Block a user