2
0
mirror of https://github.com/Thracky/GlosSI.git synced 2024-11-03 09:40:18 +00:00

Revert "Use memory adress of overlay instead of winmessages"

This reverts commit e2438e1ff1.
This commit is contained in:
Peter Repukat 2017-12-30 17:36:26 +01:00
parent e2438e1ff1
commit 2fe7025fbb
2 changed files with 36 additions and 6 deletions

View File

@ -15,9 +15,11 @@ limitations under the License.
*/
#include "SteamTargetRenderer.h"
std::atomic<bool> SteamTargetRenderer::overlayOpen = false;
HHOOK SteamTargetRenderer::hook = nullptr;
std::atomic<bool> SteamTargetRenderer::bHookSteam = false;
SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication(argc, argv)
{
getSteamOverlay();
@ -86,9 +88,9 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication(
if (hmodGameOverlayRenderer != nullptr)
{
overlayOpen = reinterpret_cast<uint64_t*>(uint64_t(hmodGameOverlayRenderer) + 0x13A63C);
//Hook MessageQueue to detect if overlay gets opened / closed
//Steam Posts a Message with 0x14FA / 0x14F7 when the overlay gets opened / closed
hook = SetWindowsHookEx(WH_GETMESSAGE, HookCallback, nullptr, GetCurrentThreadId());
}
@ -108,6 +110,12 @@ SteamTargetRenderer::SteamTargetRenderer(int& argc, char** argv) : QApplication(
SteamTargetRenderer::~SteamTargetRenderer()
{
if (hmodGameOverlayRenderer != nullptr)
{
UnhookWindowsHookEx(hook);
}
renderThread.join();
if (controllerThread.isRunning())
controllerThread.stop();
@ -171,7 +179,7 @@ void SteamTargetRenderer::RunSfWindowLoop()
//Window focus trickery
if (hmodGameOverlayRenderer != nullptr)
{
if (*overlayOpen)
if (overlayOpen)
{
if (!bNeedFocusSwitch)
{
@ -348,6 +356,27 @@ void SteamTargetRenderer::moveMouseIntoOverlay()
}
//WinHook Callback to check if the overlay is opened/closed
LRESULT WINAPI SteamTargetRenderer::HookCallback(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode >= 0)
{
PMSG msg = reinterpret_cast<PMSG>(lParam);
std::cout << "DEBUG: " << "message: " << msg->message << std::endl;
if (msg->message == 0x14FA) //Posted when the overlay gets opened
{
overlayOpen = true;
std::cout << "Overlay Opened!\n";
}
else if (msg->message == 0x14F7 || msg->message == 0x14FD || msg->message == 512 || msg->message == 0x2a3)
{
overlayOpen = false;
std::cout << "Overlay closed!\n";
}
}
return CallNextHookEx(hook, nCode, wParam, lParam);
}
void SteamTargetRenderer::unhookBindings()
{
if (bHookSteam)

View File

@ -91,7 +91,8 @@ private:
#else
WCHAR* overlayModuleName = L"GameOverlayRenderer.dll";
#endif
uint64_t *overlayOpen;
static std::atomic<bool> overlayOpen;
static HHOOK hook;
HWND hwForeGroundWindow = nullptr;
bool bNeedFocusSwitch = false;