SetEventWinHook crashes WPF application with Stack Overflow

2

I am running into a problem where my application is crashing a WPF application due to EventHooking. Below is simple code that I tried and was still able to recreate the crash. This is only when running against some sort of custom tree view that has a number of its nodes expanded.

{
...
_focusChangedHandler =  OnFocusChanged;
_focusChangedGCHandle = GCHandle.Alloc(_focusChangedHandler);
_focusChangedHookId = User32.SetWinEventHook(User32.EVENT_OBJECT_FOCUS,
    User32.EVENT_OBJECT_FOCUS, IntPtr.Zero, _focusChangedHandler,
    0,0,User32.WINEVENT_OUTOFCONTEXT);
...
}

private void OnFocusChanged(IntPtr hWinEventHook, uint eventType,
                            IntPtr hwnd,
                            int idObject, int idChild, uint dwEventThread,
                            uint dwmsEventTime)
{
}

I also had the customer test this with an explicit new User32.WinEventDelegate(OnFocusChanged) and without the GCHandle.Alloc. As well as a combination of all those scenarios. This did NOT solve the problem

Does anybody have any idea why this might be happening?

*We did have a problem with this WPF application and creating memory/performance issues around virtualization being cancelled by IAccessible calls, however we have since removed those calls.

EDIT PER REQUEST

The only information I have on the third party is from an event log:

Faulting application name: THIRDPARTY.exe, version: x.y.z, time stamp: 0x4fb0d031
Faulting module name: clr.dll, version: 4.0.30319.296, time stamp: 0x50484aa9
Exception code: 0xc00000fd
Fault offset: 0x00001ac6
Faulting process id: 0x6f50
Faulting application start time: 0x01cdf9a521428158
Faulting application path: C:\Program Files (x86)\THIRDPARTYEXEPATH
Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Report Id: d8e42ff6-6598-11e2-9614-441ea14b96e0

The Exception code is a stack overflow as far as my research tells me

c#
winapi
crash
stack-overflow
event-hooking
asked on Stack Overflow Feb 4, 2013 by Justin Pihony • edited Feb 4, 2013 by Justin Pihony

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0