Release 941017

Sun Oct 16 13:29:07 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)

	* [controls/button.c]
	Implemented WM_GETDLGCODE, WM_SETFONT, BM_SETSTYLE, BM_SETCHECK,
	BM_SETSTATE.
	Implemented default button painting.
	Optimised redrawing.
	Fixed owner-draw buttons.

	* [controls/static.c]
	Implemented WM_SETFONT.
	A few optimisations in painting code.
	Bug fix for SS_SIMPLE controls.

	* [if1632/callback.c]
	Preliminary GetCodeHandle().

	* [if1632/gdi.spec]
	Changed 'pascal' to 'pascal16' everywhere it's needed.

	* [include/windows.h]
	Fixed a few data structures.

	* [memory/heap.c]
	Bug fix in HEAP_ReAlloc().

	* [misc/cursor.c]
	Fixed SetCursor().

	* [objects/bitblt.c]
	Fixed PatBlt() when using BLACKNESS or WHITENESS codes.

	* [objects/font.c]
	Better font mapping code.
	Implemented GetTextFace().

	* [objects/region.c]
	Bug fix in REGION_MakePixmap().
	Faster region copying.

	* [objects/text.c]
	Implemented ExtTextOut().
	Implemented DT_NOCLIP style for DrawText().

	* [windows/dc.c]
	Free the bitmap when deleting a memory DC.

	* [windows/dce.c]
	Added support for windows that have no associated X window.
	Implemented DCX_CLIPSIBLINGS and DCX_PARENTCLIP in GetDCEx().

	* [windows/defdlg.c]
	Implemented default push button handling and DM_SETDEFID.
	Implemented WM_NEXTDLGCTL.

	* [windows/dialog.c]
	Implemented default push button handling.
	Beginning of a keyboard interface in dialogs
	(does not really work yet).
	Fixed dialogs that use a special font.

	* [windows/event.c] [windows/focus.c]
	Added support for non-X windows.

	* [windows/graphics.c]
	Rewritten FloodFill() and implemented ExtFloodFill().

	* [windows/message.c]
	Cleaner hardware messages and X events handling.

	* [windows/defwnd.c] [windows/painting.c]
	Implemented WM_SETREDRAW.

	* [windows/win.c]
	Only create an X window for top-level windows, or for the desktop.
	Child windows now use their parent's drawable.

	* [windows/winpos.c]
	Beginning of support for non-X windows (still somewhat broken).
	Implemented *DeferWindowPos().

	* [*/Imakefile]
	Cleaned up some Imakefiles.
	Moved dc.c from windows/ to objects/.
	Moved cursor.c from misc/ to windows/.

Sun Oct 16 12:21:52 1994  Michael Patra <micky@marie.physik.tu-berlin.d400.de>

	* [include/debug.h]
	  [include/stddebug.h]
	  [*/*.c]
        Rewritten all the calls to printf for displaying debug-information
        (messages like "LoadImage: loading SOL (SOL.EXE)" etc.) 
        Added option "-debugmsg" to Wine. Example: "-debugmsg +all" will turn
        all these messages on, "-debugmsg -dll" will turn all messages 
	concerning DLLs off.

	* [controls/combo.c]
	Added some handling for combo controls with ownerdraw-styles
        (just creating and passing the necessary messages to the 
	corresponding listbox control; the edit-control needs to be
	replaced with something else).

	* [controls/edit.c]
	  [windows/dialog.c]
	Added support for use of global heap memory in dialogs with 
	edit controls.

	* [controls/listbox.c]
	Added support for item data.
	ListBoxInsertString(): Fixed bug for elements which are not inserted
	after the currently last element.
	
	* [misc/dos_fs.c]
	  [miscemu/int21.c]
	DOS_ValidDirectory(): Checks whether a given string is in fact the
	valid name of a directory.

Sat Oct 15 17:35:00 PDT 1994		<martin@cs.csufresno.edu>

	* [Imakefile]
	generate wine.sym after creating wine

	* [debugger/dbg.y]
	load "wine.sym" when entering debugger

	* [debugger/info.c]
	symbolic backtrace for 32-bit stack. Breaks 16-bit bt.

Sun Sep  25 12:00:00 PDT 1994   <martin@osiris.cs.csufresno.edu>

	* [rc/rc.y] [rc/rc.h] [rc/rc.l] [rc/winerc.c]
	Files created

Sun Sep 18 11:04:45 MET DST 1994          Dag Asheim (dash@ifi.uio.no)

	* [misc/spy.c]
	Exclude and Include no longer requires a terminating ';' to
	register the last component.

Thu Sep 15 23:10:09 MET DST 1994          Dag Asheim (dash@ifi.uio.no)

	* [Configure]
	Rewrote much of it.  Added capability to generate a wine.ini
	file.  Commented out the processor emulator options until that
	becomes interesting.  Gives a warning if it sees any *.rej
	files.  I hope I haven't assumed to much about the shell/OS so
	that it breaks under *BSD.

	* [misc/dos_fs.c]
	Removed/changed calls to ToUnix() (which calls tolower()) so
	that the part of the pathname which correspond with the drive
	letter on DOS no longer will be mapped to lowercase.  This
	means that it should be possible to have uppercase letters in
	the [drives] section of wine.ini.

	* [LICENSE]
	Cosmetic changes so that it displays better in the window you
	get from pressing "Credit_License" in the "About WINE" window.

Sun Aug 21 21:12:06 MET DST 1994	<erik@xs4all.nl>

	* [controls/menu.c]
	LoadMenu() moved to loader/resource.c.

	* [misc/main.c]
	Added stub for FileCDR().

	* [include/peexe.h]
	Added, from Eric's pe-test.

	* [include/resource.h]
	Added.

	* [loader/resources.c]
	Removed duplicated code in *Resource() functions.
	Moved NE-program specific functions into ne_image.c.
	Moved NE-fileformat functions to ne_resource.c.

	* [pe_image.c] [pe_resource.c]
	Added. Nothing implemented to run PE-executables, resource
	loading only.

	* [misc/file.c]
	Changed OpenFile() to use macros.

	* [misc/shell.c]
	Added NULL-ptr checks to ShellAbout().

	* [miscemu/int21.c]
	Fixed a few typos.

	* [miscemu/kernel.c]
	Added _DI = _DS, to put the caller's instance in DI. Doesn't
	work properly if caller changed DS :-(
This commit is contained in:
Alexandre Julliard 1994-10-17 18:12:41 +00:00
parent 940d58c201
commit aca057835e
135 changed files with 8180 additions and 5619 deletions

2
BUGS
View File

@ -1,8 +1,8 @@
- EBP and ESP are sometimes corrupted while running 16-bit code.
- Dialog Boxes created by WM_CREATE handler aren't visible
- RegisterClass() with hbrBackground = COLOR_APPWORKSPACE+1 does not work.
- MDI does not send WM_GETMINMAX message.
- InitializeLoadedDLLs() can't init LZEXPAND.DLL. (cs:ip => 0:0)
- LoadCursor does not correctly handle bitmap cursors
- AllocCSToDSAlias() shouldn't alloc alias for the same segment multiple times.
- Dialogs don't support resources which are referred to as integers.
- grep for FIXME in the source files.

191
ChangeLog
View File

@ -1,3 +1,194 @@
Sun Oct 16 13:29:07 1994 Alexandre Julliard (julliard@lamisun.epfl.ch)
* [controls/button.c]
Implemented WM_GETDLGCODE, WM_SETFONT, BM_SETSTYLE, BM_SETCHECK,
BM_SETSTATE.
Implemented default button painting.
Optimised redrawing.
Fixed owner-draw buttons.
* [controls/static.c]
Implemented WM_SETFONT.
A few optimisations in painting code.
Bug fix for SS_SIMPLE controls.
* [if1632/callback.c]
Preliminary GetCodeHandle().
* [if1632/gdi.spec]
Changed 'pascal' to 'pascal16' everywhere it's needed.
* [include/windows.h]
Fixed a few data structures.
* [memory/heap.c]
Bug fix in HEAP_ReAlloc().
* [misc/cursor.c]
Fixed SetCursor().
* [objects/bitblt.c]
Fixed PatBlt() when using BLACKNESS or WHITENESS codes.
* [objects/font.c]
Better font mapping code.
Implemented GetTextFace().
* [objects/region.c]
Bug fix in REGION_MakePixmap().
Faster region copying.
* [objects/text.c]
Implemented ExtTextOut().
Implemented DT_NOCLIP style for DrawText().
* [windows/dc.c]
Free the bitmap when deleting a memory DC.
* [windows/dce.c]
Added support for windows that have no associated X window.
Implemented DCX_CLIPSIBLINGS and DCX_PARENTCLIP in GetDCEx().
* [windows/defdlg.c]
Implemented default push button handling and DM_SETDEFID.
Implemented WM_NEXTDLGCTL.
* [windows/dialog.c]
Implemented default push button handling.
Beginning of a keyboard interface in dialogs
(does not really work yet).
Fixed dialogs that use a special font.
* [windows/event.c] [windows/focus.c]
Added support for non-X windows.
* [windows/graphics.c]
Rewritten FloodFill() and implemented ExtFloodFill().
* [windows/message.c]
Cleaner hardware messages and X events handling.
* [windows/defwnd.c] [windows/painting.c]
Implemented WM_SETREDRAW.
* [windows/win.c]
Only create an X window for top-level windows, or for the desktop.
Child windows now use their parent's drawable.
* [windows/winpos.c]
Beginning of support for non-X windows (still somewhat broken).
Implemented *DeferWindowPos().
* [*/Imakefile]
Cleaned up some Imakefiles.
Moved dc.c from windows/ to objects/.
Moved cursor.c from misc/ to windows/.
Sun Oct 16 12:21:52 1994 Michael Patra <micky@marie.physik.tu-berlin.d400.de>
* [include/debug.h]
[include/stddebug.h]
[*/*.c]
Rewritten all the calls to printf for displaying debug-information
(messages like "LoadImage: loading SOL (SOL.EXE)" etc.)
Added option "-debugmsg" to Wine. Example: "-debugmsg +all" will turn
all these messages on, "-debugmsg -dll" will turn all messages
concerning DLLs off.
* [controls/combo.c]
Added some handling for combo controls with ownerdraw-styles
(just creating and passing the necessary messages to the
corresponding listbox control; the edit-control needs to be
replaced with something else).
* [controls/edit.c]
[windows/dialog.c]
Added support for use of global heap memory in dialogs with
edit controls.
* [controls/listbox.c]
Added support for item data.
ListBoxInsertString(): Fixed bug for elements which are not inserted
after the currently last element.
* [misc/dos_fs.c]
[miscemu/int21.c]
DOS_ValidDirectory(): Checks whether a given string is in fact the
valid name of a directory.
Sat Oct 15 17:35:00 PDT 1994 <martin@cs.csufresno.edu>
* [Imakefile]
generate wine.sym after creating wine
* [debugger/dbg.y]
load "wine.sym" when entering debugger
* [debugger/info.c]
symbolic backtrace for 32-bit stack. Breaks 16-bit bt.
Sun Sep 18 11:04:45 MET DST 1994 Dag Asheim (dash@ifi.uio.no)
* [misc/spy.c]
Exclude and Include no longer requires a terminating ';' to
register the last component.
Thu Sep 15 23:10:09 MET DST 1994 Dag Asheim (dash@ifi.uio.no)
* [Configure]
Rewrote much of it. Added capability to generate a wine.ini
file. Commented out the processor emulator options until that
becomes interesting. Gives a warning if it sees any *.rej
files. I hope I haven't assumed to much about the shell/OS so
that it breaks under *BSD.
* [misc/dos_fs.c]
Removed/changed calls to ToUnix() (which calls tolower()) so
that the part of the pathname which correspond with the drive
letter on DOS no longer will be mapped to lowercase. This
means that it should be possible to have uppercase letters in
the [drives] section of wine.ini.
* [LICENSE]
Cosmetic changes so that it displays better in the window you
get from pressing "Credit_License" in the "About WINE" window.
Sun Aug 21 21:12:06 MET DST 1994 <erik@xs4all.nl>
* [controls/menu.c]
LoadMenu() moved to loader/resource.c.
* [misc/main.c]
Added stub for FileCDR().
* [include/peexe.h]
Added, from Eric's pe-test.
* [include/resource.h]
Added.
* [loader/resources.c]
Removed duplicated code in *Resource() functions.
Moved NE-program specific functions into ne_image.c.
Moved NE-fileformat functions to ne_resource.c.
* [pe_image.c] [pe_resource.c]
Added. Nothing implemented to run PE-executables, resource
loading only.
* [misc/file.c]
Changed OpenFile() to use macros.
* [misc/shell.c]
Added NULL-ptr checks to ShellAbout().
* [miscemu/int21.c]
Fixed a few typos.
* [miscemu/kernel.c]
Added _DI = _DS, to put the caller's instance in DI. Doesn't
work properly if caller changed DS :-(
----------------------------------------------------------------------
Thu Aug 25 15:24:36 EDT 1994 <jrichard@cs.uml.edu>

213
Configure
View File

@ -1,30 +1,57 @@
#! /bin/sh
#
# Configure script for wine
: ${EDITOR:=vi}
: ${PAGER:=more}
ALLDEFINES=''
echo
# Ask question 'str' and sets 'var' reply (defaulting to 'def' on CR)
prompt ()
{
str="$1"
var="$2"
def="$3"
eval $var='$def'
echo
echo -n "$str [$def]? "
input=`head -1` # When using read, user must double all backslashes
if [ -n "$input" ]
then
eval $var='$input'
fi
}
echo -n 'Build Wine as emulator or library (E/L) [E]? '
read input
if [ "$input" = 'l' -o "$input" = 'L' ]
then
WINELIB='#define WINELIB -DWINELIB'
ALLDEFINES="$ALLDEFINES -DWINELIB"
WINELIB='#define WINELIB -DWINELIB'
ALLDEFINES="$ALLDEFINES -DWINELIB"
else
WINELIB=''
echo -n 'Use processor emulator (*DOES*NOT*WORK*YET*) (Y/N) [N]? '
read input
if [ "$input" = 'y' -o "$input" = 'Y' ]
then
PROCEMU='#define PROCEMU'
echo -n 'bochs directory [/usr/src/bochs]? '
read input
if [ "$input" = '' ]
then
ALLDEFINES="$ALLDEFINES -DPROC_EMU_DIR=/usr/src/bochs"
else
ALLDEFINES="$ALLDEFINES -DPROC_EMU_DIR="$input
fi
fi
WINELIB=''
# Commented out until the processor emulator starts to work.
#
# echo
# echo -n 'Use processor emulator (*DOES*NOT*WORK*YET*) (Y/N) [N]? '
# read input
# if [ "$input" = 'y' -o "$input" = 'Y' ]
# then
# PROCEMU='#define PROCEMU'
# echo
# echo -n 'bochs directory [/usr/src/bochs]? '
# read input
# if [ "$input" = '' ]
# then
# ALLDEFINES="$ALLDEFINES -DPROC_EMU_DIR=/usr/src/bochs"
# else
# ALLDEFINES="$ALLDEFINES -DPROC_EMU_DIR="$input
# fi
# fi
fi
echo
@ -32,54 +59,154 @@ echo -n 'Short filenames (Y/N) [N]? '
read input
if [ "$input" = 'y' -o "$input" = 'Y' ]
then
SHORTNAMES='#define ShortNames -DSHORTNAMES'
ALLDEFINES="$ALLDEFINES -DSHORTNAMES"
SHORTNAMES='#define ShortNames -DSHORTNAMES'
ALLDEFINES="$ALLDEFINES -DSHORTNAMES"
else
SHORTNAMES=''
SHORTNAMES=''
fi
echo -n 'Global configfile name [/usr/local/etc/wine.conf]? '
prompt "Global configfile name" WINE_CONFIGFILE /usr/local/etc/wine.conf
WINE_INI_GLOBAL='#define WINE_INI_GLOBAL "'$WINE_CONFIGFILE'"'
if [ -r $WINE_CONFIGFILE ]
then
DEFAULT_ANS=N
else
DEFAULT_ANS=Y
fi
echo
echo -n "Do you want to make a config file now (Y/N) [$DEFAULT_ANS]? "
read input
if [ "$input" = '' ]
then
WINE_INI_GLOBAL='#define WINE_INI_GLOBAL "/usr/local/etc/wine.conf"'
input="$DEFAULT_ANS"
fi
if [ "$input" = 'y' -o "$input" = 'Y' ]
then
if [ -r $WINE_CONFIGFILE ]
then
echo "Backing up the old file to ${WINE_CONFIGFILE}.old."
if cp $WINE_CONFIGFILE ${WINE_CONFIGFILE}.old
then :
else
echo "Error while creating backup file. Fix it and run Configure again"
exit 1
fi
fi
case `awk 'BEGIN {s=0} {if ($3=="msdos") s++} END {print s}' /etc/fstab` in
0) CF_C=/c;;
1) CF_C=`awk '{if ($3=="msdos") print $2}' /etc/fstab`;;
*) CF_C=`awk '{if ($3=="msdos") {print $2;exit}}' /etc/fstab`;;
esac
prompt "Which directory do you want to use as A:" CF_A /a
prompt "Which directory do you want to use as C:" CF_C $CF_C
prompt "Where is the Windows directory" CF_Windows 'c:\windows'
prompt "Where is the System directory" CF_System 'c:\windows\system'
prompt "Where should Windows apps store temp files" CF_Temp 'c:\temp'
prompt "Which path should be used to find executables and DLL's" CF_Path 'c:\windows;c:\windows\system'
prompt "Where is sysres.dll" CF_SystemResources `pwd`/sysres.dll
prompt "Where is COM1" CF_Com1 '/dev/cua0'
prompt "Where is COM2" CF_Com2 '/dev/cua1'
prompt "Where is LPT1" CF_Lpt1 '/dev/lp0'
prompt "Log messages to which file (CON = stdout)" CF_File 'CON'
echo
sed -n -e 's/^ *\"\(WM_[A-Z0-9]*\)\".*/\1/p' < misc/spy.c | \
sort | pr -ta4w83 | sed '1 i\
Here is the list of messages:\
\
' | $PAGER
prompt "Exclude which messages from the log" CF_Exclude 'WM_SIZE;WM_TIMER'
echo
echo "The config file $WINE_CONFIGFILE now looks like this:"
tee $WINE_CONFIGFILE << EOF
[drives]
A=$CF_A
C=$CF_C
[wine]
Windows=$CF_Windows
System=$CF_System
Temp=$CF_Temp
Path=$CF_Path
SystemResources=$CF_SystemResources
[serialports]
Com1=$CF_Com1
Com2=$CF_Com2
[parallelports]
Lpt1=$CF_Lpt1
[spy]
File=$CF_File
Exclude=$CF_Exclude
EOF
echo
echo -n "Do you want to edit it using $EDITOR (Y/N) [N]? "
read input
if [ "$input" = 'y' -o "$input" = 'Y' ]
then
$EDITOR $WINE_CONFIGFILE
fi
else
WINE_INI_GLOBAL='#define WINE_INI_GLOBAL "'$input'"'
if [ ! -r $WINE_CONFIGFILE ]
then
echo 'Ok, remember to make it yourself later.'
fi
fi
NEWBUILD=''
if [ "`(domainname)`" = 'amscons.com' ]
then
echo
echo -n 'New build program (Y/N) [N]? '
read input
if [ "$input" = 'y' -o "$input" = 'Y' ]
then
NEWBUILD='#define NewBuild -DNEWBUILD'
ALLDEFINES="$ALLDEFINES -DNEWBUILD"
else
NEWBUILD=''
fi
else
NEWBUILD=''
fi
NEWLINUXLDT=''
if [ -f /usr/include/linux/ldt.h ]
if grep -s seg_not_present /usr/include/linux/ldt.h 2> /dev/null
then
if grep seg_not_present /usr/include/linux/ldt.h
then
NEWLINUXLDT='#define NEW_LDT_STRUCT'
fi
NEWLINUXLDT='#define NEW_LDT_STRUCT'
fi
echo '/* autoconf.h generated automatically. Run Configure. */' > autoconf.h
echo $WINELIB >> autoconf.h
echo $SHORTNAMES >> autoconf.h
echo $NEWBUILD >> autoconf.h
echo $WINE_INI_GLOBAL >> autoconf.h
echo $NEWLINUXLDT >> autoconf.h
echo $ENDIAN >> autoconf.h
echo $PROCEMU >> autoconf.h
echo $PROCEMUDIR >> autoconf.h
echo "#define AutoDefines $ALLDEFINES" >> autoconf.h
cat > autoconf.h << EOF
/* autoconf.h generated automatically. Run Configure. */
$WINELIB
$SHORTNAMES
$NEWBUILD
$WINE_INI_GLOBAL
$NEWLINUXLDT
$ENDIAN
$PROCEMUDIR
#define AutoDefines $ALLDEFINES
EOF
xmkmf -a
if [ 0 -lt `find . -name "*.rej" -print | wc -l` ]
then
cat << EOF
WARNING: You have some files named "*.rej". Rejected patch files?
Maybe you tried to upgrade Wine by diff-files, and that patch failed.
If something doesn't work, this might be the reason. See "man patch".
List of "*.rej" files:
EOF
find . -name "*.rej" -print
echo
fi

View File

@ -81,3 +81,37 @@ Some functions are defined as type "register" in the DLL specification files.
Inorder to return values in the registers to the WIN16 program, the handler
function must exit by calling ReturnFromRegisterFunc(). Look at the function
DOS3Call() for an example of how this works.
DEBUG MESSAGES:
To display a message only during debugging, you normally write something
like this:
#ifdef DEBUG_WIN
printf("abc...");
#endif
You can write this shorter (and better) in this way:
dprintf_win(stddeb,"abc...");
All symbols of the form dprintf_xxxx are macros defined in include/debug.h .
The macro-definitions are generated by the shell-script tools/make_debug. It
scans the source code for symbols of this forms and puts the necessary
macro definitions in include/debug.h and include/stddebug.h . These macros
test for the symbol DEBUG_XXXX (e.g. dprintf_win refers to DEBUG_WIN) being
defined and thus decided whether to actually display the text. If you want
to enable specific types of messages, simply put the corresponding
#define DEBUG_XXXX in include/stddebug.h . If you want to enable or disable
a specific type of message in just one c-source-file, put the corresponding
#define DEBUG_XXXX or #undefine DEBUG_XXXX between #include<stddebug.h> and
#include <debug.h> in that specific file. In addition you can change the
types of displayed messages by supplying the "-debugmsg" option to Wine.
The file handle "stddeb" is intended for displaying standard informational
messages, whereas "stdnimp" is intended for displaying messages concerning
not yet implemented functions.
You have to start tools/make_debug only if you introduced a new macro,
e.g. dprintf_win32s - not if you just changed one of the #define
DEBUG_XXX's in include/stddebug.h or in a specific file.

View File

@ -87,7 +87,7 @@ SYSLIBS = -lm -lg
MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
AllTarget(wine)
AllTarget(wine.sym)
#ifndef WINELIB
NormalProgramTarget(wine,$(EMUOBJS) $(COMMONOBJS),$(DEPXLIB),$(XLIB),$(SYSLIBS))
@ -95,9 +95,17 @@ NormalProgramTarget(wine,$(EMUOBJS) $(COMMONOBJS),$(DEPXLIB),$(XLIB),$(SYSLIBS))
NormalLibraryTarget(wine,$(LIBOBJS) $(COMMONOBJS))
#endif
wine.sym: wine
nm wine|sort >wine.sym
clean::
$(RM) wine.sym
depend::
install::
etags::
etags `find . -name '*.[chS]'`

View File

@ -7,7 +7,7 @@ included in the original work (you may also add your own
copyright notice); and (3) agree to indemnify and hold all prior
authors, copyright holders and licensors of the work harmless
from and against all damages arising from use of the work.
You may distribute sources of derivative works of the work
provided that (1) (a) all source files of the original work that
have been modified, (b) all source files of the derivative work
@ -19,7 +19,7 @@ Sources") carry a prominent notice explaining the nature and date
of the modification and/or creation. You are encouraged to make
the Necessary Sources available under this license in order to
further the development and acceptance of the work.
EXCEPT AS OTHERWISE RESTRICTED BY LAW, THIS WORK IS PROVIDED
WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND, INCLUDING
BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF FITNESS FOR A
@ -27,4 +27,3 @@ PARTICULAR PURPOSE, MERCHANTABILITY OR TITLE. EXCEPT AS
OTHERWISE PROVIDED BY LAW, NO AUTHOR, COPYRIGHT HOLDER OR
LICENSOR SHALL BE LIABLE TO YOU FOR DAMAGES OF ANY KIND, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

View File

@ -5,19 +5,18 @@ MODULE = controls
SRCS = \
button.c \
combo.c \
desktop.c \
edit.c \
listbox.c \
menu.c \
scroll.c \
static.c \
edit.c \
desktop.c \
widgets.c
OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

File diff suppressed because it is too large Load Diff

View File

@ -5,11 +5,6 @@
*
*/
#define DEBUG_COMBO
/*
#define DEBUG_COMBO
*/
static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <stdio.h>
@ -22,6 +17,11 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include "heap.h"
#include "win.h"
#include "prototypes.h"
#include "stddebug.h"
/* #define DEBUG_COMBO */
/* #undef DEBUG_COMBO */
#include "debug.h"
HBITMAP hComboBit = 0;
@ -34,26 +34,22 @@ int CreateComboStruct(HWND hwnd);
*/
LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
{
WORD wRet;
RECT rect;
int y, count;
int width, height;
int AltState;
WND *wndPtr;
LPHEADCOMBO lphc;
HDC hDC, hMemDC;
HDC hDC;
BITMAP bm;
char str[128];
PAINTSTRUCT paintstruct;
static RECT rectsel;
int style;
switch(message)
{
case WM_CREATE:
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == NULL) return 0;
#ifdef DEBUG_COMBO
printf("Combo WM_CREATE %lX !\n", lphc);
#endif
dprintf_combo(stddeb,"Combo WM_CREATE %p !\n", lphc);
if (hComboBit == (HBITMAP)NULL)
hComboBit = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_COMBO));
GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
@ -77,15 +73,21 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE | SS_LEFT,
0, 0, width - bm.bmHeight, bm.bmHeight,
hwnd, 1, wndPtr->hInstance, 0L);
style=0;
if ((wndPtr->dwStyle & CBS_HASSTRINGS) == CBS_HASSTRINGS)
style |= LBS_HASSTRINGS;
if ((wndPtr->dwStyle & CBS_OWNERDRAWFIXED) ==CBS_OWNERDRAWFIXED)
style |= LBS_OWNERDRAWFIXED;
if ((wndPtr->dwStyle & CBS_OWNERDRAWVARIABLE)==CBS_OWNERDRAWVARIABLE)
style |= LBS_OWNERDRAWVARIABLE;
lphc->hWndLBox = CreateWindow("LISTBOX", "",
WS_POPUP | WS_BORDER | WS_VSCROLL | LBS_NOTIFY,
WS_POPUP | WS_BORDER | WS_VSCROLL | LBS_NOTIFY | style,
rect.left, rect.top + bm.bmHeight,
width, height, wndPtr->hwndParent, 0,
wndPtr->hInstance, (LPSTR)MAKELONG(0, hwnd));
ShowWindow(lphc->hWndLBox, SW_HIDE);
#ifdef DEBUG_COMBO
printf("Combo Creation LBox=%X!\n", lphc->hWndLBox);
#endif
dprintf_combo(stddeb,"Combo Creation LBox=%X!\n",
lphc->hWndLBox);
return 0;
case WM_DESTROY:
lphc = ComboGetStorageHeader(hwnd);
@ -99,14 +101,11 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
*((LPHEADCOMBO *)&wndPtr->wExtra[1]) = 0;
printf("Combo WM_DESTROY after clearing wExtra !\n");
*/
#ifdef DEBUG_COMBO
printf("Combo WM_DESTROY %lX !\n", lphc);
#endif
dprintf_combo(stddeb,"Combo WM_DESTROY %p !\n", lphc);
return DefWindowProc( hwnd, message, wParam, lParam );
case WM_SHOWWINDOW:
#ifdef DEBUG_COMBO
printf("ComboBox WM_SHOWWINDOW hWnd=%04X !\n", hwnd);
#endif
dprintf_combo(stddeb,"ComboBox WM_SHOWWINDOW hWnd=%04X !\n",
hwnd);
if (!(wParam == 0 && lParam == 0L)) {
InvalidateRect(hwnd, NULL, TRUE);
}
@ -137,12 +136,12 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
}
break;
case WM_LBUTTONDOWN:
printf("Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam);
dprintf_combo(stddeb,"Combo WM_LBUTTONDOWN wParam=%x lParam=%lX !\n", wParam, lParam);
GetClientRect(hwnd, &rect);
rect.left = rect.right - (rect.bottom - rect.top);
hDC = GetDC(hwnd);
InflateRect(&rect, -1, -1);
DrawReliefRect(hDC, rect, 1, 1);
GRAPH_DrawReliefRect(hDC, &rect, 1, 1);
ReleaseDC(hwnd, hDC);
wndPtr = WIN_FindWndPtr(hwnd);
lphc = ComboGetStorageHeader(hwnd);
@ -153,27 +152,27 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
SetFocus(lphc->hWndLBox);
}
else {
printf("before Combo Restore Focus !\n");
dprintf_combo(stddeb,"before Combo Restore Focus !\n");
SetFocus(lphc->hWndEdit);
printf("before Combo List Hide !\n");
dprintf_combo(stddeb,"before Combo List Hide !\n");
ShowWindow(lphc->hWndLBox, SW_HIDE);
printf("before Combo List GetCurSel !\n");
dprintf_combo(stddeb,"before Combo List GetCurSel !\n");
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
if (y != LB_ERR) {
printf("before Combo List GetText !\n");
dprintf_combo(stddeb,"before Combo List GetText !\n");
SendMessage(lphc->hWndLBox, LB_GETTEXT, (WORD)y, (LPARAM)str);
SendMessage(lphc->hWndEdit, WM_SETTEXT, (WORD)y, (LPARAM)str);
}
printf("End of Combo List Hide !\n");
dprintf_combo(stddeb,"End of Combo List Hide !\n");
}
break;
case WM_LBUTTONUP:
printf("Combo WM_LBUTTONUP wParam=%x lParam=%lX !\n", wParam, lParam);
dprintf_combo(stddeb,"Combo WM_LBUTTONUP wParam=%x lParam=%lX !\n", wParam, lParam);
GetClientRect(hwnd, &rect);
rect.left = rect.right - (rect.bottom - rect.top);
hDC = GetDC(hwnd);
InflateRect(&rect, -1, -1);
DrawReliefRect(hDC, rect, 1, 0);
GRAPH_DrawReliefRect(hDC, &rect, 1, 0);
ReleaseDC(hwnd, hDC);
break;
case WM_KEYDOWN:
@ -182,7 +181,7 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
if (lphc == NULL) return 0;
y = SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L);
count = SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L);
printf("COMBOBOX // GetKeyState(VK_MENU)=%d\n", GetKeyState(VK_MENU));
dprintf_combo(stddeb,"COMBOBOX // GetKeyState(VK_MENU)=%d\n", GetKeyState(VK_MENU));
if (GetKeyState(VK_MENU) < 0) {
lphc->dwState = lphc->dwState ^ CB_SHOWDROPDOWN;
if ((lphc->dwState & CB_SHOWDROPDOWN) == CB_SHOWDROPDOWN) {
@ -223,21 +222,22 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
}
break;
case WM_MEASUREITEM:
printf("ComboBoxWndProc WM_MEASUREITEM !\n");
dprintf_combo(stddeb,"ComboBoxWndProc WM_MEASUREITEM !\n");
return(SendMessage(GetParent(hwnd), WM_MEASUREITEM, wParam, lParam));
case WM_CTLCOLOR:
return(SendMessage(GetParent(hwnd), WM_CTLCOLOR, wParam, lParam));
case WM_DRAWITEM:
return(SendMessage(GetParent(hwnd), WM_DRAWITEM, wParam, lParam));
case WM_PAINT:
GetClientRect(hwnd, &rect);
hDC = BeginPaint(hwnd, &paintstruct);
hMemDC = CreateCompatibleDC(hDC);
if (hMemDC != 0 && hComboBit != 0) {
if (hComboBit != 0) {
GetObject(hComboBit, sizeof(BITMAP), (LPSTR)&bm);
SelectObject(hMemDC, hComboBit);
BitBlt(hDC, rect.right - bm.bmWidth, 0,
bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
GRAPH_DrawBitmap( hDC, hComboBit,
rect.right - bm.bmWidth, 0,
0, 0, bm.bmWidth, bm.bmHeight,
SRCCOPY );
}
DeleteDC(hMemDC);
EndPaint(hwnd, &paintstruct);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
@ -264,41 +264,37 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
}
break;
case CB_ADDSTRING:
#ifdef DEBUG_COMBO
printf("CB_ADDSTRING '%s' !\n", (LPSTR)lParam);
#endif
dprintf_combo(stddeb,"CB_ADDSTRING '%s' !\n", (LPSTR)lParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_ADDSTRING, wParam, lParam));
case CB_GETLBTEXT:
#ifdef DEBUG_COMBO
printf("CB_GETLBTEXT #%u !\n", wParam);
#endif
dprintf_combo(stddeb,"CB_GETLBTEXT #%u !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_GETTEXT, wParam, lParam));
case CB_GETLBTEXTLEN:
printf("CB_GETLBTEXTLEN !\n");
dprintf_combo(stddeb,"CB_GETLBTEXTLEN !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_GETTEXTLEN, wParam, lParam));
case CB_INSERTSTRING:
printf("CB_INSERTSTRING '%s' !\n", (LPSTR)lParam);
dprintf_combo(stddeb,"CB_INSERTSTRING '%s' !\n",(LPSTR)lParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_INSERTSTRING, wParam, lParam));
case CB_DELETESTRING:
printf("CB_DELETESTRING #%u !\n", wParam);
dprintf_combo(stddeb,"CB_DELETESTRING #%u !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_DELETESTRING, wParam, 0L));
case CB_RESETCONTENT:
printf("CB_RESETCONTENT !\n");
dprintf_combo(stddeb,"CB_RESETCONTENT !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_RESETCONTENT, 0, 0L));
case CB_DIR:
printf("ComboBox CB_DIR !\n");
dprintf_combo(stddeb,"ComboBox CB_DIR !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_DIR, wParam, lParam));
@ -310,34 +306,35 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_GETCOUNT, 0, 0L));
case CB_GETCURSEL:
printf("ComboBox CB_GETCURSEL !\n");
dprintf_combo(stddeb,"ComboBox CB_GETCURSEL !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_GETCURSEL, 0, 0L));
case CB_SETCURSEL:
printf("ComboBox CB_SETCURSEL wParam=%X !\n", wParam);
dprintf_combo(stddeb,"ComboBox CB_SETCURSEL wParam=%X !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_SETCURSEL, wParam, 0L));
case CB_GETEDITSEL:
printf("ComboBox CB_GETEDITSEL !\n");
dprintf_combo(stddeb,"ComboBox CB_GETEDITSEL !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
/* return(SendMessage(lphc->hWndEdit, EM_GETSEL, 0, 0L)); */
break;
case CB_SETEDITSEL:
printf("ComboBox CB_SETEDITSEL lParam=%lX !\n", lParam);
dprintf_combo(stddeb,"ComboBox CB_SETEDITSEL lParam=%lX !\n",
lParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
/* return(SendMessage(lphc->hWndEdit, EM_SETSEL, 0, lParam)); */
break;
case CB_SELECTSTRING:
printf("ComboBox CB_SELECTSTRING !\n");
dprintf_combo(stddeb,"ComboBox CB_SELECTSTRING !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
break;
case CB_SHOWDROPDOWN:
printf("ComboBox CB_SHOWDROPDOWN !\n");
dprintf_combo(stddeb,"ComboBox CB_SHOWDROPDOWN !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
lphc->dwState = lphc->dwState | CB_SHOWDROPDOWN;
@ -352,19 +349,19 @@ LONG ComboBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
}
break;
case CB_GETITEMDATA:
printf("ComboBox CB_GETITEMDATA wParam=%X !\n", wParam);
dprintf_combo(stddeb,"ComboBox CB_GETITEMDATA wParam=%X !\n", wParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_GETITEMDATA, wParam, 0L));
break;
case CB_SETITEMDATA:
printf("ComboBox CB_SETITEMDATA wParam=%X lParam=%lX !\n", wParam, lParam);
dprintf_combo(stddeb,"ComboBox CB_SETITEMDATA wParam=%04X lParam=%08lX!\n", wParam, lParam);
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
return(SendMessage(lphc->hWndLBox, LB_SETITEMDATA, wParam, lParam));
break;
case CB_LIMITTEXT:
printf("ComboBox CB_LIMITTEXT !\n");
dprintf_combo(stddeb,"ComboBox CB_LIMITTEXT !\n");
lphc = ComboGetStorageHeader(hwnd);
if (lphc == NULL) return 0;
/* return(SendMessage(lphc->hWndEdit, EM_LIMITTEXT, wParam, 0L)); */
@ -384,7 +381,7 @@ LPHEADCOMBO ComboGetStorageHeader(HWND hwnd)
LPHEADCOMBO lphc;
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == 0) {
printf("Bad Window handle on ComboBox !\n");
fprintf(stderr,"Bad Window handle on ComboBox !\n");
return 0;
}
lphc = *((LPHEADCOMBO *)&wndPtr->wExtra[1]);
@ -399,7 +396,7 @@ int CreateComboStruct(HWND hwnd)
LPHEADCOMBO lphc;
wndPtr = WIN_FindWndPtr(hwnd);
if (wndPtr == 0) {
printf("Bad Window handle on ComboBox !\n");
fprintf(stderr,"Bad Window handle on ComboBox !\n");
return 0;
}
lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO));
@ -415,19 +412,20 @@ int CreateComboStruct(HWND hwnd)
*/
BOOL DlgDirSelectComboBox(HWND hDlg, LPSTR lpStr, int nIDLBox)
{
printf("DlgDirSelectComboBox(%04X, '%s', %d) \n", hDlg, lpStr, nIDLBox);
fprintf(stdnimp,"DlgDirSelectComboBox(%04X, '%s', %d) \n",
hDlg, lpStr, nIDLBox);
}
/************************************************************************
* DlgDirListComboBox [USER.195]
* DlgDirListComboBox [USER.195]
*/
int DlgDirListComboBox(HWND hDlg, LPSTR lpPathSpec,
int nIDLBox, int nIDStat, WORD wType)
{
HWND hWnd;
LPHEADCOMBO lphc;
printf("DlgDirListComboBox(%04X, '%s', %d, %d, %04X) \n",
LPHEADCOMBO lphc;
dprintf_combo(stddeb,"DlgDirListComboBox(%04X, '%s', %d, %d, %04X) \n",
hDlg, lpPathSpec, nIDLBox, nIDStat, wType);
hWnd = GetDlgItem(hDlg, nIDLBox);
lphc = ComboGetStorageHeader(hWnd);

View File

@ -10,6 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "win.h"
#include "desktop.h"
#include "prototypes.h"
@ -213,7 +214,7 @@ BOOL DESKTOP_SetPattern(char *pattern )
int i;
for (i = 0; i < 8; i++) pattern[i] = pat[i] & 0xffff;
hbitmap = CreateBitmap( 8, 8, 1, 1, pattern );
hbitmap = CreateBitmap( 8, 8, 1, 1, (LPSTR)pattern );
infoPtr->hbrushPattern = CreatePatternBrush( hbitmap );
DeleteObject( hbitmap );
}

View File

@ -8,6 +8,7 @@
static char Copyright[] = "Copyright David W. Metcalfe, 1994";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
@ -16,8 +17,11 @@ static char Copyright[] = "Copyright David W. Metcalfe, 1994";
#include "class.h"
#include "user.h"
#include "scroll.h"
#include "stddebug.h"
/* #define DEBUG_EDIT /* */
/* #undef DEBUG_EDIT /* */
#include "debug.h"
#define NOTIFY_PARENT(hWndCntrl, wNotifyCode) \
SendMessage(GetParent(hWndCntrl), WM_COMMAND, \
@ -190,7 +194,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case EM_FMTLINES:
printf("edit: EM_FMTLINES message received\n");
fprintf(stdnimp,"edit: EM_FMTLINES message received\n");
if (!wParam)
lResult = 1L;
else
@ -224,7 +228,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case EM_GETPASSWORDCHAR:
printf("edit: cannot process EM_GETPASSWORDCHAR message\n");
fprintf(stdnimp,"edit: cannot process EM_GETPASSWORDCHAR message\n");
break;
case EM_GETRECT:
@ -236,7 +240,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case EM_GETWORDBREAKPROC:
printf("edit: cannot process EM_GETWORDBREAKPROC message\n");
fprintf(stdnimp,"edit: cannot process EM_GETWORDBREAKPROC message\n");
break;
case EM_LIMITTEXT:
@ -264,7 +268,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case EM_LINESCROLL:
printf("edit: cannot process EM_LINESCROLL message\n");
fprintf(stdnimp,"edit: cannot process EM_LINESCROLL message\n");
break;
case EM_REPLACESEL:
@ -283,16 +287,16 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case EM_SETPASSWORDCHAR:
printf("edit: cannot process EM_SETPASSWORDCHAR message\n");
fprintf(stdnimp,"edit: cannot process EM_SETPASSWORDCHAR message\n");
break;
case EM_SETREADONLY:
printf("edit: cannot process EM_SETREADONLY message\n");
fprintf(stdnimp,"edit: cannot process EM_SETREADONLY message\n");
break;
case EM_SETRECT:
case EM_SETRECTNP:
printf("edit: cannot process EM_SETRECT(NP) message\n");
fprintf(stdnimp,"edit: cannot process EM_SETRECT(NP) message\n");
break;
case EM_SETSEL:
@ -307,7 +311,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
break;
case EM_SETWORDBREAKPROC:
printf("edit: cannot process EM_SETWORDBREAKPROC message\n");
fprintf(stdnimp,"edit: cannot process EM_SETWORDBREAKPROC message\n");
break;
case EM_UNDO:
@ -317,6 +321,9 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
ShowCaret(hwnd);
break;
case WM_GETDLGCODE:
return DLGC_HASSETSEL | DLGC_WANTCHARS | DLGC_WANTARROWS;
case WM_CHAR:
EDIT_CharMsg(hwnd, wParam);
break;
@ -351,7 +358,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam)
if ((int)wParam > (len = strlen(textPtr)))
{
strcpy((char *)lParam, textPtr);
lResult = (DWORD)len;
lResult = (DWORD)len ;
}
else
lResult = 0L;
@ -461,11 +468,17 @@ long EDIT_NCCreateMsg(HWND hwnd, LONG lParam)
char *text;
int len;
/* store pointer to local heap in window structure so that */
/* store pointer to local or global heap in window structure so that */
/* EDITSTATE structure itself can be stored on local heap */
(MDESC **)*(LONG *)(wndPtr->wExtra + 2) =
if (HEAP_LocalFindHeap(createStruct->hInstance)!=NULL)
(MDESC **)*(LONG *)(wndPtr->wExtra + 2) =
&HEAP_LocalFindHeap(createStruct->hInstance)->free_list;
else
{
(MDESC **)*(LONG *)(wndPtr->wExtra + 2) =
GlobalLock(createStruct->hInstance);
/* GlobalUnlock(createStruct->hInstance); */
}
/* allocate space for state variable structure */
(HANDLE)(*(wndPtr->wExtra)) = EDIT_HeapAlloc(hwnd, sizeof(EDITSTATE));
es = (EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
@ -647,7 +660,7 @@ void EDIT_BuildTextPointers(HWND hwnd)
/* advance through current line */
while (*cp && *cp != '\n')
{
len += EDIT_CharWidth(hwnd, *cp, len);
len += EDIT_CharWidth(hwnd, (BYTE)*cp, len);
/* width of line in pixels */
cp++;
}
@ -697,10 +710,8 @@ void EDIT_PaintMsg(HWND hwnd)
hdc = BeginPaint(hwnd, &ps);
rc = ps.rcPaint;
#ifdef DEBUG_EDIT
printf("WM_PAINT: rc=(%d,%d), (%d,%d)\n", rc.left, rc.top,
dprintf_edit(stddeb,"WM_PAINT: rc=(%d,%d), (%d,%d)\n", rc.left, rc.top,
rc.right, rc.bottom);
#endif
if (es->PaintBkgd)
FillWindow(GetParent(hwnd), hwnd, hdc, CTLCOLOR_EDIT);
@ -728,9 +739,7 @@ HANDLE EDIT_GetTextLine(HWND hwnd, int selection)
int len = 0;
char *cp, *cp1;
#ifdef DEBUG_EDIT
printf("GetTextLine %d\n", selection);
#endif
dprintf_edit(stddeb,"GetTextLine %d\n", selection);
cp = cp1 = EDIT_TextLine(hwnd, selection);
/* advance through line */
while (*cp && *cp != '\n')
@ -783,11 +792,9 @@ int EDIT_StrLength(HWND hwnd, char *str, int len, int pcol)
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
for (i = 0; i < len; i++)
plen += EDIT_CharWidth(hwnd, *(str + i), pcol + plen);
plen += EDIT_CharWidth(hwnd, (BYTE)(*(str + i)), pcol + plen);
#ifdef DEBUG_EDIT
printf("EDIT_StrLength: returning %d\n", plen);
#endif
dprintf_edit(stddeb,"EDIT_StrLength: returning %d\n", plen);
return plen;
}
@ -838,42 +845,32 @@ void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y)
else
GetClientRect(hwnd, &rc);
#ifdef DEBUG_EDIT
printf("WriteTextLine %d\n", y);
#endif
dprintf_edit(stddeb,"WriteTextLine %d\n", y);
/* make sure y is inside the window */
if (y < es->wtop || y > (es->wtop + ClientHeight(wndPtr, es)))
{
#ifdef DEBUG_EDIT
printf("EDIT_WriteTextLine: y (%d) is not a displayed line\n", y);
#endif
dprintf_edit(stddeb,"EDIT_WriteTextLine: y (%d) is not a displayed line\n", y);
return;
}
/* make sure rectangle is within window */
if (rc.left >= ClientWidth(wndPtr) - 1)
{
#ifdef DEBUG_EDIT
printf("EDIT_WriteTextLine: rc.left (%d) is greater than right edge\n",
dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.left (%d) is greater than right edge\n",
rc.left);
#endif
return;
}
if (rc.right <= 0)
{
#ifdef DEBUG_EDIT
printf("EDIT_WriteTextLine: rc.right (%d) is less than left edge\n",
dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.right (%d) is less than left edge\n",
rc.right);
#endif
return;
}
if (y - es->wtop < (rc.top / es->txtht) ||
y - es->wtop > (rc.bottom / es->txtht))
{
#ifdef DEBUG_EDIT
printf("EDIT_WriteTextLine: y (%d) is outside window\n", y);
#endif
dprintf_edit(stddeb,"EDIT_WriteTextLine: y (%d) is outside window\n", y);
return;
}
@ -1010,9 +1007,7 @@ void EDIT_WriteText(HWND hwnd, char *lp, int off, int len, int row,
short *charWidths = (short *)EDIT_HeapAddr(hwnd, es->hCharWidths);
char *blanks = (char *)EDIT_HeapAddr(hwnd, es->hBlankLine);
#ifdef DEBUG_EDIT
printf("EDIT_WriteText lp=%s, off=%d, len=%d, row=%d, col=%d, reverse=%d\n", lp, off, len, row, col, reverse);
#endif
dprintf_edit(stddeb,"EDIT_WriteText lp=%s, off=%d, len=%d, row=%d, col=%d, reverse=%d\n", lp, off, len, row, col, reverse);
hdc = GetDC(hwnd);
hStr = EDIT_GetStr(hwnd, lp, off, len, &diff);
@ -1111,14 +1106,12 @@ HANDLE EDIT_GetStr(HWND hwnd, char *lp, int off, int len, int *diff)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_GetStr %s %d %d\n", lp, off, len);
#endif
dprintf_edit(stddeb,"EDIT_GetStr %s %d %d\n", lp, off, len);
while (i < off)
{
s_i = i;
i += EDIT_CharWidth(hwnd, *(lp + ch), i);
i += EDIT_CharWidth(hwnd, (BYTE)(*(lp + ch)), i);
ch++;
}
@ -1133,7 +1126,7 @@ HANDLE EDIT_GetStr(HWND hwnd, char *lp, int off, int len, int *diff)
while (i < len + off)
{
i += EDIT_CharWidth(hwnd, *(lp + ch), i);
i += EDIT_CharWidth(hwnd, (BYTE)(*(lp + ch)), i);
ch++;
}
@ -1142,9 +1135,7 @@ HANDLE EDIT_GetStr(HWND hwnd, char *lp, int off, int len, int *diff)
for (i = ch1, j = 0; i < ch; i++, j++)
str[j] = lp[i];
str[++j] = '\0';
#ifdef DEBUG_EDIT
printf("EDIT_GetStr: returning %s\n", str);
#endif
dprintf_edit(stddeb,"EDIT_GetStr: returning %s\n", str);
return hStr;
}
@ -1159,9 +1150,7 @@ void EDIT_CharMsg(HWND hwnd, WORD wParam)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_CharMsg: wParam=%c\n", (char)wParam);
#endif
dprintf_edit(stddeb,"EDIT_CharMsg: wParam=%c\n", (char)wParam);
switch (wParam)
{
@ -1203,9 +1192,7 @@ void EDIT_KeyTyped(HWND hwnd, short ch)
RECT rc;
BOOL FullPaint = FALSE;
#ifdef DEBUG_EDIT
printf("EDIT_KeyTyped: ch=%c\n", (char)ch);
#endif
dprintf_edit(stddeb,"EDIT_KeyTyped: ch=%c\n", (char)ch);
/* delete selected text (if any) */
if (SelMarked(es))
@ -1294,14 +1281,14 @@ void EDIT_KeyTyped(HWND hwnd, short ch)
/* test end of window */
if (es->WndCol >= ClientWidth(wndPtr) -
EDIT_CharWidth(hwnd, ch, es->WndCol + es->wleft))
EDIT_CharWidth(hwnd, (BYTE)ch, es->WndCol + es->wleft))
{
/* TODO:- Word wrap to be handled here */
/* if (!(currchar == text + es->MaxTextLen - 2)) */
EDIT_KeyHScroll(hwnd, SB_LINEDOWN);
}
es->WndCol += EDIT_CharWidth(hwnd, ch, es->WndCol + es->wleft);
es->WndCol += EDIT_CharWidth(hwnd, (BYTE)ch, es->WndCol + es->wleft);
es->CurrCol++;
SetCaretPos(es->WndCol, es->WndRow * es->txtht);
ShowCaret(hwnd);
@ -1385,7 +1372,7 @@ void EDIT_Forward(HWND hwnd)
}
else
{
es->WndCol += EDIT_CharWidth(hwnd, *CurrChar, es->WndCol + es->wleft);
es->WndCol += EDIT_CharWidth(hwnd, (BYTE)(*CurrChar), es->WndCol + es->wleft);
es->CurrCol++;
if (es->WndCol >= ClientWidth(wndPtr))
EDIT_KeyHScroll(hwnd, SB_LINEDOWN);
@ -1406,9 +1393,8 @@ void EDIT_Downward(HWND hwnd)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_Downward: WndRow=%d, wtop=%d, wlines=%d\n", es->WndRow, es->wtop, es->wlines);
#endif
dprintf_edit(stddeb,"EDIT_Downward: WndRow=%d, wtop=%d, wlines=%d\n",
es->WndRow, es->wtop, es->wlines);
if (IsMultiLine() && (es->WndRow + es->wtop + 1 < es->wlines))
{
@ -1469,12 +1455,12 @@ void EDIT_Backward(HWND hwnd)
{
--es->CurrCol;
if (*CurrChar == VK_TAB)
es->WndCol -= EDIT_CharWidth(hwnd, *CurrChar,
es->WndCol -= EDIT_CharWidth(hwnd, (BYTE)(*CurrChar),
EDIT_StrLength(hwnd,
EDIT_TextLine(hwnd, es->CurrLine),
es->CurrCol, 0));
else
es->WndCol -= EDIT_CharWidth(hwnd, *CurrChar, 0);
es->WndCol -= EDIT_CharWidth(hwnd, (BYTE)(*CurrChar), 0);
if (es->WndCol < 0)
EDIT_KeyHScroll(hwnd, SB_LINEUP);
}
@ -1502,7 +1488,7 @@ void EDIT_End(HWND hwnd)
while (*CurrChar && *CurrChar != '\n')
{
es->WndCol += EDIT_CharWidth(hwnd, *CurrChar, es->WndCol + es->wleft);
es->WndCol += EDIT_CharWidth(hwnd, (BYTE)(*CurrChar), es->WndCol + es->wleft);
es->CurrCol++;
}
@ -1583,9 +1569,7 @@ void EDIT_KeyDownMsg(HWND hwnd, WORD wParam)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_KeyDownMsg: key=%x\n", wParam);
#endif
dprintf_edit(stddeb,"EDIT_KeyDownMsg: key=%x\n", wParam);
HideCaret(hwnd);
switch (wParam)
@ -2014,9 +1998,7 @@ void EDIT_VScrollLine(HWND hwnd, WORD opt)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_VScrollLine: direction=%d\n", opt);
#endif
dprintf_edit(stddeb,"EDIT_VScrollLine: direction=%d\n", opt);
if (opt == SB_LINEDOWN)
{
@ -2222,15 +2204,13 @@ int EDIT_PixelToChar(HWND hwnd, int row, int *pixel)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_PixelToChar: row=%d, pixel=%d\n", row, *pixel);
#endif
dprintf_edit(stddeb,"EDIT_PixelToChar: row=%d, pixel=%d\n", row, *pixel);
text = EDIT_TextLine(hwnd, row);
while (i < *pixel)
{
s_i = i;
i += EDIT_CharWidth(hwnd, *(text + ch), i);
i += EDIT_CharWidth(hwnd, (BYTE)(*(text + ch)), i);
ch++;
}
@ -2581,9 +2561,7 @@ void EDIT_ExtendSel(HWND hwnd, int x, int y)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_ExtendSel: x=%d, y=%d\n", x, y);
#endif
dprintf_edit(stddeb,"EDIT_ExtendSel: x=%d, y=%d\n", x, y);
bbl = es->SelEndLine;
bbc = es->SelEndCol;
@ -2657,9 +2635,7 @@ void EDIT_WriteSel(HWND hwnd, int y, int start, int end)
EDITSTATE *es =
(EDITSTATE *)EDIT_HeapAddr(hwnd, (HANDLE)(*(wndPtr->wExtra)));
#ifdef DEBUG_EDIT
printf("EDIT_WriteSel: y=%d start=%d end=%d\n", y, start, end);
#endif
dprintf_edit(stddeb,"EDIT_WriteSel: y=%d start=%d end=%d\n", y, start,end);
GetClientRect(hwnd, &rc);
/* make sure y is within the window */
@ -3023,10 +2999,13 @@ LONG EDIT_UndoMsg(HWND hwnd)
unsigned int EDIT_HeapAlloc(HWND hwnd, int bytes)
{
WND *wndPtr = WIN_FindWndPtr(hwnd);
return ((unsigned int)HEAP_Alloc((MDESC **)
unsigned int ret;
ret = ((unsigned int)HEAP_Alloc((MDESC **)
*(LONG *)(wndPtr->wExtra + 2),
GMEM_MOVEABLE, bytes) & 0xffff);
if (ret == 0)
printf("EDIT_HeapAlloc: Out of heap-memory\n");
return ret;
}

View File

@ -5,9 +5,6 @@
*
*/
/*
#define DEBUG_LISTBOX
*/
static char Copyright[] = "Copyright Martin Ayotte, 1993";
@ -24,6 +21,10 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include "listbox.h"
#include "scroll.h"
#include "prototypes.h"
#include "stddebug.h"
/* #define DEBUG_LISTBOX /* */
/* #undef DEBUG_LISTBOX /* */
#include "debug.h"
#define GMEM_ZEROINIT 0x0040
@ -37,7 +38,8 @@ int CreateListBoxStruct(HWND hwnd);
void ListBoxAskMeasure(WND *wndPtr, LPHEADLIST lphl, LPLISTSTRUCT lpls);
int ListBoxAddString(HWND hwnd, LPSTR newstr);
int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr);
int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr);
int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr, BOOL bItemData);
int ListBoxSetItemData(HWND hwnd, UINT uIndex, DWORD ItemData);
int ListBoxDeleteString(HWND hwnd, UINT uIndex);
int ListBoxFindString(HWND hwnd, UINT nFirst, LPSTR MatchStr);
int ListBoxResetContent(HWND hwnd);
@ -51,6 +53,11 @@ int ListBoxDefaultItem(HWND hwnd, WND *wndPtr,
LPHEADLIST lphl, LPLISTSTRUCT lpls);
int ListBoxFindNextMatch(HWND hwnd, WORD wChar);
#define HasStrings(wndPtr) ( \
( ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) != LBS_OWNERDRAWFIXED) && \
((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE) ) || \
((wndPtr->dwStyle & LBS_HASSTRINGS) == LBS_HASSTRINGS) )
/***********************************************************************
* ListBoxWndProc
@ -69,9 +76,7 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
case WM_CREATE:
CreateListBoxStruct(hwnd);
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
#ifdef DEBUG_LISTBOX
printf("ListBox WM_CREATE %lX !\n", lphl);
#endif
dprintf_listbox(stddeb,"ListBox WM_CREATE %lX !\n", lphl);
if (lphl == NULL) return 0;
createStruct = (CREATESTRUCT *)lParam;
if (HIWORD(createStruct->lpCreateParams) != 0)
@ -97,15 +102,12 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
ListBoxResetContent(hwnd);
free(lphl);
*((LPHEADLIST *)&wndPtr->wExtra[1]) = 0;
#ifdef DEBUG_LISTBOX
printf("ListBox WM_DESTROY %lX !\n", lphl);
#endif
dprintf_listbox(stddeb,"ListBox WM_DESTROY %lX !\n", lphl);
return 0;
case WM_VSCROLL:
#ifdef DEBUG_LISTBOX
printf("ListBox WM_VSCROLL w=%04X l=%08X !\n", wParam, lParam);
#endif
dprintf_listbox(stddeb,"ListBox WM_VSCROLL w=%04X l=%08X !\n",
wParam, lParam);
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == NULL) return 0;
y = lphl->FirstVisible;
@ -141,9 +143,8 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
return 0;
case WM_HSCROLL:
#ifdef DEBUG_LISTBOX
printf("ListBox WM_HSCROLL w=%04X l=%08X !\n", wParam, lParam);
#endif
dprintf_listbox(stddeb,"ListBox WM_HSCROLL w=%04X l=%08X !\n",
wParam, lParam);
lphl = ListBoxGetStorageHeader(hwnd);
if (lphl == NULL) return 0;
y = lphl->FirstVisible;
@ -220,7 +221,6 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
if (lphl == NULL) return 0;
SendMessage(lphl->hWndLogicParent, WM_COMMAND, wndPtr->wIDmenu,
MAKELONG(hwnd, LBN_DBLCLK));
printf("ListBox Send LBN_DBLCLK !\n");
return 0;
case WM_MOUSEMOVE:
if ((wParam & MK_LBUTTON) != 0) {
@ -276,10 +276,12 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
hWndCtl = GetNextDlgTabItem(lphl->hWndLogicParent,
hwnd, !(GetKeyState(VK_SHIFT) < 0));
SetFocus(hWndCtl);
#ifdef DEBUG_LISTBOX
if ((GetKeyState(VK_SHIFT) < 0))
printf("ListBox PreviousDlgTabItem %04X !\n", hWndCtl);
dprintf_listbox(stddeb,"ListBox PreviousDlgTabItem %04X !\n", hWndCtl);
else
printf("ListBox NextDlgTabItem %04X !\n", hWndCtl);
dprintf_listbox(stddeb,"ListBox NextDlgTabItem %04X !\n", hWndCtl);
#endif
break;
case VK_HOME:
lphl->ItemFocused = 0;
@ -352,29 +354,21 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
StdDrawListBox(hwnd);
break;
case WM_SETFOCUS:
#ifdef DEBUG_LISTBOX
printf("ListBox WM_SETFOCUS !\n");
#endif
dprintf_listbox(stddeb,"ListBox WM_SETFOCUS !\n");
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
break;
case WM_KILLFOCUS:
#ifdef DEBUG_LISTBOX
printf("ListBox WM_KILLFOCUS !\n");
#endif
dprintf_listbox(stddeb,"ListBox WM_KILLFOCUS !\n");
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
break;
case LB_RESETCONTENT:
#ifdef DEBUG_LISTBOX
printf("ListBox LB_RESETCONTENT !\n");
#endif
dprintf_listbox(stddeb,"ListBox LB_RESETCONTENT !\n");
ListBoxResetContent(hwnd);
return 0;
case LB_DIR:
#ifdef DEBUG_LISTBOX
printf("ListBox LB_DIR !\n");
#endif
dprintf_listbox(stddeb,"ListBox LB_DIR !\n");
wRet = ListBoxDirectory(hwnd, wParam, (LPSTR)lParam);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
@ -383,16 +377,12 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
wRet = ListBoxAddString(hwnd, (LPSTR)lParam);
return wRet;
case LB_GETTEXT:
wRet = ListBoxGetText(hwnd, wParam, (LPSTR)lParam);
#ifdef DEBUG_LISTBOX
printf("ListBox LB_GETTEXT #%u '%s' !\n", wParam, (LPSTR)lParam);
#endif
return wRet;
wRet = ListBoxGetText(hwnd, wParam, (LPSTR)lParam, FALSE);
return wRet;
case LB_INSERTSTRING:
wRet = ListBoxInsertString(hwnd, wParam, (LPSTR)lParam);
return wRet;
case LB_DELETESTRING:
printf("ListBox LB_DELETESTRING #%u !\n", wParam);
wRet = ListBoxDeleteString(hwnd, wParam);
return wRet;
case LB_FINDSTRING:
@ -405,13 +395,13 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
return lphl->ItemsCount;
case LB_GETCURSEL:
lphl = ListBoxGetStorageHeader(hwnd);
#ifdef DEBUG_LISTBOX
printf("ListBox LB_GETCURSEL %u !\n", lphl->ItemFocused);
#endif
dprintf_listbox(stddeb,"ListBox LB_GETCURSEL %u !\n",
lphl->ItemFocused);
return lphl->ItemFocused;
case LB_GETHORIZONTALEXTENT:
return wRet;
case LB_GETITEMDATA:
wRet = ListBoxGetText(hwnd, wParam, (LPSTR)lParam, TRUE);
return wRet;
case LB_GETITEMHEIGHT:
return wRet;
@ -441,25 +431,26 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
case LB_SETHORIZONTALEXTENT:
return wRet;
case LB_SETITEMDATA:
wRet = ListBoxSetItemData(hwnd, wParam, lParam);
return wRet;
case LB_SETTABSTOPS:
return wRet;
case LB_SETCURSEL:
#ifdef DEBUG_LISTBOX
printf("ListBox LB_SETCURSEL wParam=%x !\n", wParam);
#endif
dprintf_listbox(stddeb,"ListBox LB_SETCURSEL wParam=%x !\n",
wParam);
wRet = ListBoxSetCurSel(hwnd, wParam);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
return wRet;
case LB_SETSEL:
printf("ListBox LB_SETSEL wParam=%x lParam=%lX !\n", wParam, lParam);
dprintf_listbox(stddeb,"ListBox LB_SETSEL wParam=%x lParam=%lX !\n", wParam, lParam);
wRet = ListBoxSetSel(hwnd, LOWORD(lParam), wParam);
InvalidateRect(hwnd, NULL, TRUE);
UpdateWindow(hwnd);
return wRet;
case LB_SETTOPINDEX:
printf("ListBox LB_SETTOPINDEX wParam=%x !\n", wParam);
dprintf_listbox(stddeb,"ListBox LB_SETTOPINDEX wParam=%x !\n",
wParam);
lphl = ListBoxGetStorageHeader(hwnd);
lphl->FirstVisible = wParam;
wndPtr = WIN_FindWndPtr(hwnd);
@ -469,9 +460,7 @@ LONG ListBoxWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam )
UpdateWindow(hwnd);
break;
case LB_SETITEMHEIGHT:
#ifdef DEBUG_LISTBOX
printf("ListBox LB_SETITEMHEIGHT wParam=%x lParam=%lX !\n", wParam, lParam);
#endif
dprintf_listbox(stddeb,"ListBox LB_SETITEMHEIGHT wParam=%x lParam=%lX !\n", wParam, lParam);
wRet = ListBoxSetItemHeight(hwnd, wParam, lParam);
return wRet;
@ -566,8 +555,8 @@ void StdDrawListBox(HWND hwnd)
dwOldTextColor = SetTextColor(hdc, 0x00FFFFFFL);
FillRect(hdc, &lpls->dis.rcItem, GetStockObject(BLACK_BRUSH));
}
TextOut(hdc, rect.left + 5, h + 2, (char *)lpls->dis.itemData,
strlen((char *)lpls->dis.itemData));
TextOut(hdc, rect.left + 5, h + 2, (char *)lpls->itemText,
strlen((char *)lpls->itemText));
if (lpls->dis.itemState != 0) {
SetTextColor(hdc, dwOldTextColor);
}
@ -597,7 +586,7 @@ EndOfPaint:
void OwnerDrawListBox(HWND hwnd)
{
WND *wndPtr;
WND *wndPtr,*ParentWndPtr;
LPHEADLIST lphl;
LPLISTSTRUCT lpls;
PAINTSTRUCT ps;
@ -631,34 +620,41 @@ void OwnerDrawListBox(HWND hwnd)
for (i = 1; i <= lphl->ItemsCount; i++) {
if (i >= lphl->FirstVisible) {
lpls->dis.hDC = hdc;
lpls->dis.hwndItem = hwnd;
lpls->dis.CtlType = ODT_LISTBOX;
lpls->dis.itemID = i - 1;
if ((!lpls->dis.CtlID)&&(lphl->hWndLogicParent))
{
ListBoxGetWindowAndStorage(lphl->hWndLogicParent, &ParentWndPtr);
lpls->dis.CtlID = ParentWndPtr->wIDmenu;
}
h2 = lpls->dis.rcItem.bottom - lpls->dis.rcItem.top;
lpls->dis.rcItem.top = h;
lpls->dis.rcItem.bottom = h + h2;
lpls->dis.rcItem.left = rect.left;
lpls->dis.rcItem.right = rect.right;
lpls->dis.itemAction = ODA_DRAWENTIRE;
if (lpls->dis.itemState != 0) {
/* if (lpls->dis.itemState != 0) {
lpls->dis.itemAction |= ODA_SELECT;
}
if (lphl->ItemFocused == i - 1) {
lpls->dis.itemAction |= ODA_FOCUS;
}
#ifdef DEBUT_LISTBOX
printf("LBOX WM_DRAWITEM #%d left=%d top=%d right=%d bottom=%d !\n",
i, lpls->dis.rcItem.left, lpls->dis.rcItem.top,
}*/
dprintf_listbox(stddeb,"LBOX WM_DRAWITEM #%d left=%d top=%d right=%d bottom=%d !\n",
i-1, lpls->dis.rcItem.left, lpls->dis.rcItem.top,
lpls->dis.rcItem.right, lpls->dis.rcItem.bottom);
printf("LBOX WM_DRAWITEM Parent=%X &dis=%lX CtlID=%u !\n",
dprintf_listbox(stddeb,"LBOX WM_DRAWITEM Parent=%X &dis=%lX CtlID=%u !\n",
hWndParent, (LONG)&lpls->dis, lpls->dis.CtlID);
printf("LBOX WM_DRAWITEM '%s' !\n", lpls->dis.itemData);
#endif
SendMessage(lphl->hWndLogicParent, WM_DRAWITEM, i, (LPARAM)&lpls->dis);
if (lpls->dis.itemState != 0) {
InvertRect(hdc, &lpls->dis.rcItem);
}
dprintf_listbox(stddeb,"LBOX WM_DRAWITEM %08X!\n",lpls->dis.itemData);
if (HasStrings(wndPtr))
dprintf_listbox(stddeb," '%s'\n",lpls->itemText);
SendMessage(lphl->hWndLogicParent, WM_DRAWITEM, i-1, (LPARAM)&lpls->dis);
/* if (lpls->dis.itemState != 0) {
InvertRect(hdc, &lpls->dis.rcItem);
} */
h += h2;
lphl->ItemsVisible++;
if (h > rect.bottom) goto EndOfPaint;
/* if (h > rect.bottom) goto EndOfPaint;*/
}
if (lpls->lpNext == NULL) goto EndOfPaint;
lpls = (LPLISTSTRUCT)lpls->lpNext;
@ -672,6 +668,7 @@ EndOfPaint:
UpdateWindow(wndPtr->hWndVScroll);
*/
}
}
@ -739,7 +736,7 @@ void ListBoxAskMeasure(WND *wndPtr, LPHEADLIST lphl, LPLISTSTRUCT lpls)
HANDLE hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(MEASUREITEMSTRUCT));
measure = (MEASUREITEMSTRUCT *) USER_HEAP_ADDR(hTemp);
if (measure == NULL) {
printf("ListBoxAskMeasure() // Bad allocation of Measure struct !\n");
fprintf(stderr,"ListBoxAskMeasure() // Bad allocation of Measure struct !\n");
return;
}
measure->CtlType = ODT_LISTBOX;
@ -767,7 +764,7 @@ int ListBoxAddString(HWND hwnd, LPSTR newstr)
hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT));
lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hTemp);
if (lplsnew == NULL) {
printf("ListBoxAddString() // Bad allocation of new item !\n");
fprintf(stderr,"ListBoxAddString() // Bad allocation of new item !\n");
return LB_ERRSPACE;
}
lpls = lphl->lpFirst;
@ -780,30 +777,30 @@ int ListBoxAddString(HWND hwnd, LPSTR newstr)
else
lphl->lpFirst = lplsnew;
lphl->ItemsCount++;
#ifdef DEBUG_LISTBOX
printf("Items Count = %u\n", lphl->ItemsCount);
#endif
dprintf_listbox(stddeb,"Items Count = %u\n", lphl->ItemsCount);
hTemp = 0;
if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) != LBS_OWNERDRAWFIXED) &&
((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE)) {
hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1);
str = (LPSTR)USER_HEAP_ADDR(hTemp);
if (str == NULL) return LB_ERRSPACE;
strcpy(str, newstr);
newstr = str;
#ifdef DEBUG_LISTBOX
printf("ListBoxAddString// after strcpy '%s'\n", str);
#endif
}
}
ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew);
if (HasStrings(wndPtr))
{
hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1);
str = (LPSTR)USER_HEAP_ADDR(hTemp);
if (str == NULL) return LB_ERRSPACE;
strcpy(str, newstr);
newstr = str;
lplsnew->itemText = str;
lplsnew->dis.itemData = 0;
dprintf_listbox(stddeb,"ListBoxAddString// after strcpy '%s'\n", str);
}
else
{
lplsnew->itemText = NULL;
lplsnew->dis.itemData = (DWORD)newstr;
}
lplsnew->hMem = hTemp;
lplsnew->lpNext = NULL;
lplsnew->dis.itemID = lphl->ItemsCount;
lplsnew->dis.itemData = (DWORD)newstr;
lplsnew->hData = hTemp;
if ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)
if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)|| ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED))
ListBoxAskMeasure(wndPtr, lphl, lplsnew);
if (wndPtr->dwStyle & WS_VSCROLL)
SetScrollRange(hwnd, SB_VERT, 1, lphl->ItemsCount,
@ -821,7 +818,7 @@ int ListBoxAddString(HWND hwnd, LPSTR newstr)
if (wndPtr->dwStyle & WS_HSCROLL)
ShowScrollBar(hwnd, SB_HORZ, TRUE);
}
return lphl->ItemsCount;
return lphl->ItemsCount-1;
}
@ -833,12 +830,14 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr)
HANDLE hTemp;
LPSTR str;
UINT Count;
#ifdef DEBUG_LISTBOX
printf("ListBoxInsertString(%04X, %d, %08X);\n", hwnd, uIndex, newstr);
#endif
dprintf_listbox(stddeb,"ListBoxInsertString(%04X, %d, %08X);\n",
hwnd, uIndex, newstr);
if (uIndex == (UINT)-1) return ListBoxAddString(hwnd, newstr);
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
if (lphl == NULL) return LB_ERR;
/* The following line will cause problems if the content of the */
/* listbox is sorted by the listbox itself */
if (uIndex == lphl->ItemsCount) return ListBoxAddString(hwnd, newstr);
if (uIndex >= lphl->ItemsCount) return LB_ERR;
lpls = lphl->lpFirst;
if (lpls == NULL) return LB_ERR;
@ -850,32 +849,44 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr)
hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LISTSTRUCT));
lplsnew = (LPLISTSTRUCT) USER_HEAP_ADDR(hTemp);
if (lplsnew == NULL) {
printf("ListBoxInsertString() // Bad allocation of new item !\n");
fprintf(stderr,"ListBoxInsertString() // Bad allocation of new item !\n");
return LB_ERRSPACE;
}
ListBoxDefaultItem(hwnd, wndPtr, lphl, lplsnew);
lplsnew->hMem = hTemp;
lpls->lpNext = lplsnew;
if (uIndex == 0)
{
lplsnew->lpNext = lphl->lpFirst;
lphl->lpFirst = lplsnew;
}
else
{
lplsnew->lpNext = lpls->lpNext;
lpls->lpNext = lplsnew;
}
lphl->ItemsCount++;
hTemp = 0;
if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) != LBS_OWNERDRAWFIXED) &&
((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) != LBS_OWNERDRAWVARIABLE)) {
hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1);
str = (LPSTR)USER_HEAP_ADDR(hTemp);
if (str == NULL) return LB_ERRSPACE;
strcpy(str, newstr);
newstr = str;
if (HasStrings(wndPtr))
{
hTemp = USER_HEAP_ALLOC(GMEM_MOVEABLE, strlen(newstr) + 1);
str = (LPSTR)USER_HEAP_ADDR(hTemp);
if (str == NULL) return LB_ERRSPACE;
strcpy(str, newstr);
newstr = str;
lplsnew->itemText = str;
lplsnew->dis.itemData = 0;
#ifdef DEBUG_LISTBOX
printf("ListBoxInsertString // after strcpy '%s'\n", str);
printf("ListBoxInsertString // after strcpy '%s'\n", str);
#endif
}
}
lplsnew->lpNext = NULL;
}
else
{
lplsnew->itemText = NULL;
lplsnew->dis.itemData = (DWORD)newstr;
}
lplsnew->dis.itemID = lphl->ItemsCount;
lplsnew->dis.itemData = (DWORD)newstr;
lplsnew->hData = hTemp;
if ((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)
if (((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)|| ((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED))
ListBoxAskMeasure(wndPtr, lphl, lplsnew);
if (wndPtr->dwStyle & WS_VSCROLL)
SetScrollRange(hwnd, SB_VERT, 1, lphl->ItemsCount,
@ -896,16 +907,18 @@ int ListBoxInsertString(HWND hwnd, UINT uIndex, LPSTR newstr)
#ifdef DEBUG_LISTBOX
printf("ListBoxInsertString // count=%d\n", lphl->ItemsCount);
#endif
return lphl->ItemsCount;
return /* lphl->ItemsCount;*/ uIndex;
}
int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr)
int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr, BOOL bItemData)
{
WND *wndPtr;
LPHEADLIST lphl;
LPLISTSTRUCT lpls;
UINT Count;
if (!bItemData)
*OutStr=0;
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
if (lphl == NULL) return LB_ERR;
if (uIndex >= lphl->ItemsCount) return LB_ERR;
@ -916,18 +929,38 @@ int ListBoxGetText(HWND hwnd, UINT uIndex, LPSTR OutStr)
if (lpls->lpNext == NULL) return LB_ERR;
lpls = (LPLISTSTRUCT)lpls->lpNext;
}
if (((wndPtr->dwStyle & LBS_OWNERDRAWFIXED) == LBS_OWNERDRAWFIXED) ||
((wndPtr->dwStyle & LBS_OWNERDRAWVARIABLE) == LBS_OWNERDRAWVARIABLE)) {
if ((wndPtr->dwStyle & LBS_HASSTRINGS) != LBS_HASSTRINGS) {
*((long *)OutStr) = lpls->dis.itemData;
return 4;
}
}
if (bItemData)
return lpls->dis.itemData;
if (!(HasStrings(wndPtr)) )
{
*((long *)OutStr) = lpls->dis.itemData;
return 4;
}
strcpy(OutStr, (char *)lpls->dis.itemData);
strcpy(OutStr, lpls->itemText);
return strlen(OutStr);
}
int ListBoxSetItemData(HWND hwnd, UINT uIndex, DWORD ItemData)
{
WND *wndPtr;
LPHEADLIST lphl;
LPLISTSTRUCT lpls;
UINT Count;
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
if (lphl == NULL) return LB_ERR;
if (uIndex >= lphl->ItemsCount) return LB_ERR;
lpls = lphl->lpFirst;
if (lpls == NULL) return LB_ERR;
if (uIndex > lphl->ItemsCount) return LB_ERR;
for(Count = 0; Count < uIndex; Count++) {
if (lpls->lpNext == NULL) return LB_ERR;
lpls = (LPLISTSTRUCT)lpls->lpNext;
}
lpls->dis.itemData = ItemData;
return 1;
}
int ListBoxDeleteString(HWND hwnd, UINT uIndex)
{
@ -972,20 +1005,28 @@ int ListBoxDeleteString(HWND hwnd, UINT uIndex)
int ListBoxFindString(HWND hwnd, UINT nFirst, LPSTR MatchStr)
{
WND *wndPtr;
LPHEADLIST lphl;
LPLISTSTRUCT lpls;
UINT Count;
lphl = ListBoxGetStorageHeader(hwnd);
lphl = ListBoxGetWindowAndStorage(hwnd, &wndPtr);
if (lphl == NULL) return LB_ERR;
if (nFirst > lphl->ItemsCount) return LB_ERR;
lpls = lphl->lpFirst;
if (lpls == NULL) return LB_ERR;
Count = 0;
while(lpls != NULL) {
if (strcmp((char *)lpls->dis.itemData, MatchStr) == 0) return Count;
lpls = (LPLISTSTRUCT)lpls->lpNext;
Count++;
}
if (HasStrings(wndPtr))
{
if (strcmp(lpls->itemText, MatchStr) == 0) return Count;
}
else
{
if (lpls->dis.itemData == (DWORD)MatchStr) return Count;
}
lpls = (LPLISTSTRUCT)lpls->lpNext;
Count++;
}
return LB_ERR;
}
@ -1004,9 +1045,7 @@ int ListBoxResetContent(HWND hwnd)
lpls2 = lpls;
lpls = (LPLISTSTRUCT)lpls->lpNext;
if (i != 0) {
#ifdef DEBUG_LISTBOX
printf("ResetContent #%u\n", i);
#endif
dprintf_listbox(stddeb,"ResetContent #%u\n", i);
if (lpls2->hData != 0 && lpls2->hData != lpls2->hMem)
USER_HEAP_FREE(lpls2->hData);
if (lpls2->hMem != 0) USER_HEAP_FREE(lpls2->hMem);
@ -1016,8 +1055,8 @@ int ListBoxResetContent(HWND hwnd)
lphl->lpFirst = NULL;
lphl->FirstVisible = 1;
lphl->ItemsCount = 0;
lphl->ItemFocused = 0;
lphl->PrevFocused = 0;
lphl->ItemFocused = /*0*/-1;
lphl->PrevFocused = /*0*/-1;
if ((wndPtr->dwStyle && LBS_NOTIFY) != 0)
SendMessage(lphl->hWndLogicParent, WM_COMMAND,
wndPtr->wIDmenu, MAKELONG(hwnd, LBN_SELCHANGE));
@ -1114,53 +1153,64 @@ int ListBoxGetSel(HWND hwnd, WORD wIndex)
int ListBoxDirectory(HWND hwnd, UINT attrib, LPSTR filespec)
{
struct dosdirent *dp;
struct dosdirent *newdp;
struct stat st;
int x, wRet;
char temp[256];
struct dosdirent *dp;
struct dosdirent *newdp;
struct stat st;
int x, wRet;
char temp[256];
#ifdef DEBUG_LISTBOX
fprintf(stderr,"ListBoxDirectory: %s, %4x\n",filespec,attrib);
fprintf(stderr,"ListBoxDirectory: %s, %4x\n",filespec,attrib);
#endif
if ((dp = (struct dosdirent *)DOS_opendir(filespec)) ==NULL) return 0;
while (dp = (struct dosdirent *)DOS_readdir(dp)) {
if (!dp->inuse) break;
if ((dp = (struct dosdirent *)DOS_opendir(filespec)) ==NULL) return 0;
while (dp = (struct dosdirent *)DOS_readdir(dp))
{
if (!dp->inuse) break;
#ifdef DEBUG_LISTBOX
printf("ListBoxDirectory %08X '%s' !\n", dp->filename, dp->filename);
printf("ListBoxDirectory %08X '%s' !\n", dp->filename, dp->filename);
#endif
if (dp->attribute & FA_DIREC) {
if (attrib & DDL_DIRECTORY) {
sprintf(temp, "[%s]", dp->filename);
if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR) break;
}
} else
if (attrib & DDL_EXCLUSIVE) {
if (attrib & (DDL_READWRITE | DDL_READONLY | DDL_HIDDEN | DDL_SYSTEM) )
if ( (wRet = ListBoxAddString(hwnd, dp->filename)) == LB_ERR)
break;
} else {
if ( (wRet = ListBoxAddString(hwnd, dp->filename)) == LB_ERR)
break;
}
}
DOS_closedir(dp);
if (attrib & DDL_DRIVES)
if (dp->attribute & FA_DIREC)
{
for (x=0;x!=MAX_DOS_DRIVES;x++)
{
if (DOS_ValidDrive(x))
{
sprintf(temp, "[-%c-]", 'a'+x);
if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR)
break;
}
}
if (attrib & DDL_DIRECTORY)
{
sprintf(temp, "[%s]", dp->filename);
if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR) break;
}
}
else
{
if (attrib & DDL_EXCLUSIVE)
{
if (attrib & (DDL_READWRITE | DDL_READONLY | DDL_HIDDEN |
DDL_SYSTEM) )
if ( (wRet = ListBoxAddString(hwnd, dp->filename))
== LB_ERR)
break;
}
else
{
if ( (wRet = ListBoxAddString(hwnd, dp->filename)) == LB_ERR)
break;
}
}
}
DOS_closedir(dp);
if (attrib & DDL_DRIVES)
{
for (x=0;x!=MAX_DOS_DRIVES;x++)
{
if (DOS_ValidDrive(x))
{
sprintf(temp, "[-%c-]", 'a'+x);
if ( (wRet = ListBoxAddString(hwnd, temp)) == LB_ERR)
break;
}
}
}
#ifdef DEBUG_LISTBOX
printf("End of ListBoxDirectory !\n");
printf("End of ListBoxDirectory !\n");
#endif
return wRet;
return wRet;
}
@ -1221,7 +1271,7 @@ int ListBoxDefaultItem(HWND hwnd, WND *wndPtr,
{
RECT rect;
if (wndPtr == NULL || lphl == NULL || lpls == NULL) {
printf("ListBoxDefaultItem() // Bad Pointers !\n");
fprintf(stderr,"ListBoxDefaultItem() // Bad Pointers !\n");
return FALSE;
}
GetClientRect(hwnd, &rect);
@ -1259,7 +1309,7 @@ int ListBoxFindNextMatch(HWND hwnd, WORD wChar)
Count = 0;
while(lpls != NULL) {
if (Count > lphl->ItemFocused) {
if (*((char *)lpls->dis.itemData) == (char)wChar) {
if (*(lpls->itemText) == (char)wChar) {
lphl->FirstVisible = Count - lphl->ItemsVisible / 2;
if (lphl->FirstVisible < 1) lphl->FirstVisible = 1;
if ((wndPtr->dwStyle & LBS_MULTIPLESEL) == LBS_MULTIPLESEL) {
@ -1280,7 +1330,7 @@ int ListBoxFindNextMatch(HWND hwnd, WORD wChar)
Count = 0;
lpls = lphl->lpFirst;
while(lpls != NULL) {
if (*((char *)lpls->dis.itemData) == (char)wChar) {
if (*(lpls->itemText) == (char)wChar) {
if (Count == lphl->ItemFocused) return LB_ERR;
lphl->FirstVisible = Count - lphl->ItemsVisible / 2;
if (lphl->FirstVisible < 1) lphl->FirstVisible = 1;
@ -1307,7 +1357,7 @@ int ListBoxFindNextMatch(HWND hwnd, WORD wChar)
*/
BOOL DlgDirSelect(HWND hDlg, LPSTR lpStr, int nIDLBox)
{
printf("DlgDirSelect(%04X, '%s', %d) \n", hDlg, lpStr, nIDLBox);
fprintf(stdnimp,"DlgDirSelect(%04X, '%s', %d) \n", hDlg, lpStr, nIDLBox);
}
@ -1318,11 +1368,27 @@ int DlgDirList(HWND hDlg, LPSTR lpPathSpec,
int nIDLBox, int nIDStat, WORD wType)
{
HWND hWnd;
printf("DlgDirList(%04X, '%s', %d, %d, %04X) \n",
int ret;
dprintf_listbox(stddeb,"DlgDirList(%04X, '%s', %d, %d, %04X) \n",
hDlg, lpPathSpec, nIDLBox, nIDStat, wType);
hWnd = GetDlgItem(hDlg, nIDLBox);
ListBoxResetContent(hWnd);
return ListBoxDirectory(hWnd, wType, lpPathSpec);
if (nIDLBox)
hWnd = GetDlgItem(hDlg, nIDLBox);
else
hWnd = 0;
if (hWnd)
ListBoxResetContent(hWnd);
if (hWnd)
ret=ListBoxDirectory(hWnd, wType, lpPathSpec);
else
ret=0;
if (nIDStat)
{
int drive;
drive = DOS_GetDefaultDrive();
SendDlgItemMessage(hDlg, nIDStat, WM_SETTEXT, 0,
(LONG) DOS_GetCurrentDir(drive) );
}
return ret;
}

View File

@ -11,9 +11,6 @@ static char Copyright2[] = "Copyright Alexandre Julliard, 1994";
* This is probably not the meaning this style has in MS-Windows.
*/
/*
#define DEBUG_MENU
*/
#include <ctype.h>
#include <stdlib.h>
@ -27,6 +24,14 @@ static char Copyright2[] = "Copyright Alexandre Julliard, 1994";
#include "user.h"
#include "win.h"
#include "message.h"
#include "debug.h"
/* #define DEBUG_MENU /* */
/* #undef DEBUG_MENU /* */
/* #define DEBUG_MENUCALC /* */
/* #undef DEBUG_MENUCALC /* */
/* #define DEBUG_MENUSHORTCUT /* */
/* #undef DEBUG_MENUSHORTCUT /* */
/* Dimension of the menu bitmaps */
static WORD check_bitmap_width = 0, check_bitmap_height = 0;
@ -95,7 +100,7 @@ BOOL MENU_Init()
if (!(hSysMenu = LoadMenu( hSysRes, "SYSMENU" )))
{
printf("SysMenu not found in system resources !\n");
fprintf(stderr,"SysMenu not found in system resources !\n");
return FALSE;
}
@ -373,10 +378,8 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect, LPPOPUPMENU lppop,
if ((lprect == NULL) || (lppop == NULL)) return;
if (lppop->nItems == 0) return;
#ifdef DEBUG_MENUCALC
printf("MenuBarCalcSize left=%d top=%d right=%d bottom=%d !\n",
dprintf_menucalc(stddeb,"MenuBarCalcSize left=%d top=%d right=%d bottom=%d !\n",
lprect->left, lprect->top, lprect->right, lprect->bottom);
#endif
items = (MENUITEM *)USER_HEAP_ADDR( lppop->hItems );
lppop->Width = lprect->right - lprect->left;
lppop->Height = 0;
@ -602,9 +605,8 @@ WORD MENU_DrawMenuBar(HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw)
lppop = (LPPOPUPMENU) USER_HEAP_ADDR( wndPtr->wIDmenu );
if (lppop == NULL || lprect == NULL) return SYSMETRICS_CYMENU;
#ifdef DEBUG_MENU
printf("MENU_DrawMenuBar(%04X, %08X, %08X); !\n", hDC, lprect, lppop);
#endif
dprintf_menu(stddeb,"MENU_DrawMenuBar(%04X, %08X, %08X); !\n",
hDC, lprect, lppop);
if (lppop->Height == 0) MENU_MenuBarCalcSize(hDC, lprect, lppop, hwnd);
lprect->bottom = lprect->top + lppop->Height;
if (suppress_draw) return lppop->Height;
@ -1481,9 +1483,8 @@ BOOL ChangeMenu(HMENU hMenu, WORD nPos, LPSTR lpNewItem,
BOOL CheckMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags)
{
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("CheckMenuItem (%04X, %04X, %04X) !\n", hMenu, wItemID, wFlags);
#endif
dprintf_menu(stddeb,"CheckMenuItem (%04X, %04X, %04X) !\n",
hMenu, wItemID, wFlags);
if (!(lpitem = MENU_FindItem(&hMenu, &wItemID, wFlags))) return FALSE;
if (wFlags & MF_CHECKED) lpitem->item_flags |= MF_CHECKED;
else lpitem->item_flags &= ~MF_CHECKED;
@ -1497,9 +1498,8 @@ BOOL CheckMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags)
BOOL EnableMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags)
{
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("EnableMenuItem (%04X, %04X, %04X) !\n", hMenu, wItemID, wFlags);
#endif
dprintf_menu(stddeb,"EnableMenuItem (%04X, %04X, %04X) !\n",
hMenu, wItemID, wFlags);
if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return FALSE;
/* We can't have MF_GRAYED and MF_DISABLED together */
@ -1527,10 +1527,8 @@ int GetMenuString(HMENU hMenu, WORD wItemID,
{
LPMENUITEM lpitem;
int maxsiz;
#ifdef DEBUG_MENU
printf("GetMenuString(%04X, %04X, %08X, %d, %04X);\n",
dprintf_menu(stddeb,"GetMenuString(%04X, %04X, %08X, %d, %04X);\n",
hMenu, wItemID, str, nMaxSiz, wFlags);
#endif
if (str == NULL) return FALSE;
lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags );
if (lpitem != NULL) {
@ -1540,9 +1538,7 @@ int GetMenuString(HMENU hMenu, WORD wItemID,
}
else
maxsiz = 0;
#ifdef DEBUG_MENU
printf("GetMenuString // Found !\n");
#endif
dprintf_menu(stddeb,"GetMenuString // Found !\n");
return maxsiz;
}
return 0;
@ -1556,10 +1552,8 @@ BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, WORD wItemID, WORD wHilite)
{
LPPOPUPMENU menu;
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("HiliteMenuItem(%04X, %04X, %04X, %04X);\n",
dprintf_menu(stddeb,"HiliteMenuItem(%04X, %04X, %04X, %04X);\n",
hWnd, hMenu, wItemID, wHilite);
#endif
if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wHilite ))) return FALSE;
if (!(menu = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu))) return FALSE;
if (menu->FocusedItem == wItemID) return TRUE;
@ -1575,9 +1569,8 @@ BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, WORD wItemID, WORD wHilite)
WORD GetMenuState(HMENU hMenu, WORD wItemID, WORD wFlags)
{
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("GetMenuState(%04X, %04X, %04X);\n", hMenu, wItemID, wFlags);
#endif
dprintf_menu(stddeb,"GetMenuState(%04X, %04X, %04X);\n",
hMenu, wItemID, wFlags);
if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return -1;
if (lpitem->item_flags & MF_POPUP)
{
@ -1595,14 +1588,11 @@ WORD GetMenuState(HMENU hMenu, WORD wItemID, WORD wFlags)
WORD GetMenuItemCount(HMENU hMenu)
{
LPPOPUPMENU menu;
#ifdef DEBUG_MENU
printf("GetMenuItemCount(%04X);\n", hMenu);
#endif
dprintf_menu(stddeb,"GetMenuItemCount(%04X);\n", hMenu);
menu = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu);
if (menu == NULL) return (WORD)-1;
#ifdef DEBUG_MENU
printf("GetMenuItemCount(%04X) return %d \n", hMenu, menu->nItems);
#endif
dprintf_menu(stddeb,"GetMenuItemCount(%04X) return %d \n",
hMenu, menu->nItems);
return menu->nItems;
}
@ -1615,9 +1605,7 @@ WORD GetMenuItemID(HMENU hMenu, int nPos)
LPPOPUPMENU menu;
MENUITEM *item;
#ifdef DEBUG_MENU
printf("GetMenuItemID(%04X, %d);\n", hMenu, nPos);
#endif
dprintf_menu(stddeb,"GetMenuItemID(%04X, %d);\n", hMenu, nPos);
if (!(menu = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu))) return -1;
if ((nPos < 0) || (nPos >= menu->nItems)) return -1;
item = (MENUITEM *) USER_HEAP_ADDR( menu->hItems );
@ -1635,14 +1623,12 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt
MENUITEM *lpitem, *newItems;
LPPOPUPMENU menu;
#ifdef DEBUG_MENU
if (IS_STRING_ITEM(wFlags))
printf("InsertMenu (%04X, %04X, %04X, '%s') !\n",
dprintf_menu(stddeb,"InsertMenu (%04X, %04X, %04X, '%s') !\n",
hMenu, wFlags, wItemID, lpNewItem);
else
printf("InsertMenu (%04X, %04X, %04X, %04X, %08X) !\n",
dprintf_menu(stddeb,"InsertMenu (%04X, %04X, %04X, %04X, %08X) !\n",
hMenu, nPos, wFlags, wItemID, lpNewItem);
#endif
/* Find where to insert new item */
@ -1724,9 +1710,8 @@ BOOL RemoveMenu(HMENU hMenu, WORD nPos, WORD wFlags)
{
LPPOPUPMENU menu;
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("RemoveMenu (%04X, %04X, %04X) !\n", hMenu, nPos, wFlags);
#endif
dprintf_menu(stddeb,"RemoveMenu (%04X, %04X, %04X) !\n",
hMenu, nPos, wFlags);
if (!(lpitem = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE;
if (!(menu = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu))) return FALSE;
@ -1774,14 +1759,12 @@ BOOL DeleteMenu(HMENU hMenu, WORD nPos, WORD wFlags)
BOOL ModifyMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewItem)
{
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
if (IS_STRING_ITEM(wFlags))
printf("ModifyMenu (%04X, %04X, %04X, %04X, '%s') !\n",
dprintf_menu(stddeb,"ModifyMenu (%04X, %04X, %04X, %04X, '%s') !\n",
hMenu, nPos, wFlags, wItemID, lpNewItem);
else
printf("ModifyMenu (%04X, %04X, %04X, %04X, %08X) !\n",
dprintf_menu(stddeb,"ModifyMenu (%04X, %04X, %04X, %04X, %08X) !\n",
hMenu, nPos, wFlags, wItemID, lpNewItem);
#endif
if (!(lpitem = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE;
if (IS_STRING_ITEM(lpitem->item_flags)) USER_HEAP_FREE( lpitem->hText );
@ -1832,10 +1815,8 @@ BOOL SetMenuItemBitmaps(HMENU hMenu, WORD nPos, WORD wFlags,
HBITMAP hNewCheck, HBITMAP hNewUnCheck)
{
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("SetMenuItemBitmaps (%04X, %04X, %04X, %04X, %08X) !\n",
dprintf_menu(stddeb,"SetMenuItemBitmaps (%04X, %04X, %04X, %04X, %08X) !\n",
hMenu, nPos, wFlags, hNewCheck, hNewUnCheck);
#endif
if (!(lpitem = MENU_FindItem( &hMenu, &nPos, wFlags ))) return FALSE;
if (!hNewCheck && !hNewUnCheck)
@ -1862,9 +1843,7 @@ HMENU CreateMenu()
{
HMENU hMenu;
LPPOPUPMENU menu;
#ifdef DEBUG_MENU
printf("CreateMenu !\n");
#endif
dprintf_menu(stddeb,"CreateMenu !\n");
if (!(hMenu = USER_HEAP_ALLOC( GMEM_MOVEABLE, sizeof(POPUPMENU) )))
return 0;
menu = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu);
@ -1878,9 +1857,7 @@ HMENU CreateMenu()
menu->hWnd = 0;
menu->hItems = 0;
menu->FocusedItem = NO_SELECTED_ITEM;
#ifdef DEBUG_MENU
printf("CreateMenu // return %04X\n", hMenu);
#endif
dprintf_menu(stddeb,"CreateMenu // return %04X\n", hMenu);
return hMenu;
}
@ -1891,9 +1868,7 @@ HMENU CreateMenu()
BOOL DestroyMenu(HMENU hMenu)
{
LPPOPUPMENU lppop;
#ifdef DEBUG_MENU
printf("DestroyMenu (%04X) !\n", hMenu);
#endif
dprintf_menu(stddeb,"DestroyMenu (%04X) !\n", hMenu);
if (hMenu == 0) return FALSE;
lppop = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu);
if (lppop == NULL) return FALSE;
@ -1906,44 +1881,15 @@ BOOL DestroyMenu(HMENU hMenu)
for (i = lppop->nItems; i > 0; i--, item++)
{
if (item->item_flags & MF_POPUP)
DestroyMenu( item->item_flags & MF_POPUP );
DestroyMenu( item->item_id );
}
USER_HEAP_FREE( lppop->hItems );
}
USER_HEAP_FREE( hMenu );
#ifdef DEBUG_MENU
printf("DestroyMenu (%04X) // End !\n", hMenu);
#endif
dprintf_menu(stddeb,"DestroyMenu (%04X) // End !\n", hMenu);
return TRUE;
}
/**********************************************************************
* LoadMenu [USER.150]
*/
HMENU LoadMenu(HINSTANCE instance, char *menu_name)
{
HMENU hMenu;
HANDLE hMenu_desc;
MENU_HEADER *menu_desc;
#ifdef DEBUG_MENU
if ((LONG)menu_name & 0xFFFF0000L)
printf("LoadMenu: instance %02x, menu '%s'\n", instance, menu_name);
else
printf("LoadMenu: instance %02x, menu '%04X'\n", instance, menu_name);
#endif
if (instance == (HANDLE)NULL) instance = hSysRes;
if (menu_name == NULL ||
(hMenu_desc = RSC_LoadMenu(instance, menu_name)) == 0 ||
(menu_desc = (MENU_HEADER *) GlobalLock(hMenu_desc)) == NULL) {
return 0;
}
hMenu = LoadMenuIndirect((LPSTR)menu_desc);
GlobalUnlock( hMenu_desc );
return hMenu;
}
/**********************************************************************
* GetSystemMenu [USER.156]
*/
@ -1992,19 +1938,19 @@ BOOL SetMenu(HWND hWnd, HMENU hMenu)
LPPOPUPMENU lpmenu;
WND * wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == NULL) {
printf("SetMenu(%04X, %04X) // Bad window handle !\n", hWnd, hMenu);
fprintf(stderr,"SetMenu(%04X, %04X) // Bad window handle !\n",
hWnd, hMenu);
return FALSE;
}
#ifdef DEBUG_MENU
printf("SetMenu(%04X, %04X);\n", hWnd, hMenu);
#endif
dprintf_menu(stddeb,"SetMenu(%04X, %04X);\n", hWnd, hMenu);
if (GetCapture() == hWnd) ReleaseCapture();
wndPtr->wIDmenu = hMenu;
if (hMenu != 0)
{
lpmenu = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu);
if (lpmenu == NULL) {
printf("SetMenu(%04X, %04X) // Bad menu handle !\n", hWnd, hMenu);
fprintf(stderr,"SetMenu(%04X, %04X) // Bad menu handle !\n",
hWnd, hMenu);
return FALSE;
}
lpmenu->hWnd = hWnd;
@ -2025,9 +1971,7 @@ HMENU GetSubMenu(HMENU hMenu, short nPos)
{
LPPOPUPMENU lppop;
LPMENUITEM lpitem;
#ifdef DEBUG_MENU
printf("GetSubMenu (%04X, %04X) !\n", hMenu, nPos);
#endif
dprintf_menu(stddeb,"GetSubMenu (%04X, %04X) !\n", hMenu, nPos);
if (!(lppop = (LPPOPUPMENU) USER_HEAP_ADDR(hMenu))) return 0;
if ((WORD)nPos >= lppop->nItems) return 0;
lpitem = (MENUITEM *) USER_HEAP_ADDR( lppop->hItems );
@ -2043,15 +1987,12 @@ void DrawMenuBar(HWND hWnd)
{
WND *wndPtr;
LPPOPUPMENU lppop;
#ifdef DEBUG_MENU
printf("DrawMenuBar (%04X)\n", hWnd);
#endif
dprintf_menu(stddeb,"DrawMenuBar (%04X)\n", hWnd);
wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr != NULL && (wndPtr->dwStyle & WS_CHILD) == 0 &&
wndPtr->wIDmenu != 0) {
#ifdef DEBUG_MENU
printf("DrawMenuBar wIDmenu=%04X \n", wndPtr->wIDmenu);
#endif
dprintf_menu(stddeb,"DrawMenuBar wIDmenu=%04X \n",
wndPtr->wIDmenu);
lppop = (LPPOPUPMENU) USER_HEAP_ADDR(wndPtr->wIDmenu);
if (lppop == NULL) return;
@ -2089,9 +2030,8 @@ HMENU LoadMenuIndirect(LPSTR menu_template)
{
HMENU hMenu;
MENU_HEADER *menu_desc;
#ifdef DEBUG_MENU
printf("LoadMenuIndirect: menu_template '%08X'\n", menu_template);
#endif
dprintf_menu(stddeb,"LoadMenuIndirect: menu_template '%08X'\n",
menu_template);
hMenu = CreateMenu();
menu_desc = (MENU_HEADER *)menu_template;
ParseMenuResource((WORD *)(menu_desc + 1), 0, hMenu);
@ -2119,9 +2059,7 @@ HMENU CopySysMenu()
AppendMenu( hMenu, item->item_flags, item->item_id, item->item_text );
}
#ifdef DEBUG_MENU
printf("CopySysMenu hMenu=%04X !\n", hMenu);
#endif
dprintf_menu(stddeb,"CopySysMenu hMenu=%04X !\n", hMenu);
return hMenu;
}

View File

@ -7,9 +7,6 @@
* by Peter Broadhurst, 940611
*/
/*
#define DEBUG_SCROLL
*/
static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <stdlib.h>
@ -22,6 +19,11 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include "heap.h"
#include "win.h"
#include "prototypes.h"
#include "stddebug.h"
/* #define DEBUG_SCROLL /* */
/* #undef DEBUG_SCROLL /* */
#include "debug.h"
HBITMAP hUpArrow = 0;
HBITMAP hDnArrow = 0;
@ -83,16 +85,12 @@ LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam )
lpCreat->cx, 16, SWP_NOZORDER);
}
CreateScrollBarStruct(hWnd);
#ifdef DEBUG_SCROLL
printf("ScrollBar Creation !\n");
#endif
dprintf_scroll(stddeb,"ScrollBar Creation !\n");
return 0;
case WM_DESTROY:
lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
if (lphs == 0) return 0;
#ifdef DEBUG_SCROLL
printf("ScrollBar WM_DESTROY %lX !\n", lphs);
#endif
dprintf_scroll(stddeb,"ScrollBar WM_DESTROY %lX !\n", lphs);
free(lphs);
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = 0;
return 0;
@ -116,9 +114,7 @@ LONG ScrollBarWndProc( HWND hWnd, WORD message, WORD wParam, LONG lParam )
return(SendMessage(wndPtr->hwndParent, message, wParam, lParam));
case WM_TIMER:
#ifdef DEBUG_SCROLL
printf("ScrollBar WM_TIMER wParam=%X lParam=%lX !\n", wParam, lParam);
#endif
dprintf_scroll(stddeb,"ScrollBar WM_TIMER wParam=%X lParam=%lX !\n", wParam, lParam);
lphs = ScrollBarGetWindowAndStorage(hWnd, &wndPtr);
KillTimer(hWnd, wParam);
switch(lphs->ButtonDown) {
@ -175,67 +171,51 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y)
if (nBar == SB_CTL) {
hWndParent = GetParent(hWnd);
dwOwner = MAKELONG(0, lphs->hWndOwner);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown SB_CTL // x=%d y=%d\n", x, y);
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown SB_CTL // x=%d y=%d\n", x, y);
}
else {
hWndParent = hWnd;
dwOwner = 0L;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown SB_?SCROLL // x=%d y=%d\n", x, y);
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown SB_?SCROLL // x=%d y=%d\n", x, y);
}
/*
SetFocus(lphs->hWndOwner);
*/
CopyRect(&rect, &lphs->rect);
#ifdef DEBUG_SCROLL
printf("ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n",
dprintf_scroll(stddeb,"ScrollDown / x=%d y=%d left=%d top=%d right=%d bottom=%d \n",
x, y, rect.left, rect.top, rect.right, rect.bottom);
#endif
if (lphs->Direction == WM_VSCROLL) {
width = rect.right - rect.left;
if (y <= lphs->rectUp.bottom) {
lphs->ButtonDown = 1;
InvalidateRect(lphs->hWndOwner, &lphs->rectUp, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEUP\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_LINEUP\n");
SendMessage(hWndParent, lphs->Direction,
SB_LINEUP, dwOwner);
}
if (y >= lphs->rectDown.top) {
lphs->ButtonDown = 2;
InvalidateRect(lphs->hWndOwner, &lphs->rectDown, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEDOWN\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_LINEDOWN\n");
SendMessage(hWndParent, lphs->Direction,
SB_LINEDOWN, dwOwner);
}
if (y > lphs->rectUp.bottom && y < (lphs->CurPix + width)) {
lphs->ButtonDown = 5;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEUP\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_PAGEUP\n");
SendMessage(hWndParent, lphs->Direction,
SB_PAGEUP, dwOwner);
}
if (y < lphs->rectDown.top && y > (lphs->CurPix + (width << 1))) {
lphs->ButtonDown = 6;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_PAGEDOWN\n");
SendMessage(hWndParent, lphs->Direction,
SB_PAGEDOWN, dwOwner);
}
if (lphs->MaxPix > 0 && y > (lphs->CurPix + width) &&
y < (lphs->CurPix + (width << 1))) {
lphs->ThumbActive = TRUE;
#ifdef DEBUG_SCROLL
printf("THUMB DOWN !\n");
#endif
dprintf_scroll(stddeb,"THUMB DOWN !\n");
}
}
else {
@ -243,43 +223,33 @@ void ScrollBarButtonDown(HWND hWnd, int nBar, int x, int y)
if (x <= lphs->rectUp.right) {
lphs->ButtonDown = 3;
InvalidateRect(lphs->hWndOwner, &lphs->rectUp, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEUP\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_LINEUP\n");
SendMessage(hWndParent, lphs->Direction,
SB_LINEUP, dwOwner);
}
if (x >= lphs->rectDown.left) {
lphs->ButtonDown = 4;
InvalidateRect(lphs->hWndOwner, &lphs->rectDown, TRUE);
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_LINEDOWN\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_LINEDOWN\n");
SendMessage(hWndParent, lphs->Direction,
SB_LINEDOWN, dwOwner);
}
if (x > lphs->rectUp.right && x < (lphs->CurPix + height)) {
lphs->ButtonDown = 5;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEUP\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_PAGEUP\n");
SendMessage(hWndParent, lphs->Direction,
SB_PAGEUP, dwOwner);
}
if (x < lphs->rectDown.left && x > (lphs->CurPix + (height << 1))) {
lphs->ButtonDown = 6;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonDown send SB_PAGEDOWN\n");
#endif
dprintf_scroll(stddeb,"ScrollBarButtonDown send SB_PAGEDOWN\n");
SendMessage(hWndParent, lphs->Direction,
SB_PAGEDOWN, dwOwner);
}
if (lphs->MaxPix > 0 && x > (lphs->CurPix + height) &&
x < (lphs->CurPix + (height << 1))) {
lphs->ThumbActive = TRUE;
#ifdef DEBUG_SCROLL
printf("THUMB DOWN !\n");
#endif
dprintf_scroll(stddeb,"THUMB DOWN !\n");
}
}
if (lphs->ButtonDown != 0) {
@ -297,9 +267,7 @@ void ScrollBarButtonUp(HWND hWnd, int nBar, int x, int y)
LPHEADSCROLL lphs;
RECT rect, rect2;
HDC hDC;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonUp // x=%d y=%d\n", x, y);
#endif
dprintf_scroll(stddeb,"ScrollBarButtonUp // x=%d y=%d\n", x, y);
lphs = GetScrollObjectStruct(hWnd, nBar);
if(lphs->ThumbActive)
{
@ -347,25 +315,19 @@ void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y)
if (nBar == SB_CTL) {
hWndParent = GetParent(hWnd);
hWndOwner = lphs->hWndOwner;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonMove SB_CTL // x=%d y=%d\n", x, y);
#endif
dprintf_scroll(stddeb,"ScrollBarButtonMove SB_CTL // x=%d y=%d\n", x, y);
}
else {
hWndParent = hWnd;
hWndOwner = 0;
#ifdef DEBUG_SCROLL
printf("ScrollBarButtonMove SB_?SCROLL // x=%d y=%d\n", x, y);
#endif
dprintf_scroll(stddeb,"ScrollBarButtonMove SB_?SCROLL // x=%d y=%d\n", x, y);
}
if(x<lphs->rect.left||x>lphs->rect.right||
y<lphs->rect.top||y>lphs->rect.bottom)
{
#ifdef DEBUG_SCROLL
printf("Rejecting thumb position !\n");
#endif
dprintf_scroll(stddeb,"Rejecting thumb position !\n");
lphs->ThumbVal=lphs->CurVal;/*revert to last set position*/
}
else
@ -385,9 +347,8 @@ void ScrollBarMouseMove(HWND hWnd, int nBar, WORD wParam, int x, int y)
lphs->MaxPix) + lphs->MinVal;
}
#ifdef DEBUG_SCROLL
printf("Scroll WM_MOUSEMOVE val=%d pix=%d\n", lphs->ThumbVal, y);
#endif
dprintf_scroll(stddeb,"Scroll WM_MOUSEMOVE val=%d pix=%d\n",
lphs->ThumbVal, y);
SendMessage(hWndParent, lphs->Direction,
SB_THUMBTRACK, MAKELONG(lphs->ThumbVal, hWndOwner));
}
@ -399,7 +360,7 @@ LPHEADSCROLL ScrollBarGetWindowAndStorage(HWND hWnd, WND **wndPtr)
LPHEADSCROLL lphs;
*(wndPtr) = Ptr = WIN_FindWndPtr(hWnd);
if (Ptr == 0) {
printf("Bad Window handle on ScrollBar !\n");
fprintf(stderr,"Bad Window handle on ScrollBar !\n");
return 0;
}
lphs = *((LPHEADSCROLL *)&Ptr->wExtra[1]);
@ -413,7 +374,7 @@ LPHEADSCROLL ScrollBarGetStorageHeader(HWND hWnd)
LPHEADSCROLL lphs;
wndPtr = WIN_FindWndPtr(hWnd);
if (wndPtr == 0) {
printf("Bad Window handle on ScrollBar !\n");
fprintf(stderr,"Bad Window handle on ScrollBar !\n");
return 0;
}
lphs = *((LPHEADSCROLL *)&wndPtr->wExtra[1]);
@ -427,20 +388,19 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
HWND hWndParent;
HBRUSH hBrush;
HDC hMemDC;
HBITMAP hOldBmp;
BITMAP bm;
RECT rect;
UINT i, w, w2, h, h2, siz;
char C[128];
if (lphs == NULL) return;
#ifdef DEBUG_SCROLL
printf("StdDrawScrollBar nBar=%04X !\n", nBar);
dprintf_scroll(stddeb,"StdDrawScrollBar nBar=%04X !\n", nBar);
if (lphs->Direction == WM_VSCROLL)
printf("StdDrawScrollBar Vertical left=%d top=%d right=%d bottom=%d !\n",
dprintf_scroll(stddeb,"StdDrawScrollBar Vertical left=%d top=%d right=%d bottom=%d !\n",
lprect->left, lprect->top, lprect->right, lprect->bottom);
else
printf("StdDrawScrollBar Horizontal left=%d top=%d right=%d bottom=%d !\n",
dprintf_scroll(stddeb,"StdDrawScrollBar Horizontal left=%d top=%d right=%d bottom=%d !\n",
lprect->left, lprect->top, lprect->right, lprect->bottom);
#endif
if (nBar == SB_CTL)
hWndParent = GetParent(hWnd);
else
@ -489,9 +449,9 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
if (lphs->Direction == WM_VSCROLL) {
GetObject(hUpArrow, sizeof(BITMAP), (LPSTR)&bm);
if (lphs->ButtonDown == 1)
SelectObject(hMemDC, hUpArrowD);
hOldBmp = SelectObject(hMemDC, hUpArrowD);
else
SelectObject(hMemDC, hUpArrow);
hOldBmp = SelectObject(hMemDC, hUpArrow);
StretchBlt(hDC, rect.left, rect.top, w, h2, hMemDC,
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
GetObject(hDnArrow, sizeof(BITMAP), (LPSTR)&bm);
@ -507,9 +467,9 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
else {
GetObject(hLfArrow, sizeof(BITMAP), (LPSTR)&bm);
if (lphs->ButtonDown == 3)
SelectObject(hMemDC, hLfArrowD);
hOldBmp = SelectObject(hMemDC, hLfArrowD);
else
SelectObject(hMemDC, hLfArrow);
hOldBmp = SelectObject(hMemDC, hLfArrow);
StretchBlt(hDC, rect.left, rect.top, w2, h, hMemDC,
0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
GetObject(hRgArrow, sizeof(BITMAP), (LPSTR)&bm);
@ -522,6 +482,7 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
rect.left += w2;
rect.right -= w2;
}
SelectObject( hMemDC, hOldBmp );
DeleteDC(hMemDC);
FillRect(hDC, &rect, hBrush);
if (lphs->MaxPix != 0) {
@ -534,9 +495,9 @@ void StdDrawScrollBar(HWND hWnd, HDC hDC, int nBar, LPRECT lprect, LPHEADSCROLL
FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH));
InflateRect(&rect, -1, -1);
FillRect(hDC, &rect, GetStockObject(LTGRAY_BRUSH));
DrawReliefRect(hDC, rect, 2, 0);
GRAPH_DrawReliefRect(hDC, &rect, 2, 0);
InflateRect(&rect, -3, -3);
DrawReliefRect(hDC, rect, 1, 1);
GRAPH_DrawReliefRect(hDC, &rect, 1, 1);
}
}
@ -555,9 +516,7 @@ int CreateScrollBarStruct(HWND hWnd)
lphs = AllocScrollBar(WS_VSCROLL, width, height);
else
lphs = AllocScrollBar(WS_HSCROLL, width, height);
#ifdef DEBUG_SCROLL
printf("CreateScrollBarStruct %lX !\n", lphs);
#endif
dprintf_scroll(stddeb,"CreateScrollBarStruct %lX !\n", lphs);
*((LPHEADSCROLL *)&wndPtr->wExtra[1]) = lphs;
lphs->hWndOwner = hWnd;
CopyRect(&lphs->rect, &wndPtr->rectClient);
@ -587,7 +546,7 @@ LPHEADSCROLL AllocScrollBar(DWORD dwStyle, int width, int height)
hRgArrowD = LoadBitmap((HINSTANCE)NULL, MAKEINTRESOURCE(OBM_RGARROWD));
lphs = (LPHEADSCROLL)malloc(sizeof(HEADSCROLL));
if (lphs == 0) {
printf("Bad Memory Alloc on ScrollBar !\n");
fprintf(stderr,"Bad Memory Alloc on ScrollBar !\n");
return NULL;
}
lphs->ThumbActive = FALSE;
@ -630,9 +589,8 @@ void NC_CreateScrollBars(HWND hWnd)
if (wndPtr->dwStyle & WS_VSCROLL) {
if (wndPtr->dwStyle & WS_HSCROLL) height -= SYSMETRICS_CYHSCROLL;
lphs = AllocScrollBar(WS_VSCROLL, SYSMETRICS_CXVSCROLL, height);
#ifdef DEBUG_SCROLL
printf("NC_CreateScrollBars Vertical %lX !\n", lphs);
#endif
dprintf_scroll(stddeb,"NC_CreateScrollBars Vertical %lX !\n",
lphs);
lphs->rect.left = width - SYSMETRICS_CYVSCROLL;
lphs->rect.right = width;
lphs->hWndOwner = hWnd;
@ -643,9 +601,7 @@ void NC_CreateScrollBars(HWND hWnd)
if (wndPtr->dwStyle & WS_HSCROLL) {
if (wndPtr->dwStyle & WS_VSCROLL) width -= SYSMETRICS_CYVSCROLL;
lphs = AllocScrollBar(WS_HSCROLL, width, SYSMETRICS_CYHSCROLL);
#ifdef DEBUG_SCROLL
printf("NC_CreateScrollBars Horizontal %lX !\n", lphs);
#endif
dprintf_scroll(stddeb,"NC_CreateScrollBars Horizontal %lX !\n", lphs);
lphs->rect.top = height - SYSMETRICS_CYHSCROLL;
lphs->rect.bottom = height;
lphs->hWndOwner = hWnd;
@ -689,12 +645,10 @@ int SetScrollPos(HWND hWnd, int nBar, int nPos, BOOL bRedraw)
if(lphs->CurPix <0)lphs->CurPix=0;
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
#ifdef DEBUG_SCROLL
printf("SetScrollPos val=%d pixval=%d pixmax%d\n",
dprintf_scroll(stddeb,"SetScrollPos val=%d pixval=%d pixmax%d\n",
(short)nPos, lphs->CurPix, lphs->MaxPix);
printf("SetScrollPos min=%d max=%d\n",
dprintf_scroll(stddeb,"SetScrollPos min=%d max=%d\n",
lphs->MinVal, lphs->MaxVal);
#endif
if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
if (nBar == SB_CTL) {
InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
@ -745,9 +699,8 @@ void SetScrollRange(HWND hWnd, int nBar, int MinPos, int MaxPos, BOOL bRedraw)
(lphs->MaxVal - lphs->MinVal);
if(lphs->CurPix <0)lphs->CurPix=0;
if (lphs->CurPix > lphs->MaxPix) lphs->CurPix = lphs->MaxPix;
#ifdef DEBUG_SCROLL
printf("SetScrollRange min=%d max=%d\n", lphs->MinVal, lphs->MaxVal);
#endif
dprintf_scroll(stddeb,"SetScrollRange min=%d max=%d\n",
lphs->MinVal, lphs->MaxVal);
if ((bRedraw) && (IsWindowVisible(lphs->hWndOwner))) {
if (nBar == SB_CTL) {
InvalidateRect(lphs->hWndOwner, &lphs->rect, TRUE);
@ -785,10 +738,8 @@ void GetScrollRange(HWND hWnd, int nBar, LPINT lpMin, LPINT lpMax)
void ShowScrollBar(HWND hWnd, WORD wBar, BOOL bFlag)
{
WND *wndPtr;
printf("ShowScrollBar hWnd=%04X wBar=%d bFlag=%d\n", hWnd, wBar, bFlag);
#ifdef DEBUG_SCROLL
printf("ShowScrollBar hWnd=%04X wBar=%d bFlag=%d\n", hWnd, wBar, bFlag);
#endif
dprintf_scroll(stddeb,"ShowScrollBar hWnd=%04X wBar=%d bFlag=%d\n",
hWnd, wBar, bFlag);
if (wBar == SB_CTL) {
if (bFlag)
ShowWindow(hWnd, SW_SHOW);

View File

@ -11,85 +11,83 @@ static char Copyright[] = "Copyright David W. Metcalfe, 1993";
#include <windows.h>
#include "win.h"
#include "user.h"
#include "static.h"
#include "icon.h"
extern void DEFWND_SetText( HWND hwnd, LPSTR text ); /* windows/defwnd.c */
static LONG PaintTextfn(HWND hwnd);
static LONG PaintRectfn(HWND hwnd);
static LONG PaintFramefn(HWND hwnd);
static LONG PaintIconfn(HWND hwnd);
static void PaintTextfn( HWND hwnd, HDC hdc );
static void PaintRectfn( HWND hwnd, HDC hdc );
static void PaintFramefn( HWND hwnd, HDC hdc );
static void PaintIconfn( HWND hwnd, HDC hdc );
static COLORREF color_windowframe, color_background, color_window,
color_windowtext;
static COLORREF color_windowframe, color_background, color_window;
#define NOTIFY_PARENT(hWndCntrl, wNotifyCode) \
SendMessage(GetParent(hWndCntrl), WM_COMMAND, \
GetDlgCtrlID(hWndCntrl), MAKELPARAM(hWndCntrl, wNotifyCode));
#define DIM(array) ((sizeof array)/(sizeof array[0]))
typedef struct
typedef void (*pfPaint)(HWND, HDC);
#define LAST_STATIC_TYPE SS_LEFTNOWORDWRAP
static pfPaint staticPaintFunc[LAST_STATIC_TYPE+1] =
{
LONG (*paintfn)();
} STATICFN;
#define MAX_STATIC_TYPE 12
static STATICFN staticfn[MAX_STATIC_TYPE] =
{
{ (LONG(*)())PaintTextfn }, /* SS_LEFT */
{ (LONG(*)())PaintTextfn }, /* SS_CENTER */
{ (LONG(*)())PaintTextfn }, /* SS_RIGHT */
{ (LONG(*)())PaintIconfn }, /* SS_ICON */
{ (LONG(*)())PaintRectfn }, /* SS_BLACKRECT */
{ (LONG(*)())PaintRectfn }, /* SS_GRAYRECT */
{ (LONG(*)())PaintRectfn }, /* SS_WHITERECT */
{ (LONG(*)())PaintFramefn }, /* SS_BLACKFRAME */
{ (LONG(*)())PaintFramefn }, /* SS_GRAYFRAME */
{ (LONG(*)())PaintFramefn }, /* SS_WHITEFRAME */
{ (LONG(*)())PaintTextfn }, /* SS_SIMPLE */
{ (LONG(*)())PaintTextfn } /* SS_LEFTNOWORDWRAP */
PaintTextfn, /* SS_LEFT */
PaintTextfn, /* SS_CENTER */
PaintTextfn, /* SS_RIGHT */
PaintIconfn, /* SS_ICON */
PaintRectfn, /* SS_BLACKRECT */
PaintRectfn, /* SS_GRAYRECT */
PaintRectfn, /* SS_WHITERECT */
PaintFramefn, /* SS_BLACKFRAME */
PaintFramefn, /* SS_GRAYFRAME */
PaintFramefn, /* SS_WHITEFRAME */
NULL, /* Not defined */
PaintTextfn, /* SS_SIMPLE */
PaintTextfn /* SS_LEFTNOWORDWRAP */
};
/***********************************************************************
* STATIC_SetIcon
*
* Set the icon for an SS_ICON control.
*/
static void STATIC_SetIcon( HWND hwnd, HICON hicon )
{
WND *wndPtr = WIN_FindWndPtr( hwnd );
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
if ((wndPtr->dwStyle & 0x0f) != SS_ICON) return;
if (infoPtr->hIcon) DestroyIcon( infoPtr->hIcon );
infoPtr->hIcon = hicon;
if (hicon)
{
ICONALLOC *icon = (ICONALLOC *) GlobalLock( hicon );
SetWindowPos( hwnd, 0, 0, 0,
icon->descriptor.Width, icon->descriptor.Height,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER );
GlobalUnlock( hicon );
}
}
/***********************************************************************
* StaticWndProc
*/
LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam)
{
LONG lResult = 0;
HDC hDC;
RECT rc;
LPSTR textPtr;
WND *wndPtr = WIN_FindWndPtr(hWnd);
LONG style = wndPtr->dwStyle & 0x0000000F;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
switch (uMsg) {
case WM_ENABLE:
InvalidateRect(hWnd, NULL, FALSE);
break;
case WM_NCCREATE:
if (style == SS_ICON)
{
/* Note: we use wndPtr->hText to store the icon handle */
CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam;
if (createStruct->lpszName)
wndPtr->hText = LoadIcon( createStruct->hInstance,
createStruct->lpszName );
return 1;
}
else return DefWindowProc(hWnd, uMsg, wParam, lParam);
case WM_NCDESTROY:
if (style == SS_ICON)
{
if (wndPtr->hText) DestroyIcon( wndPtr->hText );
wndPtr->hText = 0;
return 0;
}
else return DefWindowProc(hWnd, uMsg, wParam, lParam);
case WM_CREATE:
if (style < 0L || style >= (LONG)DIM(staticfn)) {
if (style < 0L || style > LAST_STATIC_TYPE) {
lResult = -1L;
break;
}
@ -97,49 +95,68 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam)
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
lResult = 0L;
if (style == SS_ICON) {
/*
SetWindowPos(hWnd, (HWND)NULL, 0, 0, 32, 32,
SWP_NOZORDER | SWP_NOMOVE);
*/
}
if (style == SS_ICON)
{
CREATESTRUCT * createStruct = (CREATESTRUCT *)lParam;
if (createStruct->lpszName)
STATIC_SetIcon( hWnd, LoadIcon( createStruct->hInstance,
createStruct->lpszName ));
}
break;
case WM_DESTROY:
STATIC_SetIcon( hWnd, 0 ); /* Destroy the current icon */
break;
case WM_PAINT:
if (staticfn[style].paintfn)
(staticfn[style].paintfn)(hWnd);
if (staticPaintFunc[style])
{
PAINTSTRUCT ps;
BeginPaint( hWnd, &ps );
(staticPaintFunc[style])( hWnd, ps.hdc );
EndPaint( hWnd, &ps );
}
break;
case WM_SYSCOLORCHANGE:
color_windowframe = GetSysColor(COLOR_WINDOWFRAME);
color_background = GetSysColor(COLOR_BACKGROUND);
color_window = GetSysColor(COLOR_WINDOW);
color_windowtext = GetSysColor(COLOR_WINDOWTEXT);
InvalidateRect(hWnd, NULL, TRUE);
break;
case WM_SETTEXT:
if (style == SS_ICON) break;
DEFWND_SetText( hWnd, (LPSTR)lParam );
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
break;
case WM_SETFONT:
if (style == SS_ICON) return 0;
infoPtr->hFont = wParam;
if (LOWORD(lParam))
{
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
}
break;
case WM_GETFONT:
return infoPtr->hFont;
case WM_NCHITTEST:
return HTTRANSPARENT;
case WM_GETDLGCODE:
return DLGC_STATIC;
case STM_GETICON:
if (style != SS_ICON) return 0;
return (HICON)wndPtr->hText;
return infoPtr->hIcon;
case STM_SETICON:
if (style != SS_ICON) return 0;
if (wndPtr->hText) DestroyIcon( wndPtr->hText );
wndPtr->hText = wParam;
InvalidateRect( hWnd, NULL, TRUE );
UpdateWindow( hWnd );
STATIC_SetIcon( hWnd, wParam );
InvalidateRect( hWnd, NULL, FALSE );
UpdateWindow( hWnd );
return 0;
default:
@ -151,27 +168,19 @@ LONG StaticWndProc(HWND hWnd, WORD uMsg, WORD wParam, LONG lParam)
}
static LONG PaintTextfn(HWND hwnd)
static void PaintTextfn( HWND hwnd, HDC hdc )
{
PAINTSTRUCT ps;
RECT rc;
HDC hdc;
HBRUSH hBrush;
HANDLE hText;
char *text;
int textlen;
WORD wFormat;
WND *wndPtr = WIN_FindWndPtr(hwnd);
LONG style = wndPtr->dwStyle;
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rc);
textlen = GetWindowTextLength(hwnd);
hText = USER_HEAP_ALLOC(0, textlen+1);
text = USER_HEAP_ADDR(hText);
GetWindowText(hwnd, text, textlen+1);
text = USER_HEAP_ADDR( wndPtr->hText );
switch (style & 0x0000000F)
{
@ -199,70 +208,48 @@ static LONG PaintTextfn(HWND hwnd)
if (style & SS_NOPREFIX)
wFormat |= DT_NOPREFIX;
hBrush = SendMessage(GetParent(hwnd), WM_CTLCOLOR, (WORD)hdc,
MAKELONG(hwnd, CTLCOLOR_STATIC));
if (infoPtr->hFont) SelectObject( hdc, infoPtr->hFont );
hBrush = SendMessage( wndPtr->hwndParent, WM_CTLCOLOR, (WORD)hdc,
MAKELONG(hwnd, CTLCOLOR_STATIC));
if (hBrush == (HBRUSH)NULL) hBrush = GetStockObject(WHITE_BRUSH);
FillRect(hdc, &rc, hBrush);
DrawText(hdc, text, textlen, &rc, wFormat);
USER_HEAP_FREE(hText);
EndPaint(hwnd, &ps);
DrawText(hdc, text, -1, &rc, wFormat);
}
static LONG PaintRectfn(HWND hwnd)
static void PaintRectfn( HWND hwnd, HDC hdc )
{
PAINTSTRUCT ps;
RECT rc;
HDC hdc;
HPEN hOldPen, hPen;
HBRUSH hOldBrush, hBrush;
HBRUSH hBrush;
WND *wndPtr = WIN_FindWndPtr(hwnd);
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rc);
switch (wndPtr->dwStyle & 0x0000000F)
{
case SS_BLACKRECT:
hPen = CreatePen(PS_SOLID, 1, color_windowframe);
hBrush = CreateSolidBrush(color_windowframe);
break;
case SS_GRAYRECT:
hPen = CreatePen(PS_SOLID, 1, color_background);
hBrush = CreateSolidBrush(color_background);
break;
case SS_WHITERECT:
hPen = CreatePen(PS_SOLID, 1, color_window);
hBrush = CreateSolidBrush(color_window);
break;
}
hOldPen = (HPEN)SelectObject(hdc, (HANDLE)hPen);
hOldBrush = (HBRUSH)SelectObject(hdc, (HANDLE)hBrush);
Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
SelectObject(hdc, (HANDLE)hOldPen);
SelectObject(hdc, (HANDLE)hOldBrush);
DeleteObject((HANDLE)hPen);
DeleteObject((HANDLE)hBrush);
EndPaint(hwnd, &ps);
FillRect( hdc, &rc, hBrush );
}
static LONG PaintFramefn(HWND hwnd)
static void PaintFramefn( HWND hwnd, HDC hdc )
{
PAINTSTRUCT ps;
RECT rc;
HDC hdc;
HPEN hOldPen, hPen;
HBRUSH hOldBrush, hBrush;
WND *wndPtr = WIN_FindWndPtr(hwnd);
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rc);
switch (wndPtr->dwStyle & 0x0000000F)
@ -289,22 +276,19 @@ static LONG PaintFramefn(HWND hwnd)
SelectObject(hdc, (HANDLE)hOldBrush);
DeleteObject((HANDLE)hPen);
DeleteObject((HANDLE)hBrush);
EndPaint(hwnd, &ps);
}
static LONG PaintIconfn(HWND hwnd)
static void PaintIconfn( HWND hwnd, HDC hdc )
{
WND *wndPtr;
PAINTSTRUCT ps;
RECT rc;
HDC hdc;
HBRUSH hbrush;
WND *wndPtr = WIN_FindWndPtr(hwnd);
STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra;
wndPtr = WIN_FindWndPtr(hwnd);
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd, &rc);
FillRect(hdc, &rc, GetStockObject(WHITE_BRUSH));
if (wndPtr->hText) DrawIcon(hdc, rc.left, rc.top, wndPtr->hText );
EndPaint(hwnd, &ps);
hbrush = SendMessage( wndPtr->hwndParent, WM_CTLCOLOR, hdc,
MAKELONG(hwnd, CTLCOLOR_STATIC));
FillRect( hdc, &rc, hbrush );
if (infoPtr->hIcon) DrawIcon( hdc, rc.left, rc.top, infoPtr->hIcon );
}

View File

@ -7,12 +7,12 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "win.h"
#include "button.h"
#include "static.h"
#include "desktop.h"
#include "mdi.h"
#include "gdi.h"
LONG ButtonWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG StaticWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG ListBoxWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
LONG ComboBoxWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
@ -24,25 +24,25 @@ LONG MDIClientWndProc ( HWND hwnd, WORD message, WORD wParam, LONG lParam );
static WNDCLASS WIDGETS_BuiltinClasses[] =
{
{ CS_GLOBALCLASS, (LONG(*)())ButtonWndProc, 0, 2,
{ CS_GLOBALCLASS | CS_PARENTDC, ButtonWndProc, 0, sizeof(BUTTONINFO),
0, 0, 0, 0, NULL, "BUTTON" },
{ CS_GLOBALCLASS, (LONG(*)())StaticWndProc, 0, 0,
{ CS_GLOBALCLASS | CS_PARENTDC, StaticWndProc, 0, sizeof(STATICINFO),
0, 0, 0, 0, NULL, "STATIC" },
{ CS_GLOBALCLASS, (LONG(*)())ScrollBarWndProc, 0, 8,
{ CS_GLOBALCLASS | CS_PARENTDC, ScrollBarWndProc, 0, 8,
0, 0, 0, 0, NULL, "SCROLLBAR" },
{ CS_GLOBALCLASS, (LONG(*)())ListBoxWndProc, 0, 8,
{ CS_GLOBALCLASS | CS_PARENTDC, ListBoxWndProc, 0, 8,
0, 0, 0, 0, NULL, "LISTBOX" },
{ CS_GLOBALCLASS, (LONG(*)())ComboBoxWndProc, 0, 8,
{ CS_GLOBALCLASS | CS_PARENTDC, ComboBoxWndProc, 0, 8,
0, 0, 0, 0, NULL, "COMBOBOX" },
{ CS_GLOBALCLASS, (LONG(*)())EditWndProc, 0, 4,
{ CS_GLOBALCLASS | CS_PARENTDC, EditWndProc, 0, 4,
0, 0, 0, 0, NULL, "EDIT" },
{ CS_GLOBALCLASS | CS_SAVEBITS, (LONG(*)())PopupMenuWndProc, 0, 8,
{ CS_GLOBALCLASS | CS_SAVEBITS, PopupMenuWndProc, 0, 8,
0, 0, 0, 0, NULL, POPUPMENU_CLASS_NAME },
{ CS_GLOBALCLASS, (LONG(*)())DesktopWndProc, 0, sizeof(DESKTOPINFO),
{ CS_GLOBALCLASS, DesktopWndProc, 0, sizeof(DESKTOPINFO),
0, 0, 0, 0, NULL, DESKTOP_CLASS_NAME },
{ CS_GLOBALCLASS | CS_SAVEBITS, (LONG(*)())DefDlgProc, 0, DLGWINDOWEXTRA,
{ CS_GLOBALCLASS | CS_SAVEBITS, DefDlgProc, 0, DLGWINDOWEXTRA,
0, 0, 0, 0, NULL, DIALOG_CLASS_NAME },
{ CS_GLOBALCLASS, (LONG(*)())MDIClientWndProc, 0, sizeof(MDICLIENTINFO),
{ CS_GLOBALCLASS, MDIClientWndProc, 0, sizeof(MDICLIENTINFO),
0, 0, 0, STOCK_LTGRAY_BRUSH, NULL, "MDICLIENT" }
};

View File

@ -16,12 +16,7 @@ SRCS = \
lex.yy.c \
info.c
OBJS = \
dbg.tab.o \
break.o \
hash.o \
lex.yy.o \
info.o
OBJS = $(SRCS:.c=.o)
/*
* All the SUBDIR stuff

View File

@ -178,14 +178,16 @@ wine_debug(int signal, int * regs)
/* This is intended to read the entry points from the Windows image, and
insert them in the hash table. It does not work yet, so it is commented out. */
#if 0
if(!loaded_symbols){
loaded_symbols++;
read_symboltable("wine.sym");
#if 0
load_entrypoints();
}
#endif
}
/* Remove the breakpoints from memory... */
fprintf(stderr,"Removing BPs\n");
insert_break(0);
/* If we stopped on a breakpoint, report this fact */

View File

@ -157,10 +157,10 @@ load_entrypoints(){
struct w_files * wpnt;
for(wpnt = wine_files; wpnt; wpnt = wpnt->next){
cpnt = wpnt->nrname_table;
cpnt = wpnt->ne->nrname_table;
while(1==1){
if( ((int) cpnt) - ((int)wpnt->nrname_table) >
wpnt->ne_header->nrname_tab_length) break;
if( ((int) cpnt) - ((int)wpnt->ne->nrname_table) >
wpnt->ne->ne_header->nrname_tab_length) break;
len = *cpnt++;
strncpy(buffer, cpnt, len);
buffer[len] = 0;
@ -168,7 +168,7 @@ load_entrypoints(){
j = GetEntryPointFromOrdinal(wpnt, ordinal);
address = j & 0xffff;
j = j >> 16;
address |= (wpnt->selector_table[j].selector) << 16;
address |= (wpnt->ne->selector_table[j].selector) << 16;
fprintf(stderr,"%s -> %x\n", buffer, address);
add_hash(buffer, (unsigned int *) address);
cpnt += len + 2;

View File

@ -282,16 +282,18 @@ void dbg_bt(){
}
fprintf(stderr,"Backtrace:\n");
fprintf(stderr,"%d %4.4x:%4.4x\n", frameno++, SC_CS, SC_EIP(dbg_mask));
fprintf(stderr,"%d ",frameno);
print_address(frame->u.win32.saved_ip,stderr);
cs = SC_CS;
frame = (struct frame *) ((SC_EBP(dbg_mask) & ~1) | (SC_SS << 16));
while((cs & 3) == 3) {
/* See if in 32 bit mode or not. Assume GDT means 32 bit. */
if ((cs & 7) != 7) {
cs = frame->u.win32.saved_cs;
fprintf(stderr,"%d %4.4x:%4.4x\n", frameno++, cs,
frame->u.win32.saved_ip);
void CallTo32();
fprintf(stderr,"\n%d ",frameno++);
print_address(frame->u.win32.saved_ip,stderr);
if(frame->u.win32.saved_ip<((char*)CallTo32+1000))break;
frame = (struct frame *) frame->u.win32.saved_bp;
} else {
cs = frame->u.win16.saved_cs;
@ -301,5 +303,6 @@ void dbg_bt(){
(SC_SS << 16));
}
}
putchar('\n');
}

View File

@ -11,9 +11,7 @@ SRCS = \
dis-buf.c \
i386-dis.c
OBJS = \
dis-buf.o \
i386-dis.o
OBJS = $(SRCS:.c=.o)
#ifdef xi386
#define i386 1
@ -22,7 +20,6 @@ OBJS = \
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

View File

@ -11,14 +11,10 @@ SRCS = \
editline.c \
sysunix.c
OBJS = \
complete.o \
editline.o \
sysunix.o
OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

View File

@ -6,6 +6,4 @@ AllTarget()
depend::
CleanTarget()
includes::

View File

@ -62,15 +62,16 @@ MakeDllFromSpec(winsock,$(TOP)/$(MODULE))
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
pop.h: $(TOP)/tools/build
$(TOP)/tools/build -p
call.s: call.S pop.h
includes::
touch pop.h
install::
clean::
$(RM) dll* dtb* pop.h call.s
touch pop.h

View File

@ -26,6 +26,12 @@ struct thunk_s
unsigned char thunk[10];
};
static __inline__ int Is16bitAddress(void *address)
{
return ((unsigned int) address
>= (((FIRST_SELECTOR << 3) | 0x0007) << 16));
}
/**********************************************************************
* PushOn16
*/
@ -139,10 +145,25 @@ void FreeProcInstance(FARPROC func)
}
}
/**********************************************************************
* GetCodeHandle (KERNEL.93)
*/
HANDLE GetCodeHandle( FARPROC proc )
{
struct thunk_s *tp = (struct thunk_s *)proc;
/* Return the code segment containing 'proc'. */
/* Not sure if this is really correct (shouldn't matter that much). */
printf( "STUB: GetCodeHandle(%p) returning %x\n",
tp->thunk[8] + (tp->thunk[9] << 8) );
return tp->thunk[8] + (tp->thunk[9] << 8);
}
/**********************************************************************
* CallWindowProc (USER.122)
*/
LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message,
LONG CallWindowProc( WNDPROC func, HWND hwnd, WORD message,
WORD wParam, LONG lParam )
{
SpyMessage(hwnd, message, wParam, lParam);

View File

@ -5,15 +5,15 @@ id 3
length 490
1 pascal SetBkColor(word long) SetBkColor(1 2)
2 pascal SetBkMode(word word) SetBkMode(1 2)
3 pascal SetMapMode(word word) SetMapMode(1 2)
4 pascal SetROP2(word word) SetROP2(1 2)
5 pascal SetRelAbs(word word) SetRelAbs(1 2)
6 pascal SetPolyFillMode(word word) SetPolyFillMode(1 2)
7 pascal SetStretchBltMode(word word) SetStretchBltMode(1 2)
8 pascal SetTextCharacterExtra(word s_word) SetTextCharacterExtra(1 2)
2 pascal16 SetBkMode(word word) SetBkMode(1 2)
3 pascal16 SetMapMode(word word) SetMapMode(1 2)
4 pascal16 SetROP2(word word) SetROP2(1 2)
5 pascal16 SetRelAbs(word word) SetRelAbs(1 2)
6 pascal16 SetPolyFillMode(word word) SetPolyFillMode(1 2)
7 pascal16 SetStretchBltMode(word word) SetStretchBltMode(1 2)
8 pascal16 SetTextCharacterExtra(word s_word) SetTextCharacterExtra(1 2)
9 pascal SetTextColor(word long) SetTextColor(1 2)
10 pascal SetTextJustification(word s_word s_word) SetTextJustification(1 2 3)
10 pascal16 SetTextJustification(word s_word s_word) SetTextJustification(1 2 3)
11 pascal SetWindowOrg(word s_word s_word) SetWindowOrg(1 2 3)
12 pascal SetWindowExt(word s_word s_word) SetWindowExt(1 2 3)
13 pascal SetViewportOrg(word s_word s_word) SetViewportOrg(1 2 3)
@ -24,146 +24,146 @@ length 490
17 pascal OffsetViewportOrg(word s_word s_word) OffsetViewportOrg(1 2 3)
18 pascal ScaleViewportExt(word s_word s_word s_word s_word)
ScaleViewportExt(1 2 3 4 5)
19 pascal LineTo(word s_word s_word) LineTo(1 2 3)
19 pascal16 LineTo(word s_word s_word) LineTo(1 2 3)
20 pascal MoveTo(word s_word s_word) MoveTo(1 2 3)
21 pascal ExcludeClipRect(word s_word s_word s_word s_word)
ExcludeClipRect(1 2 3 4 5)
22 pascal IntersectClipRect(word s_word s_word s_word s_word)
IntersectClipRect(1 2 3 4 5)
23 pascal Arc(word s_word s_word s_word s_word s_word s_word s_word s_word)
Arc(1 2 3 4 5 6 7 8 9)
24 pascal Ellipse(word s_word s_word s_word s_word) Ellipse(1 2 3 4 5)
25 pascal FloodFill(word word word long) FloodFill(1 2 3 4)
26 pascal Pie(word s_word s_word s_word s_word s_word s_word s_word s_word)
Pie(1 2 3 4 5 6 7 8 9)
27 pascal Rectangle(word s_word s_word s_word s_word) Rectangle(1 2 3 4 5)
28 pascal RoundRect(word s_word s_word s_word s_word s_word s_word)
RoundRect(1 2 3 4 5 6 7)
29 pascal PatBlt(word s_word s_word s_word s_word long) PatBlt(1 2 3 4 5 6)
30 pascal SaveDC(word) SaveDC(1)
21 pascal16 ExcludeClipRect(word s_word s_word s_word s_word)
ExcludeClipRect(1 2 3 4 5)
22 pascal16 IntersectClipRect(word s_word s_word s_word s_word)
IntersectClipRect(1 2 3 4 5)
23 pascal16 Arc(word s_word s_word s_word s_word s_word s_word s_word s_word)
Arc(1 2 3 4 5 6 7 8 9)
24 pascal16 Ellipse(word s_word s_word s_word s_word) Ellipse(1 2 3 4 5)
25 pascal16 FloodFill(word s_word s_word long) FloodFill(1 2 3 4)
26 pascal16 Pie(word s_word s_word s_word s_word s_word s_word s_word s_word)
Pie(1 2 3 4 5 6 7 8 9)
27 pascal16 Rectangle(word s_word s_word s_word s_word) Rectangle(1 2 3 4 5)
28 pascal16 RoundRect(word s_word s_word s_word s_word s_word s_word)
RoundRect(1 2 3 4 5 6 7)
29 pascal16 PatBlt(word s_word s_word s_word s_word long) PatBlt(1 2 3 4 5 6)
30 pascal16 SaveDC(word) SaveDC(1)
31 pascal SetPixel(word s_word s_word long) SetPixel(1 2 3 4)
32 pascal OffsetClipRgn(word s_word s_word) OffsetClipRgn(1 2 3)
33 pascal TextOut(word s_word s_word ptr word) TextOut(1 2 3 4 5)
34 pascal BitBlt( word s_word s_word s_word s_word word s_word s_word long)
BitBlt(1 2 3 4 5 6 7 8 9)
35 pascal StretchBlt( word s_word s_word s_word s_word word s_word s_word s_word s_word long)
StretchBlt(1 2 3 4 5 6 7 8 9 10 11)
36 pascal Polygon (word ptr word) Polygon (1 2 3)
37 pascal Polyline (word ptr word) Polyline (1 2 3)
32 pascal16 OffsetClipRgn(word s_word s_word) OffsetClipRgn(1 2 3)
33 pascal16 TextOut(word s_word s_word ptr word) TextOut(1 2 3 4 5)
34 pascal16 BitBlt( word s_word s_word s_word s_word word s_word s_word long)
BitBlt(1 2 3 4 5 6 7 8 9)
35 pascal16 StretchBlt( word s_word s_word s_word s_word word s_word s_word s_word s_word long)
StretchBlt(1 2 3 4 5 6 7 8 9 10 11)
36 pascal16 Polygon (word ptr word) Polygon (1 2 3)
37 pascal16 Polyline (word ptr word) Polyline (1 2 3)
38 pascal Escape(word word word ptr ptr) Escape(1 2 3 4 5)
39 pascal RestoreDC(word s_word) RestoreDC(1 2)
40 pascal FillRgn(word word word) FillRgn(1 2 3)
39 pascal16 RestoreDC(word s_word) RestoreDC(1 2)
40 pascal16 FillRgn(word word word) FillRgn(1 2 3)
#41 pascal FrameRgn
42 pascal InvertRgn(word word) InvertRgn(1 2)
43 pascal PaintRgn(word word) PaintRgn(1 2)
44 pascal SelectClipRgn(word word) SelectClipRgn(1 2)
45 pascal SelectObject(word word) SelectObject(1 2)
42 pascal16 InvertRgn(word word) InvertRgn(1 2)
43 pascal16 PaintRgn(word word) PaintRgn(1 2)
44 pascal16 SelectClipRgn(word word) SelectClipRgn(1 2)
45 pascal16 SelectObject(word word) SelectObject(1 2)
#46 pascal __GP?
47 pascal CombineRgn(word word word word) CombineRgn(1 2 3 4)
48 pascal CreateBitmap(word word word word ptr) CreateBitmap(1 2 3 4 5)
49 pascal CreateBitmapIndirect(ptr) CreateBitmapIndirect(1)
50 pascal CreateBrushIndirect(ptr) CreateBrushIndirect(1)
51 pascal CreateCompatibleBitmap(word word word) CreateCompatibleBitmap(1 2 3)
52 pascal CreateCompatibleDC(word) CreateCompatibleDC(1)
53 pascal CreateDC(ptr ptr ptr ptr) CreateDC(1 2 3 4)
54 pascal CreateEllipticRgn(s_word s_word s_word s_word)
CreateEllipticRgn(1 2 3 4)
55 pascal CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect(1)
56 pascal CreateFont(s_word s_word s_word s_word s_word word word word
word word word word word ptr)
CreateFont(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
57 pascal CreateFontIndirect(ptr) CreateFontIndirect(1)
58 pascal CreateHatchBrush(word long) CreateHatchBrush(1 2)
60 pascal CreatePatternBrush(word) CreatePatternBrush(1)
61 pascal CreatePen(s_word s_word long) CreatePen(1 2 3)
62 pascal CreatePenIndirect(ptr) CreatePenIndirect(1)
63 pascal CreatePolygonRgn(ptr word word) CreatePolygonRgn(1 2 3)
64 pascal CreateRectRgn(s_word s_word s_word s_word) CreateRectRgn(1 2 3 4)
65 pascal CreateRectRgnIndirect(ptr) CreateRectRgnIndirect(1)
66 pascal CreateSolidBrush(long) CreateSolidBrush(1)
67 pascal DPtoLP(word ptr s_word) DPtoLP(1 2 3)
68 pascal DeleteDC(word) DeleteDC(1)
69 pascal DeleteObject(word) DeleteObject(1)
70 pascal EnumFonts(word ptr ptr ptr) EnumFonts(1 2 3 4)
71 pascal EnumObjects(word word ptr ptr) EnumObjects(1 2 3 4)
72 pascal EqualRgn(word word) EqualRgn(1 2)
73 pascal ExcludeVisRect(word s_word s_word s_word s_word)
ExcludeVisRect(1 2 3 4 5)
47 pascal16 CombineRgn(word word word word) CombineRgn(1 2 3 4)
48 pascal16 CreateBitmap(word word word word ptr) CreateBitmap(1 2 3 4 5)
49 pascal16 CreateBitmapIndirect(ptr) CreateBitmapIndirect(1)
50 pascal16 CreateBrushIndirect(ptr) CreateBrushIndirect(1)
51 pascal16 CreateCompatibleBitmap(word word word) CreateCompatibleBitmap(1 2 3)
52 pascal16 CreateCompatibleDC(word) CreateCompatibleDC(1)
53 pascal16 CreateDC(ptr ptr ptr ptr) CreateDC(1 2 3 4)
54 pascal16 CreateEllipticRgn(s_word s_word s_word s_word)
CreateEllipticRgn(1 2 3 4)
55 pascal16 CreateEllipticRgnIndirect(ptr) CreateEllipticRgnIndirect(1)
56 pascal16 CreateFont(s_word s_word s_word s_word s_word word word word
word word word word word ptr)
CreateFont(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
57 pascal16 CreateFontIndirect(ptr) CreateFontIndirect(1)
58 pascal16 CreateHatchBrush(word long) CreateHatchBrush(1 2)
60 pascal16 CreatePatternBrush(word) CreatePatternBrush(1)
61 pascal16 CreatePen(s_word s_word long) CreatePen(1 2 3)
62 pascal16 CreatePenIndirect(ptr) CreatePenIndirect(1)
63 pascal16 CreatePolygonRgn(ptr word word) CreatePolygonRgn(1 2 3)
64 pascal16 CreateRectRgn(s_word s_word s_word s_word) CreateRectRgn(1 2 3 4)
65 pascal16 CreateRectRgnIndirect(ptr) CreateRectRgnIndirect(1)
66 pascal16 CreateSolidBrush(long) CreateSolidBrush(1)
67 pascal16 DPtoLP(word ptr s_word) DPtoLP(1 2 3)
68 pascal16 DeleteDC(word) DeleteDC(1)
69 pascal16 DeleteObject(word) DeleteObject(1)
70 pascal16 EnumFonts(word ptr ptr ptr) EnumFonts(1 2 3 4)
71 pascal16 EnumObjects(word word ptr ptr) EnumObjects(1 2 3 4)
72 pascal16 EqualRgn(word word) EqualRgn(1 2)
73 pascal16 ExcludeVisRect(word s_word s_word s_word s_word)
ExcludeVisRect(1 2 3 4 5)
74 pascal GetBitmapBits(word long ptr) GetBitmapBits(1 2 3)
75 pascal GetBkColor(word) GetBkColor(1)
76 pascal GetBkMode(word) GetBkMode(1)
77 pascal GetClipBox(word ptr) GetClipBox(1 2)
76 pascal16 GetBkMode(word) GetBkMode(1)
77 pascal16 GetClipBox(word ptr) GetClipBox(1 2)
78 pascal GetCurrentPosition(word) GetCurrentPosition(1)
79 pascal GetDCOrg(word) GetDCOrg(1)
80 pascal GetDeviceCaps(word s_word) GetDeviceCaps(1 2)
81 pascal GetMapMode(word) GetMapMode(1)
82 pascal GetObject(word word ptr) GetObject(1 2 3)
80 pascal16 GetDeviceCaps(word s_word) GetDeviceCaps(1 2)
81 pascal16 GetMapMode(word) GetMapMode(1)
82 pascal16 GetObject(word word ptr) GetObject(1 2 3)
83 pascal GetPixel(word s_word s_word) GetPixel(1 2 3)
84 pascal GetPolyFillMode(word) GetPolyFillMode(1)
85 pascal GetROP2(word) GetROP2(1)
86 pascal GetRelAbs(word) GetRelAbs(1)
87 pascal GetStockObject(word) GetStockObject(1)
88 pascal GetStretchBltMode(word) GetStretchBltMode(1)
89 pascal GetTextCharacterExtra(word) GetTextCharacterExtra(1)
84 pascal16 GetPolyFillMode(word) GetPolyFillMode(1)
85 pascal16 GetROP2(word) GetROP2(1)
86 pascal16 GetRelAbs(word) GetRelAbs(1)
87 pascal16 GetStockObject(word) GetStockObject(1)
88 pascal16 GetStretchBltMode(word) GetStretchBltMode(1)
89 pascal16 GetTextCharacterExtra(word) GetTextCharacterExtra(1)
90 pascal GetTextColor(word) GetTextColor(1)
91 pascal GetTextExtent(word ptr s_word) GetTextExtent(1 2 3)
#92 pascal GetTextFace
93 pascal GetTextMetrics(word ptr) GetTextMetrics(1 2)
92 pascal16 GetTextFace(word s_word ptr) GetTextFace(1 2 3)
93 pascal16 GetTextMetrics(word ptr) GetTextMetrics(1 2)
94 pascal GetViewportExt(word) GetViewportExt(1)
95 pascal GetViewportOrg(word) GetViewportOrg(1)
96 pascal GetWindowExt(word) GetWindowExt(1)
97 pascal GetWindowOrg(word) GetWindowOrg(1)
98 pascal IntersectVisRect(word s_word s_word s_word s_word)
IntersectVisRect(1 2 3 4 5)
99 pascal LPtoDP(word ptr s_word) LPtoDP(1 2 3)
100 pascal LineDDA(s_word s_word s_word s_word ptr long)
LineDDA(1 2 3 4 5 6)
101 pascal OffsetRgn(word s_word s_word) OffsetRgn(1 2 3)
102 pascal OffsetVisRgn(word s_word s_word) OffsetVisRgn(1 2 3)
103 pascal PtVisible(word s_word s_word) PtVisible(1 2 3)
104 pascal RectVisibleOld(word ptr) RectVisible(1 2)
105 pascal SelectVisRgn(word word) SelectVisRgn(1 2)
98 pascal16 IntersectVisRect(word s_word s_word s_word s_word)
IntersectVisRect(1 2 3 4 5)
99 pascal16 LPtoDP(word ptr s_word) LPtoDP(1 2 3)
100 pascal16 LineDDA(s_word s_word s_word s_word ptr long)
LineDDA(1 2 3 4 5 6)
101 pascal16 OffsetRgn(word s_word s_word) OffsetRgn(1 2 3)
102 pascal16 OffsetVisRgn(word s_word s_word) OffsetVisRgn(1 2 3)
103 pascal16 PtVisible(word s_word s_word) PtVisible(1 2 3)
104 pascal16 RectVisibleOld(word ptr) RectVisible(1 2)
105 pascal16 SelectVisRgn(word word) SelectVisRgn(1 2)
106 pascal SetBitmapBits(word long ptr) SetBitmapBits(1 2 3)
117 pascal SetDCOrg(word s_word s_word) SetDCOrg(1 2 3)
#121 pascal Death
#122 pascal ReSurRection
123 pascal PlayMetaFile(word word) PlayMetaFile(1 2)
123 pascal16 PlayMetaFile(word word) PlayMetaFile(1 2)
#124 pascal GetMetaFile
125 pascal CreateMetaFile(ptr) CreateMetaFile(1)
126 pascal CloseMetaFile(word) CloseMetaFile(1)
127 pascal DeleteMetaFile(word) DeleteMetaFile(1)
125 pascal16 CreateMetaFile(ptr) CreateMetaFile(1)
126 pascal16 CloseMetaFile(word) CloseMetaFile(1)
127 pascal16 DeleteMetaFile(word) DeleteMetaFile(1)
128 pascal MulDiv(s_word s_word s_word) MulDiv(1 2 3)
129 pascal SaveVisRgn(word) SaveVisRgn(1)
130 pascal RestoreVisRgn(word) RestoreVisRgn(1)
131 pascal InquireVisRgn(word) InquireVisRgn(1)
132 pascal SetEnvironment(ptr ptr word) SetEnvironment(1 2 3)
133 pascal GetEnvironment(ptr ptr word) GetEnvironment(1 2 3)
134 pascal GetRgnBox(word ptr) GetRgnBox(1 2)
129 pascal16 SaveVisRgn(word) SaveVisRgn(1)
130 pascal16 RestoreVisRgn(word) RestoreVisRgn(1)
131 pascal16 InquireVisRgn(word) InquireVisRgn(1)
132 pascal16 SetEnvironment(ptr ptr word) SetEnvironment(1 2 3)
133 pascal16 GetEnvironment(ptr ptr word) GetEnvironment(1 2 3)
134 pascal16 GetRgnBox(word ptr) GetRgnBox(1 2)
#135 pascal ScanLr
#136 pascal RemoveFontResource
148 pascal SetBrushOrg(word s_word s_word) SetBrushOrg(1 2 3)
149 pascal GetBrushOrg(word) GetBrushOrg(1)
150 pascal UnrealizeObject(word) UnrealizeObject(1)
150 pascal16 UnrealizeObject(word) UnrealizeObject(1)
#151 pascal CopyMetaFile
153 pascal CreateIC(ptr ptr ptr ptr) CreateIC(1 2 3 4)
153 pascal16 CreateIC(ptr ptr ptr ptr) CreateIC(1 2 3 4)
154 pascal GetNearestColor(word long) GetNearestColor(1 2)
#155 pascal QueryAbort
156 pascal CreateDiscardableBitmap(word word word)
CreateDiscardableBitmap(1 2 3)
156 pascal16 CreateDiscardableBitmap(word word word)
CreateDiscardableBitmap(1 2 3)
#159 pascal GetMetaFileBits
#160 pascal SetMetaFileBits
161 pascal PtInRegion(word s_word s_word) PtInRegion(1 2 3)
161 pascal16 PtInRegion(word s_word s_word) PtInRegion(1 2 3)
162 pascal GetBitmapDimension(word) GetBitmapDimension(1)
163 pascal SetBitmapDimension(word s_word s_word) SetBitmapDimension(1 2 3)
#169 pascal IsDCDirty
#170 pascal SetDCStatus
172 pascal SetRectRgn(word s_word s_word s_word s_word) SetRectRgn(1 2 3 4 5)
173 pascal GetClipRgn(word) GetClipRgn(1)
172 pascal16 SetRectRgn(word s_word s_word s_word s_word) SetRectRgn(1 2 3 4 5)
173 pascal16 GetClipRgn(word) GetClipRgn(1)
#175 pascal EnumMetaFile
176 pascal PlayMetaFileRecord(word ptr ptr word) PlayMetaFileRecord(1 2 3 4)
179 pascal GetDCState(word) GetDCState(1)
180 pascal SetDCState(word word) SetDCState(1 2)
181 pascal RectInRegionOld(word ptr) RectInRegion(1 2)
176 pascal16 PlayMetaFileRecord(word ptr ptr word) PlayMetaFileRecord(1 2 3 4)
179 pascal16 GetDCState(word) GetDCState(1)
180 pascal16 SetDCState(word word) SetDCState(1 2)
181 pascal16 RectInRegionOld(word ptr) RectInRegion(1 2)
#190 pascal SetDCHook
#191 pascal GetDCHook
#192 pascal SetHookFlags
@ -203,7 +203,7 @@ length 490
#246 pascal STARTSPOOLPAGE
#247 pascal ENDSPOOLPAGE
#248 pascal QUERYJOB
250 pascal Copy(ptr ptr word) Copy(1 2 3)
250 pascal16 Copy(ptr ptr word) Copy(1 2 3)
#253 pascal DeleteSpoolPage
#254 pascal SpoolFile
#300 pascal ENGINEENUMERATEFONT
@ -221,31 +221,32 @@ length 490
#312 pascal CONVERTOUTLINEFONTFILE
#313 pascal GETRASTERIZERCAPS
#314 pascal ENGINEEXTTEXTOUT
330 pascal EnumFontFamilies(word ptr ptr ptr) EnumFontFamilies(1 2 3 4)
330 pascal16 EnumFontFamilies(word ptr ptr ptr) EnumFontFamilies(1 2 3 4)
#332 pascal GETKERNINGPAIRS
345 pascal GetTextAlign(word) GetTextAlign(1)
346 pascal SetTextAlign(word word) SetTextAlign(1 2)
348 pascal Chord(word s_word s_word s_word s_word s_word s_word s_word s_word)
Chord(1 2 3 4 5 6 7 8 9)
345 pascal16 GetTextAlign(word) GetTextAlign(1)
346 pascal16 SetTextAlign(word word) SetTextAlign(1 2)
348 pascal16 Chord(word s_word s_word s_word s_word s_word s_word s_word s_word)
Chord(1 2 3 4 5 6 7 8 9)
349 pascal SetMapperFlags(word word) SetMapperFlags(1 2)
350 pascal GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4)
351 pascal ExtTextOut(word s_word s_word word ptr ptr s_word ptr)
ExtTextOut(1 2 3 4 5 6 7 8)
350 pascal16 GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4)
351 pascal16 ExtTextOut(word s_word s_word word ptr ptr s_word ptr)
ExtTextOut(1 2 3 4 5 6 7 8)
#352 pascal GETPHYSICALFONTHANDLE
#353 pascal GETASPECTRATIOFILTER
#354 pascal SHRINKGDIHEAP
360 pascal CreatePalette(ptr) CreatePalette(1)
361 pascal GDISelectPalette(word word) GDISelectPalette(1 2)
362 pascal GDIRealizePalette(word) GDIRealizePalette(1)
363 pascal GetPaletteEntries(word word word ptr) GetPaletteEntries(1 2 3 4)
364 pascal SetPaletteEntries(word word word ptr) SetPaletteEntries(1 2 3 4)
365 pascal RealizeDefaultPalette(word) RealizeDefaultPalette(1)
360 pascal16 CreatePalette(ptr) CreatePalette(1)
361 pascal16 GDISelectPalette(word word) GDISelectPalette(1 2)
362 pascal16 GDIRealizePalette(word) GDIRealizePalette(1)
363 pascal16 GetPaletteEntries(word word word ptr) GetPaletteEntries(1 2 3 4)
364 pascal16 SetPaletteEntries(word word word ptr) SetPaletteEntries(1 2 3 4)
365 pascal16 RealizeDefaultPalette(word) RealizeDefaultPalette(1)
#366 pascal UPDATECOLORS
#367 pascal ANIMATEPALETTE
#368 pascal RESIZEPALETTE
370 pascal GetNearestPaletteIndex(word long) GetNearestPaletteIndex(1 2)
375 pascal GetSystemPaletteEntries(word word word ptr)
GetSystemPaletteEntries(1 2 3 4)
370 pascal16 GetNearestPaletteIndex(word long) GetNearestPaletteIndex(1 2)
372 pascal16 ExtFloodFill(word s_word s_word long word) ExtFloodFill(1 2 3 4)
375 pascal16 GetSystemPaletteEntries(word word word ptr)
GetSystemPaletteEntries(1 2 3 4)
#376 pascal RESETDC
#377 pascal STARTDOC
#378 pascal ENDDOC
@ -260,51 +261,53 @@ length 490
#407 pascal CREATEUSERBITMAP
#409 pascal CREATEUSERDISCARDABLEBITMAP
#410 pascal ISVALIDMETAFILE
411 pascal GetCurLogFont(word) GetCurLogFont(1)
411 pascal16 GetCurLogFont(word) GetCurLogFont(1)
#412 pascal ISDCCURRENTPALETTE
#439 pascal STRETCHDIBITS
440 pascal SetDIBits(word word word word ptr ptr word) SetDIBits(1 2 3 4 5 6 7)
441 pascal GetDIBits(word word word word ptr ptr word) GetDIBits(1 2 3 4 5 6 7)
442 pascal CreateDIBitmap(word ptr long ptr ptr word)
CreateDIBitmap(1 2 3 4 5 6)
443 pascal SetDIBitsToDevice(word s_word s_word word word word word word word ptr ptr word)
SetDIBitsToDevice(1 2 3 4 5 6 7 8 9 10 11 12)
444 pascal CreateRoundRectRgn(s_word s_word s_word s_word s_word s_word)
CreateRoundRectRgn(1 2 3 4 5 6)
445 pascal CreateDIBPatternBrush(word word) CreateDIBPatternBrush(1 2)
440 pascal16 SetDIBits(word word word word ptr ptr word) SetDIBits(1 2 3 4 5 6 7)
441 pascal16 GetDIBits(word word word word ptr ptr word) GetDIBits(1 2 3 4 5 6 7)
442 pascal16 CreateDIBitmap(word ptr long ptr ptr word)
CreateDIBitmap(1 2 3 4 5 6)
443 pascal16 SetDIBitsToDevice(word s_word s_word word word word word word
word ptr ptr word)
SetDIBitsToDevice(1 2 3 4 5 6 7 8 9 10 11 12)
444 pascal16 CreateRoundRectRgn(s_word s_word s_word s_word s_word s_word)
CreateRoundRectRgn(1 2 3 4 5 6)
445 pascal16 CreateDIBPatternBrush(word word) CreateDIBPatternBrush(1 2)
#449 pascal DEVICECOLORMATCH
450 pascal PolyPolygon(word ptr ptr word) PolyPolygon(1 2 3 4)
451 pascal CreatePolyPolygonRgn(ptr ptr word word)
CreatePolyPolygonRgn(1 2 3 4)
450 pascal16 PolyPolygon(word ptr ptr word) PolyPolygon(1 2 3 4)
451 pascal16 CreatePolyPolygonRgn(ptr ptr word word)
CreatePolyPolygonRgn(1 2 3 4)
#452 pascal GDISEEGDIDO
#460 pascal GDITASKTERMINATION
461 return SetObjectOwner 4 0
462 pascal IsGDIObject(word) IsGDIObject(1)
462 pascal16 IsGDIObject(word) IsGDIObject(1)
#463 pascal MAKEOBJECTPRIVATE
#464 pascal FIXUPBOGUSPUBLISHERMETAFILE
465 pascal RectVisible(word ptr) RectVisible(1 2)
466 pascal RectInRegion(word ptr) RectInRegion(1 2)
465 pascal16 RectVisible(word ptr) RectVisible(1 2)
466 pascal16 RectInRegion(word ptr) RectInRegion(1 2)
#467 pascal UNICODETOANSI
468 pascal GetBitmapDimensionEx(word ptr) GetBitmapDimensionEx(1 2)
469 pascal GetBrushOrgEx(word ptr) GetBrushOrgEx(1 2)
470 pascal GetCurrentPositionEx(word ptr) GetCurrentPositionEx(1 2)
471 pascal GetTextExtentPoint(word ptr s_word ptr) GetTextExtentPoint(1 2 3 4)
472 pascal GetViewportExtEx(word ptr) GetViewportExtEx(1 2)
473 pascal GetViewportOrgEx(word ptr) GetViewportOrgEx(1 2)
474 pascal GetWindowExtEx(word ptr) GetWindowExtEx(1 2)
475 pascal GetWindowOrgEx(word ptr) GetWindowOrgEx(1 2)
476 pascal OffsetViewportOrgEx(word s_word s_word ptr)
OffsetViewportOrgEx(1 2 3 4)
477 pascal OffsetWindowOrgEx(word s_word s_word ptr) OffsetWindowOrgEx(1 2 3 4)
478 pascal SetBitmapDimensionEx(word s_word s_word ptr)
SetBitmapDimensionEx(1 2 3 4)
479 pascal SetViewportExtEx(word s_word s_word ptr) SetViewportExtEx(1 2 3 4)
480 pascal SetViewportOrgEx(word s_word s_word ptr) SetViewportOrgEx(1 2 3 4)
481 pascal SetWindowExtEx(word s_word s_word ptr) SetWindowExtEx(1 2 3 4)
482 pascal SetWindowOrgEx(word s_word s_word ptr) SetWindowOrgEx(1 2 3 4)
483 pascal MoveToEx(word s_word s_word ptr) MoveToEx(1 2 3 4)
484 pascal ScaleViewportExtEx(word s_word s_word s_word s_word ptr)
ScaleViewportExtEx(1 2 3 4 5 6)
485 pascal ScaleWindowExtEx(word s_word s_word s_word s_word ptr)
ScaleWindowExtEx(1 2 3 4 5 6)
468 pascal16 GetBitmapDimensionEx(word ptr) GetBitmapDimensionEx(1 2)
469 pascal16 GetBrushOrgEx(word ptr) GetBrushOrgEx(1 2)
470 pascal16 GetCurrentPositionEx(word ptr) GetCurrentPositionEx(1 2)
471 pascal16 GetTextExtentPoint(word ptr s_word ptr) GetTextExtentPoint(1 2 3 4)
472 pascal16 GetViewportExtEx(word ptr) GetViewportExtEx(1 2)
473 pascal16 GetViewportOrgEx(word ptr) GetViewportOrgEx(1 2)
474 pascal16 GetWindowExtEx(word ptr) GetWindowExtEx(1 2)
475 pascal16 GetWindowOrgEx(word ptr) GetWindowOrgEx(1 2)
476 pascal16 OffsetViewportOrgEx(word s_word s_word ptr)
OffsetViewportOrgEx(1 2 3 4)
477 pascal16 OffsetWindowOrgEx(word s_word s_word ptr)
OffsetWindowOrgEx(1 2 3 4)
478 pascal16 SetBitmapDimensionEx(word s_word s_word ptr)
SetBitmapDimensionEx(1 2 3 4)
479 pascal16 SetViewportExtEx(word s_word s_word ptr) SetViewportExtEx(1 2 3 4)
480 pascal16 SetViewportOrgEx(word s_word s_word ptr) SetViewportOrgEx(1 2 3 4)
481 pascal16 SetWindowExtEx(word s_word s_word ptr) SetWindowExtEx(1 2 3 4)
482 pascal16 SetWindowOrgEx(word s_word s_word ptr) SetWindowOrgEx(1 2 3 4)
483 pascal16 MoveToEx(word s_word s_word ptr) MoveToEx(1 2 3 4)
484 pascal16 ScaleViewportExtEx(word s_word s_word s_word s_word ptr)
ScaleViewportExtEx(1 2 3 4 5 6)
485 pascal16 ScaleWindowExtEx(word s_word s_word s_word s_word ptr)
ScaleWindowExtEx(1 2 3 4 5 6)
#486 pascal GETASPECTRATIOFILEREX

View File

@ -93,7 +93,7 @@ length 415
word word word word word)
KERNEL_InitTask()
92 pascal16 GetTempDrive(byte) GetTempDrive(1)
#93 pascal16 GETCODEHANDLE
93 pascal16 GetCodeHandle(ptr) GetCodeHandle(1)
#94 DEFINEHANDLETABLE
95 pascal16 LoadLibrary(ptr) LoadLibrary(1)
96 pascal16 FreeLibrary(word) FreeLibrary(1)
@ -108,7 +108,7 @@ length 415
#103 NETBIOSCALL
#104 GETCODEINFO
#105 GETEXEVERSION
#106 SETSWAPAREASIZE
106 pascal SetSwapAreaSize(word) SetSwapAreaSize(1)
107 pascal SetErrorMode(word) SetErrorMode(1)
#108 SWITCHSTACKTO
#109 SWITCHSTACKBACK
@ -135,7 +135,7 @@ length 415
GetPrivateProfileString(1 2 3 4 5 6)
129 pascal16 WritePrivateProfileString(ptr ptr ptr ptr)
WritePrivateProfileString(1 2 3 4)
#130 FILECBR
130 pascal FileCDR(ptr) FileCDR(1)
131 pascal GetDOSEnvironment() GetDOSEnvironment()
132 pascal GetWinFlags() GetWinFlags()
#133 GETEXEPTR

View File

@ -110,12 +110,12 @@ DLLRelay(unsigned int func_num, unsigned int seg_off)
unsigned short *stack_p;
ret_addr = (unsigned int *) ((char *) seg_off + 0x14);
printf("Calling %s (%s.%d), 16-bit stack at %04x:%04x, ",
printf("Call %s (%s.%d), stack=%04x:%04x, ",
dll_p->export_name,
dll_builtin_table[dll_id].dll_name, ordinal,
seg_off >> 16, seg_off & 0xffff);
printf("return to %08x\n", *ret_addr);
printf(" ESP %08x, EBP %08x, SS %04x\n",
printf("ret=%08x", *ret_addr);
printf(" ESP=%08x, EBP=%08x, SS=%04x\n",
IF1632_Saved16_esp, IF1632_Saved16_ebp,
IF1632_Saved16_ss);

View File

@ -270,9 +270,10 @@ length 540
256 pascal GetDriverInfo(word ptr) GetDriverInfo(1 2)
257 pascal GetNextDriver(word long) GetNextDriver(1 2)
258 pascal MapWindowPoints(word word ptr word) MapWindowPoints(1 2 3 4)
#259 BEGINDEFERWINDOWPOS
#260 DEFERWINDOWPOS
#261 ENDDEFERWINDOWPOS
259 pascal16 BeginDeferWindowPos(s_word) BeginDeferWindowPos(1)
260 pascal16 DeferWindowPos(word word word s_word s_word s_word s_word word)
DeferWindowPos(1 2 3 4 5 6 7 8)
261 pascal16 EndDeferWindowPos(word) EndDeferWindowPos(1)
262 pascal GetWindow(word word) GetWindow(1 2)
263 pascal GetMenuItemCount(word) GetMenuItemCount(1)
264 pascal GetMenuItemID(word word) GetMenuItemID(1 2)

View File

@ -33,6 +33,4 @@ AllTarget()
depend::
CleanTarget()
includes::

View File

@ -10,9 +10,6 @@
#include <X11/Xlib.h>
#include "windows.h"
/* Handle of the bitmap selected by default in a memory DC */
extern HBITMAP BITMAP_hbitmapMemDC;
/* GCs used for B&W and color bitmap operations */
extern GC BITMAP_monoGC, BITMAP_colorGC;

33
include/button.h Normal file
View File

@ -0,0 +1,33 @@
/*
* Button-class extra info
*
* Copyright 1994 Alexandre Julliard
*/
#ifndef BUTTON_H
#define BUTTON_H
#include "windows.h"
/* Extra info for BUTTON windows */
/* Note: under MS-Windows, state is a BYTE and this structure is */
/* only 3 bytes long. I don't think there are programs out there */
/* broken enough to rely on this :-) */
typedef struct
{
WORD state; /* Current state */
HFONT hFont; /* Button font (or 0 for system font) */
} BUTTONINFO;
/* Button state values */
#define BUTTON_UNCHECKED 0x00
#define BUTTON_CHECKED 0x01
#define BUTTON_3STATE 0x02
#define BUTTON_HIGHLIGHTED 0x04
#define BUTTON_HASFOCUS 0x08
#define BUTTON_STATE(hwnd) ((WIN_FindWndPtr(hwnd))->wExtra[0])
extern LONG ButtonWndProc( HWND hWnd, WORD uMsg, WORD wParam, LONG lParam );
#endif /* BUTTON_H */

916
include/debug.h Normal file
View File

@ -0,0 +1,916 @@
#include <stdio.h>
#define stddeb stdout
#define stdnimp stderr
# /* Do not remove this line or change anything below this line */
#ifdef DEBUG_NONE_EXT
#undef DEBUG_ACCEL
#undef DEBUG_BITMAP
#undef DEBUG_CARET
#undef DEBUG_CDAUDIO
#undef DEBUG_CLASS
#undef DEBUG_CLIPBOARD
#undef DEBUG_CLIPPING
#undef DEBUG_COMBO
#undef DEBUG_COMM
#undef DEBUG_CURSOR
#undef DEBUG_DC
#undef DEBUG_DIALOG
#undef DEBUG_DLL
#undef DEBUG_DOSFS
#undef DEBUG_DRIVER
#undef DEBUG_EDIT
#undef DEBUG_ENUM
#undef DEBUG_EVENT
#undef DEBUG_EXEC
#undef DEBUG_FILE
#undef DEBUG_FIXUP
#undef DEBUG_FONT
#undef DEBUG_GDI
#undef DEBUG_GRAPHICS
#undef DEBUG_HEAP
#undef DEBUG_ICON
#undef DEBUG_INT
#undef DEBUG_KEY
#undef DEBUG_KEYBOARD
#undef DEBUG_LDT
#undef DEBUG_LISTBOX
#undef DEBUG_MCIWAVE
#undef DEBUG_MDI
#undef DEBUG_MENU
#undef DEBUG_MENUCALC
#undef DEBUG_MESSAGE
#undef DEBUG_METAFILE
#undef DEBUG_MODULE
#undef DEBUG_MSG
#undef DEBUG_NONCLIENT
#undef DEBUG_PALETTE
#undef DEBUG_REGION
#undef DEBUG_RESOURCE
#undef DEBUG_SCROLL
#undef DEBUG_SYSCOLOR
#undef DEBUG_TEXT
#undef DEBUG_TIMER
#undef DEBUG_UTILITY
#undef DEBUG_WIN
#endif
#ifdef DEBUG_ALL_EXT
#define DEBUG_ACCEL
#define DEBUG_BITMAP
#define DEBUG_CARET
#define DEBUG_CDAUDIO
#define DEBUG_CLASS
#define DEBUG_CLIPBOARD
#define DEBUG_CLIPPING
#define DEBUG_COMBO
#define DEBUG_COMM
#define DEBUG_CURSOR
#define DEBUG_DC
#define DEBUG_DIALOG
#define DEBUG_DLL
#define DEBUG_DOSFS
#define DEBUG_DRIVER
#define DEBUG_EDIT
#define DEBUG_ENUM
#define DEBUG_EVENT
#define DEBUG_EXEC
#define DEBUG_FILE
#define DEBUG_FIXUP
#define DEBUG_FONT
#define DEBUG_GDI
#define DEBUG_GRAPHICS
#define DEBUG_HEAP
#define DEBUG_ICON
#define DEBUG_INT
#define DEBUG_KEY
#define DEBUG_KEYBOARD
#define DEBUG_LDT
#define DEBUG_LISTBOX
#define DEBUG_MCIWAVE
#define DEBUG_MDI
#define DEBUG_MENU
#define DEBUG_MENUCALC
#define DEBUG_MESSAGE
#define DEBUG_METAFILE
#define DEBUG_MODULE
#define DEBUG_MSG
#define DEBUG_NONCLIENT
#define DEBUG_PALETTE
#define DEBUG_REGION
#define DEBUG_RESOURCE
#define DEBUG_SCROLL
#define DEBUG_SYSCOLOR
#define DEBUG_TEXT
#define DEBUG_TIMER
#define DEBUG_UTILITY
#define DEBUG_WIN
#endif
#ifdef DEBUG_RUNTIME
#ifdef DEBUG_DEFINE_VARIABLES
short debug_msg_enabled[]={
#ifdef DEBUG_ACCEL
1,
#else
0,
#endif
#ifdef DEBUG_BITMAP
1,
#else
0,
#endif
#ifdef DEBUG_CARET
1,
#else
0,
#endif
#ifdef DEBUG_CDAUDIO
1,
#else
0,
#endif
#ifdef DEBUG_CLASS
1,
#else
0,
#endif
#ifdef DEBUG_CLIPBOARD
1,
#else
0,
#endif
#ifdef DEBUG_CLIPPING
1,
#else
0,
#endif
#ifdef DEBUG_COMBO
1,
#else
0,
#endif
#ifdef DEBUG_COMM
1,
#else
0,
#endif
#ifdef DEBUG_CURSOR
1,
#else
0,
#endif
#ifdef DEBUG_DC
1,
#else
0,
#endif
#ifdef DEBUG_DIALOG
1,
#else
0,
#endif
#ifdef DEBUG_DLL
1,
#else
0,
#endif
#ifdef DEBUG_DOSFS
1,
#else
0,
#endif
#ifdef DEBUG_DRIVER
1,
#else
0,
#endif
#ifdef DEBUG_EDIT
1,
#else
0,
#endif
#ifdef DEBUG_ENUM
1,
#else
0,
#endif
#ifdef DEBUG_EVENT
1,
#else
0,
#endif
#ifdef DEBUG_EXEC
1,
#else
0,
#endif
#ifdef DEBUG_FILE
1,
#else
0,
#endif
#ifdef DEBUG_FIXUP
1,
#else
0,
#endif
#ifdef DEBUG_FONT
1,
#else
0,
#endif
#ifdef DEBUG_GDI
1,
#else
0,
#endif
#ifdef DEBUG_GRAPHICS
1,
#else
0,
#endif
#ifdef DEBUG_HEAP
1,
#else
0,
#endif
#ifdef DEBUG_ICON
1,
#else
0,
#endif
#ifdef DEBUG_INT
1,
#else
0,
#endif
#ifdef DEBUG_KEY
1,
#else
0,
#endif
#ifdef DEBUG_KEYBOARD
1,
#else
0,
#endif
#ifdef DEBUG_LDT
1,
#else
0,
#endif
#ifdef DEBUG_LISTBOX
1,
#else
0,
#endif
#ifdef DEBUG_MCIWAVE
1,
#else
0,
#endif
#ifdef DEBUG_MDI
1,
#else
0,
#endif
#ifdef DEBUG_MENU
1,
#else
0,
#endif
#ifdef DEBUG_MENUCALC
1,
#else
0,
#endif
#ifdef DEBUG_MESSAGE
1,
#else
0,
#endif
#ifdef DEBUG_METAFILE
1,
#else
0,
#endif
#ifdef DEBUG_MODULE
1,
#else
0,
#endif
#ifdef DEBUG_MSG
1,
#else
0,
#endif
#ifdef DEBUG_NONCLIENT
1,
#else
0,
#endif
#ifdef DEBUG_PALETTE
1,
#else
0,
#endif
#ifdef DEBUG_REGION
1,
#else
0,
#endif
#ifdef DEBUG_RESOURCE
1,
#else
0,
#endif
#ifdef DEBUG_SCROLL
1,
#else
0,
#endif
#ifdef DEBUG_SYSCOLOR
1,
#else
0,
#endif
#ifdef DEBUG_TEXT
1,
#else
0,
#endif
#ifdef DEBUG_TIMER
1,
#else
0,
#endif
#ifdef DEBUG_UTILITY
1,
#else
0,
#endif
#ifdef DEBUG_WIN
1,
#else
0,
#endif
0};
#else
extern short debug_msg_enabled[];
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_accel if(debug_msg_enabled[0]) fprintf
#else
#ifdef DEBUG_ACCEL
#define dprintf_accel fprintf
#else
#define dprintf_accel
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_bitmap if(debug_msg_enabled[1]) fprintf
#else
#ifdef DEBUG_BITMAP
#define dprintf_bitmap fprintf
#else
#define dprintf_bitmap
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_caret if(debug_msg_enabled[2]) fprintf
#else
#ifdef DEBUG_CARET
#define dprintf_caret fprintf
#else
#define dprintf_caret
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_cdaudio if(debug_msg_enabled[3]) fprintf
#else
#ifdef DEBUG_CDAUDIO
#define dprintf_cdaudio fprintf
#else
#define dprintf_cdaudio
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_class if(debug_msg_enabled[4]) fprintf
#else
#ifdef DEBUG_CLASS
#define dprintf_class fprintf
#else
#define dprintf_class
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_clipboard if(debug_msg_enabled[5]) fprintf
#else
#ifdef DEBUG_CLIPBOARD
#define dprintf_clipboard fprintf
#else
#define dprintf_clipboard
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_clipping if(debug_msg_enabled[6]) fprintf
#else
#ifdef DEBUG_CLIPPING
#define dprintf_clipping fprintf
#else
#define dprintf_clipping
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_combo if(debug_msg_enabled[7]) fprintf
#else
#ifdef DEBUG_COMBO
#define dprintf_combo fprintf
#else
#define dprintf_combo
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_comm if(debug_msg_enabled[8]) fprintf
#else
#ifdef DEBUG_COMM
#define dprintf_comm fprintf
#else
#define dprintf_comm
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_cursor if(debug_msg_enabled[9]) fprintf
#else
#ifdef DEBUG_CURSOR
#define dprintf_cursor fprintf
#else
#define dprintf_cursor
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_dc if(debug_msg_enabled[10]) fprintf
#else
#ifdef DEBUG_DC
#define dprintf_dc fprintf
#else
#define dprintf_dc
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_dialog if(debug_msg_enabled[11]) fprintf
#else
#ifdef DEBUG_DIALOG
#define dprintf_dialog fprintf
#else
#define dprintf_dialog
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_dll if(debug_msg_enabled[12]) fprintf
#else
#ifdef DEBUG_DLL
#define dprintf_dll fprintf
#else
#define dprintf_dll
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_dosfs if(debug_msg_enabled[13]) fprintf
#else
#ifdef DEBUG_DOSFS
#define dprintf_dosfs fprintf
#else
#define dprintf_dosfs
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_driver if(debug_msg_enabled[14]) fprintf
#else
#ifdef DEBUG_DRIVER
#define dprintf_driver fprintf
#else
#define dprintf_driver
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_edit if(debug_msg_enabled[15]) fprintf
#else
#ifdef DEBUG_EDIT
#define dprintf_edit fprintf
#else
#define dprintf_edit
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_enum if(debug_msg_enabled[16]) fprintf
#else
#ifdef DEBUG_ENUM
#define dprintf_enum fprintf
#else
#define dprintf_enum
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_event if(debug_msg_enabled[17]) fprintf
#else
#ifdef DEBUG_EVENT
#define dprintf_event fprintf
#else
#define dprintf_event
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_exec if(debug_msg_enabled[18]) fprintf
#else
#ifdef DEBUG_EXEC
#define dprintf_exec fprintf
#else
#define dprintf_exec
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_file if(debug_msg_enabled[19]) fprintf
#else
#ifdef DEBUG_FILE
#define dprintf_file fprintf
#else
#define dprintf_file
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_fixup if(debug_msg_enabled[20]) fprintf
#else
#ifdef DEBUG_FIXUP
#define dprintf_fixup fprintf
#else
#define dprintf_fixup
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_font if(debug_msg_enabled[21]) fprintf
#else
#ifdef DEBUG_FONT
#define dprintf_font fprintf
#else
#define dprintf_font
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_gdi if(debug_msg_enabled[22]) fprintf
#else
#ifdef DEBUG_GDI
#define dprintf_gdi fprintf
#else
#define dprintf_gdi
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_graphics if(debug_msg_enabled[23]) fprintf
#else
#ifdef DEBUG_GRAPHICS
#define dprintf_graphics fprintf
#else
#define dprintf_graphics
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_heap if(debug_msg_enabled[24]) fprintf
#else
#ifdef DEBUG_HEAP
#define dprintf_heap fprintf
#else
#define dprintf_heap
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_icon if(debug_msg_enabled[25]) fprintf
#else
#ifdef DEBUG_ICON
#define dprintf_icon fprintf
#else
#define dprintf_icon
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_int if(debug_msg_enabled[26]) fprintf
#else
#ifdef DEBUG_INT
#define dprintf_int fprintf
#else
#define dprintf_int
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_key if(debug_msg_enabled[27]) fprintf
#else
#ifdef DEBUG_KEY
#define dprintf_key fprintf
#else
#define dprintf_key
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_keyboard if(debug_msg_enabled[28]) fprintf
#else
#ifdef DEBUG_KEYBOARD
#define dprintf_keyboard fprintf
#else
#define dprintf_keyboard
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_ldt if(debug_msg_enabled[29]) fprintf
#else
#ifdef DEBUG_LDT
#define dprintf_ldt fprintf
#else
#define dprintf_ldt
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_listbox if(debug_msg_enabled[30]) fprintf
#else
#ifdef DEBUG_LISTBOX
#define dprintf_listbox fprintf
#else
#define dprintf_listbox
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_mciwave if(debug_msg_enabled[31]) fprintf
#else
#ifdef DEBUG_MCIWAVE
#define dprintf_mciwave fprintf
#else
#define dprintf_mciwave
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_mdi if(debug_msg_enabled[32]) fprintf
#else
#ifdef DEBUG_MDI
#define dprintf_mdi fprintf
#else
#define dprintf_mdi
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_menu if(debug_msg_enabled[33]) fprintf
#else
#ifdef DEBUG_MENU
#define dprintf_menu fprintf
#else
#define dprintf_menu
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_menucalc if(debug_msg_enabled[34]) fprintf
#else
#ifdef DEBUG_MENUCALC
#define dprintf_menucalc fprintf
#else
#define dprintf_menucalc
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_message if(debug_msg_enabled[35]) fprintf
#else
#ifdef DEBUG_MESSAGE
#define dprintf_message fprintf
#else
#define dprintf_message
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_metafile if(debug_msg_enabled[36]) fprintf
#else
#ifdef DEBUG_METAFILE
#define dprintf_metafile fprintf
#else
#define dprintf_metafile
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_module if(debug_msg_enabled[37]) fprintf
#else
#ifdef DEBUG_MODULE
#define dprintf_module fprintf
#else
#define dprintf_module
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_msg if(debug_msg_enabled[38]) fprintf
#else
#ifdef DEBUG_MSG
#define dprintf_msg fprintf
#else
#define dprintf_msg
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_nonclient if(debug_msg_enabled[39]) fprintf
#else
#ifdef DEBUG_NONCLIENT
#define dprintf_nonclient fprintf
#else
#define dprintf_nonclient
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_palette if(debug_msg_enabled[40]) fprintf
#else
#ifdef DEBUG_PALETTE
#define dprintf_palette fprintf
#else
#define dprintf_palette
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_region if(debug_msg_enabled[41]) fprintf
#else
#ifdef DEBUG_REGION
#define dprintf_region fprintf
#else
#define dprintf_region
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_resource if(debug_msg_enabled[42]) fprintf
#else
#ifdef DEBUG_RESOURCE
#define dprintf_resource fprintf
#else
#define dprintf_resource
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_scroll if(debug_msg_enabled[43]) fprintf
#else
#ifdef DEBUG_SCROLL
#define dprintf_scroll fprintf
#else
#define dprintf_scroll
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_syscolor if(debug_msg_enabled[44]) fprintf
#else
#ifdef DEBUG_SYSCOLOR
#define dprintf_syscolor fprintf
#else
#define dprintf_syscolor
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_text if(debug_msg_enabled[45]) fprintf
#else
#ifdef DEBUG_TEXT
#define dprintf_text fprintf
#else
#define dprintf_text
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_timer if(debug_msg_enabled[46]) fprintf
#else
#ifdef DEBUG_TIMER
#define dprintf_timer fprintf
#else
#define dprintf_timer
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_utility if(debug_msg_enabled[47]) fprintf
#else
#ifdef DEBUG_UTILITY
#define dprintf_utility fprintf
#else
#define dprintf_utility
#endif
#endif
#ifdef DEBUG_RUNTIME
#define dprintf_win if(debug_msg_enabled[48]) fprintf
#else
#ifdef DEBUG_WIN
#define dprintf_win fprintf
#else
#define dprintf_win
#endif
#endif
#ifdef DEBUG_RUNTIME
#ifdef DEBUG_DEFINE_VARIABLES
static char *debug_msg_name[] = {
"accel",
"bitmap",
"caret",
"cdaudio",
"class",
"clipboard",
"clipping",
"combo",
"comm",
"cursor",
"dc",
"dialog",
"dll",
"dosfs",
"driver",
"edit",
"enum",
"event",
"exec",
"file",
"fixup",
"font",
"gdi",
"graphics",
"heap",
"icon",
"int",
"key",
"keyboard",
"ldt",
"listbox",
"mciwave",
"mdi",
"menu",
"menucalc",
"message",
"metafile",
"module",
"msg",
"nonclient",
"palette",
"region",
"resource",
"scroll",
"syscolor",
"text",
"timer",
"utility",
"win",
""};
#endif
#endif

View File

@ -16,15 +16,15 @@
*/
typedef struct
{
LONG msgResult;
FARPROC dlgProc;
LONG userInfo;
HWND hwndFocus;
HFONT hUserFont;
HMENU hMenu;
WORD xBaseUnit;
LONG msgResult; /* Result of EndDialog() / Default button id */
WNDPROC dlgProc; /* Dialog procedure */
LONG userInfo; /* User information (for DWL_USER) */
HWND hwndFocus; /* Current control with focus */
HFONT hUserFont; /* Dialog font */
HMENU hMenu; /* Dialog menu */
WORD xBaseUnit; /* Dialog units (depends on the font) */
WORD yBaseUnit;
WORD fEnd;
WORD fEnd; /* EndDialog() called for this dialog */
HANDLE hDialogHeap;
} DIALOGINFO;

View File

@ -17,21 +17,36 @@ typedef struct resource_name_table
char id[MAX_NAME_LENGTH];
} RESNAMTAB;
struct ne_data {
struct ne_header_s *ne_header;
struct ne_segment_table_entry_s *seg_table;
struct segment_descriptor_s *selector_table;
char *lookup_table;
char *nrname_table;
char *rname_table;
RESNAMTAB *resnamtab;
};
struct pe_data {
struct pe_header_s *pe_header;
struct pe_segment_table *pe_seg;
struct PE_Import_Directory *pe_import;
struct PE_Export_Directory *pe_export;
struct PE_Resource_Directory *pe_resource;
int resource_offset; /* offset to resource typedirectory in file */
};
struct w_files
{
struct w_files * next;
char * name; /* Name, as it appears in the windows binaries */
char * filename; /* Actual name of the unix file that satisfies this */
int fd;
struct mz_header_s *mz_header;
struct ne_header_s *ne_header;
struct ne_segment_table_entry_s *seg_table;
struct segment_descriptor_s *selector_table;
char * lookup_table;
char * nrname_table;
char * rname_table;
unsigned short hinstance;
RESNAMTAB *resnamtab;
int initialised;
struct mz_header_s *mz_header;
struct ne_data *ne;
struct pe_data *pe;
};
extern struct w_files *wine_files;

View File

@ -302,7 +302,6 @@ extern HANDLE GDI_AllocObject( WORD, WORD );
extern BOOL GDI_FreeObject( HANDLE );
extern GDIOBJHDR * GDI_GetObjPtr( HANDLE, WORD );
extern Display * XT_display; /* Will be removed */
extern Display * display;
extern Screen * screen;
extern Window rootWindow;

View File

@ -15,7 +15,7 @@ typedef struct
{
HHOOK next; /* Next hook in chain */
HOOKPROC proc; /* Hook procedure */
short id; /* Hook id (WH_???) */
short id; /* Hook id (WH_xxx) */
HTASK htask; /* Task owning this hook */
} HOOKDATA;

View File

@ -7,6 +7,7 @@ typedef struct tagLISTSTRUCT {
DRAWITEMSTRUCT dis;
HANDLE hMem;
HANDLE hData;
char *itemText;
void *lpNext;
} LISTSTRUCT;
typedef LISTSTRUCT FAR* LPLISTSTRUCT;
@ -26,7 +27,7 @@ typedef struct tagHEADLIST {
void *lpFirst;
DWORD dwStyle;
HWND hWndLogicParent;
HFONT hFont;
HFONT hFont;
} HEADLIST;
typedef HEADLIST FAR* LPHEADLIST;

View File

@ -10,6 +10,7 @@ struct dosdirent {
char filename[256];
char filemask[12];
char attribute;
char search_attribute;
long filesize;
long filetime;
};

214
include/peexe.h Normal file
View File

@ -0,0 +1,214 @@
/*
* Copyright Eric Youngdale (1994)
*/
#ifndef __WINE_PEEXE_H
#define __WINE_PEEXE_H
struct coff_header
{
u_short Machine;
u_short NumberOfSections;
u_long TimeDateStamp;
u_long PointerToSymbolTable;
u_long NumberOfSymbols;
u_short SizeOfOptionalHeader;
u_short Characteristics;
};
/* These defines describe the meanings of the bits in the Characteristics
field */
#define IMAGE_FILE_RELOCS_STRIPPED 1 /* No relocation info */
#define IMAGE_FILE_EXECUTABLE_IMAGE 2
#define IMAGE_FILE_LINE_NUMS_STRIPPED 4
#define IMAGE_FILE_LOCAL_SYMS_STRIPPED 8
#define IMAGE_FILE_16BIT_MACHINE 0x40
#define IMAGE_FILE_BYTES_REVERSED_LO 0x80
#define IMAGE_FILE_32BIT_MACHINE 0x100
#define IMAGE_FILE_DEBUG_STRIPPED 0x200
#define IMAGE_FILE_SYSTEM 0x1000
#define IMAGE_FILE_DLL 0x2000
#define IMAGE_FILE_BYTES_REVERSED_HI 0x8000
/* These are the settings of the Machine field. */
#define IMAGE_FILE_MACHINE_UNKNOWN 0
#define IMAGE_FILE_MACHINE_I860 0x14d
#define IMAGE_FILE_MACHINE_I386 0x14c
#define IMAGE_FILE_MACHINE_R3000 0x162
#define IMAGE_FILE_MACHINE_R4000 0x166
#define IMAGE_FILE_MACHINE_ALPHA 0x184
struct Directory
{
u_long Virtual_address;
u_long Size;
};
/* Optional coff header - used by NT to provide additional information. */
struct ocoffhdr
{
u_short Magic; /* Good old COFF magic 0413 */
u_char MajorLinkerVersion;
u_char MinorLinkerVersion;
u_long SizeOfCode;
u_long SizeOfInitializedData;
u_long SizeOfUninitializedData;
u_long AddressOfEntryPoint;
u_long BaseOfCode;
u_long BaseOfData;
u_long BaseOfImage;
u_long SectionAlignment;
u_long FileAlignment;
u_short MajorOperatingSystemVersion;
u_short MinorOperatingSystemVersion;
u_short MajorImageVersion;
u_short MinorImageVersion;
u_short MajorSubsystemVersion;
u_short MinorSubsystemVersion;
u_long Unknown1;
u_long SizeOfImage;
u_long SizeOfHeaders;
u_long CheckSum;
u_short Subsystem;
u_short DllCharacteristics;
u_long SizeOfStackReserve;
u_long SizeOfStackCommit;
u_long SizeOfHeapReserve;
u_long SizeOfHeapCommit;
u_long LoaderFlags;
u_long NumberOfRvaAndSizes;
struct Directory DataDirectory[16];
};
/* These are indexes into the DataDirectory array */
#define IMAGE_FILE_EXPORT_DIRECTORY 0
#define IMAGE_FILE_IMPORT_DIRECTORY 1
#define IMAGE_FILE_RESOURCE_DIRECTORY 2
#define IMAGE_FILE_EXCEPTION_DIRECTORY 3
#define IMAGE_FILE_SECURITY_DIRECTORY 4
#define IMAGE_FILE_BASE_RELOCATION_TABLE 5
#define IMAGE_FILE_DEBUG_DIRECTORY 6
#define IMAGE_FILE_DESCRIPTION_STRING 7
#define IMAGE_FILE_MACHINE_VALUE 8 /* Mips */
#define IMAGE_FILE_THREAD_LOCAL_STORAGE 9
#define IMAGE_FILE_CALLBACK_DIRECTORY 10
struct pe_header_s
{
char magic[4]; /* Must be 'P', 'E', 0, 0 */
struct coff_header coff;
struct ocoffhdr opt_coff;
};
struct pe_segment_table
{
u_char Name[8];
u_long Virtual_Size;
u_long Virtual_Address;
u_long Size_Of_Raw_Data;
u_long PointerToRawData;
u_long PointerToRelocations;
u_long PointerToLinenumbers;
u_short NumberOfRelocations;
u_short NumberOfLinenumbers;
u_long Characteristics;
};
/* These defines are for the Characteristics bitfield. */
#define IMAGE_SCN_TYPE_CNT_CODE 0x20
#define IMAGE_SCN_TYPE_CNT_INITIALIZED_DATA 0x40
#define IMAGE_SCN_TYPE_CNT_UNINITIALIZED_DATA 0x80
#define IMAGE_SCN_MEM_DISCARDABLE 0x2000000
#define IMAGE_SCN_MEM_SHARED 0x10000000
#define IMAGE_SCN_MEM_EXECUTE 0x20000000
#define IMAGE_SCN_MEM_READ 0x40000000
#define IMAGE_SCN_MEM_WRITE 0x80000000
/*
* Import module directory stuff
*/
struct PE_Import_Directory
{
u_int Import_List;
u_int reserved[2];
u_int ModuleName;
u_int reserved1;
};
struct pe_import_name
{
u_short Hint;
u_char Name[1];
};
/*
* Export module directory stuff
*/
struct PE_Export_Directory
{
u_long Characteristics;
u_long TimeDateStamp;
u_short Major_version;
u_short Minor_version;
u_long Name;
u_long Base;
u_long Number_Of_Functions;
u_long Number_Of_Names;
u_long * AddressOfFunctions;
u_long * AddressOfNames;
u_short * Address_Of_Name_Ordinals;
};
/*
* Resource directory stuff
*/
struct PE_Resource_Directory
{
u_long Characteristics;
u_long TimeDateStamp;
u_short MajorVersion;
u_short MinorVersion;
u_short NumberOfNamedEntries;
u_short NumberOfIdEntries;
};
struct PE_Directory_Entry
{
u_long Name;
u_long OffsetToData;
};
struct PE_Directory_Name_String
{
u_short Length;
char NameString[1];
};
struct PE_Directory_Name_String_U
{
u_short Length;
u_short NameString[1];
};
struct PE_Resource_Leaf_Entry
{
u_long OffsetToData;
u_long Size;
u_long CodePage;
u_long Reserved;
};
#define IMAGE_RESOURCE_NAME_IS_STRING 0x80000000
#define IMAGE_RESOURCE_DATA_IS_DIRECTORY 0x80000000
#endif /* __WINE_PEEXE_H */

View File

@ -40,16 +40,6 @@ int set_ldt_entry(int entry, unsigned long base, unsigned int limit,
extern int OpenResourceFile(HANDLE instance);
extern HBITMAP ConvertCoreBitmap( HDC hdc, BITMAPCOREHEADER * image );
extern HBITMAP ConvertInfoBitmap( HDC hdc, BITMAPINFO * image );
extern int FindResourceByNumber(struct resource_nameinfo_s *result_p,
int type_id, int resource_id);
extern int FindResourceByName(struct resource_nameinfo_s *result_p,
int type_id, char *resource_name);
extern HICON LoadIcon(HANDLE instance, LPSTR icon_name);
extern HANDLE RSC_LoadResource(int instance, char *rsc_name, int type,
int *image_size_ret);
extern int LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen);
extern HANDLE RSC_LoadMenu(HANDLE instance, LPSTR menu_name);
extern HBITMAP LoadBitmap(HANDLE instance, LPSTR bmp_name);
/* loader/selector.c */

23
include/resource.h Normal file
View File

@ -0,0 +1,23 @@
#ifndef __WINE_RESOURCE_H
#define __WINE_RESOURCE_H
#include "dlls.h"
typedef struct resource_s {
struct resource_s *next;
HANDLE info_mem; /* this struct */
int size_shift;
struct resource_nameinfo_s nameinfo;
HANDLE rsc_mem; /* resource data */
/* */
HANDLE instance; /* resource instance */
LPSTR name; /* resource name */
LPSTR type; /* resource type */
int count; /* lock count */
int size; /* resource size */
int fd; /* fd */
int offset; /* offset */
struct w_files *wpnt;
} RESOURCE;
#endif /* __WINE_RESOURCE_H */

View File

@ -77,12 +77,6 @@ extern int IPCCopySelector(int i_old, unsigned long new, int swap_type);
#define FIRST_SELECTOR 8
static __inline__ int Is16bitAddress(void *address)
{
return ((unsigned int) address
>= (((FIRST_SELECTOR << 3) | 0x0007) << 16));
}
extern SEGDESC Segments[];
#endif /* SEGMEM_H */

22
include/static.h Normal file
View File

@ -0,0 +1,22 @@
/*
* Static-class extra info
*
* Copyright 1994 Alexandre Julliard
*/
#ifndef STATIC_H
#define STATIC_H
#include "windows.h"
/* Extra info for STATIC windows */
typedef struct
{
HFONT hFont; /* Control font (or 0 for system font) */
WORD dummy; /* Don't know what MS-Windows puts in there */
HICON hIcon; /* Icon handle for SS_ICON controls */
} STATICINFO;
extern LONG StaticWndProc( HWND hWnd, WORD uMsg, WORD wParam, LONG lParam );
#endif /* STATIC_H */

178
include/stddebug.h Normal file
View File

@ -0,0 +1,178 @@
/* If you define this you can enable or disable specific debugging- */
/* messages at run-time by supplying the "-debugmsg" option to Wine */
#define DEBUG_RUNTIME /* */
/* Define this if you want to enable all debugging-messages, except */
/* the ones explicitly disabled in a specific *.c-file. */
/* #define DEBUG_ALL */
/* Define this if you want to enable all debugging-messages, even */
/* the ones explicitly disabled in specific *.c-files. */
/* #define DEBUG_ALL_EXT */
/* Define this if you want to disable all debugging-messages, except */
/* the ones explicitly enabled in a specifiy *.c-file. */
/* #define DEBUG_NONE */
/* Define this if you want to disable all debugging-messages, even */
/* the ones explicitly enabled in specific *.c-files. */
/* #define DEBUG_NONE_EXT */
/* You can enable or disable specific debugging-messages here. */
/* However, this can be overridden in the individual *.c-files */
/* between #include <stddebug.h> and #include <debug.h> */
/* #define DEBUG_EDIT */
/* #define DEBUG_MENU */
/* #define DEBUG_MENUCALC */
/* #define DEBUG_SCROLL */
/* #define DEBUG_COMBO */
/* #define DEBUG_LISTBOX */
/* #define DEBUG_TASK */
/* #define DEBUG_SELECTORS */
/* #define DEBUG_RESOURCE */
/* #define DEBUG_ACCEL */
/* #define DEBUG_FIXUP */
/* #define DEBUG_MODULE */
/* #define DEBUG_LDT */
/* #define DEBUG_HEAP */
/* #define DEBUG_MCIWAVE */
/* #define DEBUG_MCIWAVE */
/* #define DEBUG_INT */
/* #define DEBUG_METAFILE */
/* #define DEBUG_GDI */
/* #define DEBUG_BITMAP */
/* #define DEBUG_FONT */
/* #define DEBUG_PALETTE */
/* #define DEBUG_ICON */
/* #define DEBUG_REGION */
/* #define DEBUG_TEXT */
/* #define DEBUG_CLIPPING */
/* #define DEBUG_CARET */
/* #define DEBUG_CLASS */
/* #define DEBUG_DC */
/* #define DEBUG_DIALOG */
/* #define DEBUG_MESSAGE */
/* #define DEBUG_EVENT */
/* #define DEBUG_KEY */
/* #define DEBUG_GRAPHICS */
/* #define DEBUG_MDI */
/* #define DEBUG_MSG */
/* #define DEBUG_NONCLIENT */
/* #define DEBUG_SYSCOLOR */
/* #define DEBUG_TIMER */
/* #define DEBUG_UTILITY */
/* #define DEBUG_WIN */
/* #define DEBUG_ENUM */
/* #define DEBUG_DLL */
# /* Do not remove this line or change anything below this line */
#ifdef DEBUG_NONE
#undef DEBUG_ACCEL
#undef DEBUG_BITMAP
#undef DEBUG_CARET
#undef DEBUG_CDAUDIO
#undef DEBUG_CLASS
#undef DEBUG_CLIPBOARD
#undef DEBUG_CLIPPING
#undef DEBUG_COMBO
#undef DEBUG_COMM
#undef DEBUG_CURSOR
#undef DEBUG_DC
#undef DEBUG_DIALOG
#undef DEBUG_DLL
#undef DEBUG_DOSFS
#undef DEBUG_DRIVER
#undef DEBUG_EDIT
#undef DEBUG_ENUM
#undef DEBUG_EVENT
#undef DEBUG_EXEC
#undef DEBUG_FILE
#undef DEBUG_FIXUP
#undef DEBUG_FONT
#undef DEBUG_GDI
#undef DEBUG_GRAPHICS
#undef DEBUG_HEAP
#undef DEBUG_ICON
#undef DEBUG_INT
#undef DEBUG_KEY
#undef DEBUG_KEYBOARD
#undef DEBUG_LDT
#undef DEBUG_LISTBOX
#undef DEBUG_MCIWAVE
#undef DEBUG_MDI
#undef DEBUG_MENU
#undef DEBUG_MENUCALC
#undef DEBUG_MESSAGE
#undef DEBUG_METAFILE
#undef DEBUG_MODULE
#undef DEBUG_MSG
#undef DEBUG_NONCLIENT
#undef DEBUG_PALETTE
#undef DEBUG_REGION
#undef DEBUG_RESOURCE
#undef DEBUG_SCROLL
#undef DEBUG_SYSCOLOR
#undef DEBUG_TEXT
#undef DEBUG_TIMER
#undef DEBUG_UTILITY
#undef DEBUG_WIN
#endif
#ifdef DEBUG_ALL
#define DEBUG_ACCEL
#define DEBUG_BITMAP
#define DEBUG_CARET
#define DEBUG_CDAUDIO
#define DEBUG_CLASS
#define DEBUG_CLIPBOARD
#define DEBUG_CLIPPING
#define DEBUG_COMBO
#define DEBUG_COMM
#define DEBUG_CURSOR
#define DEBUG_DC
#define DEBUG_DIALOG
#define DEBUG_DLL
#define DEBUG_DOSFS
#define DEBUG_DRIVER
#define DEBUG_EDIT
#define DEBUG_ENUM
#define DEBUG_EVENT
#define DEBUG_EXEC
#define DEBUG_FILE
#define DEBUG_FIXUP
#define DEBUG_FONT
#define DEBUG_GDI
#define DEBUG_GRAPHICS
#define DEBUG_HEAP
#define DEBUG_ICON
#define DEBUG_INT
#define DEBUG_KEY
#define DEBUG_KEYBOARD
#define DEBUG_LDT
#define DEBUG_LISTBOX
#define DEBUG_MCIWAVE
#define DEBUG_MDI
#define DEBUG_MENU
#define DEBUG_MENUCALC
#define DEBUG_MESSAGE
#define DEBUG_METAFILE
#define DEBUG_MODULE
#define DEBUG_MSG
#define DEBUG_NONCLIENT
#define DEBUG_PALETTE
#define DEBUG_REGION
#define DEBUG_RESOURCE
#define DEBUG_SCROLL
#define DEBUG_SYSCOLOR
#define DEBUG_TEXT
#define DEBUG_TIMER
#define DEBUG_UTILITY
#define DEBUG_WIN
#endif

View File

@ -9,7 +9,7 @@
#include <X11/Xlib.h>
#include "windows.h"
#include "class.h"
#define WND_MAGIC 0x444e4957 /* 'WIND' */
@ -38,7 +38,7 @@ typedef struct tagWND
HRGN hrgnUpdate; /* Update region */
HWND hwndPrevActive; /* Previous active top-level window */
HWND hwndLastActive; /* Last active popup hwnd */
FARPROC lpfnWndProc; /* Window procedure */
WNDPROC lpfnWndProc; /* Window procedure */
DWORD dwStyle; /* Window style (from CreateWindow) */
DWORD dwExStyle; /* Extended style (from CreateWindowEx) */
HANDLE hdce; /* Window DCE (if CS_OWNDC or CS_CLASSDC) */
@ -48,10 +48,7 @@ typedef struct tagWND
WORD wIDmenu; /* ID or hmenu (from CreateWindow) */
HANDLE hText; /* Handle of window text */
WORD flags; /* Misc. flags (see below) */
Window window; /* X window */
HICON hIcon; /* icon's MS-windows handle */
WORD iconWidth; /* width of icon */
WORD iconHeight; /* height of icon */
Window window; /* X window (only for top-level windows) */
RECT rectClientSave; /* where client rect is saved when icon*/
HMENU hSysMenu; /* window's copy of System Menu */
HANDLE hProp; /* Handle of Properties List */
@ -63,14 +60,16 @@ typedef struct tagWND
#define WIN_ERASE_UPDATERGN 0x01 /* Update region needs erasing */
#define WIN_NEEDS_BEGINPAINT 0x02 /* WM_PAINT sent to window */
#define WIN_GOT_SIZEMSG 0x04 /* WM_SIZE has been sent to the window */
#define WIN_OWN_DC 0x08 /* Win class has style CS_OWNDC */
#define WIN_CLASS_DC 0x10 /* Win class has style CS_CLASSDC */
#define WIN_DOUBLE_CLICKS 0x20 /* Win class has style CS_DBLCLKS */
#define WIN_RESTORE_MAX 0x40 /* Maximize when restoring */
#define WIN_INTERNAL_PAINT 0x80 /* Internal WM_PAINT message pending */
#define WIN_RESTORE_MAX 0x08 /* Maximize when restoring */
#define WIN_INTERNAL_PAINT 0x10 /* Internal WM_PAINT message pending */
#define WIN_NO_REDRAW 0x20 /* WM_SETREDRAW called for this window */
#define WIN_CLASS_INFO(wndPtr) (CLASS_FindClassPtr((wndPtr)->hClass)->wc)
#define WIN_CLASS_STYLE(wndPtr) (WIN_CLASS_INFO(wndPtr).style)
/* Window functions */
WND *WIN_FindWndPtr( HWND hwnd );
Window WIN_GetXWindow( HWND hwnd );
BOOL WIN_UnlinkWindow( HWND hwnd );
BOOL WIN_LinkWindow( HWND hwnd, HWND hwndInsertAfter );
HWND WIN_FindWinToRepaint( HWND hwnd );

View File

@ -50,6 +50,7 @@ DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
DECLARE_HANDLE(LOCALHANDLE);
DECLARE_HANDLE(HMETAFILE);
DECLARE_HANDLE(HDWP);
#define TRUE 1
#define FALSE 0
@ -81,41 +82,6 @@ DECLARE_HANDLE(HMETAFILE);
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
typedef long LONG;
typedef WORD HANDLE;
typedef HANDLE HWND;
typedef HANDLE HDC;
typedef HANDLE HCLASS;
typedef HANDLE HCURSOR;
typedef HANDLE HFONT;
typedef HANDLE HPEN;
typedef HANDLE HRGN;
typedef HANDLE HPALETTE;
typedef HANDLE HICON;
typedef HANDLE HINSTANCE;
typedef HANDLE HMENU;
typedef HANDLE HBITMAP;
typedef HANDLE HBRUSH;
typedef HANDLE LOCALHANDLE;
typedef char *LPSTR;
typedef char *NPSTR;
typedef short *LPINT;
typedef void *LPVOID;
typedef long (*FARPROC)();
typedef int CATCHBUF[9];
typedef int *LPCATCHBUF;
#define TRUE 1
#define FALSE 0
#define CW_USEDEFAULT ((short)0x8000)
#define FAR
#define NEAR
#define PASCAL
#ifndef NULL
#define NULL (void *)0
#endif
*/
typedef struct { INT x, y; } POINT;
typedef POINT *PPOINT;
@ -158,19 +124,11 @@ typedef PAINTSTRUCT *LPPAINTSTRUCT;
/* Window classes */
#ifdef WINELIB
typedef LONG (*WNDPROC)(HWND, UINT, WPARAM, LPARAM);
#else
typedef LONG (* WNDPROC)();
#endif
typedef struct {
WORD style;
#ifdef WINELIB
WNDPROC lpfnWndProc;
#else
LONG (*lpfnWndProc)() WINE_PACKED;
#endif
WNDPROC lpfnWndProc WINE_PACKED;
INT cbClsExtra, cbWndExtra;
HANDLE hInstance;
HICON hIcon;
@ -763,18 +721,18 @@ typedef struct tagTEXTMETRIC
INT tmAveCharWidth;
INT tmMaxCharWidth;
INT tmWeight;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
BYTE tmFirstChar;
BYTE tmLastChar;
BYTE tmDefaultChar;
BYTE tmBreakChar;
BYTE tmPitchAndFamily;
BYTE tmCharSet;
INT tmOverhang;
INT tmDigitizedAspectX;
INT tmDigitizedAspectY;
BYTE tmItalic;
BYTE tmUnderlined;
BYTE tmStruckOut;
BYTE tmFirstChar;
BYTE tmLastChar;
BYTE tmDefaultChar;
BYTE tmBreakChar;
BYTE tmPitchAndFamily;
BYTE tmCharSet;
INT tmOverhang WINE_PACKED;
INT tmDigitizedAspectX WINE_PACKED;
INT tmDigitizedAspectY WINE_PACKED;
} TEXTMETRIC, *PTEXTMETRIC, *NPTEXTMETRIC, *LPTEXTMETRIC;
/* tmPitchAndFamily values */
@ -793,6 +751,10 @@ typedef struct tagTEXTMETRIC
#define TA_BOTTOM 0x08
#define TA_BASELINE 0x18
/* ExtTextOut() parameters */
#define ETO_GRAYED 0x01
#define ETO_OPAQUE 0x02
#define ETO_CLIPPED 0x04
typedef struct tagPALETTEENTRY
{
@ -872,6 +834,10 @@ typedef struct tagLOGPEN
#define ABSOLUTE 1
#define RELATIVE 2
/* Flood fill modes */
#define FLOODFILLBORDER 0
#define FLOODFILLSURFACE 1
/* Device parameters for GetDeviceCaps() */
#define DRIVERVERSION 0
#define TECHNOLOGY 2
@ -1567,14 +1533,7 @@ enum { WM_NULL, WM_CREATE, WM_DESTROY, WM_MOVE, WM_UNUSED0, WM_SIZE, WM_ACTIVATE
#define SW_PARENTOPENING 3
#define SW_OTHERRESTORED 4
/*
enum { SW_HIDE, SW_SHOWNORMAL, SW_NORMAL, SW_SHOWMINIMIZED,
SW_SHOWMAXIMIZED, SW_MAXIMIZE, SW_SHOWNOACTIVATE, SW_SHOW,
SW_MINIMIZE, SW_SHOWMINNOACTIVE, SW_SHOWNA, SW_RESTORE,
SW_INTERNAL_HIDE, SW_INTERNAL_RESTORE };
*/
/* ShowWindow() codes */
#define SW_HIDE 0
#define SW_SHOWNORMAL 1
#define SW_NORMAL 1
@ -1713,30 +1672,29 @@ enum { SW_HIDE, SW_SHOWNORMAL, SW_NORMAL, SW_SHOWMINIMIZED,
#define DT_INTERNAL 4096
/* Window Styles */
#define WS_OVERLAPPED 0x00000000L
#define WS_POPUP 0x80000000L
#define WS_CHILD 0x40000000L
#define WS_MINIMIZE 0x20000000L
#define WS_VISIBLE 0x10000000L
#define WS_DISABLED 0x08000000L
#define WS_CLIPSIBLINGS 0x04000000L
#define WS_CLIPCHILDREN 0x02000000L
#define WS_MAXIMIZE 0x01000000L
#define WS_CAPTION 0x00C00000L
#define WS_BORDER 0x00800000L
#define WS_DLGFRAME 0x00400000L
#define WS_VSCROLL 0x00200000L
#define WS_HSCROLL 0x00100000L
#define WS_SYSMENU 0x00080000L
#define WS_THICKFRAME 0x00040000L
#define WS_GROUP 0x00020000L
#define WS_TABSTOP 0x00010000L
#define WS_MINIMIZEBOX 0x00020000L
#define WS_MINIMIZEBOX 0x00020000L
#define WS_MAXIMIZEBOX 0x00010000L
#define WS_TILED WS_OVERLAPPED
#define WS_ICONIC WS_MINIMIZE
#define WS_SIZEBOX WS_THICKFRAME
#define WS_OVERLAPPED 0x00000000L
#define WS_POPUP 0x80000000L
#define WS_CHILD 0x40000000L
#define WS_MINIMIZE 0x20000000L
#define WS_VISIBLE 0x10000000L
#define WS_DISABLED 0x08000000L
#define WS_CLIPSIBLINGS 0x04000000L
#define WS_CLIPCHILDREN 0x02000000L
#define WS_MAXIMIZE 0x01000000L
#define WS_CAPTION 0x00C00000L
#define WS_BORDER 0x00800000L
#define WS_DLGFRAME 0x00400000L
#define WS_VSCROLL 0x00200000L
#define WS_HSCROLL 0x00100000L
#define WS_SYSMENU 0x00080000L
#define WS_THICKFRAME 0x00040000L
#define WS_GROUP 0x00020000L
#define WS_TABSTOP 0x00010000L
#define WS_MINIMIZEBOX 0x00020000L
#define WS_MAXIMIZEBOX 0x00010000L
#define WS_TILED WS_OVERLAPPED
#define WS_ICONIC WS_MINIMIZE
#define WS_SIZEBOX WS_THICKFRAME
#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME| WS_MINIMIZEBOX | WS_MAXIMIZEBOX)
#define WS_POPUPWINDOW (WS_POPUP | WS_BORDER | WS_SYSMENU)
#define WS_CHILDWINDOW (WS_CHILD)
@ -2069,8 +2027,8 @@ typedef struct tagDRAWITEMSTRUCT
UINT itemState;
HWND hwndItem;
HDC hDC;
RECT rcItem;
DWORD itemData;
RECT rcItem WINE_PACKED;
DWORD itemData WINE_PACKED;
} DRAWITEMSTRUCT;
typedef DRAWITEMSTRUCT NEAR* PDRAWITEMSTRUCT;
typedef DRAWITEMSTRUCT FAR* LPDRAWITEMSTRUCT;
@ -2084,7 +2042,7 @@ typedef struct tagMEASUREITEMSTRUCT
UINT itemID;
UINT itemWidth;
UINT itemHeight;
DWORD itemData;
DWORD itemData WINE_PACKED;
} MEASUREITEMSTRUCT;
typedef MEASUREITEMSTRUCT NEAR* PMEASUREITEMSTRUCT;
typedef MEASUREITEMSTRUCT FAR* LPMEASUREITEMSTRUCT;
@ -2112,7 +2070,7 @@ typedef struct tagCOMPAREITEMSTRUCT
UINT itemID1;
DWORD itemData1;
UINT itemID2;
DWORD itemData2;
DWORD itemData2 WINE_PACKED;
} COMPAREITEMSTRUCT;
typedef COMPAREITEMSTRUCT NEAR* PCOMPAREITEMSTRUCT;
typedef COMPAREITEMSTRUCT FAR* LPCOMPAREITEMSTRUCT;
@ -2269,9 +2227,9 @@ typedef struct tagMETAHEADER
WORD mtType;
WORD mtHeaderSize;
WORD mtVersion;
DWORD mtSize __attribute__ ((packed));
DWORD mtSize WINE_PACKED;
WORD mtNoObjects;
DWORD mtMaxRecord __attribute__ ((packed));
DWORD mtMaxRecord WINE_PACKED;
WORD mtNoParameters;
} METAHEADER;
@ -2296,9 +2254,9 @@ typedef HANDLETABLE *LPHANDLETABLE;
/* Clipboard metafile picture structure */
typedef struct tagMETAFILEPICT
{
int mm;
int xExt;
int yExt;
INT mm;
INT xExt;
INT yExt;
HMETAFILE hMF;
} METAFILEPICT;
typedef METAFILEPICT *LPMETAFILEPICT;
@ -2488,6 +2446,7 @@ Fa(BOOL,DestroyIcon,HICON,a)
Fa(BOOL,DestroyMenu,HMENU,a)
Fa(BOOL,DestroyWindow,HWND,a)
Fa(BOOL,EnableHardwareInput,BOOL,a)
Fa(BOOL,EndDeferWindowPos,HDWP,hWinPosInfo)
Fa(BOOL,FreeModule,HANDLE,a)
Fa(BOOL,FreeResource,HANDLE,a)
#ifndef GLOBAL_SOURCE
@ -2534,7 +2493,7 @@ Fa(DWORD,GlobalSize,HANDLE,a)
#endif
Fa(DWORD,OemKeyScan,WORD,a)
Fa(FARPROC,LocalNotify,FARPROC,a)
Fa(HANDLE,BeginDeferWindowPos,int,nNumWindows)
Fa(HDWP,BeginDeferWindowPos,INT,nNumWindows)
Fa(HMETAFILE,CloseMetaFile,HANDLE,a)
Fa(HANDLE,CreateMetaFile,LPSTR,a)
Fa(HANDLE,GetAtomHandle,ATOM,a)
@ -2653,7 +2612,6 @@ Fa(short,GetTextCharacterExtra,HDC,a)
Fa(void,ClipCursor,LPRECT,a)
Fa(void,CloseWindow,HWND,a)
Fa(void,DrawMenuBar,HWND,a)
Fa(void,EndDeferWindowPos,HANDLE,hWinPosInfo)
Fa(void,FatalExit,int,a)
Fa(void,FreeLibrary,HANDLE,a)
Fa(void,FreeProcInstance,FARPROC,a)
@ -2876,6 +2834,7 @@ Fc(HPEN,CreatePen,short,a,short,b,COLORREF,c)
Fc(HRGN,CreatePolygonRgn,LPPOINT,a,short,b,short,c)
Fc(HWND,GetNextDlgGroupItem,HWND,a,HWND,b,BOOL,c)
Fc(HWND,GetNextDlgTabItem,HWND,a,HWND,b,BOOL,c)
Fc(INT,GetTextFace,HDC,a,INT,b,LPSTR,c)
Fc(LONG,GetBitmapBits,HBITMAP,a,LONG,b,LPSTR,c)
Fc(LONG,SetBitmapBits,HBITMAP,a,LONG,b,LPSTR,c)
Fc(LONG,SetClassLong,HWND,a,short,b,LONG,c)
@ -2894,7 +2853,6 @@ Fc(int,GetInstanceData,HANDLE,a,NPSTR,b,int,c)
Fc(int,GetKeyNameText,LONG,a,LPSTR,b,int,c)
Fc(int,GetModuleFileName,HANDLE,a,LPSTR,b,short,c)
Fc(int,GetObject,HANDLE,a,int,b,LPSTR,c)
Fc(int,GetTextFace,HDC,a,int,b,LPSTR,c)
Fc(int,GetUpdateRgn,HWND,a,HRGN,b,BOOL,c)
Fc(int,GetWindowText,HWND,a,LPSTR,b,int,c)
Fc(int,MulDiv,int,a,int,b,int,c)
@ -2929,7 +2887,7 @@ Fd(BOOL,GetMessage,LPMSG,msg,HWND,b,WORD,c,WORD,d)
Fd(BOOL,GetTextExtentPoint,HDC,a,LPSTR,b,short,c,LPSIZE,d)
Fd(BOOL,DrawIcon,HDC,a,short,b,short,c,HICON,d)
Fd(BOOL,EnumMetaFile,HDC,a,LOCALHANDLE,b,FARPROC,c,BYTE FAR*,d)
Fd(BOOL,FloodFill,HDC,a,short,b,short,c,DWORD,d)
Fd(BOOL,FloodFill,HDC,a,INT,b,INT,c,COLORREF,d)
Fd(BOOL,GetCharWidth,HDC,a,WORD,b,WORD,c,LPINT,d)
Fd(BOOL,HiliteMenuItem,HWND,a,HMENU,b,WORD,c,WORD,d)
Fd(BOOL,MoveToEx,HDC,a,short,b,short,c,LPPOINT,d)
@ -2948,8 +2906,8 @@ Fd(HHOOK,SetWindowsHookEx,short,a,HOOKPROC,b,HINSTANCE,c,HTASK,d)
Fd(HRGN,CreateEllipticRgn,short,a,short,b,short,c,short,d)
Fd(HRGN,CreatePolyPolygonRgn,LPPOINT,a,LPINT,b,short,c,short,d)
Fd(HRGN,CreateRectRgn,short,a,short,b,short,c,short,d)
Fd(HWND,CreateDialog,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d)
Fd(HWND,CreateDialogIndirect,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d)
Fd(HWND,CreateDialog,HANDLE,a,LPCSTR,b,HWND,c,WNDPROC,d)
Fd(HWND,CreateDialogIndirect,HANDLE,a,LPCSTR,b,HWND,c,WNDPROC,d)
Fd(LONG,DefDlgProc,HWND,a,WORD,b,WORD,c,LONG,d)
Fd(LONG,DefMDIChildProc,HWND,a,WORD,b,WORD,c,LONG,d)
Fd(LONG,DefWindowProc,HWND,a,WORD,b,WORD,c,LONG,d)
@ -2966,8 +2924,8 @@ Fd(BOOL,SetWindowOrgEx,HDC,a,short,b,short,c,LPPOINT,d)
Fd(BOOL,OffsetViewportOrgEx,HDC,a,short,b,short,c,LPPOINT,d)
Fd(BOOL,OffsetWindowOrgEx,HDC,a,short,b,short,c,LPPOINT,d)
Fd(int,CombineRgn,HRGN,a,HRGN,b,HRGN,c,short,d)
Fd(int,DialogBox,HINSTANCE,a,LPCSTR,b,HWND,c,FARPROC,d)
Fd(int,DialogBoxIndirect,HANDLE,a,HANDLE,b,HWND,c,FARPROC,d)
Fd(int,DialogBox,HINSTANCE,a,LPCSTR,b,HWND,c,WNDPROC,d)
Fd(int,DialogBoxIndirect,HANDLE,a,HANDLE,b,HWND,c,WNDPROC,d)
Fd(int,EnumFonts,HDC,a,LPSTR,b,FARPROC,c,LPSTR,d)
Fd(int,EnumObjects,HDC,a,int,b,FARPROC,c,LPSTR,d)
Fd(int,GetDlgItemText,HWND,a,WORD,b,LPSTR,c,WORD,d)
@ -2989,10 +2947,10 @@ Fd(void,SetDlgItemInt,HWND,a,WORD,b,WORD,c,BOOL,d)
Fe(BOOL,Rectangle,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom)
Fe(int,DrawText,HDC,a,LPSTR,str,int,c,LPRECT,d,WORD,flag)
Fe(BOOL,PeekMessage,LPMSG,a,HWND,b,WORD,c,WORD,d,WORD,e)
Fe(LONG,CallWindowProc,FARPROC,a,HWND,b,WORD,c,WORD,d,LONG,e)
Fe(LONG,CallWindowProc,WNDPROC,a,HWND,b,WORD,c,WORD,d,LONG,e)
Fe(BOOL,ChangeMenu,HMENU,a,WORD,b,LPSTR,c,WORD,d,WORD,e)
Fe(BOOL,Ellipse,HDC,a,int,b,int,c,int,d,int,e)
Fe(BOOL,ExtFloodFill,HDC,a,int,b,int,c,DWORD,d,WORD,e)
Fe(BOOL,ExtFloodFill,HDC,a,INT,b,INT,c,COLORREF,d,WORD,e)
Fe(BOOL,FrameRgn,HDC,a,HRGN,b,HBRUSH,e,int,c,int,d)
Fe(BOOL,InsertMenu,HMENU,a,WORD,b,WORD,c,WORD,d,LPSTR,e)
Fe(BOOL,ModifyMenu,HMENU,a,WORD,b,WORD,c,WORD,d,LPSTR,e)
@ -3002,12 +2960,12 @@ Fe(DWORD,GetTabbedTextExtent,HDC,a,LPSTR,b,int,c,int,d,LPINT,e)
Fe(DWORD,ScaleViewportExt,HDC,a,short,b,short,c,short,d,short,e)
Fe(DWORD,ScaleWindowExt,HDC,a,short,b,short,c,short,d,short,e)
Fe(HBITMAP,CreateBitmap,short,a,short,b,BYTE,c,BYTE,d,LPSTR,e)
Fe(HWND,CreateDialogIndirectParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LPARAM,e)
Fe(HWND,CreateDialogParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LPARAM,e)
Fe(HWND,CreateDialogIndirectParam,HANDLE,a,LPCSTR,b,HWND,c,WNDPROC,d,LPARAM,e)
Fe(HWND,CreateDialogParam,HANDLE,a,LPCSTR,b,HWND,c,WNDPROC,d,LPARAM,e)
Fe(LONG,DefFrameProc,HWND,a,HWND,b,WORD,c,WORD,d,LONG,e)
Fe(LONG,SendDlgItemMessage,HWND,a,WORD,b,WORD,c,WORD,d,LONG,e)
Fe(int,DialogBoxIndirectParam,HANDLE,a,HANDLE,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DialogBoxParam,HANDLE,a,LPCSTR,b,HWND,c,FARPROC,d,LONG,e)
Fe(int,DialogBoxIndirectParam,HANDLE,a,HANDLE,b,HWND,c,WNDPROC,d,LONG,e)
Fe(int,DialogBoxParam,HANDLE,a,LPCSTR,b,HWND,c,WNDPROC,d,LONG,e)
Fe(int,DlgDirList,HWND,a,LPSTR,b,int,c,int,d,WORD,e)
Fe(int,DlgDirListComboBox,HWND,a,LPSTR,b,int,c,int,d,WORD,e)
Fe(int,Escape,HDC,a,int,b,int,c,LPSTR,d,LPSTR,e)
@ -3041,7 +2999,7 @@ Fg(int,GetDIBits,HDC,a,HANDLE,a2,WORD,b,WORD,c,LPSTR,d,LPBITMAPINFO,e,WORD,f)
Fg(int,SetDIBits,HDC,a,HANDLE,a2,WORD,b,WORD,c,LPSTR,d,LPBITMAPINFO,e,WORD,f)
Fg(BOOL,SetWindowPos,HWND,a,HWND,b,short,c,short,d,short,e,short,f,WORD,g)
Fh(BOOL,ExtTextOut,HDC,a,short,b,short,c,WORD,d,LPRECT,e,LPSTR,f,WORD,g,LPINT,h)
Fh(HANDLE,DeferWindowPos,HANDLE,hWinPosInfo,HWND,hWnd,HWND,hWndInsertAfter,int,x,int,y,int,cx,int,cy,WORD,wFlags)
Fh(HDWP,DeferWindowPos,HDWP,hWinPosInfo,HWND,hWnd,HWND,hWndInsertAfter,INT,x,INT,y,INT,cx,INT,cy,WORD,wFlags)
Fh(LONG,TabbedTextOut,HDC,a,short,b,short,c,LPSTR,d,short,e,short,f,LPINT,g,short,h)
Fh(int,ScrollWindowEx,HWND,a,short,b,short,c,LPRECT,d,LPRECT,e,HRGN,f,LPRECT,g,WORD,h)
Fi(BOOL,Arc,HDC,a,int,xLeft,int,yTop,int,xRight,int,yBottom,int,xStart,int,yStart,int,xEnd,int,yEnd)

21
include/winpos.h Normal file
View File

@ -0,0 +1,21 @@
/*
* *DeferWindowPos() structure and definitions
*
* Copyright 1994 Alexandre Julliard
*/
#ifndef WINPOS_H
#define WINPOS_H
#define DWP_MAGIC 0x5057 /* 'WP' */
typedef struct
{
WORD actualCount;
WORD suggestedCount;
WORD valid;
WORD wMagic;
WINDOWPOS winPos[1];
} DWP;
#endif /* WINPOS_H */

View File

@ -8,6 +8,9 @@ SRCS = \
ldtlib.c \
main.c \
ne_image.c \
ne_resource.c \
pe_image.c \
pe_resource.c \
selector.c \
signal.c \
library.c \
@ -18,7 +21,6 @@ OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

View File

@ -6,6 +6,10 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdlib.h>
#include <errno.h>
#include "autoconf.h"
#include "stddebug.h"
/* #define DEBUG_LDT /* */
/* #undef DEBUG_LDT /* */
#include "debug.h"
#ifdef linux
#include <linux/unistd.h>
@ -76,12 +80,11 @@ set_ldt_entry(int entry, unsigned long base, unsigned int limit,
struct segment_descriptor *sd;
int ret;
#ifdef DEBUG_LDT
printf("set_ldt_entry: entry=%x base=%x limit=%x%s %s-bit contents=%d %s\n",
entry, base, limit, limit_in_pages_flag?"-pages":"",
seg_32bit_flag?"32":"16",
contents, read_only_flag?"read-only":"");
#endif
dprintf_ldt(stddeb,
"set_ldt_entry: entry=%x base=%x limit=%x%s %s-bit contents=%d %s\n",
entry, base, limit, limit_in_pages_flag?"-pages":"",
seg_32bit_flag?"32":"16",
contents, read_only_flag?"read-only":"");
sd = make_sd(base, limit, contents, read_only_flag, seg_32bit_flag, limit_in_pages_flag);
ret = i386_set_ldt(entry, (union descriptor *)sd, 1);

View File

@ -1,11 +1,8 @@
/*
* Modules & Libraries functions
* Module & Library functions
*/
static char Copyright[] = "Copyright Martin Ayotte, 1994";
static char Copyright[] = "Copyright 1993, 1994 Martin Ayotte, Robert J. Amstadt, Erik Bos";
/*
#define DEBUG_MODULE
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -13,18 +10,31 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "neexe.h"
#include "segmem.h"
#include "dlls.h"
#include "wine.h"
#include "wineopts.h"
#include "arch.h"
#include "options.h"
#include "prototypes.h"
#include "windows.h"
#include "dlls.h"
#include "task.h"
#include "toolhelp.h"
#include "stddebug.h"
/* #define DEBUG_MODULE /* */
/* #undef DEBUG_MODULE /* */
#include "debug.h"
extern struct w_files *wine_files;
extern char WindowsPath[256];
extern struct dll_name_table_entry_s dll_builtin_table[];
extern char *GetDosFileName(char *);
struct w_files *GetFileInfo(HANDLE);
char *GetDosFileName(char *);
extern HANDLE hSysRes;
struct w_files *wine_files = NULL;
static char *DLL_Extensions[] = { "dll", NULL };
static char *EXE_Extensions[] = { "exe", NULL };
#define IS_BUILTIN_DLL(handle) ((handle >> 8) == 0xff)
@ -48,6 +58,196 @@ void ExtractDLLName(char *libname, char *temp)
}
}
struct w_files *
GetFileInfo(unsigned short instance)
{
register struct w_files *w = wine_files;
while (w && w->hinstance != instance)
w = w->next;
return w;
}
int IsDLLLoaded(char *name)
{
struct w_files *wpnt;
if(FindDLLTable(name))
return 1;
for(wpnt = wine_files; wpnt; wpnt = wpnt->next)
if(strcmp(wpnt->name, name) == 0)
return 1;
return 0;
}
void InitDLL(struct w_files *wpnt)
{
if (wpnt->ne)
InitNEDLL(wpnt);
else
InitPEDLL(wpnt);
}
void InitializeLoadedDLLs(struct w_files *wpnt)
{
static flagReadyToRun = 0;
struct w_files *final_wpnt;
printf("InitializeLoadedDLLs %08X\n", wpnt);
if (wpnt == NULL)
{
flagReadyToRun = 1;
fprintf(stderr, "Initializing DLLs\n");
}
if (!flagReadyToRun)
return;
#if 1
if (wpnt != NULL)
fprintf(stderr, "Initializing %s\n", wpnt->name);
#endif
/*
* Initialize libraries
*/
if (!wpnt)
{
wpnt = wine_files;
final_wpnt = NULL;
}
else
{
final_wpnt = wpnt->next;
}
for( ; wpnt != final_wpnt; wpnt = wpnt->next)
InitDLL(wpnt);
}
/**********************************************************************
* LoadImage
* Load one executable into memory
*/
HINSTANCE LoadImage(char *module, int filetype, int change_dir)
{
HINSTANCE handle;
struct w_files *wpnt, *wpnt1;
char buffer[256], header[2], modulename[64], *fullname;
ExtractDLLName(module, modulename);
printf("LoadImage [%s]\n", module);
/* built-in one ? */
if (FindDLLTable(modulename)) {
return GetModuleHandle(modulename);
}
/* already loaded ? */
for (wpnt = wine_files ; wpnt ; wpnt = wpnt->next)
if (strcasecmp(wpnt->name, modulename) == 0)
return wpnt->hinstance;
/*
* search file
*/
fullname = FindFile(buffer, sizeof(buffer), module,
(filetype == EXE ? EXE_Extensions : DLL_Extensions),
WindowsPath);
if (fullname == NULL)
{
fprintf(stderr, "LoadImage: I can't find %s.dll | %s.exe !\n",
module, module);
return 2;
}
fullname = GetDosFileName(fullname);
fprintf(stderr,"LoadImage: loading %s (%s)\n [%s]\n",
module, buffer, fullname);
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 if we could load the file.
*/
wpnt = (struct w_files *) malloc(sizeof(struct w_files));
/*
* Open file for reading.
*/
wpnt->fd = open(buffer, O_RDONLY);
if (wpnt->fd < 0)
return 2;
/*
* Establish header pointers.
*/
wpnt->filename = strdup(buffer);
wpnt->name = strdup(modulename);
/* read mz header */
wpnt->mz_header = (struct mz_header_s *) malloc(sizeof(struct mz_header_s));;
lseek(wpnt->fd, 0, SEEK_SET);
if (read(wpnt->fd, wpnt->mz_header, sizeof(struct mz_header_s)) !=
sizeof(struct mz_header_s))
{
myerror("Unable to read MZ header from file");
}
if (wpnt->mz_header->must_be_0x40 != 0x40)
myerror("This is not a Windows program");
/* read first two bytes to determine filetype */
lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET);
read(wpnt->fd, &header, sizeof(header));
handle = 0;
if (header[0] == 'N' && header[1] == 'E')
handle = LoadNEImage(wpnt);
if (header[0] == 'P' && header[1] == 'E')
handle = LoadPEImage(wpnt);
wpnt->hinstance = handle;
if (handle > 32) {
/* ok, loaded, add to the end of the list */
if(wine_files == NULL)
wine_files = wpnt;
else {
wpnt1 = wine_files;
while(wpnt1->next)
wpnt1 = wpnt1->next;
wpnt1->next = wpnt;
}
wpnt->next = NULL;
return handle;
} else {
fprintf(stderr, "wine: (%s) unknown fileformat !\n", wpnt->filename);
close(wpnt->fd);
free(wpnt->filename);
free(wpnt->name);
free(wpnt);
return 14;
}
}
/**********************************************************************
* GetModuleHandle [KERNEL.47]
*/
@ -174,22 +374,27 @@ HANDLE LoadLibrary(LPSTR libname)
return h;
}
/**********************************************************************
* FreeLibrary [KERNEL.96]
*/
void FreeLibrary(HANDLE hLib)
{
printf("FreeLibrary(%04X);\n", hLib);
struct w_files *wpnt;
printf("FreeLibrary(%04X);\n", hLib);
/* built-in dll ? */
if (IS_BUILTIN_DLL(hLib))
if (IS_BUILTIN_DLL(hLib) || hLib == 0 || hLib == hSysRes)
return;
/*
while (lpMod != NULL) {
if (lpMod->hInst == hLib) {
if (lpMod->Count == 1) {
wpnt = GetFileInfo(hLib);
if (wpnt->ne)
NEunloadImage(wpnt);
else
PEunloadImage(wpnt);
if (hLib != (HANDLE)NULL) GlobalFree(hLib);
if (lpMod->ModuleName != NULL) free(lpMod->ModuleName);
if (lpMod->FileName != NULL) free(lpMod->FileName);
@ -215,7 +420,7 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name)
#ifdef WINELIB
WINELIB_UNIMP ("GetProcAddress");
#else
int i, sel, addr, ret;
int sel, addr, ret;
register struct w_files *w = wine_files;
int ordinal, len;
char * cpnt;
@ -275,11 +480,11 @@ FARPROC GetProcAddress(HANDLE hModule, char *proc_name)
{
AnsiUpper(proc_name);
printf("GetProcAddress: %04X, '%s'\n", hModule, proc_name);
cpnt = w->nrname_table;
cpnt = w->ne->nrname_table;
while(TRUE)
{
if (((int) cpnt) - ((int)w->nrname_table) >
w->ne_header->nrname_tab_length) return NULL;
if (((int) cpnt) - ((int)w->ne->nrname_table) >
w->ne->ne_header->nrname_tab_length) return NULL;
len = *cpnt++;
strncpy(C, cpnt, len);
C[len] = '\0';
@ -343,24 +548,24 @@ FillModStructLoaded(MODULEENTRY *lpModule, struct w_files *dll)
}
/**********************************************************************
* ModuleFirst [TOOHELP.59]
* ModuleFirst [TOOLHELP.59]
*/
BOOL ModuleFirst(MODULEENTRY *lpModule)
{
printf("ModuleFirst(%08X)\n", lpModule);
printf("ModuleFirst(%08X)\n", (int) lpModule);
FillModStructBuiltIn(lpModule, &dll_builtin_table[0]);
return TRUE;
}
/**********************************************************************
* ModuleNext [TOOHELP.60]
* ModuleNext [TOOLHELP.60]
*/
BOOL ModuleNext(MODULEENTRY *lpModule)
{
struct w_files *w;
printf("ModuleNext(%08X)\n", lpModule);
printf("ModuleNext(%08X)\n", (int) lpModule);
if (IS_BUILTIN_DLL(lpModule->hModule)) {
/* last built-in ? */
@ -383,13 +588,13 @@ BOOL ModuleNext(MODULEENTRY *lpModule)
}
/**********************************************************************
* ModuleFindHandle [TOOHELP.62]
* ModuleFindHandle [TOOLHELP.62]
*/
HMODULE ModuleFindHandle(MODULEENTRY *lpModule, HMODULE hModule)
{
struct w_files *w;
printf("ModuleFindHandle(%08X, %04X)\n", lpModule, hModule);
printf("ModuleFindHandle(%08X, %04X)\n", (int) lpModule, (int)hModule);
/* built-in dll ? */
if (IS_BUILTIN_DLL(hModule)) {
@ -406,7 +611,7 @@ HMODULE ModuleFindHandle(MODULEENTRY *lpModule, HMODULE hModule)
}
/**********************************************************************
* ModuleFindName [TOOHELP.61]
* ModuleFindName [TOOLHELP.61]
*/
HMODULE ModuleFindName(MODULEENTRY *lpModule, LPCSTR lpstrName)
{

View File

@ -9,12 +9,6 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <unistd.h>
#include <string.h>
#include <errno.h>
#ifdef linux
#include <linux/unistd.h>
#include <linux/head.h>
#include <linux/ldt.h>
#include <linux/segment.h>
#endif
#include "neexe.h"
#include "segmem.h"
#include "prototypes.h"
@ -23,32 +17,22 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "windows.h"
#include "wineopts.h"
#include "arch.h"
#include "task.h"
#include "options.h"
#include "stddebug.h"
/* #define DEBUG_DLL /* */
/* #undef DEBUG_DLL /* */
#include "debug.h"
/* #define DEBUG_FIXUP */
extern HANDLE CreateNewTask(HINSTANCE hInst);
extern int CallToInit16(unsigned long csip, unsigned long sssp,
unsigned short ds);
extern void CallTo32();
char *GetDosFileName(char *unixfilename);
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;
char **Argv;
int Argc;
HINSTANCE hSysRes;
static char *DLL_Extensions[] = { "dll", NULL };
static char *EXE_Extensions[] = { "exe", NULL };
unsigned short WIN_StackSize;
unsigned short WIN_HeapSize;
/**********************************************************************
* myerror
@ -64,195 +48,19 @@ myerror(const char *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");
}
}
#endif
int IsDLLLoaded(char *name)
{
struct w_files *wpnt;
if(FindDLLTable(name))
return 1;
for(wpnt = wine_files; wpnt; wpnt = wpnt->next)
if(strcmp(wpnt->name, name) == 0)
return 1;
return 0;
}
/**********************************************************************
* LoadImage
* Load one executable into memory
*/
HINSTANCE LoadImage(char *module, int filetype, int change_dir)
{
unsigned int read_size;
int i;
struct w_files * wpnt, *wpnt1;
unsigned int status;
char buffer[256], header[2], modulename[64], *fullname;
ExtractDLLName(module, modulename);
printf("%sLoadImage \n", module);
/* built-in one ? */
if (FindDLLTable(modulename)) {
return GetModuleHandle(modulename);
}
/* already loaded ? */
for (wpnt = wine_files ; wpnt ; wpnt = wpnt->next)
if (strcasecmp(wpnt->name, modulename) == 0)
return wpnt->hinstance;
/*
* search file
*/
fullname = FindFile(buffer, sizeof(buffer), module,
(filetype == EXE ? EXE_Extensions : DLL_Extensions),
WindowsPath);
if (fullname == NULL)
{
fprintf(stderr, "LoadImage: I can't find %s.dll | %s.exe !\n",
module, module);
return 2;
}
fullname = GetDosFileName(fullname);
WIN_ProgramName = strdup(fullname);
fprintf(stderr,"LoadImage: loading %s (%s)\n [%s]\n",
module, 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;
wpnt->resnamtab = (RESNAMTAB *) -1;
/*
* Open file for reading.
*/
wpnt->fd = open(buffer, O_RDONLY);
if (wpnt->fd < 0)
return 2;
/*
* Establish header pointers.
*/
wpnt->filename = strdup(buffer);
wpnt->name = strdup(modulename);
/* if(module) {
wpnt->name = strdup(module);
ToDos(wpnt->name);
}*/
/* read mz header */
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 &&
wpnt->mz_header->must_be_0x40 != 0x1e)
myerror("This is not a Windows program");
/* read first two bytes to determine filetype */
status = lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET);
read(wpnt->fd, &header, sizeof(header));
if (header[0] == 'N' && header[1] == 'E')
return (LoadNEImage(wpnt));
if (header[0] == 'P' && header[1] == 'E') {
printf("win32 applications are not supported");
return 14;
}
fprintf(stderr, "wine: (%s) unknown fileformat !\n", wpnt->filename);
return 14;
}
#ifndef WINELIB
/**********************************************************************
* main
*/
int _WinMain(int argc, char **argv)
{
int segment;
char *p;
char *sysresname;
char filename[256];
char *p, filename[256];
HANDLE hTaskMain;
HINSTANCE hInstMain;
struct w_files *wpnt;
#ifdef WINESTAT
char * cp;
#endif
struct w_files * wpnt;
int cs_reg, ds_reg, ss_reg, ip_reg, sp_reg;
int rv;
Argc = argc - 1;
Argv = argv + 1;
@ -274,7 +82,7 @@ int _WinMain(int argc, char **argv)
fprintf(stderr, "wine: can't load %s!.\n", Argv[0]);
exit(1);
}
hTaskMain = CreateNewTask(hInstMain);
hTaskMain = CreateNewTask(hInstMain, 0);
printf("_WinMain // hTaskMain=%04X hInstMain=%04X !\n", hTaskMain, hInstMain);
GetPrivateProfileString("wine", "SystemResources", "sysres.dll",
@ -285,18 +93,8 @@ int _WinMain(int argc, char **argv)
fprintf(stderr, "wine: can't load %s!.\n", filename);
exit(1);
} else
printf("System Resources Loaded // hSysRes='%04X'\n", hSysRes);
dprintf_dll(stddeb,"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];
@ -312,96 +110,14 @@ int _WinMain(int argc, char **argv)
*/
init_wine_signals();
/*
* Fixup stack and jump to start.
*/
WIN_StackSize = wine_files->ne_header->stack_length;
WIN_HeapSize = wine_files->ne_header->local_heap_length;
wpnt = GetFileInfo(hInstMain);
if (Options.debug)
wine_debug(0, NULL);
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 InitDLL(struct w_files *wpnt)
{
int cs_reg, ds_reg, ip_reg, rv;
/*
* 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;
if (cs_reg) {
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);
} else
printf("%s skipped\n", wpnt->name);
}
}
void InitializeLoadedDLLs(struct w_files *wpnt)
{
static flagReadyToRun = 0;
struct w_files *final_wpnt;
printf("InitializeLoadedDLLs %08X\n", wpnt);
if (wpnt == NULL)
{
flagReadyToRun = 1;
fprintf(stderr, "Initializing DLLs\n");
}
if (!flagReadyToRun)
return;
#if 1
if (wpnt != NULL)
fprintf(stderr, "Initializing %s\n", wpnt->name);
#endif
/*
* Initialize libraries
*/
if (!wpnt)
{
wpnt = wine_files;
final_wpnt = NULL;
}
if (wpnt->ne)
StartNEprogram(wpnt);
else
{
final_wpnt = wpnt->next;
}
for( ; wpnt != final_wpnt; wpnt = wpnt->next)
InitDLL(wpnt);
}
#else /* #ifndef WINELIB */
void InitDLL(struct w_files *wpnt)
{
StartPEprogram(wpnt);
}
#endif /* #ifndef WINELIB */

View File

@ -7,8 +7,8 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h>
#ifdef linux
#include <linux/unistd.h>
#include <linux/head.h>
#include <linux/ldt.h>
#include <linux/segment.h>
@ -24,20 +24,23 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "wineopts.h"
#include "arch.h"
#include "options.h"
#include "stddebug.h"
/* #define DEBUG_FIXUP /* */
/* #undef DEBUG_FIXUP /* */
#include "debug.h"
extern HANDLE CreateNewTask(HINSTANCE hInst);
extern void InitializeLoadedDLLs(struct w_files *wpnt);
extern int CallToInit16(unsigned long csip, unsigned long sssp,
unsigned short ds);
extern void InitializeLoadedDLLs(struct w_files *wpnt);
extern void FixupFunctionPrologs(struct w_files * wpnt);
char * GetModuleName(struct w_files * wpnt, int index, char *buffer);
extern void CallTo32();
extern char WindowsPath[256];
char *WIN_ProgramName;
extern unsigned short WIN_StackSize;
extern unsigned short WIN_HeapSize;
HINSTANCE hSysRes;
int FixupSegment(struct w_files *, int);
void FixupFunctionPrologs(struct w_files *);
char *GetModuleName(struct w_files * wpnt, int index, char *buffer);
#ifndef WINELIB
@ -61,71 +64,61 @@ HINSTANCE LoadNEImage(struct w_files *wpnt)
{
unsigned int read_size, status, segment;
int i;
char buffer[256];
char *fullname;
HANDLE t;
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);
wpnt->ne = malloc(sizeof(struct ne_data));
wpnt->ne->resnamtab = NULL;
wpnt->ne->ne_header = malloc(sizeof(struct ne_header_s));
lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET);
load_ne_header(wpnt->fd, wpnt->ne->ne_header);
#ifndef WINELIB
/*
* Create segment selectors.
*/
status = lseek(wpnt->fd, wpnt->mz_header->ne_offset +
wpnt->ne_header->segment_tab_offset,
wpnt->ne->ne_header->segment_tab_offset,
SEEK_SET);
read_size = wpnt->ne_header->n_segment_tab *
read_size = wpnt->ne->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)
wpnt->ne->seg_table = (struct ne_segment_table_entry_s *) malloc(read_size);
if (read(wpnt->fd, wpnt->ne->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].
wpnt->ne->selector_table = CreateSelectors(wpnt);
wpnt->hinstance = (wpnt->ne->
selector_table[wpnt->ne->ne_header->auto_data_seg-1].
selector);
#endif
/* 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);
read_size = wpnt->ne->ne_header->entry_tab_length;
wpnt->ne->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)
wpnt->ne->ne_header->entry_tab_offset, SEEK_SET);
if (read(wpnt->fd, wpnt->ne->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)
status = lseek(wpnt->fd, wpnt->ne->ne_header->nrname_tab_offset, SEEK_SET);
read_size = wpnt->ne->ne_header->nrname_tab_length;
wpnt->ne->nrname_table = (char *) malloc(read_size);
if (read(wpnt->fd, wpnt->ne->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)
wpnt->ne->ne_header->rname_tab_offset, SEEK_SET);
read_size = wpnt->ne->ne_header->moduleref_tab_offset -
wpnt->ne->ne_header->rname_tab_offset;
wpnt->ne->rname_table = (char *) malloc(read_size);
if (read(wpnt->fd, wpnt->ne->rname_table, read_size) != read_size)
myerror("Unable to read rname table header from file");
/* Now get the module name, if the current one is a filename */
/* nope, name by which dll is loaded is used !
if (strchr(wpnt->name, '\\') || strchr(wpnt->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;
*/
/*
* Now load any DLLs that this module refers to.
*/
for(i=0; i<wpnt->ne_header->n_mod_ref_tab; i++)
for(i=0; i<wpnt->ne->ne_header->n_mod_ref_tab; i++)
{
char buff[14];
GetModuleName(wpnt, i + 1, buff);
@ -136,7 +129,7 @@ HINSTANCE LoadNEImage(struct w_files *wpnt)
#ifndef WINELIB
/* fixup references */
for (segment = 0; segment < wpnt->ne_header->n_segment_tab; segment++)
for (segment = 0; segment < wpnt->ne->ne_header->n_segment_tab; segment++)
if (FixupSegment(wpnt, segment) < 0)
myerror("fixup failed.");
@ -174,7 +167,7 @@ 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;
struct ne_header_s *ne_header = wpnt->ne->ne_header;
int length;
WORD name_offset, status;
int i;
@ -194,7 +187,8 @@ GetModuleName(struct w_files * wpnt, int index, char *buffer)
/* Module names are always upper case */
for(i=0; i<length; i++)
if(buffer[i] >= 'a' && buffer[i] <= 'z') buffer[i] &= ~0x20;
if (islower(buffer[i]))
buffer[i] = toupper(buffer[i]);
return buffer;
}
@ -208,14 +202,13 @@ 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 mz_header_s *mz_header = wpnt->mz_header;
struct ne_header_s *ne_header = wpnt->ne->ne_header;
struct ne_segment_table_entry_s *seg_table = wpnt->ne->seg_table;
struct segment_descriptor_s *selector_table = wpnt->ne->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;
@ -229,10 +222,8 @@ FixupSegment(struct w_files * wpnt, int segment_num)
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
dprintf_fixup(stddeb, "Segment fixups for %s, segment %d, selector %x\n",
wpnt->name, segment_num, (int) sel->base_addr >> 16);
if ((seg->seg_data_offset == 0) ||
!(seg->seg_flags & NE_SEGFLAGS_RELOC_DATA))
@ -293,10 +284,8 @@ FixupSegment(struct w_files * wpnt, int segment_num)
return -1;
}
#ifdef DEBUG_FIXUP
printf("%d: %s.%d: %04.4x:%04.4x\n", i + 1, dll_name, ordinal,
selector, address);
#endif
dprintf_fixup(stddeb,"%d: %s.%d: %04.4x:%04.4x\n", i + 1,
dll_name, ordinal, selector, address);
break;
case NE_RELTYPE_NAMEADD:
@ -328,10 +317,8 @@ FixupSegment(struct w_files * wpnt, int segment_num)
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
dprintf_fixup(stddeb,"%d: %s %s.%d: %04.4x:%04.4x\n", i + 1,
func_name, dll_name, ordinal, selector, address);
break;
case NE_RELTYPE_INTERNAL:
@ -348,9 +335,8 @@ FixupSegment(struct w_files * wpnt, int segment_num)
address = rep->target2;
}
#ifdef DEBUG_FIXUP
printf("%d: %04.4x:%04.4x\n", i + 1, selector, address);
#endif
dprintf_fixup(stddeb,"%d: %04.4x:%04.4x\n",
i + 1, selector, address);
break;
case 7:
@ -362,19 +348,20 @@ FixupSegment(struct w_files * wpnt, int segment_num)
* successfully emulate the coprocessor if it doesn't
* exist.
*/
#ifdef DEBUG_FIXUP
printf("%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ",
dprintf_fixup(stddeb,
"%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
dprintf_fixup(stddeb,"TARGET %04.4x %04.4x\n",
rep->target1, rep->target2);
continue;
default:
fprintf(stderr,"%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ",
dprintf_fixup(stddeb,
"%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",
dprintf_fixup(stddeb,"TARGET %04.4x %04.4x\n",
rep->target1, rep->target2);
free(rep1);
return -1;
@ -388,23 +375,21 @@ FixupSegment(struct w_files * wpnt, int segment_num)
{
if (FindDLLTable(dll_name) == NULL)
additive = 2;
fprintf(stderr,"%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ",
dprintf_fixup(stddeb,
"%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",
dprintf_fixup(stddeb,"TARGET %04.4x %04.4x\n",
rep->target1, rep->target2);
fprintf(stderr, " Additive = %d\n", additive);
dprintf_fixup(stddeb, " 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",
dprintf_fixup(stddeb," %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)
@ -417,10 +402,8 @@ FixupSegment(struct w_files * wpnt, int segment_num)
case NE_RADDR_POINTER32:
do {
#ifdef DEBUG_FIXUP
printf(" %04.4x:%04.4x:%04.4x POINTER32\n",
dprintf_fixup(stddeb," %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)
@ -434,10 +417,8 @@ FixupSegment(struct w_files * wpnt, int segment_num)
case NE_RADDR_SELECTOR:
do {
#ifdef DEBUG_FIXUP
printf(" %04.4x:%04.4x:%04.4x SELECTOR\n",
dprintf_fixup(stddeb," %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);
@ -449,10 +430,12 @@ FixupSegment(struct w_files * wpnt, int segment_num)
break;
default:
printf("%d: ADDR TYPE %d, TYPE %d, OFFSET %04.4x, ",
dprintf_fixup(stddeb,
"%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);
dprintf_fixup(stddeb,
"TARGET %04.4x %04.4x\n", rep->target1, rep->target2);
free(rep1);
return -1;
}
@ -462,4 +445,60 @@ FixupSegment(struct w_files * wpnt, int segment_num)
return 0;
}
int NEunloadImage(struct w_files *wpnt)
{
printf("NEunloadImage() called!\n");
/* free resources, image */
return 1;
}
int StartNEprogram(struct w_files *wpnt)
{
int cs_reg, ds_reg, ss_reg, ip_reg, sp_reg;
/*
* Fixup stack and jump to start.
*/
WIN_StackSize = wpnt->ne->ne_header->stack_length;
WIN_HeapSize = wpnt->ne->ne_header->local_heap_length;
ds_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->auto_data_seg-1].selector;
cs_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->cs-1].selector;
ip_reg = wpnt->ne->ne_header->ip;
ss_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->ss-1].selector;
sp_reg = wpnt->ne->ne_header->sp;
return CallToInit16(cs_reg << 16 | ip_reg, ss_reg << 16 | sp_reg, ds_reg);
}
void InitNEDLL(struct w_files *wpnt)
{
int cs_reg, ds_reg, ip_reg, rv;
/*
* Is this a library?
*/
if (wpnt->ne->ne_header->format_flags & 0x8000)
{
if (!(wpnt->ne->ne_header->format_flags & 0x0001))
{
/* Not SINGLEDATA */
fprintf(stderr, "Library is not marked SINGLEDATA\n");
exit(1);
}
ds_reg = wpnt->ne->selector_table[wpnt->ne->
ne_header->auto_data_seg-1].selector;
cs_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->cs-1].selector;
ip_reg = wpnt->ne->ne_header->ip;
if (cs_reg) {
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);
} else
printf("%s skipped\n", wpnt->name);
}
}
#endif /* !WINELIB */

499
loader/ne_resource.c Normal file
View File

@ -0,0 +1,499 @@
static char RCSId[] = "$Id: ne_resource.c,v 1.4 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "windows.h"
#include "neexe.h"
#include "peexe.h"
#include "arch.h"
#include "dlls.h"
#include "resource.h"
/* #define DEBUG_RESOURCE */
static int ResourceFd = -1;
static HANDLE ResourceInst = 0;
static struct w_files *ResourceFileInfo;
/**********************************************************************
* RSC_LoadNameTable
*/
void RSC_LoadNameTable(void)
{
struct resource_typeinfo_s typeinfo;
struct resource_nameinfo_s nameinfo;
unsigned short size_shift;
RESNAMTAB *top, *new;
char read_buf[1024];
char *p;
int i;
unsigned short len;
off_t rtoff;
off_t saved_pos;
top = NULL;
/*
* Move to beginning of resource table.
*/
rtoff = (ResourceFileInfo->mz_header->ne_offset +
ResourceFileInfo->ne->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/*
* Read block size.
*/
if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift))
{
return;
}
size_shift = CONV_SHORT(size_shift);
/*
* Find resource.
*/
typeinfo.type_id = 0xffff;
while (typeinfo.type_id != 0)
{
if (!load_typeinfo (ResourceFd, &typeinfo))
break;
if (typeinfo.type_id == 0)
break;
if (typeinfo.type_id == 0x800f)
{
for (i = 0; i < typeinfo.count; i++)
{
if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo))
{
break;
}
saved_pos = lseek(ResourceFd, 0, SEEK_CUR);
lseek(ResourceFd, (long) nameinfo.offset << size_shift,
SEEK_SET);
read(ResourceFd, &len, sizeof(len));
while (len)
{
new = (RESNAMTAB *) GlobalQuickAlloc(sizeof(*new));
new->next = top;
top = new;
read(ResourceFd, &new->type_ord, 2);
read(ResourceFd, &new->id_ord, 2);
read(ResourceFd, read_buf, len - 6);
p = read_buf + strlen(read_buf) + 1;
strncpy(new->id, p, MAX_NAME_LENGTH);
new->id[MAX_NAME_LENGTH - 1] = '\0';
read(ResourceFd, &len, sizeof(len));
}
lseek(ResourceFd, saved_pos, SEEK_SET);
}
break;
}
else
{
lseek(ResourceFd, (typeinfo.count * sizeof(nameinfo)), SEEK_CUR);
}
}
ResourceFileInfo->ne->resnamtab = top;
}
/**********************************************************************
* OpenResourceFile
*/
int
OpenResourceFile(HANDLE instance)
{
struct w_files *w;
char *res_file;
if (ResourceInst == instance)
return ResourceFd;
w = GetFileInfo(instance);
if (w == NULL)
return -1;
ResourceFileInfo = w;
res_file = w->filename;
if (ResourceFd >= 0)
close(ResourceFd);
ResourceInst = instance;
ResourceFd = open (res_file, O_RDONLY);
#if 1
#ifndef WINELIB
if (w->ne->resnamtab == (RESNAMTAB *) -1)
{
RSC_LoadNameTable();
}
#endif
#endif
#ifdef DEBUG_RESOURCE
printf("OpenResourceFile(%04X) // file='%s' hFile=%04X !\n",
instance, w->filename, ResourceFd);
#endif
return ResourceFd;
}
int load_typeinfo (int fd, struct resource_typeinfo_s *typeinfo)
{
return read (fd, typeinfo, sizeof (*typeinfo)) == sizeof (*typeinfo);
}
int type_match(int type_id1, int type_id2, int fd, off_t off)
{
off_t old_pos;
unsigned char c;
size_t nbytes;
char name[256];
if (type_id1 == -1)
return 1;
if ((type_id1 & 0xffff0000) == 0) {
if ((type_id2 & 0x8000) == 0)
return 0;
return (type_id1 & 0x000f) == (type_id2 & 0x000f);
}
if ((type_id2 & 0x8000) != 0)
return 0;
#ifdef DEBUG_RESOURCE
printf("type_compare: type_id2=%04X !\n", type_id2);
#endif
old_pos = lseek(fd, 0, SEEK_CUR);
lseek(fd, off + type_id2, SEEK_SET);
read(fd, &c, 1);
nbytes = CONV_CHAR_TO_LONG (c);
#ifdef DEBUG_RESOURCE
printf("type_compare: namesize=%d\n", nbytes);
#endif
read(fd, name, nbytes);
lseek(fd, old_pos, SEEK_SET);
name[nbytes] = '\0';
#ifdef DEBUG_RESOURCE
printf("type_compare: name=`%s'\n", name);
#endif
return strcasecmp((char *) type_id1, name) == 0;
}
/**********************************************************************
* FindResourceByNumber
*/
int
FindResourceByNumber(struct resource_nameinfo_s *result_p,
int type_id, int resource_id)
{
struct resource_typeinfo_s typeinfo;
struct resource_nameinfo_s nameinfo;
unsigned short size_shift;
int i;
off_t rtoff;
/*
* Move to beginning of resource table.
*/
rtoff = (ResourceFileInfo->mz_header->ne_offset +
ResourceFileInfo->ne->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/*
* Read block size.
*/
if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift))
{
printf("FindResourceByNumber (%d) bad block size !\n",(int) resource_id);
return -1;
}
size_shift = CONV_SHORT(size_shift);
/*
* Find resource.
*/
for (;;) {
if (!load_typeinfo (ResourceFd, &typeinfo)){
printf("FindResourceByNumber (%X) bad typeinfo size !\n", resource_id);
return -1;
}
#ifdef DEBUG_RESOURCE
printf("FindResourceByNumber type=%X count=%d ?=%d searched=%08X\n",
typeinfo.type_id, typeinfo.count, typeinfo.reserved, type_id);
#endif
if (typeinfo.type_id == 0) break;
if (type_match(type_id, typeinfo.type_id, ResourceFd, rtoff)) {
for (i = 0; i < typeinfo.count; i++) {
#ifndef WINELIB
if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo))
#else
if (!load_nameinfo (ResourceFd, &nameinfo))
#endif
{
printf("FindResourceByNumber (%X) bad nameinfo size !\n", resource_id);
return -1;
}
#ifdef DEBUG_RESOURCE
printf("FindResource: search type=%X id=%X // type=%X id=%X\n",
type_id, resource_id, typeinfo.type_id, nameinfo.id);
#endif
if (nameinfo.id == resource_id) {
memcpy(result_p, &nameinfo, sizeof(nameinfo));
return size_shift;
}
}
}
else {
lseek(ResourceFd, (typeinfo.count * sizeof(nameinfo)), SEEK_CUR);
}
}
return -1;
}
/**********************************************************************
* FindResourceByName
*/
int
FindResourceByName(struct resource_nameinfo_s *result_p,
int type_id, char *resource_name)
{
struct resource_typeinfo_s typeinfo;
struct resource_nameinfo_s nameinfo;
unsigned short size_shift;
off_t old_pos, new_pos;
unsigned char nbytes;
char name[256];
int i;
off_t rtoff;
/*
* Check for loaded name table.
*/
if (ResourceFileInfo->ne->resnamtab != NULL)
{
RESNAMTAB *e;
for (e = ResourceFileInfo->ne->resnamtab; e != NULL; e = e->next)
{
if (e->type_ord == (type_id & 0x000f) &&
strcasecmp(e->id, resource_name) == 0)
{
return FindResourceByNumber(result_p, type_id, e->id_ord);
}
}
return -1;
}
/*
* Move to beginning of resource table.
*/
rtoff = (ResourceFileInfo->mz_header->ne_offset +
ResourceFileInfo->ne->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/*
* Read block size.
*/
if (read(ResourceFd, &size_shift, sizeof(size_shift)) !=
sizeof(size_shift))
{
printf("FindResourceByName (%s) bad block size !\n", resource_name);
return -1;
}
size_shift = CONV_SHORT (size_shift);
/*
* Find resource.
*/
for (;;)
{
if (!load_typeinfo (ResourceFd, &typeinfo))
{
printf("FindResourceByName (%s) bad typeinfo size !\n", resource_name);
return -1;
}
#ifdef DEBUG_RESOURCE
printf("FindResourceByName typeinfo.type_id=%X count=%d type_id=%X\n",
typeinfo.type_id, typeinfo.count, type_id);
#endif
if (typeinfo.type_id == 0) break;
if (type_match(type_id, typeinfo.type_id, ResourceFd, rtoff))
{
for (i = 0; i < typeinfo.count; i++)
{
#ifndef WINELIB
if (read(ResourceFd, &nameinfo, sizeof(nameinfo)) !=
sizeof(nameinfo))
#else
if (!load_nameinfo (ResourceFd, &nameinfo))
#endif
{
printf("FindResourceByName (%s) bad nameinfo size !\n", resource_name);
return -1;
}
/*
if ((nameinfo.id & 0x8000) != 0) continue;
*/
#ifdef DEBUG_RESOURCE
printf("FindResourceByName // nameinfo.id=%04X !\n", nameinfo.id);
#endif
old_pos = lseek(ResourceFd, 0, SEEK_CUR);
new_pos = rtoff + nameinfo.id;
lseek(ResourceFd, new_pos, SEEK_SET);
read(ResourceFd, &nbytes, 1);
#ifdef DEBUG_RESOURCE
printf("FindResourceByName // namesize=%d !\n", nbytes);
#endif
nbytes = CONV_CHAR_TO_LONG (nbytes);
read(ResourceFd, name, nbytes);
lseek(ResourceFd, old_pos, SEEK_SET);
name[nbytes] = '\0';
#ifdef DEBUG_RESOURCE
printf("FindResourceByName type_id=%X (%d of %d) name='%s' resource_name='%s'\n",
typeinfo.type_id, i + 1, typeinfo.count,
name, resource_name);
#endif
if (strcasecmp(name, resource_name) == 0)
{
memcpy(result_p, &nameinfo, sizeof(nameinfo));
return size_shift;
}
}
}
else {
lseek(ResourceFd, (typeinfo.count * sizeof(nameinfo)), SEEK_CUR);
}
}
return -1;
}
/**********************************************************************
* GetRsrcCount [internal]
*/
int GetRsrcCount(HINSTANCE hInst, int type_id)
{
struct resource_typeinfo_s typeinfo;
struct resource_nameinfo_s nameinfo;
unsigned short size_shift;
off_t rtoff;
if (hInst == 0) return 0;
#ifdef DEBUG_RESOURCE
printf("GetRsrcCount hInst=%04X typename=%08X\n", hInst, type_id);
#endif
if (OpenResourceFile(hInst) < 0) return 0;
/*
* Move to beginning of resource table.
*/
rtoff = (ResourceFileInfo->mz_header->ne_offset +
ResourceFileInfo->ne->ne_header->resource_tab_offset);
lseek(ResourceFd, rtoff, SEEK_SET);
/*
* Read block size.
*/
if (read(ResourceFd, &size_shift, sizeof(size_shift)) != sizeof(size_shift)) {
printf("GetRsrcCount // bad block size !\n");
return -1;
}
size_shift = CONV_SHORT (size_shift);
for (;;) {
if (!load_typeinfo (ResourceFd, &typeinfo)) {
printf("GetRsrcCount // bad typeinfo size !\n");
return 0;
}
#ifdef DEBUG_RESOURCE
printf("GetRsrcCount // typeinfo.type_id=%X count=%d type_id=%X\n",
typeinfo.type_id, typeinfo.count, type_id);
#endif
if (typeinfo.type_id == 0) break;
if (type_match(type_id, typeinfo.type_id, ResourceFd, rtoff)) {
return typeinfo.count;
}
else {
lseek(ResourceFd, (typeinfo.count * sizeof(nameinfo)), SEEK_CUR);
}
}
return 0;
}
/**********************************************************************
* NE_FindResource [KERNEL.60]
*/
int
NE_FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name,
RESOURCE *r)
{
int type;
#ifdef DEBUG_RESOURCE
printf("NE_FindResource hInst=%04X typename=%08X resname=%08X\n",
instance, type_name, resource_name);
#endif
ResourceFd = r->fd;
ResourceFileInfo = r->wpnt;
/* nametable loaded ? */
if (r->wpnt->ne->resnamtab == NULL)
RSC_LoadNameTable();
if (((int) type_name & 0xffff0000) == 0)
{
type = (int) type_name;
}
else if (type_name[0] == '\0')
{
type = -1;
}
else if (type_name[0] == '#')
{
type = atoi(type_name + 1);
}
else
{
type = (int) type_name;
}
if (((int) resource_name & 0xffff0000) == 0)
{
r->size_shift = FindResourceByNumber(&r->nameinfo, type,
(int) resource_name | 0x8000);
}
else if (resource_name[0] == '\0')
{
r->size_shift = FindResourceByNumber(&r->nameinfo, type, -1);
}
else if (resource_name[0] == '#')
{
r->size_shift = FindResourceByNumber(&r->nameinfo, type,
atoi(resource_name + 1));
}
else
{
r->size_shift = FindResourceByName(&r->nameinfo, type, resource_name);
}
if (r->size_shift == -1)
{
printf("NE_FindResource hInst=%04X typename=%08X resname=%08X not found!\n",
instance, (int) type_name, (int) resource_name);
return 0;
}
r->size = r->nameinfo.length << r->size_shift;
r->offset = r->nameinfo.offset << r->size_shift;
return 1;
}

213
loader/pe_image.c Normal file
View File

@ -0,0 +1,213 @@
/*
* Copyright 1994 Eric Youndale & Erik Bos
*
* based on Eric Youndale's pe-test and:
*
* ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include "windows.h"
#include "dlls.h"
#include "neexe.h"
#include "peexe.h"
#define MAP_ANONYMOUS 0x20
unsigned int load_addr;
void my_wcstombs(char * result, u_short * source, int len)
{
while(len--) {
if(isascii(*source)) *result++ = *source++;
else {
printf("Unable to handle unicode right now\n");
exit(0);
}
};
}
char * xmmap(char * vaddr, unsigned int v_size, int prot, int flags,
int fd, unsigned int file_offset)
{
char * result;
result = mmap(vaddr, v_size, prot, flags, fd, file_offset);
if((unsigned int) result != 0xffffffff) return result;
/* Sigh. Alignment must be wrong for mmap. Do this the hard way. */
if(!(flags & MAP_FIXED)) {
vaddr = 0x40000000;
flags |= MAP_FIXED;
};
mmap(vaddr, v_size, prot, MAP_ANONYMOUS | flags, 0, 0);
lseek(fd, file_offset, SEEK_SET);
read(fd, vaddr, v_size);
return vaddr;
};
dump_exports(struct PE_Export_Directory * pe_exports)
{
char * Module;
int i;
u_short * ordinal;
u_long * function;
u_char ** name, *ename;
Module = ((char *) load_addr) + pe_exports->Name;
printf("\n*******EXPORT DATA*******\nModule name is %s, %d functions, %d names\n",
Module,
pe_exports->Number_Of_Functions,
pe_exports->Number_Of_Names);
ordinal = (u_short *) (((char *) load_addr) + (int) pe_exports->Address_Of_Name_Ordinals);
function = (u_long *) (((char *) load_addr) + (int) pe_exports->AddressOfFunctions);
name = (u_char **) (((char *) load_addr) + (int) pe_exports->AddressOfNames);
printf("%-32s Ordinal Virt Addr\n", "Function Name");
for(i=0; i< pe_exports->Number_Of_Functions; i++)
{
ename = (char *) (((char *) load_addr) + (int) *name++);
printf("%-32s %4d %8.8x\n", ename, *ordinal++, *function++);
}
return;
}
dump_imports(struct PE_Import_Directory *pe_imports)
{
struct PE_Import_Directory * pe_imp;
/* OK, now dump the import list */
printf("\nDumping imports list\n");
pe_imp = pe_imports;
while (pe_imp->ModuleName)
{
char * Module, *Function;
struct pe_import_name * pe_name;
unsigned int * import_list;
char * c;
Module = ((char *) load_addr) + pe_imp->ModuleName;
printf("%s\n", Module);
c = strchr(Module, '.');
if (c) *c = 0;
import_list = (unsigned int *)
(((unsigned int) load_addr) + pe_imp->Import_List);
while(*import_list)
{
pe_name = (struct pe_import_name *) ((int) load_addr + *import_list);
printf("--- %s %s.%d\n", pe_name->Name, Module, pe_name->Hint);
import_list++;
}
pe_imp++;
};
}
static void dump_table(struct w_files *wpnt)
{
int i;
printf("Dump of segment table\n");
printf(" Name VSz Vaddr SzRaw Fileadr *Reloc *Lineum #Reloc #Linum Char\n");
for(i=0; i< wpnt->pe->pe_header->coff.NumberOfSections; i++)
{
printf("%8s: %4.4x %8.8x %8.8x %8.8x %8.8x %8.8x %4.4x %4.4x %8.8x\n",
wpnt->pe->pe_seg[i].Name,
wpnt->pe->pe_seg[i].Virtual_Size,
wpnt->pe->pe_seg[i].Virtual_Address,
wpnt->pe->pe_seg[i].Size_Of_Raw_Data,
wpnt->pe->pe_seg[i].PointerToRawData,
wpnt->pe->pe_seg[i].PointerToRelocations,
wpnt->pe->pe_seg[i].PointerToLinenumbers,
wpnt->pe->pe_seg[i].NumberOfRelocations,
wpnt->pe->pe_seg[i].NumberOfLinenumbers,
wpnt->pe->pe_seg[i].Characteristics);
}
}
/**********************************************************************
* LoadPEImage
* Load one PE format executable into memory
*/
HINSTANCE LoadPEImage(struct w_files *wpnt)
{
int i, result;
wpnt->pe = malloc(sizeof(struct pe_data));
wpnt->pe->pe_header = malloc(sizeof(struct pe_header_s));
/* read PE header */
lseek(wpnt->fd, wpnt->mz_header->ne_offset, SEEK_SET);
read(wpnt->fd, wpnt->pe->pe_header, sizeof(struct pe_header_s));
/* read sections */
wpnt->pe->pe_seg = malloc(sizeof(struct pe_segment_table) *
wpnt->pe->pe_header->coff.NumberOfSections);
read(wpnt->fd, wpnt->pe->pe_seg, sizeof(struct pe_segment_table) *
wpnt->pe->pe_header->coff.NumberOfSections);
load_addr = wpnt->pe->pe_header->opt_coff.BaseOfImage;
dump_table(wpnt);
for(i=0; i < wpnt->pe->pe_header->coff.NumberOfSections; i++)
{
if(!load_addr) {
result = xmmap(0, wpnt->pe->pe_seg[i].Size_Of_Raw_Data, 7, MAP_PRIVATE,
wpnt->fd, wpnt->pe->pe_seg[i].PointerToRawData);
load_addr = (unsigned int) result - wpnt->pe->pe_seg[i].Virtual_Address;
} else {
result = xmmap((char *) load_addr + wpnt->pe->pe_seg[i].Virtual_Address,
wpnt->pe->pe_seg[i].Size_Of_Raw_Data, 7, MAP_PRIVATE | MAP_FIXED,
wpnt->fd, wpnt->pe->pe_seg[i].PointerToRawData);
}
if(strcmp(wpnt->pe->pe_seg[i].Name, ".idata") == 0)
wpnt->pe->pe_import = (struct PE_Import_Directory *) result;
if(strcmp(wpnt->pe->pe_seg[i].Name, ".edata") == 0)
wpnt->pe->pe_export = (struct PE_Export_Directory *) result;
if(strcmp(wpnt->pe->pe_seg[i].Name, ".rsrc") == 0) {
wpnt->pe->pe_resource = (struct PE_Resource_Directory *) result;
/* save offset for PE_FindResource */
wpnt->pe->resource_offset = wpnt->pe->pe_seg[i].Virtual_Address -
wpnt->pe->pe_seg[i].PointerToRawData;
}
}
if(wpnt->pe->pe_import) dump_imports(wpnt->pe->pe_import);
if(wpnt->pe->pe_export) dump_exports(wpnt->pe->pe_export);
wpnt->hinstance = 0x8000;
return (wpnt->hinstance);
}
int PEunloadImage(struct w_files *wpnt)
{
printf("PEunloadImage() called!\n");
/* free resources, image, unmap */
return 1;
}
int StartPEprogram(struct w_files *wpnt)
{
printf("StartPEprogram() called!\n");
return 0;
}
void InitPEDLL(struct w_files *wpnt)
{
/* Is this a library? */
if (wpnt->pe->pe_header->coff.Characteristics & IMAGE_FILE_DLL) {
printf("InitPEDLL() called!\n");
}
}

151
loader/pe_resource.c Normal file
View File

@ -0,0 +1,151 @@
/*
* (c) 1994 Erik Bos <erik@hacktic.nl>
*
* based on Eric Youndale's pe-test and:
*
* ftp.microsoft.com:/pub/developer/MSDN/CD8/PEFILE.ZIP
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "windows.h"
#include "neexe.h"
#include "peexe.h"
#include "dlls.h"
#include "resource.h"
#define DEBUG_RESOURCE
static int
find_lang(char *root, struct PE_Resource_Directory *resource, RESOURCE *r)
{
int i;
struct PE_Directory_Entry *type_dir;
struct PE_Resource_Leaf_Entry *leaf;
type_dir = (struct PE_Directory_Entry *)(resource + 1);
type_dir += resource->NumberOfNamedEntries;
/* grab the 1st resource available */
leaf = (struct PE_Resource_Leaf_Entry *) (root + type_dir->OffsetToData);
#ifdef DEBUG_RESOURCE
printf("\t\tPE_findlang: id %8x\n", (int) type_dir->Name);
printf("\t\taddress %d, size %d, language id %d\n", leaf->OffsetToData, leaf->Size, leaf->CodePage);
#endif
r->offset = leaf->OffsetToData - r->wpnt->pe->resource_offset;
r->size = leaf->Size;
printf("\t\toffset %d, size %d\n", r->offset, r->size);
return 1;
/* for(i=0; i< resource->NumberOfIdEntries; i++) {
leaf = (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY));
#ifdef DEBUG_RESOURCE
printf("\t\tPE_findlang: id %8x\n", (int) type_dir->Name);
printf("\t\t%x %x %x\n", leaf->OffsetToData, leaf->Size,
leaf->CodePage);
#endif
type_dir++;
} */
}
static int
find_resource(char *root, struct PE_Resource_Directory *resource,
LPSTR resource_name, RESOURCE *r)
{
int i;
char res_name[256];
struct PE_Directory_Entry *type_dir;
struct PE_Directory_Name_String_U *name;
type_dir = (struct PE_Directory_Entry *)(resource + 1);
if (HIWORD((DWORD)resource_name)) {
for(i=0; i< resource->NumberOfNamedEntries; i++) {
name = (struct PE_Directory_Name_String_U *)(root + (type_dir->Name & ~IMAGE_RESOURCE_NAME_IS_STRING));
memset(res_name, 0, sizeof(res_name));
my_wcstombs(res_name, name->NameString, name->Length);
#ifdef DEBUG_RESOURCE
printf("\tPE_findresource: name %s\n", res_name);
#endif
if (strcasecmp(res_name, resource_name) == 0)
return find_lang(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), r);
type_dir++;
}
} else {
type_dir += resource->NumberOfNamedEntries;
for(i=0; i< resource->NumberOfIdEntries; i++) {
#ifdef DEBUG_RESOURCE
printf("\tPE_findresource: name %8x\n", (int) type_dir->Name);
#endif
if (type_dir->Name == ((int) resource_name & 0xff))
return find_lang(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), r);
type_dir++;
}
}
return 0;
}
static int
find_type(struct PE_Resource_Directory *resource, LPSTR resource_name,
LPSTR type_name, RESOURCE *r)
{
int i;
char *root, res_name[256];
struct PE_Directory_Entry *type_dir;
struct PE_Directory_Name_String_U *name;
root = (char *) resource;
type_dir = (struct PE_Directory_Entry *)(resource + 1);
if (HIWORD((DWORD)type_name)) {
for(i=0; i< resource->NumberOfNamedEntries; i++) {
name = (struct PE_Directory_Name_String_U *)(root + (type_dir->Name & ~IMAGE_RESOURCE_NAME_IS_STRING));
memset(res_name, 0, sizeof(res_name));
my_wcstombs(res_name, name->NameString, name->Length);
#ifdef DEBUG_RESOURCE
printf("PE_findtype: type %s\n", res_name);
#endif
if (strcasecmp(res_name, type_name) == 0)
return find_resource(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), resource_name, r);
type_dir++;
}
} else {
type_dir += resource->NumberOfNamedEntries;
for(i=0; i< resource->NumberOfIdEntries; i++) {
#ifdef DEBUG_RESOURCE
printf("PE_findtype: type %8x\n", (int) type_dir->Name);
#endif
if (type_dir->Name == ((int) type_name & 0xff))
return find_resource(root, (struct PE_Resource_Directory *) (root + (type_dir->OffsetToData & ~IMAGE_RESOURCE_DATA_IS_DIRECTORY)), resource_name, r);
type_dir++;
}
}
return 0;
}
/**********************************************************************
* PE_FindResource [KERNEL.60]
*/
int
PE_FindResource(HANDLE instance, LPSTR resource_name, LPSTR type_name,
RESOURCE *r)
{
#ifdef DEBUG_RESOURCE
printf("PE_FindResource hInst=%04X typename=%08X resname=%08X\n",
instance, (int) type_name, (int) resource_name);
#endif
if (HIWORD((DWORD)resource_name))
if (resource_name[0] == '#')
resource_name = (LPSTR) atoi(resource_name + 1);
if (HIWORD((DWORD)type_name))
if (type_name[0] == '#')
type_name = (LPSTR) atoi(type_name + 1);
return find_type(r->wpnt->pe->pe_resource, resource_name, type_name,r);
}

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,7 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include <errno.h>
#ifdef __linux__
#include <sys/mman.h>
#include <linux/unistd.h>
#include <linux/head.h>
#include <linux/mman.h>
@ -28,8 +29,10 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "wine.h"
#include "windows.h"
#include "prototypes.h"
#include "debug.h"
/* #define DEBUG_SELECTORS /* */
/* #undef DEBUG_SELECTORS /* */
#ifdef linux
#define DEV_ZERO
@ -60,7 +63,6 @@ SEGDESC Segments[MAX_SELECTORS];
extern void KERNEL_Ordinal_102();
extern void UNIXLIB_Ordinal_0();
extern char *WIN_ProgramName;
extern char WindowsPath[256];
extern char **Argv;
@ -505,8 +507,7 @@ CreateNewSegments(int code_flag, int read_only, int length, int n_segments)
i = FindUnusedSelectors(n_segments);
#ifdef DEBUG_SELECTORS
fprintf(stderr,
"Using %d segments starting at index %d.\n", n_segments, i);
fprintf(stddeb, "Using %d segments starting at index %d.\n", n_segments, i);
#endif
/*
@ -609,10 +610,10 @@ unsigned int GetEntryDLLName(char * dll_name, char * function, int * sel,
/* Not a builtin symbol, look to see what the file has for us */
for(wpnt = wine_files; wpnt; wpnt = wpnt->next){
if(strcasecmp(wpnt->name, dll_name)) continue;
cpnt = wpnt->nrname_table;
cpnt = wpnt->ne->nrname_table;
while(1==1){
if( ((int) cpnt) - ((int)wpnt->nrname_table) >
wpnt->ne_header->nrname_tab_length) return 1;
if( ((int) cpnt) - ((int)wpnt->ne->nrname_table) >
wpnt->ne->ne_header->nrname_tab_length) return 1;
len = *cpnt++;
if(strncmp(cpnt, function, len) == 0) break;
cpnt += len + 2;
@ -662,9 +663,8 @@ GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal)
{
int fd = wpnt->fd;
struct mz_header_s *mz_header = wpnt->mz_header;
struct ne_header_s *ne_header = wpnt->ne_header;
struct ne_header_s *ne_header = wpnt->ne->ne_header;
union lookup entry_tab_pointer;
struct entry_tab_header_s *eth;
struct entry_tab_movable_s *etm;
@ -672,8 +672,7 @@ GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal)
int current_ordinal;
int i;
entry_tab_pointer.cpnt = wpnt->lookup_table;
entry_tab_pointer.cpnt = wpnt->ne->lookup_table;
/*
* Let's walk through the table until we get to our entry.
*/
@ -707,7 +706,7 @@ GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal)
if (current_ordinal == ordinal)
{
return ((unsigned int)
(wpnt->selector_table[etm->seg_number - 1].base_addr +
(wpnt->ne->selector_table[etm->seg_number - 1].base_addr +
etm->offset));
}
}
@ -718,7 +717,7 @@ GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal)
if (current_ordinal == ordinal)
{
return ((unsigned int)
(wpnt->selector_table[eth->seg_number - 1].base_addr +
(wpnt->ne->selector_table[eth->seg_number - 1].base_addr +
(int) etf->offset[0] +
((int) etf->offset[1] << 8)));
}
@ -726,73 +725,6 @@ GetEntryPointFromOrdinal(struct w_files * wpnt, int ordinal)
}
}
}
/**********************************************************************
*/
void
FixupFunctionPrologs(struct w_files * wpnt)
{
struct mz_header_s *mz_header = wpnt->mz_header;
struct ne_header_s *ne_header = wpnt->ne_header;
union lookup entry_tab_pointer;
struct entry_tab_header_s *eth;
struct entry_tab_movable_s *etm;
struct entry_tab_fixed_s *etf;
unsigned char *fixup_ptr;
int i;
if (!(ne_header->format_flags & 0x0001))
return;
entry_tab_pointer.cpnt = wpnt->lookup_table;
/*
* Let's walk through the table and fixup prologs as we go.
*/
while (1)
{
/* Get bundle header */
eth = entry_tab_pointer.eth++;
/* Check for end of table */
if (eth->n_entries == 0)
return;
/* Check for empty bundle */
if (eth->seg_number == 0)
continue;
/* Examine each bundle */
for (i = 0; i < eth->n_entries; i++)
{
/* Moveable segment */
if (eth->seg_number >= 0xfe)
{
etm = entry_tab_pointer.etm++;
fixup_ptr = (wpnt->selector_table[etm->seg_number-1].base_addr
+ etm->offset);
}
else
{
etf = entry_tab_pointer.etf++;
fixup_ptr = (wpnt->selector_table[eth->seg_number-1].base_addr
+ (int) etf->offset[0]
+ ((int) etf->offset[1] << 8));
}
/* Verify the signature */
if (((fixup_ptr[0] == 0x1e && fixup_ptr[1] == 0x58)
|| (fixup_ptr[0] == 0x8c && fixup_ptr[1] == 0xd8))
&& fixup_ptr[2] == 0x90)
{
fixup_ptr[0] = 0xb8; /* MOV AX, */
fixup_ptr[1] = wpnt->hinstance;
fixup_ptr[2] = (wpnt->hinstance >> 8);
}
}
}
}
/**********************************************************************
* GetDOSEnvironment
@ -810,7 +742,6 @@ CreateEnvironment(void)
{
char **e;
char *p;
unsigned short *w;
SEGDESC * s;
s = CreateNewSegments(0, 0, PAGE_SIZE, 1);
@ -836,18 +767,15 @@ CreateEnvironment(void)
}
*p++ = '\0';
w = (unsigned short *) p;
*w = strlen(WIN_ProgramName);
strcpy(p + 2, WIN_ProgramName);
/*
* Display environment
*/
fprintf(stderr, "Environment at %08.8x\n", s->base_addr);
#ifdef DEBUG_SELECTORS
fprintf(stddeb, "Environment at %08.8x\n", s->base_addr);
for (p = s->base_addr; *p; p += strlen(p) + 1)
fprintf(stderr, " %s\n", p);
p += 3;
fprintf(stderr, " Program: %s\n", p);
fprintf(stddeb, " %s\n", p);
#endif
return s;
}
@ -918,8 +846,8 @@ SEGDESC *
CreateSelectors(struct w_files * wpnt)
{
int fd = wpnt->fd;
struct ne_segment_table_entry_s *seg_table = wpnt->seg_table;
struct ne_header_s *ne_header = wpnt->ne_header;
struct ne_segment_table_entry_s *seg_table = wpnt->ne->seg_table;
struct ne_header_s *ne_header = wpnt->ne->ne_header;
SEGDESC *selectors, *s, *stmp;
unsigned short auto_data_sel;
int contents, read_only;
@ -1059,13 +987,78 @@ CreateSelectors(struct w_files * wpnt)
return selectors;
}
/**********************************************************************
*/
void
FixupFunctionPrologs(struct w_files * wpnt)
{
struct mz_header_s *mz_header = wpnt->mz_header;
struct ne_header_s *ne_header = wpnt->ne->ne_header;
union lookup entry_tab_pointer;
struct entry_tab_header_s *eth;
struct entry_tab_movable_s *etm;
struct entry_tab_fixed_s *etf;
unsigned char *fixup_ptr;
int i;
if (!(ne_header->format_flags & 0x0001))
return;
entry_tab_pointer.cpnt = wpnt->ne->lookup_table;
/*
* Let's walk through the table and fixup prologs as we go.
*/
while (1)
{
/* Get bundle header */
eth = entry_tab_pointer.eth++;
/* Check for end of table */
if (eth->n_entries == 0)
return;
/* Check for empty bundle */
if (eth->seg_number == 0)
continue;
/* Examine each bundle */
for (i = 0; i < eth->n_entries; i++)
{
/* Moveable segment */
if (eth->seg_number >= 0xfe)
{
etm = entry_tab_pointer.etm++;
fixup_ptr = (wpnt->ne->selector_table[etm->seg_number-1].base_addr
+ etm->offset);
}
else
{
etf = entry_tab_pointer.etf++;
fixup_ptr = (wpnt->ne->selector_table[eth->seg_number-1].base_addr
+ (int) etf->offset[0]
+ ((int) etf->offset[1] << 8));
}
/* Verify the signature */
if (((fixup_ptr[0] == 0x1e && fixup_ptr[1] == 0x58)
|| (fixup_ptr[0] == 0x8c && fixup_ptr[1] == 0xd8))
&& fixup_ptr[2] == 0x90)
{
fixup_ptr[0] = 0xb8; /* MOV AX, */
fixup_ptr[1] = wpnt->hinstance;
fixup_ptr[2] = (wpnt->hinstance >> 8);
}
}
}
}
/***********************************************************************
* GetSelectorBase (KERNEL.186)
*/
DWORD GetSelectorBase(WORD wSelector)
{
fprintf(stderr, "GetSelectorBase(selector %4X) stub!\n", wSelector);
fprintf(stdnimp, "GetSelectorBase(selector %4X) stub!\n", wSelector);
}
/***********************************************************************
@ -1073,7 +1066,7 @@ DWORD GetSelectorBase(WORD wSelector)
*/
void SetSelectorBase(WORD wSelector, DWORD dwBase)
{
fprintf(stderr, "SetSelectorBase(selector %4X, base %8X) stub!\n",
fprintf(stdnimp, "SetSelectorBase(selector %4X, base %8X) stub!\n",
wSelector, dwBase);
}
@ -1082,7 +1075,7 @@ void SetSelectorBase(WORD wSelector, DWORD dwBase)
*/
DWORD GetSelectorLimit(WORD wSelector)
{
fprintf(stderr, "GetSelectorLimit(selector %4X) stub!\n", wSelector);
fprintf(stdnimp, "GetSelectorLimit(selector %4X) stub!\n", wSelector);
return 0xffff;
}
@ -1092,7 +1085,7 @@ DWORD GetSelectorLimit(WORD wSelector)
*/
void SetSelectorLimit(WORD wSelector, DWORD dwLimit)
{
fprintf(stderr, "SetSelectorLimit(selector %4X, base %8X) stub!\n",
fprintf(stdnimp, "SetSelectorLimit(selector %4X, base %8X) stub!\n",
wSelector, dwLimit);
}

View File

@ -12,14 +12,26 @@
#include <syscall.h>
#endif
#ifdef linux
#define inline __inline__ /* So we can compile with -ansi */
#include <linux/sched.h>
#include <asm/system.h>
#undef inline
#endif
#include "wine.h"
#include "segmem.h"
#include "prototypes.h"
#include "win.h"
extern int do_int10(struct sigcontext_struct *);
extern int do_int13(struct sigcontext_struct *);
extern int do_int15(struct sigcontext_struct *);
extern int do_int16(struct sigcontext_struct *);
extern int do_int25(struct sigcontext_struct *);
extern int do_int26(struct sigcontext_struct *);
extern int do_int2a(struct sigcontext_struct *);
extern int do_int2f(struct sigcontext_struct *);
extern int do_int31(struct sigcontext_struct *);
#if !defined(BSD4_4) || defined(linux)
char * cstack[4096];
@ -90,8 +102,6 @@ static void win_fault(int signal, int code, struct sigcontext *scp)
{
#endif
unsigned char * instr;
unsigned int * dump;
int i;
/* First take care of a few preliminaries */
#ifdef linux

View File

@ -3,9 +3,6 @@
*/
static char Copyright[] = "Copyright Martin Ayotte, 1994";
/*
#define DEBUG_TASK
*/
#include <stdio.h>
#include <stdlib.h>
@ -15,6 +12,12 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#include "windows.h"
#include "wine.h"
#include "task.h"
#include "debug.h"
/* #define DEBUG_TASK /* */
/* #undef DEBUG_TASK /* */
static LPWINETASKENTRY lpTaskList = NULL;
static int nTaskCount = 0;
@ -27,7 +30,7 @@ HTASK GetCurrentTask()
LPWINETASKENTRY lpTask = lpTaskList;
int pid = getpid();
#ifdef DEBUG_TASK
printf("GetCurrentTask() // unix_pid=%08X !\n", pid);
fprintf(stddeb,"GetCurrentTask() // unix_pid=%08X !\n", pid);
#endif
if (lpTask == NULL) return 0;
while (TRUE) {
@ -36,7 +39,7 @@ HTASK GetCurrentTask()
lpTask = lpTask->lpNextTask;
}
#ifdef DEBUG_TASK
printf("GetCurrentTask() returned hTask=%04X !\n", lpTask->te.hTask);
fprintf(stddeb,"GetCurrentTask() returned hTask=%04X !\n", lpTask->te.hTask);
#endif
return lpTask->te.hTask;
}
@ -47,7 +50,9 @@ HTASK GetCurrentTask()
*/
WORD GetNumTasks()
{
printf("GetNumTasks() returned %d !\n", nTaskCount);
#ifdef DEBUG_TASK
fprintf(stddeb,"GetNumTasks() returned %d !\n", nTaskCount);
#endif
return nTaskCount;
}
@ -60,17 +65,23 @@ HTASK GetWindowTask(HWND hWnd)
HWND *wptr;
int count;
LPWINETASKENTRY lpTask = lpTaskList;
printf("GetWindowTask(%04X) !\n", hWnd);
#ifdef DEBUG_TASK
fprintf(stddeb,"GetWindowTask(%04X) !\n", hWnd);
#endif
while (lpTask != NULL) {
wptr = lpTask->lpWndList;
if (wptr != NULL) {
count = 0;
while (++count < MAXWIN_PER_TASK) {
printf("GetWindowTask // searching %04X %04X !\n",
#ifdef DEBUG_TASK
fprintf(stddeb,"GetWindowTask // searching %04X %04X !\n",
lpTask->te.hTask, *(wptr));
#endif
if (*(wptr) == hWnd) {
printf("GetWindowTask(%04X) found hTask=%04X !\n",
#ifdef DEBUG_TASK
fprintf(stddeb,"GetWindowTask(%04X) found hTask=%04X !\n",
hWnd, lpTask->te.hTask);
#endif
return lpTask->te.hTask;
}
wptr++;
@ -91,22 +102,30 @@ BOOL EnumTaskWindows(HANDLE hTask, FARPROC lpEnumFunc, LONG lParam)
BOOL bRet;
int count = 0;
LPWINETASKENTRY lpTask = lpTaskList;
printf("EnumTaskWindows(%04X, %08X, %08X) !\n", hTask, lpEnumFunc, lParam);
#ifdef DEBUG_TASK
fprintf(stddeb,"EnumTaskWindows(%04X, %08X, %08X) !\n", hTask, lpEnumFunc, lParam);
#endif
while (TRUE) {
if (lpTask->te.hTask == hTask) break;
if (lpTask == NULL) {
printf("EnumTaskWindows // hTask=%04X not found !\n", hTask);
#ifdef DEBUG_TASK
fprintf(stddeb,"EnumTaskWindows // hTask=%04X not found !\n", hTask);
#endif
return FALSE;
}
lpTask = lpTask->lpNextTask;
}
printf("EnumTaskWindows // found hTask=%04X !\n", hTask);
#ifdef DEBUG_TASK
fprintf(stddeb,"EnumTaskWindows // found hTask=%04X !\n", hTask);
#endif
wptr = lpTask->lpWndList;
if (wptr == NULL) return FALSE;
if (lpEnumFunc == NULL) return FALSE;
while ((hWnd = *(wptr++)) != 0) {
if (++count >= MAXWIN_PER_TASK) return FALSE;
printf("EnumTaskWindows // hWnd=%04X count=%d !\n", hWnd, count);
#ifdef DEBUG_TASK
fprintf(stddeb,"EnumTaskWindows // hWnd=%04X count=%d !\n", hWnd, count);
#endif
#ifdef WINELIB
bRet = (*lpEnumFunc)(hWnd, lParam);
#else
@ -140,7 +159,7 @@ HANDLE CreateNewTask(HINSTANCE hInst, HTASK hTaskParent)
hTask = GlobalAlloc(GMEM_MOVEABLE, sizeof(WINETASKENTRY));
lpNewTask = (LPWINETASKENTRY) GlobalLock(hTask);
#ifdef DEBUG_TASK
printf("CreateNewTask entry allocated %08X\n", lpNewTask);
fprintf(stddeb,"CreateNewTask entry allocated %08X\n", lpNewTask);
#endif
if (lpNewTask == NULL) return 0;
if (lpTaskList == NULL) {
@ -173,7 +192,7 @@ HANDLE CreateNewTask(HINSTANCE hInst, HTASK hTaskParent)
if (lpNewTask->lpWndList != NULL)
memset((LPSTR)lpNewTask->lpWndList, 0, MAXWIN_PER_TASK * sizeof(HWND));
#ifdef DEBUG_TASK
printf("CreateNewTask // unix_pid=%08X return hTask=%04X\n",
fprintf(stddeb,"CreateNewTask // unix_pid=%08X return hTask=%04X\n",
lpNewTask->unix_pid, hTask);
#endif
GlobalUnlock(hTask);
@ -191,12 +210,12 @@ BOOL AddWindowToTask(HTASK hTask, HWND hWnd)
int count = 0;
LPWINETASKENTRY lpTask = lpTaskList;
#ifdef DEBUG_TASK
printf("AddWindowToTask(%04X, %04X); !\n", hTask, hWnd);
fprintf(stddeb,"AddWindowToTask(%04X, %04X); !\n", hTask, hWnd);
#endif
while (TRUE) {
if (lpTask->te.hTask == hTask) break;
if (lpTask == NULL) {
printf("AddWindowToTask // hTask=%04X not found !\n", hTask);
fprintf(stderr,"AddWindowToTask // hTask=%04X not found !\n", hTask);
return FALSE;
}
lpTask = lpTask->lpNextTask;
@ -209,7 +228,7 @@ BOOL AddWindowToTask(HTASK hTask, HWND hWnd)
}
*wptr = hWnd;
#ifdef DEBUG_TASK
printf("AddWindowToTask // window added, count=%d !\n", count);
fprintf(stddeb,"AddWindowToTask // window added, count=%d !\n", count);
#endif
return TRUE;
}
@ -224,12 +243,12 @@ BOOL RemoveWindowFromTask(HTASK hTask, HWND hWnd)
int count = 0;
LPWINETASKENTRY lpTask = lpTaskList;
#ifdef DEBUG_TASK
printf("RemoveWindowToTask(%04X, %04X); !\n", hTask, hWnd);
fprintf(stddeb,"RemoveWindowToTask(%04X, %04X); !\n", hTask, hWnd);
#endif
while (TRUE) {
if (lpTask->te.hTask == hTask) break;
if (lpTask == NULL) {
printf("RemoveWindowFromTask // hTask=%04X not found !\n", hTask);
fprintf(stderr,"RemoveWindowFromTask // hTask=%04X not found !\n", hTask);
return FALSE;
}
lpTask = lpTask->lpNextTask;
@ -246,15 +265,16 @@ BOOL RemoveWindowFromTask(HTASK hTask, HWND hWnd)
wptr++;
}
#ifdef DEBUG_TASK
printf("RemoveWindowFromTask // window removed, count=%d !\n", --count);
fprintf(stddeb,"RemoveWindowFromTask // window removed, count=%d !\n", --count);
#endif
return TRUE;
}
BOOL TaskFirst(LPTASKENTRY lpTask)
{
printf("TaskFirst(%8x)\n", (int) lpTask);
#ifdef DEBUG_TASK
fprintf(stddeb,"TaskFirst(%8x)\n", (int) lpTask);
#endif
if (lpTaskList) {
memcpy(lpTask, &lpTaskList->te, lpTask->dwSize);
return TRUE;
@ -265,9 +285,9 @@ BOOL TaskFirst(LPTASKENTRY lpTask)
BOOL TaskNext(LPTASKENTRY lpTask)
{
LPWINETASKENTRY list;
printf("TaskNext(%8x)\n", (int) lpTask);
#ifdef DEBUG_TASK
fprintf(stddeb,"TaskNext(%8x)\n", (int) lpTask);
#endif
list = lpTaskList;
while (list) {
if (list->te.hTask == lpTask->hTask) {
@ -286,9 +306,9 @@ BOOL TaskNext(LPTASKENTRY lpTask)
BOOL TaskFindHandle(LPTASKENTRY lpTask, HTASK hTask)
{
static LPWINETASKENTRY list;
printf("TaskFindHandle(%8x,%4x)\n", (int) lpTask, hTask);
#ifdef DEBUG_TASK
fprintf(stddeb,"TaskFindHandle(%8x,%4x)\n", (int) lpTask, hTask);
#endif
list = lpTaskList;
while (list) {
if (list->te.hTask == hTask) {

View File

@ -11,7 +11,6 @@ OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

View File

@ -1,7 +1,6 @@
static char RCSId[] = "$Id: global.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
/* #define DEBUG_HEAP /* */
#define GLOBAL_SOURCE
#include <stdio.h>
@ -11,6 +10,11 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "toolhelp.h"
#include "heap.h"
#include "segmem.h"
#include "stddebug.h"
/* #define DEBUG_HEAP /* */
/* #undef DEBUG_HEAP /* */
#include "debug.h"
GDESC *GlobalList = NULL;
static unsigned short next_unused_handle = 1;
@ -99,7 +103,7 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments)
s = CreateNewSegments(0, 0, 0x10000, n_segments);
if (s == NULL)
{
printf("GlobalGetFreeSegments // bad CreateNewSegments !\n");
fprintf(stderr,"GlobalGetFreeSegments // bad CreateNewSegments !\n");
return NULL;
}
for (count = 0; count < n_segments; count++, s++)
@ -107,7 +111,7 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments)
g = (GDESC *) malloc(sizeof(*g));
if (g == NULL)
{
printf("GlobalGetFreeSegments // bad GDESC malloc !\n");
fprintf(stderr,"GlobalGetFreeSegments // bad GDESC malloc !\n");
return NULL;
}
g->prev = g_prev;
@ -145,7 +149,7 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments)
{
if (g == NULL)
{
printf("GlobalGetFreeSegments // bad Segments chain !\n");
fprintf(stderr,"GlobalGetFreeSegments // bad Segments chain !\n");
return NULL;
}
g->sequence = i + 1;
@ -178,9 +182,9 @@ GlobalAlloc(unsigned int flags, unsigned long size)
GDESC *g_prev;
void *m;
#ifdef DEBUG_HEAP
printf("GlobalAlloc flags %4X, size %d\n", flags, size);
#endif
dprintf_heap(stddeb,"GlobalAlloc flags %4X, size %d\n", flags, size);
if (size == 0) size = 1;
/*
* If this block is fixed or very big we need to allocate entire
@ -243,9 +247,7 @@ GlobalAlloc(unsigned int flags, unsigned long size)
* We have a new block. Let's create a GDESC entry for it.
*/
g = malloc(sizeof(*g));
#ifdef DEBUG_HEAP
printf("New GDESC %08x\n", g);
#endif
dprintf_heap(stddeb,"New GDESC %08x\n", g);
if (g == NULL)
return 0;
@ -268,9 +270,7 @@ GlobalAlloc(unsigned int flags, unsigned long size)
if ((next_unused_handle & 7) == 7)
next_unused_handle++;
#ifdef DEBUG_HEAP
printf("GlobalAlloc: returning %04x\n", g->handle);
#endif
dprintf_heap(stddeb,"GlobalAlloc: returning %04x\n", g->handle);
return g->handle;
}
}
@ -344,9 +344,7 @@ GlobalLock(unsigned int block)
g->lock_count++;
#ifdef DEBUG_HEAP
printf("GlobalLock: returning %08x\n", g->addr);
#endif
dprintf_heap(stddeb,"GlobalLock: returning %08x\n", g->addr);
return g->addr;
}
@ -804,8 +802,8 @@ DWORD GetFreeSpace(UINT wFlags)
for (i = 0; i < 512; i++)
if (free_map[i] == 1)
total_free++;
printf("GetFreeSpace // return %ld !\n", total_free << 16);
dprintf_heap(stddeb,"GetFreeSpace // return %ld !\n", total_free << 16);
return total_free << 16;
}
@ -816,3 +814,12 @@ BOOL MemManInfo(LPMEMMANINFO lpmmi)
{
return 1;
}
/***********************************************************************
* SetSwapAreaSize (KERNEL.106)
*/
LONG SetSwapAreaSize( WORD size )
{
printf( "STUB: SetSwapAreaSize(%d)\n", size );
return MAKELONG( size, 0xffff );
}

View File

@ -8,8 +8,11 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "segmem.h"
#include "heap.h"
#include "regfunc.h"
#include "stddebug.h"
/* #define DEBUG_HEAP /* */
/* #undef DEBUG_HEAP /* */
#include "debug.h"
LHEAP *LocalHeaps = NULL;
@ -46,9 +49,9 @@ HEAP_Alloc(MDESC **free_list, int flags, int bytes)
{
MDESC *m, *m_new;
#ifdef DEBUG_HEAP
printf("HeapAlloc: free_list %08x, flags %x, bytes %d\n",
dprintf_heap(stddeb,"HeapAlloc: free_list %08x, flags %x, bytes %d\n",
free_list, flags, bytes);
#ifdef DEBUG_HEAP
HEAP_CheckHeap(free_list);
#endif
@ -83,8 +86,8 @@ HEAP_Alloc(MDESC **free_list, int flags, int bytes)
m->flags = 0;
if (flags & GLOBAL_FLAGS_ZEROINIT)
memset(m + 1, 0, bytes);
dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", (m + 1));
#ifdef DEBUG_HEAP
printf("HeapAlloc: returning %08x\n", (m + 1));
HEAP_CheckHeap(free_list);
#endif
return (void *) (m + 1);
@ -107,15 +110,15 @@ HEAP_Alloc(MDESC **free_list, int flags, int bytes)
m->flags = 0;
if (flags & GLOBAL_FLAGS_ZEROINIT)
memset(m + 1, 0, bytes);
dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", (m + 1));
#ifdef DEBUG_HEAP
printf("HeapAlloc: returning %08x\n", (m + 1));
HEAP_CheckHeap(free_list);
#endif
return (void *) (m + 1);
}
dprintf_heap(stddeb,"HeapAlloc: returning %08x\n", 0);
#ifdef DEBUG_HEAP
printf("HeapAlloc: returning %08x\n", 0);
HEAP_CheckHeap(free_list);
#endif
return 0;
@ -140,40 +143,36 @@ HEAP_ReAlloc(MDESC **free_list, void *old_block,
*/
m = (MDESC *) old_block - 1;
dprintf_heap(stddeb,"HEAP_ReAlloc new_size=%d !\n", new_size);
dprintf_heap(stddeb,"HEAP_ReAlloc old_block=%08X !\n", old_block);
dprintf_heap(stddeb,"HEAP_ReAlloc m=%08X free_list=%08X !\n", m,free_list);
dprintf_heap(stddeb,"HEAP_ReAlloc m->prev=%08X !\n", m->prev);
dprintf_heap(stddeb,"HEAP_ReAlloc m->next=%08X !\n", m->next);
dprintf_heap(stddeb,"HEAP_ReAlloc *free_list=%08X !\n", *free_list);
#ifdef DEBUG_HEAP
printf("HEAP_ReAlloc new_size=%d !\n", new_size);
printf("HEAP_ReAlloc old_block=%08X !\n", old_block);
printf("HEAP_ReAlloc m=%08X free_list=%08X !\n", m, free_list);
printf("HEAP_ReAlloc m->prev=%08X !\n", m->prev);
printf("HEAP_ReAlloc m->next=%08X !\n", m->next);
printf("HEAP_ReAlloc *free_list=%08X !\n", *free_list);
HEAP_CheckHeap(free_list);
#endif
if (m->prev != m || m->next != m ||
((int) m & 0xffff0000) != ((int) *free_list & 0xffff0000))
{
#ifdef DEBUG_HEAP
printf("Attempt to resize bad pointer, m = %08x, *free_list = %08x\n",
fprintf(stderr,"Attempt to resize bad pointer, m = %08x, *free_list = %08x\n",
m, free_list);
HEAP_CheckHeap(free_list);
#endif
return NULL;
}
/*
* Check for grow block
*/
#ifdef DEBUG_HEAP
printf("HEAP_ReAlloc Check for grow block !\n");
#endif
dprintf_heap(stddeb,"HEAP_ReAlloc Check for grow block !\n");
if (new_size > m->length)
{
m_free = m + 1 + m->length / sizeof(MDESC);
if (m_free->next == m_free ||
m_free->prev == m_free ||
m_free->length + sizeof(MDESC) < new_size)
m_free->length + 2*sizeof(MDESC) < new_size - m->length)
{
void *new_p = HEAP_Alloc(free_list, flags, new_size);
if (new_p ==NULL)
@ -196,9 +195,7 @@ HEAP_ReAlloc(MDESC **free_list, void *old_block,
m->length += sizeof(MDESC) + m_free->length;
#ifdef DEBUG_HEAP
printf("HEAP_ReAlloc before GLOBAL_FLAGS_ZEROINIT !\n");
#endif
dprintf_heap(stddeb,"HEAP_ReAlloc before GLOBAL_FLAGS_ZEROINIT !\n");
if (flags & GLOBAL_FLAGS_ZEROINIT)
memset(m_free, '\0', sizeof(MDESC) + m_free->length);
}
@ -206,15 +203,13 @@ HEAP_ReAlloc(MDESC **free_list, void *old_block,
/*
* Check for shrink block.
*/
#ifdef DEBUG_HEAP
printf("HEAP_ReAlloc Check for shrink block !\n");
#endif
if (new_size < m->length - 4 * sizeof(MDESC))
dprintf_heap(stddeb,"HEAP_ReAlloc Check for shrink block !\n");
if (new_size + 4*sizeof(MDESC) < m->length)
{
m_free = m + new_size / sizeof(MDESC) + 2;
m_free->next = m_free;
m_free->prev = m_free;
m_free->length = m->length - (int) m_free - (int) m;
m_free->length = m->length - ((int) m_free - (int) m);
m->length = (int) m_free - (int) (m + 1);
HEAP_Free(free_list, m_free + 1);
}
@ -236,9 +231,9 @@ HEAP_Free(MDESC **free_list, void *block)
MDESC *m;
MDESC *m_prev;
#ifdef DEBUG_HEAP
printf("HeapFree: free_list %08x, block %08x\n",
dprintf_heap(stddeb,"HeapFree: free_list %08x, block %08x\n",
free_list, block);
#ifdef DEBUG_HEAP
HEAP_CheckHeap(free_list);
#endif
@ -248,11 +243,9 @@ HEAP_Free(MDESC **free_list, void *block)
m_free = (MDESC *) block - 1;
if (m_free->prev != m_free || m_free->next != m_free)
{
#ifdef DEBUG_HEAP
printf("Attempt to free bad pointer,"
fprintf(stderr,"Attempt to free bad pointer,"
"m_free = %08x, *free_list = %08x\n",
m_free, free_list);
#endif
return -1;
}
@ -265,11 +258,9 @@ HEAP_Free(MDESC **free_list, void *block)
}
else if (((int) m_free & 0xffff0000) != ((int) *free_list & 0xffff0000))
{
#ifdef DEBUG_HEAP
printf("Attempt to free bad pointer,"
fprintf(stderr,"Attempt to free bad pointer,"
"m_free = %08x, *free_list = %08x\n",
m_free, free_list);
#endif
return -1;
}
@ -282,22 +273,18 @@ HEAP_Free(MDESC **free_list, void *block)
if (m_prev != NULL && (int) m_prev + m_prev->length > (int) m_free)
{
#ifdef DEBUG_HEAP
printf("Attempt to free bad pointer,"
fprintf(stderr,"Attempt to free bad pointer,"
"m_free = %08x, m_prev = %08x (length %x)\n",
m_free, m_prev, m_prev->length);
#endif
return -1;
}
if ((m != NULL && (int) m_free + m_free->length > (int) m) ||
(int) m_free + m_free->length > ((int) m_free | 0xffff))
{
#ifdef DEBUG_HEAP
printf("Attempt to free bad pointer,"
fprintf(stderr,"Attempt to free bad pointer,"
"m_free = %08x (length %x), m = %08x\n",
m_free, m_free->length, m);
#endif
return -1;
}
@ -359,9 +346,7 @@ HEAP_LocalFindHeap(unsigned short owner)
{
LHEAP *lh;
#ifdef DEBUG_HEAP
printf("HEAP_LocalFindHeap: owner %04x\n", owner);
#endif
dprintf_heap(stddeb,"HEAP_LocalFindHeap: owner %04x\n", owner);
for (lh = LocalHeaps; lh != NULL; lh = lh->next)
{
@ -380,10 +365,8 @@ HEAP_LocalInit(unsigned short owner, void *start, int length)
{
LHEAP *lh;
#ifdef DEBUG_HEAP
printf("HEAP_LocalInit: owner %04x, start %08x, length %04x\n",
owner, start, length);
#endif
dprintf_heap(stddeb,"HEAP_LocalInit: owner %04x, start %08x, length %04x\n"
,owner, start, length);
if (length < 2 * sizeof(MDESC))
return;
@ -424,16 +407,12 @@ WIN16_LocalAlloc(int flags, int bytes)
{
void *m;
#ifdef DEBUG_HEAP
printf("WIN16_LocalAlloc: flags %x, bytes %d\n", flags, bytes);
printf(" called from segment %04x\n", Stack16Frame[11]);
#endif
dprintf_heap(stddeb,"WIN16_LocalAlloc: flags %x, bytes %d\n", flags,bytes);
dprintf_heap(stddeb," called from segment %04x\n", Stack16Frame[11]);
m = HEAP_Alloc(LOCALHEAP(), flags, bytes);
#ifdef DEBUG_HEAP
printf("WIN16_LocalAlloc: returning %x\n", (int) m);
#endif
dprintf_heap(stddeb,"WIN16_LocalAlloc: returning %x\n", (int) m);
return m;
}
@ -461,7 +440,7 @@ unsigned int
WIN16_LocalFlags(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
@ -510,7 +489,7 @@ WIN16_LocalInit(unsigned int segment, unsigned int start, unsigned int end)
HEAP_Init(&lh->free_list,
(void *) ((segment << 16) | start), end - start + 1);
}
printf("WIN16_LocalInit // return segment=%04X !\n", segment);
dprintf_heap(stddeb,"WIN16_LocalInit // return segment=%04X !\n", segment);
return segment;
}
@ -521,7 +500,7 @@ void *
WIN16_LocalLock(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
@ -538,11 +517,12 @@ void *
WIN16_LocalReAlloc(unsigned int handle, int bytes, int flags)
{
void *m;
#ifdef DEBUG_HEAP
printf("WIN16_LocalReAlloc(%04X, %d, %04X); !\n", handle, bytes, flags);
printf("WIN16_LocalReAlloc // LOCALHEAP()=%08X !\n", LOCALHEAP());
printf("WIN16_LocalReAlloc // *LOCALHEAP()=%08X !\n", *LOCALHEAP());
#endif
dprintf_heap(stddeb,"WIN16_LocalReAlloc(%04X, %d, %04X); !\n",
handle, bytes, flags);
dprintf_heap(stddeb,"WIN16_LocalReAlloc // LOCALHEAP()=%08X !\n",
LOCALHEAP());
dprintf_heap(stddeb,"WIN16_LocalReAlloc // *LOCALHEAP()=%08X !\n",
*LOCALHEAP());
m = HEAP_ReAlloc(LOCALHEAP(), (void *)
(((int) *LOCALHEAP() & 0xffff0000) | (handle & 0xffff)),
bytes, flags);
@ -557,7 +537,7 @@ unsigned int
WIN16_LocalSize(unsigned int handle)
{
MDESC *m;
m = (MDESC *) (((int) *LOCALHEAP() & 0xffff0000) |
(handle & 0xffff)) - 1;
if (m->next != m || m->prev != m)
@ -619,9 +599,7 @@ WORD GetFreeSystemResources(WORD SystemResourceType)
unsigned int UserFree=0,UserResult=0;
unsigned int result=0;
MDESC *m;
printf("GetFreeSystemResources(%u)\n",SystemResourceType);
dprintf_heap(stddeb,"GetFreeSystemResources(%u)\n",SystemResourceType);
switch(SystemResourceType) {
case(USERRESOURCES):
for (m = USER_Heap; m != NULL; m = m->next) /* add up free area in heap */

View File

@ -7,7 +7,6 @@ SRCS = \
atom.c \
clipboard.c \
comm.c \
cursor.c \
dos_fs.c \
driver.c \
exec.c \
@ -35,7 +34,6 @@ OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,6 @@
static char Copyright[] = "Copyright Martin Ayotte, 1994";
/*
#define DEBUG_CLIPBOARD
*/
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
@ -20,6 +16,10 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#include "prototypes.h"
#include "heap.h"
#include "win.h"
#include "stddebug.h"
/* #define DEBUG_CLIPBOARD /* */
/* #undef DEBUG_CLIPBOARD /* */
#include "debug.h"
typedef struct tagCLIPFORMAT {
WORD wFormatID;
@ -58,9 +58,7 @@ BOOL OpenClipboard(HWND hWnd)
{
if (hWndClipboardOwner != 0) return FALSE;
hWndClipboardOwner = hWnd;
#ifdef DEBUG_CLIPBOARD
printf("OpenClipboard(%04X); !\n", hWnd);
#endif
dprintf_clipboard(stddeb,"OpenClipboard(%04X); !\n", hWnd);
return TRUE;
}
@ -72,9 +70,7 @@ BOOL CloseClipboard()
{
if (hWndClipboardOwner == 0) return FALSE;
hWndClipboardOwner = 0;
#ifdef DEBUG_CLIPBOARD
printf("CloseClipboard(); !\n");
#endif
dprintf_clipboard(stddeb,"CloseClipboard(); !\n");
return TRUE;
}
@ -86,9 +82,7 @@ BOOL EmptyClipboard()
{
LPCLIPFORMAT lpFormat = ClipFormats;
if (hWndClipboardOwner == 0) return FALSE;
#ifdef DEBUG_CLIPBOARD
printf("EmptyClipboard(); !\n");
#endif
dprintf_clipboard(stddeb,"EmptyClipboard(); !\n");
while(TRUE) {
if (lpFormat == NULL) break;
if (lpFormat->hData != 0) {
@ -106,9 +100,8 @@ BOOL EmptyClipboard()
*/
HWND GetClipboardOwner()
{
#ifdef DEBUG_CLIPBOARD
printf("GetClipboardOwner() = %04X !\n", hWndClipboardOwner);
#endif
dprintf_clipboard(stddeb,
"GetClipboardOwner() = %04X !\n", hWndClipboardOwner);
return hWndClipboardOwner;
}
@ -119,9 +112,8 @@ HWND GetClipboardOwner()
HANDLE SetClipboardData(WORD wFormat, HANDLE hData)
{
LPCLIPFORMAT lpFormat = ClipFormats;
#ifdef DEBUG_CLIPBOARD
printf("SetClipboardDate(%04X, %04X) !\n", wFormat, hData);
#endif
dprintf_clipboard(stddeb,
"SetClipboardDate(%04X, %04X) !\n", wFormat, hData);
while(TRUE) {
if (lpFormat == NULL) return 0;
if (lpFormat->wFormatID == wFormat) break;
@ -139,9 +131,7 @@ HANDLE SetClipboardData(WORD wFormat, HANDLE hData)
HANDLE GetClipboardData(WORD wFormat)
{
LPCLIPFORMAT lpFormat = ClipFormats;
#ifdef DEBUG_CLIPBOARD
printf("GetClipboardData(%04X) !\n", wFormat);
#endif
dprintf_clipboard(stddeb,"GetClipboardData(%04X) !\n", wFormat);
while(TRUE) {
if (lpFormat == NULL) return 0;
if (lpFormat->wFormatID == wFormat) break;
@ -161,17 +151,14 @@ int CountClipboardFormats()
while(TRUE) {
if (lpFormat == NULL) break;
if (lpFormat->hData != 0) {
#ifdef DEBUG_CLIPBOARD
printf("CountClipboardFormats // Find Not Empty (%04X) !\n",
dprintf_clipboard(stddeb,
"CountClipboardFormats // Find Not Empty (%04X) !\n",
lpFormat->hData);
#endif
FormatCount++;
}
lpFormat = lpFormat->NextFormat;
}
#ifdef DEBUG_CLIPBOARD
printf("CountClipboardFormats() = %d !\n", FormatCount);
#endif
dprintf_clipboard(stddeb,"CountClipboardFormats() = %d !\n", FormatCount);
return FormatCount;
}
@ -182,9 +169,7 @@ int CountClipboardFormats()
WORD EnumClipboardFormats(WORD wFormat)
{
LPCLIPFORMAT lpFormat = ClipFormats;
#ifdef DEBUG_CLIPBOARD
printf("EnumClipboardFormats(%04X) !\n", wFormat);
#endif
dprintf_clipboard(stddeb,"EnumClipboardFormats(%04X) !\n", wFormat);
if (wFormat == 0) {
if (lpFormat->hData != 0)
return lpFormat->wFormatID;
@ -196,20 +181,17 @@ WORD EnumClipboardFormats(WORD wFormat)
if (lpFormat->wFormatID == wFormat) break;
lpFormat = lpFormat->NextFormat;
}
#ifdef DEBUG_CLIPBOARD
printf("EnumClipboardFormats // Find Last (%04X) !\n",
dprintf_clipboard(stddeb,"EnumClipboardFormats // Find Last (%04X) !\n",
lpFormat->wFormatID);
#endif
lpFormat = lpFormat->NextFormat;
while(TRUE) {
if (lpFormat == NULL) return 0;
if (lpFormat->hData != 0) break;
lpFormat = lpFormat->NextFormat;
}
#ifdef DEBUG_CLIPBOARD
printf("EnumClipboardFormats // Find Not Empty Id=%04X hData=%04X !\n",
dprintf_clipboard(stddeb,
"EnumClipboardFormats // Find Not Empty Id=%04X hData=%04X !\n",
lpFormat->wFormatID, lpFormat->hData);
#endif
return lpFormat->wFormatID;
}
@ -229,9 +211,7 @@ WORD RegisterClipboardFormat(LPCSTR FormatName)
lpNewFormat = (LPCLIPFORMAT)malloc(sizeof(CLIPFORMAT));
if (lpNewFormat == NULL) return 0;
lpFormat->NextFormat = lpNewFormat;
#ifdef DEBUG_CLIPBOARD
printf("RegisterClipboardFormat('%s') !\n", FormatName);
#endif
dprintf_clipboard(stddeb,"RegisterClipboardFormat('%s') !\n", FormatName);
lpNewFormat->wFormatID = LastRegFormat;
lpNewFormat->wRefCount = 1;
lpNewFormat->Name = (LPSTR)malloc(strlen(FormatName) + 1);
@ -254,20 +234,18 @@ WORD RegisterClipboardFormat(LPCSTR FormatName)
int GetClipboardFormatName(WORD wFormat, LPSTR retStr, short maxlen)
{
LPCLIPFORMAT lpFormat = ClipFormats;
#ifdef DEBUG_CLIPBOARD
printf("GetClipboardFormat(%04X, %08X, %d) !\n", wFormat, retStr, maxlen);
#endif
dprintf_clipboard(stddeb,
"GetClipboardFormat(%04X, %08X, %d) !\n", wFormat, retStr, maxlen);
while(TRUE) {
if (lpFormat == NULL) return 0;
if (lpFormat->wFormatID == wFormat) break;
lpFormat = lpFormat->NextFormat;
}
if (lpFormat->Name == NULL) return 0;
#ifdef DEBUG_CLIPBOARD
printf("GetClipboardFormat // Name='%s' !\n", lpFormat->Name);
#endif
dprintf_clipboard(stddeb,
"GetClipboardFormat // Name='%s' !\n", lpFormat->Name);
maxlen = min(maxlen - 1, strlen(lpFormat->Name));
printf("GetClipboardFormat // maxlen=%d !\n", maxlen);
dprintf_clipboard(stddeb,"GetClipboardFormat // maxlen=%d !\n", maxlen);
memcpy(retStr, lpFormat->Name, maxlen);
retStr[maxlen] = 0;
return maxlen;
@ -279,9 +257,7 @@ int GetClipboardFormatName(WORD wFormat, LPSTR retStr, short maxlen)
*/
HWND SetClipboardViewer(HWND hWnd)
{
#ifdef DEBUG_CLIPBOARD
printf("SetClipboardFormat(%04X) !\n", hWnd);
#endif
dprintf_clipboard(stddeb,"SetClipboardFormat(%04X) !\n", hWnd);
hWndViewer = hWnd;
}
@ -291,9 +267,8 @@ HWND SetClipboardViewer(HWND hWnd)
*/
HWND GetClipboardViewer()
{
#ifdef DEBUG_CLIPBOARD
printf("GetClipboardFormat() = %04X !\n", hWndViewer);
#endif
dprintf_clipboard(stddeb,"GetClipboardFormat() = %04X !\n", hWndViewer);
return hWndViewer;
}
@ -302,9 +277,8 @@ HWND GetClipboardViewer()
*/
BOOL ChangeClipboardChain(HWND hWnd, HWND hWndNext)
{
#ifdef DEBUG_CLIPBOARD
printf("ChangeClipboardChain(%04X, %04X) !\n", hWnd, hWndNext);
#endif
dprintf_clipboard(stdnimp,
"ChangeClipboardChain(%04X, %04X) !\n", hWnd, hWndNext);
}
@ -314,9 +288,7 @@ BOOL ChangeClipboardChain(HWND hWnd, HWND hWndNext)
BOOL IsClipboardFormatAvailable(WORD wFormat)
{
LPCLIPFORMAT lpFormat = ClipFormats;
#ifdef DEBUG_CLIPBOARD
printf("IsClipboardFormatAvailable(%04X) !\n", wFormat);
#endif
dprintf_clipboard(stddeb,"IsClipboardFormatAvailable(%04X) !\n", wFormat);
while(TRUE) {
if (lpFormat == NULL) return FALSE;
if (lpFormat->wFormatID == wFormat) break;
@ -331,9 +303,8 @@ BOOL IsClipboardFormatAvailable(WORD wFormat)
*/
HWND GetOpenClipboardWindow()
{
#ifdef DEBUG_CLIPBOARD
printf("GetOpenClipboardWindow() = %04X !\n", hWndClipboardOwner);
#endif
dprintf_clipboard(stddeb,
"GetOpenClipboardWindow() = %04X !\n", hWndClipboardOwner);
return hWndClipboardOwner;
}
@ -343,9 +314,8 @@ HWND GetOpenClipboardWindow()
*/
int GetPriorityClipboardFormat(WORD FAR *lpPriorityList, short nCount)
{
#ifdef DEBUG_CLIPBOARD
printf("GetPriorityClipboardFormat(%08X, %d) !\n", lpPriorityList, nCount);
#endif
dprintf_clipboard(stdnimp,
"GetPriorityClipboardFormat(%08X, %d) !\n", lpPriorityList, nCount);
}

View File

@ -19,8 +19,10 @@
#include "wine.h"
#include "windows.h"
#include "comm.h"
#include "stddebug.h"
/* #define DEBUG_COMM /* */
/* #undef DEBUG_COMM /* */
#include "debug.h"
int commerror = 0, eventmask = 0;
@ -141,9 +143,8 @@ int BuildCommDCB(LPSTR device, DCB FAR *lpdcb)
int port;
char *ptr, temp[256];
#ifdef DEBUG_COMM
fprintf(stderr,"BuildCommDCB: (%s), ptr %d\n", device, (long) lpdcb);
#endif
dprintf_comm(stddeb,
"BuildCommDCB: (%s), ptr %d\n", device, (long) lpdcb);
commerror = 0;
if (!strncasecmp(device,"COM",3)) {
@ -174,14 +175,14 @@ fprintf(stderr,"BuildCommDCB: (%s), ptr %d\n", device, (long) lpdcb);
strcpy(temp,device+5);
ptr = strtok(temp, ",");
fprintf(stderr,"BuildCommDCB: baudrate (%s)\n", ptr);
dprintf_comm(stddeb,"BuildCommDCB: baudrate (%s)\n", ptr);
lpdcb->BaudRate = atoi(ptr);
ptr = strtok(NULL, ",");
if (islower(*ptr))
*ptr = toupper(*ptr);
fprintf(stderr,"BuildCommDCB: parity (%c)\n", *ptr);
dprintf_comm(stddeb,"BuildCommDCB: parity (%c)\n", *ptr);
switch (*ptr) {
case 'N':
lpdcb->Parity = NOPARITY;
@ -205,11 +206,11 @@ fprintf(stderr,"BuildCommDCB: (%s), ptr %d\n", device, (long) lpdcb);
}
ptr = strtok(NULL, ",");
fprintf(stderr, "BuildCommDCB: charsize (%c)\n", *ptr);
dprintf_comm(stddeb, "BuildCommDCB: charsize (%c)\n", *ptr);
lpdcb->ByteSize = *ptr - '0';
ptr = strtok(NULL, ",");
fprintf(stderr, "BuildCommDCB: stopbits (%c)\n", *ptr);
dprintf_comm(stddeb, "BuildCommDCB: stopbits (%c)\n", *ptr);
switch (*ptr) {
case '1':
lpdcb->StopBits = ONESTOPBIT;
@ -230,10 +231,8 @@ int OpenComm(LPSTR device, UINT cbInQueue, UINT cbOutQueue)
{
int port, fd;
#ifdef DEBUG_COMM
fprintf(stderr,"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue);
#endif
dprintf_comm(stddeb,
"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue);
commerror = 0;
if (!strncasecmp(device,"COM",3)) {
@ -288,10 +287,7 @@ fprintf(stderr,"OpenComm: %s, %d, %d\n", device, cbInQueue, cbOutQueue);
int CloseComm(int fd)
{
#ifdef DEBUG_COMM
fprintf(stderr,"CloseComm: fd %d\n", fd);
#endif
dprintf_comm(stddeb,"CloseComm: fd %d\n", fd);
if (close(fd) == -1) {
commerror = WinError();
return -1;
@ -305,10 +301,7 @@ int SetCommBreak(int fd)
{
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"SetCommBreak: fd: %d\n", fd);
#endif
dprintf_comm(stddeb,"SetCommBreak: fd: %d\n", fd);
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -323,10 +316,7 @@ int ClearCommBreak(int fd)
{
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"ClearCommBreak: fd: %d\n", fd);
#endif
dprintf_comm(stddeb,"ClearCommBreak: fd: %d\n", fd);
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -342,10 +332,8 @@ LONG EscapeCommFunction(int fd, int nFunction)
int max;
struct termios port;
#ifdef DEBUG_COMM
fprintf(stderr,"EscapeCommFunction fd: %d, function: %d\n", fd, nFunction);
#endif
dprintf_comm(stddeb,
"EscapeCommFunction fd: %d, function: %d\n", fd, nFunction);
if (tcgetattr(fd, &port) == -1) {
commerror = WinError();
return -1;
@ -392,7 +380,9 @@ fprintf(stderr,"EscapeCommFunction fd: %d, function: %d\n", fd, nFunction);
break;
default:
fprintf(stderr,"EscapeCommFunction fd: %d, unknown function: %d\n", fd, nFunction);
fprintf(stderr,
"EscapeCommFunction fd: %d, unknown function: %d\n",
fd, nFunction);
break;
}
@ -409,10 +399,7 @@ int FlushComm(int fd, int fnQueue)
{
int queue;
#ifdef DEBUG_COMM
fprintf(stderr,"FlushComm fd: %d, queue: %d\n", fd, fnQueue);
#endif
dprintf_comm(stddeb,"FlushComm fd: %d, queue: %d\n", fd, fnQueue);
switch (fnQueue) {
case 0:
queue = TCOFLUSH;
@ -421,7 +408,9 @@ fprintf(stderr,"FlushComm fd: %d, queue: %d\n", fd, fnQueue);
queue = TCIFLUSH;
break;
default:
fprintf(stderr,"FlushComm fd: %d, UNKNOWN queue: %d\n", fd, fnQueue);
fprintf(stderr,
"FlushComm fd: %d, UNKNOWN queue: %d\n",
fd, fnQueue);
return -1;
}
@ -436,28 +425,23 @@ fprintf(stderr,"FlushComm fd: %d, queue: %d\n", fd, fnQueue);
int GetCommError(int fd, COMSTAT FAR *lpStat)
{
#ifdef DEBUG_COMM
fprintf(stderr,"GetCommError: fd %d (current error %d)\n", fd, commerror);
#endif
dprintf_comm(stddeb,
"GetCommError: fd %d (current error %d)\n", fd, commerror);
return(commerror);
}
UINT FAR* SetCommEventMask(int fd, UINT fuEvtMask)
{
#ifdef DEBUG_COMM
fprintf(stderr,"SetCommEventMask: fd %d, mask %d\n", fd, fuEvtMask);
#endif
dprintf_comm(stddeb,
"SetCommEventMask: fd %d, mask %d\n", fd, fuEvtMask);
eventmask |= fuEvtMask;
return (UINT *)&eventmask;
}
UINT GetCommEventMask(int fd, int fnEvtClear)
{
#ifdef DEBUG_COMM
fprintf(stderr,"GetCommEventMask: fd %d, mask %d\n", fd, fnEvtClear);
#endif
dprintf_comm(stddeb,
"GetCommEventMask: fd %d, mask %d\n", fd, fnEvtClear);
eventmask &= ~fnEvtClear;
return eventmask;
}
@ -466,10 +450,8 @@ int SetCommState(DCB FAR *lpdcb)
{
struct termios port;
#ifdef DEBUG_COMM
fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
#endif
dprintf_comm(stddeb,
"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
if (tcgetattr(lpdcb->Id, &port) == -1) {
commerror = WinError();
return -1;
@ -489,7 +471,7 @@ fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
port.c_lflag &= ~(ICANON|ECHO|ISIG);
port.c_lflag |= NOFLSH;
fprintf(stderr,"SetCommState: baudrate %d\n",lpdcb->BaudRate);
dprintf_comm(stddeb,"SetCommState: baudrate %d\n",lpdcb->BaudRate);
#ifdef CBAUD
port.c_cflag &= ~CBAUD;
switch (lpdcb->BaudRate) {
@ -577,7 +559,7 @@ fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
}
port.c_ispeed = port.c_ospeed;
#endif
fprintf(stderr,"SetCommState: bytesize %d\n",lpdcb->ByteSize);
dprintf_comm(stddeb,"SetCommState: bytesize %d\n",lpdcb->ByteSize);
port.c_cflag &= ~CSIZE;
switch (lpdcb->ByteSize) {
case 5:
@ -597,7 +579,7 @@ fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
return -1;
}
fprintf(stderr,"SetCommState: parity %d\n",lpdcb->Parity);
dprintf_comm(stddeb,"SetCommState: parity %d\n",lpdcb->Parity);
port.c_cflag &= ~(PARENB | PARODD);
if (lpdcb->fParity)
switch (lpdcb->Parity) {
@ -618,7 +600,7 @@ fprintf(stderr,"SetCommState: fd %d, ptr %d\n", lpdcb->Id, (long) lpdcb);
}
fprintf(stderr,"SetCommState: stopbits %d\n",lpdcb->StopBits);
dprintf_comm(stddeb,"SetCommState: stopbits %d\n",lpdcb->StopBits);
switch (lpdcb->StopBits) {
case ONESTOPBIT:
port.c_cflag &= ~CSTOPB;
@ -655,10 +637,7 @@ int GetCommState(int fd, DCB FAR *lpdcb)
{
struct termios port;
#ifdef DEBUG_COMM
fprintf(stderr,"GetCommState: fd %d, ptr %d\n", fd, (long) lpdcb);
#endif
dprintf_comm(stddeb,"GetCommState: fd %d, ptr %d\n", fd, (long) lpdcb);
if (tcgetattr(fd, &port) == -1) {
commerror = WinError();
return -1;
@ -772,10 +751,8 @@ int TransmitCommChar(int fd, char chTransmit)
{
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"TransmitCommChar: fd %d, data %d \n", fd, chTransmit);
#endif
dprintf_comm(stddeb,
"TransmitCommChar: fd %d, data %d \n", fd, chTransmit);
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -799,10 +776,7 @@ int UngetCommChar(int fd, char chUnget)
{
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"UngetCommChar: fd %d (char %d)\n", fd, chUnget);
#endif
dprintf_comm(stddeb,"UngetCommChar: fd %d (char %d)\n", fd, chUnget);
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -825,10 +799,8 @@ int ReadComm(int fd, LPSTR lpvBuf, int cbRead)
int status, length;
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"ReadComm: fd %d, ptr %d, length %d\n", fd, (long) lpvBuf, cbRead);
#endif
dprintf_comm(stddeb,
"ReadComm: fd %d, ptr %d, length %d\n", fd, (long) lpvBuf, cbRead);
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -864,10 +836,8 @@ int WriteComm(int fd, LPSTR lpvBuf, int cbWrite)
int x, length;
struct DosDeviceStruct *ptr;
#ifdef DEBUG_COMM
fprintf(stderr,"WriteComm: fd %d, ptr %d, length %d\n", fd, (long) lpvBuf, cbWrite);
#endif
dprintf_comm(stddeb,"WriteComm: fd %d, ptr %d, length %d\n",
fd, (long) lpvBuf, cbWrite);
if ((ptr = GetDeviceStruct(fd)) == NULL) {
commerror = IE_BADID;
return -1;
@ -878,10 +848,8 @@ fprintf(stderr,"WriteComm: fd %d, ptr %d, length %d\n", fd, (long) lpvBuf, cbWri
return -1;
}
#ifdef DEBUG_COMM
for (x=0; x != cbWrite ; x++)
fprintf(stderr,"%c", *(lpvBuf + x) );
#endif
dprintf_comm(stddeb,"%c", *(lpvBuf + x) );
length = write(fd, (void *) lpvBuf, cbWrite);

View File

@ -3,6 +3,8 @@
* NOV 1993 Erik Bos (erik@(trashcan.)hacktic.nl)
*
* FindFile by Bob, hacked for dos & unixpaths by Erik.
*
* Bugfix by dash@ifi.uio.no: ToUnix() was called to often
*/
#include <ctype.h>
@ -28,8 +30,10 @@
#include "prototypes.h"
#include "autoconf.h"
#include "comm.h"
/* #define DEBUG /* */
#include "stddebug.h"
/* #define DEBUG_DOSFS /* */
/* #undef DEBIG_DOSFS /* */
#include "debug.h"
#define WINE_INI_USER "~/.winerc"
#define MAX_OPEN_DIRS 16
@ -141,8 +145,7 @@ void DOS_InitFS(void)
for (x=0; x!=MAX_DOS_DRIVES; x++) {
if (DosDrives[x].rootdir != NULL) {
#ifdef DEBUG
fprintf(stderr, "DOSFS: %c: => %-40s %s %s %X %d\n",
dprintf_dosfs(stddeb, "DOSFS: %c: => %-40s %s %s %X %d\n",
'A'+x,
DosDrives[x].rootdir,
DosDrives[x].cwd,
@ -150,21 +153,18 @@ void DOS_InitFS(void)
DosDrives[x].serialnumber,
DosDrives[x].disabled
);
#endif
}
}
for (x=0; x!=MAX_OPEN_DIRS ; x++)
DosDirs[x].inuse = 0;
#ifdef DEBUG
fprintf(stderr,"wine.ini = %s\n",WINE_INI);
fprintf(stderr,"win.ini = %s\n",WIN_INI);
fprintf(stderr,"windir = %s\n",WindowsDirectory);
fprintf(stderr,"sysdir = %s\n",SystemDirectory);
fprintf(stderr,"tempdir = %s\n",TempDirectory);
fprintf(stderr,"path = %s\n",WindowsPath);
#endif
dprintf_dosfs(stddeb,"wine.ini = %s\n",WINE_INI);
dprintf_dosfs(stddeb,"win.ini = %s\n",WIN_INI);
dprintf_dosfs(stddeb,"windir = %s\n",WindowsDirectory);
dprintf_dosfs(stddeb,"sysdir = %s\n",SystemDirectory);
dprintf_dosfs(stddeb,"tempdir = %s\n",TempDirectory);
dprintf_dosfs(stddeb,"path = %s\n",WindowsPath);
}
WORD DOS_GetEquipment(void)
@ -224,23 +224,17 @@ WORD DOS_GetEquipment(void)
equipment = (diskdrives << 6) | (serialports << 9) |
(parallelports << 14) | 0x02;
#ifdef DEBUG
fprintf(stderr, "DOS_GetEquipment : diskdrives = %d serialports = %d "
dprintf_dosfs(stddeb, "DOS_GetEquipment : diskdrives = %d serialports = %d "
"parallelports = %d\n"
"DOS_GetEquipment : equipment = %d\n",
diskdrives, serialports, parallelports, equipment);
#endif
return (equipment);
}
int DOS_ValidDrive(int drive)
{
/*
#ifdef DEBUG
fprintf(stderr,"ValidDrive %c (%d)\n",'A'+drive,drive);
#endif
*/
dprintf_dosfs(stddeb,"ValidDrive %c (%d)\n",'A'+drive,drive);
if (drive >= MAX_DOS_DRIVES)
return 0;
if (DosDrives[drive].rootdir == NULL)
@ -251,21 +245,31 @@ int DOS_ValidDrive(int drive)
return 1;
}
int DOS_ValidDirectory(char *name)
{
char *dirname;
struct stat s;
if ((dirname = GetUnixFileName(name)) == NULL)
return 0;
if (stat(dirname,&s))
return 0;
if (!S_ISDIR(s.st_mode))
return 0;
return 1;
}
int DOS_GetDefaultDrive(void)
{
#ifdef DEBUG
fprintf(stderr,"GetDefaultDrive (%c)\n",'A'+CurrentDrive);
#endif
dprintf_dosfs(stddeb,"GetDefaultDrive (%c)\n",'A'+CurrentDrive);
return( CurrentDrive);
}
void DOS_SetDefaultDrive(int drive)
{
#ifdef DEBUG
fprintf(stderr,"SetDefaultDrive to %c:\n",'A'+drive);
#endif
dprintf_dosfs(stddeb,"SetDefaultDrive to %c:\n",'A'+drive);
if (DOS_ValidDrive(drive))
CurrentDrive = drive;
}
@ -336,11 +340,9 @@ static void GetUnixDirName(char *rootdir, char *name)
cwdptr = rootdir + strlen(rootdir);
nameptr = name;
/*
#ifdef DEBUG
fprintf(stderr,"GetUnixDirName: %s <=> %s => ",rootdir, name);
#endif
*/
dprintf_dosfs(stddeb,"GetUnixDirName: %s <=> %s => ",rootdir, name);
while (*nameptr) {
if (*nameptr == '.' & !filename) {
nameptr++;
@ -379,11 +381,11 @@ static void GetUnixDirName(char *rootdir, char *name)
*cwdptr = '\0';
ToUnix(rootdir);
/*
#ifdef DEBUG
fprintf(stderr,"%s\n", rootdir);
#endif
*/
}
char *GetUnixFileName(char *dosfilename)
@ -408,12 +410,7 @@ char *GetUnixFileName(char *dosfilename)
strcat(temp, DosDrives[drive].cwd);
GetUnixDirName(temp + strlen(DosDrives[drive].rootdir), dosfilename);
ToUnix(temp);
#ifdef DEBUG
fprintf(stderr,"GetUnixFileName: %s => %s\n", dosfilename, temp);
#endif
dprintf_dosfs(stddeb,"GetUnixFileName: %s => %s\n", dosfilename, temp);
return(temp);
}
@ -427,7 +424,6 @@ char *GetDosFileName(char *unixfilename)
if (DosDrives[i].rootdir != NULL) {
strcpy(rootdir, DosDrives[i].rootdir);
strcat(rootdir, "/");
ToUnix(rootdir);
if (strncmp(rootdir, unixfilename, strlen(rootdir)) == 0) {
sprintf(temp, "%c:\\%s", 'A' + i, unixfilename + strlen(rootdir));
ToDos(temp);
@ -451,30 +447,34 @@ char *DOS_GetCurrentDir(int drive)
strcpy(temp, DosDrives[drive].cwd);
ToDos(temp);
fprintf(stderr, "2 %s\n", temp);
ChopOffSlash(temp);
#ifdef DEBUG
fprintf(stderr,"DOS_GetCWD: %c: %s\n",'A'+drive, temp + 1);
#endif
dprintf_dosfs(stddeb,"DOS_GetCWD: %c: %s\n",'A'+drive, temp + 1);
return (temp + 1);
}
int DOS_ChangeDir(int drive, char *dirname)
{
char temp[256];
char temp[256],old[256];
if (!DOS_ValidDrive(drive))
return 0;
strcpy(temp, dirname);
ToUnix(temp);
strcpy(old, DosDrives[drive].cwd);
GetUnixDirName(DosDrives[drive].cwd, temp);
strcat(DosDrives[drive].cwd,"/");
#ifdef DEBUG
fprintf(stderr,"DOS_SetCWD: %c: %s\n",'A'+drive, DosDrives[drive].cwd);
#endif
dprintf_dosfs(stddeb,"DOS_SetCWD: %c: %s\n",'A'+drive,
DosDrives[drive].cwd);
if (!DOS_ValidDirectory(DosDrives[drive].cwd))
{
strcpy(DosDrives[drive].cwd, old);
return 0;
}
return 1;
}
@ -489,12 +489,11 @@ int DOS_MakeDir(int drive, char *dirname)
GetUnixDirName(temp, dirname);
strcat(DosDrives[drive].cwd,"/");
ToUnix(temp);
ToUnix(temp + strlen(DosDrives[drive].cwd));
mkdir(temp,0);
#ifdef DEBUG
fprintf(stderr,"DOS_MakeDir: %c:\%s => %s",'A'+drive, dirname, temp);
#endif
dprintf_dosfs(stddeb,
"DOS_MakeDir: %c:\%s => %s",'A'+drive, dirname, temp);
return 1;
}
@ -541,7 +540,8 @@ int DOS_GetFreeSpace(int drive, long *size, long *available)
return 0;
if (statfs(DosDrives[drive].rootdir, &info) < 0) {
fprintf(stderr,"dosfs: cannot do statfs(%s)\n",DosDrives[drive].rootdir);
fprintf(stderr,"dosfs: cannot do statfs(%s)\n",
DosDrives[drive].rootdir);
return 0;
}
@ -563,7 +563,6 @@ char *FindFile(char *buffer, int buflen, char *filename, char **extensions,
if (strchr(filename, '\\') != NULL)
{
strncpy(buffer, GetUnixFileName(filename), buflen);
ToUnix(buffer);
stat( buffer, &filestat);
if (S_ISREG(filestat.st_mode))
return buffer;
@ -577,10 +576,7 @@ char *FindFile(char *buffer, int buflen, char *filename, char **extensions,
return buffer;
}
#ifdef DEBUG
fprintf(stderr,"FindFile: looking for %s\n", filename);
#endif
dprintf_dosfs(stddeb,"FindFile: looking for %s\n", filename);
rootnamelen = strlen(filename);
if ((rootname = malloc(rootnamelen + 1)) == NULL)
return NULL;
@ -600,10 +596,7 @@ fprintf(stderr,"FindFile: looking for %s\n", filename);
else
d = opendir( dirname );
#ifdef DEBUG
fprintf(stderr,"in %s\n",dirname);
#endif
dprintf_dosfs(stddeb,"in %s\n",dirname);
if (d != NULL)
{
while ((f = readdir(d)) != NULL)
@ -637,7 +630,6 @@ fprintf(stderr,"FindFile: looking for %s\n", filename);
if (S_ISREG(filestat.st_mode)) {
closedir(d);
free(rootname);
ToUnix(buffer);
return buffer;
} else
found = 0;
@ -693,7 +685,6 @@ char *WinIniFileName(void)
strcpy(name, GetUnixFileName(WindowsDirectory));
strcat(name, "/");
strcat(name, "win.ini");
ToUnix(name);
name = realloc(name, strlen(name) + 1);
@ -704,10 +695,7 @@ static int match(char *filename, char *filemask)
{
int x, masklength = strlen(filemask);
#ifdef DEBUG
fprintf(stderr, "match: %s, %s\n", filename, filemask);
#endif
dprintf_dosfs(stddeb, "match: %s, %s\n", filename, filemask);
for (x = 0; x != masklength ; x++) {
/* printf("(%c%c) ", *filename, filemask[x]);
*/
@ -763,9 +751,7 @@ struct dosdirent *DOS_opendir(char *dosdirname)
}
}
#ifdef DEBUG
fprintf(stderr,"DOS_opendir: %s -> %s\n", unixdirname, temp);
#endif
dprintf_dosfs(stddeb,"DOS_opendir: %s -> %s\n", unixdirname, temp);
DosDirs[x].inuse = 1;
strcpy(DosDirs[x].unixpath, temp);
@ -800,7 +786,7 @@ struct dosdirent *DOS_readdir(struct dosdirent *de)
strcpy(temp,de->unixpath);
strcat(temp,"/");
strcat(temp,de->filename);
ToUnix(temp);
ToUnix(temp + strlen(de->unixpath));
stat (temp, &st);
de->attribute = 0x0;

View File

@ -12,6 +12,10 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#include "user.h"
#include "dlls.h"
#include "driver.h"
#include "stddebug.h"
/* #define DEBUG_DRIVER /* */
/* #undef DEBUG_DRIVER /* */
#include "debug.h"
LPDRIVERITEM lpDrvItemList = NULL;
@ -23,16 +27,19 @@ void LoadStartupDrivers()
LPSTR file = "SYSTEM.INI";
if (GetPrivateProfileString("drivers", NULL,
"", str, sizeof(str), file) < 2) {
printf("LoadStartupDrivers // can't find drivers section in '%s'\n", file);
fprintf(stderr,
"LoadStartupDrivers // can't find drivers section in '%s'\n",
file);
return;
}
while(strlen(ptr) != 0) {
printf("LoadStartupDrivers // str='%s'\n", ptr);
dprintf_driver(stddeb,"LoadStartupDrivers // str='%s'\n", ptr);
hDrv = OpenDriver(ptr, "drivers", 0L);
printf("LoadStartupDrivers // hDrv=%04X\n", hDrv);
dprintf_driver(stddeb,
"LoadStartupDrivers // hDrv=%04X\n", hDrv);
ptr += strlen(ptr) + 1;
}
printf("LoadStartupDrivers // end of list !\n");
dprintf_driver(stddeb,"LoadStartupDrivers // end of list !\n");
}
/**************************************************************************
@ -40,12 +47,12 @@ void LoadStartupDrivers()
*/
LRESULT WINAPI SendDriverMessage(HDRVR hDriver, WORD msg, LPARAM lParam1, LPARAM lParam2)
{
printf("SendDriverMessage(%04X, %04X, %08X, %08X);\n",
dprintf_driver(stdnimp,"SendDriverMessage(%04X, %04X, %08X, %08X);\n",
hDriver, msg, lParam1, lParam2);
}
/**************************************************************************
* OpenDriver [USER.252]
* OpenDriver [USER.252]
*/
HDRVR OpenDriver(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
{
@ -53,12 +60,12 @@ HDRVR OpenDriver(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
LPDRIVERITEM lpnewdrv;
LPDRIVERITEM lpdrv = lpDrvItemList;
char DrvName[128];
printf("OpenDriver('%s', '%s', %08X);\n",
dprintf_driver(stddeb,"OpenDriver('%s', '%s', %08X);\n",
lpDriverName, lpSectionName, lParam);
if (lpSectionName == NULL) lpSectionName = "drivers";
GetPrivateProfileString(lpSectionName, lpDriverName,
"", DrvName, sizeof(DrvName), "SYSTEM.INI");
printf("OpenDriver // DrvName='%s'\n", DrvName);
dprintf_driver(stddeb,"OpenDriver // DrvName='%s'\n", DrvName);
if (strlen(DrvName) < 1) return 0;
while (lpdrv != NULL) {
if (lpdrv->lpNextItem == NULL) break;
@ -88,7 +95,7 @@ HDRVR OpenDriver(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
lpnewdrv->lpPrevItem = lpdrv;
}
lpnewdrv->lpDrvProc = NULL;
printf("OpenDriver // hDrvr=%04X loaded !\n", hDrvr);
dprintf_driver(stddeb,"OpenDriver // hDrvr=%04X loaded !\n", hDrvr);
return hDrvr;
}
@ -98,7 +105,8 @@ HDRVR OpenDriver(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam)
LRESULT CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
{
LPDRIVERITEM lpdrv;
printf("CloseDriver(%04X, %08X, %08X);\n", hDrvr, lParam1, lParam2);
dprintf_driver(stddeb,
"CloseDriver(%04X, %08X, %08X);\n", hDrvr, lParam1, lParam2);
lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr);
if (lpdrv != NULL && lpdrv->dis.hDriver == hDrvr) {
if (lpdrv->lpPrevItem)
@ -107,7 +115,7 @@ LRESULT CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
((LPDRIVERITEM)lpdrv->lpNextItem)->lpPrevItem = lpdrv->lpPrevItem;
GlobalUnlock(hDrvr);
GlobalFree(hDrvr);
printf("CloseDriver // hDrvr=%04X closed !\n", hDrvr);
dprintf_driver(stddeb,"CloseDriver // hDrvr=%04X closed !\n", hDrvr);
return TRUE;
}
return FALSE;
@ -120,7 +128,7 @@ HANDLE GetDriverModuleHandle(HDRVR hDrvr)
{
LPDRIVERITEM lpdrv;
HANDLE hModule = 0;
printf("GetDriverModuleHandle(%04X);\n", hDrvr);
dprintf_driver(stddeb,"GetDriverModuleHandle(%04X);\n", hDrvr);
lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr);
if (lpdrv != NULL) {
hModule = lpdrv->dis.hModule;
@ -169,7 +177,7 @@ LRESULT DefDriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg,
BOOL GetDriverInfo(HDRVR hDrvr, LPDRIVERINFOSTRUCT lpDrvInfo)
{
LPDRIVERITEM lpdrv;
printf("GetDriverInfo(%04X, %08X);\n", hDrvr, lpDrvInfo);
dprintf_driver(stddeb,"GetDriverInfo(%04X, %08X);\n", hDrvr, lpDrvInfo);
if (lpDrvInfo == NULL) return FALSE;
lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr);
if (lpdrv == NULL) return FALSE;
@ -185,15 +193,16 @@ HDRVR GetNextDriver(HDRVR hDrvr, DWORD dwFlags)
{
LPDRIVERITEM lpdrv;
HDRVR hRetDrv = 0;
printf("GetNextDriver(%04X, %08X);\n", hDrvr, dwFlags);
dprintf_driver(stddeb,"GetNextDriver(%04X, %08X);\n", hDrvr, dwFlags);
if (hDrvr == 0) {
if (lpDrvItemList == NULL) {
printf("GetNextDriver // drivers list empty !\n");
dprintf_driver(stddeb,
"GetNextDriver // drivers list empty !\n");
LoadStartupDrivers();
if (lpDrvItemList == NULL) return 0;
}
printf("GetNextDriver // return first %04X !\n",
lpDrvItemList->dis.hDriver);
dprintf_driver(stddeb,"GetNextDriver // return first %04X !\n",
lpDrvItemList->dis.hDriver);
return lpDrvItemList->dis.hDriver;
}
lpdrv = (LPDRIVERITEM) GlobalLock(hDrvr);
@ -208,7 +217,7 @@ HDRVR GetNextDriver(HDRVR hDrvr, DWORD dwFlags)
}
GlobalUnlock(hDrvr);
}
printf("GetNextDriver // return %04X !\n", hRetDrv);
dprintf_driver(stddeb,"GetNextDriver // return %04X !\n", hRetDrv);
return hRetDrv;
}

View File

@ -13,6 +13,10 @@
#include "dlls.h"
#include "wine.h"
#include "windows.h"
#include "stddebug.h"
/* #define DEBUG_EXEC /* */
/* #undef DEBUG_EXEC /* */
#include "debug.h"
#define HELP_CONTEXT 0x0001
#define HELP_QUIT 0x0002
@ -53,40 +57,41 @@ void InitializeLoadedNewDLLs(HINSTANCE hInst)
int cs_reg, ds_reg, ip_reg;
int rv;
fprintf(stderr, "Initializing New DLLs\n");
dprintf_exec(stddeb, "Initializing New DLLs\n");
/*
* Initialize libraries
*/
printf("InitializeLoadedNewDLLs() before searching hInst=%04X !\n", hInst);
dprintf_exec(stddeb,
"InitializeLoadedNewDLLs() before searching hInst=%04X !\n", hInst);
w = wine_files;
while (w && w->hinstance != hInst) w = w->next;
if (w == NULL) return;
printf("InitializeLoadedNewDLLs() // before InitLoop !\n");
dprintf_exec(stddeb,"InitializeLoadedNewDLLs() // before InitLoop !\n");
for(wpnt = w; wpnt; wpnt = wpnt->next)
{
/*
* Is this a library?
*/
if (wpnt->ne_header->format_flags & 0x8000)
if (wpnt->ne->ne_header->format_flags & 0x8000)
{
if (!(wpnt->ne_header->format_flags & 0x0001))
if (!(wpnt->ne->ne_header->format_flags & 0x0001))
{
/* Not SINGLEDATA */
fprintf(stderr, "Library is not marked SINGLEDATA\n");
exit(1);
}
ds_reg = wpnt->selector_table[wpnt->
ds_reg = wpnt->ne->selector_table[wpnt->ne->
ne_header->auto_data_seg-1].selector;
cs_reg = wpnt->selector_table[wpnt->ne_header->cs-1].selector;
ip_reg = wpnt->ne_header->ip;
cs_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->cs-1].selector;
ip_reg = wpnt->ne->ne_header->ip;
fprintf(stderr, "Initializing %s, cs:ip %04x:%04x, ds %04x\n",
dprintf_exec(stddeb, "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);
dprintf_exec(stddeb,"rv = %x\n", rv);
}
}
}
@ -100,28 +105,29 @@ void StartNewTask(HINSTANCE hInst)
int rv;
int segment;
printf("StartNewTask() before searching hInst=%04X !\n", hInst);
dprintf_exec(stddeb,
"StartNewTask() before searching hInst=%04X !\n", hInst);
wpnt = wine_files;
while (wpnt && wpnt->hinstance != hInst) wpnt = wpnt->next;
if (wpnt == NULL) return;
printf("StartNewTask() // before FixupSegment !\n");
dprintf_exec(stddeb,"StartNewTask() // before FixupSegment !\n");
for(w = wpnt; w; w = w->next) {
for (segment = 0; segment < w->ne_header->n_segment_tab; segment++) {
for (segment = 0; segment < w->ne->ne_header->n_segment_tab; segment++) {
if (FixupSegment(w, segment) < 0) {
myerror("fixup failed.");
}
}
}
printf("StartNewTask() before InitializeLoadedNewDLLs !\n");
dprintf_exec(stddeb,"StartNewTask() before InitializeLoadedNewDLLs !\n");
InitializeLoadedNewDLLs(hInst);
printf("StartNewTask() before setup register !\n");
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;
ss_reg = wpnt->selector_table[wpnt->ne_header->ss-1].selector;
sp_reg = wpnt->ne_header->sp;
dprintf_exec(stddeb,"StartNewTask() before setup register !\n");
ds_reg = (wpnt->ne->selector_table[wpnt->ne->ne_header->auto_data_seg-1].selector);
cs_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->cs-1].selector;
ip_reg = wpnt->ne->ne_header->ip;
ss_reg = wpnt->ne->selector_table[wpnt->ne->ne_header->ss-1].selector;
sp_reg = wpnt->ne->ne_header->sp;
printf("StartNewTask() before CallToInit16() !\n");
dprintf_exec(stddeb,"StartNewTask() before CallToInit16() !\n");
rv = CallToInit16(cs_reg << 16 | ip_reg, ss_reg << 16 | sp_reg, ds_reg);
printf ("rv = %x\n", rv);
@ -141,7 +147,7 @@ HANDLE LoadModule(LPSTR modulefile, LPVOID lpParamBlk)
{
PARAMBLOCK *pblk = lpParamBlk;
WORD *lpCmdShow;
printf("LoadModule '%s' %08X\n", modulefile, lpParamBlk);
dprintf_exec(stddeb,"LoadModule '%s' %08X\n", modulefile, lpParamBlk);
if (lpParamBlk == NULL) return 0;
lpCmdShow = (WORD *)pblk->lpCmdShow;
return WinExec(pblk->lpCmdLine, lpCmdShow[1]);
@ -159,7 +165,7 @@ WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
LPFNWINMAIN lpfnMain;
HINSTANCE hInst = 0;
HANDLE hTask = 0;
printf("WinExec('%s', %04X)\n", lpCmdLine, nCmdShow);
dprintf_exec(stddeb,"WinExec('%s', %04X)\n", lpCmdLine, nCmdShow);
/* ArgV[0] = "wine";
c = 1; */
for (x = x2 = 0; x < strlen(lpCmdLine) + 1; x++) {
@ -171,36 +177,43 @@ WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
}
}
ArgV[c] = NULL;
for (c = 0; ArgV[c] != NULL; c++) printf("--> '%s' \n", ArgV[c]);
for (c = 0; ArgV[c] != NULL; c++)
dprintf_exec(stddeb,"--> '%s' \n", ArgV[c]);
switch(fork()) {
case -1:
printf("Can't 'fork' process !\n");
fprintf(stderr,"Can't 'fork' process !\n");
break;
case 0:
if ((hInst = LoadImage(ArgV[0], EXE, 1)) == (HINSTANCE) NULL ) {
fprintf(stderr, "wine: can't find %s!.\n", ArgV[0]);
printf("Child process died !\n");
fprintf(stderr,"Child process died !\n");
exit(1);
}
hTask = CreateNewTask(hInst);
printf("WinExec // hTask=%04X hInst=%04X !\n", hTask, hInst);
dprintf_exec(stddeb,
"WinExec // hTask=%04X hInst=%04X !\n", hTask, hInst);
StartNewTask(hInst);
/*
lpfnMain = (LPFNWINMAIN)GetProcAddress(hInst, (LPSTR)0L);
printf("WineExec() // lpfnMain=%08X\n", (LONG)lpfnMain);
dprintf_exec(stddeb,
"WineExec() // lpfnMain=%08X\n", (LONG)lpfnMain);
if (lpfnMain != NULL) {
(lpfnMain)(hInst, 0, lpCmdLine, nCmdShow);
printf("WineExec() // after lpfnMain\n");
dprintf_exec(stddeb,
"WineExec() // after lpfnMain\n");
}
*/
/* hTask = CreateNewTask(0);
printf("WinExec // New Task hTask=%04X !\n", hTask);
dprintf_exec(stddeb,
"WinExec // New Task hTask=%04X !\n", hTask);
execvp(ArgV[0], ArgV); */
printf("Child process died !\n");
fprintf(stderr,"Child process died !\n");
exit(1);
default:
printf("WinExec (Main process stay alive) hTask=%04X !\n", hTask);
dprintf_exec(stddeb,
"WinExec (Main process stay alive) hTask=%04X !\n",
hTask);
break;
}
for (c = 0; ArgV[c] != NULL; c++) free(ArgV[c]);
@ -213,7 +226,8 @@ WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
*/
BOOL ExitWindows(DWORD dwReserved, WORD wRetCode)
{
printf("EMPTY STUB !!! ExitWindows(%08X, %04X) !\n", dwReserved, wRetCode);
dprintf_exec(stdnimp,"EMPTY STUB !!! ExitWindows(%08X, %04X) !\n",
dwReserved, wRetCode);
}
@ -223,18 +237,19 @@ BOOL ExitWindows(DWORD dwReserved, WORD wRetCode)
BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
{
char str[256];
printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData);
dprintf_exec(stddeb,"WinHelp(%s, %u, %lu)\n",
lpHelpFile, wCommand, dwData);
switch(wCommand) {
case 0:
case HELP_HELPONHELP:
GetWindowsDirectory(str, sizeof(str));
strcat(str, "\\winhelp.exe");
printf("'%s'\n", str);
dprintf_exec(stddeb,"'%s'\n", str);
break;
case HELP_INDEX:
GetWindowsDirectory(str, sizeof(str));
strcat(str, "\\winhelp.exe");
printf("'%s'\n", str);
dprintf_exec(stddeb,"'%s'\n", str);
break;
default:
return FALSE;

View File

@ -22,8 +22,8 @@
#include <limits.h>
#include <unistd.h>
#include <time.h>
#include <windows.h>
#include <sys/stat.h>
#include <string.h>
#include "prototypes.h"
#include "regfunc.h"
#include "windows.h"
@ -31,11 +31,13 @@
#include "msdos.h"
#include "registers.h"
#include "options.h"
#include "stddebug.h"
/* #define DEBUG_FILE /* */
/* #undef DEBUG_FILE /* */
#include "debug.h"
#define MAX_PATH 255
/* #define DEBUG_FILE /* */
char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256];
extern char WindowsPath[256];
@ -55,18 +57,13 @@ INT _lopen (LPSTR lpPathName, INT iReadWrite)
int handle;
char *UnixFileName;
#ifdef DEBUG_FILE
fprintf (stderr, "_lopen: open('%s', %X);\n", lpPathName, iReadWrite);
#endif
dprintf_file(stddeb, "_lopen: open('%s', %X);\n", lpPathName, iReadWrite);
if ((UnixFileName = GetUnixFileName(lpPathName)) == NULL)
return HFILE_ERROR;
iReadWrite &= 0x000F;
handle = open (UnixFileName, iReadWrite);
#ifdef DEBUG_FILE
fprintf (stderr, "_lopen: open: %s (handle %d)\n", UnixFileName, handle);
#endif
dprintf_file(stddeb, "_lopen: open: %s (handle %d)\n", UnixFileName, handle);
if (handle == -1)
return HFILE_ERROR;
@ -81,10 +78,8 @@ INT _lread (INT hFile, LPSTR lpBuffer, WORD wBytes)
{
int result;
#ifdef DEBUG_FILE
fprintf(stderr, "_lread: handle %d, buffer = %ld, length = %d\n",
dprintf_file(stddeb, "_lread: handle %d, buffer = %ld, length = %d\n",
hFile, (int) lpBuffer, wBytes);
#endif
result = read (hFile, lpBuffer, wBytes);
@ -101,13 +96,10 @@ INT _lwrite (INT hFile, LPSTR lpBuffer, WORD wBytes)
{
int result;
#if 0
#ifdef DEBUG_FILE
fprintf(stderr, "_lwrite: handle %d, buffer = %ld, length = %d\n",
dprintf_file(stddeb, "_lwrite: handle %d, buffer = %ld, length = %d\n",
hFile, (int) lpBuffer, wBytes);
#endif
#endif
result = write (hFile, lpBuffer, wBytes);
result = write (hFile, lpBuffer, wBytes);
if (result == -1)
return HFILE_ERROR;
@ -120,9 +112,7 @@ INT _lwrite (INT hFile, LPSTR lpBuffer, WORD wBytes)
***************************************************************************/
INT _lclose (INT hFile)
{
#ifdef DEBUG_FILE
fprintf(stderr, "_lclose: handle %d\n", hFile);
#endif
dprintf_file(stddeb, "_lclose: handle %d\n", hFile);
if (close (hFile))
return HFILE_ERROR;
else
@ -135,9 +125,11 @@ INT _lclose (INT hFile)
INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
{
int handle;
#ifndef PROCEMU
struct sigcontext_struct ccontext;
/* To make macros like EAX happy */
struct sigcontext_struct *context=&ccontext;
#endif
char filename[MAX_PATH+1];
int action;
struct stat s;
@ -145,9 +137,7 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
int res;
int verify_time;
#ifdef DEBUG_FILE
fprintf(stderr,"Openfile(%s,<struct>,%d) ",lpFileName,wStyle);
#endif
dprintf_file(stddeb,"Openfile(%s,<struct>,%d) ",lpFileName,wStyle);
action = wStyle & 0xff00;
@ -196,14 +186,12 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
break;
GetWindowsDirectory (filename,MAX_PATH);
if (filename[1] != ':')
strcat(filename,'\\');
if (filename[1] != ':') strcat(filename,"\\");
strcat (filename, lpFileName);
if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
break;
GetSystemDirectory (filename,MAX_PATH);
if (filename[1] != ':')
strcat(filename,'\\');
if (filename[1] != ':') strcat(filename,"\\");
strcat (filename, lpFileName);
if ( (!stat(GetUnixFileName(filename), &s)) && (S_ISREG(s.st_mode)) )
break;
@ -263,17 +251,17 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
/* Now we are actually going to open the file. According to Microsoft's
Knowledge Basis, this is done by calling int 21h, ax=3dh. */
EAX = 0x00003d00;
EAX = (EAX & 0xffffff0f) | (wStyle & 0x0070); /* Handle OF_SHARE_xxx etc. */
EAX = (EAX & 0xfffffff0) | (wStyle & 0x0003); /* Handle OF_READ etc. */
AX = 0x3d00;
AL = (AL & 0x0f) | (wStyle & 0x70); /* Handle OF_SHARE_xxx etc. */
AL = (AL & 0xf0) | (wStyle & 0x03); /* Handle OF_READ etc. */
DS = segment (ofs->szPathName);
EDX = (EDX & 0xffff0000) | offset (ofs->szPathName);
DX = offset (ofs->szPathName);
OpenExistingFile (context);
if (EFL & 0x00000001) /* Cflag */
{
ofs->nErrCode = (AX & 0x00ff);
ofs->nErrCode = AL;
return -1;
}
@ -293,7 +281,7 @@ INT OpenFile (LPSTR lpFileName, LPOFSTRUCT ofs, WORD wStyle)
#endif
WORD SetHandleCount (WORD wNumber)
{
printf("SetHandleCount(%d)\n",wNumber);
dprintf_file(stddeb,"SetHandleCount(%d)\n",wNumber);
return((wNumber<OPEN_MAX) ? wNumber : OPEN_MAX);
}
@ -304,9 +292,8 @@ LONG _llseek (INT hFile, LONG lOffset, INT nOrigin)
{
int origin;
#ifdef DEBUG_FILE
fprintf(stderr, "_llseek: handle %d, offset %ld, origin %d\n", hFile, lOffset, nOrigin);
#endif
dprintf_file(stddeb, "_llseek: handle %d, offset %ld, origin %d\n",
hFile, lOffset, nOrigin);
switch (nOrigin) {
case 1: origin = SEEK_CUR;
@ -328,10 +315,8 @@ INT _lcreat (LPSTR lpszFilename, INT fnAttribute)
int handle;
char *UnixFileName;
#ifdef DEBUG_FILE
fprintf(stderr, "_lcreat: filename %s, attributes %d\n",lpszFilename,
fnAttribute);
#endif
dprintf_file(stddeb, "_lcreat: filename %s, attributes %d\n",
lpszFilename, fnAttribute);
if ((UnixFileName = GetUnixFileName(lpszFilename)) == NULL)
return HFILE_ERROR;
handle = open (UnixFileName, O_CREAT | O_TRUNC | O_WRONLY, 426);
@ -348,9 +333,7 @@ INT _lcreat (LPSTR lpszFilename, INT fnAttribute)
UINT GetDriveType(INT drive)
{
#ifdef DEBUG_FILE
fprintf(stderr,"GetDriveType %c:\n",'A'+drive);
#endif
dprintf_file(stddeb,"GetDriveType %c:\n",'A'+drive);
if (!DOS_ValidDrive(drive))
return DRIVE_DOESNOTEXIST;
@ -366,9 +349,7 @@ UINT GetDriveType(INT drive)
***************************************************************************/
BYTE GetTempDrive(BYTE chDriveLetter)
{
#ifdef DEBUG_FILE
fprintf(stderr,"GetTempDrive (%d)\n",chDriveLetter);
#endif
dprintf_file(stddeb,"GetTempDrive (%d)\n",chDriveLetter);
return('C');
}
@ -382,9 +363,7 @@ UINT GetWindowsDirectory(LPSTR lpszSysPath, UINT cbSysPath)
else
strcpy(lpszSysPath, WindowsDirectory);
#ifdef DEBUG_FILE
fprintf(stderr,"GetWindowsDirectory (%s)\n",lpszSysPath);
#endif
dprintf_file(stddeb,"GetWindowsDirectory (%s)\n",lpszSysPath);
ChopOffSlash(lpszSysPath);
return(strlen(lpszSysPath));
@ -399,9 +378,7 @@ UINT GetSystemDirectory(LPSTR lpszSysPath, UINT cbSysPath)
else
strcpy(lpszSysPath, SystemDirectory);
#ifdef DEBUG_FILE
fprintf(stderr,"GetSystemDirectory (%s)\n",lpszSysPath);
#endif
dprintf_file(stddeb,"GetSystemDirectory (%s)\n",lpszSysPath);
ChopOffSlash(lpszSysPath);
return(strlen(lpszSysPath));
@ -428,10 +405,8 @@ INT GetTempFileName(BYTE bDriveLetter, LPCSTR lpszPrefixString, UINT uUnique, LP
ToDos(lpszTempFileName);
#ifdef DEBUG_FILE
fprintf(stderr,"GetTempFilename: %c %s %d => %s\n",bDriveLetter,
dprintf_file(stddeb,"GetTempFilename: %c %s %d => %s\n",bDriveLetter,
lpszPrefixString,uUnique,lpszTempFileName);
#endif
if ((handle = _lcreat (lpszTempFileName, 0x0000)) == -1) {
fprintf(stderr,"GetTempFilename: can't create temp file '%s' !\n", lpszTempFileName);
}
@ -446,7 +421,7 @@ INT GetTempFileName(BYTE bDriveLetter, LPCSTR lpszPrefixString, UINT uUnique, LP
***************************************************************************/
WORD SetErrorMode(WORD x)
{
fprintf(stderr,"wine: SetErrorMode %4x (ignored)\n",x);
dprintf_file(stdnimp,"wine: SetErrorMode %4x (ignored)\n",x);
}
/***************************************************************************

View File

@ -3,16 +3,21 @@ static char Copyright[] = "Copyright Scott A. Laird, Erik Bos 1993, 1994";
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "prototypes.h"
#include "windows.h"
#include "keyboard.h"
#include "stddebug.h"
/* #define DEBUG_KEYBOARD /* */
/* #undef DEBUG_KEYBOARD /* */
#include "debug.h"
int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState,
LPVOID lpChar, WORD wFlags)
{
int i;
printf("ToAscii (%d,%d)\n",wVirtKey, wScanCode);
dprintf_keyboard(stddeb,"ToAscii (%d,%d)\n",wVirtKey, wScanCode);
/* FIXME: this is not sufficient but better than returing -1 */
@ -29,7 +34,7 @@ int ToAscii(WORD wVirtKey, WORD wScanCode, LPSTR lpKeyState,
DWORD OemKeyScan(WORD wOemChar)
{
printf("*OemKeyScan (%d)\n",wOemChar);
dprintf_keyboard(stddeb,"*OemKeyScan (%d)\n",wOemChar);
return wOemChar;
}
@ -41,7 +46,7 @@ WORD VkKeyScan(WORD cChar)
{
int i;
printf("VkKeyScan (%d)\n",cChar);
dprintf_keyboard(stddeb,"VkKeyScan (%d)\n",cChar);
for (i = 0 ; i != KeyTableSize ; i++)
if (KeyTable[i].ASCII == cChar)
@ -52,7 +57,7 @@ WORD VkKeyScan(WORD cChar)
int GetKeyboardType(int nTypeFlag)
{
printf("GetKeyboardType(%d)\n",nTypeFlag);
dprintf_keyboard(stddeb,"GetKeyboardType(%d)\n",nTypeFlag);
switch(nTypeFlag)
{
case 0: /* Keyboard type */
@ -104,7 +109,7 @@ WORD MapVirtualKey(WORD wCode, WORD wMapType)
int GetKbCodePage(void)
{
printf("GetKbCodePage()\n");
dprintf_keyboard(stddeb,"GetKbCodePage()\n");
return 850;
}
@ -112,7 +117,7 @@ int GetKeyNameText(LONG lParam, LPSTR lpBuffer, int nSize)
{
int i;
printf("GetKeyNameText(%d,<ptr>, %d)\n",lParam,nSize);
dprintf_keyboard(stddeb,"GetKeyNameText(%d,<ptr>, %d)\n",lParam,nSize);
lParam >>= 16;
lParam &= 0xff;

View File

@ -100,8 +100,8 @@ LPSTR AnsiUpper(LPSTR strOrChar)
}
return strOrChar;
} else
if (IsCharLower((char) strOrChar))
return (LPSTR) ToUpper(strOrChar);
if (IsCharLower((int)strOrChar))
return (LPSTR) ToUpper((int)strOrChar);
else
return (LPSTR) strOrChar;
}
@ -133,8 +133,8 @@ LPSTR AnsiLower(LPSTR strOrChar)
}
return strOrChar;
} else
if (IsCharUpper((char) strOrChar))
return (LPSTR) ToLower(strOrChar);
if (IsCharUpper((int)strOrChar))
return (LPSTR) ToLower((int)strOrChar);
else
return (LPSTR) strOrChar;
}

View File

@ -9,6 +9,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <locale.h>
#include <X11/Xlib.h>
#include <X11/Xresource.h>
@ -19,6 +20,9 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994";
#include "options.h"
#include "prototypes.h"
#include "texts.h"
#define DEBUG_DEFINE_VARIABLES
#include "stddebug.h"
#include "debug.h"
#define WINE_CLASS "Wine" /* Class name for resources */
@ -33,8 +37,6 @@ typedef ENVENTRY *LPENVENTRY;
LPENVENTRY lpEnvList = NULL;
Display * XT_display; /* To be removed */
Display *display;
Screen *screen;
Window rootWindow;
@ -42,7 +44,6 @@ int screenWidth = 0, screenHeight = 0; /* Desktop window dimensions */
int screenDepth = 0; /* Screen depth to use */
int desktopX = 0, desktopY = 0; /* Desktop window position (if any) */
char *ProgramName; /* Used by resource.c with WINELIB */
extern ButtonTexts ButtonText;
struct options Options =
@ -70,7 +71,8 @@ static XrmOptionDescRec optionsTable[] =
{ "-synchronous", ".synchronous", XrmoptionNoArg, (caddr_t)"on" },
{ "-spy", ".spy", XrmoptionSepArg, (caddr_t)NULL },
{ "-debug", ".debug", XrmoptionNoArg, (caddr_t)"on" },
{ "-relaydbg", ".relaydbg", XrmoptionNoArg, (caddr_t)"on" }
{ "-relaydbg", ".relaydbg", XrmoptionNoArg, (caddr_t)"on" },
{ "-debugmsg", ".debugmsg", XrmoptionSepArg, (caddr_t)NULL }
};
#define NB_OPTIONS (sizeof(optionsTable) / sizeof(optionsTable[0]))
@ -89,7 +91,8 @@ static XrmOptionDescRec optionsTable[] =
" -synchronous Turn on synchronous display mode\n" \
" -backingstore Turn on backing store\n" \
" -spy file Turn on message spying to the specified file\n" \
" -relaydbg Display call relay information\n"
" -relaydbg Display call relay information\n" \
" -debugmsg name Turn debugging-messages on or off\n"
/***********************************************************************
@ -232,9 +235,6 @@ static void MAIN_ParseOptions( int *argc, char *argv[] )
exit(1);
}
/* Use app-defaults */
display->db = db;
/* Get all options */
if (MAIN_GetResource( db, ".iconic", &value ))
Options.cmdShow = SW_SHOWMINIMIZED;
@ -254,6 +254,49 @@ static void MAIN_ParseOptions( int *argc, char *argv[] )
screenDepth = atoi( value.addr );
if (MAIN_GetResource( db, ".desktop", &value))
Options.desktopGeometry = value.addr;
if (MAIN_GetResource( db, ".debugmsg", &value))
{
#ifndef DEBUG_RUNTIME
fprintf(stderr,"%s: Option \"-debugmsg\" not implemented.\n" \
" Recompile with DEBUG_RUNTIME in include/stddebug.h defined.\n",
argv[0]);
exit(1);
#else
char *p=(char*)value.addr;
if (strlen(p)<3)
goto msgerror;
if ((*p!='+')&&(*p!='-'))
goto msgerror;
if (!strcasecmp(p+1,"all"))
{
int i;
for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
debug_msg_enabled[i]=(*p=='+');
}
else
{
int i;
for (i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
if (debug_msg_name && (!strcasecmp(p+1,debug_msg_name[i])))
{
debug_msg_enabled[i]=(*p=='+');
break;
}
if (i==sizeof(debug_msg_enabled)/sizeof(short))
{
msgerror:
fprintf(stderr,"%s: Syntax: -debugmsg +xxx or -debugmsg -xxx with xxx one of\n",argv[0]);
fprintf(stderr,"%-9s ","all");
for(i=0;i<sizeof(debug_msg_enabled)/sizeof(short);i++)
if(debug_msg_name[i])
fprintf(stderr,"%-9s%c",debug_msg_name[i],
(((i+2)%8==0)?'\n':' '));
fprintf(stderr,"\n\n");
exit(1);
}
}
#endif
}
/* MAIN_GetAllButtonTexts(db); */
@ -371,7 +414,6 @@ int main( int argc, char *argv[] )
screen = DefaultScreenOfDisplay( display );
screenWidth = WidthOfScreen( screen );
screenHeight = HeightOfScreen( screen );
XT_display = display;
if (screenDepth) /* -depth option specified */
{
depth_list = XListDepths(display,DefaultScreen(display),&depth_count);
@ -390,7 +432,6 @@ int main( int argc, char *argv[] )
if (Options.desktopGeometry) MAIN_CreateDesktop( argc, argv );
else rootWindow = DefaultRootWindow( display );
ProgramName = argv [0];
MAIN_SaveSetup();
DOS_InitFS();
Comm_Init();
@ -690,3 +731,11 @@ BOOL IsRomModule(HANDLE x)
return FALSE;
}
/***********************************************************************
* FileCDR (KERNEL.130)
*/
void FileCDR(FARPROC x)
{
printf("FileCDR(%8x)\n", (int) x);
}

View File

@ -11,18 +11,21 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#ifdef BUILTIN_MMSYSTEM
/*
#define DEBUG_CDAUDIO
*/
#include "stdio.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "win.h"
#include "user.h"
#include "driver.h"
#include "mmsystem.h"
#include "stddebug.h"
/* #define DEBUG_CDAUDIO /* */
/* #undef DEBUG_CDAUDIO /* */
#include "debug.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#ifdef linux
#include <linux/soundcard.h>
#include <linux/cdrom.h>
@ -84,9 +87,8 @@ DWORD CDAUDIO_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms)
#ifdef linux
UINT wDevID;
int cdrom;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciOpen(%08X, %08X);\n", dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciOpen(%08X, %08X);\n",
dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
wDevID = lpParms->wDeviceID;
if (CDADev[wDevID].nUseCount > 0) {
@ -103,14 +105,14 @@ DWORD CDAUDIO_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms)
CDADev[wDevID].fShareable = dwFlags & MCI_OPEN_SHAREABLE;
}
if (dwFlags & MCI_OPEN_ELEMENT) {
printf("CDAUDIO_mciOpen // MCI_OPEN_ELEMENT !\n");
dprintf_cdaudio(stddeb,"CDAUDIO_mciOpen // MCI_OPEN_ELEMENT !\n");
/* return MCIERR_NO_ELEMENT_ALLOWED; */
}
memcpy(&CDADev[wDevID].openParms, lpParms, sizeof(MCI_OPEN_PARMS));
CDADev[wDevID].wNotifyDeviceID = lpParms->wDeviceID;
CDADev[wDevID].unixdev = open (CDAUDIO_DEV, O_RDONLY, 0);
if (CDADev[wDevID].unixdev == -1) {
printf("CDAUDIO_mciOpen // can't open '%s' !\n", CDAUDIO_DEV);
fprintf(stderr,"CDAUDIO_mciOpen // can't open '%s' !\n", CDAUDIO_DEV);
return MCIERR_HARDWARE;
}
CDADev[wDevID].mode = 0;
@ -122,11 +124,13 @@ DWORD CDAUDIO_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms)
CDADev[wDevID].lpdwTrackLen = NULL;
CDADev[wDevID].lpdwTrackPos = NULL;
if (!CDAUDIO_GetTracksInfo(wDevID)) {
printf("CDAUDIO_mciOpen // error reading TracksInfo !\n");
fprintf(stderr,"CDAUDIO_mciOpen // error reading TracksInfo !\n");
/* return MCIERR_INTERNAL; */
}
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciOpen // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciOpen // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -142,9 +146,8 @@ DWORD CDAUDIO_mciOpen(DWORD dwFlags, LPMCI_OPEN_PARMS lpParms)
DWORD CDAUDIO_mciClose(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciClose(%u, %08X, %08X);\n", wDevID, dwParam, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciClose(%u, %08X, %08X);\n",
wDevID, dwParam, lpParms);
if (CDADev[wDevID].lpdwTrackLen != NULL) free(CDADev[wDevID].lpdwTrackLen);
if (CDADev[wDevID].lpdwTrackPos != NULL) free(CDADev[wDevID].lpdwTrackPos);
close(CDADev[wDevID].unixdev);
@ -158,12 +161,12 @@ DWORD CDAUDIO_mciGetDevCaps(UINT wDevID, DWORD dwFlags,
LPMCI_GETDEVCAPS_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciGetDevCaps(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciGetDevCaps(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (dwFlags & MCI_GETDEVCAPS_ITEM) {
printf("CDAUDIO_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08X;\n",
dprintf_cdaudio(stddeb,
"CDAUDIO_mciGetDevCaps // MCI_GETDEVCAPS_ITEM dwItem=%08X;\n",
lpParms->dwItem);
switch(lpParms->dwItem) {
case MCI_GETDEVCAPS_CAN_RECORD:
@ -197,7 +200,9 @@ DWORD CDAUDIO_mciGetDevCaps(UINT wDevID, DWORD dwFlags,
return MCIERR_UNRECOGNIZED_COMMAND;
}
}
printf("CDAUDIO_mciGetDevCaps // lpParms->dwReturn=%08X;\n", lpParms->dwReturn);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciGetDevCaps // lpParms->dwReturn=%08X;\n",
lpParms->dwReturn);
return 0;
#else
return MCIERR_INTERNAL;
@ -210,9 +215,8 @@ DWORD CDAUDIO_mciGetDevCaps(UINT wDevID, DWORD dwFlags,
DWORD CDAUDIO_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciInfo(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciInfo(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
lpParms->lpstrReturn = NULL;
switch(dwFlags) {
@ -238,15 +242,14 @@ DWORD CDAUDIO_mciInfo(UINT wDevID, DWORD dwFlags, LPMCI_INFO_PARMS lpParms)
DWORD CDAUDIO_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (CDADev[wDevID].unixdev == 0) return MMSYSERR_NOTENABLED;
if (dwFlags & MCI_NOTIFY) {
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
#endif
dprintf_cdaudio(stddeb,
"CDAUDIO_mciStatus // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -255,19 +258,17 @@ DWORD CDAUDIO_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
case MCI_STATUS_CURRENT_TRACK:
if (!CDAUDIO_GetCDStatus(wDevID)) return MCIERR_INTERNAL;
lpParms->dwReturn = CDADev[wDevID].nCurTrack;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus // CURRENT_TRACK=%u!\n", lpParms->dwReturn);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // CURRENT_TRACK=%u!\n", lpParms->dwReturn);
return 0;
case MCI_STATUS_LENGTH:
if (CDADev[wDevID].nTracks == 0) {
if (!CDAUDIO_GetTracksInfo(wDevID)) {
printf("CDAUDIO_mciStatus // error reading TracksInfo !\n");
fprintf(stderr,"CDAUDIO_mciStatus // error reading TracksInfo !\n");
return MCIERR_INTERNAL;
}
}
if (dwFlags & MCI_TRACK) {
printf("CDAUDIO_mciStatus // MCI_TRACK #%u LENGTH=??? !\n",
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_TRACK #%u LENGTH=??? !\n",
lpParms->dwTrack);
if (lpParms->dwTrack > CDADev[wDevID].nTracks)
return MCIERR_OUTOFRANGE;
@ -277,26 +278,24 @@ DWORD CDAUDIO_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
lpParms->dwReturn = CDADev[wDevID].dwTotalLen;
lpParms->dwReturn = CDAUDIO_CalcTime(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwReturn);
printf("CDAUDIO_mciStatus // LENGTH=%u !\n", lpParms->dwReturn);
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // LENGTH=%u !\n", lpParms->dwReturn);
return 0;
case MCI_STATUS_MODE:
if (!CDAUDIO_GetCDStatus(wDevID)) return MCIERR_INTERNAL;
lpParms->dwReturn = CDADev[wDevID].mode;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus // MCI_STATUS_MODE=%08X !\n",
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_STATUS_MODE=%08X !\n",
lpParms->dwReturn);
#endif
return 0;
case MCI_STATUS_MEDIA_PRESENT:
lpParms->dwReturn = (CDADev[wDevID].nTracks > 0) ? TRUE : FALSE;
if (lpParms->dwReturn == FALSE)
printf("CDAUDIO_mciStatus // MEDIA_NOT_PRESENT !\n");
fprintf(stderr,"CDAUDIO_mciStatus // MEDIA_NOT_PRESENT !\n");
else
printf("CDAUDIO_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n");
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_STATUS_MEDIA_PRESENT !\n");
return 0;
case MCI_STATUS_NUMBER_OF_TRACKS:
lpParms->dwReturn = CDAUDIO_GetNumberOfTracks(wDevID);
printf("CDAUDIO_mciStatus // MCI_STATUS_NUMBER_OF_TRACKS = %u !\n",
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_STATUS_NUMBER_OF_TRACKS = %u !\n",
lpParms->dwReturn);
if (lpParms->dwReturn == (WORD)-1) return MCIERR_INTERNAL;
return 0;
@ -305,39 +304,33 @@ DWORD CDAUDIO_mciStatus(UINT wDevID, DWORD dwFlags, LPMCI_STATUS_PARMS lpParms)
lpParms->dwReturn = CDADev[wDevID].dwCurFrame;
if (dwFlags & MCI_STATUS_START) {
lpParms->dwReturn = CDADev[wDevID].dwFirstOffset;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus // get MCI_STATUS_START !\n");
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // get MCI_STATUS_START !\n");
}
if (dwFlags & MCI_TRACK) {
if (lpParms->dwTrack > CDADev[wDevID].nTracks)
return MCIERR_OUTOFRANGE;
lpParms->dwReturn = CDADev[wDevID].lpdwTrackPos[lpParms->dwTrack - 1];
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus // get MCI_TRACK #%u !\n", lpParms->dwTrack);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // get MCI_TRACK #%u !\n", lpParms->dwTrack);
}
lpParms->dwReturn = CDAUDIO_CalcTime(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwReturn);
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStatus // MCI_STATUS_POSITION=%08X !\n",
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_STATUS_POSITION=%08X !\n",
lpParms->dwReturn);
#endif
return 0;
case MCI_STATUS_READY:
printf("CDAUDIO_mciStatus // MCI_STATUS_READY !\n");
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_STATUS_READY !\n");
lpParms->dwReturn = TRUE;
return 0;
case MCI_STATUS_TIME_FORMAT:
printf("CDAUDIO_mciStatus // MCI_STATUS_TIME_FORMAT !\n");
dprintf_cdaudio(stddeb,"CDAUDIO_mciStatus // MCI_STATUS_TIME_FORMAT !\n");
lpParms->dwReturn = MCI_FORMAT_MILLISECONDS;
return 0;
default:
printf("CDAUDIO_mciStatus // unknowm command %04X !\n", lpParms->dwItem);
fprintf(stderr,"CDAUDIO_mciStatus // unknown command %04X !\n", lpParms->dwItem);
return MCIERR_UNRECOGNIZED_COMMAND;
}
}
printf("CDAUDIO_mciStatus // not MCI_STATUS_ITEM !\n");
fprintf(stderr,"CDAUDIO_mciStatus // not MCI_STATUS_ITEM !\n");
return 0;
#else
return MMSYSERR_NOTENABLED;
@ -356,16 +349,15 @@ DWORD CDAUDIO_CalcTime(UINT wDevID, DWORD dwFormatType, DWORD dwFrame)
UINT wMinutes;
UINT wSeconds;
UINT wFrames;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcTime(%u, %08X, %lu);\n", wDevID, dwFormatType, dwFrame);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_CalcTime(%u, %08X, %lu);\n",
wDevID, dwFormatType, dwFrame);
TryAGAIN:
switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS:
dwTime = dwFrame / CDFRAMES_PERSEC * 1000;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcTime // MILLISECONDS %u\n", dwTime);
#endif
dprintf_cdaudio(stddeb,
"CDAUDIO_CalcTime // MILLISECONDS %u\n",
dwTime);
break;
case MCI_FORMAT_MSF:
wMinutes = dwFrame / CDFRAMES_PERMIN;
@ -373,10 +365,8 @@ TryAGAIN:
wFrames = dwFrame - CDFRAMES_PERMIN * wMinutes -
CDFRAMES_PERSEC * wSeconds;
dwTime = MCI_MAKE_MSF(wMinutes, wSeconds, wFrames);
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcTime // MSF %02u:%02u:%02u -> dwTime=%u\n",
dprintf_cdaudio(stddeb,"CDAUDIO_CalcTime // MSF %02u:%02u:%02u -> dwTime=%u\n",
wMinutes, wSeconds, wFrames, dwTime);
#endif
break;
case MCI_FORMAT_TMSF:
for (wTrack = 0; wTrack < CDADev[wDevID].nTracks; wTrack++) {
@ -390,10 +380,9 @@ TryAGAIN:
wFrames = dwFrame - CDFRAMES_PERMIN * wMinutes -
CDFRAMES_PERSEC * wSeconds;
dwTime = MCI_MAKE_TMSF(wTrack, wMinutes, wSeconds, wFrames);
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcTime // %02u-%02u:%02u:%02u\n",
dprintf_cdaudio(stddeb,
"CDAUDIO_CalcTime // %02u-%02u:%02u:%02u\n",
wTrack, wMinutes, wSeconds, wFrames);
#endif
break;
default:
/* unknown format ! force TMSF ! ... */
@ -413,36 +402,34 @@ DWORD CDAUDIO_CalcFrame(UINT wDevID, DWORD dwFormatType, DWORD dwTime)
DWORD dwFrame = 0;
#ifdef linux
UINT wTrack;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcFrame(%u, %08X, %lu);\n", wDevID, dwFormatType, dwTime);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_CalcFrame(%u, %08X, %lu);\n",
wDevID, dwFormatType, dwTime);
TryAGAIN:
switch (dwFormatType) {
case MCI_FORMAT_MILLISECONDS:
dwFrame = dwTime * CDFRAMES_PERSEC / 1000;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcFrame // MILLISECONDS %u\n", dwFrame);
#endif
dprintf_cdaudio(stddeb,
"CDAUDIO_CalcFrame // MILLISECONDS %u\n",
dwFrame);
break;
case MCI_FORMAT_MSF:
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcFrame // MSF %02u:%02u:%02u\n",
dprintf_cdaudio(stddeb,
"CDAUDIO_CalcFrame // MSF %02u:%02u:%02u\n",
MCI_MSF_MINUTE(dwTime), MCI_MSF_SECOND(dwTime),
MCI_MSF_FRAME(dwTime));
#endif
dwFrame += CDFRAMES_PERMIN * MCI_MSF_MINUTE(dwTime);
dwFrame += CDFRAMES_PERSEC * MCI_MSF_SECOND(dwTime);
dwFrame += MCI_MSF_FRAME(dwTime);
break;
case MCI_FORMAT_TMSF:
wTrack = MCI_TMSF_TRACK(dwTime);
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_CalcFrame // TMSF %02u-%02u:%02u:%02u\n",
dprintf_cdaudio(stddeb,
"CDAUDIO_CalcFrame // TMSF %02u-%02u:%02u:%02u\n",
MCI_TMSF_TRACK(dwTime), MCI_TMSF_MINUTE(dwTime),
MCI_TMSF_SECOND(dwTime), MCI_TMSF_FRAME(dwTime));
printf("CDAUDIO_CalcFrame // TMSF trackpos[%u]=%u\n",
dprintf_cdaudio(stddeb,
"CDAUDIO_CalcFrame // TMSF trackpos[%u]=%u\n",
wTrack, CDADev[wDevID].lpdwTrackPos[wTrack - 1]);
#endif
dwFrame = CDADev[wDevID].lpdwTrackPos[wTrack - 1];
dwFrame += CDFRAMES_PERMIN * MCI_TMSF_MINUTE(dwTime);
dwFrame += CDFRAMES_PERSEC * MCI_TMSF_SECOND(dwTime);
@ -467,7 +454,9 @@ UINT CDAUDIO_GetNumberOfTracks(UINT wDevID)
struct cdrom_tochdr hdr;
if (CDADev[wDevID].nTracks == 0) {
if (ioctl(CDADev[wDevID].unixdev, CDROMREADTOCHDR, &hdr)) {
printf("GetNumberOfTracks(%u) // Error occured !\n", wDevID);
fprintf(stderr,
"GetNumberOfTracks(%u) // Error occured !\n",
wDevID);
return (WORD)-1;
}
CDADev[wDevID].nTracks = hdr.cdth_trk1;
@ -491,7 +480,8 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID)
if (CDADev[wDevID].nTracks == 0) {
if (CDAUDIO_GetNumberOfTracks(wDevID) == (WORD)-1) return FALSE;
}
printf("CDAUDIO_GetTracksInfo // nTracks=%u\n", CDADev[wDevID].nTracks);
dprintf_cdaudio(stddeb,"CDAUDIO_GetTracksInfo // nTracks=%u\n",
CDADev[wDevID].nTracks);
if (CDADev[wDevID].lpdwTrackLen != NULL)
free(CDADev[wDevID].lpdwTrackLen);
CDADev[wDevID].lpdwTrackLen = (LPDWORD)malloc(
@ -502,7 +492,8 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID)
(CDADev[wDevID].nTracks + 1) * sizeof(DWORD));
if (CDADev[wDevID].lpdwTrackLen == NULL ||
CDADev[wDevID].lpdwTrackPos == NULL) {
printf("CDAUDIO_GetTracksInfo // error allocating track table !\n");
fprintf(stderr,
"CDAUDIO_GetTracksInfo // error allocating track table !\n");
return FALSE;
}
memset(CDADev[wDevID].lpdwTrackLen, 0,
@ -516,7 +507,8 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID)
entry.cdte_track = i + 1;
entry.cdte_format = CDROM_MSF;
if (ioctl(CDADev[wDevID].unixdev, CDROMREADTOCENTRY, &entry)) {
printf("CDAUDIO_GetTracksInfo // error read entry\n");
fprintf(stderr,
"CDAUDIO_GetTracksInfo // error read entry\n");
return FALSE;
}
start = CDFRAMES_PERSEC * (SECONDS_PERMIN *
@ -524,7 +516,9 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID)
entry.cdte_addr.msf.frame;
if (i == 0) {
CDADev[wDevID].dwFirstOffset = last_start = start;
printf("CDAUDIO_GetTracksInfo // dwFirstOffset=%u\n", start);
dprintf_cdaudio(stddeb,
"CDAUDIO_GetTracksInfo // dwFirstOffset=%u\n",
start);
}
else {
length = start - last_start;
@ -533,12 +527,14 @@ BOOL CDAUDIO_GetTracksInfo(UINT wDevID)
total_length += length;
CDADev[wDevID].lpdwTrackLen[i - 1] = length;
CDADev[wDevID].lpdwTrackPos[i - 1] = start;
printf("CDAUDIO_GetTracksInfo // track #%u start=%u len=%u\n",
i, start, length);
dprintf_cdaudio(stddeb,
"CDAUDIO_GetTracksInfo // track #%u start=%u len=%u\n",
i, start, length);
}
}
CDADev[wDevID].dwTotalLen = total_length;
printf("CDAUDIO_GetTracksInfo // total_len=%u\n", total_length);
dprintf_cdaudio(stddeb,"CDAUDIO_GetTracksInfo // total_len=%u\n",
total_length);
fflush(stdout);
return TRUE;
#else
@ -556,36 +552,28 @@ BOOL CDAUDIO_GetCDStatus(UINT wDevID)
int oldmode = CDADev[wDevID].mode;
CDADev[wDevID].sc.cdsc_format = CDROM_MSF;
if (ioctl(CDADev[wDevID].unixdev, CDROMSUBCHNL, &CDADev[wDevID].sc)) {
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_GetCDStatus // opened or no_media !\n");
#endif
fprintf(stderr,"CDAUDIO_GetCDStatus // opened or no_media !\n");
CDADev[wDevID].mode = MCI_MODE_NOT_READY;
return TRUE;
}
switch (CDADev[wDevID].sc.cdsc_audiostatus) {
case CDROM_AUDIO_INVALID:
printf("CDAUDIO_GetCDStatus // device doesn't support status !\n");
fprintf(stderr,"CDAUDIO_GetCDStatus // device doesn't support status !\n");
return FALSE;
case CDROM_AUDIO_NO_STATUS:
CDADev[wDevID].mode = MCI_MODE_STOP;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_GetCDStatus // MCI_MODE_STOP !\n");
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_GetCDStatus // MCI_MODE_STOP !\n");
break;
case CDROM_AUDIO_PLAY:
CDADev[wDevID].mode = MCI_MODE_PLAY;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_GetCDStatus // MCI_MODE_PLAY !\n");
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_GetCDStatus // MCI_MODE_PLAY !\n");
break;
case CDROM_AUDIO_PAUSED:
CDADev[wDevID].mode = MCI_MODE_PAUSE;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_GetCDStatus // MCI_MODE_PAUSE !\n");
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_GetCDStatus // MCI_MODE_PAUSE !\n");
break;
default:
printf("CDAUDIO_GetCDStatus // status=%02X !\n",
dprintf_cdaudio(stddeb,"CDAUDIO_GetCDStatus // status=%02X !\n",
CDADev[wDevID].sc.cdsc_audiostatus);
}
CDADev[wDevID].nCurTrack = CDADev[wDevID].sc.cdsc_trk;
@ -593,16 +581,14 @@ BOOL CDAUDIO_GetCDStatus(UINT wDevID)
CDFRAMES_PERMIN * CDADev[wDevID].sc.cdsc_absaddr.msf.minute +
CDFRAMES_PERSEC * CDADev[wDevID].sc.cdsc_absaddr.msf.second +
CDADev[wDevID].sc.cdsc_absaddr.msf.frame;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_GetCDStatus // %02u-%02u:%02u:%02u \n",
dprintf_cdaudio(stddeb,"CDAUDIO_GetCDStatus // %02u-%02u:%02u:%02u \n",
CDADev[wDevID].sc.cdsc_trk,
CDADev[wDevID].sc.cdsc_absaddr.msf.minute,
CDADev[wDevID].sc.cdsc_absaddr.msf.second,
CDADev[wDevID].sc.cdsc_absaddr.msf.frame);
#endif
if (oldmode != CDADev[wDevID].mode && oldmode == MCI_MODE_OPEN) {
if (!CDAUDIO_GetTracksInfo(wDevID)) {
printf("CDAUDIO_GetCDStatus // error updating TracksInfo !\n");
fprintf(stderr,"CDAUDIO_GetCDStatus // error updating TracksInfo !\n");
return MCIERR_INTERNAL;
}
}
@ -620,9 +606,8 @@ DWORD CDAUDIO_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
#ifdef linux
int start, end;
struct cdrom_msf msf;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciPlay(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciPlay(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (CDADev[wDevID].unixdev == 0) return MMSYSERR_NOTENABLED;
start = 0; end = CDADev[wDevID].dwTotalLen;
@ -630,18 +615,15 @@ DWORD CDAUDIO_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
if (dwFlags & MCI_FROM) {
start = CDAUDIO_CalcFrame(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwFrom);
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciPlay // MCI_FROM=%08X -> %u \n",
lpParms->dwFrom, start);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciPlay // MCI_FROM=%08X -> %u \n",
lpParms->dwFrom, start);
}
if (dwFlags & MCI_TO) {
end = CDAUDIO_CalcFrame(wDevID,
CDADev[wDevID].dwTimeFormat, lpParms->dwTo);
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciPlay // MCI_TO=%08X -> %u \n",
lpParms->dwTo, end);
#endif
dprintf_cdaudio(stddeb,
"CDAUDIO_mciPlay // MCI_TO=%08X -> %u \n",
lpParms->dwTo, end);
}
start += CDADev[wDevID].dwFirstOffset;
end += CDADev[wDevID].dwFirstOffset;
@ -652,21 +634,21 @@ DWORD CDAUDIO_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
msf.cdmsf_sec1 = (end % CDFRAMES_PERMIN) / CDFRAMES_PERSEC;
msf.cdmsf_frame1 = end % CDFRAMES_PERSEC;
if (ioctl(CDADev[wDevID].unixdev, CDROMSTART)) {
printf("CDAUDIO_mciPlay // motor doesn't start !\n");
fprintf(stderr,"CDAUDIO_mciPlay // motor doesn't start !\n");
return MCIERR_HARDWARE;
}
if (ioctl(CDADev[wDevID].unixdev, CDROMPLAYMSF, &msf)) {
printf("CDAUDIO_mciPlay // device doesn't play !\n");
fprintf(stderr,"CDAUDIO_mciPlay // device doesn't play !\n");
return MCIERR_HARDWARE;
}
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciPlay // msf = %d:%d:%d %d:%d:%d\n",
dprintf_cdaudio(stddeb,"CDAUDIO_mciPlay // msf = %d:%d:%d %d:%d:%d\n",
msf.cdmsf_min0, msf.cdmsf_sec0, msf.cdmsf_frame0,
msf.cdmsf_min1, msf.cdmsf_sec1, msf.cdmsf_frame1);
#endif
CDADev[wDevID].mode = MCI_MODE_PLAY;
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciPlay // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciPlay // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -682,14 +664,15 @@ DWORD CDAUDIO_mciPlay(UINT wDevID, DWORD dwFlags, LPMCI_PLAY_PARMS lpParms)
DWORD CDAUDIO_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciStop(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciStop(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev, CDROMSTOP)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciStop // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciStop // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -705,14 +688,15 @@ DWORD CDAUDIO_mciStop(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
DWORD CDAUDIO_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciPause(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciPause(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev, CDROMPAUSE)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_PAUSE;
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciPause // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciPause // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -728,14 +712,15 @@ DWORD CDAUDIO_mciPause(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
DWORD CDAUDIO_mciResume(UINT wDevID, DWORD dwFlags, LPMCI_GENERIC_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciResume(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciResume(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev, CDROMRESUME)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_STOP;
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciResume // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciResume // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -753,9 +738,8 @@ DWORD CDAUDIO_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
#ifdef linux
DWORD dwRet;
MCI_PLAY_PARMS PlayParms;
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciSeek(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciSeek(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
if (ioctl(CDADev[wDevID].unixdev, CDROMRESUME)) return MCIERR_HARDWARE;
CDADev[wDevID].mode = MCI_MODE_SEEK;
@ -774,7 +758,9 @@ DWORD CDAUDIO_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
if (dwRet != 0) return dwRet;
dwRet = CDAUDIO_mciStop(wDevID, MCI_WAIT, (LPMCI_GENERIC_PARMS)&PlayParms);
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciSeek // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciSeek // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -791,9 +777,8 @@ DWORD CDAUDIO_mciSeek(UINT wDevID, DWORD dwFlags, LPMCI_SEEK_PARMS lpParms)
DWORD CDAUDIO_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
{
#ifdef linux
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciSet(%u, %08X, %08X);\n", wDevID, dwFlags, lpParms);
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciSet(%u, %08X, %08X);\n",
wDevID, dwFlags, lpParms);
if (lpParms == NULL) return MCIERR_INTERNAL;
/*
printf("CDAUDIO_mciSet // dwTimeFormat=%08X\n", lpParms->dwTimeFormat);
@ -802,33 +787,30 @@ DWORD CDAUDIO_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
if (dwFlags & MCI_SET_TIME_FORMAT) {
switch (lpParms->dwTimeFormat) {
case MCI_FORMAT_MILLISECONDS:
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciSet // MCI_FORMAT_MILLISECONDS !\n");
#endif
dprintf_cdaudio(stddeb,
"CDAUDIO_mciSet // MCI_FORMAT_MILLISECONDS !\n");
break;
case MCI_FORMAT_MSF:
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciSet // MCI_FORMAT_MSF !\n");
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciSet // MCI_FORMAT_MSF !\n");
break;
case MCI_FORMAT_TMSF:
#ifdef DEBUG_CDAUDIO
printf("CDAUDIO_mciSet // MCI_FORMAT_TMSF !\n");
#endif
dprintf_cdaudio(stddeb,"CDAUDIO_mciSet // MCI_FORMAT_TMSF !\n");
break;
default:
printf("CDAUDIO_mciSet // bad time format !\n");
fprintf(stderr,"CDAUDIO_mciSet // bad time format !\n");
return MCIERR_BAD_TIME_FORMAT;
}
CDADev[wDevID].dwTimeFormat = lpParms->dwTimeFormat;
}
if (dwFlags & MCI_SET_DOOR_OPEN) {
printf("CDAUDIO_mciSet // MCI_SET_DOOR_OPEN !\n");
dprintf_cdaudio(stddeb,
"CDAUDIO_mciSet // MCI_SET_DOOR_OPEN !\n");
if (ioctl(CDADev[wDevID].unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
CDADev[wDevID].nTracks = 0;
}
if (dwFlags & MCI_SET_DOOR_CLOSED) {
printf("CDAUDIO_mciSet // MCI_SET_DOOR_CLOSED !\n");
dprintf_cdaudio(stddeb,
"CDAUDIO_mciSet // MCI_SET_DOOR_CLOSED !\n");
if (ioctl(CDADev[wDevID].unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
CDADev[wDevID].nTracks = 0;
}
@ -836,7 +818,9 @@ DWORD CDAUDIO_mciSet(UINT wDevID, DWORD dwFlags, LPMCI_SET_PARMS lpParms)
if (dwFlags & MCI_SET_ON) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_SET_OFF) return MCIERR_UNSUPPORTED_FUNCTION;
if (dwFlags & MCI_NOTIFY) {
printf("CDAUDIO_mciSet // MCI_NOTIFY_SUCCESSFUL %08X !\n", lpParms->dwCallback);
dprintf_cdaudio(stddeb,
"CDAUDIO_mciSet // MCI_NOTIFY_SUCCESSFUL %08X !\n",
lpParms->dwCallback);
mciDriverNotify((HWND)LOWORD(lpParms->dwCallback),
CDADev[wDevID].wNotifyDeviceID, MCI_NOTIFY_SUCCESSFUL);
}
@ -910,12 +894,13 @@ LRESULT CDAUDIO_DriverProc(DWORD dwDevID, HDRVR hDriv, WORD wMsg,
return CDAUDIO_mciSeek(dwDevID, dwParam1,
(LPMCI_SEEK_PARMS)dwParam2);
case MCI_SET_DOOR_OPEN:
printf("CDAUDIO_DriverProc // MCI_SET_DOOR_OPEN !\n");
dprintf_cdaudio(stddeb,
"CDAUDIO_DriverProc // MCI_SET_DOOR_OPEN !\n");
if (ioctl(CDADev[dwDevID].unixdev, CDROMEJECT)) return MCIERR_HARDWARE;
CDADev[dwDevID].nTracks = 0;
return 0;
case MCI_SET_DOOR_CLOSED:
printf("CDAUDIO_DriverProc // MCI_SET_DOOR_CLOSED !\n");
dprintf_cdaudio(stddeb,"CDAUDIO_DriverProc // MCI_SET_DOOR_CLOSED !\n");
if (ioctl(CDADev[dwDevID].unixdev, CDROMEJECT, 1)) return MCIERR_HARDWARE;
CDADev[dwDevID].nTracks = 0;
return 0;

View File

@ -14,6 +14,7 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#include <windows.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include "prototypes.h"
@ -93,8 +94,16 @@ int MessageBox(HWND hWnd, LPSTR str, LPSTR title, WORD type)
lpmb->Title = (LPSTR) malloc(strlen(title) + 1);
strcpy(lpmb->Title, title);
/* lpmb->Str = str;*/
lpmb->Str = (LPSTR) malloc(strlen(str) + 1);
strcpy(lpmb->Str, str);
if (str && *str)
{
lpmb->Str = (LPSTR) malloc(strlen(str) + 1);
strcpy(lpmb->Str, str);
}
else
{
lpmb->Str = (LPSTR) malloc(8);
strcpy(lpmb->Str, "Message");
}
lpmb->wType = type;
lpmb->ActiveFlg = TRUE;
wndClass.style = CS_HREDRAW | CS_VREDRAW ;

View File

@ -11,14 +11,16 @@ static char Copyright[] = "Copyright Martin Ayotte, 1994";
#ifdef BUILTIN_MMSYSTEM
#include "stdio.h"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "win.h"
#include "user.h"
#include "driver.h"
#include "mmsystem.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#ifdef linux
#include <linux/soundcard.h>
#endif

View File

@ -7,7 +7,9 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993";
#ifndef WINELIB
#include "stdio.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "win.h"

View File

@ -359,10 +359,17 @@ INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam);
*/
INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon)
{
fprintf(stderr, "ShellAbout ! (%s, %s)\n", szApp, szOtherStuff);
/* fprintf(stderr, "ShellAbout ! (%s, %s)\n", szApp, szOtherStuff);*/
strcpy(AppName, szApp);
strcpy(AppMisc, szOtherStuff);
if (szApp)
strcpy(AppName, szApp);
else
*AppName = 0;
if (szOtherStuff)
strcpy(AppMisc, szOtherStuff);
else
*AppMisc = 0;
return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (FARPROC)AboutDlgProc);
}

View File

@ -241,8 +241,8 @@ const char *MessageTypeNames[SPY_MAX_MSGNUM + 1] =
"WM_EXITSIZEMOVE" /* 0x0232 */
};
char SpyFilters[256];
char SpyIncludes[256];
char SpyFilters[256+1];
char SpyIncludes[256+1];
#endif /* NOSPY */
@ -303,7 +303,14 @@ void SpyInit(void)
}
GetPrivateProfileString("spy", "exclude", "", SpyFilters,
sizeof(SpyFilters), WINE_INI);
sizeof(SpyFilters)-1, WINE_INI);
GetPrivateProfileString("spy", "include", "", SpyIncludes,
sizeof(SpyIncludes), WINE_INI);
sizeof(SpyIncludes)-1, WINE_INI);
if (*SpyIncludes != 0) {
strcat(SpyIncludes, ";");
}
if (*SpyFilters != 0) {
strcat(SpyFilters, ";");
}
}

View File

@ -22,7 +22,6 @@ OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

View File

@ -2,6 +2,10 @@
#include <stdio.h>
#include "prototypes.h"
#include "regfunc.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
struct Win87EmInfoStruct {
unsigned short Version;
@ -15,8 +19,8 @@ struct Win87EmInfoStruct {
int
WIN87_fpmath()
{
printf( "_fpmath: (%x:%x %x %x)\n",_CONTEXT->sc_cs, _CONTEXT->sc_eip,
_CONTEXT->sc_es, _BX & 0xffff);
dprintf_int(stddeb, "_fpmath: (%x:%x %x %x)\n",_CONTEXT->sc_cs,
_CONTEXT->sc_eip, _CONTEXT->sc_es, _BX & 0xffff);
switch(_BX & 0xffff)
{
@ -31,17 +35,19 @@ WIN87_fpmath()
void
WIN87_WinEm87Info(struct Win87EmInfoStruct *pWIS, int cbWin87EmInfoStruct)
{
printf( "__WinEm87Info(%p,%d)\n",pWIS,cbWin87EmInfoStruct);
dprintf_int(stddeb, "__WinEm87Info(%p,%d)\n",pWIS,cbWin87EmInfoStruct);
}
void
WIN87_WinEm87Restore(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
{
printf( "__WinEm87Restore(%p,%d)\n",pWin87EmSaveArea,cbWin87EmSaveArea);
dprintf_int(stddeb, "__WinEm87Restore(%p,%d)\n",
pWin87EmSaveArea,cbWin87EmSaveArea);
}
void
WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
{
printf( "__WinEm87Save(%p,%d)\n",pWin87EmSaveArea,cbWin87EmSaveArea);
dprintf_int(stddeb, "__WinEm87Save(%p,%d)\n",
pWin87EmSaveArea,cbWin87EmSaveArea);
}

View File

@ -2,6 +2,10 @@
#include <stdlib.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context)
{

View File

@ -2,6 +2,12 @@
#include <stdlib.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context);
int do_int13(struct sigcontext_struct *context)
{

View File

@ -2,6 +2,12 @@
#include <stdlib.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context);
int do_int15(struct sigcontext_struct *context)
{

View File

@ -2,6 +2,12 @@
#include <stdlib.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context);
int do_int16(struct sigcontext_struct *context)
{

View File

@ -4,21 +4,29 @@
#include "registers.h"
#include "wine.h"
#include "options.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
#ifdef linux
#define inline __inline__ /* So we can compile with -ansi */
#include <linux/sched.h> /* needed for HZ */
#undef inline
#endif
#define BCD_TO_BIN(x) ((x&15) + (x>>4)*10)
#define BIN_TO_BCD(x) ((x%10) + ((x/10)<<4))
void IntBarf(int i, struct sigcontext_struct *context);
int do_int1A(struct sigcontext_struct * context){
time_t ltime;
struct tm *bdtime;
int ticks;
if (Options.relay_debug) {
printf("int1A: AX %04x, BX %04x, CX %04x, DX %04x, "
fprintf(stddeb,"int1A: AX %04x, BX %04x, CX %04x, DX %04x, "
"SI %04x, DI %04x, DS %04x, ES %04x\n",
AX, BX, CX, DX, SI, DI, DS, ES);
}
@ -30,7 +38,8 @@ int do_int1A(struct sigcontext_struct * context){
CX = ticks >> 16;
DX = ticks & 0x0000FFFF;
AX = 0; /* No midnight rollover */
printf("int1a_00 // ltime=%ld ticks=%ld\n", ltime, ticks);
dprintf_int(stddeb,"int1a_00 // ltime=%ld ticks=%ld\n",
ltime, ticks);
break;
case 2:

View File

@ -22,6 +22,10 @@
#include "msdos.h"
#include "registers.h"
#include "options.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
WORD ExtendedError, CodePage = 437;
BYTE ErrorClass, Action, ErrorLocus;
@ -38,6 +42,7 @@ WORD sharing_retries = 3; /* number of retries at sharing violation */
WORD sharing_pause = 1; /* pause between retries */
extern char TempDirectory[];
void IntBarf(int i, struct sigcontext_struct *context);
static int Error(int e, int class, int el)
{
@ -89,6 +94,7 @@ void errno_to_doserr(void)
}
}
/*
static void Barf(struct sigcontext_struct *context)
{
fprintf(stderr, "int21: unknown/not implemented parameters:\n");
@ -96,6 +102,7 @@ static void Barf(struct sigcontext_struct *context)
"SI %04x, DI %04x, DS %04x, ES %04x\n",
AX, BX, CX, DX, SI, DI, DS, ES);
}
*/
void ChopOffWhiteSpace(char *string)
{
@ -265,9 +272,9 @@ static void WriteFile(struct sigcontext_struct *context)
if (BX < 3) {
for (x = 0;x != CX;x++) {
fprintf(stderr, "%c", *ptr++);
dprintf_int(stddeb, "%c", *ptr++);
}
fflush(stderr);
fflush(stddeb);
Error (0,0,0);
AL = CX;
@ -356,6 +363,12 @@ static void ioctlGenericBlkDevReq(struct sigcontext_struct *context)
else
drive = BL - 1;
if (!DOS_ValidDrive(drive)) {
AX = 0x02;
SetCflag;
return;
}
if (CH != 0x08) {
IntBarf(0x21, context);
return;
@ -363,6 +376,7 @@ static void ioctlGenericBlkDevReq(struct sigcontext_struct *context)
switch (CL) {
case 0x60: /* get device parameters */
/* used by w4wgrp's winfile */
memset(dataptr, 0, 0x26);
dataptr[0] = 0x04;
dataptr[6] = 0; /* media type */
if (drive > 1)
@ -378,7 +392,6 @@ static void ioctlGenericBlkDevReq(struct sigcontext_struct *context)
setword(&dataptr[4], 80); /* # of cylinders */
}
CreateBPB(drive, &dataptr[7]);
AL = 0;
ResetCflag;
return;
default:
@ -450,7 +463,7 @@ void OpenExistingFile(struct sigcontext_struct *context)
case 1:
mode = O_WRONLY;
break;
default:
mode = O_RDWR;
break;
@ -471,7 +484,7 @@ void OpenExistingFile(struct sigcontext_struct *context)
break;
case 0x30: /* DENYREAD */
fprintf(stderr,
dprintf_int(stdnimp,
"OpenExistingFile (%s): DENYREAD changed to DENYALL\n",
pointer(DS,DX));
case 0x10: /* DENYALL */
@ -536,7 +549,7 @@ static void RenameFile(struct sigcontext_struct *context)
{
char *newname, *oldname;
fprintf(stderr,"int21: renaming %s to %s\n",
dprintf_int(stddeb,"int21: renaming %s to %s\n",
pointer(DS,DX), pointer(ES,DI) );
oldname = GetUnixFileName( pointer(DS,DX) );
@ -551,7 +564,7 @@ static void MakeDir(struct sigcontext_struct *context)
{
char *dirname;
fprintf(stderr,"int21: makedir %s\n", pointer(DS,DX) );
dprintf_int(stddeb,"int21: makedir %s\n", pointer(DS,DX) );
if ((dirname = GetUnixFileName( pointer(DS,DX) ))== NULL) {
AL = CanNotMakeDir;
@ -572,19 +585,23 @@ static void ChangeDir(struct sigcontext_struct *context)
int drive;
char *dirname = pointer(DS,DX);
drive = DOS_GetDefaultDrive();
fprintf(stderr,"int21: changedir %s\n", dirname);
dprintf_int(stddeb,"int21: changedir %s\n", dirname);
if (dirname != NULL && dirname[1] == ':') {
drive = toupper(dirname[0]) - 'A';
dirname += 2;
}
DOS_ChangeDir(drive, dirname);
if (!DOS_ChangeDir(drive, dirname))
{
SetCflag;
AX=0x03;
}
}
static void RemoveDir(struct sigcontext_struct *context)
{
char *dirname;
fprintf(stderr,"int21: removedir %s\n", pointer(DS,DX) );
dprintf_int(stddeb,"int21: removedir %s\n", pointer(DS,DX) );
if ((dirname = GetUnixFileName( pointer(DS,DX) ))== NULL) {
AL = CanNotMakeDir;
@ -623,14 +640,16 @@ static void FindNext(struct sigcontext_struct *context)
SetCflag;
return;
}
} while (*(dta + 0x0c) != dp->attribute);
} /* while (*(dta + 0x0c) != dp->attribute);*/
while ( ( dp->search_attribute & dp->attribute) != dp->attribute);
*(dta + 0x15) = dp->attribute;
setword(&dta[0x16], 0x1234); /* time */
setword(&dta[0x18], 0x1234); /* date */
setdword(&dta[0x1a], dp->filesize);
strncpy(dta + 0x1e, dp->filename, 13);
AL;
AL = 0;
ResetCflag;
return;
}
@ -640,7 +659,7 @@ static void FindFirst(struct sigcontext_struct *context)
BYTE drive, *path = pointer(DS, DX);
struct dosdirent *dp;
if (path[1] == ':') {
if ((*path)&&(path[1] == ':')) {
drive = (islower(*path) ? toupper(*path) : *path) - 'A';
if (!DOS_ValidDrive(drive)) {
@ -674,6 +693,7 @@ static void FindFirst(struct sigcontext_struct *context)
return;
}
dp->search_attribute = ECX & (FA_LABEL | FA_DIREC);
memcpy(dta + 0x0d, &dp, sizeof(dp));
FindNext(context);
}
@ -720,7 +740,7 @@ static void CreateTempFile(struct sigcontext_struct *context)
sprintf(temp,"%s\\win%d.tmp",TempDirectory,(int) getpid());
fprintf(stderr,"CreateTempFile %s\n",temp);
dprintf_int(stddeb,"CreateTempFile %s\n",temp);
handle = open(GetUnixFileName(temp), O_CREAT | O_TRUNC | O_RDWR);
@ -793,7 +813,7 @@ static void GetDiskSerialNumber(struct sigcontext_struct *context)
strncpy(dataptr + 6, DOS_GetVolumeLabel(drive), 8);
strncpy(dataptr + 0x11, "FAT16 ", 8);
AL;
AL = 0;
ResetCflag;
}
@ -830,8 +850,8 @@ static void DumpFCB(BYTE *fcb)
for (y = 0; y !=2 ; y++) {
for (x = 0; x!=15;x++)
fprintf(stderr, "%02x ", *fcb++);
fprintf(stderr,"\n");
dprintf_int(stddeb, "%02x ", *fcb++);
dprintf_int(stddeb,"\n");
}
}
@ -850,14 +870,14 @@ static void FindFirstFCB(struct sigcontext_struct *context)
if ((*fcb) == 0xff)
{
standard_fcb = fcb + 7;
output_fcb = dta + 7;
standard_fcb = (struct fcb *)(fcb + 7);
output_fcb = (struct fcb *)(dta + 7);
*dta = 0xff;
}
else
{
standard_fcb = fcb;
output_fcb = dta;
standard_fcb = (struct fcb *)fcb;
output_fcb = (struct fcb *)dta;
}
if (standard_fcb->drive)
@ -875,7 +895,7 @@ static void FindFirstFCB(struct sigcontext_struct *context)
output_fcb->drive = drive;
if (*(fcb) == 0xff)
if (*(fcb) == 0xff)
{
if (*(fcb+6) & FA_LABEL) /* return volume label */
{
@ -883,14 +903,14 @@ static void FindFirstFCB(struct sigcontext_struct *context)
memset(&output_fcb->name, ' ', 11);
if (DOS_GetVolumeLabel(drive) != NULL)
{
strncpy(&output_fcb->name, DOS_GetVolumeLabel(drive), 11);
strncpy(output_fcb->name, DOS_GetVolumeLabel(drive), 11);
AL = 0x00;
return;
}
}
}
strncpy(&(output_fcb->name),&(standard_fcb->name),11);
strncpy(output_fcb->name, standard_fcb->name, 11);
if (*fcb == 0xff)
*(dta+6) = ( *(fcb+6) & (!FA_DIREC));
@ -940,11 +960,11 @@ static void DeleteFileFCB(struct sigcontext_struct *context)
while (DOS_readdir(dp) != NULL)
{
strcpy(ptr, dp->filename);
fprintf(stderr, "int21: delete file %s\n", temp);
dprintf_int(stddeb, "int21: delete file %s\n", temp);
/* unlink(GetUnixFileName(temp)); */
}
DOS_closedir(dp);
AL;
AL = 0;
}
static void RenameFileFCB(struct sigcontext_struct *context)
@ -986,10 +1006,11 @@ static void RenameFileFCB(struct sigcontext_struct *context)
{
strcpy(oldnameptr, dp->filename);
strcpy(newnameptr, fcb + 1);
fprintf(stderr, "int21: renamefile %s -> %s\n", oldname, newname);
dprintf_int(stddeb, "int21: renamefile %s -> %s\n",
oldname, newname);
}
DOS_closedir(dp);
AL;
AL = 0;
}
@ -1080,7 +1101,7 @@ int do_int21(struct sigcontext_struct * context)
{
if (Options.relay_debug)
{
printf("int21: AX %04x, BX %04x, CX %04x, DX %04x, "
fprintf(stddeb,"int21: AX %04x, BX %04x, CX %04x, DX %04x, "
"SI %04x, DI %04x, DS %04x, ES %04x\n",
AX, BX, CX, DX, SI, DI, DS, ES);
}
@ -1178,7 +1199,7 @@ int do_int21(struct sigcontext_struct * context)
AL = DOS_GetDefaultDrive();
Error (0,0,0);
break;
case 0x1a: /* SET DISK TRANSFER AREA ADDRESS */
dta = pointer(DS, DX);
break;
@ -1197,7 +1218,9 @@ int do_int21(struct sigcontext_struct * context)
case 0x25: /* SET INTERRUPT VECTOR */
/* Ignore any attempt to set a segment vector */
fprintf(stderr, "int21: set interrupt vector %2x (%04x:%04x)\n", AL, DS, DX);
dprintf_int(stdnimp,
"int21: set interrupt vector %2x (%04x:%04x)\n",
AL, DS, DX);
break;
case 0x2a: /* GET SYSTEM DATE */
@ -1265,7 +1288,8 @@ int do_int21(struct sigcontext_struct * context)
case 0x35: /* GET INTERRUPT VECTOR */
/* Return a NULL segment selector - this will bomb,
if anyone ever tries to use it */
fprintf(stderr, "int21: get interrupt vector %2x\n", AX & 0xff);
dprintf_int(stdnimp, "int21: get interrupt vector %2x\n",
AX & 0xff);
ES = 0;
BX = 0;
break;
@ -1379,7 +1403,7 @@ int do_int21(struct sigcontext_struct * context)
ResetCflag;
break;
case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
case 0x47: /* "CWD" - GET CURRENT DIRECTORY */
GetCurrentDirectory(context);
AX = 0x0100;
/* intlist: many Microsoft products for Windows rely on this */
@ -1398,7 +1422,7 @@ int do_int21(struct sigcontext_struct * context)
case 0x4c: /* "EXIT" - TERMINATE WITH RETURN CODE */
exit(AL);
break;
case 0x4d: /* GET RETURN CODE */
AL = NoError; /* normal exit */
break;
@ -1474,7 +1498,7 @@ int do_int21(struct sigcontext_struct * context)
AL = InvalidDrive;
SetCflag;
break;
}
}
else
{
ResetCflag;

View File

@ -3,6 +3,10 @@
#include "registers.h"
#include "msdos.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
int do_int25(struct sigcontext_struct *context)
{
@ -18,7 +22,7 @@ int do_int25(struct sigcontext_struct *context)
begin = DX;
length = CX;
}
fprintf(stderr, "int25: abs diskread, drive %d, sector %d, "
dprintf_int(stdnimp, "int25: abs diskread, drive %d, sector %d, "
"count %d, buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
memset(dataptr, 0, length * 512);

View File

@ -3,6 +3,12 @@
#include "registers.h"
#include "msdos.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context);
int do_int26(struct sigcontext_struct *context)
{
@ -19,7 +25,7 @@ int do_int26(struct sigcontext_struct *context)
length = CX;
}
fprintf(stderr,"int26: abs diskwrite, drive %d, sector %d, count %d,"
dprintf_int(stdnimp,"int26: abs diskwrite, drive %d, sector %d, count %d,"
" buffer %d\n", EAX & 0xff, begin, length, (int) dataptr);
ResetCflag;

View File

@ -2,6 +2,12 @@
#include <stdlib.h>
#include "msdos.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context);
int do_int2a(struct sigcontext_struct *context)
{

View File

@ -2,10 +2,14 @@
#include <stdlib.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
void IntBarf(int i, struct sigcontext_struct *context);
int do_int2f_16(struct sigcontext_struct *context);
int do_int2f(struct sigcontext_struct *context)
{
switch((context->sc_eax >> 8) & 0xff)
@ -33,16 +37,16 @@ int do_int2f_16(struct sigcontext_struct *context)
switch(context->sc_eax & 0xff) {
case 0x00:
/* return 'major/minor' for MSWin 3.1 */
printf("do_int2f_16 // return 'major/minor' for MSWin 3.1 !\n");
dprintf_int(stddeb,"do_int2f_16 // return 'major/minor' for MSWin 3.1 !\n");
context->sc_eax = 0x0310;
return 1;
case 0x86:
case 0x86:
/* operating in protected mode under DPMI */
printf("do_int2f_16 // operating in protected mode under DPMI !\n");
dprintf_int(stddeb,"do_int2f_16 // operating in protected mode under DPMI !\n");
context->sc_eax = 0x0000;
return 1;
case 0x87:
printf("do_int2f_16 // return DPMI flags !\n");
case 0x87:
dprintf_int(stddeb,"do_int2f_16 // return DPMI flags !\n");
context->sc_eax = 0x0000; /* DPMI Installed */
context->sc_ebx = 0x0001; /* 32bits available */
context->sc_ecx = 0x04; /* processor 486 */

View File

@ -2,6 +2,10 @@
#include <stdlib.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
typedef struct {
WORD accessed : 1;
@ -33,7 +37,8 @@ BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc);
int do_int31(struct sigcontext_struct *context)
{
LPDESCRIPTOR lpDesc;
printf("do_int31 // context->sc_eax=%04X\n", context->sc_eax);
dprintf_int(stddeb,"do_int31 // context->sc_eax=%04X\n",
context->sc_eax);
switch(context->sc_eax)
{
case 0x0000:
@ -60,35 +65,43 @@ HANDLE DPMI_GetNewSelector(WORD selcount)
{
LPSTR ptr;
HANDLE pmSel;
printf("DPMI_GetNewSelector(%d); !\n", selcount);
dprintf_int(stddeb,"DPMI_GetNewSelector(%d); !\n", selcount);
pmSel = GlobalAlloc(GMEM_FIXED, 4096);
ptr = GlobalLock(pmSel);
printf("DPMI_GetNewSelector() return %04X !\n", pmSel);
dprintf_int(stddeb,"DPMI_GetNewSelector() return %04X !\n", pmSel);
return pmSel;
}
BOOL DPMI_FreeSelector(HANDLE pmSel)
{
printf("DPMI_FreeSelector(%04X); !\n", pmSel);
dprintf_int(stddeb,"DPMI_FreeSelector(%04X); !\n", pmSel);
GlobalFree(pmSel);
return 0;
}
BOOL DPMI_SetDescriptor(HANDLE pmSel, LPDESCRIPTOR lpDesc)
{
printf("DPMI_SetDescriptor(%04X, %08X); !\n", pmSel, lpDesc);
printf("DPMI lpDesc->Limit=%u \n", lpDesc->Limit);
printf("DPMI lpDesc->addr_lo=%04X \n", lpDesc->addr_lo);
printf("DPMI lpDesc->addr_hi=%02X \n", lpDesc->addr_hi);
printf("DPMI lpDesc->access.accessed=%u \n", lpDesc->access.accessed);
printf("DPMI lpDesc->access.read_write=%u \n", lpDesc->access.read_write);
printf("DPMI lpDesc->access.conf_exp=%u \n", lpDesc->access.conf_exp);
printf("DPMI lpDesc->access.code=%u \n", lpDesc->access.code);
printf("DPMI lpDesc->access.xsystem=%u \n", lpDesc->access.xsystem);
printf("DPMI lpDesc->access.dpl=%u \n", lpDesc->access.dpl);
printf("DPMI lpDesc->access.present=%u \n", lpDesc->access.present);
printf("DPMI lpDesc->reserved=%04X \n", lpDesc->reserved);
dprintf_int(stdnimp,"DPMI_SetDescriptor(%04X, %08X); !\n",
pmSel, lpDesc);
dprintf_int(stdnimp,"DPMI lpDesc->Limit=%u \n", lpDesc->Limit);
dprintf_int(stdnimp,"DPMI lpDesc->addr_lo=%04X \n", lpDesc->addr_lo);
dprintf_int(stdnimp,"DPMI lpDesc->addr_hi=%02X \n", lpDesc->addr_hi);
dprintf_int(stdnimp,"DPMI lpDesc->access.accessed=%u \n",
lpDesc->access.accessed);
dprintf_int(stdnimp,"DPMI lpDesc->access.read_write=%u \n",
lpDesc->access.read_write);
dprintf_int(stdnimp,"DPMI lpDesc->access.conf_exp=%u \n",
lpDesc->access.conf_exp);
dprintf_int(stdnimp,"DPMI lpDesc->access.code=%u \n",
lpDesc->access.code);
dprintf_int(stdnimp,"DPMI lpDesc->access.xsystem=%u \n",
lpDesc->access.xsystem);
dprintf_int(stdnimp,"DPMI lpDesc->access.dpl=%u \n",
lpDesc->access.dpl);
dprintf_int(stdnimp,"DPMI lpDesc->access.present=%u \n",
lpDesc->access.present);
dprintf_int(stdnimp,"DPMI lpDesc->reserved=%04X \n", lpDesc->reserved);
return FALSE;
}

View File

@ -3,6 +3,10 @@
#include <time.h>
#include "registers.h"
#include "wine.h"
#include "stddebug.h"
/* #define DEBUG_INT */
/* #undef DEBUG_INT */
#include "debug.h"
static BYTE cmosaddress;
@ -18,7 +22,7 @@ static BYTE cmosimage[64] = {
void inportb(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: inb (%x)\n", DX);
dprintf_int(stddeb, "IO: inb (%x)\n", DX);
switch(DX) {
case 0x70:
@ -33,14 +37,14 @@ void inportb(struct sigcontext_struct *context)
void inport(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: in (%x)\n", DX);
dprintf_int(stdnimp, "IO: in (%x)\n", DX);
AX = 0xffff;
}
void outportb(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: outb (%x), %x\n", DX, AX);
dprintf_int(stdnimp, "IO: outb (%x), %x\n", DX, AX);
switch (EDX & 0xffff)
{
@ -56,5 +60,5 @@ void outportb(struct sigcontext_struct *context)
void outport(struct sigcontext_struct *context)
{
fprintf(stderr, "IO: out (%x), %x\n", DX, AX);
dprintf_int(stdnimp, "IO: out (%x), %x\n", DX, AX);
}

View File

@ -6,6 +6,8 @@ static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
#include "prototypes.h"
#include "regfunc.h"
#include "options.h"
#include "stddebug.h"
#include "debug.h"
extern unsigned short WIN_StackSize;
@ -18,9 +20,8 @@ KERNEL_LockSegment(int segment)
if (segment == -1)
segment = *(Stack16Frame + 6);
#ifdef RELAY_DEBUG
printf("LockSegment: segment %x\n", segment);
#endif
if (Options.relay_debug)
fprintf(stddeb,"LockSegment: segment %x\n", segment);
return segment;
}
@ -34,9 +35,8 @@ KERNEL_UnlockSegment(int segment)
if (segment == -1)
segment = *(Stack16Frame + 6);
#ifdef RELAY_DEBUG
printf("UnlockSegment: segment %x\n", segment);
#endif
if (Options.relay_debug)
fprintf(stddeb,"UnlockSegment: segment %x\n", segment);
return segment;
}
@ -50,6 +50,11 @@ KERNEL_InitTask()
_AX = 1;
_CX = WIN_StackSize;
_DX = Options.cmdShow;
_DI = _DS;
/* FIXME: DI should contain the instance handle of the caller, _DS doesn't
always work as the caller might have changed it. */
_SI = 0;
ReturnFromRegisterFunc();
/* Function does not return */
@ -61,8 +66,7 @@ KERNEL_InitTask()
int
KERNEL_WaitEvent(int task)
{
#ifdef RELAY_DEBUG
printf("WaitEvent: task %d\n", task);
#endif
if (Options.relay_debug)
fprintf(stddeb,"WaitEvent: task %d\n", task);
return 0;
}

View File

@ -3,44 +3,28 @@
MODULE = objects
SRCS = \
bitblt.c \
bitmap.c \
brush.c \
clipping.c \
color.c \
dc.c \
dcvalues.c \
dib.c \
dither.c \
font.c \
gdiobj.c \
linedda.c \
metafile.c \
palette.c \
pen.c \
dib.c \
region.c \
text.c \
dcvalues.c \
clipping.c \
bitblt.c \
linedda.c \
color.c \
dither.c \
metafile.c
text.c
OBJS = \
bitmap.o \
brush.o \
font.o \
gdiobj.o \
palette.o \
pen.o \
dib.o \
region.o \
text.o \
dcvalues.o \
clipping.o \
bitblt.o \
linedda.o \
color.o \
dither.o \
metafile.o
OBJS = $(SRCS:.c=.o)
WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
DependTarget()
CleanTarget()
includes::

View File

@ -13,6 +13,11 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "gdi.h"
#include "metafile.h"
#include "options.h"
#include "stddebug.h"
/* #define DEBUG_GDI /* */
/* #undef DEBUG_GDI /* */
#include "debug.h"
extern const int DC_XROPfunction[];
@ -26,8 +31,6 @@ extern const int DC_XROPfunction[];
BOOL PatBlt( HDC hdc, short left, short top,
short width, short height, DWORD rop)
{
int x1, x2, y1, y2;
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc)
{
@ -38,22 +41,42 @@ BOOL PatBlt( HDC hdc, short left, short top,
return TRUE;
}
#ifdef DEBUG_GDI
printf( "PatBlt: %d %d,%d %dx%d %06x\n",
dprintf_gdi(stddeb, "PatBlt: %d %d,%d %dx%d %06x\n",
hdc, left, top, width, height, rop );
#endif
/* Convert ROP3 code to ROP2 code */
rop >>= 16;
if (!DC_SetupGCForBrush( dc )) rop &= 0x0f;
else rop = (rop & 0x03) | ((rop >> 4) & 0x0c);
XSetFunction( XT_display, dc->u.x.gc, DC_XROPfunction[rop] );
x1 = dc->w.DCOrgX + XLPTODP( dc, left );
x2 = dc->w.DCOrgX + XLPTODP( dc, left + width );
y1 = dc->w.DCOrgY + YLPTODP( dc, top );
y2 = dc->w.DCOrgY + YLPTODP( dc, top + height );
XFillRectangle( XT_display, dc->u.x.drawable, dc->u.x.gc,
MIN(x1,x2), MIN(y1,y2), abs(x2-x1), abs(y2-y1) );
/* Special case for BLACKNESS and WHITENESS */
if (!Options.usePrivateMap && ((rop == R2_BLACK-1) || (rop == R2_WHITE-1)))
{
XSetForeground( display, dc->u.x.gc, (rop == R2_BLACK-1) ?
BlackPixelOfScreen(screen) : WhitePixelOfScreen(screen));
XSetFillStyle( display, dc->u.x.gc, FillSolid );
rop = R2_COPYPEN;
}
XSetFunction( display, dc->u.x.gc, DC_XROPfunction[rop] );
left = dc->w.DCOrgX + XLPTODP( dc, left );
top = dc->w.DCOrgY + YLPTODP( dc, top );
/* Convert dimensions to device coords */
if ((width = (width * dc->w.VportExtX) / dc->w.WndExtX) < 0)
{
width = -width;
left -= width;
}
if ((height = (height * dc->w.VportExtY) / dc->w.WndExtY) < 0)
{
height = -height;
top -= height;
}
XFillRectangle( display, dc->u.x.drawable, dc->u.x.gc,
left, top, width, height );
return TRUE;
}
@ -69,18 +92,17 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height,
DWORD saverop = rop;
DC *dcDest, *dcSrc;
#ifdef DEBUG_GDI
printf( "BitBlt: %d %d,%d %dx%d %d %d,%d %08x\n",
hdcDest, xDest, yDest, width, height, hdcSrc, xSrc, ySrc, rop );
#endif
if (width == 0 || height == 0) return FALSE;
dprintf_gdi(stddeb, "BitBlt: %04x %d,%d %dx%d %04x %d,%d %08x\n",
hdcDest, xDest, yDest, width, height, hdcSrc, xSrc, ySrc, rop);
if (width == 0 || height == 0) return FALSE;
if ((rop & 0xcc0000) == ((rop & 0x330000) << 2))
return PatBlt( hdcDest, xDest, yDest, width, height, rop );
rop >>= 16;
if ((rop & 0x0f) != (rop >> 4))
{
printf( "BitBlt: Unimplemented ROP %02x\n", rop );
dprintf_gdi(stdnimp, "BitBlt: Unimplemented ROP %02x\n", rop );
return FALSE;
}
@ -109,21 +131,21 @@ BOOL BitBlt( HDC hdcDest, short xDest, short yDest, short width, short height,
return FALSE; /* Should call StretchBlt here */
DC_SetupGCForText( dcDest );
XSetFunction( XT_display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f] );
XSetFunction( display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f] );
if (dcSrc->w.bitsPerPixel == dcDest->w.bitsPerPixel)
{
XCopyArea( XT_display, dcSrc->u.x.drawable,
XCopyArea( display, dcSrc->u.x.drawable,
dcDest->u.x.drawable, dcDest->u.x.gc,
MIN(xs1,xs2), MIN(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1),
MIN(xd1,xd2), MIN(yd1,yd2) );
min(xs1,xs2), min(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1),
min(xd1,xd2), min(yd1,yd2) );
}
else
{
if (dcSrc->w.bitsPerPixel != 1) return FALSE;
XCopyPlane( XT_display, dcSrc->u.x.drawable,
XCopyPlane( display, dcSrc->u.x.drawable,
dcDest->u.x.drawable, dcDest->u.x.gc,
MIN(xs1,xs2), MIN(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1),
MIN(xd1,xd2), MIN(yd1,yd2), 1 );
min(xs1,xs2), min(ys1,ys2), abs(xs2-xs1), abs(ys2-ys1),
min(xd1,xd2), min(yd1,yd2), 1 );
}
return TRUE;
}
@ -248,7 +270,7 @@ static void wonb_stretch(XImage *sxi, XImage *dxi,
/* scaling without having to worry about overflows. */
/* ##### muldiv64() borrowed from svgalib 1.03 ##### */
static inline int muldiv64( int m1, int m2, int d )
static __inline__ int muldiv64( int m1, int m2, int d )
{
/* int32 * int32 -> int64 / int32 -> int32 */
#ifdef i386
@ -331,13 +353,11 @@ BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short h
WORD stretchmode;
BOOL flg;
#ifdef DEBUG_GDI
fprintf(stderr, "StretchBlt: %d %d,%d %dx%d %d %d,%d %dx%d %08x\n",
dprintf_gdi(stddeb, "StretchBlt: %d %d,%d %dx%d %d %d,%d %dx%d %08x\n",
hdcDest, xDest, yDest, widthDest, heightDest, hdcSrc, xSrc,
ySrc, widthSrc, heightSrc, rop );
printf("StretchMode is %x\n",
dprintf_gdi(stddeb, "StretchMode is %x\n",
((DC *)GDI_GetObjPtr(hdcDest, DC_MAGIC))->w.stretchBltMode);
#endif
if (widthDest == 0 || heightDest == 0) return FALSE;
if (widthSrc == 0 || heightSrc == 0) return FALSE;
@ -356,7 +376,7 @@ BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short h
rop >>= 16;
if ((rop & 0x0f) != (rop >> 4))
{
printf( "StretchBlt: Unimplemented ROP %02x\n", rop );
dprintf_gdi(stdnimp, "StretchBlt: Unimplemented ROP %02x\n", rop );
return FALSE;
}
@ -427,7 +447,7 @@ BOOL StretchBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short h
DC_SetupGCForText(dcDest);
XSetFunction(display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f]);
XPutImage(display, dcDest->u.x.drawable, dcDest->u.x.gc,
dxi, 0, 0, MIN(xd1,xd2), MIN(yd1,yd2),
dxi, 0, 0, min(xd1,xd2), min(yd1,yd2),
widthDest, heightDest);
/* now free the images we created */

View File

@ -6,23 +6,28 @@
static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "gdi.h"
#include "bitmap.h"
#include "stddebug.h"
/* #define DEBUG_GDI /* */
/* #undef DEBUG_GDI /* */
/* #define DEBUG_BITMAP /* */
/* #define DEBUG_BITMAP /* */
#include "debug.h"
/* Include OEM bitmaps */
#include "bitmaps/check_boxes"
#include "bitmaps/check_mark"
#include "bitmaps/menu_arrow"
/* Handle of the bitmap selected by default in a memory DC */
HBITMAP BITMAP_hbitmapMemDC = 0;
/* GCs used for B&W and color bitmap operations */
GC BITMAP_monoGC = 0, BITMAP_colorGC = 0;
extern void DC_InitDC( HDC hdc ); /* dc.c */
/***********************************************************************
* BITMAP_Init
@ -49,9 +54,7 @@ BOOL BITMAP_Init()
XFreePixmap( display, tmpPixmap );
}
}
BITMAP_hbitmapMemDC = CreateBitmap( 1, 1, 1, 1, NULL );
return (BITMAP_hbitmapMemDC != 0);
return TRUE;
}
@ -143,10 +146,8 @@ HBITMAP CreateBitmap( short width, short height,
BYTE planes, BYTE bpp, LPSTR bits )
{
BITMAP bitmap = { 0, width, height, 0, planes, bpp, bits };
#ifdef DEBUG_GDI
printf( "CreateBitmap: %dx%d, %d colors\n",
dprintf_gdi(stddeb, "CreateBitmap: %dx%d, %d colors\n",
width, height, 1 << (planes*bpp) );
#endif
return CreateBitmapIndirect( &bitmap );
}
@ -157,9 +158,8 @@ HBITMAP CreateBitmap( short width, short height,
HBITMAP CreateCompatibleBitmap( HDC hdc, short width, short height )
{
DC * dc;
#ifdef DEBUG_GDI
printf( "CreateCompatibleBitmap: %d %dx%d\n", hdc, width, height );
#endif
dprintf_gdi(stddeb, "CreateCompatibleBitmap: %d %dx%d\n",
hdc, width, height );
if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
return CreateBitmap( width, height, 1, dc->w.bitsPerPixel, NULL );
}
@ -222,11 +222,9 @@ LONG GetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return 0;
#ifdef DEBUG_BITMAP
printf( "GetBitmapBits: %dx%d %d colors %p\n",
dprintf_bitmap(stddeb, "GetBitmapBits: %dx%d %d colors %p\n",
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, buffer );
#endif
/* Only get entire lines */
height = count / bmp->bitmap.bmWidthBytes;
if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
@ -253,11 +251,10 @@ LONG SetBitmapBits( HBITMAP hbitmap, LONG count, LPSTR buffer )
bmp = (BITMAPOBJ *) GDI_GetObjPtr( hbitmap, BITMAP_MAGIC );
if (!bmp) return 0;
#ifdef DEBUG_BITMAP
printf( "SetBitmapBits: %dx%d %d colors %p\n",
dprintf_bitmap(stddeb, "SetBitmapBits: %dx%d %d colors %p\n",
bmp->bitmap.bmWidth, bmp->bitmap.bmHeight,
1 << bmp->bitmap.bmBitsPixel, buffer );
#endif
/* Only set entire lines */
height = count / bmp->bitmap.bmWidthBytes;
if (height > bmp->bitmap.bmHeight) height = bmp->bitmap.bmHeight;
@ -314,9 +311,7 @@ HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap,
XFreeGC( display, dc->u.x.gc );
dc->u.x.gc = XCreateGC( display, dc->u.x.drawable, 0, NULL );
dc->w.bitsPerPixel = bmp->bitmap.bmBitsPixel;
/* Re-select objects with changed depth */
SelectObject( hdc, dc->w.hPen );
SelectObject( hdc, dc->w.hBrush );
DC_InitDC( hdc );
}
return prevHandle;
}
@ -326,7 +321,7 @@ HBITMAP BITMAP_SelectObject( HDC hdc, DC * dc, HBITMAP hbitmap,
*/
HBITMAP CreateDiscardableBitmap(HDC hdc, short width, short height)
{
printf("CreateDiscardableBitmap(%04X, %d, %d); "
dprintf_bitmap(stddeb,"CreateDiscardableBitmap(%04X, %d, %d); "
"// call CreateCompatibleBitmap() for now!\n",
hdc, width, height);
return CreateCompatibleBitmap(hdc, width, height);

View File

@ -10,7 +10,10 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include "bitmap.h"
#include "prototypes.h"
#include "metafile.h"
#include "stddebug.h"
/* #define DEBUG_GDI /* */
/* #undef DEBUG_GDI /* */
#include "debug.h"
#define NB_HATCH_STYLES 6
@ -47,9 +50,7 @@ HBRUSH CreateBrushIndirect( LOGBRUSH * brush )
HBRUSH CreateHatchBrush( short style, COLORREF color )
{
LOGBRUSH logbrush = { BS_HATCHED, color, style };
#ifdef DEBUG_GDI
printf( "CreateHatchBrush: %d %06x\n", style, color );
#endif
dprintf_gdi(stddeb, "CreateHatchBrush: %d %06x\n", style, color );
if ((style < 0) || (style >= NB_HATCH_STYLES)) return 0;
return CreateBrushIndirect( &logbrush );
}
@ -63,9 +64,7 @@ HBRUSH CreatePatternBrush( HBITMAP hbitmap )
LOGBRUSH logbrush = { BS_PATTERN, 0, 0 };
BITMAPOBJ *bmp, *newbmp;
#ifdef DEBUG_GDI
printf( "CreatePatternBrush: %d\n", hbitmap );
#endif
dprintf_gdi(stddeb, "CreatePatternBrush: %d\n", hbitmap );
/* Make a copy of the bitmap */
@ -89,9 +88,7 @@ HBRUSH CreateDIBPatternBrush( HANDLE hbitmap, WORD coloruse )
BITMAPINFO *info, *newInfo;
int size;
#ifdef DEBUG_GDI
printf( "CreateDIBPatternBrush: %d\n", hbitmap );
#endif
dprintf_gdi(stddeb, "CreateDIBPatternBrush: %d\n", hbitmap );
/* Make a copy of the bitmap */
@ -122,9 +119,7 @@ HBRUSH CreateDIBPatternBrush( HANDLE hbitmap, WORD coloruse )
HBRUSH CreateSolidBrush( COLORREF color )
{
LOGBRUSH logbrush = { BS_SOLID, color, 0 };
#ifdef DEBUG_GDI
printf( "CreateSolidBrush: %06x\n", color );
#endif
dprintf_gdi(stddeb, "CreateSolidBrush: %06x\n", color );
return CreateBrushIndirect( &logbrush );
}

View File

@ -9,7 +9,10 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993";
#include <stdio.h>
#include "gdi.h"
#include "metafile.h"
#include "stddebug.h"
/* #define DEBUG_CLIPPING /* */
/* #undef DEBUG_CLIPPING /* */
#include "debug.h"
/***********************************************************************
* CLIPPING_SetDeviceClipping
@ -109,9 +112,7 @@ int SelectClipRgn( HDC hdc, HRGN hrgn )
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "SelectClipRgn: %d %d\n", hdc, hrgn );
#endif
dprintf_clipping(stddeb, "SelectClipRgn: %d %d\n", hdc, hrgn );
return CLIPPING_SelectRgn( dc, &dc->w.hClipRgn, hrgn );
}
@ -124,9 +125,7 @@ int SelectVisRgn( HDC hdc, HRGN hrgn )
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "SelectVisRgn: %d %d\n", hdc, hrgn );
#endif
dprintf_clipping(stddeb, "SelectVisRgn: %d %d\n", hdc, hrgn );
return CLIPPING_SelectRgn( dc, &dc->w.hVisRgn, hrgn );
}
@ -145,9 +144,7 @@ int OffsetClipRgn( HDC hdc, short x, short y )
return NULLREGION; /* ?? */
}
#ifdef DEBUG_CLIPPING
printf( "OffsetClipRgn: %d %d,%d\n", hdc, x, y );
#endif
dprintf_clipping(stddeb, "OffsetClipRgn: %d %d,%d\n", hdc, x, y );
if (dc->w.hClipRgn)
{
@ -166,9 +163,7 @@ int OffsetVisRgn( HDC hdc, short x, short y )
{
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "OffsetVisRgn: %d %d,%d\n", hdc, x, y );
#endif
dprintf_clipping(stddeb, "OffsetVisRgn: %d %d,%d\n", hdc, x, y );
if (dc->w.hVisRgn)
{
@ -240,10 +235,8 @@ int ExcludeClipRect( HDC hdc, short left, short top,
return NULLREGION; /* ?? */
}
#ifdef DEBUG_CLIPPING
printf( "ExcludeClipRect: %d %dx%d,%dx%d\n",
dprintf_clipping(stddeb, "ExcludeClipRect: %d %dx%d,%dx%d\n",
hdc, left, top, right, bottom );
#endif
return CLIPPING_IntersectRect( dc, &dc->w.hClipRgn, left, top,
right, bottom, 1 );
}
@ -264,10 +257,8 @@ int IntersectClipRect( HDC hdc, short left, short top,
return NULLREGION; /* ?? */
}
#ifdef DEBUG_CLIPPING
printf( "IntersectClipRect: %d %dx%d,%dx%d\n",
dprintf_clipping(stddeb, "IntersectClipRect: %d %dx%d,%dx%d\n",
hdc, left, top, right, bottom );
#endif
return CLIPPING_IntersectRect( dc, &dc->w.hClipRgn, left, top,
right, bottom, 0 );
}
@ -281,10 +272,8 @@ int ExcludeVisRect( HDC hdc, short left, short top,
{
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "ExcludeVisRect: %d %dx%d,%dx%d\n",
dprintf_clipping(stddeb, "ExcludeVisRect: %d %dx%d,%dx%d\n",
hdc, left, top, right, bottom );
#endif
return CLIPPING_IntersectRect( dc, &dc->w.hVisRgn, left, top,
right, bottom, 1 );
}
@ -298,10 +287,8 @@ int IntersectVisRect( HDC hdc, short left, short top,
{
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "IntersectVisRect: %d %dx%d,%dx%d\n",
dprintf_clipping(stddeb, "IntersectVisRect: %d %dx%d,%dx%d\n",
hdc, left, top, right, bottom );
#endif
return CLIPPING_IntersectRect( dc, &dc->w.hVisRgn, left, top,
right, bottom, 0 );
}
@ -314,11 +301,10 @@ BOOL PtVisible( HDC hdc, short x, short y )
{
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "PtVisible: %d %d,%d\n", hdc, x, y );
#endif
if (!dc->w.hClipRgn) return FALSE;
return PtInRegion( dc->w.hClipRgn, x, y );
dprintf_clipping(stddeb, "PtVisible: %d %d,%d\n", hdc, x, y );
if (!dc->w.hGCClipRgn) return FALSE;
return PtInRegion( dc->w.hGCClipRgn, XLPTODP(dc,x), YLPTODP(dc,y) );
}
@ -327,13 +313,16 @@ BOOL PtVisible( HDC hdc, short x, short y )
*/
BOOL RectVisible( HDC hdc, LPRECT rect )
{
RECT tmpRect;
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "RectVisible: %d %p\n", hdc, rect );
#endif
if (!dc->w.hClipRgn) return FALSE;
return RectInRegion( dc->w.hClipRgn, rect );
if (!dc) return FALSE;
dprintf_clipping(stddeb,"RectVisible: %d %p\n", hdc, rect );
if (!dc->w.hGCClipRgn) return FALSE;
tmpRect.left = XLPTODP(dc, rect->left);
tmpRect.top = YLPTODP(dc, rect->top);
tmpRect.right = XLPTODP(dc, rect->right);
tmpRect.bottom = YLPTODP(dc, rect->bottom);
return RectInRegion( dc->w.hGCClipRgn, &tmpRect );
}
@ -344,9 +333,7 @@ int GetClipBox( HDC hdc, LPRECT rect )
{
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "GetClipBox: %d %p\n", hdc, rect );
#endif
dprintf_clipping(stddeb, "GetClipBox: %d %p\n", hdc, rect );
if (dc->w.hGCClipRgn) return GetRgnBox( dc->w.hGCClipRgn, rect );
else
@ -368,9 +355,7 @@ HRGN SaveVisRgn( HDC hdc )
RGNOBJ *obj, *copyObj;
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return 0;
#ifdef DEBUG_CLIPPING
printf( "SaveVisRgn: %d\n", hdc );
#endif
dprintf_clipping(stddeb, "SaveVisRgn: %d\n", hdc );
if (!dc->w.hVisRgn) return 0;
if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC )))
return 0;
@ -393,9 +378,7 @@ int RestoreVisRgn( HDC hdc )
RGNOBJ *obj, *savedObj;
DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
if (!dc) return ERROR;
#ifdef DEBUG_CLIPPING
printf( "RestoreVisRgn: %d\n", hdc );
#endif
dprintf_clipping(stddeb, "RestoreVisRgn: %d\n", hdc );
if (!dc->w.hVisRgn) return ERROR;
if (!(obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hVisRgn, REGION_MAGIC )))
return ERROR;

Some files were not shown because too many files have changed in this diff Show More