Anatoly asked:
How can I write a test for this function or build program use it?
I think writing good win16 tests requires a 16 bit linker. Fortunately, OpenWatcom has one, and works on Wine. It's amazingly easy to install it and build one of its demo apps: $ wget http://ftp.openwatcom.org/ftp/open-watcom-c-win32-1.6.exe $ wine open-watcom-c-win32-1.6.exe $ wineboot $ cd .wine/drive_c/WATCOM/samples/win/alarm/win16 $ wine wmake $ wine alarm
This builds an honest-to-goodness win16 binary that works on XP (possibly with one warning dialog you have to ignore).
Unfortuately, Wine doesn't currently run these win16 apps properly; they hang with
err:ntdll:RtlpWaitForCriticalSection section 0x7b91f300 "syslevel.c: Win16Mutex" wait timed out in thread 000b, blocked by 000c, retrying (60 sec)
This is embarassing. These are the "hello, world" of 16 bit windows apps, and current wine (well, wine-0.9.37-g3739b5f) can't run them...
I haven't looked to see if older wine runs these 16 bit demo apps properly.
On 6/19/07, Dan Kegel dank@kegel.com wrote:
Unfortuately, Wine doesn't currently run these win16 apps properly; they hang with
err:ntdll:RtlpWaitForCriticalSection section 0x7b91f300 "syslevel.c: Win16Mutex" wait timed out in thread 000b, blocked by 000c, retrying (60 sec)
Filed as http://bugs.winehq.org/show_bug.cgi?id=8744 I tried this at home, and it works fine there with wine-0.9.37 or wine-0.9.39, so I marked my own bug WORKSFORME until I figure out how to reproduce it better.
So OpenWatcom might indeed be a great way to compile win16 test cases. Not sure if it's *the* way to do it... anyone know a better way? - Dan
So, the original question was "How to test OpenFile16"? Here's a more complete answer. First, install OpenWatcom as previously described. Then create a text file blah.c containing something like
#include <win/win16.h>
int PASCAL WinMain( HINSTANCE this_inst, HINSTANCE prev_inst, LPSTR cmdline, int cmdshow ) { HFILE h; OFSTRUCT of; h = OpenFile("foobar.dat", &of, OF_CREATE); if (h == HFILE_ERROR) MessageBox(NULL, "Failed", "foobar", 0); else MessageBox(NULL, "OK", "foobar", 0); }
Then compile it with OpenWatcom like this:
$ wine wcl -Zw blah.c
This seems to produce a simple 16 bit testcase that works.
To verify OpenFile16 is being called, get a +file log:
WINEDEBUG=+file wine blah.exe 2>&1 | grep OpenFile trace:file:OpenFile16 "Z:\home\dank\blah.exe" OF_READ OF_SHARE_DENY_WRITE trace:file:OpenFile16 found "Z:\home\dank\blah.exe" trace:file:OpenFile16 (Z:\home\dank\blah.exe): OK, return = 0x58 trace:file:OpenFile16 "foobar.dat" OF_READ OF_SHARE_COMPAT OF_CREATE trace:file:OpenFile foobar.dat OF_READ OF_SHARE_COMPAT OF_CREATE trace:file:OpenFile foobar.dat 1000 trace:file:OpenFile (foobar.dat): OK, return = 0x78 trace:file:OpenFile16 (foobar.dat): OK, return = 0x78
The next step would probably be to figure out how to get Wine's test harness, or something like it, to work in 16 bits.
Dan Kegel wrote:
On 6/19/07, Dan Kegel dank@kegel.com wrote:
Unfortuately, Wine doesn't currently run these win16 apps properly; they hang with
err:ntdll:RtlpWaitForCriticalSection section 0x7b91f300 "syslevel.c: Win16Mutex" wait timed out in thread 000b, blocked by 000c, retrying (60 sec)
Filed as http://bugs.winehq.org/show_bug.cgi?id=8744 I tried this at home, and it works fine there with wine-0.9.37 or wine-0.9.39, so I marked my own bug WORKSFORME until I figure out how to reproduce it better.
AFAIK and AFAICS 16bit apps do not run with 64bit kernel, and I get a similar message when trying to run alarm.exe on 64bit kernel (with 32bit wine).
At some point I got a notice in kernel log about this when I tried to run 16bit apps, but that no longer seems to be the case (...with newer kernels?).