2019-05-15 20:24:39 +08:00
|
|
|
#include <regex>
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
#include <streambuf>
|
|
|
|
#include <iostream>
|
|
|
|
|
2024-01-06 00:51:59 +08:00
|
|
|
// these are defined in dll.cpp at the top like this:
|
|
|
|
// static char old_xxx[128] = ...
|
2019-05-15 20:24:39 +08:00
|
|
|
|
2024-04-20 07:22:55 +08:00
|
|
|
const static std::vector<std::pair<std::string, std::string>> interface_patterns = {
|
|
|
|
{ R"(SteamClient\d+)", "client" },
|
|
|
|
|
|
|
|
{ R"(SteamGameServerStats\d+)", "gameserver_stats" },
|
|
|
|
{ R"(SteamGameServer\d+)", "gameserver" },
|
|
|
|
|
|
|
|
{ R"(SteamMatchMakingServers\d+)", "matchmaking_servers" },
|
|
|
|
{ R"(SteamMatchMaking\d+)", "matchmaking" },
|
|
|
|
|
|
|
|
{ R"(SteamUser\d+)", "user" },
|
|
|
|
{ R"(SteamFriends\d+)", "friends" },
|
|
|
|
{ R"(SteamUtils\d+)", "utils" },
|
|
|
|
{ R"(STEAMUSERSTATS_INTERFACE_VERSION\d+)", "user_stats" },
|
|
|
|
{ R"(STEAMAPPS_INTERFACE_VERSION\d+)", "apps" },
|
|
|
|
{ R"(SteamNetworking\d+)", "networking" },
|
|
|
|
{ R"(STEAMREMOTESTORAGE_INTERFACE_VERSION\d+)", "remote_storage" },
|
|
|
|
{ R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)", "screenshots" },
|
|
|
|
{ R"(STEAMHTTP_INTERFACE_VERSION\d+)", "http" },
|
|
|
|
{ R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)", "unified_messages" },
|
|
|
|
|
|
|
|
{ R"(STEAMCONTROLLER_INTERFACE_VERSION\d+)", "controller" },
|
|
|
|
{ R"(SteamController\d+)", "controller" },
|
|
|
|
|
|
|
|
{ R"(STEAMUGC_INTERFACE_VERSION\d+)", "ugc" },
|
|
|
|
{ R"(STEAMAPPLIST_INTERFACE_VERSION\d+)", "applist" },
|
|
|
|
{ R"(STEAMMUSIC_INTERFACE_VERSION\d+)", "music" },
|
|
|
|
{ R"(STEAMMUSICREMOTE_INTERFACE_VERSION\d+)", "music_remote" },
|
|
|
|
{ R"(STEAMHTMLSURFACE_INTERFACE_VERSION_\d+)", "html_surface" },
|
|
|
|
{ R"(STEAMINVENTORY_INTERFACE_V\d+)", "inventory" },
|
|
|
|
{ R"(STEAMVIDEO_INTERFACE_V\d+)", "video" },
|
|
|
|
{ R"(SteamMasterServerUpdater\d+)", "masterserver_updater" },
|
2024-01-06 00:51:59 +08:00
|
|
|
};
|
|
|
|
|
2024-04-20 07:22:55 +08:00
|
|
|
unsigned int findinterface(std::ofstream &out_file, const std::string &file_contents, const std::pair<std::string, std::string> &interface_patt)
|
2019-05-15 20:24:39 +08:00
|
|
|
{
|
2024-04-20 07:22:55 +08:00
|
|
|
std::regex interface_regex(interface_patt.first);
|
2019-05-15 20:24:39 +08:00
|
|
|
auto begin = std::sregex_iterator(file_contents.begin(), file_contents.end(), interface_regex);
|
|
|
|
auto end = std::sregex_iterator();
|
|
|
|
|
|
|
|
unsigned int matches = 0;
|
2024-04-20 07:22:55 +08:00
|
|
|
for (std::sregex_iterator itr = begin; itr != end; ++itr) {
|
|
|
|
out_file << interface_patt.second << "=" << itr->str() << std::endl;
|
2019-05-15 20:24:39 +08:00
|
|
|
++matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
if (argc < 2) {
|
2024-01-06 00:51:59 +08:00
|
|
|
std::cerr << "usage: " << argv[0] << " <path to steam_api .dll or .so>" << std::endl;
|
2019-05-15 20:24:39 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ifstream steam_api_file(argv[1], std::ios::binary);
|
2024-01-06 00:51:59 +08:00
|
|
|
if (!steam_api_file.is_open()) {
|
|
|
|
std::cerr << "Error opening file" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string steam_api_contents(
|
|
|
|
(std::istreambuf_iterator<char>(steam_api_file)),
|
|
|
|
std::istreambuf_iterator<char>());
|
2019-05-15 20:24:39 +08:00
|
|
|
steam_api_file.close();
|
|
|
|
|
2024-04-20 07:22:55 +08:00
|
|
|
if (steam_api_contents.empty()) {
|
2024-01-06 00:51:59 +08:00
|
|
|
std::cerr << "Error loading data" << std::endl;
|
2019-05-15 20:24:39 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-01-06 00:51:59 +08:00
|
|
|
unsigned int total_matches = 0;
|
2024-04-20 07:22:55 +08:00
|
|
|
std::ofstream out_file("configs.app.ini");
|
2024-01-06 00:51:59 +08:00
|
|
|
if (!out_file.is_open()) {
|
|
|
|
std::cerr << "Error opening output file" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2019-05-15 20:24:39 +08:00
|
|
|
|
2024-04-20 07:22:55 +08:00
|
|
|
out_file << "[app::steam_interfaces]" << std::endl;
|
2024-01-06 02:23:49 +08:00
|
|
|
for (const auto &patt : interface_patterns) {
|
2024-01-06 00:51:59 +08:00
|
|
|
total_matches += findinterface(out_file, steam_api_contents, patt);
|
2019-05-15 20:24:39 +08:00
|
|
|
}
|
2024-04-20 07:22:55 +08:00
|
|
|
out_file << std::endl;
|
2024-01-06 00:51:59 +08:00
|
|
|
out_file.close();
|
2019-05-15 20:24:39 +08:00
|
|
|
|
2024-01-06 00:51:59 +08:00
|
|
|
if (total_matches == 0) {
|
|
|
|
std::cerr << "No interfaces were found" << std::endl;
|
|
|
|
return 1;
|
2019-05-15 20:24:39 +08:00
|
|
|
}
|
|
|
|
|
2024-01-06 00:51:59 +08:00
|
|
|
return 0;
|
2019-05-15 20:24:39 +08:00
|
|
|
}
|