Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update commit third-party\build\win + fix msbuild warnings + improved tools\generate_interfaces\generate_interfaces.cpp + fixed finding of "STEAMCONTROLLER_INTERFACE_VERSION" interface #30

Merged
merged 3 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions dll/local_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ int Local_Storage::store_file_data(std::string folder, std::string file, const c
myfile.open(std::filesystem::u8path(folder + file), std::ios::binary | std::ios::out);
if (!myfile.is_open()) return -1;
myfile.write(data, length);
int position = myfile.tellp();
int position = static_cast<int>(myfile.tellp());
myfile.close();
return position;
}
Expand Down Expand Up @@ -666,7 +666,8 @@ int Local_Storage::get_file_data(const std::string &full_path, char *data, unsig
myfile.read (data, max_length);
myfile.close();
reset_LastError();
return myfile.gcount();

return static_cast<int>(myfile.gcount());
}

int Local_Storage::get_data(std::string folder, std::string file, char *data, unsigned int max_length, unsigned int offset)
Expand Down Expand Up @@ -700,7 +701,7 @@ int Local_Storage::count_files(std::string folder)
folder.append(PATH_SEPARATOR);
}

return get_filenames_recursive(save_directory + appid + folder).size();
return static_cast<int>(get_filenames_recursive(save_directory + appid + folder).size());
}

bool Local_Storage::file_exists(std::string folder, std::string file)
Expand Down
2 changes: 1 addition & 1 deletion dll/steam_matchmaking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ void Steam_Matchmaking::RunCallbacks()

PRINT_DEBUG("Lobby " "%" PRIu64 " use %u", l.room_id(), use);
if (use) PUSH_BACK_IF_NOT_IN(filtered_lobbies, (uint64)l.room_id());
if (filtered_lobbies.size() >= filter_max_results_copy) {
if (filtered_lobbies.size() >= static_cast<size_t>(filter_max_results_copy)) {
PRINT_DEBUG("returning lobby search results, count=%zu", filtered_lobbies.size());
searching = false;
LobbyMatchList_t data{};
Expand Down
4 changes: 2 additions & 2 deletions dll/steam_user_stats_achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ void Steam_User_Stats::load_achievements_icons()
auto now1 = std::chrono::high_resolution_clock::now();
#endif

size_t idx = 0;
int idx = 0;
for (;
idx < settings->paginated_achievements_icons && last_loaded_ach_icon < defined_achievements.size();
++idx, ++last_loaded_ach_icon) {
Expand All @@ -819,7 +819,7 @@ void Steam_User_Stats::load_achievements_icons()
#ifndef EMU_RELEASE_BUILD
auto now2 = std::chrono::high_resolution_clock::now();
auto dd = (unsigned)std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count();
PRINT_DEBUG("attempted to load %zu achievements icons in %u ms", idx * 2, dd);
PRINT_DEBUG("attempted to load %d achievements icons in %u ms", idx * 2, dd);
#endif

}
13 changes: 8 additions & 5 deletions steamclient/steamclient.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@

//#include "dll.h"
#define WIN32_LEAN_AND_MEAN

// #include "dll.h"
#include "Windows.h"

#ifdef _WIN64
#define DLL_NAME "steam_api64.dll"
#else
#define DLL_NAME "steam_api.dll"
#endif

extern "C" __declspec( dllexport ) void *CreateInterface( const char *pName, int *pReturnCode )
extern "C" __declspec(dllexport) void *CreateInterface(const char *pName, int *pReturnCode)
{
//PRINT_DEBUG("%s", pName);
// PRINT_DEBUG("%s", pName);

HMODULE steam_api = LoadLibraryA(DLL_NAME);
void *(__stdcall* create_interface)(const char*) = (void * (__stdcall *)(const char*))GetProcAddress(steam_api, "SteamInternal_CreateInterface");

void *(__stdcall * create_interface)(const char *) = reinterpret_cast<void *(__stdcall *)(const char *)>(GetProcAddress(steam_api, "SteamInternal_CreateInterface"));

return create_interface(pName);
}
2 changes: 1 addition & 1 deletion third-party/build/win
Submodule win updated from c8c5f5 to 6cf041
54 changes: 30 additions & 24 deletions tools/generate_interfaces/generate_interfaces.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#include <regex>
#include <string>
#include <fstream>
#include <streambuf>
#include <iostream>
#include <filesystem>

// these are defined in dll.cpp at the top like this:
// static char old_xxx[128] = ...

const static std::vector<std::string> interface_patterns = {
R"(SteamClient\d+)",

R"(SteamGameServerStats\d+)",
R"(SteamGameServer\d+)",

Expand All @@ -27,10 +25,10 @@ const static std::vector<std::string> interface_patterns = {
R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)",
R"(STEAMHTTP_INTERFACE_VERSION\d+)",
R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)",
R"(STEAMCONTROLLER_INTERFACE_VERSION\d+)",

R"(STEAMCONTROLLER_INTERFACE_VERSION)",
R"(SteamController\d+)",

R"(STEAMUGC_INTERFACE_VERSION\d+)",
R"(STEAMAPPLIST_INTERFACE_VERSION\d+)",
R"(STEAMMUSIC_INTERFACE_VERSION\d+)",
Expand All @@ -47,56 +45,64 @@ unsigned int findinterface(
const std::string &interface_patt)
{
std::regex interface_regex(interface_patt);
auto begin = std::sregex_iterator(file_contents.begin(), file_contents.end(), interface_regex);

auto begin = std::sregex_iterator(file_contents.cbegin(), file_contents.cend(), 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;

for (std::sregex_iterator i = begin; i != end; ++i)
{
out_file << i->str() << std::endl;
++matches;
}

return matches;
}

int main (int argc, char *argv[])
int main(int argc, char *argv[])
{
if (argc < 2) {
if (argc < 2)
{
std::cerr << "usage: " << argv[0] << " <path to steam_api .dll or .so>" << std::endl;
return 1;
}

std::ifstream steam_api_file(std::filesystem::u8path(argv[1]), std::ios::binary);
if (!steam_api_file.is_open()) {
std::cerr << "Error opening file" << std::endl;
if (!steam_api_file)
{
std::cerr << "Error opening file: " << argv[1] << std::endl;
return 1;
}

std::string steam_api_contents(
(std::istreambuf_iterator<char>(steam_api_file)),
std::istreambuf_iterator<char>());
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) {
if (steam_api_contents.empty())
{
std::cerr << "Error loading data" << std::endl;
return 1;
}

unsigned int total_matches = 0;
std::ofstream out_file(std::filesystem::u8path("steam_interfaces.txt"));
if (!out_file.is_open()) {
std::ofstream out_file("steam_interfaces.txt");
if (!out_file)
{
std::cerr << "Error opening output file" << std::endl;
return 1;
}

for (const auto &patt : interface_patterns) {
unsigned int total_matches = 0;

for (const auto &patt : interface_patterns)
{
total_matches += findinterface(out_file, steam_api_contents, patt);
}

out_file.close();

if (total_matches == 0) {
if (total_matches == 0)
{
std::cerr << "No interfaces were found" << std::endl;
return 1;
}
Expand Down