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

Add some missing implementations #8

Merged
merged 6 commits into from
Aug 18, 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
60 changes: 60 additions & 0 deletions dev.notes/how to add a branch as a submodule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
1. create an orphan branch
```shell
git checkout --orphan 'third-party/my-branch'
```
2. make sure no files are staged yet
```shell
git rm -r -f --cached .
```
3. copy some new files (or add ones that already exist)
```shell
cp ~/myfile.txt ./
```
4. stage the required files
```shell
git add myfile.txt
```
you can also stage all files in the current directory
```shell
git add .
```
5. commit the files
```shell
git commit -m 'my commit msg'
```
6. add the branch as submodule
```shell
git -c protocol.file.allow=always submodule add -f -b 'third-party/my-branch' file://"$(pwd)" 'my-relative-dir/without/dot/at/beginning'
```
git by default disallow local repos, this option `protocol.file.allow=always` forces git to allow it
this will:
- look for a **local** repo in the directory shown by `pwd` (current folder),
notice how we don't simply use `./` because if we did that git will try to use the `origin` of the repo,
and since the origin (github/gitlab/etc...) doesn't have this branch yet it will fail, using the file protocol (`file://absolute_path`) forces git to use the local repo files
you can of course push the branch to origin before doing this step
- look for a branch named `third-party/my-branch`
- create a submodule pointing at this branch inside a new folder `my-relative-dir/without/dot/at/beginning`
notice that the new folder does **not** start with `./` as usual
7. fix the submodule path
after the last command, the file `.gitmodules` will point at the absolute path of the repo on disk, fix it to be relative
```shell
git -c protocol.file.allow=always submodule add -f -b 'third-party/my-branch' ./ 'my-relative-dir/without/dot/at/beginning'
```
this time git won't try to grab the data from origin, it will just edit `.gitmodules`
8. new git management objects/files will be staged, you can view them
```shell
git status
```
possible output
```shell
On branch third-party/my-branch

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: .gitmodules
new file: third-party/my-branch
```
9. commit these 2 files
```shell
git commit -m 'add branch third-party/my-branch as submodule'
```
8 changes: 7 additions & 1 deletion dll/dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,13 @@ STEAMCLIENT_API steam_bool Steam_GetAPICallResult( HSteamPipe hSteamPipe, SteamA
STEAMCLIENT_API void *CreateInterface( const char *pName, int *pReturnCode )
{
PRINT_DEBUG("%s %p", pName, pReturnCode);
return create_client_interface(pName);
auto ptr = create_client_interface(pName);
if (ptr) {
if (pReturnCode) *pReturnCode = 1;
} else {
if (pReturnCode) *pReturnCode = 0;
}
return ptr;
}

STEAMCLIENT_API void Breakpad_SteamMiniDumpInit( uint32 a, const char *b, const char *c )
Expand Down
5 changes: 5 additions & 0 deletions dll/dll/steam_networking_sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public ISteamNetworkingSockets004,
public ISteamNetworkingSockets006,
public ISteamNetworkingSockets008,
public ISteamNetworkingSockets009,
public ISteamNetworkingSockets010,
public ISteamNetworkingSockets011,
public ISteamNetworkingSockets
{
class Settings *settings{};
Expand Down Expand Up @@ -488,6 +490,9 @@ public ISteamNetworkingSockets
/// - k_EResultInvalidParam - nLanes is bad
EResult GetConnectionRealTimeStatus( HSteamNetConnection hConn, SteamNetConnectionRealTimeStatus_t *pStatus, int nLanes, SteamNetConnectionRealTimeLaneStatus_t *pLanes );

// based on reversing the vftable returned from original steamclient64.dll
bool GetConnectionRealTimeStatus_old( HSteamNetConnection hConn, SteamNetConnectionRealTimeStatus_t *pStatus );

/// Fetch the next available message(s) from the socket, if any.
/// Returns the number of messages returned into your array, up to nMaxMessages.
/// If the connection handle is invalid, -1 is returned.
Expand Down
1 change: 1 addition & 0 deletions dll/dll/steam_remote_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public ISteamRemoteStorage011,
public ISteamRemoteStorage012,
public ISteamRemoteStorage013,
public ISteamRemoteStorage014,
public ISteamRemoteStorage015,
public ISteamRemoteStorage
{
private:
Expand Down
1 change: 1 addition & 0 deletions dll/dll/steam_ugc.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public ISteamUGC007,
public ISteamUGC008,
public ISteamUGC009,
public ISteamUGC010,
public ISteamUGC011,
public ISteamUGC012,
public ISteamUGC013,
public ISteamUGC014,
Expand Down
22 changes: 10 additions & 12 deletions dll/steam_client_interface_getter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,16 @@ void *Steam_Client::GetISteamGenericInterface( HSteamUser hSteamUser, HSteamPipe
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets004 *>( steam_networking_sockets_temp));
} else if (strcmp(pchVersion, "SteamNetworkingSockets006") == 0) {
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets006 *>( steam_networking_sockets_temp));

// SteamNetworkingSockets007 Not found in public Archive, must be between 1.47-1.48

} else if (strcmp(pchVersion, "SteamNetworkingSockets007") == 0) { // Not found in public Archive, real steamclient64.dll returns null
return nullptr;
} else if (strcmp(pchVersion, "SteamNetworkingSockets008") == 0) {
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets008 *>( steam_networking_sockets_temp));
} else if (strcmp(pchVersion, "SteamNetworkingSockets009") == 0) {
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets009 *>( steam_networking_sockets_temp));

// SteamNetworkingSockets010-011 Not found in public Archive, must be between 1.52-1.53

} else if (strcmp(pchVersion, "SteamNetworkingSockets010") == 0) { // Not found in public Archive, based on reversing
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets010 *>( steam_networking_sockets_temp));
} else if (strcmp(pchVersion, "SteamNetworkingSockets011") == 0) { // Not found in public Archive, based on reversing, requested by appid 1492070
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets011 *>( steam_networking_sockets_temp));
} else if (strcmp(pchVersion, STEAMNETWORKINGSOCKETS_INTERFACE_VERSION) == 0) {
return reinterpret_cast<void *>(static_cast<ISteamNetworkingSockets *>( steam_networking_sockets_temp));
}
Expand Down Expand Up @@ -572,9 +572,8 @@ ISteamRemoteStorage *Steam_Client::GetISteamRemoteStorage( HSteamUser hSteamuser
return reinterpret_cast<ISteamRemoteStorage *>(static_cast<ISteamRemoteStorage013 *>(steam_remote_storage));
} else if (strcmp(pchVersion, "STEAMREMOTESTORAGE_INTERFACE_VERSION014") == 0) {
return reinterpret_cast<ISteamRemoteStorage *>(static_cast<ISteamRemoteStorage014 *>(steam_remote_storage));

// STEAMREMOTESTORAGE_INTERFACE_VERSION015 Not found in public Archive, must be between 1.51-1.52

} else if (strcmp(pchVersion, "STEAMREMOTESTORAGE_INTERFACE_VERSION015") == 0) { // Not found in public Archive, based on reversing
return reinterpret_cast<ISteamRemoteStorage *>(static_cast<ISteamRemoteStorage015 *>(steam_remote_storage));
} else if (strcmp(pchVersion, STEAMREMOTESTORAGE_INTERFACE_VERSION) == 0) {
return reinterpret_cast<ISteamRemoteStorage *>(static_cast<ISteamRemoteStorage *>(steam_remote_storage));
}
Expand Down Expand Up @@ -710,9 +709,8 @@ ISteamUGC *Steam_Client::GetISteamUGC( HSteamUser hSteamUser, HSteamPipe hSteamP
return reinterpret_cast<ISteamUGC *>(static_cast<ISteamUGC009 *>(steam_ugc_temp));
} else if (strcmp(pchVersion, "STEAMUGC_INTERFACE_VERSION010") == 0) {
return reinterpret_cast<ISteamUGC *>(static_cast<ISteamUGC010 *>(steam_ugc_temp));

// STEAMUGC_INTERFACE_VERSION011 Not found in public Archive, must be between 1.42-1.43

} else if (strcmp(pchVersion, "STEAMUGC_INTERFACE_VERSION011") == 0) { // Not found in public Archive, based on reversing
return reinterpret_cast<ISteamUGC *>(static_cast<ISteamUGC011 *>(steam_ugc_temp));
} else if (strcmp(pchVersion, "STEAMUGC_INTERFACE_VERSION012") == 0) {
return reinterpret_cast<ISteamUGC *>(static_cast<ISteamUGC012 *>(steam_ugc_temp));
} else if (strcmp(pchVersion, "STEAMUGC_INTERFACE_VERSION013") == 0) {
Expand Down
20 changes: 19 additions & 1 deletion dll/steam_networking_sockets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ bool Steam_Networking_Sockets::GetConnectionInfo( HSteamNetConnection hConn, Ste
/// - k_EResultInvalidParam - nLanes is bad
EResult Steam_Networking_Sockets::GetConnectionRealTimeStatus( HSteamNetConnection hConn, SteamNetConnectionRealTimeStatus_t *pStatus, int nLanes, SteamNetConnectionRealTimeLaneStatus_t *pLanes )
{
PRINT_DEBUG("%s %u %p %i %p", __FUNCTION__, hConn, pStatus, nLanes, pLanes);
PRINT_DEBUG("%u %p %i %p", hConn, pStatus, nLanes, pLanes);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto connect_socket = sbcs->connect_sockets.find(hConn);
if (connect_socket == sbcs->connect_sockets.end()) return k_EResultNoConnection;
Expand All @@ -950,6 +950,24 @@ EResult Steam_Networking_Sockets::GetConnectionRealTimeStatus( HSteamNetConnecti
return k_EResultOK;
}

// based on reversing the vftable returned from original steamclient64.dll
bool Steam_Networking_Sockets::GetConnectionRealTimeStatus_old( HSteamNetConnection hConn, SteamNetConnectionRealTimeStatus_t *pStatus )
{
PRINT_DEBUG("undocumented API, interface v10-11");
/*
...
xor r9d, r9d // int nLanes = 0
mov qword ptr ss:[rsp+0x20], 0x0 // SteamNetConnectionRealTimeLaneStatus_t *pLanes = nullptr
...
call qword ptr ds:[rax+0x80] // call GetConnectionRealTimeStatus(hConn, pStatus, nLanes, pLanes)
test eax, eax
setne al if (eax !=0) { al=1 } else { al=0 }
...
ret
*/
return GetConnectionRealTimeStatus(hConn, pStatus, 0, nullptr) != EResult::k_EResultNone;
}

/// Fetch the next available message(s) from the socket, if any.
/// Returns the number of messages returned into your array, up to nMaxMessages.
/// If the connection handle is invalid, -1 is returned.
Expand Down
22 changes: 0 additions & 22 deletions helpers/common_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,28 +133,6 @@ void common_helpers::write(std::ofstream &file, std::string_view data)
file << data << std::endl;
}

std::wstring common_helpers::str_to_w(std::string_view str)
{
if (str.empty()) return std::wstring();
auto cvt_state = std::mbstate_t();
const char* src = &str[0];
size_t conversion_bytes = std::mbsrtowcs(nullptr, &src, 0, &cvt_state);
std::wstring res(conversion_bytes + 1, L'\0');
std::mbsrtowcs(&res[0], &src, res.size(), &cvt_state);
return res.substr(0, conversion_bytes);
}

std::string common_helpers::wstr_to_a(std::wstring_view wstr)
{
if (wstr.empty()) return std::string();
auto cvt_state = std::mbstate_t();
const wchar_t* src = &wstr[0];
size_t conversion_bytes = std::wcsrtombs(nullptr, &src, 0, &cvt_state);
std::string res(conversion_bytes + 1, '\0');
std::wcsrtombs(&res[0], &src, res.size(), &cvt_state);
return res.substr(0, conversion_bytes);
}

bool common_helpers::starts_with_i(std::string_view target, std::string_view query)
{
if (target.size() < query.size()) {
Expand Down
Loading