diff --git a/GlosSITarget/AppLauncher.cpp b/GlosSITarget/AppLauncher.cpp index d62db50..02dfbae 100644 --- a/GlosSITarget/AppLauncher.cpp +++ b/GlosSITarget/AppLauncher.cpp @@ -18,9 +18,14 @@ limitations under the License. #include #ifdef _WIN32 +#define COBJMACROS +#include +#include +#include #include #include #include +#include #endif #include "Settings.h" @@ -183,6 +188,17 @@ void AppLauncher::launchUWPApp(const LPCWSTR package_full_name, const std::wstri HRESULT result = CoInitialize(nullptr); if (SUCCEEDED(result)) { + // DllInjector::TakeDebugPrivilege(); + HRESULT hResult = S_OK; + ATL::CComQIPtr debugSettings; + hResult = debugSettings.CoCreateInstance(CLSID_PackageDebugSettings, NULL, CLSCTX_ALL); + debugSettings->EnableDebugging( + L"Microsoft.MinecraftUWP_1.18.203.0_x64__8wekyb3d8bbwe", + L"D:\\Alia5\\Documents\\Visual_Studio_Projects\\GlosSI\\x64\\Debug\\GlosSITarget.exe", + NULL + ); + + CComPtr sp_app_activation_manager; // Initialize IApplicationActivationManager result = CoCreateInstance( @@ -209,6 +225,7 @@ void AppLauncher::launchUWPApp(const LPCWSTR package_full_name, const std::wstri } else { spdlog::error("CoCreateInstance failed: Code {}", result); } + debugSettings->DisableDebugging(L"Microsoft.MinecraftUWP_1.18.203.0_x64__8wekyb3d8bbwe"); CoUninitialize(); } else { diff --git a/GlosSITarget/main.cpp b/GlosSITarget/main.cpp index a5a28f7..5afb599 100644 --- a/GlosSITarget/main.cpp +++ b/GlosSITarget/main.cpp @@ -16,12 +16,16 @@ limitations under the License. #ifdef _WIN32 #define NOMINMAX #include +#include +#undef WIN32_NO_STATUS +#include #endif #include #include #include +#include "DllInjector.h" #include "SteamTarget.h" #include "OverlayLogSink.h" @@ -95,7 +99,11 @@ int main(int argc, char* argv[]) path /= "GlosSI"; if (!std::filesystem::exists(path)) std::filesystem::create_directories(path); - path /= "glossitarget.log"; + if (__argc > 1 && std::string(__argv[1]) == "-p") { + path /= "glossitarget_UWP_inject.log"; + } else { + path /= "glossitarget.log"; + } const auto file_sink = std::make_shared(path.string(), true); #else auto file_sink = std::make_shared("/tmp/glossitarget.log", true); @@ -120,8 +128,63 @@ int main(int argc, char* argv[]) #ifdef _WIN32 std::string argsv = ""; if (__argc > 1) { - for (int i = 1; i < __argc; i++) - argsv += i == 1 ? __argv[i] : std::string(" ") + __argv[i]; + if (std::string(__argv[1]) == "-p" && __argc >= 3) { + DWORD pid = std::stoi(std::string(__argv[2])); + spdlog::debug("DLLInject requested with pid: {}", pid); + if (DllInjector::TakeDebugPrivilege()) { + // No need to eject, as the dll is self-ejecting. + if (DllInjector::Inject( + pid, + L"Test.dll")) { + spdlog::info("Successfully injected Test.dll..."); + + // -- + + typedef LONG (NTAPI *fnNtResumeProcess)(IN HANDLE processHandle); + + auto resume_proc = reinterpret_cast(GetProcAddress(GetModuleHandle(L"ntdll.dll"), "NtResumeProcess")); + if (!resume_proc) { + spdlog::error("Failed to get address of NtResumeProcess"); + } else { + spdlog::debug("Got adress of NTResumeProc..."); + } + + HANDLE process = NULL; + + process = OpenProcess( + PROCESS_QUERY_INFORMATION | PROCESS_SUSPEND_RESUME | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_VM_WRITE, + false, + pid); + + if (!process) { + spdlog::error("Failed to open process"); + spdlog::shutdown(); + return 1; + } + + spdlog::debug("Resuming proc..."); + if (!NT_SUCCESS(resume_proc(process))) + { + spdlog::error("Failed to resume proc!"); + } + CloseHandle(process); + + + // -- + + } else { + spdlog::error("Couldn't inject..."); + } + } else { + spdlog::error("Couldn't take debug privilege!"); + } + + spdlog::shutdown(); + return 0; + } else { + for (int i = 1; i < __argc; i++) + argsv += i == 1 ? __argv[i] : std::string(" ") + __argv[i]; + } } Settings::Parse(argsv); SteamTarget target(__argc, __argv);