diff --git a/ANNOUNCE b/ANNOUNCE index 5a10f8b2e07..e19ef7287ff 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,15 +1,14 @@ -This is release 951003 of Wine the MS Windows emulator. This is still a +This is release 951105 of Wine the MS Windows emulator. This is still a developer's only release. There are many bugs and many unimplemented API features. Most applications still do not work. Patches should be submitted to "wine-new@amscons.com". Please don't forget to include a ChangeLog entry. I'll make a new release every other week. -WHAT'S NEW with Wine-951003: (see ChangeLog for details) - - New cursor handling. - - French, Danish and Finnish language support. - - Lots of Winelib improvements. - - Preliminary VxD support. +WHAT'S NEW with Wine-951105: (see ChangeLog for details) + - A lot of fixes for Winelib. + - Built-in debugger improvements. + - Get/SetMetafileBits implemented. - Lots of bug fixes. See the README file in the distribution for installation instructions. @@ -18,11 +17,11 @@ Because of lags created by using mirror, this message may reach you before the release is available at the ftp sites. The sources will be available from the following locations: - sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-951003.tar.gz - tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-951003.tar.gz - ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-951003.tar.gz - ftp.funet.fi:/pub/OS/Linux/ALPHA/Wine/Wine-951003.tar.gz - aris.com:/pub/linux/ALPHA/Wine/development/Wine-951003.tar.gz + sunsite.unc.edu:/pub/Linux/ALPHA/wine/Wine-951105.tar.gz + tsx-11.mit.edu:/pub/linux/ALPHA/Wine/development/Wine-951105.tar.gz + ftp.infomagic.com:/pub/mirrors/linux/wine/development/Wine-951105.tar.gz + ftp.funet.fi:/pub/OS/Linux/ALPHA/Wine/Wine-951105.tar.gz + aris.com:/pub/linux/ALPHA/Wine/development/Wine-951105.tar.gz It should also be available from any site that mirrors tsx-11 or sunsite. diff --git a/ChangeLog b/ChangeLog index 3ddda8eff90..988d9a6609c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,179 @@ +---------------------------------------------------------------------- +Fri Nov 3 20:08:17 1995 Alexandre Julliard + + * [configure.in] + Attempt to check for -li386 on NetBSD. Please test this. + +Mon Oct 30 12:40:32 EST 1995 Jim Peterson + + * [*/*] + Eliminated various warnings with either explicit casts or more + accurate variable/parameter declarations (e.g. INT instead of short + or WORD). + Changed macros 'min' and 'max' to 'MIN' and 'MAX', since they're + macros. + + * [controls/edit.c] [windows/defdlg.c] + Added '#ifdef SUPERFLUOUS_FUNCTIONS' wrappers around function + definition of EDIT_KeyVScrollDoc, EDIT_TextLineNumber, and + DEFDLG_FindDefButton to avoid warnings. + + * [controls/button.c] [controls/scroll.c] [windows/defwnd.c] + [windows/message.c] [windows/nonclient.c] + Converted MAKEPOINT macro call to manual conversion. + + * [include/windows.h] + For WINELIB32, structures POINT, SIZE, and RECT have LONG members + instead of INT. This also invalidates the macro MAKEPOINT(), which + is not supported in Win32. Also defined the POINTS structure (SHORT + members) and the MAKEPOINTS macro. + + * [misc/commdlg.c] + Changed a lot of 'strcpy' calls to 'strncpy' calls. I'm desperate to + find this memory bug, and this should be done anyway. + + * [controls/edit.c] + Well, the alteration mentioned above didn't do it, but #ifdef'ing out + a few lines in EDIT_ClearText did. This leads to bugs, but for now, + it's better than bizzare memory troubles. + + * [toolkit/miscstubs.c] + Removed warning messages in GLOBAL_CreateBlock(), GLOBAL_FreeBlock(), + and RELAY32_GetEntryPoint(). These are the most popular warnings, and + their current implementation seems fine. + +Sat Oct 28 09:39:18 1995 Jochen Karrer + + * [objects/cursoricon.c] + Fix for "broken" X servers that invert masked cursor colors. + +Fri Oct 27 19:27:21 1995 Alex Korobka + + * [windows/dialog.c] [windows/nonclient.c] + Remove unnecessary items from the system menu. + +Thu Oct 26 05:03:03 MET 1995 Philippe De Muyter + + * [objects/color.c] [objects/palette.c] + Make GetNearestColor return a RGB value instead of a pixel value. + +Wed Oct 25 23:33:39 1995 Martin von Loewis + + * [controls/desktop.c][controls/menu.c][include/menu.h] + Changed WORD parameters to UINT parameters. + + * [include/wintypes.h] + Made UINT 32bit for WINELIB. + + * [loader/main.c] + Disabled RELAY32_Init and MODULE_Init for WINELIB. + + * [misc/main.c] + Assume CPU386 for WINELIB. + + * [rc/winerc] + add_popup: set MF_POPUP flag on menu item. + + * [toolkit/Makefile.in][toolkit/hello3.c][toolkit/hello3res.c] + Add resource demo hello3 for WINELIB. + New file README.resources. + + * [toolkit/miscstubs.c] + Add a case for 17. + +Tue Oct 17 15:13:10 IST 1995 Itai Nahshon + + * [loader/module.c] + Do not append .exe if the file name already has an extension. + + * [misc/profile.c] + Avoid creating a file with a junk name if a .ini file does not + exist. + + * [if1632/gdi.spec] [if1632/user.spec] [if1632/dummy.c] + Added a lot of dummy stubs for Windows Hebrew version. + +Tue Oct 17 01:03:24 1995 William Magro + + * [controls/button.c] + Fix for buttons with no label. + + * [controls/combo.c][controls/listbox.c] + Fixes for scrollbar positioning. Now disappears correctly + for short lists. + + * [controls/edit.c] + Handle memory allocation differently when building as library. + + * [controls/static] + Don't destroy old icon before drawing new icon. (Fixes landscape/ + portrait toggle icon in print dialog.) + + * [if1632/gdi.spec] + New functions SetMetaFileBits and GetMetaFileBits + + * [include/sysmetrics.h] [windows/sysmetrics.c] + Add support for GetSystemMetrics(SM_CMETRICS) == SM_CMETRICS + + * [include/windows.h] + META_EXTTEXTOUT, not META_SETTEXTOUT + define GetCurrentTime as GetTickCount (for wine library) + + * [loader/main.c] + Don't initialize built-in modules in wine library + + * [memory/local.c] + LocalReAlloc was defined incorrectly. Swap flags and size arguments. + + * [misc/main.c] + Always report CPUTYPE=4 to wine library. + + * [objects/dib.c] + RLE8 images were missing top line when decompressed. + + * [objects/metafile.c] + SetMetaFileBits and GetMetaFileBits implemented. Works when called + from winhelp. More testing needed. Various memory leaks plugged. + Various other bug fixes. New metafile operations added in + PlayMetaFileRecord: CreatePalette, SetTextAlign, SelectPalette, + SetMapperFlags, RealizePalette, ExtTextOut, Escape. Testing needed. + + * [toolkit/heap.c] + LocalUnLock changed to LocalUnlock + +Sun Oct 15 21:55:33 1995 Anand Kumria + + * [misc/winsock.c] + Return the correct error number, for host lookup operations. + Also, correct the problem with send_message. + +Fri Oct 13 19:04:35 1995 Morten Welinder + + * [Makefile.in] + Using nm's built-in sorting. + + * [*/*.c] + Use xmalloc for malloc and xrealloc for realloc in all ungarded + cases. + + * [debugger/dbg.y] + Handle C-like expressions. Clean-up. + + * [debugger/debug.l] + Lots of new tokens for expressions. + + * [debugger/info.c] + Implement "list" command for disassembling. + + * [misc/ole2nls.c] + Implement more Danish stuff. + +Fri Oct 6 10:39:39 1995 Ram'on Garc'ia + + * [loader/module.c] + Updated self-loading modules to support for new 32 bit + stack frames. + ---------------------------------------------------------------------- Sun Oct 1 15:48:34 1995 Alexandre Julliard diff --git a/Make.rules.in b/Make.rules.in index 7894d2b5755..4dd971da6b0 100644 --- a/Make.rules.in +++ b/Make.rules.in @@ -32,7 +32,7 @@ depend:: $(C_SRCS) mv tmp_make Makefile clean:: - $(RM) *.o \#*\# *~ *.bak tmp_make + $(RM) *.o \#*\# *~ *.bak *.flc tmp_make distclean:: clean $(RM) Makefile diff --git a/Makefile.in b/Makefile.in index 130f12fc024..19f8a124a13 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,6 +6,7 @@ # langclean: remove all files which have to be remade if # a different LANGuage is selected # depend: create the dependencies +# etags: Create a TAGS file for Emacs. # # Author: Michael Patra # @@ -20,7 +21,7 @@ TOPSRC = @top_srcdir@ DIVINCL = -I$(TOPSRC)/include XPM_LIB = -lXpm XLIB = @X_PRE_LIBS@ -lXext -lX11 @X_EXTRA_LIBS@ -LDLIBS = -lm +LDLIBS = @LDLIBS@ AR = ar rc RANLIB = @RANLIB@ RM = rm -f @@ -59,9 +60,9 @@ LIBOBJS = toolkit/toolkit.o all: $(MAIN_TARGET) -wine: $(COMMONSUBDIRS) $(EMUSUBDIRS) dummy +wine wine.sym: $(COMMONSUBDIRS) $(EMUSUBDIRS) dummy $(CC) -o wine $(COMMONOBJS) $(EMUOBJS) $(LDOPTIONS) $(X_LIBS) $(XPM_LIB) $(XLIB) $(LDLIBS) - nm wine | grep -v _compiled | sort >wine.sym + nm -n wine | grep -v _compiled >wine.sym winelib.a: $(COMMONSUBDIRS) $(LIBSUBDIRS) dummy $(RM) $@ @@ -79,7 +80,7 @@ etags: clean: for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) clean); done - $(RM) *.o \#*\# *~ *.bak wine wine.sym winelib.a TAGS + $(RM) *.o \#*\# *~ *.bak *.flc wine wine.sym winelib.a TAGS distclean: for i in $(ALLSUBDIRS); do (cd $$i; $(MAKE) distclean); done diff --git a/configure b/configure index 73944bc8798..c0df84d2ee9 100755 --- a/configure +++ b/configure @@ -413,6 +413,7 @@ fi # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS="-g -O2 -Wall" test -z "$LDFLAGS" && LDFLAGS=-g +test -z "$LDLIBS" && LDLIBS=-lm # Check whether --with-library or --without-library was given. @@ -573,7 +574,7 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error @@ -587,7 +588,7 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error @@ -693,7 +694,7 @@ test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h cat > conftest.$ac_ext < EOF @@ -756,7 +757,7 @@ rm -f conftest* ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <&6 fi +echo $ac_n "checking for -li386""... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_lib_i386'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-li386 $LIBS" +cat > conftest.$ac_ext <&6 + LDLIBS="$LDLIBS -li386" +else + echo "$ac_t""no" 1>&6 +fi + + for ac_func in tcgetattr do @@ -1196,7 +1231,7 @@ if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&6 else cat > conftest.$ac_ext < EOF @@ -1281,7 +1316,7 @@ if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1335,7 +1370,7 @@ if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < conftest.$ac_ext <&6 else cat > conftest.$ac_ext < #include @@ -1455,7 +1490,7 @@ rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1473,7 +1508,7 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -1494,7 +1529,7 @@ if test "$cross_compiling" = yes; then ac_cv_header_stdc=no else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -1528,7 +1563,7 @@ if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -1705,6 +1740,7 @@ s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g +s%@LDLIBS@%$LDLIBS%g s%@MAIN_TARGET@%$MAIN_TARGET%g s%@LANG@%$LANG%g s%@SET_MAKE@%$SET_MAKE%g diff --git a/configure.in b/configure.in index 8460d1d836d..4bbf3fef2ff 100644 --- a/configure.in +++ b/configure.in @@ -7,6 +7,7 @@ AC_INIT(controls/edit.c) # We want these before the checks, so the checks can modify their values. test -z "$CFLAGS" && CFLAGS="-g -O2 -Wall" AC_SUBST(CFLAGS) test -z "$LDFLAGS" && LDFLAGS=-g AC_SUBST(LDFLAGS) +test -z "$LDLIBS" && LDLIBS=-lm AC_SUBST(LDLIBS) dnl **** Command-line arguments **** @@ -29,7 +30,7 @@ AC_ARG_WITH(malloc-debug, [ --with-malloc-debug enable malloc() debugging], [AC_DEFINE(MALLOC_DEBUGGING)]) -dnl **** Check for some programs **** +dnl **** Check for some programs and libraries **** AC_PROG_MAKE_SET AC_PROG_CC @@ -37,6 +38,10 @@ AC_PATH_XTRA AC_PROG_YACC AC_PROG_LEX AC_PROG_RANLIB +dnl Check for -li386 for NetBSD +AC_CHECK_LIB(i386,i386_set_ldt,LDLIBS="$LDLIBS -li386") + +dnl **** Check for functions and header files **** AC_CHECK_FUNCS(tcgetattr) AC_CHECK_HEADERS(stdlib.h) diff --git a/controls/button.c b/controls/button.c index 087a7d726d5..9310643e656 100644 --- a/controls/button.c +++ b/controls/button.c @@ -71,6 +71,7 @@ static WORD checkBoxWidth = 0, checkBoxHeight = 0; LRESULT ButtonWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { RECT rect; + POINT pt; LONG lResult = 0; WND *wndPtr = WIN_FindWndPtr(hWnd); LONG style = wndPtr->dwStyle & 0x0000000F; @@ -139,7 +140,9 @@ LRESULT ButtonWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (!(infoPtr->state & BUTTON_HIGHLIGHTED)) break; SendMessage( hWnd, BM_SETSTATE, FALSE, 0 ); GetClientRect( hWnd, &rect ); - if (PtInRect( &rect, MAKEPOINT(lParam) )) + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + if (PtInRect( &rect, pt )) { switch(style) { @@ -171,7 +174,9 @@ LRESULT ButtonWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (GetCapture() == hWnd) { GetClientRect( hWnd, &rect ); - if (PtInRect( &rect, MAKEPOINT(lParam)) ) + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + if (PtInRect( &rect, pt) ) SendMessage( hWnd, BM_SETSTATE, TRUE, 0 ); else SendMessage( hWnd, BM_SETSTATE, FALSE, 0 ); } @@ -314,7 +319,7 @@ static void PB_Paint( HWND hButton, HDC hDC, WORD action ) /* draw button label, if any: */ text = (char*) USER_HEAP_LIN_ADDR( wndPtr->hText ); - if (text[0]) + if (text && text[0]) { SetTextColor( hDC, (wndPtr->dwStyle & WS_DISABLED) ? GetSysColor(COLOR_GRAYTEXT) : GetSysColor(COLOR_BTNTEXT)); @@ -369,8 +374,6 @@ static void CB_Paint( HWND hWnd, HDC hDC, WORD action ) GetTextMetrics(hDC, &tm); delta = (rc.bottom - rc.top - tm.tmHeight) >> 1; - text = (char*) USER_HEAP_LIN_ADDR( wndPtr->hText ); - textlen = strlen( text ); /* Draw the check-box bitmap */ x = y = 0; @@ -383,6 +386,9 @@ static void CB_Paint( HWND hWnd, HDC hDC, WORD action ) x, y, checkBoxWidth, checkBoxHeight ); rc.left += checkBoxWidth + tm.tmAveCharWidth / 2; + if (!(text = (char*) USER_HEAP_LIN_ADDR( wndPtr->hText ))) return; + textlen = strlen( text ); + if (action == ODA_DRAWENTIRE) { if (wndPtr->dwStyle & WS_DISABLED) @@ -400,7 +406,7 @@ static void CB_Paint( HWND hWnd, HDC hDC, WORD action ) rc.bottom -= delta + 1; } rc.left--; - rc.right = min( rc.left + size.cx + 2, rc.right ); + rc.right = MIN( rc.left + size.cx + 2, rc.right ); DrawFocusRect(hDC, &rc); } } @@ -453,7 +459,7 @@ static void GB_Paint( HWND hWnd, HDC hDC, WORD action ) LineTo( hDC, rc.left, rc.bottom-1 ); LineTo( hDC, rc.left, rc.top+2 ); - text = (char*) USER_HEAP_LIN_ADDR( wndPtr->hText ); + if (!(text = (char*) USER_HEAP_LIN_ADDR( wndPtr->hText ))) return; GetTextExtentPoint(hDC, text, strlen(text), &size); rc.left += 10; rc.right = rc.left + size.cx + 1; diff --git a/controls/combo.c b/controls/combo.c index aab97f53932..8284d51532e 100644 --- a/controls/combo.c +++ b/controls/combo.c @@ -22,6 +22,7 @@ #include "dos_fs.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" /* * Note: Combos are probably implemented in a different way by Windows. @@ -59,7 +60,7 @@ int CreateComboStruct(HWND hwnd, LONG style) { LPHEADCOMBO lphc; - lphc = (LPHEADCOMBO)malloc(sizeof(HEADCOMBO)); + lphc = (LPHEADCOMBO)xmalloc(sizeof(HEADCOMBO)); SetWindowLong(hwnd,4,(LONG)lphc); lphc->hWndEdit = 0; lphc->hWndLBox = 0; @@ -652,7 +653,11 @@ LPHEADLIST CLBoxGetListHeader(HWND hwnd) static LONG CBLCreate( HWND hwnd, WORD wParam, LONG lParam ) { CREATESTRUCT *createStruct = (CREATESTRUCT *)PTR_SEG_TO_LIN(lParam); +#ifdef WINELIB32 + SetWindowLong(hwnd,0,(LONG)createStruct->lpCreateParams); +#else SetWindowWord(hwnd,0,LOWORD(createStruct->lpCreateParams)); +#endif return 0; } @@ -772,7 +777,7 @@ static LONG CBLPaint( HWND hwnd, WORD wParam, LONG lParam ) lpls->itemRect.left = rect.left; lpls->itemRect.right = rect.right; - dprintf_listbox(stddeb,"drawing item: %d %d %d %d %d\n",rect.left,top,rect.right,top+height,lpls->itemState); + dprintf_listbox(stddeb,"drawing item: %ld %d %ld %d %d\n",(LONG)rect.left,top,(LONG)rect.right,top+height,lpls->itemState); if (lphl->OwnerDrawn) { ListBoxDrawItem (combohwnd, lphl, hdc, lpls, &lpls->itemRect, ODA_DRAWENTIRE, 0); if (lpls->itemState) @@ -790,6 +795,7 @@ static LONG CBLPaint( HWND hwnd, WORD wParam, LONG lParam ) lpls = lpls->lpNext; } + SetScrollRange(hwnd, SB_VERT, 0, ListMaxFirstVisible(lphl), TRUE); SelectObject(hdc,hOldFont); EndPaint( hwnd, &ps ); return 0; diff --git a/controls/desktop.c b/controls/desktop.c index ef9377b9aa8..b3796f493db 100644 --- a/controls/desktop.c +++ b/controls/desktop.c @@ -118,7 +118,7 @@ static LONG DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, DESKTOPINFO *infoPtr ) * * Window procedure for the desktop window. */ -LRESULT DesktopWndProc ( HWND hwnd, WORD message, WPARAM wParam, LPARAM lParam ) +LRESULT DesktopWndProc ( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra; diff --git a/controls/edit.c b/controls/edit.c index 957c8707c7d..31534d65ffb 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -18,6 +18,7 @@ #include "user.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" #ifdef WINELIB32 @@ -46,7 +47,7 @@ typedef struct RECT fmtrc; /* rectangle in which to format text */ int txtht; /* height of text line in pixels */ HANDLE hText; /* handle to text buffer */ - short *CharWidths; /* widths of chars in font */ + INT *CharWidths; /* widths of chars in font */ unsigned int *textptrs; /* list of line offsets */ char *BlankLine; /* to fill blank lines quickly */ int CurrCol; /* current column */ @@ -106,7 +107,12 @@ static HLOCAL EDIT_HeapAlloc(HWND hwnd, int bytes, WORD flags) { HLOCAL ret; +#if defined(WINELIB) + /* temporary fix, until Local memory is correctly implemented in WINELIB */ + ret = LocalAlloc( flags, bytes ); +#else ret = LOCAL_Alloc( WIN_GetWindowInstance(hwnd), flags, bytes ); +#endif if (!ret) printf("EDIT_HeapAlloc: Out of heap-memory\n"); return ret; @@ -122,9 +128,13 @@ static void *EDIT_HeapLock(HWND hwnd, HANDLE handle) HINSTANCE hinstance = WIN_GetWindowInstance( hwnd ); HANDLE offs; +#if defined(WINELIB) + return handle; +#else if (handle == 0) return 0; offs = LOCAL_Lock( hinstance, handle ); return PTR_SEG_OFF_TO_LIN( hinstance, offs ); +#endif } /********************************************************************* @@ -132,8 +142,12 @@ static void *EDIT_HeapLock(HWND hwnd, HANDLE handle) */ static void EDIT_HeapUnlock(HWND hwnd, HANDLE handle) { +#if defined(WINELIB) + return 0; +#else if (handle == 0) return; LOCAL_Unlock( WIN_GetWindowInstance( hwnd ), handle ); +#endif } /********************************************************************* @@ -143,8 +157,12 @@ static void EDIT_HeapUnlock(HWND hwnd, HANDLE handle) */ static HLOCAL EDIT_HeapReAlloc(HWND hwnd, HANDLE handle, int bytes) { +#if defined(WINELIB) + return LocalReAlloc( handle, bytes, LMEM_FIXED ); +#else return LOCAL_ReAlloc( WIN_GetWindowInstance(hwnd), handle, bytes, LMEM_FIXED ); +#endif } @@ -155,7 +173,11 @@ static HLOCAL EDIT_HeapReAlloc(HWND hwnd, HANDLE handle, int bytes) */ static void EDIT_HeapFree(HWND hwnd, HANDLE handle) { +#if defined(WINELIB) + LocalFree( handle ); +#else LOCAL_Free( WIN_GetWindowInstance(hwnd), handle ); +#endif } @@ -166,7 +188,11 @@ static void EDIT_HeapFree(HWND hwnd, HANDLE handle) */ static unsigned int EDIT_HeapSize(HWND hwnd, HANDLE handle) { +#if defined(WINELIB) + return LocalSize( handle ); +#else return LOCAL_Size( WIN_GetWindowInstance(hwnd), handle ); +#endif } /******************************************************************** @@ -239,7 +265,7 @@ static void EDIT_ClearTextPointers(HWND hwnd) EDITSTATE *es = EDIT_GetEditState(hwnd); dprintf_edit( stddeb, "EDIT_ClerTextPointers\n" ); - es->textptrs = realloc(es->textptrs, sizeof(int)); + es->textptrs = xrealloc(es->textptrs, sizeof(int)); es->textptrs[0] = 0; } @@ -267,7 +293,7 @@ static void EDIT_BuildTextPointers(HWND hwnd) } else es->wlines = 1; dprintf_edit( stddeb, "EDIT_BuildTextPointers: realloc\n" ); - es->textptrs = realloc(es->textptrs, (es->wlines + 2) * sizeof(int)); + es->textptrs = xrealloc(es->textptrs, (es->wlines + 2) * sizeof(int)); cp = text; dprintf_edit(stddeb,"BuildTextPointers: %d lines, pointer %p\n", @@ -290,7 +316,7 @@ static void EDIT_BuildTextPointers(HWND hwnd) /* width of line in pixels */ cp++; } - es->textwidth = max(es->textwidth, len); + es->textwidth = MAX(es->textwidth, len); if (*cp) cp++; /* skip '\n' */ } @@ -345,7 +371,7 @@ static char *EDIT_GetTextLine(HWND hwnd, int selection) else len = cp - cp1; /* store selected line and return handle */ - cp = malloc( len + 1 ); + cp = xmalloc( len + 1 ); strncpy( cp, cp1, len); cp[len] = 0; return cp; @@ -497,8 +523,8 @@ static void EDIT_WriteText(HWND hwnd, char *lp, int off, int len, int row, if (strlen(es->BlankLine) < (es->ClientWidth / es->CharWidths[32]) + 2) { dprintf_edit( stddeb, "EDIT_WriteText: realloc\n" ); - es->BlankLine = realloc(es->BlankLine, - (es->ClientWidth / es->CharWidths[32]) + 2); + es->BlankLine = xrealloc(es->BlankLine, + (es->ClientWidth / es->CharWidths[32]) + 2); memset(es->BlankLine, ' ', (es->ClientWidth / es->CharWidths[32]) + 2); es->BlankLine[(es->ClientWidth / es->CharWidths[32]) + 1] = 0; } @@ -585,14 +611,14 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) /* make sure rectangle is within window */ if (rc.left >= es->ClientWidth - 1) { - dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.left (%d) is greater than right edge\n", - rc.left); + dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.left (%ld) is greater than right edge\n", + (LONG)rc.left); return; } if (rc.right <= 0) { - dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.right (%d) is less than left edge\n", - rc.right); + dprintf_edit(stddeb,"EDIT_WriteTextLine: rc.right (%ld) is less than left edge\n", + (LONG)rc.right); return; } if (y - es->wtop < (rc.top / es->txtht) || @@ -626,7 +652,7 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) off += rc.left; lnlen = lnlen1 - off; } - len = min(lnlen, rc.right - rc.left); + len = MIN(lnlen, rc.right - rc.left); if (SelMarked(es)) { @@ -655,7 +681,7 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) col = EDIT_StrWidth(hwnd, lp, sbc, 0); if (col > (es->wleft + rc.left)) { - len = min(col - off, rc.right - off); + len = MIN(col - off, rc.right - off); EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, rc.left, &rc, FALSE, FALSE); off = col; @@ -665,24 +691,24 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) col = EDIT_StrWidth(hwnd, lp, sec, 0); if (col < (es->wleft + rc.right)) { - len = min(col - off, rc.right - off); + len = MIN(col - off, rc.right - off); EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, off - es->wleft, &rc, FALSE, TRUE); off = col; - len = min(lnlen - off, rc.right - off); + len = MIN(lnlen - off, rc.right - off); EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, off - es->wleft, &rc, TRUE, FALSE); } else { - len = min(lnlen - off, rc.right - off); + len = MIN(lnlen - off, rc.right - off); EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, off - es->wleft, &rc, TRUE, TRUE); } } else { - len = min(lnlen - off, rc.right - off); + len = MIN(lnlen - off, rc.right - off); if (col < (es->wleft + rc.right)) EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, off - es->wleft, &rc, TRUE, TRUE); @@ -693,11 +719,11 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) col = EDIT_StrWidth(hwnd, lp, sec, 0); if (col < (es->wleft + rc.right)) { - len = min(col - off, rc.right - off); + len = MIN(col - off, rc.right - off); EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, off - es->wleft, &rc, FALSE, TRUE); off = col; - len = min(lnlen - off, rc.right - off); + len = MIN(lnlen - off, rc.right - off); EDIT_WriteText(hwnd, lp, off, len, y - es->wtop, off - es->wleft, &rc, TRUE, FALSE); } @@ -719,7 +745,7 @@ static void EDIT_WriteTextLine(HWND hwnd, RECT *rect, int y) static int EDIT_ComputeVScrollPos(HWND hwnd) { int vscrollpos; - short minpos, maxpos; + INT minpos, maxpos; EDITSTATE *es = EDIT_GetEditState(hwnd); GetScrollRange(hwnd, SB_VERT, &minpos, &maxpos); @@ -742,7 +768,7 @@ static int EDIT_ComputeVScrollPos(HWND hwnd) static int EDIT_ComputeHScrollPos(HWND hwnd) { int hscrollpos; - short minpos, maxpos; + INT minpos, maxpos; EDITSTATE *es = EDIT_GetEditState(hwnd); GetScrollRange(hwnd, SB_HORZ, &minpos, &maxpos); @@ -913,13 +939,13 @@ static void EDIT_StickEnd(HWND hwnd) char *cp = EDIT_TextLine(hwnd, es->CurrLine); int currpel; - es->CurrCol = min(len, es->CurrCol); - es->WndCol = min(EDIT_StrWidth(hwnd, cp, len, 0) - es->wleft, es->WndCol); + es->CurrCol = MIN(len, es->CurrCol); + es->WndCol = MIN(EDIT_StrWidth(hwnd, cp, len, 0) - es->wleft, es->WndCol); currpel = EDIT_StrWidth(hwnd, cp, es->CurrCol, 0); if (es->wleft > currpel) { - es->wleft = max(0, currpel - 20); + es->wleft = MAX(0, currpel - 20); es->WndCol = currpel - es->wleft; UpdateWindow(hwnd); } @@ -1080,6 +1106,7 @@ static void EDIT_KeyVScrollPage(HWND hwnd, WORD opt) } } +#ifdef SUPERFLUOUS_FUNCTIONS /********************************************************************* * EDIT_KeyVScrollDoc * @@ -1114,6 +1141,7 @@ static void EDIT_KeyVScrollDoc(HWND hwnd, WORD opt) SetScrollPos(hwnd, SB_VERT, vscrollpos, TRUE); } } +#endif /********************************************************************* * EDIT_DelKey @@ -1287,9 +1315,11 @@ static void EDIT_ClearText(HWND hwnd) char *text; dprintf_edit(stddeb,"EDIT_ClearText %d\n",blen); +#ifndef WINELIB es->hText = EDIT_HeapReAlloc(hwnd, es->hText, blen); text = EDIT_HeapLock(hwnd, es->hText); memset(text, 0, blen); +#endif es->textlen = 0; es->wlines = 0; es->CurrLine = es->CurrCol = 0; @@ -1297,7 +1327,9 @@ static void EDIT_ClearText(HWND hwnd) es->wleft = es->wtop = 0; es->textwidth = 0; es->TextChanged = FALSE; +#ifndef WINELIB EDIT_ClearTextPointers(hwnd); +#endif } /********************************************************************* @@ -1421,6 +1453,7 @@ static void EDIT_DeleteSel(HWND hwnd) } } +#ifdef SUPERFLUOUS_FUNCTIONS /********************************************************************* * EDIT_TextLineNumber * @@ -1444,6 +1477,7 @@ static int EDIT_TextLineNumber(HWND hwnd, char *lp) } return lineno - 1; } +#endif /********************************************************************* * EDIT_SetAnchor @@ -1529,7 +1563,7 @@ static void EDIT_ExtendSel(HWND hwnd, INT x, INT y) bbl = es->SelEndLine; bbc = es->SelEndCol; - y = max(y,0); + y = MAX(y,0); if (IsMultiLine(hwnd)) { if ((line = es->wtop + y / es->txtht) >= es->wlines) @@ -1549,7 +1583,7 @@ static void EDIT_ExtendSel(HWND hwnd, INT x, INT y) es->CurrLine = es->wtop + es->WndRow; es->SelEndLine = es->CurrLine; - es->WndCol = es->wleft + max(x,0); + es->WndCol = es->wleft + MAX(x,0); if (es->WndCol > EDIT_StrWidth(hwnd, cp, len, 0)) es->WndCol = EDIT_StrWidth(hwnd, cp, len, 0); es->CurrCol = EDIT_PixelToChar(hwnd, es->CurrLine, &(es->WndCol)); @@ -1764,12 +1798,12 @@ static void EDIT_KeyTyped(HWND hwnd, short ch) HideCaret(hwnd); if (IsMultiLine(hwnd) && es->wlines > 1) { - es->textwidth = max(es->textwidth, + es->textwidth = MAX(es->textwidth, EDIT_StrWidth(hwnd, EDIT_TextLine(hwnd, es->CurrLine), (int)(EDIT_TextLine(hwnd, es->CurrLine + 1) - EDIT_TextLine(hwnd, es->CurrLine)), 0)); } else { - es->textwidth = max(es->textwidth, + es->textwidth = MAX(es->textwidth, EDIT_StrWidth(hwnd, text, strlen(text), 0)); } @@ -1887,15 +1921,15 @@ static LONG EDIT_SetTabStopsMsg(HWND hwnd, WORD wParam, LONG lParam) dprintf_edit( stddeb, "EDIT_SetTabStops\n" ); es->NumTabStops = wParam; if (wParam == 0) - es->TabStops = realloc(es->TabStops, 2); + es->TabStops = xrealloc(es->TabStops, 2); else if (wParam == 1) { - es->TabStops = realloc(es->TabStops, 2); + es->TabStops = xrealloc(es->TabStops, 2); es->TabStops[0] = LOWORD(lParam); } else { - es->TabStops = realloc(es->TabStops, wParam * sizeof(*es->TabStops)); + es->TabStops = xrealloc(es->TabStops, wParam * sizeof(*es->TabStops)); memcpy(es->TabStops, (unsigned short *)PTR_SEG_TO_LIN(lParam), wParam); } return 0; @@ -1912,7 +1946,7 @@ static LONG EDIT_GetLineMsg(HWND hwnd, WORD wParam, LONG lParam) cp = EDIT_TextLine(hwnd, wParam); cp1 = EDIT_TextLine(hwnd, wParam + 1); - len = min((int)(cp1 - cp), (WORD)(*buffer)); + len = MIN((int)(cp1 - cp), (WORD)(*buffer)); dprintf_edit( stddeb, "EDIT_GetLineMsg: %d %d, len %d\n", (int)(WORD)(*buffer), (int)(WORD)(*(char *)buffer), len); strncpy(buffer, cp, len); @@ -2181,8 +2215,8 @@ static void EDIT_WM_Paint(HWND hwnd) hdc = BeginPaint(hwnd, &ps); rc = ps.rcPaint; - dprintf_edit(stddeb,"WM_PAINT: rc=(%d,%d), (%d,%d)\n", rc.left, rc.top, - rc.right, rc.bottom); + dprintf_edit(stddeb,"WM_PAINT: rc=(%ld,%ld), (%ld,%ld)\n", (LONG)rc.left, + (LONG)rc.top, (LONG)rc.right, (LONG)rc.bottom); if (es->PaintBkgd) FillWindow(GetParent(hwnd), hwnd, hdc, (HBRUSH)CTLCOLOR_EDIT); @@ -2210,10 +2244,10 @@ static long EDIT_WM_NCCreate(HWND hwnd, LONG lParam) /* EDITSTATE structure itself can be stored on local heap */ /* allocate space for state variable structure */ - es = malloc( sizeof(EDITSTATE) ); + es = xmalloc( sizeof(EDITSTATE) ); SetWindowLong( hwnd, 0, (LONG)es ); - es->textptrs = malloc(sizeof(int)); - es->CharWidths = malloc(256 * sizeof(short)); + es->textptrs = xmalloc(sizeof(int)); + es->CharWidths = xmalloc(256 * sizeof(INT)); es->ClientWidth = es->ClientHeight = 1; /* --- text buffer */ es->MaxTextLen = MAXTEXTLEN + 1; @@ -2289,7 +2323,7 @@ static long EDIT_WM_Create(HWND hwnd, LONG lParam) /* --- char width array */ /* only initialise chars <= 32 as X returns strange widths */ /* for other chars */ - memset(es->CharWidths, 0, 256 * sizeof(short)); + memset(es->CharWidths, 0, 256 * sizeof(INT)); GetCharWidth(hdc, 32, 254, &es->CharWidths[32]); /* --- other structure variables */ @@ -2306,11 +2340,11 @@ static long EDIT_WM_Create(HWND hwnd, LONG lParam) es->hDeletedText = 0; es->DeletedLength = 0; es->NumTabStops = 0; - es->TabStops = malloc( sizeof(short) ); + es->TabStops = xmalloc( sizeof(short) ); /* allocate space for a line full of blanks to speed up */ /* line filling */ - es->BlankLine = malloc( (es->ClientWidth / es->CharWidths[32]) + 2); + es->BlankLine = xmalloc( (es->ClientWidth / es->CharWidths[32]) + 2); memset(es->BlankLine, ' ', (es->ClientWidth / es->CharWidths[32]) + 2); es->BlankLine[(es->ClientWidth / es->CharWidths[32]) + 1] = 0; diff --git a/controls/listbox.c b/controls/listbox.c index 393f497c06a..d06760dd9e5 100644 --- a/controls/listbox.c +++ b/controls/listbox.c @@ -24,6 +24,7 @@ #include "dos_fs.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" #if 0 #define LIST_HEAP_ALLOC(lphl,f,size) ((int)HEAP_Alloc(&lphl->Heap,f,size) & 0xffff) @@ -56,13 +57,8 @@ void CreateListBoxStruct(HWND hwnd, WORD CtlType, LONG styles, HWND parent) { LPHEADLIST lphl; - lphl = (LPHEADLIST)malloc(sizeof(HEADLIST)); + lphl = (LPHEADLIST)xmalloc(sizeof(HEADLIST)); SetWindowLong(hwnd, 0, (LONG)lphl); - if (lphl == NULL) { - fprintf(stderr,"malloc failed in CreateListBoxStruct()\n"); - exit(1); /* Things won't get better */ - } - ListBoxInitialize(lphl); lphl->DrawCtlType = CtlType; lphl->CtlID = GetWindowWord(hwnd,GWW_ID); @@ -1147,7 +1143,7 @@ static LONG LBPaint(HWND hwnd, WORD wParam, LONG lParam) if (top > rect.bottom) { if (lphl->dwStyle & LBS_MULTICOLUMN) { - lphl->ItemsPerColumn = max(lphl->ItemsPerColumn, ipc); + lphl->ItemsPerColumn = MAX(lphl->ItemsPerColumn, ipc); ipc = 0; top = 0; rect.left += lphl->ColumnsWidth; @@ -1182,6 +1178,7 @@ static LONG LBPaint(HWND hwnd, WORD wParam, LONG lParam) lpls = lpls->lpNext; } + ListBoxUpdateWindow(hwnd,lphl,FALSE); SelectObject(hdc,hOldFont); EndPaint( hwnd, &ps ); return 0; diff --git a/controls/menu.c b/controls/menu.c index 90db99cb636..b14d1ab2733 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -135,7 +135,7 @@ static BOOL MENU_IsInSysMenu( POPUPMENU *menu, POINT pt ) * Find a menu item. Return a pointer on the item, and modifies *hmenu * in case the item was in a sub-menu. */ -static MENUITEM *MENU_FindItem( HMENU *hmenu, WORD *nPos, WORD wFlags ) +static MENUITEM *MENU_FindItem( HMENU *hmenu, UINT *nPos, UINT wFlags ) { POPUPMENU *menu; MENUITEM *item; @@ -178,7 +178,7 @@ static MENUITEM *MENU_FindItem( HMENU *hmenu, WORD *nPos, WORD wFlags ) * * Find the item at the specified coordinates (screen coords). */ -static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu, int x, int y, WORD *pos ) +static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu, int x, int y, UINT *pos ) { MENUITEM *item; WND *wndPtr; @@ -207,7 +207,7 @@ static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu, int x, int y, WORD *pos * Find the menu item selected by a key press. * Return item id, -1 if none, -2 if we should close the menu. */ -static WORD MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, WORD key ) +static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, UINT key ) { POPUPMENU *menu; LPMENUITEM lpitem; @@ -299,7 +299,7 @@ static void MENU_CalcItemSize( HDC hdc, LPMENUITEM lpitem, HWND hwndOwner, dwSize = (lpitem->item_text == NULL) ? 0 : GetTextExtent( hdc, lpitem->item_text, strlen(lpitem->item_text)); lpitem->rect.right += LOWORD(dwSize); - lpitem->rect.bottom += max( HIWORD(dwSize), SYSMETRICS_CYMENU ); + lpitem->rect.bottom += MAX( HIWORD(dwSize), SYSMETRICS_CYMENU ); if (menuBar) lpitem->rect.right += MENU_BAR_ITEMS_SPACE; else if ((p = strchr( lpitem->item_text, '\t' )) != NULL) @@ -351,23 +351,23 @@ static void MENU_PopupMenuCalcSize( LPPOPUPMENU lppop, HWND hwndOwner ) (lpitem->item_flags & (MF_MENUBREAK | MF_MENUBARBREAK))) break; MENU_CalcItemSize( hdc, lpitem, hwndOwner, orgX, orgY, FALSE ); if (lpitem->item_flags & MF_MENUBARBREAK) orgX++; - maxX = max( maxX, lpitem->rect.right ); + maxX = MAX( maxX, lpitem->rect.right ); orgY = lpitem->rect.bottom; if (lpitem->xTab) { - maxTab = max( maxTab, lpitem->xTab ); - maxTabWidth = max(maxTabWidth,lpitem->rect.right-lpitem->xTab); + maxTab = MAX( maxTab, lpitem->xTab ); + maxTabWidth = MAX(maxTabWidth,lpitem->rect.right-lpitem->xTab); } } /* Finish the column (set all items to the largest width found) */ - maxX = max( maxX, maxTab + maxTabWidth ); + maxX = MAX( maxX, maxTab + maxTabWidth ); for (lpitem = &items[start]; start < i; start++, lpitem++) { lpitem->rect.right = maxX; if (lpitem->xTab) lpitem->xTab = maxTab; } - lppop->Height = max( lppop->Height, orgY ); + lppop->Height = MAX( lppop->Height, orgY ); } lppop->Width = maxX; @@ -388,8 +388,8 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect, LPPOPUPMENU lppop, if ((lprect == NULL) || (lppop == NULL)) return; if (lppop->nItems == 0) return; - dprintf_menucalc(stddeb,"MenuBarCalcSize left=%d top=%d right=%d bottom=%d !\n", - lprect->left, lprect->top, lprect->right, lprect->bottom); + dprintf_menucalc(stddeb,"MenuBarCalcSize left=%ld top=%ld right=%ld bottom=%ld !\n", + (LONG)lprect->left, (LONG)lprect->top, (LONG)lprect->right, (LONG)lprect->bottom); items = (MENUITEM *)USER_HEAP_LIN_ADDR( lppop->hItems ); lppop->Width = lprect->right - lprect->left; lppop->Height = 0; @@ -414,7 +414,7 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect, LPPOPUPMENU lppop, if (i != start) break; else lpitem->rect.right = lprect->right; } - maxY = max( maxY, lpitem->rect.bottom ); + maxY = MAX( maxY, lpitem->rect.bottom ); orgX = lpitem->rect.right; } @@ -450,7 +450,7 @@ static void MENU_MenuBarCalcSize( HDC hdc, LPRECT lprect, LPPOPUPMENU lppop, * Draw a single menu item. */ static void MENU_DrawMenuItem( HWND hwnd, HDC hdc, LPMENUITEM lpitem, - WORD height, BOOL menuBar ) + UINT height, BOOL menuBar ) { RECT rect; @@ -626,7 +626,7 @@ static void MENU_DrawPopupMenu( HWND hwnd, HDC hdc, HMENU hmenu ) * * Paint a menu bar. Returns the height of the menu bar. */ -WORD MENU_DrawMenuBar(HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw) +UINT MENU_DrawMenuBar(HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw) { LPPOPUPMENU lppop; LPMENUITEM lpitem; @@ -661,7 +661,7 @@ WORD MENU_DrawMenuBar(HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw) * * Display a popup menu. */ -static BOOL MENU_ShowPopup(HWND hwndOwner, HMENU hmenu, WORD id, int x, int y) +static BOOL MENU_ShowPopup(HWND hwndOwner, HMENU hmenu, UINT id, int x, int y) { POPUPMENU *menu; @@ -703,7 +703,7 @@ static BOOL MENU_ShowPopup(HWND hwndOwner, HMENU hmenu, WORD id, int x, int y) /*********************************************************************** * MENU_SelectItem */ -static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, WORD wIndex ) +static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, UINT wIndex ) { MENUITEM *items; LPPOPUPMENU lppop; @@ -741,8 +741,9 @@ static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, WORD wIndex ) { NC_DrawSysButton( lppop->hWnd, hdc, TRUE ); #ifdef WINELIB32 +/* FIX: LostInfo */ SendMessage( hwndOwner, WM_MENUSELECT, - MAKEWPARAM( GetSystemMenu( lppop->hWnd, FALSE ), + MAKEWPARAM( (DWORD)GetSystemMenu( lppop->hWnd, FALSE ), lppop->wFlags | MF_MOUSESELECT ), (LPARAM)hmenu ); #else @@ -770,8 +771,9 @@ static void MENU_SelectItem( HWND hwndOwner, HMENU hmenu, WORD wIndex ) } } #ifdef WINELIB32 +/* FIX: Lost Info */ else SendMessage( hwndOwner, WM_MENUSELECT, - MAKEWPARAM( hmenu, lppop->wFlags | MF_MOUSESELECT), + MAKEWPARAM( (DWORD)hmenu, lppop->wFlags | MF_MOUSESELECT), (LPARAM)hmenu ); #else else SendMessage( hwndOwner, WM_MENUSELECT, hmenu, @@ -1044,7 +1046,7 @@ static BOOL MENU_ButtonDown( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, { POPUPMENU *menu; MENUITEM *item; - WORD id; + UINT id; if (!hmenu) return FALSE; /* Outside all menus */ menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu ); @@ -1095,7 +1097,7 @@ static BOOL MENU_ButtonUp( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, POPUPMENU *menu; MENUITEM *item; HMENU hsubmenu = 0; - WORD id; + UINT id; if (!hmenu) return FALSE; /* Outside all menus */ menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu ); @@ -1136,7 +1138,7 @@ static BOOL MENU_MouseMove( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent, { MENUITEM *item; POPUPMENU *menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu ); - WORD id = NO_SELECTED_ITEM; + UINT id = NO_SELECTED_ITEM; if (hmenu) { @@ -1253,7 +1255,7 @@ static void MENU_KeyRight( HWND hwndOwner, HMENU hmenu, HMENU *hmenuCurrent ) * If 'x' and 'y' are not 0, we simulate a button-down event at (x,y) * before beginning tracking. This is to help menu-bar tracking. */ -static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, +static BOOL MENU_TrackMenu( HMENU hmenu, UINT wFlags, int x, int y, HWND hwnd, LPRECT lprect ) { MSG *msg; @@ -1261,7 +1263,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, POPUPMENU *menu; HMENU hmenuCurrent = hmenu; BOOL fClosed = FALSE, fRemove; - WORD pos; + UINT pos; fEndMenuCalled = FALSE; if (!(menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( hmenu ))) return FALSE; @@ -1275,7 +1277,7 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, msg = (MSG *)USER_HEAP_LIN_ADDR( hMsg ); while (!fClosed) { - if (!MSG_InternalGetMessage( USER_HEAP_SEG_ADDR(hMsg), 0, + if (!MSG_InternalGetMessage( (SEGPTR)USER_HEAP_SEG_ADDR(hMsg), 0, hwnd, MSGF_MENU, 0, TRUE )) break; @@ -1390,8 +1392,8 @@ static BOOL MENU_TrackMenu( HMENU hmenu, WORD wFlags, int x, int y, /* We will find a better way real soon... */ if ((msg->wParam <= 32) || (msg->wParam >= 127)) break; pos = MENU_FindItemByKey( hwnd, hmenuCurrent, msg->wParam ); - if (pos == (WORD)-2) fClosed = TRUE; - else if (pos == (WORD)-1) MessageBeep(0); + if (pos == (UINT)-2) fClosed = TRUE; + else if (pos == (UINT)-1) MessageBeep(0); else { MENU_SelectItem( hwnd, hmenuCurrent, pos ); @@ -1445,7 +1447,7 @@ void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt ) * * Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand(). */ -void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam ) +void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); if (!wndPtr->wIDmenu) return; @@ -1463,7 +1465,7 @@ void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam ) /********************************************************************** * TrackPopupMenu (USER.416) */ -BOOL TrackPopupMenu( HMENU hMenu, WORD wFlags, short x, short y, +BOOL TrackPopupMenu( HMENU hMenu, UINT wFlags, short x, short y, short nReserved, HWND hWnd, LPRECT lpRect ) { if (!MENU_ShowPopup( hWnd, hMenu, 0, x, y )) return FALSE; @@ -1483,7 +1485,7 @@ LRESULT PopupMenuWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) CREATESTRUCT *createStruct = (CREATESTRUCT*)PTR_SEG_TO_LIN(lParam); #ifdef WINELIB32 HMENU hmenu = (HMENU) (createStruct->lpCreateParams); - SetWindowLong( hwnd, 0, hmenu ); + SetWindowLong( hwnd, 0, (LONG)hmenu ); #else HMENU hmenu = (HMENU) ((int)createStruct->lpCreateParams & 0xffff); SetWindowWord( hwnd, 0, hmenu ); @@ -1521,7 +1523,7 @@ LRESULT PopupMenuWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) * * Compute the size of the menu bar height. Used by NC_HandleNCCalcSize(). */ -WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth, int orgX, int orgY ) +UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth, int orgX, int orgY ) { HDC hdc; RECT rectBar; @@ -1529,7 +1531,8 @@ WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth, int orgX, int orgY ) LPPOPUPMENU lppop; if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return 0; - if (!(lppop = (LPPOPUPMENU)USER_HEAP_LIN_ADDR(wndPtr->wIDmenu))) return 0; + if (!(lppop = (LPPOPUPMENU)USER_HEAP_LIN_ADDR((HMENU)wndPtr->wIDmenu))) + return 0; hdc = GetDC( hwnd ); SetRect( &rectBar, orgX, orgY, orgX+menubarWidth, orgY+SYSMETRICS_CYMENU ); MENU_MenuBarCalcSize( hdc, &rectBar, lppop, hwnd ); @@ -1541,8 +1544,8 @@ WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth, int orgX, int orgY ) /********************************************************************** * ChangeMenu [USER.153] */ -BOOL ChangeMenu(HMENU hMenu, WORD nPos, LPSTR lpNewItem, - WORD wItemID, WORD wFlags) +BOOL ChangeMenu(HMENU hMenu, UINT nPos, LPSTR lpNewItem, + UINT wItemID, UINT wFlags) { dprintf_menu(stddeb,"ChangeMenu: menu="NPFMT" pos=%d ptr=%p item=%04x flags=%04x\n", hMenu, nPos, lpNewItem, wItemID, wFlags); @@ -1568,7 +1571,7 @@ BOOL ChangeMenu(HMENU hMenu, WORD nPos, LPSTR lpNewItem, /********************************************************************** * CheckMenuItem [USER.154] */ -BOOL CheckMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags) +BOOL CheckMenuItem(HMENU hMenu, UINT wItemID, UINT wFlags) { LPMENUITEM lpitem; dprintf_menu(stddeb,"CheckMenuItem ("NPFMT", %04X, %04X) !\n", @@ -1583,7 +1586,7 @@ BOOL CheckMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags) /********************************************************************** * EnableMenuItem [USER.155] */ -BOOL EnableMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags) +BOOL EnableMenuItem(HMENU hMenu, UINT wItemID, UINT wFlags) { LPMENUITEM lpitem; dprintf_menu(stddeb,"EnableMenuItem ("NPFMT", %04X, %04X) !\n", @@ -1610,8 +1613,8 @@ BOOL EnableMenuItem(HMENU hMenu, WORD wItemID, WORD wFlags) /******************************************************************* * GetMenuString (USER.161) */ -int GetMenuString( HMENU hMenu, WORD wItemID, - LPSTR str, short nMaxSiz, WORD wFlags ) +int GetMenuString( HMENU hMenu, UINT wItemID, + LPSTR str, short nMaxSiz, UINT wFlags ) { LPMENUITEM lpitem; @@ -1621,7 +1624,7 @@ int GetMenuString( HMENU hMenu, WORD wItemID, str[0] = '\0'; if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return 0; if (!lpitem->item_text || !IS_STRING_ITEM(lpitem->item_flags)) return 0; - nMaxSiz = min( nMaxSiz-1, strlen(lpitem->item_text) ); + nMaxSiz = MIN( nMaxSiz-1, strlen(lpitem->item_text) ); strncpy( str, lpitem->item_text, nMaxSiz ); str[nMaxSiz] = '\0'; dprintf_menu( stddeb, "GetMenuString: returning '%s'\n", str ); @@ -1632,7 +1635,7 @@ int GetMenuString( HMENU hMenu, WORD wItemID, /********************************************************************** * HiliteMenuItem [USER.162] */ -BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, WORD wItemID, WORD wHilite) +BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, UINT wItemID, UINT wHilite) { LPPOPUPMENU menu; LPMENUITEM lpitem; @@ -1650,7 +1653,7 @@ BOOL HiliteMenuItem(HWND hWnd, HMENU hMenu, WORD wItemID, WORD wHilite) /********************************************************************** * GetMenuState [USER.250] */ -WORD GetMenuState(HMENU hMenu, WORD wItemID, WORD wFlags) +UINT GetMenuState(HMENU hMenu, UINT wItemID, UINT wFlags) { LPMENUITEM lpitem; dprintf_menu(stddeb,"GetMenuState("NPFMT", %04X, %04X);\n", @@ -1658,7 +1661,7 @@ WORD GetMenuState(HMENU hMenu, WORD wItemID, WORD wFlags) if (!(lpitem = MENU_FindItem( &hMenu, &wItemID, wFlags ))) return -1; if (lpitem->item_flags & MF_POPUP) { - POPUPMENU *menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( lpitem->item_id ); + POPUPMENU *menu = (POPUPMENU *) USER_HEAP_LIN_ADDR( (HMENU)lpitem->item_id ); if (!menu) return -1; else return (menu->nItems << 8) | (menu->wFlags & 0xff); } @@ -1674,7 +1677,7 @@ WORD GetMenuItemCount(HMENU hMenu) LPPOPUPMENU menu; dprintf_menu(stddeb,"GetMenuItemCount("NPFMT");\n", hMenu); menu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu); - if (menu == NULL) return (WORD)-1; + if (menu == NULL) return (UINT)-1; dprintf_menu(stddeb,"GetMenuItemCount("NPFMT") return %d \n", hMenu, menu->nItems); return menu->nItems; @@ -1684,7 +1687,7 @@ WORD GetMenuItemCount(HMENU hMenu) /********************************************************************** * GetMenuItemID [USER.264] */ -WORD GetMenuItemID(HMENU hMenu, int nPos) +UINT GetMenuItemID(HMENU hMenu, int nPos) { LPPOPUPMENU menu; MENUITEM *item; @@ -1701,7 +1704,7 @@ WORD GetMenuItemID(HMENU hMenu, int nPos) /********************************************************************** * InsertMenu [USER.410] */ -BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewItem) +BOOL InsertMenu(HMENU hMenu, UINT nPos, UINT wFlags, UINT wItemID, LPSTR lpNewItem) { HANDLE hNewItems; MENUITEM *lpitem, *newItems; @@ -1721,7 +1724,7 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt /* Find where to insert new item */ if ((wFlags & MF_BYPOSITION) && - ((nPos == (WORD)-1) || (nPos == GetMenuItemCount(hMenu)))) + ((nPos == (UINT)-1) || (nPos == GetMenuItemCount(hMenu)))) { /* Special case: append to menu Some programs specify the menu length to do that */ @@ -1786,11 +1789,15 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt lpitem->item_text = (char *)USER_HEAP_LIN_ADDR( lpitem->hText ); strcpy( lpitem->item_text, lpNewItem ); } +#ifdef WINELIB32 + else if (wFlags & MF_BITMAP) lpitem->hText = (HANDLE)lpNewItem; +#else else if (wFlags & MF_BITMAP) lpitem->hText = LOWORD((DWORD)lpNewItem); +#endif else lpitem->item_text = lpNewItem; if (wFlags & MF_POPUP) /* Set the MF_POPUP flag on the popup-menu */ - ((POPUPMENU *)USER_HEAP_LIN_ADDR(wItemID))->wFlags |= MF_POPUP; + ((POPUPMENU *)USER_HEAP_LIN_ADDR((HMENU)wItemID))->wFlags |= MF_POPUP; SetRectEmpty( &lpitem->rect ); lpitem->hCheckBit = hStdCheck; @@ -1802,7 +1809,7 @@ BOOL InsertMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt /********************************************************************** * AppendMenu [USER.411] */ -BOOL AppendMenu(HMENU hMenu, WORD wFlags, WORD wItemID, LPSTR lpNewItem) +BOOL AppendMenu(HMENU hMenu, UINT wFlags, UINT wItemID, LPSTR lpNewItem) { return InsertMenu( hMenu, -1, wFlags | MF_BYPOSITION, wItemID, lpNewItem ); } @@ -1811,7 +1818,7 @@ BOOL AppendMenu(HMENU hMenu, WORD wFlags, WORD wItemID, LPSTR lpNewItem) /********************************************************************** * RemoveMenu [USER.412] */ -BOOL RemoveMenu(HMENU hMenu, WORD nPos, WORD wFlags) +BOOL RemoveMenu(HMENU hMenu, UINT nPos, UINT wFlags) { LPPOPUPMENU menu; LPMENUITEM lpitem; @@ -1846,7 +1853,7 @@ BOOL RemoveMenu(HMENU hMenu, WORD nPos, WORD wFlags) /********************************************************************** * DeleteMenu [USER.413] */ -BOOL DeleteMenu(HMENU hMenu, WORD nPos, WORD wFlags) +BOOL DeleteMenu(HMENU hMenu, UINT nPos, UINT wFlags) { MENUITEM *item = MENU_FindItem( &hMenu, &nPos, wFlags ); if (!item) return FALSE; @@ -1860,7 +1867,7 @@ BOOL DeleteMenu(HMENU hMenu, WORD nPos, WORD wFlags) /********************************************************************** * ModifyMenu [USER.414] */ -BOOL ModifyMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewItem) +BOOL ModifyMenu(HMENU hMenu, UINT nPos, UINT wFlags, UINT wItemID, LPSTR lpNewItem) { LPMENUITEM lpitem; if (IS_STRING_ITEM(wFlags)) @@ -1884,7 +1891,11 @@ BOOL ModifyMenu(HMENU hMenu, WORD nPos, WORD wFlags, WORD wItemID, LPSTR lpNewIt lpitem->item_text = (char *)USER_HEAP_LIN_ADDR( lpitem->hText ); strcpy( lpitem->item_text, lpNewItem ); } +#ifdef WINELIB32 + else if (wFlags & MF_BITMAP) lpitem->hText = (HANDLE)lpNewItem; +#else else if (wFlags & MF_BITMAP) lpitem->hText = LOWORD((DWORD)lpNewItem); +#endif else lpitem->item_text = lpNewItem; SetRectEmpty( &lpitem->rect ); return TRUE; @@ -1918,7 +1929,7 @@ DWORD GetMenuCheckMarkDimensions() /********************************************************************** * SetMenuItemBitmaps [USER.418] */ -BOOL SetMenuItemBitmaps(HMENU hMenu, WORD nPos, WORD wFlags, +BOOL SetMenuItemBitmaps(HMENU hMenu, UINT nPos, UINT wFlags, HBITMAP hNewCheck, HBITMAP hNewUnCheck) { LPMENUITEM lpitem; @@ -1990,7 +2001,7 @@ BOOL DestroyMenu(HMENU hMenu) for (i = lppop->nItems; i > 0; i--, item++) { if (item->item_flags & MF_POPUP) - DestroyMenu( item->item_id ); + DestroyMenu( (HMENU)item->item_id ); } USER_HEAP_FREE( lppop->hItems ); } @@ -2032,7 +2043,7 @@ HMENU GetMenu(HWND hWnd) { WND * wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) return 0; - return wndPtr->wIDmenu; + return (HMENU)wndPtr->wIDmenu; } @@ -2050,7 +2061,7 @@ BOOL SetMenu(HWND hWnd, HMENU hMenu) } dprintf_menu(stddeb,"SetMenu("NPFMT", "NPFMT");\n", hWnd, hMenu); if (GetCapture() == hWnd) ReleaseCapture(); - wndPtr->wIDmenu = hMenu; + wndPtr->wIDmenu = (UINT)hMenu; if (hMenu != 0) { lpmenu = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu); @@ -2079,7 +2090,7 @@ HMENU GetSubMenu(HMENU hMenu, short nPos) LPMENUITEM lpitem; dprintf_menu(stddeb,"GetSubMenu ("NPFMT", %04X) !\n", hMenu, nPos); if (!(lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(hMenu))) return 0; - if ((WORD)nPos >= lppop->nItems) return 0; + if ((UINT)nPos >= lppop->nItems) return 0; lpitem = (MENUITEM *) USER_HEAP_LIN_ADDR( lppop->hItems ); if (!(lpitem[nPos].item_flags & MF_POPUP)) return 0; return lpitem[nPos].item_id; @@ -2099,7 +2110,7 @@ void DrawMenuBar(HWND hWnd) wndPtr->wIDmenu != 0) { dprintf_menu(stddeb,"DrawMenuBar wIDmenu=%04X \n", wndPtr->wIDmenu); - lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR(wndPtr->wIDmenu); + lppop = (LPPOPUPMENU) USER_HEAP_LIN_ADDR((HMENU)wndPtr->wIDmenu); if (lppop == NULL) return; lppop->Height = 0; /* Make sure we call MENU_MenuBarCalcSize */ @@ -2217,7 +2228,7 @@ WORD * ParseMenuResource(WORD *first_item, int level, HMENU hMenu) hSubMenu = CreatePopupMenu(); next_item = ParseMenuResource(next_item, level, hSubMenu); AppendMenu(hMenu, popup_item->item_flags, - hSubMenu, popup_item->item_text); + (UINT)hSubMenu, popup_item->item_text); } else { MENUITEMTEMPLATE *normal_item = (MENUITEMTEMPLATE *) item; diff --git a/controls/scroll.c b/controls/scroll.c index 507c8971f00..3d7a67e8db2 100644 --- a/controls/scroll.c +++ b/controls/scroll.c @@ -209,7 +209,7 @@ static UINT SCROLL_GetThumbVal( SCROLLINFO *infoPtr, RECT *rect, { int pixels = vertical ? rect->bottom-rect->top : rect->right-rect->left; if ((pixels -= 3*SYSMETRICS_CXVSCROLL+1) <= 0) return infoPtr->MinVal; - pos = max( 0, pos - SYSMETRICS_CXVSCROLL ); + pos = MAX( 0, pos - SYSMETRICS_CXVSCROLL ); if (pos > pixels) pos = pixels; dprintf_scroll(stddeb,"GetThumbVal: pos=%d ret=%d\n", pos, (infoPtr->MinVal @@ -592,8 +592,8 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) return; /* Should never happen */ } - dprintf_scroll( stddeb, "ScrollBar Event: hwnd="NPFMT" bar=%d msg=%x pt=%d,%d hit=%d\n", - hwnd, nBar, msg, pt.x, pt.y, hittest ); + dprintf_scroll( stddeb, "ScrollBar Event: hwnd="NPFMT" bar=%d msg=%x pt=%ld,%ld hit=%d\n", + hwnd, nBar, msg, (LONG)pt.x, (LONG)pt.y, hittest ); switch(trackHitTest) { @@ -757,7 +757,11 @@ void SCROLL_HandleScrollEvent( HWND hwnd, int nBar, WORD msg, POINT pt ) * ScrollBarWndProc */ LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) -{ +{ + POINT Pt; + Pt.x = LOWORD(lParam); Pt.y = HIWORD(lParam); + /* ^ Can't use MAKEPOINT macro in WINELIB32 */ + switch(message) { case WM_CREATE: @@ -800,7 +804,7 @@ LONG ScrollBarWndProc( HWND hwnd, WORD message, WORD wParam, LONG lParam ) case WM_LBUTTONUP: case WM_MOUSEMOVE: case WM_SYSTIMER: - SCROLL_HandleScrollEvent( hwnd, SB_CTL, message, MAKEPOINT(lParam) ); + SCROLL_HandleScrollEvent( hwnd, SB_CTL, message, Pt ); break; case WM_KEYDOWN: diff --git a/controls/static.c b/controls/static.c index b88dd2ff638..ce812523766 100644 --- a/controls/static.c +++ b/controls/static.c @@ -55,7 +55,8 @@ static void STATIC_SetIcon( HWND hwnd, HICON hicon ) STATICINFO *infoPtr = (STATICINFO *)wndPtr->wExtra; if ((wndPtr->dwStyle & 0x0f) != SS_ICON) return; - if (infoPtr->hIcon) DestroyIcon( infoPtr->hIcon ); +/* FIXME: is this OK? + if (infoPtr->hIcon) DestroyIcon( infoPtr->hIcon ); */ infoPtr->hIcon = hicon; if (hicon) { diff --git a/debugger/dbg.y b/debugger/dbg.y index 7eb5a58c0da..cd3b9cf68df 100644 --- a/debugger/dbg.y +++ b/debugger/dbg.y @@ -1,9 +1,9 @@ - %{ /* * Parser for command lines in the Wine debugger * * Copyright 1993 Eric Youngdale + * Copyright 1995 Morten Welinder */ #include @@ -33,7 +33,7 @@ int yyerror(char *); int integer; } -%token CONT STEP NEXT QUIT HELP BACKTRACE INFO STACK SEGMENTS REGS +%token CONT STEP LIST NEXT QUIT HELP BACKTRACE INFO STACK SEGMENTS REGS %token ENABLE DISABLE BREAK DELETE SET MODE PRINT EXAM DEFINE ABORT %token NO_SYMBOL %token SYMBOLFILE @@ -42,82 +42,144 @@ int yyerror(char *); %token NUM FORMAT %token REG +/* %left ',' */ +/* %left '=' OP_OR_EQUAL OP_XOR_EQUAL OP_AND_EQUAL OP_SHL_EQUAL \ + OP_SHR_EQUAL OP_PLUS_EQUAL OP_MINUS_EQUAL \ + OP_TIMES_EQUAL OP_DIVIDE_EQUAL OP_MODULO_EQUAL */ +/* %left OP_COND */ /* ... ? ... : ... */ +%left OP_LOR +%left OP_LAND +%left '|' +%left '^' +%left '&' +%left OP_EQ OP_NE +%left '<' '>' OP_LE OP_GE +%left OP_SHL OP_SHR +%left '+' '-' +%left '*' '/' '%' +%left OP_SIGN '!' '~' OP_DEREF /* OP_INC OP_DEC OP_ADDR */ +%nonassoc ':' + %type expr -%type
addr symbol +%type
addr segaddr symbol %% - input: /* empty */ - | input line { issue_prompt(); } + input: line { issue_prompt(); } + | input line { issue_prompt(); } - line: '\n' - | error '\n' { yyerrok; } - | QUIT '\n' { exit(0); } - | HELP '\n' { DEBUG_Help(); } - | CONT '\n' { dbg_exec_mode = EXEC_CONT; return 0; } - | STEP '\n' { dbg_exec_mode = EXEC_STEP_INSTR; return 0; } - | NEXT '\n' { dbg_exec_mode = EXEC_STEP_OVER; return 0; } - | ABORT '\n' { kill(getpid(), SIGABRT); } - | SYMBOLFILE IDENTIFIER '\n' { DEBUG_ReadSymbolTable( $2 ); } - | DEFINE IDENTIFIER addr '\n' { DEBUG_AddSymbol( $2, &$3 ); } - | MODE NUM '\n' { mode_command($2); } - | ENABLE NUM '\n' { DEBUG_EnableBreakpoint( $2, TRUE ); } - | DISABLE NUM '\n' { DEBUG_EnableBreakpoint( $2, FALSE ); } - | BREAK '*' addr '\n' { DEBUG_AddBreakpoint( &$3 ); } - | BREAK symbol '\n' { DEBUG_AddBreakpoint( &$2 ); } - | BREAK '\n' { DBG_ADDR addr = { CS_reg(DEBUG_context), - EIP_reg(DEBUG_context) }; - DEBUG_AddBreakpoint( &addr ); - } - | DELETE BREAK NUM '\n' { DEBUG_DelBreakpoint( $3 ); } - | BACKTRACE '\n' { DEBUG_BackTrace(); } + line: command '\n' + | '\n' + | error '\n' { yyerrok; } + + command: QUIT { exit(0); } + | HELP { DEBUG_Help(); } + | CONT { dbg_exec_mode = EXEC_CONT; return 0; } + | STEP { dbg_exec_mode = EXEC_STEP_INSTR; return 0; } + | NEXT { dbg_exec_mode = EXEC_STEP_OVER; return 0; } + | LIST { DEBUG_List( NULL, 15 ); } + | LIST addr { DEBUG_List( &$2, 15 ); } + | ABORT { kill(getpid(), SIGABRT); } + | SYMBOLFILE IDENTIFIER { DEBUG_ReadSymbolTable( $2 ); } + | DEFINE IDENTIFIER addr { DEBUG_AddSymbol( $2, &$3 ); } + | MODE NUM { mode_command($2); } + | ENABLE NUM { DEBUG_EnableBreakpoint( $2, TRUE ); } + | DISABLE NUM { DEBUG_EnableBreakpoint( $2, FALSE ); } + | BREAK '*' addr { DEBUG_AddBreakpoint( &$3 ); } + | BREAK symbol { DEBUG_AddBreakpoint( &$2 ); } + | BREAK { DBG_ADDR addr = { CS_reg(DEBUG_context), + EIP_reg(DEBUG_context) }; + DEBUG_AddBreakpoint( &addr ); + } + | DELETE BREAK NUM { DEBUG_DelBreakpoint( $3 ); } + | BACKTRACE { DEBUG_BackTrace(); } | infocmd | x_command | print_command | deposit_command deposit_command: - SET REG '=' expr '\n' { DEBUG_SetRegister( $2, $4 ); } - | SET '*' addr '=' expr '\n' { DEBUG_WriteMemory( &$3, $5 ); } - | SET IDENTIFIER '=' addr '\n' { if (!DEBUG_SetSymbolValue( $2, &$4 )) - { - fprintf( stderr, "Symbol %s not found\n", $2 ); - YYERROR; - } - } + SET REG '=' expr { DEBUG_SetRegister( $2, $4 ); } + | SET '*' addr '=' expr { DEBUG_WriteMemory( &$3, $5 ); } + | SET IDENTIFIER '=' addr { if (!DEBUG_SetSymbolValue( $2, &$4 )) + { + fprintf( stderr, + "Symbol %s not found\n", $2 ); + YYERROR; + } + } x_command: - EXAM addr '\n' { DEBUG_ExamineMemory( &$2, 1, 'x'); } - | EXAM FORMAT addr '\n' { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff ); } + EXAM addr { DEBUG_ExamineMemory( &$2, 1, 'x'); } + | EXAM FORMAT addr { DEBUG_ExamineMemory( &$3, $2>>8, $2&0xff ); } print_command: - PRINT addr '\n' { DEBUG_Print( &$2, 1, 'x' ); } - | PRINT FORMAT addr '\n' { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff ); } + PRINT addr { DEBUG_Print( &$2, 1, 'x' ); } + | PRINT FORMAT addr { DEBUG_Print( &$3, $2 >> 8, $2 & 0xff ); } symbol: IDENTIFIER { if (!DEBUG_GetSymbolValue( $1, &$$ )) - { - fprintf( stderr, "Symbol %s not found\n", $1 ); - YYERROR; - } - } + { + fprintf( stderr, "Symbol %s not found\n", $1 ); + YYERROR; + } + } - addr: expr { $$.seg = 0xffffffff; $$.off = $1; } - | expr ':' expr { $$.seg = $1; $$.off = $3; } - | symbol { $$ = $1; } + addr: expr { $$.seg = 0xffffffff; $$.off = $1; } + | segaddr { $$ = $1; } - expr: NUM { $$ = $1; } - | REG { $$ = DEBUG_GetRegister($1); } - | expr '+' NUM { $$ = $1 + $3; } - | expr '-' NUM { $$ = $1 - $3; } - | '(' expr ')' { $$ = $2; } - | '*' addr { $$ = DEBUG_ReadMemory( &$2 ); } + segaddr: expr ':' expr { $$.seg = $1; $$.off = $3; } + | symbol { $$ = $1; } + + expr: NUM { $$ = $1; } + | REG { $$ = DEBUG_GetRegister($1); } + | expr OP_LOR expr { $$ = $1 || $3; } + | expr OP_LAND expr { $$ = $1 && $3; } + | expr '|' expr { $$ = $1 | $3; } + | expr '&' expr { $$ = $1 & $3; } + | expr '^' expr { $$ = $1 ^ $3; } + | expr OP_EQ expr { $$ = $1 == $3; } + | expr '>' expr { $$ = $1 > $3; } + | expr '<' expr { $$ = $1 < $3; } + | expr OP_GE expr { $$ = $1 >= $3; } + | expr OP_LE expr { $$ = $1 <= $3; } + | expr OP_NE expr { $$ = $1 != $3; } + | expr OP_SHL expr { $$ = (unsigned)$1 << $3; } + | expr OP_SHR expr { $$ = (unsigned)$1 >> $3; } + | expr '+' expr { $$ = $1 + $3; } + | expr '-' expr { $$ = $1 - $3; } + | expr '*' expr { $$ = $1 * $3; } + | expr '/' expr + { if ($3) + if ($3 == -1 && $1 == 0x80000000l) + yyerror ("Division overflow"); + else + $$ = $1 / $3; + else + yyerror ("Division by zero"); } + | expr '%' expr + { if ($3) + if ($3 == -1 && $1 == 0x80000000l) + $$ = 0; /* A sensible result in this case. */ + else + $$ = $1 % $3; + else + yyerror ("Division by zero"); } + | '-' expr %prec OP_SIGN { $$ = -$2; } + | '+' expr %prec OP_SIGN { $$ = $2; } + | '!' expr { $$ = !$2; } + | '~' expr { $$ = ~$2; } + | '(' expr ')' { $$ = $2; } +/* For parser technical reasons we can't use "addr" here. */ + | '*' expr %prec OP_DEREF { DBG_ADDR addr = { 0xffffffff, $2 }; + $$ = DEBUG_ReadMemory( &addr ); } + | '*' segaddr %prec OP_DEREF { $$ = DEBUG_ReadMemory( &$2 ); } - infocmd: INFO REGS '\n' { DEBUG_InfoRegisters(); } - | INFO STACK '\n' { DEBUG_InfoStack(); } - | INFO BREAK '\n' { DEBUG_InfoBreakpoints(); } - | INFO SEGMENTS '\n' { LDT_Print( 0, -1 ); } - | INFO SEGMENTS expr '\n' { LDT_Print( SELECTOR_TO_ENTRY($3), 1 ); } + infocmd: INFO REGS { DEBUG_InfoRegisters(); } + | INFO STACK { DEBUG_InfoStack(); } + | INFO BREAK { DEBUG_InfoBreakpoints(); } + | INFO SEGMENTS { LDT_Print( 0, -1 ); } + | INFO SEGMENTS expr { LDT_Print( SELECTOR_TO_ENTRY($3), 1 ); } %% diff --git a/debugger/debug.l b/debugger/debug.l index ef142ed8926..c46eb100c67 100644 --- a/debugger/debug.l +++ b/debugger/debug.l @@ -34,9 +34,17 @@ IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~]* %% -\n { syntax_error = 0; return '\n'; } /*Indicate end of command*/ +\n { syntax_error = 0; return '\n'; } /*Indicates end of command*/ -[-+=()*:] { return *yytext; } +"||" { return OP_LOR; } +"&&" { return OP_LAND; } +"==" { return OP_EQ; } +"!=" { return OP_NE; } +"<=" { return OP_LE; } +">=" { return OP_GE; } +"<<" { return OP_SHL; } +">>" { return OP_SHR; } +[-+<=>|&^()*/%:!~] { return *yytext; } "0x"{HEXDIGIT}+ { sscanf(yytext, "%x", &yylval.integer); return NUM; } {DIGIT}+ { sscanf(yytext, "%d", &yylval.integer); return NUM; } @@ -72,25 +80,26 @@ $ds { yylval.reg = REG_DS; return REG; } $cs { yylval.reg = REG_CS; return REG; } $ss { yylval.reg = REG_SS; return REG; } -info|inf|in { return INFO; } -segments|segment|segm|seg|se { return SEGMENTS; } -break|brea|bre|br|b { return BREAK; } -enable|enabl|enab|ena { return ENABLE;} -disable|disabl|disab|disa|dis { return DISABLE; } -delete|delet|dele|del { return DELETE; } -quit|qui|qu|q { return QUIT; } -x { return EXAM; } +info|inf|in { return INFO; } +show|sho|sh { return INFO; } +list|l { return LIST; } +segments|segment|segm|seg|se { return SEGMENTS; } +break|brea|bre|br|b { return BREAK; } +enable|enabl|enab|ena { return ENABLE;} +disable|disabl|disab|disa|dis { return DISABLE; } +delete|delet|dele|del { return DELETE; } +quit|qui|qu|q { return QUIT; } +x { return EXAM; } -help|hel|he { return HELP; } -"?" { return HELP; } +help|hel|he|"?" { return HELP; } -set|se { return SET; } +set|se { return SET; } -bt { return BACKTRACE; } +bt { return BACKTRACE; } -cont|con|co|c { return CONT; } -step|ste|st|s { return STEP; } -next|nex|ne|n { return NEXT; } +cont|con|co|c { return CONT; } +step|ste|st|s { return STEP; } +next|nex|ne|n { return NEXT; } symbolfile|symbolfil|symbolfi|symbolf|symbol|symbo|symb { return SYMBOLFILE; } @@ -100,9 +109,9 @@ print|prin|pri|pr|p { return PRINT; } mode { return MODE; } -registers|regs|reg|re { return REGS; } +registers|regs|reg|re { return REGS; } -stack|stac|sta|st { return STACK; } +stack|stac|sta|st { return STACK; } {IDENTIFIER} { yylval.string = make_symbol(yytext); return IDENTIFIER; } diff --git a/debugger/hash.c b/debugger/hash.c index f6569c8ffae..8a325c7a09c 100644 --- a/debugger/hash.c +++ b/debugger/hash.c @@ -14,6 +14,7 @@ #include "selectors.h" #include "debugger.h" #include "toolhelp.h" +#include "xmalloc.h" struct name_hash { @@ -48,7 +49,7 @@ void DEBUG_AddSymbol( const char * name, const DBG_ADDR *addr ) struct name_hash * new; int hash; - new = (struct name_hash *) malloc(sizeof(struct name_hash)); + new = (struct name_hash *) xmalloc(sizeof(struct name_hash)); new->addr = *addr; new->name = strdup(name); new->next = NULL; diff --git a/debugger/info.c b/debugger/info.c index 4914a15b86c..54d5140b63a 100644 --- a/debugger/info.c +++ b/debugger/info.c @@ -125,3 +125,27 @@ NULL while(helptext[i]) fprintf(stderr,"%s\n", helptext[i++]); } + + + +/*********************************************************************** + * DEBUG_List + * + * Implementation of the 'list' command. + */ +void DEBUG_List( DBG_ADDR *addr, int count ) +{ + static DBG_ADDR lasttime = { 0xffffffff, 0 }; + + if (addr == NULL) addr = &lasttime; + DBG_FIX_ADDR_SEG( addr, CS_reg(DEBUG_context) ); + while (count-- > 0) + { + DEBUG_PrintAddress( addr, dbg_mode ); + fprintf( stderr, ": " ); + if (!DBG_CHECK_READ_PTR( addr, 1 )) break; + DEBUG_Disasm( addr ); + fprintf (stderr, "\n"); + } + lasttime = *addr; +} diff --git a/if1632/Makefile.in b/if1632/Makefile.in index 52e0a187f1e..60ac9072797 100644 --- a/if1632/Makefile.in +++ b/if1632/Makefile.in @@ -17,6 +17,7 @@ SPEC32_FILES = $(DLLS32:.spec=.c) C_SRCS = \ $(SPEC32_FILES) \ callback.c \ + dummy.c \ relay.c \ relay32.c diff --git a/if1632/dummy.c b/if1632/dummy.c new file mode 100644 index 00000000000..08c0fc6d611 --- /dev/null +++ b/if1632/dummy.c @@ -0,0 +1,42 @@ +#include +long stub_GDI_530(void) { fprintf(stderr, "Warning: GDI_530: unimplemented stub\n"); return 0; } +long stub_GDI_531(void) { fprintf(stderr, "Warning: GDI_531: unimplemented stub\n"); return 0; } +long stub_GDI_532(void) { fprintf(stderr, "Warning: GDI_532: unimplemented stub\n"); return 0; } +long stub_GDI_536(void) { fprintf(stderr, "Warning: GDI_536: unimplemented stub\n"); return 0; } +long stub_GDI_538(void) { fprintf(stderr, "Warning: GDI_538: unimplemented stub\n"); return 0; } +long stub_GDI_540(void) { fprintf(stderr, "Warning: GDI_540: unimplemented stub\n"); return 0; } +long stub_GDI_543(void) { fprintf(stderr, "Warning: GDI_543: unimplemented stub\n"); return 0; } +long stub_GDI_555(void) { fprintf(stderr, "Warning: GDI_555: unimplemented stub\n"); return 0; } +long stub_GDI_560(void) { fprintf(stderr, "Warning: GDI_560: unimplemented stub\n"); return 0; } +long stub_GDI_561(void) { fprintf(stderr, "Warning: GDI_561: unimplemented stub\n"); return 0; } +long stub_GDI_564(void) { fprintf(stderr, "Warning: GDI_564: unimplemented stub\n"); return 0; } +long stub_GDI_565(void) { fprintf(stderr, "Warning: GDI_565: unimplemented stub\n"); return 0; } +long stub_GDI_566(void) { fprintf(stderr, "Warning: GDI_566: unimplemented stub\n"); return 0; } +long stub_GDI_571(void) { fprintf(stderr, "Warning: GDI_571: unimplemented stub\n"); return 0; } +long stub_GDI_572(void) { fprintf(stderr, "Warning: GDI_572: unimplemented stub\n"); return 0; } +long stub_GDI_573(void) { fprintf(stderr, "Warning: GDI_573: unimplemented stub\n"); return 0; } +long stub_GDI_556(void) { fprintf(stderr, "Warning: GDI_556: unimplemented stub\n"); return 0; } +long stub_GDI_558(void) { fprintf(stderr, "Warning: GDI_558: unimplemented stub\n"); return 0; } +long stub_GDI_569(void) { fprintf(stderr, "Warning: GDI_569: unimplemented stub\n"); return 0; } +long stub_KERNEL_450(void) { fprintf(stderr, "Warning: KERNEL_450: unimplemented stub\n"); return 0; } +long stub_USER_489(void) { fprintf(stderr, "Warning: USER_489: unimplemented stub\n"); return 0; } +long stub_USER_490(void) { fprintf(stderr, "Warning: USER_490: unimplemented stub\n"); return 0; } +long stub_USER_492(void) { fprintf(stderr, "Warning: USER_492: unimplemented stub\n"); return 0; } +long stub_USER_496(void) { fprintf(stderr, "Warning: USER_496: unimplemented stub\n"); return 0; } +long stub_USER_902(void) { fprintf(stderr, "Warning: USER_902: unimplemented stub\n"); return 0; } +long stub_USER_905(void) { fprintf(stderr, "Warning: USER_905: unimplemented stub\n"); return 0; } +long stub_USER_906(void) { fprintf(stderr, "Warning: USER_906: unimplemented stub\n"); return 0; } +long stub_USER_907(void) { fprintf(stderr, "Warning: USER_907: unimplemented stub\n"); return 0; } +long stub_USER_909(void) { fprintf(stderr, "Warning: USER_909: unimplemented stub\n"); return 0; } +long stub_USER_910(void) { fprintf(stderr, "Warning: USER_910: unimplemented stub\n"); return 0; } +long stub_USER_911(void) { fprintf(stderr, "Warning: USER_911: unimplemented stub\n"); return 0; } +long stub_USER_912(void) { fprintf(stderr, "Warning: USER_912: unimplemented stub\n"); return 0; } +long stub_USER_913(void) { fprintf(stderr, "Warning: USER_913: unimplemented stub\n"); return 0; } +long stub_USER_914(void) { fprintf(stderr, "Warning: USER_914: unimplemented stub\n"); return 0; } +long stub_USER_915(void) { fprintf(stderr, "Warning: USER_915: unimplemented stub\n"); return 0; } +long stub_USER_916(void) { fprintf(stderr, "Warning: USER_916: unimplemented stub\n"); return 0; } +long stub_USER_918(void) { fprintf(stderr, "Warning: USER_918: unimplemented stub\n"); return 0; } +long stub_USER_919(void) { fprintf(stderr, "Warning: USER_919: unimplemented stub\n"); return 0; } +long stub_USER_920(void) { fprintf(stderr, "Warning: USER_920: unimplemented stub\n"); return 0; } +long stub_USER_922(void) { fprintf(stderr, "Warning: USER_922: unimplemented stub\n"); return 0; } +long stub_USER_923(void) { fprintf(stderr, "Warning: USER_923: unimplemented stub\n"); return 0; } diff --git a/if1632/gdi.spec b/if1632/gdi.spec index f9600079f5c..5dd559377f3 100644 --- a/if1632/gdi.spec +++ b/if1632/gdi.spec @@ -140,8 +140,8 @@ id 3 154 pascal GetNearestColor(word long) GetNearestColor 155 stub QueryAbort 156 pascal16 CreateDiscardableBitmap(word word word) CreateDiscardableBitmap -159 stub GetMetaFileBits -160 stub SetMetaFileBits +159 pascal16 GetMetaFileBits(word) GetMetaFileBits +160 pascal16 SetMetaFileBits(word) SetMetaFileBits 161 pascal16 PtInRegion(word s_word s_word) PtInRegion 162 pascal GetBitmapDimension(word) GetBitmapDimension 163 pascal SetBitmapDimension(word s_word s_word) SetBitmapDimension @@ -375,3 +375,23 @@ id 3 822 stub ICMTranslateRGB 823 stub ICMTranslateRGBs 824 stub ICMCheckCOlorsInGamut +# Stubs for Hebrew version +530 pascal16 GDI_530() stub_GDI_530 +531 pascal16 GDI_531() stub_GDI_531 +532 pascal16 GDI_532() stub_GDI_532 +536 pascal16 GDI_536() stub_GDI_536 +538 pascal16 GDI_538() stub_GDI_538 +540 pascal16 GDI_540() stub_GDI_540 +543 pascal16 GDI_543() stub_GDI_543 +555 pascal16 GDI_555() stub_GDI_555 +560 pascal16 GDI_560() stub_GDI_560 +561 pascal16 GDI_561() stub_GDI_561 +564 pascal16 GDI_564() stub_GDI_564 +565 pascal16 GDI_565() stub_GDI_565 +566 pascal16 GDI_566() stub_GDI_566 +571 pascal16 GDI_571() stub_GDI_571 +572 pascal16 GDI_572() stub_GDI_572 +573 pascal16 GDI_573() stub_GDI_573 +556 pascal16 GDI_556() stub_GDI_556 +558 pascal16 GDI_558() stub_GDI_558 +569 pascal16 GDI_569() stub_GDI_569 diff --git a/if1632/kernel.spec b/if1632/kernel.spec index 4cf8424ef63..9a5b15fc012 100644 --- a/if1632/kernel.spec +++ b/if1632/kernel.spec @@ -283,6 +283,7 @@ id 1 421 stub SetFileAttributes 422 stub GetDiskFreeSpace 432 stub FileTimeToLocalFileTime +450 pascal16 KERNEL_450() stub_KERNEL_450 491 stub RegisterServiceProcess 513 stub LoadLibraryEx32W 514 stub FreeLibrary32W diff --git a/if1632/user.spec b/if1632/user.spec index 63b7a9df2bb..469bbc570da 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -297,7 +297,7 @@ id 2 292 pascal16 UnhookWindowsHookEx(segptr) UnhookWindowsHookEx 293 pascal CallNextHookEx(segptr s_word word long) CallNextHookEx 294 stub LockWindowUpdate -#299 MOUSE_EVENT +299 register Mouse_Event() Mouse_Event 300 stub UnloadInstalledDrivers #301 BOZOSLIVEHERE :-)) #306 BEAR306 @@ -319,7 +319,7 @@ id 2 334 pascal GetQueueStatus(word) GetQueueStatus 335 pascal16 GetInputState() GetInputState 336 stub LoadCursorIconHandler -337 stub GetMouseEventProc +337 pascal GetMouseEventProc() GetMouseEventProc #341 _FFFE_FARFRAME 343 stub GetFilePortName 356 stub LoadDIBCursorHandler @@ -514,3 +514,25 @@ id 2 855 stub Usr32ThkConnectionDataSL 890 stub InstallIMT 891 stub UninstallIMT +# Stubs for Hebrew version +489 pascal16 USER_489() stub_USER_489 +490 pascal16 USER_490() stub_USER_490 +492 pascal16 USER_492() stub_USER_492 +496 pascal16 USER_496() stub_USER_496 +902 pascal16 USER_902() stub_USER_902 +905 pascal16 USER_905() stub_USER_905 +906 pascal16 USER_906() stub_USER_906 +907 pascal16 USER_907() stub_USER_907 +909 pascal16 USER_909() stub_USER_909 +910 pascal16 USER_910() stub_USER_910 +911 pascal16 USER_911() stub_USER_911 +912 pascal16 USER_912() stub_USER_912 +913 pascal16 USER_913() stub_USER_913 +914 pascal16 USER_914() stub_USER_914 +915 pascal16 USER_915() stub_USER_915 +916 pascal16 USER_916() stub_USER_916 +918 pascal16 USER_918() stub_USER_918 +919 pascal16 USER_919() stub_USER_919 +920 pascal16 USER_920() stub_USER_920 +922 pascal16 USER_922() stub_USER_922 +923 pascal16 USER_923() stub_USER_923 diff --git a/include/accel.h b/include/accel.h index 59fdbd870ba..b8e569063e2 100644 --- a/include/accel.h +++ b/include/accel.h @@ -5,6 +5,8 @@ * */ +#include "windows.h" + typedef struct { WORD wEvent; WORD wIDval; diff --git a/include/bitmap.h b/include/bitmap.h index c236cdcd3ec..fc07762c18e 100644 --- a/include/bitmap.h +++ b/include/bitmap.h @@ -28,7 +28,7 @@ extern GC BITMAP_monoGC, BITMAP_colorGC; { \ int width_bytes = DIB_GetImageWidthBytes( (width), (bpp) ); \ (image) = XCreateImage(display, DefaultVisualOfScreen(screen), \ - (bpp), ZPixmap, 0, malloc( (height)*width_bytes ), \ + (bpp), ZPixmap, 0, xmalloc( (height)*width_bytes ),\ (width), (height), 32, width_bytes ); \ } diff --git a/include/debugger.h b/include/debugger.h index 9190ff1c5e2..deb92faf4dd 100644 --- a/include/debugger.h +++ b/include/debugger.h @@ -86,6 +86,7 @@ extern void DEBUG_LoadEntryPoints(void); extern void DEBUG_Print( const DBG_ADDR *addr, int count, char format ); extern void DEBUG_PrintAddress( const DBG_ADDR *addr, int addrlen ); extern void DEBUG_Help(void); +extern void DEBUG_List( DBG_ADDR *addr, int count ); /* debugger/memory.c */ extern BOOL DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size ); diff --git a/include/menu.h b/include/menu.h index d2fae7c1e0e..59f292df5c8 100644 --- a/include/menu.h +++ b/include/menu.h @@ -9,11 +9,11 @@ #define MENU_MAGIC 0x554d /* 'MU' */ extern BOOL MENU_Init(void); -extern WORD MENU_GetMenuBarHeight( HWND hwnd, WORD menubarWidth, +extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth, int orgX, int orgY ); /* menu.c */ extern void MENU_TrackMouseMenuBar( HWND hwnd, POINT pt ); /* menu.c */ -extern void MENU_TrackKbdMenuBar( HWND hwnd, WORD wParam ); /* menu.c */ -extern WORD MENU_DrawMenuBar( HDC hDC, LPRECT lprect, +extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam ); /* menu.c */ +extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, HWND hwnd, BOOL suppress_draw ); /* menu.c */ extern HMENU CopySysMenu(); /* menu.c */ @@ -22,7 +22,7 @@ extern LRESULT PopupMenuWndProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lPar typedef struct tagMENUITEM { WORD item_flags; /* Item flags */ - WORD item_id; /* Item or popup id */ + UINT item_id; /* Item or popup id */ RECT rect; /* Item area (relative to menu window) */ WORD xTab; /* X position of text after Tab */ HBITMAP hCheckBit; /* Bitmap for checked item */ @@ -43,7 +43,7 @@ typedef struct tagPOPUPMENU WORD nItems; /* Number of items in the menu */ HWND hWnd; /* Window containing the menu */ HANDLE hItems; /* Handle to the items array */ - WORD FocusedItem; /* Currently focused item */ + UINT FocusedItem; /* Currently focused item */ } POPUPMENU, *LPPOPUPMENU; typedef struct diff --git a/include/sysmetrics.h b/include/sysmetrics.h index 11e08b40b42..52ffa6c92d2 100644 --- a/include/sysmetrics.h +++ b/include/sysmetrics.h @@ -75,6 +75,6 @@ #define SYSMETRICS_MENUDROPALIGNMENT sysMetrics[SM_MENUDROPALIGNMENT] extern void SYSMETRICS_Init(void); -extern short sysMetrics[SM_CMETRICS]; +extern short sysMetrics[SM_CMETRICS+1]; #endif diff --git a/include/win.h b/include/win.h index f40937d2681..49491a2fe3a 100644 --- a/include/win.h +++ b/include/win.h @@ -51,7 +51,7 @@ typedef struct tagWND HANDLE hdce; /* Window DCE (if CS_OWNDC or CS_CLASSDC) */ HANDLE hVScroll; /* Vertical scroll-bar info */ HANDLE hHScroll; /* Horizontal scroll-bar info */ - WORD wIDmenu; /* ID or hmenu (from CreateWindow) */ + UINT wIDmenu; /* ID or hmenu (from CreateWindow) */ HANDLE hText; /* Handle of window text */ WORD flags; /* Misc. flags (see below) */ Window window; /* X window (only for top-level windows) */ diff --git a/include/windows.h b/include/windows.h index e151ebf1999..064434d05bc 100644 --- a/include/windows.h +++ b/include/windows.h @@ -9,21 +9,24 @@ #pragma pack(1) #endif -typedef struct { - INT x; - INT y; -} POINT; +#ifdef WINELIB32 +typedef struct { LONG x,y; } POINT; +typedef struct { SHORT x,y; } POINTS; +typedef struct { LONG cx,cy; } SIZE, *LPSIZE; +typedef struct { LONG left, top, right, bottom; } RECT; +#define MAKEPOINTS(l) (*((POINTS *)&(l))) +#else +typedef struct { INT x,y; } POINT; +typedef struct { INT cx,cy; } SIZE, *LPSIZE; +typedef struct { INT left, top, right, bottom; } RECT; +#define MAKEPOINT(l) (*((POINT *)&(l))) +#endif typedef POINT *PPOINT; typedef POINT *NPPOINT; typedef POINT *LPPOINT; - -typedef struct -{ - INT cx; - INT cy; -} SIZE, *LPSIZE; - -#define MAKEPOINT(l) (*((POINT *)&(l))) +typedef RECT *LPRECT; +typedef RECT *NPRECT; +typedef RECT *PRECT; #ifdef WINELIB32 #define MAKEWPARAM(low, high) ((LONG)(((WORD)(low)) | \ @@ -33,11 +36,6 @@ typedef struct #define MAKELPARAM(low, high) ((LONG)(((WORD)(low)) | \ (((DWORD)((WORD)(high))) << 16))) -typedef struct { INT left, top, right, bottom; } RECT; -typedef RECT *LPRECT; -typedef RECT *NPRECT; -typedef RECT *PRECT; - typedef struct { HDC hdc; BOOL fErase; @@ -425,9 +423,9 @@ typedef struct tagDEBUGHOOKINFO typedef struct tagMSG { HWND hwnd; - WORD message; - WORD wParam; - DWORD lParam WINE_PACKED; + UINT message; + WPARAM wParam; + LPARAM lParam WINE_PACKED; DWORD time WINE_PACKED; POINT pt WINE_PACKED; } MSG, *LPMSG; @@ -1569,6 +1567,13 @@ enum { WM_NULL, WM_CREATE, WM_DESTROY, WM_MOVE, WM_UNUSED0, WM_SIZE, WM_ACTIVAT #define MK_CONTROL 0x0008 #define MK_MBUTTON 0x0010 + /* Mouse_Event flags */ +#define ME_MOVE 0x01 +#define ME_LDOWN 0x02 +#define ME_LUP 0x04 +#define ME_RDOWN 0x08 +#define ME_RUP 0x10 + /* Queue status flags */ #define QS_KEY 0x0001 #define QS_MOUSEMOVE 0x0002 @@ -2366,7 +2371,7 @@ typedef METAFILEPICT *LPMETAFILEPICT; #define META_DRAWTEXT 0x062F #define META_CHORD 0x0830 #define META_SETMAPPERFLAGS 0x0231 -#define META_SETTEXTOUT 0x0A32 +#define META_EXTTEXTOUT 0x0A32 #define META_SETDIBTODEV 0x0D33 #define META_SELECTPALETTE 0x0234 #define META_REALIZEPALETTE 0x0035 @@ -2458,19 +2463,19 @@ ATOM GlobalDeleteAtom(ATOM); ATOM GlobalFindAtom(SEGPTR); ATOM RegisterClass(LPWNDCLASS); BOOL AnyPopup(void); -BOOL AppendMenu(HMENU,WORD,WORD,LPSTR); +BOOL AppendMenu(HMENU,UINT,UINT,LPSTR); BOOL Arc(HDC,int,int,int,int,int,int,int,int); BOOL BitBlt(HDC,short,short,short,short,HDC,short,short,DWORD); BOOL BringWindowToTop(HWND); BOOL CallMsgFilter(SEGPTR,short); BOOL ChangeClipboardChain(HWND,HWND); -BOOL ChangeMenu(HMENU,WORD,LPSTR,WORD,WORD); -BOOL CheckMenuItem(HMENU,WORD,WORD); +BOOL ChangeMenu(HMENU,UINT,LPSTR,UINT,UINT); +BOOL CheckMenuItem(HMENU,UINT,UINT); BOOL Chord(HDC,int,int,int,int,int,int,int,int); BOOL CloseClipboard(void); BOOL DPtoLP(HDC,LPPOINT,int); BOOL DeleteDC(HDC); -BOOL DeleteMenu(HMENU,WORD,WORD); +BOOL DeleteMenu(HMENU,UINT,UINT); BOOL DeleteMetaFile(HMETAFILE); BOOL DeleteObject(HANDLE); BOOL DestroyCursor(HCURSOR); @@ -2483,7 +2488,7 @@ BOOL DrawIcon(HDC,short,short,HICON); BOOL Ellipse(HDC,int,int,int,int); BOOL EmptyClipboard(void); BOOL EnableHardwareInput(BOOL); -BOOL EnableMenuItem(HMENU,WORD,WORD); +BOOL EnableMenuItem(HMENU,UINT,UINT); BOOL EnableScrollBar(HWND,INT,UINT); BOOL EnableWindow(HWND,BOOL); BOOL EndDeferWindowPos(HDWP); @@ -2521,9 +2526,9 @@ BOOL GetWindowPlacement(HWND,LPWINDOWPLACEMENT); BOOL GlobalUnWire(HGLOBAL); BOOL GlobalUnlock(HGLOBAL); BOOL GrayString(HDC,HBRUSH,FARPROC,LPARAM,INT,INT,INT,INT,INT); -BOOL HiliteMenuItem(HWND,HMENU,WORD,WORD); +BOOL HiliteMenuItem(HWND,HMENU,UINT,UINT); BOOL InSendMessage(void); -BOOL InsertMenu(HMENU,WORD,WORD,WORD,LPSTR); +BOOL InsertMenu(HMENU,UINT,UINT,UINT,LPSTR); BOOL IntersectRect(LPRECT,LPRECT,LPRECT); BOOL InvertRgn(HDC,HRGN); BOOL IsBadCodePtr(SEGPTR); @@ -2552,7 +2557,7 @@ BOOL LPtoDP(HDC,LPPOINT,int); BOOL LineTo(HDC,short,short); BOOL LocalInit(HANDLE,WORD,WORD); BOOL LocalUnlock(HANDLE); -BOOL ModifyMenu(HMENU,WORD,WORD,WORD,LPSTR); +BOOL ModifyMenu(HMENU,UINT,UINT,UINT,LPSTR); BOOL MoveToEx(HDC,short,short,LPPOINT); BOOL MoveWindow(HWND,short,short,short,short,BOOL); BOOL OemToAnsi(LPSTR,LPSTR); @@ -2578,8 +2583,8 @@ BOOL RectVisible(HDC,LPRECT); BOOL Rectangle(HDC,int,int,int,int); BOOL RedrawWindow(HWND,LPRECT,HRGN,UINT); BOOL RemoveFontResource(LPSTR); -BOOL RemoveMenu(HMENU,WORD,WORD); -BOOL ResizePalette(HPALETTE,WORD); +BOOL RemoveMenu(HMENU,UINT,UINT); +BOOL ResizePalette(HPALETTE,UINT); BOOL RestoreDC(HDC,short); BOOL RoundRect(HDC,short,short,short,short,short,short); BOOL ScaleViewportExtEx(HDC,short,short,short,short,LPSIZE); @@ -2591,7 +2596,7 @@ BOOL SetDeskPattern(void); BOOL SetDeskWallPaper(LPSTR); BOOL SetErrorMode(WORD); BOOL SetMenu(HWND,HMENU); -BOOL SetMenuItemBitmaps(HMENU,WORD,WORD,HBITMAP,HBITMAP); +BOOL SetMenuItemBitmaps(HMENU,UINT,UINT,HBITMAP,HBITMAP); BOOL SetMessageQueue(int); BOOL SetProp(HWND,SEGPTR,HANDLE); BOOL SetViewportExtEx(HDC,short,short,LPSIZE); @@ -2606,7 +2611,7 @@ BOOL StretchBlt(HDC,short,short,short,short,HDC,short,short,short,short,DWORD); BOOL SubtractRect(LPRECT,LPRECT,LPRECT); BOOL SwapMouseButton(BOOL); BOOL TextOut(HDC,short,short,LPSTR,short); -BOOL TrackPopupMenu(HMENU,WORD,short,short,short,HWND,LPRECT); +BOOL TrackPopupMenu(HMENU,UINT,short,short,short,HWND,LPRECT); BOOL TranslateMDISysAccel(HWND,LPMSG); BOOL TranslateMessage(LPMSG); BOOL UnhookWindowsHook(short,FARPROC); @@ -2628,7 +2633,8 @@ DWORD GetAspectRatioFilter(HDC); DWORD GetBitmapDimension(HBITMAP); DWORD GetBrushOrg(HDC); DWORD GetCurrentPosition(HDC); -DWORD GetCurrentTime(void); +/*DWORD GetCurrentTime(void);*/ +#define GetCurrentTime GetTickCount DWORD GetDCOrg(HDC); DWORD GetDialogBaseUnits(void); DWORD GetFreeSpace(WORD); @@ -2648,7 +2654,11 @@ DWORD GetWindowExt(HDC); DWORD GetWindowOrg(HDC); DWORD GlobalCompact(DWORD); DWORD GlobalDOSAlloc(DWORD); -DWORD GlobalHandle(WORD); +#ifdef WINELIB32 +HGLOBAL GlobalHandle(LPCVOID); +#else +DWORD GlobalHandle(UINT); +#endif DWORD GlobalSize(HGLOBAL); DWORD MoveTo(HDC,short,short); DWORD OemKeyScan(WORD); @@ -2666,6 +2676,7 @@ DWORD SetViewportOrg(HDC,short,short); DWORD SetWindowExt(HDC,short,short); DWORD SetWindowOrg(HDC,short,short); DWORD SizeofResource(HANDLE,HRSRC); +FARPROC GetMouseEventProc(void); FARPROC GetProcAddress(HANDLE,SEGPTR); FARPROC LocalNotify(FARPROC); FARPROC MakeProcInstance(FARPROC,HANDLE); @@ -2758,8 +2769,8 @@ HPEN CreatePen(short,short,COLORREF); HPEN CreatePenIndirect(LOGPEN*); HRGN CreateEllipticRgn(short,short,short,short); HRGN CreateEllipticRgnIndirect(LPRECT); -HRGN CreatePolyPolygonRgn(LPPOINT,LPINT,short,short); -HRGN CreatePolygonRgn(LPPOINT,short,short); +HRGN CreatePolyPolygonRgn(LPPOINT,LPINT,INT,INT); +HRGN CreatePolygonRgn(LPPOINT,INT,INT); HRGN CreateRectRgn(short,short,short,short); HRGN CreateRectRgnIndirect(LPRECT); HRGN CreateRoundRectRgn(short,short,short,short,short,short); @@ -2869,15 +2880,15 @@ WORD GetAtomName(ATOM,LPSTR,short); WORD GetBkMode(HDC); WORD GetCaretBlinkTime(void); WORD GetClassWord(HWND,short); -WORD GetCommEventMask(int,int); +UINT GetCommEventMask(int,int); WORD GetDlgItemInt(HWND,WORD,BOOL*,BOOL); WORD GetDoubleClickTime(void); WORD GetDriveType(INT); WORD GetInternalWindowPos(HWND,LPRECT,LPPOINT); WORD GetMapMode(HDC); WORD GetMenuItemCount(HMENU); -WORD GetMenuItemID(HMENU,int); -WORD GetMenuState(HMENU,WORD,WORD); +UINT GetMenuItemID(HMENU,int); +UINT GetMenuState(HMENU,UINT,UINT); WORD GetNearestPaletteIndex(HPALETTE,DWORD); WORD GetNumTasks(void); WORD GetPaletteEntries(HPALETTE,WORD,WORD,LPPALETTEENTRY); @@ -2887,12 +2898,12 @@ WORD GetProfileInt(LPSTR,LPSTR,int); WORD GetROP2(HDC); WORD GetRelAbs(HDC); WORD GetStretchBltMode(HDC); -WORD GetSystemDirectory(LPSTR,WORD); +UINT GetSystemDirectory(LPSTR,UINT); WORD GetSystemPaletteEntries(HDC,WORD,WORD,LPPALETTEENTRY); WORD GetSystemPaletteUse(HDC); WORD GetTextAlign(HDC); WORD GetWindowWord(HWND,short); -WORD GetWindowsDirectory(LPSTR,WORD); +UINT GetWindowsDirectory(LPSTR,UINT); WORD GlobalDOSFree(WORD); WORD GlobalFlags(HGLOBAL); WORD GlobalGetAtomName(ATOM,LPSTR,short); @@ -2927,7 +2938,7 @@ WORD SetTextAlign(HDC,WORD); WORD SetTimer(HWND,WORD,WORD,FARPROC); WORD SetWindowWord(HWND,short,WORD); WORD VkKeyScan(WORD); -WORD* SetCommEventMask(int,WORD); +UINT* SetCommEventMask(int,UINT); int BuildCommDCB(LPSTR,DCB*); int Catch(LPCATCHBUF); int ClearCommBreak(int); @@ -2969,7 +2980,7 @@ int GetKBCodePage(void); int GetKeyNameText(LONG,LPSTR,int); int GetKeyState(int); int GetKeyboardType(int); -int GetMenuString(HMENU,WORD,LPSTR,short,WORD); +int GetMenuString(HMENU,UINT,LPSTR,short,UINT); int GetModuleFileName(HANDLE,LPSTR,short); int GetModuleUsage(HANDLE); int GetObject(HANDLE,int,LPSTR); @@ -2989,7 +3000,7 @@ int MessageBox(HWND,LPSTR,LPSTR,WORD); int MulDiv(int,int,int); int OffsetClipRgn(HDC,short,short); int OffsetRgn(HRGN,short,short); -int OpenComm(LPSTR,WORD,WORD); +int OpenComm(LPSTR,UINT,UINT); int OpenSound(void); int ProfInsChk(void); int ReadComm(int,LPSTR,int); diff --git a/include/wintypes.h b/include/wintypes.h index 348af36c13b..ff785d1f67c 100644 --- a/include/wintypes.h +++ b/include/wintypes.h @@ -9,32 +9,41 @@ # define WINELIB32 # endif # endif +#else +# ifdef WINELIB32 +# undef WINELIB16 +# define WINELIB +# endif +# ifdef WINELIB16 +# define WINELIB +# endif #endif -typedef short INT; -typedef unsigned short UINT; -#define UIFMT "%hu" typedef unsigned short WORD; typedef unsigned long DWORD; typedef unsigned short BOOL; typedef unsigned char BYTE; typedef long LONG; #ifdef WINELIB32 +typedef int INT; +typedef unsigned int UINT; +typedef short SHORT; typedef LONG WPARAM; +typedef void* HANDLE; +typedef void* NPVOID; +#define UIFMT "%u" +#define NPFMT "%p" #else +typedef short INT; +typedef unsigned short UINT; typedef UINT WPARAM; +typedef WORD HANDLE; +typedef WORD NPVOID; +#define UIFMT "%hu" +#define NPFMT "%04X" #endif typedef LONG LPARAM; typedef LONG LRESULT; -#ifdef WINELIB32 -typedef void* HANDLE; -typedef void* NPVOID; -#define NPFMT "%p" -#else -typedef WORD HANDLE; -typedef WORD NPVOID; -#define NPFMT "%04X" -#endif typedef DWORD HHOOK; typedef DWORD SEGPTR; typedef char *LPSTR; @@ -46,6 +55,7 @@ typedef WORD *LPWORD; typedef DWORD *LPDWORD; typedef LONG *LPLONG; typedef void *LPVOID; +typedef const void *LPCVOID; typedef WORD CATCHBUF[9]; typedef WORD *LPCATCHBUF; @@ -119,12 +129,12 @@ typedef FARPROC HOOKPROC; #define SELECTOROF(ptr) (HIWORD(ptr)) #define OFFSETOF(ptr) (LOWORD(ptr)) -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#ifndef MAX +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif #endif /* __WINE_WINTYPES_H */ diff --git a/include/xmalloc.h b/include/xmalloc.h new file mode 100644 index 00000000000..e8b183df6cd --- /dev/null +++ b/include/xmalloc.h @@ -0,0 +1,8 @@ +#ifdef HAVE_STDLIB_H +#include +#else +#define size_t unsigned int +#endif + +void *xmalloc (size_t); +void *xrealloc (void *, size_t); diff --git a/ipc/dde_proc.c b/ipc/dde_proc.c index df6e6a8aff9..c72f37103b4 100644 --- a/ipc/dde_proc.c +++ b/ipc/dde_proc.c @@ -28,6 +28,7 @@ #include "dde.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" int curr_proc_idx= -1; @@ -73,7 +74,7 @@ void dde_proc_add_fifo(int val) { fifo_element *created; - created= (fifo_element*) malloc( sizeof(fifo_element) ); + created= (fifo_element*) xmalloc( sizeof(fifo_element) ); created->value = val; created->next = NULL; diff --git a/ipc/shm_block.c b/ipc/shm_block.c index 259378f2bbe..6a5106b024a 100644 --- a/ipc/shm_block.c +++ b/ipc/shm_block.c @@ -24,6 +24,7 @@ #include "shm_block.h" #include "shm_semaph.h" #include "dde_proc.h" +#include "xmalloc.h" /* How each shmid is maped to local pointer */ /* Only attached shm blocks are in this construct */ @@ -79,7 +80,7 @@ struct shm_block *shm_attach_block(int shm_id, int proc_idx, block=(struct shm_block*)shmat(shm_id, NULL, 0); if (block==NULL || block == (struct shm_block*) -1) return NULL; - this=(struct local_shm_map *)malloc(sizeof(*this)); + this=(struct local_shm_map *)xmalloc(sizeof(*this)); this->next= shm_map; shm_map = this; this->shm_id= shm_id; diff --git a/ipc/shm_fragment_test.c b/ipc/shm_fragment_test.c index 896471543a2..708dad4fc35 100644 --- a/ipc/shm_fragment_test.c +++ b/ipc/shm_fragment_test.c @@ -16,6 +16,7 @@ #include #include "shm_block.h" #include "shm_fragment.h" +#include "xmalloc.h" #define DO_FREE(id) (-id) #define LIST_LENGTH 20 @@ -60,8 +61,7 @@ int main() static char *ptr[LIST_LENGTH]; - block=malloc(SHM_MINBLOCK); - assert(block); + block=xmalloc(SHM_MINBLOCK); /* setup first item in the free list */ shm_FragmentInit(block, sizeof(*block), SHM_MINBLOCK); diff --git a/loader/main.c b/loader/main.c index de7df1efb32..08ad7cd88ef 100644 --- a/loader/main.c +++ b/loader/main.c @@ -58,10 +58,10 @@ int MAIN_Init(void) /* Initialize Win32 relay code */ if (!RELAY32_Init()) return 0; -#endif /* Create built-in modules */ if (!MODULE_Init()) return 0; +#endif /* Initialize the DOS file system */ DOS_InitFS(); diff --git a/loader/module.c b/loader/module.c index e48ed033699..7186c931ca5 100644 --- a/loader/module.c +++ b/loader/module.c @@ -24,20 +24,22 @@ #include "debug.h" #include "callback.h" +#include "wine.h" static HMODULE hFirstModule = 0; static HMODULE hCachedModule = 0; /* Module cached by MODULE_OpenFile */ +static HANDLE hInitialStack32 = 0; /*********************************************************************** * MODULE_LoadBuiltin * * Load a built-in module. If the 'force' parameter is FALSE, we only * load the module if it has not been disabled via the -dll option. */ +#ifndef WINELIB /* JBP: Not really allowed in libwine.a (FIXME:?) */ static HMODULE MODULE_LoadBuiltin( LPCSTR name, BOOL force ) { -#ifndef WINELIB /* JBP: Not really allowed in libwine.a (FIXME:?) */ HMODULE hModule; NE_MODULE *pModule; SEGTABLEENTRY *pSegTable; @@ -91,7 +93,7 @@ static HMODULE MODULE_LoadBuiltin( LPCSTR name, BOOL force ) hFirstModule = hModule; return hModule; } - +#endif /*********************************************************************** * MODULE_Init @@ -102,6 +104,7 @@ BOOL MODULE_Init(void) { /* For these, built-in modules are always used */ +#ifndef WINELIB32 if (!MODULE_LoadBuiltin( "KERNEL", TRUE ) || !MODULE_LoadBuiltin( "GDI", TRUE ) || !MODULE_LoadBuiltin( "USER", TRUE ) || @@ -317,6 +320,7 @@ DWORD MODULE_AllocateSegment(WORD wFlags, WORD wSize, WORD wElem) /*********************************************************************** * MODULE_CreateSegments */ +#ifndef WINELIB32 static BOOL MODULE_CreateSegments( HMODULE hModule ) { SEGTABLEENTRY *pSegment; @@ -343,11 +347,13 @@ static BOOL MODULE_CreateSegments( HMODULE hModule ) (pModule->dgroup - 1) * sizeof(SEGTABLEENTRY) : 0; return TRUE; } +#endif /*********************************************************************** * MODULE_GetInstance */ +#ifndef WINELIB32 static HINSTANCE MODULE_GetInstance( HMODULE hModule ) { SEGTABLEENTRY *pSegment; @@ -360,6 +366,7 @@ static HINSTANCE MODULE_GetInstance( HMODULE hModule ) return pSegment->selector; } +#endif /*********************************************************************** @@ -795,7 +802,7 @@ LPSTR MODULE_GetModuleName( HMODULE hModule ) if (!(pModule = (NE_MODULE *)GlobalLock( hModule ))) return NULL; p = (BYTE *)pModule + pModule->name_table; - len = min( *p, 8 ); + len = MIN( *p, 8 ); memcpy( buffer, p + 1, len ); buffer[len] = '\0'; return buffer; @@ -1023,6 +1030,33 @@ HINSTANCE LoadModule( LPCSTR name, LPVOID paramBlock ) oldsp = IF1632_Saved16_sp; IF1632_Saved16_ss = pModule->self_loading_sel; IF1632_Saved16_sp = 0xFF00; + if (!IF1632_Stack32_base) { + STACK32FRAME* frame32; + char *stack32Top; + /* Setup an initial 32 bit stack frame */ + hInitialStack32 = GLOBAL_Alloc( GMEM_FIXED, 0x10000, + hModule, FALSE, FALSE, + FALSE ); + + /* Create the 32-bit stack frame */ + + *(DWORD *)GlobalLock(hInitialStack32) = 0xDEADBEEF; + stack32Top = (char*)GlobalLock(hInitialStack32) + + 0x10000; + frame32 = (STACK32FRAME *)stack32Top - 1; + frame32->saved_esp = (DWORD)stack32Top; + frame32->edi = 0; + frame32->esi = 0; + frame32->edx = 0; + frame32->ecx = 0; + frame32->ebx = 0; + frame32->ebp = 0; + frame32->retaddr = 0; + frame32->codeselector = WINE_CODE_SELECTOR; + /* pTask->esp = (DWORD)frame32; */ + IF1632_Stack32_base = WIN16_GlobalLock(hInitialStack32); + + } CallTo16_word_ww (selfloadheader->BootApp, pModule->self_loading_sel, hModule, fd); /* some BootApp procs overwrite the selector of dgroup */ @@ -1030,6 +1064,11 @@ HINSTANCE LoadModule( LPCSTR name, LPVOID paramBlock ) IF1632_Saved16_ss = oldss; IF1632_Saved16_sp = oldsp; for (i = 2; i <= pModule->seg_count; i++) NE_LoadSegment( hModule, i ); + if (hInitialStack32){ + GlobalUnlock (hInitialStack32); + GlobalFree (hInitialStack32); + IF1632_Stack32_base = hInitialStack32 = 0; + } } else { @@ -1229,13 +1268,28 @@ HANDLE WinExec( LPSTR lpCmdLine, WORD nCmdShow ) handle = LoadModule( filename, ¶ms ); if (handle == (HANDLE)2) /* file not found */ { + /* Check that the original file name did not have a suffix */ + p = strrchr(filename, '.'); + if (p && !(strchr(p, '/') || strchr(p, '\\'))) + return handle; /* filename already includes a suffix! */ strcat( filename, ".exe" ); handle = LoadModule( filename, ¶ms ); } GlobalFree( cmdShowHandle ); GlobalFree( cmdLineHandle ); - Yield(); /* program is executed immediatly ....needed for word */ + +#if 0 + if (handle < (HANDLE)32) /* Error? */ + return handle; + +/* FIXME: Yield never returns! + We may want to run more applications or start the debugger + before calling Yield. If we don't Yield will be called immdiately + after returning. Why is it needed for Word anyway? */ + Yield(); /* program is executed immediately ....needed for word */ + +#endif return handle; } diff --git a/loader/ne_image.c b/loader/ne_image.c index 9167a999d74..97748171989 100644 --- a/loader/ne_image.c +++ b/loader/ne_image.c @@ -24,6 +24,7 @@ #include "stackframe.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" /*********************************************************************** @@ -107,7 +108,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) but may be missing something. If you have any doco please either send it to me or fix the code yourself. gfm@werple.mira.net.au */ - char* buff = malloc(size); + char* buff = xmalloc(size); char* curr = buff; read(fd, buff, size); while(curr < buff + size) { @@ -137,7 +138,7 @@ BOOL NE_LoadSegment( HMODULE hModule, WORD segnum ) (char *)pModule + pModule->name_table + 1, segnum, pSeg->selector ); - reloc_entries = (struct relocation_entry_s *)malloc(count * sizeof(struct relocation_entry_s)); + reloc_entries = (struct relocation_entry_s *)xmalloc(count * sizeof(struct relocation_entry_s)); if (read( fd, reloc_entries, count * sizeof(struct relocation_entry_s)) != count * sizeof(struct relocation_entry_s)) { diff --git a/loader/pe_image.c b/loader/pe_image.c index 18117cd3eef..47c9d87fe34 100644 --- a/loader/pe_image.c +++ b/loader/pe_image.c @@ -28,6 +28,7 @@ #include "selectors.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" #define MAP_ANONYMOUS 0x20 @@ -184,17 +185,17 @@ HINSTANCE PE_LoadImage(struct w_files *wpnt) { int i, result; - wpnt->pe = malloc(sizeof(struct pe_data)); + wpnt->pe = xmalloc(sizeof(struct pe_data)); memset(wpnt->pe,0,sizeof(struct pe_data)); - wpnt->pe->pe_header = malloc(sizeof(struct pe_header_s)); + wpnt->pe->pe_header = xmalloc(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); + wpnt->pe->pe_seg = xmalloc(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); @@ -261,7 +262,7 @@ HINSTANCE PE_LoadModule(int fd, OFSTRUCT *ofs, LOADPARAMS* params) ALIAS_UseAliases=1; - wpnt=malloc(sizeof(struct w_files)); + wpnt=xmalloc(sizeof(struct w_files)); wpnt->next=wine_files; wine_files=wpnt; wpnt->ofs=*ofs; @@ -271,7 +272,7 @@ HINSTANCE PE_LoadModule(int fd, OFSTRUCT *ofs, LOADPARAMS* params) wpnt->hModule=0; wpnt->initialised=0; lseek(fd,0,SEEK_SET); - wpnt->mz_header=malloc(sizeof(struct mz_header_s)); + wpnt->mz_header=xmalloc(sizeof(struct mz_header_s)); read(fd,wpnt->mz_header,sizeof(struct mz_header_s)); size=sizeof(NE_MODULE) + diff --git a/loader/resource.c b/loader/resource.c index 7a5b4b171d1..437d8e20752 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -362,7 +362,7 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen) dprintf_resource( stddeb, "strlen = %d\n", (int)*p ); - i = min(buflen - 1, *p); + i = MIN(buflen - 1, *p); if (buffer == NULL) return i; if (i > 0) { diff --git a/loader/signal.c b/loader/signal.c index 3a560c5c78b..8a31b8d1716 100644 --- a/loader/signal.c +++ b/loader/signal.c @@ -18,6 +18,7 @@ #include "miscemu.h" #include "registers.h" #include "win.h" +#include "xmalloc.h" #if !defined(BSD4_4) || defined(linux) || defined(__FreeBSD__) char * cstack[4096]; @@ -57,8 +58,8 @@ static void win_fault(int signal, int code, struct sigcontext *context) { if (CS_reg(context) == WINE_CODE_SELECTOR) { - fprintf(stderr, "Segmentation fault in Wine program (%x:%lx)." - " Please debug\n", + fprintf(stderr, "Segmentation fault in Wine program (%04x:%08lx)." + " Please debug.\n", CS_reg(context), EIP_reg(context) ); } else if (INSTR_EmulateInstruction( context )) return; @@ -100,14 +101,10 @@ void init_wine_signals(void) struct sigaltstack ss; #if !defined (__FreeBSD__) - if ((ss.ss_base = malloc(MINSIGSTKSZ)) == NULL) { + ss.ss_base = xmalloc (MINSIGSTKSZ); #else - if ((ss.ss_sp = malloc(MINSIGSTKSZ)) == NULL) { + ss.ss_sp = xmalloc (MINSIGSTKSZ); #endif - fprintf(stderr, "Unable to allocate signal stack (%d bytes)\n", - MINSIGSTKSZ); - exit(1); - } ss.ss_size = MINSIGSTKSZ; ss.ss_flags = 0; if (sigaltstack(&ss, NULL) < 0) { diff --git a/memory/local.c b/memory/local.c index 9f215af5359..e20bd9c3354 100644 --- a/memory/local.c +++ b/memory/local.c @@ -328,7 +328,7 @@ BOOL LocalInit( HANDLE selector, WORD start, WORD end ) } ptr = PTR_SEG_OFF_TO_LIN( selector, 0 ); - start = LALIGN( max( start, sizeof(INSTANCEDATA) ) ); + start = LALIGN( MAX( start, sizeof(INSTANCEDATA) ) ); heapInfoArena = LALIGN(start + sizeof(LOCALARENA) ); freeArena = LALIGN( heapInfoArena + ARENA_HEADER_SIZE + sizeof(LOCALHEAPINFO) ); @@ -521,7 +521,7 @@ static HLOCAL LOCAL_GetBlock( WORD ds, WORD size, WORD flags ) } size += ARENA_HEADER_SIZE; - size = LALIGN( max( size, sizeof(LOCALARENA) ) ); + size = LALIGN( MAX( size, sizeof(LOCALARENA) ) ); /* Find a suitable free block */ arena = LOCAL_FindFreeBlock( ds, size ); @@ -740,6 +740,8 @@ HLOCAL LOCAL_ReAlloc( HANDLE ds, HLOCAL handle, WORD size, WORD flags ) WORD arena, newhandle, blockhandle; LONG nextarena; + if (!handle) return LOCAL_Alloc( ds, size, flags ); + dprintf_local( stddeb, "LocalReAlloc: %04x %d %04x ds=%04x\n", handle, size, flags, ds ); if (!(pInfo = LOCAL_GetHeap( ds ))) return 0; @@ -904,9 +906,9 @@ HLOCAL LocalAlloc( WORD flags, WORD size ) /*********************************************************************** * LocalReAlloc (KERNEL.6) */ -HLOCAL LocalReAlloc( HLOCAL handle, WORD flags, WORD size ) +HLOCAL LocalReAlloc( HLOCAL handle, WORD size, WORD flags ) { - return LOCAL_ReAlloc( CURRENT_DS, handle, flags, size ); + return LOCAL_ReAlloc( CURRENT_DS, handle, size, flags ); } diff --git a/misc/Makefile.in b/misc/Makefile.in index 778e331cd61..26ac02d4485 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -28,7 +28,8 @@ C_SRCS = \ stress.c \ user.c \ user32.c \ - winsocket.c + winsocket.c \ + xmalloc.c all: checkrc $(MODULE).o diff --git a/misc/clipboard.c b/misc/clipboard.c index d3df59d0ecb..68f5fe76c55 100644 --- a/misc/clipboard.c +++ b/misc/clipboard.c @@ -265,7 +265,7 @@ int GetClipboardFormatName(WORD wFormat, LPSTR retStr, short maxlen) if (lpFormat->Name == NULL) return 0; dprintf_clipboard(stddeb, "GetClipboardFormat // Name='%s' !\n", lpFormat->Name); - maxlen = min(maxlen - 1, strlen(lpFormat->Name)); + maxlen = MIN(maxlen - 1, strlen(lpFormat->Name)); dprintf_clipboard(stddeb,"GetClipboardFormat // maxlen=%d !\n", maxlen); memcpy(retStr, lpFormat->Name, maxlen); retStr[maxlen] = 0; diff --git a/misc/commdlg.c b/misc/commdlg.c index f85624fb61c..5b86ad3a3fa 100644 --- a/misc/commdlg.c +++ b/misc/commdlg.c @@ -171,9 +171,9 @@ static BOOL FILEDLG_ScanDir(HWND hWnd, LPSTR newPath) { char str[512],str2[512]; - strcpy(str,newPath); + strncpy(str,newPath,511); str[511]=0; SendDlgItemMessage(hWnd, edt1, WM_GETTEXT, 511, MAKE_SEGPTR(str2)); - strcat(str, str2); + strncat(str,str2,511-strlen(str)); str[511]=0; if (!DlgDirList(hWnd, str, lst1, 0, 0x0000)) return FALSE; DlgDirList(hWnd, "*.*", lst2, stc1, 0x8010); @@ -210,7 +210,7 @@ static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index) /*********************************************************************** * FILEDLG_WMDrawItem [internal] */ -static LONG FILEDLG_WMDrawItem(HWND hWnd, WORD wParam, LONG lParam) +static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam) { LPDRAWITEMSTRUCT lpdis = (LPDRAWITEMSTRUCT)PTR_SEG_TO_LIN(lParam); char str[512]; @@ -219,7 +219,7 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WORD wParam, LONG lParam) BITMAP bm; HDC hMemDC; - strcpy(str, ""); + str[0]=0; if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1) { hBrush = SelectObject(lpdis->hDC, GetStockObject(LTGRAY_BRUSH)); SelectObject(lpdis->hDC, hBrush); @@ -290,7 +290,7 @@ static LONG FILEDLG_WMDrawItem(HWND hWnd, WORD wParam, LONG lParam) /*********************************************************************** * FILEDLG_WMMeasureItem [internal] */ -static LONG FILEDLG_WMMeasureItem(HWND hWnd, WORD wParam, LONG lParam) +static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM wParam, LPARAM lParam) { BITMAP bm; LPMEASUREITEMSTRUCT lpmeasure; @@ -305,7 +305,7 @@ static LONG FILEDLG_WMMeasureItem(HWND hWnd, WORD wParam, LONG lParam) * FILEDLG_WMInitDialog [internal] */ -static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam) +static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam) { int n; LPOPENFILENAME lpofn; @@ -321,7 +321,7 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam) while(*pstr) { n = strlen(pstr); - strcpy(tmpstr, pstr); + strncpy(tmpstr, pstr, 511); tmpstr[511]=0; printf("lpstrCustomFilter // add tmpstr='%s' ", tmpstr); SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, MAKE_SEGPTR(tmpstr)); pstr += n + 1; @@ -335,7 +335,7 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam) while(*pstr) { n = strlen(pstr); - strcpy(tmpstr, pstr); + strncpy(tmpstr, pstr, 511); tmpstr[511]=0; printf("lpstrFilter // add tmpstr='%s' ", tmpstr); SendDlgItemMessage(hWnd, cmb1, CB_ADDSTRING, 0, MAKE_SEGPTR(tmpstr)); pstr += n + 1; @@ -347,8 +347,9 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam) if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL) lpofn->nFilterIndex = 1; SendDlgItemMessage(hWnd, cmb1, CB_SETCURSEL, lpofn->nFilterIndex - 1, 0); - strcpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter), - PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1)); + strncpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter), + PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),511); + tmpstr[511]=0; printf("nFilterIndex = %ld // SetText of edt1 to '%s'\n", lpofn->nFilterIndex, tmpstr); SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr)); @@ -358,7 +359,8 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam) /* read initial directory */ if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL) { - strcpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir)); + strncpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 510); + tmpstr[510]=0; if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\' && tmpstr[strlen(tmpstr)-1] != ':') strcat(tmpstr,"\\"); @@ -380,7 +382,7 @@ static LONG FILEDLG_WMInitDialog(HWND hWnd, WORD wParam, LONG lParam) /*********************************************************************** * FILEDLG_WMCommand [internal] */ -static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) +static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) { LONG lRet; LPOPENFILENAME lpofn; @@ -437,7 +439,7 @@ static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) pstr = FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter), PTR_SEG_TO_LIN(lpofn->lpstrFilter), lRet); - strcpy(tmpstr2, pstr); + strncpy(tmpstr2, pstr, 511); tmpstr2[511]=0; SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2)); FILEDLG_ScanDir(hWnd, tmpstr); return TRUE; @@ -456,13 +458,13 @@ static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) /* edit control contains wildcards */ if (pstr != NULL) { - strcpy(tmpstr2, pstr+1); + strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0; *(pstr+1) = 0; } else { strcpy(tmpstr2, tmpstr); - strcpy(tmpstr, ""); + *tmpstr=0; } printf("commdlg: %s, %s\n", tmpstr, tmpstr2); SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2)); @@ -478,10 +480,11 @@ static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) if (lRet == LB_ERR) return TRUE; lpofn->nFilterIndex = lRet + 1; printf("commdlg: lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex); - strcpy(tmpstr2, + strncpy(tmpstr2, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter), PTR_SEG_TO_LIN(lpofn->lpstrFilter), - lRet)); + lRet), 511); + tmpstr2[511]=0; SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2)); /* if ScanDir succeeds, we have changed the directory */ if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE; @@ -491,7 +494,7 @@ static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) { /* strip off the pathname */ *pstr = 0; - strcpy(tmpstr2, pstr+1); + strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0; SendDlgItemMessage(hWnd, edt1, WM_SETTEXT, 0, MAKE_SEGPTR(tmpstr2)); /* Should we MessageBox() if this fails? */ if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE; @@ -506,10 +509,11 @@ static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) tmpstr2[0] = 'A'+ drive; tmpstr2[1] = ':'; tmpstr2[2] = '\\'; - strcpy(tmpstr2 + 3, DOS_GetCurrentDir(drive)); + strncpy(tmpstr2 + 3, DOS_GetCurrentDir(drive), 510); tmpstr2[510]=0; if (strlen(tmpstr2) > 3) strcat(tmpstr2, "\\"); - strcat(tmpstr2, tmpstr); + strncat(tmpstr2, tmpstr, 511-strlen(tmpstr2)); tmpstr2[511]=0; + printf("strcpy'ing '%s'\n",tmpstr2); fflush(stdout); strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2); } lpofn->nFileOffset = 0; @@ -525,6 +529,7 @@ static LONG FILEDLG_WMCommand(HWND hWnd, WORD wParam, LONG lParam) lRet = SendDlgItemMessage(hWnd, lst1, LB_GETCURSEL, 0, 0); SendDlgItemMessage(hWnd, lst1, LB_GETTEXT, lRet, MAKE_SEGPTR(tmpstr)); + printf("strcpy'ing '%s'\n",tmpstr); fflush(stdout); strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFileTitle), tmpstr); } EndDialog(hWnd, TRUE); @@ -873,7 +878,7 @@ int GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf) break; } printf("\n---> '%s' ", &lpFile[i]); - len = min(cbBuf, strlen(&lpFile[i]) + 1); + len = MIN(cbBuf, strlen(&lpFile[i]) + 1); strncpy(lpTitle, &lpFile[i], len + 1); if (len != cbBuf) return len; diff --git a/misc/dos_fs.c b/misc/dos_fs.c index 66670589a85..13f52bf7b32 100644 --- a/misc/dos_fs.c +++ b/misc/dos_fs.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -35,6 +36,7 @@ #include "task.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" #ifndef WINE_INI_GLOBAL /* Get the WINE_INI_GLOBAL definition from autoconf.h */ @@ -765,13 +767,13 @@ char *WinIniFileName(void) if (name) return name; - name = malloc(1024); + name = xmalloc(1024); strcpy(name, DOS_GetUnixFileName(WindowsDirectory)); strcat(name, "/"); strcat(name, "win.ini"); - name = realloc(name, strlen(name) + 1); + name = xrealloc(name, strlen(name) + 1); return name; } @@ -858,9 +860,9 @@ struct dosdirent *DOS_opendir(char *dosdirname) for (x=0; x <= max_open_dirs; x++) { if (x == max_open_dirs) { if (DosDirs) { - DosDirs=(struct dosdirent*)realloc(DosDirs,(++max_open_dirs)*sizeof(DosDirs[0])); + DosDirs=(struct dosdirent*)xrealloc(DosDirs,(++max_open_dirs)*sizeof(DosDirs[0])); } else { - DosDirs=(struct dosdirent*)malloc(sizeof(DosDirs[0])); + DosDirs=(struct dosdirent*)xmalloc(sizeof(DosDirs[0])); max_open_dirs=1; } break; /* this one is definitely not in use */ diff --git a/misc/file.c b/misc/file.c index b9bcc062903..1d18e83b574 100644 --- a/misc/file.c +++ b/misc/file.c @@ -350,7 +350,7 @@ INT _lcreat (LPSTR lpszFilename, INT fnAttribute) /*************************************************************************** GetDriveType ***************************************************************************/ -UINT GetDriveType(INT drive) +WORD GetDriveType(INT drive) { dprintf_file(stddeb,"GetDriveType %c:\n",'A'+drive); diff --git a/misc/main.c b/misc/main.c index d8876a199a2..9de2fe72ab6 100644 --- a/misc/main.c +++ b/misc/main.c @@ -27,6 +27,7 @@ #define DEBUG_DEFINE_VARIABLES #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" const char people[] = "Wine is available thanks to the work of " "Bob Amstadt, Dag Asheim, Martin Ayotte, Ross Biro, Erik Bos, " @@ -125,11 +126,13 @@ static XrmOptionDescRec optionsTable[] = /*********************************************************************** * MAIN_Usage */ +#ifndef WINELIB32 static void MAIN_Usage( char *name ) { fprintf( stderr, USAGE, name ); exit(1); } +#endif /*********************************************************************** @@ -165,8 +168,8 @@ static int MAIN_GetResource( XrmDatabase db, char *name, XrmValue *value ) char *dummy; int retval; - buff_instance = (char *)malloc(strlen(Options.programName)+strlen(name)+1); - buff_class = (char *)malloc( strlen(WINE_CLASS) + strlen(name) + 1 ); + buff_instance = (char *)xmalloc(strlen(Options.programName)+strlen(name)+1); + buff_class = (char *)xmalloc( strlen(WINE_CLASS) + strlen(name) + 1 ); strcpy( buff_instance, Options.programName ); strcat( buff_instance, name ); @@ -299,7 +302,7 @@ static void MAIN_ParseOptions( int *argc, char *argv[] ) if (!(display = XOpenDisplay( display_name ))) { fprintf( stderr, "%s: Can't open display: %s\n", - argv[0], display_name ? display_name : "" ); + argv[0], display_name ? display_name : "(none specified)" ); exit(1); } @@ -588,7 +591,11 @@ LONG GetWinFlags(void) { WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486 }; /* There doesn't seem to be any Pentium flag. */ - long cpuflag = cpuflags[min (runtime_cpu (), 4)]; +#ifndef WINELIB + long cpuflag = cpuflags[MIN (runtime_cpu (), 4)]; +#else + long cpuflag = cpuflags[4]; +#endif if (Options.enhanced) return (WF_ENHANCED | cpuflag | WF_PMODE | WF_80x87 | WF_PAGING); @@ -685,7 +692,7 @@ int GetEnvironment(LPSTR lpPortName, LPSTR lpEnviron, WORD nMaxSiz) lpPortName, lpEnviron, nMaxSiz); while (lpEnv != NULL) { if (lpEnv->Name != NULL && strcmp(lpEnv->Name, lpPortName) == 0) { - nCount = min(nMaxSiz, lpEnv->wSize); + nCount = MIN(nMaxSiz, lpEnv->wSize); memcpy(lpEnviron, lpEnv->Value, nCount); printf("GetEnvironnement() // found '%s' !\n", lpEnviron); return nCount; diff --git a/misc/ole2nls.c b/misc/ole2nls.c index 5915ce8d828..f0dc52fe093 100644 --- a/misc/ole2nls.c +++ b/misc/ole2nls.c @@ -317,6 +317,108 @@ LOCVAL(LOCALE_INEGSEPBYSPACE) */ #endif /* LANG(De) */ +#if #LANG(Da) +/* LOCVAL(LOCALE_ILANGUAGE,"9") */ +LOCVAL(LOCALE_SLANGUAGE,"Dansk") +LOCVAL(LOCALE_SENGLANGUAGE,"Danish") +LOCVAL(LOCALE_SABBREVLANGNAME,"dan") +LOCVAL(LOCALE_SNATIVELANGNAME,"Dansk") +LOCVAL(LOCALE_ICOUNTRY,"45") +LOCVAL(LOCALE_SCOUNTRY,"Danmark") +LOCVAL(LOCALE_SENGCOUNTRY,"Denmark") +LOCVAL(LOCALE_SABBREVCTRYNAME,"Da") +LOCVAL(LOCALE_SNATIVECTRYNAME,"Danmark") +/* LOCVAL(LOCALE_IDEFAULTLANGUAGE,"9") */ +LOCVAL(LOCALE_IDEFAULTCOUNTRY,"45") +/* LOCVAL(LOCALE_IDEFAULTCODEPAGE) */ +/* LOCVAL(LOCALE_IDEFAULTANSICODEPAGE) */ +LOCVAL(LOCALE_SLIST,";") +LOCVAL(LOCALE_IMEASURE,"0") +LOCVAL(LOCALE_SDECIMAL,",") +LOCVAL(LOCALE_STHOUSAND,".") +/* LOCVAL(LOCALE_SGROUPING) */ +LOCVAL(LOCALE_IDIGITS,"2") +LOCVAL(LOCALE_ILZERO,"1") +/* LOCVAL(LOCALE_INEGNUMBER) */ +/* LOCVAL(LOCALE_SNATIVEDIGITS) */ +LOCVAL(LOCALE_SCURRENCY,"kr") +/* LOCVAL(LOCALE_SINTLSYMBOL) */ +LOCVAL(LOCALE_SMONDECIMALSEP,",") +LOCVAL(LOCALE_SMONTHOUSANDSEP,".") +/* LOCVAL(LOCALE_SMONGROUPING) */ +LOCVAL(LOCALE_ICURRDIGITS,"2") +/* LOCVAL(LOCALE_IINTLCURRDIGITS) */ +LOCVAL(LOCALE_ICURRENCY,"3") +LOCVAL(LOCALE_INEGCURR,"8") +LOCVAL(LOCALE_SDATE,".") +LOCVAL(LOCALE_STIME,":") +LOCVAL(LOCALE_SSHORTDATE,"dd/MM-yyyy") +LOCVAL(LOCALE_SLONGDATE,"ddd, d. MMMM yyyy") +/* LOCVAL(LOCALE_STIMEFORMAT) */ +LOCVAL(LOCALE_IDATE,"1") +/* LOCVAL(LOCALE_ILDATE) */ +LOCVAL(LOCALE_ITIME,"1") +/* LOCVAL(LOCALE_ITIMEMARKPOSN) */ +/* LOCVAL(LOCALE_ICENTURY) */ +LOCVAL(LOCALE_ITLZERO,"1") +/* LOCVAL(LOCALE_IDAYLZERO) */ +/* LOCVAL(LOCALE_IMONLZERO) */ +/* LOCVAL(LOCALE_S1159) */ +/* LOCVAL(LOCALE_S2359) */ +/* LOCVAL(LOCALE_ICALENDARTYPE) */ +/* LOCVAL(LOCALE_IOPTIONALCALENDAR) */ +/* LOCVAL(LOCALE_IFIRSTDAYOFWEEK) */ +/* LOCVAL(LOCALE_IFIRSTWEEKOFYEAR) */ +LOCVAL(LOCALE_SDAYNAME1,"Mandag") +LOCVAL(LOCALE_SDAYNAME2,"Tirsdag") +LOCVAL(LOCALE_SDAYNAME3,"Onsdag") +LOCVAL(LOCALE_SDAYNAME4,"Torsdag") +LOCVAL(LOCALE_SDAYNAME5,"Fredag") +LOCVAL(LOCALE_SDAYNAME6,"Lørdag") +LOCVAL(LOCALE_SDAYNAME7,"Søndag") +LOCVAL(LOCALE_SABBREVDAYNAME1,"Ma") +LOCVAL(LOCALE_SABBREVDAYNAME2,"Ti") +LOCVAL(LOCALE_SABBREVDAYNAME3,"On") +LOCVAL(LOCALE_SABBREVDAYNAME4,"To") +LOCVAL(LOCALE_SABBREVDAYNAME5,"Fr") +LOCVAL(LOCALE_SABBREVDAYNAME6,"Lø") +LOCVAL(LOCALE_SABBREVDAYNAME7,"Sø") +LOCVAL(LOCALE_SMONTHNAME1,"Januar") +LOCVAL(LOCALE_SMONTHNAME2,"Februar") +LOCVAL(LOCALE_SMONTHNAME3,"Marts") +LOCVAL(LOCALE_SMONTHNAME4,"April") +LOCVAL(LOCALE_SMONTHNAME5,"Maj") +LOCVAL(LOCALE_SMONTHNAME6,"Juni") +LOCVAL(LOCALE_SMONTHNAME7,"Juli") +LOCVAL(LOCALE_SMONTHNAME8,"August") +LOCVAL(LOCALE_SMONTHNAME9,"September") +LOCVAL(LOCALE_SMONTHNAME10,"Oktober") +LOCVAL(LOCALE_SMONTHNAME11,"November") +LOCVAL(LOCALE_SMONTHNAME12,"December") +LOCVAL(LOCALE_SMONTHNAME13,"") +LOCVAL(LOCALE_SABBREVMONTHNAME1,"Jan") +LOCVAL(LOCALE_SABBREVMONTHNAME2,"Feb") +LOCVAL(LOCALE_SABBREVMONTHNAME3,"Mar") +LOCVAL(LOCALE_SABBREVMONTHNAME4,"Apr") +LOCVAL(LOCALE_SABBREVMONTHNAME5,"Maj") +LOCVAL(LOCALE_SABBREVMONTHNAME6,"Jun") +LOCVAL(LOCALE_SABBREVMONTHNAME7,"Jul") +LOCVAL(LOCALE_SABBREVMONTHNAME8,"Aug") +LOCVAL(LOCALE_SABBREVMONTHNAME9,"Sep") +LOCVAL(LOCALE_SABBREVMONTHNAME10,"Okt") +LOCVAL(LOCALE_SABBREVMONTHNAME11,"Nov") +LOCVAL(LOCALE_SABBREVMONTHNAME12,"Dec") +LOCVAL(LOCALE_SABBREVMONTHNAME13,"") +/* LOCVAL(LOCALE_SPOSITIVESIGN) */ +/* LOCVAL(LOCALE_SNEGATIVESIGN) */ +/* LOCVAL(LOCALE_IPOSSIGNPOSN) */ +/* LOCVAL(LOCALE_INEGSIGNPOSN) */ +/* LOCVAL(LOCALE_IPOSSYMPRECEDES) */ +/* LOCVAL(LOCALE_IPOSSEPBYSPACE) */ +/* LOCVAL(LOCALE_INEGSYMPRECEDES) */ +/* LOCVAL(LOCALE_INEGSEPBYSPACE) */ +#endif /* LANG(Da) */ + /*Insert other languages here*/ diff --git a/misc/profile.c b/misc/profile.c index d9067b1817c..7dce5121627 100644 --- a/misc/profile.c +++ b/misc/profile.c @@ -29,9 +29,9 @@ static char Copyright [] = "Copyright (C) 1993 Miguel de Icaza"; #include "stddebug.h" /* #define DEBUG_PROFILE */ #include "debug.h" +#include "xmalloc.h" #define STRSIZE 255 -#define xmalloc(x) malloc(x) #define overflow (next == &CharBuffer [STRSIZE-1]) enum { FirstBrace, OnSecHeader, IgnoreToEOL, KeyDef, KeyValue }; @@ -101,6 +101,8 @@ static TSecHeader *load (char *filename, char **pfullname) char c; char path[MAX_PATH+1]; + *pfullname = NULL; + /* Try the Windows directory */ GetWindowsDirectory(path, sizeof(path)); @@ -126,6 +128,7 @@ static TSecHeader *load (char *filename, char **pfullname) } if (f == NULL) { fprintf(stderr, "profile.c: load() can't find file %s\n", filename); + /* FIXME: we ought to create it now (in which directory?) */ return NULL; } @@ -276,7 +279,7 @@ static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName, dprintf_profile(stddeb,"GetSetProfile // No more storage for enum !\n"); return (Size - 2); } - slen = min(strlen(key->KeyName) + 1, left); + slen = MIN(strlen(key->KeyName) + 1, left); dprintf_profile(stddeb,"GetSetProfile // strncpy(%p, %p, %d);\n", ReturnedString, key->Value, slen); strncpy (p, key->KeyName, slen); @@ -298,7 +301,7 @@ static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName, Current->changed=TRUE; return 1; } - slen = min(strlen(key->Value), Size - 1); + slen = MIN(strlen(key->Value), Size - 1); ReturnedString[slen] = 0; strncpy (ReturnedString, key->Value, slen); dprintf_profile(stddeb,"GetSetProfile // Return ``%s''\n", ReturnedString); @@ -310,7 +313,7 @@ static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName, if (set) { new_key (section, KeyName, Default); } else { - int slen = min(strlen(Default), Size - 1); + int slen = MIN(strlen(Default), Size - 1); ReturnedString[slen] = 0; strncpy(ReturnedString, Default, slen); dprintf_profile(stddeb,"GetSetProfile // Key not found\n"); @@ -327,7 +330,7 @@ static short GetSetProfile (int set, LPSTR AppName, LPSTR KeyName, Current->Section = section; Current->changed = TRUE; } else { - int slen = min(strlen(Default), Size - 1); + int slen = MIN(strlen(Default), Size - 1); ReturnedString[slen] = 0; strncpy(ReturnedString, Default, slen); dprintf_profile(stddeb,"GetSetProfile // Section not found\n"); @@ -418,7 +421,7 @@ static void dump_profile (TProfile *p) dump_profile (p->link); if(!p->changed) return; - if ((profile = fopen (p->FullName, "w")) != NULL){ + if (p->FullName && (profile = fopen (p->FullName, "w")) != NULL){ dump_sections (profile, p->Section); fclose (profile); } diff --git a/misc/rect.c b/misc/rect.c index 0b5133bca4e..c5d79854350 100644 --- a/misc/rect.c +++ b/misc/rect.c @@ -8,9 +8,6 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "windows.h" -#define MIN(a,b) ((a) < (b) ? (a) : (b)) -#define MAX(a,b) ((a) > (b) ? (a) : (b)) - /*********************************************************************** * SetRect (USER.72) diff --git a/misc/shell.c b/misc/shell.c index 12822f1f464..86d60ee7b05 100644 --- a/misc/shell.c +++ b/misc/shell.c @@ -18,6 +18,7 @@ #include "win.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" LPKEYSTRUCT lphRootKey = NULL,lphTopKey = NULL; @@ -111,7 +112,7 @@ SHELL_SaveRegistry(void) { * (HKEY_LOCAL_MACHINE,HKEY_CURRENT_USER or whatever) * -choose better filename(s) */ - _SaveKey(HKEY_CLASSES_ROOT,"/tmp/winereg"); + _SaveKey((HKEY)HKEY_CLASSES_ROOT,"/tmp/winereg"); } #define BUFSIZE 256 @@ -139,10 +140,10 @@ _LoadLevel(FILE *f,LPKEYSTRUCT lpKey,int tabsexp,char *buf) { lpNewKey=lpKey->lpSubLvl=(LPKEYSTRUCT)GlobalLock(hNewKey); lpNewKey->hKey = hNewKey; lpNewKey->dwType = 0; - lpNewKey->lpSubKey = - lpNewKey->lpValue = - lpNewKey->lpSubLvl = - lpNewKey->lpNextKey = + lpNewKey->lpSubKey = NULL; + lpNewKey->lpValue = NULL; + lpNewKey->lpSubLvl = NULL; + lpNewKey->lpNextKey = NULL; lpNewKey->lpPrevKey = NULL; if (NULL!=(t=strchr(s,'='))) { *t='\0';t++; @@ -165,9 +166,9 @@ _LoadLevel(FILE *f,LPKEYSTRUCT lpKey,int tabsexp,char *buf) { lpNewKey->lpPrevKey = lpKey; lpNewKey->hKey = hNewKey; lpNewKey->dwType = 0; - lpNewKey->lpSubKey = - lpNewKey->lpValue = - lpNewKey->lpSubLvl = + lpNewKey->lpSubKey = NULL; + lpNewKey->lpValue = NULL; + lpNewKey->lpSubLvl = NULL; lpNewKey->lpNextKey = NULL; if (NULL!=(t=strchr(s,'='))) { *t='\0';t++; @@ -209,7 +210,7 @@ SHELL_LoadRegistry(void) { dwRet=SHELL_RegCheckForRoot(); if (dwRet!=ERROR_SUCCESS) return;/*very bad magic, if we can't even allocate the rootkeys*/ - _LoadKey(HKEY_CLASSES_ROOT,"/tmp/winereg"); + _LoadKey((HKEY)HKEY_CLASSES_ROOT,"/tmp/winereg"); } /************************************************************************* @@ -386,7 +387,7 @@ LONG RegSetValue(HKEY hKey, LPCSTR lpSubKey, DWORD dwType, lpKey = (LPKEYSTRUCT)GlobalLock(hRetKey); if (lpKey == NULL) return ERROR_BADKEY; if (lpKey->lpValue != NULL) free(lpKey->lpValue); - lpKey->lpValue = malloc(strlen(lpVal) + 1); + lpKey->lpValue = xmalloc(strlen(lpVal) + 1); strcpy(lpKey->lpValue, lpVal); dprintf_reg(stddeb,"RegSetValue // successful key='%s' val='%s' !\n", lpSubKey, lpKey->lpValue); return ERROR_SUCCESS; @@ -458,7 +459,7 @@ LONG RegEnumKey(HKEY hKey, DWORD dwSubKey, LPSTR lpBuf, DWORD dwSize) lpKey = lpKey->lpSubLvl; while(lpKey != NULL){ if (!dwSubKey){ - len = min(dwSize-1,strlen(lpKey->lpSubKey)); + len = MIN(dwSize-1,strlen(lpKey->lpSubKey)); strncpy(lpBuf,lpKey->lpSubKey,len); lpBuf[len] = 0; dprintf_reg(stddeb, "RegEnumKey: found %s\n",lpBuf); @@ -479,7 +480,7 @@ void DragAcceptFiles(HWND hWnd, BOOL b) { /* flips WS_EX_ACCEPTFILES bit according to the value of b (TRUE or FALSE) */ - dprintf_reg(stddeb,"DragAcceptFiles(%04x, %u) old exStyle %08lx\n",hWnd,b,GetWindowLong(hWnd,GWL_EXSTYLE)); + dprintf_reg(stddeb,"DragAcceptFiles("NPFMT", %u) old exStyle %08lx\n",hWnd,b,GetWindowLong(hWnd,GWL_EXSTYLE)); SetWindowLong(hWnd,GWL_EXSTYLE,GetWindowLong(hWnd,GWL_EXSTYLE) | b*(LONG)WS_EX_ACCEPTFILES); } @@ -498,7 +499,7 @@ UINT DragQueryFile(HDROP hDrop, WORD wFile, LPSTR lpszFile, WORD wLength) LPSTR lpCurrent; WORD i; - dprintf_reg(stddeb,"DragQueryFile(%04x, %i, %p, %u)\n", + dprintf_reg(stddeb,"DragQueryFile("NPFMT", %i, %p, %u)\n", hDrop,wFile,lpszFile,wLength); lpDropFileStruct = (LPDROPFILESTRUCT) GlobalLock(hDrop); @@ -610,7 +611,7 @@ HINSTANCE ShellExecute(HWND hWnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpPa strcat(cmd,lpFile); } else { char *s; - s=malloc(len+strlen(lpFile)+10); + s=xmalloc(len+strlen(lpFile)+10); strncpy(s,cmd,t-cmd); s[t-cmd]='\0'; strcat(s,lpFile); diff --git a/misc/spy.c b/misc/spy.c index eba14fe49ea..2d4c4306112 100644 --- a/misc/spy.c +++ b/misc/spy.c @@ -408,14 +408,14 @@ void EnterSpyMessage(int iFlag, HWND hWnd, WORD msg, WORD wParam, LONG lParam) if(msg <= WM_USER) { if(MessageTypeNames[msg]) - dprintf_message(stddeb,"(%04x) message [%04x] %s dispatched wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"("NPFMT") message [%04x] %s dispatched wp=%04x lp=%08lx\n", hWnd, msg, MessageTypeNames[msg], wParam, lParam); else - dprintf_message(stddeb,"(%04x) message [%04x] dispatched wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"("NPFMT") message [%04x] dispatched wp=%04x lp=%08lx\n", hWnd, msg, wParam, lParam); } else - dprintf_message(stddeb,"(%04x) message [%04x] WM_USER+%04d dispatched wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"("NPFMT") message [%04x] WM_USER+%04d dispatched wp=%04x lp=%08lx\n", hWnd, msg, msg-WM_USER ,wParam ,lParam); break; case SPY_SENDMESSAGE: @@ -425,27 +425,27 @@ void EnterSpyMessage(int iFlag, HWND hWnd, WORD msg, WORD wParam, LONG lParam) lpstrSpyMessageFrom = lpstrSpyMessageFromWine; else { - sprintf(lpstrSpyMessageFromTask, "task %04x", hTask); + sprintf(lpstrSpyMessageFromTask, "task "NPFMT, hTask); lpstrSpyMessageFrom = lpstrSpyMessageFromTask; } if(msg <= WM_USER) { if(MessageTypeNames[msg]) - dprintf_message(stddeb,"%s(%04x) message [%04x] %s sent from %s wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"%s("NPFMT") message [%04x] %s sent from %s wp=%04x lp=%08lx\n", lpstrSpyMessageIndent, hWnd, msg, MessageTypeNames[msg], lpstrSpyMessageFrom, wParam, lParam); else - dprintf_message(stddeb,"%s(%04x) message [%04x] sent from %s wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"%s("NPFMT") message [%04x] sent from %s wp=%04x lp=%08lx\n", lpstrSpyMessageIndent, hWnd, msg, lpstrSpyMessageFrom, wParam, lParam); } else - dprintf_message(stddeb,"%s(%04x) message [%04x] WM_USER+%04x sent from %s wp=%04x lp=%08lx\n", + dprintf_message(stddeb,"%s("NPFMT") message [%04x] WM_USER+%04x sent from %s wp=%04x lp=%08lx\n", lpstrSpyMessageIndent, hWnd, msg, msg-WM_USER, lpstrSpyMessageFrom, @@ -461,15 +461,15 @@ void EnterSpyMessage(int iFlag, HWND hWnd, WORD msg, WORD wParam, LONG lParam) case SPY_DEFWNDPROC: if(msg <= WM_USER) if(MessageTypeNames[msg]) - dprintf_message(stddeb, "%s(%04x) DefWindowProc: %s [%04x] wp=%04x lp=%08lx\n", + dprintf_message(stddeb, "%s("NPFMT") DefWindowProc: %s [%04x] wp=%04x lp=%08lx\n", lpstrSpyMessageIndent, hWnd, MessageTypeNames[msg], msg, wParam, lParam ); else - dprintf_message(stddeb, "%s(%04x) DefWindowProc: [%04x] wp=%04x lp=%08lx\n", + dprintf_message(stddeb, "%s("NPFMT") DefWindowProc: [%04x] wp=%04x lp=%08lx\n", lpstrSpyMessageIndent, hWnd, msg, wParam, lParam ); else - dprintf_message(stddeb, "%s(%04x) DefWindowProc: WM_USER+%d [%04x] wp=%04x lp=%08lx\n", + dprintf_message(stddeb, "%s("NPFMT") DefWindowProc: WM_USER+%d [%04x] wp=%04x lp=%08lx\n", lpstrSpyMessageIndent, hWnd, msg - WM_USER, msg, wParam, lParam ); break; @@ -493,11 +493,11 @@ void ExitSpyMessage(int iFlag, HWND hWnd, WORD msg, LONG lReturn) switch(iFlag) { case SPY_RESULT_INVALIDHWND: - dprintf_message(stddeb,"%s(%04x) message [%04x] HAS INVALID HWND\n", + dprintf_message(stddeb,"%s("NPFMT") message [%04x] HAS INVALID HWND\n", lpstrSpyMessageIndent, hWnd, msg); break; case SPY_RESULT_OK: - dprintf_message(stddeb,"%s(%04x) message [%04x] returned %08lx\n", + dprintf_message(stddeb,"%s("NPFMT") message [%04x] returned %08lx\n", lpstrSpyMessageIndent, hWnd, msg, lReturn); break; default: diff --git a/misc/user32.c b/misc/user32.c index 5a4c02f9853..b91b7498652 100644 --- a/misc/user32.c +++ b/misc/user32.c @@ -115,7 +115,7 @@ HDC USER32_BeginPaint(DWORD hwnd,struct WIN32_PAINTSTRUCT *lpps) BOOL USER32_EndPaint(DWORD hwnd,struct WIN32_PAINTSTRUCT *lpps) { PAINTSTRUCT ps; - ps.hdc=lpps->hdc; + ps.hdc=(HDC)lpps->hdc; ps.fErase=lpps->fErase; ps.rcPaint.top=lpps->rcPaint.top; ps.rcPaint.left=lpps->rcPaint.left; diff --git a/misc/winsocket.c b/misc/winsocket.c index 23675a1c9de..52baf78e6cf 100644 --- a/misc/winsocket.c +++ b/misc/winsocket.c @@ -91,7 +91,9 @@ struct WinSockHeap { }; static struct WinSockHeap *Heap; static HANDLE HeapHandle; +#ifndef WINELIB32 static int ScratchPtr; +#endif #ifndef WINELIB #define GET_SEG_PTR(x) MAKELONG((int)((char*)(x)-(char*)Heap), \ @@ -110,6 +112,7 @@ static int ScratchPtr; inet_ntoa(((struct sockaddr_in *)a)->sin_addr), \ ntohs(((struct sockaddr_in *)a)->sin_port)) +#ifndef WINELIB32 static void ResetScratch() { ScratchPtr=0; @@ -131,6 +134,7 @@ static SEGPTR scratch_strdup(char * s) strcpy(ret,s); return GET_SEG_PTR(ret); } +#endif static WORD wsaerrno(void) { @@ -141,7 +145,7 @@ static WORD wsaerrno(void) errno, sys_errlist[errno]); #else fprintf(stderr, "winsock: errno %d, (%s).\n", - errno, strerror(errno)); + errno, strerror(errno)); #endif #else fprintf(stderr, "winsock: errno %d\n", errno); @@ -151,6 +155,7 @@ static WORD wsaerrno(void) switch(errno) { case EINTR: return WSAEINTR; + case EBADF: return WSAEBADF; case EACCES: return WSAEACCES; case EFAULT: return WSAEFAULT; case EINVAL: return WSAEINVAL; @@ -158,7 +163,6 @@ static WORD wsaerrno(void) case EWOULDBLOCK: return WSAEWOULDBLOCK; case EINPROGRESS: return WSAEINPROGRESS; case EALREADY: return WSAEALREADY; - case EBADF: case ENOTSOCK: return WSAENOTSOCK; case EDESTADDRREQ: return WSAEDESTADDRREQ; case EMSGSIZE: return WSAEMSGSIZE; @@ -195,6 +199,8 @@ static WORD wsaerrno(void) case EDQUOT: return WSAEDQUOT; case ESTALE: return WSAESTALE; case EREMOTE: return WSAEREMOTE; +/* just in case we ever get here and there are no problems */ + case 0: return 0; #ifdef EDQUOT default: @@ -209,9 +215,50 @@ static void errno_to_wsaerrno(void) wsa_errno = wsaerrno(); } + +static WORD wsaherrno(void) +{ +#if DEBUG_WINSOCK +#ifndef sun +#if defined(__FreeBSD__) + fprintf(stderr, "winsock: h_errno %d, (%s).\n", + h_errno, sys_errlist[h_errno]); +#else + fprintf(stderr, "winsock: h_errno %d.\n", h_errno); + herror("wine: winsock: wsaherrno"); +#endif +#else + fprintf(stderr, "winsock: h_errno %d\n", h_errno); +#endif +#endif + + switch(h_errno) + { + case TRY_AGAIN: return WSATRY_AGAIN; + case HOST_NOT_FOUND: return WSAHOST_NOT_FOUND; + case NO_RECOVERY: return WSANO_RECOVERY; + case NO_DATA: return WSANO_DATA; +/* just in case we ever get here and there are no problems */ + case 0: return 0; + +#ifdef EDQUOT + default: +#endif + fprintf(stderr, "winsock: unknown h_errorno %d!\n", h_errno); + return WSAEOPNOTSUPP; + } +} + + +static void herrno_to_wsaerrno(void) +{ + wsa_errno = wsaherrno(); +} + + static void convert_sockopt(INT *level, INT *optname) { -/* $%#%!@! why couldn't they use the same values for both winsock and unix ? */ +/* $%#%!#! why couldn't they use the same values for both winsock and unix ? */ switch (*level) { case -1: @@ -376,7 +423,11 @@ INT WINSOCK_getpeername(SOCKET s, struct sockaddr *name, INT *namelen) dump_sockaddr(name); if (getpeername(s, name, (int *) namelen) < 0) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return SOCKET_ERROR; } return 0; @@ -386,7 +437,11 @@ INT WINSOCK_getsockname(SOCKET s, struct sockaddr *name, INT *namelen) { dprintf_winsock(stddeb, "WSA_getsockname: socket: %d, ptr %8x, ptr %8x\n", s, (int) name, (int) *namelen); if (getsockname(s, name, (int *) namelen) < 0) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return SOCKET_ERROR; } return 0; @@ -596,6 +651,10 @@ SOCKET WINSOCK_socket(INT af, INT type, INT protocol) } if (sock > 0xffff) { + /* we set the value of wsa_errno directly, because + * only support socket numbers up to 0xffff. The + * value return indicates there are no descriptors available + */ wsa_errno = WSAEMFILE; return INVALID_SOCKET; } @@ -616,7 +675,11 @@ SEGPTR WINSOCK_gethostbyaddr(const char *addr, INT len, INT type) dprintf_winsock(stddeb, "WSA_gethostbyaddr: ptr %8x, len %d, type %d\n", (int) addr, len, type); if ((host = gethostbyaddr(addr, len, type)) == NULL) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return NULL; } CONVERT_HOSTENT(&Heap->hostent_addr, host); @@ -634,7 +697,11 @@ SEGPTR WINSOCK_gethostbyname(const char *name) dprintf_winsock(stddeb, "WSA_gethostbyname: %s\n", name); if ((host = gethostbyname(name)) == NULL) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return NULL; } CONVERT_HOSTENT(&Heap->hostent_name, host); @@ -647,7 +714,11 @@ INT WINSOCK_gethostname(char *name, INT namelen) dprintf_winsock(stddeb, "WSA_gethostname: name %s, len %d\n", name, namelen); if (gethostname(name, namelen) < 0) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return SOCKET_ERROR; } return 0; @@ -663,7 +734,11 @@ SEGPTR WINSOCK_getprotobyname(char *name) dprintf_winsock(stddeb, "WSA_getprotobyname: name %s\n", name); if ((proto = getprotobyname(name)) == NULL) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return NULL; } CONVERT_PROTOENT(&Heap->protoent_name, proto); @@ -681,7 +756,11 @@ SEGPTR WINSOCK_getprotobynumber(INT number) dprintf_winsock(stddeb, "WSA_getprotobynumber: num %d\n", number); if ((proto = getprotobynumber(number)) == NULL) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return NULL; } CONVERT_PROTOENT(&Heap->protoent_number, proto); @@ -702,7 +781,11 @@ SEGPTR WINSOCK_getservbyname(const char *name, const char *proto) dprintf_winsock(stddeb, "WSA_getservbyname: name %s, proto %s\n", name, proto); if ((service = getservbyname(name, proto)) == NULL) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return NULL; } CONVERT_SERVENT(&Heap->servent_name, service); @@ -720,7 +803,11 @@ SEGPTR WINSOCK_getservbyport(INT port, const char *proto) dprintf_winsock(stddeb, "WSA_getservbyport: port %d, name %s\n", port, proto); if ((service = getservbyport(port, proto)) == NULL) { - errno_to_wsaerrno(); + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } return NULL; } CONVERT_SERVENT(&Heap->servent_port, service); @@ -742,7 +829,8 @@ static void recv_message(int sig) { struct ipc_packet message; - if (msgrcv(wine_key, (struct msgbuf*)&message, +/* FIXME: something about no message of desired type */ + if (msgrcv(wine_key, (struct msgbuf*)&(message), IPC_PACKET_SIZE, MTYPE, IPC_NOWAIT) == -1) perror("wine: msgrcv"); @@ -759,7 +847,7 @@ static void recv_message(int sig) } -static void send_message(HANDLE handle, HWND hWnd, u_int wMsg, long lParam) +static void send_message( HWND hWnd, u_int wMsg, HANDLE handle, long lParam) { struct ipc_packet message; @@ -773,7 +861,8 @@ static void send_message(HANDLE handle, HWND hWnd, u_int wMsg, long lParam) "WSA: send (hwnd "NPFMT", wMsg %d, handle "NPFMT", lParam %ld)\n", hWnd, wMsg, handle, lParam); - if (msgsnd(wine_key, (struct msgbuf*)&message, +/* FIXME: something about invalid argument */ + if (msgsnd(wine_key, (struct msgbuf*)&(message), IPC_PACKET_SIZE, IPC_NOWAIT) == -1) perror("wine: msgsnd"); @@ -793,6 +882,11 @@ HANDLE WSAAsyncGetHostByAddr(HWND hWnd, u_int wMsg, const char *addr, return handle; } else { if ((host = gethostbyaddr(addr, len, type)) == NULL) { + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } send_message(hWnd, wMsg, handle, wsaerrno() << 16); exit(0); } @@ -815,6 +909,11 @@ HANDLE WSAAsyncGetHostByName(HWND hWnd, u_int wMsg, const char *name, return handle; } else { if ((host = gethostbyname(name)) == NULL) { + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } send_message(hWnd, wMsg, handle, wsaerrno() << 16); exit(0); } @@ -837,6 +936,11 @@ HANDLE WSAAsyncGetProtoByName(HWND hWnd, u_int wMsg, const char *name, return handle; } else { if ((proto = getprotobyname(name)) == NULL) { + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } send_message(hWnd, wMsg, handle, wsaerrno() << 16); exit(0); } @@ -859,6 +963,11 @@ HANDLE WSAAsyncGetProtoByNumber(HWND hWnd, u_int wMsg, INT number, return handle; } else { if ((proto = getprotobynumber(number)) == NULL) { + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } send_message(hWnd, wMsg, handle, wsaerrno() << 16); exit(0); } @@ -881,6 +990,11 @@ HANDLE WSAAsyncGetServByName(HWND hWnd, u_int wMsg, const char *name, return handle; } else { if ((service = getservbyname(name, proto)) == NULL) { + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } send_message(hWnd, wMsg, handle, wsaerrno() << 16); exit(0); } @@ -903,6 +1017,11 @@ HANDLE WSAAsyncGetServByPort(HWND hWnd, u_int wMsg, INT port, const char return handle; } else { if ((service = getservbyport(port, proto)) == NULL) { + if (h_errno < 0) { + errno_to_wsaerrno(); + } else { + herrno_to_wsaerrno(); + } send_message(hWnd, wMsg, handle, wsaerrno() << 16); exit(0); } @@ -946,8 +1065,8 @@ INT WSAAsyncSelect(SOCKET s, HWND hWnd, u_int wMsg, long lEvent) event |= FD_READ; if (FD_ISSET(s, &write_fds)) event |= FD_WRITE; - - send_message(hWnd, wMsg, s, (wsaerrno() << 16) | event); + /* FIXME: the first time through we get a winsock error of 2, why? */ + send_message(hWnd, wMsg, (HANDLE)s, (wsaerrno() << 16) | event); } } } @@ -1049,7 +1168,7 @@ INT WSAStartup(WORD wVersionRequested, LPWSADATA lpWSAData) /* ipc stuff */ if ((wine_key = msgget(IPC_PRIVATE, 0600)) == -1) - perror("wine: msgget"); + perror("wine: msgget"); signal(SIGUSR1, recv_message); diff --git a/misc/xmalloc.c b/misc/xmalloc.c new file mode 100644 index 00000000000..24dcef58794 --- /dev/null +++ b/misc/xmalloc.c @@ -0,0 +1,44 @@ +/* + xmalloc - a safe malloc + + Use this function instead of malloc whenever you don't intend to check + the return value yourself, for instance because you don't have a good + way to handle a zero return value. + + Typically, Wine's own memory requests should be handles by this function, + while the client's should use malloc directly (and Wine should return an + error to the client if allocation fails). + + Copyright 1995 by Morten Welinder. + +*/ + +#include +#include "xmalloc.h" + +void * +xmalloc (size_t size) +{ + void *res; + + res = malloc (size ? size : 1); + if (res == NULL) + { + fprintf (stderr, "Virtual memory exhausted.\n"); + exit (1); + } + return res; +} + + +void * +xrealloc (void *ptr, size_t size) +{ + void *res = realloc (ptr, size); + if (res == NULL) + { + fprintf (stderr, "Virtual memory exhausted.\n"); + exit (1); + } + return res; +} diff --git a/miscemu/dosmem.c b/miscemu/dosmem.c index fd673eefc1c..4568eb8ecd0 100644 --- a/miscemu/dosmem.c +++ b/miscemu/dosmem.c @@ -13,6 +13,7 @@ #include "ldt.h" #include "miscemu.h" #include "module.h" +#include "xmalloc.h" HANDLE DOSMEM_BiosSeg; /* BIOS data segment at 0x40:0 */ @@ -90,7 +91,7 @@ BOOL DOSMEM_Init(void) /* Allocate 7 64k segments for 0000, A000, B000, C000, D000, E000, F000. */ - dosmem = malloc( 0x70000 ); + dosmem = xmalloc( 0x70000 ); MODULE_SetEntryPoint( hModule, 183, /* KERNEL.183: __0000H */ GLOBAL_CreateBlock( GMEM_FIXED, dosmem, diff --git a/miscemu/instr.c b/miscemu/instr.c index 83f7cefafe4..09daf43e2a7 100644 --- a/miscemu/instr.c +++ b/miscemu/instr.c @@ -429,10 +429,10 @@ BOOL INSTR_EmulateInstruction( struct sigcontext_struct *context ) if (outp) /* FIXME: Check segment readable. */ - ; + (void)0; else /* FIXME: Check segment writeable. */ - ; + (void)0; if (repX) if (long_addr) diff --git a/miscemu/int21.c b/miscemu/int21.c index 30862a6470e..0228602eb0e 100644 --- a/miscemu/int21.c +++ b/miscemu/int21.c @@ -799,8 +799,10 @@ static void CreateTempFile(struct sigcontext_struct *context) { char temp[256]; int handle; - - sprintf(temp,"%s\\win%d.tmp",TempDirectory,(int) getpid()); + static int counter = 0; + + sprintf(temp,"%s\\win%d.%03d",TempDirectory,(int) getpid(), counter); + counter = (counter + 1) % 1000; dprintf_int(stddeb,"CreateTempFile %s\n",temp); diff --git a/multimedia/mcistring.c b/multimedia/mcistring.c index 79fe669813e..3ea208f1199 100644 --- a/multimedia/mcistring.c +++ b/multimedia/mcistring.c @@ -22,6 +22,7 @@ #include "mmsystem.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" extern MCI_OPEN_DRIVER_PARMS mciDrv[MAXMCIDRIVERS]; @@ -1393,7 +1394,7 @@ MCISTR_Load(_MCISTR_PROTO_) { len+=strlen(keywords[i])+1; i++; } - s=(char*)malloc(len); + s=(char*)xmalloc(len); *s='\0'; while (ilpData = (LPSTR) malloc(1200); + lpMidiHdr->lpData = (LPSTR) xmalloc(1200); lpMidiHdr->dwBufferLength = 1024; lpMidiHdr->dwUser = 0L; lpMidiHdr->dwFlags = 0L; diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c index db3e707e066..81f1c1b9a92 100644 --- a/multimedia/mmsystem.c +++ b/multimedia/mmsystem.c @@ -23,6 +23,7 @@ #include "mmsystem.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" static int InstalledCount; static int InstalledListLen; @@ -533,7 +534,7 @@ msg# 543 : tmsf msgptr = "Unknown MCI Error !\n"; break; } - maxbuf = min(uLength - 1, strlen(msgptr)); + maxbuf = MIN(uLength - 1, strlen(msgptr)); if (maxbuf > 0) strncpy(lpstrBuffer, msgptr, maxbuf); lpstrBuffer[maxbuf + 1] = '\0'; return(TRUE); @@ -699,7 +700,7 @@ DWORD mciSysInfo(DWORD dwFlags, LPMCI_SYSINFO_PARMS lpParms) if (lpInstallNames == NULL) { InstalledCount = 0; InstalledListLen = 0; - ptr = lpInstallNames = malloc(2048); + ptr = lpInstallNames = xmalloc(2048); GetPrivateProfileString("mci", NULL, "", lpInstallNames, 2000, SysFile); while(strlen(ptr) > 0) { dprintf_mci(stddeb, "---> '%s' \n", ptr); @@ -900,7 +901,7 @@ msg# 343 : There are no MIDI devices installed on the system. Use the Drivers op msgptr = "Unknown MIDI Error !\n"; break; } - maxbuf = min(uSize - 1, strlen(msgptr)); + maxbuf = MIN(uSize - 1, strlen(msgptr)); if (maxbuf > 0) strncpy(lpText, msgptr, maxbuf); lpText[maxbuf + 1] = '\0'; return(TRUE); @@ -1356,7 +1357,7 @@ UINT waveGetErrorText(UINT uError, LPSTR lpText, UINT uSize) msgptr = "Unknown MMSYSTEM Error !\n"; break; } - maxbuf = min(uSize - 1, strlen(msgptr)); + maxbuf = MIN(uSize - 1, strlen(msgptr)); if (maxbuf > 0) strncpy(lpText, msgptr, maxbuf); lpText[maxbuf + 1] = '\0'; return(TRUE); diff --git a/multimedia/time.c b/multimedia/time.c index 5193abde7ca..c9e7f220500 100644 --- a/multimedia/time.c +++ b/multimedia/time.c @@ -135,7 +135,7 @@ WORD timeSetEvent(WORD wDelay, WORD wResol, LPTIMECALLBACK lpFunc, if (lpNewTimer == NULL) return 0; while (lpTimer != NULL) { - wNewID = max(wNewID, lpTimer->wTimerID); + wNewID = MAX(wNewID, lpTimer->wTimerID); if (lpTimer->Next == NULL) break; lpTimer = lpTimer->Next; diff --git a/objects/bitblt.c b/objects/bitblt.c index ae7dd30e309..89ae404c83b 100644 --- a/objects/bitblt.c +++ b/objects/bitblt.c @@ -17,6 +17,7 @@ #include "stddebug.h" /* #define DEBUG_BITBLT */ #include "debug.h" +#include "xmalloc.h" #define DST 0 /* Destination drawable */ @@ -1063,11 +1064,11 @@ BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst, dcSrc, xSrc, ySrc, widthSrc, heightSrc, &visRectSrc, &visRectDst )) return TRUE; - dprintf_bitblt( stddeb, " vissrc=%d,%d-%d,%d visdst=%d,%d-%d,%d\n", - visRectSrc.left, visRectSrc.top, - visRectSrc.right, visRectSrc.bottom, - visRectDst.left, visRectDst.top, - visRectDst.right, visRectDst.bottom ); + dprintf_bitblt( stddeb, " vissrc=%ld,%ld-%ld,%ld visdst=%ld,%ld-%ld,%ld\n", + (LONG)visRectSrc.left, (LONG)visRectSrc.top, + (LONG)visRectSrc.right, (LONG)visRectSrc.bottom, + (LONG)visRectDst.left, (LONG)visRectDst.top, + (LONG)visRectDst.right, (LONG)visRectDst.bottom ); } else { @@ -1075,9 +1076,9 @@ BOOL BITBLT_InternalStretchBlt( DC *dcDst, short xDst, short yDst, if (!BITBLT_GetVisRectangles( dcDst, xDst, yDst, widthDst, heightDst, NULL, 0, 0, 0, 0, NULL, &visRectDst )) return TRUE; - dprintf_bitblt( stddeb, " vissrc=none visdst=%d,%d-%d,%d\n", - visRectDst.left, visRectDst.top, - visRectDst.right, visRectDst.bottom ); + dprintf_bitblt( stddeb, " vissrc=none visdst=%ld,%ld-%ld,%ld\n", + (LONG)visRectDst.left, (LONG)visRectDst.top, + (LONG)visRectDst.right, (LONG)visRectDst.bottom ); } width = visRectDst.right - visRectDst.left; diff --git a/objects/brush.c b/objects/brush.c index 982920abbe1..1034c40af39 100644 --- a/objects/brush.c +++ b/objects/brush.c @@ -11,6 +11,7 @@ #include "color.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" #define NB_HATCH_STYLES 6 diff --git a/objects/clipping.c b/objects/clipping.c index e6a3335884c..08e65d71f5e 100644 --- a/objects/clipping.c +++ b/objects/clipping.c @@ -311,8 +311,9 @@ BOOL RectVisible( HDC hdc, LPRECT rect ) RECT tmpRect; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); if (!dc) return FALSE; - dprintf_clipping(stddeb,"RectVisible: "NPFMT" %d,%dx%d,%d\n", - hdc, rect->left, rect->top, rect->right, rect->bottom ); + dprintf_clipping(stddeb,"RectVisible: "NPFMT" %ld,%ldx%ld,%ld\n", + hdc, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, + (LONG)rect->bottom ); if (!dc->w.hGCClipRgn) return FALSE; /* copy rectangle to avoid overwriting by LPtoDP */ tmpRect = *rect; diff --git a/objects/color.c b/objects/color.c index 5941340a61b..41e222c4b23 100644 --- a/objects/color.c +++ b/objects/color.c @@ -12,6 +12,7 @@ #include "gdi.h" #include "color.h" #include "palette.h" +#include "xmalloc.h" Colormap COLOR_WinColormap = 0; int COLOR_FixedMap = 0; @@ -126,8 +127,8 @@ static HPALETTE COLOR_InitPalette(void) if ((COLOR_WinColormap == DefaultColormapOfScreen(screen)) && (screenDepth <= 8)) { - COLOR_PaletteToPixel = (int *)malloc( sizeof(int) * size ); - COLOR_PixelToPalette = (int *)malloc( sizeof(int) * size ); + COLOR_PaletteToPixel = (int *)xmalloc( sizeof(int) * size ); + COLOR_PixelToPalette = (int *)xmalloc( sizeof(int) * size ); for (i = 0; i < size; i++) /* Set the default mapping */ COLOR_PaletteToPixel[i] = COLOR_PixelToPalette[i] = i; } @@ -334,6 +335,7 @@ int COLOR_ToPhysical( DC *dc, COLORREF color ) idx = color & 0xffff; if (idx >= palPtr->logpalette.palNumEntries) { + fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is out of bounds, assuming black\n", color, idx); /* out of bounds */ red = green = blue = 0; } @@ -375,12 +377,20 @@ int COLOR_ToPhysical( DC *dc, COLORREF color ) } if (dc&&dc->u.x.pal.mappingSize) { - if (index >= dc->u.x.pal.mappingSize) return 0; + if (index >= dc->u.x.pal.mappingSize) + { + fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is >= dc->u.x.pal.mappingSize, assuming pixel 0\n", color, index); + return 0; + } mapping = (WORD *) GDI_HEAP_LIN_ADDR( dc->u.x.pal.hMapping ); } else { - if (index >= NB_RESERVED_COLORS) return 0; + if (index >= NB_RESERVED_COLORS) + { + fprintf(stderr, "COLOR_ToPhysical(%lx) : idx %d is >= NB_RESERVED_COLORS, assuming pixel 0\n", color, index); + return 0; + } mapping = (WORD *) GDI_HEAP_LIN_ADDR( hSysColorTranslation ); } if (mapping) return mapping[index]; @@ -424,20 +434,6 @@ void COLOR_SetMapping( DC *dc, HANDLE map, HANDLE revMap, WORD size ) } -/*********************************************************************** - * GetNearestColor (GDI.154) - */ -COLORREF GetNearestColor( HDC hdc, COLORREF color ) -{ - WORD index; - DC *dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return 0; - if (screenDepth > 8) return color; /* FIXME */ - index = (WORD)(COLOR_ToPhysical( dc, color & 0xffffff ) & 0xffff); - return PALETTEINDEX( index ); -} - - /*********************************************************************** * RealizeDefaultPalette (GDI.365) */ diff --git a/objects/cursoricon.c b/objects/cursoricon.c index 6cc3f2a24e2..fcb553e3903 100644 --- a/objects/cursoricon.c +++ b/objects/cursoricon.c @@ -32,6 +32,7 @@ #include "win.h" #include "stddebug.h" #include "debug.h" +#include "xmalloc.h" Cursor CURSORICON_XCursor = None; /* Current X cursor */ @@ -278,8 +279,8 @@ static HANDLE CURSORICON_Load( HANDLE hInstance, SEGPTR name, int width, size = DIB_BitmapInfoSize( bmi, DIB_RGB_COLORS ); /* Make sure we have room for the monochrome bitmap later on */ - size = max( size, sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD) ); - pInfo = (BITMAPINFO *)malloc( size ); + size = MAX( size, sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD) ); + pInfo = (BITMAPINFO *)xmalloc( size ); memcpy( pInfo, bmi, size ); if (pInfo->bmiHeader.biSize == sizeof(BITMAPINFOHEADER)) @@ -442,7 +443,7 @@ HICON LoadIcon( HANDLE hInstance, SEGPTR name ) return CURSORICON_Load( hInstance, name, SYSMETRICS_CXICON, SYSMETRICS_CYICON, - min( 16, 1 << screenDepth ), FALSE ); + MIN( 16, 1 << screenDepth ), FALSE ); } @@ -506,7 +507,7 @@ HANDLE CreateCursorIconIndirect( HANDLE hInstance, CURSORICONINFO *info, */ HICON CopyIcon( HANDLE hInstance, HICON hIcon ) { - dprintf_icon( stddeb, "CopyIcon: %04x %04x\n", hInstance, hIcon ); + dprintf_icon( stddeb, "CopyIcon: "NPFMT" "NPFMT"\n", hInstance, hIcon ); return CURSORICON_Copy( hInstance, hIcon ); } @@ -516,7 +517,7 @@ HICON CopyIcon( HANDLE hInstance, HICON hIcon ) */ HCURSOR CopyCursor( HANDLE hInstance, HCURSOR hCursor ) { - dprintf_cursor( stddeb, "CopyCursor: %04x %04x\n", hInstance, hCursor ); + dprintf_cursor( stddeb, "CopyCursor: "NPFMT" "NPFMT"\n", hInstance, hCursor ); return CURSORICON_Copy( hInstance, hCursor ); } @@ -526,8 +527,9 @@ HCURSOR CopyCursor( HANDLE hInstance, HCURSOR hCursor ) */ BOOL DestroyIcon( HICON hIcon ) { - dprintf_icon( stddeb, "DestroyIcon: %04x\n", hIcon ); - return GlobalFree( hIcon ); + dprintf_icon( stddeb, "DestroyIcon: "NPFMT"\n", hIcon ); + /* FIXME: should check for OEM icon here */ + return (GlobalFree( hIcon ) != 0); } @@ -536,8 +538,9 @@ BOOL DestroyIcon( HICON hIcon ) */ BOOL DestroyCursor( HCURSOR hCursor ) { - dprintf_cursor( stddeb, "DestroyCursor: %04x\n", hCursor ); - return GlobalFree( hCursor ); + dprintf_cursor( stddeb, "DestroyCursor: "NPFMT"\n", hCursor ); + /* FIXME: should check for OEM cursor here */ + return (GlobalFree( hCursor ) != 0); } @@ -628,7 +631,7 @@ static BOOL CURSORICON_SetCursor( HCURSOR hCursor ) if (!(ptr = (CURSORICONINFO*)GlobalLock( hCursor ))) return FALSE; if (ptr->bPlanes * ptr->bBitsPerPixel != 1) { - fprintf( stderr, "Cursor %04x has more than 1 bpp!\n", hCursor ); + fprintf( stderr, "Cursor "NPFMT" has more than 1 bpp!\n", hCursor ); return FALSE; } @@ -672,22 +675,26 @@ static BOOL CURSORICON_SetCursor( HCURSOR hCursor ) * bits on the screen) to black. This require some boolean * arithmetic: * - * Windows X11 - * Xor And Result Bits Mask - * 0 0 black 0 1 - * 0 1 no change X 0 - * 1 0 white 1 1 - * 1 1 inverted 0 1 (=black) + * Windows | X11 + * Xor And Result | Bits Mask Result + * 0 0 black | 0 1 background + * 0 1 no change | X 0 no change + * 1 0 white | 1 1 foreground + * 1 1 inverted | 0 1 background * * which gives: - * Bits = 'Xor' xor 'And' + * Bits = 'Xor' and not 'And' * Mask = 'Xor' or not 'And' + * + * FIXME: apparently some servers do support 'inverted' color. + * I don't know if it's correct per the X spec, but maybe + * we ought to take advantage of it. -- AJ */ XCopyArea( display, pixmapAll, pixmapBits, BITMAP_monoGC, 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 ); XCopyArea( display, pixmapAll, pixmapMask, BITMAP_monoGC, 0, 0, ptr->nWidth, ptr->nHeight, 0, 0 ); - XSetFunction( display, BITMAP_monoGC, GXxor ); + XSetFunction( display, BITMAP_monoGC, GXandReverse ); XCopyArea( display, pixmapAll, pixmapBits, BITMAP_monoGC, 0, ptr->nHeight, ptr->nWidth, ptr->nHeight, 0, 0 ); XSetFunction( display, BITMAP_monoGC, GXorReverse ); @@ -740,7 +747,7 @@ HCURSOR SetCursor( HCURSOR hCursor ) HCURSOR hOldCursor; if (hCursor == hActiveCursor) return hActiveCursor; /* No change */ - dprintf_cursor( stddeb, "SetCursor: %04x\n", hCursor ); + dprintf_cursor( stddeb, "SetCursor: "NPFMT"\n", hCursor ); hOldCursor = hActiveCursor; hActiveCursor = hCursor; /* Change the cursor shape only if it is visible */ @@ -755,7 +762,7 @@ HCURSOR SetCursor( HCURSOR hCursor ) void SetCursorPos( short x, short y ) { dprintf_cursor( stddeb, "SetCursorPos: x=%d y=%d\n", x, y ); - XWarpPointer( display, None, rootWindow, 0, 0, 0, 0, x, y ); + XWarpPointer( display, rootWindow, rootWindow, 0, 0, 0, 0, x, y ); } @@ -818,7 +825,8 @@ void GetCursorPos( POINT *pt ) pt->x = rootX + desktopX; pt->y = rootY + desktopY; } - dprintf_cursor(stddeb, "GetCursorPos: ret=%d,%d\n", pt->x, pt->y ); + dprintf_cursor(stddeb, "GetCursorPos: ret=%ld,%ld\n", (LONG)pt->x, + (LONG)pt->y ); } @@ -836,7 +844,7 @@ void GetClipCursor( RECT *rect ) */ WORD GetIconID( HANDLE hResource, DWORD resType ) { - fprintf( stderr, "GetIconId(%04x,%ld): empty stub!\n", + fprintf( stderr, "GetIconId("NPFMT",%ld): empty stub!\n", hResource, resType ); return 0; } @@ -847,7 +855,7 @@ WORD GetIconID( HANDLE hResource, DWORD resType ) */ HICON LoadIconHandler( HANDLE hResource, BOOL bNew ) { - fprintf( stderr, "LoadIconHandle(%04x,%d): empty stub!\n", + fprintf( stderr, "LoadIconHandle("NPFMT",%d): empty stub!\n", hResource, bNew ); return 0; } diff --git a/objects/dc.c b/objects/dc.c index 7dbd68e7b4c..41c981aa85a 100644 --- a/objects/dc.c +++ b/objects/dc.c @@ -14,6 +14,7 @@ #include "color.h" #include "debug.h" #include "font.h" +#include "xmalloc.h" static DeviceCaps * displayDevCaps = NULL; @@ -463,7 +464,7 @@ HDC CreateDC( LPSTR driver, LPSTR device, LPSTR output, LPSTR initData ) if (!displayDevCaps) { - displayDevCaps = (DeviceCaps *) malloc( sizeof(DeviceCaps) ); + displayDevCaps = (DeviceCaps *) xmalloc( sizeof(DeviceCaps) ); DC_FillDevCaps( displayDevCaps ); } diff --git a/objects/dib.c b/objects/dib.c index 1082b743b84..3c020462f4f 100644 --- a/objects/dib.c +++ b/objects/dib.c @@ -16,6 +16,7 @@ #include "stddebug.h" #include "color.h" #include "debug.h" +#include "xmalloc.h" /*********************************************************************** @@ -280,7 +281,7 @@ static void DIB_SetImageBits_RLE4( WORD lines, BYTE *bits, WORD width, BYTE *begin = bits; lines--; - while ((INT)lines >= 0) + while ((short)lines >= 0) { length = *bits++; if (length) { /* encoded */ @@ -451,7 +452,7 @@ static void DIB_SetImageBits_RLE8(WORD lines, * what caused the previous implementation to * fail. [JAY] */ - line=0; /* Cause exit from do loop. */ + line=-1; /* Cause exit from do loop. */ break; } @@ -511,7 +512,7 @@ static void DIB_SetImageBits_RLE8(WORD lines, } /* process either an encoded sequence or an escape sequence */ /* We expect to come here more than once per line. */ - } while (line > 0); /* Do this until the bitmap is filled */ + } while (line >= 0); /* Do this until the bitmap is filled */ /* * Everybody comes here at the end. diff --git a/objects/font.c b/objects/font.c index b1a89a896cd..be7ac76c4ff 100644 --- a/objects/font.c +++ b/objects/font.c @@ -518,8 +518,9 @@ BOOL GetTextExtentPoint( HDC hdc, LPSTR str, short count, LPSIZE size ) size->cy = abs((dc->u.x.font.fstruct->ascent+dc->u.x.font.fstruct->descent) * dc->w.WndExtY / dc->w.VportExtY); - dprintf_font(stddeb,"GetTextExtentPoint("NPFMT" '%*.*s' %d %p): returning %d,%d\n", - hdc, count, count, str, count, size, size->cx, size->cy ); + dprintf_font(stddeb,"GetTextExtentPoint("NPFMT" '%*.*s' %d %p): returning %ld,%ld\n", + hdc, count, count, str, count, size, (LONG)size->cx, + (LONG)size->cy ); return TRUE; } diff --git a/objects/gdiobj.c b/objects/gdiobj.c index b2434125125..7f0e6a3cf53 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -18,6 +18,7 @@ #include "stddebug.h" /* #define DEBUG_GDI */ #include "debug.h" +#include "xmalloc.h" LPSTR GDI_Heap = NULL; WORD GDI_HeapSel = 0; @@ -200,7 +201,7 @@ BOOL GDI_AppendToPenBrushList(HANDLE hNewObj) int i = 1; if (hNewObj == 0) return FALSE; if (lpPenBrushList == NULL) { - lpPenBrushList = malloc(MAX_OBJ * sizeof(HANDLE)); + lpPenBrushList = xmalloc(MAX_OBJ * sizeof(HANDLE)); lpPenBrushList[0] = 0; dprintf_gdi(stddeb,"GDI_AppendToPenBrushList() lpPenBrushList allocated !\n"); } @@ -495,7 +496,7 @@ int EnumObjects(HDC hDC, int nObjType, FARPROC lpEnumFunc, LPSTR lpData) if (header->wMagic == PEN_MAGIC) { PEN_GetObject( (PENOBJ *)header, sizeof(LOGPEN), lpLog); dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnStyle=%04X\n", ((LPLOGPEN)lpLog)->lopnStyle); - dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnWidth=%d\n", ((LPLOGPEN)lpLog)->lopnWidth.x); + dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnWidth=%ld\n", (LONG)((LPLOGPEN)lpLog)->lopnWidth.x); dprintf_gdi(stddeb,"EnumObjects // DC_Pen lopnColor=%08lX\n", ((LPLOGPEN)lpLog)->lopnColor); } nRet = CallEnumObjectsProc(lpEnumFunc, GDI_HEAP_SEG_ADDR(hLog), diff --git a/objects/metafile.c b/objects/metafile.c index 9628e99306c..e1d176e6558 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -50,6 +50,7 @@ HMETAFILE GetMetaFile(LPSTR lpFilename) strcpy(mf->Filename, lpFilename); mf->wMagic = METAFILE_MAGIC; if ((mf->hFile = _lopen(lpFilename, OF_READ)) == HFILE_ERROR) { + GlobalFree(mf->hMetaHdr); GlobalFree(hmf); return 0; } @@ -60,13 +61,16 @@ HMETAFILE GetMetaFile(LPSTR lpFilename) } _lclose(mf->hFile); + if (mh->mtType != 1) { + GlobalFree(mf->hMetaHdr); + GlobalFree(hmf); + return 0; + } GlobalUnlock(mf->hMetaHdr); GlobalUnlock(hmf); - if (mh->mtType != 1) - return 0; - else - return hmf; + return hmf; + } /****************************************************************** @@ -86,11 +90,14 @@ HANDLE CreateMetaFile(LPSTR lpFilename) if (!handle) return 0; dc = (DC *)GDI_HEAP_LIN_ADDR(handle); - if (!(dc->w.hMetaFile = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE)))) + if (!(dc->w.hMetaFile = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE)))) { + GDI_FreeObject(handle); return 0; + } mf = (METAFILE *)GlobalLock(dc->w.hMetaFile); if (!(mf->hMetaHdr = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAHEADER)))) { + GDI_FreeObject(handle); GlobalFree(dc->w.hMetaFile); return 0; } @@ -108,7 +115,12 @@ HANDLE CreateMetaFile(LPSTR lpFilename) { mh->mtType = 1; strcpy(mf->Filename, lpFilename); +#ifndef WINELIB mf->hFile = _lcreat(lpFilename, 0); +#else + /* temporary fix until _lcreate works under WINELIB */ + mf->hFile = creat(lpFilename, 0666); +#endif if (_lwrite(mf->hFile, (char *)mh, MFHEADERSIZE) == -1) { GlobalFree(mf->hMetaHdr); @@ -194,7 +206,7 @@ BOOL DeleteMetaFile(HMETAFILE hmf) { METAFILE *mf = (METAFILE *)GlobalLock(hmf); - if (mf->wMagic != METAFILE_MAGIC) + if (!mf || mf->wMagic != METAFILE_MAGIC) return FALSE; GlobalFree(mf->hMetaHdr); @@ -437,7 +449,7 @@ void PlayMetaFileRecord(HDC hdc, HANDLETABLE *ht, METARECORD *mr, case META_POLYPOLYGON: PolyPolygon(hdc, (LPPOINT)(mr->rdParam + *(mr->rdParam) + 1), - (mr->rdParam + 1), *(mr->rdParam)); + (LPINT)(mr->rdParam + 1), *(mr->rdParam)); break; case META_POLYLINE: @@ -499,12 +511,130 @@ void PlayMetaFileRecord(HDC hdc, HANDLETABLE *ht, METARECORD *mr, CreateBrushIndirect((LOGBRUSH *)(&(mr->rdParam)))); break; + /* W. Magro: Some new metafile operations. Not all debugged. */ + case META_CREATEPALETTE: + MF_AddHandle(ht, nHandles, + CreatePalette((LPLOGPALETTE)mr->rdParam)); + break; + + case META_SETTEXTALIGN: + fprintf(stderr,"PlayMetaFileRecord: SETTEXTALIGN: %hd\n",mr->rdParam[0]); + SetTextAlign(hdc, *(mr->rdParam)); + break; + + case META_SELECTPALETTE: + SelectPalette(hdc, *(ht->objectHandle + *(mr->rdParam+1)),*(mr->rdParam)); + break; + + case META_SETMAPPERFLAGS: + SetMapperFlags(hdc, *(mr->rdParam)); + break; + + case META_REALIZEPALETTE: + RealizePalette(hdc); + break; + + case META_ESCAPE: + dprintf_metafile(stddeb,"PlayMetaFileRecord: META_ESCAPE unimplemented.\n"); + break; + + case META_EXTTEXTOUT: /* FIXME: don't know the exact parameters here */ + { + short x,y,options,x5,x6,x7,x8; + y=mr->rdParam[0]; /* X position */ + x=mr->rdParam[1]; /* Y position */ + s1=mr->rdParam[2]; /* String length */ + options=mr->rdParam[3]; + x5=mr->rdParam[(s1+1)/2+4]; /* unknown meaning */ + x6=mr->rdParam[(s1+1)/2+5]; /* unknown meaning */ + x7=mr->rdParam[(s1+1)/2+6]; /* unknown meaning */ + x8=mr->rdParam[(s1+1)/2+7]; /* unknown meaning */ + ExtTextOut(hdc, x, y, options, (LPRECT) &mr->rdParam[(s1+1)/2+4], (char *)(mr->rdParam + 4), s1, NULL); + /* fprintf(stderr,"EXTTEXTOUT (len: %d) %hd : %hd %hd %hd %hd [%s].\n", + (mr->rdSize-s1),options,x5,x6,x7,x8,(char*) &(mr->rdParam[4]) );*/ + } + break; + /* End new metafile operations. */ + default: - fprintf(stderr,"PlayMetaFileRecord: Unknown record type %x\n", + fprintf(stddeb,"PlayMetaFileRecord: Unknown record type %x\n", mr->rdFunction); } } +/****************************************************************** + * GetMetaFileBits by William Magro, 19 Sep 1995 + * + * Trade in a meta file object handle for a handle to the meta file memory + */ +HANDLE GetMetaFileBits(HMETAFILE hmf) +{ + + /* save away the meta file bits handle */ + METAFILE *mf = (METAFILE *)GlobalLock(hmf); + HANDLE hMem = mf->hMetaHdr; + METAHEADER *mh = (METAHEADER *)GlobalLock(hMem); + + dprintf_metafile(stddeb,"GetMetaFileBits: hmf in: %x\n", hmf); + + /* can't get bits of disk based metafile */ + /* FIXME: should the disk file be loaded in this case? */ + if(mh->mtType == 1) { + fprintf(stderr, + "GetMetaFileBits: application requested bits of disk meta file.\n"); + GlobalUnlock(hMem); + GlobalUnlock(hmf); + return FALSE; + } + + /* unlock the memory and invalidate the metafile handle */ + GlobalUnlock(hMem); + GlobalFree(hmf); + + dprintf_metafile(stddeb,"GetMetaFileBits: hMem out: %x\n", hMem); + + return hMem; +} + +/****************************************************************** + * SetMetaFileBits by William Magro, 19 Sep 1995 + * + * Trade in a meta file memory handle for a handle to a meta file object + */ +HMETAFILE SetMetaFileBits(HANDLE hMem) +{ + HMETAFILE hmf; + METAFILE *mf; + METAHEADER *mh = (METAHEADER *)GlobalLock(hMem); + + dprintf_metafile(stddeb,"SetMetaFileBits: hMem in: %x\n", hMem); + + if (!mh) return FALSE; + + /* now it is a memory meta file */ + mh->mtType = 0; + + hmf = GlobalAlloc(GMEM_MOVEABLE, sizeof(METAFILE)); + mf = (METAFILE *)GlobalLock(hmf); + if (!mf) { + GlobalUnlock(hMem); + GlobalFree(hmf); + return FALSE; + } + + /* use the supplied memory handle */ + mf->hMetaHdr = hMem; + mf->wMagic = METAFILE_MAGIC; + mf->MetaOffset = mh->mtHeaderSize * 2; + mf->hFile = mf->hBuffer = (HANDLE) NULL; + + GlobalUnlock(hMem); + GlobalUnlock(hmf); + + dprintf_metafile(stddeb,"SetMetaFileBits: hmf out: %x\n", hmf); + + return hmf; +} /****************************************************************** * MF_WriteRecord @@ -538,7 +668,7 @@ BOOL MF_WriteRecord(HMETAFILE hmf, METARECORD *mr, WORD rlen) } mh->mtSize += rlen / 2; - mh->mtMaxRecord = max(mh->mtMaxRecord, rlen / 2); + mh->mtMaxRecord = MAX(mh->mtMaxRecord, rlen / 2); GlobalUnlock(mf->hMetaHdr); return TRUE; } diff --git a/objects/palette.c b/objects/palette.c index 7fa2cfe10e7..ccd0b42e485 100644 --- a/objects/palette.c +++ b/objects/palette.c @@ -23,6 +23,56 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993,1994"; static WORD SystemPaletteUse = SYSPAL_STATIC; /* currently not considered */ + +/*********************************************************************** + * PALETTE_GetNearestIndexAndColor + */ +static WORD PALETTE_GetNearestIndexAndColor(HPALETTE hpalette, COLORREF *color) +{ + int i, minDist, dist; + WORD index = 0; + BYTE r, g, b; + PALETTEENTRY * entry; + PALETTEOBJ * palPtr; + + palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC ); + if (!palPtr) return 0; + + if ((COLOR_WinColormap != DefaultColormapOfScreen(screen)) && + (hpalette == STOCK_DEFAULT_PALETTE)) + { + if ((*color & 0xffffff) == 0) return 0; /* Entry 0 is black */ + if ((*color & 0xffffff) == 0xffffff) /* Max entry is white */ + return palPtr->logpalette.palNumEntries - 1; + } + + r = GetRValue(*color); + g = GetGValue(*color); + b = GetBValue(*color); + + entry = palPtr->logpalette.palPalEntry; + for (i = 0, minDist = MAXINT; minDist !=0 && + i < palPtr->logpalette.palNumEntries ; i++) + { + if (entry->peFlags != 0xff) + { + dist = (r - entry->peRed) * (r - entry->peRed) + + (g - entry->peGreen) * (g - entry->peGreen) + + (b - entry->peBlue) * (b - entry->peBlue); + if (dist < minDist) + { + minDist = dist; + index = i; + } + } + entry++; + } + entry = &palPtr->logpalette.palPalEntry[index]; + *color = RGB( entry->peRed, entry->peGreen, entry->peBlue ); + return index; +} + + /*********************************************************************** * CreatePalette (GDI.360) */ @@ -145,50 +195,29 @@ WORD GetSystemPaletteEntries( HDC hdc, WORD start, WORD count, */ WORD GetNearestPaletteIndex( HPALETTE hpalette, COLORREF color ) { - int i, minDist, dist; - WORD index = 0; - BYTE r, g, b; - PALETTEENTRY * entry; - PALETTEOBJ * palPtr; - - palPtr = (PALETTEOBJ *) GDI_GetObjPtr( hpalette, PALETTE_MAGIC ); - if (!palPtr) return 0; - - if ((COLOR_WinColormap != DefaultColormapOfScreen(screen)) && - (hpalette == STOCK_DEFAULT_PALETTE)) - { - if ((color & 0xffffff) == 0) return 0; /* Entry 0 is black */ - if ((color & 0xffffff) == 0xffffff) /* Max entry is white */ - return palPtr->logpalette.palNumEntries - 1; - } - - r = GetRValue(color); - g = GetGValue(color); - b = GetBValue(color); - - entry = palPtr->logpalette.palPalEntry; - for (i = 0, minDist = MAXINT; minDist !=0 && - i < palPtr->logpalette.palNumEntries ; i++) - { - if (entry->peFlags != 0xff) - { - dist = (r - entry->peRed) * (r - entry->peRed) + - (g - entry->peGreen) * (g - entry->peGreen) + - (b - entry->peBlue) * (b - entry->peBlue); - if (dist < minDist) - { - minDist = dist; - index = i; - } - } - entry++; - } + WORD index = PALETTE_GetNearestIndexAndColor( hpalette, &color ); dprintf_palette(stddeb,"GetNearestPaletteIndex("NPFMT",%06lx): returning %d\n", - hpalette, color, index ); + hpalette, color, index ); return index; } +/*********************************************************************** + * GetNearestColor (GDI.154) + */ +COLORREF GetNearestColor( HDC hdc, COLORREF color ) +{ + COLORREF nearest = color; + DC *dc; + + if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0; + PALETTE_GetNearestIndexAndColor( dc->w.hPalette, &nearest ); + dprintf_palette(stddeb,"GetNearestColor(%06lx): returning %06lx\n", + color, nearest ); + return nearest; +} + + /*********************************************************************** * PALETTE_GetObject */ diff --git a/objects/region.c b/objects/region.c index 5be23ffc539..73adc51a825 100644 --- a/objects/region.c +++ b/objects/region.c @@ -240,7 +240,7 @@ HRGN CreateEllipticRgnIndirect( LPRECT rect ) /*********************************************************************** * CreatePolygonRgn (GDI.63) */ -HRGN CreatePolygonRgn( POINT * points, short count, short mode ) +HRGN CreatePolygonRgn( POINT * points, INT count, INT mode ) { return CreatePolyPolygonRgn( points, &count, 1, mode ); } @@ -249,8 +249,8 @@ HRGN CreatePolygonRgn( POINT * points, short count, short mode ) /*********************************************************************** * CreatePolyPolygonRgn (GDI.451) */ -HRGN CreatePolyPolygonRgn( POINT * points, short * count, - short nbpolygons, short mode ) +HRGN CreatePolyPolygonRgn( POINT * points, INT * count, + INT nbpolygons, INT mode ) { RGNOBJ * obj; HRGN hrgn; diff --git a/objects/text.c b/objects/text.c index fd94b1041de..3b6ec2240b1 100644 --- a/objects/text.c +++ b/objects/text.c @@ -15,6 +15,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993, 1994"; #include "stddebug.h" /* #define DEBUG_TEXT */ #include "debug.h" +#include "xmalloc.h" #define TAB 9 #define LF 10 @@ -196,8 +197,9 @@ int DrawText( HDC hdc, LPSTR str, int count, LPRECT rect, WORD flags ) int width = rect->right - rect->left; int max_width = 0; - dprintf_text(stddeb,"DrawText: '%s', %d , [(%d,%d),(%d,%d)]\n", str, count, - rect->left, rect->top, rect->right, rect->bottom); + dprintf_text(stddeb,"DrawText: '%s', %d , [(%ld,%ld),(%ld,%ld)]\n", str, + count, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, + (LONG)rect->bottom); if (count == -1) count = strlen(str); strPtr = str; @@ -307,8 +309,9 @@ BOOL ExtTextOut( HDC hdc, short x, short y, WORD flags, LPRECT lprect, dprintf_text(stddeb,"ExtTextOut: %d,%d '%*.*s', %d flags=%d\n", x, y, count, count, str, count, flags); if (lprect != NULL) { - dprintf_text(stddeb, "rect %d %d %d %d\n", - lprect->left, lprect->top, lprect->right, lprect->bottom ); + dprintf_text(stddeb, "rect %ld %ld %ld %ld\n", (LONG)lprect->left, + (LONG)lprect->top, (LONG)lprect->right, + (LONG)lprect->bottom ); } /* Setup coordinates */ @@ -418,7 +421,7 @@ BOOL ExtTextOut( HDC hdc, short x, short y, WORD flags, LPRECT lprect, { XTextItem *items, *pitem; - items = malloc( count * sizeof(XTextItem) ); + items = xmalloc( count * sizeof(XTextItem) ); for (i = 0, pitem = items; i < count; i++, pitem++) { pitem->chars = str + i; diff --git a/rc/winerc.c b/rc/winerc.c index afdd89e8a39..06f83966c86 100644 --- a/rc/winerc.c +++ b/rc/winerc.c @@ -34,6 +34,20 @@ char hname[256],sname[256]; int transform_binary_file(void); int yyparse(void); +static void *xmalloc (size_t size) +{ + void *res; + + res = malloc (size ? size : 1); + if (res == NULL) + { + fprintf (stderr, "Virtual memory exhausted.\n"); + exit (1); + } + return res; +} + + int main(int argc,char *argv[]) { extern int yydebug; @@ -130,10 +144,8 @@ DWORD get_DWORD(unsigned char* p) /*create a new gen_res, initial size 100*/ gen_res *new_res() -{ gen_res* ret=malloc(sizeof(gen_res)+100); +{ gen_res* ret=xmalloc(sizeof(gen_res)+100); int i; - if(!ret) - fprintf(stderr,"Out of memory\n"),exit(1); for(i=0;ig_next=g_start; ret->g_prev=0; @@ -188,7 +200,7 @@ gen_res* delete_bytes(gen_res* res,int start,int len) /*create a new style*/ rc_style *new_style() { - rc_style *ret=malloc(sizeof(rc_style)); + rc_style *ret=xmalloc(sizeof(rc_style)); /*initially, no bits have to be reset*/ ret->and=-1; /*initially, no bits are set*/ @@ -464,6 +476,7 @@ gen_res *add_menuitem(char* name,int id,int flags,gen_res *res) gen_res *add_popup(char *name,short flags, gen_res* body, gen_res*res) { char c_flags[2]; + flags|=MF_POPUP; if(res->num_entries==0)flags|=MF_END; put_WORD(c_flags,flags); res=insert_at_beginning(res,body->res,body->size); @@ -617,7 +630,7 @@ gen_res* int_to_raw(int i,gen_res* res) /* translate "Hello,\\tworld!\\10" to "Hello,\tworld!\n" */ char *parse_c_string(char *in) { - char *out=malloc(strlen(in)-1); + char *out=xmalloc(strlen(in)-1); char *it; char tmp[5],*tend; for(it=out,in++;*in;in++) diff --git a/toolkit/Makefile.in b/toolkit/Makefile.in index 73f87464f81..55745dd939a 100644 --- a/toolkit/Makefile.in +++ b/toolkit/Makefile.in @@ -19,9 +19,21 @@ hello: hello.o ../winelib.a hello2: hello2.o ../winelib.a gcc -g -o hello2 hello2.o ../winelib.a -lm $(X_LIBS) -lXpm $(XLIB) +hello3: hello3res.o hello3.o + gcc -g -o hello3 hello3.o hello3res.o ../winelib.a -lm $(X_LIBS) -lXpm $(XLIB) + +hello3.o: hello3res.o + +hello3res.o: hello3res.rc + echo "#include \"windows.h\"" >hello3res.rct + echo WINDOWS_H_ENDS_HERE >>hello3res.rct + cat hello3res.rc >>hello3res.rct + $(CC) $(ALLCFLAGS) -E -x c -P hello3res.rct | sed -e '1,/^WINDOWS_H_ENDS_HERE/d' | ../rc/winerc -o hello3res -v -p hello3 + gcc -c hello3res.c + @MAKE_RULES@ clean:: - $(RM) hello hello2 + $(RM) hello hello2 hello3 ### Dependencies: diff --git a/toolkit/README.resources b/toolkit/README.resources new file mode 100644 index 00000000000..2ceb5a7b00a --- /dev/null +++ b/toolkit/README.resources @@ -0,0 +1,91 @@ +This is a short discussion of resources in WineLib. + +Introduction +Resources are used to store dialogs, menus, bitmaps, icons, +version information, strings, fonts, and accelerators. +In a Win3.1 programming environment, there are three file formats for +resources: +- the RC script, which is human-readable and can be processed by a resource +compiler +- the .RES file, which is the output of the resource compiler +- the .EXE and .DLL files, which store resources as a part of the NE +file format +For WineLib, only a part of this is supported. In particular, there is no +.RES file, the executable is not a NE file (as it is a native Unix executable), +and some resource types are not implemented: icons, version information, +strings, and fonts. + +Building a WineLib application +The build process assumes that the C source files and the resource script +is available. At the moment, a single resource script is recommended. +This script is processed by winerc: +1) the preprocessor is used to resolve symbolic style name (LBS_STANDARD, ...) +into numbers. This involves processing windows.h +2) the unused parts of windows.h (type definitions) are removed. This would +not be necessary if Wine's windows.h would use the RC_INVOKED macro. +3) winerc is invoked to create a binary representation of the resources. +This representation is stored as C source code (arrays). +4) gcc is used to compile the generated C code. +Now, each resource is available as a C array to the application. As the +executable is not in the NE format, it is not possible to retrieve resource +locations in the executable via name. Instead, the resources have to be +referenced with their generated C array names. The linker then resolves +these names in the compiled resource file. +5) The program sources are compiled and linked with the output of step 4. +A sample build process is in toolkit/Makefile:hello3. + +Required changes to the program sources +Because loading the resources from an instance handle is not possible, +the *Indirect functions have to be used to load a resource. The C arrays +can be directly passed to the *Indirect functions. So, instead of writing + + hMenu=LoadMenu(hInstance,"MAIN"); + +write + + hMenu=LoadMenuIndirect(hello3_MENU_MAIN.bytes); + +Fortunately, the Windows API has the following functions available: +DialogBoxIndirect +CreateDialogIndirect +DialogBoxIndirectParam +CreateDialogIndirectParam + +LoadMenuIndirect +SetDIBitsToDevice + +Sample code is available in hello3.c. hello3res.c contains the corresponding +resources. + +Keeping a common source +Clearly, changing the sources is not very desirable, and suggestions how +to reduce the amount of work are welcome. In the meantime, two approaches +allow at least to remain a common source between the Win3.1 code and the +WineLib code: +1) conditional compiles: +When compiling a WineLib application, WINELIB is defined. This can be used +to select Wine-specific code. +2) usage of winerc for Windows: The *Indirect functions are available on +plain Win3.1, and the resource format is fully compatible. Thus, recompiling +sources modified for WineLib on Win3.1 is possible and known to work. + +Open problems +1) Icons and cursors: For these resources, there is no *Indirect function +documented. In addition, both are implemented by a set of two resources. +This is the reason why they are not supported by winerc. +2) Accelerators: Although winerc supports accelerators, there is no +LoadAcceleratorIndirect function. A work-around would be to define one. +3) Fonts: Font resources are not supported by Wine at all. +4) String tables: Although string tables are not supported by winerc, there +is no reason not to add such support. Again, some indirect loading would +be necessary. +5) API requires loading by name: At some places, the name of a resource +is passed instead of a handle. The WNDCLASS structure contains the name +of a menu resource, and the icon in a dialog box is referenced by its name. +(Are there some more places?) +Clearly, loading the resource by name would be highly desirable. The +resource compiler currently creates a structure containing all resources +defined in an RC file. However, it is not clear how WINELIB could find the +location of this structure, especially, when there is more than one RC file. + + diff --git a/toolkit/atom.c b/toolkit/atom.c index 26ae4457630..48fbfbe3d0d 100644 --- a/toolkit/atom.c +++ b/toolkit/atom.c @@ -10,6 +10,7 @@ #include #include "windows.h" +#include "xmalloc.h" #ifdef CONFIG_IPC #include "dde_atom.h" @@ -90,7 +91,7 @@ static ATOM ATOM_AddAtom( ATOMtoHANDLEtable** tableptr, SEGPTR name ) } if(!FirstUnused) { - *tableptr = malloc(sizeof(ATOMtoHANDLEtable)); + *tableptr = xmalloc(sizeof(ATOMtoHANDLEtable)); (*tableptr)->next = NULL; for(i=0; i<16; i++) { diff --git a/toolkit/heap.c b/toolkit/heap.c index 370f7c6a6f2..75faefccba9 100644 --- a/toolkit/heap.c +++ b/toolkit/heap.c @@ -8,9 +8,11 @@ /* #ifndef __STDC__ */ #include +#include #include /* #endif */ #include "windows.h" +#include "xmalloc.h" #ifdef WINELIB16 @@ -39,7 +41,7 @@ static void **HEAP_GetFreeSlot (HANDLE *hNum) } /* No free slots */ - last->next = malloc (sizeof (handle_table_t)); + last->next = xmalloc (sizeof (handle_table_t)); table = last->next; memset (table, 0, sizeof (handle_table_t)); i = 0; @@ -131,7 +133,7 @@ HANDLE LocalReAlloc (HANDLE hMem, WORD flags, WORD bytes) { void **m = HEAP_FindSlot (hMem); - realloc (*m, bytes); + xrealloc (*m, bytes); } WORD LocalSize (HANDLE hMem) @@ -140,7 +142,7 @@ WORD LocalSize (HANDLE hMem) } -BOOL LocalUnLock (HANDLE hMem) +BOOL LocalUnlock (HANDLE hMem) { return 0; } @@ -162,7 +164,7 @@ char *GlobalLock (HANDLE hMem) BOOL GlobalUnlock (HANDLE hMem) { - return LocalUnLock (hMem); + return LocalUnlock (hMem); } WORD GlobalFlags (HANDLE hMem) @@ -208,9 +210,47 @@ DWORD int GlobalHandle(WORD selector) #endif #else /* WINELIB16 */ + +#ifdef DEBUG_HEAP +static void* LastTwenty[20]={ 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0 }; + +void CheckMem(void* f) +{ + int i; + + for(i=0; i<20; i++) + { + if(LastTwenty[i]==f) + LastTwenty[i]=NULL; + else if(LastTwenty[i]) + if( *((int*)LastTwenty[i]) != 0x12345678 || + *(((int*)LastTwenty[i])+1) != 0x0fedcba9 ) + fprintf(stderr,"memory corrupted at %p\n",LastTwenty[i]); + } + fflush(stderr); +} + +void NewMem(void* n) +{ + int i; + for(i=0; i<20; i++) + if(!LastTwenty[i]) + { + LastTwenty[i]=n; + return; + } + for(i=0; i<20; i++) + LastTwenty[i]=LastTwenty[i+1]; + LastTwenty[4]=n; +} +#endif + HANDLE LocalAlloc (WORD flags, WORD bytes) { HANDLE m; +#ifdef DEBUG_HEAP + bytes+=2*sizeof(int); +#endif if (flags & LMEM_WINE_ALIGN) m = memalign (4, bytes); @@ -220,6 +260,14 @@ HANDLE LocalAlloc (WORD flags, WORD bytes) if (flags & LMEM_ZEROINIT) bzero (m, bytes); } +#ifdef DEBUG_HEAP + CheckMem(NULL); + *((int*) m)=0x12345678; + *(((int*) m)+1)=0x0fedcba9; + fprintf(stderr,"%p malloc'd\n",m); fflush(stderr); + NewMem(m); + return (HANDLE) (((int*)m)+2); +#endif return m; } @@ -235,7 +283,24 @@ WORD LocalFlags (HANDLE hMem) HANDLE LocalFree (HANDLE hMem) { +#ifdef DEBUG_HEAP + hMem=(HANDLE) (((int*)hMem)-2); + CheckMem(hMem); + fprintf(stderr,"%p free-ing...",hMem); + if( *((int*)hMem) != 0x12345678 || + *(((int*)hMem)+1) != 0x0fedcba9 ) + fprintf(stderr,"memory corrupted..."); + else + { + *((int*)hMem) = 0x9abcdef0; + *(((int*)hMem)+1) = 0x87654321; + } + fflush(stderr); +#endif free(hMem); +#ifdef DEBUG_HEAP + fprintf(stderr,"free'd\n"); fflush(stderr); +#endif return 0; } @@ -251,8 +316,11 @@ LPVOID LocalLock (HANDLE hMem) HANDLE LocalReAlloc (HANDLE hMem, WORD flags, WORD bytes) { - realloc(hMem, bytes); - return hMem; +#ifdef DEBUG_HEAP + LocalFree(hMem); + return LocalAlloc(flags,bytes); +#endif + return realloc(hMem, bytes); } WORD LocalSize (HANDLE hMem) @@ -262,7 +330,7 @@ WORD LocalSize (HANDLE hMem) } -BOOL LocalUnLock (HANDLE hMem) +BOOL LocalUnlock (HANDLE hMem) { return 0; } @@ -284,7 +352,7 @@ LPVOID GlobalLock (HGLOBAL hMem) BOOL GlobalUnlock (HANDLE hMem) { - return LocalUnLock (hMem); + return LocalUnlock (hMem); } WORD GlobalFlags (HANDLE hMem) diff --git a/toolkit/hello3.c b/toolkit/hello3.c new file mode 100644 index 00000000000..c688cecf277 --- /dev/null +++ b/toolkit/hello3.c @@ -0,0 +1,85 @@ +#include +#include "hello3res.h" + +BOOL CALLBACK DlgProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam) +{ + switch(msg) + { + case WM_INITDIALOG: + return 1; + case WM_COMMAND: + if(wParam==100) + DestroyWindow(hWnd); + return 0; + } + return 0; +} + +LRESULT WndProc (HWND wnd, UINT msg, WPARAM w, LPARAM l) +{ + switch (msg){ + + case WM_COMMAND: + switch(w){ + case 100: + CreateDialogIndirect(0,hello3_DIALOG_DIADEMO.bytes,wnd,(WNDPROC)DlgProc); + return 0; + case 101: + { + BITMAPINFO *bm=hello3_BITMAP_BITDEMO.bytes; + char *bits=bm; + HDC hdc=GetDC(wnd); + bits+=bm->bmiHeader.biSize; + bits+=(1<bmiHeader.biBitCount)*sizeof(RGBQUAD); + SetDIBitsToDevice(hdc,0,0,bm->bmiHeader.biWidth, + bm->bmiHeader.biHeight,0,0,0,bm->bmiHeader.biHeight, + bits,bm,DIB_RGB_COLORS); + ReleaseDC(wnd,hdc); + return 0; + } + default: + return DefWindowProc (wnd, msg, w, l); + } + case WM_DESTROY: + PostQuitMessage (0); + break; + + default: + return DefWindowProc (wnd, msg, w, l); + } + return 0l; +} + +int PASCAL WinMain (HANDLE inst, HANDLE prev, LPSTR cmdline, int show) +{ + HWND wnd; + MSG msg; + WNDCLASS class; + + if (!prev){ + class.style = CS_HREDRAW | CS_VREDRAW; + class.lpfnWndProc = WndProc; + class.cbClsExtra = 0; + class.cbWndExtra = 0; + class.hInstance = inst; + class.hIcon = LoadIcon (0, IDI_APPLICATION); + class.hCursor = LoadCursor (0, IDC_ARROW); + class.hbrBackground = GetStockObject (WHITE_BRUSH); + class.lpszMenuName = 0; + class.lpszClassName = (SEGPTR)"class"; + } + if (!RegisterClass (&class)) + return FALSE; + + wnd = CreateWindow ("class", "Test app", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, + LoadMenuIndirect(hello3_MENU_MAIN.bytes), inst, 0); + ShowWindow (wnd, show); + UpdateWindow (wnd); + + while (GetMessage (&msg, 0, 0, 0)){ + TranslateMessage (&msg); + DispatchMessage (&msg); + } + return 0; +} diff --git a/toolkit/hello3res.rc b/toolkit/hello3res.rc new file mode 100644 index 00000000000..23f29c5e1a5 --- /dev/null +++ b/toolkit/hello3res.rc @@ -0,0 +1,32 @@ +MAIN MENU +{ + POPUP "Menu demo" { + MENUITEM "Dialog Demo", 100 + MENUITEM "Bitmap Demo", 101 + } +} + +DIADEMO DIALOG 20, 20, 179, 118 +STYLE DS_MODALFRAME | WS_CAPTION | WS_POPUP | WS_VISIBLE | WS_SYSMENU +CAPTION "Dialog demo" +FONT 8, "Helv" +BEGIN + CONTROL "Pushbutton", 100, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 14, 92, 52, 13 + CONTROL "Checkbox", 101, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 19, 76, 47, 12 + CONTROL "Static text", 102, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE, 17, 60, 39, 10 +#if 0 + /* Edit controls don't work, yet */ + CONTROL "Edit control", 103, "EDIT", ES_LEFT | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 18, 41, 44, 13 +#endif + CONTROL "Radio button", 104, "BUTTON", BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE, 17, 23, 58, 12 + CONTROL "Checkbox", 101, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 19, 76, 47, 12 +#if 0 + CONTROL "", 106, "COMBOBOX", CBS_DROPDOWN | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 86, 23, 86, 85 +#else + CONTROL "", 106, "LISTBOX", LBS_STANDARD | LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 86, 23, 86, 85 +#endif +END + + +BITDEMO BITMAP "../rc/winelogo.bmp" + diff --git a/toolkit/miscstubs.c b/toolkit/miscstubs.c index 5db9016bb0d..ddeeb498ac9 100644 --- a/toolkit/miscstubs.c +++ b/toolkit/miscstubs.c @@ -11,6 +11,7 @@ #include "windows.h" #include "global.h" #include "debug.h" +#include "xmalloc.h" int CallTo32_LargeStack( int (*func)(), int nbargs, ...) { @@ -32,6 +33,8 @@ int CallTo32_LargeStack( int (*func)(), int nbargs, ...) a[7],a[8],a[9],a[10]); case 14: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6], a[7],a[8],a[9],a[10],a[11],a[12],a[13]); + case 17: return func(a[0],a[1],a[2],a[3],a[4],a[5],a[6], + a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15],a[16]); default: fprintf(stderr,"JBP: CallTo32_LargeStack called with unsupported " "number of arguments (%d). Ignored.\n",nbargs); return 0; @@ -40,25 +43,6 @@ int CallTo32_LargeStack( int (*func)(), int nbargs, ...) WORD CallTo16_word_ ( FARPROC func, WORD arg ) { return func(arg); } -/* typedef void* ATOM; */ -/* ATOM GlobalAddAtom(char *n) */ -/* { */ -/* return strdup(n); */ -/* } */ -/* GlobalDeleteAtom(ATOM n) */ -/* { */ -/* free(n); */ -/* } */ -/* GlobalFindAtom(char*n) */ -/* { */ -/* fprintf(stderr,"JBP: GlobalFindAtom() ignored.\n"); */ -/* return 0; */ -/* } */ -/* char *GlobalGetAtomName(ATOM a) */ -/* { */ -/* return a; */ -/* } */ - void GlobalFreeAll(HANDLE owner) { fprintf(stderr,"JBP: GlobalFreeAll() ignored.\n"); @@ -70,123 +54,36 @@ SEGPTR WIN16_GlobalLock(HGLOBAL h) } - -#if 0 -typedef WORD* HLOCAL; - -int IsValidHLOCAL(HLOCAL handle) -{ - return *(handle-1) + *(handle-2) == 0; /* Valid HLOCAL's sum to 0 */ -} - -/*********************************************************************** - * LOCAL_Free - * - */ HLOCAL LOCAL_Free( WORD ds, HLOCAL handle ) { - if (!IsValidHLOCAL(handle)) return handle; /* couldn't free it */ - free(handle-2); - return 0; -} - - -/*********************************************************************** - * LOCAL_Alloc - * - */ -HLOCAL LOCAL_Alloc( WORD ds, WORD flags, WORD size ) -{ - HLOCAL handle; - - handle = malloc(size + 2*sizeof(WORD)); - handle += 2; - *(handle-2) = size; - *(handle-1) = -size; - return handle; -} - - -/*********************************************************************** - * LOCAL_ReAlloc - * - */ -HLOCAL LOCAL_ReAlloc( WORD ds, HLOCAL handle, WORD size, WORD flags ) -{ - HLOCAL newhandle; - - if(!IsValidHLOCAL(handle))return 0; - newhandle = realloc(handle-2, size+2*sizeof(WORD)); - newhandle += 2; - *(newhandle-2) = size; - *(newhandle-1) = -size; - return newhandle; -} - - -/*********************************************************************** - * LOCAL_Lock - */ -WORD LOCAL_Lock( WORD ds, HLOCAL handle ) -{ - if(!IsValidHLOCAL(handle))return 0; - return handle; -} - - -/*********************************************************************** - * LOCAL_Unlock - */ -BOOL LOCAL_Unlock( WORD ds, HLOCAL handle ) -{ - return TRUE; -} - - -/*********************************************************************** - * LOCAL_Size - * - */ -WORD LOCAL_Size( WORD ds, HLOCAL handle ) -{ - return *(handle-2); -} -#endif - -HLOCAL LOCAL_Free( WORD ds, HLOCAL handle ) -{ - fprintf(stderr,"JBP: LOCAL_*() ignored.\n"); - return 0; + return LocalFree(handle); } HLOCAL LOCAL_Alloc( WORD ds, WORD flags, WORD size ) { - fprintf(stderr,"JBP: LOCAL_*() ignored.\n"); - return 0; + return LocalAlloc(flags,size); } HLOCAL LOCAL_ReAlloc( WORD ds, HLOCAL handle, WORD size, WORD flags ) { - fprintf(stderr,"JBP: LOCAL_*() ignored.\n"); - return 0; + return LocalReAlloc(handle,size,flags); } -WORD LOCAL_Lock( WORD ds, HLOCAL handle ) +NPVOID LOCAL_Lock( WORD ds, HLOCAL handle ) { - fprintf(stderr,"JBP: LOCAL_*() ignored.\n"); - return 0; + return LocalLock(handle); } BOOL LOCAL_Unlock( WORD ds, HLOCAL handle ) { - fprintf(stderr,"JBP: LOCAL_*() ignored.\n"); - return 1; + fprintf(stderr,"JBP: LOCAL_Unlock() ignored.\n"); + return 1; } WORD LOCAL_Size( WORD ds, HLOCAL handle ) { - fprintf(stderr,"JBP: LOCAL_*() ignored.\n"); - return 0; + fprintf(stderr,"JBP: LOCAL_Size() ignored.\n"); + return 0; } void FarSetOwner(HANDLE a, WORD b) @@ -240,17 +137,17 @@ HGLOBAL GLOBAL_CreateBlock( WORD flags, void *ptr, DWORD size, BOOL is32Bit, BOOL isReadOnly, SHMDATA *shmdata) { - fprintf(stderr,"JBP: GLOBAL_CreateBlock() faked.\n"); +/* fprintf(stderr,"JBP: GLOBAL_CreateBlock() faked.\n");*/ return ptr; } BOOL GLOBAL_FreeBlock( HGLOBAL handle ) { - fprintf(stderr,"JBP: GLOBAL_FreeBlock() ignored.\n"); +/* fprintf(stderr,"JBP: GLOBAL_FreeBlock() ignored.\n");*/ return 1; } -DWORD GlobalHandle(WORD a) +HGLOBAL GlobalHandle(LPCVOID a) { fprintf(stderr,"JBP: GlobalHandle() ignored.\n"); return 0; @@ -258,7 +155,7 @@ DWORD GlobalHandle(WORD a) void *RELAY32_GetEntryPoint(char *dll_name, char *item, int hint) { - fprintf(stderr,"JBP: RELAY32_GetEntryPoint() ignored.\n"); +/* fprintf(stderr,"JBP: RELAY32_GetEntryPoint() ignored.\n");*/ return NULL; } diff --git a/toolkit/winmain.c b/toolkit/winmain.c index 1982f6bf987..f132725674e 100644 --- a/toolkit/winmain.c +++ b/toolkit/winmain.c @@ -11,10 +11,13 @@ extern int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int); extern void TASK_Reschedule(void); extern int USER_InitApp(HINSTANCE); +char* progname=NULL; + int _WinMain (int argc, char *argv []) { HINSTANCE hInstance; + progname=*argv; if(!MAIN_Init()) return 0; /* JBP: Needed for DosDrives[] structure, etc. */ hInstance = WinExec( *argv, SW_SHOWNORMAL ); TASK_Reschedule(); diff --git a/tools/build.c b/tools/build.c index 59588755d6b..70ff43f22de 100644 --- a/tools/build.c +++ b/tools/build.c @@ -84,6 +84,32 @@ static int debugging = 1; ((int)&(((struct sigcontext_struct *)1)->reg) - 1 \ - sizeof(struct sigcontext_struct)) +static void *xmalloc (size_t size) +{ + void *res; + + res = malloc (size ? size : 1); + if (res == NULL) + { + fprintf (stderr, "Virtual memory exhausted.\n"); + exit (1); + } + return res; +} + + +static void *xrealloc (void *ptr, size_t size) +{ + void *res = realloc (ptr, size); + if (res == NULL) + { + fprintf (stderr, "Virtual memory exhausted.\n"); + exit (1); + } + return res; +} + + static int IsNumberString(char *s) { while (*s != '\0') @@ -155,7 +181,7 @@ static char * GetToken(void) if (ParseBuffer == NULL) { - ParseBuffer = malloc(512); + ParseBuffer = xmalloc(512); ParseNext = ParseBuffer; Line++; while (1) @@ -205,7 +231,7 @@ static int ParseVariable(int ordinal, int type) n_values = 0; value_array_size = 25; - value_array = malloc(sizeof(*value_array) * value_array_size); + value_array = xmalloc(sizeof(*value_array) * value_array_size); while ((token = GetToken()) != NULL) { @@ -216,8 +242,8 @@ static int ParseVariable(int ordinal, int type) if (n_values == value_array_size) { value_array_size += 25; - value_array = realloc(value_array, - sizeof(*value_array) * value_array_size); + value_array = xrealloc(value_array, + sizeof(*value_array) * value_array_size); } if (endptr == NULL || *endptr != '\0') @@ -244,11 +270,11 @@ static int ParseVariable(int ordinal, int type) odp->type = type; strcpy(odp->export_name, export_name); - vdp = malloc(sizeof(*vdp)); + vdp = xmalloc(sizeof(*vdp)); odp->additional_data = vdp; vdp->n_values = n_values; - vdp->values = realloc(value_array, sizeof(*value_array) * n_values); + vdp->values = xrealloc(value_array, sizeof(*value_array) * n_values); return 0; } @@ -263,7 +289,7 @@ static int ParseExportFunction(int ordinal, int type) odp = &OrdinalDefinitions[ordinal]; strcpy(odp->export_name, GetToken()); odp->type = type; - fdp = malloc(sizeof(*fdp)); + fdp = xmalloc(sizeof(*fdp)); odp->additional_data = fdp; token = GetToken(); @@ -331,7 +357,7 @@ static int ParseReturn(int ordinal) char *token; char *endptr; - rdp = malloc(sizeof(*rdp)); + rdp = xmalloc(sizeof(*rdp)); odp = &OrdinalDefinitions[ordinal]; strcpy(odp->export_name, GetToken()); @@ -368,7 +394,7 @@ static int ParseStub( int ordinal ) odp = &OrdinalDefinitions[ordinal]; strcpy( odp->export_name, GetToken() ); odp->type = TYPE_STUB; - fdp = malloc(sizeof(*fdp)); + fdp = xmalloc(sizeof(*fdp)); odp->additional_data = fdp; fdp->arg_types[0] = '\0'; strcpy( fdp->internal_name, STUB_CALLBACK ); @@ -533,7 +559,7 @@ static void BuildModule( int max_code_offset, int max_data_offset ) * BYTE[n] Entry table */ - buffer = malloc( 0x10000 ); + buffer = xmalloc( 0x10000 ); pModule = (NE_MODULE *)buffer; pModule->magic = NE_SIGNATURE; @@ -1625,7 +1651,7 @@ int main(int argc, char **argv) { /* File header */ - printf( "/* File generated automatically. Do no edit! */\n\n" ); + printf( "/* File generated automatically. Do not edit! */\n\n" ); printf( "\t.text\n" ); /* Build the 32-bit large stack callback */ @@ -1652,7 +1678,7 @@ int main(int argc, char **argv) { /* File header */ - printf( "/* File generated automatically. Do no edit! */\n\n" ); + printf( "/* File generated automatically. Do not edit! */\n\n" ); printf( "\t.text\n" ); printf( "\t.globl " PREFIX "CALL16_Start\n" ); printf( PREFIX "CALL16_Start:\n" ); diff --git a/win32/file.c b/win32/file.c index 61b4a09ab12..160fc409ca0 100644 --- a/win32/file.c +++ b/win32/file.c @@ -21,7 +21,7 @@ DWORD GetFileType(HANDLE hFile) { DWORD file_type; - if(hFile < 3) + if((DWORD)hFile < 3) { file_type = 2; /* FILE_TYPE_CHAR */ } @@ -67,7 +67,7 @@ DWORD SetFilePointer(HANDLE hFile, LONG distance, LONG *highword, } } - rc = lseek(hFile, distance, method); + rc = lseek((DWORD)hFile, distance, method); if(rc == -1) SetLastError(ErrnoToLastError(errno)); return rc; @@ -84,9 +84,9 @@ BOOL WriteFile(HANDLE hFile, LPVOID lpBuffer, DWORD numberOfBytesToWrite, { int written; - if(hFile < 3) + if((DWORD)hFile < 3) { - written = write(hFile, lpBuffer, numberOfBytesToWrite); + written = write((DWORD)hFile, lpBuffer, numberOfBytesToWrite); if(numberOfBytesWritten) *numberOfBytesWritten = written; } diff --git a/win32/init.c b/win32/init.c index 8000edc7027..0554a2f4b16 100644 --- a/win32/init.c +++ b/win32/init.c @@ -33,9 +33,9 @@ VOID GetStartupInfoA(LPSTARTUPINFO lpStartupInfo) lpStartupInfo->lpTitle = "Title"; lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */ - lpStartupInfo->hStdInput = 0; - lpStartupInfo->hStdOutput = 1; - lpStartupInfo->hStdError = 2; + lpStartupInfo->hStdInput = (HANDLE)0; + lpStartupInfo->hStdOutput = (HANDLE)1; + lpStartupInfo->hStdError = (HANDLE)2; } int KERN32_Init(void) diff --git a/windows/defdlg.c b/windows/defdlg.c index 9f30af19fea..4f152fb8301 100644 --- a/windows/defdlg.c +++ b/windows/defdlg.c @@ -62,6 +62,7 @@ static BOOL DEFDLG_RestoreFocus( HWND hwnd, DIALOGINFO *infoPtr ) } +#ifdef SUPERFLUOUS_FUNCTIONS /*********************************************************************** * DEFDLG_FindDefButton * @@ -78,6 +79,7 @@ static HWND DEFDLG_FindDefButton( HWND hwndDlg ) } return hwndChild; } +#endif /*********************************************************************** diff --git a/windows/defwnd.c b/windows/defwnd.c index 1479b689546..eda4fe27514 100644 --- a/windows/defwnd.c +++ b/windows/defwnd.c @@ -71,7 +71,10 @@ LRESULT DefWindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) return NC_HandleNCPaint( hwnd ); case WM_NCHITTEST: - return NC_HandleNCHitTest( hwnd, MAKEPOINT(lParam) ); + { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + return NC_HandleNCHitTest( hwnd, pt ); + } case WM_NCLBUTTONDOWN: return NC_HandleNCLButtonDown( hwnd, wParam, lParam ); @@ -236,7 +239,10 @@ LRESULT DefWindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) return NC_HandleSetCursor( hwnd, wParam, lParam ); case WM_SYSCOMMAND: - return NC_HandleSysCommand( hwnd, wParam, MAKEPOINT(lParam) ); + { + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; + return NC_HandleSysCommand( hwnd, wParam, pt ); + } case WM_SYSKEYDOWN: if (wParam == VK_MENU) diff --git a/windows/dialog.c b/windows/dialog.c index 8dc29c4be2e..6a168053e8e 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -328,12 +328,29 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, SEGPTR dlgTemplate, if (hMenu) DestroyMenu( hMenu ); return 0; } + wndPtr = WIN_FindWndPtr( hwnd ); + + /* Purge junk from system menu */ + /* FIXME: this doesn't belong here */ + + DeleteMenu(wndPtr->hSysMenu,SC_SIZE,MF_BYCOMMAND); + if (!(wndPtr->dwStyle & WS_MAXIMIZEBOX) ) + { + DeleteMenu(wndPtr->hSysMenu,SC_MAXIMIZE,MF_BYCOMMAND); + if( !(wndPtr->dwStyle & WS_MINIMIZEBOX) ) + { + DeleteMenu(wndPtr->hSysMenu,SC_MINIMIZE,MF_BYCOMMAND); + DeleteMenu(wndPtr->hSysMenu,SC_RESTORE,MF_BYCOMMAND); + } + } + else + if (!(wndPtr->dwStyle & WS_MINIMIZEBOX) ) + DeleteMenu(wndPtr->hSysMenu,SC_MINIMIZE,MF_BYCOMMAND); /* Create control windows */ dprintf_dialog(stddeb, " BEGIN\n" ); - wndPtr = WIN_FindWndPtr( hwnd ); dlgInfo = (DIALOGINFO *)wndPtr->wExtra; dlgInfo->msgResult = 0; /* This is used to store the default button id */ dlgInfo->hDialogHeap = 0; @@ -469,7 +486,7 @@ static int DIALOG_DoDialogBox( HWND hwnd, HWND owner ) EnableWindow( owner, FALSE ); ShowWindow( hwnd, SW_SHOW ); - while (MSG_InternalGetMessage( USER_HEAP_SEG_ADDR(msgHandle), hwnd, owner, + while (MSG_InternalGetMessage( (SEGPTR)USER_HEAP_SEG_ADDR(msgHandle), hwnd, owner, MSGF_DIALOGBOX, PM_REMOVE, !(wndPtr->dwStyle & DS_NOIDLEMSG) )) { diff --git a/windows/event.c b/windows/event.c index a91d24832e3..28f21e1f43c 100644 --- a/windows/event.c +++ b/windows/event.c @@ -19,6 +19,8 @@ #include "message.h" #include "clipboard.h" #include "winpos.h" +#include "registers.h" +#include "stackframe.h" #include "stddebug.h" /* #define DEBUG_EVENT */ /* #define DEBUG_KEY */ @@ -586,6 +588,58 @@ HWND GetCapture() } +/*********************************************************************** + * GetMouseEventProc (USER.337) + */ +FARPROC GetMouseEventProc(void) +{ + char name[] = "Mouse_Event"; + return GetProcAddress( GetModuleHandle("USER"), MAKE_SEGPTR(name) ); +} + + +/*********************************************************************** + * Mouse_Event (USER.299) + */ +#ifndef WINELIB +void Mouse_Event( struct sigcontext_struct context ) +{ + /* Register values: + * AX = mouse event + * BX = horizontal displacement if AX & ME_MOVE + * CX = vertical displacement if AX & ME_MOVE + * DX = button state (?) + * SI = mouse event flags (?) + */ + Window root, child; + int rootX, rootY, childX, childY; + unsigned int state; + + if (AX_reg(&context) & ME_MOVE) + { + /* We have to actually move the cursor */ + XWarpPointer( display, rootWindow, None, 0, 0, 0, 0, + (short)BX_reg(&context), (short)CX_reg(&context) ); + return; + } + if (!XQueryPointer( display, rootWindow, &root, &child, + &rootX, &rootY, &childX, &childY, &state )) return; + if (AX_reg(&context) & ME_LDOWN) + hardware_event( WM_LBUTTONDOWN, EVENT_XStateToKeyState( state ), 0L, + rootX - desktopX, rootY - desktopY, GetTickCount(), 0); + if (AX_reg(&context) & ME_LUP) + hardware_event( WM_LBUTTONUP, EVENT_XStateToKeyState( state ), 0L, + rootX - desktopX, rootY - desktopY, GetTickCount(), 0); + if (AX_reg(&context) & ME_RDOWN) + hardware_event( WM_RBUTTONDOWN, EVENT_XStateToKeyState( state ), 0L, + rootX - desktopX, rootY - desktopY, GetTickCount(), 0); + if (AX_reg(&context) & ME_RUP) + hardware_event( WM_RBUTTONUP, EVENT_XStateToKeyState( state ), 0L, + rootX - desktopX, rootY - desktopY, GetTickCount(), 0); +} +#endif + + /********************************************************************** * EnableHardwareInput [USER.331] */ diff --git a/windows/graphics.c b/windows/graphics.c index 608fbea13d3..d4475ba0bf8 100644 --- a/windows/graphics.c +++ b/windows/graphics.c @@ -21,6 +21,7 @@ #include "color.h" #include "region.h" #include "debug.h" +#include "xmalloc.h" static __inline__ void swap_int(int *a, int *b) { @@ -786,7 +787,7 @@ BOOL Polygon (HDC hdc, LPPOINT pt, int count) { register int i; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - XPoint *points = (XPoint *) malloc (sizeof (XPoint) * (count+1)); + XPoint *points = (XPoint *) xmalloc (sizeof (XPoint) * (count+1)); if (!dc) { @@ -847,7 +848,7 @@ BOOL PolyPolygon( HDC hdc, LPPOINT pt, LPINT counts, WORD polygons ) XPoint *points; for (i = 0; i < polygons; i++) if (counts[i] > max) max = counts[i]; - points = (XPoint *) malloc( sizeof(XPoint) * (max+1) ); + points = (XPoint *) xmalloc( sizeof(XPoint) * (max+1) ); for (i = 0; i < polygons; i++) { diff --git a/windows/hook.c b/windows/hook.c index 08472af7e35..d56c93f1011 100644 --- a/windows/hook.c +++ b/windows/hook.c @@ -109,7 +109,7 @@ HHOOK SetWindowsHookEx( short id, HOOKPROC proc, HINSTANCE hinst, HTASK htask ) if ((id < FIRST_HOOK) || (id > LAST_HOOK)) return 0; if (id != WH_GETMESSAGE && id != WH_CALLWNDPROC) { - fprintf( stdnimp, "Unimplemented hook set: (%d,%08lx,%04x,%04x)!\n", + fprintf( stdnimp, "Unimplemented hook set: (%d,%08lx,"NPFMT","NPFMT")!\n", id, (DWORD)proc, hinst, htask ); } if (htask) /* Task-specific hook */ diff --git a/windows/mdi.c b/windows/mdi.c index 76f6d87f545..e1a3ddfab2a 100644 --- a/windows/mdi.c +++ b/windows/mdi.c @@ -414,8 +414,9 @@ LONG MDICascade(HWND parent, MDICLIENTINFO *ci) xsize = rect.right - 8 * spacing; dprintf_mdi(stddeb, - "MDICascade: Client wnd at (%d,%d) - (%d,%d), spacing %d\n", - rect.left, rect.top, rect.right, rect.bottom, spacing); + "MDICascade: Client wnd at (%ld,%ld) - (%ld,%ld), spacing %d\n", + (LONG)rect.left, (LONG)rect.top, (LONG)rect.right, (LONG)rect.bottom, + spacing); dprintf_mdi(stddeb, "MDICascade: searching for last child\n"); hinfo = ci->infoActiveChildren; while(1) { diff --git a/windows/message.c b/windows/message.c index adefb1475e9..a30935614e6 100644 --- a/windows/message.c +++ b/windows/message.c @@ -291,6 +291,7 @@ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) static DWORD lastClickTime = 0; static WORD lastClickMsg = 0; static POINT lastClickPos = { 0, 0 }; + POINT pt = msg->pt; BOOL mouseClick = ((msg->message == WM_LBUTTONDOWN) || (msg->message == WM_RBUTTONDOWN) || @@ -301,8 +302,8 @@ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) if (GetCapture()) { msg->hwnd = GetCapture(); - msg->lParam = MAKELONG( msg->pt.x, msg->pt.y ); - ScreenToClient( msg->hwnd, (LPPOINT)&msg->lParam ); + ScreenToClient( msg->hwnd, &pt ); + msg->lParam = MAKELONG( pt.x, pt.y ); return TRUE; /* No need to further process the message */ } @@ -379,16 +380,14 @@ static BOOL MSG_TranslateMouseMsg( MSG *msg, BOOL remove ) /* Build the translated message */ - msg->lParam = MAKELONG( msg->pt.x, msg->pt.y ); if (hittest == HTCLIENT) - { - ScreenToClient( msg->hwnd, (LPPOINT)&msg->lParam ); - } + ScreenToClient( msg->hwnd, &pt ); else { msg->wParam = hittest; msg->message += WM_NCLBUTTONDOWN - WM_LBUTTONDOWN; } + msg->lParam = MAKELONG( pt.x, pt.y ); return TRUE; } @@ -952,7 +951,7 @@ BOOL PeekMessage( LPMSG msg, HWND hwnd, WORD first, WORD last, WORD flags ) /*********************************************************************** * GetMessage (USER.108) */ -BOOL GetMessage( SEGPTR msg, HWND hwnd, WORD first, WORD last ) +BOOL GetMessage( SEGPTR msg, HWND hwnd, UINT first, UINT last ) { MSG_PeekMessage( (MSG *)PTR_SEG_TO_LIN(msg), hwnd, first, last, PM_REMOVE, FALSE ); diff --git a/windows/msgbox.c b/windows/msgbox.c index e0cd46cebf5..ddb9690b67d 100644 --- a/windows/msgbox.c +++ b/windows/msgbox.c @@ -121,7 +121,7 @@ LRESULT SystemMessageBoxProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) lRet = DrawText(hdc, lpmb->text, -1, &rect, DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT); theight = rect.bottom - rect.top; - tiheight = 16 + max(iheight, theight); + tiheight = 16 + MAX(iheight, theight); ReleaseDC(hItem, hdc); /* Position the text */ diff --git a/windows/nonclient.c b/windows/nonclient.c index aa77bef4ba6..086dc181e68 100644 --- a/windows/nonclient.c +++ b/windows/nonclient.c @@ -102,8 +102,9 @@ void AdjustWindowRectEx( LPRECT rect, DWORD style, BOOL menu, DWORD exStyle ) style |= WS_CAPTION; if (exStyle & WS_EX_DLGMODALFRAME) style &= ~WS_THICKFRAME; - dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%d,%d)-(%d,%d) %08lx %d %08lx\n", - rect->left, rect->top, rect->right, rect->bottom, style, menu, exStyle ); + dprintf_nonclient(stddeb, "AdjustWindowRectEx: (%ld,%ld)-(%ld,%ld) %08lx %d %08lx\n", + (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, (LONG)rect->bottom, + style, menu, exStyle ); NC_AdjustRect( rect, style, menu, exStyle ); } @@ -176,9 +177,9 @@ void NC_GetMinMaxInfo( HWND hwnd, POINT *maxSize, POINT *maxPos, /* Some sanity checks */ - pMinMax->ptMaxTrackSize.x = max( pMinMax->ptMaxTrackSize.x, + pMinMax->ptMaxTrackSize.x = MAX( pMinMax->ptMaxTrackSize.x, pMinMax->ptMinTrackSize.x ); - pMinMax->ptMaxTrackSize.y = max( pMinMax->ptMaxTrackSize.y, + pMinMax->ptMaxTrackSize.y = MAX( pMinMax->ptMaxTrackSize.y, pMinMax->ptMinTrackSize.y ); if (maxSize) *maxSize = pMinMax->ptMaxSize; @@ -260,8 +261,8 @@ LONG NC_HandleNCHitTest( HWND hwnd, POINT pt ) WND *wndPtr = WIN_FindWndPtr( hwnd ); if (!wndPtr) return HTERROR; - dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd="NPFMT" pt=%d,%d\n", - hwnd, pt.x, pt.y ); + dprintf_nonclient(stddeb, "NC_HandleNCHitTest: hwnd="NPFMT" pt=%ld,%ld\n", + hwnd, (LONG)pt.x, (LONG)pt.y ); GetWindowRect( hwnd, &rect ); if (!PtInRect( &rect, pt )) return HTNOWHERE; @@ -927,23 +928,23 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) else SetRect( &mouseRect, 0, 0, SYSMETRICS_CXSCREEN, SYSMETRICS_CYSCREEN ); if (ON_LEFT_BORDER(hittest)) { - mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x ); - mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x ); + mouseRect.left = MAX( mouseRect.left, sizingRect.right-maxTrack.x ); + mouseRect.right = MIN( mouseRect.right, sizingRect.right-minTrack.x ); } else if (ON_RIGHT_BORDER(hittest)) { - mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x ); - mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x ); + mouseRect.left = MAX( mouseRect.left, sizingRect.left+minTrack.x ); + mouseRect.right = MIN( mouseRect.right, sizingRect.left+maxTrack.x ); } if (ON_TOP_BORDER(hittest)) { - mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y ); - mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y); + mouseRect.top = MAX( mouseRect.top, sizingRect.bottom-maxTrack.y ); + mouseRect.bottom = MIN( mouseRect.bottom,sizingRect.bottom-minTrack.y); } else if (ON_BOTTOM_BORDER(hittest)) { - mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y ); - mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y ); + mouseRect.top = MAX( mouseRect.top, sizingRect.top+minTrack.y ); + mouseRect.bottom = MIN( mouseRect.bottom, sizingRect.top+maxTrack.y ); } SendMessage( hwnd, WM_ENTERSIZEMOVE, 0, 0 ); @@ -988,10 +989,10 @@ static void NC_DoSizeMove( HWND hwnd, WORD wParam, POINT pt ) case VK_RIGHT: pt.x += 8; break; } - pt.x = max( pt.x, mouseRect.left ); - pt.x = min( pt.x, mouseRect.right ); - pt.y = max( pt.y, mouseRect.top ); - pt.y = min( pt.y, mouseRect.bottom ); + pt.x = MAX( pt.x, mouseRect.left ); + pt.x = MIN( pt.x, mouseRect.right ); + pt.y = MAX( pt.y, mouseRect.top ); + pt.y = MIN( pt.y, mouseRect.bottom ); dx = pt.x - capturePoint.x; dy = pt.y - capturePoint.y; @@ -1120,9 +1121,10 @@ static void NC_TrackScrollBar( HWND hwnd, WORD wParam, POINT pt ) case WM_LBUTTONUP: case WM_MOUSEMOVE: case WM_SYSTIMER: - pt = MAKEPOINT(msg->lParam); - pt.x += wndPtr->rectClient.left - wndPtr->rectWindow.left; - pt.y += wndPtr->rectClient.top - wndPtr->rectWindow.top; + pt.x = LOWORD(msg->lParam) + wndPtr->rectClient.left - + wndPtr->rectWindow.left; + pt.y = HIWORD(msg->lParam) + wndPtr->rectClient.top - + wndPtr->rectWindow.top; SCROLL_HandleScrollEvent( hwnd, scrollbar, msg->message, pt ); break; default: @@ -1177,6 +1179,7 @@ static void NC_TrackSysMenu( HWND hwnd, HDC hdc, POINT pt ) LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) { HDC hdc = GetWindowDC( hwnd ); + POINT pt = { LOWORD(lParam), HIWORD(lParam) }; switch(wParam) /* Hit test */ { @@ -1185,7 +1188,7 @@ LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ) break; case HTSYSMENU: - NC_TrackSysMenu( hwnd, hdc, MAKEPOINT(lParam) ); + NC_TrackSysMenu( hwnd, hdc, pt ); break; case HTMENU: @@ -1245,8 +1248,11 @@ LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam ) switch(wParam) /* Hit test */ { case HTCAPTION: - SendMessage( hwnd, WM_SYSCOMMAND, - IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam ); + /* stop processing if WS_MAXIMIZEBOX is missing */ + + if( GetWindowLong( hwnd , GWL_STYLE) & WS_MAXIMIZEBOX ) + SendMessage( hwnd, WM_SYSCOMMAND, + IsZoomed(hwnd) ? SC_RESTORE : SC_MAXIMIZE, lParam ); break; case HTSYSMENU: @@ -1266,8 +1272,8 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ) { WND *wndPtr = WIN_FindWndPtr( hwnd ); - dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %lx %d,%d\n", - (DWORD)wParam, pt.x, pt.y ); + dprintf_nonclient(stddeb, "Handling WM_SYSCOMMAND %lx %ld,%ld\n", + (DWORD)wParam, (LONG)pt.x, (LONG)pt.y ); if (wndPtr->dwStyle & WS_CHILD) ScreenToClient( wndPtr->hwndParent, &pt ); diff --git a/windows/painting.c b/windows/painting.c index 7e166320d47..014426df0a0 100644 --- a/windows/painting.c +++ b/windows/painting.c @@ -140,9 +140,9 @@ BOOL RedrawWindow( HWND hwnd, LPRECT rectUpdate, HRGN hrgnUpdate, UINT flags ) if (rectUpdate) { - dprintf_win( stddeb, "RedrawWindow: "NPFMT" %d,%d-%d,%d "NPFMT" flags=%04x\n", - hwnd, rectUpdate->left, rectUpdate->top, - rectUpdate->right, rectUpdate->bottom, hrgnUpdate, flags); + dprintf_win( stddeb, "RedrawWindow: "NPFMT" %ld,%ld-%ld,%ld "NPFMT" flags=%04x\n", + hwnd, (LONG)rectUpdate->left, (LONG)rectUpdate->top, + (LONG)rectUpdate->right, (LONG)rectUpdate->bottom, hrgnUpdate, flags); } else { diff --git a/windows/scroll.c b/windows/scroll.c index d662983e36c..b24fcbfe1f1 100644 --- a/windows/scroll.c +++ b/windows/scroll.c @@ -27,8 +27,8 @@ void ScrollWindow(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect) HRGN hrgnUpdate; RECT rc, cliprc; - dprintf_scroll(stddeb,"ScrollWindow: dx=%d, dy=%d, rect=%d,%d,%d,%d\n", - dx, dy, rect->left, rect->top, rect->right, rect->bottom); + dprintf_scroll(stddeb,"ScrollWindow: dx=%d, dy=%d, rect=%ld,%ld,%ld,%ld\n", + dx, dy, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, (LONG)rect->bottom); hdc = GetDC(hwnd); @@ -60,8 +60,8 @@ BOOL ScrollDC(HDC hdc, short dx, short dy, LPRECT rc, LPRECT cliprc, short width, height; DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC); - dprintf_scroll(stddeb, "ScrollDC: dx=%d, dy=%d, rc=%d,%d,%d,%d\n", dx, dy, - rc->left, rc->top, rc->right, rc->bottom); + dprintf_scroll(stddeb, "ScrollDC: dx=%d, dy=%d, rc=%ld,%ld,%ld,%ld\n", dx, dy, + (LONG)rc->left, (LONG)rc->top, (LONG)rc->right, (LONG)rc->bottom); if (rc == NULL) return FALSE; @@ -136,8 +136,9 @@ int ScrollWindowEx(HWND hwnd, short dx, short dy, LPRECT rect, LPRECT clipRect, HDC hdc; RECT rc, cliprc; - dprintf_scroll(stddeb,"ScrollWindowEx: dx=%d, dy=%d, rect=%d,%d,%d,%d\n", - dx, dy, rect->left, rect->top, rect->right, rect->bottom); + dprintf_scroll(stddeb,"ScrollWindowEx: dx=%d, dy=%d, rect=%ld,%ld,%ld,%ld\n", + dx, dy, (LONG)rect->left, (LONG)rect->top, (LONG)rect->right, + (LONG)rect->bottom); hdc = GetDC(hwnd); diff --git a/windows/sysmetrics.c b/windows/sysmetrics.c index 3aa9bb33a9e..64b80dc836a 100644 --- a/windows/sysmetrics.c +++ b/windows/sysmetrics.c @@ -10,7 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1994"; #include "gdi.h" #include "sysmetrics.h" -short sysMetrics[SM_CMETRICS]; +short sysMetrics[SM_CMETRICS+1]; /*********************************************************************** * SYSMETRICS_Init @@ -62,6 +62,7 @@ void SYSMETRICS_Init(void) sysMetrics[SM_MENUDROPALIGNMENT] = GetProfileInt( "windows","MenuDropAlignment", 0 ); sysMetrics[SM_PENWINDOWS] = 0; sysMetrics[SM_DBCSENABLED] = 0; + sysMetrics[SM_CMETRICS] = SM_CMETRICS; } @@ -70,6 +71,6 @@ void SYSMETRICS_Init(void) */ int GetSystemMetrics( WORD index ) { - if (index >= SM_CMETRICS) return 0; + if (index > SM_CMETRICS) return 0; else return sysMetrics[index]; } diff --git a/windows/win.c b/windows/win.c index 164b563beff..1e0d209ed46 100644 --- a/windows/win.c +++ b/windows/win.c @@ -209,7 +209,7 @@ static void WIN_DestroyWindow( HWND hwnd ) } if (!(wndPtr->dwStyle & WS_CHILD)) { - if (wndPtr->wIDmenu) DestroyMenu( wndPtr->wIDmenu ); + if (wndPtr->wIDmenu) DestroyMenu( (HMENU)wndPtr->wIDmenu ); } if (wndPtr->hSysMenu) DestroyMenu( wndPtr->hSysMenu ); if (wndPtr->window) XDestroyWindow( display, wndPtr->window ); @@ -285,7 +285,7 @@ BOOL WIN_CreateDesktopWindow(void) * CreateWindow (USER.41) */ HWND CreateWindow( SEGPTR className, SEGPTR windowName, - DWORD style, short x, short y, short width, short height, + DWORD style, INT x, INT y, INT width, INT height, HWND parent, HMENU menu, HANDLE instance, SEGPTR data ) { return CreateWindowEx( 0, className, windowName, style, @@ -297,7 +297,7 @@ HWND CreateWindow( SEGPTR className, SEGPTR windowName, * CreateWindowEx (USER.452) */ HWND CreateWindowEx( DWORD exStyle, SEGPTR className, SEGPTR windowName, - DWORD style, short x, short y, short width, short height, + DWORD style, INT x, INT y, INT width, INT height, HWND parent, HMENU menu, HANDLE instance, SEGPTR data ) { HANDLE class, hwnd; @@ -465,7 +465,7 @@ HWND CreateWindowEx( DWORD exStyle, SEGPTR className, SEGPTR windowName, else if (classPtr->wc.lpszMenuName) SetMenu( hwnd, LoadMenu( instance, classPtr->wc.lpszMenuName ) ); } - else wndPtr->wIDmenu = menu; + else wndPtr->wIDmenu = (UINT)menu; /* Send the WM_CREATE message */ @@ -744,12 +744,13 @@ WORD SetWindowWord( HWND hwnd, short offset, WORD newval ) if (offset >= 0) ptr = (WORD *)(((char *)wndPtr->wExtra) + offset); else switch(offset) { - case GWW_ID: ptr = &wndPtr->wIDmenu; break; #ifdef WINELIB32 + case GWW_ID: case GWW_HINSTANCE: fprintf(stderr,"SetWindowWord called with offset %d.\n",offset); return 0; #else + case GWW_ID: ptr = &wndPtr->wIDmenu; break; case GWW_HINSTANCE: ptr = (WORD*)&wndPtr->hInstance; break; #endif default: return 0; diff --git a/windows/winpos.c b/windows/winpos.c index 32ca21c6da7..119b2651538 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -619,8 +619,8 @@ LONG WINPOS_HandleWindowPosChanging( WINDOWPOS *winpos ) (wndPtr->dwStyle & (WS_POPUP | WS_CHILD) == 0)) { NC_GetMinMaxInfo( winpos->hwnd, &maxSize, NULL, NULL, NULL ); - winpos->cx = min( winpos->cx, maxSize.x ); - winpos->cy = min( winpos->cy, maxSize.y ); + winpos->cx = MIN( winpos->cx, maxSize.x ); + winpos->cy = MIN( winpos->cy, maxSize.y ); } return 0; } @@ -702,7 +702,7 @@ static void WINPOS_MoveWindowZOrder( HWND hwnd, HWND hwndAfter ) /*********************************************************************** - * WINPOS_SetXWindosPos + * WINPOS_SetXWindowPos * * SetWindowPos() for an X window. Used by the real SetWindowPos(). */