diff --git a/dom/plugins/ipc/FunctionHook.cpp b/dom/plugins/ipc/FunctionHook.cpp index 25479eb4723c..1ea963ea558c 100644 --- a/dom/plugins/ipc/FunctionHook.cpp +++ b/dom/plugins/ipc/FunctionHook.cpp @@ -296,16 +296,23 @@ 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", - reinterpret_cast(CreateFileWHookFn), - (void**) &sCreateFileWStub); - k32Intercept.AddHook("CreateFileA", - reinterpret_cast(CreateFileAHookFn), - (void**) &sCreateFileAStub); + sKernel32Intercept.AddHook("CreateFileW", + reinterpret_cast(CreateFileWHookFn), + (void**) &sCreateFileWStub); + sKernel32Intercept.AddHook("CreateFileA", + reinterpret_cast(CreateFileAHookFn), + (void**) &sCreateFileAStub); } #endif // defined(XP_WIN)