From 1fd5471502d8d737ad79566077e3beee9f143d46 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Sun, 16 Jun 2019 00:14:05 +0200 Subject: [PATCH 1/4] Fixed find_interfaces.ps1 Added a condition to test steam_api.dll or steam_api64.dll. Used the ASCII encoding, last version was using UTF-16 with BOM making the emu read really strange interfaces :). --- scripts/find_interfaces.ps1 | 71 ++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/scripts/find_interfaces.ps1 b/scripts/find_interfaces.ps1 index fb7b23a..4d0c53a 100644 --- a/scripts/find_interfaces.ps1 +++ b/scripts/find_interfaces.ps1 @@ -3,37 +3,58 @@ $fi = $args[0] if( ! $fi ) { $fi = "steam_api.dll" + + if( !(Test-Path $fi) ) + { + $fi = "steam_api64.dll" + } + + if( !(Test-Path $fi) ) + { + Write-Output "Failed to find steam_api or steam_api64" + Return 1 + } +} +else +{ + if( !(Test-Path $fi) ) + { + Write-Output "Failed to find $fi" + Return 1 + } } -function findinterface($api) +function findinterface + +($api) { $str = Select-String "$api[0-9][0-9][0-9]" $fi if( $str -match "$api[0-9]{3}" ) { Write-Output "$($matches[0])" - } + } } -findinterface SteamClient >steam_interfaces.txt -findinterface SteamGameServer >>steam_interfaces.txt -findinterface SteamGameServerStats >>steam_interfaces.txt -findinterface SteamUser >>steam_interfaces.txt -findinterface SteamFriends >>steam_interfaces.txt -findinterface SteamUtils >>steam_interfaces.txt -findinterface SteamMatchMaking >>steam_interfaces.txt -findinterface SteamMatchMakingServers >>steam_interfaces.txt -findinterface STEAMUSERSTATS_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMAPPS_INTERFACE_VERSION >>steam_interfaces.txt -findinterface SteamNetworking >>steam_interfaces.txt -findinterface STEAMREMOTESTORAGE_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMSCREENSHOTS_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMHTTP_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMUNIFIEDMESSAGES_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMCONTROLLER_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMUGC_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMAPPLIST_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMMUSIC_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMMUSICREMOTE_INTERFACE_VERSION >>steam_interfaces.txt -findinterface STEAMHTMLSURFACE_INTERFACE_VERSION_ >>steam_interfaces.txt -findinterface STEAMINVENTORY_INTERFACE_V >>steam_interfaces.txt -findinterface SteamController >>steam_interfaces.txt \ No newline at end of file +findinterface SteamClient | Out-File -Encoding ASCII -FilePath steam_interfaces.txt +findinterface SteamGameServer | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamGameServerStats | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamUser | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamFriends | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamUtils | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamMatchMaking | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamMatchMakingServers | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMUSERSTATS_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMAPPS_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamNetworking | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMREMOTESTORAGE_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMSCREENSHOTS_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMHTTP_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMUNIFIEDMESSAGES_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMCONTROLLER_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMUGC_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMAPPLIST_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMMUSIC_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMMUSICREMOTE_INTERFACE_VERSION | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMHTMLSURFACE_INTERFACE_VERSION_ | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface STEAMINVENTORY_INTERFACE_V | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt +findinterface SteamController | Out-File -Encoding ASCII -Append -FilePath steam_interfaces.txt \ No newline at end of file From 6d22c4989eca9a0f4cc3e8a387b811fbe72caf3e Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Sun, 16 Jun 2019 12:10:51 +0200 Subject: [PATCH 2/4] Modified Sanitize Modified Sanitize to allow all ANSI printable chars. --- dll/settings.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dll/settings.cpp b/dll/settings.cpp index f71f588..affa95f 100644 --- a/dll/settings.cpp +++ b/dll/settings.cpp @@ -23,11 +23,10 @@ std::string Settings::sanitize(std::string name) name.erase(std::remove(name.begin(), name.end(), '\n'), name.end()); name.erase(std::remove(name.begin(), name.end(), '\r'), name.end()); - for (int i = 0; i < name.size(); ++i) { - if (name[i] >= 'a' && name[i] <= 'z') continue; - if (name[i] >= 'A' && name[i] <= 'Z') continue; - if (name[i] >= '0' && name[i] <= '9') continue; - name[i] = ' '; + for (auto& i : name) + { + if (!isprint(i)) + i = ' '; } return name; From b034ee878166f92848d414eda3afc94a77a6ad93 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Tue, 18 Jun 2019 00:25:56 +0200 Subject: [PATCH 3/4] Changed param source in strncpy In strncpy its the destination size that should be in the 3rd parameter. --- dll/net.proto | 6 +++++- dll/steam_friends.h | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/dll/net.proto b/dll/net.proto index a6d6414..9808822 100644 --- a/dll/net.proto +++ b/dll/net.proto @@ -176,10 +176,14 @@ message Auth_Ticket { message Friend_Messages { enum Types { LOBBY_INVITE = 0; + GAME_INVITE = 1; } Types type = 1; - uint64 lobby_id = 2; + oneof invite_data { + uint64 lobby_id = 2; + bytes connect_str = 3; + } } message Common_Message { diff --git a/dll/steam_friends.h b/dll/steam_friends.h index 039b5a1..105186d 100644 --- a/dll/steam_friends.h +++ b/dll/steam_friends.h @@ -545,6 +545,7 @@ void SetPlayedWith( CSteamID steamIDUserPlayedWith ) void ActivateGameOverlayInviteDialog( CSteamID steamIDLobby ) { PRINT_DEBUG("Steam_Friends::ActivateGameOverlayInviteDialog\n"); + // TODO: Here open the overlay } // gets the small (32x32) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set @@ -775,8 +776,14 @@ void RequestFriendRichPresence( CSteamID steamIDFriend ) bool InviteUserToGame( CSteamID steamIDFriend, const char *pchConnectString ) { PRINT_DEBUG("Steam_Friends::InviteUserToGame\n"); - //TODO - return true; + Common_Message msg; + Friend_Messages *friend_messages = new Friend_Messages(); + friend_messages->set_type(Friend_Messages::GAME_INVITE); + friend_messages->set_connect_str(pchConnectString); + msg.set_allocated_friend_messages(friend_messages); + msg.set_source_id(settings->get_local_steam_id().ConvertToUint64()); + msg.set_dest_id(steamIDFriend.ConvertToUint64()); + return network->sendTo(&msg, true); } @@ -1021,6 +1028,15 @@ void Callback(Common_Message *msg) data.m_steamIDFriend = CSteamID((uint64)msg->source_id()); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); } + + if (msg->friend_messages().type() == Friend_Messages::GAME_INVITE) { + PRINT_DEBUG("Steam_Friends Got Game Invite\n"); + std::string const& connect_str = msg->friend_messages().connect_str(); + GameRichPresenceJoinRequested_t data; + data.m_steamIDFriend = CSteamID((uint64)msg->source_id()); + strncpy(data.m_rgchConnect, connect_str.c_str(), k_cchMaxRichPresenceValueLength); + callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); + } } } From aa9e3c0c46e00efba870ab901a4d64d39eef29d8 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Wed, 10 Jul 2019 08:03:40 -0400 Subject: [PATCH 4/4] Small improvements to last commit. --- dll/steam_friends.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dll/steam_friends.h b/dll/steam_friends.h index 105186d..145a1d5 100644 --- a/dll/steam_friends.h +++ b/dll/steam_friends.h @@ -776,6 +776,10 @@ void RequestFriendRichPresence( CSteamID steamIDFriend ) bool InviteUserToGame( CSteamID steamIDFriend, const char *pchConnectString ) { PRINT_DEBUG("Steam_Friends::InviteUserToGame\n"); + std::lock_guard lock(global_mutex); + Friend *f = find_friend(steamIDFriend); + if (!f) return false; + Common_Message msg; Friend_Messages *friend_messages = new Friend_Messages(); friend_messages->set_type(Friend_Messages::GAME_INVITE); @@ -1028,13 +1032,14 @@ void Callback(Common_Message *msg) data.m_steamIDFriend = CSteamID((uint64)msg->source_id()); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); } - + if (msg->friend_messages().type() == Friend_Messages::GAME_INVITE) { PRINT_DEBUG("Steam_Friends Got Game Invite\n"); + //TODO: I'm pretty sure that the user should accept the invite before this is posted but we do like above std::string const& connect_str = msg->friend_messages().connect_str(); - GameRichPresenceJoinRequested_t data; + GameRichPresenceJoinRequested_t data = {}; data.m_steamIDFriend = CSteamID((uint64)msg->source_id()); - strncpy(data.m_rgchConnect, connect_str.c_str(), k_cchMaxRichPresenceValueLength); + strncpy(data.m_rgchConnect, connect_str.c_str(), k_cchMaxRichPresenceValueLength - 1); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); } }