mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Bug 1180684 - Part 2. Hook GetKeyState on plugin process. r=aklotz
MozReview-Commit-ID: 3cCWMYYaTkn --HG-- extra : rebase_source : 5350555661244ba0e3afe86bde12988270f9f7cf
This commit is contained in:
parent
893f6698da
commit
0d03e6a9b7
@ -157,6 +157,8 @@ parent:
|
||||
|
||||
async ReturnSitesWithData(nsCString[] aSites, uint64_t aCallbackId);
|
||||
|
||||
intr GetKeyState(int32_t aVirtKey)
|
||||
returns (int16_t aState);
|
||||
};
|
||||
|
||||
} // namespace plugins
|
||||
|
@ -90,6 +90,9 @@ static WindowsDllInterceptor sUser32Intercept;
|
||||
typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi);
|
||||
static GetWindowInfoPtr sGetWindowInfoPtrStub = nullptr;
|
||||
static HWND sBrowserHwnd = nullptr;
|
||||
// sandbox process doesn't get current key states. So we need get it on chrome.
|
||||
typedef SHORT (WINAPI *GetKeyStatePtr)(int);
|
||||
static GetKeyStatePtr sGetKeyStatePtrStub = nullptr;
|
||||
#endif
|
||||
|
||||
/* static */
|
||||
@ -2066,6 +2069,20 @@ PMCGetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi)
|
||||
pwi->rcWindow = pwi->rcClient;
|
||||
return result;
|
||||
}
|
||||
|
||||
// static
|
||||
SHORT WINAPI
|
||||
PMCGetKeyState(int aVirtKey)
|
||||
{
|
||||
PluginModuleChild* chromeInstance = PluginModuleChild::GetChrome();
|
||||
if (chromeInstance) {
|
||||
int16_t ret = 0;
|
||||
if (chromeInstance->CallGetKeyState(aVirtKey, &ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return sGetKeyStatePtrStub(aVirtKey);
|
||||
}
|
||||
#endif
|
||||
|
||||
PPluginInstanceChild*
|
||||
@ -2086,12 +2103,18 @@ PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
|
||||
mQuirks = GetChrome()->mQuirks;
|
||||
|
||||
#ifdef XP_WIN
|
||||
sUser32Intercept.Init("user32.dll");
|
||||
if ((mQuirks & QUIRK_FLASH_HOOK_GETWINDOWINFO) &&
|
||||
!sGetWindowInfoPtrStub) {
|
||||
sUser32Intercept.Init("user32.dll");
|
||||
sUser32Intercept.AddHook("GetWindowInfo", reinterpret_cast<intptr_t>(PMCGetWindowInfoHook),
|
||||
(void**) &sGetWindowInfoPtrStub);
|
||||
}
|
||||
|
||||
if ((mQuirks & QUIRK_FLASH_HOOK_GETKEYSTATE) &&
|
||||
!sGetKeyStatePtrStub) {
|
||||
sUser32Intercept.AddHook("GetKeyState", reinterpret_cast<intptr_t>(PMCGetKeyState),
|
||||
(void**) &sGetKeyStatePtrStub);
|
||||
}
|
||||
#endif
|
||||
|
||||
return new PluginInstanceChild(&mFunctions, aMimeType, aMode, aNames,
|
||||
|
@ -3365,4 +3365,20 @@ PluginModuleChromeParent::RecvProfile(const nsCString& aProfile)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleParent::AnswerGetKeyState(const int32_t& aVirtKey, int16_t* aRet)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
PluginModuleChromeParent::AnswerGetKeyState(const int32_t& aVirtKey,
|
||||
int16_t* aRet)
|
||||
{
|
||||
#if defined(XP_WIN)
|
||||
*aRet = ::GetKeyState(aVirtKey);
|
||||
return true;
|
||||
#else
|
||||
return PluginModuleParent::AnswerGetKeyState(aVirtKey, aRet);
|
||||
#endif
|
||||
}
|
||||
|
@ -208,6 +208,8 @@ protected:
|
||||
|
||||
virtual bool RecvProfile(const nsCString& aProfile) override { return true; }
|
||||
|
||||
virtual bool AnswerGetKeyState(const int32_t& aVirtKey, int16_t* aRet) override;
|
||||
|
||||
virtual bool RecvReturnClearSiteData(const NPError& aRv,
|
||||
const uint64_t& aCallbackId) override;
|
||||
|
||||
@ -498,6 +500,9 @@ class PluginModuleChromeParent
|
||||
virtual bool
|
||||
RecvProfile(const nsCString& aProfile) override;
|
||||
|
||||
virtual bool
|
||||
AnswerGetKeyState(const int32_t& aVirtKey, int16_t* aRet) override;
|
||||
|
||||
private:
|
||||
virtual void
|
||||
EnteredCxxStack() override;
|
||||
|
@ -35,6 +35,9 @@ int GetQuirksFromMimeTypeAndFilename(const nsCString& aMimeType,
|
||||
quirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
|
||||
quirks |= QUIRK_FLASH_FIXUP_MOUSE_CAPTURE;
|
||||
quirks |= QUIRK_WINLESS_HOOK_IME;
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
quirks |= QUIRK_FLASH_HOOK_GETKEYSTATE;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,8 @@ enum PluginQuirks {
|
||||
QUIRK_UNITY_FIXUP_MOUSE_CAPTURE = 1 << 11,
|
||||
// Win: Hook IMM32 API to handle IME event on windowless plugin
|
||||
QUIRK_WINLESS_HOOK_IME = 1 << 12,
|
||||
// Win: Hook GetKeyState to get keyboard state on sandbox process
|
||||
QUIRK_FLASH_HOOK_GETKEYSTATE = 1 << 13,
|
||||
};
|
||||
|
||||
int GetQuirksFromMimeTypeAndFilename(const nsCString& aMimeType,
|
||||
|
Loading…
Reference in New Issue
Block a user