From ed80ac19017a8278cc571a3cb629a4e276c7c3b7 Mon Sep 17 00:00:00 2001 From: FragsAreUs <32180105+FragsAreUs@users.noreply.github.com> Date: Mon, 26 Sep 2022 13:21:00 -0400 Subject: [PATCH] Added Ownership check Copied from momo's boiii steam check so that you have to own the game on steam in order to launch the client --- src/client/RCa02912 | Bin 0 -> 6744 bytes src/client/component/steam_proxy.cpp | 69 +++++++++++++++++++++++---- src/client/std_include.hpp | 1 + 3 files changed, 62 insertions(+), 8 deletions(-) create mode 100644 src/client/RCa02912 diff --git a/src/client/RCa02912 b/src/client/RCa02912 new file mode 100644 index 0000000000000000000000000000000000000000..39de9bd279bed0e34f0c72462b1943e8228e5266 GIT binary patch literal 6744 zcmdUzT~8ZF6o$`rrT&Mlxk=U5#z2y$cVLWhYcRrwCQ>B}uyLrULAGg#)F0pHo$;_c zyK6(*C?ZpdTHX4dT5u54l>ORR1c+qYlr53UxYb9--hcJAJ|6WB)*^Wtsc|KCfV>Ol-8jliI3;$< z*bFXb&?MHdAGi`5!(IAL8J}|>GM1N^KqqcjcFUZqlPo!2gIh;C#+EZ^FPudq8!-3G zaera2?4_-9)$RL&)-M+$Lu6kf!DF{=N7l2xo!G9mtqZqfYuYw%T|2anyc>nf+dp0Mwz5-9JfthepL?%St ze~HC7GhcrNRx4`~qH99d%40L)Be566+=RDK8+ttXN--mwi%~dRZ-)_2lbtMYeyLO zxTJBiWj{NbQ}Sv6O_L1nxz+xVccHRJ#)w){c~qY!E7Y zT>05+pnFYq9+hyGrb4UfaFH&}CrMaFS0*c685`jL6#d1$jYZoo_hh&H7P2&JO%YL# z5w-Mu73ZY9XZq-DW9G8bRK#vS^Nl zGxnUS$76VgJ!ciZiiw*2%3T?!{oWn#@lLc>Dyh4$Nf9hBgc#9VHnL(~Rpi_|Yl?pL z=nc_8=;gf{^C`nCrhiI|#Wh?SrJX|h6zAs{HFabSHS?8V++X)*i~o zzG{ZgXL+qoWT_f0(ryjk=XVcmUxcUcj40z25QD4CLX2^C*xoH=X5yx785?pvFg z>Hr$l&_n1}UGc06lH${nnTv5nzjm?8vQTql$-Wn9yA@n}1)VP_`?QAcmuj$shJ82x zi0|c+XXK+|KzpewHCI*H$8%Pa)`}LtWp+MA(lvIC`NdMQHr9zV-<|GKy$5LCMgQHU zQoT0nn0DRDy}i`RA?FD-Y`ej`Lr%3+$I?AymC<{C-fl13Bl`|~wg2k#E3^ISvOUTl z!CL#)Illq_cVyQli0B+@Ok{Ws@|gG&3GF_XcW8YyRX^tUqh-3LV|lHsXi(#)|8sQG z`ag8f%8eS>yrLr1;5~BR$2`xOGh>!kl}kkTiEre7Q{#^ z{`}}Fq>t%h4!P9DrkIvLeGa6jcx1w*6*^wA;@ucSgRXc#1_=6|jersuc%1&xZ4ADload_client(); this->clean_up_on_error(); @@ -43,11 +51,25 @@ namespace steam_proxy #ifndef DEV_BUILD try { - this->start_mod("\xF0\x9F\x8E\xAE IW7-Mod ", 292730); + const auto res = this->start_mod("\xF0\x9F\x8E\xAE" "IW7-Mod", steam::SteamUtils()->GetAppID()); + + switch (res) + { + case ownership_state::nosteam: + throw std::runtime_error("Steam must be running to play this game!"); + case ownership_state::unowned: + throw std::runtime_error("You must own the game on steam to play this mod!"); + case ownership_state::error: + throw std::runtime_error("Failed to verify ownership of the game!"); + case ownership_state::success: + break; + } } catch (std::exception& e) { printf("Steam: %s\n", e.what()); + MessageBoxA(GetForegroundWindow(), e.what(), "Error", MB_ICONERROR); + TerminateProcess(GetCurrentProcess(), 1234); } #endif } @@ -122,13 +144,30 @@ namespace steam_proxy this->client_utils_ = this->client_engine_.invoke(14, this->steam_pipe_); // GetIClientUtils } - void start_mod(const std::string& title, size_t app_id) + ownership_state start_mod(const std::string& title, const size_t app_id) { - if (!this->client_utils_ || !this->client_user_) return; + __try + { + return this->start_mod_unsafe(title, app_id); + } + __except (EXCEPTION_EXECUTE_HANDLER) + { + this->do_cleanup(); + return ownership_state::error; + } + } + + ownership_state start_mod_unsafe(const std::string& title, size_t app_id) + { + if (!this->client_utils_ || !this->client_user_) + { + return ownership_state::nosteam; + } if (!this->client_user_.invoke("BIsSubscribedApp", app_id)) { - app_id = 480; // Spacewar + //app_id = 480; // Spacewar + return ownership_state::unowned; } this->client_utils_.invoke("SetAppIDForCurrentPipe", app_id, false); @@ -143,11 +182,25 @@ namespace steam_proxy game_id.raw.type = 1; // k_EGameIDTypeGameMod game_id.raw.app_id = app_id & 0xFFFFFF; - const auto* mod_id = "IW7-Mod"; + const auto* mod_id = "bo3"; game_id.raw.mod_id = *reinterpret_cast(mod_id) | 0x80000000; this->client_user_.invoke("SpawnProcess", path.data(), cmdline.data(), our_directory, &game_id.bits, title.data(), 0, 0, 0); + + return ownership_state::success; + } + + void do_cleanup() + { + this->client_engine_ = nullptr; + this->client_user_ = nullptr; + this->client_utils_ = nullptr; + + this->steam_pipe_ = nullptr; + this->global_user_ = nullptr; + + this->steam_client_module_ = utils::nt::library{ nullptr }; } void clean_up_on_error() @@ -186,4 +239,4 @@ namespace steam_proxy } } -//REGISTER_COMPONENT(steam_proxy::component) +REGISTER_COMPONENT(steam_proxy::component) diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index 284af27b..89e8af42 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -81,6 +81,7 @@ #include #include #include +#include #include #include