Merge pull request #30 from Sak32009/dev

update commit third-party\build\win + fix msbuild warnings + improved tools\generate_interfaces\generate_interfaces.cpp + fixed finding of "STEAMCONTROLLER_INTERFACE_VERSION" interface
This commit is contained in:
Detanup01 2024-08-25 01:59:31 +02:00 committed by GitHub
commit 1503cc43d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 46 additions and 36 deletions

View File

@ -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); myfile.open(std::filesystem::u8path(folder + file), std::ios::binary | std::ios::out);
if (!myfile.is_open()) return -1; if (!myfile.is_open()) return -1;
myfile.write(data, length); myfile.write(data, length);
int position = myfile.tellp(); int position = static_cast<int>(myfile.tellp());
myfile.close(); myfile.close();
return position; return position;
} }
@ -666,7 +666,8 @@ int Local_Storage::get_file_data(const std::string &full_path, char *data, unsig
myfile.read (data, max_length); myfile.read (data, max_length);
myfile.close(); myfile.close();
reset_LastError(); 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) int Local_Storage::get_data(std::string folder, std::string file, char *data, unsigned int max_length, unsigned int offset)
@ -700,7 +701,7 @@ int Local_Storage::count_files(std::string folder)
folder.append(PATH_SEPARATOR); 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) bool Local_Storage::file_exists(std::string folder, std::string file)

View File

@ -1384,7 +1384,7 @@ void Steam_Matchmaking::RunCallbacks()
PRINT_DEBUG("Lobby " "%" PRIu64 " use %u", l.room_id(), use); PRINT_DEBUG("Lobby " "%" PRIu64 " use %u", l.room_id(), use);
if (use) PUSH_BACK_IF_NOT_IN(filtered_lobbies, (uint64)l.room_id()); 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()); PRINT_DEBUG("returning lobby search results, count=%zu", filtered_lobbies.size());
searching = false; searching = false;
LobbyMatchList_t data{}; LobbyMatchList_t data{};

View File

@ -807,7 +807,7 @@ void Steam_User_Stats::load_achievements_icons()
auto now1 = std::chrono::high_resolution_clock::now(); auto now1 = std::chrono::high_resolution_clock::now();
#endif #endif
size_t idx = 0; int idx = 0;
for (; for (;
idx < settings->paginated_achievements_icons && last_loaded_ach_icon < defined_achievements.size(); idx < settings->paginated_achievements_icons && last_loaded_ach_icon < defined_achievements.size();
++idx, ++last_loaded_ach_icon) { ++idx, ++last_loaded_ach_icon) {
@ -819,7 +819,7 @@ void Steam_User_Stats::load_achievements_icons()
#ifndef EMU_RELEASE_BUILD #ifndef EMU_RELEASE_BUILD
auto now2 = std::chrono::high_resolution_clock::now(); auto now2 = std::chrono::high_resolution_clock::now();
auto dd = (unsigned)std::chrono::duration_cast<std::chrono::milliseconds>(now2 - now1).count(); 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 #endif
} }

View File

@ -1,18 +1,21 @@
//#include "dll.h"
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
// #include "dll.h"
#include "Windows.h" #include "Windows.h"
#ifdef _WIN64 #ifdef _WIN64
#define DLL_NAME "steam_api64.dll" #define DLL_NAME "steam_api64.dll"
#else #else
#define DLL_NAME "steam_api.dll" #define DLL_NAME "steam_api.dll"
#endif #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); 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); return create_interface(pName);
} }

@ -1 +1 @@
Subproject commit c8c5f528a1a90e7ba786990aa5176a389aae0ec9 Subproject commit 6cf0418a1973e43abc7a34bdf447e4305f4a235f

View File

@ -1,16 +1,14 @@
#include <regex> #include <regex>
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <streambuf>
#include <iostream> #include <iostream>
#include <filesystem> #include <filesystem>
// these are defined in dll.cpp at the top like this: // these are defined in dll.cpp at the top like this:
// static char old_xxx[128] = ... // static char old_xxx[128] = ...
const static std::vector<std::string> interface_patterns = { const static std::vector<std::string> interface_patterns = {
R"(SteamClient\d+)", R"(SteamClient\d+)",
R"(SteamGameServerStats\d+)", R"(SteamGameServerStats\d+)",
R"(SteamGameServer\d+)", R"(SteamGameServer\d+)",
@ -27,10 +25,10 @@ const static std::vector<std::string> interface_patterns = {
R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)", R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)",
R"(STEAMHTTP_INTERFACE_VERSION\d+)", R"(STEAMHTTP_INTERFACE_VERSION\d+)",
R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)", R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)",
R"(STEAMCONTROLLER_INTERFACE_VERSION\d+)", R"(STEAMCONTROLLER_INTERFACE_VERSION)",
R"(SteamController\d+)", R"(SteamController\d+)",
R"(STEAMUGC_INTERFACE_VERSION\d+)", R"(STEAMUGC_INTERFACE_VERSION\d+)",
R"(STEAMAPPLIST_INTERFACE_VERSION\d+)", R"(STEAMAPPLIST_INTERFACE_VERSION\d+)",
R"(STEAMMUSIC_INTERFACE_VERSION\d+)", R"(STEAMMUSIC_INTERFACE_VERSION\d+)",
@ -47,56 +45,64 @@ unsigned int findinterface(
const std::string &interface_patt) const std::string &interface_patt)
{ {
std::regex interface_regex(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(); auto end = std::sregex_iterator();
unsigned int matches = 0; unsigned int matches = 0;
for (std::sregex_iterator i = begin; i != end; ++i) {
std::smatch match = *i; for (std::sregex_iterator i = begin; i != end; ++i)
std::string match_str = match.str(); {
out_file << match_str << std::endl; out_file << i->str() << std::endl;
++matches; ++matches;
} }
return 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; std::cerr << "usage: " << argv[0] << " <path to steam_api .dll or .so>" << std::endl;
return 1; return 1;
} }
std::ifstream steam_api_file(std::filesystem::u8path(argv[1]), std::ios::binary); std::ifstream steam_api_file(std::filesystem::u8path(argv[1]), std::ios::binary);
if (!steam_api_file.is_open()) { if (!steam_api_file)
std::cerr << "Error opening file" << std::endl; {
std::cerr << "Error opening file: " << argv[1] << std::endl;
return 1; return 1;
} }
std::string steam_api_contents( std::string steam_api_contents((std::istreambuf_iterator<char>(steam_api_file)), std::istreambuf_iterator<char>());
(std::istreambuf_iterator<char>(steam_api_file)),
std::istreambuf_iterator<char>());
steam_api_file.close(); steam_api_file.close();
if (steam_api_contents.size() == 0) { if (steam_api_contents.empty())
{
std::cerr << "Error loading data" << std::endl; std::cerr << "Error loading data" << std::endl;
return 1; return 1;
} }
unsigned int total_matches = 0; std::ofstream out_file("steam_interfaces.txt");
std::ofstream out_file(std::filesystem::u8path("steam_interfaces.txt")); if (!out_file)
if (!out_file.is_open()) { {
std::cerr << "Error opening output file" << std::endl; std::cerr << "Error opening output file" << std::endl;
return 1; 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); total_matches += findinterface(out_file, steam_api_contents, patt);
} }
out_file.close(); out_file.close();
if (total_matches == 0) { if (total_matches == 0)
{
std::cerr << "No interfaces were found" << std::endl; std::cerr << "No interfaces were found" << std::endl;
return 1; return 1;
} }