CE 6.0: Why Remote Spy doesn't (cross process window subclassing).

Spy++ on the desktop, and Remote Spy on the Windows CE tools is a cool utility that gives you the ability to look at the Windows Messages being delivered to processes running on a target device, that is until CE 6.0 shipped. With CE 6.0 the Remote Spy tool you can view window properties but cannot view windows messages - but why doesn't this work ?

Let's examine the CE 5.0 memory model, in CE 5.0 the operating system runs in a 4GB virtual address space - 2GB for kernel space and 2GB for user space - the 2GB user space is divided into a number of 32MB slots which is where the user space processes run (and is why CE 1.0 through CE 5.0 were limited to a maximum of 32 processes running at one time) - for an application to subclass a window running in another process you would simply call something like...

LONG lOldWndProc=GetWindowLong(hWnd,GWL_WNDPROC);

Note that the return value from the GetWindowLong call when passing in the GWL_WNDPROC parameter is the address of the window procedure (which is probably running in another process) - in CE 5.0 land this was fine because all processes were running in the same 2GB user space, so a pointer from one process was still valid in another process.

With the release of CE 6.0 all processes are running their own unique 2GB virtual address space, this means that a pointer within one process is only valid within that process address space (see where this is going?). So calling GetWindowLong with GWL_WNDPROC on a window owned by another process *could* return you a pointer to the window procedure, but the pointer isn't valid within your process address space and therefore you cannot subclass the window - which is why Remote Spy doesn't show you Windows Messages on CE 6.0.

- Mike