Subclassing (using MFC) a wndow under explorer process
-
Hi, Isn't it possible to subclass a window in the explorer process, using CWnd::SubclassWindow() ? My intention is to skin the systray clock. What I did: 1. Created a MFC dll. 2. Injected it to the explorer process using "CreateRemoteThread - LoadLibrary" technique. 3. Took the window handle of systray clock in the dll's InitInstance. 4. Replaced the window proc using SetWindowLong. These were successful, and in the replaced proc, I could do the custom draw by processing WM_PAINT. The problem: I derived a class from CWnd, say CMyClock. And subclassed the systray clock window with CMyClock object (member) instead of proc replacement. Now the explorer crashes. I tried to debug the explorer process. I found that subclassing is fine, and InitInstance completed successfully. After a very little time it crashed and the call stack was as follows...
ntdll.dll!7c901230() > msvcr71d.dll!_CrtDbgBreak() Line 93 C msvcr71d.dll!_CrtDbgReport(int nRptType=2, const char * szFile=0x01b44c68, int nLine=384, const char * szModule=0x00000000, const char * szFormat=0x00000000, ...) Line 427 C mfc71d.dll!AfxAssertFailedLine(const char * lpszFileName=0x01b44c68, int nLine=384) Line 28 + 0x14 C++ mfc71d.dll!AfxWndProc(HWND__ * hWnd=0x000f01c8, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0) Line 384 + 0x15 C++ MyClockDll.dll!AfxWndProcDllStatic(HWND__ * hWnd=0x000f01c8, unsigned int nMsg=15, unsigned int wParam=0, long lParam=0) Line 53 + 0x15 C++ user32.dll!7e418734() user32.dll!7e418816() user32.dll!7e41b4c0() user32.dll!7e41b50c() ntdll.dll!7c90eae3() user32.dll!7e4194d2() user32.dll!7e41b530() user32.dll!7e42d950() user32.dll!7e418a10() user32.dll!7e42dbbf() user32.dll!7e42593f() user32.dll!7e43a91e()
What could be wrong? Any suggestions or ideas? Thanks in advance.
- NS - [ODBaseBtn]