From 73450d65c3c28bd51cbf195d2a6673604f24da6f Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 18 May 1994 18:29:32 +0000 Subject: [PATCH] Release 940518 Tue May 17 23:03:16 1994 Bob Amstadt (bob@pooh) * [windows/dce.c] Fixed bug with dce initialization that was causing dialog boxes to not be displayed. * [if1632/callback.c] Better fix for bug found by Martin. Sat May 14 19:48:39 1994 Rick Sladkey (jrs@world.std.com) * [ memory/heap.c ] Redirect HEAP_ReAlloc calls with NULL argument to HEAP_Alloc. May 16, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [objects/font.c] Make EnumFonts() calling a callback with dummy fonts ... :-) * [objects/text.c] Add Empty Stub for ExtTextOut(), which temporarely call Textout(). * [if1632/callback.c] Temporarely go around bug in CallWindowProc(), you will see printfs. * [controls/edit.c] Make EDIT controls focused by a mouse click. * [misc/property.c] Bug Fix in function EnumProps(), better use of CallBack16(). * [misc/mmsystem.c] Basic Skelton's for MCI messages dispatching function. Sun May 15 16:15:17 1994 Erik Bos (erik@hacktic.nl) * [windows/utility.c] Added windows_wsprintf() for the emulator, wsprintf() is for libwine. Sat May 14 22:16:40 1994 Rick Sladkey (jrs@world.std.com) * [misc/cursor.c] Fix pointer problems in LoadCursor leading to heap corruption. * [ controls/menu.c ] Fix two NULL dereferencing bugs. Sun May 15 20:07:48 1994 Rick Sladkey (jrs@world.std.com) * [objects/font.c] Fix NULL pointer dereferencing bug in GetCharWidth. * [loader/resource.c] Fix under-allocation of memory in LoadAccelerators. * [windows/class.c] Ignore negative sizes for extra fields in RegisterClass. Sun May 15 06:35:03 1994 David Metcalfe * [objects/metafile.c] [include/metafile.h] [include/windows.h] [objects/gdiobj.c] [objects/brush.c] [objects/pen.c] [objects/text.c] [objects/dcvalues.c] [windows/graphics.c] [windows/dc.c] [windows/mapping.c] Beginnings of metafile support. * [misc/file.c] Corrected spelling of _lcreat. * [controls/edit.c] Minor bug fixes. --- ChangeLog | 73 ++++++++++++ Imakefile | 4 + README | 7 ++ controls/edit.c | 8 +- controls/menu.c | 152 +++++++++++++------------ debugger/Imakefile | 17 +-- debugger/dbg.y | 6 +- debugger/info.c | 53 +++++---- if1632/callback.c | 39 ++++++- if1632/gdi.spec | 11 +- if1632/kernel.spec | 2 +- if1632/pop.h | 16 +++ if1632/shell.spec | 32 +++--- if1632/user.spec | 5 +- include/heap.h | 22 ++-- include/segmem.h | 9 +- include/windows.h | 146 ++++++++++++++++++++---- loader/library.c | 1 + loader/resource.c | 11 +- loader/task.c | 6 +- memory/global.c | 81 +++++++------- memory/heap.c | 26 +++-- misc/cursor.c | 4 +- misc/file.c | 16 +-- misc/mmsystem.c | 322 ++++++++++++++++++++++++++++++++++++++++++----------- misc/property.c | 49 +++++++- misc/shell.c | 31 +++--- misc/winsocket.c | 6 +- objects/Imakefile | 6 +- objects/brush.c | 21 ++++ objects/dcvalues.c | 23 ++-- objects/font.c | 138 ++++++++++++++++++++++- objects/gdiobj.c | 6 +- objects/pen.c | 6 +- objects/text.c | 24 +++- windows/class.c | 5 + windows/dc.c | 18 ++- windows/dialog.c | 5 + windows/graphics.c | 251 +++++++++++++++++++++++++++-------------- windows/mapping.c | 9 +- windows/utility.c | 155 ++++++++++++++++++++++---- windows/win.c | 9 ++ 42 files changed, 1388 insertions(+), 443 deletions(-) create mode 100644 if1632/pop.h diff --git a/ChangeLog b/ChangeLog index ed79d40e4f7..ed36b230216 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,77 @@ ---------------------------------------------------------------------- +Tue May 17 23:03:16 1994 Bob Amstadt (bob@pooh) + + * [windows/dce.c] + Fixed bug with dce initialization that was causing dialog boxes to not + be displayed. + + * [if1632/callback.c] + Better fix for bug found by Martin. + +Sat May 14 19:48:39 1994 Rick Sladkey (jrs@world.std.com) + + * [ memory/heap.c ] + Redirect HEAP_ReAlloc calls with NULL argument to HEAP_Alloc. + +May 16, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) + + * [objects/font.c] + Make EnumFonts() calling a callback with dummy fonts ... :-) + + * [objects/text.c] + Add Empty Stub for ExtTextOut(), which temporarely call Textout(). + + * [if1632/callback.c] + Temporarely go around bug in CallWindowProc(), you will see printfs. + + * [controls/edit.c] + Make EDIT controls focused by a mouse click. + + * [misc/property.c] + Bug Fix in function EnumProps(), better use of CallBack16(). + + * [misc/mmsystem.c] + Basic Skelton's for MCI messages dispatching function. + +Sun May 15 16:15:17 1994 Erik Bos (erik@hacktic.nl) + + * [windows/utility.c] + Added windows_wsprintf() for the emulator, wsprintf() is + for libwine. + +Sat May 14 22:16:40 1994 Rick Sladkey (jrs@world.std.com) + + * [misc/cursor.c] + Fix pointer problems in LoadCursor leading to heap corruption. + + * [ controls/menu.c ] + Fix two NULL dereferencing bugs. + +Sun May 15 20:07:48 1994 Rick Sladkey (jrs@world.std.com) + + * [objects/font.c] + Fix NULL pointer dereferencing bug in GetCharWidth. + + * [loader/resource.c] + Fix under-allocation of memory in LoadAccelerators. + + * [windows/class.c] + Ignore negative sizes for extra fields in RegisterClass. + +Sun May 15 06:35:03 1994 David Metcalfe + + * [objects/metafile.c] [include/metafile.h] [include/windows.h] + [objects/gdiobj.c] [objects/brush.c] [objects/pen.c] + [objects/text.c] [objects/dcvalues.c] [windows/graphics.c] + [windows/dc.c] [windows/mapping.c] + Beginnings of metafile support. + + * [misc/file.c] + Corrected spelling of _lcreat. + + * [controls/edit.c] + Minor bug fixes. +---------------------------------------------------------------------- May 9, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte) * [controls/scroll.c] diff --git a/Imakefile b/Imakefile index 5f126650370..f87fc8fe710 100644 --- a/Imakefile +++ b/Imakefile @@ -61,6 +61,7 @@ EMUOBJS = \ debugger.o \ memory.o \ miscemu.o \ + opcodes.o \ readline.o LIBOBJS = \ @@ -97,3 +98,6 @@ NormalLibraryTarget(wine,$(LIBOBJS) $(COMMONOBJS)) depend:: install:: + +etags:: + etags `find . -name '*.[chS]'` \ No newline at end of file diff --git a/README b/README index 40aadbce151..1d735be87ea 100644 --- a/README +++ b/README @@ -171,6 +171,13 @@ bob@amscons.com 7. WHAT'S NEW +WHAT'S NEW with Wine-940518: (see ChangeLog for details) + - debugger improvements + - bug fixes to get some dialog boxes working. + - skeleton for passing MCI functions. + - beginnings of metafile support. + - and many many bug fixes! + WHAT'S NEW with Wine-940510: (see ChangeLog for details) - debugger improvements - mmsystem diff --git a/controls/edit.c b/controls/edit.c index 55678c066a9..552824726e4 100644 --- a/controls/edit.c +++ b/controls/edit.c @@ -309,6 +309,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam) break; case WM_KEYDOWN: + printf("EDIT WM_KEYDOWN w=%04X !\n", wParam); EDIT_KeyDownMsg(hwnd, wParam); break; @@ -319,6 +320,7 @@ LONG EditWndProc(HWND hwnd, WORD uMsg, WORD wParam, LONG lParam) case WM_LBUTTONDOWN: HideCaret(hwnd); + SetFocus(hwnd); EDIT_LButtonDownMsg(hwnd, wParam, lParam); SetCaretPos(es->WndCol, es->WndRow * es->txtht); ShowCaret(hwnd); @@ -2043,8 +2045,6 @@ void EDIT_SetSelMsg(HWND hwnd, LONG lParam) WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HEAP_ADDR((HANDLE)(*(wndPtr->wExtra))); - if ((short)(lParam) < 0 || (short)(lParam >> 16) < 0) - return; so = LOWORD(lParam); eo = HIWORD(lParam); if (so > eo) @@ -2343,7 +2343,7 @@ LONG EDIT_LineFromCharMsg(HWND hwnd, WORD wParam) WND *wndPtr = WIN_FindWndPtr(hwnd); EDITSTATE *es = (EDITSTATE *)EDIT_HEAP_ADDR((HANDLE)(*(wndPtr->wExtra))); - if (wParam == 0xffff) /* really -1 */ + if (wParam == (WORD)-1) return (LONG)(es->SelBegLine); else EDIT_GetLineCol(hwnd, wParam, &row, &col); @@ -2362,7 +2362,7 @@ LONG EDIT_LineIndexMsg(HWND hwnd, WORD wParam) EDITSTATE *es = (EDITSTATE *)EDIT_HEAP_ADDR((HANDLE)(*(wndPtr->wExtra))); unsigned int *textPtrs = (unsigned int *)EDIT_HEAP_ADDR(es->hTextPtrs); - if (wParam == 0xffff) /* really -1 */ + if (wParam == (WORD)-1) wParam = es->CurrLine; return (LONG)(*(textPtrs + wParam)); diff --git a/controls/menu.c b/controls/menu.c index 9ef90f4147b..e41c96837f8 100644 --- a/controls/menu.c +++ b/controls/menu.c @@ -502,46 +502,53 @@ void MenuButtonUp(HWND hWnd, LPPOPUPMENU lppop, int x, int y) void MenuMouseMove(HWND hWnd, LPPOPUPMENU lppop, WORD wParam, int x, int y) { - HDC hDC; - RECT rect; - HMENU hSubMenu; - LPMENUITEM lpitem, lpitem2; - LPPOPUPMENU lppop2; - WORD wRet; -/* if ((wParam & MK_LBUTTON) != 0) { */ - if (GetKeyState(VK_LBUTTON) != 0) { - lpitem = MenuFindItem(lppop, x, y, &wRet); + HDC hDC; + RECT rect; + HMENU hSubMenu; + LPMENUITEM lpitem, lpitem2; + LPPOPUPMENU lppop2; + WORD wRet; + + if (GetKeyState(VK_LBUTTON) != 0) + { + lpitem = MenuFindItem(lppop, x, y, &wRet); #ifdef DEBUG_MENU - printf("MenuMouseMove // x=%d y=%d // wRet=%d lpitem=%08X !\n", - x, y, wRet, lpitem); -#endif - if ((lpitem != NULL) && (lppop->FocusedItem != wRet)) { - lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); - hDC = GetWindowDC(hWnd); - if ((lpitem2->item_flags & MF_POPUP) == MF_POPUP) { - HideAllSubPopupMenu(lppop); - } - MenuItemSelect(hWnd, lppop, wRet); - if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) { - hSubMenu = (HMENU)lpitem->item_id; - lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu); - if (lppop2 == NULL) { - ReleaseDC(hWnd, hDC); - return; - } - if (lppop->BarFlag) { - lppop2->hWndParent = hWnd; - GetWindowRect(hWnd, &rect); - rect.top += lppop->rect.bottom; - TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, - rect.left + lpitem->rect.left, rect.top, - 0, lppop->ownerWnd, (LPRECT)NULL); - } - GlobalUnlock(hSubMenu); - } - ReleaseDC(hWnd, hDC); - } + printf("MenuMouseMove // x=%d y=%d // wRet=%d lpitem=%08X !\n", + x, y, wRet, lpitem); +#endif + if ((lpitem != NULL) && (lppop->FocusedItem != wRet)) + { + lpitem2 = GetMenuItemPtr(lppop, lppop->FocusedItem); + hDC = GetWindowDC(hWnd); + if ((lpitem2 != NULL ) && + (lpitem2->item_flags & MF_POPUP) == MF_POPUP) + { + HideAllSubPopupMenu(lppop); + } + MenuItemSelect(hWnd, lppop, wRet); + if ((lpitem->item_flags & MF_POPUP) == MF_POPUP) + { + hSubMenu = (HMENU)lpitem->item_id; + lppop2 = (LPPOPUPMENU) GlobalLock(hSubMenu); + if (lppop2 == NULL) + { + ReleaseDC(hWnd, hDC); + return; + } + if (lppop->BarFlag) + { + lppop2->hWndParent = hWnd; + GetWindowRect(hWnd, &rect); + rect.top += lppop->rect.bottom; + TrackPopupMenu(hSubMenu, TPM_LEFTBUTTON, + rect.left + lpitem->rect.left, rect.top, + 0, lppop->ownerWnd, (LPRECT)NULL); } + GlobalUnlock(hSubMenu); + } + ReleaseDC(hWnd, hDC); + } + } } @@ -562,38 +569,46 @@ void ResetHiliteFlags(LPPOPUPMENU lppop) void MenuItemSelect0(HWND hWnd, LPPOPUPMENU lppop, LPMENUITEM lpitem, WORD wIndex) { - LPMENUITEM lpprev; - if (lppop == NULL) return; - if (lppop->FocusedItem != (WORD)-1) { - lpprev = GetMenuItemPtr(lppop, lppop->FocusedItem); - if (lpprev != NULL) { - lpprev->item_flags &= MF_HILITE ^ 0xFFFF; - if ((lpprev->item_flags & MF_POPUP) == MF_POPUP) - HideAllSubPopupMenu(lppop); - if (lppop->BarFlag) - DrawMenuBar(hWnd); - else { - InvalidateRect(hWnd, &lpprev->rect, TRUE); - UpdateWindow(hWnd); - } - } - } + LPMENUITEM lpprev; + + if (lppop == NULL) + return; + if (lppop->FocusedItem != (WORD)-1) + { + lpprev = GetMenuItemPtr(lppop, lppop->FocusedItem); + if (lpprev != NULL) + { + lpprev->item_flags &= MF_HILITE ^ 0xFFFF; + if ((lpprev->item_flags & MF_POPUP) == MF_POPUP) + HideAllSubPopupMenu(lppop); + if (lppop->BarFlag) + DrawMenuBar(hWnd); + else + { + InvalidateRect(hWnd, &lpprev->rect, TRUE); + UpdateWindow(hWnd); + } + } + } lppop->FocusedItem = wIndex; - if (lpitem == NULL || wIndex == (WORD)-1) { - ResetHiliteFlags(lppop); - if (lppop->BarFlag) DrawMenuBar(hWnd); - } - else { - lpitem->item_flags |= MF_HILITE; - if (lppop->BarFlag) - DrawMenuBar(hWnd); - else { - InvalidateRect(hWnd, &lpitem->rect, TRUE); - UpdateWindow(hWnd); - } - } + if (lpitem == NULL || wIndex == (WORD)-1) + { + ResetHiliteFlags(lppop); + if (lppop->BarFlag) DrawMenuBar(hWnd); + } + else + { + lpitem->item_flags |= MF_HILITE; + if (lppop->BarFlag) + DrawMenuBar(hWnd); + else + { + InvalidateRect(hWnd, &lpitem->rect, TRUE); + UpdateWindow(hWnd); + } SendMessage(hWnd, WM_MENUSELECT, lpitem->item_id, - MAKELONG(0, lpitem->item_flags)); + MAKELONG(0, lpitem->item_flags)); + } } @@ -1984,7 +1999,6 @@ BOOL SetMenu(HWND hWnd, HMENU hMenu) return FALSE; } lpmenu->ownerWnd = hWnd; - printf("SetMenu(%04X, %04X) // %04X\n", hWnd, hMenu, lpmenu->ownerWnd); ResetHiliteFlags(lpmenu); if (GetCapture() == hWnd) ReleaseCapture(); GlobalUnlock(hMenu); diff --git a/debugger/Imakefile b/debugger/Imakefile index 5958e7d293d..8f4d8a7a065 100644 --- a/debugger/Imakefile +++ b/debugger/Imakefile @@ -5,32 +5,23 @@ MODULE = debugger -SUBDIRS = readline +SUBDIRS = opcodes readline -DEFINES = -DUSE_READLINE - -/* Quick and dirt hack, since i386 is defined as 1. sigh */ -#define temp i386 -#undef i386 +DEFINES = -DUSE_READLINE -Iopcodes SRCS = \ dbg.tab.c \ break.c \ hash.c \ lex.yy.c \ - info.c \ - i386-pinsn.c + info.c OBJS = \ dbg.tab.o \ break.o \ hash.o \ lex.yy.o \ - info.o \ - i386-pinsn.o - -#define i386 temp -#undef temp + info.o /* * All the SUBDIR stuff diff --git a/debugger/dbg.y b/debugger/dbg.y index 7dea72f0990..e99e2187300 100644 --- a/debugger/dbg.y +++ b/debugger/dbg.y @@ -19,7 +19,8 @@ unsigned int * regval = NULL; unsigned int dbg_mask = 0; unsigned int dbg_mode = 0; -void issue_prompt(); +void issue_prompt(void); +void mode_command(int); %} @@ -50,7 +51,7 @@ void issue_prompt(); line: '\n' | infocmd '\n' - | error '\n' {yyerrok; } + | error '\n' { yyerrok; } | QUIT '\n' { exit(0); }; | HELP '\n' { dbg_help(); }; | CONT '\n' { return; }; @@ -161,6 +162,7 @@ wine_debug(int signal, int * regs) dbg_mode = 16; }; #endif + fprintf(stderr,"In %d bit mode.\n", dbg_mode); /* This is intended to read the entry points from the Windows image, and insert them in the hash table. It does not work yet, so it is commented out. */ diff --git a/debugger/info.c b/debugger/info.c index 0a98d8977a4..b4b2358b347 100644 --- a/debugger/info.c +++ b/debugger/info.c @@ -5,33 +5,23 @@ */ #include +#include "opcodes/dis-asm.h" #include "regpos.h" extern int * regval; extern unsigned int dbg_mask; extern unsigned int dbg_mode; -extern int print_insn(char * memaddr, char * realaddr, FILE * stream, int addrlen); - -/* THese three helper functions eliminate the need for patching the -module from gdb for disassembly of code */ - void application_not_running() { fprintf(stderr,"Application not running\n"); } -void read_memory(char * memaddr, char * buffer, int len){ - memcpy(buffer, memaddr, len); -} - -void fputs_filtered(char * buffer, FILE * outfile){ - fputs(buffer, outfile); -} - void print_address(unsigned int addr, FILE * outfile){ char * name; - name = find_nearest_symbol(addr); + extern char * find_nearest_symbol(unsigned int *); + + name = find_nearest_symbol((unsigned int *) addr); if(name) fprintf(outfile,"0x%8.8x(%s)", addr, name); else @@ -39,12 +29,36 @@ void print_address(unsigned int addr, FILE * outfile){ } +void print_address_info(bfd_vma addr, disassemble_info * info){ + print_address((unsigned int) addr, info->stream); +} + +int print_insn(char *realmemaddr, char *memaddr, FILE *stream, int addrlen){ + static disassemble_info info; + static int initialized = 0; + + if (!initialized) { + INIT_DISASSEMBLE_INFO(info, stderr); + info.print_address_func = print_address_info; + initialized = 1; + } + info.stream = stream; + info.buffer = memaddr; + info.buffer_vma = (bfd_vma) realmemaddr; + info.buffer_length = 1024; + if (addrlen == 16) + return print_insn_i286((bfd_vma) realmemaddr, &info); + if (addrlen == 32) + return print_insn_i386((bfd_vma) realmemaddr, &info); + fprintf(stderr, "invalid address length %d.\n", addrlen); + return 0; +} void info_reg(){ if(!regval) { application_not_running(); - return 0; + return; } fprintf(stderr,"Register dump:\n"); @@ -73,7 +87,7 @@ void info_stack(){ if(!regval) { application_not_running(); - return 0; + return; } fprintf(stderr,"Stack dump:\n"); @@ -234,10 +248,7 @@ char * helptext[] = { "", "The disassembly code seems to work most of the time, but it does get", "a little confused at times. The 16 bit mode probably has not been used", -"much so there are probably bugs. I snagged the file from the gdb-4.7", -"source tree, which is what was on my latest cdrom. I should check to see", -"if newer versions of gdb have anything substanitally different for the", -"disassembler.", +"much so there are probably bugs.", "", NULL}; @@ -271,7 +282,7 @@ void dbg_bt(){ if(!regval) { application_not_running(); - return 0; + return; } fprintf(stderr,"Backtrace:\n"); diff --git a/if1632/callback.c b/if1632/callback.c index ac2ab9f79be..02f5cda1952 100644 --- a/if1632/callback.c +++ b/if1632/callback.c @@ -1,6 +1,8 @@ static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $"; static char Copyright[] = "Copyright Robert J. Amstadt, 1993"; +#include +#include #include "windows.h" #include "callback.h" #include "wine.h" @@ -143,9 +145,39 @@ LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message, WORD wParam, LONG lParam ) { SpyMessage(hwnd, message, wParam, lParam); - - if (Is16bitAddress(func)) + + if (HIWORD((LONG)func) == WINE_CODE_SELECTOR) + { + static struct dll_table_entry_s *user_tab = NULL; + void *address = (void *) ((LONG) func & 0xffff); + + if (user_tab == NULL) + user_tab = FindDLLTable("USER"); + + /* DefWindowProc */ + if (user_tab[104].address == address) + return DefWindowProc(hwnd, message, wParam, lParam); + + /* DefDlgProc */ + else if (user_tab[308].address == address) + return DefDlgProc(hwnd, message, wParam, lParam); + + /* DefMDIChildProc */ + else if (user_tab[447].address == address) + return DefMDIChildProc(hwnd, message, wParam, lParam); + + /* default */ + else + { + fprintf(stderr, "wine: Unknown wine callback %08x\n", func); + exit(1); + } + } + else if (Is16bitAddress(func)) { +#ifdef DEBUG_CALLBACK + printf("CallWindowProc // 16bit func=%08X !\n", func); +#endif PushOn16( CALLBACK_SIZE_WORD, hwnd ); PushOn16( CALLBACK_SIZE_WORD, message ); PushOn16( CALLBACK_SIZE_WORD, wParam ); @@ -155,6 +187,9 @@ LONG CallWindowProc( FARPROC func, HWND hwnd, WORD message, } else { +#ifdef DEBUG_CALLBACK + printf("CallWindowProc // 32bit func=%08X !\n", func); +#endif return (*func)(hwnd, message, wParam, lParam); } } diff --git a/if1632/gdi.spec b/if1632/gdi.spec index 9a87ccca15b..10c2ba9bd60 100644 --- a/if1632/gdi.spec +++ b/if1632/gdi.spec @@ -129,9 +129,9 @@ length 490 #122 pascal ReSurRection #123 pascal PlayMetaFile #124 pascal GetMetaFile -#125 pascal CreateMetaFile -#126 pascal CloseMetaFile -#127 pascal DeleteMetaFile +125 pascal CreateMetaFile(ptr) CreateMetaFile(1) +126 pascal CloseMetaFile(word) CloseMetaFile(1) +127 pascal DeleteMetaFile(word) DeleteMetaFile(1) 128 pascal MulDiv(s_word s_word s_word) MulDiv(1 2 3) 129 pascal SaveVisRgn(word) SaveVisRgn(1) 130 pascal RestoreVisRgn(word) RestoreVisRgn(1) @@ -219,7 +219,7 @@ length 490 #312 pascal CONVERTOUTLINEFONTFILE #313 pascal GETRASTERIZERCAPS #314 pascal ENGINEEXTTEXTOUT -#330 pascal ENUMFONTFAMILIES +330 pascal EnumFontFamilies(word ptr ptr ptr) EnumFontFamilies(1 2 3 4) #332 pascal GETKERNINGPAIRS 345 pascal GetTextAlign(word) GetTextAlign(1) 346 pascal SetTextAlign(word word) SetTextAlign(1 2) @@ -227,7 +227,8 @@ length 490 Chord(1 2 3 4 5 6 7 8 9) 349 pascal SetMapperFlags(word word) SetMapperFlags(1 2) 350 pascal GetCharWidth(word word word ptr) GetCharWidth(1 2 3 4) -#351 pascal EXTTEXTOUT +351 pascal ExtTextOut(word s_word s_word word ptr ptr s_word ptr) + ExtTextOut(1 2 3 4 5 6 7 8) #352 pascal GETPHYSICALFONTHANDLE #353 pascal GETASPECTRATIOFILTER #354 pascal SHRINKGDIHEAP diff --git a/if1632/kernel.spec b/if1632/kernel.spec index 0744f78a618..2f00be8faf1 100644 --- a/if1632/kernel.spec +++ b/if1632/kernel.spec @@ -81,7 +81,7 @@ length 415 #80 RESERVED4 81 pascal _lclose(word) _lclose(1) 82 pascal _lread(word ptr word) _lread(1 2 3) -83 pascal _lcreate(ptr word) _lcreate(1 2) +83 pascal _lcreat(ptr word) _lcreat(1 2) 84 pascal _llseek(word long word) _llseek(1 2 3) 85 pascal _lopen(ptr word) _lopen(1 2) 86 pascal _lwrite(word ptr word) _lwrite(1 2 3) diff --git a/if1632/pop.h b/if1632/pop.h new file mode 100644 index 00000000000..ff2d96106e2 --- /dev/null +++ b/if1632/pop.h @@ -0,0 +1,16 @@ + add $8,%esp + popw %es + add $2,%esp + popw %ds + add $2,%esp + popl %edi + popl %esi + popl %ebp + add $4,%esp + popl %ebx + popl %edx + popl %ecx + popl %eax + add $16,%esp + popfl + add $20,%esp diff --git a/if1632/shell.spec b/if1632/shell.spec index 52499e3c457..fb44c1cbca0 100644 --- a/if1632/shell.spec +++ b/if1632/shell.spec @@ -9,33 +9,33 @@ length 103 # proper parameters. It's just to have stub for PROGMAN.EXE ... # - 1 pascal RegOpenKey() RegOpenKey() - 2 pascal RegCreateKey() RegCreateKey() - 3 pascal RegCloseKey() RegCloseKey() - 4 pascal RegDeleteKey() RegDeleteKey() - 9 pascal DragAcceptFiles() DragAcceptFiles() - 20 pascal ShellExecute(ptr) ShellExecute(1) + 1 pascal RegOpenKey(word ptr ptr) RegOpenKey(1 2 3) + 2 pascal RegCreateKey(word ptr ptr) RegCreateKey(1 2 3) + 3 pascal RegCloseKey(word) RegCloseKey(1) + 4 pascal RegDeleteKey(word ptr) RegDeleteKey(1 2) + 5 pascal RegSetValue(word ptr long ptr long) RegSetValue(1 2 3 4 5) + 6 pascal RegQueryValue(word ptr ptr ptr) RegQueryValue(1 2 3 4) + 7 pascal RegEnumKey(word long ptr long) RegEnumKey(1 2 3 4) + 9 pascal DragAcceptFiles(word word) DragAcceptFiles(1 2) + 11 pascal DragQueryFile(word s_word ptr s_word) DragQueryFile(1 2 3 4) + 12 pascal DragFinish(word) DragFinish(1) + 13 pascal DragQueryPoint(word ptr) DragQueryPoint(1 2) + 20 pascal ShellExecute(word ptr ptr ptr ptr s_word) ShellExecute(1 2 3 4 5 6) + 21 pascal FindExecutable(ptr ptr ptr) FindExecutable(1 2 3) + 22 pascal ShellAbout(word ptr ptr word) ShellAbout(1 2 3 4) + 33 pascal AboutDlgProc(word word word long) AboutDlgProc(1 2 3 4) + 34 pascal ExtractIcon(word ptr s_word) ExtractIcon(1 2 3) 102 pascal RegisterShellHook(ptr) RegisterShellHook(1) 103 pascal ShellHookProc() ShellHookProc() # 8 7 0000 WEP exported, shared data -# 33 9 0136 ABOUTDLGPROC exported, shared data -# 34 10 021a EXTRACTICON exported, shared data -# 21 4 1154 FINDEXECUTABLE exported, shared data #100 4 0550 HERETHARBETYGARS exported, shared data # 38 5 0000 FINDENVIRONMENTSTRING exported, shared data -# 7 2 14dc REGENUMKEY exported, shared data # 37 5 00ae DOENVIRONMENTSUBST exported, shared data # 20 4 110a SHELLEXECUTE exported, shared data #101 8 010e FINDEXEDLGPROC exported, shared data -# 11 6 0094 DRAGQUERYFILE exported, shared data -# 13 6 0000 DRAGQUERYPOINT exported, shared data -# 5 2 16f4 REGSETVALUE exported, shared data # 39 10 026e INTERNALEXTRACTICON exported, shared data -# 22 9 0000 SHELLABOUT exported, shared data -# 6 2 168e REGQUERYVALUE exported, shared data # 32 9 0829 WCI exported, shared data # 36 10 08dc EXTRACTASSOCIATEDICON exported, shared data -# 12 6 0142 DRAGFINISH exported, shared data diff --git a/if1632/user.spec b/if1632/user.spec index a2aa4bda973..1bb9eed9dc6 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -108,6 +108,7 @@ length 540 102 pascal AdjustWindowRect(ptr long word) AdjustWindowRect(1 2 3) 103 pascal MapDialogRect(word ptr) MapDialogRect(1 2) 104 pascal MessageBeep(word) MessageBeep(1) +105 pascal FlashWindow(word word) FlashWindow(1 2) 106 pascal GetKeyState(word) GetKeyState(1) 107 pascal DefWindowProc(word word word long) DefWindowProc(1 2 3 4) 108 pascal GetMessage(ptr word word word) GetMessage(1 2 3 4) @@ -357,7 +358,9 @@ length 540 417 pascal GetMenuCheckMarkDimensions() GetMenuCheckMarkDimensions() 418 pascal SetMenuItemBitmaps(word word word word word) SetMenuItemBitmaps(1 2 3 4 5) -420 pascal wsprintf(ptr ptr) wsprintf(1 2) +420 pascal wsprintf() windows_wsprintf() +# windows_wsprintf() handles arguments itself, as libc can't handle an +# 16-bit stack. DLLRelay() will pass 16-bit stack pointer as 1st arg. 421 pascal wvsprintf(ptr ptr ptr) wvsprintf(1 2 3) #422 DLGDIRSELECTEX #423 DLGDIRSELECTCOMBOBOXEX diff --git a/include/heap.h b/include/heap.h index 94ba9c95667..22fe1294132 100644 --- a/include/heap.h +++ b/include/heap.h @@ -60,16 +60,18 @@ extern LHEAP *HEAP_LocalFindHeap(unsigned short owner); */ typedef struct global_mem_desc_s { - struct global_mem_desc_s *next; - struct global_mem_desc_s *prev; - unsigned short handle; - short sequence; - void *addr; - int length; - int lock_count; - void *linear_addr; - int linear_key; - int linear_count; + struct global_mem_desc_s *next; /* Next GDESC in list */ + struct global_mem_desc_s *prev; /* Previous GDESC in list */ + unsigned short handle; /* Handle of this block. */ + short sequence; /* Block sequence # in huge block */ + void *addr; /* Address allocated with mmap() */ + int length; /* Length of block */ + int lock_count; /* Block lock count */ + unsigned short alias; /* Offset-zero alias selector */ + unsigned int alias_key; /* Offset-zero alias sh. mem. key */ + void *linear_addr; /* Linear address of huge block */ + int linear_key; /* Linear shared memory key */ + int linear_count; /* Linear lock count */ } GDESC; extern GDESC *GlobalList; diff --git a/include/segmem.h b/include/segmem.h index b0f38f7f997..afe7741cdb4 100644 --- a/include/segmem.h +++ b/include/segmem.h @@ -6,6 +6,8 @@ #ifndef SEGMEM_H #define SEGMEM_H +#include "wine.h" + #ifdef __linux__ #define HAVE_IPC #include @@ -77,13 +79,10 @@ extern int IPCCopySelector(int i_old, unsigned long new, int swap_type); static __inline__ int Is16bitAddress(void *address) { - return ((int) address >= (((FIRST_SELECTOR << 3) | 0x0007) << 16)); + return ((unsigned int) address + >= (((FIRST_SELECTOR << 3) | 0x0007) << 16)); } extern SEGDESC Segments[]; #endif /* SEGMEM_H */ - - - - diff --git a/include/windows.h b/include/windows.h index 6d92dddfe22..0b2756829fe 100644 --- a/include/windows.h +++ b/include/windows.h @@ -45,7 +45,7 @@ DECLARE_HANDLE(HMENU); DECLARE_HANDLE(HBITMAP); DECLARE_HANDLE(HBRUSH); DECLARE_HANDLE(LOCALHANDLE); - +DECLARE_HANDLE(HMETAFILE); #define TRUE 1 #define FALSE 0 @@ -850,14 +850,6 @@ typedef struct tagLOGPEN #define ALTERNATE 1 #define WINDING 2 -typedef struct { - DWORD rdSize; - WORD rdFunction, rdParam[1]; -} METARECORD; -typedef METARECORD *LPMETARECORD; -typedef METARECORD *NPMETARECORD; -typedef METARECORD *PMETARECORD; - /* Background modes */ #define TRANSPARENT 1 #define OPAQUE 2 @@ -1334,12 +1326,6 @@ typedef struct tagCOMSTAT #define WF_PAGING 0x0800 #define WF_WLO 0x8000 -typedef struct -{ - HANDLE objectHandle[1]; -}HANDLETABLE; -typedef HANDLETABLE *LPHANDLETABLE; - #define MAKEINTRESOURCE(i) (LPSTR)((DWORD)((WORD)(i))) #define IDI_APPLICATION MAKEINTRESOURCE(32512) @@ -2240,6 +2226,126 @@ typedef COMPAREITEMSTRUCT FAR* LPCOMPAREITEMSTRUCT; #define WM_ASKCBFORMATNAME 0x030C #define WM_CHANGECBCHAIN 0x030D +/* Metafile header structure */ +typedef struct tagMETAHEADER +{ + WORD mtType; + WORD mtHeaderSize; + WORD mtVersion; + DWORD mtSize __attribute__ ((packed)); + WORD mtNoObjects; + DWORD mtMaxRecord __attribute__ ((packed)); + WORD mtNoParameters; +} METAHEADER; + +/* Metafile typical record structure */ +typedef struct tagMETARECORD +{ + DWORD rdSize; + WORD rdFunction; + WORD rdParam[1]; +} METARECORD; +typedef METARECORD *PMETARECORD; +typedef METARECORD *LPMETARECORD; + +/* Handle table structure */ +typedef struct tagHANDLETABLE +{ + HANDLE objectHandle[1]; +} HANDLETABLE; +typedef HANDLETABLE *PHANDLETABLE; +typedef HANDLETABLE *LPHANDLETABLE; + +/* Clipboard metafile picture structure */ +typedef struct tagMETAFILEPICT +{ + int mm; + int xExt; + int yExt; + HMETAFILE hMF; +} METAFILEPICT; +typedef METAFILEPICT *LPMETAFILEPICT; + +/* Metafile functions */ +#define META_SETBKCOLOR 0x0201 +#define META_SETBKMODE 0x0102 +#define META_SETMAPMODE 0x0103 +#define META_SETROP2 0x0104 +#define META_SETRELABS 0x0105 +#define META_SETPOLYFILLMODE 0x0106 +#define META_SETSTRETCHBLTMODE 0x0107 +#define META_SETTEXTCHAREXTRA 0x0108 +#define META_SETTEXTCOLOR 0x0209 +#define META_SETTEXTJUSTIFICATION 0x020A +#define META_SETWINDOWORG 0x020B +#define META_SETWINDOWEXT 0x020C +#define META_SETVIEWPORTORG 0x020D +#define META_SETVIEWPORTEXT 0x020E +#define META_OFFSETWINDOWORG 0x020F +#define META_SCALEWINDOWEXT 0x0410 +#define META_OFFSETVIEWPORTORG 0x0211 +#define META_SCALEVIEWPORTEXT 0x0412 +#define META_LINETO 0x0213 +#define META_MOVETO 0x0214 +#define META_EXCLUDECLIPRECT 0x0415 +#define META_INTERSECTCLIPRECT 0x0416 +#define META_ARC 0x0817 +#define META_ELLIPSE 0x0418 +#define META_FLOODFILL 0x0419 +#define META_PIE 0x081A +#define META_RECTANGLE 0x041B +#define META_ROUNDRECT 0x061C +#define META_PATBLT 0x061D +#define META_SAVEDC 0x001E +#define META_SETPIXEL 0x041F +#define META_OFFSETCLIPRGN 0x0220 +#define META_TEXTOUT 0x0521 +#define META_BITBLT 0x0922 +#define META_STRETCHBLT 0x0B23 +#define META_POLYGON 0x0324 +#define META_POLYLINE 0x0325 +#define META_ESCAPE 0x0626 +#define META_RESTOREDC 0x0127 +#define META_FILLREGION 0x0228 +#define META_FRAMEREGION 0x0429 +#define META_INVERTREGION 0x012A +#define META_PAINTREGION 0x012B +#define META_SELECTCLIPREGION 0x012C +#define META_SELECTOBJECT 0x012D +#define META_SETTEXTALIGN 0x012E +#define META_DRAWTEXT 0x062F +#define META_CHORD 0x0830 +#define META_SETMAPPERFLAGS 0x0231 +#define META_SETTEXTOUT 0x0A32 +#define META_SETDIBTODEV 0x0D33 +#define META_SELECTPALETTE 0x0234 +#define META_REALIZEPALETTE 0x0035 +#define META_ANIMATEPALETTE 0x0436 +#define META_SETPALENTRIES 0x0037 +#define META_POLYPOLYGON 0x0538 +#define META_RESIZEPALETTE 0x0139 +#define META_DIBBITBLT 0x0940 +#define META_DIBSTRETCHBLT 0x0B41 +#define META_DIBCREATEPATTERNBRUSH 0x0142 +#define META_STRETCHDIB 0x0F43 +#define META_EXTFLOODFILL 0x0548 +#define META_RESETDC 0x014C +#define META_STARTDOC 0x014D +#define META_STARTPAGE 0x004F +#define META_ENDPAGE 0x0050 +#define META_ABORTDOC 0x0052 +#define META_ENDDOC 0x005E +#define META_DELETEOBJECT 0x01F0 +#define META_CREATEPALETTE 0x00F7 +#define META_CREATEBRUSH 0x00F8 +#define META_CREATEPATTERNBRUSH 0x01F9 +#define META_CREATEPENINDIRECT 0x02FA +#define META_CREATEFONTINDIRECT 0x02FB +#define META_CREATEBRUSHINDIRECT 0x02FC +#define META_CREATEBITMAPINDIRECT 0x02FD +#define META_CREATEBITMAP 0x06FE +#define META_CREATEREGION 0x06FF + #define F(ret,name) ret name(void); #define Fa(ret,name,t1,a1) ret name(t1 a1); @@ -2338,7 +2444,7 @@ Fa(ATOM,GlobalDeleteAtom,ATOM,a) Fa(ATOM,GlobalFindAtom,LPCSTR,a) Fa(BOOL,BringWindowToTop,HWND,a) Fa(BOOL,DeleteDC,HDC,a) -Fa(BOOL,DeleteMetaFile,HANDLE,a) +Fa(BOOL,DeleteMetaFile,HMETAFILE,a) Fa(BOOL,DeleteObject,HANDLE,a) Fa(BOOL,DestroyCursor,HCURSOR,a) Fa(BOOL,DestroyIcon,HICON,a) @@ -2392,7 +2498,7 @@ Fa(DWORD,GlobalSize,HANDLE,a) Fa(DWORD,OemKeyScan,WORD,a) Fa(FARPROC,LocalNotify,FARPROC,a) Fa(HANDLE,BeginDeferWindowPos,int,nNumWindows) -Fa(HANDLE,CloseMetaFile,HANDLE,a) +Fa(HMETAFILE,CloseMetaFile,HANDLE,a) Fa(HANDLE,CreateMetaFile,LPSTR,a) Fa(HANDLE,GetAtomHandle,ATOM,a) Fa(HANDLE,GetClipboardData,WORD,a) @@ -2680,8 +2786,8 @@ Fb(void,ValidateRgn,HWND,a,HRGN,b) Fc(BOOL,LineTo,HDC,a,short,b,short,c) Fc(WORD,GetInternalWindowPos,HWND,a,LPRECT,b,LPPOINT,c) Fc(LONG,_llseek,INT,a,LONG,b,INT,c) -Fc(WORD,_lread,INT,a,LPSTR,b,INT,c) -Fc(WORD,_lwrite,INT,a,LPSTR,b,INT,c) +Fc(INT,_lread,INT,a,LPSTR,b,INT,c) +Fc(INT,_lwrite,INT,a,LPSTR,b,INT,c) Fc(int,FillRect,HDC,a,LPRECT,b,HBRUSH,c) Fc(DWORD,MoveTo,HDC,a,short,b,short,c) Fc(BOOL,CheckMenuItem,HMENU,a,WORD,b,WORD,c) @@ -2896,7 +3002,7 @@ Fg(HICON,CreateIcon,HANDLE,a,int,b,int,c,BYTE,d,BYTE,e,LPSTR,f,LPSTR,g) Fg(int,GetDIBits,HDC,a,HANDLE,a2,WORD,b,WORD,c,LPSTR,d,LPBITMAPINFO,e,WORD,f) Fg(int,SetDIBits,HDC,a,HANDLE,a2,WORD,b,WORD,c,LPSTR,d,LPBITMAPINFO,e,WORD,f) Fg(BOOL,SetWindowPos,HWND,a,HWND,b,short,c,short,d,short,e,short,f,WORD,g) -Fh(BOOL,ExtTextOut,HDC,a,int,b,int,c,WORD,d,LPRECT,e,LPSTR,f,WORD,g,LPINT,h) +Fh(BOOL,ExtTextOut,HDC,a,short,b,short,c,WORD,d,LPRECT,e,LPSTR,f,WORD,g,LPINT,h) Fh(HANDLE,DeferWindowPos,HANDLE,hWinPosInfo,HWND,hWnd,HWND,hWndInsertAfter,int,x,int,y,int,cx,int,cy,WORD,wFlags) Fh(LONG,TabbedTextOut,HDC,a,int,b,int,c,LPSTR,d,int,e,int,f,LPINT,g,int,h) Fh(int,ScrollWindowEx,HWND,a,short,b,short,c,LPRECT,d,LPRECT,e,HRGN,f,LPRECT,g,WORD,h) diff --git a/loader/library.c b/loader/library.c index cede6ec5edd..6cfbe080eee 100644 --- a/loader/library.c +++ b/loader/library.c @@ -117,6 +117,7 @@ HANDLE LoadLibrary(LPSTR libname) if (FindDLLTable(libname)) { + printf("Library was a builtin - returning 0x23\n"); return WINE_CODE_SELECTOR; } diff --git a/loader/resource.c b/loader/resource.c index dbd7d92588f..a5fb3c8544e 100644 --- a/loader/resource.c +++ b/loader/resource.c @@ -573,7 +573,7 @@ HANDLE LoadAccelerators(HANDLE instance, LPSTR lpTableName) HANDLE rsc_mem; BYTE *lp; ACCELHEADER *lpAccelTbl; - int i, image_size; + int i, image_size, n; #ifdef DEBUG_ACCEL if (((LONG)lpTableName & 0xFFFF0000L) == 0L) printf("LoadAccelerators: instance = %04X, name = %08X\n", @@ -597,11 +597,12 @@ HANDLE LoadAccelerators(HANDLE instance, LPSTR lpTableName) #ifdef DEBUG_ACCEL printf("LoadAccelerators / image_size=%d\n", image_size); #endif + n = image_size/5; hAccel = GlobalAlloc(GMEM_MOVEABLE, - sizeof(ACCELHEADER) + sizeof(ACCELENTRY) + image_size); + sizeof(ACCELHEADER) + (n + 1)*sizeof(ACCELENTRY)); lpAccelTbl = (LPACCELHEADER)GlobalLock(hAccel); lpAccelTbl->wCount = 0; - for (i = 0; ; i++) { + for (i = 0; i < n; i++) { lpAccelTbl->tbl[i].type = *(lp++); lpAccelTbl->tbl[i].wEvent = *((WORD *)lp); lp += 2; @@ -895,6 +896,10 @@ LoadString(HANDLE instance, WORD resource_id, LPSTR buffer, int buflen) buffer[i] = '\0'; } else { + if (buflen > 1) { + buffer[0] = '\0'; + return 0; + } printf("LoadString // I dont know why , but caller give buflen=%d *p=%d !\n", buflen, *p); printf("LoadString // and try to obtain string '%s'\n", p + 1); } diff --git a/loader/task.c b/loader/task.c index 980ddc77e82..856f634c9d3 100644 --- a/loader/task.c +++ b/loader/task.c @@ -102,14 +102,14 @@ BOOL EnumTaskWindows(HANDLE hTask, FARPROC lpEnumFunc, LONG lParam) printf("EnumTaskWindows // found hTask=%04X !\n", hTask); wptr = lpTask->lpWndList; if (wptr == NULL) return FALSE; + if (lpEnumFunc == NULL) return FALSE; while ((hWnd = *(wptr++)) != 0) { if (++count >= MAXWIN_PER_TASK) return FALSE; printf("EnumTaskWindows // hWnd=%04X count=%d !\n", hWnd, count); #ifdef WINELIB - if (lpEnumFunc != NULL) bRet = (*lpEnumFunc)(hWnd, lParam); + bRet = (*lpEnumFunc)(hWnd, lParam); #else - if (lpEnumFunc != NULL) - bRet = CallBack16(lpEnumFunc, 2, lParam, (int) hWnd); + bRet = CallBack16(lpEnumFunc, 2, 0, (int)hWnd, 2, (int)lParam); #endif if (bRet == 0) break; } diff --git a/memory/global.c b/memory/global.c index 29717e07c1b..c257027ac5b 100644 --- a/memory/global.c +++ b/memory/global.c @@ -103,18 +103,20 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments) for (count = 0; count < n_segments; count++, s++) { g = (GDESC *) malloc(sizeof(*g)); - if (g == NULL) { + if (g == NULL) + { printf("GlobalGetFreeSegments // bad GDESC malloc !\n"); return NULL; - } - g->prev = g_prev; - g->next = NULL; - g->handle = s->selector; - g->sequence = -1; - g->addr = s->base_addr; - g->length = s->length; - g->linear_addr = NULL; - g->linear_key = 0; + } + g->prev = g_prev; + g->next = NULL; + g->handle = s->selector; + g->sequence = -1; + g->addr = s->base_addr; + g->length = s->length; + g->alias = 0; + g->linear_addr = NULL; + g->linear_key = 0; g->linear_count = 0; if (!(flags & GLOBAL_FLAGS_MOVEABLE)) g->lock_count = 1; @@ -139,14 +141,16 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments) g = g_start; for (i = 0; i < n_segments; i++, g = g->next) { - if (g == NULL) { + if (g == NULL) + { printf("GlobalGetFreeSegments // bad Segments chain !\n"); return NULL; - } - g->sequence = i + 1; - g->length = n_segments; - g->linear_addr = NULL; - g->linear_key = 0; + } + g->sequence = i + 1; + g->length = n_segments; + g->alias = 0; + g->linear_addr = NULL; + g->linear_key = 0; g->linear_count = 0; } @@ -154,6 +158,15 @@ GlobalGetFreeSegments(unsigned int flags, int n_segments) } /********************************************************************** + * WIN16_GlobalAlloc + */ +HANDLE +WIN16_GlobalAlloc(unsigned int flags, unsigned long size) +{ + return GlobalAlloc(flags & ~GLOBAL_FLAGS_MOVEABLE, size); +} + +/********************************************************************** * GlobalAlloc */ HANDLE @@ -234,14 +247,15 @@ GlobalAlloc(unsigned int flags, unsigned long size) if (g == NULL) return 0; - g->handle = next_unused_handle; - g->sequence = 0; - g->addr = m; - g->linear_addr = NULL; - g->linear_key = 0; + g->handle = next_unused_handle; + g->sequence = 0; + g->addr = m; + g->alias = 0; + g->linear_addr = NULL; + g->linear_key = 0; g->linear_count = 0; - g->length = size; - g->next = g_prev->next; + g->length = size; + g->next = g_prev->next; if (g->next) g->next->prev = g; g->lock_count = 0; @@ -323,28 +337,15 @@ GlobalLock(unsigned int block) { GDESC *g; - if (block == 0) + if ((g = GlobalGetGDesc(block)) == NULL) return 0; - /* - * Find GDESC for this block. - */ - for (g = GlobalList; g != NULL; g = g->next) - { - if (g->handle == block) - { - g->lock_count++; -#ifdef DEBUG_HEAP - printf("GlobalLock: returning %08x\n", g->addr); -#endif - return g->addr; - } - } + g->lock_count++; #ifdef DEBUG_HEAP - printf("GlobalLock: returning %08x\n", 0); + printf("GlobalLock: returning %08x\n", g->addr); #endif - return NULL; + return g->addr; } /********************************************************************** diff --git a/memory/heap.c b/memory/heap.c index 471d5fea8e6..c54c0eee2ba 100644 --- a/memory/heap.c +++ b/memory/heap.c @@ -116,23 +116,28 @@ HEAP_ReAlloc(MDESC **free_list, void *old_block, { MDESC *m_free; MDESC *m; + + + if (!old_block) + return HEAP_Alloc(free_list, flags, new_size); + /* * Check validity of block */ m = (MDESC *) old_block - 1; + #ifdef DEBUG_HEAP - printf("HEAP_ReAlloc new_size=%d !\n", new_size); - printf("HEAP_ReAlloc old_block=%08X !\n", old_block); - printf("HEAP_ReAlloc m=%08X free_list=%08X !\n", m, free_list); - printf("HEAP_ReAlloc m->prev=%08X !\n", m->prev); - printf("HEAP_ReAlloc m->next=%08X !\n", m->next); - printf("HEAP_ReAlloc *free_list=%08X !\n", *free_list); + printf("HEAP_ReAlloc new_size=%d !\n", new_size); + printf("HEAP_ReAlloc old_block=%08X !\n", old_block); + printf("HEAP_ReAlloc m=%08X free_list=%08X !\n", m, free_list); + printf("HEAP_ReAlloc m->prev=%08X !\n", m->prev); + printf("HEAP_ReAlloc m->next=%08X !\n", m->next); + printf("HEAP_ReAlloc *free_list=%08X !\n", *free_list); #endif - if (m->prev != m || m->next != m || + + if (m->prev != m || m->next != m || ((int) m & 0xffff0000) != ((int) *free_list & 0xffff0000)) { - printf("Attempt to resize bad pointer, m = %08x, *free_list = %08x\n", - m, free_list); #ifdef DEBUG_HEAP printf("Attempt to resize bad pointer, m = %08x, *free_list = %08x\n", m, free_list); @@ -144,8 +149,9 @@ HEAP_ReAlloc(MDESC **free_list, void *old_block, * Check for grow block */ #ifdef DEBUG_HEAP - printf("HEAP_ReAlloc Check for grow block !\n"); + printf("HEAP_ReAlloc Check for grow block !\n"); #endif + if (new_size > m->length) { m_free = m + 1 + m->length / sizeof(MDESC); diff --git a/misc/cursor.c b/misc/cursor.c index 874ff9222b9..49ce26c0d91 100644 --- a/misc/cursor.c +++ b/misc/cursor.c @@ -171,7 +171,7 @@ HCURSOR LoadCursor(HANDLE instance, LPSTR cursor_name) ReleaseDC(GetDesktopWindow(), hdc); return 0; } - lp += 2; + (char *)lp += 2; for (j = 0; j < 16; j++) printf("%04X ", *(lp + j)); /* @@ -180,7 +180,7 @@ HCURSOR LoadCursor(HANDLE instance, LPSTR cursor_name) else */ lpcur->hBitmap = 0; - lp += sizeof(BITMAP); +/* lp += sizeof(BITMAP); */ for (i = 0; i < 81; i++) { char temp = *((char *)lp + 162 + i); *((char *)lp + 162 + i) = *((char *)lp + 324 - i); diff --git a/misc/file.c b/misc/file.c index ff4bcbae4b3..3348f758ccf 100644 --- a/misc/file.c +++ b/misc/file.c @@ -12,7 +12,7 @@ * * DEC 93 Erik Bos (erik@(trashcan.)hacktic.nl) * - Existing functions modified to use dosfs functions. - * - Added _llseek, _lcreate, GetDriveType, GetTempDrive, + * - Added _llseek, _lcreat, GetDriveType, GetTempDrive, * GetWindowsDirectory, GetSystemDirectory, GetTempFileName. * ************************************************************************/ @@ -27,7 +27,7 @@ #include #include "prototypes.h" -#define DEBUG_FILE +/* #define DEBUG_FILE */ char WindowsDirectory[256], SystemDirectory[256], TempDirectory[256]; @@ -63,7 +63,7 @@ INT _lopen (LPSTR lpPathName, INT iReadWrite) /*************************************************************************** _lread ***************************************************************************/ -WORD _lread (INT hFile, LPSTR lpBuffer, INT wBytes) +INT _lread (INT hFile, LPSTR lpBuffer, INT wBytes) { int result; @@ -83,7 +83,7 @@ WORD _lread (INT hFile, LPSTR lpBuffer, INT wBytes) /**************************************************************************** _lwrite ****************************************************************************/ -WORD _lwrite (INT hFile, LPSTR lpBuffer, INT wBytes) +INT _lwrite (INT hFile, LPSTR lpBuffer, INT wBytes) { int result; @@ -196,15 +196,15 @@ LONG _llseek (INT hFile, LONG lOffset, INT nOrigin) } /*************************************************************************** - _lcreate + _lcreat ***************************************************************************/ -INT _lcreate (LPSTR lpszFilename, INT fnAttribute) +INT _lcreat (LPSTR lpszFilename, INT fnAttribute) { int handle; char *UnixFileName; #ifdef DEBUG_FILE - fprintf(stderr, "_lcreate: filename %s, attributes %d\n",lpszFilename, + fprintf(stderr, "_lcreat: filename %s, attributes %d\n",lpszFilename, fnAttribute); #endif if ((UnixFileName = GetUnixFileName(lpszFilename)) == NULL) @@ -307,7 +307,7 @@ INT GetTempFileName(BYTE bDriveLetter, LPCSTR lpszPrefixString, UINT uUnique, LP fprintf(stderr,"GetTempFilename: %c %s %d => %s\n",bDriveLetter, lpszPrefixString,uUnique,lpszTempFileName); #endif - if ((handle = _lcreate (lpszTempFileName, 0x0000)) == -1) { + if ((handle = _lcreat (lpszTempFileName, 0x0000)) == -1) { fprintf(stderr,"GetTempFilename: can't create temp file '%s' !\n", lpszTempFileName); } else diff --git a/misc/mmsystem.c b/misc/mmsystem.c index 042974cb6ff..9332079d78a 100644 --- a/misc/mmsystem.c +++ b/misc/mmsystem.c @@ -10,6 +10,8 @@ static char Copyright[] = "Copyright Martin Ayotte, 1993"; #include "win.h" #include "mmsystem.h" +static WORD mciActiveDev = 0; + int MCI_LibMain(HANDLE hInstance, WORD wDataSeg, WORD cbHeapSize, LPSTR lpCmdLine) @@ -78,6 +80,9 @@ DWORD WINAPI auxOutMessage(UINT uDeviceID, UINT uMessage, DWORD dw1, DWORD dw2) +/************************************************************************** +* mciGetErrorString [MMSYSTEM.706] +*/ BOOL mciGetErrorString (DWORD wError, LPSTR lpstrBuffer, UINT uLength) { LPSTR msgptr; @@ -331,23 +336,204 @@ msg# 543 : tmsf break; } maxbuf = min(uLength - 1, strlen(msgptr)); - strncpy(lpstrBuffer, msgptr, maxbuf); + if (maxbuf > 0) strncpy(lpstrBuffer, msgptr, maxbuf); lpstrBuffer[maxbuf + 1] = '\0'; return(TRUE); } +/************************************************************************** +* mciWaveOpen [internal] +*/ +DWORD mciWaveOpen(UINT wDevID, DWORD dwParam, LPMCI_WAVE_OPEN_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + printf("mciWaveOpen(%04X, %08X, %08X)\n", wDevID, dwParam, lpParms); + return MCIERR_INTERNAL; +} + + +/************************************************************************** +* mciOpen [internal] +*/ +DWORD mciOpen(UINT wDevID, DWORD dwParam, LPMCI_OPEN_PARMS lpParms) +{ + DWORD dwDevTyp = 0; + if (lpParms == NULL) return MCIERR_INTERNAL; + printf("mciOpen(%04X, %08X, %08X)\n", wDevID, dwParam, lpParms); + if (dwParam & MCI_OPEN_TYPE) { + if (lpParms->lpstrDeviceType == NULL) return MCIERR_INTERNAL; + if (dwParam & MCI_OPEN_TYPE_ID) { + printf("MCI_OPEN // Dev=%08X !\n", lpParms->lpstrDeviceType); + dwDevTyp = (DWORD)lpParms->lpstrDeviceType; + } + else { + if (strcmp(lpParms->lpstrDeviceType, "cdaudio") == 0) { + dwDevTyp = MCI_DEVTYPE_CD_AUDIO; + } + else + if (strcmp(lpParms->lpstrDeviceType, "waveaudio") == 0) { + dwDevTyp = MCI_DEVTYPE_WAVEFORM_AUDIO; + } + else + if (strcmp(lpParms->lpstrDeviceType, "Sequencer") == 0) { + dwDevTyp = MCI_DEVTYPE_SEQUENCER; + } + else + if (strcmp(lpParms->lpstrDeviceType, "Animation1") == 0) { + dwDevTyp = MCI_DEVTYPE_ANIMATION; + } + } + switch(dwDevTyp) { + case MCI_DEVTYPE_CD_AUDIO: + printf("MCI_OPEN // No SEQUENCER yet !\n"); + return MCIERR_DEVICE_NOT_INSTALLED; + case MCI_DEVTYPE_WAVEFORM_AUDIO: + printf("MCI_OPEN // No WAVEAUDIO yet !\n"); + return MCIERR_DEVICE_NOT_INSTALLED; + case MCI_DEVTYPE_SEQUENCER: + printf("MCI_OPEN // No SEQUENCER yet !\n"); + return MCIERR_DEVICE_NOT_INSTALLED; + case MCI_DEVTYPE_ANIMATION: + printf("MCI_OPEN // No ANIMATION yet !\n"); + return MCIERR_DEVICE_NOT_INSTALLED; + case MCI_DEVTYPE_DIGITAL_VIDEO: + printf("MCI_OPEN // No DIGITAL_VIDEO yet !\n"); + return MCIERR_DEVICE_NOT_INSTALLED; + default: + printf("MCI_OPEN // Invalid Device Name '%08X' !\n", lpParms->lpstrDeviceType); + return MCIERR_INVALID_DEVICE_NAME; + } + lpParms->wDeviceID = ++mciActiveDev; + printf("MCI_OPEN // wDeviceID=%04X !\n", lpParms->wDeviceID); + return 0; + } + if (dwParam & MCI_OPEN_ELEMENT) { + printf("MCI_OPEN // Element !\n"); + printf("MCI_OPEN // Elem=%s' !\n", lpParms->lpstrElementName); + } + return MCIERR_INTERNAL; +} + + +/************************************************************************** +* mciSound [internal] +*/ +DWORD mciSound(UINT wDevID, DWORD dwParam, LPMCI_SOUND_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + if (dwParam & MCI_SOUND_NAME) + printf("MCI_SOUND // file='%s' !\n", lpParms->lpstrSoundName); + return MCIERR_INVALID_DEVICE_ID; +} + + +/************************************************************************** +* mciGetDevCaps [internal] +*/ +DWORD mciGetDevCaps(UINT wDevID, DWORD dwParam, LPMCI_GETDEVCAPS_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + lpParms->dwReturn = 0; + return 0; +} + + +/************************************************************************** +* mciInfo [internal] +*/ +DWORD mciInfo(UINT wDevID, DWORD dwParam, LPMCI_INFO_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + lpParms->lpstrReturn = NULL; + lpParms->dwRetSize = 0; + return 0; +} + + +/************************************************************************** +* mciStatus [internal] +*/ +DWORD mciStatus(UINT wDevID, DWORD dwParam, LPMCI_STATUS_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + return 0; +} + + +/************************************************************************** +* mciPlay [internal] +*/ +DWORD mciPlay(UINT wDevID, DWORD dwParam, LPMCI_PLAY_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + return 0; +} + +/************************************************************************** +* mciRecord [internal] +*/ +DWORD mciRecord(UINT wDevID, DWORD dwParam, LPMCI_RECORD_PARMS lpParms) +{ + if (lpParms == NULL) return MCIERR_INTERNAL; + return 0; +} + + +/************************************************************************** +* mciClose [internal] +*/ +DWORD mciClose(UINT wDevID) +{ + return 0; +} + + +/************************************************************************** +* mciSendCommand [MMSYSTEM.701] +*/ DWORD mciSendCommand(UINT wDevID, UINT wMsg, DWORD dwParam1, DWORD dwParam2) { printf("mciSendCommand(%04X, %04X, %08X, %08X)\n", wDevID, wMsg, dwParam1, dwParam2); + switch(wMsg) { + case MCI_OPEN: + printf("mciSendCommand // MCI_OPEN !\n"); + if (dwParam1 & MCI_WAVE_OPEN_BUFFER) + return mciWaveOpen(wDevID, dwParam1, + (LPMCI_WAVE_OPEN_PARMS)dwParam2); + else + return mciOpen(wDevID, dwParam1, (LPMCI_OPEN_PARMS)dwParam2); + case MCI_PLAY: + printf("mciSendCommand // MCI_PLAY !\n"); + return mciPlay(wDevID, dwParam1, (LPMCI_PLAY_PARMS)dwParam2); + case MCI_RECORD: + printf("mciSendCommand // MCI_RECORD !\n"); + return mciRecord(wDevID, dwParam1, (LPMCI_RECORD_PARMS)dwParam2); + case MCI_CLOSE: + printf("mciSendCommand // MCI_CLOSE !\n"); + return mciClose(wDevID); + case MCI_SOUND: + printf("mciSendCommand // MCI_SOUND !\n"); + return mciSound(wDevID, dwParam1, (LPMCI_SOUND_PARMS)dwParam2); + case MCI_STATUS: + printf("mciSendCommand // MCI_STATUS !\n"); + return mciStatus(wDevID, dwParam1, (LPMCI_STATUS_PARMS)dwParam2); + case MCI_INFO: + printf("mciSendCommand // MCI_INFO !\n"); + return mciInfo(wDevID, dwParam1, (LPMCI_INFO_PARMS)dwParam2); + case MCI_GETDEVCAPS: + printf("mciSendCommand // MCI_GETDEVCAPS !\n"); + return mciGetDevCaps(wDevID, dwParam1, (LPMCI_GETDEVCAPS_PARMS)dwParam2); + } return MCIERR_DEVICE_NOT_INSTALLED; } - - +/************************************************************************** +* mciGetDeviceID [MMSYSTEM.703] +*/ UINT mciGetDeviceID (LPCSTR lpstrName) { printf("mciGetDeviceID(%s)\n", lpstrName); @@ -356,6 +542,9 @@ UINT mciGetDeviceID (LPCSTR lpstrName) +/************************************************************************** +* mciSendString [MMSYSTEM.702] +*/ DWORD WINAPI mciSendString (LPCSTR lpstrCommand, LPSTR lpstrReturnString, UINT uReturnLength, HWND hwndCallback) { @@ -483,7 +672,7 @@ msg# 343 : There are no MIDI devices installed on the system. Use the Drivers op break; } maxbuf = min(uSize - 1, strlen(msgptr)); - strncpy(lpText, msgptr, maxbuf); + if (maxbuf > 0) strncpy(lpText, msgptr, maxbuf); lpText[maxbuf + 1] = '\0'; return(TRUE); } @@ -493,6 +682,7 @@ UINT WINAPI midiOutOpen(HMIDIOUT FAR* lphMidiOut, UINT uDeviceID, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { printf("midiOutOpen\n"); + if (lphMidiOut != NULL) *lphMidiOut = 0; return 0; } @@ -603,6 +793,7 @@ UINT WINAPI midiInOpen(HMIDIIN FAR* lphMidiIn, UINT uDeviceID, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { printf("midiInOpen\n"); + if (lphMidiIn != NULL) *lphMidiIn = 0; return 0; } @@ -698,65 +889,68 @@ UINT WINAPI waveOutGetErrorText(UINT uError, LPSTR lpText, UINT uSize) UINT WINAPI waveGetErrorText(UINT uError, LPSTR lpText, UINT uSize) { - if ((lpText == NULL) || (uSize < 1)) return(FALSE); - lpText[0] = '\0'; - switch(uError) - { - case MMSYSERR_NOERROR: - sprintf(lpText, "The specified command was carried out."); - break; - case MMSYSERR_ERROR: - sprintf(lpText, "Undefined external error."); - break; - case MMSYSERR_BADDEVICEID: - sprintf(lpText, "A device ID has been used that is out of range for your system."); - break; - case MMSYSERR_NOTENABLED: - sprintf(lpText, "The driver was not enabled."); - break; - case MMSYSERR_ALLOCATED: - sprintf(lpText, "The specified device is already in use. Wait until it is free, and then try again."); - break; - case MMSYSERR_INVALHANDLE: - sprintf(lpText, "The specified device handle is invalid."); - break; - case MMSYSERR_NODRIVER: - sprintf(lpText, "There is no driver installed on your system !\n"); - break; - case MMSYSERR_NOMEM: - sprintf(lpText, "Not enough memory available for this task. Quit one or more applications to increase available memory, and then try again."); - break; - case MMSYSERR_NOTSUPPORTED: - sprintf(lpText, "This function is not supported. Use the Capabilities function to determine which functions and messages the driver supports."); - break; - case MMSYSERR_BADERRNUM: - sprintf(lpText, "An error number was specified that is not defined in the system."); - break; - case MMSYSERR_INVALFLAG: - sprintf(lpText, "An invalid flag was passed to a system function."); - break; - case MMSYSERR_INVALPARAM: - sprintf(lpText, "An invalid parameter was passed to a system function."); - break; - case WAVERR_BADFORMAT: - sprintf(lpText, "The specified format is not supported or cannot be translated. Use the Capabilities function to determine the supported formats"); - break; - case WAVERR_STILLPLAYING: - sprintf(lpText, "Cannot perform this operation while media data is still playing. Reset the device, or wait until the data is finished playing."); - break; - case WAVERR_UNPREPARED: - sprintf(lpText, "The wave header was not prepared. Use the Prepare function to prepare the header, and then try again."); - break; - case WAVERR_SYNC: - sprintf(lpText, "Cannot open the device without using the WAVE_ALLOWSYNC flag. Use the flag, and then try again."); - break; - - default: - sprintf(lpText, "Unkown MMSYSTEM Error !\n"); - break; - } - lpText[uSize - 1] = '\0'; - return(TRUE); + LPSTR msgptr; + int maxbuf; + printf("waveGetErrorText(%04X, %08X, %d);\n", uError, lpText, uSize); + if ((lpText == NULL) || (uSize < 1)) return(FALSE); + lpText[0] = '\0'; + switch(uError) { + case MMSYSERR_NOERROR: + msgptr = "The specified command was carried out."; + break; + case MMSYSERR_ERROR: + msgptr = "Undefined external error."; + break; + case MMSYSERR_BADDEVICEID: + msgptr = "A device ID has been used that is out of range for your system."; + break; + case MMSYSERR_NOTENABLED: + msgptr = "The driver was not enabled."; + break; + case MMSYSERR_ALLOCATED: + msgptr = "The specified device is already in use. Wait until it is free, and then try again."; + break; + case MMSYSERR_INVALHANDLE: + msgptr = "The specified device handle is invalid."; + break; + case MMSYSERR_NODRIVER: + msgptr = "There is no driver installed on your system !\n"; + break; + case MMSYSERR_NOMEM: + msgptr = "Not enough memory available for this task. Quit one or more applications to increase available memory, and then try again."; + break; + case MMSYSERR_NOTSUPPORTED: + msgptr = "This function is not supported. Use the Capabilities function to determine which functions and messages the driver supports."; + break; + case MMSYSERR_BADERRNUM: + msgptr = "An error number was specified that is not defined in the system."; + break; + case MMSYSERR_INVALFLAG: + msgptr = "An invalid flag was passed to a system function."; + break; + case MMSYSERR_INVALPARAM: + msgptr = "An invalid parameter was passed to a system function."; + break; + case WAVERR_BADFORMAT: + msgptr = "The specified format is not supported or cannot be translated. Use the Capabilities function to determine the supported formats"; + break; + case WAVERR_STILLPLAYING: + msgptr = "Cannot perform this operation while media data is still playing. Reset the device, or wait until the data is finished playing."; + break; + case WAVERR_UNPREPARED: + msgptr = "The wave header was not prepared. Use the Prepare function to prepare the header, and then try again."; + break; + case WAVERR_SYNC: + msgptr = "Cannot open the device without using the WAVE_ALLOWSYNC flag. Use the flag, and then try again."; + break; + default: + msgptr = "Unkown MMSYSTEM Error !\n"; + break; + } + maxbuf = min(uSize - 1, strlen(msgptr)); + if (maxbuf > 0) strncpy(lpText, msgptr, maxbuf); + lpText[maxbuf + 1] = '\0'; + return(TRUE); } @@ -764,6 +958,7 @@ UINT WINAPI waveOutOpen(HWAVEOUT FAR* lphWaveOut, UINT uDeviceID, const WAVEFORMAT FAR* lpFormat, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { printf("waveOutOpen\n"); +if (lphWaveOut != NULL) *lphWaveOut = 0; return 0; } @@ -920,6 +1115,7 @@ UINT WINAPI waveInOpen(HWAVEIN FAR* lphWaveIn, UINT uDeviceID, const WAVEFORMAT FAR* lpFormat, DWORD dwCallback, DWORD dwInstance, DWORD dwFlags) { printf("waveInOpen\n"); +if (lphWaveIn != NULL) *lphWaveIn = 0; return 0; } diff --git a/misc/property.c b/misc/property.c index 55abcb925b9..3ce34c8a464 100644 --- a/misc/property.c +++ b/misc/property.c @@ -45,7 +45,10 @@ HANDLE RemoveProp(HWND hWnd, LPSTR lpStr) lpProp = (LPPROPENTRY) GlobalLock(wndPtr->hProp); if (lpProp == NULL) return 0; while (TRUE) { - if (strcmp(lpProp->PropName, lpStr) == 0) { + if ((((DWORD)lpStr & 0xFFFF0000) == 0L && + lpProp->Atom == LOWORD((DWORD)lpStr)) || + (((DWORD)lpStr & 0xFFFF0000) != 0L && + strcmp(lpProp->PropName, lpStr) == 0)) { printf("RemoveProp // Property found ! hData=%04X\n", lpProp->hData); hOldData = lpProp->hData; if (lpProp->lpPrevProp != NULL) @@ -54,7 +57,7 @@ HANDLE RemoveProp(HWND hWnd, LPSTR lpStr) if (lpProp->lpNextProp != NULL) ((LPPROPENTRY)lpProp->lpNextProp)->lpPrevProp = lpProp->lpPrevProp; - free(lpProp->PropName); + if (lpProp->PropName != NULL) free(lpProp->PropName); free(lpProp); GlobalUnlock(wndPtr->hProp); return hOldData; @@ -84,7 +87,7 @@ HANDLE GetProp(HWND hWnd, LPSTR lpStr) wndPtr = WIN_FindWndPtr(hWnd); if (wndPtr == NULL) { printf("GetProp // Bad Window handle !\n"); - return FALSE; + return 0; } lpProp = (LPPROPENTRY) GlobalLock(wndPtr->hProp); if (lpProp == NULL) return 0; @@ -130,7 +133,10 @@ BOOL SetProp(HWND hWnd, LPSTR lpStr, HANDLE hData) lpProp = (LPPROPENTRY) GlobalLock(wndPtr->hProp); if (lpProp != NULL) { while (TRUE) { - if (strcmp(lpProp->PropName, lpStr) == 0) { + if ((((DWORD)lpStr & 0xFFFF0000) == 0L && + lpProp->Atom == LOWORD((DWORD)lpStr)) || + (((DWORD)lpStr & 0xFFFF0000) != 0L && + strcmp(lpProp->PropName, lpStr) == 0)) { #ifdef DEBUG_PROP printf("SetProp // change already exinsting property !\n"); #endif @@ -190,8 +196,39 @@ BOOL SetProp(HWND hWnd, LPSTR lpStr, HANDLE hData) */ int EnumProps(HWND hWnd, FARPROC lpEnumFunc) { - printf("EMPTY STUB !!! EnumProps(%04X, %08X)\n", hWnd, lpEnumFunc); - return -1; + WND *wndPtr; + LPPROPENTRY lpProp; + LPSTR str; + int nRet; + printf("EnumProps(%04X, %08X)\n", hWnd, lpEnumFunc); + wndPtr = WIN_FindWndPtr(hWnd); + if (wndPtr == NULL) { + printf("EnumProps // Bad Window handle !\n"); + return 0; + } + lpProp = (LPPROPENTRY) GlobalLock(wndPtr->hProp); + if (lpProp == NULL) return 0; + if (lpEnumFunc != NULL) return 0; + while (TRUE) { + printf("EnumProps // lpProp->Atom=%04X !\n", lpProp->Atom); + str = (LPSTR)MAKELONG(lpProp->Atom, 0); + if (lpProp->PropName != NULL) { + printf("EnumProps // lpProp->PropName='%s' !\n", lpProp->PropName); + str = lpProp->PropName; + } +#ifdef WINELIB + nRet = (*lpEnumFunc)((HWND)hWnd, (WORD)0, + (LPSTR)str, (HANDLE)lpProp->hData); +#else + nRet = CallBack16(lpEnumFunc, 4, (HANDLE)lpProp->hData, + (LPSTR)str, (WORD)0, (HWND)hWnd); +#endif + if (nRet == 0) break; + if (lpProp->lpNextProp == NULL) break; + lpProp = lpProp->lpNextProp; + } + GlobalUnlock(wndPtr->hProp); + return 0; } diff --git a/misc/shell.c b/misc/shell.c index bb863532e82..779c5952e2d 100644 --- a/misc/shell.c +++ b/misc/shell.c @@ -134,6 +134,21 @@ HINSTANCE FindExecutable(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult) } char AppName[256], AppMisc[256]; +INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam); + +/************************************************************************* + * ShellAbout [SHELL.22] + */ +INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon) +{ + fprintf(stderr, "ShellAbout ! (%s, %s)\n", szApp, szOtherStuff); + + strcpy(AppName, szApp); + strcpy(AppMisc, szOtherStuff); + + return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (FARPROC)AboutDlgProc); +} + /************************************************************************* * AboutDlgProc [SHELL.33] @@ -145,7 +160,7 @@ INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam) switch(msg) { case WM_INITDIALOG: sprintf(temp, "About %s", AppName); -/* SetDlgItemText(hWnd, 0, temp);*/ + SetWindowText(hWnd, temp); SetDlgItemText(hWnd, 100, AppMisc); break; @@ -160,20 +175,6 @@ INT AboutDlgProc(HWND hWnd, WORD msg, WORD wParam, LONG lParam) } /************************************************************************* - * ShellAbout [SHELL.22] - */ -INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON hIcon) -{ - fprintf(stderr, "ShellAbout ! (%s, %s)\n", szApp, szOtherStuff); - - strcpy(AppName, szApp); - strcpy(AppMisc, szOtherStuff); - - return DialogBox(hSysRes, "SHELL_ABOUT_MSGBOX", hWnd, (FARPROC)AboutDlgProc); -} - - -/************************************************************************* * ExtractIcon [SHELL.34] */ HICON ExtractIcon(HINSTANCE hInst, LPCSTR lpszExeFileName, UINT nIconIndex) diff --git a/misc/winsocket.c b/misc/winsocket.c index cc361f6bfc8..4d9d5c04d26 100644 --- a/misc/winsocket.c +++ b/misc/winsocket.c @@ -549,8 +549,12 @@ struct servent *Winsock_getservbyport(INT port, const char FAR *proto) /******************** winsock specific functions ************************ * */ +static HANDLE new_handle = 0; -#define AllocWSAHandle() getpid() +HANDLE AllocWSAHandle(void) +{ + return new_handle++; +} static void recv_message(int sig) { diff --git a/objects/Imakefile b/objects/Imakefile index bce8061220e..b39ccd22e89 100644 --- a/objects/Imakefile +++ b/objects/Imakefile @@ -17,7 +17,8 @@ SRCS = \ bitblt.c \ linedda.c \ color.c \ - dither.c + dither.c \ + metafile.c OBJS = \ bitmap.o \ @@ -34,7 +35,8 @@ OBJS = \ bitblt.o \ linedda.o \ color.o \ - dither.o + dither.o \ + metafile.o WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS)) DependTarget() diff --git a/objects/brush.c b/objects/brush.c index 94641842cc2..563617fbfb5 100644 --- a/objects/brush.c +++ b/objects/brush.c @@ -9,6 +9,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "gdi.h" #include "bitmap.h" #include "prototypes.h" +#include "metafile.h" #define NB_HATCH_STYLES 6 @@ -228,6 +229,26 @@ HBRUSH BRUSH_SelectObject( HDC hdc, DC * dc, HBRUSH hbrush, BRUSHOBJ * brush ) HBITMAP hBitmap; BITMAPINFO * bmpInfo; HBRUSH prevHandle = dc->w.hBrush; + + if (dc->header.wMagic == METAFILE_DC_MAGIC) + { + switch (brush->logbrush.lbStyle) + { + case BS_SOLID: + case BS_HATCHED: + case BS_HOLLOW: + if (!MF_CreateBrushIndirect(dc, &(brush->logbrush))) + return 0; + break; + + case BS_PATTERN: + case BS_DIBPATTERN: + if (!MF_CreatePatternBrush(dc, &(brush->logbrush))) + return 0; + break; + } + return 1; + } dc->w.hBrush = hbrush; diff --git a/objects/dcvalues.c b/objects/dcvalues.c index 12b775f1b02..33b51ac068d 100644 --- a/objects/dcvalues.c +++ b/objects/dcvalues.c @@ -7,6 +7,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "gdi.h" +#include "metafile.h" /* Default DC values */ const WIN_DC_INFO DCVAL_defaultValues = @@ -96,25 +97,33 @@ func_type func_name( HDC hdc, func_type val ) \ return prevVal; \ } -#define DC_SET_MODE( func_name, dc_field, min_val, max_val ) \ +#define DC_SET_MODE( func_name, dc_field, min_val, max_val, meta_func ) \ WORD func_name( HDC hdc, WORD mode ) \ { \ WORD prevMode; \ DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); \ - if (!dc) return 0; \ if ((mode < min_val) || (mode > max_val)) return 0; \ + if (!dc) { \ + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); \ + if (!dc) return 0; \ + MF_MetaParam1(dc, meta_func, mode); \ + return 1; \ + } \ prevMode = dc->w.dc_field; \ dc->w.dc_field = mode; \ return prevMode; \ } -DC_SET_MODE( SetBkMode, backgroundMode, TRANSPARENT, OPAQUE ) /* GDI.2 */ -DC_SET_MODE( SetROP2, ROPmode, R2_BLACK, R2_WHITE ) /* GDI.4 */ -DC_SET_MODE( SetRelAbs, relAbsMode, ABSOLUTE, RELATIVE ) /* GDI.5 */ -DC_SET_MODE( SetPolyFillMode, polyFillMode, ALTERNATE, WINDING ) /* GDI.6 */ +DC_SET_MODE( SetBkMode, backgroundMode, TRANSPARENT, OPAQUE, + META_SETBKMODE ) /* GDI.2 */ +DC_SET_MODE( SetROP2, ROPmode, R2_BLACK, R2_WHITE, META_SETROP2 ) /* GDI.4 */ +DC_SET_MODE( SetRelAbs, relAbsMode, ABSOLUTE, RELATIVE, + META_SETRELABS ) /* GDI.5 */ +DC_SET_MODE( SetPolyFillMode, polyFillMode, ALTERNATE, WINDING, + META_SETPOLYFILLMODE ) /* GDI.6 */ DC_SET_MODE( SetStretchBltMode, stretchBltMode, - BLACKONWHITE, COLORONCOLOR ) /* GDI.7 */ + BLACKONWHITE, COLORONCOLOR, META_SETSTRETCHBLTMODE ) /* GDI.7 */ DC_GET_VAL( COLORREF, GetBkColor, backgroundColor ) /* GDI.75 */ DC_GET_VAL( WORD, GetBkMode, backgroundMode ) /* GDI.76 */ DC_GET_X_Y( DWORD, GetCurrentPosition, CursPosX, CursPosY ) /* GDI.78 */ diff --git a/objects/font.c b/objects/font.c index b346d8a0321..2ff21c51404 100644 --- a/objects/font.c +++ b/objects/font.c @@ -10,6 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include #include #include +#include "user.h" #include "gdi.h" @@ -414,7 +415,7 @@ BOOL GetCharWidth(HDC hdc, WORD wFirstChar, WORD wLastChar, LPINT lpBuffer) for (i = wFirstChar, j = 0; i <= wLastChar; i++, j++) { CI_GET_CHAR_INFO(xfont, i, def, cs); - *(lpBuffer + j) = cs->width; + *(lpBuffer + j) = cs ? cs->width : xfont->max_bounds.width; if (*(lpBuffer + j) < 0) *(lpBuffer + j) = 0; } @@ -425,11 +426,138 @@ BOOL GetCharWidth(HDC hdc, WORD wFirstChar, WORD wLastChar, LPINT lpBuffer) /************************************************************************* * EnumFonts [GDI.70] */ -int EnumFonts(HDC hDC, LPSTR lpFaceName, FARPROC lpFontFunc, LPSTR lpData) +int EnumFonts(HDC hDC, LPSTR lpFaceName, FARPROC lpEnumFunc, LPSTR lpData) { - printf("EMPTY STUB !!! EnumFonts(%04X, %08X, %08X, %08X)\n", - hDC, lpFaceName, lpFontFunc, lpData); - return -1; + HANDLE hLog; + HANDLE hMet; + LPLOGFONT lpLogFont; + LPTEXTMETRIC lptm; + int nRet; + printf("EnumFonts(%04X, %08X, %08X, %08X)\n", + hDC, lpFaceName, lpEnumFunc, lpData); + if (lpEnumFunc == NULL) return 0; + hLog = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LOGFONT) + LF_FACESIZE); + lpLogFont = (LPLOGFONT) USER_HEAP_ADDR(hLog); + if (lpLogFont == NULL) { + printf("EnumFonts // can't alloc LOGFONT struct !\n"); + return 0; + } + hMet = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(TEXTMETRIC)); + lptm = (LPTEXTMETRIC) USER_HEAP_ADDR(hMet); + if (lptm == NULL) { + USER_HEAP_FREE(hLog); + printf("EnumFonts // can't alloc TEXTMETRIC struct !\n"); + return 0; + } + while (TRUE) { + printf("EnumFonts // !\n"); + lpLogFont->lfHeight = 18; + lpLogFont->lfWidth = 12; + lpLogFont->lfEscapement = 0; + lpLogFont->lfOrientation = 0; + lpLogFont->lfWeight = FW_REGULAR; + lpLogFont->lfItalic = 0; + lpLogFont->lfUnderline = 0; + lpLogFont->lfStrikeOut = 0; + lpLogFont->lfCharSet = ANSI_CHARSET; + lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; + lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lpLogFont->lfQuality = DEFAULT_QUALITY; + lpLogFont->lfPitchAndFamily = FIXED_PITCH | FF_MODERN; + strcpy(lpLogFont->lfFaceName, "Courier"); + printf("lpLogFont=%08X lptm=%08X\n", lpLogFont, lptm); +#ifdef WINELIB + nRet = (*lpEnumFunc)(lpLogFont, lptm, 0, lpData); +#else + nRet = CallBack16(lpEnumFunc, 4, 2, (int)lpLogFont, + 2, (int)lptm, 0, (int)0, 2, (int)lpData); +#endif + if (nRet == 0) break; + lpLogFont->lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS; + strcpy(lpLogFont->lfFaceName, "Helvetica"); + printf("lpLogFont=%08X lptm=%08X\n", lpLogFont, lptm); +#ifdef WINELIB + nRet = (*lpEnumFunc)(lpLogFont, lptm, 0, lpData); +#else + nRet = CallBack16(lpEnumFunc, 4, 2, (int)lpLogFont, + 2, (int)lptm, 0, (int)0, 2, (int)lpData); +#endif + if (nRet == 0) break; + else break; + } + USER_HEAP_FREE(hMet); + USER_HEAP_FREE(hLog); + return 0; +} + + +/************************************************************************* + * EnumFontFamilies [GDI.330] + */ +int EnumFontFamilies(HDC hDC, LPSTR lpszFamily, FARPROC lpEnumFunc, LPSTR lpData) +{ + HANDLE hLog; + HANDLE hMet; + LPLOGFONT lpLogFont; + LPTEXTMETRIC lptm; + int nRet; + printf("EnumFontFamilies(%04X, %08X, %08X, %08X)\n", + hDC, lpszFamily, lpEnumFunc, lpData); + if (lpEnumFunc == NULL) return 0; + hLog = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(LOGFONT) + LF_FACESIZE); + lpLogFont = (LPLOGFONT) USER_HEAP_ADDR(hLog); + if (lpLogFont == NULL) { + printf("EnumFontFamilies // can't alloc LOGFONT struct !\n"); + return 0; + } + hMet = USER_HEAP_ALLOC(GMEM_MOVEABLE, sizeof(TEXTMETRIC)); + lptm = (LPTEXTMETRIC) USER_HEAP_ADDR(hMet); + if (lptm == NULL) { + USER_HEAP_FREE(hLog); + printf("EnumFontFamilies // can't alloc TEXTMETRIC struct !\n"); + return 0; + } + while (TRUE) { + printf("EnumFontFamilies // !\n"); + lpLogFont->lfHeight = 12; + lpLogFont->lfWidth = 8; + lpLogFont->lfEscapement = 0; + lpLogFont->lfOrientation = 0; + lpLogFont->lfWeight = FW_REGULAR; + lpLogFont->lfItalic = 0; + lpLogFont->lfUnderline = 0; + lpLogFont->lfStrikeOut = 0; + lpLogFont->lfCharSet = ANSI_CHARSET; + lpLogFont->lfOutPrecision = OUT_DEFAULT_PRECIS; + lpLogFont->lfClipPrecision = CLIP_DEFAULT_PRECIS; + lpLogFont->lfQuality = DEFAULT_QUALITY; + lpLogFont->lfPitchAndFamily = FIXED_PITCH | FF_MODERN; + strcpy(lpLogFont->lfFaceName, "Courier"); +/* lpLogFont->lfFullName[LF_FACESIZE] = 12; + lpLogFont->lfStyle[LF_FACESIZE] = 12; */ + printf("lpLogFont=%08X lptm=%08X\n", lpLogFont, lptm); +#ifdef WINELIB + nRet = (*lpEnumFunc)(lpLogFont, lptm, 0, lpData); +#else + nRet = CallBack16(lpEnumFunc, 4, 2, (int)lpLogFont, + 2, (int)lptm, 0, (int)0, 2, (int)lpData); +#endif + if (nRet == 0) break; + lpLogFont->lfPitchAndFamily = VARIABLE_PITCH | FF_SWISS; + strcpy(lpLogFont->lfFaceName, "Helvetica"); + printf("lpLogFont=%08X lptm=%08X\n", lpLogFont, lptm); +#ifdef WINELIB + nRet = (*lpEnumFunc)(lpLogFont, lptm, 0, lpData); +#else + nRet = CallBack16(lpEnumFunc, 4, 2, (int)lpLogFont, + 2, (int)lptm, 0, (int)0, 2, (int)lpData); +#endif + if (nRet == 0) break; + else break; + } + USER_HEAP_FREE(hMet); + USER_HEAP_FREE(hLog); + return 0; } diff --git a/objects/gdiobj.c b/objects/gdiobj.c index cd7888755c3..6243fd2700d 100644 --- a/objects/gdiobj.c +++ b/objects/gdiobj.c @@ -356,7 +356,11 @@ HANDLE SelectObject( HDC hdc, HANDLE handle ) if (!ptr) return 0; dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return 0; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return 0; + } switch(ptr->wMagic) { diff --git a/objects/pen.c b/objects/pen.c index 48da2526a73..cf3089fee88 100644 --- a/objects/pen.c +++ b/objects/pen.c @@ -7,6 +7,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "gdi.h" +#include "metafile.h" extern WORD COLOR_ToPhysical( DC *dc, COLORREF color ); @@ -60,8 +61,11 @@ HPEN PEN_SelectObject( DC * dc, HPEN hpen, PENOBJ * pen ) static char dash_dot[] = { 2, 2 }; /* -- -- -- -- -- -- */ static char dash_dashdot[] = { 4,3,2,3 }; /* ---- -- ---- -- */ static char dash_dashdotdot[] = { 4,2,2,2,2,2 }; /* ---- -- -- ---- */ - HPEN prevHandle = dc->w.hPen; + + if (dc->header.wMagic == METAFILE_DC_MAGIC) + return MF_CreatePenIndirect(dc, &(pen->logpen)); + dc->w.hPen = hpen; dc->u.x.pen.style = pen->logpen.lopnStyle; diff --git a/objects/text.c b/objects/text.c index ae01b208841..0d9690b8bd3 100644 --- a/objects/text.c +++ b/objects/text.c @@ -9,6 +9,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include #include "windows.h" #include "gdi.h" +#include "metafile.h" #define TAB 9 #define LF 10 @@ -255,7 +256,14 @@ BOOL TextOut( HDC hdc, short x, short y, LPSTR str, short count ) XFontStruct *font; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return FALSE; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_TextOut(dc, x, y, str, count); + return TRUE; + } + if (!DC_SetupGCForText( dc )) return TRUE; font = dc->u.x.font.fstruct; @@ -403,3 +411,17 @@ BOOL GrayString(HDC hdc, HBRUSH hbr, FARPROC gsprc, LPARAM lParam, return s; } } + +/*********************************************************************** + * ExtTextOut [GDI.351] + */ +BOOL ExtTextOut(HDC hDC, short x, short y, WORD wOptions, LPRECT lprect, + LPSTR str, WORD count, LPINT lpDx) +{ + printf("EMPTY STUB !!! ExtTextOut(); ! (call TextOut() for new)\n"); + TextOut(hDC, x, y, str, count); + return FALSE; +} + + + diff --git a/windows/class.c b/windows/class.c index 68277c661ce..753ee0d2895 100644 --- a/windows/class.c +++ b/windows/class.c @@ -110,6 +110,11 @@ ATOM RegisterClass( LPWNDCLASS class ) if (!(prevClassPtr->wc.style & CS_GLOBALCLASS)) return 0; } + /* bug for bug compatible */ + + if (class->cbClsExtra < 0) class->cbClsExtra = 0; + if (class->cbWndExtra < 0) class->cbWndExtra = 0; + /* Create class */ handle = USER_HEAP_ALLOC( GMEM_MOVEABLE, sizeof(CLASS)+class->cbClsExtra ); diff --git a/windows/dc.c b/windows/dc.c index 58dd531dbb5..c5cc0c72688 100644 --- a/windows/dc.c +++ b/windows/dc.c @@ -10,6 +10,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include #include "gdi.h" #include "bitmap.h" +#include "metafile.h" static DeviceCaps * displayDevCaps = NULL; @@ -104,6 +105,7 @@ static void DC_InitDC( HDC hdc ) SelectObject( hdc, dc->w.hFont ); XSetGraphicsExposures( XT_display, dc->u.x.gc, False ); CLIPPING_SetDeviceClipping( dc ); + FONT_SelectObject(dc, STOCK_SYSTEM_FIXED_FONT, NULL); } @@ -477,7 +479,13 @@ COLORREF SetBkColor( HDC hdc, COLORREF color ) { COLORREF oldColor; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return 0x80000000; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return 0x80000000; + MF_MetaParam2(dc, META_SETBKCOLOR, HIWORD(color), LOWORD(color)); + return 0; /* ?? */ + } oldColor = dc->w.backgroundColor; dc->w.backgroundColor = color; @@ -493,7 +501,13 @@ COLORREF SetTextColor( HDC hdc, COLORREF color ) { COLORREF oldColor; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return 0x80000000; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return 0x80000000; + MF_MetaParam2(dc, META_SETTEXTCOLOR, HIWORD(color), LOWORD(color)); + return 0; /* ?? */ + } oldColor = dc->w.textColor; dc->w.textColor = color; diff --git a/windows/dialog.c b/windows/dialog.c index 379b0b082c0..772408452e7 100644 --- a/windows/dialog.c +++ b/windows/dialog.c @@ -4,6 +4,8 @@ * Copyright 1993 Alexandre Julliard */ +#define DEBUG_DIALOG /* */ + static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include @@ -267,6 +269,9 @@ HWND CreateDialogIndirectParam( HINSTANCE hInst, LPCSTR dlgTemplate, return 0; } + ShowWindow(hwnd, SW_SHOWNORMAL); + UpdateWindow(hwnd); + /* Create control windows */ #ifdef DEBUG_DIALOG diff --git a/windows/graphics.c b/windows/graphics.c index 2594c917b76..a80d5cf63b8 100644 --- a/windows/graphics.c +++ b/windows/graphics.c @@ -26,7 +26,14 @@ extern int COLOR_ToPhysical( DC *dc, COLORREF color ); BOOL LineTo( HDC hdc, short x, short y ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return FALSE; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaParam2(dc, META_LINETO, x, y); + return TRUE; + } + if (DC_SetupGCForPen( dc )) XDrawLine(XT_display, dc->u.x.drawable, dc->u.x.gc, dc->w.DCOrgX + XLPTODP( dc, dc->w.CursPosX ), @@ -44,9 +51,21 @@ BOOL LineTo( HDC hdc, short x, short y ) */ DWORD MoveTo( HDC hdc, short x, short y ) { - POINT pt; - if (MoveToEx( hdc, x, y, &pt )) return pt.x | (pt.y << 16); - else return 0; + short oldx, oldy; + DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaParam2(dc, META_MOVETO, x, y); + return 0; + } + + oldx = dc->w.CursPosX; + oldy = dc->w.CursPosY; + dc->w.CursPosX = x; + dc->w.CursPosY = y; + return oldx | (oldy << 16); } @@ -81,7 +100,29 @@ BOOL GRAPH_DrawArc( HDC hdc, int left, int top, int right, int bottom, double start_angle, end_angle, diff_angle; XPoint points[3]; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return FALSE; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + switch (lines) + { + case 0: + MF_MetaParam8(dc, META_ARC, left, top, right, bottom, + xstart, ystart, xend, yend); + break; + + case 1: + MF_MetaParam8(dc, META_CHORD, left, top, right, bottom, + xstart, ystart, xend, yend); + break; + + case 2: + MF_MetaParam8(dc, META_PIE, left, top, right, bottom, + xstart, ystart, xend, yend); + break; + } + return 0; + } left = XLPTODP( dc, left ); top = YLPTODP( dc, top ); @@ -166,7 +207,13 @@ BOOL Chord( HDC hdc, int left, int top, int right, int bottom, BOOL Ellipse( HDC hdc, int left, int top, int right, int bottom ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return FALSE; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaParam4(dc, META_ELLIPSE, left, top, right, bottom); + return 0; + } left = XLPTODP( dc, left ); top = YLPTODP( dc, top ); @@ -192,7 +239,13 @@ BOOL Ellipse( HDC hdc, int left, int top, int right, int bottom ) BOOL Rectangle( HDC hdc, int left, int top, int right, int bottom ) { DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return FALSE; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaParam4(dc, META_RECTANGLE, left, top, right, bottom); + return TRUE; + } left = XLPTODP( dc, left ); top = YLPTODP( dc, top ); @@ -219,7 +272,14 @@ BOOL RoundRect( HDC hDC, short left, short top, short right, short bottom, { int x1, y1, x2, y2; DC * dc = (DC *) GDI_GetObjPtr(hDC, DC_MAGIC); - if (!dc) return FALSE; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hDC, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaParam6(dc, META_ROUNDRECT, left, top, right, bottom, + ell_width, ell_height); + return TRUE; + } /* printf("RoundRect(%d %d %d %d %d %d\n", left, top, right, bottom, ell_width, ell_height); @@ -350,7 +410,13 @@ COLORREF SetPixel( HDC hdc, short x, short y, COLORREF color ) PALETTEENTRY entry; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return 0; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return 0; + MF_MetaParam4(dc, META_SETPIXEL, x, y, HIWORD(color), LOWORD(color)); + return 1; + } x = dc->w.DCOrgX + XLPTODP( dc, x ); y = dc->w.DCOrgY + YLPTODP( dc, y ); @@ -522,25 +588,32 @@ void DrawReliefRect( HDC hdc, RECT rect, int thickness, BOOL pressed ) */ BOOL Polyline (HDC hdc, LPPOINT pt, int count) { - register int i; - DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - - if (DC_SetupGCForPen( dc )) - { - for (i = 0; i < count-1; i ++) - XDrawLine (XT_display, dc->u.x.drawable, dc->u.x.gc, - dc->w.DCOrgX + XLPTODP(dc, pt [i].x), - dc->w.DCOrgY + YLPTODP(dc, pt [i].y), - dc->w.DCOrgX + XLPTODP(dc, pt [i+1].x), - dc->w.DCOrgY + YLPTODP(dc, pt [i+1].y)); - XDrawLine (XT_display, dc->u.x.drawable, dc->u.x.gc, - dc->w.DCOrgX + XLPTODP(dc, pt [count-1].x), - dc->w.DCOrgY + YLPTODP(dc, pt [count-1].y), - dc->w.DCOrgX + XLPTODP(dc, pt [0].x), - dc->w.DCOrgY + YLPTODP(dc, pt [0].y)); - } + register int i; + DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaPoly(dc, META_POLYLINE, pt, count); + return TRUE; + } + + if (DC_SetupGCForPen( dc )) + { + for (i = 0; i < count-1; i ++) + XDrawLine (XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + XLPTODP(dc, pt [i].x), + dc->w.DCOrgY + YLPTODP(dc, pt [i].y), + dc->w.DCOrgX + XLPTODP(dc, pt [i+1].x), + dc->w.DCOrgY + YLPTODP(dc, pt [i+1].y)); + XDrawLine (XT_display, dc->u.x.drawable, dc->u.x.gc, + dc->w.DCOrgX + XLPTODP(dc, pt [count-1].x), + dc->w.DCOrgY + YLPTODP(dc, pt [count-1].y), + dc->w.DCOrgX + XLPTODP(dc, pt [0].x), + dc->w.DCOrgY + YLPTODP(dc, pt [0].y)); + } - return (TRUE); + return (TRUE); } @@ -549,31 +622,39 @@ BOOL Polyline (HDC hdc, LPPOINT pt, int count) */ 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); + register int i; + DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); + XPoint *points = (XPoint *) malloc (sizeof (XPoint) * count+1); - if (DC_SetupGCForBrush( dc )) - { + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaPoly(dc, META_POLYGON, pt, count); + return TRUE; + } + + if (DC_SetupGCForBrush( dc )) + { - for (i = 0; i < count; i++) - { - points [i].x = dc->w.DCOrgX + XLPTODP(dc, pt [i].x); - points [i].y = dc->w.DCOrgY + YLPTODP(dc, pt [i].y); - } - points [count] = points [0]; + for (i = 0; i < count; i++) + { + points [i].x = dc->w.DCOrgX + XLPTODP(dc, pt [i].x); + points [i].y = dc->w.DCOrgY + YLPTODP(dc, pt [i].y); + } + points [count] = points [0]; - XFillPolygon( XT_display, dc->u.x.drawable, dc->u.x.gc, - points, count, Complex, CoordModeOrigin); + XFillPolygon( XT_display, dc->u.x.drawable, dc->u.x.gc, + points, count, Complex, CoordModeOrigin); - if (DC_SetupGCForPen ( dc )) - { - XDrawLines( XT_display, dc->u.x.drawable, dc->u.x.gc, - points, count, CoordModeOrigin ); - } + if (DC_SetupGCForPen ( dc )) + { + XDrawLines( XT_display, dc->u.x.drawable, dc->u.x.gc, + points, count, CoordModeOrigin ); } - free ((void *) points); - return (TRUE); + } + free ((void *) points); + return (TRUE); } /********************************************************************** @@ -619,51 +700,57 @@ static BOOL FloodFill_rec(XImage *image, int x, int y, */ BOOL FloodFill(HDC hdc, short x, short y, DWORD crColor) { - Pixel boundrypixel; - int imagex, imagey; - XImage *image; - DC *dc; + Pixel boundrypixel; + int imagex, imagey; + XImage *image; + DC *dc; #ifdef DEBUG_GRAPHICS - printf("FloodFill %x %d,%d %x\n", hdc, x, y, crColor); + printf("FloodFill %x %d,%d %x\n", hdc, x, y, crColor); #endif - dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); - - if (!dc) return 0; + dc = (DC *) GDI_GetObjPtr(hdc, DC_MAGIC); + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return FALSE; + MF_MetaParam4(dc, META_FLOODFILL, x, y, HIWORD(crColor), + LOWORD(crColor)); + return TRUE; + } - x = dc->w.DCOrgX + XLPTODP(dc, x); - y = dc->w.DCOrgY + YLPTODP(dc, y); + x = dc->w.DCOrgX + XLPTODP(dc, x); + y = dc->w.DCOrgY + YLPTODP(dc, y); - if (x < dc->w.DCOrgX || x > dc->w.DCOrgX + dc->w.DCSizeX || - y < dc->w.DCOrgY || y > dc->w.DCOrgY + dc->w.DCSizeY) - return 0; + if (x < dc->w.DCOrgX || x > dc->w.DCOrgX + dc->w.DCSizeX || + y < dc->w.DCOrgY || y > dc->w.DCOrgY + dc->w.DCSizeY) + return FALSE; - if (!DC_SetupGCForBrush(dc)) - return FALSE; + if (!DC_SetupGCForBrush(dc)) + return FALSE; - boundrypixel = GetNearestPaletteIndex( dc->w.hPalette, crColor ); + boundrypixel = GetNearestPaletteIndex( dc->w.hPalette, crColor ); - image = XGetImage(display, dc->u.x.drawable, - dc->w.DCOrgX, dc->w.DCOrgY, - dc->w.DCSizeX, dc->w.DCSizeY, AllPlanes, ZPixmap); - if (XGetPixel(image, x, y) == boundrypixel) - return FALSE; - if (!FloodFill_rec(image, x, y, - 0,0, - dc->w.DCOrgX + dc->w.DCSizeX, - dc->w.DCOrgY + dc->w.DCSizeY, - boundrypixel, dc->u.x.brush.pixel)) { - XDestroyImage(image); - return 0; - } - - XPutImage(display, dc->u.x.drawable, dc->u.x.gc, image, - 0, 0, - dc->w.DCOrgX, dc->w.DCOrgY, - dc->w.DCSizeX, dc->w.DCSizeY); + image = XGetImage(display, dc->u.x.drawable, + dc->w.DCOrgX, dc->w.DCOrgY, + dc->w.DCSizeX, dc->w.DCSizeY, AllPlanes, ZPixmap); + if (XGetPixel(image, x, y) == boundrypixel) + return FALSE; + if (!FloodFill_rec(image, x, y, + 0, 0, + dc->w.DCOrgX + dc->w.DCSizeX, + dc->w.DCOrgY + dc->w.DCSizeY, + boundrypixel, dc->u.x.brush.pixel)) { XDestroyImage(image); + return FALSE; + } - return TRUE; + XPutImage(display, dc->u.x.drawable, dc->u.x.gc, image, + 0, 0, + dc->w.DCOrgX, dc->w.DCOrgY, + dc->w.DCSizeX, dc->w.DCSizeY); + XDestroyImage(image); + + return TRUE; } diff --git a/windows/mapping.c b/windows/mapping.c index e361a0f8aea..b7a475323ce 100644 --- a/windows/mapping.c +++ b/windows/mapping.c @@ -7,6 +7,7 @@ static char Copyright[] = "Copyright Alexandre Julliard, 1993"; #include "gdi.h" +#include "metafile.h" /*********************************************************************** @@ -75,7 +76,13 @@ WORD SetMapMode( HDC hdc, WORD mode ) { WORD prevMode; DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ); - if (!dc) return 0; + if (!dc) + { + dc = (DC *)GDI_GetObjPtr(hdc, METAFILE_DC_MAGIC); + if (!dc) return 0; + MF_MetaParam1(dc, META_SETMAPMODE, mode); + return 1; + } #ifdef DEBUG_GDI printf( "SetMapMode: %d %d\n", hdc, mode ); diff --git a/windows/utility.c b/windows/utility.c index 00e16836d76..c16616d21b4 100644 --- a/windows/utility.c +++ b/windows/utility.c @@ -52,7 +52,7 @@ void UTILITY_strip015(char *dest) { int DebugPrintString(char *str) { - printf("%s", str); + fprintf(stderr, "%s", str); return 0; } @@ -78,7 +78,7 @@ void OutputDebugString(LPSTR foo) static void UTILITY_qualify(const char *source, char *dest) { #ifdef debug_utility - printf("UTILITY_qualify(\"%s\", \"%s\");\n", source, dest); + fprintf(stderr, "UTILITY_qualify(\"%s\", \"%s\");\n", source, dest); #endif if(!source) return; /* Dumbass attack! */ while(*source) { @@ -130,7 +130,7 @@ size_t UTILITY_argsize(const char *format, BOOL windows) if(*format) { char modifier = ' '; #ifdef debug_utility - printf("found:\t\"%%"); + fprintf(stderr, "found:\t\"%%"); #endif format++; /* skip past '%' */ /* First skip the flags, field width, etc. */ @@ -138,39 +138,39 @@ size_t UTILITY_argsize(const char *format, BOOL windows) if ((*format == '#') || (*format == '-') || (*format == '+') || (*format == ' ')) { #ifdef debug_utility - printf("%c", *format); + fprintf(stderr, "%c", *format); #endif format++; } /* Now the field width, etc. */ while(isdigit(*format)) { #ifdef debug_utility - printf("%c", *format); + fprintf(stderr, "%c", *format); #endif format++; } if(*format == '.') { #ifdef debug_utility - printf("%c", *format); + fprintf(stderr, "%c", *format); #endif format++; } while(isdigit(*format)) { #ifdef debug_utility - printf("%c", *format); + fprintf(stderr, "%c", *format); #endif format++; } /* Now we handle the rest */ if((*format == 'h') || (*format == 'l') || (*format == 'L')) { #ifdef debug_utility - printf("%c", modifier); + fprintf(stderr, "%c", modifier); #endif modifier = *(format++); } /* Handle the actual type. */ #ifdef debug_utility - printf("%c\"\n", *format); + fprintf(stderr, "%c\"\n", *format); #endif switch(*format) { case 'd': @@ -200,7 +200,7 @@ size_t UTILITY_argsize(const char *format, BOOL windows) }; #undef INT_SIZE #ifdef debug_utility - printf("UTILITY_argsize: returning %i\n", size); + fprintf(stderr, "UTILITY_argsize: returning %i\n", size); #endif return size; }; @@ -228,7 +228,7 @@ char *UTILITY_convertArgs(char *format, char *winarg) if(*format) { char modifier = ' '; #ifdef debug_utility - printf("found:\t\"%%"); + fprintf(stderr, "found:\t\"%%"); #endif format++; /* skip past '%' */ /* First skip the flags, field width, etc. */ @@ -244,7 +244,7 @@ char *UTILITY_convertArgs(char *format, char *winarg) modifier = *(format++); /* Handle the actual type. */ #ifdef debug_utility - printf("%c\"\n", *format); + fprintf(stderr, "%c\"\n", *format); #endif switch(*format) { case 'd': @@ -282,18 +282,132 @@ char *UTILITY_convertArgs(char *format, char *winarg) return result; }; +#ifndef WINELIB +INT windows_wsprintf(BYTE *win_stack) +{ + LPSTR lpOutput, lpFormat; + BYTE *new_stack, *stack_ptr, *ptr; + int stacklength, result; + + lpOutput = (LPSTR) *(DWORD*)win_stack; + win_stack += 4; + lpFormat = (LPSTR) *(DWORD*)win_stack; + win_stack += 4; + + /* determine # of bytes pushed on 16-bit stack by checking printf's + format string */ + + ptr = lpFormat; + stacklength = 0; + do { + if (*ptr++ != '%') + continue; + + /* skip width/precision */ + while ( *ptr == '-' || *ptr == '+' || *ptr == '.' || + *ptr == ' ' || isdigit(*ptr)) + ptr++; + + switch(*ptr++) { + case 'l': ptr++; /* skip next type character */ + stacklength += 4; + continue; + case 's': + stacklength += 4; + continue; + case 'c': + case 'd': + case 'i': + case 'u': + case 'x': + case 'X': + stacklength += 2; + continue; + default: + fprintf(stderr, "wsprintf: oops, unknown formattype `%c' used!\n", *ptr); + } + } while (*ptr); + + /* create 32-bit stack for libc's vsprintf() */ + + new_stack = malloc(2 * stacklength); + stack_ptr = new_stack + 2 * stacklength; + win_stack += stacklength; + ptr = lpFormat; + do { + if (*ptr++ != '%') + continue; + + /* skip width/precision */ + while ( *ptr == '-' || *ptr == '+' || *ptr == '.' || + *ptr == ' ' || isdigit(*ptr)) + ptr++; + + switch(*ptr++) { + case 's': + stack_ptr -= 4; + win_stack -= 4; + *(DWORD*)stack_ptr = *(DWORD*)win_stack; + continue; + case 'l': + stack_ptr -= 4; + win_stack -= 4; + *(DWORD*)stack_ptr = *(DWORD*)win_stack; + ptr++; /* skip next type character */ + continue; + case 'c': + stack_ptr -= 4; + win_stack -= 2; + +/* windows' wsprintf() %c ignores 0's, we replace 0 with 1 to make sure + that the remaining part of the string isn't ignored by the winapp */ + + if (*(WORD*)win_stack) + *(DWORD*)stack_ptr = *(WORD*)win_stack; + else + *(DWORD*)stack_ptr = 1; + continue; + case 'd': + case 'i': + stack_ptr -= 4; + win_stack -= 2; + *(int*)stack_ptr = *(INT*)win_stack; + continue; + case 'u': + case 'x': + case 'X': + stack_ptr -= 4; + win_stack -= 2; + *(DWORD*)stack_ptr = *(WORD*)win_stack; + continue; + default: + stack_ptr -= 4; + win_stack -= 4; + *(DWORD*)stack_ptr = 0; + fprintf(stderr, "wsprintf: oops, unknown formattype %c used!\n", *ptr); + } + } while (*ptr); + + result = vsprintf(lpOutput, lpFormat, stack_ptr); + free(new_stack); + + return result; +} +#endif /************************************************************************** - * wsprintf [USER.420] + * wsprintf [USER.420] (not used by relay) */ int wsprintf(LPSTR lpOutput, LPSTR lpFormat, ...) { -va_list valist; -int ArgCnt; -va_start(valist, lpFormat); -ArgCnt = vsprintf(lpOutput, lpFormat, valist); -va_end(valist); -return (ArgCnt); + va_list valist; + int ArgCnt; + + va_start(valist, lpFormat); + ArgCnt = vsprintf(lpOutput, lpFormat, valist); + va_end(valist); + + return ArgCnt; } @@ -320,12 +434,11 @@ int wvsprintf(LPSTR buf, LPSTR format, LPSTR args) /* Change the format string so that ints are handled as short by default */ - UTILITY_qualify(format, qualified_fmt); /* Convert agruments to 32-bit values */ newargs = UTILITY_convertArgs(format, args); - result = vsprintf(buf, qualified_fmt, newargs); + free(newargs); return result; }; diff --git a/windows/win.c b/windows/win.c index aac7dcd16da..572dfe6c67a 100644 --- a/windows/win.c +++ b/windows/win.c @@ -971,6 +971,15 @@ BOOL AnyPopup() return FALSE; } +/******************************************************************* + * FlashWindow [USER.105] + */ +BOOL FlashWindow(HWND hWnd, BOOL bInvert) +{ + printf("EMPTY STUB !! FlashWindow !\n"); + return FALSE; +} + /******************************************************************* * SetSysModalWindow [USER.188] -- 2.11.4.GIT