From 6319e5d0f22ec906f2304074cf59a269b1cb729f Mon Sep 17 00:00:00 2001 From: a Date: Fri, 8 Aug 2025 03:59:51 +0300 Subject: [PATCH] add updated code + readme --- post_build/README.steam_old_lib.md | 31 +- premake5.lua | 12 +- steam_old_lib/README.md | 4 + steam_old_lib/dllmain.cpp | 291 ++- steam_old_lib/steam_old_lib.cpp | 1897 ++++++++++++++--- steam_old_lib/steam_old_lib.hpp | 122 -- steam_old_lib/steam_old_lib/SteamCommon.h | 665 ++++++ steam_old_lib/steam_old_lib/steam_old_lib.hpp | 11 + 8 files changed, 2609 insertions(+), 424 deletions(-) create mode 100644 steam_old_lib/README.md delete mode 100644 steam_old_lib/steam_old_lib.hpp create mode 100644 steam_old_lib/steam_old_lib/SteamCommon.h create mode 100644 steam_old_lib/steam_old_lib/steam_old_lib.hpp diff --git a/post_build/README.steam_old_lib.md b/post_build/README.steam_old_lib.md index c6bbb1ec..90e95094 100644 --- a/post_build/README.steam_old_lib.md +++ b/post_build/README.steam_old_lib.md @@ -1,14 +1,29 @@ ## What is this ? This is an old Windows-only library equivalent to `steam_api.dll` that's still used by some old games. -## How to use ? -You have some options to choose from: -- Copy & paste it beside the game's `.exe` file -- Or, inject it via `ColdClientLoader` (check its dedicated readme) -- Or, inject it using any other loader/injector you prefer - ## Purpose ? -Bypass initial/basic checks in old games protected with old version of Stub drm. +Bypass initial/basic checks in old games. ## Note -Note that it doesn't emulate any Steam functionality at the moment. +Note that it doesn't emulate all the required functionality at the moment, some functions are still missing. + +## How to use ? + +### Option 1: +- Copy & paste this dll beside the game's `.exe` file +- Copy `steam_api.dll` and `steamclient.dll` from the experimental build beside the game's `.exe` file +- Generate the `steam_interfaces.txt` file +- Run the game + +### Option 2: +- Copy & paste this dll inside the folder `steam_settings/load_dlls/` +- Copy `steam_api.dll` and `steamclient.dll` from the experimental build beside the game's `.exe` file +- Generate the `steam_interfaces.txt` file +- Run the game + +### Option 3: +- Copy the dll to a separate folder, ex: `extra_dlls` +- In `ColdClientLoader.ini` set the options: + * `ForceInjectSteamClient=1` + * `DllsToInjectFolder=extra_dlls` +- Run `ColdClientLoader` diff --git a/premake5.lua b/premake5.lua index c6e6b14a..e70176b5 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1379,6 +1379,7 @@ project "lib_steam_old" files { "steam_old_lib/**", "helpers/common_helpers.cpp", "helpers/common_helpers/**", + "helpers/dbg_log.cpp", "helpers/dbg_log/**", 'libs/utfcpp/**', -- detours detours_files, @@ -1388,7 +1389,16 @@ project "lib_steam_old" } -- x32 common source files files { - "resources/win/client/32/resources.rc" + "resources/win/api/32/resources.rc" + } + + + -- libs to link + --------- + -- Windows libs to link + filter {} -- reset the filter and remove all active keywords + links { + 'Ws2_32', } -- End lib_steam_old diff --git a/steam_old_lib/README.md b/steam_old_lib/README.md new file mode 100644 index 00000000..cdb3d069 --- /dev/null +++ b/steam_old_lib/README.md @@ -0,0 +1,4 @@ +## Credits +* https://github.com/SteamRE/open-steamworks/ +* https://gitlab.com/KittenPopo/csgo-2018-source/ +* Valve diff --git a/steam_old_lib/dllmain.cpp b/steam_old_lib/dllmain.cpp index 3fcdfeac..c04bba54 100644 --- a/steam_old_lib/dllmain.cpp +++ b/steam_old_lib/dllmain.cpp @@ -1,31 +1,302 @@ -#include "steam_old_lib.hpp" +// if you're wondering, sold = steam old + +#include "steam_old_lib/steam_old_lib.hpp" + +#include "common_helpers/common_helpers.hpp" +#include "dll/common_includes.h" + +#include "detours/detours.h" + +#include +#include +#include +#include + +#define WIN32_LEAN_AND_MEAN +#include + +#include // WinVerifyTrust + +#ifndef EMU_RELEASE_BUILD +#include "dbg_log/dbg_log.hpp" +#endif + + +#ifndef EMU_RELEASE_BUILD +dbg_log dbg_logger( + []{ + static wchar_t dll_path[8192]{}; + auto chars = GetModuleFileNameW((HINSTANCE)&__ImageBase, dll_path, sizeof(dll_path) / sizeof(dll_path[0])); + auto wpath = std::wstring_view(dll_path, chars); + return common_helpers::to_str(wpath.substr(0, wpath.find_last_of(L"\\/"))) + PATH_SEPARATOR + + "STEAM_OLD_LOG_" + std::to_string(common_helpers::rand_number(UINT32_MAX)) + ".log"; + }() +); +#endif static bool dll_loaded = false; +static HMODULE my_hModule = nullptr; + +static HMODULE wintrust_dll = nullptr; +static std::wstring wintrust_lib_path = L""; + +static bool WinVerifyTrust_hooked = false; +static bool LoadLibraryA_hooked = false; +static bool LoadLibraryExA_hooked = false; +static bool LoadLibraryW_hooked = false; +static bool LoadLibraryExW_hooked = false; + +static HMODULE hmod_steamclient = nullptr; +static void *ptr_CreateInterface = nullptr; + + +static inline bool is_steam_lib_A(const char *str) { + return str && str[0] && ( + common_helpers::ends_with_i(str, "Steam.dll") || + common_helpers::ends_with_i(str, "Steam") + ); +} + +static inline bool is_steam_lib_W(const wchar_t *str) { + return str && str[0] && ( + common_helpers::ends_with_i(str, L"Steam.dll") || + common_helpers::ends_with_i(str, L"Steam") + ); +} + + +static decltype(WinVerifyTrust) *actual_WinVerifyTrust = nullptr; +__declspec(noinline) +static LONG WINAPI WinVerifyTrust_hook(HWND hwnd, GUID *pgActionID, LPVOID pWVTData) { + if (WinVerifyTrust_hooked) { + PRINT_DEBUG_ENTRY(); + SetLastError(ERROR_SUCCESS); + return 0; // success + } + + if (actual_WinVerifyTrust) { + return actual_WinVerifyTrust(hwnd, pgActionID, pWVTData); + } + + SetLastError(ERROR_SUCCESS); + return 0; // success +} + +static decltype(LoadLibraryA) *actual_LoadLibraryA = LoadLibraryA; +__declspec(noinline) +static HMODULE WINAPI LoadLibraryA_hook(LPCSTR lpLibFileName) +{ + if (LoadLibraryA_hooked && is_steam_lib_A(lpLibFileName)) { + PRINT_DEBUG_ENTRY(); + SetLastError(ERROR_SUCCESS); + return my_hModule; + } + + return actual_LoadLibraryA(lpLibFileName); +} + +static decltype(LoadLibraryExA) *actual_LoadLibraryExA = LoadLibraryExA; +__declspec(noinline) +static HMODULE WINAPI LoadLibraryExA_hook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) +{ + if (LoadLibraryExA_hooked && is_steam_lib_A(lpLibFileName)) { + PRINT_DEBUG_ENTRY(); + SetLastError(ERROR_SUCCESS); + return my_hModule; + } + + return actual_LoadLibraryExA(lpLibFileName, hFile, dwFlags); +} + +static decltype(LoadLibraryW) *actual_LoadLibraryW = LoadLibraryW; +__declspec(noinline) +static HMODULE WINAPI LoadLibraryW_hook(LPCWSTR lpLibFileName) +{ + if (LoadLibraryW_hooked && is_steam_lib_W(lpLibFileName)) { + PRINT_DEBUG_ENTRY(); + SetLastError(ERROR_SUCCESS); + return my_hModule; + } + + return actual_LoadLibraryW(lpLibFileName); +} + +static decltype(LoadLibraryExW) *actual_LoadLibraryExW = LoadLibraryExW; +__declspec(noinline) +static HMODULE WINAPI LoadLibraryExW_hook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) +{ + if (LoadLibraryExW_hooked && is_steam_lib_W(lpLibFileName)) { + PRINT_DEBUG_ENTRY(); + SetLastError(ERROR_SUCCESS); + return my_hModule; + } + + return actual_LoadLibraryExW(lpLibFileName, hFile, dwFlags); +} + + +static bool redirect_win32_apis() +{ + PRINT_DEBUG_ENTRY(); + try { + wintrust_dll = LoadLibraryExW(wintrust_lib_path.c_str(), NULL, 0); + if (!wintrust_dll) throw std::runtime_error(""); + + actual_WinVerifyTrust = (decltype(actual_WinVerifyTrust))GetProcAddress(wintrust_dll, "WinVerifyTrust"); + if (!actual_WinVerifyTrust) throw std::runtime_error(""); + + if (DetourTransactionBegin() != NO_ERROR) throw std::runtime_error(""); + if (DetourUpdateThread(GetCurrentThread()) != NO_ERROR) throw std::runtime_error(""); + + if (DetourAttach((PVOID *)&actual_WinVerifyTrust, (PVOID)WinVerifyTrust_hook) != NO_ERROR) throw std::runtime_error(""); + if (DetourAttach((PVOID *)&actual_LoadLibraryA, (PVOID)LoadLibraryA_hook) != NO_ERROR) throw std::runtime_error(""); + if (DetourAttach((PVOID *)&actual_LoadLibraryExA, (PVOID)LoadLibraryExA_hook) != NO_ERROR) throw std::runtime_error(""); + if (DetourAttach((PVOID *)&actual_LoadLibraryW, (PVOID)LoadLibraryW_hook) != NO_ERROR) throw std::runtime_error(""); + if (DetourAttach((PVOID *)&actual_LoadLibraryExW, (PVOID)LoadLibraryExW_hook) != NO_ERROR) throw std::runtime_error(""); + if (DetourTransactionCommit() != NO_ERROR) throw std::runtime_error(""); + + WinVerifyTrust_hooked = true; + LoadLibraryA_hooked = true; + LoadLibraryExA_hooked = true; + LoadLibraryW_hooked = true; + LoadLibraryExW_hooked = true; + + return true; + } catch (...) { + + } + + if (wintrust_dll) { + FreeLibrary(wintrust_dll); + wintrust_dll = nullptr; + } + + return false; +} + +static bool restore_win32_apis() +{ + PRINT_DEBUG_ENTRY(); + WinVerifyTrust_hooked = false; + LoadLibraryA_hooked = false; + LoadLibraryExA_hooked = false; + LoadLibraryW_hooked = false; + LoadLibraryExW_hooked = false; + + bool ret = false; + + try { + if (DetourTransactionBegin() != NO_ERROR) throw std::runtime_error(""); + if (DetourUpdateThread(GetCurrentThread()) != NO_ERROR) throw std::runtime_error(""); + + if (actual_WinVerifyTrust) { + DetourDetach((PVOID *)&actual_WinVerifyTrust, (PVOID)WinVerifyTrust_hook); + } + + DetourDetach((PVOID *)&actual_LoadLibraryA, (PVOID)LoadLibraryA_hook); + DetourDetach((PVOID *)&actual_LoadLibraryExA, (PVOID)LoadLibraryExA_hook); + DetourDetach((PVOID *)&actual_LoadLibraryW, (PVOID)LoadLibraryW_hook); + DetourDetach((PVOID *)&actual_LoadLibraryExW, (PVOID)LoadLibraryExW_hook); + if (DetourTransactionCommit() != NO_ERROR) throw std::runtime_error(""); + + ret = true; + } catch (...) { + + } + + if (wintrust_dll) { + FreeLibrary(wintrust_dll); + wintrust_dll = nullptr; + } + + return ret; +} + +static void* steamclient_loader(bool load) +{ + if (load) { + if (!ptr_CreateInterface) { + PRINT_DEBUG("loading steamclient"); + if (!hmod_steamclient) { + hmod_steamclient = LoadLibraryExW(L"steamclient.dll", NULL, 0); + } + + if (hmod_steamclient) { + ptr_CreateInterface = GetProcAddress(hmod_steamclient, "CreateInterface"); + } + } + } else { + if (hmod_steamclient) { + PRINT_DEBUG("unloading steamclient"); + FreeLibrary(hmod_steamclient); + hmod_steamclient = nullptr; + ptr_CreateInterface = nullptr; + } + } + return ptr_CreateInterface; +} + +static bool patch() +{ + PRINT_DEBUG_ENTRY(); + if (wintrust_lib_path.empty()) { + auto size = GetSystemDirectoryW(&wintrust_lib_path[0], 0); + if (size <= 0) return false; + + wintrust_lib_path.resize(size); + size = GetSystemDirectoryW(&wintrust_lib_path[0], (unsigned)wintrust_lib_path.size()); + if (size >= (unsigned)wintrust_lib_path.size()) { + wintrust_lib_path.clear(); + return false; + } + + wintrust_lib_path.pop_back(); // remove null + wintrust_lib_path += L"\\Wintrust.dll"; + } + + return redirect_win32_apis(); +} + +static void deinit() +{ + PRINT_DEBUG_ENTRY(); + steamclient_loader(false); + sold::set_steamclient_loader(nullptr); + sold::set_tid(0); + if (dll_loaded) { + restore_win32_apis(); + } +} + BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) { switch (reason) { case DLL_PROCESS_ATTACH: { - if (!soldlib::patch((void*)hModule)) { - -#ifdef SOLD_EXTRA_DEBUG - MessageBoxA(nullptr, "Failed to initialize", "Main", MB_OK | MB_ICONERROR); -#endif - + PRINT_DEBUG("DLL_PROCESS_ATTACH"); + my_hModule = hModule; + auto my_tid = GetCurrentThreadId(); + if (!steamclient_loader(true)) { + PRINT_DEBUG("[X] failed to load steamclient.dll"); // https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain // "The system immediately calls your entry-point function with DLL_PROCESS_DETACH and unloads the DLL" return FALSE; } + if (!patch()) { + PRINT_DEBUG("[X] failed to patch"); + return FALSE; + } + sold::set_steamclient_loader(steamclient_loader); + sold::set_tid(my_tid); dll_loaded = true; } break; case DLL_PROCESS_DETACH: { - if (dll_loaded) { - soldlib::restore(); - } + PRINT_DEBUG("DLL_PROCESS_DETACH"); + deinit(); } break; } diff --git a/steam_old_lib/steam_old_lib.cpp b/steam_old_lib/steam_old_lib.cpp index 08a754b0..d0515f0d 100644 --- a/steam_old_lib/steam_old_lib.cpp +++ b/steam_old_lib/steam_old_lib.cpp @@ -1,399 +1,1730 @@ -#include "steam_old_lib.hpp" +#include "steam_old_lib/steam_old_lib.hpp" +#include "steam_old_lib/SteamCommon.h" #include "common_helpers/common_helpers.hpp" -#include "detours/detours.h" +#define INCLUDED_STEAM2_USERID_STRUCTS +#include "dll/common_includes.h" #include #include #include #include -#include // WinVerifyTrust +#include // getenv +#include // size_t +#include // std::strncpy +#include +#include +#include -#define S_API extern "C" __declspec(dllexport) -#define STEAM_CALL __cdecl +#define SOLD_ERR_OK 1 +#define SOLD_ERR_FAIL 0 -#define STEAM_INVALID_CALL_HANDLE 0 +#define SOLD_ITF_CODE_OK 0 +#define SOLD_ITF_CODE_FAIL 1 -static HMODULE my_hModule = nullptr; -HMODULE wintrust_dll = nullptr; -std::wstring wintrust_lib_path = L""; +using CreateInterface_t = void* (__cdecl *)( const char *pName, int *pReturnCode ); -static bool WinVerifyTrust_hooked = false; -static bool LoadLibraryA_hooked = false; -static bool LoadLibraryExA_hooked = false; -static bool LoadLibraryW_hooked = false; -static bool LoadLibraryExW_hooked = false; +constexpr const static char SOLD_ITF_NAME_CLIENT[] = "SteamClient017"; +constexpr const static char SOLD_ITF_NAME_UTILS[] = "SteamUtils009"; +constexpr const static char SOLD_ITF_NAME_USER[] = "SteamUser019"; +constexpr const static char SOLD_ITF_NAME_APPS[] = "STEAMAPPS_INTERFACE_VERSION008"; +constexpr const static char SOLD_ITF_NAME_FRIENDS[] = "SteamFriends017"; -static decltype(WinVerifyTrust) *actual_WinVerifyTrust = nullptr; -__declspec(noinline) -static LONG WINAPI WinVerifyTrust_hook(HWND hwnd, GUID *pgActionID, LPVOID pWVTData) { - if (WinVerifyTrust_hooked) { - SetLastError(ERROR_SUCCESS); - return 0; // success - } +// we have to use specific headers (ex: ISteamClient017 vs ISteamClient) +// otherwise direct pointer access would result in invalid vftable access +// because we earlier requested a specific version via CreateInterface() +static ISteamClient017 *sold_steam_client = nullptr; +static ISteamUtils009 *sold_steam_utils = nullptr; +static ISteamUser019 *sold_steam_user = nullptr; +static ISteamApps *sold_steam_apps = nullptr; // TODO at that time ISteamApps == ISteamApps008 (update this when the interface vesion changes) - if (actual_WinVerifyTrust) { - return actual_WinVerifyTrust(hwnd, pgActionID, pWVTData); - } - - SetLastError(ERROR_SUCCESS); - return 0; // success -} +static_assert( + sizeof(STEAMAPPS_INTERFACE_VERSION) == sizeof(SOLD_ITF_NAME_APPS) + && STEAMAPPS_INTERFACE_VERSION[sizeof(STEAMAPPS_INTERFACE_VERSION) - 1] == SOLD_ITF_NAME_APPS[sizeof(SOLD_ITF_NAME_APPS) - 1] + && STEAMAPPS_INTERFACE_VERSION[sizeof(STEAMAPPS_INTERFACE_VERSION) - 2] == SOLD_ITF_NAME_APPS[sizeof(SOLD_ITF_NAME_APPS) - 2] + && STEAMAPPS_INTERFACE_VERSION[sizeof(STEAMAPPS_INTERFACE_VERSION) - 3] == SOLD_ITF_NAME_APPS[sizeof(SOLD_ITF_NAME_APPS) - 3] + && STEAMAPPS_INTERFACE_VERSION[sizeof(STEAMAPPS_INTERFACE_VERSION) - 4] == SOLD_ITF_NAME_APPS[sizeof(SOLD_ITF_NAME_APPS) - 4] + , + "ISteamApps interface was updated,\n" + "change the variable definition to a specific version,\n" + "ex: ISteamApps008" +); -static decltype(LoadLibraryA) *actual_LoadLibraryA = LoadLibraryA; -__declspec(noinline) -static HMODULE WINAPI LoadLibraryA_hook(LPCSTR lpLibFileName) -{ - if (LoadLibraryA_hooked && - lpLibFileName && lpLibFileName[0] && - common_helpers::ends_with_i(lpLibFileName, "Steam.dll")) { - return my_hModule; - } +static sold::steamclient_loader_t *steamclient_loader = nullptr; +static CreateInterface_t ptrCreateInterface = nullptr; - return actual_LoadLibraryA(lpLibFileName); -} +static HSteamPipe sold_hsteam_pipe = 0; +static HSteamUser sold_hsteam_user = 0; -static decltype(LoadLibraryExA) *actual_LoadLibraryExA = LoadLibraryExA; -__declspec(noinline) -static HMODULE WINAPI LoadLibraryExA_hook(LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) -{ - if (LoadLibraryExA_hooked && - lpLibFileName && lpLibFileName[0] && - common_helpers::ends_with_i(lpLibFileName, "Steam.dll")) { - return my_hModule; - } +static bool startup_ok = false; - return actual_LoadLibraryExA(lpLibFileName, hFile, dwFlags); -} +static uint32 sold_game_appid = 0; -static decltype(LoadLibraryW) *actual_LoadLibraryW = LoadLibraryW; -__declspec(noinline) -static HMODULE WINAPI LoadLibraryW_hook(LPCWSTR lpLibFileName) -{ - if (LoadLibraryW_hooked && - lpLibFileName && lpLibFileName[0] && - common_helpers::ends_with_i(lpLibFileName, L"Steam.dll")) { - return my_hModule; - } +static char game_installpath[1024]{}; +static DepotId_t installed_depots[64]{}; - return actual_LoadLibraryW(lpLibFileName); -} +constexpr const static TSteamAppInfo apps_infos[] = { + { 8600, "RACE 07" }, + { 8610, "RACE 07 Dedicated Server" }, + { 8640, "RACE On" }, + { 8641, "RACE 07_Exp_Toad" }, + { 8650, "RACE 07 - Andy Priaulx Crowne Plaza Expansion" }, + { 8660, "GTR Evolution" }, + { 8690, "STCC - The Game" }, + { 44620, "STCC 2" }, + { 44621, "RACE 07_Exp_Frog2" }, + { 44630, "RACE 07 - Formula RaceRoom Add-On" }, + { 44631, "RACE 07_Exp_MosquitoPack1" }, + { 44650, "GT Power Expansion" }, + { 44651, "RACE 07_Exp_MosquitoPack3" }, + { 44660, "The Retro Expansion" }, + { 44661, "RACE 07_Exp_MosquitoPack4" }, + { 44670, "WTCC 2010" }, + { 44671, "RACE 07_Exp_MosquitoPack5" }, + { 44680, "Race Injection" }, + { 44681, "RACE 07_Exp_Mosquito" }, + { 44683, "RACE 07_Exp_MosquitoIntro" }, + { 44711, "RACE 07_Exp_MosquitoPack4Beta" }, +}; +constexpr const static unsigned APPS_INFOS_COUNT = sizeof(apps_infos) / sizeof(apps_infos[0]); -static decltype(LoadLibraryExW) *actual_LoadLibraryExW = LoadLibraryExW; -__declspec(noinline) -static HMODULE WINAPI LoadLibraryExW_hook(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags) -{ - if (LoadLibraryExW_hooked && - lpLibFileName && lpLibFileName[0] && - common_helpers::ends_with_i(lpLibFileName, L"Steam.dll")) { - return my_hModule; - } - - return actual_LoadLibraryExW(lpLibFileName, hFile, dwFlags); -} +constexpr const static std::string_view servers_list[] = { + "208.64.200.65:27015", + "208.64.200.39:27011", + "208.64.200.52:27011", +}; +constexpr const static unsigned SERVERS_LIST_COUNT = sizeof(servers_list) / sizeof(servers_list[0]); -static bool redirect_win32_apis() -{ - try { - wintrust_dll = LoadLibraryExW(wintrust_lib_path.c_str(), NULL, 0); - if (!wintrust_dll) throw std::runtime_error(""); - - actual_WinVerifyTrust = (decltype(actual_WinVerifyTrust))GetProcAddress(wintrust_dll, "WinVerifyTrust"); - if (!actual_WinVerifyTrust) throw std::runtime_error(""); - - if (DetourTransactionBegin() != NO_ERROR) throw std::runtime_error(""); - if (DetourUpdateThread(GetCurrentThread()) != NO_ERROR) throw std::runtime_error(""); - - if (DetourAttach((PVOID *)&actual_WinVerifyTrust, (PVOID)WinVerifyTrust_hook) != NO_ERROR) throw std::runtime_error(""); - if (DetourAttach((PVOID *)&actual_LoadLibraryA, (PVOID)LoadLibraryA_hook) != NO_ERROR) throw std::runtime_error(""); - if (DetourAttach((PVOID *)&actual_LoadLibraryExA, (PVOID)LoadLibraryExA_hook) != NO_ERROR) throw std::runtime_error(""); - if (DetourAttach((PVOID *)&actual_LoadLibraryW, (PVOID)LoadLibraryW_hook) != NO_ERROR) throw std::runtime_error(""); - if (DetourAttach((PVOID *)&actual_LoadLibraryExW, (PVOID)LoadLibraryExW_hook) != NO_ERROR) throw std::runtime_error(""); - if (DetourTransactionCommit() != NO_ERROR) throw std::runtime_error(""); - - WinVerifyTrust_hooked = true; - LoadLibraryA_hooked = true; - LoadLibraryExA_hooked = true; - LoadLibraryW_hooked = true; - LoadLibraryExW_hooked = true; - - return true; - } catch (...) { - - } - - if (wintrust_dll) { - FreeLibrary(wintrust_dll); - wintrust_dll = nullptr; - } - - return false; -} - -static bool restore_win32_apis() -{ - WinVerifyTrust_hooked = false; - LoadLibraryA_hooked = false; - LoadLibraryExA_hooked = false; - LoadLibraryW_hooked = false; - LoadLibraryExW_hooked = false; - - bool ret = false; - - try { - if (DetourTransactionBegin() != NO_ERROR) throw std::runtime_error(""); - if (DetourUpdateThread(GetCurrentThread()) != NO_ERROR) throw std::runtime_error(""); - - if (actual_WinVerifyTrust) { - DetourDetach((PVOID *)&actual_WinVerifyTrust, (PVOID)WinVerifyTrust_hook); - } - - DetourDetach((PVOID *)&actual_LoadLibraryA, (PVOID)LoadLibraryA_hook); - DetourDetach((PVOID *)&actual_LoadLibraryExA, (PVOID)LoadLibraryExA_hook); - DetourDetach((PVOID *)&actual_LoadLibraryW, (PVOID)LoadLibraryW_hook); - DetourDetach((PVOID *)&actual_LoadLibraryExW, (PVOID)LoadLibraryExW_hook); - if (DetourTransactionCommit() != NO_ERROR) throw std::runtime_error(""); - - ret = true; - } catch (...) { - - } - - if (wintrust_dll) { - FreeLibrary(wintrust_dll); - wintrust_dll = nullptr; - } - - return ret; -} - -#ifdef SOLD_EXTRA_DEBUG -extern "C" __declspec(dllexport) -#endif -void __cdecl notify_patch_done() -{ -#ifdef SOLD_EXTRA_DEBUG - MessageBoxA(nullptr, "Cleanup/Uninstall was called, hook a debugger here!", "Cleanup called", MB_OK | MB_ICONASTERISK); -#endif -} - -static void set_ok_err(soldlib::TSteamError *pError) { +static void set_ok_err(TSteamError *pError) { if (pError) { - pError->eSteamError = soldlib::ESteamError::eSteamErrorNone; - pError->eDetailedErrorType = soldlib::EDetailedPlatformErrorType::eNoDetailedErrorAvailable; + pError->eSteamError = ESteamError::eSteamErrorNone; + pError->eDetailedErrorType = EDetailedPlatformErrorType::eNoDetailedErrorAvailable; pError->nDetailedErrorCode = 0; pError->szDesc[0] = 0; } } -static void set_bad_err(soldlib::TSteamError *pError) { +static void set_steam_err(TSteamError *pError, const char *desc = "", ESteamError eSteamError = ESteamError::eSteamErrorUnknown) { if (pError) { - pError->eSteamError = soldlib::ESteamError::eSteamErrorBadArg; - pError->eDetailedErrorType = soldlib::EDetailedPlatformErrorType::eNoDetailedErrorAvailable; - pError->nDetailedErrorCode = soldlib::ESteamError::eSteamErrorBadArg; - pError->szDesc[0] = 0; - } -} - -bool soldlib::patch(void *lib_hModule) -{ - my_hModule = (HMODULE)lib_hModule; - - if (wintrust_lib_path.empty()) { - auto size = GetSystemDirectoryW(&wintrust_lib_path[0], 0); - if (size <= 0) return false; - - wintrust_lib_path.resize(size); - size = GetSystemDirectoryW(&wintrust_lib_path[0], (unsigned)wintrust_lib_path.size()); - if (size >= (unsigned)wintrust_lib_path.size()) { - wintrust_lib_path.clear(); - return false; + pError->eSteamError = eSteamError; + pError->eDetailedErrorType = EDetailedPlatformErrorType::eNoDetailedErrorAvailable; + pError->nDetailedErrorCode = ESteamError::eSteamErrorBadArg; + if (desc) { + std::strncpy(pError->szDesc, desc, sizeof(pError->szDesc) - 1); } + } +} - wintrust_lib_path.pop_back(); // remove null - wintrust_lib_path += L"\\Wintrust.dll"; +static int set_wrapper_not_impl_err(TSteamError *pError) +{ + PRINT_DEBUG_ENTRY(); + set_steam_err(pError, "Wrapper not implemented", ESteamError::eSteamErrorUnknown); + return SOLD_ERR_FAIL; +} + +static void* create_interface_internal(const char *pName, int *pReturnCode) +{ + PRINT_DEBUG("'%s'", pName); + if (!ptrCreateInterface) { + ptrCreateInterface = reinterpret_cast(steamclient_loader(true)); + if (!ptrCreateInterface) { + PRINT_DEBUG("[X] failed to load steamclient.dll or find CreateInterface()"); + if (pReturnCode) *pReturnCode = SOLD_ITF_CODE_FAIL; + return nullptr; + } else { + PRINT_DEBUG("loaded steamclient.dll, CreateInterface() @ %p", ptrCreateInterface); + } } - return redirect_win32_apis(); -} - -bool soldlib::restore() -{ - return restore_win32_apis(); + return ptrCreateInterface(pName, pReturnCode); } -S_API int STEAM_CALL SteamStartup( unsigned int uUsingMask, soldlib::TSteamError *pError ) +STEAM_API void* CreateInterface(const char *pName, int *pReturnCode) { + PRINT_DEBUG("'%s'", pName); + return create_interface_internal(pName, pReturnCode); +} + +STEAM_API int STEAM_CALL SteamAbortCall( SteamCallHandle_t handle, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); set_ok_err(pError); - return 1; + + return SOLD_ERR_OK; } -S_API int STEAM_CALL SteamCleanup( soldlib::TSteamError *pError ) +STEAM_API void STEAM_CALL SteamAbortOngoingUserIDTicketValidation( SteamUserIDTicketValidationHandle_t Handle ) { + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamAckSubscriptionReceipt( unsigned int uSubscriptionId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamBlockingCall( SteamCallHandle_t handle, unsigned int uiProcessTickMS, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); set_ok_err(pError); - // restore_win32_apis(); // appid 7450 loads the dll again at runtime, we can't unload here - notify_patch_done(); - return 1; + + return SOLD_ERR_OK; } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamUninstall( soldlib::TSteamError *pError ) +STEAM_API SteamCallHandle_t STEAM_CALL SteamChangeAccountName( const char *cszCurrentPassphrase, const char *cszNewAccountName, TSteamError *pError ) { + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamChangeEmailAddress( const char *cszNewEmailAddress, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamChangeForgottenPassword( const char *cszUser, const char *cszAnswerToQuestion, const char *cszEmailVerificationKey, const char *cszNewPassphrase, int *pbChanged, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamChangeOfflineStatus( TSteamOfflineStatus *pStatus, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamChangePassword( const char *cszCurrentPassphrase, const char *cszNewPassphrase, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamChangePersonalQA( const char *cszCurrentPassphrase, const char *cszNewPersonalQuestion, const char *cszNewAnswerToQuestion, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamCheckAppOwnership( unsigned int uAppId, int* pbOwned, TSteamGlobalUserID* pSteamID, TSteamError* pError ) +{ + PRINT_DEBUG("%u", uAppId); set_ok_err(pError); - // restore_win32_apis(); // appid 7450 loads the dll again at runtime, we can't unload here - notify_patch_done(); - return STEAM_INVALID_CALL_HANDLE; -} -S_API int STEAM_CALL SteamGetAccountStatus( unsigned int* puAccountStatusFlags, soldlib::TSteamError *pError ) -{ - if (puAccountStatusFlags) { - *puAccountStatusFlags = - soldlib::ESteamAccountStatusBitFields::eSteamAccountStatusDefault - | soldlib::ESteamAccountStatusBitFields::eSteamAccountStatusEmailVerified; + // real dll doesn't check for null + if (pbOwned) *pbOwned = 0; + + if (!sold_steam_user) { + PRINT_DEBUG("[X] SteamUser is null!"); + return SOLD_ERR_FAIL; + } + + CSteamID account_steamid = sold_steam_user->GetSteamID(); + // real dll doesn't check for null + if (pSteamID && account_steamid == SteamIDFromSteam2UserID(pSteamID, account_steamid.GetEUniverse())) { + // real dll doesn't check for null + bool subed = sold_steam_apps && sold_steam_apps->BIsSubscribedApp(uAppId); + // real dll doesn't check for null + if (pbOwned) *pbOwned = subed; + + PRINT_DEBUG("is subbed = %i", (int)subed); + return SOLD_ERR_OK; } - set_ok_err(pError); - return 1; + PRINT_DEBUG("[X] pSteamID is null or not same account"); + return SOLD_ERR_FAIL; } -S_API int STEAM_CALL SteamGetCurrentEmailAddress( char *szEmailaddress, unsigned int uBufSize, unsigned int *puEmailaddressChars, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamCleanup( TSteamError *pError ) { - constexpr const static std::string_view EMAIL = "orca@gbe.com"; + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); - unsigned copied = 0; - if (szEmailaddress && uBufSize > 0) { - copied = (unsigned)EMAIL.copy(szEmailaddress, uBufSize); - szEmailaddress[copied] = 0; + if (sold_steam_client) { + sold_steam_client->ReleaseUser(sold_hsteam_pipe, sold_hsteam_user); + sold_steam_client->BReleaseSteamPipe(sold_hsteam_pipe); + sold_steam_client = nullptr; } - if (puEmailaddressChars) *puEmailaddressChars = copied; - set_ok_err(pError); - return 1; + + sold_steam_utils = nullptr; + sold_steam_user = nullptr; + sold_steam_apps = nullptr; + + startup_ok = false; + + // free steamclient lib, don't do that here some games still need the steamclient dll + // if (steamclient_loader) { + // steamclient_loader(false); + // PRINT_DEBUG("[?] unloaded steamclient.dll"); + // } + + // free Steam2.dll lib + return SOLD_ERR_OK; } -// https://gitlab.com/KittenPopo/csgo-2018-source/-/blob/main/common/Steam.h -// https://github.com/SteamRE/open-steamworks/blob/master/Open%20Steamworks/Steam.h -S_API int STEAM_CALL SteamIsAppSubscribed( unsigned int uAppId, int *pbIsAppSubscribed, int *pbIsSubscriptionPending, soldlib::TSteamError *pError ) { - if (pbIsAppSubscribed) *pbIsAppSubscribed = 1; - if (pbIsSubscriptionPending) *pbIsSubscriptionPending = 0; - set_ok_err(pError); - return 1; -} - -S_API int STEAM_CALL SteamIsSubscribed( unsigned int uSubscriptionId, int *pbIsSubscribed, int *pbIsSubscriptionPending, soldlib::TSteamError *pError ) +STEAM_API void STEAM_CALL SteamClearError( TSteamError *pError ) { - if (pbIsSubscribed) *pbIsSubscribed = 1; - if (pbIsSubscriptionPending) *pbIsSubscriptionPending = 0; + PRINT_DEBUG_ENTRY(); set_ok_err(pError); - return 1; } -S_API int STEAM_CALL SteamIsLoggedIn( int *pbIsLoggedIn, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamCloseFile( SteamHandle_t hFile, TSteamError *pError ) { - if (pbIsLoggedIn) *pbIsLoggedIn = 1; + PRINT_DEBUG_TODO(); set_ok_err(pError); - return 1; + + return SOLD_ERR_FAIL; } -S_API int STEAM_CALL SteamIsSecureComputer( int *pbIsSecureComputer, soldlib::TSteamError *pError ) +STEAM_API SteamCallHandle_t STEAM_CALL SteamCreateAccount( const char *cszUser, const char *cszEmailAddress, const char *cszPassphrase, const char *cszCreationKey, const char *cszPersonalQuestion, const char *cszAnswerToQuestion, int *pbCreated, TSteamError *pError ) { - if (pbIsSecureComputer) *pbIsSecureComputer = 1; - set_ok_err(pError); - return 1; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamLaunchApp( unsigned int uAppId, unsigned int uLaunchOption, const char *cszArgs, soldlib::TSteamError *pError ) +STEAM_API SteamCallHandle_t STEAM_CALL SteamCreateCachePreloaders( TSteamError *pError ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamLogin( const char *cszUser, const char *cszPassphrase, int bIsSecureComputer, soldlib::TSteamError *pError ) +STEAM_API SteamHandle_t STEAM_CALL SteamCreateLogContext( const char *cszName ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return STEAM_INVALID_HANDLE; } - -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamRefreshAccountInfo( soldlib::TSteamError *pError ) +STEAM_API SteamCallHandle_t STEAM_CALL SteamDefragCaches( unsigned int uAppId, TSteamError* pError ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamRefreshAccountInfoEx( int bContentDescriptionOnly, soldlib::TSteamError* pError ) +STEAM_API SteamCallHandle_t STEAM_CALL SteamDeleteAccount( TSteamError *pError ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamRefreshAccountInfo2( int bRefreshAccount, int bRefreshCDDB, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateApp( unsigned int uId, TSteamApp *pApp, TSteamError *pError ) { + static std::list custom_names{}; + + // this implementation is incomplete, real dll does some other stuff + PRINT_DEBUG_TODO(); + PRINT_DEBUG("%u", uId); set_ok_err(pError); - return 1; + + if (pApp) { + pApp->uId = uId; + pApp->uLatestVersionId = 1; + pApp->uCurrentVersionId = 1; + pApp->uMinCacheFileSizeMB = 1; + pApp->uMaxCacheFileSizeMB = 1; + pApp->uNumLaunchOptions = 1; + pApp->uNumIcons = 0; + pApp->uNumVersions = 1; + } + + const TSteamAppInfo *ptr_info = nullptr; + for (auto &app_info : apps_infos) { + if (app_info.uAppId == uId) { + ptr_info = &app_info; + break; + } + } + + if (ptr_info) { + std::strncpy(pApp->szName, ptr_info->szAppName, pApp->uMaxNameChars); + } else { + // readl dll returns formatted "Steam App %u" + auto &name = custom_names.emplace_back("Steam App " + std::to_string(uId)); + std::strncpy(pApp->szName, name.c_str(), pApp->uMaxNameChars); + } + std::strncpy(pApp->szLatestVersionLabel, "1", pApp->uMaxLatestVersionLabelChars); + std::strncpy(pApp->szCurrentVersionLabel, "1", pApp->uMaxCurrentVersionLabelChars); + + sold_steam_apps->GetAppInstallDir(uId, pApp->szInstallDirName, pApp->uMaxInstallDirNameChars); + + DepotId_t vecDepots[32]{}; + uint32 depots_count = sold_steam_apps->GetInstalledDepots(uId, vecDepots, sizeof(vecDepots) / sizeof(vecDepots[0])); + pApp->uNumDependencies = depots_count; + + PRINT_DEBUG("appid %u, dependencies %u", uId, depots_count); + return SOLD_ERR_OK; } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamRefreshLogin( const char *cszPassphrase, int bIsSecureComputer, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateAppDependency( unsigned int uAppId, unsigned int uIndex, TSteamAppDependencyInfo *pDependencyInfo, TSteamError *pError ) { + PRINT_DEBUG("%u [%u]", uAppId, uIndex); set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + + DepotId_t vecDepots[32]; + memset(vecDepots, 0, sizeof(vecDepots)); + + // real dll doesn't check for null + uint32 depots_count = sold_steam_apps + ? sold_steam_apps->GetInstalledDepots(uAppId, vecDepots, sizeof(vecDepots) / sizeof(vecDepots[0])) + : 0; + + PRINT_DEBUG("depots count=%u", depots_count); + if (uIndex < depots_count) { + char mount_path[sizeof(TSteamAppDependencyInfo::szMountPath)]{}; + // real dll doesn't check for null + if (sold_steam_apps) { + sold_steam_apps->GetAppInstallDir(uAppId, mount_path, sizeof(mount_path)); + } + // real dll doesn't check for null + if (pDependencyInfo) { + pDependencyInfo->uAppId = vecDepots[uIndex]; + memcpy(pDependencyInfo->szMountPath, mount_path, sizeof(pDependencyInfo->szMountPath)); + pDependencyInfo->bIsSystemDefined = 1; + } + PRINT_DEBUG("app install/mount dir '%s'", mount_path); + } else { + // real dll doesn't check for null + if (pDependencyInfo) { + pDependencyInfo->uAppId = 0; + pDependencyInfo->szMountPath[0] = 0; + pDependencyInfo->bIsSystemDefined = 0; + } + PRINT_DEBUG("[X] index out of range"); + } + + return SOLD_ERR_OK; } - -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamSubscribe( unsigned int uSubscriptionId, const void /*TSteamSubscriptionBillingInfo*/ *pSubscriptionBillingInfo, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateAppIcon( unsigned int uAppId, unsigned int uIconIndex, unsigned char *pIconData, unsigned int uIconDataBufSize, unsigned int *puSizeOfIconData, TSteamError *pError ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamUnsubscribe( unsigned int uSubscriptionId, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateAppLaunchOption( unsigned int uAppId, unsigned int uLaunchOptionIndex, TSteamAppLaunchOption *pLaunchOption, TSteamError *pError ) { - set_ok_err(pError); - return 1; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamUpdateAccountBillingInfo( const void /*TSteamPaymentCardInfo*/ *pPaymentCardInfo, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateAppVersion( unsigned int uAppId, unsigned int uVersionIndex, TSteamAppVersion *pAppVersion, TSteamError *pError ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned /*SteamCallHandle_t*/ STEAM_CALL SteamUpdateSubscriptionBillingInfo( unsigned int uSubscriptionId, const void /*TSteamSubscriptionBillingInfo*/ *pSubscriptionBillingInfo, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateSubscription( unsigned int uId, TSteamSubscription *pSubscription, TSteamError *pError ) { - set_ok_err(pError); - return STEAM_INVALID_CALL_HANDLE; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API unsigned int STEAM_CALL SteamNumAppsRunning( soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamEnumerateSubscriptionDiscount( unsigned int uSubscriptionId, unsigned int uDiscountIndex, TSteamSubscriptionDiscount *pDiscount, TSteamError *pError ) { - set_ok_err(pError); - return 1; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } -S_API int STEAM_CALL SteamCheckAppOwnership( unsigned int uAppId, int* pbOwned, void /*TSteamGlobalUserID*/ *pSteamID, soldlib::TSteamError* pError ) +STEAM_API int STEAM_CALL SteamEnumerateSubscriptionDiscountQualifier( unsigned int uSubscriptionId, unsigned int uDiscountIndex, unsigned int uQualifierIndex, TSteamDiscountQualifier *pDiscountQualifier, TSteamError *pError ) { - if (pbOwned) *pbOwned = 1; - set_ok_err(pError); - return 1; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); } - -S_API int STEAM_CALL SteamGetAppDLCStatus( unsigned int uAppId, unsigned int uDLCCacheId, int *pbDownloaded, soldlib::TSteamError *pError ) +STEAM_API int STEAM_CALL SteamFindApp( const char *cszAppName, unsigned int *puAppId, TSteamError *pError ) { - if (pbDownloaded) *pbDownloaded = 0; + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} - if (0 == uAppId || UINT32_MAX == uAppId) { - set_bad_err(pError); +STEAM_API int STEAM_CALL SteamFindClose( SteamHandle_t hDirectory, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API SteamHandle_t STEAM_CALL SteamFindFirst( const char *cszPattern, ESteamFindFilter eFilter, TSteamElemInfo *pFindInfo, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API SteamHandle_t STEAM_CALL SteamFindFirst64( const char *cszPattern, ESteamFindFilter eFilter, TSteamElemInfo64 *pFindInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamFindNext( SteamHandle_t hDirectory, TSteamElemInfo *pFindInfo, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamFindNext64( SteamHandle_t hDirectory, TSteamElemInfo64 *pFindInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API const char* STEAM_CALL SteamFindServersGetErrorString() +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return "Wrapper not implemented: SteamFindServersXXX"; +} + +STEAM_API int STEAM_CALL SteamFindServersIterateServer(ESteamServerType eSteamServerType, unsigned int uIndex, char *szServerAddress, int iServerAddressChars) +{ + PRINT_DEBUG("<%u> %u", eSteamServerType, uIndex); + if ((eSteamServerType == ESteamServerType::eSteamHalfLife2MasterServer) && (uIndex < SERVERS_LIST_COUNT)) { + // real dll doesn't check for null + if (szServerAddress && iServerAddressChars > 0) { + auto copied = servers_list[uIndex].copy(szServerAddress, iServerAddressChars - 1); + szServerAddress[copied] = 0; + } return 0; } - if (pbDownloaded) *pbDownloaded = 1; - set_ok_err(pError); - return 1; + // real dll doesn't check for null + if (szServerAddress && iServerAddressChars > 0) *szServerAddress = 0; + return -1; +} + +STEAM_API int STEAM_CALL SteamFindServersNumServers( ESteamServerType eSteamServerType ) +{ + PRINT_DEBUG("<%u>", eSteamServerType); + int count = 0; + if (eSteamServerType == ESteamServerType::eSteamHalfLife2MasterServer) { + count = (int)SERVERS_LIST_COUNT; + } + return count; +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamFlushCache( unsigned int uCacheId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamFlushFile( SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamForceCellId( unsigned int uCellId, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamForgetAllHints( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamGenerateSuggestedAccountNames( const char *cszAccountNameToSelectMasterAS, const char *cszGenerateNamesLikeAccountName, char *pSuggestedNamesBuf, unsigned int uBufSize, unsigned int *puNumSuggestedChars, TSteamError *pError) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAccountStatus( unsigned int *puAccountStatusFlags, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamGetAppCacheSize( unsigned int uCacheId, unsigned int *pCacheSizeInMb, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAppDLCStatus( unsigned int uAppId, unsigned int uDLCCacheId, int *pbDownloaded, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAppDependencies( unsigned int uAppId, unsigned int *puCacheIds, unsigned int uMaxIds, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAppDir( unsigned int uAppId, char *szPath, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAppIds( unsigned int *puIds, unsigned int uMaxIds, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + if (uMaxIds < APPS_INFOS_COUNT) { // this is a predetermined limit in the original dll + set_steam_err(pError, "AppID buffer too small"); + return SOLD_ERR_FAIL; + } + + // real dll doesn't check for null/size + if (puIds && uMaxIds > 0) { + const auto min_size = uMaxIds < APPS_INFOS_COUNT ? uMaxIds : APPS_INFOS_COUNT; + for (unsigned idx = 0; idx < min_size; ++idx) { + puIds[idx] = apps_infos[idx].uAppId; + } + PRINT_DEBUG("copied %u items", min_size); + } else { + PRINT_DEBUG("[?] nothing was copied, null buffer or size=0"); + } + + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamGetAppPurchaseCountry( unsigned int uAppId, char* szCountryBuf, unsigned int uBufSize, unsigned int* pPurchaseTime, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAppStats( TSteamAppStats *pAppStats, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + // real dll doesn't check for null + if (pAppStats) { + // these are actual hardcoded values from the real dll + pAppStats->uNumApps = APPS_INFOS_COUNT; + pAppStats->uMaxNameChars = STEAM_MAX_PATH; + pAppStats->uMaxInstallDirNameChars = STEAM_MAX_PATH; + pAppStats->uMaxVersionLabelChars = STEAM_MAX_PATH; + pAppStats->uMaxLaunchOptions = 1; + pAppStats->uMaxLaunchOptionDescChars = STEAM_MAX_PATH; + pAppStats->uMaxLaunchOptionCmdLineChars = STEAM_MAX_PATH; + pAppStats->uMaxNumIcons = 0; + pAppStats->uMaxIconSize = 0; + pAppStats->uMaxDependencies = 0; + } + + return SOLD_ERR_OK; +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamGetAppUpdateStats( unsigned int uAppOrCacheId, ESteamAppUpdateStatsQueryType eQueryType, TSteamUpdateStats *pUpdateStats, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return STEAM_INVALID_CALL_HANDLE; +} + +STEAM_API int STEAM_CALL SteamGetAppUserDefinedInfo( unsigned int uAppId, const char *cszKey, char *szValueBuf, unsigned int uValueBufLen, unsigned int *puValueLen, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetAppUserDefinedRecord(unsigned int uAppId, KeyValueIteratorCallback_t AddEntryToKeyValueFunc, void* pvCKeyValue, TSteamError *pError) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetCacheDecryptionKey( unsigned int uCacheId, char* pchKeyBuffer, unsigned int cubBuff, unsigned int* pcubKey, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetCacheDefaultDirectory( char *szPath, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetCacheFilePath( unsigned int uCacheId, char *szPathBuf, unsigned int uBufSize, unsigned int *puPathChars, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamGetCachePercentFragmentation( unsigned int uAppId, unsigned int* puPctFragmentation, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetContentServerInfo( unsigned int uAppId, unsigned int *puServerId, unsigned int *puServerIpAddress, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetCurrentAppId(unsigned int *puAppId, TSteamError *pError) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + // real dll doesn't check for null + if (puAppId) *puAppId = 0; + + if (!sold_steam_utils) { + return SOLD_ERR_FAIL; + } + + uint32 appid = sold_steam_utils->GetAppID(); + // real dll doesn't check for null + if (puAppId) *puAppId = appid; + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamGetCurrentCellID(int *param_1, int *param_2, TSteamError *pError) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + // real dll doesn't check for null + if (param_1) *param_1 = 1; + if (param_2) *param_2 = 100; + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamGetCurrentEmailAddress( char *szEmailAddress, unsigned int uBufSize, unsigned int *puEmailChars, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetDepotParent( unsigned int uDepotId, unsigned int* puParentId, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + + +STEAM_API ESteamError STEAM_CALL SteamGetEncryptedUserIDTicket( const void *pEncryptionKeyReceivedFromAppServer, unsigned int uEncryptionKeyLength, void *pOutputBuffer, unsigned int uSizeOfOutputBuffer, unsigned int *pReceiveSizeOfEncryptedTicket, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return ESteamError::eSteamErrorBadArg; +} + +STEAM_API const char* STEAM_CALL SteamGetEncryptionKeyToSendToNewClient( unsigned int * pReceiveSizeOfEncryptionKey ) +{ + // that's the whole function in the real dll! + PRINT_DEBUG_ENTRY(); + // real dll doesn't check for null + if (pReceiveSizeOfEncryptionKey) *pReceiveSizeOfEncryptionKey = 27; + return "Steam2WrapperEncryptionKey"; +} + +STEAM_API int STEAM_CALL SteamGetFileAttributeFlags( const char* cszName, int* puFlags, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetLocalClientVersion( unsigned int* puBootstrapperVersion, unsigned int* puClientVersion, TSteamError *pError ) +{ + // that's the whole function in the real dll! + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + // real dll doesn't check for null + if (puBootstrapperVersion) *puBootstrapperVersion = 1; + if (puClientVersion) *puClientVersion = 1; + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamGetLocalFileCopy( const char *cszName, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamGetNumAccountsWithEmailAddress( const char *cszEmailAddress, unsigned int *puNumAccounts, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetOfflineStatus( TSteamOfflineStatus *pStatus, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + // real dll doesn't check for null + if (pStatus) { + pStatus->eOfflineNow = 0; + pStatus->eOfflineNextSession = 0; + } + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamGetSponsorUrl( unsigned int uAppId, char *szUrl, unsigned int uBufSize, unsigned int *pUrlChars, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetSubscriptionExtendedInfo( unsigned int uSubscriptionId, const char* cszKeyName, char* szKeyValue, unsigned int uBufferLength, unsigned int* puRecievedLength, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetSubscriptionIds( unsigned int *puIds, unsigned int uMaxIds, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetSubscriptionPurchaseCountry( unsigned int uSubscriptionId, char* szCountryBuf, unsigned int uBufSize , int* pPurchaseTime, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetSubscriptionReceipt( unsigned int uSubscriptionId, TSteamSubscriptionReceipt *pSubscriptionReceipt, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetSubscriptionStats( TSteamSubscriptionStats *pSubscriptionStats, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetTotalUpdateStats( TSteamUpdateStats *pUpdateStats, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetUser( char *szUser, unsigned int uBufSize, unsigned int *puUserChars, TSteamGlobalUserID *pOptionalReceiveUserID, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + if (puUserChars) *puUserChars = 0; + if (!sold_steam_user) { + PRINT_DEBUG("[X] SteamUser is null!"); + return SOLD_ERR_FAIL; + } + if (!szUser) { + uBufSize = 0; + } + const char *user_val = getenv("SteamUser"); + + // === emu specific START + if (!user_val || !user_val[0]) { + user_val = getenv("SteamAppUser"); + } + + if (!user_val || !user_val[0]) { + auto friends_itf = sold_steam_client + ? reinterpret_cast(sold_steam_client->GetISteamGenericInterface(sold_hsteam_user, sold_hsteam_pipe, SOLD_ITF_NAME_FRIENDS)) + : static_cast(nullptr); + if (friends_itf) { + user_val = friends_itf->GetPersonaName(); + } + } + + if (!user_val || !user_val[0]) { + user_val = DEFAULT_NAME; + } + // === emu specific END + + { + unsigned copy_count = 0; + if (uBufSize > 0) { + auto user_val_view = std::string_view(user_val); + copy_count = (unsigned)user_val_view.copy(szUser, uBufSize - 1); + szUser[copy_count] = 0; + } + if (puUserChars) *puUserChars = copy_count; + } + + if (pOptionalReceiveUserID) { + sold_steam_user->GetSteamID().ConvertToSteam2(pOptionalReceiveUserID); + } + + PRINT_DEBUG("copied buffer '%s'", szUser); + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamGetUserType( unsigned int *puUserTypeFlags, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamGetVersion( char *szVersion, unsigned int uVersionBufSize ) +{ + PRINT_DEBUG_ENTRY(); + if (szVersion && uVersionBufSize > 0) { + std::strncpy(szVersion, "1.0.0.0", uVersionBufSize - 1); + return SOLD_ERR_OK; + } + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamGetc( SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamHintResourceNeed( const char *cszMasterList, int bForgetEverything, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API ESteamError STEAM_CALL SteamInitializeUserIDTicketValidator( const char * pszOptionalPublicEncryptionKeyFilename, const char * pszOptionalPrivateDecryptionKeyFilename, unsigned int ClientClockSkewToleranceInSeconds, unsigned int ServerClockSkewToleranceInSeconds, unsigned int MaxNumLoginsWithinClientClockSkewTolerancePerClient, unsigned int HintPeakSimultaneousValidations, unsigned int AbortValidationAfterStallingForNProcessSteps ) +{ + // that's the whole function in the real dll! + PRINT_DEBUG_ENTRY(); + return ESteamError::eSteamErrorNone; +} + +STEAM_API int STEAM_CALL SteamInsertAppDependency( unsigned int uAppId, unsigned int uIndex, TSteamAppDependencyInfo *pDependencyInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamIsAccountNameInUse( const char *cszAccountName, int *pbIsUsed, TSteamError *pError) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamIsAppSubscribed( unsigned int uAppId, int *pbIsAppSubscribed, int *pbIsSubscriptionPending, TSteamError *pError ) +{ + PRINT_DEBUG("%u", uAppId); + set_ok_err(pError); // never changed afterwards + + // original dll doesn't check for null + if (pbIsAppSubscribed) *pbIsAppSubscribed = 0; + if (!sold_steam_apps) { + PRINT_DEBUG("[X] SteamApps is null!"); + return SOLD_ERR_FAIL; + } + if (pbIsSubscriptionPending) *pbIsSubscriptionPending = 0; // never changed afterwards + bool subed = sold_steam_apps->BIsSubscribedApp(uAppId); + // real dll doesn't check for null + if (pbIsAppSubscribed) *pbIsAppSubscribed = subed; + + PRINT_DEBUG("is subbed = %i", (int)subed); + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamIsCacheLoadingEnabled( unsigned int uAppId, int *pbIsLoading, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamStat( const char *cszName, TSteamElemInfo *pInfo, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + if (pError) pError->eSteamError = ESteamError::eSteamErrorNotFound; + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamIsFileImmediatelyAvailable( const char *cszName, TSteamError *pError ) +{ + PRINT_DEBUG("'%s'", cszName); + set_ok_err(pError); + + TSteamElemInfo elem_info{}; + int err_code = SteamStat(cszName, &elem_info, pError); + PRINT_DEBUG("ret=%i", err_code); + return err_code != -1 ? SOLD_ERR_OK : SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamIsFileNeededByApp( unsigned int uAppId, const char* pchFileName, SteamUnsigned64_t u64FileSize, unsigned int* puCacheId, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamIsFileNeededByCache( unsigned int uCacheId, const char* pchFileName, SteamUnsigned64_t u64FileSize, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamIsLoggedIn( int *pbIsLoggedIn, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + // real dll doesn't check for null + if (pbIsLoggedIn) *pbIsLoggedIn = 1; + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamIsSecureComputer( int *pbIsSecure, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamIsSubscribed( unsigned int uSubscriptionId, int *pbIsSubscribed, int *pbIsSubscriptionPending, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamIsUsingSdkContentServer( int *pbUsingSdkCS, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamLaunchApp( unsigned int uAppId, unsigned int uLaunchOption, const char *cszArgs, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + // real function: + // ---------------- + // HINSTANCE ret = ShellExecuteW(NULL, NULL, , "-applaunch ", NULL, 1); + // return ret > 32; + // ---------------- + + // https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499- + return 2; // ERROR_FILE_NOT_FOUND +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamLoadCacheFromDir( unsigned int uAppId, const char *szPath, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamLoadFileToApp( unsigned int uAppId, const char* pchFileName, const void* pubDataChunk, unsigned int cubDataChunk, SteamUnsigned64_t cubDataOffset, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamLoadFileToCache( unsigned int uCacheId, const char* pchFileName, const void* pubDataChunk, unsigned int cubDataChunk, SteamUnsigned64_t cubDataOffset, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamLog( SteamHandle_t hContext, const char *cszMsg ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return SOLD_ERR_FAIL; +} + +STEAM_API void STEAM_CALL SteamLogResourceLoadFinished( const char *cszMsg ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); +} + +STEAM_API void STEAM_CALL SteamLogResourceLoadStarted( const char *cszMsg ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamLogin( const char *cszUser, const char *cszPassphrase, int bIsSecureComputer, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamLogout( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + + +STEAM_API void STEAM_CALL SteamMiniDumpInit() +{ + PRINT_DEBUG_TODO(); +} + +// TODO +STEAM_API int STEAM_CALL SteamMountAppFilesystem( TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API SteamHandle_t STEAM_CALL SteamMountFilesystem( unsigned int uAppId, const char *szMountPath, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_OK; +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamMoveApp( unsigned int uAppId, const char *szPath, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API unsigned int STEAM_CALL SteamNumAppsRunning( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamHandle_t STEAM_CALL SteamOpenFileEx( const char *cszName, const char *cszMode, unsigned int *puFileSize, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return STEAM_INVALID_CALL_HANDLE; +} + +STEAM_API SteamHandle_t STEAM_CALL SteamOpenFile( const char *cszName, const char *cszMode, TSteamError *pError ) +{ + PRINT_DEBUG("'%s' '%s'", cszName, cszMode); + + unsigned int uFileSize = 0; + return SteamOpenFileEx(cszName, cszMode, &uFileSize, pError); +} + +STEAM_API SteamHandle_t STEAM_CALL SteamOpenFile64( const char *cszPath, const char *cszMode, SteamUnsigned64_t *pu64FileSize, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamHandle_t STEAM_CALL SteamOpenTmpFile( TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return STEAM_INVALID_CALL_HANDLE; +} + +STEAM_API ESteamError STEAM_CALL SteamOptionalCleanUpAfterClientHasDisconnected( unsigned int ObservedClientIPAddr, unsigned int ClientLocalIPAddr ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return ESteamError::eSteamErrorNone; +} + +STEAM_API int STEAM_CALL SteamPauseCachePreloading( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamPrintFile( SteamHandle_t hFile, TSteamError *pError, const char *cszFormat, ... ) +{ + PRINT_DEBUG_TODO(); + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamProcessCall( SteamCallHandle_t handle, TSteamProgress *pProgress, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + if (pProgress) { + pProgress->bValid = 1; + pProgress->uPercentDone = 100; + pProgress->szProgress[0] = 0; + } + return SOLD_ERR_OK; +} + +STEAM_API ESteamError STEAM_CALL SteamProcessOngoingUserIDTicketValidation( SteamUserIDTicketValidationHandle_t Handle, TSteamGlobalUserID *pReceiveValidSteamGlobalUserID, unsigned int *pReceiveClientLocalIPAddr, unsigned char *pOptionalReceiveProofOfAuthenticationToken, size_t SizeOfOptionalAreaToReceiveProofOfAuthenticationToken, size_t *pOptionalReceiveSizeOfProofOfAuthenticationToken ) +{ + PRINT_DEBUG_TODO(); + + return ESteamError::eSteamErrorNothingToDo; +} + +STEAM_API int STEAM_CALL SteamPutc( int cChar, SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API unsigned int STEAM_CALL SteamReadFile( void *pBuf, unsigned int uSize, unsigned int uCount, SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return 0; +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRefreshAccountInfo( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRefreshAccountInfo2( int bRefreshAccount, int bRefreshCDDB, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRefreshAccountInfoEx( int bContentDescriptionOnly, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRefreshLogin( const char *cszPassphrase, int bIsSecureComputer, TSteamError * pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamReleaseCacheFiles( unsigned int uAppId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamRemoveAppDependency( unsigned int uAppId, unsigned int uIndex, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRepairOrDecryptCaches( unsigned int uAppId, int bForceValidation, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRequestAccountsByCdKeyEmail( const char *cszCdKey, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRequestAccountsByEmailAddressEmail( const char *cszEmailAddress, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRequestEmailAddressVerificationEmail( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamRequestForgottenPasswordEmail( const char *cszUser, SteamPersonalQuestion_t ReceivePersonalQuestion, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamResumeCachePreloading( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamSeekFile( SteamHandle_t hFile, long lOffset, ESteamSeekMethod, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + if (pError) pError->eSteamError = ESteamError::eSteamErrorEOF; + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamSeekFile64( SteamHandle_t hFile, SteamSigned64_t s64Offset, ESteamSeekMethod eMethod, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamSetAppCacheSize( unsigned int uCacheId, unsigned int nCacheSizeInMb, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamSetAppVersion( unsigned int uAppId, unsigned int uAppVersionId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamSetCacheDefaultDirectory( const char *szPath, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamSetMaxStallCount( unsigned int uNumStalls, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamSetNotificationCallback( SteamNotificationCallback_t pCallbackFunction, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamSetUser( const char *cszUser, int *pbUserSet, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamSetUser2( const char *cszUser, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamSetvBuf( SteamHandle_t hFile, void* pBuf, ESteamBufferMethod eMethod, unsigned int uBytes, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamShutdownEngine(TSteamError *pError) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamShutdownSteamBridgeInterface( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API ESteamError STEAM_CALL SteamShutdownUserIDTicketValidator() +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return ESteamError::eSteamErrorNone; +} + +STEAM_API long STEAM_CALL SteamSizeFile( SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return 0; +} + +STEAM_API SteamSigned64_t STEAM_CALL SteamSizeFile64( SteamHandle_t hFile, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamStartEngine(TSteamError *pError) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamStartEngineEx( TSteamError *pError, bool bStartOffline, bool bDetectOnlineOfflineState ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamStartLoadingCache( unsigned int uAppId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API ESteamError STEAM_CALL SteamStartValidatingNewValveCDKey( void *pEncryptedNewValveCDKeyFromClient, unsigned int uSizeOfEncryptedNewValveCDKeyFromClient, unsigned int ObservedClientIPAddr, struct sockaddr *pPrimaryValidateNewCDKeyServerSockAddr, struct sockaddr *pSecondaryValidateNewCDKeyServerSockAddr, SteamUserIDTicketValidationHandle_t *pReceiveHandle ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return ESteamError::eSteamErrorNone; +} + +STEAM_API ESteamError STEAM_CALL SteamStartValidatingUserIDTicket( void *pEncryptedUserIDTicketFromClient, unsigned int uSizeOfEncryptedUserIDTicketFromClient, unsigned int ObservedClientIPAddr, SteamUserIDTicketValidationHandle_t *pReceiveHandle ) +{ + PRINT_DEBUG_TODO(); + + return ESteamError::eSteamErrorBadArg; +} + +STEAM_API int STEAM_CALL SteamStartup( unsigned int uUsingMask, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + if (startup_ok) { + PRINT_DEBUG("startup was already called"); + return SOLD_ERR_OK; + } + + if (!steamclient_loader) { + PRINT_DEBUG("[X] steamclient.dll loader is null!"); + set_steam_err(pError, "SteamAPI_Init_Internal failed", ESteamError::eSteamErrorUnknown); + return SOLD_ERR_FAIL; + } + + sold_steam_client = reinterpret_cast(create_interface_internal(SOLD_ITF_NAME_CLIENT, nullptr)); + if (!sold_steam_client) { + PRINT_DEBUG("[X] failed to get SteamClient interface"); + set_steam_err(pError, "SteamAPI_Init_Internal failed", ESteamError::eSteamErrorUnknown); + return SOLD_ERR_FAIL; + } + + sold_hsteam_pipe = sold_steam_client->CreateSteamPipe(); + sold_hsteam_user = sold_steam_client->ConnectToGlobalUser(sold_hsteam_pipe); + sold_steam_utils = reinterpret_cast(sold_steam_client->GetISteamGenericInterface(sold_hsteam_user, sold_hsteam_pipe, SOLD_ITF_NAME_UTILS)); + sold_steam_user = reinterpret_cast(sold_steam_client->GetISteamGenericInterface(sold_hsteam_user, sold_hsteam_pipe, SOLD_ITF_NAME_USER)); + sold_steam_apps = reinterpret_cast(sold_steam_client->GetISteamGenericInterface(sold_hsteam_user, sold_hsteam_pipe, SOLD_ITF_NAME_APPS)); + if (!sold_steam_utils || !sold_steam_user || !sold_steam_apps || 0 == sold_hsteam_user) { + PRINT_DEBUG("[X] one of the required interfaces is missing or bad HSteamUser"); + set_steam_err(pError, "Missing interface", ESteamError::eSteamErrorUnknown); + return SOLD_ERR_FAIL; + } + + sold_game_appid = sold_steam_utils->GetAppID(); + if (0 == sold_game_appid) { + PRINT_DEBUG("[X] invalid appid"); + set_steam_err(pError, "Invalid appid", ESteamError::eSteamErrorUnknown); + return SOLD_ERR_FAIL; + } + + sold_steam_apps->GetAppInstallDir(sold_game_appid, game_installpath, (uint32)sizeof(game_installpath)); + sold_steam_apps->GetInstalledDepots(sold_game_appid, installed_depots, (uint32)(sizeof(installed_depots) / sizeof(installed_depots[0]))); + + PRINT_DEBUG("done"); + startup_ok = true; + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamStat64( const char *cszName, TSteamElemInfo64 *pInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamStopLoadingCache( unsigned int uAppId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamSubscribe( unsigned int uSubscriptionId, const TSteamSubscriptionBillingInfo *pSubscriptionBillingInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API long STEAM_CALL SteamTellFile( SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return 0; +} + +STEAM_API SteamSigned64_t STEAM_CALL SteamTellFile64( SteamHandle_t hFile, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamUninstall( TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamUnmountAppFilesystem( TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API int STEAM_CALL SteamUnmountFilesystem( SteamHandle_t hFs, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + return SOLD_ERR_OK; +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamUnsubscribe( unsigned int uSubscriptionId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamUpdateAccountBillingInfo( const TSteamPaymentCardInfo *pPaymentCardInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamUpdateSubscriptionBillingInfo( unsigned int uSubscriptionId, const TSteamSubscriptionBillingInfo *pSubscriptionBillingInfo, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamVerifyEmailAddress( const char *cszEmailVerificationKey, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API int STEAM_CALL SteamVerifyPassword( const char *cszPassphrase, int *pbCorrect, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamWaitForAppReadyToLaunch( unsigned int uAppId, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamWaitForAppResources( unsigned int uAppId, const char* cszMasterList, TSteamError* pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API SteamCallHandle_t STEAM_CALL SteamWaitForResources( const char *cszMasterList, TSteamError *pError ) +{ + PRINT_DEBUG_ENTRY(); + set_ok_err(pError); + + return SOLD_ERR_OK; +} + +STEAM_API int STEAM_CALL SteamWasBlobRegistryDeleted( int *puWasDeleted, TSteamError *pError ) +{ + // that's the whole function in the original dll! + PRINT_DEBUG_ENTRY(); + return set_wrapper_not_impl_err(pError); +} + +STEAM_API unsigned int STEAM_CALL SteamWriteFile( const void *pBuf, unsigned int uSize, unsigned int uCount, SteamHandle_t hFile, TSteamError *pError ) +{ + PRINT_DEBUG_TODO(); + set_ok_err(pError); + + return SOLD_ERR_FAIL; +} + +STEAM_API void STEAM_CALL SteamWriteMiniDumpFromAssert(unsigned int unknown1, unsigned int unknown2, unsigned int unknown3, const char *szMessage, const char *szFileName) +{ + // that's the whole function in the original dll! + PRINT_DEBUG("Wrapper not implemented:SteamWriteMiniDumpFromAssert"); +} + +STEAM_API void STEAM_CALL SteamWriteMiniDumpSetComment( const char* cszComment ) +{ + PRINT_DEBUG_TODO(); + PRINT_DEBUG( "%s", cszComment); +} + +STEAM_API void STEAM_CALL SteamWriteMiniDumpUsingExceptionInfo( unsigned int uStructuredExceptionCode, /*struct _EXCEPTION_POINTERS*/ void* pExceptionInfo) +{ + PRINT_DEBUG_TODO(); + PRINT_DEBUG(" app is writing a crash dump! [XXXXXXXXXXXXXXXXXXXXXXXXXXX]"); +} + +STEAM_API void STEAM_CALL SteamWriteMiniDumpUsingExceptionInfoWithBuildId(unsigned int uStructuredExceptionCode, /*struct _EXCEPTION_POINTERS*/ void* pExceptionInfo, unsigned int uBuildID) +{ + PRINT_DEBUG_TODO(); + PRINT_DEBUG(" app is writing a crash dump! [XXXXXXXXXXXXXXXXXXXXXXXXXXX]"); +} + +STEAM_API void STEAM_CALL SteamWriteMiniDumpWithAppID() +{ + // that's the whole function in the original dll! + PRINT_DEBUG("Wrapper not implemented:SteamWriteMiniDumpWithAppID"); +} + +STEAM_API void* STEAM_CALL _f(const char *szInterfaceVersionRequested) +{ + PRINT_DEBUG_TODO(); + return create_interface_internal(szInterfaceVersionRequested, nullptr); +} + +// declare "g_dwDllEntryThreadId" as an export, then actually define it +STEAM_API unsigned long g_dwDllEntryThreadId; +unsigned long g_dwDllEntryThreadId = 0; + + + +void sold::set_steamclient_loader(steamclient_loader_t *loader) +{ + steamclient_loader = loader; +} + +void sold::set_tid(unsigned long tid) +{ + g_dwDllEntryThreadId = tid; } diff --git a/steam_old_lib/steam_old_lib.hpp b/steam_old_lib/steam_old_lib.hpp deleted file mode 100644 index a45a9490..00000000 --- a/steam_old_lib/steam_old_lib.hpp +++ /dev/null @@ -1,122 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN -#include - - -#if !defined(SOLD_EXTRA_DEBUG) - #if defined(DEBUG) || defined(_DEBUG) - #define SOLD_EXTRA_DEBUG - #endif -#endif - - -namespace soldlib { - - // https://github.com/SteamRE/open-steamworks/blob/master/Open%20Steamworks/SteamTypes.h -#define STEAM_MAX_PATH 255 - -// https://github.com/SteamRE/open-steamworks/blob/master/Open%20Steamworks/ESteamError.h -typedef enum ESteamError -{ - eSteamErrorNone = 0, - eSteamErrorUnknown = 1, - eSteamErrorLibraryNotInitialized = 2, - eSteamErrorLibraryAlreadyInitialized = 3, - eSteamErrorConfig = 4, - eSteamErrorContentServerConnect = 5, - eSteamErrorBadHandle = 6, - eSteamErrorHandlesExhausted = 7, - eSteamErrorBadArg = 8, - eSteamErrorNotFound = 9, - eSteamErrorRead = 10, - eSteamErrorEOF = 11, - eSteamErrorSeek = 12, - eSteamErrorCannotWriteNonUserConfigFile = 13, - eSteamErrorCacheOpen = 14, - eSteamErrorCacheRead = 15, - eSteamErrorCacheCorrupted = 16, - eSteamErrorCacheWrite = 17, - eSteamErrorCacheSession = 18, - eSteamErrorCacheInternal = 19, - eSteamErrorCacheBadApp = 20, - eSteamErrorCacheVersion = 21, - eSteamErrorCacheBadFingerPrint = 22, - - eSteamErrorNotFinishedProcessing = 23, - eSteamErrorNothingToDo = 24, - eSteamErrorCorruptEncryptedUserIDTicket = 25, - eSteamErrorSocketLibraryNotInitialized = 26, - eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27, - eSteamErrorBadProtocolVersion = 28, - eSteamErrorReplayedUserIDTicketFromClient = 29, - eSteamErrorReceiveResultBufferTooSmall = 30, - eSteamErrorSendFailed = 31, - eSteamErrorReceiveFailed = 32, - eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33, - eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34, - eSteamErrorValidationStalledSoAborted = 35, - eSteamErrorInvalidUserIDTicket = 36, - eSteamErrorClientLoginRateTooHigh = 37, - eSteamErrorClientWasNeverValidated = 38, - eSteamErrorInternalSendBufferTooSmall = 39, - eSteamErrorInternalReceiveBufferTooSmall = 40, - eSteamErrorUserTicketExpired = 41, - eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42, - - eSteamErrorNotLoggedIn = 101, - eSteamErrorAlreadyExists = 102, - eSteamErrorAlreadySubscribed = 103, - eSteamErrorNotSubscribed = 104, - eSteamErrorAccessDenied = 105, - eSteamErrorFailedToCreateCacheFile = 106, - eSteamErrorCallStalledSoAborted = 107, - eSteamErrorEngineNotRunning = 108, - eSteamErrorEngineConnectionLost = 109, - eSteamErrorLoginFailed = 110, - eSteamErrorAccountPending = 111, - eSteamErrorCacheWasMissingRetry = 112, - eSteamErrorLocalTimeIncorrect = 113, - eSteamErrorCacheNeedsDecryption = 114, - eSteamErrorAccountDisabled = 115, - eSteamErrorCacheNeedsRepair = 116, - eSteamErrorRebootRequired = 117, - - eSteamErrorNetwork = 200, - - eSteamErrorOffline = 201, -} ESteamError; - -// https://github.com/SteamRE/open-steamworks/blob/master/Open%20Steamworks/TSteamError.h -typedef enum EDetailedPlatformErrorType -{ - eNoDetailedErrorAvailable, - eStandardCerrno, - eWin32LastError, - eWinSockLastError, - eDetailedPlatformErrorCount -} EDetailedPlatformErrorType; - -typedef struct TSteamError -{ - ESteamError eSteamError; - EDetailedPlatformErrorType eDetailedErrorType; - int nDetailedErrorCode; - char szDesc[STEAM_MAX_PATH]; -} TSteamError; - -// https://gitlab.com/KittenPopo/csgo-2018-source/-/blob/main/common/SteamCommon.h -// https://github.com/ValveSoftware/source-sdk-2013/blob/master/src/common/steamcommon.h -typedef enum -{ - eSteamAccountStatusDefault = 0x00000000, - eSteamAccountStatusEmailVerified = 0x00000001, - /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */ - eSteamAccountDisabled = 0x00000004 -} ESteamAccountStatusBitFields; - - -bool patch(void *lib_hModule); -bool restore(); - -} diff --git a/steam_old_lib/steam_old_lib/SteamCommon.h b/steam_old_lib/steam_old_lib/SteamCommon.h new file mode 100644 index 00000000..da7b8438 --- /dev/null +++ b/steam_old_lib/steam_old_lib/SteamCommon.h @@ -0,0 +1,665 @@ +#pragma once + + +#define STEAM_API extern "C" __declspec(dllexport) +#define STEAM_CALL __cdecl + +typedef void (STEAM_CALL *KeyValueIteratorCallback_t )(const char *Key, const char *Val, void *pvParam); + + +/****************************************************************************** +** +** Exported macros and constants +** +******************************************************************************/ + +/* DEPRECATED -- these are ignored now, all API access is granted on SteamStartup */ +#define STEAM_USING_FILESYSTEM (0x00000001) +#define STEAM_USING_LOGGING (0x00000002) +#define STEAM_USING_USERID (0x00000004) +#define STEAM_USING_ACCOUNT (0x00000008) +#define STEAM_USING_ALL (0x0000000f) +/* END DEPRECATED */ + +#define STEAM_MAX_PATH (255) +#define STEAM_QUESTION_MAXLEN (255) +#define STEAM_SALT_SIZE (8) +#define STEAM_PROGRESS_PERCENT_SCALE (0x00001000) + +/* These are maximum significant string lengths, excluding nul-terminator. */ +#define STEAM_CARD_NUMBER_SIZE (17) +#define STEAM_CARD_HOLDERNAME_SIZE (100) +#define STEAM_CARD_EXPYEAR_SIZE (4) +#define STEAM_CARD_EXPMONTH_SIZE (2) +#define STEAM_CARD_CVV2_SIZE (5) +#define STEAM_BILLING_ADDRESS1_SIZE (128) +#define STEAM_BILLING_ADDRESS2_SIZE (128) +#define STEAM_BILLING_CITY_SIZE (50) +#define STEAM_BILLING_ZIP_SIZE (16) +#define STEAM_BILLING_STATE_SIZE (32) +#define STEAM_BILLING_COUNTRY_SIZE (32) +#define STEAM_BILLING_PHONE_SIZE (20) +#define STEAM_BILLING_EMAIL_ADDRESS_SIZE (100) +#define STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE (20) +#define STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE (200) +#define STEAM_EXTERNAL_ACCOUNTNAME_SIZE (100) +#define STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE (80) +#define STEAM_BILLING_CONFIRMATION_CODE_SIZE (22) +#define STEAM_BILLING_CARD_APPROVAL_CODE_SIZE (100) +#define STEAM_BILLING_TRANS_DATE_SIZE (9) // mm/dd/yy +#define STEAM_BILLING_TRANS_TIME_SIZE (9) // hh:mm:ss + +// other stuff based on reversing +#define VPK_FILE_HANDLE_FLAG 0x40000000 + +/****************************************************************************** +** +** Scalar type and enumerated type definitions. +** +******************************************************************************/ + + +typedef unsigned int SteamHandle_t; + +typedef void * SteamUserIDTicketValidationHandle_t; + +typedef unsigned int SteamCallHandle_t; + +#if defined(_MSC_VER) +typedef __int64 SteamSigned64_t; +typedef unsigned __int64 SteamUnsigned64_t; +#else +typedef long long SteamSigned64_t; +typedef unsigned long long SteamUnsigned64_t; +#endif + +typedef enum +{ + eSteamSeekMethodSet = 0, + eSteamSeekMethodCur = 1, + eSteamSeekMethodEnd = 2 +} ESteamSeekMethod; + +typedef enum +{ + eSteamBufferMethodFBF = 0, + eSteamBufferMethodNBF = 1 +} ESteamBufferMethod; + +typedef enum +{ + eSteamErrorNone = 0, + eSteamErrorUnknown = 1, + eSteamErrorLibraryNotInitialized = 2, + eSteamErrorLibraryAlreadyInitialized = 3, + eSteamErrorConfig = 4, + eSteamErrorContentServerConnect = 5, + eSteamErrorBadHandle = 6, + eSteamErrorHandlesExhausted = 7, + eSteamErrorBadArg = 8, + eSteamErrorNotFound = 9, + eSteamErrorRead = 10, + eSteamErrorEOF = 11, + eSteamErrorSeek = 12, + eSteamErrorCannotWriteNonUserConfigFile = 13, + eSteamErrorCacheOpen = 14, + eSteamErrorCacheRead = 15, + eSteamErrorCacheCorrupted = 16, + eSteamErrorCacheWrite = 17, + eSteamErrorCacheSession = 18, + eSteamErrorCacheInternal = 19, + eSteamErrorCacheBadApp = 20, + eSteamErrorCacheVersion = 21, + eSteamErrorCacheBadFingerPrint = 22, + + eSteamErrorNotFinishedProcessing = 23, + eSteamErrorNothingToDo = 24, + eSteamErrorCorruptEncryptedUserIDTicket = 25, + eSteamErrorSocketLibraryNotInitialized = 26, + eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27, + eSteamErrorBadProtocolVersion = 28, + eSteamErrorReplayedUserIDTicketFromClient = 29, + eSteamErrorReceiveResultBufferTooSmall = 30, + eSteamErrorSendFailed = 31, + eSteamErrorReceiveFailed = 32, + eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33, + eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34, + eSteamErrorValidationStalledSoAborted = 35, + eSteamErrorInvalidUserIDTicket = 36, + eSteamErrorClientLoginRateTooHigh = 37, + eSteamErrorClientWasNeverValidated = 38, + eSteamErrorInternalSendBufferTooSmall = 39, + eSteamErrorInternalReceiveBufferTooSmall = 40, + eSteamErrorUserTicketExpired = 41, + eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42, + + eSteamErrorNotLoggedIn = 101, + eSteamErrorAlreadyExists = 102, + eSteamErrorAlreadySubscribed = 103, + eSteamErrorNotSubscribed = 104, + eSteamErrorAccessDenied = 105, + eSteamErrorFailedToCreateCacheFile = 106, + eSteamErrorCallStalledSoAborted = 107, + eSteamErrorEngineNotRunning = 108, + eSteamErrorEngineConnectionLost = 109, + eSteamErrorLoginFailed = 110, + eSteamErrorAccountPending = 111, + eSteamErrorCacheWasMissingRetry = 112, + eSteamErrorLocalTimeIncorrect = 113, + eSteamErrorCacheNeedsDecryption = 114, + eSteamErrorAccountDisabled = 115, + eSteamErrorCacheNeedsRepair = 116, + eSteamErrorRebootRequired = 117, + + eSteamErrorNetwork = 200, + eSteamErrorOffline = 201 + + +} ESteamError; + + +typedef enum +{ + eNoDetailedErrorAvailable, + eStandardCerrno, + eWin32LastError, + eWinSockLastError, + eDetailedPlatformErrorCount +} EDetailedPlatformErrorType; + +typedef enum /* Filter elements returned by SteamFind{First,Next} */ +{ + eSteamFindLocalOnly, /* limit search to local filesystem */ + eSteamFindRemoteOnly, /* limit search to remote repository */ + eSteamFindAll /* do not limit search (duplicates allowed) */ +} ESteamFindFilter; + + +/****************************************************************************** +** +** Exported structure and complex type definitions. +** +******************************************************************************/ + + +typedef struct +{ + ESteamError eSteamError; + EDetailedPlatformErrorType eDetailedErrorType; + int nDetailedErrorCode; + char szDesc[STEAM_MAX_PATH]; +} TSteamError; + + + +typedef struct +{ + int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */ + unsigned int uSizeOrCount; /* If element is a file, this contains size of file in bytes */ + int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */ + char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */ + long lLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */ + long lLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */ + long lCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */ +} TSteamElemInfo; + + +// https://github.com/SteamRE/open-steamworks/blob/master/Open%20Steamworks/TSteamElemInfo.h +typedef struct TSteamElemInfo64 +{ + int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */ + unsigned long long ullSizeOrCount; /* If element is a file, this contains size of file in bytes */ + int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */ + char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */ + long long llLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */ + long long llLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */ + long long llCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */ +} TSteamElemInfo64; + + +typedef struct +{ + unsigned int uNumSubscriptions; + unsigned int uMaxNameChars; + unsigned int uMaxApps; + +} TSteamSubscriptionStats; + + +typedef struct +{ + unsigned int uNumApps; + unsigned int uMaxNameChars; + unsigned int uMaxInstallDirNameChars; + unsigned int uMaxVersionLabelChars; + unsigned int uMaxLaunchOptions; + unsigned int uMaxLaunchOptionDescChars; + unsigned int uMaxLaunchOptionCmdLineChars; + unsigned int uMaxNumIcons; + unsigned int uMaxIconSize; + unsigned int uMaxDependencies; + +} TSteamAppStats; + +typedef struct +{ + char *szLabel; + unsigned int uMaxLabelChars; + unsigned int uVersionId; + int bIsNotAvailable; +} TSteamAppVersion; + +typedef struct +{ + char *szDesc; + unsigned int uMaxDescChars; + char *szCmdLine; + unsigned int uMaxCmdLineChars; + unsigned int uIndex; + unsigned int uIconIndex; + int bNoDesktopShortcut; + int bNoStartMenuShortcut; + int bIsLongRunningUnattended; + +} TSteamAppLaunchOption; + + +typedef struct +{ + char *szName; + unsigned int uMaxNameChars; + char *szLatestVersionLabel; + unsigned int uMaxLatestVersionLabelChars; + char *szCurrentVersionLabel; + unsigned int uMaxCurrentVersionLabelChars; + char *szInstallDirName; + unsigned int uMaxInstallDirNameChars; + unsigned int uId; + unsigned int uLatestVersionId; + unsigned int uCurrentVersionId; + unsigned int uMinCacheFileSizeMB; + unsigned int uMaxCacheFileSizeMB; + unsigned int uNumLaunchOptions; + unsigned int uNumIcons; + unsigned int uNumVersions; + unsigned int uNumDependencies; + +} TSteamApp; + +typedef enum +{ + eNoCost = 0, + eBillOnceOnly = 1, + eBillMonthly = 2, + eProofOfPrepurchaseOnly = 3, + eGuestPass = 4, + eHardwarePromo = 5, + eNumBillingTypes, +} EBillingType; + +typedef struct +{ + char *szName; + unsigned int uMaxNameChars; + unsigned int *puAppIds; + unsigned int uMaxAppIds; + unsigned int uId; + unsigned int uNumApps; + EBillingType eBillingType; + unsigned int uCostInCents; + unsigned int uNumDiscounts; + int bIsPreorder; + int bRequiresShippingAddress; + unsigned int uDomesticShippingCostInCents; + unsigned int uInternationalShippingCostInCents; + bool bIsCyberCafeSubscription; + unsigned int uGameCode; + char szGameCodeDesc[STEAM_MAX_PATH]; + bool bIsDisabled; + bool bRequiresCD; + unsigned int uTerritoryCode; + bool bIsSteam3Subscription; + +} TSteamSubscription; + +typedef struct +{ + char szName[STEAM_MAX_PATH]; + unsigned int uDiscountInCents; + unsigned int uNumQualifiers; + +} TSteamSubscriptionDiscount; + +typedef struct +{ + char szName[STEAM_MAX_PATH]; + unsigned int uRequiredSubscription; + int bIsDisqualifier; + +} TSteamDiscountQualifier; + +typedef struct TSteamProgress +{ + int bValid; /* non-zero if call provides progress info */ + unsigned int uPercentDone; /* 0 to 100 * STEAM_PROGRESS_PERCENT_SCALE if bValid */ + char szProgress[STEAM_MAX_PATH]; /* additional progress info */ +} TSteamProgress; + +typedef enum +{ + eSteamNotifyTicketsWillExpire, + eSteamNotifyAccountInfoChanged, + eSteamNotifyContentDescriptionChanged, + eSteamNotifyPleaseShutdown, + eSteamNotifyNewContentServer, + eSteamNotifySubscriptionStatusChanged, + eSteamNotifyContentServerConnectionLost, + eSteamNotifyCacheLoadingCompleted, + eSteamNotifyCacheNeedsDecryption, + eSteamNotifyCacheNeedsRepair +} ESteamNotificationCallbackEvent; + + +typedef void(*SteamNotificationCallback_t)(ESteamNotificationCallbackEvent eEvent, unsigned int nData); + + +typedef char SteamPersonalQuestion_t[ STEAM_QUESTION_MAXLEN + 1 ]; + +typedef struct +{ + unsigned char uchSalt[STEAM_SALT_SIZE]; +} SteamSalt_t; + +typedef enum +{ + eVisa = 1, + eMaster = 2, + eAmericanExpress = 3, + eDiscover = 4, + eDinnersClub = 5, + eJCB = 6 +} ESteamPaymentCardType; + +typedef struct +{ + ESteamPaymentCardType eCardType; + char szCardNumber[ STEAM_CARD_NUMBER_SIZE +1 ]; + char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szCardExpYear[ STEAM_CARD_EXPYEAR_SIZE + 1 ]; + char szCardExpMonth[ STEAM_CARD_EXPMONTH_SIZE+ 1 ]; + char szCardCVV2[ STEAM_CARD_CVV2_SIZE + 1 ]; + char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + char szBillingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; + char szBillingEmailAddress[ STEAM_BILLING_EMAIL_ADDRESS_SIZE + 1 ]; + unsigned int uExpectedCostInCents; + unsigned int uExpectedTaxInCents; + /* If the TSteamSubscription says that shipping info is required, */ + /* then the following fields must be filled out. */ + /* If szShippingName is empty, then assumes so are the rest. */ + char szShippingName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szShippingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szShippingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szShippingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szShippingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szShippingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szShippingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + char szShippingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; + unsigned int uExpectedShippingCostInCents; + +} TSteamPaymentCardInfo; + +typedef struct +{ + char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; + + /* A ProofOfPurchase token is not necessarily a nul-terminated string; it may be binary data + (perhaps encrypted). Hence we need a length and an array of bytes. */ + unsigned int uLengthOfBinaryProofOfPurchaseToken; + char cBinaryProofOfPurchaseToken[ STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE + 1 ]; +} TSteamPrepurchaseInfo; + +typedef struct +{ + char szAccountName[ STEAM_EXTERNAL_ACCOUNTNAME_SIZE + 1 ]; + char szPassword[ STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE + 1 ]; +} TSteamExternalBillingInfo; + +typedef enum +{ + ePaymentCardInfo = 1, + ePrepurchasedInfo = 2, + eAccountBillingInfo = 3, + eExternalBillingInfo = 4, /* indirect billing via ISP etc (not supported yet) */ + ePaymentCardReceipt = 5, + ePrepurchaseReceipt = 6, + eEmptyReceipt = 7 +} ESteamSubscriptionBillingInfoType; + +typedef struct +{ + ESteamSubscriptionBillingInfoType eBillingInfoType; + union { + TSteamPaymentCardInfo PaymentCardInfo; + TSteamPrepurchaseInfo PrepurchaseInfo; + TSteamExternalBillingInfo ExternalBillingInfo; + char bUseAccountBillingInfo; + }; + +} TSteamSubscriptionBillingInfo; + +typedef enum +{ + /* Subscribed */ + eSteamSubscriptionOK = 0, /* Subscribed */ + eSteamSubscriptionPending = 1, /* Awaiting transaction completion */ + eSteamSubscriptionPreorder = 2, /* Is currently a pre-order */ + eSteamSubscriptionPrepurchaseTransferred = 3, /* hop to this account */ + /* Unusbscribed */ + eSteamSubscriptionPrepurchaseInvalid = 4, /* Invalid cd-key */ + eSteamSubscriptionPrepurchaseRejected = 5, /* hopped out / banned / etc */ + eSteamSubscriptionPrepurchaseRevoked = 6, /* hop away from this account */ + eSteamSubscriptionPaymentCardDeclined = 7, /* CC txn declined */ + eSteamSubscriptionCancelledByUser = 8, /* Cancelled by client */ + eSteamSubscriptionCancelledByVendor = 9, /* Cancelled by us */ + eSteamSubscriptionPaymentCardUseLimit = 10, /* Card used too many times, potential fraud */ + eSteamSubscriptionPaymentCardAlert = 11, /* Got a "pick up card" or the like from bank */ + eSteamSubscriptionFailed = 12, /* Other Error in subscription data or transaction failed/lost */ + eSteamSubscriptionPaymentCardAVSFailure = 13, /* Card failed Address Verification check */ + eSteamSubscriptionPaymentCardInsufficientFunds = 14, /* Card failed due to insufficient funds */ + eSteamSubscriptionRestrictedCountry = 15 /* The subscription is not available in the user's country */ + +} ESteamSubscriptionStatus; + +typedef struct +{ + ESteamPaymentCardType eCardType; + char szCardLastFourDigits[ 4 + 1 ]; + char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + + // The following are only available after the subscription leaves "pending" status + char szCardApprovalCode[ STEAM_BILLING_CARD_APPROVAL_CODE_SIZE + 1]; + char szTransDate[ STEAM_BILLING_TRANS_DATE_SIZE + 1]; /* mm/dd/yy */ + char szTransTime[ STEAM_BILLING_TRANS_TIME_SIZE + 1]; /* hh:mm:ss */ + unsigned int uPriceWithoutTax; + unsigned int uTaxAmount; + unsigned int uShippingCost; + +} TSteamPaymentCardReceiptInfo; + +typedef struct +{ + char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; +} TSteamPrepurchaseReceiptInfo; + +typedef struct +{ + ESteamSubscriptionStatus eStatus; + ESteamSubscriptionStatus ePreviousStatus; + ESteamSubscriptionBillingInfoType eReceiptInfoType; + char szConfirmationCode[ STEAM_BILLING_CONFIRMATION_CODE_SIZE + 1]; + union { + TSteamPaymentCardReceiptInfo PaymentCardReceiptInfo; + TSteamPrepurchaseReceiptInfo PrepurchaseReceiptInfo; + }; + +} TSteamSubscriptionReceipt; + +typedef enum +{ + ePhysicalBytesReceivedThisSession = 1, + eAppReadyToLaunchStatus = 2, + eAppPreloadStatus = 3, + eAppEntireDepot = 4, + eCacheBytesPresent = 5 +} ESteamAppUpdateStatsQueryType; + +typedef struct +{ + SteamUnsigned64_t uBytesTotal; + SteamUnsigned64_t uBytesPresent; +} TSteamUpdateStats; + +typedef enum +{ + eSteamUserAdministrator = 0x00000001, /* May subscribe, unsubscribe, etc */ + eSteamUserDeveloper = 0x00000002, /* Steam or App developer */ + eSteamUserCyberCafe = 0x00000004 /* CyberCafe, school, etc -- UI should ask for password */ + /* before allowing logout, unsubscribe, etc */ +} ESteamUserTypeFlags; + +typedef enum +{ + eSteamAccountStatusDefault = 0x00000000, + eSteamAccountStatusEmailVerified = 0x00000001, + /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */ + eSteamAccountDisabled = 0x00000004 +} ESteamAccountStatusBitFields ; + + +typedef enum +{ + eSteamBootstrapperError = -1, + eSteamBootstrapperDontCheckForUpdate = 0, + eSteamBootstrapperCheckForUpdateAndRerun = 7 + +} ESteamBootStrapperClientAppResult; + +typedef enum +{ + eSteamOnline = 0, + eSteamOffline = 1, + eSteamNoAuthMode = 2, + eSteamBillingOffline = 3 +} eSteamOfflineStatus; + +typedef struct +{ + int eOfflineNow; + int eOfflineNextSession; +} TSteamOfflineStatus; + +typedef struct +{ + unsigned int uAppId; + int bIsSystemDefined; + char szMountPath[STEAM_MAX_PATH]; +} TSteamAppDependencyInfo; + +typedef enum +{ + eSteamOpenFileRegular = 0x0, + eSteamOpenFileIgnoreLocal = 0x1, + eSteamOpenFileChecksumReads = 0x2 +} ESteamOpenFileFlags; + +typedef enum +{ + eSteamValveCDKeyValidationServer = 0, + eSteamHalfLifeMasterServer = 1, + eSteamFriendsServer = 2, + eSteamCSERServer = 3, + eSteamHalfLife2MasterServer = 4, + eSteamRDKFMasterServer = 5, + eMaxServerTypes = 6 +} ESteamServerType; + +/****************************************************************************** +** +** More exported constants +** +******************************************************************************/ + + +const SteamHandle_t STEAM_INVALID_HANDLE = 0; +const SteamCallHandle_t STEAM_INVALID_CALL_HANDLE = 0; +const SteamUserIDTicketValidationHandle_t STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE = 0; +const unsigned int STEAM_USE_LATEST_VERSION = 0xFFFFFFFF; + + +/****************************************************************************** +** Each Steam instance (licensed Steam Service Provider) has a unique SteamInstanceID_t. +** +** Each Steam instance as its own DB of users. +** Each user in the DB has a unique SteamLocalUserID_t (a serial number, with possible +** rare gaps in the sequence). +** +******************************************************************************/ + +typedef unsigned short SteamInstanceID_t; // MUST be 16 bits + + +#if defined ( _WIN32 ) +typedef unsigned __int64 SteamLocalUserID_t; // MUST be 64 bits +#else +typedef unsigned long long SteamLocalUserID_t; // MUST be 64 bits +#endif + +/****************************************************************************** +** +** Applications need to be able to authenticate Steam users from ANY instance. +** So a SteamIDTicket contains SteamGlobalUserID, which is a unique combination of +** instance and user id. +** +** SteamLocalUserID is an unsigned 64-bit integer. +** For platforms without 64-bit int support, we provide access via a union that splits it into +** high and low unsigned 32-bit ints. Such platforms will only need to compare LocalUserIDs +** for equivalence anyway - not perform arithmetic with them. +** +********************************************************************************/ +typedef struct +{ + unsigned int Low32bits; + unsigned int High32bits; +} TSteamSplitLocalUserID; + +typedef struct +{ + SteamInstanceID_t m_SteamInstanceID; + + union + { + SteamLocalUserID_t As64bits; + TSteamSplitLocalUserID Split; + } m_SteamLocalUserID; + +} TSteamGlobalUserID; + + +// other stuff based on reversing +typedef struct +{ + unsigned int uAppId; + const char szAppName[64]; + +} TSteamAppInfo; diff --git a/steam_old_lib/steam_old_lib/steam_old_lib.hpp b/steam_old_lib/steam_old_lib/steam_old_lib.hpp new file mode 100644 index 00000000..5c232db7 --- /dev/null +++ b/steam_old_lib/steam_old_lib/steam_old_lib.hpp @@ -0,0 +1,11 @@ +#pragma once + + +namespace sold { + +using steamclient_loader_t = void* (bool load); + +void set_steamclient_loader(steamclient_loader_t *loader); +void set_tid(unsigned long tid); + +}