mirror of
https://github.com/Thracky/GlosSI.git
synced 2024-11-03 09:40:18 +00:00
SteamTarget: add file logs
This commit is contained in:
parent
2230669248
commit
500086cf68
@ -21,6 +21,9 @@ limitations under the License.
|
||||
#include "../common/Injector.h"
|
||||
#include "../common/process_alive.h"
|
||||
|
||||
#define LOGURU_IMPLEMENTATION 1
|
||||
#include "../common/loguru.hpp"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
@ -35,12 +38,15 @@ limitations under the License.
|
||||
#include <Shobjidl.h>
|
||||
|
||||
|
||||
|
||||
SteamTarget::SteamTarget(int& argc, char** argv) : QApplication(argc, argv)
|
||||
{
|
||||
loguru::init(argc, argv);
|
||||
}
|
||||
|
||||
void SteamTarget::init()
|
||||
{
|
||||
loguru::add_file("last.log", loguru::Truncate, loguru::Verbosity_INFO);
|
||||
connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
|
||||
SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(ConsoleCtrlCallback), true);
|
||||
ShowWindow(GetConsoleWindow(), SW_HIDE);
|
||||
@ -89,6 +95,7 @@ void SteamTarget::readIni()
|
||||
{
|
||||
if (arguments().size() == 1)
|
||||
{
|
||||
LOG_F(WARNING, "Target configuration file must be specified! Using default Values!");
|
||||
QMessageBox::warning(nullptr, "GloSC", "Target configuration file must be specified! Using default Values!");
|
||||
}
|
||||
else {
|
||||
@ -180,14 +187,21 @@ void SteamTarget::initOverlayEvents()
|
||||
|
||||
hook_commons::PlaceJMP(reinterpret_cast<BYTE*>(addressClosed),
|
||||
reinterpret_cast<DWORD>(overlay_hook::overlay_closed_hookFN), std::string(overlay_closed_func_mask).length());
|
||||
} else {
|
||||
LOG_F(WARNING, "Failed to find overlayClosed signature!");
|
||||
}
|
||||
} else {
|
||||
LOG_F(WARNING, "Failed to find overlayOpened signature!");
|
||||
}
|
||||
}
|
||||
|
||||
void SteamTarget::launchWatchdog() const
|
||||
{
|
||||
const QString watchDogPath = QDir::toNativeSeparators(applicationDirPath()) + "\\GloSC_Watchdog.exe";
|
||||
QProcess::startDetached("explorer.exe", QStringList() << watchDogPath);
|
||||
if(QProcess::startDetached("explorer.exe", QStringList() << watchDogPath))
|
||||
LOG_F(INFO, "Launched Watchdog");
|
||||
else
|
||||
LOG_F(WARNING, "Failed to launch Watchdog!");
|
||||
}
|
||||
|
||||
void SteamTarget::launchApplication()
|
||||
|
@ -133,13 +133,11 @@ void TargetOverlay::overlayLoop()
|
||||
|
||||
void TargetOverlay::onOverlayOpened()
|
||||
{
|
||||
std::cout << "Overlay opened!\n";
|
||||
overlay_state_ = 1;
|
||||
}
|
||||
|
||||
void TargetOverlay::onOverlayClosed()
|
||||
{
|
||||
std::cout << "Overlay closed!\n";
|
||||
overlay_state_ = 2;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,9 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
#include "VirtualControllerThread.h"
|
||||
//
|
||||
|
||||
#include "../common/loguru.hpp"
|
||||
|
||||
|
||||
VirtualControllerThread::VirtualControllerThread(const int delay)
|
||||
{
|
||||
@ -22,7 +24,7 @@ VirtualControllerThread::VirtualControllerThread(const int delay)
|
||||
|
||||
if (!VIGEM_SUCCESS(vigem_connect(driver_)))
|
||||
{
|
||||
std::cout << "Error initializing ViGem!" << std::endl;
|
||||
LOG_F(ERROR, "initializing ViGem!");
|
||||
MessageBoxW(NULL, L"Error initializing ViGem!", L"GloSC-SteamTarget", MB_OK);
|
||||
b_should_run_ = false;
|
||||
}
|
||||
@ -146,7 +148,7 @@ void VirtualControllerThread::controllerLoop()
|
||||
}
|
||||
if (vigem_res == VIGEM_ERROR_NONE)
|
||||
{
|
||||
std::cout << "Plugged in controller " << vigem_target_get_index(vt_x360_[i]) << std::endl;
|
||||
LOG_F(INFO, "Plugged in controller %d", vigem_target_get_index(vt_x360_[i]));
|
||||
vigem_target_x360_register_notification(driver_, vt_x360_[i],
|
||||
reinterpret_cast<PVIGEM_X360_NOTIFICATION>(&VirtualControllerThread::
|
||||
controllerCallback));
|
||||
@ -160,7 +162,7 @@ void VirtualControllerThread::controllerLoop()
|
||||
{
|
||||
if (VIGEM_SUCCESS(vigem_target_remove(driver_, vt_x360_[i])))
|
||||
{
|
||||
std::cout << "Unplugged controller " << vigem_target_get_index(vt_x360_[i]) << std::endl;
|
||||
LOG_F(INFO, "Unplugged controller %d", vigem_target_get_index(vt_x360_[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ limitations under the License.
|
||||
#include <tlhelp32.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "../common/loguru.hpp"
|
||||
|
||||
|
||||
void Injector::TakeDebugPrivilege()
|
||||
{
|
||||
HANDLE hProcess = GetCurrentProcess(), hToken;
|
||||
@ -45,8 +48,11 @@ int Injector::Inject(DWORD pid, std::wstring &libPath)
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION | PROCESS_VM_WRITE, false, pid);
|
||||
|
||||
if (!hProcess)
|
||||
{
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
allocAddress = VirtualAllocEx(hProcess, NULL, pathSize, MEM_COMMIT, PAGE_READWRITE);
|
||||
|
||||
if (!allocAddress)
|
||||
@ -96,12 +102,14 @@ int Injector::Eject(DWORD pid, std::wstring &libPath)
|
||||
|
||||
|
||||
if (!findModule(pid, libPath, hLibMod))
|
||||
{
|
||||
return 2;
|
||||
|
||||
}
|
||||
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_CREATE_THREAD | PROCESS_VM_OPERATION, false, pid);
|
||||
if (!hProcess)
|
||||
{
|
||||
return 1;
|
||||
|
||||
}
|
||||
pfnThreadRtn = (PTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(L"Kernel32"), "FreeLibrary");
|
||||
|
||||
if (!pfnThreadRtn)
|
||||
@ -175,29 +183,29 @@ int Injector::hookSteam()
|
||||
|
||||
if (pid == NULL)
|
||||
{
|
||||
std::wcout << "Can't detect Steam.exe running" << std::endl;
|
||||
LOG_F(WARNING, "Can't detect Steam.exe running");
|
||||
return 0;
|
||||
}
|
||||
const int result = Injector::Inject(pid, libPath);
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
std::wcout << "Inject success!" << std::endl;
|
||||
LOG_F(INFO, "Inject success!");
|
||||
return 1;
|
||||
case 1:
|
||||
std::wcout << "Error: Couldn't open process" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't open process");
|
||||
break;
|
||||
case 2:
|
||||
std::wcout << "Error: Couldn't allocate memory" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't allocate memory");
|
||||
break;
|
||||
case 3:
|
||||
std::wcout << "Error: Couldn't write memory" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't write memory");
|
||||
break;
|
||||
case 4:
|
||||
std::wcout << "Error: Couldn't get pointer ro LoadLibraryW" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't get pointer ro LoadLibraryW");
|
||||
break;
|
||||
case 5:
|
||||
std::wcout << "Error: Couldn't start remote thread" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't start remote thread");
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
@ -232,7 +240,7 @@ int Injector::unhookSteam()
|
||||
|
||||
if (pid == NULL)
|
||||
{
|
||||
std::wcout << "Can't detect Steam.exe running" << std::endl;
|
||||
LOG_F(WARNING, "Can't detect Steam.exe running");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -240,19 +248,19 @@ int Injector::unhookSteam()
|
||||
switch (result)
|
||||
{
|
||||
case 0:
|
||||
std::wcout << "Eject success!" << std::endl;
|
||||
LOG_F(INFO, "Eject success!");
|
||||
return 1;
|
||||
case 1:
|
||||
std::wcout << "Error: Couldn't open process" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't open process");
|
||||
break;
|
||||
case 2:
|
||||
std::wcout << "Error: Couldn't find module in process" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't find module in process");
|
||||
break;
|
||||
case 3:
|
||||
std::wcout << "Error: Couldn't get pointer ro FreeLibrary" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't get pointer ro FreeLibrary");
|
||||
break;
|
||||
case 4:
|
||||
std::wcout << "Error: Couldn't start remote thread" << std::endl;
|
||||
LOG_F(ERROR, "Couldn't start remote thread");
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
|
2926
common/loguru.hpp
Normal file
2926
common/loguru.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user