SetWindowLong9x V0.0

This DLL is a WH_GETMESSAGE hook that reacts to a registered message "WM_SETWINDOWLONG9X" being posted.
It will change the message to WM_NULL and do a SetWindowLong to the window that received it.

The reason why I programmed this is because this is written about SetWindowLong in MSDN Oct99:
"Windows 95/98: The SetWindowLong function may fail if the window specified by the hWnd parameter does not belong to the same process as the calling thread."
Yeah, for me it was like all the time. 100% failure rate.

With this you can change anything except GWL_WNDPROC:-16 (just like in WinNT) because that WOULD BE VERY BAD AND WILL CRASH THE PROGRAM.
Hence it's checked for and will be ignored.
Also don't attempt to change DWL_DLGPROC:4 on dialog boxes. (this is NOT checked)


Basic usage:
Call SWL_HookThread with the thread ID returned by GetWindowThreadProcessId(TargetHWND,NULL).
Then you can just PostMessage(TargetHWND,msg,nIndex,dwNewLong) with the msg parameter being set by RegisterWindowMessage("WM_SETWINDOWLONG9X"). 

It's up to you to use GetWindowLong() before overwriting the value.
Also DO NOT USE SendMessage(), it WILL NOT work that way!!!
YOU MUST call SWL_UnhookThread() before hooking a new thread.
Calling SWL_About() beings up the about MessageBox, this shows you that the DLL loaded correctly. 


Suggestions for extensions:
It might be inefficient to hook and unhook due to potential overhead on loading and unloading the DLL into the target process space.
If you need to hook multiple threads (or processes) at once then you NEED to change the source code of the DLL.
You could copy paste more variants of MsgHook;SWL_UnhookThread;SWL_MsgProc;SWL_HookThread and add numbers or letters to the names.
An alternative way would be to change "HHOOK MsgHook" into a array like "HHOOK MsgHook[N]" and add a another equally sized array next to it like "DWORD ThreadIDs[N]".
That way it's possible to reuse the code for multiple threads, just store the ThreadID into the array after a sucessful SetWindowsHookEx() and clear it after UnhookWindowsHookEx().
Then you could use GetCurrentThreadId() in SWL_MsgProc to scan through ThreadIDs fetch the correct MsgHook value from array for CallNextHookEx().

I had no need to do that, so I didn't.

All I wanted was a proper full screen mode in the DVD Player application for the Toshiba Tecra 8000. 
(1998 Pentium-II Laptop with hardware MPEG2 decoder that has it's own CVBS and Y/C outputs)


T. Sosnow. <t-sosnow@posteo.com>
Visit QWERTZ-tek at http://qwertz.w10.site/ for my other stuff
April 23, 2026