Log in

View Full Version : Why I have this access between processes?


Hero
March 10th, 2005, 04:53
Hi all
I get some strange(perhaps for me) result when I using GetWindowLong , SetWindowLong.
See this code:

Quote:
OldWindowProc = (WNDPROC)GetWindowLong(hwnd,GWL_WNDPROC);
SetWindowLong(hwnd,GWL_WNDPROC,(long)(CProcessIdDlg::WindowProc));

My problem is that shown handle is not in current process of application,and its
process is compeletly separated from current application process.
Then why I can set that handle's window's WinProc in that process to a WinProc in my Application?????
I think the processes' memory are isolated from each other and they can't access
each one in normal why,Then why this work?
I using Windows CE 4.2 for my test.


sincerely yours

blabberer
March 10th, 2005, 05:43
windows ce it probably allows you to set the GWL_WNDPROC

msdn says that restriction applies only to nt/2000/xp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windowclasses/
indowclassreference/windowclassfunctions/setwindowlong.asp

Quote:

GWL_WNDPROC
Sets a new address for the window procedure.

Windows NT/2000/XP: You cannot change this attribute if the window does not belong to the same process as the calling thread.



btw if SendMessage,PostMessage can work then all these functions must also work
all it needs is a handle and if you provide a handle then the underlying code will just validate the hWnd and work if it was validated i think