[ros-kernel] Suggested implementation ideas for the various WndProc, CallWndProc etc fixes

Jonathan Wilson jonwil at tpgi.com.au
Mon Nov 10 17:51:31 CET 2003

One problem with this is that we need to free these structures at some point.
 From further analysis (and from reading MSDN), the best time to delete 
these structures from their storage in win32k is when the app that called 
the function that created the structure, i.e. SetWindowLong, SetClassLong 
or RegisterClassEx terminates, since this is when the handle would become 
invalid due to the WNDPROC disappearing from memory when the app terminates 
and the code is unloaded from memory (because a Window Procedure handle).

Given that the pointer passed to SetClassLong, SetWindowLong and 
RegisterClassEx and so on is a pointer thats relative to the local address 
space of the app, when the app disappears, the code will disappear and the 
pointer we store in the structure is now pointing to god knows what.
MSDN explicitly says that you can only subclass a window if you are the 
owner of that window and that you can only superclass a window class if it 
is a system class or if it is a class you registered.

So, we need to store the "process ID" (whatever ROS/windows has that passes 
for one) in the structure. And we need to implement clean-up code when the 
module is unloaded and/or the app terminates to remove all the "owned by 
this process" structures. Of course, should the process terminate wierdly 
and not call the usual cleanups, it will leak. However, my experience shows 
that even a dead simple program will leak memory on real windows if 
teminated unexpectedly so we should be fine here. (unless someone wants to 
suggest a work-around)

Lets get these implementation details (like figuring out how to store the 
data and when to delete the memory we are storing the data in) worked out 
ASAP so that someone (probobly me unless someone else gets to it first) can 
get this thing coded.

More information about the Ros-kernel mailing list