Skip to content

Commit

Permalink
Prevent hook helper from running when in UWP mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xupefei committed Jul 11, 2017
1 parent 031803a commit d855e80
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions QuickLook.Native/QuickLook.Native32/DialogHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions QuickLook.Native/QuickLook.Native32/HelperMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions QuickLook.Native/QuickLook.Native32/HelperMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ class HelperMethods
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();
};
4 changes: 4 additions & 0 deletions QuickLook.Native/QuickLook.Native32/WoW64HookHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -37,6 +38,9 @@ bool WoW64HookHelper::Launch()
return true;
#endif

if (HelperMethods::IsUWP())
return true;

if (CheckStatus())
return true;

Expand Down
1 change: 1 addition & 0 deletions QuickLook.Native/QuickLook.Native32/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
#include<Shlobj.h>
#include<Shellapi.h>
#include<Psapi.h>
#include<AppModel.h>

0 comments on commit d855e80

Please sign in to comment.