From cf05e58266df143abe6b1bb741728c413a4babaa Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Wed, 15 May 2019 08:24:39 -0400 Subject: [PATCH] Add program to generate steam_interfaces.txt --- Readme_generate_interfaces.txt | 3 ++ Readme_release.txt | 5 ++- build_win_find_interfaces.bat | 7 ++++ build_win_release.bat | 1 + dll/steam_client.cpp | 2 +- generate_interfaces_file.cpp | 77 ++++++++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 Readme_generate_interfaces.txt create mode 100644 build_win_find_interfaces.bat create mode 100644 generate_interfaces_file.cpp diff --git a/Readme_generate_interfaces.txt b/Readme_generate_interfaces.txt new file mode 100644 index 0000000..47d0008 --- /dev/null +++ b/Readme_generate_interfaces.txt @@ -0,0 +1,3 @@ +Just drag your steam_api.dll or steam_api64.dll on the exe file and it will generate a steam_interfaces.txt file. + +If it doesn't work, copy the steam_api dll beside the exe and then drag it on it or open up a command prompt and do: generate_interfaces_file.exe steam_api.dll diff --git a/Readme_release.txt b/Readme_release.txt index af340c1..47b12ad 100644 --- a/Readme_release.txt +++ b/Readme_release.txt @@ -7,8 +7,9 @@ Put a steam_appid.txt file that contains the appid of the game right beside it i If your game has an original steam_api(64).dll older than may 2016 (Properties->Digital Signatures->Timestamp) you might have to add a steam_interfaces.txt beside my emulator library if the game isn't working. -This file contains interface versions, an example (for resident evil 5) is provided. -If you are on linux you can look in the linux/tools folder (or the scripts folder in the repo) for a script to generate the steam_interfaces.txt file. +This file contains interface versions, an example (for resident evil 5) is provided. +If you are on Windows, look in the tools folder for a program to generate the steam_interfaces.txt file. +If you are on linux you can look in the linux/tools folder (or the scripts folder in the repo) for a script to generate the steam_interfaces.txt file. You can also just get a hex editor and search for them (Search for the string: SteamUser0) in the original steam_api dll (or libsteam_api.so on linux) or look in the ini of a crack that works on that game. diff --git a/build_win_find_interfaces.bat b/build_win_find_interfaces.bat new file mode 100644 index 0000000..8a92ef5 --- /dev/null +++ b/build_win_find_interfaces.bat @@ -0,0 +1,7 @@ +mkdir release\tools +del /Q release\tools\* +call build_env_x86.bat +cl generate_interfaces_file.cpp /EHsc /MP12 /Ox /link /debug:none /OUT:release\tools\generate_interfaces_file.exe +del /Q /S release\tools\*.lib +del /Q /S release\tools\*.exp +copy Readme_generate_interfaces.txt release\tools\Readme_generate_interfaces.txt diff --git a/build_win_release.bat b/build_win_release.bat index c9d0f9f..329012d 100644 --- a/build_win_release.bat +++ b/build_win_release.bat @@ -16,3 +16,4 @@ copy Readme_release.txt release\Readme.txt xcopy /s files_example\* release\ call build_win_release_experimental.bat call build_win_lobby_connect.bat +call build_win_find_interfaces.bat diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 2143b8b..6377209 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -684,7 +684,7 @@ void *Steam_Client::GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe return GetISteamFriends(hSteamUser, hSteamPipe, pchVersion); } else if (strstr(pchVersion, "SteamMatchMaking") == pchVersion) { return GetISteamMatchmaking(hSteamUser, hSteamPipe, pchVersion); - } else if (strstr(pchVersion, "SteamController") == pchVersion) { + } else if (strstr(pchVersion, "SteamController") == pchVersion || strstr(pchVersion, "STEAMCONTROLLER_INTERFACE_VERSION") == pchVersion) { return GetISteamController(hSteamUser, hSteamPipe, pchVersion); } else if (strstr(pchVersion, "STEAMUGC_INTERFACE_VERSION") == pchVersion) { return GetISteamUGC(hSteamUser, hSteamPipe, pchVersion); diff --git a/generate_interfaces_file.cpp b/generate_interfaces_file.cpp new file mode 100644 index 0000000..e2e0364 --- /dev/null +++ b/generate_interfaces_file.cpp @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include + + +unsigned int findinterface(std::ofstream &out_file, std::string &file_contents, std::string interface) +{ + std::regex interface_regex(interface); + auto begin = std::sregex_iterator(file_contents.begin(), file_contents.end(), interface_regex); + auto end = std::sregex_iterator(); + + unsigned int matches = 0; + for (std::sregex_iterator i = begin; i != end; ++i) { + std::smatch match = *i; + std::string match_str = match.str(); + out_file << match_str << std::endl; + ++matches; + } + + return matches; +} + +int main (int argc, char *argv[]) +{ + if (argc < 2) { + std::cout << "usage: " << argv[0] << " " << std::endl; + return 1; + } + + std::ifstream steam_api_file(argv[1], std::ios::binary); + std::string steam_api_contents((std::istreambuf_iterator(steam_api_file)), + std::istreambuf_iterator()); + steam_api_file.close(); + + if (steam_api_contents.size() == 0) { + std::cout << "Error opening file" << std::endl; + return 1; + } + + std::ofstream out_file("steam_interfaces.txt"); + std::vector interface_names = {"SteamClient", + "SteamGameServer", + "SteamGameServerStats", + "SteamUser", + "SteamFriends", + "SteamUtils", + "SteamMatchMaking", + "SteamMatchMakingServers", + "STEAMUSERSTATS_INTERFACE_VERSION", + "STEAMAPPS_INTERFACE_VERSION", + "SteamNetworking", + "STEAMREMOTESTORAGE_INTERFACE_VERSION", + "STEAMSCREENSHOTS_INTERFACE_VERSION", + "STEAMHTTP_INTERFACE_VERSION", + "STEAMUNIFIEDMESSAGES_INTERFACE_VERSION", + "STEAMUGC_INTERFACE_VERSION", + "STEAMAPPLIST_INTERFACE_VERSION", + "STEAMMUSIC_INTERFACE_VERSION", + "STEAMMUSICREMOTE_INTERFACE_VERSION", + "STEAMHTMLSURFACE_INTERFACE_VERSION_", + "STEAMINVENTORY_INTERFACE_V", + "SteamController", + "SteamMasterServerUpdater", + "STEAMVIDEO_INTERFACE_V"}; + + for (auto name : interface_names) { + findinterface(out_file, steam_api_contents, name + "\\d{3}"); + } + + if (!findinterface(out_file, steam_api_contents, "STEAMCONTROLLER_INTERFACE_VERSION\\d{3}")) { + findinterface(out_file, steam_api_contents, "STEAMCONTROLLER_INTERFACE_VERSION"); + } + + out_file.close(); +}