[Proxy] Remove steam start
This commit is contained in:
parent
dc15f92b8b
commit
445c7825c0
@ -5,7 +5,6 @@ namespace Components
|
|||||||
bool Loader::Pregame = true;
|
bool Loader::Pregame = true;
|
||||||
bool Loader::Postgame = false;
|
bool Loader::Postgame = false;
|
||||||
bool Loader::Uninitializing = false;
|
bool Loader::Uninitializing = false;
|
||||||
bool Loader::ComInitialized = false;
|
|
||||||
std::vector<Component*> Loader::Components;
|
std::vector<Component*> Loader::Components;
|
||||||
|
|
||||||
bool Loader::IsPregame()
|
bool Loader::IsPregame()
|
||||||
@ -23,11 +22,6 @@ namespace Components
|
|||||||
return Loader::Uninitializing;
|
return Loader::Uninitializing;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Loader::IsComInitialized()
|
|
||||||
{
|
|
||||||
return Loader::ComInitialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Loader::Initialize()
|
void Loader::Initialize()
|
||||||
{
|
{
|
||||||
Loader::Pregame = true;
|
Loader::Pregame = true;
|
||||||
@ -35,9 +29,6 @@ namespace Components
|
|||||||
Loader::Uninitializing = false;
|
Loader::Uninitializing = false;
|
||||||
Utils::Memory::GetAllocator()->clear();
|
Utils::Memory::GetAllocator()->clear();
|
||||||
|
|
||||||
Loader::ComInitialized = false;
|
|
||||||
if (!Loader::PerformingUnitTests() && !Utils::IsWineEnvironment()) Loader::ComInitialized = (CoInitialize(nullptr) == S_OK);
|
|
||||||
|
|
||||||
Loader::Register(new Flags());
|
Loader::Register(new Flags());
|
||||||
Loader::Register(new Singleton());
|
Loader::Register(new Singleton());
|
||||||
Loader::Register(new Exception()); // install our exception handler as early as posssible to get better debug dumps from startup crashes
|
Loader::Register(new Exception()); // install our exception handler as early as posssible to get better debug dumps from startup crashes
|
||||||
@ -130,8 +121,6 @@ namespace Components
|
|||||||
|
|
||||||
Loader::Components.clear();
|
Loader::Components.clear();
|
||||||
Utils::Memory::GetAllocator()->clear();
|
Utils::Memory::GetAllocator()->clear();
|
||||||
|
|
||||||
if (!Loader::PerformingUnitTests() && !Utils::IsWineEnvironment() && Loader::ComInitialized) CoUninitialize();
|
|
||||||
Loader::Uninitializing = false;
|
Loader::Uninitializing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ namespace Components
|
|||||||
static bool IsPregame();
|
static bool IsPregame();
|
||||||
static bool IsPostgame();
|
static bool IsPostgame();
|
||||||
static bool IsUninitializing();
|
static bool IsUninitializing();
|
||||||
static bool IsComInitialized();
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static T* GetInstance()
|
static T* GetInstance()
|
||||||
@ -58,7 +57,6 @@ namespace Components
|
|||||||
static bool Pregame;
|
static bool Pregame;
|
||||||
static bool Postgame;
|
static bool Postgame;
|
||||||
static bool Uninitializing;
|
static bool Uninitializing;
|
||||||
static bool ComInitialized;
|
|
||||||
static std::vector<Component*> Components;
|
static std::vector<Component*> Components;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ namespace Components
|
|||||||
std::queue<Toast::UIToast> Toast::Queue;
|
std::queue<Toast::UIToast> Toast::Queue;
|
||||||
std::mutex Toast::Mutex;
|
std::mutex Toast::Mutex;
|
||||||
|
|
||||||
Toast::WinToastHandler* Toast::ToastHandler = nullptr;
|
|
||||||
|
|
||||||
void Toast::Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback)
|
void Toast::Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback)
|
||||||
{
|
{
|
||||||
Game::Material* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material;
|
Game::Material* material = Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_MATERIAL, image.data()).material;
|
||||||
@ -20,12 +18,6 @@ namespace Components
|
|||||||
Toast::Mutex.unlock();
|
Toast::Mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Toast::ShowNative(const WinToastLib::WinToastTemplate& toast)
|
|
||||||
{
|
|
||||||
if (!Loader::IsComInitialized() || !Toast::ToastHandler) return false;
|
|
||||||
return WinToastLib::WinToast::instance()->showToast(toast, Toast::ToastHandler) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Toast::GetIcon()
|
std::string Toast::GetIcon()
|
||||||
{
|
{
|
||||||
char ourPath[MAX_PATH] = { 0 };
|
char ourPath[MAX_PATH] = { 0 };
|
||||||
@ -156,15 +148,6 @@ namespace Components
|
|||||||
{
|
{
|
||||||
if (Dedicated::IsEnabled() || Monitor::IsEnabled()) return;
|
if (Dedicated::IsEnabled() || Monitor::IsEnabled()) return;
|
||||||
|
|
||||||
if (Loader::IsComInitialized())
|
|
||||||
{
|
|
||||||
Toast::ToastHandler = new Toast::WinToastHandler;
|
|
||||||
|
|
||||||
WinToastLib::WinToast::instance()->setAppName(L"IW4x");
|
|
||||||
WinToastLib::WinToast::instance()->setAppUserModelId(WinToastLib::WinToast::configureAUMI(L"IW4x", L"IW4x", L"IW4x", L"0"));
|
|
||||||
WinToastLib::WinToast::instance()->initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
Scheduler::OnReady([]()
|
Scheduler::OnReady([]()
|
||||||
{
|
{
|
||||||
Scheduler::OnFrame(Toast::Handler);
|
Scheduler::OnFrame(Toast::Handler);
|
||||||
@ -180,31 +163,4 @@ namespace Components
|
|||||||
{
|
{
|
||||||
Toast::Queue = std::queue<Toast::UIToast>();
|
Toast::Queue = std::queue<Toast::UIToast>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toast::preDestroy()
|
|
||||||
{
|
|
||||||
if (Dedicated::IsEnabled() || Monitor::IsEnabled() || !Loader::IsComInitialized()) return;
|
|
||||||
|
|
||||||
// Destroying that on the main thread deadlocks.
|
|
||||||
// I did not write the library, so whatever.
|
|
||||||
// If we are not in the postgame state,
|
|
||||||
// we are not allowed to spawn threads,
|
|
||||||
// so just don't uninitialize the library.
|
|
||||||
// That means we did not uninitialize the game
|
|
||||||
// correctly anyways.
|
|
||||||
if (Loader::IsPostgame())
|
|
||||||
{
|
|
||||||
std::thread([]()
|
|
||||||
{
|
|
||||||
delete WinToastLib::WinToast::instance();
|
|
||||||
delete Toast::ToastHandler;
|
|
||||||
Toast::ToastHandler = nullptr;
|
|
||||||
}).join();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete Toast::ToastHandler;
|
|
||||||
Toast::ToastHandler = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,9 @@ namespace Components
|
|||||||
public:
|
public:
|
||||||
Toast();
|
Toast();
|
||||||
~Toast();
|
~Toast();
|
||||||
void preDestroy() override;
|
|
||||||
|
|
||||||
typedef WinToastLib::WinToastTemplate Template;
|
|
||||||
|
|
||||||
static void Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
|
static void Show(std::string image, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
|
||||||
static void Show(Game::Material* material, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
|
static void Show(Game::Material* material, std::string title, std::string description, int length, Utils::Slot<void()> callback = Utils::Slot<void()>());
|
||||||
static bool ShowNative(const WinToastLib::WinToastTemplate& toast);
|
|
||||||
|
|
||||||
static std::string GetIcon();
|
static std::string GetIcon();
|
||||||
|
|
||||||
@ -29,20 +25,10 @@ namespace Components
|
|||||||
Utils::Slot<void()> callback;
|
Utils::Slot<void()> callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WinToastHandler: public WinToastLib::IWinToastHandler
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void toastActivated() const override {};
|
|
||||||
void toastDismissed(WinToastLib::IWinToastHandler::WinToastDismissalReason /*state*/) const override {};
|
|
||||||
void toastFailed() const override {};
|
|
||||||
};
|
|
||||||
|
|
||||||
static void Handler();
|
static void Handler();
|
||||||
static void Draw(UIToast* toast);
|
static void Draw(UIToast* toast);
|
||||||
|
|
||||||
static std::queue<UIToast> Queue;
|
static std::queue<UIToast> Queue;
|
||||||
static std::mutex Mutex;
|
static std::mutex Mutex;
|
||||||
|
|
||||||
static WinToastHandler* ToastHandler;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <Aclapi.h>
|
#include <Aclapi.h>
|
||||||
#include <Psapi.h>
|
#include <Psapi.h>
|
||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
|
#include <Shlwapi.h>
|
||||||
|
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable: 4091)
|
#pragma warning(disable: 4091)
|
||||||
@ -76,7 +77,6 @@ template <size_t S> class Sizer { };
|
|||||||
#include <mongoose.h>
|
#include <mongoose.h>
|
||||||
#include <json11.hpp>
|
#include <json11.hpp>
|
||||||
#include <tomcrypt.h>
|
#include <tomcrypt.h>
|
||||||
#include <wintoastlib.h>
|
|
||||||
#include <udis86.h>
|
#include <udis86.h>
|
||||||
|
|
||||||
#ifdef max
|
#ifdef max
|
||||||
|
@ -364,65 +364,6 @@ namespace Steam
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Proxy::StartSteamIfNecessary()
|
|
||||||
{
|
|
||||||
if (Proxy::GetSteamDirectory().empty() || !Steam::Enabled()) return;
|
|
||||||
|
|
||||||
HKEY hRegKey;
|
|
||||||
DWORD pid = 0;
|
|
||||||
if (RegOpenKeyExA(HKEY_CURRENT_USER, STEAM_REGISTRY_PROCESS_PATH, 0, KEY_QUERY_VALUE, &hRegKey) != ERROR_SUCCESS) return;
|
|
||||||
|
|
||||||
DWORD dwLength = sizeof(pid);
|
|
||||||
RegQueryValueExA(hRegKey, "pid", nullptr, nullptr, reinterpret_cast<BYTE*>(&pid), &dwLength);
|
|
||||||
RegCloseKey(hRegKey);
|
|
||||||
|
|
||||||
if (pid)
|
|
||||||
{
|
|
||||||
HANDLE process = OpenProcess(PROCESS_QUERY_INFORMATION, 0, pid);
|
|
||||||
if (process)
|
|
||||||
{
|
|
||||||
::Utils::Memory::Allocator allocator;
|
|
||||||
allocator.reference(process, [](HANDLE hProcess)
|
|
||||||
{
|
|
||||||
CloseHandle(hProcess);
|
|
||||||
});
|
|
||||||
|
|
||||||
allocator.reference(allocator.allocate(1), [](void*)
|
|
||||||
{
|
|
||||||
Proxy::LaunchWatchGuard();
|
|
||||||
});
|
|
||||||
|
|
||||||
DWORD exitCode;
|
|
||||||
if (!GetExitCodeProcess(process, &exitCode)) return;
|
|
||||||
if (exitCode == STILL_ACTIVE) return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string steamExe = Proxy::GetSteamDirectory() + "\\steam.exe";
|
|
||||||
if (::Utils::IO::FileExists(steamExe))
|
|
||||||
{
|
|
||||||
Components::Toast::Template templ = Components::Toast::Template(Components::Toast::Template::ImageAndText02);
|
|
||||||
templ.setTextField(L"Please wait", Components::Toast::Template::FirstLine);
|
|
||||||
templ.setTextField(L"Starting Steam...", Components::Toast::Template::SecondLine);
|
|
||||||
|
|
||||||
std::string icon = Components::Toast::GetIcon();
|
|
||||||
templ.setImagePath(std::wstring(icon.begin(), icon.end()));
|
|
||||||
|
|
||||||
Components::Toast::ShowNative(templ);
|
|
||||||
|
|
||||||
// If steam has crashed, the user is not null, so we reset it to be able to check if steam started
|
|
||||||
if (Proxy::GetActiveUser()) Proxy::ResetActiveUser();
|
|
||||||
|
|
||||||
ShellExecuteA(nullptr, nullptr, steamExe.data(), "-silent", nullptr, 1);
|
|
||||||
|
|
||||||
::Utils::Time::Interval interval;
|
|
||||||
while (!interval.elapsed(15s) && !Proxy::GetActiveUser()) std::this_thread::sleep_for(10ms);
|
|
||||||
std::this_thread::sleep_for(1s);
|
|
||||||
}
|
|
||||||
|
|
||||||
Proxy::LaunchWatchGuard();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Proxy::Inititalize()
|
bool Proxy::Inititalize()
|
||||||
{
|
{
|
||||||
std::string directoy = Proxy::GetSteamDirectory();
|
std::string directoy = Proxy::GetSteamDirectory();
|
||||||
@ -432,7 +373,7 @@ namespace Steam
|
|||||||
|
|
||||||
if (!Components::Dedicated::IsEnabled() && !Components::ZoneBuilder::IsEnabled())
|
if (!Components::Dedicated::IsEnabled() && !Components::ZoneBuilder::IsEnabled())
|
||||||
{
|
{
|
||||||
Proxy::StartSteamIfNecessary();
|
Proxy::LaunchWatchGuard();
|
||||||
|
|
||||||
Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false);
|
Proxy::Overlay = ::Utils::Library(GAMEOVERLAY_LIB, false);
|
||||||
if (!Proxy::Overlay.valid()) return false;
|
if (!Proxy::Overlay.valid()) return false;
|
||||||
|
@ -354,7 +354,6 @@ namespace Steam
|
|||||||
static void RunCallback(int32_t callId, void* data, size_t size);
|
static void RunCallback(int32_t callId, void* data, size_t size);
|
||||||
|
|
||||||
static void UnregisterCalls();
|
static void UnregisterCalls();
|
||||||
static void StartSteamIfNecessary();
|
|
||||||
static void LaunchWatchGuard();
|
static void LaunchWatchGuard();
|
||||||
|
|
||||||
static void ResetActiveUser();
|
static void ResetActiveUser();
|
||||||
|
Loading…
Reference in New Issue
Block a user