2019-05-15 20:24:39 +08:00
|
|
|
#include <regex>
|
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
2024-06-29 13:15:57 +08:00
|
|
|
#include <filesystem>
|
2019-05-15 20:24:39 +08:00
|
|
|
|
2024-01-06 00:51:59 +08:00
|
|
|
// these are defined in dll.cpp at the top like this:
|
|
|
|
// static char old_xxx[128] = ...
|
2024-04-23 10:37:18 +08:00
|
|
|
const static std::vector<std::string> interface_patterns = {
|
|
|
|
R"(SteamClient\d+)",
|
2024-08-25 02:02:04 +08:00
|
|
|
|
2024-04-23 10:37:18 +08:00
|
|
|
R"(SteamGameServerStats\d+)",
|
|
|
|
R"(SteamGameServer\d+)",
|
|
|
|
|
|
|
|
R"(SteamMatchMakingServers\d+)",
|
|
|
|
R"(SteamMatchMaking\d+)",
|
|
|
|
|
|
|
|
R"(SteamUser\d+)",
|
|
|
|
R"(SteamFriends\d+)",
|
|
|
|
R"(SteamUtils\d+)",
|
|
|
|
R"(STEAMUSERSTATS_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMAPPS_INTERFACE_VERSION\d+)",
|
|
|
|
R"(SteamNetworking\d+)",
|
|
|
|
R"(STEAMREMOTESTORAGE_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMHTTP_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)",
|
2024-08-25 02:02:04 +08:00
|
|
|
|
|
|
|
R"(STEAMCONTROLLER_INTERFACE_VERSION)",
|
2024-04-23 10:37:18 +08:00
|
|
|
R"(SteamController\d+)",
|
2024-08-25 02:02:04 +08:00
|
|
|
|
2024-04-23 10:37:18 +08:00
|
|
|
R"(STEAMUGC_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMAPPLIST_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMMUSIC_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMMUSICREMOTE_INTERFACE_VERSION\d+)",
|
|
|
|
R"(STEAMHTMLSURFACE_INTERFACE_VERSION_\d+)",
|
|
|
|
R"(STEAMINVENTORY_INTERFACE_V\d+)",
|
|
|
|
R"(STEAMVIDEO_INTERFACE_V\d+)",
|
|
|
|
R"(SteamMasterServerUpdater\d+)",
|
2024-01-06 00:51:59 +08:00
|
|
|
};
|
|
|
|
|
2024-04-23 10:37:18 +08:00
|
|
|
unsigned int findinterface(
|
|
|
|
std::ofstream &out_file,
|
|
|
|
const std::string &file_contents,
|
|
|
|
const std::string &interface_patt)
|
2019-05-15 20:24:39 +08:00
|
|
|
{
|
2024-04-23 10:37:18 +08:00
|
|
|
std::regex interface_regex(interface_patt);
|
2024-08-25 02:02:04 +08:00
|
|
|
|
|
|
|
auto begin = std::sregex_iterator(file_contents.cbegin(), file_contents.cend(), interface_regex);
|
2019-05-15 20:24:39 +08:00
|
|
|
auto end = std::sregex_iterator();
|
|
|
|
|
|
|
|
unsigned int matches = 0;
|
2024-08-25 02:02:04 +08:00
|
|
|
|
|
|
|
for (std::sregex_iterator i = begin; i != end; ++i)
|
|
|
|
{
|
|
|
|
out_file << i->str() << std::endl;
|
2019-05-15 20:24:39 +08:00
|
|
|
++matches;
|
|
|
|
}
|
|
|
|
|
|
|
|
return matches;
|
|
|
|
}
|
|
|
|
|
2024-08-25 02:02:04 +08:00
|
|
|
int main(int argc, char *argv[])
|
2019-05-15 20:24:39 +08:00
|
|
|
{
|
2024-08-25 02:02:04 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-06-29 13:15:57 +08:00
|
|
|
std::ifstream steam_api_file(std::filesystem::u8path(argv[1]), std::ios::binary);
|
2024-08-25 02:02:04 +08:00
|
|
|
if (!steam_api_file)
|
|
|
|
{
|
|
|
|
std::cerr << "Error opening file: " << argv[1] << std::endl;
|
2024-01-06 00:51:59 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2024-08-25 02:02:04 +08:00
|
|
|
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-08-25 02:02:04 +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-08-25 02:02:04 +08:00
|
|
|
std::ofstream out_file("steam_interfaces.txt");
|
|
|
|
if (!out_file)
|
|
|
|
{
|
2024-01-06 00:51:59 +08:00
|
|
|
std::cerr << "Error opening output file" << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
2019-05-15 20:24:39 +08:00
|
|
|
|
2024-08-25 02:02:04 +08:00
|
|
|
unsigned int total_matches = 0;
|
|
|
|
|
|
|
|
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-08-25 02:02:04 +08:00
|
|
|
|
2024-01-06 00:51:59 +08:00
|
|
|
out_file.close();
|
2019-05-15 20:24:39 +08:00
|
|
|
|
2024-08-25 02:02:04 +08:00
|
|
|
if (total_matches == 0)
|
|
|
|
{
|
2024-01-06 00:51:59 +08:00
|
|
|
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
|
|
|
}
|