INT_PTR WINAPI Detour_DialogBoxParamW(
HINSTANCE hInstance, LPCWSTR lpTemplateName,
HWND hwndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
{
INT_PTR nRes = -1;
HMODULE hmod = IEProcess::GetProcessModule();
HRESULT hr = IEProcess::GetTabWindowExports(hmod)->WaitForTabWindow(
false, hwndParent, &hwndParent);
if (SUCCEEDED(hr))
{
HANDLE hModalDialogLock;
hr = IEProcess::GetTabWindowExports(hmod)->AcquireModalDialogLockAndParent(
hwndParent, &hwndParent, &hModalDialogLock);
if (SUCCEEDED(hr))
{
nRes = Real_DialogBoxParamW(hInstance, lpTemplateName,
hwndParent, lpDialogFunc, dwInitParam);
IEProcess::GetTabWindowExports(hmod)->ReleaseModalDialogLockAndParent(
hModalDialogLock);
}
}
return nRes;
}