2016-11-18 00:40:14 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 Peter Repukat - FlatspotSoftware
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
2016-11-19 01:24:49 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2016-11-18 00:40:14 +00:00
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
2016-11-18 00:22:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <dwmapi.h>
|
|
|
|
|
|
|
|
#include <SFML\System.hpp>
|
|
|
|
#include <SFML\Graphics.hpp>
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <thread>
|
|
|
|
|
2017-02-12 21:40:18 +00:00
|
|
|
#include <QApplication>
|
2016-11-18 00:22:07 +00:00
|
|
|
#include <QTimer>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QBuffer>
|
|
|
|
#include <QDatastream>
|
|
|
|
#include <QSharedmemory>
|
|
|
|
#include <QSettings>
|
2016-11-26 21:57:32 +00:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QDir>
|
2017-02-12 21:40:18 +00:00
|
|
|
#include <psapi.h>
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2016-11-19 01:24:49 +00:00
|
|
|
#include "VirtualControllerThread.h"
|
2017-02-15 19:13:41 +00:00
|
|
|
#include <atomic>
|
2016-11-19 01:24:49 +00:00
|
|
|
|
2017-01-25 16:54:08 +00:00
|
|
|
class SteamTargetRenderer : public QApplication
|
2016-11-18 00:22:07 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-01-25 16:54:08 +00:00
|
|
|
SteamTargetRenderer(int& argc, char** argv);
|
2016-11-18 00:22:07 +00:00
|
|
|
~SteamTargetRenderer();
|
|
|
|
|
|
|
|
void run();
|
|
|
|
|
2017-01-25 16:54:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
private:
|
2017-01-25 16:54:08 +00:00
|
|
|
void stop();
|
2017-01-25 23:01:26 +00:00
|
|
|
void getSteamOverlay();
|
|
|
|
void RunSfWindowLoop();
|
|
|
|
void makeSfWindowTransparent(sf::RenderWindow& window);
|
|
|
|
void drawDebugEdges();
|
|
|
|
void hookBindings();
|
|
|
|
|
|
|
|
void loadLogo();
|
2017-01-25 16:54:08 +00:00
|
|
|
|
2017-02-12 21:40:18 +00:00
|
|
|
std::atomic<bool> bRunLoop = true;
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2017-02-15 03:04:27 +00:00
|
|
|
bool bUseDesktopConfig = false;
|
2016-11-19 03:41:04 +00:00
|
|
|
bool bDrawDebugEdges = false;
|
2016-11-18 00:22:07 +00:00
|
|
|
bool bDrawOverlay = true;
|
|
|
|
bool bVsync = false;
|
2017-01-25 16:13:48 +00:00
|
|
|
int iRefreshRate = 30;
|
2016-11-18 00:22:07 +00:00
|
|
|
sf::CircleShape sfCshape;
|
|
|
|
sf::RenderWindow sfWindow;
|
|
|
|
|
|
|
|
std::thread renderThread;
|
|
|
|
|
|
|
|
HWND consoleHwnd;
|
|
|
|
|
2017-02-12 21:40:18 +00:00
|
|
|
HMODULE hmodGameOverlayRenderer = nullptr;
|
2016-11-20 08:19:58 +00:00
|
|
|
#ifdef _AMD64_
|
2017-02-12 21:40:18 +00:00
|
|
|
WCHAR* overlayModuleName = L"GameOverlayRenderer64.dll";
|
2016-11-20 08:19:58 +00:00
|
|
|
#else
|
2017-02-12 21:40:18 +00:00
|
|
|
WCHAR* overlayModuleName = L"GameOverlayRenderer.dll";
|
2016-11-20 08:19:58 +00:00
|
|
|
#endif
|
2017-02-12 21:40:18 +00:00
|
|
|
static std::atomic<bool> overlayOpen;
|
|
|
|
static HHOOK hook;
|
|
|
|
static LRESULT WINAPI HookCallback(int nCode, WPARAM wParam, LPARAM lParam);
|
|
|
|
|
2017-02-05 00:39:47 +00:00
|
|
|
HWND hwForeGroundWindow = nullptr;
|
2016-11-18 00:22:07 +00:00
|
|
|
bool bNeedFocusSwitch = false;
|
|
|
|
|
2016-11-19 01:24:49 +00:00
|
|
|
VirtualControllerThread controllerThread;
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2016-11-19 01:24:49 +00:00
|
|
|
bool bEnableControllers = true;
|
2016-11-18 00:22:07 +00:00
|
|
|
|
2017-02-15 19:13:41 +00:00
|
|
|
static std::atomic<bool> bHookSteam;
|
2016-11-26 21:57:32 +00:00
|
|
|
|
2016-11-19 05:30:48 +00:00
|
|
|
QTimer updateTimer;
|
|
|
|
|
2017-01-25 23:01:26 +00:00
|
|
|
std::unique_ptr<sf::Texture> spriteTexture;
|
|
|
|
sf::Sprite backgroundSprite;
|
2016-11-26 21:57:32 +00:00
|
|
|
|
2017-02-15 19:13:41 +00:00
|
|
|
static BOOL WINAPI ConsoleCtrlCallback(_In_ DWORD dwCtrlType);
|
|
|
|
|
2016-11-26 21:57:32 +00:00
|
|
|
const QString LaunchGame = "LaunchGame";
|
|
|
|
const QString LaunchedProcessFinished = "LaunchedProcessFinished";
|
|
|
|
const QString IsSteamHooked = "IsSteamHooked";
|
|
|
|
const QStringList defaultSharedMemData = QStringList()
|
|
|
|
<< LaunchGame
|
|
|
|
<< ""
|
|
|
|
<< ""
|
|
|
|
<< LaunchedProcessFinished
|
|
|
|
<< "0"
|
|
|
|
<< IsSteamHooked
|
|
|
|
<< "-1";
|
|
|
|
|
2016-11-18 00:22:07 +00:00
|
|
|
private slots:
|
|
|
|
void launchApp();
|
2016-11-19 05:30:48 +00:00
|
|
|
void checkSharedMem();
|
2016-11-18 00:22:07 +00:00
|
|
|
};
|
|
|
|
|