Win32 -> OS/2

Autor: Przemek Dobrowolski (Przemek.Dobrowolski_at_f88.n480.z2.fidonet.org)
Data: Sat 21 Feb 1998 - 00:02:48 MET


Sie masz All!

Przepraszam za to že tekst nie jest sformatowany... ale przeczytajcie!!!

* Crossposted in OS2.POL
* Crossposted in SYSTEMY.POL
* Crossposted in PL.COMP.OS.OS2

=== Cut ===
 LinkExchange Member

The Win32-OS/2 Project

Web page by Timur Tabi
Last Updated: February 11, 1998
European visitors: please use the German mirror site at
http://win32os2.home.pages.de or the Swedish mirror at
http://www.sdg.ml.org/win32os2/.

Save yourself time and trouble! Avoid having to ask dumb questions! Keep
up-to-date on the
latest beta version! Click on this button, and you'll get email whenever this
web page changes.

Introduction

The Win32-OS/2 Project is a collection of tools and DLL's that allow an end
user to convert a Win32 (i.e. Win95/WinNT)
program into a native OS/2 program, and then run that program under OS/2
without needing Windows or Win-OS/2 support
installed.

If you don't know what OS/2 is, or if you would just like more information on
OS/2, please check out my New OS/2 User
Web Page.

Also, many people have asked how much this software will cost. IT WILL BE
FREE! Yes, that's right, FREE! Free for
commercial users AND home users.

There is also a transcript from a V.O.I.C.E. IRC question-and-answer chat
session with Peter Fitzsimmons and Timur Tabi.
A lot of frequently asked questions were posted and answered during this
session, so you may find answers to your questions
there. The transcript was edited by Chris Wenham of OS/2 e-Zine.

We need your help! UPDATED!

IT HAS COME TO MY ATTENTION THAT THERE ARE A NUMBER OF PEOPLE OUT THERE WHO
JUST DON'T
GET IT.

1. Please wait until the public beta test before emailing us any offers. Try
the converter yourself first. If it doesn't work,
then we can talk.

2. Don't tell us about software we can download ourselves. We're only
interested in commercial software that has to be
purchased.

3. Don't ask us what software we want - that's completely missing the point.
The idea is for YOU to send US software that
YOU want to have converted. Look at the Win95/NT software that YOU NEED TO USE
under OS/2, and pick from that
list. We don't want suggestions. We don't want advice.

There will be a public beta released around mid-February. Please wait until
after you have tried the beta yourself before
emailing us.

We will soon be accepting donations of Windows 95/NT software. Our intention is
that you purchase an application and
have it shipped to us. We need to have a full blown legal copy of the
application, because we will need all manuals and we
may also need to contact the vendor's technical support. Without a full legal
copy of the application, we will not have all the
resources we need to convert it.

IMPORTANT NOTE: We make no guarantees whatsoever that we will be able to
convert your application. All we are
offering is to include your application in our test suite. We will be aware of
the problems, but we make no promises that we
will be able to fix them. Our goal is to be able to convert every Windows 95/NT
application, but there are limits, and we
know that there are some Windows 95/NT applications that we will never be able
to convert.

The team member who will accept your donation will depend on what kind of
application and where you live. First
determine if any of the team members is working on the appropriate area. If no
one qualifies, then send it to the nearest team
member.

 Team Member
                  Category of Application or Location
 Felix Maschek
                  All communications apps, such as TAPI and ISDN apps.
 Joel Troster
                  All MIDI applications.
 Sander van Leeuwen
                  Any general apps from those in Europe, and any Glide-based
games (no D3D!) from anywhere
 Kevin Laughbaum
                  All OpenGL applications
 Chris McKillop
                  Any general apps from those in Canada, and the US if Timur
gets overloaded.
 Timur Tabi
                  Any general apps from those in the United States

For email addresses, please see the bottom of this web page, and contact the
team member directly. Please note that we will
NOT be able to return your software back to you.

 Submitted Software
                                                  Team Member
                                                                     Status
 Finale 97 (Coda Music Technology)
                                                  Joel Troster
                                                                     being
tested
 Cakewalk 5 (Cakewalk)
                                                  Joel Troster
                                                                     offered,
not yet submitted
 Mathcad 7 (Mathsoft)
                                                  Timur Tabi
                                                                     offered,
not yet submitted
 Grapher for Windows (Golden Software)
                                                  Timur Tabi
                                                                     offered,
not yet submitted
 Surfer for Windows (Golden Software)
                                                  Timur Tabi
                                                                     offered,
not yet submitted

List of Converted Apps

Here's a list of apps that we KNOW that we can convert or not convert - this is
not a comprehensive list by any means. Do
not ask us if we've tried such-and-such app - if it's not on this list, THEN WE
HAVEN'T TRIED IT!

                                    Applications that we know work
 Application
                       Comments
 Quake II
                       Yes (including sound). Full screen on a 3Dfx Voodoo card
(same speed as in NT), and
                       Windowed (software rendering) on any system (slower than
in NT) - see screen shot
 GLide (VooDoo 3D
 Library)
                       Yes, including most demos from 3Dfx's web site
 Solitaire. Freecell,
 Reversi, Notepad
                       Converts just fine - see screen shot
 GDI demo
                       Converts just fine - see screen shot
 Rasmol
                       Freeware molecule viewer - converts just fine. See
                       http://klaatu.oit.umass.edu/microbio/rasmol/
 MFC Samples
                       Some of the simple MFC samples

                                Applications that we know DO NOT work
 Application
                 Comments
 Microsoft Office 97
                 This program forces itself above the 512 MB limit for OS/2
applications (see the Implementation
                 Notes below), so without a change to the OS/2 kernel, it'll
never work. Besides, it's really big and
                 probably uses lots of undocumented functions.
 winhlp32.exe
                 Windows 95/NT help viewer

Status

We are currently conducting a private beta test of the Quake II converter. We
expect that this test will last 1-2 weeks. After
we've fixed the bugs, we'll be conducting our first public beta test. To be
certain that you're notified, use URL Minder to get
email when this page is updated. See the top of this page for instructions.

There are three prime areas of current development:

Resources. Resources are GUI items like icons, menus, translatable strings,
etc. They are stored inside the .EXE or .DLL.
Open32 requires that all resources be in OS/2 format, so pe2lx must also
translate the resources from Windows format to
OS/2 format.

 Resource Type
               Status
 bit maps
               working
 accelerators
               working
 cursors
               working
 menus
               working
 dialog boxes
               working
 icons
               working
 strings
               Win32 supports numeric and text string ID's, whereas OS/2
supports only
               numeric ID's, so a stub function in kernel32.dll does the
translation.
 version
               version.dll is needed to read these resources, but it's not
implemented yet.
               Fortunately, very few apps use this resource

Console API. The console API's are what text mode Win32 apps use to write text
to the screen and read from the keyboard.
These API's belong in kernel32.dll, but currently they're being developed in
their own DLL. STDIN/STDOUT is the last
hurdle, and some techniques are being explored.

Updating the Supplemental DLL's. Currently, there is support for over 1,750
Win32 API's (including OLE), of which 750
are fully implemented via Open32, and the remaining 1000 are provided in
supplemental DLL's, of which 500 are currently
stubs that do nothing.

 DLL Name
          Purpose/Function
                                                         Status
 advapi32
          Registry and security apis (among others)
                                                         Approx. 20% (most of
the registry API's). The other
                                                         80% is for the NT
security API's, which will not be
                                                         supported.
 gdi32
          All the GDI (graphics) API's
                                                         77%
 kernel32
          Kernel apis (file system, memory, threads, events, etc.)
          and console API's
                                                         57% complete. Console
API's are not in this DLL
                                                         yet.
 ole32
          OLE and OLE2
                                                         All stubs - just
enough functionality to get an app
                                                         thinking that OLE is
available (needed for some
                                                         apps).
 user32
          Window apis (create/manipulate windows, dialogs,
          menus, etc.)
                                                         72%
 shell32
          GUI extensions, drag 'n drop, shell extensions in
          Win95/NT, all sorts of weird things like loading
          resources from other exes/dlls.
                                                         Less than 5%
 version
          Versioning API. (used to extract info from the version
          resource most win32 exe's contain)
                                                         All stubs
 winmm
          Multimedia API's
                                                         15%. Wave-out is now
working
 ddraw
          DirectDraw
                                                         25%. Partially
implemented - enough to run a
                                                         DirectX SDK animated
donut sample.
 comctl32
          Common GUI controls, like buttons, toolbar, image lists,
          notebooks, etc.
                                                         Converted, some
controls already work
 comdlg
          Common dialog boxes (file open/save, print, palette, find,
          etc.)
                                                         Completely implemented
using Open32.
 dsound
          DirectSound
                                                         All stubs
 winspool
          Called winspool.drv in real Windows.
                                                         Only one function is
implemented
 winsock
          TCP/IP sockets support
                                                         75%. E.g. Win95's
TELNET works.
 capi2032
          CAPI 2.0 ISDN API
                                                         100%.
 tapi32
          Telephony API
                                                         All stubs.
 mpr
          Network stuff
                                                         All stubs.
 netapi
          Network stuff
                                                         All stubs.
 opengl32
          OpenGL API
                                                         80% stubs, 15% fully
implemented, 5% not yet
                                                         implemented

A bunch of text files that show each of the DLL's, the functions in them, which
ones have been implemented, and other
goodies can be found in this directory.

In particular:

    done.lst contains a list of functions that we had coded by hand (as of late
June)
    w95.lst contains a list of functions exported by the real Win95 DLL's.
    open32.list -- functions supplied by PMWINX.DLL (the Open32 DLL)

Implementation Notes

Just a few random notes about the implementation of pe2lx and the supplemental
DLL's

    Open32 uses the _System calling convention (as do all OS/2 API's) whereas
Win32 uses __stdcall. The solution, in the
    words of Sander:
        I've used some C++ for most of it. Create a class for, say, a window
procedure. Set the procedure address of the
        api to the static one in the class. After it's called for the first
time, the window handle is stored in class object
        which is used for later for lookup and the original win32 procedure is
called. For window hooks/enumeration
        handlers, you can add the pointer to the class object in the user
parameter which is used for lookup.
    Software exceptions (like XCPT_SIGNAL_BREAK caused by pressing Ctrl-Break)
are supported, but hardware
    exceptions (like "drive not ready") are not supported. The Win32 hardware
exception model is almost, but not quite,
    like the OS/2 model, so a little work is still needed.
    16-bit <-> 32-bit thunks will not be supported. Unfortunately, all Win95
MIDI apps need a 16-bit DLL in order to do
    accurate timing.
    There is a 512 MB limitation problem. OS/2 (except for OS/2 Warp Server
Advanced SMP) has a 512 MB limitation
    per process. Unfortunately, some Win32 apps (notably MS Word) force
themselves to be loaded above 512 MB, and
    therefore they cannot be converted. The limit for Win32 is 2 GB. The
limit for OS/2 Warp Server Advanced SMP is 3
    GB. Hopefully, IBM will correct the situation in a fixpack.

Frequently Asked Questions

What's the difference between Win32, Win95, and WinNT?

Windows 95 (Win95) and Windows NT (WinNT) are two different operating systems
sold by Microsoft. These are
products that you can purchase and install on your computer, and they allow you
to use a wide variety of applications. An
operating system is the layer between the applications you use and the computer
hardware. The choice of operating system
dictates everything about your computer: which hardware you can use, which
software you can run, how they will look, and
how well your computer performs as a whole.

Win32 is the name of an API (Application Programming Interface) that both Win95
and WinNT support. API's are used by
programmers. An API is a collection of services that an operating system
provides for applications to use. Most
applications are written to a specific API for a specific operating system.
Since both Win95 and WinNT support the Win32
API (with minor differences), it's very easy to write an application that works
on both Win95 and WinNT at the same time.
An application which runs on Win95 and WinNT is called a Win32 application.

What is Open32?

With OS/2 Warp 4, IBM tried to make it easy for developers to port their
Windows applications to OS/2 by providing the
Win32 API in addition to the standard OS/2 API. The idea was that a developer
could take his Windows program and just
recompile it (perhaps after some minor changes) with a standard OS/2 compiler.
The program, when run under OS/2, would
look more or less like a normal OS/2 application.

The name given for the Win32 API as implemented under OS/2 is Open32. Open32
is not the complete Win32 API - many
individual functions are missing. The biggest software vendor who uses Open32
is Lotus - all of their new OS/2
applications use the Open32 API extensively.

What's Win32s?

Win32s is a subset of Win32 (a different subset than Open32) specifically for
Windows 3.1. As you know, Windows 3.1 is
basically a 16-bit operating system, but with the help of Win32s, it's possible
to write 32-bit applications that run on
Windows 3.1. They don't run as well as they would on Windows 95/NT, but they
do run, and they are better than the
standard 16-bit applications. Many developers use Win32s to provide the same
application on Windows 3.1 and Windows
95/NT.

There are several versions of Win32s. The most recent is version 1.30.
Unfortunately, Win-OS/2 only supports Win32s
1.25. This means that there are a number of Windows 3.1 applications which
will not work under OS/2 simply because they
need a higher level of Win32s.

Can I convert 16-bit Windows 3.1 applications?

Windows 3.1 16-bit applications (a.k.a. Win16 apps) will not be supported.
After all, that's why OS/2 have Win-OS/2.
However, a large number of Windows 3.1 apps are actually Win32s apps. We've
found that we can convert and run Win32s
apps, so they will be supported. However, Win32s support is not a priority for
us, since many Win32s apps are already
available as true Win32 apps.

What about the legal issues?

Won't Microsoft try to stop us? Well, this software is not doing anything
different from what the operating system has to do
to load your program into memory. Besides, it certainly is no more illegal
than the fact that IBM provides the Win32 API in
OS/2, or that the Linux community is providing a Win32 emulator in the form of
WINE. In other words, this project is
perfectly legal. However, some companies may require by their license that you
run their apps only under Microsoft
Windows, although many people have said that such a requirement is illegal in
most places. But that's not our problem,
because that would be like convicting a gun manufacturer if someone uses one of
their weapons to kill a person.

Screen Shots

Click on the thumbnails to see the full-size picture.

                      Solitaire and GDI demo (1024 x 768 x 256)

                      Quake II (1024 x 768 x 256)

PE2LX - The EXE/DLL file translator

Pe2lx is the name given to the tool which converts your Win32 EXE's and DLL's
into native OS/2 EXE's and DLL's. Pe2lx
stands for Portable Executable To Linear Executable converter. PE is Win32's
executable (.EXE and .DLL) format, and
LX is OS/2's. To see a description of the LX format, take a look at omf.inf.

Some key differences are:

    EXE file layout:
        PE consists of sections for code, data, resources, imports, exports,
debug, TLS.
        LX is basically the same, but called objects. Structure is very
different though.
    Fixups (imported functions)
        PE: One or more pages with imported apis (IMPORT section). Win32 apps
call imported apis by referencing a
        specific offset into these pages
                  LX: Every call to an imported function has a fixup (so the
fixup points to the offset portion of the opcode for
        a call)
    Resources
        LX: Plain array of resources (each resource starts after a src32
structure:
            struct rsrc32 /* Resource Table Entry */
            {
               unsigned short type; /* Resource type */
               unsigned short name; /* Resource name */
               unsigned long cb; /* Resource size */
               unsigned short obj; /* Object number */
               unsigned long offset; /* Offset within object */
            };
        PE: Resources stored into a tree, which consists of 4 levels:
          1.resource type
          2.name ids (numeric or strings)
          3.language
          4.(leafs) actual resources
    Platform supprt
        LX has support for 16 bit EXE's
        PE only 32 bit, but also for other platforms (PPC, Alpha, MIPS)

The conversion process consists of:

    Read in and store all the data sections (read-only & read/write) without
modifications in the OS/2 EXE.
    Read the code section(s) and put a single page in front of it in the OS/2
exe. This code handles some differences
    between OS/2 and win32.
    Ignore the Win32 debug sections. Read import section (contains imported
API's) and convert it to the OS/2 import
    format.
    Read export section (DLL's only) and convert to OS/2 export format.
    Read internal fixup section (if present) and also convert it.
    Read all the resources (if present) and convert them to OS/2 format (Open32
requirement).
    Save OS/2 EXE/DLL.

The result is a new set of .EXE's and .DLL's. These are the converted
executables.

Supplemental DLL's - Filling the holes in Open32

As mentioned earlier, the Open32 API is not the complete Win32 API set. Far
from it, actually, so the Win32-OS/2 project
has to fill in those gaps by itself.

To do this, supplemental DLL's are provided. These DLL's contain not only
those API functions that are not in Open32, but
they can also contain replacements for those functions that are in Open32 but
do not work correctly.

In addition, these DLL's can also contain pre-processing for some Open32 API's.
For instance, a particular Open32 API
could perhaps implement only a portion of the functionality of its Win32
counterpart. The stub function in the supplemental
DLL could perform the missing task and then call upon the Open32 DLL to handle
the rest.

The stub functions in the supplemental DLL's all have a prefix of "OS2"
(although they are not exported as such). The reason
for this is that the converted EXE must link not only to all of the
supplemental DLL's, but also to the Open32 DLL
(PMWINX.DLL), because PMWINX.DLL does most of the real work (after all, it is
an implementation of the Win32 API).
All functions must have unique names, so if PMWINX.DLL has a function called
"ReadFile", there cannot be a function with
that same name in the any of the supplemental DLL's, because then OS/2 wouldn't
know which version to use when the
application calls "ReadFile". So when pe2lx converts the EXE to OS/2 format,
it also changes all of the API names.
"ReadFile" becomes "OS2ReadFile".

There are three different categories of Open32 API's:

    A Win32 API that is not in Open32. Besides whole categories of API's (like
all DirectX API's), there are partiticular
    functions that for some odd reason, are just not part of Open32. An
example is VirtualAlloc(LPVOID lpvAddress,
    DWORD cbSize, DWORD fdwAllocationType, DWORD fdwProtect). The stub
function implements this API by
    calling DosAllocMem.
    An Open32 function that is so buggy that it's useless and needs to be
completely replaced by a stub function in
    one of the supplemental DLL's. So far, none have been found.
    An Open32 function that's missing something small, something that can be
made-up with a little extra code in a
    supplemental DLL. Sometimes it's just a missing or broken sub-feature,
sometimes the parameters need to be
    converted on the fly.
        Lots of apis that have procedure addresses as parameters need extra
code due to the difference in calling
        convention.
        All the indirect dialog creation API's (those that have a parameter to
a dialog template structure instead of a
        resource id; i.e. CreateDialogIndirect) contain extra code to convert
Win32 dialogs to OS/2 format on-the-fly.
        This is a requirement of Open32
        There's also one that's a bit buggy: HHOOK SetWindowsHookA(int idHook,
HOOKPROC hkprc). This one
        doesn't work for hooktype WH_CBT.

Ok, how do I use this thing?

Once you have converted all of your .EXE's and DLL's with pe2lx, all you need
to do is run them under OS/2. Since you
need Open32 for this to work, you must have OS/2 Warp 4, or Warp 3 with at
least FixPack 26 applied. Also, if you have
applied Warp 4 FixPack 3, you must either apply the os2krnl fix on top of that,
or apply FixPack 4 or later. Also, there
seems to be some debate as to whether Warp Server Advanced SMP can be used, as
some have reported that the Warp
Server/Warp 3 FixPacks do not add Open32 support to Warp Server, yet others say
that the support can be manually added.
UPDATED!

Who's on the Project

A list of all the project team members and their assignments.

 Name
                      Email Address
                                                Accomplishments and
Current/Future Work
 Timur Tabi
                      timur_at_io.com
                                                Maintainer of web site. Spoke
at Warpstock.
 Sander van Leeuwen
                      sandervl_at_xs4all.nl
                                                Almost everything (pe2lx +
dll's)
 Peter Fitzsimmons
                      pfitz_at_ican.net
                                                API utilities, development
environment and help with pe2lx,
                                                user32, kernel32.
 Christophe M. Vallat
                      miodrag_at_mygale.org
                                                Registry API's.
 Saxon Joseph Hyde Jones
                      saxon_at_gpu.srv.ualberta.ca
                                                temporarily unavailable
UPDATED!
 Vince Vielhaber
                      vev_at_michvhf.com
                                                Winsock
 Kevin Laughbaum
                      klaughbaum_at_utsi.com
                                                OpenGL
 Felix Maschek
                      felix_at_maschek.com
                                                Capi2032 and Tapi32
 Chris McKillop
                      cdmckill_at_engmail.uwaterloo.ca
                                                Build environment
 Joel Troster
                      jtroster_at_ibm.net
                                                MIDI support
 Patrick Haller
                      haller_at_zebra.fh-weingarten.de
                                                Console API's NEW!

Back to Timur's homepage
=== Cut ===

                                                            *Przemek/2*
... Pozostancie mroczni, pijani i metalowi



To archiwum zostało wygenerowane przez hypermail 2.1.7 : Tue 18 May 2004 - 15:16:23 MET DST