Compare commits

..

7 Commits

12 changed files with 128 additions and 484 deletions

View File

@ -8,7 +8,7 @@ call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Od /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe
copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\ copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def

View File

@ -649,6 +649,13 @@ static void load_dlls()
std::vector<std::string> paths = Local_Storage::get_filenames_path(path); std::vector<std::string> paths = Local_Storage::get_filenames_path(path);
for (auto & p: paths) { for (auto & p: paths) {
std::string full_path = path + p; std::string full_path = path + p;
size_t length = full_path.length();
if (length < 4) continue;
if (std::toupper(full_path[length - 1]) != 'L') continue;
if (std::toupper(full_path[length - 2]) != 'L') continue;
if (std::toupper(full_path[length - 3]) != 'D') continue;
if (full_path[length - 4] != '.') continue;
PRINT_DEBUG("Trying to load %s\n", full_path.c_str()); PRINT_DEBUG("Trying to load %s\n", full_path.c_str());
if (LoadLibraryA(full_path.c_str())) { if (LoadLibraryA(full_path.c_str())) {
PRINT_DEBUG("LOADED %s\n", full_path.c_str()); PRINT_DEBUG("LOADED %s\n", full_path.c_str());

View File

@ -27,11 +27,7 @@
#include "steam_remote_storage.h" #include "steam_remote_storage.h"
#include "steam_screenshots.h" #include "steam_screenshots.h"
#include "steam_http.h" #include "steam_http.h"
#ifdef CONTROLLER_SUPPORT
#include "steam_controller.h" #include "steam_controller.h"
#else
#include "steam_controller_disabled.h"
#endif
#include "steam_ugc.h" #include "steam_ugc.h"
#include "steam_applist.h" #include "steam_applist.h"
#include "steam_music.h" #include "steam_music.h"

View File

@ -16,6 +16,18 @@
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#include "base.h" #include "base.h"
#ifndef CONTROLLER_SUPPORT
inline void GamepadInit(void) {}
inline void GamepadShutdown(void) {}
inline void GamepadUpdate(void) {}
inline GAMEPAD_BOOL GamepadIsConnected(GAMEPAD_DEVICE device) { return GAMEPAD_FALSE; }
inline GAMEPAD_BOOL GamepadButtonDown(GAMEPAD_DEVICE device, GAMEPAD_BUTTON button) { return GAMEPAD_FALSE; }
inline float GamepadTriggerLength(GAMEPAD_DEVICE device, GAMEPAD_TRIGGER trigger) { return 0.0; }
inline GAMEPAD_STICKDIR GamepadStickDir(GAMEPAD_DEVICE device, GAMEPAD_STICK stick) { return STICKDIR_CENTER; }
inline void GamepadStickNormXY(GAMEPAD_DEVICE device, GAMEPAD_STICK stick, float* outX, float* outY) {}
inline float GamepadStickLength(GAMEPAD_DEVICE device, GAMEPAD_STICK stick) { return 0.0; }
inline void GamepadSetRumble(GAMEPAD_DEVICE device, float left, float right, unsigned int rumble_length_ms) {}
#endif
struct Controller_Map { struct Controller_Map {
std::map<ControllerDigitalActionHandle_t, std::set<int>> active_digital; std::map<ControllerDigitalActionHandle_t, std::set<int>> active_digital;
@ -756,7 +768,7 @@ int GetGamepadIndexForController( ControllerHandle_t ulControllerHandle )
// Returns the associated controller handle for the specified emulated gamepad // Returns the associated controller handle for the specified emulated gamepad
ControllerHandle_t GetControllerForGamepadIndex( int nIndex ) ControllerHandle_t GetControllerForGamepadIndex( int nIndex )
{ {
PRINT_DEBUG("Steam_Controller::GetControllerForGamepadIndex\n"); PRINT_DEBUG("Steam_Controller::GetControllerForGamepadIndex %i\n", nIndex);
ControllerHandle_t out = nIndex + 1; ControllerHandle_t out = nIndex + 1;
auto controller = controllers.find(out); auto controller = controllers.find(out);
if (controller == controllers.end()) return 0; if (controller == controllers.end()) return 0;
@ -890,7 +902,7 @@ const char *GetGlyphForActionOrigin( EInputActionOrigin eOrigin )
// Returns the input type for a particular handle // Returns the input type for a particular handle
ESteamInputType GetInputTypeForHandle( ControllerHandle_t controllerHandle ) ESteamInputType GetInputTypeForHandle( ControllerHandle_t controllerHandle )
{ {
PRINT_DEBUG("Steam_Controller::GetInputTypeForHandle\n"); PRINT_DEBUG("Steam_Controller::GetInputTypeForHandle %llu\n", controllerHandle);
auto controller = controllers.find(controllerHandle); auto controller = controllers.find(controllerHandle);
if (controller == controllers.end()) return k_ESteamInputType_Unknown; if (controller == controllers.end()) return k_ESteamInputType_Unknown;
return k_ESteamInputType_XBox360Controller; return k_ESteamInputType_XBox360Controller;

View File

@ -1,375 +0,0 @@
/* Copyright (C) 2019 Mr Goldberg
This file is part of the Goldberg Emulator
The Goldberg Emulator is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The Goldberg Emulator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */
#include "base.h"
class Steam_Controller :
public ISteamController001,
public ISteamController003,
public ISteamController004,
public ISteamController005,
public ISteamController006,
public ISteamController,
public ISteamInput
{
public:
Steam_Controller(class Settings *settings, class SteamCallResults *callback_results, class SteamCallBacks *callbacks, class RunEveryRunCB *run_every_runcb)
{
}
// Init and Shutdown must be called when starting/ending use of this interface
bool Init()
{
PRINT_DEBUG("Steam_Controller::Init()\n");
return true;
}
bool Init( const char *pchAbsolutePathToControllerConfigVDF )
{
PRINT_DEBUG("Steam_Controller::Init() old\n");
return Init();
}
bool Shutdown()
{
PRINT_DEBUG("Steam_Controller::Shutdown()\n");
return true;
}
void SetOverrideMode( const char *pchMode )
{
PRINT_DEBUG("Steam_Controller::SetOverrideMode\n");
}
// Synchronize API state with the latest Steam Controller inputs available. This
// is performed automatically by SteamAPI_RunCallbacks, but for the absolute lowest
// possible latency, you call this directly before reading controller state.
void RunFrame()
{
PRINT_DEBUG("Steam_Controller::RunFrame()\n");
}
bool GetControllerState( uint32 unControllerIndex, SteamControllerState001_t *pState )
{
PRINT_DEBUG("Steam_Controller::GetControllerState()\n");
return false;
}
// Enumerate currently connected controllers
// handlesOut should point to a STEAM_CONTROLLER_MAX_COUNT sized array of ControllerHandle_t handles
// Returns the number of handles written to handlesOut
int GetConnectedControllers( ControllerHandle_t *handlesOut )
{
PRINT_DEBUG("GetConnectedControllers\n");
return 0;
}
// Invokes the Steam overlay and brings up the binding screen
// Returns false is overlay is disabled / unavailable, or the user is not in Big Picture mode
bool ShowBindingPanel( ControllerHandle_t controllerHandle )
{
PRINT_DEBUG("ShowBindingPanel\n");
return false;
}
// ACTION SETS
// Lookup the handle for an Action Set. Best to do this once on startup, and store the handles for all future API calls.
ControllerActionSetHandle_t GetActionSetHandle( const char *pszActionSetName )
{
PRINT_DEBUG("GetActionSetHandle %s\n", pszActionSetName);
return 124;
}
// Reconfigure the controller to use the specified action set (ie 'Menu', 'Walk' or 'Drive')
// This is cheap, and can be safely called repeatedly. It's often easier to repeatedly call it in
// your state loops, instead of trying to place it in all of your state transitions.
void ActivateActionSet( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle )
{
PRINT_DEBUG("ActivateActionSet\n");
}
ControllerActionSetHandle_t GetCurrentActionSet( ControllerHandle_t controllerHandle )
{
PRINT_DEBUG("GetCurrentActionSet\n");
return 124;
}
void ActivateActionSetLayer( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetLayerHandle )
{
PRINT_DEBUG("ActivateActionSetLayer\n");
}
void DeactivateActionSetLayer( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetLayerHandle )
{
PRINT_DEBUG("DeactivateActionSetLayer\n");
}
void DeactivateAllActionSetLayers( ControllerHandle_t controllerHandle )
{
PRINT_DEBUG("DeactivateAllActionSetLayers\n");
}
int GetActiveActionSetLayers( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t *handlesOut )
{
PRINT_DEBUG("GetActiveActionSetLayers\n");
return 0;
}
// ACTIONS
// Lookup the handle for a digital action. Best to do this once on startup, and store the handles for all future API calls.
ControllerDigitalActionHandle_t GetDigitalActionHandle( const char *pszActionName )
{
PRINT_DEBUG("GetDigitalActionHandle %s\n", pszActionName);
return 123;
}
// Returns the current state of the supplied digital game action
ControllerDigitalActionData_t GetDigitalActionData( ControllerHandle_t controllerHandle, ControllerDigitalActionHandle_t digitalActionHandle )
{
PRINT_DEBUG("GetDigitalActionData\n");
ControllerDigitalActionData_t digitalData;
digitalData.bActive = false;
return digitalData;
}
// Get the origin(s) for a digital action within an action set. Returns the number of origins supplied in originsOut. Use this to display the appropriate on-screen prompt for the action.
// originsOut should point to a STEAM_CONTROLLER_MAX_ORIGINS sized array of EControllerActionOrigin handles
int GetDigitalActionOrigins( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerDigitalActionHandle_t digitalActionHandle, EControllerActionOrigin *originsOut )
{
PRINT_DEBUG("GetDigitalActionOrigins\n");
return 0;
}
int GetDigitalActionOrigins( InputHandle_t inputHandle, InputActionSetHandle_t actionSetHandle, InputDigitalActionHandle_t digitalActionHandle, EInputActionOrigin *originsOut )
{
PRINT_DEBUG("GetDigitalActionOrigins steaminput\n");
return 0;
}
// Lookup the handle for an analog action. Best to do this once on startup, and store the handles for all future API calls.
ControllerAnalogActionHandle_t GetAnalogActionHandle( const char *pszActionName )
{
PRINT_DEBUG("GetAnalogActionHandle %s\n", pszActionName);
return 125;
}
// Returns the current state of these supplied analog game action
ControllerAnalogActionData_t GetAnalogActionData( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t analogActionHandle )
{
PRINT_DEBUG("GetAnalogActionData\n");
ControllerAnalogActionData_t data;
data.eMode = k_EInputSourceMode_None;
data.x = data.y = 0;
data.bActive = false;
return data;
}
// Get the origin(s) for an analog action within an action set. Returns the number of origins supplied in originsOut. Use this to display the appropriate on-screen prompt for the action.
// originsOut should point to a STEAM_CONTROLLER_MAX_ORIGINS sized array of EControllerActionOrigin handles
int GetAnalogActionOrigins( ControllerHandle_t controllerHandle, ControllerActionSetHandle_t actionSetHandle, ControllerAnalogActionHandle_t analogActionHandle, EControllerActionOrigin *originsOut )
{
PRINT_DEBUG("GetAnalogActionOrigins\n");
return 0;
}
int GetAnalogActionOrigins( InputHandle_t inputHandle, InputActionSetHandle_t actionSetHandle, InputAnalogActionHandle_t analogActionHandle, EInputActionOrigin *originsOut )
{
PRINT_DEBUG("GetAnalogActionOrigins steaminput\n");
return 0;
}
void StopAnalogActionMomentum( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t eAction )
{
PRINT_DEBUG("StopAnalogActionMomentum\n");
}
// Trigger a haptic pulse on a controller
void TriggerHapticPulse( ControllerHandle_t controllerHandle, ESteamControllerPad eTargetPad, unsigned short usDurationMicroSec )
{
PRINT_DEBUG("TriggerHapticPulse\n");
}
void TriggerHapticPulse( uint32 unControllerIndex, ESteamControllerPad eTargetPad, unsigned short usDurationMicroSec )
{
PRINT_DEBUG("TriggerHapticPulse old\n");
TriggerHapticPulse(unControllerIndex, eTargetPad, usDurationMicroSec );
}
// Trigger a pulse with a duty cycle of usDurationMicroSec / usOffMicroSec, unRepeat times.
// nFlags is currently unused and reserved for future use.
void TriggerRepeatedHapticPulse( ControllerHandle_t controllerHandle, ESteamControllerPad eTargetPad, unsigned short usDurationMicroSec, unsigned short usOffMicroSec, unsigned short unRepeat, unsigned int nFlags )
{
PRINT_DEBUG("TriggerRepeatedHapticPulse\n");
}
// Tigger a vibration event on supported controllers.
void TriggerVibration( ControllerHandle_t controllerHandle, unsigned short usLeftSpeed, unsigned short usRightSpeed )
{
PRINT_DEBUG("TriggerVibration\n");
}
// Set the controller LED color on supported controllers.
void SetLEDColor( ControllerHandle_t controllerHandle, uint8 nColorR, uint8 nColorG, uint8 nColorB, unsigned int nFlags )
{
PRINT_DEBUG("SetLEDColor\n");
}
// Returns the associated gamepad index for the specified controller, if emulating a gamepad
int GetGamepadIndexForController( ControllerHandle_t ulControllerHandle )
{
PRINT_DEBUG("GetGamepadIndexForController\n");
return 0;
}
// Returns the associated controller handle for the specified emulated gamepad
ControllerHandle_t GetControllerForGamepadIndex( int nIndex )
{
PRINT_DEBUG("GetControllerForGamepadIndex\n");
return 0;
}
// Returns raw motion data from the specified controller
ControllerMotionData_t GetMotionData( ControllerHandle_t controllerHandle )
{
PRINT_DEBUG("GetMotionData\n");
ControllerMotionData_t data = {};
return data;
}
// Attempt to display origins of given action in the controller HUD, for the currently active action set
// Returns false is overlay is disabled / unavailable, or the user is not in Big Picture mode
bool ShowDigitalActionOrigins( ControllerHandle_t controllerHandle, ControllerDigitalActionHandle_t digitalActionHandle, float flScale, float flXPosition, float flYPosition )
{
PRINT_DEBUG("ShowDigitalActionOrigins\n");
return true;
}
bool ShowAnalogActionOrigins( ControllerHandle_t controllerHandle, ControllerAnalogActionHandle_t analogActionHandle, float flScale, float flXPosition, float flYPosition )
{
PRINT_DEBUG("ShowAnalogActionOrigins\n");
return true;
}
// Returns a localized string (from Steam's language setting) for the specified origin
const char *GetStringForActionOrigin( EControllerActionOrigin eOrigin )
{
PRINT_DEBUG("GetStringForActionOrigin\n");
return "Button String";
}
const char *GetStringForActionOrigin( EInputActionOrigin eOrigin )
{
PRINT_DEBUG("GetStringForActionOrigin steaminput\n");
return "Button String";
}
// Get a local path to art for on-screen glyph for a particular origin
const char *GetGlyphForActionOrigin( EControllerActionOrigin eOrigin )
{
PRINT_DEBUG("GetGlyphForActionOrigin\n");
return "";
}
const char *GetGlyphForActionOrigin( EInputActionOrigin eOrigin )
{
PRINT_DEBUG("GetGlyphForActionOrigin steaminput\n");
return "";
}
// Returns the input type for a particular handle
ESteamInputType GetInputTypeForHandle( ControllerHandle_t controllerHandle )
{
PRINT_DEBUG("GetInputTypeForHandle\n");
return k_ESteamInputType_Unknown;
}
const char *GetStringForXboxOrigin( EXboxOrigin eOrigin )
{
PRINT_DEBUG("GetStringForXboxOrigin\n");
return "";
}
const char *GetGlyphForXboxOrigin( EXboxOrigin eOrigin )
{
PRINT_DEBUG("GetGlyphForXboxOrigin\n");
return "";
}
EControllerActionOrigin GetActionOriginFromXboxOrigin_( ControllerHandle_t controllerHandle, EXboxOrigin eOrigin )
{
PRINT_DEBUG("GetActionOriginFromXboxOrigin\n");
return k_EControllerActionOrigin_None;
}
EInputActionOrigin GetActionOriginFromXboxOrigin( InputHandle_t inputHandle, EXboxOrigin eOrigin )
{
PRINT_DEBUG("GetActionOriginFromXboxOrigin steaminput\n");
return k_EInputActionOrigin_None;
}
EControllerActionOrigin TranslateActionOrigin( ESteamInputType eDestinationInputType, EControllerActionOrigin eSourceOrigin )
{
PRINT_DEBUG("TranslateActionOrigin\n");
return k_EControllerActionOrigin_None;
}
EInputActionOrigin TranslateActionOrigin( ESteamInputType eDestinationInputType, EInputActionOrigin eSourceOrigin )
{
PRINT_DEBUG("TranslateActionOrigin steaminput\n");
return k_EInputActionOrigin_None;
}
bool GetControllerBindingRevision( ControllerHandle_t controllerHandle, int *pMajor, int *pMinor )
{
PRINT_DEBUG("GetControllerBindingRevision\n");
return false;
}
bool GetDeviceBindingRevision( InputHandle_t inputHandle, int *pMajor, int *pMinor )
{
PRINT_DEBUG("GetDeviceBindingRevision\n");
return false;
}
uint32 GetRemotePlaySessionID( InputHandle_t inputHandle )
{
PRINT_DEBUG("GetRemotePlaySessionID\n");
return 0;
}
};

View File

@ -107,11 +107,16 @@ Steam_Networking_Sockets(class Settings *settings, class Networking *network, cl
this->run_every_runcb->remove(&Steam_Networking_Sockets::steam_run_every_runcb, this); this->run_every_runcb->remove(&Steam_Networking_Sockets::steam_run_every_runcb, this);
} }
static unsigned long get_socket_id()
{
static unsigned long socket_id;
socket_id++;
return socket_id;
}
HSteamListenSocket new_listen_socket(int nSteamConnectVirtualPort) HSteamListenSocket new_listen_socket(int nSteamConnectVirtualPort)
{ {
static HSteamListenSocket socket_id; HSteamListenSocket socket_id = get_socket_id();
++socket_id;
if (socket_id == k_HSteamListenSocket_Invalid) ++socket_id; if (socket_id == k_HSteamListenSocket_Invalid) ++socket_id;
auto conn = std::find_if(listen_sockets.begin(), listen_sockets.end(), [&nSteamConnectVirtualPort](struct Listen_Socket const& conn) { return conn.virtual_port == nSteamConnectVirtualPort;}); auto conn = std::find_if(listen_sockets.begin(), listen_sockets.end(), [&nSteamConnectVirtualPort](struct Listen_Socket const& conn) { return conn.virtual_port == nSteamConnectVirtualPort;});
@ -165,8 +170,7 @@ HSteamNetConnection new_connect_socket(SteamNetworkingIdentity remote_identity,
socket.user_data = -1; socket.user_data = -1;
socket.poll_group = k_HSteamNetPollGroup_Invalid; socket.poll_group = k_HSteamNetPollGroup_Invalid;
static HSteamNetConnection socket_id; HSteamNetConnection socket_id = get_socket_id();
++socket_id;
if (socket_id == k_HSteamNetConnection_Invalid) ++socket_id; if (socket_id == k_HSteamNetConnection_Invalid) ++socket_id;
if (connect_sockets.insert(std::make_pair(socket_id, socket)).second == false) { if (connect_sockets.insert(std::make_pair(socket_id, socket)).second == false) {
@ -833,7 +837,25 @@ int ReceiveMessagesOnListenSocket( HSteamListenSocket hSocket, SteamNetworkingMe
bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pInfo ) bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pInfo )
{ {
PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo\n"); PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo\n");
if (!pInfo)
return false; return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto connect_socket = connect_sockets.find(hConn);
if (connect_socket == connect_sockets.end()) return false;
memset(pInfo, 0, sizeof(SteamNetConnectionInfo_t));
pInfo->m_identityRemote = connect_socket->second.remote_identity;
pInfo->m_nUserData = connect_socket->second.user_data;
pInfo->m_hListenSocket = connect_socket->second.listen_socket_id;
//pInfo->m_addrRemote; //TODO
pInfo->m_idPOPRemote = 0;
pInfo->m_idPOPRelay = 0;
pInfo->m_eState = convert_status(connect_socket->second.status);
pInfo->m_eEndReason = 0; //TODO
pInfo->m_szEndDebug[0] = 0;
sprintf(pInfo->m_szConnectionDescription, "%u", hConn);
return true;
} }
@ -878,7 +900,7 @@ int ReceiveMessagesOnListenSocket( HSteamListenSocket hSocket, SteamNetworkingMe
/// Returns information about the specified connection. /// Returns information about the specified connection.
bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *pInfo ) bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *pInfo )
{ {
PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo\n"); PRINT_DEBUG("Steam_Networking_Sockets::GetConnectionInfo001\n");
return false; return false;
} }
@ -888,7 +910,21 @@ bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *
bool GetQuickConnectionStatus( HSteamNetConnection hConn, SteamNetworkingQuickConnectionStatus *pStats ) bool GetQuickConnectionStatus( HSteamNetConnection hConn, SteamNetworkingQuickConnectionStatus *pStats )
{ {
PRINT_DEBUG("Steam_Networking_Sockets::GetQuickConnectionStatus\n"); PRINT_DEBUG("Steam_Networking_Sockets::GetQuickConnectionStatus\n");
if (!pStats)
return false; return false;
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto connect_socket = connect_sockets.find(hConn);
if (connect_socket == connect_sockets.end()) return false;
memset(pStats, 0, sizeof(SteamNetworkingQuickConnectionStatus));
pStats->m_eState = convert_status(connect_socket->second.status);
pStats->m_nPing = 10; //TODO: calculate real numbers?
pStats->m_flConnectionQualityLocal = 1.0;
pStats->m_flConnectionQualityRemote = 1.0;
//TODO: rest
return true;
} }

View File

@ -18,13 +18,15 @@ bool Windows_Hook::start_hook()
{ {
GetRawInputBuffer = ::GetRawInputBuffer; GetRawInputBuffer = ::GetRawInputBuffer;
GetRawInputData = ::GetRawInputData; GetRawInputData = ::GetRawInputData;
SetCursorPos = ::SetCursorPos;
PRINT_DEBUG("Hooked Windows\n"); PRINT_DEBUG("Hooked Windows\n");
BeginHook(); BeginHook();
HookFuncs( HookFuncs(
std::make_pair<void**, void*>(&(PVOID&)GetRawInputBuffer, &Windows_Hook::MyGetRawInputBuffer), std::make_pair<void**, void*>(&(PVOID&)GetRawInputBuffer, &Windows_Hook::MyGetRawInputBuffer),
std::make_pair<void**, void*>(&(PVOID&)GetRawInputData , &Windows_Hook::MyGetRawInputData) std::make_pair<void**, void*>(&(PVOID&)GetRawInputData , &Windows_Hook::MyGetRawInputData),
std::make_pair<void**, void*>(&(PVOID&)SetCursorPos , &Windows_Hook::MySetCursorPos)
); );
EndHook(); EndHook();
@ -169,6 +171,18 @@ UINT WINAPI Windows_Hook::MyGetRawInputData(HRAWINPUT hRawInput, UINT uiCommand,
return 0; return 0;
} }
BOOL WINAPI Windows_Hook::MySetCursorPos(int x, int y)
{
if (get_steam_client()->steam_overlay->ShowOverlay()) {
POINT p;
GetCursorPos(&p);
x = p.x;
y = p.y;
}
return Windows_Hook::Inst()->SetCursorPos(x, y);
}
///////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////
Windows_Hook::Windows_Hook() : Windows_Hook::Windows_Hook() :

View File

@ -26,11 +26,13 @@ private:
// Hook to Windows window messages // Hook to Windows window messages
decltype(GetRawInputBuffer)* GetRawInputBuffer; decltype(GetRawInputBuffer)* GetRawInputBuffer;
decltype(GetRawInputData)* GetRawInputData; decltype(GetRawInputData)* GetRawInputData;
decltype(SetCursorPos)* SetCursorPos;
static LRESULT CALLBACK HookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK HookWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static UINT WINAPI MyGetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader); static UINT WINAPI MyGetRawInputBuffer(PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader);
static UINT WINAPI MyGetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader); static UINT WINAPI MyGetRawInputData(HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader);
static BOOL WINAPI MySetCursorPos(int x, int y);
public: public:
virtual ~Windows_Hook(); virtual ~Windows_Hook();

View File

@ -52,7 +52,6 @@ public:
/// setting the options "immediately" after creation. /// setting the options "immediately" after creation.
virtual HSteamNetConnection ConnectByIPAddress( const SteamNetworkingIPAddr &address, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0; virtual HSteamNetConnection ConnectByIPAddress( const SteamNetworkingIPAddr &address, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
#ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
/// Like CreateListenSocketIP, but clients will connect using ConnectP2P /// Like CreateListenSocketIP, but clients will connect using ConnectP2P
/// ///
/// nVirtualPort specifies how clients can connect to this socket using /// nVirtualPort specifies how clients can connect to this socket using
@ -81,7 +80,6 @@ public:
/// SteamNetworkingConfigValue_t for more about why this is preferable to /// SteamNetworkingConfigValue_t for more about why this is preferable to
/// setting the options "immediately" after creation. /// setting the options "immediately" after creation.
virtual HSteamNetConnection ConnectP2P( const SteamNetworkingIdentity &identityRemote, int nVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0; virtual HSteamNetConnection ConnectP2P( const SteamNetworkingIdentity &identityRemote, int nVirtualPort, int nOptions, const SteamNetworkingConfigValue_t *pOptions ) = 0;
#endif
/// Accept an incoming connection that has been received on a listen socket. /// Accept an incoming connection that has been received on a listen socket.
/// ///
@ -411,8 +409,6 @@ public:
/// other connections.) /// other connections.)
virtual int ReceiveMessagesOnPollGroup( HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages ) = 0; virtual int ReceiveMessagesOnPollGroup( HSteamNetPollGroup hPollGroup, SteamNetworkingMessage_t **ppOutMessages, int nMaxMessages ) = 0;
#ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
// //
// Clients connecting to dedicated servers hosted in a data center, // Clients connecting to dedicated servers hosted in a data center,
// using central-authority-granted tickets. // using central-authority-granted tickets.
@ -608,7 +604,6 @@ public:
/// If you expect to be using relayed connections, then you probably want /// If you expect to be using relayed connections, then you probably want
/// to call ISteamNetworkingUtils::InitRelayNetworkAccess() when your app initializes /// to call ISteamNetworkingUtils::InitRelayNetworkAccess() when your app initializes
virtual bool ReceivedP2PCustomSignal( const void *pMsg, int cbMsg, ISteamNetworkingCustomSignalingRecvContext *pContext ) = 0; virtual bool ReceivedP2PCustomSignal( const void *pMsg, int cbMsg, ISteamNetworkingCustomSignalingRecvContext *pContext ) = 0;
#endif // #ifndef STEAMNETWORKINGSOCKETS_ENABLE_SDR
// //
// Certificate provision by the application. On Steam, we normally handle all this automatically // Certificate provision by the application. On Steam, we normally handle all this automatically

View File

@ -8,7 +8,6 @@
class ISteamNetworkingUtils001 class ISteamNetworkingUtils001
{ {
public: public:
#ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
// //
// Initialization // Initialization
@ -149,7 +148,6 @@ public:
/// Get list of all POP IDs. Returns the number of entries that were filled into /// Get list of all POP IDs. Returns the number of entries that were filled into
/// your list. /// your list.
virtual int GetPOPList( SteamNetworkingPOPID *list, int nListSz ) = 0; virtual int GetPOPList( SteamNetworkingPOPID *list, int nListSz ) = 0;
#endif // #ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
// //
// Misc // Misc

View File

@ -8,7 +8,6 @@
class ISteamNetworkingUtils002 class ISteamNetworkingUtils002
{ {
public: public:
#ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
// //
// Initialization and status check // Initialization and status check
@ -152,7 +151,6 @@ public:
/// Get list of all POP IDs. Returns the number of entries that were filled into /// Get list of all POP IDs. Returns the number of entries that were filled into
/// your list. /// your list.
virtual int GetPOPList( SteamNetworkingPOPID *list, int nListSz ) = 0; virtual int GetPOPList( SteamNetworkingPOPID *list, int nListSz ) = 0;
#endif // #ifdef STEAMNETWORKINGSOCKETS_ENABLE_SDR
// //
// Misc // Misc

View File

@ -45,7 +45,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
} }
if (GetFileAttributesA(CurrentDirectory) == INVALID_FILE_ATTRIBUTES) { if (GetFileAttributesA(CurrentDirectory) == INVALID_FILE_ATTRIBUTES) {
MessageBoxA(NULL, "Couldn't find the configuration file(ColdClientLoader.ini).", "ColdClientLoader", MB_ICONERROR); MessageBoxA(NULL, "Couldn't find the configuration file(ColdClientLoader.ini).", "ColdClientLoader", MB_ICONERROR);
ExitProcess(NULL); return 0;
} }
GetPrivateProfileStringA("SteamClient", "SteamClient64Dll", "", Client64Path, MAX_PATH, CurrentDirectory); GetPrivateProfileStringA("SteamClient", "SteamClient64Dll", "", Client64Path, MAX_PATH, CurrentDirectory);
@ -60,27 +60,23 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
SetEnvironmentVariableA("SteamGameId", AppId); SetEnvironmentVariableA("SteamGameId", AppId);
} }
CHAR TMP[MAX_PATH] = { 0 }; CHAR TMP[MAX_PATH] = {};
if (!IsNotRelativePathOrRemoveFileName(Client64Path, false)) { if (!IsNotRelativePathOrRemoveFileName(Client64Path, false)) {
ZeroMemory(TMP, sizeof(TMP));
lstrcpyA(TMP, Client64Path); lstrcpyA(TMP, Client64Path);
ZeroMemory(Client64Path, sizeof(Client64Path)); ZeroMemory(Client64Path, sizeof(Client64Path));
GetFullPathNameA(TMP, MAX_PATH, Client64Path, NULL); GetFullPathNameA(TMP, MAX_PATH, Client64Path, NULL);
} }
if (!IsNotRelativePathOrRemoveFileName(ClientPath, false)) { if (!IsNotRelativePathOrRemoveFileName(ClientPath, false)) {
ZeroMemory(TMP, sizeof(TMP));
lstrcpyA(TMP, ClientPath); lstrcpyA(TMP, ClientPath);
ZeroMemory(ClientPath, sizeof(ClientPath)); ZeroMemory(ClientPath, sizeof(ClientPath));
GetFullPathNameA(TMP, MAX_PATH, ClientPath, NULL); GetFullPathNameA(TMP, MAX_PATH, ClientPath, NULL);
} }
if (!IsNotRelativePathOrRemoveFileName(ExeFile, false)) { if (!IsNotRelativePathOrRemoveFileName(ExeFile, false)) {
ZeroMemory(TMP, sizeof(TMP));
lstrcpyA(TMP, ExeFile); lstrcpyA(TMP, ExeFile);
ZeroMemory(ExeFile, sizeof(ExeFile)); ZeroMemory(ExeFile, sizeof(ExeFile));
GetFullPathNameA(TMP, MAX_PATH, ExeFile, NULL); GetFullPathNameA(TMP, MAX_PATH, ExeFile, NULL);
} }
if (!IsNotRelativePathOrRemoveFileName(ExeRunDir, false)) { if (!IsNotRelativePathOrRemoveFileName(ExeRunDir, false)) {
ZeroMemory(TMP, sizeof(TMP));
lstrcpyA(TMP, ExeRunDir); lstrcpyA(TMP, ExeRunDir);
ZeroMemory(ExeRunDir, sizeof(ExeRunDir)); ZeroMemory(ExeRunDir, sizeof(ExeRunDir));
GetFullPathNameA(TMP, MAX_PATH, ExeRunDir, NULL); GetFullPathNameA(TMP, MAX_PATH, ExeRunDir, NULL);
@ -88,17 +84,17 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
if (GetFileAttributesA(Client64Path) == INVALID_FILE_ATTRIBUTES) { if (GetFileAttributesA(Client64Path) == INVALID_FILE_ATTRIBUTES) {
MessageBoxA(NULL, "Couldn't find the requested SteamClient64Dll.", "ColdClientLoader", MB_ICONERROR); MessageBoxA(NULL, "Couldn't find the requested SteamClient64Dll.", "ColdClientLoader", MB_ICONERROR);
ExitProcess(NULL); return 0;
} }
if (GetFileAttributesA(ClientPath) == INVALID_FILE_ATTRIBUTES) { if (GetFileAttributesA(ClientPath) == INVALID_FILE_ATTRIBUTES) {
MessageBoxA(NULL, "Couldn't find the requested SteamClientDll.", "ColdClientLoader", MB_ICONERROR); MessageBoxA(NULL, "Couldn't find the requested SteamClientDll.", "ColdClientLoader", MB_ICONERROR);
ExitProcess(NULL); return 0;
} }
if (GetFileAttributesA(ExeFile) == INVALID_FILE_ATTRIBUTES) { if (GetFileAttributesA(ExeFile) == INVALID_FILE_ATTRIBUTES) {
MessageBoxA(NULL, "Couldn't find the requested Exe file.", "ColdClientLoader", MB_ICONERROR); MessageBoxA(NULL, "Couldn't find the requested Exe file.", "ColdClientLoader", MB_ICONERROR);
ExitProcess(NULL); return 0;
} }
CHAR CommandLine[8192]; CHAR CommandLine[8192];
@ -106,73 +102,39 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
if (!ExeFile[0] || !CreateProcessA(ExeFile, CommandLine, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, ExeRunDir, &info, &processInfo)) if (!ExeFile[0] || !CreateProcessA(ExeFile, CommandLine, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, ExeRunDir, &info, &processInfo))
{ {
MessageBoxA(NULL, "Unable to load the requested EXE file.", "ColdClientLoader", MB_ICONERROR); MessageBoxA(NULL, "Unable to load the requested EXE file.", "ColdClientLoader", MB_ICONERROR);
ExitProcess(NULL); return 0;
} }
HKEY Registrykey; HKEY Registrykey;
// Declare some variables to be used for Steam registry. // Declare some variables to be used for Steam registry.
DWORD UserId = 0x03100004771F810D & 0xffffffff; DWORD UserId = 0x03100004771F810D & 0xffffffff;
DWORD ProcessID = GetCurrentProcessId(); DWORD ProcessID = GetCurrentProcessId();
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) != ERROR_SUCCESS) bool orig_steam = false;
{
if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, 0, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &Registrykey, NULL) != ERROR_SUCCESS)
{
MessageBoxA(NULL, "Unable to patch Steam process informations on the Windows registry.", "ColdClientLoader", MB_ICONERROR);
TerminateProcess(processInfo.hProcess, NULL);
ExitProcess(NULL);
}
else
{
// Set values to Windows registry.
RegSetValueExA(Registrykey, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD));
RegSetValueExA(Registrykey, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD));
{
// Before saving to the registry check again if the path was valid and if the file exist
if (GetFileAttributesA(ClientPath) != INVALID_FILE_ATTRIBUTES) {
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)ClientPath, (DWORD)lstrlenA(ClientPath) + 1);
}
else {
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)"", 0);
}
if (GetFileAttributesA(Client64Path) != INVALID_FILE_ATTRIBUTES) {
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)Client64Path, (DWORD)lstrlenA(Client64Path) + 1);
}
else {
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)"", 0);
}
}
RegSetValueExA(Registrykey, "Universe", NULL, REG_SZ, (LPBYTE)"Public", (DWORD)lstrlenA("Public") + 1);
// Close the HKEY Handle.
RegCloseKey(Registrykey);
ResumeThread(processInfo.hThread);
WaitForSingleObject(processInfo.hThread, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
ExitProcess(NULL);
}
}
else
{
DWORD keyType = REG_SZ; DWORD keyType = REG_SZ;
CHAR OrgSteamCDir[MAX_PATH] = { 0 }; CHAR OrgSteamCDir[MAX_PATH] = { 0 };
CHAR OrgSteamCDir64[MAX_PATH] = { 0 }; CHAR OrgSteamCDir64[MAX_PATH] = { 0 };
DWORD Size1 = MAX_PATH; DWORD Size1 = MAX_PATH;
DWORD Size2 = MAX_PATH; DWORD Size2 = MAX_PATH;
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) == ERROR_SUCCESS)
{
orig_steam = true;
// Get original values to restore later. // Get original values to restore later.
RegQueryValueExA(Registrykey, "SteamClientDll", 0, &keyType, (LPBYTE)& OrgSteamCDir, &Size1); RegQueryValueExA(Registrykey, "SteamClientDll", 0, &keyType, (LPBYTE)& OrgSteamCDir, &Size1);
RegQueryValueExA(Registrykey, "SteamClientDll64", 0, &keyType, (LPBYTE)& OrgSteamCDir64, &Size2); RegQueryValueExA(Registrykey, "SteamClientDll64", 0, &keyType, (LPBYTE)& OrgSteamCDir64, &Size2);
} else {
if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, 0, REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS, NULL, &Registrykey, NULL) != ERROR_SUCCESS)
{
MessageBoxA(NULL, "Unable to patch Steam process informations on the Windows registry.", "ColdClientLoader", MB_ICONERROR);
TerminateProcess(processInfo.hProcess, NULL);
return 0;
}
}
// Set values to Windows registry. // Set values to Windows registry.
RegSetValueExA(Registrykey, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD)); RegSetValueExA(Registrykey, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD));
RegSetValueExA(Registrykey, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD)); RegSetValueExA(Registrykey, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD));
{ {
// Before saving to the registry check again if the path was valid and if the file exist // Before saving to the registry check again if the path was valid and if the file exist
if (GetFileAttributesA(ClientPath) != INVALID_FILE_ATTRIBUTES) { if (GetFileAttributesA(ClientPath) != INVALID_FILE_ATTRIBUTES) {
@ -198,6 +160,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
CloseHandle(processInfo.hProcess); CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread); CloseHandle(processInfo.hThread);
if (orig_steam) {
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) == ERROR_SUCCESS) if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) == ERROR_SUCCESS)
{ {
// Restore the values. // Restore the values.
@ -207,9 +170,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
// Close the HKEY Handle. // Close the HKEY Handle.
RegCloseKey(Registrykey); RegCloseKey(Registrykey);
} }
ExitProcess(NULL);
} }
return 0;
return 1;
} }