Bug 1446499: Use static nsWindowsDllInterceptor in plugin's HookProtectedMode r=aklotz

HookProtectedMode requires its nsWindowsDllInterceptor to last as long as the functions need to be overridden.  This uses a static object instead of a local one.

--HG--
extra : rebase_source : 7ba3f2fc1e19f89936b7f7fa490554e9cf9b885c
This commit is contained in:
David Parks 2018-04-03 17:09:36 -07:00
Родитель 679c14a9c4
Коммит a9fd0592af
1 изменённых файлов: 14 добавлений и 7 удалений

Просмотреть файл

@ -296,14 +296,21 @@ CreateFileWHookFn(LPCWSTR aFname, DWORD aAccess, DWORD aShare,
void FunctionHook::HookProtectedMode()
{
// Make sure we only do this once.
static bool sRunOnce = false;
if (sRunOnce) {
return;
}
sRunOnce = true;
// Legacy code. Uses the nsWindowsDLLInterceptor directly instead of
// using the FunctionHook
sKernel32Intercept.Init("kernel32.dll");
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Plugin);
WindowsDllInterceptor k32Intercept("kernel32.dll");
k32Intercept.AddHook("CreateFileW",
sKernel32Intercept.AddHook("CreateFileW",
reinterpret_cast<intptr_t>(CreateFileWHookFn),
(void**) &sCreateFileWStub);
k32Intercept.AddHook("CreateFileA",
sKernel32Intercept.AddHook("CreateFileA",
reinterpret_cast<intptr_t>(CreateFileAHookFn),
(void**) &sCreateFileAStub);
}