jakethompson1 wrote on 2023-06-13, 23:25:
I don't think you could get what you want--the ability to run arbitrary PEs on Windows 3.1--without, essentially, recreating Windows 95.
For one thing, Win16 and Win32s executables all share a single address space, so only PEs with a relocation table can execute under Win32s. Any PEs missing one and it's game over, not even considering whether it makes unsupported API calls or not.
Recreating Windows 95? OP said "9x", and of course there are applications written for 98 SE which won't run on 95 RTM, so really where would one draw the line? How many APIs do you need to support to get to a Windows 95 baseline, and then how many more do you need for 98 SE? These are just rhetorical questions not directed at anyone in particular, although if anyone feels like answering them I would be interested (but not because I want to do the work to implement them - I'm just curious)!
If one wants a lightweight operating system capable of running arbitrary Windows 95 or 98 or 98 SE applications, I think "what parts can I strip out of 95/98/98 SE to make it more lightweight" is a practical question you might ask - and that's a question which has already been answered quite a few times over the years, I think - whereas "how do I reimplement 95/98/98 SE on top of some other operating system" is a lot harder (unless you start with wine) and "how do I do that but on top of a closed source, 16-bit operating system" is probably approaching the most difficult way you could do it as far as I know. Of course that might be a fun project for someone who knows how to do it, like trying to run DOOM on some obscure hardware, but probably much bigger and less cool.
Grzyb wrote on 2023-06-14, 20:59:
But what about Win32s apps?
Are they required to behave like Win16 apps?
Or is there preemptive multitasking for them in WIndows 3.1x ?
Looks like Jo22 was right - from the Win32s Programmer's Reference:
Win32 applications operate under the same constraints as Win16 applications. To keep the user interface responsive, Win32 applications must check their message queue regularly. On Windows NT, a Win32 application that does not check its message queue and handle messages in a timely manner only affects its own user interface and the user may switch away and work on other applications. Windows 3.1, however, uses messages to schedule processes. Therefore, applications (16- or 32-bit) must handle messages in a timely manner in order to keep Windows 3.1 responsive.
Azarien wrote on 2023-06-15, 21:35:
This sentence sounds especially promising:
Win386 is still available as part of the latest Open Watcom release (version 1.9 as of this writing)
Yeah, it works in 1.9. I wonder if it works in 2.0; I've never tried using that version.
If you want to run 32 bit apps (including "some win 9x software") but keep the Windows 3.x vibe I'd suggest NT 3.51 instead.
I wonder if anyone has ever tried making a "lite" version of any Windows NT version?
Jo22 wrote on 2023-06-17, 16:03:
Makes me wonder if these Windows programs can still be run on Windows x64.
I mean, at the core, they are 32-Bit. But the stub.. 🤷
It seems unlikely to me that Microsoft would have done the work to keep such a small subset of Windows 3.x applications working on 64-bit Windows, particularly since I imagine it wouldn't have been that simple.
Win386 application code is itself is 32-bit as you say, and is linked against the Win386 API, which is a 32-bit API that - as Azarien (sort of) said - is not the Win32 API, but instead uses the Win16 API (so contains some 16-bit code too). Since Win386 was (according to the virtuallyfun link you posted) "bound to the executable", I guess it's separate enough from the application that perhaps one could make a loader that - instead of using the Win386 loader and API inside the executable - mapped the Win386 API calls to Win32 calls instead of Win16.
However, my understanding from reading the documentation is that the Win386 API is mostly meant to look just like the Win16 API, but is callable from 32-bit code. That is natural - it would be work for Watcom to design a whole new API, and then it would be a bigger barrier for their users to port their code from Win16 to Win386 - so some kind of Win386 loader for Win32 would be effectively doing the work of mapping from the Win16 API to the Win32 API but for 32-bit code instead of 16-bit code. Many of the Win16 API functions also exist in Win32 (but with different parameter sizes like in Win386), but there are quite a few significant differences too. Such a translation layer seems like the kind of thing which would work for some programs but not others, and of the few people who actually have a Win386 program they want to run, I can imagine that many would probably think it is much more reliable to just run a 32-bit version of Windows in a VM than use the buggy translation layer.
Edit: I just remembered that winevdm exists, so that must mean that the work of mapping Win16 to Win32 has already been done (but not by Microsoft!). It has a lot of issues raised in GitHub though.
the3dfxdude wrote on 2023-06-18, 03:47:
Well what if you wanted to package up a windows program, but not have to worry about Windows licensing? Well I guess you could loadlin linux from DOS, boot into Xwindows, and then call Wine... 😉 But I guess at that point you might as well build up a Linux program installer with Wine in mind and advertise your program runs on Linux, and just call it there.
If one was happy to run it on Linux (and modern Windows and Mac) perhaps one could use Boxedwine.