Prevent hook helper from running when in UWP mode

This commit is contained in:
Paddy Xu
2017-07-11 23:43:16 +03:00
parent 031803a40e
commit d855e80bdc
5 changed files with 20 additions and 0 deletions

View File

@@ -34,6 +34,9 @@ static WCHAR filePathBuffer[MAX_PATH] = {'\0'};
void DialogHook::GetSelected(PWCHAR buffer)
{
if (HelperMethods::IsUWP())
return;
auto hwndfg = GetForegroundWindow();
DWORD pid = 0;
auto tid = GetWindowThreadProcessId(hwndfg, &pid);

View File

@@ -71,3 +71,14 @@ bool HelperMethods::IsCursorActivated(HWND hwnd)
GetGUIThreadInfo(tId, &gui);
return gui.flags || gui.hwndCaret;
}
bool HelperMethods::IsUWP()
{
auto pGCPFN = decltype(&GetCurrentPackageFullName)(GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetCurrentPackageFullName"));
if (!pGCPFN)
return false;
UINT32 pn = 0;
return pGCPFN(&pn, nullptr) == ERROR_INSUFFICIENT_BUFFER;
}

View File

@@ -22,4 +22,5 @@ public:
static void GetSelectedInternal(CComQIPtr<IWebBrowserApp> pWebBrowserApp, PWCHAR buffer);
static void ObtainFirstItem(CComPtr<IDataObject> dao, PWCHAR buffer);
static bool IsCursorActivated(HWND hwndfg);
static bool HelperMethods::IsUWP();
};

View File

@@ -17,6 +17,7 @@
#include "stdafx.h"
#include "WoW64HookHelper.h"
#include "HelperMethods.h"
#define HELPER_FILE L"\\QuickLook.WoW64HookHelper.exe"
#define RUN_ARG L"033A853A-E4B2-4552-9A91-E88789761C48"
@@ -37,6 +38,9 @@ bool WoW64HookHelper::Launch()
return true;
#endif
if (HelperMethods::IsUWP())
return true;
if (CheckStatus())
return true;

View File

@@ -32,3 +32,4 @@
#include<Shlobj.h>
#include<Shellapi.h>
#include<Psapi.h>
#include<AppModel.h>