From b7258befe02dfa88b23a1f7f1ba4dacc09dd71ab Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 1 Sep 1995 15:57:28 +0000 Subject: [PATCH] Release 950901 Thu Aug 31 17:19:57 1995 Alexandre Julliard * [Configure] Added compile-time option for IPC. * [configure.in] Added command-line options for language, IPC and malloc debugging. * [controls/menu.c] WM_MENUSELECT was sometimes sent to the wrong window. * [debugger/break.c] For the 'next' command, only step over instruction that require it. This allows 'next' to do the right thing with jmp and ret instructions. * [ipc/*.c] [memory/atom.c] [memory/global.c] IPC can now be configured out at compile-time. * [loader/task.c] Bug fix in TASK_Reschedule() that could cause a task to be deleted twice. * [miscemu/dosmem.c] (New file) Partial emulation of the BIOS data segment. * [miscemu/instr.c] Trap attempts to access selector 0x40 and remap the access to segment __0040H. * [tools/build.c] Fixed bug in CallTo32_LargeStack() that caused problems when compiling Wine with the -fomit-frame-pointer option. * [windows/message.c] Fixed bug in hardware event handling that could cause some events to get ignored. Sat Aug 26 13:12:59 IST 1995 Michael Veksler * [ipc/README] [ipc/dde.tex] LaTeX documentation for the ipc and DDE stuff. Wed Aug 23 22:01:23 GMT 1995 Michael Veksler * [ipc/Imakefile] [ipc/wine_test_stub.c] Fixed IPC testing. Now it can be compiled with "make tests" Wed Aug 23 21:04:14 1995 Fons Botman * [if1632/kernel.spec] [include/windows.h] [misc/main.c] Added GetWinDebugInfo/SetWinDebugInfo stub for player.exe Sun Aug 20 13:49:42 1995 Marcus Meissner * [miscemu/int21.c] Misc fix to int21,ah=40 (write) to match _lwrite(). AX=0x440A (check if handle is remote) added. * [multimedia/mmsystem.c] Moved mciSendString to mcistring.c. * [multimedia/mcistring.c] New file, string interface for MCI (not complete, not thoroughly tested). * [multimedia/audio.c] IOCTL prints errors; one paranoid check disabled. * [misc/file.c] Misc operator precedence fixes. * [if1632/gdi.spec] [objects/bitblt.c] Stub for FastWindowFrame (parameters not correct). Sat Aug 19 01:31:23 1995 Graham Menhennitt * [loader/ne_image.c] Preliminary support for iterated segments. Sat Aug 19 00:43:04 1995 Andrew Taylor (andrew@riscan.com) * [windows/mapping.c] In function MAPPING_FixIsotropic(), VportExt[XY] is multiplied by the absolute value of (ydim / xdim) or (xdim / ydim). Thu Aug 15 23:00:16 Gregory Trubetskoy * [objects/oembitmap.c] Added some includes for Windows 95. * [include/sysmetrics.h] Added some sysmetrics for Windows 95. * [include/bitmaps/*95] New files: obm_close_95, obm_closed_95, obm_reduce_95, obm_reduced_95 obm_zoom_95, obm_zoomd_95 - these are some pixmaps for Windows 95. Thu Aug 10 12:00:00 1995 Jan Willamowius (jan@janhh.shnet.org) * [misc/shell.c] [rc/sysres*.rc] The caption of the ShellAbout dialog box is language specific and should be defined in the resources. --- ANNOUNCE | 23 +- ChangeLog | 105 ++ Configure | 6 + Imakefile | 1 - Makefile.in | 11 +- RELEASE-NOTES | 23 +- configure | 365 +----- configure.in | 83 +- controls/Makefile.in | 2 +- controls/button.c | 1 - controls/menu.c | 109 +- debugger/Makefile.in | 5 +- debugger/break.c | 85 +- debugger/memory.c | 6 +- debugger/readline/Makefile.in | 5 +- debugger/readline/sysunix.c | 4 - if1632/Makefile.in | 15 +- if1632/gdi.spec | 2 +- if1632/kernel.spec | 4 +- if1632/pop.h | 18 - include/atom.h | 6 - include/bitmaps/obm_close_95 | 23 + include/bitmaps/obm_closed_95 | 23 + include/bitmaps/obm_reduce_95 | 23 + include/bitmaps/obm_reduced_95 | 23 + include/bitmaps/obm_zoom_95 | 23 + include/bitmaps/obm_zoomd_95 | 23 + include/dde_atom.h | 17 +- include/dde_mem.h | 5 + include/dde_proc.h | 6 + include/miscemu.h | 25 +- include/shm_block.h | 6 +- include/shm_fragment.h | 4 + include/shm_main_blk.h | 5 + include/shm_semaph.h | 4 + include/sysmetrics.h | 26 + include/windows.h | 52 + include/winsock.h | 2 +- ipc/Imakefile | 38 +- ipc/Makefile.in | 2 +- ipc/README | 38 +- ipc/bit_array.c | 6 +- ipc/dde.tex | 962 ++++++++++++++ ipc/dde_atom.c | 18 +- ipc/dde_mem.c | 4 + ipc/dde_proc.c | 7 + ipc/generic_hash.c | 4 + ipc/shm_block.c | 5 +- ipc/shm_fragment.c | 4 + ipc/shm_main_blk.c | 4 + ipc/shm_semaph.c | 4 + ipc/wine_test_stub.c | 2 +- loader/Makefile.in | 2 +- loader/main.c | 3 + loader/module.c | 42 +- loader/ne_image.c | 42 +- loader/signal.c | 14 +- loader/task.c | 7 +- loader/wine.c | 756 ----------- memory/Makefile.in | 2 +- memory/atom.c | 33 +- memory/global.c | 63 +- misc/Makefile.in | 2 +- misc/clipboard.c | 1 + misc/file.c | 6 +- misc/main.c | 24 + misc/profile.c | 2 + misc/shell.c | 8 +- miscemu/Imakefile | 1 + miscemu/Makefile.in | 21 +- miscemu/dosmem.c | 184 +++ miscemu/emulate.c | 5 +- miscemu/instr.c | 552 ++++++-- miscemu/int1a.c | 42 +- miscemu/int21.c | 25 +- multimedia/Imakefile | 1 + multimedia/Makefile.in | 15 +- multimedia/audio.c | 10 +- multimedia/mcistring.c | 2177 ++++++++++++++++++++++++++++++++ multimedia/mmsystem.c | 777 +----------- objects/Makefile.in | 2 +- objects/bitblt.c | 8 + objects/font.c | 5 +- objects/oembitmap.c | 30 +- rc/ChangeLog | 5 - rc/Makefile.in | 4 +- rc/rc.h | 106 -- rc/rc.l | 75 -- rc/rc.y | 210 --- rc/sysres.rc | 2 +- rc/sysres_De.rc | 2 +- rc/sysres_No.rc | 2 +- tools/Makefile.in | 2 +- tools/build.c | 33 +- windows/Makefile.in | 2 +- windows/class.c | 11 +- windows/mapping.c | 5 +- windows/message.c | 61 +- windows/win.c | 2 + wine.ini | 2 +- 100 files changed, 4852 insertions(+), 2801 deletions(-) delete mode 100644 if1632/pop.h create mode 100644 include/bitmaps/obm_close_95 create mode 100644 include/bitmaps/obm_closed_95 create mode 100644 include/bitmaps/obm_reduce_95 create mode 100644 include/bitmaps/obm_reduced_95 create mode 100644 include/bitmaps/obm_zoom_95 create mode 100644 include/bitmaps/obm_zoomd_95 create mode 100644 ipc/dde.tex delete mode 100644 loader/wine.c create mode 100644 miscemu/dosmem.c create mode 100644 multimedia/mcistring.c delete mode 100644 rc/ChangeLog delete mode 100644 rc/rc.h delete mode 100644 rc/rc.l delete mode 100644 rc/rc.y diff --git a/ANNOUNCE b/ANNOUNCE index 137878ffda9..81203046f50 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,14 +1,15 @@ -This is release 950817 of Wine the MS Windows emulator. This is still a +This is release 950901 of Wine the MS Windows emulator. This is still a developer's only release. There are many bugs and many unimplemented API features. Most applications still do not work. Patches should be submitted to "wine-new@amscons.com". Please don't forget -to include a ChangeLog entry. I'll make a new release every other Sunday. +to include a ChangeLog entry. I'll make a new release every other week. -WHAT'S NEW with Wine-950817: (see ChangeLog for details) - - Built-in debugger improvements. - - Multimedia fixes. - - IPC can be disabled at run-time. +WHAT'S NEW with Wine-950901: (see ChangeLog for details) + - Accesses to BIOS segment 0x40 are trapped and emulated. + - Multimedia improvements. + - IPC can now be disabled at compile-time. + - Documentation for the IPC code. - Lots of bug fixes. See the README file in the distribution for installation instructions. @@ -17,11 +18,11 @@ Because of lags created by using mirror, this message may reach you before the release is available at the ftp sites. The sources will be available from the following locations: - sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-950817.tar.gz - tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-950817.tar.gz - ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-950817.tar.gz - ftp.funet.fi:/pub/OS/Linux/ALPHA/Wine/Wine-950817.tar.gz - aris.com:/pub/linux/ALPHA/Wine/development/Wine-950817.tar.gz + sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-950901.tar.gz + tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-950901.tar.gz + ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-950901.tar.gz + ftp.funet.fi:/pub/OS/Linux/ALPHA/Wine/Wine-950901.tar.gz + aris.com:/pub/linux/ALPHA/Wine/development/Wine-950901.tar.gz It should also be available from any site that mirrors tsx-11 or sunsite. diff --git a/ChangeLog b/ChangeLog index 29c8497cebc..5a64227e6d9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,108 @@ +Thu Aug 31 17:19:57 1995 Alexandre Julliard + + * [Configure] + Added compile-time option for IPC. + + * [configure.in] + Added command-line options for language, IPC and malloc + debugging. + + * [controls/menu.c] + WM_MENUSELECT was sometimes sent to the wrong window. + + * [debugger/break.c] + For the 'next' command, only step over instruction that require + it. This allows 'next' to do the right thing with jmp and ret + instructions. + + * [ipc/*.c] [memory/atom.c] [memory/global.c] + IPC can now be configured out at compile-time. + + * [loader/task.c] + Bug fix in TASK_Reschedule() that could cause a task to be deleted + twice. + + * [miscemu/dosmem.c] (New file) + Partial emulation of the BIOS data segment. + + * [miscemu/instr.c] + Trap attempts to access selector 0x40 and remap the access to + segment __0040H. + + * [tools/build.c] + Fixed bug in CallTo32_LargeStack() that caused problems when + compiling Wine with the -fomit-frame-pointer option. + + * [windows/message.c] + Fixed bug in hardware event handling that could cause some events + to get ignored. + +Sat Aug 26 13:12:59 IST 1995 Michael Veksler + + * [ipc/README] [ipc/dde.tex] + LaTeX documentation for the ipc and DDE stuff. + +Wed Aug 23 22:01:23 GMT 1995 Michael Veksler + + * [ipc/Imakefile] [ipc/wine_test_stub.c] + Fixed IPC testing. Now it can be compiled with "make tests" + +Wed Aug 23 21:04:14 1995 Fons Botman + + * [if1632/kernel.spec] [include/windows.h] [misc/main.c] + Added GetWinDebugInfo/SetWinDebugInfo stub for player.exe + +Sun Aug 20 13:49:42 1995 Marcus Meissner + + * [miscemu/int21.c] + Misc fix to int21,ah=40 (write) to match _lwrite(). + AX=0x440A (check if handle is remote) added. + + * [multimedia/mmsystem.c] + Moved mciSendString to mcistring.c. + + * [multimedia/mcistring.c] + New file, string interface for MCI (not complete, not thoroughly + tested). + + * [multimedia/audio.c] + IOCTL prints errors; one paranoid check disabled. + + * [misc/file.c] + Misc operator precedence fixes. + + * [if1632/gdi.spec] [objects/bitblt.c] + Stub for FastWindowFrame (parameters not correct). + +Sat Aug 19 01:31:23 1995 Graham Menhennitt + + * [loader/ne_image.c] + Preliminary support for iterated segments. + +Sat Aug 19 00:43:04 1995 Andrew Taylor (andrew@riscan.com) + + * [windows/mapping.c] + In function MAPPING_FixIsotropic(), VportExt[XY] is multiplied by + the absolute value of (ydim / xdim) or (xdim / ydim). + +Thu Aug 15 23:00:16 Gregory Trubetskoy + + * [objects/oembitmap.c] + Added some includes for Windows 95. + + * [include/sysmetrics.h] + Added some sysmetrics for Windows 95. + + * [include/bitmaps/*95] + New files: obm_close_95, obm_closed_95, obm_reduce_95, obm_reduced_95 + obm_zoom_95, obm_zoomd_95 - these are some pixmaps for Windows 95. + +Thu Aug 10 12:00:00 1995 Jan Willamowius (jan@janhh.shnet.org) + + * [misc/shell.c] [rc/sysres*.rc] + The caption of the ShellAbout dialog box is language specific and + should be defined in the resources. + ---------------------------------------------------------------------- Thu Aug 17 19:30:14 1995 Alexandre Julliard diff --git a/Configure b/Configure index 9a9435a9dc0..7e7f4a0a592 100644 --- a/Configure +++ b/Configure @@ -49,6 +49,12 @@ do done ALLDEFINES="$ALLDEFINES -ALANG\($LANGUAGE\)" +prompt "Inter-process communication" CONFIG_IPC N +if [ CONFIG_IPC = 'Y' -o $CONFIG_IPC = 'y' ] +then + ALLDEFINES="$ALLDEFINES -DCONFIG_IPC" +fi + prompt "Malloc debugging" MALLOC_DEBUGGING N if [ MALLOC_DEBUGGING = 'Y' -o $MALLOC_DEBUGGING = 'y' ] then diff --git a/Imakefile b/Imakefile index 5488945df88..47ffac606e4 100644 --- a/Imakefile +++ b/Imakefile @@ -3,7 +3,6 @@ #if defined(i386FreeBsd) || defined(FreeBSDArchitecture) MAKE = gmake -CC = gcc -D__FreeBSD__ #endif DEFINES = AutoDefines -DUSE_READLINE diff --git a/Makefile.in b/Makefile.in index 59cd6cb20a8..fd71192a537 100644 --- a/Makefile.in +++ b/Makefile.in @@ -12,6 +12,7 @@ CC = @CC@ CFLAGS = @CFLAGS@ +DEFS = @DEFS@ XINCL = @x_includes@ TOPSRC = @top_srcdir@ DIVINCL = -I$(TOPSRC)/include @@ -22,7 +23,7 @@ LDLIBS = -lm LD = @LD@ LANG = @LANG@ LDCOMBINEFLAGS = @LDCOMBINEFLAGS@ - +@SET_MAKE@ COMMONSUBDIRS = controls rc ipc loader misc multimedia objects windows @@ -53,7 +54,7 @@ wine: $(SUBDIRS) dummy $(CC) -o wine $(OBJS) $(LDOPTIONS) $(XDIR) $(XPM_LIB) $(XLIB) $(LDLIBS) $(SUBDIRS): dummy - @cd $@; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'LD=$(LD)' 'LDCOMBINEFLAGS=$(LDCOMBINEFLAGS)' 'LANG=$(LANG)' + @cd $@; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'DEFS=$(DEFS)' 'LD=$(LD)' 'LDCOMBINEFLAGS=$(LDCOMBINEFLAGS)' 'LANG=$(LANG)' depend: for i in $(SUBDIRS); do (cd $$i; $(MAKE) depend); done @@ -63,14 +64,14 @@ etags: clean: for i in $(SUBDIRS); do (cd $$i; $(MAKE) clean); done - rm -f *.o \#*\# *~ wine wine.sym TAGS + rm -f *.o \#*\# *~ *.bak wine wine.sym TAGS distclean: for i in $(SUBDIRS); do (cd $$i; $(MAKE) distclean); done echo "/* autoconf.h generated automatically. Run Configure */" >autoconf.h echo "#error You must run Configure before you can build the makefiles." >>autoconf.h - rm -f *.o \#*\# *~ wine wine.sym - rm -f stamp-config config.* include/config.h Makefile + rm -f *.o \#*\# *~ *.bak wine wine.sym TAGS + rm -f config.* include/config.h Makefile countryclean: for i in $(SUBDIRS); do (cd $$i; $(MAKE) countryclean); done diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 85028b1035c..ee927be04b9 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -12,16 +12,19 @@ realises the problem later on. 'make' again and watch the output. Be sure to analyze the problem before you report it to the newsgroup. 2. What are these questions in Configure? -Emulator/Library: You need an emulator when you want to run MS-Win -binaries. You need a library when you want to compile the source code -of a Windows program. -Language: Wine can present the system menu in multiple languages. Select -one of English, German, or Norwegian here. -Malloc debugging: When enabled, the mtrace and mcheck GNU libc functions -are called. You might want to set the MALLOC_TRACE environment variable -to a trace file name. If your system supports another way of malloc -debugging, feel free to add it. -Config file: Sets the Wine environment. See README for details. +- Emulator/Library: You need an emulator when you want to run MS-Win + binaries. You need a library when you want to compile the source code + of a Windows program. +- Language: Wine can present the system menu in multiple languages. Select + one of English, German, or Norwegian here. +- Inter-process communication: Allows setting up a DDE conversation + between different instances of Wine. Only really useful when + building Wine as a library. +- Malloc debugging: When enabled, the mtrace and mcheck GNU libc functions + are called. You might want to set the MALLOC_TRACE environment variable + to a trace file name. If your system supports another way of malloc + debugging, feel free to add it. +- Config file: Sets the Wine environment. See README for details. 3. BAR.EXE used to work, but does not work anymore Look at the ChangeLog to see what files have been changed. Try to undo diff --git a/configure b/configure index f495a92c155..3b8d7dae928 100755 --- a/configure +++ b/configure @@ -12,6 +12,12 @@ ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: +ac_help="$ac_help + --with-language=LANG change the default language (LANG=En/De/No)" +ac_help="$ac_help + --with-ipc use inter-process communication for DDE" +ac_help="$ac_help + --with-malloc-debug enable malloc() debugging" ac_help="$ac_help --with-x use the X Window System" @@ -402,11 +408,38 @@ fi - # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS="-g -O2 -Wall" test -z "$LDFLAGS" && LDFLAGS=-g +# Check whether --with-language or --without-language was given. +withval="$with_language" +if test -n "$withval"; then + LANG="-ALANG\($withval\)" +else + LANG="-ALANG\(En\)" +fi + + +# Check whether --with-ipc or --without-ipc was given. +withval="$with_ipc" +if test -n "$withval"; then + cat >> confdefs.h <<\EOF +#define CONFIG_IPC 1 +EOF + +fi + +# Check whether --with-malloc-debug or --without-malloc-debug was given. +withval="$with_malloc_debug" +if test -n "$withval"; then + cat >> confdefs.h <<\EOF +#define MALLOC_DEBUGGING 1 +EOF + +fi + + echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 set dummy ${MAKE-make}; ac_make=$2 if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then @@ -521,7 +554,7 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error @@ -535,7 +568,7 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error @@ -621,7 +654,7 @@ test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h cat > conftest.$ac_ext < EOF @@ -684,7 +717,7 @@ rm -f conftest* ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext < conftest.$ac_ext <&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext < EOF @@ -971,122 +1004,12 @@ else fi done -ac_header_dirent=no -for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h -do -ac_safe=`echo "$ac_hdr" | tr './\055' '___'` -echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -#include <$ac_hdr> -int main() { return 0; } -int t() { -DIR *dirp = 0; -; return 0; } -EOF -if eval $ac_compile; then - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=yes" -else - rm -rf conftest* - eval "ac_cv_header_dirent_$ac_safe=no" -fi -rm -f conftest* - -fi -if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` - cat >> confdefs.h <&6 -fi -done -# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. -if test $ac_header_dirent = dirent.h; then -echo $ac_n "checking for -ldir""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_lib_dir'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-ldir $LIBS" -cat > conftest.$ac_ext <&6 - LIBS="$LIBS -ldir" -else - echo "$ac_t""no" 1>&6 -fi - -else -echo $ac_n "checking for -lx""... $ac_c" 1>&6 -if eval "test \"`echo '$''{'ac_cv_lib_x'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - ac_save_LIBS="$LIBS" -LIBS="-lx $LIBS" -cat > conftest.$ac_ext <&6 - LIBS="$LIBS -lx" -else - echo "$ac_t""no" 1>&6 -fi - -fi - echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6 if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1140,7 +1063,7 @@ if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < conftest.$ac_ext <&6 else cat > conftest.$ac_ext < #include @@ -1260,7 +1183,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1278,7 +1201,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1299,7 +1222,7 @@ if test "$cross_compiling" = yes; then ac_cv_header_stdc=no else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1333,7 +1256,7 @@ if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1364,82 +1287,6 @@ if test -z "${top_srcdir}"; then TOP_SRCDIR="." else TOP_SRCDIR="${top_srcdir}" -fi -echo $ac_n "checking for language in autoconf.h""... $ac_c" 1>&6 -if test -f ${TOP_SRCDIR}/autoconf.h; then -LANG=`tr ' ' '\n' < ${TOP_SRCDIR}/autoconf.h | grep '\-ALANG' | head -1` -if test -n "${LANG}"; then -echo "$ac_t""`echo "${LANG}" | cut -b9-10`" 1>&6 -fi -fi -if test -z "${LANG}"; then -echo "$ac_t""no" 1>&6 -fi - - -if test -z "${LANG}"; then -echo $ac_n "checking for language through domainname""... $ac_c" 1>&6 -DNAME=`domainname` -if test `echo "${DNAME}" | grep -c "\.no"` -ne 0; then -LANG="-ALANG\(No\)" -echo "$ac_t""No" 1>&6 -fi -if test `echo "${DNAME}" | grep -c "\.de"` -ne 0; then -LANG="-ALANG\(De\)" -echo "$ac_t""De" 1>&6 -fi -if test `echo "${DNAME}" | grep -c "\.uk"` -ne 0; then -LANG="-ALANG\(En\)" -echo "$ac_t""En" 1>&6 -fi -if test `echo "${DNAME}" | grep -c "\.com"` -ne 0; then -LANG="-ALANG\(En\)" -echo "$ac_t""En" 1>&6 -fi -if test `echo "${DNAME}" | grep -c "\.edu"` -ne 0; then -LANG="-ALANG\(En\)" -echo "$ac_t""En" 1>&6 -fi -if test `echo "${DNAME}" | grep -c "\.gov"` -ne 0; then -LANG="-ALANG\(En\)" -echo "$ac_t""En" 1>&6 -fi -if test -z "${LANG}"; then -echo "$ac_t""no" 1>&6 -fi -fi - -if test -z "${LANG}"; then -echo $ac_n "checking for linux""... $ac_c" 1>&6 -cat > conftest.$ac_ext <&5 | - egrep "yes" >/dev/null 2>&1; then - rm -rf conftest* - echo "$ac_t""yes" 1>&6 -echo $ac_n "checking for language by examining keymap""... $ac_c" 1>&6 -if test `dumpkeys | grep "keycode *26" | tr ' ' '\n' | grep -c udiaeresis` -ne 0; then -echo "$ac_t""De" 1>&6 -LANG='-ALANG\(De\)' -else -echo "$ac_t""no" 1>&6 -LANG='-ALANG\(En\)' -fi - -else - rm -rf conftest* - echo "$ac_t""no" 1>&6 -LANG='-ALANG\(En\)' - -fi -rm -f conftest* - fi echo $ac_n "checking for wine.ini in autoconf.h""... $ac_c" 1>&6 @@ -1518,7 +1365,19 @@ fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 -DEFS=-DHAVE_CONFIG_H +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} @@ -1555,7 +1414,7 @@ done ac_given_srcdir=$srcdir -trap 'rm -fr `echo "controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile Makefile autoconf.h include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +trap 'rm -fr `echo "controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile Makefile autoconf.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 # Protect against being on the right side of a sed subst in config.status. sed 's/%@/@@/; s/@%/@@/; s/%g$/@g/; /@g$/s/[\\\\&%]/\\\\&/g; @@ -1571,6 +1430,7 @@ s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g +s%@LANG@%$LANG%g s%@SET_MAKE@%$SET_MAKE%g s%@CC@%$CC%g s%@CPP@%$CPP%g @@ -1583,7 +1443,6 @@ s%@x_libraries@%$x_libraries%g s%@LIBOBJS@%$LIBOBJS%g s%@LD@%$LD%g s%@LDCOMBINEFLAGS@%$LDCOMBINEFLAGS%g -s%@LANG@%$LANG%g s%@WINE_INI_GLOBAL@%$WINE_INI_GLOBAL%g CEOF @@ -1641,104 +1500,8 @@ s%@top_srcdir@%$top_srcdir%g fi; done rm -f conftest.subs -# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where -# NAME is the cpp macro being defined and VALUE is the value it is being given. -# -# ac_d sets the value in "#define NAME VALUE" lines. -ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' -ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' -ac_dC='\3' -ac_dD='%g' -# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". -ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_uB='\([ ]\)%\1#\2define\3' -ac_uC=' ' -ac_uD='\4%g' -# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". -ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' -ac_eB='$%\1#\2define\3' -ac_eC=' ' -ac_eD='%g' - -CONFIG_HEADERS=${CONFIG_HEADERS-"include/config.h"} -for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then - # Support "outfile[:infile]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%.*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - echo creating $ac_file - - rm -f conftest.frag conftest.in conftest.out - cp $ac_given_srcdir/$ac_file_in conftest.in - -EOF - -# Transform confdefs.h into a sed script conftest.vals that substitutes -# the proper values into config.h.in to produce config.h. And first: -# Protect against being on the right side of a sed subst in config.status. -# Protect against being in an unquoted here document in config.status. -rm -f conftest.vals -cat > conftest.hdr <<\EOF -s/[\\&%]/\\&/g -s%[\\$`]%\\&%g -s%#define \([A-Za-z_][A-Za-z0-9_]*\) \(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp -s%ac_d%ac_u%gp -s%ac_u%ac_e%gp -EOF -sed -n -f conftest.hdr confdefs.h > conftest.vals -rm -f conftest.hdr - -# This sed command replaces #undef with comments. This is necessary, for -# example, in the case of _POSIX_SOURCE, which is predefined and required -# on some systems where configure will not decide to define it. -cat >> conftest.vals <<\EOF -s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% -EOF - -# Break up conftest.vals because some shells have a limit on -# the size of here documents, and old seds have small limits too. -# Maximum number of lines to put in a single here document. -ac_max_here_lines=12 - -rm -f conftest.tail -while : -do - ac_lines=`grep -c . conftest.vals` - # grep -c gives empty output for an empty file on some AIX systems. - if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi - # Write a limited-size here document to conftest.frag. - echo ' cat > conftest.frag <> $CONFIG_STATUS - sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS - echo 'CEOF - sed -f conftest.frag conftest.in > conftest.out - rm -f conftest.in - mv conftest.out conftest.in -' >> $CONFIG_STATUS - sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail - rm -f conftest.vals - mv conftest.tail conftest.vals -done -rm -f conftest.vals - -cat >> $CONFIG_STATUS <<\EOF - rm -f conftest.frag conftest.h - echo "/* $ac_file. Generated automatically by configure. */" > conftest.h - cat conftest.in >> conftest.h - rm -f conftest.in - if cmp -s $ac_file conftest.h 2>/dev/null; then - echo "$ac_file is unchanged" - rm -f conftest.h - else - rm -f $ac_file - mv conftest.h $ac_file - fi -fi; done -touch stamp-config exit 0 EOF chmod +x $CONFIG_STATUS diff --git a/configure.in b/configure.in index eded50a35cd..71aac5c451d 100644 --- a/configure.in +++ b/configure.in @@ -3,12 +3,23 @@ dnl Author: Michael Patra dnl AC_REVISION([configure.in 1.00]) AC_INIT(controls/edit.c) -AC_CONFIG_HEADER(include/config.h) # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS="-g -O2 -Wall" AC_SUBST(CFLAGS) test -z "$LDFLAGS" && LDFLAGS=-g AC_SUBST(LDFLAGS) +AC_ARG_WITH(language, +[ --with-language=LANG change the default language (LANG=En/De/No)], +[LANG="-ALANG\($withval\)"], +[LANG="-ALANG\(En\)"],) +AC_SUBST(LANG) +AC_ARG_WITH(ipc, +[ --with-ipc use inter-process communication for DDE], +[AC_DEFINE(CONFIG_IPC)]) +AC_ARG_WITH(malloc-debug, +[ --with-malloc-debug enable malloc() debugging], +[AC_DEFINE(MALLOC_DEBUGGING)]) + AC_PROG_MAKE_SET AC_PROG_CC AC_PATH_X @@ -41,70 +52,6 @@ TOP_SRCDIR="." else TOP_SRCDIR="${top_srcdir}" fi -AC_MSG_CHECKING(for language in autoconf.h) -if test -f ${TOP_SRCDIR}/autoconf.h; then -LANG=`tr ' ' '\n' < ${TOP_SRCDIR}/autoconf.h | grep '\-ALANG' | head -1` -if test -n "${LANG}"; then -AC_MSG_RESULT(`echo "${LANG}" | cut -b9-10`) -fi -fi -if test -z "${LANG}"; then -AC_MSG_RESULT(no) -fi -AC_SUBST(LANG) - -if test -z "${LANG}"; then -AC_MSG_CHECKING(for language through domainname) -DNAME=`domainname` -if test `echo "${DNAME}" | grep -c "\.no"` -ne 0; then -LANG="-ALANG\(No\)" -AC_MSG_RESULT(No) -fi -if test `echo "${DNAME}" | grep -c "\.de"` -ne 0; then -LANG="-ALANG\(De\)" -AC_MSG_RESULT(De) -fi -if test `echo "${DNAME}" | grep -c "\.uk"` -ne 0; then -LANG="-ALANG\(En\)" -AC_MSG_RESULT(En) -fi -if test `echo "${DNAME}" | grep -c "\.com"` -ne 0; then -LANG="-ALANG\(En\)" -AC_MSG_RESULT(En) -fi -if test `echo "${DNAME}" | grep -c "\.edu"` -ne 0; then -LANG="-ALANG\(En\)" -AC_MSG_RESULT(En) -fi -if test `echo "${DNAME}" | grep -c "\.gov"` -ne 0; then -LANG="-ALANG\(En\)" -AC_MSG_RESULT(En) -fi -if test -z "${LANG}"; then -AC_MSG_RESULT(no) -fi -fi - -if test -z "${LANG}"; then -AC_MSG_CHECKING(for linux) -AC_EGREP_CPP(yes, -[#ifdef linux - yes -#endif -], AC_MSG_RESULT(yes) -AC_MSG_CHECKING(for language by examining keymap) -if test `dumpkeys | grep "keycode *26" | tr ' ' '\n' | grep -c udiaeresis` -ne 0; then -AC_MSG_RESULT(De) -LANG='-ALANG\(De\)' -else -AC_MSG_RESULT(no) -LANG='-ALANG\(En\)' -fi -, -AC_MSG_RESULT(no) -LANG='-ALANG\(En\)' -) -fi AC_MSG_CHECKING(for wine.ini in autoconf.h) if test -f ${TOP_SRCDIR}/autoconf.h; then @@ -129,11 +76,7 @@ fi fi AC_SUBST(WINE_INI_GLOBAL) - -test -z "$LDFLAGS" && LDFLAGS=-g AC_SUBST(LDFLAGS) - - -AC_OUTPUT(controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile Makefile autoconf.h, [touch stamp-config]) +AC_OUTPUT(controls/Makefile ipc/Makefile loader/Makefile memory/Makefile misc/Makefile miscemu/Makefile multimedia/Makefile objects/Makefile windows/Makefile rc/Makefile debugger/Makefile debugger/readline/Makefile tools/Makefile if1632/Makefile Makefile autoconf.h) echo echo "Configure finished. Do 'make depend; make' to compile Wine." diff --git a/controls/Makefile.in b/controls/Makefile.in index 9aa20c7e840..02cbb3be369 100644 --- a/controls/Makefile.in +++ b/controls/Makefile.in @@ -27,7 +27,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/controls/button.c b/controls/button.c index 9e29e543b2a..b33900afaf0 100644 --- a/controls/button.c +++ b/controls/button.c @@ -261,7 +261,6 @@ static void PB_Paint( HWND hButton, HDC hDC, WORD action ) HBRUSH hOldBrush; char *text; DWORD dwTextSize; - int delta; TEXTMETRIC tm; WND *wndPtr = WIN_FindWndPtr( hButton ); BUTTONINFO *infoPtr = (BUTTONINFO *)wndPtr->wExtra; diff --git a/controls/menu.c b/controls/menu.c index 88c4c150890..598de3adc35 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -697,7 +697,7 @@ static BOOL MENU_ShowPopup(HWND hwndOwner, HMENU hmenu, WORD id, int x, int y) /*********************************************************************** * MENU_SelectItem */ -static void MENU_SelectItem( HMENU hmenu, WORD wIndex ) +static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, WORD wIndex ) { MENUITEM *items; LPPOPUPMENU lppop; @@ -739,8 +739,9 @@ static void MENU_SelectItem( HMENU hmenu, WORD wIndex ) MENU_DrawMenuItem( lppop->hWnd, hdc, &items[lppop->FocusedItem], lppop->Height, !(lppop->wFlags & MF_POPUP) ); dprintf_menu(stddeb,"Sending WM_MENUSELECT %04x %04x\n", items[lppop->FocusedItem].item_id,items[lppop->FocusedItem].item_flags); - SendMessage(lppop->hWnd, WM_MENUSELECT, items[lppop->FocusedItem].item_id, - MAKELONG( items[lppop->FocusedItem].item_flags | MF_MOUSESELECT, hmenu)); + SendMessage( hwndOwner, WM_MENUSELECT, + items[lppop->FocusedItem].item_id, + MAKELONG( items[lppop->FocusedItem].item_flags | MF_MOUSESELECT, hmenu)); } } ReleaseDC( lppop->hWnd, hdc ); @@ -750,7 +751,7 @@ static void MENU_SelectItem( HMENU hmenu, WORD wIndex ) /*********************************************************************** * MENU_SelectNextItem */ -static void MENU_SelectNextItem( HMENU hmenu ) +static void MENU_SelectNextItem( HWND hwndOwner, HMENU hmenu ) { int i; MENUITEM *items; @@ -766,13 +767,13 @@ static void MENU_SelectNextItem( HMENU hmenu ) { if (!(items[i].item_flags & MF_SEPARATOR)) { - MENU_SelectItem( hmenu, i ); + MENU_SelectItem( hwndOwner, hmenu, i ); return; } } if (MENU_HasSysMenu( menu )) { - MENU_SelectItem( hmenu, SYSMENU_SELECTED ); + MENU_SelectItem( hwndOwner, hmenu, SYSMENU_SELECTED ); return; } } @@ -780,18 +781,19 @@ static void MENU_SelectNextItem( HMENU hmenu ) { if (!(items[i].item_flags & MF_SEPARATOR)) { - MENU_SelectItem( hmenu, i ); + MENU_SelectItem( hwndOwner, hmenu, i ); return; } } - if (MENU_HasSysMenu( menu )) MENU_SelectItem( hmenu, SYSMENU_SELECTED ); + if (MENU_HasSysMenu( menu )) + MENU_SelectItem( hwndOwner, hmenu, SYSMENU_SELECTED ); } /*********************************************************************** * MENU_SelectPrevItem */ -static void MENU_SelectPrevItem( HMENU hmenu ) +static void MENU_SelectPrevItem( HWND hwndOwner, HMENU hmenu ) { int i; MENUITEM *items; @@ -807,13 +809,13 @@ static void MENU_SelectPrevItem( HMENU hmenu ) { if (!(items[i].item_flags & MF_SEPARATOR)) { - MENU_SelectItem( hmenu, i ); + MENU_SelectItem( hwndOwner, hmenu, i ); return; } } if (MENU_HasSysMenu( menu )) { - MENU_SelectItem( hmenu, SYSMENU_SELECTED ); + MENU_SelectItem( hwndOwner, hmenu, SYSMENU_SELECTED ); return; } } @@ -821,11 +823,12 @@ static void MENU_SelectPrevItem( HMENU hmenu ) { if (!(items[i].item_flags & MF_SEPARATOR)) { - MENU_SelectItem( hmenu, i ); + MENU_SelectItem( hwndOwner, hmenu, i ); return; } } - if (MENU_HasSysMenu( menu )) MENU_SelectItem( hmenu, SYSMENU_SELECTED ); + if (MENU_HasSysMenu( menu )) + MENU_SelectItem( hwndOwner, hmenu, SYSMENU_SELECTED ); } @@ -856,7 +859,7 @@ static HMENU MENU_GetSubPopup( HMENU hmenu ) * * Hide the sub-popup menus of this menu. */ -static void MENU_HideSubPopups( HMENU hmenu ) +static void MENU_HideSubPopups( HWND hwndOwner, HMENU hmenu ) { MENUITEM *item; POPUPMENU *menu, *submenu; @@ -877,9 +880,9 @@ static void MENU_HideSubPopups( HMENU hmenu ) hsubmenu = item->item_id; } submenu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hsubmenu ); - MENU_HideSubPopups( hsubmenu ); + MENU_HideSubPopups( hwndOwner, hsubmenu ); if (submenu->hWnd) ShowWindow( submenu->hWnd, SW_HIDE ); - MENU_SelectItem( hsubmenu, NO_SELECTED_ITEM ); + MENU_SelectItem( hwndOwner, hsubmenu, NO_SELECTED_ITEM ); } @@ -902,7 +905,7 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, BOOL selectFirst ) { MENU_ShowPopup(hwndOwner, wndPtr->hSysMenu, 0, wndPtr->rectClient.left, wndPtr->rectClient.top - menu->Height - 2*SYSMETRICS_CYBORDER); - if (selectFirst) MENU_SelectNextItem( wndPtr->hSysMenu ); + if (selectFirst) MENU_SelectNextItem( hwndOwner, wndPtr->hSysMenu ); return wndPtr->hSysMenu; } item = ((MENUITEM *)USER_HEAP_LIN_ADDR(menu->hItems)) + menu->FocusedItem; @@ -921,7 +924,7 @@ static HMENU MENU_ShowSubPopup( HWND hwndOwner, HMENU hmenu, BOOL selectFirst ) wndPtr->rectWindow.left + item->rect.left, wndPtr->rectWindow.top + item->rect.bottom ); } - if (selectFirst) MENU_SelectNextItem( (HMENU)item->item_id ); + if (selectFirst) MENU_SelectNextItem( hwndOwner, (HMENU)item->item_id ); return (HMENU)item->item_id; } @@ -1027,7 +1030,7 @@ static BOOL MENU_ButtonDown( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, { if (menu->wFlags & MF_POPUP) { - MENU_HideSubPopups( hmenu ); + MENU_HideSubPopups( hwndOwner, hmenu ); *hmenuCurrent = hmenu; } else return FALSE; @@ -1037,8 +1040,8 @@ static BOOL MENU_ButtonDown( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, } else { - MENU_HideSubPopups( hmenu ); - MENU_SelectItem( hmenu, id ); + MENU_HideSubPopups( hwndOwner, hmenu ); + MENU_SelectItem( hwndOwner, hmenu, id ); *hmenuCurrent = MENU_ShowSubPopup( hwndOwner, hmenu, FALSE ); } return TRUE; @@ -1081,8 +1084,8 @@ static BOOL MENU_ButtonUp( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, hsubmenu = item->item_id; } /* Select first item of sub-popup */ - MENU_SelectItem( hsubmenu, NO_SELECTED_ITEM ); - MENU_SelectNextItem( hsubmenu ); + MENU_SelectItem( hwndOwner, hsubmenu, NO_SELECTED_ITEM ); + MENU_SelectNextItem( hwndOwner, hsubmenu ); return TRUE; } @@ -1113,12 +1116,12 @@ static BOOL MENU_MouseMove( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, } if (id == NO_SELECTED_ITEM) { - MENU_SelectItem( *hmenuCurrent, NO_SELECTED_ITEM ); + MENU_SelectItem( hwndOwner, *hmenuCurrent, NO_SELECTED_ITEM ); } else if (menu->FocusedItem != id) { - MENU_HideSubPopups( hmenu ); - MENU_SelectItem( hmenu, id ); + MENU_HideSubPopups( hwndOwner, hmenu ); + MENU_SelectItem( hwndOwner, hmenu, id ); *hmenuCurrent = MENU_ShowSubPopup( hwndOwner, hmenu, FALSE ); } return TRUE; @@ -1143,12 +1146,12 @@ static void MENU_KeyLeft( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent ) hmenutmp = MENU_GetSubPopup( hmenuprev ); if (hmenutmp != *hmenuCurrent) hmenuprev = hmenutmp; } - MENU_HideSubPopups( hmenuprev ); + MENU_HideSubPopups( hwndOwner, hmenuprev ); if ((hmenuprev == hmenu) && !(menu->wFlags & MF_POPUP)) { /* Select previous item on the menu bar */ - MENU_SelectPrevItem( hmenu ); + MENU_SelectPrevItem( hwndOwner, hmenu ); if (*hmenuCurrent != hmenu) { /* A popup menu was displayed -> display the next one */ @@ -1186,8 +1189,8 @@ static void MENU_KeyRight( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent ) /* If on menu-bar, go to next item */ if (!(menu->wFlags & MF_POPUP)) { - MENU_HideSubPopups( hmenu ); - MENU_SelectNextItem( hmenu ); + MENU_HideSubPopups( hwndOwner, hmenu ); + MENU_SelectNextItem( hwndOwner, hmenu ); if (*hmenuCurrent != hmenu) { /* A popup menu was displayed -> display the next one */ @@ -1203,7 +1206,7 @@ static void MENU_KeyRight( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent ) hmenutmp = MENU_GetSubPopup( hmenuprev ); if (hmenutmp != *hmenuCurrent) hmenuprev = hmenutmp; } - MENU_HideSubPopups( hmenuprev ); + MENU_HideSubPopups( hwndOwner, hmenuprev ); *hmenuCurrent = hmenuprev; } } @@ -1293,17 +1296,17 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, switch(msg->wParam) { case VK_HOME: - MENU_SelectItem( hmenuCurrent, NO_SELECTED_ITEM ); - MENU_SelectNextItem( hmenuCurrent ); + MENU_SelectItem( hwnd, hmenuCurrent, NO_SELECTED_ITEM ); + MENU_SelectNextItem( hwnd, hmenuCurrent ); break; case VK_END: - MENU_SelectItem( hmenuCurrent, NO_SELECTED_ITEM ); - MENU_SelectPrevItem( hmenuCurrent ); + MENU_SelectItem( hwnd, hmenuCurrent, NO_SELECTED_ITEM ); + MENU_SelectPrevItem( hwnd, hmenuCurrent ); break; case VK_UP: - MENU_SelectPrevItem( hmenuCurrent ); + MENU_SelectPrevItem( hwnd, hmenuCurrent ); break; case VK_DOWN: @@ -1311,7 +1314,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, if (!(menu->wFlags & MF_POPUP) && (hmenuCurrent == hmenu)) hmenuCurrent = MENU_ShowSubPopup( hwnd, hmenu, TRUE ); else - MENU_SelectNextItem( hmenuCurrent ); + MENU_SelectNextItem( hwnd, hmenuCurrent ); break; case VK_LEFT: @@ -1357,7 +1360,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, else if (pos == (WORD)-1) MessageBeep(0); else { - MENU_SelectItem( hmenuCurrent, pos ); + MENU_SelectItem( hwnd, hmenuCurrent, pos ); fClosed = !MENU_ExecFocusedItem( hwnd, hmenuCurrent, &hmenuCurrent ); @@ -1378,9 +1381,10 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, } USER_HEAP_FREE( hMsg ); ReleaseCapture(); - MENU_HideSubPopups( hmenu ); + MENU_HideSubPopups( hwnd, hmenu ); if (menu->wFlags & MF_POPUP) ShowWindow( menu->hWnd, SW_HIDE ); - MENU_SelectItem( hmenu, NO_SELECTED_ITEM ); + MENU_SelectItem( hwnd, hmenu, NO_SELECTED_ITEM ); + SendMessage( hwnd, WM_MENUSELECT, 0, MAKELONG( 0xffff, 0 ) ); fEndMenuCalled = FALSE; return TRUE; } @@ -1412,8 +1416,8 @@ void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam ) if (!wndPtr->wIDmenu) return; SendMessage( hwnd, WM_ENTERMENULOOP, 0, 0 ); /* Select first selectable item */ - MENU_SelectItem( wndPtr->wIDmenu, NO_SELECTED_ITEM ); - MENU_SelectNextItem( (HMENU)wndPtr->wIDmenu ); + MENU_SelectItem( hwnd, wndPtr->wIDmenu, NO_SELECTED_ITEM ); + MENU_SelectNextItem( hwnd, (HMENU)wndPtr->wIDmenu ); MENU_TrackMenu( (HMENU)wndPtr->wIDmenu, TPM_LEFTALIGN | TPM_LEFTBUTTON, 0, 0, hwnd, NULL ); SendMessage( hwnd, WM_EXITMENULOOP, 0, 0 ); @@ -1595,8 +1599,8 @@ BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, WORD wItemID, WORD wHilite) if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wHilite ))) return FALSE; if (!(menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) return FALSE; if (menu->FocusedItem == wItemID) return TRUE; - MENU_HideSubPopups( hMenu ); - MENU_SelectItem( hMenu, wItemID ); + MENU_HideSubPopups( hWnd, hMenu ); + MENU_SelectItem( hWnd, hMenu, wItemID ); return TRUE; } @@ -1957,16 +1961,13 @@ BOOL DestroyMenu(HMENU hMenu) */ HMENU GetSystemMenu(HWND hWnd, BOOL bRevert) { - WND *wndPtr; - wndPtr = WIN_FindWndPtr(hWnd); - if (!bRevert) { - return wndPtr->hSysMenu; - } - else { - DestroyMenu(wndPtr->hSysMenu); - wndPtr->hSysMenu = CopySysMenu(); - } - return wndPtr->hSysMenu; + WND *wndPtr = WIN_FindWndPtr( hWnd ); + if (!wndPtr) return 0; + + if (!bRevert) return wndPtr->hSysMenu; + DestroyMenu(wndPtr->hSysMenu); + wndPtr->hSysMenu = CopySysMenu(); + return wndPtr->hSysMenu; } /********************************************************************** diff --git a/debugger/Makefile.in b/debugger/Makefile.in index ed50f1b08ca..75b031667c5 100644 --- a/debugger/Makefile.in +++ b/debugger/Makefile.in @@ -41,11 +41,12 @@ depend: clean: (cd readline; $(MAKE) clean) - rm -f *.o \#*\# *~ dbg.tab.c dbg.tab.h lex.yy.c y.tab.c y.tab.h tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make + rm -f dbg.tab.c dbg.tab.h lex.yy.c y.tab.c y.tab.h distclean: (cd readline; $(MAKE) distclean) - rm -f *.o \#*\# *~ dbg.tab.c dbg.tab.h lex.yy.c y.tab.c y.tab.h tmp_make Makefile + rm -f *.o \#*\# *~ *.bak dbg.tab.c dbg.tab.h lex.yy.c y.tab.c y.tab.h tmp_make Makefile countryclean: diff --git a/debugger/break.c b/debugger/break.c index b237ce07631..4406b2fdd6e 100644 --- a/debugger/break.c +++ b/debugger/break.c @@ -65,6 +65,71 @@ static void DEBUG_SetOpcode( const DBG_ADDR *addr, BYTE op ) } +/*********************************************************************** + * DEBUG_IsStepOverInstr + * + * Determine if the instruction at CS:EIP is an instruction that + * we need to step over (like a call or a repetitive string move). + */ +static BOOL DEBUG_IsStepOverInstr( struct sigcontext_struct *context ) +{ + BYTE *instr = (BYTE *)PTR_SEG_OFF_TO_LIN(CS_reg(context),EIP_reg(context)); + + for (;;) + { + switch(*instr) + { + /* Skip all prefixes */ + + case 0x2e: /* cs: */ + case 0x36: /* ss: */ + case 0x3e: /* ds: */ + case 0x26: /* es: */ + case 0x64: /* fs: */ + case 0x65: /* gs: */ + case 0x66: /* opcode size prefix */ + case 0x67: /* addr size prefix */ + case 0xf0: /* lock */ + case 0xf2: /* repne */ + case 0xf3: /* repe */ + instr++; + continue; + + /* Handle call instructions */ + + case 0xe8: /* call */ + case 0x9a: /* lcall : */ + return TRUE; + + case 0xff: /* call */ + return (((instr[1] & 0x38) == 0x10) || + ((instr[1] & 0x38) == 0x18)); + + /* Handle string instructions */ + + case 0x6c: /* insb */ + case 0x6d: /* insw */ + case 0x6e: /* outsb */ + case 0x6f: /* outsw */ + case 0xa4: /* movsb */ + case 0xa5: /* movsw */ + case 0xa6: /* cmpsb */ + case 0xa7: /* cmpsw */ + case 0xaa: /* stosb */ + case 0xab: /* stosw */ + case 0xac: /* lodsb */ + case 0xad: /* lodsw */ + case 0xae: /* scasb */ + case 0xaf: /* scasw */ + return TRUE; + + default: + return FALSE; + } + } +} + + /*********************************************************************** * DEBUG_SetBreakpoints * @@ -257,14 +322,18 @@ void DEBUG_RestartExecution( struct sigcontext_struct *context, break; case EXEC_STEP_OVER: /* Stepping over a call */ - EFL_reg(DEBUG_context) &= ~STEP_FLAG; - addr.off += instr_len; - breakpoints[0].addr = addr; - breakpoints[0].enabled = TRUE; - breakpoints[0].in_use = TRUE; - breakpoints[0].opcode = *(BYTE *)DBG_ADDR_TO_LIN( &addr ); - DEBUG_SetBreakpoints( TRUE ); - break; + if (DEBUG_IsStepOverInstr(DEBUG_context)) + { + EFL_reg(DEBUG_context) &= ~STEP_FLAG; + addr.off += instr_len; + breakpoints[0].addr = addr; + breakpoints[0].enabled = TRUE; + breakpoints[0].in_use = TRUE; + breakpoints[0].opcode = *(BYTE *)DBG_ADDR_TO_LIN( &addr ); + DEBUG_SetBreakpoints( TRUE ); + break; + } + /* else fall through to single-stepping */ case EXEC_STEP_INSTR: /* Single-stepping an instruction */ EFL_reg(DEBUG_context) |= STEP_FLAG; diff --git a/debugger/memory.c b/debugger/memory.c index 80dfcd336cd..206e587f0ef 100644 --- a/debugger/memory.c +++ b/debugger/memory.c @@ -115,7 +115,7 @@ void DEBUG_ExamineMemory( const DBG_ADDR *address, int count, char format ) { fprintf(stderr," %04x", *wdump++); addr.off += 2; - if ((i % 10) == 7) { + if ((i % 8) == 7) { fprintf(stderr,"\n"); DEBUG_PrintAddress( &addr, dbg_mode ); fprintf(stderr,": "); @@ -133,7 +133,7 @@ void DEBUG_ExamineMemory( const DBG_ADDR *address, int count, char format ) } else fprintf(stderr," %c", *pnt++); addr.off++; - if ((i % 32) == 7) { + if ((i % 32) == 31) { fprintf(stderr,"\n"); DEBUG_PrintAddress( &addr, dbg_mode ); fprintf(stderr,": "); @@ -147,7 +147,7 @@ void DEBUG_ExamineMemory( const DBG_ADDR *address, int count, char format ) { fprintf(stderr," %02x", (*pnt++) & 0xff); addr.off++; - if ((i % 32) == 7) { + if ((i % 16) == 15) { fprintf(stderr,"\n"); DEBUG_PrintAddress( &addr, dbg_mode ); fprintf(stderr,": "); diff --git a/debugger/readline/Makefile.in b/debugger/readline/Makefile.in index 5f327535f07..873f3d2d310 100644 --- a/debugger/readline/Makefile.in +++ b/debugger/readline/Makefile.in @@ -1,11 +1,12 @@ CC = @CC@ CFLAGS = @CFLAGS@ +DEFS = @DEFS@ XINCL = @x_includes@ TOPSRC = @top_srcdir@ DIVINCL = -I$(TOPSRC)/include LD = @LD@ LDCOMBINEFLAGS = @LDCOMBINEFLAGS@ -DIVDEFS = @DEFS@ -DHIDE -DANSI_ARROWS +DIVDEFS = $(DEFS) -DHIDE -DANSI_ARROWS MODULE = readline @@ -28,7 +29,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/debugger/readline/sysunix.c b/debugger/readline/sysunix.c index fdc8d2d6050..010744e1c4a 100644 --- a/debugger/readline/sysunix.c +++ b/debugger/readline/sysunix.c @@ -4,10 +4,6 @@ */ #include "editline.h" -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #if defined(HAVE_TCGETATTR) #include diff --git a/if1632/Makefile.in b/if1632/Makefile.in index 225d5fba22d..4eab62c3dc5 100644 --- a/if1632/Makefile.in +++ b/if1632/Makefile.in @@ -24,7 +24,8 @@ DLLS32 = gdi32.spec kernel32.spec shell32.spec user32.spec winprocs32.spec OBJS = $(SRCS:.c=.o) $(DLLS16:.spec=.o) $(DLLS32:.spec=.o) call16.o call32.o -SFILES = $(DLLS16:.spec=.S) +SPEC16_FILES = $(DLLS16:.spec=.S) +SPEC32_FILES = $(DLLS32:.spec=.c) .SUFFIXES: .spec @@ -42,16 +43,16 @@ SFILES = $(DLLS16:.spec=.S) all: checkbuild $(MODULE).o -$(SFILES): $(TOPSRC)/tools/build +$(SPEC16_FILES) $(SPEC32_FILES): $(TOPSRC)/tools/build checkbuild: cd $(TOPSRC)/tools; $(MAKE) 'CC=$(CC)' 'CFLAGS=$(CFLAGS)' 'LD=$(LD)' 'LDCOMBINEFLAGS=$(LDCOMBINEFLAGS)' build -call16.S: $(TOPSRC)/include/callback.h - $(TOPSRC)/tools/build -call16 `cat $(TOPSRC)/include/callback.h | grep "extern.*CallTo16_" | sed 's/.*CallTo16_\(.*\)(.*/\1/' | sort | uniq` > call16.S +call16.S: $(TOPSRC)/include/callback.h $(BUILD) + $(BUILD) -call16 `cat $(TOPSRC)/include/callback.h | grep "extern.*CallTo16_" | sed 's/.*CallTo16_\(.*\)(.*/\1/' | sort | uniq` > call16.S -call32.S: $(SFILES) - $(BUILD) -call32 `cat $(SFILES) | grep CallTo32_ | sed 's/.*CallTo32_\(.*\)/\1/' | sort | uniq` > call32.S +call32.S: $(SPEC16_FILES) + $(BUILD) -call32 `cat $(SPEC16_FILES) | grep CallTo32_ | sed 's/.*CallTo32_\(.*\)/\1/' | sort | uniq` > call32.S $(MODULE).o: $(OBJS) $(LD) $(LDCOMBINEFLAGS) $(OBJS) -o $(MODULE).o @@ -62,7 +63,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make rm -f $(DLLS16:.spec=.S) $(DLLS32:.spec=.c) call32.S call16.S distclean: clean diff --git a/if1632/gdi.spec b/if1632/gdi.spec index 7b302ad3b45..784ad66aac9 100644 --- a/if1632/gdi.spec +++ b/if1632/gdi.spec @@ -245,7 +245,7 @@ id 3 380 stub ENDPAGE 381 stub SETABORTPROC 382 stub ABORTDOC -400 stub FASTWINDOWFRAME +400 pascal16 FastWindowFrame(word long word word long) FastWindowFrame 401 stub GDIMOVEBITMAP 403 stub GDIINIT2 405 stub FINALGDIINIT diff --git a/if1632/kernel.spec b/if1632/kernel.spec index a08132be349..78815bf4d7a 100644 --- a/if1632/kernel.spec +++ b/if1632/kernel.spec @@ -232,7 +232,7 @@ id 1 #351 BUNNY_351 353 pascal lstrcpyn(segptr segptr word) lstrcpyn 354 stub GetAppCompatFlags -355 stub GetWinDebugInfo -356 stub SetWinDebugInfo +355 pascal16 GetWinDebugInfo(ptr word) GetWinDebugInfo +356 pascal16 SetWinDebugInfo(ptr) SetWinDebugInfo 403 pascal16 FarSetOwner(word word) FarSetOwner 404 pascal16 FarGetOwner(word) FarGetOwner diff --git a/if1632/pop.h b/if1632/pop.h deleted file mode 100644 index 3694b33aaac..00000000000 --- a/if1632/pop.h +++ /dev/null @@ -1,18 +0,0 @@ - add $8,%esp - popw %es - add $2,%esp - popw %ds - add $2,%esp - popl %edi - popl %esi - popl %ebp - add $4,%esp - popl %ebx - popl %edx - popl %ecx - popl %eax - add $16,%esp - popl %gs:return_value - add $20,%esp - pushl %gs:return_value - popfl diff --git a/include/atom.h b/include/atom.h index 706b7094378..5988a5b42a4 100644 --- a/include/atom.h +++ b/include/atom.h @@ -25,10 +25,4 @@ typedef struct HANDLE entries[1]; } ATOMTABLE; - -ATOM LocalAddAtom( SEGPTR str ); -ATOM LocalDeleteAtom( ATOM atom ); -ATOM LocalFindAtom( SEGPTR str ); -WORD LocalGetAtomName( ATOM atom, LPSTR buffer, short count ); - #endif /* ATOM_H */ diff --git a/include/bitmaps/obm_close_95 b/include/bitmaps/obm_close_95 new file mode 100644 index 00000000000..eeb176047cf --- /dev/null +++ b/include/bitmaps/obm_close_95 @@ -0,0 +1,23 @@ +/* XPM */ +static char * obm_close_95[] = { +"16 14 6 1", +" s button_highlight c white", +"+ s button_edge c grey85", +"X s button_face c grey75", +"o s button_shadow c grey50", +". s button_text c black", +"O s window_frame c black", +" O", +" +++++++++++++oO", +" +XXXXXXXXXXXXoO", +" +XX..XXXX..XXoO", +" +XXX..XX..XXXoO", +" +XXXX....XXXXoO", +" +XXXXX..XXXXXoO", +" +XXXX....XXXXoO", +" +XXX..XX..XXXoO", +" +XX..XXXX..XXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" ooooooooooooooO", +"OOOOOOOOOOOOOOOO"}; diff --git a/include/bitmaps/obm_closed_95 b/include/bitmaps/obm_closed_95 new file mode 100644 index 00000000000..090e9d7060b --- /dev/null +++ b/include/bitmaps/obm_closed_95 @@ -0,0 +1,23 @@ +/* XPM */ +static char * obm_closed_95[] = { +"16 14 6 1", +" s button_highlight c white", +"+ s button_edge c grey85", +"X s button_face c grey75", +"o s button_shadow c grey50", +". s button_text c black", +"O s window_frame c black", +"OOOOOOOOOOOOOOO ", +"Oooooooooooooo+ ", +"OoXXXXXXXXXXXX+ ", +"OoXXXXXXXXXXXX+ ", +"OoXXX..XXXX..X+ ", +"OoXXXX..XX..XX+ ", +"OoXXXXX....XXX+ ", +"OoXXXXXX..XXXX+ ", +"OoXXXXX....XXX+ ", +"OoXXXX..XX..XX+ ", +"OoXXX..XXXX..X+ ", +"OoXXXXXXXXXXXX+ ", +"O++++++++++++++ ", +" "}; diff --git a/include/bitmaps/obm_reduce_95 b/include/bitmaps/obm_reduce_95 new file mode 100644 index 00000000000..b32531d5295 --- /dev/null +++ b/include/bitmaps/obm_reduce_95 @@ -0,0 +1,23 @@ +/* XPM */ +static char * obm_reduce_95[] = { +"16 14 6 1", +" s button_highlight c white", +"+ s button_edge c grey85", +"X s button_face c grey75", +"o s button_shadow c grey50", +". s button_text c black", +"O s window_frame c black", +" O", +" +++++++++++++oO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XX......XXXXoO", +" +XX......XXXXoO", +" +XXXXXXXXXXXXoO", +" ooooooooooooooO", +"OOOOOOOOOOOOOOOO"}; diff --git a/include/bitmaps/obm_reduced_95 b/include/bitmaps/obm_reduced_95 new file mode 100644 index 00000000000..4199248d32e --- /dev/null +++ b/include/bitmaps/obm_reduced_95 @@ -0,0 +1,23 @@ +/* XPM */ +static char * obm_reduced_95[] = { +"16 14 6 1", +"O s button_highlight c white", +"o s button_edge c grey85", +"X s button_face c grey75", +"+ s button_shadow c grey50", +". s button_text c black", +" s window_frame c black", +" ", +" +++++++++++++oO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXXXXXXXXXXXoO", +" +XXX......XXXoO", +" +XXX......XXXoO", +" ooooooooooooooO", +"OOOOOOOOOOOOOOOO"}; diff --git a/include/bitmaps/obm_zoom_95 b/include/bitmaps/obm_zoom_95 new file mode 100644 index 00000000000..81c937a7d9a --- /dev/null +++ b/include/bitmaps/obm_zoom_95 @@ -0,0 +1,23 @@ +/* XPM */ +static char * obm_zoom_95[] = { +"16 14 6 1", +" s button_highlight c white", +"+ s button_edge c grey85", +"X s button_face c grey75", +"o s button_shadow c grey50", +". s button_text c black", +"O s window_frame c black", +" O", +" +++++++++++++oO", +" +X.........XXoO", +" +X.........XXoO", +" +X.XXXXXXX.XXoO", +" +X.XXXXXXX.XXoO", +" +X.XXXXXXX.XXoO", +" +X.XXXXXXX.XXoO", +" +X.XXXXXXX.XXoO", +" +X.XXXXXXX.XXoO", +" +X.........XXoO", +" +XXXXXXXXXXXXoO", +" ooooooooooooooO", +"OOOOOOOOOOOOOOOO"}; diff --git a/include/bitmaps/obm_zoomd_95 b/include/bitmaps/obm_zoomd_95 new file mode 100644 index 00000000000..6a15a8c4e85 --- /dev/null +++ b/include/bitmaps/obm_zoomd_95 @@ -0,0 +1,23 @@ +/* XPM */ +static char * obm_zoomd_95[] = { +"16 14 6 1", +"O s button_highlight c white", +"o s button_edge c grey85", +"X s button_face c grey75", +"+ s button_shadow c grey50", +". s button_text c black", +" s window_frame c black", +" ", +" +++++++++++++oO", +" +XXXXXXXXXXXXoO", +" +XX.........XoO", +" +XX.........XoO", +" +XX.XXXXXXX.XoO", +" +XX.XXXXXXX.XoO", +" +XX.XXXXXXX.XoO", +" +XX.XXXXXXX.XoO", +" +XX.XXXXXXX.XoO", +" +XX.XXXXXXX.XoO", +" +XX.........XoO", +" ooooooooooooooO", +"OOOOOOOOOOOOOOOO"}; diff --git a/include/dde_atom.h b/include/dde_atom.h index 56df6b7e75d..62b50ff9e4b 100644 --- a/include/dde_atom.h +++ b/include/dde_atom.h @@ -9,15 +9,20 @@ */ #ifndef __WINE_DDE_ATOM_H #define __WINE_DDE_ATOM_H + +#ifdef CONFIG_IPC + #include "windows.h" #define DDE_ATOMS 157 /* a prime number for hashing */ void ATOM_GlobalInit(void); -/* -ATOM GlobalAddAtom( LPCSTR str ); -ATOM GlobalDeleteAtom( ATOM atom ); -ATOM GlobalFindAtom( LPCSTR str ); -WORD GlobalGetAtomName( ATOM atom, LPSTR buffer, short count ) -*/ + +ATOM DDE_GlobalAddAtom( SEGPTR str ); +ATOM DDE_GlobalDeleteAtom( ATOM atom ); +ATOM DDE_GlobalFindAtom( SEGPTR str ); +WORD DDE_GlobalGetAtomName( ATOM atom, LPSTR buffer, short count ) + +#endif /* CONFIG_IPC */ + #endif __WINE_DDE_ATOM_H diff --git a/include/dde_mem.h b/include/dde_mem.h index 6a830e15161..3bc8dfaf5e7 100644 --- a/include/dde_mem.h +++ b/include/dde_mem.h @@ -9,6 +9,9 @@ */ #ifndef __WINE_DDE_MEM_H #define __WINE_DDE_MEM_H + +#ifdef CONFIG_IPC + #include "wintypes.h" #include "global.h" #include "shm_block.h" @@ -31,4 +34,6 @@ HANDLE DDE_GlobalSize(WORD); HANDLE DDE_GlobalHandle(WORD); HANDLE DDE_GlobalFlags(WORD); +#endif /* CONFIG_IPC */ + #endif /* __WINE_DDE_MEM_H */ diff --git a/include/dde_proc.h b/include/dde_proc.h index 85e682accfb..011d389ee17 100644 --- a/include/dde_proc.h +++ b/include/dde_proc.h @@ -9,6 +9,9 @@ */ #ifndef __WINE_DDE_PROC_H #define __WINE_DDE_PROC_H + +#ifdef CONFIG_IPC + #include #include "wintypes.h" #include "windows.h" @@ -54,4 +57,7 @@ BOOL DDE_SendMessage( MSG *msg); int DDE_GetRemoteMessage(); void DDE_DestroyWindow(HWND hwnd); /* delete DDE info regarding hwnd */ void DDE_TestDDE(HWND hwnd); /* do we have dde handling in the window ?*/ + +#endif /* CONFIG_IPC */ + #endif /* __WINE_DDE_PROC_H */ diff --git a/include/miscemu.h b/include/miscemu.h index 2309274d9d9..bf2b007625d 100644 --- a/include/miscemu.h +++ b/include/miscemu.h @@ -1,20 +1,39 @@ +/* + * Misc. emulation definitions + * + * Copyright 1995 Alexandre Julliard + */ + #ifndef __WINE_MISCEMU_H #define __WINE_MISCEMU_H #include "wintypes.h" #include "registers.h" + + /* miscemu/dosmem.c */ +extern BOOL DOSMEM_Init(void); +extern void DOSMEM_FillBiosSegment(void); +extern HANDLE DOSMEM_BiosSeg; + + /* miscemu/instr.c */ extern BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ); -extern DWORD inport( int port, int count ); -extern void outport( int port, int count, DWORD value ); - + /* miscemu/interrupts.c */ extern BOOL INT_Init(void); extern SEGPTR INT_GetHandler( BYTE intnum ); extern void INT_SetHandler( BYTE intnum, SEGPTR handler ); + /* miscemu/int1a.c */ +extern DWORD INT1A_GetTicksSinceMidnight(void); + + /* miscemu/int21.c */ extern void INT21_Init(void); + /* miscemu/ioports.c */ +extern DWORD inport( int port, int count ); +extern void outport( int port, int count, DWORD value ); + #define INT_BARF(context,num) \ fprintf( stderr, "int%x: unknown/not implemented parameters:\n" \ diff --git a/include/shm_block.h b/include/shm_block.h index c19c84ff026..e8612d27b91 100644 --- a/include/shm_block.h +++ b/include/shm_block.h @@ -9,6 +9,9 @@ */ #ifndef __WINE_SHM_BLOCK_H #define __WINE_SHM_BLOCK_H + +#ifdef CONFIG_IPC + #include #include "wintypes.h" #define SEGSIZE 0x10000 /* 64 */ @@ -83,4 +86,5 @@ struct shm_block *shm_attach_block(int shm_id, int proc_idx, /* delete chain of shm blocks (pointing to each other */ void shm_delete_chain(int *shmid); -#endif /* __WINE_SHM_BLOCK_H */ +#endif /* CONFIG_IPC */ +#endif /* __WINE_SHM_BLOCK_H */ diff --git a/include/shm_fragment.h b/include/shm_fragment.h index 81a4b66a371..893aee741cd 100644 --- a/include/shm_fragment.h +++ b/include/shm_fragment.h @@ -10,6 +10,8 @@ #ifndef __WINE_SHM_FRAGMENT_H #define __WINE_SHM_FRAGMENT_H +#ifdef CONFIG_IPC + #include "shm_block.h" #define NIL ((int) 0) @@ -44,4 +46,6 @@ void shm_FragPtrFree(struct shm_block *block, void *ptr); /* This is used for debugging only */ void shm_print_free_list(struct shm_block *block); +#endif /* CONFIG_IPC */ + #endif /* __WINE_SHM_FRAGMENT_H */ diff --git a/include/shm_main_blk.h b/include/shm_main_blk.h index e3f9e5b9b85..4076bcfb6ae 100644 --- a/include/shm_main_blk.h +++ b/include/shm_main_blk.h @@ -9,6 +9,9 @@ */ #ifndef __WINE_SHM_MAIN_BLK_H #define __WINE_SHM_MAIN_BLK_H + +#ifdef CONFIG_IPC + #include #include "shm_block.h" #include "shm_semaph.h" @@ -52,4 +55,6 @@ void DDE_mem_init(); int DDE_no_of_attached(); #define DDE_IPC_init() ( (main_block==NULL) ? (DDE_mem_init()) : 0 ) +#endif /* CONFIG_IPC */ + #endif /* __WINE_SHM_MAIN_BLK_H */ diff --git a/include/shm_semaph.h b/include/shm_semaph.h index 55624464894..62852f0516c 100644 --- a/include/shm_semaph.h +++ b/include/shm_semaph.h @@ -12,6 +12,8 @@ #define __WINE_SHM_SEMAPH_H /* IMPORTANT: If possible, restrict usage of these functions. */ +#ifdef CONFIG_IPC + typedef int shm_sem; void shm_read_wait(shm_sem semid); @@ -21,4 +23,6 @@ void shm_read_signal(shm_sem semid); void shm_sem_init(shm_sem *semptr); void shm_sem_done(shm_sem *semptr); +#endif /* CONFIG_IPC */ + #endif /* __WINE_SHM_SEMAPH_H */ diff --git a/include/sysmetrics.h b/include/sysmetrics.h index f9e73e7b07c..11e08b40b42 100644 --- a/include/sysmetrics.h +++ b/include/sysmetrics.h @@ -11,30 +11,56 @@ /* Constant system metrics */ +#ifdef WIN_95_LOOK +#define SYSMETRICS_CXVSCROLL 14 +#define SYSMETRICS_CYHSCROLL 14 +#else #define SYSMETRICS_CXVSCROLL 16 #define SYSMETRICS_CYHSCROLL 16 +#endif #define SYSMETRICS_CYCAPTION 20 #define SYSMETRICS_CXBORDER 1 #define SYSMETRICS_CYBORDER 1 +#ifdef WIN_95_LOOK +#define SYSMETRICS_CXDLGFRAME 2 +#define SYSMETRICS_CYDLGFRAME 2 +#define SYSMETRICS_CYVTHUMB 13 +#define SYSMETRICS_CXHTHUMB 13 +#else #define SYSMETRICS_CXDLGFRAME 4 #define SYSMETRICS_CYDLGFRAME 4 #define SYSMETRICS_CYVTHUMB 16 #define SYSMETRICS_CXHTHUMB 16 +#endif #define SYSMETRICS_CXICON 32 #define SYSMETRICS_CYICON 32 #define SYSMETRICS_CXCURSOR 32 #define SYSMETRICS_CYCURSOR 32 #define SYSMETRICS_CYMENU 18 +#ifdef WIN_95_LOOK +#define SYSMETRICS_CYVSCROLL 14 +#define SYSMETRICS_CXHSCROLL 14 +#define SYSMETRICS_CXMIN 112 +#define SYSMETRICS_CYMIN 27 +#else #define SYSMETRICS_CYVSCROLL 16 #define SYSMETRICS_CXHSCROLL 16 #define SYSMETRICS_CXMIN 100 #define SYSMETRICS_CYMIN 28 +#endif #define SYSMETRICS_CXSIZE 18 #define SYSMETRICS_CYSIZE 18 +#ifdef WIN_95_LOOK +#define SYSMETRICS_CXMINTRACK 112 +#define SYSMETRICS_CYMINTRACK 27 +#define SYSMETRICS_CXICONSPACING 75 +#define SYSMETRICS_CYICONSPACING 75 +#else #define SYSMETRICS_CXMINTRACK 100 #define SYSMETRICS_CYMINTRACK 28 #define SYSMETRICS_CXICONSPACING 20 #define SYSMETRICS_CYICONSPACING 20 +#endif /* Some non-constant system metrics */ #define SYSMETRICS_CXSCREEN sysMetrics[SM_CXSCREEN] diff --git a/include/windows.h b/include/windows.h index 61a7618b587..105237f8f4c 100644 --- a/include/windows.h +++ b/include/windows.h @@ -2318,6 +2318,56 @@ typedef METAFILEPICT *LPMETAFILEPICT; #define META_CREATEBITMAP 0x06FE #define META_CREATEREGION 0x06FF +/* Debugging support (DEBUG SYSTEM ONLY) */ +typedef struct tagWINDEBUGINFO +{ + UINT flags; + DWORD dwOptions; + DWORD dwFilter; + char achAllocModule[8]; + DWORD dwAllocBreak; + DWORD dwAllocCount; +} WINDEBUGINFO; +typedef WINDEBUGINFO FAR* LPWINDEBUGINFO; + +/* WINDEBUGINFO flags values */ +#define WDI_OPTIONS 0x0001 +#define WDI_FILTER 0x0002 +#define WDI_ALLOCBREAK 0x0004 + +/* dwOptions values */ +#define DBO_CHECKHEAP 0x0001 +#define DBO_BUFFERFILL 0x0004 +#define DBO_DISABLEGPTRAPPING 0x0010 +#define DBO_CHECKFREE 0x0020 + +#define DBO_SILENT 0x8000 + +#define DBO_TRACEBREAK 0x2000 +#define DBO_WARNINGBREAK 0x1000 +#define DBO_NOERRORBREAK 0x0800 +#define DBO_NOFATALBREAK 0x0400 +#define DBO_INT3BREAK 0x0100 + +/* DebugOutput flags values */ +#define DBF_TRACE 0x0000 +#define DBF_WARNING 0x4000 +#define DBF_ERROR 0x8000 +#define DBF_FATAL 0xc000 + +/* dwFilter values */ +#define DBF_KERNEL 0x1000 +#define DBF_KRN_MEMMAN 0x0001 +#define DBF_KRN_LOADMODULE 0x0002 +#define DBF_KRN_SEGMENTLOAD 0x0004 +#define DBF_USER 0x0800 +#define DBF_GDI 0x0400 +#define DBF_MMSYSTEM 0x0040 +#define DBF_PENWIN 0x0020 +#define DBF_APPLICATION 0x0008 +#define DBF_DRIVER 0x0010 + + #ifndef WINELIB #pragma pack(4) #endif @@ -2439,6 +2489,7 @@ Fa(BOOL,RemoveFontResource,LPSTR,a) Fa(BOOL,SetDeskWallPaper,LPSTR,a) Fa(BOOL,SetErrorMode,WORD,a) Fa(BOOL,SetMessageQueue,int,a) +Fa(BOOL,SetWinDebugInfo,LPWINDEBUGINFO,a) Fa(BOOL,SwapMouseButton,BOOL,a) Fa(BOOL,TranslateMessage,LPMSG,a) Fa(BOOL,UnhookWindowsHookEx,HHOOK,a) @@ -2623,6 +2674,7 @@ Fb(BOOL,GetCurrentPositionEx,HDC,a,LPPOINT,b) Fb(BOOL,GetTextMetrics,HDC,a,LPTEXTMETRIC,b) Fb(BOOL,GetViewportExtEx,HDC,a,LPPOINT,b) Fb(BOOL,GetViewportOrgEx,HDC,a,LPPOINT,b) +Fb(BOOL,GetWinDebugInfo,LPWINDEBUGINFO,a,UINT,b) Fb(BOOL,GetWindowExtEx,HDC,a,LPPOINT,b) Fb(BOOL,GetWindowOrgEx,HDC,a,LPPOINT,b) Fb(BOOL,GetWindowPlacement,HWND,a,LPWINDOWPLACEMENT,b) diff --git a/include/winsock.h b/include/winsock.h index a0450c24912..63e92bba84c 100644 --- a/include/winsock.h +++ b/include/winsock.h @@ -174,7 +174,7 @@ struct sockproto { * compatibility purposes. */ -#define h_errno WSAGetLastError() +/* #define h_errno WSAGetLastError() */ /* Authoritative Answer: Host not found */ #define WSAHOST_NOT_FOUND (WSABASEERR+1001) diff --git a/ipc/Imakefile b/ipc/Imakefile index cf5d6df44b8..e9e82a1f829 100644 --- a/ipc/Imakefile +++ b/ipc/Imakefile @@ -2,32 +2,36 @@ MODULE = ipc -TEST_SRCS = \ - shm_fragment_test.c \ - bit_array_test.c\ - dde_proc_test.c \ - dde_atom_test.c \ - shm_semaph_test.c \ - wine_test_stub.c \ - hash_test.c \ - dde_mem_test.c - SRCS = bit_array.c \ - dde_atom.c \ - dde_mem.c \ dde_proc.c \ - generic_hash.c \ - shm_block.c \ - shm_fragment.c \ shm_main_blk.c \ - shm_semaph.c + dde_atom.c \ + shm_semaph.c \ + dde_mem.c \ + shm_block.c \ + shm_fragment.c OBJS = $(SRCS:.c=.o) -TEST_OBJS = $(TEST_SRCS:.c=.o) + +SHM_OBJ=shm_block.o shm_semaph.o shm_main_blk.o dde_proc.o \ + dde_mem.o bit_array.o shm_fragment.o wine_test_stub.o + WineRelocatableTarget($(MODULE),,$(OBJS)) + DependTarget() +tests:: dde_mem_test dde_proc_test dde_atom_test shm_fragment_test \ + shm_semaph_test + +NormalProgramTarget(bit_array_test, bit_array.o bit_array_test.o,,,) +NormalProgramTarget(shm_semaph_test, shm_semaph_test.o shm_semaph.o,,,) +NormalProgramTarget(shm_fragment_test, shm_fragment_test.o shm_fragment.o,,,) +NormalProgramTarget(dde_atom_test, dde_atom_test.o dde_atom.o $(SHM_OBJ),,,) +NormalProgramTarget(dde_mem_test, dde_mem_test.o $(SHM_OBJ),,,) +NormalProgramTarget(dde_proc_test, dde_proc_test.o $(SHM_OBJ) ,,,) + + includes:: install:: diff --git a/ipc/Makefile.in b/ipc/Makefile.in index fd2dfaeb841..811f2b413ac 100644 --- a/ipc/Makefile.in +++ b/ipc/Makefile.in @@ -35,7 +35,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/ipc/README b/ipc/README index 6903f53265e..c004de87026 100644 --- a/ipc/README +++ b/ipc/README @@ -1,8 +1,34 @@ -This is a pre-alpha code, it does not work for 100%, -but it does not break anything (I hope). -Proper documentation (LaTeX) will be ready for the next release. + Technion- Israel Institute of Technology + Electrical Engineering software lab. -You can use "ipcl" perl script to remove junk IPC stuff. -You can use "ipcs" system program to find junk IPC stuff. -Michael + + Author : Michael Veksler 11678223 + + Tutor: Avner Lottem + + +DDE support for Wine +==================== + +Wine emulator is able to run MS-Windows 3.1 applications under Linux +(Linux is a UNIX clone) . Wine is also a toolkit allowing MS-Windows +applications to compile under Linux. Wine is a world-wide Internet +project with more than 20 developers. Wine is still under development +so many vital MS-Windows features are still missing. + +DDE is Dynamic Data Exchange used for communication between MS-Windows +applications. This project adds DDE capabilities into Wine. The new +improved Wine will be able to send messages and share memory between +two different Wine processes. + +This project uses System-V IPC mechanisms to implement DDE. + +Besides sharing memory handles and sending DDE messages, Wine processes +are synchronize to emulates MS-Windows non-preemptive task switching. +(MS-Windows switches tasks only on given instructions). This is done +without hurting the performance or stability of a single Wine process. + +The project adds DDE to Wine emulator and to the toolkit. This allows +old MS-Windows applications to be compiled for UNIX, and have DDE +working among them. diff --git a/ipc/bit_array.c b/ipc/bit_array.c index 14d72e9e496..6873c82509a 100644 --- a/ipc/bit_array.c +++ b/ipc/bit_array.c @@ -14,13 +14,15 @@ *************************************************************************** */ +#ifdef CONFIG_IPC + /* ** uncoment the following line to disable assertions, ** this may boost performance by up to 50% */ /* #define NDEBUG */ -#ifndef NO_ASM +#if defined(linux) && !defined(NO_ASM) #define HAS_BITOPS #endif @@ -275,3 +277,5 @@ int AllocateBit(bit_array *bits) return bit_nr; } + +#endif /* CONFIG_IPC */ diff --git a/ipc/dde.tex b/ipc/dde.tex new file mode 100644 index 00000000000..ef4e1fff874 --- /dev/null +++ b/ipc/dde.tex @@ -0,0 +1,962 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% Written by Michael Veksler. +%% May be freely redistributed as long as this header is unchanged. +%% The file be modified as long as there will be appropriate comment +%% containing the Author and a description. +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\documentstyle{article} +\renewcommand{\thepage}{} +\newcommand{\Wine}{Wine} +\newcommand{\WINE}{{\em WINdows Emulator}} +\newcommand{\DDE}{{\em Dynamic Data Exchange}} +\newcommand{\windoz}{MS-Win\-dows} +\newcommand{\fname}[1]{{\tt #1}} +\newcommand{\libwine}{\fname{libwine.a}} +\title{DDE\footnote{DDE is \DDE\ mechanism provided by \windoz. + (Appendix~\protect\ref{sec:DDE}). + } + \ capability for \Wine\footnote{\Wine\ (\WINE) Runs \windoz\ + programs under UNIX\@. (Appendix~\protect\ref{sec:Wine}). + } +} +\author{Michael Veksler 11678223} +%%\date{Aug 6, 1995} +\begin{document} +\maketitle +\vfill +\abstract{\Wine{} provides an environment for running or compiling + \windoz{} applications for UNIX clones (such as Linux). + \Wine{} is not yet finished and lacks many basic important features. + One of the missing features is DDE\@. DDE implementation + (especially for \libwine) requires + UNIX IPC\footnote{IPC - Inter-Process Communication}. This Project + introduces the IPC mechanism into \Wine{}, thus allowing DDE to work + between different \Wine{} processes.} + + +\vfill +{\LARGE + \begin{itemize} + \item[Instructor:] Avner Lottem + \item[Done for:] Technion- Israel Institute of Technology,\\ + Electrical Engineering software lab$^{\mbox{\small\copyright}}$. + \end{itemize} + } +\vfill + +\newpage +\renewcommand{\thepage}{\roman{page}} +\setcounter{page}{1} +\begin{center} + {\LARGE Table Of Contents} +\end{center} +\tableofcontents + +\newpage +\renewcommand{\thepage}{\arabic{page}} +\setcounter{page}{1} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% end of title +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\section{Introduction} + +\subsection{The project} +The purpose of the project is to add DDE capabilities into \Wine. +The project enables \Wine{} DDE client-server applications communication. +This involved messing around with: +\begin{itemize} + \item \windoz\ message mechanism. + \item \windoz\ memory management. + \item \windoz\ task management. + \item UNIX messages among \Wine\ processes. + \item Exchanging (sharing) UNIX memory. +\end{itemize} + +\subsection{Problem description} +DDE is essentially a communication protocol between \windoz\ +tasks. Implementing this protocol requires communication among +\Wine{} processes and among tasks in one process (each \Wine{} process +can contain several tasks). Since \Wine\ already provides +communication among internal tasks, this project provides communication +between \Wine\ processes. + +Different \Wine\ processes should be able to send \windoz\ messages +and to pass \windoz\ memory handles. There also has to be a +synchronization mechanism between the processes (\windoz\ applications +make assumptions about task switching - and don't use semaphores, or +any \windoz\ equivalent). + +Passing messages is a bit tricky. \windoz\ gives a feedback about the +success of a message (fails if the window does not exist). +In case of SendMessage (see Appendix~\ref{sec:WindozMsg}), the process +will have to halt until the message has been processed. +In case of PostMessage, things are simpler - only the existence of the +recipient has to be checked. + +\windoz\ switches tasks only when certain system calls are used (such +as delivering or polling messages). \windoz\ applications rely on this +behavior. The problem arises when two applications run on different +\Wine\ processes. Since UNIX preempts processes there is no guaranty +that the UNIX task will occur at the correct place (in respect of the +application). +One one hand is the need for compatibility (no UNIX ``current'' +execution), and on the other hand is performance and stability. + +Another problem is passing handles between \Wine\ processes. \windoz\ +applications pass atoms\footnote{See appendix~\ref{sec:WhatAreAtoms}}, +memory handles and window handles. These handles have to be allocated +globally (in shared memory) or translated on the fly. + + +If a process dies from ``unnatural causes'' (e.g.\ kill $-9$). It will +leave garbage in memory and other IPC handles will start floating +around. There should be some way to collect this garbage. + +\subsection{Solutions} +\label{sec:ProjSolutions} +\Wine\ uses Sys-V IPC mechanism (See +Appendix~\ref{sec:SysV-IPC}). This allows sharing data and passing +data between processes (The alternatives are not that good in that +respect - see Appendix~\ref{DDE-Alternatives}). +The shared data contains only essential information (performance or +compatibility). The minimum is kept on shared memory in order to get +maximum stability (\windoz\ is known as an unstable system, \Wine\ +should not imitate \windoz\ in this respect). + +Communications are done by Sys-V messages and UNIX signals (a signal +wakes \Wine\ up and the message passes the data). Sys-V messages are +used for carrying \windoz\ messages, as well as synchronization +information. There are 3 types of messages: sent, posted and ack. +Ack message is used for synchronization as well as for returning error +codes (In case sending/posting messages fail). When a message is sent, +the sending process will block until \Wine's {\em ack}{} message is +received. + +Synchronization between \Wine\ processes is divided into 2 categories, +in both cases the sender of a message waits for an ack message: +\begin{enumerate} + \item Sent messages - Wait until the recipient delivers ack message. + (When the recipient finished message processing) + \item Posted message - The recipient will send ack only during + task switching instructions (like PostMessage, GetMessage, Yield, + etc.). This way nothing will be done after PostMessage until it is + safe. +\end{enumerate} + +There is no real \Wine\ server. Every \Wine\ process has to handle +it's end. This approach somehow resembles a distributed OS\@. This +introduces some problems (Resources might not be freed in case of a +crash). On the other hand this ``distributed OS'' approach simplifies +installation and use, and improves performance. + +Atoms are stored on shared memory, so every two \Wine\ processes will +be in sync in this respect (atom 5 will mean the same on both +processes). Shared memory handles are stored on shared memory as +well. Shared memory handles are not from the same range as local +memory handles (\windoz\ requires an plication to declare about it's +shared memory). Since local memory handles have different range they +can be allocated locally (without any sync requirements - handle x may +appear on 10 different \Wine\ processes and address different data). + +Window handles are allocated locally. This approach gives stability, +but window handles are no longer unique (same handle may appear +on different processes). This requires on the fly window handle +translation. When an \windoz\ message is transfered, \Wine\ will +translate any contained window handle. The sender translates the +handle to a global (unique) handle, the receiver translates the global +handle to the local window handle. + +Collecting the garbage of dead processes is done in two cases: +\begin{enumerate} + \item When setting up a new \Wine\ process: If no \Wine\ process is + running and shared memory is floating around all the IPC stuff is + deleted. + \item When sending a message: If the recipient is dead it's IPC + handles are deleted. +\end{enumerate} + + + +\section{The software} + +\subsection{DDE project structure} +Old \Wine\ functions call the new DDE functions whenever needed. +(e.g.\ when sending a DDE message, the original SendMessage function calls +DDE\_SendMessage). This approach minimizes changes to original \Wine{} +code. The new code was written in C. The new capabilities where written +as much as possible in OOP\footnote{OOP stands for Object Oriented +Programming}{} style. + +Currently DDE uses Sys-V IPC mechanism, for it's operation. + + +\paragraph{Major OOP objects and files:} + +\begin{table}[h] + \begin{center} + \leavevmode + \begin{tabular}{|l|p{20em}|} \hline + Object & Description \\ \hline + shm\_block & shared memory block operations. \\ + shm\_main\_block & (derived from shm\_block.) Things all + DDE applications need access to. \\ + shm\_fragment & Allocation of in-block fragments. \\ + shm\_semaph & Semaphore operations. \\ + dde\_proc & Process and DDE message handling. \\ + dde\_mem & Front end of DDE memory handling + (Interface of DDE to outer world). \\ + dde\_atom & Handling global atoms. \\ + bit\_array & Array of bits. It has atomic + operations, so bits can be used instead + of semaphores. \\ \hline + \end{tabular} + \caption{Objects constructing the DDE extension.} + \label{tab:ObjList} + \end{center} +\end{table} + +Table~\ref{tab:ObjList}{} lists the objects used in the DDE code. +The following rules apply to objects: + +\begin{itemize} + \item Object names that begin with {\em dde\_$\cdots$}{} are the front + end. These objects are working directly with the rest of + \Wine. Objects that start with {\em shm\_$\cdots$}{} are the back + end. These objects provide services for the rest of the + implementation. + \item The objects are stored in file with the same name as the object. + (e.g.\ dde\_mem is stored in dde\_mem.c and dde\_mem.h). + \item For each object there is a test file (that partially tests it). + The name of this file is object's name with the word ``test'' + (e.g.\ dde\_mem object has dde\_mem\_test.c). + \item dde.h file has declarations used by dde\_proc and external DDE + users. +\end{itemize} + + +\subsection{Major algorithms} + +\paragraph{Delivering messages:} +\label{sec:DeliveringMessages} +\windoz\ messages are passed using Sys-V IPC messages. Processing +starts with SendMessage() or PostMessage() \windoz\ system +functions: +\begin{enumerate} + \item SendMessage and PostMessage call the DDE functions (same names + prefixed with DDE\_). If the DDE functions pass, don't go any + further. If it fails try to process the message in the + conventional way. + \item The DDE message functions call DDE\_DoMessage, which is + the main DDE message processing function. From now on there is no + difference between sending and posting messages (from initiator's + point of view). + \item If the message is not a DDE message or the recipient is not + remote, fail and return to original message functions. + \item Bring the message to a format suitable for IPC delivery. The + format includes: + \begin{itemize} + \item message type (sent or posted). + \item Sender window handle (translated to global window id.) + \item Other message ingredients (msg, lParam). + \end{itemize} + \item Deliver the message to every recipients using + DDE\_DoOneMessage. There might be many recipients in case of a + broadcast (when the ``recipient'' window is -1). + \item DDE\_DoOneMessage delivers the message and waits for response. + Fail if timeout is reached. +\end{enumerate} + + +\paragraph{Receiving messages:} +Messages from other \Wine\ processes are received. Processing start +from DDE\_GetRemoteMessage(): +\begin{enumerate} + \item DDE\_GetRemoteMessage is called whenever wine is going to wait + or receive X-windows message. If wine is sleeping (waiting for X), + it will waken by a SIGUSR2 signal. In this case the handler will + siglongjmp() out of the select() function. + \item If no remote message is pending in the message queue - exit. + (Sys-V message queue holds the remote messages until they are + read). + \item If the message is broadcasted, goto stage~\ref{BroadcastAlgo}. + \item Translate the global window handle of the recipient to local + handle. + \item Do this if the message was sent. Send the message to the + recipient window. Reply with ack to the sender. (Reply with the + return code of the SendMessage function). {\em \bf Return}\ with + positive return value. + \item Post the message. + \item If PostMessage fails - send failing ack message. + \item If PostMessage passes, add the message data into a FIFO\@. This + FIFO contains all messages that have to be acknowledged (who's + sender is waiting for ack). Whenever internal task switch occurs, + a item from this FIFO is popped out and an ack message is sent. + \item \label{BroadcastAlgo} Iterate through the local windows and + deliver the message to every one of them. + \item Send a positive ack message. +\end{enumerate} + +\paragraph{Allocating memory:} +Shared memory allocation is divided into two categories: internal wine +and \windoz\ application. The memory used by \windoz\ applications is +allocated in two phases - allocate internal wine, and then prepare all +the stuff needed by \windoz. + +The internal allocation (DDE\_malloc): +\begin{enumerate} + \item Try to allocate big enough memory fragment in allocated shared + memory. + \item If fragment could not be allocated, allocate a new shared + memory block. Allocate the memory fragment. + \item Allocate a shared memory handle (call the dde\_alloc\_handle() + function). The allocated handle is from a range used only by + shared memory handles. This allocation function is used only for + shared DDE memory. + \item Write the handle in the data structure. Also write the + relative location of this handle (Pointer location is useless since + it differs from one \Wine\ process to another). + This information is written in the main shared memory block. +\end{enumerate} +When a fragment is allocated, it is removed from the list of free +memory. + +Allocation for \windoz\ applications (this is done in GlobalAlloc): +\begin{enumerate} + \item Do the internal allocation (instead of malloc in the local + allocation). + \item Everything else is the same as with local memory. A segment is + allocated for the new memory, and it's data is kept in the data + structure. +\end{enumerate} + + +\paragraph{Atoms:} +Atoms have pretty simple algorithms operating on them. Since atoms are +supposed to give a unique number for each string - atoms are +implemented as hash tables. The id of the atom is the entry in the +hash table. The disadvantage of this approach is that there is a limit +on the number of atoms, the big advantages are simplicity and +speed. + +Since implementing a hash tables is strait forward, I will not +discuss it in depth. This hash table has two hash functions - primary +and secondary. When searching for an item (for deletion, addition, or +a seek) the following steps are taken: +\begin{enumerate} + \item The primary hash function returns the first entry. + \item \label{AtomHashLoop} + If the entry is empty or no unchecked entries {\bf \em fail}. + \item If the entry is correct, {\bf \em success!!!}. + \item Add the result of secondary hash function to the item index. + \item Goto step~\ref{AtomHashLoop}. +\end{enumerate} + + +\subsection{Major data structures} +There are two kinds of data structure, local and shared. The local +data structures are strait forward and will not be discussed in +detail. + +The shared data structures have four level hierarchy. Each level +depend on the other and can not exist without it. Most structures have +much less than four levels. + +\paragraph{Level one data structure - the main block:} +This data structure is part of the shm\_main\_block object. It +contains essential information needed by all \Wine\ processes. : +\begin{enumerate} + \item Semaphore identifier used for locking the data structure. + \item A table containing information about \Wine\ processes. + \item Relative pointers to atoms. + \item A table containing window information. + \item Tables with global memory handles. +\end{enumerate} + +The first level is allocated and initialized when \Wine\ calls a DDE +function the first time. DDE functions are: global memory allocation, +global atoms or DDE messages. + +The first level data structure contains the second level data +structure. + + +\paragraph{Atom element (level two):} +Each element is allocated dynamically (the size of the string is +unknown). The allocation is gained from the shm\_fragment object (each +atom is an instance of that object). Each atom contains: +\begin{enumerate} + \item Count of links. Each allocation of the atom establishes a new + link and each deallocation deletes one link (until all links are + removed). + \item The string of the atom. The string ends with a null character. +\end{enumerate} + +\paragraph{Wine processes data (level two):} +(part of the dde\_proc object) : +\begin{enumerate} + \item pid (\Wine\ process id). + \item Message queue id. + \item Semaphore used for locking process's data structure. + \item Sys-V shared memory id of the first block in the chain of + process's blocks. +\end{enumerate} + + +\paragraph{Window information (level two):} +This is part of the dde\_proc object. The index of array entry +specifies the window handle. Each entry contains: +\begin{enumerate} + \item The process index of the \Wine\ process running this window. + \item The local window handle of this window (remember that each DDE + window has different global and local handles). +\end{enumerate} + + +\paragraph{Global memory handles (Level two):} +(part of bit\_array and dde\_mem objects): +\begin{enumerate} + \item A bit array contains '1' in every entry that refers to + used global memory handle. + \item Array of handles contains handle data. Each entry refers + to a global memory handle (The index is a function of the + handle). The data includes: 1) Sys-V shared memory handles 2) + offset into the memory block. +\end{enumerate} + +\paragraph{Block allocation data structure (Level three):} +This data structure a part of the shm\_block object. It is local to +each shared memory block, so every memory block has it's own data +structure. The shared memory blocks are organized in chains grouped by +processes (each DDE process has one and only one chain): +\begin{enumerate} + \item The id of the next shared memory block in the chain. + \item The size of the block. + \item Number of free bytes in the block. + \item The index of the owner process. + \item The first item in the free list (a linked list of free items). +\end{enumerate} + + +\paragraph{Fragment allocation (Level four):} +This data is a part of the shm\_fragment object. It is a part of the shared +memory allocation mechanism. Every fragment is a part of shared memory +block. Each fragments contain: +\begin{enumerate} + \item The size of the fragment (for allocating and freeing this + fragment). + \item A union that contains one of: + \begin{itemize} + \item data - if it is allocated. + \item offset of the next free fragment (if it is a member of the + free list). + \end{itemize} +\end{enumerate} + + +\paragraph{Local reference to global memory:} +Global memory blocks are referenced from local memory. This is used +for storing pointers that refer to the memory block. It contains: +\begin{enumerate} + \item next item in the list. + \item shared memory block id. + \item Owner process. + \item Pointer to the data. +\end{enumerate} + +\paragraph{Local mirroring of global handles:} +Global handles require local segments handles (when they are locked). +These segments have to be deleted when the handle is freed. +There is a minimal mirroring of handles in the original tables of +wine, this information is stored the way local handles have always +been stored. + +\subsection{Interface and IO} +The DDE section of wine has several interfaces to different entities: +\begin{enumerate} + \item User debug information. + \item Interface between several \Wine\ processes. + \item Interface to the `old' code of \Wine. +\end{enumerate} + + +\paragraph{User debug information:} +The debug information is written according to \Wine's +conventions. This means that dprintf\_$\cdots$ macros are used to +print the debug information. (These macros allow runtime or compile time +disabling of a any sort of debug information). + +In some cases the dprintf\_$\cdots$ macros are not powerful enough. In +those cases the following construct is used instead: +\begin{verbatim} + if (debugging_dde) { + /* print whatever is needed for dde debugging */ + } +\end{verbatim} + + +\paragraph{Interface between \Wine\ processes:} +The interface between processes includes: +\begin{itemize} + \item Message delivery (see Section~\ref{sec:DeliveringMessages}). + \item Sharing \windoz\ constructs (atoms, memory, window + handles). + \item Synchronization among different \Wine\ processes so it will + appear to a \windoz\ as if there is only one process. +\end{itemize} + +\paragraph{Interface to the rest of \Wine:} +Most of the interface has been minimized to an additional few lines in +the original functions. The hook for DDE are in the following +locations: +\begin{itemize} + \item Global atoms functions - these are called directly from + \windoz\ applications. + \item Message delivery - a hook calls the DDE functions from the + original message delivery functions. + \item Initialization - Every PeekMessage() call a DDE function to + check if the current window has DDE management (by sending + a dummy WM\_DDE\_INITIATE message). + \item Waiting on messages - The original code for waiting on X + messages was enhanced to wait on DDE messages as well. This + includes aborting sleeps when SIGUSR2 signal is sent. The actual + test for DDE messages is done in the DDE code. +\end{itemize} + +\subsection{Major functions and their role} +\paragraph{Message delivery functions:} +\begin{itemize} + \item DDE\_SendMessage and DDE\_PostMessage - hooks used by original + \Wine's SendMessage and PostMessage. They return true if the + message could be successfully sent to a remote \Wine\ process. + Only in this case SendMessage and PostMessage stop further + processing. + \item DDE\_DoMessage - Try to post or send a message to another + \Wine\ process. This function can do broadcasting as well as + sending. (A message is `broadcasted' if it is delivered to every + window on the system). + \item DDE\_DoOneMessage - Deliver a message to a given wine + {\bf process}. + \item dde\_proc\_send\_ack - Send ack message to \Wine\ + process. The input window handle is used for detecting the + process. + \item get\_ack - wait for ack or timeout. +\end{itemize} + +\paragraph{Memory allocation functions:} +\begin{itemize} + \item DDE\_malloc - Allocate a shared memory fragment. This function + also allocates global memory handle. + \item DDE\_GlobalFree - Free a shared memory fragment according to + it's handle. And free the handle. + \item DDE\_SyncHandle - synchronize the global handles mirrored + locally. Delete any outdated handles, or remap reallocated + handles. + \item DDE\_mem\_init - initialize or attach the main shared memory + block, and relevant local data structures. + \item shm\_delete\_all - delete all IPC stuff related to this + process. Kill the main memory block if appropriate. +\end{itemize} + + +\section{Software testing} +The testing of this module was a substantial part of the +development. Testing revealed bugs just as they where created. + +\subsection{Testing methods utilized} +\label{sec:TestMethod} +Two major testing methods where used: +\begin{enumerate} + \item Running DDE \windoz\ applications. The applications used are + DDE demonstration applications. This applications seem to show + precisely what DDE is all about. The applications used where: + ddepop1.exe (server), showpop1.exe (client). These + applications come with \windoz\ programming manual by Charles + Petzold \cite{bib:WinManual}. + \item Running standalone DDE objects linked with a test + object. Every object was tested this way. Some objects had to be + linked with a stub that emulated \Wine's functions. The stub is + pretty poor with dde\_mem object since this object requires hard + to emulate functionalities (things like allocating a segment). + + For some objects the coverage seems to be perfect (100\%). For + some object the coverage is poor. The objects with massive stub + usage suffer from this (especially dde\_mem). +\end{enumerate} + +\subsection{input for testing} +Most of the testing described in section~\ref{sec:TestMethod} has no +input. Most of the testing knowledge is in the test objects +themselves. There are two exceptions to this rule: +\begin{enumerate} + \item The \windoz\ applications described in + section~\ref{sec:TestMethod} - which are essentially an input to + the software. These applications can't be distributed since it + will be a \copyright{} violation. + \item A trace file which is used for comparing test's output with + the expected trace result. This trace file is used for + shm\_fragment validation. This file is implementation Dependants + and should be updated whenever the object is rewritten. When + updating the trace, it should be inspected manually before it is + released. +\end{enumerate} + +\subsection{usage instructions} + +\paragraph{Running the DDE applications:} +To test the DDE applications one must run: +\begin{verbatim} + prompt> wine /full-path/ddepop1.exe > /dev/null & +\end{verbatim} +Wait for the server window to pop up (A tiny window should appear at +the lower left corner of your screen). Then activate the client by +typing: +\begin{verbatim} + prompt> wine /full-path/showpop1.exe > /dev/null +\end{verbatim} +The server updates ``USA population'' data every 5 seconds. The client +asks for a hot link (i.e.\ it sends a WM\_DDE\_ADVISE on every +item). From that point on the server updates the client of any +population change. + + +\paragraph{Running the object tests:} +The {\em run\_tests}{} script is provided to automate the object +tests. Every object test is run and the script checks for results. At +the end the script prints a nice summary table. + +Invoking tests outside the {\em run\_tests}{} script is not as simple +as it may look. Every test has differently looking output. +\begin{itemize} + \item dde\_atom\_test - The executable is run. It passes if no + errors are printed at the bottom. + \item dde\_mem\_test - The same as for dde\_atom\_test. + \item shm\_semaph\_test - The same as for dde\_atom\_test. + \item bit\_array\_test - The same as for dde\_atom\_test. + \item shm\_fragment\_test - After the executable is run, the output + has to be compared with TEST\_FRAGMENT.std + \item dde\_proc\_test - This actually runs as a client and as a + server. To activate the server one should write: +\begin{verbatim} + prompt> dde_proc_test 1 > server.log +\end{verbatim} + Then the client has to be activated within five seconds by + writing: +\begin{verbatim} + prompt> dde_proc_test > client.log +\end{verbatim} + The log files should contain: + \begin{description} + \item[server.log:] Should contain traces of received + WM\_DDE\_INITIATE message, and ack sent for it. (Pretty much + the same what {\em run\_tests}{} does). + \item[client.log:] Should contain traces of sending + WM\_DDE\_INITIATE and then receiving an ack message. + \end{description} + No `timeout' traces should be present in the log files. + +\end{itemize} + + +\section{Summary} +\subsection{Software limitations} +\begin{itemize} + \item Only most fundamental memory management functions where + written. This means that the following functions will not work: + \begin{itemize} + \item GlobalReAlloc + \item GlobalSize - two line fix. + \item GlobalFlags - two line fix. + \item LockSegment - two line fix. + \item UnlockSegment - two line fix. + \item GlobalFreeAll - will not free DDE memory. + \item GlobalPageLock - two line fix. + \item GlobalPageUnlock - two line fix. + \item GlobalFix - two line fix. + \item GlobalUnfix - two line fix. + \end{itemize} + \item Non DDE messages to remote windows will not work. This is + currently only a sanity check, it may be removed in the future. + \item Message sending has a timeout limit. This is incompatible with + \windoz. This limit increases stability of a singe \Wine\ process. + \item Synchronization mechanism between wine processes is not + perfect. It was not proved theoretically. I never saw it fail. +\end{itemize} + +\subsection{Concluding Remarks} +This extension to \Wine{} enables further development of \windoz\ IPC +support. Things like OLE can be extended using these features - +although some modifications might be inevitable. + +The most important contribution of this project is the support for +\libwine{}. Any \windoz\ application compiled under UNIX and linked to +\libwine{} will need the IPC mechanism provided by this project. + +During the progress of the project it got a bit outdated. During that +time \Wine{} started to handle tasks internally, so the external IPC +was no longer needed for the emulator configuration of +wine. Nevertheless the support of IPC for \libwine will never +be obsolete. + + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% +%% Appendixes +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\clearpage +\appendix + +\section{\Wine} +\label{sec:Wine} +\Wine\ stand for {\em WINdows Emulator}. It is an X-windows - UNIX +application (Linux and FreeBSD). \Wine\ emulates \windoz\ environment +for the \windoz\ applications. It has two uses: +\begin{enumerate} + \item Run \windoz\ binary code (compiled under \windoz). + \item To be used as a toolkit for compiling \windoz\ applications + under UNIX. (The \libwine\ library is provided) +\end{enumerate} +For emulation, only Intel-Architecture CPU (386, 486, Pentium) are +supported. \libwine\ Toolkit should run on any platforms, but it was not +tested. \Wine\ is still in alpha state, and does not support all \windoz\ +capabilities yet. + + +\section{Messages under \windoz} +\label{sec:WindozMsg} +Messages are the means of communication to a user window (from another +window or from \windoz\ itself). +Messages can be delivered in two ways: +\begin{itemize} + \item Messages can be sent. The sent message enters the window handler + asynchronously (The handler may be reentered many times). + A window sending the message waits for the recipient to process + the message and return an exit code. + \item Messages can be posted. The posted message enters a queue, and + it's up to the recipient to process it. If the recipient ignores + it, the message might be eventually sent to the recipient from + WinMain handler. +\end{itemize} + +\section{DDE} +\label{sec:DDE} +DDE stands for \DDE\@. DDE is an \windoz\ +protocol used for data exchange between applications. +It has synchronous and asynchronous operation modes. +DDE mechanism is based on messages, atoms +(Section~\ref{sec:WhatAreAtoms}) and shared memory. + +DDE applications are divided roughly into two classes: servers AND +clients. Clients have the initiative, they try to connect to the +server. Servers only maintain an existing DDE link. + + +\subsection{DDE Messages} +\paragraph{DDE message format}: + +\label{sec:DDEMessageFormat} + +DDE messages contain the following fields. +\begin{description} + \item[wnd] The recipient of this message ($-1$ if every window + should receive). + \item[msg] The ID of the message. + \item[wParam] Who sent this message. + \item[lParam] 32 bit parameter, divided into two 16 bit words. + Usually, the lower 16 bits contain a memory handle. The handle + points to some extra DATA about this message. + +\end{description} + +\paragraph{Available messages:} +\begin{description} + \item[WM\_DDE\_INITIATE] + This message is sent by the client to the whole ``world''. + {\em lParam}{} contains the two atoms used for passing the topic and + application information. + + Every server application checks if this message refers to it + (According to the Application and the Topic atoms). + + + \item[WM\_DDE\_ACK] + This is a generic response to various events + (one of them is WM\_DDE\_INITIATE). + The low part of {\em lParam}{} passes extra information, such as + success/failure. + + \item[WM\_DDE\_TERMINATE] + Kill the DDE link. + + + \item[WM\_DDE\_ADVISE] + Tell the server to inform the client of any updates. + + + \item[WM\_DDE\_UNADVISE] + Stop the WM\_DDE\_UNADVISE mode. + + + \item[WM\_DDE\_DATA] + Transfer data handle (note that the data handle must be globally allocated + with the GMEM\_DDESHARE flag). + + \item[WM\_DDE\_REQUEST] + Request a data item from the server. This message is used in a + cold link. {\em lParam}{} contains an atom describing the desired + item, and a WORD describing the wanted data format. + \item[WM\_DDE\_POKE] + The client gives the server new data. + \item[WM\_DDE\_EXECUTE] + The client asks the server to execute a procedure (according to a + command string). + +\end{description} + +\subsection{Atoms} +\label{sec:WhatAreAtoms} +Atoms are represented by numbers. Every atom maps uniquely to a string +(i.e.\ two atoms can't map to the same string). +There are two types of atoms - local and global. The local are visible +only to the application that created them. Global atoms are seen by all +\windoz\ applications. + +Functions: +\begin{description} + \item[AddAtom(str)] create a local atom that maps to ``str''. + If it exists, increment the allocation-counter, + and return the atom. + \item[DeleteAtom(atom)] decrement the allocation-counter. When it + reaches zero the atom, will be deleted. + \item[FindAtom(str)] Find the atom that maps to this string (if exist). + + \item[GetAtomName(\ldots)] Find the string that this atom points to. +\end{description} + +NOTE: +\begin{description} + \item[Global atoms] Add ``Global'' before the listed names to get Global + atom functions. + \item[Case sensitivity] All atom operations ignore case. +\end{description} + + +\section{DDE under \Wine\ - Alternatives} +\label{DDE-Alternatives} +There where three possible approaches for this project. I have chosen +System-V IPC, but it can be easily changed. + +\subsection{IPC - Inter-Process Communication} +\label{sec:SysV-IPC} + +The IPC mechanism was originated from System-V UNIX\@. This mechanism +allows complicate communication between two process (on the same machine). +IPC includes the following capabilities: +\begin{enumerate} + \item Shared Memory (shm) - can be shared among few processes and users. + \item Semaphores (These semaphores allow grouped operations - i.e.\ + operations gathered as an atomic operation). + \item Message Queues (allow few messages at a time). +\end{enumerate} + +The advantages of IPC over the other variants are: +\begin{itemize} + \item Memory access speed is good. (after the memory was attached). + \item Easy to block critical code (don't enter critical code from two + processes at the same time) +\end{itemize} +Disadvantages of IPC: +\begin{itemize} + \item Impossible to communicate to other machine. + \item Requires complex mechanism to wait both for X and IPC messages. +\end{itemize} + +\subsection{X-Windows Communication mechanisms} +The advantages of X-Windows Communication over the other variants are: +\begin{itemize} + \item Possible to communicate to other machines. + \item No need for additional mechanism that will wait both for X and DDE\@. + \item Many of the required capabilities are already there. +\end{itemize} +Disadvantages of X-windows communication: +\begin{itemize} + \item {\em Slow}\ and complex memory access. + \item May be hard to avoid two applications from entering critical + code at the same time. +\end{itemize} + +\subsection{BSD Sockets} +The advantages of Sockets are: +\begin{itemize} + \item Possible to communicate to other machines. + \item No need for complex mechanism that will wait both for X and + DDE\@. (can use one ``select'' on X-windows socket in concert with + the DDE socket). +\end{itemize} +Disadvantages of socket are: +\begin{itemize} + \item {\em Slow}{} and complex memory access. (note that mmap on a + descriptor does not work for Linux 0.99). + \item May be hard to avoid two applications from entering critical + code at the same time. +\end{itemize} + +\subsection{Why was it written in C? Pros and cons.} +Advantages of C: + +\begin{itemize} + \item History- \Wine{} is already written in C. + \item Portability- not all systems have C++. + \item Speed- C++ sometimes makes it very difficult to write fast code. + \item Maintenance- More programmers know C than C++. +\end{itemize} + +Advantages of C++: + +\begin{itemize} + \item smaller code - Templates allow Smaller and more readable code. + \item Maintenance - It is easier to add and modify code in C++ (than in C). + \item Verification - Functionality can be verified and debugged for + individual objects. +\end{itemize} + +I have decided to use C. Most of C++ advantages can be acquired +by using OOP methodologies. OOP methods that require inline functions +can't be used (without performance impact). GCC supports inline functions, +but this solution is not compatible. + + + +\section{\Wine\ basics} +\subsection{How it runs} +\Wine\ works in the following order: +\begin{enumerate} + \item \Wine\ loads the \windoz\ application into it's memory. + (in the process it, links + DLL's\footnote{DLL (Dynamically Linked Library) is linked on load-time.} + creates 16-bit segments). + \item \windoz\ code is executed. +\end{enumerate} + +\section{bibliography} +\begin{thebibliography}{99} + \bibitem{bib:WinManual} Charles Petzold {\em Programming + Windows~3.1}{} - 1992. \\ + On cover: {\em the Microsoft guide to writing applications for + windows~3.1}. \\ + Published by {\em Microsoft press}. +\end{thebibliography} + + +\newpage + + +\end{document} diff --git a/ipc/dde_atom.c b/ipc/dde_atom.c index e07690ca969..5ca9b4255d4 100644 --- a/ipc/dde_atom.c +++ b/ipc/dde_atom.c @@ -6,6 +6,7 @@ * File: dde_atom.c * Purpose : atom functionality for DDE */ +#ifdef CONFIG_IPC #include #include @@ -106,11 +107,11 @@ void ATOM_GlobalInit(void) } /*********************************************************************** - * GlobalAddAtom (USER.268) + * DDE_GlobalAddAtom */ /* important! don't forget to unlock semaphores before return */ -ATOM GlobalAddAtom( SEGPTR name ) +ATOM DDE_GlobalAddAtom( SEGPTR name ) { int atom_idx; int atom_ofs; @@ -164,10 +165,10 @@ ATOM GlobalAddAtom( SEGPTR name ) } /*********************************************************************** - * GlobalDeleteAtom (USER.269) + * DDE_GlobalDeleteAtom */ -ATOM GlobalDeleteAtom( ATOM atom ) +ATOM DDE_GlobalDeleteAtom( ATOM atom ) { int atom_idx; int atom_ofs; @@ -203,9 +204,9 @@ ATOM GlobalDeleteAtom( ATOM atom ) } /*********************************************************************** - * GlobalFindAtom (USER.270) + * DDE_GlobalFindAtom */ -ATOM GlobalFindAtom( SEGPTR name ) +ATOM DDE_GlobalFindAtom( SEGPTR name ) { int atom_idx; int atom_ofs; @@ -242,9 +243,9 @@ ATOM GlobalFindAtom( SEGPTR name ) } /*********************************************************************** - * GlobalGetAtomName (USER.271) + * DDE_GlobalGetAtomName */ -WORD GlobalGetAtomName( ATOM atom, LPSTR buffer, short count ) +WORD DDE_GlobalGetAtomName( ATOM atom, LPSTR buffer, short count ) { int atom_idx, atom_ofs; int size; @@ -283,3 +284,4 @@ WORD GlobalGetAtomName( ATOM atom, LPSTR buffer, short count ) return size; } +#endif /* CONFIG_IPC */ diff --git a/ipc/dde_mem.c b/ipc/dde_mem.c index f19b013afdf..5e9c03d8366 100644 --- a/ipc/dde_mem.c +++ b/ipc/dde_mem.c @@ -7,6 +7,8 @@ * Purpose : shared DDE memory functionality for DDE *************************************************************************** */ +#ifdef CONFIG_IPC + #include #include #include @@ -280,3 +282,5 @@ void DDE_mem_init() nr_of_bits= BITS_PER_BYTE * sizeof(main_block->free_handles); AssembleArray( &free_handles, main_block->free_handles, nr_of_bits); } + +#endif /* CONFIG_IPC */ diff --git a/ipc/dde_proc.c b/ipc/dde_proc.c index 9f5f59e9010..df6e6a8aff9 100644 --- a/ipc/dde_proc.c +++ b/ipc/dde_proc.c @@ -7,6 +7,12 @@ * Purpose : DDE signals and processes functionality for DDE *************************************************************************** */ +#ifdef CONFIG_IPC + +#if defined(__FreeBSD__) || defined(__NetBSD__) +#define msgbuf mymsg +#endif + #include #include #include @@ -716,3 +722,4 @@ void DDE_DestroyWindow(HWND hwnd) } } +#endif /* CONFIG_IPC */ diff --git a/ipc/generic_hash.c b/ipc/generic_hash.c index f5e0f44d566..df0449b8281 100644 --- a/ipc/generic_hash.c +++ b/ipc/generic_hash.c @@ -5,6 +5,8 @@ * Purpose : dynamically growing hash, may use shared or local memory. *************************************************************************** */ +#ifdef CONFIG_IPC + #include #include #include @@ -677,3 +679,5 @@ HASH_ITEM *access_local_hash(HASH_PTR ptr) { return ptr.ptr; } + +#endif /* CONFIG_IPC */ diff --git a/ipc/shm_block.c b/ipc/shm_block.c index 77ff766950f..259378f2bbe 100644 --- a/ipc/shm_block.c +++ b/ipc/shm_block.c @@ -7,6 +7,7 @@ * Purpose: Treat a shared memory block. *************************************************************************** */ +#ifdef CONFIG_IPC #define inline __inline__ #include @@ -76,7 +77,7 @@ struct shm_block *shm_attach_block(int shm_id, int proc_idx, shmctl(shm_id, IPC_STAT, &ds ); block=(struct shm_block*)shmat(shm_id, NULL, 0); - if (block==NULL) return NULL; + if (block==NULL || block == (struct shm_block*) -1) return NULL; this=(struct local_shm_map *)malloc(sizeof(*this)); this->next= shm_map; @@ -190,3 +191,5 @@ void shm_delete_chain(int *shmid) *shmid=-1; shmdt((char *)block); } + +#endif /* CONFIG_IPC */ diff --git a/ipc/shm_fragment.c b/ipc/shm_fragment.c index 098d6cc14a9..15c51feec4b 100644 --- a/ipc/shm_fragment.c +++ b/ipc/shm_fragment.c @@ -7,6 +7,8 @@ * Purpose: Data fragments and free list items. Allocate and free blocks. *************************************************************************** */ +#ifdef CONFIG_IPC + #include /* for debugging only */ #include #include /* for "stddeb" */ @@ -176,3 +178,5 @@ void shm_print_free_list(struct shm_block *block) fprintf(stddeb," [total free=%04x]\n",block->free); fflush(stddeb); } + +#endif /* CONFIG_IPC */ diff --git a/ipc/shm_main_blk.c b/ipc/shm_main_blk.c index 96b4681e8ed..fdc230718b4 100644 --- a/ipc/shm_main_blk.c +++ b/ipc/shm_main_blk.c @@ -7,6 +7,8 @@ * Purpose: Main Wine's shared memory block *************************************************************************** */ +#ifdef CONFIG_IPC + #define inline __inline__ #include #include @@ -265,3 +267,5 @@ static void shm_main_refresh() for (proc_idx= 0 ; proc_idx < DDE_PROCS ; proc_idx++) dde_proc_refresh( &main_block->proc[proc_idx] ); } + +#endif /* CONFIG_IPC */ diff --git a/ipc/shm_semaph.c b/ipc/shm_semaph.c index c2268089950..f730154c3ea 100644 --- a/ipc/shm_semaph.c +++ b/ipc/shm_semaph.c @@ -7,6 +7,8 @@ * Purpose: Handle semaphores for shared memory operations. *************************************************************************** */ +#ifdef CONFIG_IPC + #define inline __inline__ #include #include @@ -134,3 +136,5 @@ void shm_sem_done(shm_sem *semptr) *semptr= -1; } + +#endif /* CONFIG_IPC */ diff --git a/ipc/wine_test_stub.c b/ipc/wine_test_stub.c index fb1747e66d0..dd9499cea92 100644 --- a/ipc/wine_test_stub.c +++ b/ipc/wine_test_stub.c @@ -23,7 +23,7 @@ int LDT_GetEntry( int entry, ldt_entry *content ) return 0; } -int LDT_SetEntry( int entry, ldt_entry *content ) +int LDT_SetEntry( int entry, ldt_entry const *content ) { return 0; } diff --git a/loader/Makefile.in b/loader/Makefile.in index f2501204a45..bf3e4cfe14e 100644 --- a/loader/Makefile.in +++ b/loader/Makefile.in @@ -28,7 +28,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/loader/main.c b/loader/main.c index 384e3f32e2b..9bb0185188e 100644 --- a/loader/main.c +++ b/loader/main.c @@ -66,6 +66,9 @@ int MAIN_Init(void) /* Initialize interrupt vectors */ if (!INT_Init()) return 0; + /* Initialize DOS memory */ + if (!DOSMEM_Init()) return 0; + /* Initialize signal handling */ init_wine_signals(); diff --git a/loader/module.c b/loader/module.c index 45891b3bc78..f518e6c94fe 100644 --- a/loader/module.c +++ b/loader/module.c @@ -39,7 +39,6 @@ BOOL MODULE_Init(void) NE_MODULE *pModule; SEGTABLEENTRY *pSegTable; struct dll_table_s *table; - char *dosmem; int i; /* Create the built-in modules */ @@ -82,47 +81,10 @@ BOOL MODULE_Init(void) hFirstModule = hModule; } - /* Initialize some KERNEL exported values */ + /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */ - if (!(hModule = GetModuleHandle( "KERNEL" ))) return TRUE; + MODULE_SetEntryPoint( GetModuleHandle( "KERNEL" ), 178, GetWinFlags() ); - /* KERNEL.178: __WINFLAGS */ - MODULE_SetEntryPoint( hModule, 178, GetWinFlags() ); - - /* Allocate 7 64k segments for 0000, A000, B000, C000, D000, E000, F000. */ - - dosmem = malloc( 0x70000 ); - - MODULE_SetEntryPoint( hModule, 183, /* KERNEL.183: __0000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 193, /* KERNEL.193: __0040H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x400, - 0x100, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 174, /* KERNEL.174: __A000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x10000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 181, /* KERNEL.181: __B000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x20000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 182, /* KERNEL.182: __B800H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x28000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 195, /* KERNEL.195: __C000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x30000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 179, /* KERNEL.179: __D000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x40000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 190, /* KERNEL.190: __E000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x50000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 173, /* KERNEL.173: __ROMBIOS */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x60000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); - MODULE_SetEntryPoint( hModule, 194, /* KERNEL.194: __F000H */ - GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x60000, - 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); return TRUE; } diff --git a/loader/ne_image.c b/loader/ne_image.c index 2a4e9ea62aa..1450c0a62ae 100644 --- a/loader/ne_image.c +++ b/loader/ne_image.c @@ -39,6 +39,8 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) int fd; struct relocation_entry_s *rep, *reloc_entries; BYTE *func_name; + int size; + char* mem; char buffer[100]; int ordinal, additive; @@ -51,23 +53,37 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) if (!pSeg->filepos) return TRUE; /* No file image, just return */ - if (pSeg->flags & NE_SEGFLAGS_ITERATED) - { - fprintf(stderr, "Sorry, iterated segments are not supported\n" - "Please report that %*.*s, segment %d is such a segment\n", - *((BYTE*)pModule + pModule->name_table), - *((BYTE*)pModule + pModule->name_table), - (char *)pModule + pModule->name_table + 1, - segnum - ); - exit(1); - } - fd = MODULE_OpenFile( hModule ); dprintf_module( stddeb, "Loading segment %d, selector=%04x\n", segnum, pSeg->selector ); lseek( fd, pSeg->filepos << pModule->alignment, SEEK_SET ); - read( fd, GlobalLock( pSeg->selector ), pSeg->size ? pSeg->size : 0x10000); + size = pSeg->size ? pSeg->size : 0x10000; + mem = GlobalLock(pSeg->selector); + if (!(pSeg->flags & NE_SEGFLAGS_ITERATED)) + read(fd, mem, size); + else { + /* + The following bit of code for "iterated segments" was written without + any documentation on the format of these segments. It seems to work, + but may be missing something. If you have any doco please either send + it to me or fix the code yourself. gfm@werple.mira.net.au + */ + char* buff = malloc(size); + char* curr = buff; + read(fd, buff, size); + while(curr < buff + size) { + unsigned int rept = *((short*) curr)++; + unsigned int len = *((short*) curr)++; + for(; rept > 0; rept--) { + char* bytes = curr; + unsigned int byte; + for(byte = 0; byte < len; byte++) + *mem++ = *bytes++; + } + curr += len; + } + free(buff); + } if (!(pSeg->flags & NE_SEGFLAGS_RELOC_DATA)) return TRUE; /* No relocation data, we are done */ diff --git a/loader/signal.c b/loader/signal.c index 82d96517049..d943bc5cb26 100644 --- a/loader/signal.c +++ b/loader/signal.c @@ -80,19 +80,21 @@ void init_wine_signals(void) it aligned */ segv_act.sa_restorer = (void (*)()) (((unsigned int)(cstack) + sizeof(cstack) - 4) & ~3); - usr2_act.sa_restorer= segv_act.sa_restorer; - usr2_act.sa_handler = (__sighandler_t) stop_wait; /* Point to the top of the stack, minus 4 just in case, and make it aligned */ wine_sigaction(SIGSEGV, &segv_act, NULL); wine_sigaction(SIGILL, &segv_act, NULL); wine_sigaction(SIGFPE, &segv_act, NULL); - wine_sigaction(SIGUSR2, &usr2_act, NULL); #ifdef SIGBUS wine_sigaction(SIGBUS, &segv_act, NULL); #endif wine_sigaction(SIGTRAP, &segv_act, NULL); /* For breakpoints */ -#endif +#ifdef CONFIG_IPC + usr2_act.sa_restorer= segv_act.sa_restorer; + usr2_act.sa_handler = (__sighandler_t) stop_wait; + wine_sigaction(SIGUSR2, &usr2_act, NULL); +#endif /* CONFIG_IPC */ +#endif /* linux */ #if defined(__NetBSD__) || defined(__FreeBSD__) sigset_t sig_mask; struct sigaltstack ss; @@ -134,6 +136,7 @@ void init_wine_signals(void) perror("sigaction: SIGTRAP"); exit(1); } +#ifdef CONFIG_IPC usr2_act.sa_handler = (void (*)) stop_wait; /* For breakpoints */ usr2_act.sa_flags = SA_ONSTACK; usr2_act.sa_mask = sig_mask; @@ -141,7 +144,8 @@ void init_wine_signals(void) perror("sigaction: SIGUSR2"); exit(1); } -#endif +#endif /* CONFIG_IPC */ +#endif /* __FreeBSD__ || __NetBSD__ */ } #endif /* ifndef WINELIB */ diff --git a/loader/task.c b/loader/task.c index 7350965f387..b2180f43889 100644 --- a/loader/task.c +++ b/loader/task.c @@ -528,7 +528,7 @@ HTASK TASK_CreateTask( HMODULE hModule, HANDLE hInstance, HANDLE hPrevInstance, /*********************************************************************** * TASK_DeleteTask */ -void TASK_DeleteTask( HTASK hTask ) +static void TASK_DeleteTask( HTASK hTask ) { TDB *pTask; @@ -600,11 +600,16 @@ void TASK_Reschedule(void) TDB *pOldTask = NULL, *pNewTask; HTASK hTask = 0; +#ifdef CONFIG_IPC dde_reschedule(); +#endif /* First check if there's a task to kill */ if (hTaskToKill && (hTaskToKill != hCurrentTask)) + { TASK_DeleteTask( hTaskToKill ); + hTaskToKill = 0; + } /* If current task is locked, simply return */ diff --git a/loader/wine.c b/loader/wine.c deleted file mode 100644 index b88f985a914..00000000000 --- a/loader/wine.c +++ /dev/null @@ -1,756 +0,0 @@ -static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $"; -static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; - -#include -#include -#include -#include -#include -#include -#ifdef linux -#include -#include -#include -#include -#endif -#include -#include -#include "neexe.h" -#include "segmem.h" -#include "prototypes.h" -#include "dlls.h" -#include "wine.h" -#include "windows.h" -#include "wineopts.h" -#include "arch.h" -#include "options.h" - -/* #define DEBUG_FIXUP */ - -extern int CallToInit16(unsigned long csip, unsigned long sssp, - unsigned short ds); -extern void CallTo32(); - -char * GetModuleName(struct w_files * wpnt, int index, char *buffer); -extern unsigned char ran_out; -extern char WindowsPath[256]; -char *WIN_ProgramName; - -unsigned short WIN_StackSize; -unsigned short WIN_HeapSize; - -struct w_files * wine_files = NULL; - -int WineForceFail = 0; - -char **Argv; -int Argc; -struct mz_header_s *CurrentMZHeader; -struct ne_header_s *CurrentNEHeader; -int CurrentNEFile; -HINSTANCE hSysRes; - -static char *DLL_Extensions[] = { "dll", "exe", NULL }; -static char *EXE_Extensions[] = { "exe", NULL }; -static char *WinePath = NULL; - -FILE *SpyFp = NULL; - -/********************************************************************** - * myerror - */ -void -myerror(const char *s) -{ - if (s == NULL) - perror("wine"); - else - fprintf(stderr, "wine: %s\n", s); - - exit(1); -} - -/********************************************************************** - * GetFilenameFromInstance - */ -char * -GetFilenameFromInstance(unsigned short instance) -{ - register struct w_files *w = wine_files; - - while (w && w->hinstance != instance) - w = w->next; - - if (w) - return w->filename; - else - return NULL; -} - -struct w_files * -GetFileInfo(unsigned short instance) -{ - register struct w_files *w = wine_files; - - while (w && w->hinstance != instance) - w = w->next; - - return w; -} - -#ifndef WINELIB -/********************************************************************** - * - * Load MZ Header - */ -void load_mz_header(int fd, struct mz_header_s *mz_header) -{ - if (read(fd, mz_header, sizeof(struct mz_header_s)) != - sizeof(struct mz_header_s)) - { - myerror("Unable to read MZ header from file"); - } -} - -void load_ne_header (int fd, struct ne_header_s *ne_header) -{ - if (read(fd, ne_header, sizeof(struct ne_header_s)) - != sizeof(struct ne_header_s)) - { - myerror("Unable to read NE header from file"); - } -} -#endif - -/********************************************************************** - * LoadImage - * Load one NE format executable into memory - */ -HINSTANCE LoadImage(char *modulename, int filetype, int change_dir) -{ - unsigned int read_size; - int i; - struct w_files * wpnt, *wpnt1; - unsigned int status; - char buffer[256]; - char *fullname; - - /* - * search file - */ - fullname = FindFile(buffer, sizeof(buffer), modulename, - (filetype == EXE ? EXE_Extensions : DLL_Extensions), - WindowsPath); - if (fullname == NULL) - { - fprintf(stderr, "LoadImage: I can't find %s.dll | %s.exe !\n", - modulename, modulename); - return (HINSTANCE) NULL; - } - - fullname = GetDosFileName(fullname); - WIN_ProgramName = strdup(fullname); - - fprintf(stderr,"LoadImage: loading %s (%s)\n [%s]\n", - modulename, buffer, WIN_ProgramName); - - if (change_dir && fullname) - { - char dirname[256]; - char *p; - - strcpy(dirname, fullname); - p = strrchr(dirname, '\\'); - *p = '\0'; - - DOS_SetDefaultDrive(dirname[0] - 'A'); - DOS_ChangeDir(dirname[0] - 'A', dirname + 2); - } - - /* First allocate a spot to store the info we collect, and add it to - * our linked list. - */ - - wpnt = (struct w_files *) malloc(sizeof(struct w_files)); - if(wine_files == NULL) - wine_files = wpnt; - else { - wpnt1 = wine_files; - while(wpnt1->next) wpnt1 = wpnt1->next; - wpnt1->next = wpnt; - }; - wpnt->next = NULL; - - /* - * Open file for reading. - */ - wpnt->fd = open(buffer, O_RDONLY); - if (wpnt->fd < 0) - { - myerror(NULL); - } - /* - * Establish header pointers. - */ - wpnt->filename = strdup(buffer); - wpnt->name = NULL; - if(modulename) wpnt->name = strdup(modulename); - - wpnt->mz_header = (struct mz_header_s *) malloc(sizeof(struct mz_header_s));; - status = lseek(wpnt->fd, 0, SEEK_SET); - load_mz_header (wpnt->fd, wpnt->mz_header); - if (wpnt->mz_header->must_be_0x40 != 0x40) - myerror("This is not a Windows program"); - - wpnt->ne_header = (struct ne_header_s *) malloc(sizeof(struct ne_header_s)); - status = lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET); - load_ne_header (wpnt->fd, wpnt->ne_header); - if (wpnt->ne_header->header_type[0] != 'N' || - wpnt->ne_header->header_type[1] != 'E') - myerror("This is not a Windows program"); - - if(wine_files == wpnt){ - CurrentMZHeader = wpnt->mz_header; - CurrentNEHeader = wpnt->ne_header; - CurrentNEFile = wpnt->fd; - - WIN_StackSize = wpnt->ne_header->stack_length; - WIN_HeapSize = wpnt->ne_header->local_heap_length; - }; - - /* - * Create segment selectors. - */ -#ifndef WINELIB - status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + - wpnt->ne_header->segment_tab_offset, - SEEK_SET); - read_size = wpnt->ne_header->n_segment_tab * - sizeof(struct ne_segment_table_entry_s); - wpnt->seg_table = (struct ne_segment_table_entry_s *) malloc(read_size); - if (read(wpnt->fd, wpnt->seg_table, read_size) != read_size) - myerror("Unable to read segment table header from file"); - wpnt->selector_table = CreateSelectors(wpnt); - wpnt->hinstance - = wpnt-> - selector_table[wpnt->ne_header->auto_data_seg-1].selector; - - /* Get the lookup table. This is used for looking up the addresses - of functions that are exported */ - - read_size = wpnt->ne_header->entry_tab_length; - wpnt->lookup_table = (char *) malloc(read_size); - lseek(wpnt->fd, wpnt->mz_header->ne_offset + - wpnt->ne_header->entry_tab_offset, SEEK_SET); - if (read(wpnt->fd, wpnt->lookup_table, read_size) != read_size) - myerror("Unable to read lookup table header from file"); - - /* Get the iname table. This is used for looking up the names - of functions that are exported */ - - status = lseek(wpnt->fd, wpnt->ne_header->nrname_tab_offset, SEEK_SET); - read_size = wpnt->ne_header->nrname_tab_length; - wpnt->nrname_table = (char *) malloc(read_size); - if (read(wpnt->fd, wpnt->nrname_table, read_size) != read_size) - myerror("Unable to read nrname table header from file"); - - status = lseek(wpnt->fd, wpnt->mz_header->ne_offset + - wpnt->ne_header->rname_tab_offset, SEEK_SET); - read_size = wpnt->ne_header->moduleref_tab_offset - - wpnt->ne_header->rname_tab_offset; - wpnt->rname_table = (char *) malloc(read_size); - if (read(wpnt->fd, wpnt->rname_table, read_size) != read_size) - myerror("Unable to read rname table header from file"); - - /* Now get the module name */ - - wpnt->name = (char*) malloc(*wpnt->rname_table + 1); - memcpy(wpnt->name, wpnt->rname_table+1, *wpnt->rname_table); - wpnt->name[*wpnt->rname_table] = 0; -#endif - /* - * Now load any DLLs that this module refers to. - */ - for(i=0; ine_header->n_mod_ref_tab; i++){ - char buff[14]; - char buff2[256]; - int fd, j; - GetModuleName(wpnt, i + 1, buff); - -#ifndef WINELIB - if(FindDLLTable(buff)) continue; /* This module already loaded */ -#endif - - LoadImage(buff, DLL, 0); -/* - fprintf(stderr,"Unable to load:%s\n", buff); -*/ - } -return(wpnt->hinstance); -} - - -/********************************************************************** - * main - */ -_WinMain(int argc, char **argv) -{ - int segment; - char *p; - char *sysresname; - char filename[100]; - char syspath[256]; - char exe_path[256]; -#ifdef WINESTAT - char * cp; -#endif - struct w_files * wpnt; - int cs_reg, ds_reg, ss_reg, ip_reg, sp_reg; - int i; - int rv; - - Argc = argc - 1; - Argv = argv + 1; - - WinePath = malloc(1024); - - getcwd(WinePath, 512); - - if ((p = getenv("WINEPATH")) != NULL) { - strcat(WinePath, ";"); - strcat(WinePath, p); - } - - if ((hInstMain = LoadImage(Argv[0], EXE, 1)) == (HINSTANCE) NULL ) { - fprintf(stderr, "wine: can't find %s!.\n", Argv[0]); - exit(1); - } - - GetPrivateProfileString("wine", "SystemResources", "sysres.dll", - filename, sizeof(filename), WINE_INI); - - hSysRes = LoadImage(filename, DLL); - if (hSysRes == (HINSTANCE)NULL) - fprintf(stderr, "wine: can't find %s!\n", filename); - else - printf("System Resources Loaded // hSysRes='%04X'\n", hSysRes); - - /* - * Fixup references. - */ - wpnt = wine_files; - for(wpnt = wine_files; wpnt; wpnt = wpnt->next) - { - for (segment = 0; segment < wpnt->ne_header->n_segment_tab; segment++) - { - if (FixupSegment(wpnt, segment) < 0) - { - myerror("fixup failed."); - } - } - } - -#ifdef WINESTAT - cp = strrchr(argv[0], '/'); - if(!cp) cp = argv[0]; - else cp++; - if(strcmp(cp,"winestat") == 0) { - winestat(); - exit(0); - }; -#endif - - /* - * Initialize signal handling. - */ - init_wine_signals(); - - /* - * Fixup stack and jump to start. - */ - ds_reg = (wine_files-> - selector_table[wine_files->ne_header->auto_data_seg-1].selector); - cs_reg = wine_files->selector_table[wine_files->ne_header->cs-1].selector; - ip_reg = wine_files->ne_header->ip; - ss_reg = wine_files->selector_table[wine_files->ne_header->ss-1].selector; - sp_reg = wine_files->ne_header->sp; - - if (Options.debug) wine_debug(0, NULL); - - rv = CallToInit16(cs_reg << 16 | ip_reg, ss_reg << 16 | sp_reg, ds_reg); - printf ("rv = %x\n", rv); -} - -void InitializeLoadedDLLs() -{ - struct w_files * wpnt; - int cs_reg, ds_reg, ip_reg; - int rv; - - fprintf(stderr, "Initializing DLLs\n"); - - /* - * Initialize libraries - */ - wpnt = wine_files; - for(wpnt = wine_files; wpnt; wpnt = wpnt->next) - { - /* - * Is this a library? - */ - if (wpnt->ne_header->format_flags & 0x8000) - { - if (!(wpnt->ne_header->format_flags & 0x0001)) - { - /* Not SINGLEDATA */ - fprintf(stderr, "Library is not marked SINGLEDATA\n"); - exit(1); - } - - ds_reg = wpnt->selector_table[wpnt-> - ne_header->auto_data_seg-1].selector; - cs_reg = wpnt->selector_table[wpnt->ne_header->cs-1].selector; - ip_reg = wpnt->ne_header->ip; - - fprintf(stderr, "Initializing %s, cs:ip %04x:%04x, ds %04x\n", - wpnt->name, cs_reg, ip_reg, ds_reg); - - rv = CallTo16(cs_reg << 16 | ip_reg, ds_reg); - printf ("rv = %x\n", rv); - } - } -} - - -/********************************************************************** - * GetImportedName - */ -char * -GetImportedName(int fd, struct mz_header_s *mz_header, - struct ne_header_s *ne_header, int name_offset, char *buffer) -{ - char *p; - int length; - int status; - int i; - - status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset + - name_offset, SEEK_SET); - length = 0; - read(fd, &length, 1); /* Get the length byte */ - length = CONV_CHAR_TO_LONG (length); - read(fd, buffer, length); - buffer[length] = 0; - return buffer; -} - -/********************************************************************** - * GetModuleName - */ -char * -GetModuleName(struct w_files * wpnt, int index, char *buffer) -{ - int fd = wpnt->fd; - struct mz_header_s *mz_header = wpnt->mz_header; - struct ne_header_s *ne_header = wpnt->ne_header; - char *p; - int length; - WORD name_offset, status; - int i; - - status = lseek(fd, mz_header->ne_offset + ne_header->moduleref_tab_offset + - 2*(index - 1), SEEK_SET); - name_offset = 0; - read(fd, &name_offset, 2); - name_offset = CONV_SHORT (name_offset); - status = lseek(fd, mz_header->ne_offset + ne_header->iname_tab_offset + - name_offset, SEEK_SET); - length = 0; - read(fd, &length, 1); /* Get the length byte */ - length = CONV_CHAR_TO_LONG (length); - read(fd, buffer, length); - buffer[length] = 0; - - /* Module names are always upper case */ - for(i=0; i= 'a' && buffer[i] <= 'z') buffer[i] &= ~0x20; - - return buffer; -} - - -#ifndef WINELIB -/********************************************************************** - * FixupSegment - */ -int -FixupSegment(struct w_files * wpnt, int segment_num) -{ - int fd = wpnt->fd; - struct mz_header_s * mz_header = wpnt->mz_header; - struct ne_header_s *ne_header = wpnt->ne_header; - struct ne_segment_table_entry_s *seg_table = wpnt->seg_table; - struct segment_descriptor_s *selector_table = wpnt->selector_table; - struct relocation_entry_s *rep, *rep1; - struct ne_segment_table_entry_s *seg; - struct segment_descriptor_s *sel; - struct dll_table_entry_s *dll_table; - int status; - unsigned short *sp; - unsigned int selector, address; - unsigned int next_addr; - int ordinal; - char dll_name[257]; - char func_name[257]; - int i, n_entries; - int additive; - - seg = &seg_table[segment_num]; - sel = &selector_table[segment_num]; - -#ifdef DEBUG_FIXUP - printf("Segment fixups for %s, segment %d, selector %x\n", - wpnt->name, segment_num, (int) sel->base_addr >> 16); -#endif - - if ((seg->seg_data_offset == 0) || - !(seg->seg_flags & NE_SEGFLAGS_RELOC_DATA)) - return 0; - - /* - * Go through the relocation table on entry at a time. - */ - i = seg->seg_data_length; - if (i == 0) - i = 0x10000; - - status = lseek(fd, seg->seg_data_offset * - (1 << ne_header->align_shift_count) + i, SEEK_SET); - n_entries = 0; - read(fd, &n_entries, sizeof(short int)); - rep = (struct relocation_entry_s *) - malloc(n_entries * sizeof(struct relocation_entry_s)); - - if (read(fd,rep, n_entries * sizeof(struct relocation_entry_s)) != - n_entries * sizeof(struct relocation_entry_s)) - { - myerror("Unable to read relocation information"); - } - - rep1 = rep; - - for (i = 0; i < n_entries; i++, rep++) - { - /* - * Get the target address corresponding to this entry. - */ - additive = 0; - - switch (rep->relocation_type) - { - case NE_RELTYPE_ORDINALADD: - additive = 1; - - case NE_RELTYPE_ORDINAL: - if (GetModuleName(wpnt, rep->target1, - dll_name) == NULL) - { - fprintf(stderr, "NE_RELTYPE_ORDINAL failed"); - return -1; - } - - ordinal = rep->target2; - - status = GetEntryDLLOrdinal(dll_name, ordinal, &selector, - &address); - if (status) - { - char s[80]; - - sprintf(s, "Bad DLL name '%s.%d'", dll_name, ordinal); - myerror(s); - return -1; - } - -#ifdef DEBUG_FIXUP - printf("%d: %s.%d: %04.4x:%04.4x\n", i + 1, dll_name, ordinal, - selector, address); -#endif - break; - - case NE_RELTYPE_NAMEADD: - additive = 1; - - case NE_RELTYPE_NAME: - if (GetModuleName(wpnt, rep->target1, dll_name) - == NULL) - { - fprintf(stderr,"NE_RELTYPE_NAME failed"); - return -1; - } - - if (GetImportedName(fd, mz_header, ne_header, - rep->target2, func_name) == NULL) - { - fprintf(stderr,"getimportedname failed"); - return -1; - } - - status = GetEntryDLLName(dll_name, func_name, &selector, - &address); - if (status) - { - char s[80]; - - sprintf(s, "Bad DLL name '%s (%s)'", dll_name,func_name); - myerror(s); - return -1; - } - -#ifdef DEBUG_FIXUP - printf("%d: %s %s.%d: %04.4x:%04.4x\n", i + 1, func_name, - dll_name, ordinal, selector, address); -#endif - break; - - case NE_RELTYPE_INTERNAL: - case NE_RELTYPE_INT1: - if (rep->target1 == 0x00ff) - { - address = GetEntryPointFromOrdinal(wpnt, rep->target2); - selector = (address >> 16) & 0xffff; - address &= 0xffff; - } - else - { - selector = selector_table[rep->target1-1].selector; - address = rep->target2; - } - -#ifdef DEBUG_FIXUP - printf("%d: %04.4x:%04.4x\n", i + 1, selector, address); -#endif - break; - - case 7: - /* Relocation type 7: - * - * These appear to be used as fixups for the Windows - * floating point emulator. Let's just ignore them and - * try to use the hardware floating point. Linux should - * successfully emulate the coprocessor if it doesn't - * exist. - */ -#ifdef DEBUG_FIXUP - printf("%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", - i + 1, rep->address_type, rep->relocation_type, - rep->offset); - printf("TARGET %04.4x %04.4x\n", rep->target1, rep->target2); -#endif - continue; - - default: - fprintf(stderr,"%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", - i + 1, rep->address_type, rep->relocation_type, - rep->offset); - fprintf(stderr,"TARGET %04.4x %04.4x\n", - rep->target1, rep->target2); - free(rep1); - return -1; - } - - /* - * Stuff the right size result in. - */ - sp = (unsigned short *) ((char *) sel->base_addr + rep->offset); - if (additive) - { - if (FindDLLTable(dll_name) == NULL) - additive = 2; - - fprintf(stderr,"%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", - i + 1, rep->address_type, rep->relocation_type, - rep->offset); - fprintf(stderr,"TARGET %04.4x %04.4x\n", - rep->target1, rep->target2); - fprintf(stderr, " Additive = %d\n", additive); - } - - switch (rep->address_type) - { - case NE_RADDR_OFFSET16: - do { -#ifdef DEBUG_FIXUP - printf(" %04.4x:%04.4x:%04.4x OFFSET16\n", - (unsigned long) sp >> 16, (int) sp & 0xFFFF, *sp); -#endif - next_addr = *sp; - *sp = (unsigned short) address; - if (additive == 2) - *sp += next_addr; - sp = (unsigned short *) ((char *) sel->base_addr + next_addr); - } - while (next_addr != 0xffff && !additive); - - break; - - case NE_RADDR_POINTER32: - do { -#ifdef DEBUG_FIXUP - printf(" %04.4x:%04.4x:%04.4x POINTER32\n", - (unsigned long) sp >> 16, (int) sp & 0xFFFF, *sp); -#endif - next_addr = *sp; - *sp = (unsigned short) address; - if (additive == 2) - *sp += next_addr; - *(sp+1) = (unsigned short) selector; - sp = (unsigned short *) ((char *) sel->base_addr + next_addr); - } - while (next_addr != 0xffff && !additive); - - break; - - case NE_RADDR_SELECTOR: - do { -#ifdef DEBUG_FIXUP - printf(" %04.4x:%04.4x:%04.4x SELECTOR\n", - (unsigned long) sp >> 16, (int) sp & 0xFFFF, *sp); -#endif - next_addr = *sp; - *sp = (unsigned short) selector; - sp = (unsigned short *) ((char *) sel->base_addr + next_addr); - if (rep->relocation_type == NE_RELTYPE_INT1) - break; - } - while (next_addr != 0xffff && !additive); - - break; - - default: - printf("%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ", - i + 1, rep->address_type, rep->relocation_type, - rep->offset); - printf("TARGET %04.4x %04.4x\n", rep->target1, rep->target2); - free(rep1); - return -1; - } - } - - free(rep1); - return 0; -} - -/********************************************************************** - * GetProcAddress - */ -FARPROC GetProcAddress(HINSTANCE hinstance, char *proc_name) -{ - if ((int) proc_name & 0xffff0000) - printf("GetProcAddress: %#04x, '%s'\n", hinstance, proc_name); - else - printf("GetProcAddress: %#04x, %d\n", hinstance, (int) proc_name); - - return NULL; -} -#endif diff --git a/memory/Makefile.in b/memory/Makefile.in index e056dce1048..791bdaed221 100644 --- a/memory/Makefile.in +++ b/memory/Makefile.in @@ -32,7 +32,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/memory/atom.c b/memory/atom.c index db768634746..359158c2a8c 100644 --- a/memory/atom.c +++ b/memory/atom.c @@ -22,6 +22,11 @@ #include "stackframe.h" #include "user.h" +#ifdef CONFIG_IPC +#include "dde_atom.h" +#include "options.h" +#endif + #define DEFAULT_ATOMTABLE_SIZE 37 #define MIN_STR_ATOM 0xc000 @@ -321,36 +326,48 @@ WORD GetAtomName( ATOM atom, LPSTR buffer, short count ) /*********************************************************************** - * LocalAddAtom (USER.268) + * GlobalAddAtom (USER.268) */ -ATOM LocalAddAtom( SEGPTR str ) +ATOM GlobalAddAtom( SEGPTR str ) { +#ifdef CONFIG_IPC + if (Options.ipc) return DDE_GlobalAddAtom( str ); +#endif return ATOM_AddAtom( USER_HeapSel, str ); } /*********************************************************************** - * LocalDeleteAtom (USER.269) + * GlobalDeleteAtom (USER.269) */ -ATOM LocalDeleteAtom( ATOM atom ) +ATOM GlobalDeleteAtom( ATOM atom ) { +#ifdef CONFIG_IPC + if (Options.ipc) return DDE_GlobalDeleteAtom( atom ); +#endif return ATOM_DeleteAtom( USER_HeapSel, atom ); } /*********************************************************************** - * LocalFindAtom (USER.270) + * GlobalFindAtom (USER.270) */ -ATOM LocalFindAtom( SEGPTR str ) +ATOM GlobalFindAtom( SEGPTR str ) { +#ifdef CONFIG_IPC + if (Options.ipc) return DDE_GlobalFindAtom( str ); +#endif return ATOM_FindAtom( USER_HeapSel, str ); } /*********************************************************************** - * LocalGetAtomName (USER.271) + * GlobalGetAtomName (USER.271) */ -WORD LocalGetAtomName( ATOM atom, LPSTR buffer, short count ) +WORD GlobalGetAtomName( ATOM atom, LPSTR buffer, short count ) { +#ifdef CONFIG_IPC + if (Options.ipc) return DDE_GlobalGetAtomName( atom, buffer, count ); +#endif return ATOM_GetAtomName( USER_HeapSel, atom, buffer, count ); } diff --git a/memory/global.c b/memory/global.c index 704fe9d2edb..83f0dda282f 100644 --- a/memory/global.c +++ b/memory/global.c @@ -81,21 +81,6 @@ void debug_handles() if (printed) printf("\n"); } -/*********************************************************************** - * GLOBAL_FindArena - * - * Find the arena for a given handle - * (when handle is not serial - e.g. DDE) - */ -static GLOBALARENA *GLOBAL_FindArena( HGLOBAL handle) -{ - int i; - for (i = globalArenaSize-1 ; i>=0 ; i--) { - if (pGlobalArena[i].size!=0 && pGlobalArena[i].handle == handle) - return ( &pGlobalArena[i] ); - } - return NULL; -} /*********************************************************************** @@ -196,9 +181,11 @@ HGLOBAL GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL hOwner, /* Allocate the linear memory */ +#ifdef CONFIG_IPC if ((flags & GMEM_DDESHARE) && Options.ipc) - ptr= DDE_malloc(flags, size, &shmdata); + ptr = DDE_malloc(flags, size, &shmdata); else +#endif /* CONFIG_IPC */ ptr = malloc( size ); if (!ptr) return 0; @@ -216,6 +203,25 @@ HGLOBAL GLOBAL_Alloc( WORD flags, DWORD size, HGLOBAL hOwner, return handle; } + +#ifdef CONFIG_IPC +/*********************************************************************** + * GLOBAL_FindArena + * + * Find the arena for a given handle + * (when handle is not serial - e.g. DDE) + */ +static GLOBALARENA *GLOBAL_FindArena( HGLOBAL handle) +{ + int i; + for (i = globalArenaSize-1 ; i>=0 ; i--) { + if (pGlobalArena[i].size!=0 && pGlobalArena[i].handle == handle) + return ( &pGlobalArena[i] ); + } + return NULL; +} + + /*********************************************************************** * DDE_GlobalHandleToSel */ @@ -238,6 +244,7 @@ WORD DDE_GlobalHandleToSel( HGLOBAL handle ) return SELECTOROF( segptr ); } +#endif /* CONFIG_IPC */ /*********************************************************************** @@ -268,11 +275,13 @@ HGLOBAL GlobalReAlloc( HGLOBAL handle, DWORD size, WORD flags ) handle, size, flags ); if (!handle) return 0; +#ifdef CONFIG_IPC if (Options.ipc && (flags & GMEM_DDESHARE || is_dde_handle(handle))) { fprintf(stdnimp, "GlobalReAlloc: shared memory reallocating unimplemented\n"); return 0; } +#endif /* CONFIG_IPC */ pArena = GET_ARENA_PTR( handle ); @@ -366,7 +375,9 @@ HGLOBAL GlobalFree( HGLOBAL handle ) dprintf_global( stddeb, "GlobalFree: %04x\n", handle ); if (!GLOBAL_FreeBlock( handle )) return handle; /* failed */ +#ifdef CONFIG_IPC if (is_dde_handle(handle)) return DDE_GlobalFree(handle); +#endif /* CONFIG_IPC */ if (ptr) free( ptr ); return 0; } @@ -382,9 +393,13 @@ SEGPTR WIN16_GlobalLock( HGLOBAL handle ) dprintf_global( stddeb, "WIN16_GlobalLock(%04x) -> %08lx\n", handle, MAKELONG( 0, GlobalHandleToSel(handle)) ); if (!handle) return 0; - if ( !is_dde_handle(handle) && !GET_ARENA_PTR(handle)->base) - return (SEGPTR)0; +#ifdef CONFIG_IPC + if (is_dde_handle(handle)) + return (SEGPTR)MAKELONG( 0, DDE_GlobalHandleToSel(handle) ); +#endif /* CONFIG_IPC */ + + if (!GET_ARENA_PTR(handle)->base) return (SEGPTR)0; return (SEGPTR)MAKELONG( 0, GlobalHandleToSel(handle) ); } @@ -397,9 +412,9 @@ SEGPTR WIN16_GlobalLock( HGLOBAL handle ) LPSTR GlobalLock( HGLOBAL handle ) { if (!handle) return 0; - if (is_dde_handle(handle)) { - return DDE_AttachHandle(handle, NULL); - } +#ifdef CONFIG_IPC + if (is_dde_handle(handle)) return DDE_AttachHandle(handle, NULL); +#endif return (LPSTR)GET_ARENA_PTR(handle)->base; } @@ -644,9 +659,9 @@ WORD GlobalHandleToSel( HGLOBAL handle ) { dprintf_toolhelp( stddeb, "GlobalHandleToSel: %04x\n", handle ); if (!handle) return 0; - if (is_dde_handle(handle)) - return DDE_GlobalHandleToSel(handle); - +#ifdef CONFIG_IPC + if (is_dde_handle(handle)) return DDE_GlobalHandleToSel(handle); +#endif if (!(handle & 7)) { fprintf( stderr, "Program attempted invalid selector conversion\n" ); diff --git a/misc/Makefile.in b/misc/Makefile.in index c2bdaa7a4dc..f2b4a962719 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -36,7 +36,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/misc/clipboard.c b/misc/clipboard.c index e11c4a8128a..fef309d569c 100644 --- a/misc/clipboard.c +++ b/misc/clipboard.c @@ -143,6 +143,7 @@ HANDLE GetClipboardData(WORD wFormat) { LPCLIPFORMAT lpFormat = ClipFormats; dprintf_clipboard(stddeb,"GetClipboardData(%04X) !\n", wFormat); + if (!hWndClipboardOwner) return 0; if(wFormat == CF_TEXT && !wineOwnsSelection) { wait_for_selection=True; dprintf_clipboard(stddeb,"Requesting selection\n"); diff --git a/misc/file.c b/misc/file.c index 895e180095f..c3dc3ed857a 100644 --- a/misc/file.c +++ b/misc/file.c @@ -75,7 +75,7 @@ INT _lread (INT hFile, LPSTR lpBuffer, WORD wBytes) dprintf_file(stddeb, "_lread: handle %d, buffer = %p, length = %d\n", hFile, lpBuffer, wBytes); - result = wBytes == 0 ? 0 : read (hFile, lpBuffer, wBytes); + result = (wBytes == 0) ? 0 : read (hFile, lpBuffer, wBytes); if (result == -1) return HFILE_ERROR; @@ -454,12 +454,12 @@ WORD SetErrorMode(WORD x) ***************************************************************************/ LONG _hread(INT hf, LPSTR hpvBuffer, LONG cbBuffer) { - return cbBuffer == 0 ? 0 : read(hf, hpvBuffer, cbBuffer); + return (cbBuffer == 0) ? 0 : read(hf, hpvBuffer, cbBuffer); } /*************************************************************************** _hwrite ***************************************************************************/ LONG _hwrite(INT hf, LPCSTR hpvBuffer, LONG cbBuffer) { - return cbBuffer == 0 ? 0 : write(hf, hpvBuffer, cbBuffer); + return (cbBuffer == 0) ? 0 : write(hf, hpvBuffer, cbBuffer); } diff --git a/misc/main.c b/misc/main.c index 1eb750cbd2e..ceb206d33bd 100644 --- a/misc/main.c +++ b/misc/main.c @@ -846,3 +846,27 @@ void FileCDR(FARPROC x) { printf("FileCDR(%8x)\n", (int) x); } + +/*********************************************************************** +* GetWinDebugInfo (KERNEL.355) +*/ +BOOL GetWinDebugInfo(WINDEBUGINFO FAR* lpwdi, UINT flags) +{ + printf("GetWinDebugInfo(%8lx,%d) stub returning 0\n", (unsigned long)lpwdi, flags); + /* 0 means not in debugging mode/version */ + /* Can this type of debugging be used in wine ? */ + /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */ + return 0; +} + +/*********************************************************************** +* GetWinDebugInfo (KERNEL.355) +*/ +BOOL SetWinDebugInfo(WINDEBUGINFO FAR* lpwdi) +{ + printf("SetWinDebugInfo(%8lx) stub returning 0\n", (unsigned long)lpwdi); + /* 0 means not in debugging mode/version */ + /* Can this type of debugging be used in wine ? */ + /* Constants: WDI_OPTIONS WDI_FILTER WDI_ALLOCBREAK */ + return 0; +} diff --git a/misc/profile.c b/misc/profile.c index 3a400d793ad..d9067b1817c 100644 --- a/misc/profile.c +++ b/misc/profile.c @@ -382,6 +382,8 @@ WORD GetProfileInt (LPSTR AppName, LPSTR KeyName, int Default) BOOL WritePrivateProfileString (LPSTR AppName, LPSTR KeyName, LPSTR String, LPSTR FileName) { + if (!AppName || !KeyName || !String) /* Flush file to disk */ + return TRUE; return GetSetProfile (1, AppName, KeyName, String, "", 0, FileName); } diff --git a/misc/shell.c b/misc/shell.c index 21574703a2c..758feb25614 100644 --- a/misc/shell.c +++ b/misc/shell.c @@ -450,10 +450,14 @@ static char AppName[512], AppMisc[512]; */ INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam) { + char Template[512], AppTitle[512]; + switch(msg) { case WM_INITDIALOG: SendDlgItemMessage(hWnd,stc1,STM_SETICON,LOWORD(lParam),0); - SetWindowText(hWnd, AppName); + GetWindowText(hWnd, Template, 511); + sprintf(AppTitle, Template, AppName); + SetWindowText(hWnd, AppTitle); SetWindowText(GetDlgItem(hWnd,100), AppMisc); return 1; @@ -474,7 +478,7 @@ INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam) INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon) { if (szApp) { - sprintf(AppName, "About %s", szApp); + strcpy(AppName, szApp); } else { *AppName = 0; } diff --git a/miscemu/Imakefile b/miscemu/Imakefile index 74a89dfce05..60adb1ad09d 100644 --- a/miscemu/Imakefile +++ b/miscemu/Imakefile @@ -3,6 +3,7 @@ MODULE = miscemu SRCS = \ + dosmem.c \ dpmi.c \ emulate.c \ instr.c \ diff --git a/miscemu/Makefile.in b/miscemu/Makefile.in index c9af5eaaa83..426097d535b 100644 --- a/miscemu/Makefile.in +++ b/miscemu/Makefile.in @@ -9,9 +9,22 @@ LDCOMBINEFLAGS = @LDCOMBINEFLAGS@ MODULE = miscemu -SRCS = dpmi.c emulate.c instr.c int10.c int13.c \ - int1a.c int21.c int25.c int26.c int2a.c int2f.c int5c.c interrupts.c \ - ioports.c +SRCS = \ + dosmem.c \ + dpmi.c \ + emulate.c \ + instr.c \ + int10.c \ + int13.c \ + int1a.c \ + int21.c \ + int25.c \ + int26.c \ + int2a.c \ + int2f.c \ + int5c.c \ + interrupts.c \ + ioports.c OBJS = $(SRCS:.c=.o) @@ -29,7 +42,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/miscemu/dosmem.c b/miscemu/dosmem.c new file mode 100644 index 00000000000..4ac044438fd --- /dev/null +++ b/miscemu/dosmem.c @@ -0,0 +1,184 @@ +/* + * DOS memory emulation + * + * Copyright 1995 Alexandre Julliard + */ + +#include +#include +#include +#include "windows.h" +#include "global.h" +#include "ldt.h" +#include "miscemu.h" +#include "module.h" + + +HANDLE DOSMEM_BiosSeg; /* BIOS data segment at 0x40:0 */ + + +#pragma pack(1) + +typedef struct +{ + WORD Com1Addr; /* 00: COM1 I/O address */ + WORD Com2Addr; /* 02: COM2 I/O address */ + WORD Com3Addr; /* 04: COM3 I/O address */ + WORD Com4Addr; /* 06: COM4 I/O address */ + WORD Lpt1Addr; /* 08: LPT1 I/O address */ + WORD Lpt2Addr; /* 0a: LPT2 I/O address */ + WORD Lpt3Addr; /* 0c: LPT3 I/O address */ + WORD Lpt4Addr; /* 0e: LPT4 I/O address */ + WORD InstalledHardware; /* 10: Installed hardware flags */ + BYTE POSTstatus; /* 12: Power-On Self Test status */ + WORD MemSize WINE_PACKED; /* 13: Base memory size in Kb */ + WORD unused1 WINE_PACKED; /* 15: Manufacturing test scratch pad */ + BYTE KbdFlags1; /* 17: Keyboard flags 1 */ + BYTE KbdFlags2; /* 18: Keyboard flags 2 */ + BYTE unused2; /* 19: Keyboard driver workspace */ + WORD NextKbdCharPtr; /* 1a: Next character in kbd buffer */ + WORD FirstKbdCharPtr; /* 1c: First character in kbd buffer */ + WORD KbdBuffer[16]; /* 1e: Keyboard buffer */ + BYTE DisketteStatus1; /* 3e: Diskette recalibrate status */ + BYTE DisketteStatus2; /* 3f: Diskette motor status */ + BYTE DisketteStatus3; /* 40: Diskette motor timeout */ + BYTE DisketteStatus4; /* 41: Diskette last operation status */ + BYTE DiskStatus[7]; /* 42: Disk status/command bytes */ + BYTE VideoMode; /* 49: Video mode */ + WORD VideoColumns; /* 4a: Number of columns */ + WORD VideoPageSize; /* 4c: Video page size in bytes */ + WORD VideoPageStartAddr; /* 4e: Video page start address */ + BYTE VideoCursorPos[16]; /* 50: Cursor position for 8 pages */ + WORD VideoCursorType; /* 60: Video cursor type */ + BYTE VideoCurPage; /* 62: Video current page */ + WORD VideoCtrlAddr WINE_PACKED; /* 63: Video controller address */ + BYTE VideoReg1; /* 65: Video mode select register */ + BYTE VideoReg2; /* 66: Video CGA palette register */ + DWORD ResetEntry WINE_PACKED; /* 67: Warm reset entry point */ + BYTE LastIRQ; /* 6b: Last unexpected interrupt */ + DWORD Ticks; /* 6c: Ticks since midnight */ + BYTE TicksOverflow; /* 70: Timer overflow if past midnight */ + BYTE CtrlBreakFlag; /* 71: Ctrl-Break flag */ + WORD ResetFlag; /* 72: POST Reset flag */ + BYTE DiskOpStatus; /* 74: Last hard-disk operation status */ + BYTE NbHardDisks; /* 75: Number of hard disks */ + BYTE DiskCtrlByte; /* 76: Disk control byte */ + BYTE DiskIOPort; /* 77: Disk I/O port offset */ + BYTE LptTimeout[4]; /* 78: Timeouts for parallel ports */ + BYTE ComTimeout[4]; /* 7c: Timeouts for serial ports */ + WORD KbdBufferStart; /* 80: Keyboard buffer start */ + WORD KbdBufferEnd; /* 82: Keyboard buffer end */ +} BIOSDATA; + +#pragma pack(4) + + +static BIOSDATA *pBiosData = NULL; + + +/*********************************************************************** + * DOSMEM_Init + * + * Create the dos memory segments, and store them into the KERNEL + * exported values. MODULE_Init() must already have been called. + */ +BOOL DOSMEM_Init(void) +{ + HMODULE hModule = GetModuleHandle( "KERNEL" ); + char *dosmem; + + /* Allocate 7 64k segments for 0000, A000, B000, C000, D000, E000, F000. */ + + dosmem = malloc( 0x70000 ); + + MODULE_SetEntryPoint( hModule, 183, /* KERNEL.183: __0000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + DOSMEM_BiosSeg = GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x400, 0x100, + hModule, FALSE, FALSE, FALSE, NULL ); + + MODULE_SetEntryPoint( hModule, 193, /* KERNEL.193: __0040H */ + DOSMEM_BiosSeg ); + MODULE_SetEntryPoint( hModule, 174, /* KERNEL.174: __A000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x10000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 181, /* KERNEL.181: __B000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x20000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 182, /* KERNEL.182: __B800H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x28000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 195, /* KERNEL.195: __C000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x30000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 179, /* KERNEL.179: __D000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x40000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 190, /* KERNEL.190: __E000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x50000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 173, /* KERNEL.173: __ROMBIOS */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x60000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + MODULE_SetEntryPoint( hModule, 194, /* KERNEL.194: __F000H */ + GLOBAL_CreateBlock( GMEM_FIXED, dosmem + 0x60000, + 0x10000, hModule, FALSE, FALSE, FALSE, NULL )); + DOSMEM_FillBiosSegment(); + + return TRUE; +} + + +/*********************************************************************** + * DOSMEM_Alarm + * + * Increment the BIOS tick counter. + */ +static void DOSMEM_Alarm(void) +{ + pBiosData->Ticks = INT1A_GetTicksSinceMidnight(); + printf( "Ticks = %d\n", pBiosData->Ticks ); +/* + signal( SIGALRM, DOSMEM_Alarm ); + alarm( 1 ); +*/ +} + + +/*********************************************************************** + * DOSMEM_FillBiosSegment + * + * Fill the BIOS data segment with dummy values. + */ +void DOSMEM_FillBiosSegment(void) +{ + pBiosData = (BIOSDATA *)GlobalLock( DOSMEM_BiosSeg ); + + /* Clear all unused values */ + memset( pBiosData, 0, sizeof(*pBiosData) ); + + /* FIXME: should check the number of configured drives and ports */ + + pBiosData->Com1Addr = 0x3e8; + pBiosData->Com2Addr = 0x2e8; + pBiosData->Lpt1Addr = 0x378; + pBiosData->Lpt2Addr = 0x278; + pBiosData->InstalledHardware = 0x8443; + pBiosData->MemSize = 640; + pBiosData->NextKbdCharPtr = 0x1e; + pBiosData->FirstKbdCharPtr = 0x1e; + pBiosData->VideoMode = 0; + pBiosData->VideoColumns = 80; + pBiosData->VideoPageSize = 80 * 25 * 2; + pBiosData->VideoPageStartAddr = 0xb800; + pBiosData->VideoCtrlAddr = 0x3d4; + pBiosData->Ticks = INT1A_GetTicksSinceMidnight(); + pBiosData->NbHardDisks = 2; + pBiosData->KbdBufferStart = 0x1e; + pBiosData->KbdBufferEnd = 0x3e; + +/* + signal( SIGALRM, DOSMEM_Alarm ); + alarm( 1 ); +*/ +} diff --git a/miscemu/emulate.c b/miscemu/emulate.c index a8b40f33f86..afa61e7fd04 100644 --- a/miscemu/emulate.c +++ b/miscemu/emulate.c @@ -72,11 +72,12 @@ void WIN87_fpmath( struct sigcontext_struct context ) /* IN: AX&0x0C00 rounding protocol */ /* OUT: DX:AX variable popped */ { - DWORD dw,junk; + DWORD dw; /* I don't know much about asm() programming. This could be * wrong. */ - __asm__("fistp %1\nwait":"=m" (junk):"m" (dw):"memory"); +/* FIXME: could someone who really understands asm() fix this please? --AJ */ +/* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */ dprintf_int(stddeb,"emulate.c:On top of stack was %ld\n",dw); AX_reg(&context) = LOWORD(dw); DX_reg(&context) = HIWORD(dw); diff --git a/miscemu/instr.c b/miscemu/instr.c index 55388dae632..e5d89d858e9 100644 --- a/miscemu/instr.c +++ b/miscemu/instr.c @@ -11,6 +11,258 @@ #include "registers.h" +#define STACK_PTR(context) \ + (PTR_SEG_OFF_TO_LIN( SS_reg(context), \ + ((GET_SEL_FLAGS(SS_reg(context)) & LDT_FLAGS_32BIT) ? \ + ESP_reg(context) : SP_reg(context)))) + +/*********************************************************************** + * INSTR_ReplaceSelector + * + * Try to replace an invalid selector by a valid one. + * For now, only selector 0x40 is handled here. + */ +static WORD INSTR_ReplaceSelector( struct sigcontext_struct *context, WORD sel) +{ + if (sel == 0x40) + { + fprintf( stderr, "Direct access to segment 0x40 (cs:ip=%04x:%04lx).\n", + CS_reg(context), EIP_reg(context) ); + return DOSMEM_BiosSeg; + } + return 0; /* Can't replace selector */ +} + + +/*********************************************************************** + * INSTR_GetOperandAddr + * + * Return the address of an instruction operand (from the mod/rm byte). + */ +static BYTE *INSTR_GetOperandAddr( struct sigcontext_struct *context, + BYTE *instr, int long_addr, + int segprefix, int *len ) +{ + int mod, rm, base, index = 0, ss = 0, seg = 0, off; + +#define GET_VAL(val,type) \ + { *val = *(type *)instr; instr += sizeof(type); *len += sizeof(type); } + + *len = 0; + GET_VAL( &mod, BYTE ); + rm = mod & 7; + mod >>= 6; + + if (mod == 3) + { + switch(rm) + { + case 0: return (BYTE *)&EAX_reg(context); + case 1: return (BYTE *)&ECX_reg(context); + case 2: return (BYTE *)&EDX_reg(context); + case 3: return (BYTE *)&EBX_reg(context); + case 4: return (BYTE *)&ESP_reg(context); + case 5: return (BYTE *)&EBP_reg(context); + case 6: return (BYTE *)&ESI_reg(context); + case 7: return (BYTE *)&EDI_reg(context); + } + } + + if (long_addr) + { + if (rm == 4) + { + BYTE sib; + GET_VAL( &sib, BYTE ); + rm = sib & 7; + ss = sib >> 6; + switch(sib >> 3) + { + case 0: index = EAX_reg(context); break; + case 1: index = ECX_reg(context); break; + case 2: index = EDX_reg(context); break; + case 3: index = EBX_reg(context); break; + case 4: index = 0; break; + case 5: index = EBP_reg(context); break; + case 6: index = ESI_reg(context); break; + case 7: index = EDI_reg(context); break; + } + } + + switch(rm) + { + case 0: base = EAX_reg(context); seg = DS_reg(context); break; + case 1: base = ECX_reg(context); seg = DS_reg(context); break; + case 2: base = EDX_reg(context); seg = DS_reg(context); break; + case 3: base = EBX_reg(context); seg = DS_reg(context); break; + case 4: base = ESP_reg(context); seg = SS_reg(context); break; + case 5: base = EBP_reg(context); seg = SS_reg(context); break; + case 6: base = ESI_reg(context); seg = DS_reg(context); break; + case 7: base = EDI_reg(context); seg = DS_reg(context); break; + } + switch (mod) + { + case 0: + if (rm == 5) /* special case: ds:(disp32) */ + { + GET_VAL( &base, DWORD ); + seg = DS_reg(context); + } + break; + + case 1: /* 8-bit disp */ + GET_VAL( &off, BYTE ); + base += (signed char)off; + break; + + case 2: /* 32-bit disp */ + GET_VAL( &off, DWORD ); + base += (signed long)off; + break; + } + } + else /* short address */ + { + switch(rm) + { + case 0: /* ds:(bx,si) */ + base = BX_reg(context) + SI_reg(context); + seg = DS_reg(context); + break; + case 1: /* ds:(bx,di) */ + base = BX_reg(context) + DI_reg(context); + seg = DS_reg(context); + break; + case 2: /* ss:(bp,si) */ + base = BP_reg(context) + SI_reg(context); + seg = SS_reg(context); + break; + case 3: /* ss:(bp,di) */ + base = BP_reg(context) + DI_reg(context); + seg = SS_reg(context); + break; + case 4: /* ds:(si) */ + base = SI_reg(context); + seg = DS_reg(context); + break; + case 5: /* ds:(di) */ + base = DI_reg(context); + seg = DS_reg(context); + break; + case 6: /* ss:(bp) */ + base = BP_reg(context); + seg = SS_reg(context); + break; + case 7: /* ds:(bx) */ + base = BX_reg(context); + seg = DS_reg(context); + break; + } + + switch(mod) + { + case 0: + if (rm == 6) /* special case: ds:(disp16) */ + { + GET_VAL( &base, WORD ); + seg = DS_reg(context); + } + break; + + case 1: /* 8-bit disp */ + GET_VAL( &off, BYTE ); + base += (signed char)off; + break; + + case 2: /* 16-bit disp */ + GET_VAL( &off, WORD ); + base += (signed short)off; + break; + } + } + if (segprefix != -1) seg = segprefix; + + return (BYTE *)PTR_SEG_OFF_TO_LIN( seg, (base + (index << ss)) ); +} + + +/*********************************************************************** + * INSTR_EmulateLDS + * + * Emulate the LDS (and LES,LFS,etc.) instruction. + */ +static BOOL INSTR_EmulateLDS( struct sigcontext_struct *context, + BYTE *instr, int long_op, int long_addr, + int segprefix, int *len ) +{ + BYTE *regmodrm = instr + 1 + (*instr == 0x0f); + BYTE *addr = INSTR_GetOperandAddr( context, regmodrm, + long_addr, segprefix, len ); + WORD seg = *(WORD *)(addr + (long_op ? 4 : 2)); + + if (!(seg = INSTR_ReplaceSelector( context, seg ))) + return FALSE; /* Unable to emulate it */ + + /* Now store the offset in the correct register */ + + switch((*regmodrm >> 3) & 7) + { + case 0: + if (long_op) EAX_reg(context) = *(DWORD *)addr; + else AX_reg(context) = *(WORD *)addr; + break; + case 1: + if (long_op) ECX_reg(context) = *(DWORD *)addr; + else CX_reg(context) = *(WORD *)addr; + break; + case 2: + if (long_op) EDX_reg(context) = *(DWORD *)addr; + else DX_reg(context) = *(WORD *)addr; + break; + case 3: + if (long_op) EBX_reg(context) = *(DWORD *)addr; + else BX_reg(context) = *(WORD *)addr; + break; + case 4: + if (long_op) ESP_reg(context) = *(DWORD *)addr; + else SP_reg(context) = *(WORD *)addr; + break; + case 5: + if (long_op) EBP_reg(context) = *(DWORD *)addr; + else BP_reg(context) = *(WORD *)addr; + break; + case 6: + if (long_op) ESI_reg(context) = *(DWORD *)addr; + else SI_reg(context) = *(WORD *)addr; + break; + case 7: + if (long_op) EDI_reg(context) = *(DWORD *)addr; + else DI_reg(context) = *(WORD *)addr; + break; + } + + /* Store the correct segment in the segment register */ + + switch(*instr) + { + case 0xc4: ES_reg(context) = seg; break; /* les */ + case 0xc5: DS_reg(context) = seg; break; /* lds */ + case 0x0f: switch(instr[1]) + { + case 0xb2: SS_reg(context) = seg; break; /* lss */ + case 0xb4: FS_reg(context) = seg; break; /* lfs */ + case 0xb5: GS_reg(context) = seg; break; /* lgs */ + } + break; + } + + /* Add the opcode size to the total length */ + + *len += 1 + (*instr == 0x0f); + return TRUE; +} + + /*********************************************************************** * INSTR_EmulateInstruction * @@ -18,7 +270,7 @@ */ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) { - int prefix, segprefix, repX, long_op, long_addr; + int prefix, segprefix, prefixlen, len, repX, long_op, long_addr; BYTE *instr; long_op = long_addr = (GET_SEL_FLAGS(CS_reg(context)) & LDT_FLAGS_32BIT) != 0; @@ -29,6 +281,7 @@ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) segprefix = -1; /* no prefix */ prefix = 1; repX = 0; + prefixlen = 0; while(prefix) { switch(*instr) @@ -72,7 +325,7 @@ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) if (prefix) { instr++; - EIP_reg(context)++; + prefixlen++; } } @@ -80,103 +333,59 @@ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) switch(*instr) { - case 0xcd: /* int */ - if (long_op) + case 0x07: /* pop es */ + case 0x17: /* pop ss */ + case 0x1f: /* pop ds */ { - fprintf(stderr, "int xx from 32-bit code is not supported.\n"); - return FALSE; /* Unable to emulate it */ + WORD seg = *(WORD *)STACK_PTR( context ); + if ((seg = INSTR_ReplaceSelector( context, seg )) != 0) + { + switch(*instr) + { + case 0x07: ES_reg(context) = seg; break; + case 0x17: SS_reg(context) = seg; break; + case 0x1f: DS_reg(context) = seg; break; + } + SP_reg(context) += sizeof(WORD); + EIP_reg(context) += prefixlen + 1; + return TRUE; + } } - else + break; /* Unable to emulate it */ + + case 0x0f: /* extended instruction */ + switch(instr[1]) { - SEGPTR addr = INT_GetHandler( instr[1] ); - /* FIXME: should check the stack 'big' bit */ - WORD *stack = (WORD *)PTR_SEG_OFF_TO_LIN( SS_reg(context), - SP_reg(context) ); - /* Push the flags and return address on the stack */ - *(--stack) = FL_reg(context); - *(--stack) = CS_reg(context); - *(--stack) = IP_reg(context) + 2; - SP_reg(context) -= 3 * sizeof(WORD); - /* Jump to the interrupt handler */ - CS_reg(context) = HIWORD(addr); - EIP_reg(context) = LOWORD(addr); + case 0xa1: /* pop fs */ + case 0xa9: /* pop gs */ + { + WORD seg = *(WORD *)STACK_PTR( context ); + if ((seg = INSTR_ReplaceSelector( context, seg )) != 0) + { + switch(instr[1]) + { + case 0xa1: FS_reg(context) = seg; break; + case 0xa9: GS_reg(context) = seg; break; + } + SP_reg(context) += sizeof(WORD); + EIP_reg(context) += prefixlen + 2; + return TRUE; + } + } + break; + + case 0xb2: /* lss addr,reg */ + case 0xb4: /* lfs addr,reg */ + case 0xb5: /* lgs addr,reg */ + if (INSTR_EmulateLDS( context, instr, long_op, + long_addr, segprefix, &len )) + { + EIP_reg(context) += prefixlen + len; + return TRUE; + } + break; } - break; - - case 0xcf: /* iret */ - if (long_op) - { - /* FIXME: should check the stack 'big' bit */ - DWORD *stack = (DWORD *)PTR_SEG_OFF_TO_LIN( SS_reg(context), - SP_reg(context) ); - EIP_reg(context) = *stack++; - CS_reg(context) = *stack++; - EFL_reg(context) = *stack; - SP_reg(context) += 3*sizeof(DWORD); /* Pop the return address and flags */ - } - else - { - /* FIXME: should check the stack 'big' bit */ - WORD *stack = (WORD *)PTR_SEG_OFF_TO_LIN( SS_reg(context), - SP_reg(context) ); - EIP_reg(context) = *stack++; - CS_reg(context) = *stack++; - FL_reg(context) = *stack; - SP_reg(context) += 3*sizeof(WORD); /* Pop the return address and flags */ - } - break; - - case 0xe4: /* inb al,XX */ - AL_reg(context) = inport( instr[1], 1 ); - EIP_reg(context) += 2; - break; - - case 0xe5: /* in (e)ax,XX */ - if (long_op) EAX_reg(context) = inport( instr[1], 4 ); - else AX_reg(context) = inport( instr[1], 2 ); - EIP_reg(context) += 2; - break; - - case 0xe6: /* outb XX,al */ - outport( instr[1], 1, AL_reg(context) ); - EIP_reg(context) += 2; - break; - - case 0xe7: /* out XX,(e)ax */ - if (long_op) outport( instr[1], 4, EAX_reg(context) ); - else outport( instr[1], 2, AX_reg(context) ); - EIP_reg(context) += 2; - break; - - case 0xec: /* inb al,dx */ - AL_reg(context) = inport( DX_reg(context), 1 ); - EIP_reg(context)++; - break; - - case 0xed: /* in (e)ax,dx */ - if (long_op) EAX_reg(context) = inport( DX_reg(context), 4 ); - else AX_reg(context) = inport( DX_reg(context), 2 ); - EIP_reg(context)++; - break; - - case 0xee: /* outb dx,al */ - outport( DX_reg(context), 1, AL_reg(context) ); - EIP_reg(context)++; - break; - - case 0xef: /* out dx,(e)ax */ - if (long_op) outport( DX_reg(context), 4, EAX_reg(context) ); - else outport( DX_reg(context), 2, AX_reg(context) ); - EIP_reg(context)++; - break; - - case 0xfa: /* cli, ignored */ - EIP_reg(context)++; - break; - - case 0xfb: /* sti, ignored */ - EIP_reg(context)++; - break; + break; /* Unable to emulate it */ case 0x6c: /* insb */ case 0x6d: /* insw/d */ @@ -190,7 +399,7 @@ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1; int step = (EFL_reg(context) & 0x400) ? -opsize : +opsize; int seg = outp ? (segprefix >= 0 ? segprefix : DS_reg(context)) - : ES_reg(context); + : ES_reg(context); /* FIXME: is this right? */ if (outp) /* FIXME: Check segment readable. */ @@ -245,14 +454,151 @@ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) break; } } - EIP_reg(context)++; - break; + EIP_reg(context) += prefixlen + 1; } + return TRUE; - default: - fprintf(stderr, "Unexpected Windows program segfault" - " - opcode = %x\n", *instr); - return FALSE; /* Unable to emulate it */ + case 0x8e: /* mov reg,segment_reg */ + { + WORD seg = *(WORD *)INSTR_GetOperandAddr( context, instr + 1, + long_addr, segprefix, &len ); + if (!(seg = INSTR_ReplaceSelector( context, seg ))) + break; /* Unable to emulate it */ + + switch((instr[1] >> 3) & 7) + { + case 0: + ES_reg(context) = seg; + EIP_reg(context) += prefixlen + len + 1; + return TRUE; + case 1: /* cs */ + break; + case 2: + SS_reg(context) = seg; + EIP_reg(context) += prefixlen + len + 1; + return TRUE; + case 3: + DS_reg(context) = seg; + EIP_reg(context) += prefixlen + len + 1; + return TRUE; + case 4: + FS_reg(context) = seg; + EIP_reg(context) += prefixlen + len + 1; + return TRUE; + case 5: + GS_reg(context) = seg; + EIP_reg(context) += prefixlen + len + 1; + return TRUE; + case 6: /* unused */ + case 7: /* unused */ + break; + } + } + break; /* Unable to emulate it */ + + case 0xc4: /* les addr,reg */ + case 0xc5: /* lds addr,reg */ + if (INSTR_EmulateLDS( context, instr, long_op, + long_addr, segprefix, &len )) + { + EIP_reg(context) += prefixlen + len; + return TRUE; + } + break; /* Unable to emulate it */ + + case 0xcd: /* int */ + if (long_op) + { + fprintf(stderr, "int xx from 32-bit code is not supported.\n"); + break; /* Unable to emulate it */ + } + else + { + SEGPTR addr = INT_GetHandler( instr[1] ); + WORD *stack = (WORD *)STACK_PTR( context ); + /* Push the flags and return address on the stack */ + *(--stack) = FL_reg(context); + *(--stack) = CS_reg(context); + *(--stack) = IP_reg(context) + prefixlen + 2; + SP_reg(context) -= 3 * sizeof(WORD); + /* Jump to the interrupt handler */ + CS_reg(context) = HIWORD(addr); + EIP_reg(context) = LOWORD(addr); + } + return TRUE; + + case 0xcf: /* iret */ + if (long_op) + { + DWORD *stack = (DWORD *)STACK_PTR( context ); + EIP_reg(context) = *stack++; + CS_reg(context) = *stack++; + EFL_reg(context) = *stack; + SP_reg(context) += 3*sizeof(DWORD); /* Pop the return address and flags */ + } + else + { + WORD *stack = (WORD *)STACK_PTR( context ); + EIP_reg(context) = *stack++; + CS_reg(context) = *stack++; + FL_reg(context) = *stack; + SP_reg(context) += 3*sizeof(WORD); /* Pop the return address and flags */ + } + return TRUE; + + case 0xe4: /* inb al,XX */ + AL_reg(context) = inport( instr[1], 1 ); + EIP_reg(context) += prefixlen + 2; + return TRUE; + + case 0xe5: /* in (e)ax,XX */ + if (long_op) EAX_reg(context) = inport( instr[1], 4 ); + else AX_reg(context) = inport( instr[1], 2 ); + EIP_reg(context) += prefixlen + 2; + return TRUE; + + case 0xe6: /* outb XX,al */ + outport( instr[1], 1, AL_reg(context) ); + EIP_reg(context) += prefixlen + 2; + return TRUE; + + case 0xe7: /* out XX,(e)ax */ + if (long_op) outport( instr[1], 4, EAX_reg(context) ); + else outport( instr[1], 2, AX_reg(context) ); + EIP_reg(context) += prefixlen + 2; + return TRUE; + + case 0xec: /* inb al,dx */ + AL_reg(context) = inport( DX_reg(context), 1 ); + EIP_reg(context) += prefixlen + 1; + return TRUE; + + case 0xed: /* in (e)ax,dx */ + if (long_op) EAX_reg(context) = inport( DX_reg(context), 4 ); + else AX_reg(context) = inport( DX_reg(context), 2 ); + EIP_reg(context) += prefixlen + 1; + return TRUE; + + case 0xee: /* outb dx,al */ + outport( DX_reg(context), 1, AL_reg(context) ); + EIP_reg(context) += prefixlen + 1; + return TRUE; + + case 0xef: /* out dx,(e)ax */ + if (long_op) outport( DX_reg(context), 4, EAX_reg(context) ); + else outport( DX_reg(context), 2, AX_reg(context) ); + EIP_reg(context) += prefixlen + 1; + return TRUE; + + case 0xfa: /* cli, ignored */ + EIP_reg(context) += prefixlen + 1; + return TRUE; + + case 0xfb: /* sti, ignored */ + EIP_reg(context) += prefixlen + 1; + return TRUE; } - return TRUE; + fprintf(stderr, "Unexpected Windows program segfault" + " - opcode = %x\n", *instr); + return FALSE; /* Unable to emulate it */ } diff --git a/miscemu/int1a.c b/miscemu/int1a.c index 7e17e4215dd..69386c0967e 100644 --- a/miscemu/int1a.c +++ b/miscemu/int1a.c @@ -14,6 +14,27 @@ #define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4)) +/********************************************************************** + * INT1A_GetTicksSinceMidnight + * + * Return number of clock ticks since midnight. + */ +DWORD INT1A_GetTicksSinceMidnight(void) +{ + struct tm *bdtime; + struct timeval tvs; + + /* This should give us the (approximately) correct + * 18.206 clock ticks per second since midnight. + */ + gettimeofday( &tvs, NULL ); + bdtime = localtime( &tvs.tv_sec ); + return (((bdtime->tm_hour * 3600 + bdtime->tm_min * 60 + + bdtime->tm_sec) * 18206) / 1000) + + (tvs.tv_usec / 54927); +} + + /********************************************************************** * INT_Int1aHandler * @@ -24,25 +45,16 @@ void INT_Int1aHandler( struct sigcontext_struct context ) time_t ltime; DWORD ticks; struct tm *bdtime; - struct timeval tvs; switch(AH_reg(&context)) { case 0: - /* This should give us the (approximately) correct - * 18.206 clock ticks per second since midnight - * expected from this interrupt - */ - gettimeofday(&tvs, NULL); - bdtime = localtime(&tvs.tv_sec); - ticks = (((bdtime->tm_hour * 3600 + bdtime->tm_min * 60 + - bdtime->tm_sec) * 18206) / 1000) + - (tvs.tv_usec / 54927); - CX_reg(&context) = HIWORD(ticks); - DX_reg(&context) = LOWORD(ticks); - AX_reg(&context) = 0; /* No midnight rollover */ - dprintf_int(stddeb,"int1a_00 // ticks=%ld\n", ticks); - break; + ticks = INT1A_GetTicksSinceMidnight(); + CX_reg(&context) = HIWORD(ticks); + DX_reg(&context) = LOWORD(ticks); + AX_reg(&context) = 0; /* No midnight rollover */ + dprintf_int(stddeb,"int1a_00 // ticks=%ld\n", ticks); + break; case 2: ltime = time(NULL); diff --git a/miscemu/int21.c b/miscemu/int21.c index b0a05e71223..720806c41a5 100644 --- a/miscemu/int21.c +++ b/miscemu/int21.c @@ -341,14 +341,9 @@ static void WriteFile(struct sigcontext_struct *context) AX_reg(context) = CX_reg(context); RESET_CFLAG(context); } else { - size = write(BX_reg(context), ptr , CX_reg(context)); - if (size == 0) { - Error (WriteFault, EC_Unknown, EL_Unknown); - AX_reg(context) = ExtendedError; - return; - } - - if (size == -1) { + /* well, this function already handles everything we need */ + size = _lwrite(BX_reg(context),ptr,CX_reg(context)); + if (size == -1) { /* HFILE_ERROR == -1 */ errno_to_doserr(); AX_reg(context) = ExtendedError; SET_CFLAG(context); @@ -417,8 +412,12 @@ static void ioctlGetDeviceInfo(struct sigcontext_struct *context) return; } - /* This isn't the right answer, but should be close enough. */ DX_reg(context) = 0x0943; + /* bits 0-5 are current drive + * bit 6 - file has NOT been written..FIXME: correct? + * bit 8 - generate int24 if no diskspace on write/ read past end of file + * bit 11 - media not removable + */ } } RESET_CFLAG(context); @@ -1526,7 +1525,13 @@ void DOS3Call( struct sigcontext_struct context ) RESET_CFLAG(&context); } break; - + case 0x0a: /* check if handle (BX) is remote */ + /* returns DX, bit 15 set if remote, bit 14 set if date/time + * not set on close + */ + DX_reg(&context) = 0; + RESET_CFLAG(&context); + break; case 0x0b: /* SET SHARING RETRY COUNT */ if (!CX_reg(&context)) { diff --git a/multimedia/Imakefile b/multimedia/Imakefile index 582e384f1ba..51ea94fb8b3 100644 --- a/multimedia/Imakefile +++ b/multimedia/Imakefile @@ -7,6 +7,7 @@ SRCS = \ joystick.c \ mcianim.c \ mcicda.c \ + mcistring.c \ midi.c \ mmaux.c \ mmsystem.c \ diff --git a/multimedia/Makefile.in b/multimedia/Makefile.in index 17ea1c7f90d..bc034fce330 100644 --- a/multimedia/Makefile.in +++ b/multimedia/Makefile.in @@ -9,9 +9,16 @@ LDCOMBINEFLAGS = @LDCOMBINEFLAGS@ MODULE = multimedia -SRCS = audio.c joystick.c mcianim.c mcicda.c midi.c mmaux.c \ - mmsystem.c time.c - +SRCS = \ + audio.c \ + joystick.c \ + mcianim.c \ + mcicda.c \ + mcistring.c \ + midi.c \ + mmaux.c \ + mmsystem.c \ + time.c OBJS = $(SRCS:.c=.o) @@ -29,7 +36,7 @@ depend: mv tmp_make Makefile clean: - rm -f *.o \#*\# *~ tmp_make + rm -f *.o \#*\# *~ *.bak tmp_make distclean: clean rm -f Makefile diff --git a/multimedia/audio.c b/multimedia/audio.c index 5ce2271276f..5c46e07fd96 100644 --- a/multimedia/audio.c +++ b/multimedia/audio.c @@ -35,7 +35,7 @@ #define SOUND_DEV "/dev/dsp" #ifdef SOUND_VERSION -#define IOCTL(a,b,c) ioctl(a,b,&c) +#define IOCTL(a,b,c) ((-1==ioctl(a,b,&c))&&(perror("ioctl:"#b":"#c),0)) #else #define IOCTL(a,b,c) (c = ioctl(a,b,c) ) #endif @@ -863,10 +863,11 @@ static DWORD wodClose(WORD wDevID) close(WOutDev[wDevID].unixdev); WOutDev[wDevID].unixdev = 0; WOutDev[wDevID].bufsize = 0; + WOutDev[wDevID].lpQueueHdr = NULL; if (WAVE_NotifyClient(wDevID, WOM_CLOSE, 0L, 0L) != MMSYSERR_NOERROR) { dprintf_mciwave(stddeb,"Linux 'wodClose' // can't notify client !\n"); return MMSYSERR_INVALPARAM; - } + } return MMSYSERR_NOERROR; } @@ -920,10 +921,13 @@ static DWORD wodPrepare(WORD wDevID, LPWAVEHDR lpWaveHdr, DWORD dwSize) dprintf_mciwave(stddeb,"Linux 'wodPrepare' // can't prepare !\n"); return MMSYSERR_NOTENABLED; } + /* the COOL waveeditor feels much better without this check... + * someone please have a look at available documentation if (WOutDev[wDevID].lpQueueHdr != NULL) { dprintf_mciwave(stddeb,"Linux 'wodPrepare' // already prepare !\n"); return MMSYSERR_NOTENABLED; - } + } + */ WOutDev[wDevID].dwTotalPlayed = 0; WOutDev[wDevID].lpQueueHdr = lpWaveHdr; if (lpWaveHdr->dwFlags & WHDR_INQUEUE) return WAVERR_STILLPLAYING; diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c new file mode 100644 index 00000000000..653a907d393 --- /dev/null +++ b/multimedia/mcistring.c @@ -0,0 +1,2177 @@ +/* + * MCI stringinterface + * + * Copyright 1995 Marcus Meissner + */ +/* FIXME: special commands of device drivers should be handled by those drivers + */ + +#ifndef WINELIB + +#include +#include +#include +#include +#include +#include +#include "windows.h" +#include "ldt.h" +#include "callback.h" +#include "user.h" +#include "driver.h" +#include "mmsystem.h" +#include "stddebug.h" +#include "debug.h" + +extern MCI_OPEN_DRIVER_PARMS mciDrv[MAXMCIDRIVERS]; + +/* FIXME: I need to remember the aliasname of a spec. driver. + * and this is the easiest way. *sigh* + */ +static MCI_OPEN_PARMS mciOpenDrv[MAXMCIDRIVERS]; + +LONG DrvDefDriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2); + +LONG WAVE_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2); +LONG MIDI_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2); +LONG CDAUDIO_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2); +LONG ANIM_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg, + DWORD dwParam1, DWORD dwParam2); + +/* The reason why I just don't lowercase the keywords array in + * mciSendString is left as an exercise to the reader. + */ +#define STRCMP(x,y) strcasecmp(x,y) + +/* standard functionparameters for all functions */ +#define _MCISTR_PROTO_ \ + WORD wDevID,WORD uDevTyp,LPSTR lpstrReturnString,UINT uReturnLength,\ + LPCSTR dev,LPSTR *keywords,UINT nrofkeywords,DWORD dwFlags + +/* copy string to return pointer including necessary checks + * for use in mciSendString() + */ +#define _MCI_STR(s) do {\ + int __l__;\ + dprintf_mci(stddeb,"->returns \"%s\"",s);\ + if (lpstrReturnString) {\ + __l__=strlen(s);\ + if(__l__>uReturnLength) {\ + strncpy(lpstrReturnString,s,uReturnLength-1);\ + lpstrReturnString[uReturnLength-1]='\0';\ + } else\ + strcpy(lpstrReturnString,s);\ + dprintf_mci(stddeb,"-->\"%s\"\n",lpstrReturnString);\ + }\ +} while(0) + +/* calling DriverProc. We need to pass the struct as SEGMENTED POINTER. */ +#define _MCI_CALL_DRIVER(cmd,params) {\ + DWORD xparams;\ + xparams=MAKE_SEGPTR(¶ms);\ + switch(uDevTyp) {\ + case MCI_DEVTYPE_CD_AUDIO:\ + res=CDAUDIO_DriverProc(mciDrv[wDevID].wDeviceID,0,cmd,dwFlags, xparams);\ + break;\ + case MCI_DEVTYPE_WAVEFORM_AUDIO:\ + res=WAVE_DriverProc(mciDrv[wDevID].wDeviceID,0,cmd,dwFlags,xparams);\ + break;\ + case MCI_DEVTYPE_SEQUENCER:\ + res=MIDI_DriverProc(mciDrv[wDevID].wDeviceID,0,cmd,dwFlags,xparams);\ + break;\ + case MCI_DEVTYPE_ANIMATION:\ + res=ANIM_DriverProc(mciDrv[wDevID].wDeviceID,0,cmd,dwFlags,xparams);\ + break;\ + case MCI_DEVTYPE_DIGITAL_VIDEO:\ + dprintf_mci(stddeb,"_MCI_CALL_DRIVER //No DIGITAL_VIDEO yet !\n");\ + res=MCIERR_DEVICE_NOT_INSTALLED;\ + break;\ + default:\ + dprintf_mci(stddeb,"_MCI_CALL_DRIVER //Invalid Device Name '%s' !\n",dev);\ + res=MCIERR_INVALID_DEVICE_NAME;\ + break;\ + }\ +} +/* we need to have strings in 16 bit space for some things + * FIXME: this is bad. + */ +#define _MCI_STRDUP_TO_SEG(dest,source) {\ + HANDLE x;\ + x=USER_HEAP_ALLOC(strlen(source));\ + dest=(LPSTR)MAKELONG(x,USER_HeapSel);\ + strcpy(PTR_SEG_TO_LIN(dest),source);\ +} + +/* print a DWORD in the specified timeformat */ +static void +_MCISTR_printtf(char *buf,UINT uDevType,DWORD timef,DWORD val) { + *buf='\0'; + switch (timef) { + case MCI_FORMAT_MILLISECONDS: + case MCI_FORMAT_FRAMES: + case MCI_FORMAT_BYTES: + case MCI_FORMAT_SAMPLES: + case MCI_VD_FORMAT_TRACK: + /*case MCI_SEQ_FORMAT_SONGPTR: sameas MCI_VD_FORMAT_TRACK */ + sprintf(buf,"%ld",val); + break; + case MCI_FORMAT_HMS: + /* well, the macros have the same content*/ + /*FALLTRHOUGH*/ + case MCI_FORMAT_MSF: + sprintf(buf,"%d:%d:%d", + MCI_HMS_HOUR(val), + MCI_HMS_MINUTE(val), + MCI_HMS_SECOND(val) + ); + break; + case MCI_FORMAT_TMSF: + sprintf(buf,"%d:%d:%d:%d", + MCI_TMSF_TRACK(val), + MCI_TMSF_MINUTE(val), + MCI_TMSF_SECOND(val), + MCI_TMSF_FRAME(val) + ); + break; + default: + fprintf(stdnimp,__FILE__":MCISTR_Status:missing timeformat for %ld, report.\n",timef); + strcpy(buf,"0"); /* hmm */ + break; + } + return; +} +/* possible different return types */ +#define _MCISTR_int 1 +#define _MCISTR_time 2 +#define _MCISTR_bool 3 +#define _MCISTR_tfname 4 +#define _MCISTR_mode 5 +#define _MCISTR_divtype 6 +#define _MCISTR_seqtype 7 +#define _MCISTR_vdmtype 8 +#define _MCISTR_devtype 9 + +static void +_MCISTR_convreturn(int type,DWORD dwReturn,LPSTR lpstrReturnString, + WORD uReturnLength,WORD uDevTyp,int timef +) { + switch (type) { + case _MCISTR_vdmtype: + switch (dwReturn) { + case MCI_VD_MEDIA_CLV:_MCI_STR("CLV");break; + case MCI_VD_MEDIA_CAV:_MCI_STR("CAV");break; + default: + case MCI_VD_MEDIA_OTHER:_MCI_STR("other");break; + } + break; + case _MCISTR_seqtype: + switch (dwReturn) { + case MCI_SEQ_NONE:_MCI_STR("none");break; + case MCI_SEQ_SMPTE:_MCI_STR("smpte");break; + case MCI_SEQ_FILE:_MCI_STR("file");break; + case MCI_SEQ_MIDI:_MCI_STR("midi");break; + default:fprintf(stdnimp,__FILE__":MCISTR_Status:missing sequencer mode %ld\n",dwReturn); + } + break; + case _MCISTR_mode: + switch (dwReturn) { + case MCI_MODE_NOT_READY:_MCI_STR("not ready");break; + case MCI_MODE_STOP:_MCI_STR("stopped");break; + case MCI_MODE_PLAY:_MCI_STR("playing");break; + case MCI_MODE_RECORD:_MCI_STR("recording");break; + case MCI_MODE_SEEK:_MCI_STR("seeking");break; + case MCI_MODE_PAUSE:_MCI_STR("paused");break; + case MCI_MODE_OPEN:_MCI_STR("open");break; + default:break; + } + break; + case _MCISTR_bool: + if (dwReturn) + _MCI_STR("true"); + else + _MCI_STR("false"); + break; + case _MCISTR_int:{ + char buf[16]; + sprintf(buf,"%ld",dwReturn); + _MCI_STR(buf); + break; + } + case _MCISTR_time: { + char buf[100]; + _MCISTR_printtf(buf,uDevTyp,timef,dwReturn); + _MCI_STR(buf); + break; + } + case _MCISTR_tfname: + switch (timef) { + case MCI_FORMAT_MILLISECONDS:_MCI_STR("milliseconds");break; + case MCI_FORMAT_FRAMES:_MCI_STR("frames");break; + case MCI_FORMAT_BYTES:_MCI_STR("bytes");break; + case MCI_FORMAT_SAMPLES:_MCI_STR("samples");break; + case MCI_FORMAT_HMS:_MCI_STR("hms");break; + case MCI_FORMAT_MSF:_MCI_STR("msf");break; + case MCI_FORMAT_TMSF:_MCI_STR("tmsf");break; + default: + fprintf(stdnimp,__FILE__":MCISTR_Status:missing timeformat for %d, report.\n",timef); + break; + } + break; + case _MCISTR_divtype: + switch (dwReturn) { + case MCI_SEQ_DIV_PPQN:_MCI_STR("PPQN");break; + case MCI_SEQ_DIV_SMPTE_24:_MCI_STR("SMPTE 24 frame");break; + case MCI_SEQ_DIV_SMPTE_25:_MCI_STR("SMPTE 25 frame");break; + case MCI_SEQ_DIV_SMPTE_30:_MCI_STR("SMPTE 30 frame");break; + case MCI_SEQ_DIV_SMPTE_30DROP:_MCI_STR("SMPTE 30 frame drop");break; + } + case _MCISTR_devtype: + switch (dwReturn) { + case MCI_DEVTYPE_VCR:_MCI_STR("vcr");break; + case MCI_DEVTYPE_VIDEODISC:_MCI_STR("videodisc");break; + case MCI_DEVTYPE_CD_AUDIO:_MCI_STR("cd audio");break; + case MCI_DEVTYPE_OVERLAY:_MCI_STR("overlay");break; + case MCI_DEVTYPE_DAT:_MCI_STR("dat");break; + case MCI_DEVTYPE_SCANNER:_MCI_STR("scanner");break; + case MCI_DEVTYPE_ANIMATION:_MCI_STR("animation");break; + case MCI_DEVTYPE_DIGITAL_VIDEO:_MCI_STR("digital video");break; + case MCI_DEVTYPE_OTHER:_MCI_STR("other");break; + case MCI_DEVTYPE_WAVEFORM_AUDIO:_MCI_STR("waveform audio");break; + case MCI_DEVTYPE_SEQUENCER:_MCI_STR("sequencer");break; + default:fprintf(stdnimp,__FILE__":_MCISTR_convreturn:unknown device type %ld, report.\n",dwReturn);break; + } + break; + default: + fprintf(stdnimp,__FILE__":_MCISTR_convreturn:unknown resulttype %d, report.\n",type); + break; + } +} + +#define FLAG1(str,flag) \ + if (!STRCMP(keywords[i],str)) {\ + dwFlags |= flag;\ + i++;\ + continue;\ + } +#define FLAG2(str1,str2,flag) \ + if (!STRCMP(keywords[i],str1) && (i+1 + * Optional: + * "shareable" + * "alias " + * "element " + * Additional: + * waveform audio: + * "buffer " + * Animation: + * "nostatic" increaste nr of nonstatic colours + * "parent " + * "style " bitmask of WS_xxxxx (see windows.h) + * "style child" WS_CHILD + * "style overlap" WS_OVERLAPPED + * "style popup" WS_POPUP + * Overlay: + * "parent " + * "style " bitmask of WS_xxxxx (see windows.h) + * "style child" WS_CHILD + * "style overlap" WS_OVERLAPPED + * "style popup" WS_POPUP + * Returns nothing. + */ +static DWORD +MCISTR_Open(_MCISTR_PROTO_) { + int res,i; + char *s; + union { + MCI_OPEN_PARMS openParams; + MCI_WAVE_OPEN_PARMS waveopenParams; + MCI_ANIM_OPEN_PARMS animopenParams; + MCI_OVLY_OPEN_PARMS ovlyopenParams; + } U; + + U.openParams.lpstrElementName = NULL; + s=strchr(dev,'!'); + if (s!=NULL) { + *s++='\0'; + _MCI_STRDUP_TO_SEG(U.openParams.lpstrElementName,s); + } + if (!STRCMP(dev,"cdaudio")) { + uDevTyp=MCI_DEVTYPE_CD_AUDIO; + } else if (!STRCMP(dev,"waveaudio")) { + uDevTyp=MCI_DEVTYPE_WAVEFORM_AUDIO; + } else if (!STRCMP(dev,"sequencer")) { + uDevTyp=MCI_DEVTYPE_SEQUENCER; + } else if (!STRCMP(dev,"animation1")) { + uDevTyp=MCI_DEVTYPE_ANIMATION; + } else if (!STRCMP(dev,"avivideo")) { + uDevTyp=MCI_DEVTYPE_DIGITAL_VIDEO; + } else { + return MCIERR_INVALID_DEVICE_NAME; + } + wDevID=0; + while(mciDrv[wDevID].wType) { + if (++wDevID>=MAXMCIDRIVERS) { + dprintf_mci(stddeb, __FILE__":MCISTR_Open:MAXMCIDRIVERS reached!\n"); + return MCIERR_INTERNAL; + } + } + mciDrv[wDevID].wType = uDevTyp; + mciDrv[wDevID].wDeviceID = wDevID; + U.openParams.dwCallback = 0; + U.openParams.wDeviceID = wDevID; + U.ovlyopenParams.dwStyle = 0; + U.animopenParams.dwStyle = 0; + + _MCI_STRDUP_TO_SEG(U.openParams.lpstrDeviceType,dev); + U.openParams.lpstrAlias = NULL; + dwFlags |= MCI_OPEN_TYPE; + i=0; + while (i]" - returns length [of track ] in current + * timeformat + * "number of tracks" - returns number of tracks as integer + * "position [track ]" - returns position [in track ] in current + * timeformat + * "ready" - checks if device is ready to play, -> bool + * "start position" - returns start position in timeformat + * "time format" - returns timeformat (list of possible values: + * "ms" "msf" "milliseconds" "hmsf" "tmsf" "frames" + * "bytes" "samples" "hms") + * "media present" - returns if media is present as bool + * Animation: + * "forward" - returns "true" if device is playing forwards + * "speed" - returns speed for device + * "palette handle" - returns palette handle + * "window handle" - returns window handle + * "stretch" - returns stretch bool + * MIDI sequencer: + * "division type" - ? returns "PPQN" "SMPTE 24 frame" + * "SMPTE 25 frame" "SMPTE 30 frame" "SMPTE 30 drop frame" + * "tempo" - current tempo in (PPQN? speed in frames, SMPTE*? speed in hsmf) + * "offset" - offset in dito. + * "port" - midi port as integer + * "slave" - slave device ("midi","file","none","smpte") + * "master" - masterdevice (dito.) + * Overlay: + * "window handle" - see animation + * "stretch" - dito + * Video Disc: + * "speed" - speed as integer + * "forward" - returns bool (when playing forward) + * "side" - returns 1 or 2 + * "media type" - returns "CAV" "CLV" "other" + * "disc size" - returns "8" or "12" + * WAVEFORM audio: + * "input" - base queries on input set + * "output" - base queries on output set + * "format tag" - return integer format tag + * "channels" - return integer nr of channels + * "bytespersec" - return average nr of bytes/sec + * "samplespersec" - return nr of samples per sec + * "bitspersample" - return bitspersample + * "alignment" - return block alignment + * "level" - return level? + */ + +#define ITEM1(str,item,xtype) \ + if (!STRCMP(keywords[i],str)) {\ + statusParams.dwItem = item;\ + type = xtype;\ + i++;\ + continue;\ + } +#define ITEM2(str1,str2,item,xtype) \ + if ( !STRCMP(keywords[i],str1) &&\ + (i+1" "ms" "milliseconds" "msf" "hmsf" + * "tmsf" "SMPTE 24" "SMPTE 25" "SMPTE 30" + * "SMPTE drop 30" + * "audio [all|left|right] [on|off]" sets specified audiochannel on or off + * "video [on|off]" sets video on/off + * Waveform audio: + * "formattag pcm" sets format to pcm + * "formattag " sets integer formattag value + * "any input" accept input from any known source + * "any output" output to any known destination + * "input " input from source + * "output " output to destination + * "channels " sets nr of channels + * "bytespersec " sets average bytes per second + * "samplespersec " sets average samples per second (1 sample can + * be 2 bytes!) + * "alignment " sets the blockalignment to + * "bitspersample " sets the nr of bits per sample + * Sequencer: + * "master [midi|file|smpte|none]" sets the midi master device + * "slave [midi|file|smpte|none]" sets the midi master device + * "port mapper" midioutput to portmapper + * "port " midioutput to specified port + * "tempo " tempo of track (depends on timeformat/divtype) + * "offset " start offset? + */ +static DWORD +MCISTR_Set(_MCISTR_PROTO_) { + union { + MCI_SET_PARMS setParams; + MCI_WAVE_SET_PARMS wavesetParams; + MCI_SEQ_SET_PARMS seqsetParams; + } U; + int i,res; + + U.setParams.dwCallback = 0; + i = 0; + while (i */ +#define WII(str,flag,element) \ + if (!STRCMP(keywords[i],str) && (i+1" enable break on key with keyid + * (I strongly suspect, that there is another parameter: + * "window " + * but I don't see it mentioned in my documentation. + * Returns nothing. + */ +static DWORD +MCISTR_Break(_MCISTR_PROTO_) { + MCI_BREAK_PARMS breakParams; + int res,i; + + /*breakParams.hwndBreak ? */ + i=0;while (ii+1)) { + dwFlags&=~MCI_BREAK_OFF; + dwFlags|=MCI_BREAK_KEY; + sscanf(keywords[i+1],"%d",&(breakParams.nVirtKey)); + i+=2; + continue; + } + i++; + } + _MCI_CALL_DRIVER(MCI_BREAK,breakParams); + return res; +} + +#define ITEM1(str,item,xtype) \ + if (!STRCMP(keywords[i],str)) {\ + gdcParams.dwItem = item;\ + type = xtype;\ + i++;\ + continue;\ + } +#define ITEM2(str1,str2,item,xtype) \ + if ( !STRCMP(keywords[i],str1) &&\ + (i+1" record up to