Windows 1.x - overlapping windows

Discuss MS-DOS, Windows 1, 2 and 3.
Post Reply
Lucas Brooks
Posts: 773
Joined: Sat Oct 20, 2018 11:37 am
Contact:

Windows 1.x - overlapping windows

Post by Lucas Brooks »

Since Windows 1.x did not have overlapping window support, most programs were forced to use "tiled" windows. In order to make an overlapping window, the developer must use WS_POPUP instead of WS_TILED. Of course WS_POPUP creates a popup window that will be on top of all other windows and most applications use it for error messages or dialog boxes to get immediate user attention.

So, what if we patch some tiled windows to become popup windows? You'll get something similar to this (Beta Release):
Image

WinMain() is the function to patch and generally you will find a call to CreateWindow(). Patching CreateWindow() will not work on DR5 because DR5 uses CreatePopUp() for creating popup windows and most of the times there won't be enough space for a patch. Since we want to keep the patch simple, we are going to patch about 6 bytes and below is an illustration of a typical call to CreateWindow() before (left) and after (right) the patch:

Image

You must ensure that you have located the correct call to CreateWindow() because some programs creates other child and/or popup windows. Once you have located the correct call, go to a hex editor and find that call to CreateWindow(). You should find something similar to BA CC 00 (mov dx, 0CCh) roughly 18 bytes before the call. If the application uses scroll bars or different window styles, then you will find something different. It should be followed by 52 50 50 50 50 in most cases and now select 11 bytes starting from BA CC 00. You should have something like BA CC 00 52 50 50 50 50 B8 64 00 selected. Window style and window height may be different. In order to patch the executable, you should replace what you have selected with BA CC 80 52 50 50 B8 64 00 50 50. You might need to change the hard coded window height to something else because the default 100px (or 200px for graphics demo apps) is too small for most applications.

It is a good idea to leave MS-DOS Executive un-patched because you will have troubles starting tiled windows if MS-DOS Executive is a popup (it will force MS-DOS Executive to minimize and since popups are not minimize-able, you will never be able to bring MS-DOS Executive back up again and the tiled window will take over the screen area that belonged to MS-DOS Executive and you will not be able to move or minimize it). If you would like to get rid of the taskbar and you are going to patch every executable, then patching MS-DOS Executive won't be a problem anymore and it will look something like this (Alpha Release):

Image

Thanks to xelloss for suggestions about using WS_CAPTION + WS_SIZEBOX + WS_SYSMENU + WS_POPUP as the window style. Please keep in mind that popups are not minimize-able or maximize-able.

computebrute
User avatar
Donator
Posts: 680
Joined: Tue Dec 03, 2013 12:00 am
Location: us

Re: Windows 1.x - overlapping windows

Post by computebrute »

How did you figure this out? Experimentation?
Image
Image

Lollipop
Posts: 3
Joined: Sun Aug 30, 2020 2:53 pm

Re: Windows 1.x - overlapping windows

Post by Lollipop »

If I recall correctly, the creator of ToastyTech has said this but in less detail.

JimOlive
User avatar
Posts: 516
Joined: Fri Jan 31, 2014 12:07 am
Location: Winnipeg, Manitoba, Canada, North America, Earth, Solar System, Milky Way, Universe, Existence
Contact:

Re: Windows 1.x - overlapping windows

Post by JimOlive »

Probably custom code.

Lucas Brooks
Posts: 773
Joined: Sat Oct 20, 2018 11:37 am
Contact:

Re: Windows 1.x - overlapping windows

Post by Lucas Brooks »

computebrute wrote:
Sun Aug 30, 2020 3:51 pm
How did you figure this out? Experimentation?
Yeah, failed a few times before I got it right. I originally thought modifying the window style alone is enough but it turned out that some parameters also needs to be modified.
Lollipop wrote:
Sun Aug 30, 2020 5:48 pm
If I recall correctly, the creator of ToastyTech has said this but in less detail.
Mind telling me where he said this? I think he did it with his WineMine port but he modified the C source code. yksoft1 made a port of Minesweeper from the leaked Windows NT 4 source code and added a check to use popup if executed under Windows 1.x, it works like this:

Code: Select all

      {  
      DWORD style = WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU;  
      if (LOBYTE(GetVersion())>1)   
           style = style | WS_OVERLAPPED;  
      else  
           style = style | WS_POPUP;  
      hwndMain = CreateWindow(szClass, szWindowTitle,  
         /* WS_OVERLAPPED | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU*/style,  
           Preferences.xWindow-dxpBorder, Preferences.yWindow-dypAdjust,  
           dxWindow+dxpBorder, dyWindow +dypAdjust,  
           NULL, NULL, hInst, NULL);  
      } 
I don't think anyone attempted to patch compiled apps to use WS_POPUP before (otherwise I have wasted my time doing something already being done). Implementing a check to use WS_OVERLAPPED if Windows version is above 1 is pretty much impossible without source code.
JimOlive wrote:
Sun Aug 30, 2020 9:40 pm
Probably custom code.
What custom code? Patching a few bytes shouldn't really be called custom code. There might be a way to patch USER.EXE to make all WS_TILED windows WS_POPUP but not sure how to deal with different CreateWindow() parameters. Maybe we can write custom code to do that if Microsoft release the Windows 1.x source code one day.

Lollipop
Posts: 3
Joined: Sun Aug 30, 2020 2:53 pm

Re: Windows 1.x - overlapping windows

Post by Lollipop »

- ComputerHunter: I can remember that he said stuff about a "Fish" program and stuff. This screenshot is about as close as I can get:
WineMine uses a popup, while Fish uses a popup too.
http://toastytech.com/guis/win1x2x800600.png

Post Reply