-
Notifications
You must be signed in to change notification settings - Fork 14
/
generate_interfaces_file.cpp
77 lines (66 loc) · 3.3 KB
/
generate_interfaces_file.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <regex>
#include <string>
#include <fstream>
#include <streambuf>
#include <iostream>
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] << " <path to steam_api .dll or .so>" << std::endl;
return 1;
}
std::ifstream steam_api_file(argv[1], std::ios::binary);
std::string steam_api_contents((std::istreambuf_iterator<char>(steam_api_file)),
std::istreambuf_iterator<char>());
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<std::string> 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();
}