Release 970101
Wed Jan 1 15:36:17 1997 Alexandre Julliard <julliard@lrc.epfl.ch>
* [controls/listbox.c]
Use FindFirstFile/FindNextFile in LISTBOX_Directory.
* [files/dos_fs.c]
Rewrote FindFirstFile/FindNextFile to use DOSFS_FindNext().
* [files/file.c] [files/directory.c]
Use Win32 kernel objects and handles for file handles.
Unified SearchPath() and OpenFile().
* [loader/builtin.c]
Moved to if1632/ directory.
* [tools/build.c] [debugger/*] [miscemu/*]
Win16 register functions now receive the same CONTEXT * structure
as Win32 functions.
* [include/sigcontext.h] [miscemu/instr.c]
Added new macros to get register values from the SIGCONTEXT
structure (only used for instruction emulation now).
* [scheduler/process.c] [scheduler/thread.c] (New files)
Allocate process and thread structures.
* [scheduler/process.c] [win32/k32obj.c]
Added Win32 kernel objects and handles management.
* [loader/task.c]
Create a Win32 process and thread for every Win16 task.
* [misc/commdlg.c] [misc/shell.c] [windows/msgbox.c]
Built-in resources are now in Win32 format. This also avoids
16-bit callbacks for built-in dialogs.
* [misc/lzexpand.c]
Differentiate between 16-bit and 32-bit file handles.
* [miscemu/int*.c]
Moved all int emulation to msdos/ directory.
* [msdos/*]
New directory msdos/ contains all MS-DOS emulation code that can
also be used for Winelib; this should enable Winelib apps to use
DOS3Call and related functions.
* [rc/winerc.c]
A few bug fixes for Win32 resource format.
* [windows/winpos.c]
Hack in WINPOS_ReorderOwnerPopups() to avoid X crashed (still not
right though).
Sun Dec 29 17:47:55 1996 O. Flebbe <flebbe@science-computing.uni-tuebingen.de>
* [loader/pe_image.c]
Make sure BSS of a PE_Image is zero.
Sat Dec 28 22:15:34 1996 Alex Korobka <alex@trantor.pharm.sunysb.edu>
* [windows/scroll.c]
ScrollWindowEx() rewrite, ScrollDC() fix.
* [windows/nonclient.c] [controls/menu.c]
Fixed Alt-Space crashes in dialogs.
* [windows/event.c] [windows/message.c]
Some changes in mouse message generation.
Thu Dec 26 09:25:24 1996 Philippe De Muyter <phdm@info.ucl.ac.be>
* [debugger/stabs.c]
Dummy DEBUG_ReadExecutableDbgInfo provided for !__ELF__ case.
Tue Dec 24 00:59:05 MET 1996 Martin Buck <martin-2.buck@student.uni-ulm.de>
* [windows/event.c]
Changed XK_Page_{Up,Down} to XK_{Prior,Next} for X11R5
compatibility.
diff --git a/ANNOUNCE b/ANNOUNCE
index ba07f17..13b5bb4 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,13 +1,13 @@
-This is release 961222 of Wine, the MS Windows emulator. This is still a
+This is release 970101 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 correctly.
Patches should be submitted to "julliard@lrc.epfl.ch". Please don't
forget to include a ChangeLog entry.
-WHAT'S NEW with Wine-961222: (see ChangeLog for details)
- - Lots of improvements to the built-in debugger
- - Yet more Win32 stuff.
+WHAT'S NEW with Wine-970101: (see ChangeLog for details)
+ - Win32 handle management and related stuff.
+ - Several files moved around, new directories created.
- Lots of bug fixes.
See the README file in the distribution for installation instructions.
@@ -16,10 +16,10 @@
the release is available at the ftp sites. The sources will be available
from the following locations:
- ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-961222.tar.gz
- ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-961222.tar.gz
- ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-961222.tar.gz
- ftp://aris.com/pub/linux/ALPHA/Wine/development/Wine-961222.tar.gz
+ ftp://sunsite.unc.edu/pub/Linux/ALPHA/wine/development/Wine-970101.tar.gz
+ ftp://tsx-11.mit.edu/pub/linux/ALPHA/Wine/development/Wine-970101.tar.gz
+ ftp://ftp.infomagic.com/pub/mirrors/linux/wine/development/Wine-970101.tar.gz
+ ftp://aris.com/pub/linux/ALPHA/Wine/development/Wine-970101.tar.gz
It should also be available from any site that mirrors tsx-11 or sunsite.
diff --git a/ChangeLog b/ChangeLog
index 517be68..f98f01d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,86 @@
----------------------------------------------------------------------
+Wed Jan 1 15:36:17 1997 Alexandre Julliard <julliard@lrc.epfl.ch>
+
+ * [controls/listbox.c]
+ Use FindFirstFile/FindNextFile in LISTBOX_Directory.
+
+ * [files/dos_fs.c]
+ Rewrote FindFirstFile/FindNextFile to use DOSFS_FindNext().
+
+ * [files/file.c] [files/directory.c]
+ Use Win32 kernel objects and handles for file handles.
+ Unified SearchPath() and OpenFile().
+
+ * [loader/builtin.c]
+ Moved to if1632/ directory.
+
+ * [tools/build.c] [debugger/*] [miscemu/*]
+ Win16 register functions now receive the same CONTEXT * structure
+ as Win32 functions.
+
+ * [include/sigcontext.h] [miscemu/instr.c]
+ Added new macros to get register values from the SIGCONTEXT
+ structure (only used for instruction emulation now).
+
+ * [scheduler/process.c] [scheduler/thread.c] (New files)
+ Allocate process and thread structures.
+
+ * [scheduler/process.c] [win32/k32obj.c]
+ Added Win32 kernel objects and handles management.
+
+ * [loader/task.c]
+ Create a Win32 process and thread for every Win16 task.
+
+ * [misc/commdlg.c] [misc/shell.c] [windows/msgbox.c]
+ Built-in resources are now in Win32 format. This also avoids
+ 16-bit callbacks for built-in dialogs.
+
+ * [misc/lzexpand.c]
+ Differentiate between 16-bit and 32-bit file handles.
+
+ * [miscemu/int*.c]
+ Moved all int emulation to msdos/ directory.
+
+ * [msdos/*]
+ New directory msdos/ contains all MS-DOS emulation code that can
+ also be used for Winelib; this should enable Winelib apps to use
+ DOS3Call and related functions.
+
+ * [rc/winerc.c]
+ A few bug fixes for Win32 resource format.
+
+ * [windows/winpos.c]
+ Hack in WINPOS_ReorderOwnerPopups() to avoid X crashed (still not
+ right though).
+
+Sun Dec 29 17:47:55 1996 O. Flebbe <flebbe@science-computing.uni-tuebingen.de>
+
+ * [loader/pe_image.c]
+ Make sure BSS of a PE_Image is zero.
+
+Sat Dec 28 22:15:34 1996 Alex Korobka <alex@trantor.pharm.sunysb.edu>
+
+ * [windows/scroll.c]
+ ScrollWindowEx() rewrite, ScrollDC() fix.
+
+ * [windows/nonclient.c] [controls/menu.c]
+ Fixed Alt-Space crashes in dialogs.
+
+ * [windows/event.c] [windows/message.c]
+ Some changes in mouse message generation.
+
+Thu Dec 26 09:25:24 1996 Philippe De Muyter <phdm@info.ucl.ac.be>
+
+ * [debugger/stabs.c]
+ Dummy DEBUG_ReadExecutableDbgInfo provided for !__ELF__ case.
+
+Tue Dec 24 00:59:05 MET 1996 Martin Buck <martin-2.buck@student.uni-ulm.de>
+
+ * [windows/event.c]
+ Changed XK_Page_{Up,Down} to XK_{Prior,Next} for X11R5
+ compatibility.
+
+----------------------------------------------------------------------
Sun Dec 22 13:30:18 1996 Alexandre Julliard <julliard@lrc.epfl.ch>
* [graphics/metafiledrv/init.c] [graphisc/metafiledrv/mapping.c]
diff --git a/Makefile.in b/Makefile.in
index 9a676b1..f861a0a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -53,9 +53,11 @@
loader \
memory \
misc \
+ msdos \
multimedia \
objects \
resources \
+ scheduler \
win32 \
windows
@@ -82,9 +84,11 @@
loader/loader.o \
memory/memory.o \
misc/misc.o \
+ msdos/msdos.o \
multimedia/multimedia.o \
objects/objects.o \
resources/resources.o \
+ scheduler/scheduler.o \
win32/win32.o \
windows/windows.o
diff --git a/configure b/configure
index b7d6163..8189b70 100755
--- a/configure
+++ b/configure
@@ -2489,6 +2489,7 @@
memory/Makefile
misc/Makefile
miscemu/Makefile
+msdos/Makefile
multimedia/Makefile
objects/Makefile
programs/Makefile
@@ -2496,6 +2497,7 @@
programs/winhelp/Makefile
rc/Makefile
resources/Makefile
+scheduler/Makefile
tools/Makefile
win32/Makefile
windows/Makefile include/config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
@@ -2604,6 +2606,7 @@
memory/Makefile
misc/Makefile
miscemu/Makefile
+msdos/Makefile
multimedia/Makefile
objects/Makefile
programs/Makefile
@@ -2611,6 +2614,7 @@
programs/winhelp/Makefile
rc/Makefile
resources/Makefile
+scheduler/Makefile
tools/Makefile
win32/Makefile
windows/Makefile "}
diff --git a/configure.in b/configure.in
index 273f842..ede5e0c 100644
--- a/configure.in
+++ b/configure.in
@@ -131,6 +131,7 @@
memory/Makefile
misc/Makefile
miscemu/Makefile
+msdos/Makefile
multimedia/Makefile
objects/Makefile
programs/Makefile
@@ -138,6 +139,7 @@
programs/winhelp/Makefile
rc/Makefile
resources/Makefile
+scheduler/Makefile
tools/Makefile
win32/Makefile
windows/Makefile ])
diff --git a/controls/desktop.c b/controls/desktop.c
index 8fcde45..895fec4 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -10,7 +10,6 @@
#include <unistd.h>
#include "win.h"
#include "desktop.h"
-#include "directory.h"
#include "graphics.h"
#include "heap.h"
@@ -25,13 +24,13 @@
BITMAPFILEHEADER *fileHeader;
BITMAPINFO *bitmapInfo;
HBITMAP32 hbitmap;
- HFILE file;
+ HFILE32 file;
LPSTR buffer;
LONG size;
/* Read all the file into memory */
- if ((file = _lopen( filename, OF_READ )) == HFILE_ERROR)
+ if ((file = _lopen32( filename, OF_READ )) == HFILE_ERROR32)
{
UINT32 len = GetWindowsDirectory32A( NULL, 0 );
if (!(buffer = HeapAlloc( SystemHeap, 0, len + strlen(filename) + 2 )))
@@ -39,19 +38,19 @@
GetWindowsDirectory32A( buffer, len + 1 );
strcat( buffer, "\\" );
strcat( buffer, filename );
- file = _lopen( buffer, OF_READ );
+ file = _lopen32( buffer, OF_READ );
HeapFree( SystemHeap, 0, buffer );
}
- if (file == HFILE_ERROR) return 0;
- size = _llseek( file, 0, 2 );
+ if (file == HFILE_ERROR32) return 0;
+ size = _llseek32( file, 0, 2 );
if (!(buffer = HeapAlloc( SystemHeap, 0, size )))
{
- _lclose( file );
+ _lclose32( file );
return 0;
}
- _llseek( file, 0, 0 );
+ _llseek32( file, 0, 0 );
size = _lread32( file, buffer, size );
- _lclose( file );
+ _lclose32( file );
fileHeader = (BITMAPFILEHEADER *)buffer;
bitmapInfo = (BITMAPINFO *)(buffer + sizeof(BITMAPFILEHEADER));
@@ -157,7 +156,7 @@
case WM_SYSCOMMAND:
if ((wParam & 0xfff0) != SC_CLOSE) return 0;
- ExitWindows( 0, 0 );
+ ExitWindows16( 0, 0 );
case WM_SETCURSOR:
return (LRESULT)SetCursor( LoadCursor16( 0, IDC_ARROW ) );
diff --git a/controls/listbox.c b/controls/listbox.c
index ceed8b2..70f13b3 100644
--- a/controls/listbox.c
+++ b/controls/listbox.c
@@ -8,9 +8,8 @@
#include <string.h>
#include <stdio.h>
#include "windows.h"
+#include "winerror.h"
#include "drive.h"
-#include "dos_fs.h"
-#include "msdos.h"
#include "heap.h"
#include "spy.h"
#include "win.h"
@@ -478,7 +477,7 @@
else
SetTextColor( hdc, GetSysColor( COLOR_WINDOWTEXT ) );
}
- dprintf_listbox( stddeb, "Listbox %04x: painting %d (%s) action=%02x"
+ dprintf_listbox( stddeb, "Listbox %04x: painting %d (%s) action=%02x "
"rect=%d,%d-%d,%d\n",
wnd->hwndSelf, index, item ? item->str : "", action,
rect->left, rect->top, rect->right, rect->bottom );
@@ -1455,55 +1454,45 @@
LRESULT LISTBOX_Directory( WND *wnd, LB_DESCR *descr, UINT32 attrib,
LPCSTR filespec, BOOL32 long_names )
{
- char mask[13];
- const char *ptr;
- char *path, *p;
- int count, skip, pos;
- LRESULT ret;
- DOS_DIRENT entry;
+ HANDLE32 handle;
+ LRESULT ret = LB_OKAY;
+ WIN32_FIND_DATA32A entry;
+ int pos;
- /* FIXME: should use FindFirstFile/FindNextFile */
-
- if (!filespec) return LB_ERR;
- if (!(ptr = DOSFS_GetUnixFileName( filespec, FALSE ))) return LB_ERR;
- path = HEAP_strdupA( SystemHeap, 0, ptr );
- p = strrchr( path, '/' );
- *p++ = '\0';
- if (!(ptr = DOSFS_ToDosFCBFormat( p )))
+ if ((handle = FindFirstFile32A(filespec,&entry)) == INVALID_HANDLE_VALUE32)
{
- HeapFree( SystemHeap, 0, path );
- return LB_ERR;
+ if (GetLastError() != ERROR_NO_MORE_FILES) return LB_ERR;
}
- strcpy( mask, ptr );
-
- skip = 0;
- ret = LB_OKAY;
- attrib &= ~FA_LABEL;
- while ((count = DOSFS_FindNext( path, mask, NULL, 0,
- attrib, skip, &entry )) > 0)
+ else
{
- char buffer[260];
- skip += count;
- if (entry.attr & FA_DIRECTORY)
+ do
{
- if (!(attrib & DDL_DIRECTORY) || !strcmp(entry.name,". "))
- continue;
- if (long_names) sprintf( buffer, "[%s]", entry.unixname );
- else sprintf( buffer, "[%s]", DOSFS_ToDosDTAFormat( entry.name ) );
- }
- else /* not a directory */
- {
- if ((attrib & DDL_EXCLUSIVE) &&
- ((attrib & (FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCHIVE)) !=
- (entry.attr & (FA_RDONLY|FA_HIDDEN|FA_SYSTEM|FA_ARCHIVE))))
- continue;
- if (long_names) strcpy( buffer, entry.unixname );
- else strcpy( buffer, DOSFS_ToDosDTAFormat( entry.name ) );
- }
- if (!long_names) AnsiLower( buffer );
- pos = LISTBOX_FindFileStrPos( wnd, descr, buffer );
- if ((ret = LISTBOX_InsertString( wnd, descr, pos, buffer )) < 0)
- break;
+ char buffer[270];
+ if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+ {
+ if (!(attrib & DDL_DIRECTORY) ||
+ !strcmp( entry.cAlternateFileName, "." )) continue;
+ if (long_names) sprintf( buffer, "[%s]", entry.cFileName );
+ else sprintf( buffer, "[%s]", entry.cAlternateFileName );
+ }
+ else /* not a directory */
+ {
+#define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
+ FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
+
+ if ((attrib & DDL_EXCLUSIVE) &&
+ ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
+ continue;
+#undef ATTRIBS
+ if (long_names) strcpy( buffer, entry.cFileName );
+ else strcpy( buffer, entry.cAlternateFileName );
+ }
+ if (!long_names) AnsiLower( buffer );
+ pos = LISTBOX_FindFileStrPos( wnd, descr, buffer );
+ if ((ret = LISTBOX_InsertString( wnd, descr, pos, buffer )) < 0)
+ break;
+ } while (FindNextFile32A( handle, &entry ));
+ FindClose32( handle );
}
if ((ret == LB_OKAY) && (attrib & DDL_DRIVES))
@@ -1517,8 +1506,6 @@
break;
}
}
-
- HeapFree( SystemHeap, 0, path );
return ret;
}
@@ -1744,6 +1731,7 @@
break;
case LB_TIMER_DOWN:
index = descr->top_item + LISTBOX_GetCurrentPageSize( wnd, descr );
+ if (index == descr->focus_item) index++;
if (index >= descr->nb_items) index = descr->nb_items - 1;
break;
case LB_TIMER_RIGHT:
diff --git a/controls/menu.c b/controls/menu.c
index 8e8583d..8c6123f 100644
--- a/controls/menu.c
+++ b/controls/menu.c
@@ -88,7 +88,6 @@
extern void NC_DrawSysButton(HWND hwnd, HDC32 hdc, BOOL down); /*nonclient.c*/
extern BOOL NC_GetSysPopupPos(WND* wndPtr, RECT16* rect);
-extern HTASK16 TASK_GetNextTask(HTASK16);
static HBITMAP16 hStdCheck = 0;
static HBITMAP16 hStdMnArrow = 0;
@@ -111,13 +110,9 @@
static HMENU16 MENU_CopySysMenu(void)
{
HMENU16 hMenu;
- HGLOBAL16 handle;
POPUPMENU *menu;
- if (!(handle = SYSRES_LoadResource( SYSRES_MENU_SYSMENU ))) return 0;
- hMenu = LoadMenuIndirect16( GlobalLock16( handle ) );
- SYSRES_FreeResource( handle );
- if (!hMenu)
+ if (!(hMenu = LoadMenuIndirect32A( SYSRES_GetResPtr(SYSRES_MENU_SYSMENU))))
{
dprintf_menu(stddeb,"No SYSMENU\n");
return 0;
@@ -1644,8 +1639,8 @@
* 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( HMENU16 hmenu, UINT wFlags, int x, int y,
- HWND hwnd, const RECT16 *lprect )
+static BOOL32 MENU_TrackMenu( HMENU16 hmenu, UINT32 wFlags, int x, int y,
+ HWND16 hwnd, const RECT16 *lprect )
{
MSG16 msg;
POPUPMENU *menu;
@@ -1660,10 +1655,17 @@
POINT16 pt = { x, y };
MENU_ButtonDown( hwnd, hmenu, &hmenuCurrent, pt );
}
- SetCapture32( hwnd );
+
+ EVENT_Capture( hwnd, HTMENU );
+
while (!fClosed)
{
- if (!MSG_InternalGetMessage( &msg, 0, hwnd, MSGF_MENU, 0, TRUE ))
+ /* we have to keep the message in the queue until it's
+ * clear that menu loop is not over yet.
+ */
+
+ if (!MSG_InternalGetMessage( &msg, 0, hwnd, MSGF_MENU,
+ PM_NOREMOVE, TRUE ))
break;
TranslateMessage( &msg );
@@ -1672,26 +1674,29 @@
if ((msg.message >= WM_MOUSEFIRST) && (msg.message <= WM_MOUSELAST))
{
/* Find the sub-popup for this mouse event (if any) */
+
HMENU16 hsubmenu = MENU_FindMenuByCoords( hmenu, msg.pt );
switch(msg.message)
{
+ /* no WM_NC... messages in captured state */
+
+ case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
- case WM_NCRBUTTONDOWN:
if (!(wFlags & TPM_RIGHTBUTTON)) break;
/* fall through */
+
+ case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
- case WM_NCLBUTTONDOWN:
fClosed = !MENU_ButtonDown( hwnd, hsubmenu,
&hmenuCurrent, msg.pt );
break;
case WM_RBUTTONUP:
- case WM_NCRBUTTONUP:
if (!(wFlags & TPM_RIGHTBUTTON)) break;
/* fall through */
+
case WM_LBUTTONUP:
- case WM_NCLBUTTONUP:
/* If outside all menus but inside lprect, ignore it */
if (!hsubmenu && lprect && PtInRect16(lprect, msg.pt)) break;
fClosed = !MENU_ButtonUp( hwnd, hsubmenu,
@@ -1700,7 +1705,6 @@
break;
case WM_MOUSEMOVE:
- case WM_NCMOUSEMOVE:
if ((msg.wParam & MK_LBUTTON) ||
((wFlags & TPM_RIGHTBUTTON) && (msg.wParam & MK_RBUTTON)))
{
@@ -1814,22 +1818,63 @@
return TRUE;
}
+/***********************************************************************
+ * MENU_TrackSysPopup
+ */
+static void MENU_TrackSysPopup( WND* pWnd )
+{
+ RECT16 rect;
+ HMENU16 hMenu = pWnd->hSysMenu;
+ HDC16 hDC = 0;
+
+ /* track the system menu like a normal popup menu */
+
+ if( IsMenu(hMenu) )
+ {
+ HWND16 hWnd = pWnd->hwndSelf;
+ if (!(pWnd->dwStyle & WS_MINIMIZE))
+ {
+ hDC = GetWindowDC32( hWnd );
+ NC_DrawSysButton( hWnd, hDC, TRUE );
+ }
+ NC_GetSysPopupPos( pWnd, &rect );
+ MENU_InitSysMenuPopup( hMenu, pWnd->dwStyle,
+ pWnd->class->style);
+ TrackPopupMenu16( hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
+ rect.left, rect.bottom, 0, hWnd, &rect );
+ if (!(pWnd->dwStyle & WS_MINIMIZE))
+ {
+ NC_DrawSysButton( hWnd, hDC, FALSE );
+ ReleaseDC32( hWnd, hDC );
+ }
+ }
+}
/***********************************************************************
* MENU_TrackMouseMenuBar
*
* Menu-bar tracking upon a mouse event. Called from NC_HandleSysCommand().
*/
-void MENU_TrackMouseMenuBar( HWND hwnd, POINT16 pt )
+void MENU_TrackMouseMenuBar( WND* wndPtr, INT16 ht, POINT16 pt )
{
- WND *wndPtr = WIN_FindWndPtr( hwnd );
- HideCaret(0);
- SendMessage16( hwnd, WM_ENTERMENULOOP, 0, 0 );
- SendMessage16( hwnd, WM_INITMENU, wndPtr->wIDmenu, 0 );
- MENU_TrackMenu( (HMENU16)wndPtr->wIDmenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
- pt.x, pt.y, hwnd, NULL );
- SendMessage16( hwnd, WM_EXITMENULOOP, 0, 0 );
- ShowCaret(0);
+ BOOL32 bTrackSys = ((ht == HTSYSMENU && !wndPtr->wIDmenu) ||
+ (wndPtr->dwStyle & (WS_MINIMIZE | WS_CHILD)));
+ HWND16 hWnd = wndPtr->hwndSelf;
+ HMENU16 hMenu = (bTrackSys) ? wndPtr->hSysMenu : wndPtr->wIDmenu;
+
+ if( IsMenu(hMenu) )
+ {
+ HideCaret(0);
+ SendMessage16( hWnd, WM_ENTERMENULOOP, 0, 0 );
+ SendMessage16( hWnd, WM_INITMENU, hMenu, 0 );
+ if( bTrackSys )
+ MENU_TrackSysPopup( wndPtr );
+ else
+ MENU_TrackMenu( hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
+ pt.x, pt.y, hWnd, NULL );
+ SendMessage16( hWnd, WM_EXITMENULOOP, 0, 0 );
+ ShowCaret(0);
+ }
}
@@ -1838,64 +1883,67 @@
*
* Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand().
*/
-void MENU_TrackKbdMenuBar( WND* wndPtr, UINT wParam, INT vkey)
+void MENU_TrackKbdMenuBar( WND* wndPtr, UINT16 wParam, INT16 vkey)
{
- UINT uItem = NO_SELECTED_ITEM;
+ INT16 htMenu;
+ UINT16 uItem = NO_SELECTED_ITEM;
HMENU16 hTrackMenu;
- /* find window that has a menu
- */
+ /* find window that has a menu */
- if( !(wndPtr->dwStyle & WS_CHILD) )
- {
- wndPtr = WIN_FindWndPtr( GetActiveWindow() );
- if( !wndPtr ) return;
- }
- else
- while( wndPtr->dwStyle & WS_CHILD &&
- !(wndPtr->dwStyle & WS_SYSMENU) )
- if( !(wndPtr = wndPtr->parent) ) return;
+ while( wndPtr->dwStyle & WS_CHILD && !(wndPtr->dwStyle & WS_SYSMENU) )
+ if( !(wndPtr = wndPtr->parent) ) return;
- if( wndPtr->dwStyle & WS_CHILD || !wndPtr->wIDmenu )
- if( !(wndPtr->dwStyle & WS_SYSMENU) )
- return;
+ if( !wndPtr->wIDmenu && !(wndPtr->dwStyle & WS_SYSMENU) ) return;
- hTrackMenu = ( IsMenu( wndPtr->wIDmenu ) )? wndPtr->wIDmenu:
- wndPtr->hSysMenu;
+ htMenu = ((wndPtr->dwStyle & (WS_CHILD | WS_MINIMIZE)) ||
+ !wndPtr->wIDmenu) ? HTSYSMENU : HTMENU;
+ hTrackMenu = ( htMenu == HTSYSMENU ) ? wndPtr->hSysMenu : wndPtr->wIDmenu;
- HideCaret(0);
- SendMessage16( wndPtr->hwndSelf, WM_ENTERMENULOOP, 0, 0 );
- SendMessage16( wndPtr->hwndSelf, WM_INITMENU, wndPtr->wIDmenu, 0 );
+ if( IsMenu( hTrackMenu ) )
+ {
+ HideCaret(0);
+ SendMessage16( wndPtr->hwndSelf, WM_ENTERMENULOOP, 0, 0 );
+ SendMessage16( wndPtr->hwndSelf, WM_INITMENU, hTrackMenu, 0 );
- /* find suitable menu entry
- */
+ /* find suitable menu entry */
- if( vkey == VK_SPACE )
- uItem = SYSMENU_SELECTED;
- else if( vkey )
- {
- uItem = MENU_FindItemByKey( wndPtr->hwndSelf, wndPtr->wIDmenu, vkey );
- if( uItem >= 0xFFFE )
- {
- if( uItem == 0xFFFF )
- MessageBeep(0);
- SendMessage16( wndPtr->hwndSelf, WM_EXITMENULOOP, 0, 0 );
- ShowCaret(0);
- return;
- }
- }
+ if( vkey == VK_SPACE )
+ uItem = SYSMENU_SELECTED;
+ else if( vkey )
+ {
+ uItem = ( htMenu == HTSYSMENU )
+ ? 0xFFFE /* only VK_SPACE in this case */
+ : MENU_FindItemByKey( wndPtr->hwndSelf, wndPtr->wIDmenu, vkey );
+ if( uItem >= 0xFFFE )
+ {
+ if( uItem == 0xFFFF ) MessageBeep(0);
+ htMenu = 0;
+ }
+ }
- MENU_SelectItem( wndPtr->hwndSelf, hTrackMenu, uItem, TRUE );
- if( uItem == NO_SELECTED_ITEM )
- MENU_SelectItemRel( wndPtr->hwndSelf, hTrackMenu, ITEM_NEXT );
- else
- PostMessage( wndPtr->hwndSelf, WM_KEYDOWN, VK_DOWN, 0L );
+ switch( htMenu )
+ {
+ case HTMENU:
+ MENU_SelectItem( wndPtr->hwndSelf, hTrackMenu, uItem, TRUE );
+ if( uItem == NO_SELECTED_ITEM )
+ MENU_SelectItemRel( wndPtr->hwndSelf, hTrackMenu, ITEM_NEXT );
+ else
+ PostMessage( wndPtr->hwndSelf, WM_KEYDOWN, VK_DOWN, 0L );
- MENU_TrackMenu( hTrackMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
- 0, 0, wndPtr->hwndSelf, NULL );
+ MENU_TrackMenu( hTrackMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
+ 0, 0, wndPtr->hwndSelf, NULL );
+ break;
- SendMessage16( wndPtr->hwndSelf, WM_EXITMENULOOP, 0, 0 );
- ShowCaret(0);
+ case HTSYSMENU:
+ MENU_TrackSysPopup( wndPtr );
+
+ default:
+ }
+
+ SendMessage16( wndPtr->hwndSelf, WM_EXITMENULOOP, 0, 0 );
+ ShowCaret(0);
+ }
}
@@ -1927,6 +1975,20 @@
return TrackPopupMenu16(hMenu,wFlags,x,y,nReserved,hWnd,lpRect?&r:NULL);
}
+/**********************************************************************
+ * TrackPopupMenuEx (USER32.549)
+ */
+BOOL32 TrackPopupMenuEx( HMENU32 hMenu, UINT32 wFlags, INT32 x, INT32 y,
+ HWND32 hWnd, LPTPMPARAMS lpTpm )
+{
+ RECT16 r;
+
+ fprintf( stderr, "TrackPopupMenuEx: not fully implemented\n" );
+
+ if (lpTpm)
+ CONV_RECT32TO16( &lpTpm->rcExclude, &r );
+ return TrackPopupMenu16(hMenu,wFlags,x,y,0,hWnd,lpTpm?&r:NULL);
+}
/***********************************************************************
* PopupMenuWndProc
@@ -2709,7 +2771,7 @@
WORD version, offset;
LPCSTR p = (LPCSTR)template;
- dprintf_menu(stddeb,"LoadMenuIndirect32A: %p\n", template );
+ dprintf_menu(stddeb,"LoadMenuIndirect16: %p\n", template );
version = GET_WORD(p);
p += sizeof(WORD);
if (version)
@@ -2738,7 +2800,7 @@
WORD version, offset;
LPCSTR p = (LPCSTR)template;
- dprintf_menu(stddeb,"LoadMenuIndirect32A: %p\n", template );
+ dprintf_menu(stddeb,"LoadMenuIndirect16: %p\n", template );
version = GET_WORD(p);
p += sizeof(WORD);
if (version)
diff --git a/controls/oldlbox.c b/controls/oldlbox.c
index c1577ce..4c256c9 100644
--- a/controls/oldlbox.c
+++ b/controls/oldlbox.c
@@ -27,7 +27,6 @@
#include "listbox.h"
#include "dos_fs.h"
#include "drive.h"
-#include "file.h"
#include "heap.h"
#include "stddebug.h"
#include "debug.h"
@@ -699,6 +698,7 @@
LONG ListBoxDirectory(LPHEADLIST lphl, UINT attrib, LPCSTR filespec)
{
+#if 0
char mask[13];
char* temp = NULL;
const char* ptr;
@@ -772,6 +772,8 @@
SEGPTR_FREE( temp );
return ret;
+#endif
+ return 0;
}
/* ------------------------- dimensions ------------------------- */
diff --git a/debugger/break.c b/debugger/break.c
index 8c727b4..eb97f6c 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -65,9 +65,10 @@
* Determine if the instruction at CS:EIP is an instruction that
* we need to step over (like a call or a repetitive string move).
*/
-static BOOL32 DEBUG_IsStepOverInstr( SIGCONTEXT *context )
+static BOOL32 DEBUG_IsStepOverInstr(void)
{
- BYTE *instr = (BYTE *)PTR_SEG_OFF_TO_LIN(CS_reg(context),EIP_reg(context));
+ BYTE *instr = (BYTE *)PTR_SEG_OFF_TO_LIN( CS_reg(&DEBUG_context),
+ EIP_reg(&DEBUG_context) );
for (;;)
{
@@ -182,7 +183,7 @@
int num;
BYTE *p;
- DBG_FIX_ADDR_SEG( &addr, CS_reg(DEBUG_context) );
+ DBG_FIX_ADDR_SEG( &addr, CS_reg(&DEBUG_context) );
if (next_bp < MAX_BREAKPOINTS)
num = next_bp++;
@@ -273,17 +274,17 @@
* Determine if we should continue execution after a SIGTRAP signal when
* executing in the given mode.
*/
-BOOL32 DEBUG_ShouldContinue( SIGCONTEXT *context, enum exec_mode mode )
+BOOL32 DEBUG_ShouldContinue( enum exec_mode mode )
{
DBG_ADDR addr;
int bpnum;
/* If not single-stepping, back up over the int3 instruction */
- if (!(EFL_reg(DEBUG_context) & STEP_FLAG)) EIP_reg(DEBUG_context)--;
+ if (!(EFL_reg(&DEBUG_context) & STEP_FLAG)) EIP_reg(&DEBUG_context)--;
- addr.seg = (CS_reg(DEBUG_context) == WINE_CODE_SELECTOR) ?
- 0 : CS_reg(DEBUG_context);
- addr.off = EIP_reg(DEBUG_context);
+ addr.seg = (CS_reg(&DEBUG_context) == WINE_CODE_SELECTOR) ?
+ 0 : CS_reg(&DEBUG_context);
+ addr.off = EIP_reg(&DEBUG_context);
bpnum = DEBUG_FindBreakpoint( &addr );
breakpoints[0].enabled = 0; /* disable the step-over breakpoint */
@@ -299,8 +300,8 @@
/* If there's no breakpoint and we are not single-stepping, then we */
/* must have encountered an int3 in the Windows program; let's skip it. */
- if ((bpnum == -1) && !(EFL_reg(DEBUG_context) & STEP_FLAG))
- EIP_reg(DEBUG_context)++;
+ if ((bpnum == -1) && !(EFL_reg(&DEBUG_context) & STEP_FLAG))
+ EIP_reg(&DEBUG_context)++;
/* no breakpoint, continue if in continuous mode */
return (mode == EXEC_CONT);
@@ -313,14 +314,13 @@
* Set the breakpoints to the correct state to restart execution
* in the given mode.
*/
-void DEBUG_RestartExecution( SIGCONTEXT *context, enum exec_mode mode,
- int instr_len )
+void DEBUG_RestartExecution( enum exec_mode mode, int instr_len )
{
DBG_ADDR addr;
- addr.seg = (CS_reg(DEBUG_context) == WINE_CODE_SELECTOR) ?
- 0 : CS_reg(DEBUG_context);
- addr.off = EIP_reg(DEBUG_context);
+ addr.seg = (CS_reg(&DEBUG_context) == WINE_CODE_SELECTOR) ?
+ 0 : CS_reg(&DEBUG_context);
+ addr.off = EIP_reg(&DEBUG_context);
if (DEBUG_FindBreakpoint( &addr ) != -1)
mode = EXEC_STEP_INSTR; /* If there's a breakpoint, skip it */
@@ -328,14 +328,14 @@
switch(mode)
{
case EXEC_CONT: /* Continuous execution */
- EFL_reg(DEBUG_context) &= ~STEP_FLAG;
+ EFL_reg(&DEBUG_context) &= ~STEP_FLAG;
DEBUG_SetBreakpoints( TRUE );
break;
case EXEC_STEP_OVER: /* Stepping over a call */
- if (DEBUG_IsStepOverInstr(DEBUG_context))
+ if (DEBUG_IsStepOverInstr())
{
- EFL_reg(DEBUG_context) &= ~STEP_FLAG;
+ EFL_reg(&DEBUG_context) &= ~STEP_FLAG;
addr.off += instr_len;
breakpoints[0].addr = addr;
breakpoints[0].enabled = TRUE;
@@ -347,7 +347,7 @@
/* else fall through to single-stepping */
case EXEC_STEP_INSTR: /* Single-stepping an instruction */
- EFL_reg(DEBUG_context) |= STEP_FLAG;
+ EFL_reg(&DEBUG_context) |= STEP_FLAG;
break;
}
}
diff --git a/debugger/dbg.y b/debugger/dbg.y
index a7ab4f7..4bc7fdf 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -134,8 +134,8 @@
addr.off += $4;
DEBUG_AddBreakpoint( &addr );
}
- | tBREAK tEOL { DBG_ADDR addr = { CS_reg(DEBUG_context),
- EIP_reg(DEBUG_context) };
+ | tBREAK tEOL { DBG_ADDR addr = { CS_reg(&DEBUG_context),
+ EIP_reg(&DEBUG_context) };
DEBUG_AddBreakpoint( &addr );
}
@@ -239,32 +239,15 @@
}
-
/***********************************************************************
- * DEBUG_EnterDebugger
+ * DEBUG_Main
*
- * Force an entry into the debugger.
+ * Debugger main loop.
*/
-void DEBUG_EnterDebugger(void)
-{
- kill( getpid(), SIGHUP );
-}
-
-
-/***********************************************************************
- * DebugBreak16 (KERNEL.203)
- */
-void DebugBreak16( SIGCONTEXT *regs )
-{
- const char *module = MODULE_GetModuleName( GetExePtr(GetCurrentTask()) );
- fprintf( stderr, "%s called DebugBreak\n", module ? module : "???" );
- wine_debug( SIGTRAP, regs );
-}
-
-
-void wine_debug( int signal, SIGCONTEXT *regs )
+static void DEBUG_Main( int signal )
{
static int loaded_symbols = 0;
+ static BOOL32 in_debugger = FALSE;
char SymbolTableFile[256];
int instr_len = 0, newmode;
BOOL32 ret_ok;
@@ -272,8 +255,13 @@
yydebug = 0;
#endif
+ if (in_debugger)
+ {
+ fprintf( stderr, "Segmentation fault inside debugger, exiting.\n" );
+ exit(1);
+ }
+ in_debugger = TRUE;
yyin = stdin;
- DEBUG_context = regs;
DEBUG_SetBreakpoints( FALSE );
@@ -306,12 +294,12 @@
DEBUG_LoadEntryPoints();
}
- if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( regs, dbg_exec_mode ))
+ if ((signal != SIGTRAP) || !DEBUG_ShouldContinue( dbg_exec_mode ))
{
DBG_ADDR addr;
- addr.seg = CS_reg(DEBUG_context);
- addr.off = EIP_reg(DEBUG_context);
+ addr.seg = CS_reg(&DEBUG_context);
+ addr.off = EIP_reg(&DEBUG_context);
DBG_FIX_ADDR_SEG( &addr, 0 );
/* Put the display in a correct state */
@@ -332,9 +320,9 @@
DEBUG_InfoStack();
if (dbg_mode == 16)
{
- LDT_Print( SELECTOR_TO_ENTRY(DS_reg(DEBUG_context)), 1 );
- if (ES_reg(DEBUG_context) != DS_reg(DEBUG_context))
- LDT_Print( SELECTOR_TO_ENTRY(ES_reg(DEBUG_context)), 1 );
+ LDT_Print( SELECTOR_TO_ENTRY(DS_reg(&DEBUG_context)), 1 );
+ if (ES_reg(&DEBUG_context) != DS_reg(&DEBUG_context))
+ LDT_Print( SELECTOR_TO_ENTRY(ES_reg(&DEBUG_context)), 1 );
}
DEBUG_BackTrace();
}
@@ -347,7 +335,7 @@
{
DEBUG_Disasm( &addr );
fprintf(stderr,"\n");
- instr_len = addr.off - EIP_reg(DEBUG_context);
+ instr_len = addr.off - EIP_reg(&DEBUG_context);
}
ret_ok = 0;
@@ -356,18 +344,48 @@
issue_prompt();
yyparse();
flush_symbols();
- addr.seg = CS_reg(DEBUG_context);
- addr.off = EIP_reg(DEBUG_context);
+ addr.seg = CS_reg(&DEBUG_context);
+ addr.off = EIP_reg(&DEBUG_context);
DBG_FIX_ADDR_SEG( &addr, 0 );
ret_ok = DEBUG_ValidateRegisters();
if (ret_ok) ret_ok = DBG_CHECK_READ_PTR( &addr, 1 );
} while (!ret_ok);
}
- DEBUG_RestartExecution( regs, dbg_exec_mode, instr_len );
+ DEBUG_RestartExecution( dbg_exec_mode, instr_len );
+ in_debugger = FALSE;
}
+/***********************************************************************
+ * DEBUG_EnterDebugger
+ *
+ * Force an entry into the debugger.
+ */
+void DEBUG_EnterDebugger(void)
+{
+ kill( getpid(), SIGHUP );
+}
+
+
+/***********************************************************************
+ * DebugBreak16 (KERNEL.203)
+ */
+void DebugBreak16( CONTEXT *regs )
+{
+ const char *module = MODULE_GetModuleName( GetExePtr(GetCurrentTask()) );
+ fprintf( stderr, "%s called DebugBreak\n", module ? module : "???" );
+ DEBUG_Main( SIGTRAP );
+}
+
+
+void wine_debug( int signal, SIGCONTEXT *regs )
+{
+ DEBUG_SetSigContext( regs );
+ DEBUG_Main( signal );
+ DEBUG_GetSigContext( regs );
+}
+
int yyerror(char * s)
{
fprintf(stderr,"%s\n", s);
diff --git a/debugger/debug.l b/debugger/debug.l
index 93e0929..1fc3770 100644
--- a/debugger/debug.l
+++ b/debugger/debug.l
@@ -34,7 +34,7 @@
DIGIT [0-9]
HEXDIGIT [0-9a-fA-F]
FORMAT [bcdiswx]
-IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~]*
+IDENTIFIER [_a-zA-Z\.~][_a-zA-Z0-9\.~@]*
%%
diff --git a/debugger/hash.c b/debugger/hash.c
index bfbdafa..0a9df01 100644
--- a/debugger/hash.c
+++ b/debugger/hash.c
@@ -164,7 +164,7 @@
if (!nh) return FALSE;
nh->addr = *addr;
- DBG_FIX_ADDR_SEG( &nh->addr, DS_reg(DEBUG_context) );
+ DBG_FIX_ADDR_SEG( &nh->addr, DS_reg(&DEBUG_context) );
return TRUE;
}
diff --git a/debugger/info.c b/debugger/info.c
index 2abc981..ee6ce29 100644
--- a/debugger/info.c
+++ b/debugger/info.c
@@ -166,7 +166,7 @@
static DBG_ADDR lasttime = { 0xffffffff, 0 };
if (addr == NULL) addr = &lasttime;
- DBG_FIX_ADDR_SEG( addr, CS_reg(DEBUG_context) );
+ DBG_FIX_ADDR_SEG( addr, CS_reg(&DEBUG_context) );
while (count-- > 0)
{
DEBUG_PrintAddress( addr, dbg_mode, FALSE );
diff --git a/debugger/memory.c b/debugger/memory.c
index ee826b4..244fcde 100644
--- a/debugger/memory.c
+++ b/debugger/memory.c
@@ -114,7 +114,7 @@
{
DBG_ADDR addr = *address;
- DBG_FIX_ADDR_SEG( &addr, DS_reg(DEBUG_context) );
+ DBG_FIX_ADDR_SEG( &addr, DS_reg(&DEBUG_context) );
if (!DBG_CHECK_READ_PTR( &addr, sizeof(int) )) return 0;
return *(int *)DBG_ADDR_TO_LIN( &addr );
}
@@ -129,7 +129,7 @@
{
DBG_ADDR addr = *address;
- DBG_FIX_ADDR_SEG( &addr, DS_reg(DEBUG_context) );
+ DBG_FIX_ADDR_SEG( &addr, DS_reg(&DEBUG_context) );
if (!DBG_CHECK_WRITE_PTR( &addr, sizeof(int) )) return;
*(int *)DBG_ADDR_TO_LIN( &addr ) = value;
}
@@ -149,7 +149,7 @@
int i;
DBG_FIX_ADDR_SEG( &addr, (format == 'i') ?
- CS_reg(DEBUG_context) : DS_reg(DEBUG_context) );
+ CS_reg(&DEBUG_context) : DS_reg(&DEBUG_context) );
if (format != 'i' && count > 1)
{
diff --git a/debugger/registers.c b/debugger/registers.c
index 3fc5422..2ecaf6a 100644
--- a/debugger/registers.c
+++ b/debugger/registers.c
@@ -7,7 +7,7 @@
#include <stdio.h>
#include "debugger.h"
-SIGCONTEXT *DEBUG_context;
+CONTEXT DEBUG_context;
/***********************************************************************
* DEBUG_SetRegister
@@ -18,44 +18,32 @@
{
switch(reg)
{
- case REG_EAX: EAX_reg(DEBUG_context) = val; break;
- case REG_EBX: EBX_reg(DEBUG_context) = val; break;
- case REG_ECX: ECX_reg(DEBUG_context) = val; break;
- case REG_EDX: EDX_reg(DEBUG_context) = val; break;
- case REG_ESI: ESI_reg(DEBUG_context) = val; break;
- case REG_EDI: EDI_reg(DEBUG_context) = val; break;
- case REG_EBP: EBP_reg(DEBUG_context) = val; break;
- case REG_EFL: EFL_reg(DEBUG_context) = val; break;
- case REG_EIP: EIP_reg(DEBUG_context) = val; break;
- case REG_ESP: ESP_reg(DEBUG_context) = val; break;
- case REG_AX: AX_reg(DEBUG_context) = val; break;
- case REG_BX: BX_reg(DEBUG_context) = val; break;
- case REG_CX: CX_reg(DEBUG_context) = val; break;
- case REG_DX: DX_reg(DEBUG_context) = val; break;
- case REG_SI: SI_reg(DEBUG_context) = val; break;
- case REG_DI: DI_reg(DEBUG_context) = val; break;
- case REG_BP: BP_reg(DEBUG_context) = val; break;
- case REG_FL: FL_reg(DEBUG_context) = val; break;
- case REG_IP: IP_reg(DEBUG_context) = val; break;
- case REG_SP: SP_reg(DEBUG_context) = val; break;
- case REG_CS: CS_reg(DEBUG_context) = val; break;
- case REG_DS: DS_reg(DEBUG_context) = val; break;
- case REG_ES: ES_reg(DEBUG_context) = val; break;
- case REG_SS: SS_reg(DEBUG_context) = val; break;
-#ifdef FS_reg
- case REG_FS: FS_reg(DEBUG_context) = val; break;
-#else
- case REG_FS:
- fprintf( stderr, "Register %%fs not supported on this system\n" );
- break;
-#endif
-#ifdef GS_reg
- case REG_GS: GS_reg(DEBUG_context) = val; break;
-#else
- case REG_GS:
- fprintf( stderr, "Register %%gs not supported on this system\n" );
- break;
-#endif
+ case REG_EAX: EAX_reg(&DEBUG_context) = val; break;
+ case REG_EBX: EBX_reg(&DEBUG_context) = val; break;
+ case REG_ECX: ECX_reg(&DEBUG_context) = val; break;
+ case REG_EDX: EDX_reg(&DEBUG_context) = val; break;
+ case REG_ESI: ESI_reg(&DEBUG_context) = val; break;
+ case REG_EDI: EDI_reg(&DEBUG_context) = val; break;
+ case REG_EBP: EBP_reg(&DEBUG_context) = val; break;
+ case REG_EFL: EFL_reg(&DEBUG_context) = val; break;
+ case REG_EIP: EIP_reg(&DEBUG_context) = val; break;
+ case REG_ESP: ESP_reg(&DEBUG_context) = val; break;
+ case REG_AX: AX_reg(&DEBUG_context) = val; break;
+ case REG_BX: BX_reg(&DEBUG_context) = val; break;
+ case REG_CX: CX_reg(&DEBUG_context) = val; break;
+ case REG_DX: DX_reg(&DEBUG_context) = val; break;
+ case REG_SI: SI_reg(&DEBUG_context) = val; break;
+ case REG_DI: DI_reg(&DEBUG_context) = val; break;
+ case REG_BP: BP_reg(&DEBUG_context) = val; break;
+ case REG_FL: FL_reg(&DEBUG_context) = val; break;
+ case REG_IP: IP_reg(&DEBUG_context) = val; break;
+ case REG_SP: SP_reg(&DEBUG_context) = val; break;
+ case REG_CS: CS_reg(&DEBUG_context) = val; break;
+ case REG_DS: DS_reg(&DEBUG_context) = val; break;
+ case REG_ES: ES_reg(&DEBUG_context) = val; break;
+ case REG_SS: SS_reg(&DEBUG_context) = val; break;
+ case REG_FS: FS_reg(&DEBUG_context) = val; break;
+ case REG_GS: GS_reg(&DEBUG_context) = val; break;
}
}
@@ -69,49 +57,106 @@
{
switch(reg)
{
- case REG_EAX: return EAX_reg(DEBUG_context);
- case REG_EBX: return EBX_reg(DEBUG_context);
- case REG_ECX: return ECX_reg(DEBUG_context);
- case REG_EDX: return EDX_reg(DEBUG_context);
- case REG_ESI: return ESI_reg(DEBUG_context);
- case REG_EDI: return EDI_reg(DEBUG_context);
- case REG_EBP: return EBP_reg(DEBUG_context);
- case REG_EFL: return EFL_reg(DEBUG_context);
- case REG_EIP: return EIP_reg(DEBUG_context);
- case REG_ESP: return ESP_reg(DEBUG_context);
- case REG_AX: return AX_reg(DEBUG_context);
- case REG_BX: return BX_reg(DEBUG_context);
- case REG_CX: return CX_reg(DEBUG_context);
- case REG_DX: return DX_reg(DEBUG_context);
- case REG_SI: return SI_reg(DEBUG_context);
- case REG_DI: return DI_reg(DEBUG_context);
- case REG_BP: return BP_reg(DEBUG_context);
- case REG_FL: return FL_reg(DEBUG_context);
- case REG_IP: return IP_reg(DEBUG_context);
- case REG_SP: return SP_reg(DEBUG_context);
- case REG_CS: return CS_reg(DEBUG_context);
- case REG_DS: return DS_reg(DEBUG_context);
- case REG_ES: return ES_reg(DEBUG_context);
- case REG_SS: return SS_reg(DEBUG_context);
-#ifdef FS_reg
- case REG_FS: return FS_reg(DEBUG_context);
-#else
- case REG_FS:
- fprintf( stderr, "Register %%fs not supported on this system\n" );
- return 0;
-#endif
-#ifdef GS_reg
- case REG_GS: return GS_reg(DEBUG_context);
-#else
- case REG_GS:
- fprintf( stderr, "Register %%gs not supported on this system\n" );
- return 0;
-#endif
+ case REG_EAX: return EAX_reg(&DEBUG_context);
+ case REG_EBX: return EBX_reg(&DEBUG_context);
+ case REG_ECX: return ECX_reg(&DEBUG_context);
+ case REG_EDX: return EDX_reg(&DEBUG_context);
+ case REG_ESI: return ESI_reg(&DEBUG_context);
+ case REG_EDI: return EDI_reg(&DEBUG_context);
+ case REG_EBP: return EBP_reg(&DEBUG_context);
+ case REG_EFL: return EFL_reg(&DEBUG_context);
+ case REG_EIP: return EIP_reg(&DEBUG_context);
+ case REG_ESP: return ESP_reg(&DEBUG_context);
+ case REG_AX: return AX_reg(&DEBUG_context);
+ case REG_BX: return BX_reg(&DEBUG_context);
+ case REG_CX: return CX_reg(&DEBUG_context);
+ case REG_DX: return DX_reg(&DEBUG_context);
+ case REG_SI: return SI_reg(&DEBUG_context);
+ case REG_DI: return DI_reg(&DEBUG_context);
+ case REG_BP: return BP_reg(&DEBUG_context);
+ case REG_FL: return FL_reg(&DEBUG_context);
+ case REG_IP: return IP_reg(&DEBUG_context);
+ case REG_SP: return SP_reg(&DEBUG_context);
+ case REG_CS: return CS_reg(&DEBUG_context);
+ case REG_DS: return DS_reg(&DEBUG_context);
+ case REG_ES: return ES_reg(&DEBUG_context);
+ case REG_SS: return SS_reg(&DEBUG_context);
+ case REG_FS: return FS_reg(&DEBUG_context);
+ case REG_GS: return GS_reg(&DEBUG_context);
}
return 0; /* should not happen */
}
+/***********************************************************************
+ * DEBUG_SetSigContext
+ *
+ * Set the register values from a sigcontext.
+ */
+extern void DEBUG_SetSigContext( const SIGCONTEXT *sigcontext )
+{
+ EAX_reg(&DEBUG_context) = EAX_sig(sigcontext);
+ EBX_reg(&DEBUG_context) = EBX_sig(sigcontext);
+ ECX_reg(&DEBUG_context) = ECX_sig(sigcontext);
+ EDX_reg(&DEBUG_context) = EDX_sig(sigcontext);
+ ESI_reg(&DEBUG_context) = ESI_sig(sigcontext);
+ EDI_reg(&DEBUG_context) = EDI_sig(sigcontext);
+ EBP_reg(&DEBUG_context) = EBP_sig(sigcontext);
+ EFL_reg(&DEBUG_context) = EFL_sig(sigcontext);
+ EIP_reg(&DEBUG_context) = EIP_sig(sigcontext);
+ ESP_reg(&DEBUG_context) = ESP_sig(sigcontext);
+ CS_reg(&DEBUG_context) = LOWORD(CS_sig(sigcontext));
+ DS_reg(&DEBUG_context) = LOWORD(DS_sig(sigcontext));
+ ES_reg(&DEBUG_context) = LOWORD(ES_sig(sigcontext));
+ SS_reg(&DEBUG_context) = LOWORD(SS_sig(sigcontext));
+#ifdef FS_sig
+ FS_reg(&DEBUG_context) = LOWORD(FS_sig(sigcontext));
+#else
+ __asm__("movw %%fs,%w0":"=r" (FS_reg(&DEBUG_context)));
+ FS_reg(&DEBUG_context) &= 0xffff;
+#endif
+#ifdef GS_sig
+ GS_reg(&DEBUG_context) = LOWORD(GS_sig(sigcontext));
+#else
+ __asm__("movw %%gs,%w0":"=r" (GS_reg(&DEBUG_context)));
+ GS_reg(&DEBUG_context) &= 0xffff;
+#endif
+}
+
+
+/***********************************************************************
+ * DEBUG_GetSigContext
+ *
+ * Build a sigcontext from the register values.
+ */
+extern void DEBUG_GetSigContext( SIGCONTEXT *sigcontext )
+{
+ EAX_sig(sigcontext) = EAX_reg(&DEBUG_context);
+ EBX_sig(sigcontext) = EBX_reg(&DEBUG_context);
+ ECX_sig(sigcontext) = ECX_reg(&DEBUG_context);
+ EDX_sig(sigcontext) = EDX_reg(&DEBUG_context);
+ ESI_sig(sigcontext) = ESI_reg(&DEBUG_context);
+ EDI_sig(sigcontext) = EDI_reg(&DEBUG_context);
+ EBP_sig(sigcontext) = EBP_reg(&DEBUG_context);
+ EFL_sig(sigcontext) = EFL_reg(&DEBUG_context);
+ EIP_sig(sigcontext) = EIP_reg(&DEBUG_context);
+ ESP_sig(sigcontext) = ESP_reg(&DEBUG_context);
+ CS_sig(sigcontext) = CS_reg(&DEBUG_context);
+ DS_sig(sigcontext) = DS_reg(&DEBUG_context);
+ ES_sig(sigcontext) = ES_reg(&DEBUG_context);
+ SS_sig(sigcontext) = SS_reg(&DEBUG_context);
+#ifdef FS_sig
+ FS_sig(sigcontext) = FS_reg(&DEBUG_context);
+#else
+ __asm__("movw %w0,%%fs"::"r" (FS_reg(&DEBUG_context)));
+#endif
+#ifdef GS_sig
+ GS_sig(sigcontext) = GS_reg(&DEBUG_context);
+#else
+ __asm__("movw %w0,%%gs"::"r" (FS_reg(&DEBUG_context)));
+#endif
+}
+
/***********************************************************************
* DEBUG_InfoRegisters
@@ -123,35 +168,30 @@
fprintf(stderr,"Register dump:\n");
/* First get the segment registers out of the way */
- fprintf( stderr," CS:%04x SS:%04x DS:%04x ES:%04x",
- CS_reg(DEBUG_context), SS_reg(DEBUG_context),
- DS_reg(DEBUG_context), ES_reg(DEBUG_context) );
-#ifdef FS_reg
- fprintf( stderr, " FS:%04x", FS_reg(DEBUG_context) );
-#endif
-#ifdef GS_reg
- fprintf( stderr, " GS:%04x", GS_reg(DEBUG_context) );
-#endif
+ fprintf( stderr," CS:%04x SS:%04x DS:%04x ES:%04x FS:%04x GS:%04x",
+ (WORD)CS_reg(&DEBUG_context), (WORD)SS_reg(&DEBUG_context),
+ (WORD)DS_reg(&DEBUG_context), (WORD)ES_reg(&DEBUG_context),
+ (WORD)FS_reg(&DEBUG_context), (WORD)GS_reg(&DEBUG_context) );
if (dbg_mode == 16)
{
fprintf( stderr,"\n IP:%04x SP:%04x BP:%04x FLAGS:%04x\n",
- IP_reg(DEBUG_context), SP_reg(DEBUG_context),
- BP_reg(DEBUG_context), FL_reg(DEBUG_context) );
+ IP_reg(&DEBUG_context), SP_reg(&DEBUG_context),
+ BP_reg(&DEBUG_context), FL_reg(&DEBUG_context) );
fprintf( stderr," AX:%04x BX:%04x CX:%04x DX:%04x SI:%04x DI:%04x\n",
- AX_reg(DEBUG_context), BX_reg(DEBUG_context),
- CX_reg(DEBUG_context), DX_reg(DEBUG_context),
- SI_reg(DEBUG_context), DI_reg(DEBUG_context) );
+ AX_reg(&DEBUG_context), BX_reg(&DEBUG_context),
+ CX_reg(&DEBUG_context), DX_reg(&DEBUG_context),
+ SI_reg(&DEBUG_context), DI_reg(&DEBUG_context) );
}
else /* 32-bit mode */
{
fprintf( stderr, "\n EIP:%08lx ESP:%08lx EBP:%08lx EFLAGS:%08lx\n",
- EIP_reg(DEBUG_context), ESP_reg(DEBUG_context),
- EBP_reg(DEBUG_context), EFL_reg(DEBUG_context) );
+ EIP_reg(&DEBUG_context), ESP_reg(&DEBUG_context),
+ EBP_reg(&DEBUG_context), EFL_reg(&DEBUG_context) );
fprintf( stderr, " EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n",
- EAX_reg(DEBUG_context), EBX_reg(DEBUG_context),
- ECX_reg(DEBUG_context), EDX_reg(DEBUG_context) );
+ EAX_reg(&DEBUG_context), EBX_reg(&DEBUG_context),
+ ECX_reg(&DEBUG_context), EDX_reg(&DEBUG_context) );
fprintf( stderr, " ESI:%08lx EDI:%08lx\n",
- ESI_reg(DEBUG_context), EDI_reg(DEBUG_context) );
+ ESI_reg(&DEBUG_context), EDI_reg(&DEBUG_context) );
}
}
@@ -170,39 +210,35 @@
((((seg) & 7) != 7) || IS_LDT_ENTRY_FREE(SELECTOR_TO_ENTRY(seg)))) \
{ \
fprintf( stderr, "*** Invalid value for %s register: %04x\n", \
- (name), (seg) ); \
+ (name), (WORD)(seg) ); \
return FALSE; \
}
- if (CS_reg(DEBUG_context) != WINE_CODE_SELECTOR)
- CHECK_SEG( CS_reg(DEBUG_context), "CS" );
- if (SS_reg(DEBUG_context) != WINE_DATA_SELECTOR)
- CHECK_SEG( SS_reg(DEBUG_context), "SS" );
- if (DS_reg(DEBUG_context) != WINE_DATA_SELECTOR)
- CHECK_SEG( DS_reg(DEBUG_context), "DS" );
- if (ES_reg(DEBUG_context) != WINE_DATA_SELECTOR)
- CHECK_SEG( ES_reg(DEBUG_context), "ES" );
-#ifdef FS_reg
- if (FS_reg(DEBUG_context) != WINE_DATA_SELECTOR)
- CHECK_SEG( FS_reg(DEBUG_context), "FS" );
-#endif
-#ifdef GS_reg
- if (GS_reg(DEBUG_context) != WINE_DATA_SELECTOR)
- CHECK_SEG( GS_reg(DEBUG_context), "GS" );
-#endif
+ if (CS_reg(&DEBUG_context) != WINE_CODE_SELECTOR)
+ CHECK_SEG( CS_reg(&DEBUG_context), "CS" );
+ if (SS_reg(&DEBUG_context) != WINE_DATA_SELECTOR)
+ CHECK_SEG( SS_reg(&DEBUG_context), "SS" );
+ if (DS_reg(&DEBUG_context) != WINE_DATA_SELECTOR)
+ CHECK_SEG( DS_reg(&DEBUG_context), "DS" );
+ if (ES_reg(&DEBUG_context) != WINE_DATA_SELECTOR)
+ CHECK_SEG( ES_reg(&DEBUG_context), "ES" );
+ if (FS_reg(&DEBUG_context) != WINE_DATA_SELECTOR)
+ CHECK_SEG( FS_reg(&DEBUG_context), "FS" );
+ if (GS_reg(&DEBUG_context) != WINE_DATA_SELECTOR)
+ CHECK_SEG( GS_reg(&DEBUG_context), "GS" );
/* Check that CS and SS are not NULL */
- if (!(CS_reg(DEBUG_context) & ~3))
+ if (!(CS_reg(&DEBUG_context) & ~3))
{
fprintf( stderr, "*** Invalid value for CS register: %04x\n",
- CS_reg(DEBUG_context) );
+ (WORD)CS_reg(&DEBUG_context) );
return FALSE;
}
- if (!(SS_reg(DEBUG_context) & ~3))
+ if (!(SS_reg(&DEBUG_context) & ~3))
{
fprintf( stderr, "*** Invalid value for SS register: %04x\n",
- SS_reg(DEBUG_context) );
+ (WORD)SS_reg(&DEBUG_context) );
return FALSE;
}
return TRUE;
diff --git a/debugger/stabs.c b/debugger/stabs.c
index 2c238be..216ff4d 100644
--- a/debugger/stabs.c
+++ b/debugger/stabs.c
@@ -372,4 +372,12 @@
}
+#else /* !__ELF__ */
+
+int
+DEBUG_ReadExecutableDbgInfo(void)
+{
+return FALSE;
+}
+
#endif /* __ELF__ */
diff --git a/debugger/stack.c b/debugger/stack.c
index 9ac2ea2..adc4e88 100644
--- a/debugger/stack.c
+++ b/debugger/stack.c
@@ -57,17 +57,17 @@
DBG_ADDR addr;
fprintf(stderr,"Stack dump:\n");
- if ((SS_reg(DEBUG_context) == WINE_DATA_SELECTOR) ||
- (GET_SEL_FLAGS(SS_reg(DEBUG_context)) & LDT_FLAGS_32BIT))
+ if ((SS_reg(&DEBUG_context) == WINE_DATA_SELECTOR) ||
+ (GET_SEL_FLAGS(SS_reg(&DEBUG_context)) & LDT_FLAGS_32BIT))
{ /* 32-bit mode */
addr.seg = 0;
- addr.off = ESP_reg(DEBUG_context);
+ addr.off = ESP_reg(&DEBUG_context);
DEBUG_ExamineMemory( &addr, 24, 'x' );
}
else /* 16-bit mode */
{
- addr.seg = SS_reg(DEBUG_context);
- addr.off = SP_reg(DEBUG_context);
+ addr.seg = SS_reg(&DEBUG_context);
+ addr.off = SP_reg(&DEBUG_context);
DEBUG_ExamineMemory( &addr, 24, 'w' );
}
fprintf(stderr,"\n");
@@ -85,40 +85,28 @@
int frameno = 0;
fprintf(stderr,"Backtrace:\n");
- if (SS_reg(DEBUG_context) == WINE_DATA_SELECTOR) /* 32-bit mode */
+ if (SS_reg(&DEBUG_context) == WINE_DATA_SELECTOR) /* 32-bit mode */
{
- addr.seg = 0;
- addr.off = EBP_reg(DEBUG_context);
- nframe = 1;
- while (addr.off)
- {
- FRAME32 *frame = (FRAME32 *)addr.off;
- if (!DBG_CHECK_READ_PTR( &addr, sizeof(FRAME32) )) return;
- if (!frame->ip) break;
- addr.off = frame->bp;
- nframe++;
- }
- if( frames != NULL )
- {
- free(frames);
- }
-
- frames = (struct bt_info *) xmalloc(nframe
- * sizeof(struct bt_info) );
+ nframe = 1;
+ if (frames) free( frames );
+ frames = (struct bt_info *) xmalloc( sizeof(struct bt_info) );
fprintf(stderr,"%s%d ",(curr_frame == 0 ? "=>" : " "), frameno++);
- addr.off = EIP_reg(DEBUG_context);
+
+ addr.seg = 0;
+ addr.off = EIP_reg(&DEBUG_context);
frames[0].eip = addr.off;
frames[0].frame = DEBUG_PrintAddress( &addr, 32, TRUE );
fprintf( stderr, "\n" );
- addr.off = EBP_reg(DEBUG_context);
-
- frames[0].ebp = addr.off;
+ frames[0].ebp = addr.off = EBP_reg(&DEBUG_context);
while (addr.off)
{
FRAME32 *frame = (FRAME32 *)addr.off;
if (!DBG_CHECK_READ_PTR( &addr, sizeof(FRAME32) )) return;
if (!frame->ip) break;
+ nframe++;
+ frames = (struct bt_info *)xrealloc(frames,
+ nframe*sizeof(struct bt_info));
fprintf(stderr,"%s%d ", (frameno == curr_frame ? "=>" : " "),
frameno);
addr.off = frame->ip;
@@ -133,7 +121,7 @@
}
else /* 16-bit mode */
{
- WORD ss = SS_reg(DEBUG_context), cs = CS_reg(DEBUG_context);
+ WORD ss = SS_reg(&DEBUG_context), cs = CS_reg(&DEBUG_context);
if (GET_SEL_FLAGS(ss) & LDT_FLAGS_32BIT)
{
fprintf( stderr, "Not implemented: 32-bit backtrace on a different stack segment.\n" );
@@ -141,11 +129,11 @@
}
fprintf( stderr,"%d ", frameno++ );
addr.seg = cs;
- addr.off = IP_reg(DEBUG_context);
+ addr.off = IP_reg(&DEBUG_context);
DEBUG_PrintAddress( &addr, 16, TRUE );
fprintf( stderr, "\n" );
addr.seg = ss;
- addr.off = BP_reg(DEBUG_context) & ~1;
+ addr.off = BP_reg(&DEBUG_context) & ~1;
for (;;)
{
FRAME16 *frame = (FRAME16 *)DBG_ADDR_TO_LIN(&addr);
diff --git a/files/Makefile.in b/files/Makefile.in
index c5f236b..4a2735e 100644
--- a/files/Makefile.in
+++ b/files/Makefile.in
@@ -1,6 +1,6 @@
prefix = @prefix@
sysconfdir = @sysconfdir@
-DEFS = -D__WINE__ -DETCDIR=\"$(sysconfdir)\"
+DEFS = -D__WINE__ -DNO_TRANSITION_TYPES -DETCDIR=\"$(sysconfdir)\"
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ..
SRCDIR = @srcdir@
diff --git a/files/directory.c b/files/directory.c
index f83d81b..157fea4 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -6,16 +6,18 @@
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
#include "windows.h"
+#include "winerror.h"
#include "dos_fs.h"
#include "drive.h"
#include "file.h"
+#include "heap.h"
#include "msdos.h"
#include "options.h"
-#include "xmalloc.h"
#include "stddebug.h"
#include "debug.h"
@@ -42,12 +44,12 @@
{
char path[MAX_PATHNAME_LEN];
const char *dos_name ,*unix_name;
- BYTE attr;
+ BY_HANDLE_FILE_INFORMATION info;
PROFILE_GetWineIniString( "wine", keyname, defval, path, sizeof(path) );
if (!(unix_name = DOSFS_GetUnixFileName( path, TRUE )) ||
- !FILE_Stat( unix_name, &attr, NULL, NULL, NULL ) ||
- !(attr & FA_DIRECTORY))
+ !FILE_Stat( unix_name, &info ) ||
+ !(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
fprintf(stderr, "Invalid path '%s' for %s directory\n", path, keyname);
return 0;
@@ -58,8 +60,8 @@
keyname, unix_name );
return 0;
}
- *unix_path = xstrdup( unix_name );
- *dos_path = xstrdup( dos_name );
+ *unix_path = HEAP_strdupA( SystemHeap, 0, unix_name );
+ *dos_path = HEAP_strdupA( SystemHeap, 0, dos_name );
return 1;
}
@@ -71,7 +73,7 @@
{
char *p;
const char *dos_name ,*unix_name;
- BYTE attr;
+ BY_HANDLE_FILE_INFORMATION info;
int i;
for ( ; path && *path; path = p)
@@ -86,8 +88,8 @@
break;
}
if (!(unix_name = DOSFS_GetUnixFileName( path, TRUE )) ||
- !FILE_Stat( unix_name, &attr, NULL, NULL, NULL ) ||
- !(attr & FA_DIRECTORY))
+ !FILE_Stat( unix_name, &info ) ||
+ !(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
fprintf(stderr,"Warning: invalid dir '%s' in path, deleting it.\n",
path );
@@ -99,8 +101,8 @@
unix_name );
continue;
}
- DIR_UnixPath[DIR_PathElements] = xstrdup( unix_name );
- DIR_DosPath[DIR_PathElements] = xstrdup( dos_name );
+ DIR_UnixPath[DIR_PathElements] = HEAP_strdupA(SystemHeap,0,unix_name);
+ DIR_DosPath[DIR_PathElements] = HEAP_strdupA(SystemHeap,0,dos_name);
DIR_PathElements++;
}
@@ -171,11 +173,11 @@
/* Put the temp and Windows directories into the environment */
- env_p = (char *)xmalloc( strlen(DIR_TempDosDir) + 6 );
+ env_p = HEAP_xalloc( SystemHeap, 0, strlen(DIR_TempDosDir) + 6 );
strcpy( env_p, "TEMP=" );
strcpy( env_p + 5, DIR_TempDosDir );
putenv( env_p );
- env_p = (char *)xmalloc( strlen(DIR_WindowsDosDir) + 8 );
+ env_p = HEAP_xalloc( SystemHeap, 0, strlen(DIR_WindowsDosDir) + 8 );
strcpy( env_p, "windir=" );
strcpy( env_p + 7, DIR_WindowsDosDir );
putenv( env_p );
@@ -325,3 +327,303 @@
if (path) lstrcpynAtoW( path, DIR_SystemDosDir, count );
return strlen( DIR_SystemDosDir );
}
+
+
+/***********************************************************************
+ * CreateDirectory16 (KERNEL.144)
+ */
+BOOL16 CreateDirectory16( LPCSTR path, LPVOID dummy )
+{
+ dprintf_file( stddeb,"CreateDirectory16(%s,%p)\n", path, dummy );
+ return (BOOL16)CreateDirectory32A( path, NULL );
+}
+
+
+/***********************************************************************
+ * CreateDirectory32A (KERNEL32.39)
+ */
+BOOL32 CreateDirectory32A( LPCSTR path, LPSECURITY_ATTRIBUTES lpsecattribs )
+{
+ const char *unixName;
+
+ dprintf_file( stddeb, "CreateDirectory32A(%s,%p)\n", path, lpsecattribs );
+ if ((unixName = DOSFS_IsDevice( path )) != NULL)
+ {
+ dprintf_file(stddeb, "CreateDirectory: device '%s'!\n", unixName);
+ DOS_ERROR( ER_AccessDenied, EC_AccessDenied, SA_Abort, EL_Disk );
+ return FALSE;
+ }
+ if (!(unixName = DOSFS_GetUnixFileName( path, FALSE ))) return 0;
+ if ((mkdir( unixName, 0777 ) == -1) && (errno != EEXIST))
+ {
+ FILE_SetDosError();
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * CreateDirectory32W (KERNEL32.42)
+ */
+BOOL32 CreateDirectory32W( LPCWSTR path, LPSECURITY_ATTRIBUTES lpsecattribs )
+{
+ LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
+ BOOL32 ret = CreateDirectory32A( xpath, lpsecattribs );
+ HeapFree( GetProcessHeap(), 0, xpath );
+ return ret;
+}
+
+
+/***********************************************************************
+ * CreateDirectoryEx32A (KERNEL32.40)
+ */
+BOOL32 CreateDirectoryEx32A( LPCSTR template, LPCSTR path,
+ LPSECURITY_ATTRIBUTES lpsecattribs)
+{
+ return CreateDirectory32A(path,lpsecattribs);
+}
+
+
+/***********************************************************************
+ * CreateDirectoryEx32W (KERNEL32.41)
+ */
+BOOL32 CreateDirectoryEx32W( LPCWSTR template, LPCWSTR path,
+ LPSECURITY_ATTRIBUTES lpsecattribs)
+{
+ return CreateDirectory32W(path,lpsecattribs);
+}
+
+
+/***********************************************************************
+ * RemoveDirectory16 (KERNEL)
+ */
+BOOL16 RemoveDirectory16( LPCSTR path )
+{
+ return (BOOL16)RemoveDirectory32A( path );
+}
+
+
+/***********************************************************************
+ * RemoveDirectory32A (KERNEL32.437)
+ */
+BOOL32 RemoveDirectory32A( LPCSTR path )
+{
+ const char *unixName;
+
+ dprintf_file(stddeb, "RemoveDirectory: '%s'\n", path );
+
+ if ((unixName = DOSFS_IsDevice( path )) != NULL)
+ {
+ dprintf_file(stddeb, "RemoveDirectory: device '%s'!\n", unixName);
+ DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
+ return FALSE;
+ }
+ if (!(unixName = DOSFS_GetUnixFileName( path, TRUE ))) return FALSE;
+ if (rmdir( unixName ) == -1)
+ {
+ FILE_SetDosError();
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * RemoveDirectory32W (KERNEL32.438)
+ */
+BOOL32 RemoveDirectory32W( LPCWSTR path )
+{
+ LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
+ BOOL32 ret = RemoveDirectory32A( xpath );
+ HeapFree( GetProcessHeap(), 0, xpath );
+ return ret;
+}
+
+
+/***********************************************************************
+ * DIR_SearchPath
+ *
+ * Implementation of SearchPath32A. 'win32' specifies whether the search
+ * order is Win16 (module path last) or Win32 (module path first).
+ *
+ * FIXME: should return long path names.
+ */
+DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
+ DWORD buflen, LPSTR buffer, LPSTR *lastpart,
+ BOOL32 win32 )
+{
+ DWORD len;
+ LPSTR tmp;
+ int i;
+
+ /* First check the supplied parameters */
+
+ if (strchr( name, '.' )) ext = NULL; /* Ignore the specified extension */
+ if (path && !*path) path = NULL; /* Ignore empty path */
+ len = strlen(name);
+ if (ext) len += strlen(ext);
+ if (path) len += strlen(path) + 1;
+
+ /* Allocate a buffer for the file name and extension */
+
+ if (path || ext)
+ {
+ if (!(tmp = HeapAlloc( GetProcessHeap(), 0, len + 1 )))
+ {
+ SetLastError( ERROR_OUTOFMEMORY );
+ return 0;
+ }
+ if (path)
+ {
+ strcpy( tmp, path );
+ strcat( tmp, "\\" );
+ strcat( tmp, name );
+ }
+ else strcpy( tmp, name );
+ if (ext) strcat( tmp, ext );
+ }
+ else tmp = (LPSTR)name;
+
+ /* If we have an explicit path, everything's easy */
+
+ if (path || (*tmp && (tmp[1] == ':')) ||
+ strchr( tmp, '/' ) || strchr( tmp, '\\' ))
+ {
+ if (!DOSFS_GetUnixFileName( tmp, TRUE )) goto not_found;
+ lstrcpyn32A( buffer, tmp, buflen );
+ if (tmp != name) HeapFree( GetProcessHeap(), 0, tmp );
+ return len;
+ }
+
+ /* Try the path of the current executable (for Win32 search order) */
+
+ if (win32 && GetCurrentTask())
+ {
+ LPSTR p;
+ GetModuleFileName32A( GetCurrentTask(), buffer, buflen );
+ if ((p = strrchr( buffer, '\\' )))
+ {
+ lstrcpyn32A( p + 1, tmp, (INT32)buflen - (p - buffer) );
+ if (DOSFS_GetUnixFileName( buffer, TRUE ))
+ {
+ *p = '\0';
+ goto found;
+ }
+ }
+ }
+
+ /* Try the current directory */
+
+ if (DOSFS_GetUnixFileName( tmp, TRUE ))
+ {
+ GetCurrentDirectory32A( buflen, buffer );
+ goto found;
+ }
+
+ /* Try the Windows directory */
+
+ if (DOSFS_FindUnixName( DIR_WindowsUnixDir, name, NULL, 0,
+ DRIVE_GetFlags( DIR_WindowsDosDir[0] - 'A' ) ))
+ {
+ lstrcpyn32A( buffer, DIR_WindowsDosDir, buflen );
+ goto found;
+ }
+
+ /* Try the Windows system directory */
+
+ if (DOSFS_FindUnixName( DIR_SystemUnixDir, name, NULL, 0,
+ DRIVE_GetFlags( DIR_SystemDosDir[0] - 'A' ) ))
+ {
+ lstrcpyn32A( buffer, DIR_SystemDosDir, buflen );
+ goto found;
+ }
+
+ /* Try the path of the current executable (for Win16 search order) */
+
+ if (!win32 && GetCurrentTask())
+ {
+ LPSTR p;
+ GetModuleFileName32A( GetCurrentTask(), buffer, buflen );
+ if ((p = strrchr( buffer, '\\' )))
+ {
+ lstrcpyn32A( p + 1, tmp, (INT32)buflen - (p - buffer) );
+ if (DOSFS_GetUnixFileName( buffer, TRUE ))
+ {
+ *p = '\0';
+ goto found;
+ }
+ }
+ }
+ /* Try all directories in path */
+
+ for (i = 0; i < DIR_PathElements; i++)
+ {
+ if (DOSFS_FindUnixName( DIR_UnixPath[i], name, NULL, 0,
+ DRIVE_GetFlags( DIR_DosPath[i][0] - 'A' ) ))
+ {
+ lstrcpyn32A( buffer, DIR_DosPath[i], buflen );
+ goto found;
+ }
+ }
+
+not_found:
+ if (tmp != name) HeapFree( GetProcessHeap(), 0, tmp );
+ SetLastError( ERROR_FILE_NOT_FOUND );
+ DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
+ return 0;
+
+found:
+ len = strlen(buffer);
+ if (lastpart) *lastpart = buffer + len + 1;
+ if (len + 1 < buflen)
+ {
+ buffer += len;
+ *buffer++ = '\\';
+ buflen -= len + 1;
+ lstrcpyn32A( buffer, tmp, buflen );
+ }
+ len += strlen(tmp) + 1;
+ if (tmp != name) HeapFree( GetProcessHeap(), 0, tmp );
+ return len;
+}
+
+
+/***********************************************************************
+ * SearchPath32A (KERNEL32.447)
+ */
+DWORD SearchPath32A( LPCSTR path, LPCSTR name, LPCSTR ext, DWORD buflen,
+ LPSTR buffer, LPSTR *lastpart )
+{
+ return DIR_SearchPath( path, name, ext, buflen, buffer, lastpart, TRUE );
+}
+
+
+/***********************************************************************
+ * SearchPath32W (KERNEL32.448)
+ */
+DWORD SearchPath32W( LPCWSTR path, LPCWSTR name, LPCWSTR ext, DWORD buflen,
+ LPWSTR buffer, LPWSTR *lastpart )
+{
+ LPSTR pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
+ LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
+ LPSTR extA = HEAP_strdupWtoA( GetProcessHeap(), 0, ext );
+ LPSTR lastpartA;
+ LPSTR bufferA = HeapAlloc( GetProcessHeap(), 0, buflen + 1 );
+
+ DWORD ret = DIR_SearchPath( pathA, nameA, extA, buflen, bufferA,
+ &lastpartA, TRUE );
+ lstrcpyAtoW( buffer, bufferA );
+ if (lastpart)
+ {
+ if (lastpartA) *lastpart = buffer + (lastpartA - bufferA);
+ else *lastpart = NULL;
+ }
+ HeapFree( GetProcessHeap(), 0, bufferA );
+ HeapFree( GetProcessHeap(), 0, extA );
+ HeapFree( GetProcessHeap(), 0, nameA );
+ HeapFree( GetProcessHeap(), 0, pathA );
+ return ret;
+}
+
+
diff --git a/files/dos_fs.c b/files/dos_fs.c
index 6ce5881..fb3c0e7 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -8,16 +8,20 @@
#include <sys/types.h>
#include <ctype.h>
#include <dirent.h>
+#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
+#include <sys/ioctl.h>
#include <time.h>
+#include <unistd.h>
#if defined(__svr4__) || defined(_SCO_DS)
#include <sys/statfs.h>
#endif
#include "windows.h"
+#include "winerror.h"
#include "dos_fs.h"
#include "drive.h"
#include "file.h"
@@ -25,7 +29,15 @@
#include "msdos.h"
#include "stddebug.h"
#include "debug.h"
-#include "xmalloc.h"
+
+/* Define the VFAT ioctl to get both short and long file names */
+#if 0 /* not working yet */
+#ifdef linux
+#define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, long)
+#else /* linux */
+#undef VFAT_IOCTL_READDIR_BOTH /* just in case... */
+#endif /* linux */
+#endif
/* Chars we don't want to see in DOS file names */
#define INVALID_DOS_CHARS "*?<>|\"+=,;[] \345"
@@ -55,6 +67,27 @@
BYTE DOS_ErrorAction;
BYTE DOS_ErrorLocus;
+/* Info structure for FindFirstFile handle */
+typedef struct
+{
+ LPSTR path;
+ LPSTR mask;
+ int drive;
+ int skip;
+} FIND_FIRST_INFO;
+
+
+/* Directory info for DOSFS_ReadDir */
+typedef struct
+{
+ DIR *dir;
+#ifdef VFAT_IOCTL_READDIR_BOTH
+ int fd;
+ char short_name[12];
+ struct dirent dirent[2];
+#endif
+} DOS_DIR;
+
/***********************************************************************
* DOSFS_ValidDOSName
@@ -150,7 +183,11 @@
{
p++;
strcpy( buffer, ". " );
- if (*p == '.') p++;
+ if (*p == '.')
+ {
+ buffer[1] = '.';
+ p++;
+ }
return (!*p || (*p == '/') || (*p == '\\')) ? buffer : NULL;
}
@@ -265,6 +302,7 @@
static int DOSFS_MatchLong( const char *mask, const char *name,
int case_sensitive )
{
+ if (!strcmp( mask, "*.*" )) return 1;
while (*name && *mask)
{
if (*mask == '*')
@@ -292,6 +330,95 @@
/***********************************************************************
+ * DOSFS_OpenDir
+ */
+static DOS_DIR *DOSFS_OpenDir( LPCSTR path )
+{
+ DOS_DIR *dir = HeapAlloc( SystemHeap, 0, sizeof(*dir) );
+ if (!dir)
+ {
+ DOS_ERROR( ER_OutOfMemory, EC_OutOfResource, SA_Abort, EL_Memory );
+ return NULL;
+ }
+
+#ifdef VFAT_IOCTL_READDIR_BOTH
+
+ /* Check if the VFAT ioctl is supported on this directory */
+
+ if ((dir->fd = open( path, O_RDONLY )) != -1)
+ {
+ if (ioctl( dir->fd, VFAT_IOCTL_READDIR_BOTH, (long)dir->dirent ) == -1)
+ {
+ close( dir->fd );
+ dir->fd = -1;
+ }
+ else
+ {
+ /* Set the file pointer back at the start of the directory */
+ lseek( dir->fd, 0, SEEK_SET );
+ dir->dir = NULL;
+ return dir;
+ }
+ }
+#endif /* VFAT_IOCTL_READDIR_BOTH */
+
+ /* Now use the standard opendir/readdir interface */
+
+ if (!(dir->dir = opendir( path )))
+ {
+ HeapFree( SystemHeap, 0, dir );
+ return NULL;
+ }
+ return dir;
+}
+
+
+/***********************************************************************
+ * DOSFS_CloseDir
+ */
+static void DOSFS_CloseDir( DOS_DIR *dir )
+{
+#ifdef VFAT_IOCTL_READDIR_BOTH
+ if (dir->fd != -1) close( dir->fd );
+#endif /* VFAT_IOCTL_READDIR_BOTH */
+ if (dir->dir) closedir( dir->dir );
+ HeapFree( SystemHeap, 0, dir );
+}
+
+
+/***********************************************************************
+ * DOSFS_ReadDir
+ */
+static BOOL32 DOSFS_ReadDir( DOS_DIR *dir, LPCSTR *long_name,
+ LPCSTR *short_name )
+{
+ struct dirent *dirent;
+
+#ifdef VFAT_IOCTL_READDIR_BOTH
+ if (dir->fd != -1)
+ {
+ LPCSTR fcb_name;
+ if (ioctl( dir->fd, VFAT_IOCTL_READDIR_BOTH, (long)dir->dirent ) == -1)
+ return FALSE;
+ if (!dir->dirent[0].d_reclen) return FALSE;
+ fcb_name = DOSFS_ToDosFCBFormat( dir->dirent[0].d_name );
+ if (fcb_name) strcpy( dir->short_name, fcb_name );
+ else dir->short_name[0] = '\0';
+ *short_name = dir->short_name;
+ if (dir->dirent[1].d_name[0]) *long_name = dir->dirent[1].d_name;
+ else *long_name = dir->dirent[0].d_name;
+ return TRUE;
+ }
+#endif /* VFAT_IOCTL_READDIR_BOTH */
+
+ if (!(dirent = readdir( dir->dir ))) return FALSE;
+ *long_name = dirent->d_name;
+ *short_name = NULL;
+ return TRUE;
+}
+
+
+/***********************************************************************
* DOSFS_ToDosDateTime
*
* Convert a Unix time in the DOS date/time format.
@@ -344,7 +471,7 @@
*
* Convert a FILETIME format to Unix time.
*/
-time_t DOSFS_FileTimeToUnixTime( FILETIME *filetime )
+time_t DOSFS_FileTimeToUnixTime( const FILETIME *filetime )
{
/* FIXME :-) */
return filetime->dwLowDateTime;
@@ -359,7 +486,8 @@
* hashed version that fits in 8.3 format.
* File name can be terminated by '\0', '\\' or '/'.
*/
-const char *DOSFS_Hash( const char *name, int dir_format, int ignore_case )
+static const char *DOSFS_Hash( const char *name, int dir_format,
+ int ignore_case )
{
static const char invalid_chars[] = INVALID_DOS_CHARS "~.";
static const char hash_chars[32] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
@@ -439,7 +567,7 @@
{
if (!dir_format) *dst++ = '.';
for (i = 3, ext++; (i > 0) && !IS_END_OF_NAME(*ext); i--, ext++)
- *dst++ = toupper(*ext);
+ *dst++ = strchr( invalid_chars, *ext ) ? '_' : toupper(*ext);
}
if (!dir_format) *dst = '\0';
}
@@ -455,53 +583,59 @@
* File name can be terminated by '\0', '\\' or '/'.
* Return 1 if OK, 0 if no file name matches.
*/
-static int DOSFS_FindUnixName( const char *path, const char *name,
- char *buffer, int maxlen, UINT32 drive_flags )
+BOOL32 DOSFS_FindUnixName( const char *path, const char *name,
+ char *buffer, int maxlen, UINT32 drive_flags )
{
- DIR *dir;
- struct dirent *dirent;
+ DOS_DIR *dir;
+ LPCSTR long_name, short_name;
+ char dos_name[12];
+ BOOL32 ret;
- const char *dos_name = DOSFS_ToDosFCBFormat( name );
const char *p = strchr( name, '/' );
int len = p ? (int)(p - name) : strlen(name);
- dprintf_dosfs( stddeb, "DOSFS_FindUnixName: %s %s\n", path, name );
+ dprintf_dosfs( stddeb, "DOSFS_FindUnixName: %s,%s\n", path, name );
if ((p = strchr( name, '\\' ))) len = MIN( (int)(p - name), len );
- if (!(dir = opendir( path )))
+ dos_name[0] = '\0';
+ if ((p = DOSFS_ToDosFCBFormat( name ))) strcpy( dos_name, p );
+
+ if (!(dir = DOSFS_OpenDir( path )))
{
dprintf_dosfs( stddeb, "DOSFS_FindUnixName(%s,%s): can't open dir\n",
path, name );
return 0;
}
- while ((dirent = readdir( dir )) != NULL)
+
+ while ((ret = DOSFS_ReadDir( dir, &long_name, &short_name )))
{
/* Check against Unix name */
- if (len == strlen(dirent->d_name))
+ if (len == strlen(long_name))
{
if (drive_flags & DRIVE_CASE_SENSITIVE)
{
- if (!lstrncmp32A( dirent->d_name, name, len )) break;
+ if (!lstrncmp32A( long_name, name, len )) break;
}
else
{
- if (!lstrncmpi32A( dirent->d_name, name, len )) break;
+ if (!lstrncmpi32A( long_name, name, len )) break;
}
}
- if (dos_name)
+ if (dos_name[0])
{
/* Check against hashed DOS name */
- const char *hash_name = DOSFS_Hash( dirent->d_name, TRUE,
+ if (!short_name)
+ short_name = DOSFS_Hash( long_name, TRUE,
!(drive_flags & DRIVE_CASE_SENSITIVE) );
- if (!strcmp( dos_name, hash_name )) break;
+ if (!strcmp( dos_name, short_name )) break;
}
}
- if (dirent) lstrcpyn32A( buffer, dirent->d_name, maxlen );
- closedir( dir );
+ if (ret && buffer) lstrcpyn32A( buffer, long_name, maxlen );
dprintf_dosfs( stddeb, "DOSFS_FindUnixName(%s,%s) -> %s\n",
- path, name, dirent ? buffer : "** Not found **" );
- return (dirent != NULL);
+ path, name, ret ? long_name : "** Not found **" );
+ DOSFS_CloseDir( dir );
+ return ret;
}
@@ -531,6 +665,41 @@
return NULL;
}
+/***********************************************************************
+ * DOSFS_GetPathDrive
+ *
+ * Get the drive specified by a given path name (DOS or Unix format).
+ */
+static int DOSFS_GetPathDrive( const char **name )
+{
+ int drive;
+ const char *p = *name;
+
+ if (*p && (p[1] == ':'))
+ {
+ drive = toupper(*p) - 'A';
+ *name += 2;
+ }
+ else if (*p == '/') /* Absolute Unix path? */
+ {
+ if ((drive = DRIVE_FindDriveRoot( name )) == -1)
+ {
+ fprintf( stderr, "Warning: %s not accessible from a DOS drive\n",
+ *name );
+ /* Assume it really was a DOS name */
+ drive = DRIVE_GetCurrentDrive();
+ }
+ }
+ else drive = DRIVE_GetCurrentDrive();
+
+ if (!DRIVE_IsValid(drive))
+ {
+ DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
+ return -1;
+ }
+ return drive;
+}
+
/***********************************************************************
* DOSFS_GetUnixFileName
@@ -542,33 +711,14 @@
const char * DOSFS_GetUnixFileName( const char * name, int check_last )
{
static char buffer[MAX_PATHNAME_LEN];
- int drive, len, found;
+ int drive, len;
+ BOOL32 found;
UINT32 flags;
char *p, *root;
dprintf_dosfs( stddeb, "DOSFS_GetUnixFileName: %s\n", name );
- if (name[0] && (name[1] == ':'))
- {
- drive = toupper(name[0]) - 'A';
- name += 2;
- }
- else if (name[0] == '/') /* Absolute Unix path? */
- {
- if ((drive = DRIVE_FindDriveRoot( &name )) == -1)
- {
- fprintf( stderr, "Warning: %s not accessible from a DOS drive\n",
- name );
- /* Assume it really was a DOS name */
- drive = DRIVE_GetCurrentDrive();
- }
- }
- else drive = DRIVE_GetCurrentDrive();
- if (!DRIVE_IsValid(drive))
- {
- DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
- return NULL;
- }
+ if ((drive = DOSFS_GetPathDrive( &name )) == -1) return NULL;
flags = DRIVE_GetFlags(drive);
lstrcpyn32A( buffer, DRIVE_GetRoot(drive), MAX_PATHNAME_LEN );
if (buffer[1]) root = buffer + strlen(buffer);
@@ -587,7 +737,7 @@
p = buffer[1] ? buffer + strlen(buffer) : buffer;
len = MAX_PATHNAME_LEN - strlen(buffer);
- found = 1;
+ found = TRUE;
while (*name && found)
{
const char *newname = DOSFS_CheckDotDot( name, root, '/', &len );
@@ -652,29 +802,8 @@
char *p;
dprintf_dosfs( stddeb, "DOSFS_GetDosTrueName(%s,%d)\n", name, unix_format);
- if (name[0] && (name[1] == ':'))
- {
- drive = toupper(name[0]) - 'A';
- name += 2;
- }
- else if (name[0] == '/') /* Absolute Unix path? */
- {
- if ((drive = DRIVE_FindDriveRoot( &name )) == -1)
- {
- fprintf( stderr, "Warning: %s not accessible from a DOS drive\n",
- name );
- /* Assume it really was a DOS name */
- drive = DRIVE_GetCurrentDrive();
- }
- }
- else drive = DRIVE_GetCurrentDrive();
- if (!DRIVE_IsValid(drive))
- {
- DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
- return NULL;
- }
-
+ if ((drive = DOSFS_GetPathDrive( &name )) == -1) return NULL;
p = buffer;
*p++ = 'A' + drive;
*p++ = ':';
@@ -748,25 +877,32 @@
*/
int DOSFS_FindNext( const char *path, const char *short_mask,
const char *long_mask, int drive, BYTE attr,
- int skip, DOS_DIRENT *entry )
+ int skip, WIN32_FIND_DATA32A *entry )
{
- static DIR *dir = NULL;
- struct dirent *dirent;
+ static DOS_DIR *dir = NULL;
int count = 0;
static char buffer[MAX_PATHNAME_LEN];
static int cur_pos = 0;
static int drive_root = 0;
char *p;
- const char *hash_name;
+ LPCSTR long_name, short_name;
UINT32 flags;
+ BY_HANDLE_FILE_INFORMATION info;
if ((attr & ~(FA_UNUSED | FA_ARCHIVE | FA_RDONLY)) == FA_LABEL)
{
if (skip) return 0;
- strcpy( entry->name, DRIVE_GetLabel( drive ) );
- entry->attr = FA_LABEL;
- entry->size = 0;
- DOSFS_ToDosDateTime( time(NULL), &entry->date, &entry->time );
+ entry->dwFileAttributes = FILE_ATTRIBUTE_LABEL;
+ DOSFS_UnixTimeToFileTime( (time_t)0, &entry->ftCreationTime );
+ DOSFS_UnixTimeToFileTime( (time_t)0, &entry->ftLastAccessTime );
+ DOSFS_UnixTimeToFileTime( (time_t)0, &entry->ftLastWriteTime );
+ entry->nFileSizeHigh = 0;
+ entry->nFileSizeLow = 0;
+ entry->dwReserved0 = 0;
+ entry->dwReserved1 = 0;
+ strcpy( entry->cFileName,
+ DOSFS_ToDosDTAFormat( DRIVE_GetLabel( drive )) );
+ strcpy( entry->cAlternateFileName, entry->cFileName );
return 1;
}
@@ -778,9 +914,9 @@
dprintf_dosfs( stddeb, "DOSFS_FindNext: cache miss, path=%s skip=%d buf=%s cur=%d\n",
path, skip, buffer, cur_pos );
cur_pos = skip;
- if (dir) closedir(dir);
+ if (dir) DOSFS_CloseDir(dir);
if (!*path) path = "/";
- if (!(dir = opendir(path))) return 0;
+ if (!(dir = DOSFS_OpenDir(path))) return 0;
drive_path = path;
drive_root = 0;
if (DRIVE_FindDriveRoot( &drive_path ) != -1)
@@ -796,23 +932,22 @@
p = buffer + strlen(buffer);
attr |= FA_UNUSED | FA_ARCHIVE | FA_RDONLY;
flags = DRIVE_GetFlags( drive );
- hash_name = NULL;
- while ((dirent = readdir( dir )) != NULL)
+ while (DOSFS_ReadDir( dir, &long_name, &short_name ))
{
if (skip-- > 0) continue;
count++;
/* Don't return '.' and '..' in the root of the drive */
- if (drive_root && (dirent->d_name[0] == '.') &&
- (!dirent->d_name[1] ||
- ((dirent->d_name[1] == '.') && !dirent->d_name[2]))) continue;
+ if (drive_root && (long_name[0] == '.') &&
+ (!long_name[1] || ((long_name[1] == '.') && !long_name[2])))
+ continue;
/* Check the long mask */
if (long_mask)
{
- if (!DOSFS_MatchLong( long_mask, dirent->d_name,
+ if (!DOSFS_MatchLong( long_mask, long_name,
flags & DRIVE_CASE_SENSITIVE )) continue;
}
@@ -820,44 +955,208 @@
if (short_mask)
{
- hash_name = DOSFS_Hash( dirent->d_name, TRUE,
- !(flags & DRIVE_CASE_SENSITIVE) );
- if (!DOSFS_MatchShort( short_mask, hash_name )) continue;
+ if (!short_name)
+ short_name = DOSFS_Hash( long_name, TRUE,
+ !(flags & DRIVE_CASE_SENSITIVE) );
+ if (!DOSFS_MatchShort( short_mask, short_name )) continue;
}
/* Check the file attributes */
- lstrcpyn32A( p, dirent->d_name, sizeof(buffer) - (int)(p - buffer) );
- if (!FILE_Stat( buffer, &entry->attr, &entry->size,
- &entry->date, &entry->time ))
+ lstrcpyn32A( p, long_name, sizeof(buffer) - (int)(p - buffer) );
+ if (!FILE_Stat( buffer, &info ))
{
fprintf( stderr, "DOSFS_FindNext: can't stat %s\n", buffer );
continue;
}
- if (entry->attr & ~attr) continue;
+ if (info.dwFileAttributes & ~attr) continue;
/* We now have a matching entry; fill the result and return */
- if (!hash_name)
- hash_name = DOSFS_Hash( dirent->d_name, TRUE,
- !(flags & DRIVE_CASE_SENSITIVE) );
- strcpy( entry->name, hash_name );
- lstrcpyn32A( entry->unixname, dirent->d_name, sizeof(entry->unixname));
- if (!(flags & DRIVE_CASE_PRESERVING)) AnsiLower( entry->unixname );
- dprintf_dosfs( stddeb, "DOSFS_FindNext: returning %s %02x %ld\n",
- entry->name, entry->attr, entry->size );
+ if (!short_name)
+ short_name = DOSFS_Hash( long_name, TRUE,
+ !(flags & DRIVE_CASE_SENSITIVE) );
+
+ entry->dwFileAttributes = info.dwFileAttributes;
+ entry->ftCreationTime = info.ftCreationTime;
+ entry->ftLastAccessTime = info.ftLastAccessTime;
+ entry->ftLastWriteTime = info.ftLastWriteTime;
+ entry->nFileSizeHigh = info.nFileSizeHigh;
+ entry->nFileSizeLow = info.nFileSizeLow;
+ strcpy( entry->cAlternateFileName, DOSFS_ToDosDTAFormat(short_name) );
+ lstrcpyn32A( entry->cFileName, long_name, sizeof(entry->cFileName) );
+ if (!(flags & DRIVE_CASE_PRESERVING)) AnsiLower( entry->cFileName );
+ dprintf_dosfs( stddeb, "DOSFS_FindNext: returning %s (%s) %02lx %ld\n",
+ entry->cFileName, entry->cAlternateFileName,
+ entry->dwFileAttributes, entry->nFileSizeLow );
cur_pos += count;
p[-1] = '\0'; /* Remove trailing slash in buffer */
return count;
}
- closedir( dir );
+ DOSFS_CloseDir( dir );
dir = NULL;
return 0; /* End of directory */
}
+/*************************************************************************
+ * FindFirstFile16 (KERNEL.413)
+ */
+HANDLE16 FindFirstFile16( LPCSTR path, WIN32_FIND_DATA32A *data )
+{
+ HGLOBAL16 handle;
+ FIND_FIRST_INFO *info;
+ LPCSTR ptr;
+
+ if (!path) return 0;
+ if (!(ptr = DOSFS_GetUnixFileName( path, FALSE )))
+ return INVALID_HANDLE_VALUE16;
+ if (!(handle = GlobalAlloc16( GMEM_MOVEABLE, sizeof(FIND_FIRST_INFO) )))
+ return INVALID_HANDLE_VALUE16;
+ info = (FIND_FIRST_INFO *)GlobalLock16( handle );
+ info->path = HEAP_strdupA( SystemHeap, 0, ptr );
+ info->mask = strrchr( info->path, '/' );
+ *(info->mask++) = '\0';
+ if (path[0] && (path[1] == ':')) info->drive = toupper(*path) - 'A';
+ else info->drive = DRIVE_GetCurrentDrive();
+ info->skip = 0;
+ GlobalUnlock16( handle );
+ if (!FindNextFile16( handle, data ))
+ {
+ FindClose16( handle );
+ DOS_ERROR( ER_NoMoreFiles, EC_MediaError, SA_Abort, EL_Disk );
+ return INVALID_HANDLE_VALUE16;
+ }
+ return handle;
+}
+
+
+/*************************************************************************
+ * FindFirstFile32A (KERNEL32.123)
+ */
+HANDLE32 FindFirstFile32A( LPCSTR path, WIN32_FIND_DATA32A *data )
+{
+ HANDLE32 handle = FindFirstFile16( path, data );
+ if (handle == INVALID_HANDLE_VALUE16) return INVALID_HANDLE_VALUE32;
+ return handle;
+}
+
+
+/*************************************************************************
+ * FindFirstFile32W (KERNEL32.124)
+ */
+HANDLE32 FindFirstFile32W( LPCWSTR path, WIN32_FIND_DATA32W *data )
+{
+ WIN32_FIND_DATA32A dataA;
+ LPSTR pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
+ HANDLE32 handle = FindFirstFile32A( pathA, &dataA );
+ HeapFree( GetProcessHeap(), 0, pathA );
+ if (handle != INVALID_HANDLE_VALUE32)
+ {
+ data->dwFileAttributes = dataA.dwFileAttributes;
+ data->ftCreationTime = dataA.ftCreationTime;
+ data->ftLastAccessTime = dataA.ftLastAccessTime;
+ data->ftLastWriteTime = dataA.ftLastWriteTime;
+ data->nFileSizeHigh = dataA.nFileSizeHigh;
+ data->nFileSizeLow = dataA.nFileSizeLow;
+ lstrcpyAtoW( data->cFileName, dataA.cFileName );
+ lstrcpyAtoW( data->cAlternateFileName, dataA.cAlternateFileName );
+ }
+ return handle;
+}
+
+
+/*************************************************************************
+ * FindNextFile16 (KERNEL.414)
+ */
+BOOL16 FindNextFile16( HANDLE16 handle, WIN32_FIND_DATA32A *data )
+{
+ FIND_FIRST_INFO *info;
+ int count;
+
+ if (!(info = (FIND_FIRST_INFO *)GlobalLock16( handle )))
+ {
+ DOS_ERROR( ER_InvalidHandle, EC_ProgramError, SA_Abort, EL_Disk );
+ return FALSE;
+ }
+ GlobalUnlock16( handle );
+ if (!info->path)
+ {
+ DOS_ERROR( ER_NoMoreFiles, EC_MediaError, SA_Abort, EL_Disk );
+ return FALSE;
+ }
+ if (!(count = DOSFS_FindNext( info->path, NULL, info->mask, info->drive,
+ 0xff, info->skip, data )))
+ {
+ HeapFree( SystemHeap, 0, info->path );
+ info->path = info->mask = NULL;
+ DOS_ERROR( ER_NoMoreFiles, EC_MediaError, SA_Abort, EL_Disk );
+ return FALSE;
+ }
+ info->skip += count;
+ return TRUE;
+}
+
+
+/*************************************************************************
+ * FindNextFile32A (KERNEL32.126)
+ */
+BOOL32 FindNextFile32A( HANDLE32 handle, WIN32_FIND_DATA32A *data )
+{
+ return FindNextFile16( handle, data );
+}
+
+
+/*************************************************************************
+ * FindNextFile32W (KERNEL32.127)
+ */
+BOOL32 FindNextFile32W( HANDLE32 handle, WIN32_FIND_DATA32W *data )
+{
+ WIN32_FIND_DATA32A dataA;
+ if (!FindNextFile32A( handle, &dataA )) return FALSE;
+ data->dwFileAttributes = dataA.dwFileAttributes;
+ data->ftCreationTime = dataA.ftCreationTime;
+ data->ftLastAccessTime = dataA.ftLastAccessTime;
+ data->ftLastWriteTime = dataA.ftLastWriteTime;
+ data->nFileSizeHigh = dataA.nFileSizeHigh;
+ data->nFileSizeLow = dataA.nFileSizeLow;
+ lstrcpyAtoW( data->cFileName, dataA.cFileName );
+ lstrcpyAtoW( data->cAlternateFileName, dataA.cAlternateFileName );
+ return TRUE;
+}
+
+
+/*************************************************************************
+ * FindClose16 (KERNEL.415)
+ */
+BOOL16 FindClose16( HANDLE16 handle )
+{
+ FIND_FIRST_INFO *info;
+
+ if ((handle == INVALID_HANDLE_VALUE16) ||
+ !(info = (FIND_FIRST_INFO *)GlobalLock16( handle )))
+ {
+ DOS_ERROR( ER_InvalidHandle, EC_ProgramError, SA_Abort, EL_Disk );
+ return FALSE;
+ }
+ if (info->path) HeapFree( SystemHeap, 0, info->path );
+ GlobalUnlock16( handle );
+ GlobalFree16( handle );
+ return TRUE;
+}
+
+
+/*************************************************************************
+ * FindClose32 (KERNEL32.119)
+ */
+BOOL32 FindClose32( HANDLE32 handle )
+{
+ return FindClose16( (HANDLE16)handle );
+}
+
+
/***********************************************************************
- * GetShortPathNameA (KERNEL32.271)
+ * GetShortPathName32A (KERNEL32.271)
*/
DWORD GetShortPathName32A( LPCSTR longpath, LPSTR shortpath, DWORD shortlen )
{
@@ -940,7 +1239,8 @@
/***********************************************************************
* FileTimeToDosDateTime (KERNEL32.111)
*/
-BOOL32 FileTimeToDosDateTime( LPFILETIME ft, LPWORD fatdate, LPWORD fattime)
+BOOL32 FileTimeToDosDateTime( const FILETIME *ft, LPWORD fatdate,
+ LPWORD fattime )
{
time_t unixtime = DOSFS_FileTimeToUnixTime(ft);
DOSFS_ToDosDateTime(unixtime,fatdate,fattime);
@@ -951,7 +1251,7 @@
/***********************************************************************
* LocalFileTimeToFileTime (KERNEL32.373)
*/
-BOOL32 LocalFileTimeToFileTime( LPFILETIME localft, LPFILETIME utcft )
+BOOL32 LocalFileTimeToFileTime( const FILETIME *localft, LPFILETIME utcft )
{
struct tm *xtm;
@@ -966,7 +1266,7 @@
/***********************************************************************
* FileTimeToLocalFileTime (KERNEL32.112)
*/
-BOOL32 FileTimeToLocalFileTime( LPFILETIME utcft, LPFILETIME localft )
+BOOL32 FileTimeToLocalFileTime( const FILETIME *utcft, LPFILETIME localft )
{
struct tm *xtm;
@@ -981,7 +1281,7 @@
/***********************************************************************
* FileTimeToSystemTime (KERNEL32.113)
*/
-BOOL32 FileTimeToSystemTime( LPFILETIME ft, LPSYSTEMTIME syst )
+BOOL32 FileTimeToSystemTime( const FILETIME *ft, LPSYSTEMTIME syst )
{
struct tm *xtm;
time_t xtime = DOSFS_FileTimeToUnixTime(ft);
@@ -1001,7 +1301,7 @@
/***********************************************************************
* SystemTimeToFileTime (KERNEL32.526)
*/
-BOOL32 SystemTimeToFileTime( LPSYSTEMTIME syst, LPFILETIME ft )
+BOOL32 SystemTimeToFileTime( const SYSTEMTIME *syst, LPFILETIME ft )
{
struct tm xtm;
diff --git a/files/drive.c b/files/drive.c
index 522518c..b876675 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -32,7 +32,6 @@
#include "msdos.h"
#include "options.h"
#include "task.h"
-#include "xmalloc.h"
#include "stddebug.h"
#include "debug.h"
@@ -137,11 +136,11 @@
p = path + strlen(path) - 1;
while ((p > path) && ((*p == '/') || (*p == '\\'))) *p-- = '\0';
if (strlen(path))
- drive->root = xstrdup( path );
+ drive->root = HEAP_strdupA( SystemHeap, 0, path );
else
- drive->root = xstrdup( "/" );
- drive->dos_cwd = xstrdup( "" );
- drive->unix_cwd = xstrdup( "" );
+ drive->root = HEAP_strdupA( SystemHeap, 0, "/" );
+ drive->dos_cwd = HEAP_strdupA( SystemHeap, 0, "" );
+ drive->unix_cwd = HEAP_strdupA( SystemHeap, 0, "" );
drive->type = DRIVE_GetDriveType( name );
drive->flags = 0;
@@ -180,9 +179,9 @@
{
fprintf( stderr, "Warning: no valid DOS drive found, check your configuration file.\n" );
/* Create a C drive pointing to Unix root dir */
- DOSDrives[2].root = xstrdup( "/" );
- DOSDrives[2].dos_cwd = xstrdup( "" );
- DOSDrives[2].unix_cwd = xstrdup( "" );
+ DOSDrives[2].root = HEAP_strdupA( SystemHeap, 0, "/" );
+ DOSDrives[2].dos_cwd = HEAP_strdupA( SystemHeap, 0, "" );
+ DOSDrives[2].unix_cwd = HEAP_strdupA( SystemHeap, 0, "" );
strcpy( DOSDrives[2].label, "Drive C " );
DOSDrives[2].serial = 0x12345678;
DOSDrives[2].type = TYPE_HD;
@@ -413,7 +412,7 @@
{
char buffer[MAX_PATHNAME_LEN];
const char *unix_cwd, *dos_cwd;
- BYTE attr;
+ BY_HANDLE_FILE_INFORMATION info;
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
dprintf_dosfs( stddeb, "DRIVE_Chdir(%c:,%s)\n", 'A' + drive, path );
@@ -422,8 +421,8 @@
lstrcpyn32A( buffer + 2, path, sizeof(buffer) - 2 );
if (!(unix_cwd = DOSFS_GetUnixFileName( buffer, TRUE ))) return 0;
- if (!FILE_Stat( unix_cwd, &attr, NULL, NULL, NULL )) return 0;
- if (!(attr & FA_DIRECTORY))
+ if (!FILE_Stat( unix_cwd, &info )) return 0;
+ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
return 0;
@@ -437,10 +436,10 @@
dprintf_dosfs( stddeb, "DRIVE_Chdir(%c:): unix_cwd=%s dos_cwd=%s\n",
'A' + drive, unix_cwd, dos_cwd + 3 );
- free( DOSDrives[drive].dos_cwd );
- free( DOSDrives[drive].unix_cwd );
- DOSDrives[drive].dos_cwd = xstrdup( dos_cwd + 3 );
- DOSDrives[drive].unix_cwd = xstrdup( unix_cwd );
+ HeapFree( SystemHeap, 0, DOSDrives[drive].dos_cwd );
+ HeapFree( SystemHeap, 0, DOSDrives[drive].unix_cwd );
+ DOSDrives[drive].dos_cwd = HEAP_strdupA( SystemHeap, 0, dos_cwd + 3 );
+ DOSDrives[drive].unix_cwd = HEAP_strdupA( SystemHeap, 0, unix_cwd );
if (pTask && (pTask->curdrive & 0x80) &&
((pTask->curdrive & ~0x80) == drive))
@@ -569,7 +568,7 @@
LPDWORD total_clusters )
{
LPSTR xroot;
- BOOL ret;
+ BOOL32 ret;
xroot = HEAP_strdupWtoA( GetProcessHeap(), 0, root);
ret = GetDiskFreeSpace32A( xroot,cluster_sectors, sector_bytes,
diff --git a/files/file.c b/files/file.c
index 5f41ecf..f841b81 100644
--- a/files/file.c
+++ b/files/file.c
@@ -5,6 +5,7 @@
* Copyright 1996 Alexandre Julliard
*/
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -19,221 +20,110 @@
#include "windows.h"
#include "winerror.h"
-#include "directory.h"
#include "dos_fs.h"
#include "drive.h"
+#include "file.h"
#include "global.h"
#include "heap.h"
#include "msdos.h"
#include "options.h"
#include "ldt.h"
+#include "process.h"
#include "task.h"
#include "stddebug.h"
#include "debug.h"
-#include "xmalloc.h"
-#define MAX_OPEN_FILES 64 /* Max. open files for all tasks; must be <255 */
-typedef struct tagDOS_FILE
+typedef struct
{
- struct tagDOS_FILE *next;
- int count; /* Usage count (0 if free) */
- int unix_handle;
- int mode;
- char *unix_name;
- WORD filedate;
- WORD filetime;
- DWORD type; /* Type for win32 apps */
+ K32OBJ header;
+ int unix_handle;
+ int mode;
+ char *unix_name;
+ DWORD type; /* Type for win32 apps */
} DOS_FILE;
-/* Global files array */
-static DOS_FILE DOSFiles[MAX_OPEN_FILES];
-
-static DOS_FILE *FILE_First = DOSFiles;
-static DOS_FILE *FILE_LastUsed = DOSFiles;
-
-/* Small file handles array for boot-up, before the first PDB is created */
-#define MAX_BOOT_HANDLES 4
-static BYTE bootFileHandles[MAX_BOOT_HANDLES] = { 0xff, 0xff, 0xff, 0xff };
/***********************************************************************
* FILE_Alloc
*
- * Allocate a DOS file.
+ * Allocate a file.
*/
-static DOS_FILE *FILE_Alloc(void)
+static HFILE32 FILE_Alloc( DOS_FILE **file )
{
- DOS_FILE *file = FILE_First;
- if (file) FILE_First = file->next;
- else if (FILE_LastUsed >= &DOSFiles[MAX_OPEN_FILES-1])
+ HFILE32 handle;
+ *file = HeapAlloc( SystemHeap, 0, sizeof(DOS_FILE) );
+ if (!*file)
{
DOS_ERROR( ER_TooManyOpenFiles, EC_ProgramError, SA_Abort, EL_Disk );
return NULL;
}
- else file = ++FILE_LastUsed;
- file->count = 1;
- file->unix_handle = -1;
- file->unix_name = NULL;
- file->type = FILE_TYPE_DISK;
- return file;
+ (*file)->header.type = K32OBJ_FILE;
+ (*file)->header.refcount = 0;
+ (*file)->unix_handle = -1;
+ (*file)->unix_name = NULL;
+ (*file)->type = FILE_TYPE_DISK;
+
+ handle = PROCESS_AllocHandle( &(*file)->header, 0 );
+ if (handle == INVALID_HANDLE_VALUE32) *file = NULL;
+ return handle;
}
/***********************************************************************
- * FILE_Close
+ * FILE_Destroy
*
- * Close a DOS file.
+ * Destroy a DOS file.
*/
-static BOOL FILE_Close( DOS_FILE *file )
+void FILE_Destroy( K32OBJ *ptr )
{
- if (!file->count) return FALSE;
- if (--file->count > 0) return TRUE;
- /* Now really close the file */
+ DOS_FILE *file = (DOS_FILE *)ptr;
+ assert( ptr->type == K32OBJ_FILE );
+
if (file->unix_handle != -1) close( file->unix_handle );
- if (file->unix_name) free( file->unix_name );
- file->next = FILE_First;
- FILE_First = file;
- return TRUE;
-}
-
-
-/***********************************************************************
- * FILE_GetPDBFiles
- *
- * Return a pointer to the current PDB files array.
- */
-static void FILE_GetPDBFiles( BYTE **files, WORD *nbFiles )
-{
- PDB *pdb;
-
- if ((pdb = (PDB *)GlobalLock16( GetCurrentPDB() )) != NULL)
- {
- *files = PTR_SEG_TO_LIN( pdb->fileHandlesPtr );
- *nbFiles = pdb->nbFiles;
- }
- else
- {
- *files = bootFileHandles;
- *nbFiles = MAX_BOOT_HANDLES;
- }
-}
-
-
-/***********************************************************************
- * FILE_AllocTaskHandle
- *
- * Allocate a task file handle for a DOS file.
- */
-static HFILE FILE_AllocTaskHandle( DOS_FILE *dos_file )
-{
- BYTE *files, *fp;
- WORD i, nbFiles;
-
- FILE_GetPDBFiles( &files, &nbFiles );
- fp = files + 1; /* Don't use handle 0, as some programs don't like it */
- for (i = nbFiles - 1; (i > 0) && (*fp != 0xff); i--, fp++);
- if (!i)
- { /* No more handles or files */
- DOS_ERROR( ER_TooManyOpenFiles, EC_ProgramError, SA_Abort, EL_Disk );
- return -1;
- }
- *fp = dos_file ? (BYTE)(dos_file - DOSFiles) : 0;
- dprintf_file(stddeb,
- "FILE_AllocTaskHandle: returning task handle %d, dos_file %d, file %d of %d \n",
- (fp - files), *fp, nbFiles - i, nbFiles );
- return (HFILE)(fp - files);
-}
-
-
-/***********************************************************************
- * FILE_FreeTaskHandle
- *
- * Free a per-task file handle.
- */
-static void FILE_FreeTaskHandle( HFILE handle )
-{
- BYTE *files;
- WORD nbFiles;
-
- FILE_GetPDBFiles( &files, &nbFiles );
- dprintf_file( stddeb,"FILE_FreeTaskHandle: dos=%d file=%d\n",
- handle, files[handle] );
- if ((handle < 0) || (handle >= (INT)nbFiles))
- {
- fprintf( stderr, "FILE_FreeTaskHandle: invalid file handle %d\n",
- handle );
- return;
- }
- files[handle] = 0xff;
-}
-
-
-/***********************************************************************
- * FILE_SetTaskHandle
- *
- * Set the value of a task handle (no error checking).
- */
-static void FILE_SetTaskHandle( HFILE handle, DOS_FILE *file )
-{
- BYTE *files;
- WORD nbFiles;
-
- FILE_GetPDBFiles( &files, &nbFiles );
- files[handle] = (BYTE)(file - DOSFiles);
+ if (file->unix_name) HeapFree( SystemHeap, 0, file->unix_name );
+ ptr->type = K32OBJ_UNKNOWN;
+ HeapFree( SystemHeap, 0, file );
}
/***********************************************************************
* FILE_GetFile
*
- * Return the DOS file associated to a task file handle.
+ * Return the DOS file associated to a task file handle. FILE_ReleaseFile must
+ * be called to release the file.
*/
-static DOS_FILE *FILE_GetFile( HFILE handle )
+static DOS_FILE *FILE_GetFile( HFILE32 handle )
{
- BYTE *files;
- WORD nbFiles;
- DOS_FILE *file;
-
- FILE_GetPDBFiles( &files, &nbFiles );
- if ((handle < 0) || (handle >= (INT)nbFiles) ||
- (files[handle] >= MAX_OPEN_FILES) ||
- !(file = &DOSFiles[files[handle]])->count)
- {
- DOS_ERROR( ER_InvalidHandle, EC_ProgramError, SA_Abort, EL_Disk );
- return NULL;
- }
- return file;
-}
-
-
-int FILE_GetUnixHandle( HFILE hFile )
-{
- DOS_FILE *file;
-
- if (!(file = FILE_GetFile( hFile ))) return -1;
- return file->unix_handle;
+ return (DOS_FILE *)PROCESS_GetObjPtr( handle, K32OBJ_FILE );
}
/***********************************************************************
- * FILE_CloseAllFiles
+ * FILE_ReleaseFile
*
- * Close all open files of a given PDB. Used on task termination.
+ * Release a DOS file obtained with FILE_GetFile.
*/
-void FILE_CloseAllFiles( HANDLE16 hPDB )
+static void FILE_ReleaseFile( DOS_FILE *file )
{
- BYTE *files;
- WORD count;
- PDB *pdb = (PDB *)GlobalLock16( hPDB );
+ K32OBJ_DecCount( &file->header );
+}
- if (!pdb) return;
- files = PTR_SEG_TO_LIN( pdb->fileHandlesPtr );
- dprintf_file(stddeb,"FILE_CloseAllFiles: closing %d files\n",pdb->nbFiles);
- for (count = pdb->nbFiles; count > 0; count--, files++)
- {
- if (*files < MAX_OPEN_FILES) FILE_Close( &DOSFiles[*files] );
- *files = 0xff;
- }
+
+/***********************************************************************
+ * FILE_GetUnixHandle
+ *
+ * Return the Unix handle associated to a file handle.
+ */
+int FILE_GetUnixHandle( HFILE32 hFile )
+{
+ DOS_FILE *file;
+ int ret;
+
+ if (!(file = FILE_GetFile( hFile ))) return -1;
+ ret = file->unix_handle;
+ FILE_ReleaseFile( file );
+ return ret;
}
@@ -290,20 +180,20 @@
*
* Duplicate a Unix handle into a task handle.
*/
-HFILE FILE_DupUnixHandle( int fd )
+HFILE32 FILE_DupUnixHandle( int fd )
{
- HFILE handle;
+ HFILE32 handle;
DOS_FILE *file;
- if (!(file = FILE_Alloc())) return HFILE_ERROR;
- if ((file->unix_handle = dup(fd)) == -1)
+ if ((handle = FILE_Alloc( &file )) != INVALID_HANDLE_VALUE32)
{
- FILE_SetDosError();
- FILE_Close( file );
- return HFILE_ERROR;
+ if ((file->unix_handle = dup(fd)) == -1)
+ {
+ FILE_SetDosError();
+ CloseHandle( handle );
+ return INVALID_HANDLE_VALUE32;
+ }
}
- if ((handle = FILE_AllocTaskHandle( file )) == HFILE_ERROR)
- FILE_Close( file );
return handle;
}
@@ -311,12 +201,15 @@
/***********************************************************************
* FILE_OpenUnixFile
*/
-static DOS_FILE *FILE_OpenUnixFile( const char *name, int mode )
+static HFILE32 FILE_OpenUnixFile( const char *name, int mode )
{
+ HFILE32 handle;
DOS_FILE *file;
struct stat st;
- if (!(file = FILE_Alloc())) return NULL;
+ if ((handle = FILE_Alloc( &file )) == INVALID_HANDLE_VALUE32)
+ return INVALID_HANDLE_VALUE32;
+
if ((file->unix_handle = open( name, mode, 0666 )) == -1)
{
if (Options.allowReadOnly && (mode == O_RDWR))
@@ -328,32 +221,29 @@
if ((file->unix_handle == -1) || (fstat( file->unix_handle, &st ) == -1))
{
FILE_SetDosError();
- FILE_Close( file );
- return NULL;
+ CloseHandle( handle );
+ return INVALID_HANDLE_VALUE32;
}
if (S_ISDIR(st.st_mode))
{
DOS_ERROR( ER_AccessDenied, EC_AccessDenied, SA_Abort, EL_Disk );
- FILE_Close( file );
- return NULL;
+ CloseHandle( handle );
+ return INVALID_HANDLE_VALUE32;
}
/* File opened OK, now fill the DOS_FILE */
- file->unix_name = xstrdup( name );
- DOSFS_ToDosDateTime( st.st_mtime, &file->filedate, &file->filetime );
- return file;
+ file->unix_name = HEAP_strdupA( SystemHeap, 0, name );
+ return handle;
}
/***********************************************************************
* FILE_Open
*/
-HFILE FILE_Open( LPCSTR path, INT32 mode )
+HFILE32 FILE_Open( LPCSTR path, INT32 mode )
{
const char *unixName;
- DOS_FILE *file;
- HFILE handle;
dprintf_file(stddeb, "FILE_Open: '%s' %04x\n", path, mode );
if ((unixName = DOSFS_IsDevice( path )) != NULL)
@@ -363,25 +253,23 @@
{
dprintf_file(stddeb, "FILE_Open: Non-existing device\n");
DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
- return HFILE_ERROR;
+ return HFILE_ERROR32;
}
}
else /* check for filename, don't check for last entry if creating */
if (!(unixName = DOSFS_GetUnixFileName( path, !(mode & O_CREAT) )))
- return HFILE_ERROR;
+ return HFILE_ERROR32;
- if (!(file = FILE_OpenUnixFile( unixName, mode ))) return HFILE_ERROR;
- if ((handle = FILE_AllocTaskHandle( file )) == HFILE_ERROR)
- FILE_Close( file );
- return handle;
+ return FILE_OpenUnixFile( unixName, mode );
}
/***********************************************************************
* FILE_Create
*/
-static DOS_FILE *FILE_Create( LPCSTR path, int mode, int unique )
+static HFILE32 FILE_Create( LPCSTR path, int mode, int unique )
{
+ HFILE32 handle;
DOS_FILE *file;
const char *unixName;
@@ -391,104 +279,155 @@
{
dprintf_file(stddeb, "FILE_Create: creating device '%s'!\n", unixName);
DOS_ERROR( ER_AccessDenied, EC_NotFound, SA_Abort, EL_Disk );
- return NULL;
+ return INVALID_HANDLE_VALUE32;
}
- if (!(file = FILE_Alloc())) return NULL;
+ if ((handle = FILE_Alloc( &file )) == INVALID_HANDLE_VALUE32)
+ return INVALID_HANDLE_VALUE32;
if (!(unixName = DOSFS_GetUnixFileName( path, FALSE )))
{
- FILE_Close( file );
- return NULL;
+ CloseHandle( handle );
+ return INVALID_HANDLE_VALUE32;
}
if ((file->unix_handle = open( unixName,
O_CREAT | O_TRUNC | O_RDWR | (unique ? O_EXCL : 0),
mode )) == -1)
{
FILE_SetDosError();
- FILE_Close( file );
- return NULL;
+ CloseHandle( handle );
+ return INVALID_HANDLE_VALUE32;
}
/* File created OK, now fill the DOS_FILE */
- file->unix_name = xstrdup( unixName );
- DOSFS_ToDosDateTime( time(NULL), &file->filedate, &file->filetime );
- return file;
+ file->unix_name = HEAP_strdupA( SystemHeap, 0, unixName );
+ return handle;
+}
+
+
+/***********************************************************************
+ * FILE_FillInfo
+ *
+ * Fill a file information from a struct stat.
+ */
+static void FILE_FillInfo( struct stat *st, BY_HANDLE_FILE_INFORMATION *info )
+{
+ info->dwFileAttributes = FILE_ATTRIBUTE_ARCHIVE;
+ if (S_ISDIR(st->st_mode))
+ info->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+
+ DOSFS_UnixTimeToFileTime( st->st_mtime, &info->ftCreationTime );
+ DOSFS_UnixTimeToFileTime( st->st_mtime, &info->ftLastWriteTime );
+ DOSFS_UnixTimeToFileTime( st->st_atime, &info->ftLastAccessTime );
+
+ info->dwVolumeSerialNumber = 0; /* FIXME */
+ info->nFileSizeHigh = 0;
+ info->nFileSizeLow = S_ISDIR(st->st_mode) ? 0 : st->st_size;
+ info->nNumberOfLinks = st->st_nlink;
+ info->nFileIndexHigh = 0;
+ info->nFileIndexLow = st->st_ino;
}
/***********************************************************************
* FILE_Stat
*
- * Stat a Unix path name. Return 1 if OK.
+ * Stat a Unix path name. Return TRUE if OK.
*/
-int FILE_Stat( LPCSTR unixName, BYTE *pattr, DWORD *psize,
- WORD *pdate, WORD *ptime )
+BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info )
{
struct stat st;
if (stat( unixName, &st ) == -1)
{
FILE_SetDosError();
- return 0;
+ return FALSE;
}
- if (pattr) *pattr = FA_ARCHIVE | (S_ISDIR(st.st_mode) ? FA_DIRECTORY : 0);
- if (psize) *psize = S_ISDIR(st.st_mode) ? 0 : st.st_size;
- DOSFS_ToDosDateTime( st.st_mtime, pdate, ptime );
- return 1;
+ FILE_FillInfo( &st, info );
+ return TRUE;
}
/***********************************************************************
- * FILE_GetDateTime
- *
- * Get the date and time of a file.
+ * GetFileInformationByHandle (KERNEL32.219)
*/
-int FILE_GetDateTime( HFILE hFile, WORD *pdate, WORD *ptime, BOOL32 refresh )
+DWORD GetFileInformationByHandle( HFILE32 hFile,
+ BY_HANDLE_FILE_INFORMATION *info )
{
DOS_FILE *file;
+ DWORD ret = 0;
+ struct stat st;
if (!(file = FILE_GetFile( hFile ))) return 0;
- if (refresh)
+ if (fstat( file->unix_handle, &st ) == -1) FILE_SetDosError();
+ else
{
- struct stat st;
- if (fstat( file->unix_handle, &st ) == -1)
- {
- FILE_SetDosError();
- return 0;
- }
- DOSFS_ToDosDateTime( st.st_mtime, &file->filedate, &file->filetime );
+ FILE_FillInfo( &st, info );
+ ret = 1;
}
- *pdate = file->filedate;
- *ptime = file->filetime;
- return 1;
+ FILE_ReleaseFile( file );
+ return ret;
+}
+
+
+/**************************************************************************
+ * GetFileAttributes16 (KERNEL.420)
+ */
+DWORD GetFileAttributes16( LPCSTR name )
+{
+ return GetFileAttributes32A( name );
+}
+
+
+/**************************************************************************
+ * GetFileAttributes32A (KERNEL32.217)
+ */
+DWORD GetFileAttributes32A( LPCSTR name )
+{
+ BY_HANDLE_FILE_INFORMATION info;
+
+ if (!FILE_Stat( name, &info )) return -1;
+ return info.dwFileAttributes;
+}
+
+
+/**************************************************************************
+ * GetFileAttributes32W (KERNEL32.218)
+ */
+DWORD GetFileAttributes32W( LPCWSTR name )
+{
+ LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, name );
+ DWORD res = GetFileAttributes32A( nameA );
+ HeapFree( GetProcessHeap(), 0, nameA );
+ return res;
}
/***********************************************************************
- * FILE_SetDateTime
- *
- * Set the date and time of a file.
+ * GetFileSize (KERNEL32.220)
*/
-int FILE_SetDateTime( HFILE hFile, WORD date, WORD time )
+DWORD GetFileSize( HFILE32 hFile, LPDWORD filesizehigh )
{
- DOS_FILE *file;
- struct tm newtm;
- struct utimbuf filetime;
+ BY_HANDLE_FILE_INFORMATION info;
+ if (!GetFileInformationByHandle( hFile, &info )) return 0;
+ if (filesizehigh) *filesizehigh = info.nFileSizeHigh;
+ return info.nFileSizeLow;
+}
- if (!(file = FILE_GetFile( hFile ))) return 0;
- newtm.tm_sec = (time & 0x1f) * 2;
- newtm.tm_min = (time >> 5) & 0x3f;
- newtm.tm_hour = (time >> 11);
- newtm.tm_mday = (date & 0x1f);
- newtm.tm_mon = ((date >> 5) & 0x0f) - 1;
- newtm.tm_year = (date >> 9) + 80;
- filetime.actime = filetime.modtime = mktime( &newtm );
- if (utime( file->unix_name, &filetime ) != -1) return 1;
- FILE_SetDosError();
- return 0;
+/***********************************************************************
+ * GetFileTime (KERNEL32.221)
+ */
+BOOL32 GetFileTime( HFILE32 hFile, FILETIME *lpCreationTime,
+ FILETIME *lpLastAccessTime, FILETIME *lpLastWriteTime )
+{
+ BY_HANDLE_FILE_INFORMATION info;
+ if (!GetFileInformationByHandle( hFile, &info )) return FALSE;
+ if (lpCreationTime) *lpCreationTime = info.ftCreationTime;
+ if (lpLastAccessTime) *lpLastAccessTime = info.ftLastAccessTime;
+ if (lpLastWriteTime) *lpLastWriteTime = info.ftLastWriteTime;
+ return TRUE;
}
@@ -497,14 +436,15 @@
*
* dup() function for DOS handles.
*/
-HFILE FILE_Dup( HFILE hFile )
+HFILE32 FILE_Dup( HFILE32 hFile )
{
DOS_FILE *file;
- HFILE handle;
+ HFILE32 handle;
dprintf_file( stddeb, "FILE_Dup for handle %d\n", hFile );
- if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR;
- if ((handle = FILE_AllocTaskHandle( file )) != HFILE_ERROR) file->count++;
+ if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR32;
+ handle = PROCESS_AllocHandle( &file->header, 0 );
+ FILE_ReleaseFile( file );
dprintf_file( stddeb, "FILE_Dup return handle %d\n", handle );
return handle;
}
@@ -515,29 +455,14 @@
*
* dup2() function for DOS handles.
*/
-HFILE FILE_Dup2( HFILE hFile1, HFILE hFile2 )
+HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 )
{
DOS_FILE *file;
- PDB *pdb = (PDB *)GlobalLock16( GetCurrentPDB() );
- BYTE *files = PTR_SEG_TO_LIN( pdb->fileHandlesPtr );
dprintf_file( stddeb, "FILE_Dup2 for handle %d\n", hFile1 );
- if (!(file = FILE_GetFile( hFile1 ))) return HFILE_ERROR;
-
- if ((hFile2 < 0) || (hFile2 >= (INT)pdb->nbFiles))
- {
- DOS_ERROR( ER_InvalidHandle, EC_ProgramError, SA_Abort, EL_Disk );
- return HFILE_ERROR;
- }
- if (files[hFile2] < MAX_OPEN_FILES)
- {
- dprintf_file( stddeb, "FILE_Dup2 closing old handle2 %d\n",
- files[hFile2] );
- FILE_Close( &DOSFiles[files[hFile2]] );
- }
- files[hFile2] = (BYTE)(file - DOSFiles);
- file->count++;
- dprintf_file( stddeb, "FILE_Dup2 return handle2 %d\n", hFile2 );
+ if (!(file = FILE_GetFile( hFile1 ))) return HFILE_ERROR32;
+ if (!PROCESS_SetObjPtr( hFile2, &file->header, 0 )) hFile2 = HFILE_ERROR32;
+ FILE_ReleaseFile( file );
return hFile2;
}
@@ -599,11 +524,11 @@
do
{
- DOS_FILE *file;
- if ((file = FILE_Create( buffer, 0666, TRUE )) != NULL)
+ HFILE32 handle;
+ if ((handle = FILE_Create(buffer,0666,TRUE)) != INVALID_HANDLE_VALUE32)
{ /* We created it */
dprintf_file( stddeb, "GetTempFileName: created %s\n", buffer );
- FILE_Close( file );
+ CloseHandle( handle );
break;
}
if (DOS_ExtendedError != ER_FileExists) break; /* No need to go on */
@@ -641,31 +566,25 @@
/***********************************************************************
- * OpenFile (KERNEL.74) (KERNEL32.396)
+ * FILE_DoOpenFile
+ *
+ * Implementation of OpenFile16() and OpenFile32().
*/
-HFILE OpenFile( LPCSTR name, OFSTRUCT *ofs, UINT32 mode )
+static HFILE32 FILE_DoOpenFile( LPCSTR name, OFSTRUCT *ofs, UINT32 mode,
+ BOOL32 win32 )
{
- DOS_FILE *file;
- HFILE hFileRet;
+ HFILE32 hFileRet;
+ FILETIME filetime;
WORD filedatetime[2];
const char *unixName, *dosName;
char *p;
- int len, i, unixMode;
+ int unixMode;
ofs->cBytes = sizeof(OFSTRUCT);
ofs->nErrCode = 0;
if (mode & OF_REOPEN) name = ofs->szPathName;
dprintf_file( stddeb, "OpenFile: %s %04x\n", name, mode );
- /* First allocate a task handle */
-
- if ((hFileRet = FILE_AllocTaskHandle( NULL )) == HFILE_ERROR)
- {
- ofs->nErrCode = DOS_ExtendedError;
- dprintf_file( stddeb, "OpenFile: no more task handles.\n" );
- return HFILE_ERROR;
- }
-
/* OF_PARSE simply fills the structure */
if (mode & OF_PARSE)
@@ -673,12 +592,9 @@
if (!(dosName = DOSFS_GetDosTrueName( name, FALSE ))) goto error;
lstrcpyn32A( ofs->szPathName, dosName, sizeof(ofs->szPathName) );
ofs->fFixedDisk = (GetDriveType16( dosName[0]-'A' ) != DRIVE_REMOVABLE);
- dprintf_file( stddeb, "OpenFile(%s): OF_PARSE, res = '%s', %d\n",
- name, ofs->szPathName, hFileRet );
- /* Return the handle, but close it first */
- FILE_FreeTaskHandle( hFileRet );
-/* return hFileRet; */
- return 0; /* Progman seems to like this better */
+ dprintf_file( stddeb, "OpenFile(%s): OF_PARSE, res = '%s'\n",
+ name, ofs->szPathName );
+ return 0;
}
/* OF_CREATE is completely different from all other options, so
@@ -686,76 +602,37 @@
if (mode & OF_CREATE)
{
- if (!(file = FILE_Create( name, 0666, FALSE ))) goto error;
+ if ((hFileRet = FILE_Create(name,0666,FALSE))== INVALID_HANDLE_VALUE32)
+ goto error;
lstrcpyn32A( ofs->szPathName, DOSFS_GetDosTrueName( name, FALSE ),
sizeof(ofs->szPathName) );
goto success;
}
- /* Now look for the file */
-
- /* First try the current directory */
-
- lstrcpyn32A( ofs->szPathName, name, sizeof(ofs->szPathName) );
- if ((unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE )) != NULL)
- goto found;
-
- /* Now try some different paths if none was specified */
+ /* If OF_SEARCH is set, ignore the given path */
if ((mode & OF_SEARCH) && !(mode & OF_REOPEN))
{
- if (name[1] == ':') name += 2;
+ /* First try the file name as is */
+ if ((unixName = DOSFS_GetUnixFileName( name, TRUE )) != NULL)
+ {
+ lstrcpyn32A( ofs->szPathName, name, sizeof(ofs->szPathName) );
+ goto found;
+ }
+ /* Now remove the path */
+ if (name[0] && (name[1] == ':')) name += 2;
if ((p = strrchr( name, '\\' ))) name = p + 1;
if ((p = strrchr( name, '/' ))) name = p + 1;
if (!name[0]) goto not_found;
}
- else
- {
- if ((name[1] == ':') || strchr( name, '/' ) || strchr( name, '\\' ))
- goto not_found;
- }
- if ((len = sizeof(ofs->szPathName) - strlen(name) - 1) < 0) goto not_found;
+ /* Now look for the file */
- /* Try the Windows directory */
-
- GetWindowsDirectory32A( ofs->szPathName, len );
- strcat( ofs->szPathName, "\\" );
- strcat( ofs->szPathName, name );
- if ((unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE )) != NULL)
- goto found;
-
- /* Try the Windows system directory */
-
- GetSystemDirectory32A( ofs->szPathName, len );
- strcat( ofs->szPathName, "\\" );
- strcat( ofs->szPathName, name );
- if ((unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE )) != NULL)
- goto found;
-
- /* Try the path of the current executable */
-
- if (GetCurrentTask())
- {
- GetModuleFileName16( GetCurrentTask(), ofs->szPathName, len );
- if ((p = strrchr( ofs->szPathName, '\\' )))
- {
- strcpy( p + 1, name );
- if ((unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE )))
- goto found;
- }
- }
-
- /* Try all directories in path */
-
- for (i = 0; ; i++)
- {
- if (!DIR_GetDosPath( i, ofs->szPathName, len )) goto not_found;
- strcat( ofs->szPathName, "\\" );
- strcat( ofs->szPathName, name );
- if ((unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE)) != NULL)
- break;
- }
+ if (!DIR_SearchPath( NULL, name, NULL, sizeof(ofs->szPathName),
+ ofs->szPathName, NULL, win32 ))
+ goto not_found;
+ if (!(unixName = DOSFS_GetUnixFileName( ofs->szPathName, TRUE )))
+ goto not_found;
found:
dprintf_file( stddeb, "OpenFile: found '%s'\n", unixName );
@@ -766,9 +643,7 @@
{
if (unlink( unixName ) == -1) goto not_found;
dprintf_file( stddeb, "OpenFile(%s): OF_DELETE return = OK\n", name);
- /* Return the handle, but close it first */
- FILE_FreeTaskHandle( hFileRet );
- return hFileRet;
+ return 1;
}
switch(mode & 3)
@@ -782,14 +657,15 @@
unixMode = O_RDONLY; break;
}
- if (!(file = FILE_OpenUnixFile( unixName, unixMode ))) goto not_found;
- filedatetime[0] = file->filedate;
- filedatetime[1] = file->filetime;
+ if ((hFileRet = FILE_OpenUnixFile( unixName, unixMode )) == HFILE_ERROR32)
+ goto not_found;
+ GetFileTime( hFileRet, NULL, NULL, &filetime );
+ FileTimeToDosDateTime( &filetime, &filedatetime[0], &filedatetime[1] );
if ((mode & OF_VERIFY) && (mode & OF_REOPEN))
{
if (memcmp( ofs->reserved, filedatetime, sizeof(ofs->reserved) ))
{
- FILE_Close( file );
+ CloseHandle( hFileRet );
dprintf_file( stddeb, "OpenFile(%s): OF_VERIFY failed\n", name );
/* FIXME: what error here? */
DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
@@ -798,17 +674,10 @@
}
memcpy( ofs->reserved, filedatetime, sizeof(ofs->reserved) );
- if (mode & OF_EXIST)
- {
- FILE_Close( file );
- /* Return the handle, but close it first */
- FILE_FreeTaskHandle( hFileRet );
- return hFileRet;
- }
-
success: /* We get here if the open was successful */
dprintf_file( stddeb, "OpenFile(%s): OK, return = %d\n", name, hFileRet );
- FILE_SetTaskHandle( hFileRet, file );
+ if (mode & OF_EXIST) /* Return the handle, but close it first */
+ CloseHandle( hFileRet );
return hFileRet;
not_found: /* We get here if the file does not exist */
@@ -819,151 +688,52 @@
error: /* We get here if there was an error opening the file */
ofs->nErrCode = DOS_ExtendedError;
dprintf_file( stddeb, "OpenFile(%s): return = HFILE_ERROR\n", name );
- FILE_FreeTaskHandle( hFileRet );
- return HFILE_ERROR;
+ return HFILE_ERROR32;
}
-/***********************************************************************
- * SearchPath32A (KERNEL32.447)
- * Code borrowed from OpenFile above.
- */
-DWORD SearchPath32A(
- LPCSTR path,LPCSTR fn,LPCSTR ext,DWORD buflen,LPSTR buf,LPSTR *lastpart
-) {
- LPCSTR unixName;
- INT32 len;
- char testpath[1000]; /* should be enough for now */
- char *name,*p;
- int i;
-
- if (ext==NULL)
- ext = "";
- name=(char*)xmalloc(strlen(fn)+strlen(ext)+1);
- strcpy(name,fn);
- strcat(name,ext);
-
- dprintf_file(stddeb,"SearchPath32A(%s,%s,%s,%ld,%p,%p)\n",
- path,fn,ext,buflen,buf,lastpart
- );
- if (path) {
- strcpy(testpath,path);
- strcat(testpath,"\\");
- strcat(testpath,name);
- if ((unixName=DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE))!=NULL) {
- goto found;
- } else {
- strcpy(testpath,name);
- if ((unixName=DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE))!=NULL)
- goto found;
- return 0;
- }
- }
- if ((len=sizeof(testpath)-strlen(name)-1)<0)
- return 0;
-
- /* Try the path of the current executable */
- if (GetCurrentTask()) {
- GetModuleFileName16(GetCurrentTask(),testpath,len);
- if ((p=strrchr(testpath,'\\'))) {
- strcpy(p+1,name);
- if ((unixName=DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE)))
- goto found;
- }
- }
-
- /* Try the current directory */
- lstrcpyn32A(testpath,name,sizeof(testpath) );
- if ((unixName=DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE))!=NULL)
- goto found;
-
- /* Try the Windows directory */
- GetWindowsDirectory32A(testpath,len);
- strcat(testpath,"\\");
- strcat(testpath,name);
- if ((unixName = DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE))!=NULL)
- goto found;
-
- /* Try the Windows system directory */
- GetSystemDirectory32A(testpath,len);
- strcat(testpath,"\\");
- strcat(testpath,name);
- if ((unixName=DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE))!=NULL)
- goto found;
-
- /* Try all directories in path */
-
- for (i=0;;i++)
- {
- if (!DIR_GetDosPath(i,testpath,len))
- return 0;
- strcat(testpath,"\\");
- strcat(testpath,name);
- if ((unixName=DOSFS_GetUnixFileName((LPCSTR)testpath,TRUE))!=NULL)
- break;
- }
-
-found:
- strncpy(buf,testpath,buflen);
- if (NULL!=(p=strrchr(testpath,'\\')))
- p=p+1;
- else
- p=testpath;
- if (lastpart) {
- if (p-testpath<buflen)
- *lastpart=(p-testpath)+buf;
- else
- *lastpart=NULL;
- }
- dprintf_file(stddeb," -> found %s,last part is %s\n",testpath,p);
- return strlen(testpath);
-}
/***********************************************************************
- * SearchPath32W (KERNEL32.448)
+ * OpenFile16 (KERNEL.74)
*/
-DWORD SearchPath32W( LPCWSTR path, LPCWSTR fn, LPCWSTR ext, DWORD buflen,
- LPWSTR buf, LPWSTR *lastpart )
+HFILE16 OpenFile16( LPCSTR name, OFSTRUCT *ofs, UINT16 mode )
{
- LPSTR pathA = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
- LPSTR fnA = HEAP_strdupWtoA( GetProcessHeap(), 0, fn );
- LPSTR extA = HEAP_strdupWtoA( GetProcessHeap(), 0, ext );
- LPSTR lastpartA;
- LPSTR bufA = HeapAlloc( GetProcessHeap(), 0, buflen + 1 );
- DWORD ret;
-
- ret = SearchPath32A(pathA,fnA,extA,buflen,bufA,&lastpartA);
- lstrcpyAtoW( buf, bufA );
- if (lastpart)
- {
- if (lastpartA) *lastpart = buf+(lastpartA-bufA);
- else *lastpart = NULL;
- }
- HeapFree( GetProcessHeap(), 0, bufA );
- HeapFree( GetProcessHeap(), 0, fnA );
- HeapFree( GetProcessHeap(), 0, pathA );
- HeapFree( GetProcessHeap(), 0, extA );
- return ret;
+ return FILE_DoOpenFile( name, ofs, mode, FALSE );
}
-/***********************************************************************
- * _lclose (KERNEL.81) (KERNEL32.592)
- */
-HFILE _lclose( HFILE hFile )
-{
- DOS_FILE *file;
+/***********************************************************************
+ * OpenFile32 (KERNEL32.396)
+ */
+HFILE32 OpenFile32( LPCSTR name, OFSTRUCT *ofs, UINT32 mode )
+{
+ return FILE_DoOpenFile( name, ofs, mode, TRUE );
+}
+
+
+/***********************************************************************
+ * _lclose16 (KERNEL.81)
+ */
+HFILE16 _lclose16( HFILE16 hFile )
+{
dprintf_file( stddeb, "_lclose: handle %d\n", hFile );
- if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR;
- FILE_Close( file );
- FILE_FreeTaskHandle( hFile );
- return 0;
+ return CloseHandle( hFile ) ? 0 : HFILE_ERROR16;
+}
+
+
+/***********************************************************************
+ * _lclose32 (KERNEL32.592)
+ */
+HFILE32 _lclose32( HFILE32 hFile )
+{
+ dprintf_file( stddeb, "_lclose: handle %d\n", hFile );
+ return CloseHandle( hFile ) ? 0 : HFILE_ERROR32;
}
/***********************************************************************
* WIN16_hread
*/
-LONG WIN16_hread( HFILE hFile, SEGPTR buffer, LONG count )
+LONG WIN16_hread( HFILE16 hFile, SEGPTR buffer, LONG count )
{
LONG maxlen;
@@ -980,7 +750,7 @@
/***********************************************************************
* WIN16_lread
*/
-UINT16 WIN16_lread( HFILE hFile, SEGPTR buffer, UINT16 count )
+UINT16 WIN16_lread( HFILE16 hFile, SEGPTR buffer, UINT16 count )
{
return (UINT16)WIN16_hread( hFile, buffer, (LONG)count );
}
@@ -989,16 +759,17 @@
/***********************************************************************
* _lread32 (KERNEL32.596)
*/
-UINT32 _lread32( HFILE hFile, LPVOID buffer, UINT32 count )
+UINT32 _lread32( HFILE32 hFile, LPVOID buffer, UINT32 count )
{
DOS_FILE *file;
UINT32 result;
dprintf_file( stddeb, "_lread32: %d %p %d\n", hFile, buffer, count );
if (!(file = FILE_GetFile( hFile ))) return -1;
- if (!count) return 0;
- if ((result = read( file->unix_handle, buffer, count )) == -1)
+ if (!count) result = 0;
+ else if ((result = read( file->unix_handle, buffer, count )) == -1)
FILE_SetDosError();
+ FILE_ReleaseFile( file );
return result;
}
@@ -1006,52 +777,58 @@
/***********************************************************************
* _lread16 (KERNEL.82)
*/
-UINT16 _lread16( HFILE hFile, LPVOID buffer, UINT16 count )
+UINT16 _lread16( HFILE16 hFile, LPVOID buffer, UINT16 count )
{
return (UINT16)_lread32( hFile, buffer, (LONG)count );
}
/***********************************************************************
- * _lcreat (KERNEL.83) (KERNEL32.593)
+ * _lcreat16 (KERNEL.83)
*/
-HFILE _lcreat( LPCSTR path, INT32 attr )
+HFILE16 _lcreat16( LPCSTR path, INT16 attr )
{
- DOS_FILE *file;
- HFILE handle;
- int mode;
-
- dprintf_file( stddeb, "_lcreat: %s %02x\n", path, attr );
- mode = (attr & 1) ? 0444 : 0666;
- if (!(file = FILE_Create( path, mode, FALSE ))) return HFILE_ERROR;
- if ((handle = FILE_AllocTaskHandle( file )) == HFILE_ERROR)
- FILE_Close( file );
- return handle;
+ int mode = (attr & 1) ? 0444 : 0666;
+ dprintf_file( stddeb, "_lcreat16: %s %02x\n", path, attr );
+ return (HFILE16)FILE_Create( path, mode, FALSE );
+}
+
+
+/***********************************************************************
+ * _lcreat32 (KERNEL32.593)
+ */
+HFILE32 _lcreat32( LPCSTR path, INT32 attr )
+{
+ int mode = (attr & 1) ? 0444 : 0666;
+ dprintf_file( stddeb, "_lcreat32: %s %02x\n", path, attr );
+ return FILE_Create( path, mode, FALSE );
}
/***********************************************************************
* _lcreat_uniq (Not a Windows API)
*/
-HFILE _lcreat_uniq( LPCSTR path, INT32 attr )
+HFILE32 _lcreat_uniq( LPCSTR path, INT32 attr )
{
- DOS_FILE *file;
- HFILE handle;
- int mode;
-
+ int mode = (attr & 1) ? 0444 : 0666;
dprintf_file( stddeb, "_lcreat: %s %02x\n", path, attr );
- mode = (attr & 1) ? 0444 : 0666;
- if (!(file = FILE_Create( path, mode, TRUE ))) return HFILE_ERROR;
- if ((handle = FILE_AllocTaskHandle( file )) == HFILE_ERROR)
- FILE_Close( file );
- return handle;
+ return FILE_Create( path, mode, TRUE );
}
/***********************************************************************
- * _llseek (KERNEL.84) (KERNEL32.594)
+ * _llseek16 (KERNEL.84)
*/
-LONG _llseek( HFILE hFile, LONG lOffset, INT32 nOrigin )
+LONG _llseek16( HFILE16 hFile, LONG lOffset, INT16 nOrigin )
+{
+ return _llseek32( hFile, lOffset, nOrigin );
+}
+
+
+/***********************************************************************
+ * _llseek32 (KERNEL32.594)
+ */
+LONG _llseek32( HFILE32 hFile, LONG lOffset, INT32 nOrigin )
{
DOS_FILE *file;
int origin, result;
@@ -1059,7 +836,7 @@
dprintf_file( stddeb, "_llseek: handle %d, offset %ld, origin %d\n",
hFile, lOffset, nOrigin);
- if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR;
+ if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR32;
switch(nOrigin)
{
case 1: origin = SEEK_CUR; break;
@@ -1069,14 +846,24 @@
if ((result = lseek( file->unix_handle, lOffset, origin )) == -1)
FILE_SetDosError();
+ FILE_ReleaseFile( file );
return result;
}
/***********************************************************************
- * _lopen (KERNEL.85) (KERNEL32.595)
+ * _lopen16 (KERNEL.85)
*/
-HFILE _lopen( LPCSTR path, INT32 mode )
+HFILE16 _lopen16( LPCSTR path, INT16 mode )
+{
+ return _lopen32( path, mode );
+}
+
+
+/***********************************************************************
+ * _lopen32 (KERNEL32.595)
+ */
+HFILE32 _lopen32( LPCSTR path, INT32 mode )
{
INT32 unixMode;
@@ -1102,41 +889,58 @@
/***********************************************************************
* _lwrite16 (KERNEL.86)
*/
-UINT16 _lwrite16( HFILE hFile, LPCSTR buffer, UINT16 count )
+UINT16 _lwrite16( HFILE16 hFile, LPCSTR buffer, UINT16 count )
{
- return (UINT16)_hwrite( hFile, buffer, (LONG)count );
+ return (UINT16)_hwrite32( hFile, buffer, (LONG)count );
}
/***********************************************************************
* _lwrite32 (KERNEL.86)
*/
-UINT32 _lwrite32( HFILE hFile, LPCSTR buffer, UINT32 count )
+UINT32 _lwrite32( HFILE32 hFile, LPCSTR buffer, UINT32 count )
{
- return (UINT32)_hwrite( hFile, buffer, (LONG)count );
+ return (UINT32)_hwrite32( hFile, buffer, (LONG)count );
}
/***********************************************************************
- * _hread (KERNEL.349)
+ * _hread16 (KERNEL.349)
*/
-LONG _hread( HFILE hFile, LPVOID buffer, LONG count)
+LONG _hread16( HFILE16 hFile, LPVOID buffer, LONG count)
{
return _lread32( hFile, buffer, count );
}
/***********************************************************************
- * _hwrite (KERNEL.350)
+ * _hread32 (KERNEL32.590)
*/
-LONG _hwrite( HFILE hFile, LPCSTR buffer, LONG count )
+LONG _hread32( HFILE32 hFile, LPVOID buffer, LONG count)
+{
+ return _lread32( hFile, buffer, count );
+}
+
+
+/***********************************************************************
+ * _hwrite16 (KERNEL.350)
+ */
+LONG _hwrite16( HFILE16 hFile, LPCSTR buffer, LONG count )
+{
+ return _hwrite32( hFile, buffer, count );
+}
+
+
+/***********************************************************************
+ * _hwrite32 (KERNEL32.591)
+ */
+LONG _hwrite32( HFILE32 hFile, LPCSTR buffer, LONG count )
{
DOS_FILE *file;
LONG result;
dprintf_file( stddeb, "_hwrite: %d %p %ld\n", hFile, buffer, count );
- if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR;
-
+ if (!(file = FILE_GetFile( hFile ))) return HFILE_ERROR32;
if (count == 0) /* Expand or truncate at current position */
result = ftruncate( file->unix_handle,
lseek( file->unix_handle, 0, SEEK_CUR ) );
@@ -1144,6 +948,7 @@
result = write( file->unix_handle, buffer, count );
if (result == -1) FILE_SetDosError();
+ FILE_ReleaseFile( file );
return result;
}
@@ -1225,18 +1030,54 @@
}
+/*************************************************************************
+ * SetHandleCount32 (KERNEL32.494)
+ */
+UINT32 SetHandleCount32( UINT32 count )
+{
+ return MIN( 256, count );
+}
+
+
/***********************************************************************
* FlushFileBuffers (KERNEL32.133)
*/
-BOOL32 FlushFileBuffers( HFILE hFile )
+BOOL32 FlushFileBuffers( HFILE32 hFile )
{
DOS_FILE *file;
+ BOOL32 ret;
dprintf_file( stddeb, "FlushFileBuffers(%d)\n", hFile );
if (!(file = FILE_GetFile( hFile ))) return FALSE;
- if (fsync( file->unix_handle ) != -1) return TRUE;
- FILE_SetDosError();
- return FALSE;
+ if (fsync( file->unix_handle ) != -1) ret = TRUE;
+ else
+ {
+ FILE_SetDosError();
+ ret = FALSE;
+ }
+ FILE_ReleaseFile( file );
+ return ret;
+}
+
+
+/**************************************************************************
+ * SetEndOfFile (KERNEL32.483)
+ */
+BOOL32 SetEndOfFile( HFILE32 hFile )
+{
+ DOS_FILE *file;
+ BOOL32 ret = TRUE;
+
+ dprintf_file( stddeb, "SetEndOfFile(%d)\n", hFile );
+ if (!(file = FILE_GetFile( hFile ))) return FALSE;
+ if (ftruncate( file->unix_handle,
+ lseek( file->unix_handle, 0, SEEK_CUR ) ))
+ {
+ FILE_SetDosError();
+ ret = FALSE;
+ }
+ FILE_ReleaseFile( file );
+ return ret;
}
@@ -1288,122 +1129,14 @@
/***********************************************************************
- * CreateDirectory16 (KERNEL.144)
- */
-BOOL16 CreateDirectory16( LPCSTR path, LPVOID dummy )
-{
- dprintf_file( stddeb,"CreateDirectory16(%s,%p)\n", path, dummy );
- return (BOOL16)CreateDirectory32A( path, NULL );
-}
-
-
-/***********************************************************************
- * CreateDirectory32A (KERNEL32.39)
- */
-BOOL32 CreateDirectory32A( LPCSTR path, LPSECURITY_ATTRIBUTES lpsecattribs )
-{
- const char *unixName;
-
- dprintf_file( stddeb, "CreateDirectory32A(%s,%p)\n", path, lpsecattribs );
- if ((unixName = DOSFS_IsDevice( path )) != NULL)
- {
- dprintf_file(stddeb, "CreateDirectory: device '%s'!\n", unixName);
- DOS_ERROR( ER_AccessDenied, EC_AccessDenied, SA_Abort, EL_Disk );
- return FALSE;
- }
- if (!(unixName = DOSFS_GetUnixFileName( path, FALSE ))) return 0;
- if ((mkdir( unixName, 0777 ) == -1) && (errno != EEXIST))
- {
- FILE_SetDosError();
- return FALSE;
- }
- return TRUE;
-}
-
-
-/***********************************************************************
- * CreateDirectory32W (KERNEL32.42)
- */
-BOOL32 CreateDirectory32W( LPCWSTR path, LPSECURITY_ATTRIBUTES lpsecattribs )
-{
- LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
- BOOL32 ret = CreateDirectory32A( xpath, lpsecattribs );
- HeapFree( GetProcessHeap(), 0, xpath );
- return ret;
-}
-
-/***********************************************************************
- * CreateDirectoryEx32A (KERNEL32.40)
- */
-BOOL32 CreateDirectoryEx32A( LPCSTR template, LPCSTR path,
- LPSECURITY_ATTRIBUTES lpsecattribs)
-{
- return CreateDirectory32A(path,lpsecattribs);
-}
-
-/***********************************************************************
- * CreateDirectoryEx32W (KERNEL32.41)
- */
-BOOL32 CreateDirectoryEx32W( LPCWSTR template, LPCWSTR path,
- LPSECURITY_ATTRIBUTES lpsecattribs)
-{
- return CreateDirectory32W(path,lpsecattribs);
-}
-
-/***********************************************************************
- * RemoveDirectory16 (KERNEL)
- */
-BOOL16 RemoveDirectory16( LPCSTR path )
-{
- return (BOOL16)RemoveDirectory32A( path );
-}
-
-
-/***********************************************************************
- * RemoveDirectory32A (KERNEL32.437)
- */
-BOOL32 RemoveDirectory32A( LPCSTR path )
-{
- const char *unixName;
-
- dprintf_file(stddeb, "RemoveDirectory: '%s'\n", path );
-
- if ((unixName = DOSFS_IsDevice( path )) != NULL)
- {
- dprintf_file(stddeb, "RemoveDirectory: device '%s'!\n", unixName);
- DOS_ERROR( ER_FileNotFound, EC_NotFound, SA_Abort, EL_Disk );
- return FALSE;
- }
- if (!(unixName = DOSFS_GetUnixFileName( path, TRUE ))) return FALSE;
- if (rmdir( unixName ) == -1)
- {
- FILE_SetDosError();
- return FALSE;
- }
- return TRUE;
-}
-
-
-/***********************************************************************
- * RemoveDirectory32W (KERNEL32.438)
- */
-BOOL32 RemoveDirectory32W( LPCWSTR path )
-{
- LPSTR xpath = HEAP_strdupWtoA( GetProcessHeap(), 0, path );
- BOOL32 ret = RemoveDirectory32A( xpath );
- HeapFree( GetProcessHeap(), 0, xpath );
- return ret;
-}
-
-
-/***********************************************************************
* FILE_SetFileType
*/
-BOOL32 FILE_SetFileType( HFILE hFile, DWORD type )
+BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type )
{
- DOS_FILE *file = FILE_GetFile(hFile);
+ DOS_FILE *file = FILE_GetFile( hFile );
if (!file) return FALSE;
file->type = type;
+ FILE_ReleaseFile( file );
return TRUE;
}
@@ -1411,65 +1144,27 @@
/***********************************************************************
* GetFileType (KERNEL32.222)
*/
-DWORD GetFileType( HFILE hFile )
+DWORD GetFileType( HFILE32 hFile )
{
DOS_FILE *file = FILE_GetFile(hFile);
-
- if (!file)
- {
- SetLastError( ERROR_INVALID_HANDLE );
- return FILE_TYPE_UNKNOWN; /* FIXME: correct? */
- }
+ if (!file) return FILE_TYPE_UNKNOWN; /* FIXME: correct? */
+ FILE_ReleaseFile( file );
return file->type;
}
/***********************************************************************
- * GetFileTime (KERNEL32.221)
- */
-BOOL32 GetFileTime( HFILE hFile, FILETIME *lpCreationTime,
- FILETIME *lpLastAccessTime, FILETIME *lpLastWriteTime )
-{
- DOS_FILE *file = FILE_GetFile(hFile);
- struct stat stbuf;
-
- if (!file) {
- SetLastError( ERROR_INVALID_HANDLE );
- return FILE_TYPE_UNKNOWN; /* FIXME: correct? */
- }
- dprintf_file(stddeb,"SetFileTime(%s,%p,%p,%p)\n",
- file->unix_name,
- lpCreationTime,
- lpLastAccessTime,
- lpLastWriteTime
- );
- if (-1==fstat(file->unix_handle,&stbuf)) {
- FILE_SetDosError();
- return FALSE;
- }
- if (lpLastWriteTime)
- DOSFS_UnixTimeToFileTime(stbuf.st_mtime,lpLastWriteTime);
- if (lpCreationTime)
- DOSFS_UnixTimeToFileTime(stbuf.st_ctime,lpCreationTime);
- if (lpLastAccessTime)
- DOSFS_UnixTimeToFileTime(stbuf.st_atime,lpLastAccessTime);
- return TRUE;
-}
-
-
-/***********************************************************************
* SetFileTime (KERNEL32.493)
*/
-BOOL32 SetFileTime( HFILE hFile, FILETIME *lpCreationTime,
- FILETIME *lpLastAccessTime, FILETIME *lpLastWriteTime )
+BOOL32 SetFileTime( HFILE32 hFile,
+ const FILETIME *lpCreationTime,
+ const FILETIME *lpLastAccessTime,
+ const FILETIME *lpLastWriteTime )
{
DOS_FILE *file = FILE_GetFile(hFile);
struct utimbuf utimbuf;
- if (!file) {
- SetLastError( ERROR_INVALID_HANDLE );
- return FILE_TYPE_UNKNOWN; /* FIXME: correct? */
- }
+ if (!file) return FILE_TYPE_UNKNOWN; /* FIXME: correct? */
dprintf_file(stddeb,"SetFileTime(%s,%p,%p,%p)\n",
file->unix_name,
lpCreationTime,
@@ -1484,9 +1179,12 @@
utimbuf.modtime = DOSFS_FileTimeToUnixTime(lpLastWriteTime);
else
utimbuf.modtime = 0; /* FIXME */
- if (-1==utime(file->unix_name,&utimbuf)) {
+ if (-1==utime(file->unix_name,&utimbuf))
+ {
+ FILE_ReleaseFile( file );
FILE_SetDosError();
return FALSE;
}
+ FILE_ReleaseFile( file );
return TRUE;
}
diff --git a/files/profile.c b/files/profile.c
index 2f08849..393fe48 100644
--- a/files/profile.c
+++ b/files/profile.c
@@ -5,7 +5,6 @@
* Copyright 1996 Alexandre Julliard
*/
-#define NO_TRANSITION_TYPES /* This file is Win32-clean */
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
@@ -14,7 +13,6 @@
#include "windows.h"
#include "dos_fs.h"
#include "heap.h"
-#include "xmalloc.h"
#include "stddebug.h"
#include "debug.h"
@@ -139,16 +137,16 @@
for ( ; section; section = next_section)
{
- if (section->name) free( section->name );
+ if (section->name) HeapFree( SystemHeap, 0, section->name );
for (key = section->key; key; key = next_key)
{
next_key = key->next;
- if (key->name) free( key->name );
- if (key->value) free( key->value );
- free( key );
+ if (key->name) HeapFree( SystemHeap, 0, key->name );
+ if (key->value) HeapFree( SystemHeap, 0, key->value );
+ HeapFree( SystemHeap, 0, key );
}
next_section = section->next;
- free( section );
+ HeapFree( SystemHeap, 0, section );
}
}
@@ -167,7 +165,7 @@
PROFILESECTION **prev_section;
PROFILEKEY *key, **prev_key;
- first_section = (PROFILESECTION *)xmalloc( sizeof(*section) );
+ first_section = HEAP_xalloc( SystemHeap, 0, sizeof(*section) );
first_section->name = NULL;
first_section->key = NULL;
first_section->next = NULL;
@@ -192,8 +190,8 @@
{
*p2 = '\0';
p++;
- section = (PROFILESECTION *)xmalloc( sizeof(*section));
- section->name = xstrdup( p );
+ section = HEAP_xalloc( SystemHeap, 0, sizeof(*section) );
+ section->name = HEAP_strdupA( SystemHeap, 0, p );
section->key = NULL;
section->next = NULL;
*prev_section = section;
@@ -209,9 +207,9 @@
*p2++ = '\0';
while (*p2 && isspace(*p2)) p2++;
}
- key = (PROFILEKEY *)xmalloc( sizeof(*key) );
- key->name = xstrdup( p );
- key->value = p2 ? xstrdup( p2 ) : NULL;
+ key = HEAP_xalloc( SystemHeap, 0, sizeof(*key) );
+ key->name = HEAP_strdupA( SystemHeap, 0, p );
+ key->value = HEAP_strdupA( SystemHeap, 0, p2 );
key->next = NULL;
*prev_key = key;
prev_key = &key->next;
@@ -268,9 +266,9 @@
{
PROFILEKEY *to_del = *key;
*key = to_del->next;
- if (to_del->name) free( to_del->name );
- if (to_del->value) free( to_del->value );
- free( to_del );
+ if (to_del->name) HeapFree( SystemHeap, 0, to_del->name );
+ if (to_del->value) HeapFree( SystemHeap, 0, to_del->value);
+ HeapFree( SystemHeap, 0, to_del );
return TRUE;
}
key = &(*key)->next;
@@ -302,8 +300,8 @@
key = &(*key)->next;
}
if (!create) return NULL;
- *key = (PROFILEKEY *)xmalloc( sizeof(PROFILEKEY) );
- (*key)->name = xstrdup( key_name );
+ *key = HEAP_xalloc( SystemHeap, 0, sizeof(PROFILEKEY) );
+ (*key)->name = HEAP_strdupA( SystemHeap, 0, key_name );
(*key)->value = NULL;
(*key)->next = NULL;
return *key;
@@ -311,11 +309,11 @@
section = &(*section)->next;
}
if (!create) return NULL;
- *section = (PROFILESECTION *)xmalloc( sizeof(PROFILESECTION) );
- (*section)->name = xstrdup(section_name);
+ *section = HEAP_xalloc( SystemHeap, 0, sizeof(PROFILESECTION) );
+ (*section)->name = HEAP_strdupA( SystemHeap, 0, section_name );
(*section)->next = NULL;
- (*section)->key = (PROFILEKEY *)xmalloc( sizeof(PROFILEKEY) );
- (*section)->key->name = xstrdup( key_name );
+ (*section)->key = HEAP_xalloc( SystemHeap, 0, sizeof(PROFILEKEY) );
+ (*section)->key->name = HEAP_strdupA( SystemHeap, 0, key_name );
(*section)->key->value = NULL;
(*section)->key->next = NULL;
return (*section)->key;
@@ -400,10 +398,10 @@
/* Flush the previous profile */
- newdos_name = xstrdup( dos_name );
+ newdos_name = HEAP_strdupA( SystemHeap, 0, dos_name );
PROFILE_FlushFile();
PROFILE_Free( CurProfile.section );
- if (CurProfile.dos_name) free( CurProfile.dos_name );
+ if (CurProfile.dos_name) HeapFree( SystemHeap, 0, CurProfile.dos_name );
CurProfile.section = NULL;
CurProfile.dos_name = newdos_name;
@@ -528,6 +526,7 @@
key_name, TRUE );
dprintf_profile( stddeb, "PROFILE_SetString('%s','%s','%s'): ",
section_name, key_name, value );
+ if (!key) return FALSE;
if (key->value)
{
if (!strcmp( key->value, value ))
@@ -536,10 +535,10 @@
return TRUE; /* No change needed */
}
dprintf_profile( stddeb, "replacing '%s'\n", key->value );
- free( key->value );
+ HeapFree( SystemHeap, 0, key->value );
}
else dprintf_profile( stddeb, "creating key\n" );
- key->value = xstrdup( value );
+ key->value = HEAP_strdupA( SystemHeap, 0, value );
CurProfile.changed = TRUE;
}
return TRUE;
diff --git a/graphics/metafiledrv/init.c b/graphics/metafiledrv/init.c
index f1d3454..93d38ca 100644
--- a/graphics/metafiledrv/init.c
+++ b/graphics/metafiledrv/init.c
@@ -144,7 +144,7 @@
{
DC *dc;
METAFILEDRV_PDEVICE *physDev;
- HFILE hFile;
+ HFILE32 hFile;
dprintf_metafile( stddeb, "CreateMetaFile16: '%s'\n", filename );
@@ -154,13 +154,13 @@
if (filename) /* disk based metafile */
{
physDev->mh->mtType = METAFILE_DISK;
- if ((hFile = _lcreat( filename, 0 )) == HFILE_ERROR)
+ if ((hFile = _lcreat32( filename, 0 )) == HFILE_ERROR32)
{
DeleteDC32( dc->hSelf );
return 0;
}
if (_lwrite32( hFile, (LPSTR)physDev->mh,
- sizeof(*physDev->mh)) == HFILE_ERROR)
+ sizeof(*physDev->mh)) == HFILE_ERROR32)
{
DeleteDC32( dc->hSelf );
return 0;
@@ -183,7 +183,7 @@
{
DC *dc;
HMETAFILE16 hmf;
- HFILE hFile;
+ HFILE32 hFile;
METAFILEDRV_PDEVICE *physDev;
dprintf_metafile( stddeb, "CloseMetaFile(%04x)\n", hdc );
@@ -205,18 +205,18 @@
{
hFile = physDev->mh->mtNoParameters;
physDev->mh->mtNoParameters = 0;
- if (_llseek(hFile, 0L, 0) == HFILE_ERROR)
+ if (_llseek32(hFile, 0L, 0) == HFILE_ERROR32)
{
DeleteDC32( hdc );
return 0;
}
if (_lwrite32( hFile, (LPSTR)physDev->mh,
- sizeof(*physDev->mh)) == HFILE_ERROR)
+ sizeof(*physDev->mh)) == HFILE_ERROR32)
{
DeleteDC32( hdc );
return 0;
}
- _lclose(hFile);
+ _lclose32(hFile);
}
/* Now allocate a global handle for the metafile */
diff --git a/graphics/wing.c b/graphics/wing.c
index 0ed174f..c3254bc 100644
--- a/graphics/wing.c
+++ b/graphics/wing.c
@@ -149,23 +149,9 @@
bmpObjPtr->bitmap.bmHeight, bmpi->biBitCount );
if( bmpObjPtr->pixmap )
{
- WORD s;
- if( (sel = AllocSelectorArray( (bytes + 0xFFFF) >> 16 )) )
- {
- DWORD base = (DWORD)p->si.shmaddr, l;
-
- SetSelectorBase( sel, base );
- SetSelectorLimit( sel, bytes );
- s = sel;
- for( l = 0x10000; l < bytes ; )
- {
- s += __AHINCR;
- SetSelectorBase( s, base + l );
- l += 0x10000;
- SetSelectorLimit( s, (l < bytes)?0xFFFF:bytes%0x10000);
- }
- p->bits = MAKELONG(0, sel);
- }
+ sel = SELECTOR_AllocBlock( p->si.shmaddr, bytes,
+ SEGMENT_DATA, FALSE, FALSE);
+ if (sel) p->bits = PTR_SEG_OFF_TO_SEGPTR(sel,0);
else XFreePixmap( display, bmpObjPtr->pixmap );
}
if( !sel )
diff --git a/if1632/Makefile.in b/if1632/Makefile.in
index 1df513d..11222e0 100644
--- a/if1632/Makefile.in
+++ b/if1632/Makefile.in
@@ -55,6 +55,7 @@
SPEC_FILES = $(DLLS:.spec=.s)
C_SRCS = \
+ builtin.c \
dummy.c \
relay.c \
thunk.c
diff --git a/loader/builtin.c b/if1632/builtin.c
similarity index 88%
rename from loader/builtin.c
rename to if1632/builtin.c
index 0a12bc6..a023ef3 100644
--- a/loader/builtin.c
+++ b/if1632/builtin.c
@@ -4,20 +4,20 @@
* Copyright 1996 Alexandre Julliard
*/
-#ifndef WINELIB
-
+#include <assert.h>
#include <ctype.h>
#include <string.h>
#include "windows.h"
#include "gdi.h"
#include "global.h"
#include "module.h"
+#include "miscemu.h"
#include "neexe.h"
+#include "stackframe.h"
#include "user.h"
#include "stddebug.h"
#include "debug.h"
-
/* Built-in modules descriptors */
/* Don't change these structures! (see tools/build.c) */
@@ -166,6 +166,8 @@
{ NULL, 0 }
};
+ /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
+#define FIRST_INTERRUPT_ORDINAL 100
/***********************************************************************
* BUILTIN_Init
@@ -176,15 +178,13 @@
{
BUILTIN_DLL *dll;
NE_MODULE *pModule;
+ WORD vector;
+ HMODULE16 hModule;
for (dll = BuiltinDLLs; dll->descr; dll++)
if (dll->flags & DLL_FLAG_ALWAYS_USED)
if (!BUILTIN_LoadModule(dll->descr->name, TRUE)) return FALSE;
- /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
-
- MODULE_SetEntryPoint( GetModuleHandle( "KERNEL" ), 178, GetWinFlags() );
-
/* Set the USER and GDI heap selectors */
pModule = MODULE_GetPtr( GetModuleHandle( "USER" ));
@@ -192,6 +192,40 @@
pModule = MODULE_GetPtr( GetModuleHandle( "GDI" ));
GDI_HeapSel = (NE_SEG_TABLE( pModule ) + pModule->dgroup - 1)->selector;
+ /* Initialize KERNEL.178 (__WINFLAGS) with the correct flags value */
+
+ hModule = GetModuleHandle( "KERNEL" );
+ MODULE_SetEntryPoint( hModule, 178, GetWinFlags() );
+
+ /* Initialize the real-mode selector entry points */
+
+#define SET_ENTRY_POINT(num,addr) \
+ MODULE_SetEntryPoint( hModule, (num), GLOBAL_CreateBlock( GMEM_FIXED, \
+ DOSMEM_dosmem+(addr), 0x10000, hModule, \
+ FALSE, FALSE, FALSE, NULL ))
+
+ SET_ENTRY_POINT( 174, 0xa0000 ); /* KERNEL.174: __A000H */
+ SET_ENTRY_POINT( 181, 0xb0000 ); /* KERNEL.181: __B000H */
+ SET_ENTRY_POINT( 182, 0xb8000 ); /* KERNEL.182: __B800H */
+ SET_ENTRY_POINT( 195, 0xc0000 ); /* KERNEL.195: __C000H */
+ SET_ENTRY_POINT( 179, 0xd0000 ); /* KERNEL.179: __D000H */
+ SET_ENTRY_POINT( 190, 0xe0000 ); /* KERNEL.190: __E000H */
+ SET_ENTRY_POINT( 173, 0xf0000 ); /* KERNEL.173: __ROMBIOS */
+ SET_ENTRY_POINT( 194, 0xf0000 ); /* KERNEL.194: __F000H */
+ MODULE_SetEntryPoint(hModule,193,DOSMEM_BiosSeg); /* KERNEL.193: __0040H */
+#undef SET_ENTRY_POINT
+
+ /* Set interrupt vectors from entry points in WPROCS.DLL */
+
+ hModule = GetModuleHandle( "WPROCS" );
+ for (vector = 0; vector < 256; vector++)
+ {
+ FARPROC16 proc = MODULE_GetEntryPoint( hModule,
+ FIRST_INTERRUPT_ORDINAL+vector);
+ assert(proc);
+ INT_SetHandler( vector, proc );
+ }
+
return TRUE;
}
@@ -416,6 +450,20 @@
}
+/**********************************************************************
+ * BUILTIN_DefaultIntHandler
+ *
+ * Default interrupt handler.
+ */
+void BUILTIN_DefaultIntHandler( CONTEXT *context )
+{
+ WORD ordinal;
+ STACK16FRAME *frame = CURRENT_STACK16;
+ BUILTIN_GetEntryPoint16( frame->entry_cs, frame->entry_ip, &ordinal );
+ INT_BARF( context, ordinal - FIRST_INTERRUPT_ORDINAL );
+}
+
+
/***********************************************************************
* BUILTIN_ParseDLLOptions
*
@@ -475,5 +523,3 @@
fprintf(stderr,"\n");
exit(1);
}
-
-#endif /* WINELIB */
diff --git a/if1632/kernel.spec b/if1632/kernel.spec
index 7d335ba..88456fd 100644
--- a/if1632/kernel.spec
+++ b/if1632/kernel.spec
@@ -70,18 +70,18 @@
71 pascal16 DeleteAtom(word) DeleteAtom
72 pascal16 GetAtomName(word ptr word) GetAtomName
73 pascal16 GetAtomHandle(word) GetAtomHandle
-74 pascal16 OpenFile(ptr ptr word) OpenFile
+74 pascal16 OpenFile(ptr ptr word) OpenFile16
75 stub OpenPathName
76 stub DeletePathName
#77 RESERVED1
#78 RESERVED2
#79 RESERVED3
#80 RESERVED4
-81 pascal16 _lclose(word) _lclose
+81 pascal16 _lclose(word) _lclose16
82 pascal16 _lread(word segptr word) WIN16_lread
-83 pascal16 _lcreat(ptr word) _lcreat
-84 pascal _llseek(word long word) _llseek
-85 pascal16 _lopen(ptr word) _lopen
+83 pascal16 _lcreat(ptr word) _lcreat16
+84 pascal _llseek(word long word) _llseek16
+85 pascal16 _lopen(ptr word) _lopen16
86 pascal16 _lwrite(word ptr word) _lwrite16
87 pascal16 RESERVED5(ptr ptr) lstrcmp16
88 pascal lstrcpy(segptr segptr) lstrcpy16
@@ -96,7 +96,7 @@
97 pascal16 GetTempFileName(byte ptr word ptr) GetTempFileName16
98 return GetLastDiskChange 0 0
99 stub GetLPErrMode
-100 stub ValidateCodeSegments
+100 return ValidateCodeSegments 0 0
101 stub NoHookDosCall
102 register DOS3Call() DOS3Call
103 register NetBIOSCall() NetBIOSCall
@@ -135,7 +135,7 @@
134 pascal16 GetWindowsDirectory(ptr word) GetWindowsDirectory16
135 pascal16 GetSystemDirectory(ptr word) GetSystemDirectory16
136 pascal16 GetDriveType(byte) GetDriveType16
-137 pascal FatalAppExit(word ptr) FatalAppExit
+137 pascal16 FatalAppExit(word ptr) FatalAppExit16
138 pascal GetHeapSpaces(word) GetHeapSpaces
139 stub DoSignal
140 pascal16 SetSigHandler(segptr ptr ptr word word) SetSigHandler
@@ -146,7 +146,7 @@
145 pascal16 RemoveDirectory(ptr) RemoveDirectory16
146 pascal16 DeleteFile(ptr) DeleteFile16
147 pascal16 SetLastError(long) SetLastError
-148 pascal16 GetLastError() GetLastError
+148 pascal GetLastError() GetLastError
149 stub GetVersionEx
150 pascal16 DirectedYield(word) DirectedYield
151 stub WinOldApCall
@@ -163,7 +163,7 @@
163 pascal16 GlobalLRUOldest(word) GlobalLRUOldest
164 pascal16 GlobalLRUNewest(word) GlobalLRUNewest
165 return A20Proc 2 0
-166 pascal16 WinExec(ptr word) WinExec
+166 pascal16 WinExec(ptr word) WinExec16
167 pascal16 GetExpWinVer(word) GetExpWinVer
168 pascal16 DirectResAlloc(word word word) DirectResAlloc
169 pascal GetFreeSpace(word) GetFreeSpace
@@ -197,7 +197,7 @@
197 pascal16 GlobalFix(word) GlobalFix
198 pascal16 GlobalUnfix(word) GlobalUnfix
199 pascal16 SetHandleCount(word) SetHandleCount16
-200 stub ValidateFreeSpaces
+200 return ValidateFreeSpaces 0 0
201 stub ReplaceInst
202 stub RegisterPtrace
203 register DebugBreak() DebugBreak16
@@ -257,7 +257,7 @@
347 pascal16 IsBadHugeWritePtr(segptr long) IsBadHugeWritePtr16
348 pascal16 hmemcpy(ptr ptr long) hmemcpy
349 pascal _hread(word segptr long) WIN16_hread
-350 pascal _hwrite(word ptr long) _hwrite
+350 pascal _hwrite(word ptr long) _hwrite16
#351 BUNNY_351
352 pascal lstrcatn(segptr segptr word) lstrcatn16
353 pascal lstrcpyn(segptr segptr word) lstrcpyn16
@@ -279,8 +279,8 @@
417 stub WriteProfileSection
418 stub GetPrivateProfileSection
419 stub GetProfileSection
-420 stub GetFileAttributes
-421 stub SetFileAttributes
+420 pascal GetFileAttributes(ptr) GetFileAttributes16
+421 pascal16 SetFileAttributes(ptr long) SetFileAttributes16
422 pascal16 GetDiskFreeSpace(ptr ptr ptr ptr ptr) GetDiskFreeSpace16
432 stub FileTimeToLocalFileTime
450 pascal16 KERNEL_450() stub_KERNEL_450
diff --git a/if1632/kernel32.spec b/if1632/kernel32.spec
index 68d060c..9fbd367 100644
--- a/if1632/kernel32.spec
+++ b/if1632/kernel32.spec
@@ -25,7 +25,7 @@
0020 stdcall ClearCommBreak(long) ClearCommBreak32
0021 stdcall ClearCommError(long ptr ptr) ClearCommError
0022 stub CloseConsoleHandle
-0023 stdcall CloseHandle(long) CloseHandle
+0023 stdcall CloseHandle(long) CloseHandle
0024 stub CloseProfileUserMapping
0025 stub CmdBatNotification
0026 stub CommConfigDialogA
@@ -110,8 +110,8 @@
0105 stub ExpungeConsoleCommandHistoryA
0106 stub ExpungeConsoleCommandHistoryW
0107 stub ExtendVirtualBuffer
-0108 stub FatalAppExitA
-0109 stub FatalAppExitW
+0108 stdcall FatalAppExitA(long ptr) FatalAppExit32A
+0109 stdcall FatalAppExitW(long ptr) FatalAppExit32W
0110 stub FatalExit
0111 stdcall FileTimeToDosDateTime(ptr ptr ptr) FileTimeToDosDateTime
0112 stdcall FileTimeToLocalFileTime(ptr ptr) FileTimeToLocalFileTime
@@ -201,9 +201,9 @@
0196 stdcall GetCurrentDirectoryA(long ptr) GetCurrentDirectory32A
0197 stdcall GetCurrentDirectoryW(long ptr) GetCurrentDirectory32W
0198 stdcall GetCurrentProcess() GetCurrentProcess
-0199 stdcall GetCurrentProcessId() GetCurrentThreadId
-0200 stdcall GetCurrentThread() GetCurrentThread
-0201 stdcall GetCurrentThreadId() GetCurrentThreadId
+0199 stdcall GetCurrentProcessId() GetCurrentProcessId
+0200 stdcall GetCurrentThread() GetCurrentThread
+0201 stdcall GetCurrentThreadId() GetCurrentThreadId
0202 stub GetDateFormatA
0203 stub GetDateFormatW
0204 stub GetDefaultCommConfigA
@@ -398,7 +398,7 @@
0393 stub OpenConsoleW
0394 stub OpenEventA
0395 stub OpenEventW
-0396 stdcall OpenFile(ptr ptr long) OpenFile
+0396 stdcall OpenFile(ptr ptr long) OpenFile32
0397 stdcall OpenFileMappingA(long long ptr) OpenFileMapping
0398 stub OpenFileMappingW
0399 stub OpenMutexA
@@ -499,7 +499,7 @@
0494 stdcall SetHandleCount(long) SetHandleCount32
0495 stub SetHandleInformation
0496 stub SetLastConsoleEventActive
-0497 stdcall SetLastError(long) SetLastError
+0497 stdcall SetLastError(long) SetLastError
0498 stub SetLocalTime
0499 stdcall SetLocaleInfoA(long long ptr) SetLocaleInfoA
0500 stub SetLocaleInfoW
@@ -533,9 +533,9 @@
0528 stub TerminateProcess
0529 stub TerminateThread
0530 stdcall TlsAlloc() TlsAlloc
-0531 stdcall TlsFree(long) TlsFree
-0532 stdcall TlsGetValue(long) TlsGetValue
-0533 stdcall TlsSetValue(long ptr) TlsSetValue
+0531 stdcall TlsFree(long) TlsFree
+0532 stdcall TlsGetValue(long) TlsGetValue
+0533 stdcall TlsSetValue(long ptr) TlsSetValue
0534 stub TransactNamedPipe
0535 stdcall TransmitCommChar(long long) TransmitCommChar32
0536 stub TrimVirtualBuffer
@@ -568,7 +568,7 @@
0563 stub WaitNamedPipeA
0564 stub WaitNamedPipeW
0565 stdcall WideCharToMultiByte(long long ptr long ptr long ptr ptr) WideCharToMultiByte
-0566 stdcall WinExec(ptr long) WinExec
+0566 stdcall WinExec(ptr long) WinExec32
0567 stdcall WriteConsoleA(long ptr long ptr ptr) WriteConsole32A
0568 stub WriteConsoleInputA
0569 stub WriteConsoleInputVDMA
@@ -592,12 +592,12 @@
0587 stdcall WriteProfileStringA(ptr ptr ptr) WriteProfileString32A
0588 stdcall WriteProfileStringW(ptr ptr ptr) WriteProfileString32W
0589 stub WriteTapemark
-0590 stdcall _hread(long ptr long) _hread
-0591 stdcall _hwrite(long ptr long) _hwrite
-0592 stdcall _lclose(long) _lclose
-0593 stdcall _lcreat(ptr long) _lcreat
-0594 stdcall _llseek(long long long) _llseek
-0595 stdcall _lopen(ptr long) _lopen
+0590 stdcall _hread(long ptr long) _hread32
+0591 stdcall _hwrite(long ptr long) _hwrite32
+0592 stdcall _lclose(long) _lclose32
+0593 stdcall _lcreat(ptr long) _lcreat32
+0594 stdcall _llseek(long long long) _llseek32
+0595 stdcall _lopen(ptr long) _lopen32
0596 stdcall _lread(long ptr long) _lread32
0597 stdcall _lwrite(long ptr long) _lwrite32
0598 stdcall lstrcat(ptr ptr) lstrcat32A
diff --git a/if1632/lz32.spec b/if1632/lz32.spec
index 2caac4e..a51a5f1 100644
--- a/if1632/lz32.spec
+++ b/if1632/lz32.spec
@@ -1,14 +1,14 @@
name lz32
type win32
-0 stdcall LZCopy(long long) LZCopy
+0 stdcall LZCopy(long long) LZCopy32
1 stdcall LZOpenFileA(ptr ptr long) LZOpenFile32A
-2 stdcall LZInit(long) LZInit
-3 stdcall LZSeek(long long long) LZSeek
+2 stdcall LZInit(long) LZInit32
+3 stdcall LZSeek(long long long) LZSeek32
4 stdcall LZRead(long ptr long) LZRead32
-5 stdcall LZClose(long) LZClose
-6 stdcall LZStart() LZStart
-7 stdcall CopyLZFile(long long) CopyLZFile
+5 stdcall LZClose(long) LZClose32
+6 stdcall LZStart() LZStart32
+7 stdcall CopyLZFile(long long) CopyLZFile32
8 stdcall LZDone() LZDone
9 stdcall GetExpandedNameA(ptr ptr) GetExpandedName32A
10 stdcall LZOpenFileW(ptr ptr long) LZOpenFile32W
diff --git a/if1632/lzexpand.spec b/if1632/lzexpand.spec
index e05997a..a12c7e2 100644
--- a/if1632/lzexpand.spec
+++ b/if1632/lzexpand.spec
@@ -1,14 +1,14 @@
name lzexpand
type win16
-1 pascal LZCopy(word word) LZCopy
+1 pascal LZCopy(word word) LZCopy16
2 pascal16 LZOpenFile(ptr ptr word) LZOpenFile16
-3 pascal16 LZInit(word) LZInit
-4 pascal LZSeek(word long word) LZSeek
-5 pascal16 LZRead(word segptr word) LZRead16
-6 pascal16 LZClose(word) LZClose
-7 pascal16 LZStart() LZStart
-8 pascal CopyLZFile(word word) CopyLZFile
+3 pascal16 LZInit(word) LZInit16
+4 pascal LZSeek(word long word) LZSeek16
+5 pascal16 LZRead(word ptr word) LZRead16
+6 pascal16 LZClose(word) LZClose16
+7 pascal16 LZStart() LZStart16
+8 pascal CopyLZFile(word word) CopyLZFile16
9 pascal16 LZDone() LZDone
10 pascal16 GetExpandedName(ptr ptr) GetExpandedName16
#11 WEP
diff --git a/if1632/relay.c b/if1632/relay.c
index 63b3509..cc9b839 100644
--- a/if1632/relay.c
+++ b/if1632/relay.c
@@ -5,9 +5,9 @@
#include <stdio.h>
#include "windows.h"
+#include "winnt.h"
#include "global.h"
#include "module.h"
-#include "registers.h"
#include "stackframe.h"
#include "task.h"
#include "stddebug.h"
@@ -52,7 +52,7 @@
* RELAY_DebugCallFrom16
*/
void RELAY_DebugCallFrom16( int func_type, char *args,
- void *entry_point, SIGCONTEXT *context )
+ void *entry_point, CONTEXT *context )
{
STACK16FRAME *frame;
WORD ordinal;
@@ -108,25 +108,19 @@
printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
- ES_reg(context), EFL_reg(context) );
+ (WORD)ES_reg(context), EFL_reg(context) );
}
/***********************************************************************
* RELAY_DebugCallFrom16Ret
*/
-void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, SIGCONTEXT *context)
+void RELAY_DebugCallFrom16Ret( int func_type, int ret_val, CONTEXT *context)
{
STACK16FRAME *frame;
WORD ordinal;
- if (*(DWORD *)PTR_SEG_TO_LIN(IF1632_Stack32_base) != 0xDEADBEEF)
- {
- fprintf(stderr, "Wine wrote past the end of the 32 bit stack. Please report this.\n");
- exit(1); /* There's probably no point in going on */
- }
if (!debugging_relay) return;
-
frame = CURRENT_STACK16;
printf( "Ret %s() ", BUILTIN_GetEntryPoint16( frame->entry_cs,
frame->entry_ip,
@@ -147,7 +141,7 @@
printf( " AX=%04x BX=%04x CX=%04x DX=%04x SI=%04x DI=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
- ES_reg(context), EFL_reg(context) );
+ (WORD)ES_reg(context), EFL_reg(context) );
break;
}
}
diff --git a/if1632/shell.spec b/if1632/shell.spec
index 8b53f1e..c9c907d 100644
--- a/if1632/shell.spec
+++ b/if1632/shell.spec
@@ -14,8 +14,8 @@
13 pascal16 DragQueryPoint(word ptr) DragQueryPoint
20 pascal16 ShellExecute(word ptr ptr ptr ptr s_word) ShellExecute
21 pascal16 FindExecutable(ptr ptr ptr) FindExecutable
- 22 pascal16 ShellAbout(word ptr ptr word) ShellAbout
- 33 pascal16 AboutDlgProc(word word word long) AboutDlgProc
+ 22 pascal16 ShellAbout(word ptr ptr word) ShellAbout16
+ 33 pascal16 AboutDlgProc(word word word long) AboutDlgProc16
34 pascal16 ExtractIcon(word ptr s_word) ExtractIcon
36 pascal16 ExtractAssociatedIcon(word ptr ptr) ExtractAssociatedIcon
37 pascal DoEnvironmentSubst(ptr word) DoEnvironmentSubst
diff --git a/if1632/shell32.spec b/if1632/shell32.spec
index 9977d78..b7c65f7 100644
--- a/if1632/shell32.spec
+++ b/if1632/shell32.spec
@@ -84,7 +84,7 @@
0079 stub SheSetCurDrive
0080 stub SheShortenPathA
0081 stub SheShortenPathW
-0082 stdcall ShellAboutA(long ptr ptr long) ShellAbout
+0082 stdcall ShellAboutA(long ptr ptr long) ShellAbout32A
0083 stdcall ShellAboutW(long ptr ptr long) ShellAbout32W
0084 stdcall ShellExecuteA(long ptr ptr ptr ptr long) ShellExecute
0085 stub ShellExecuteEx
diff --git a/if1632/user.spec b/if1632/user.spec
index c97fdc9..dee73b5 100644
--- a/if1632/user.spec
+++ b/if1632/user.spec
@@ -8,7 +8,7 @@
4 stub DisableOEMLayer
5 pascal16 InitApp(word) InitApp
6 pascal16 PostQuitMessage(word) PostQuitMessage
-7 pascal16 ExitWindows(long word) ExitWindows
+7 pascal16 ExitWindows(long word) ExitWindows16
10 pascal16 SetTimer(word word word segptr) SetTimer16
11 pascal16 SetSystemTimer(word word word segptr) SetSystemTimer16
12 pascal16 KillTimer(word word) KillTimer16
@@ -125,9 +125,9 @@
123 pascal16 CallMsgFilter(segptr s_word) CallMsgFilter16
124 pascal16 UpdateWindow(word) UpdateWindow
125 pascal16 InvalidateRect(word ptr word) InvalidateRect16
-126 pascal16 InvalidateRgn(word word word) InvalidateRgn
+126 pascal16 InvalidateRgn(word word word) InvalidateRgn16
127 pascal16 ValidateRect(word ptr) ValidateRect16
-128 pascal16 ValidateRgn(word word) ValidateRgn
+128 pascal16 ValidateRgn(word word) ValidateRgn16
129 pascal16 GetClassWord(word s_word) GetClassWord
130 pascal16 SetClassWord(word s_word word) SetClassWord
131 pascal GetClassLong(word s_word) GetClassLong16
@@ -170,7 +170,7 @@
168 pascal16 SetCaretBlinkTime(word) SetCaretBlinkTime
169 pascal16 GetCaretBlinkTime() GetCaretBlinkTime16
170 pascal16 ArrangeIconicWindows(word) ArrangeIconicWindows
-171 pascal16 WinHelp(word ptr word long) WinHelp
+171 pascal16 WinHelp(word ptr word long) WinHelp16
172 stub SwitchToThisWindow
173 pascal16 LoadCursor(word segptr) LoadCursor16
174 pascal16 LoadIcon(word segptr) LoadIcon16
diff --git a/if1632/user32.spec b/if1632/user32.spec
index a0cb5c4..3f5f9e8 100644
--- a/if1632/user32.spec
+++ b/if1632/user32.spec
@@ -199,7 +199,7 @@
0192 stdcall EnumWindows(ptr long) THUNK_EnumWindows32
0193 stdcall EqualRect(ptr ptr) EqualRect32
0194 stdcall ExcludeUpdateRgn(long long) ExcludeUpdateRgn
-0195 stub ExitWindowsEx
+0195 stdcall ExitWindowsEx(long long) ExitWindowsEx
0196 stdcall FillRect(long ptr long) FillRect32
0197 stdcall FindWindowA(ptr ptr) FindWindow32A
0198 stdcall FindWindowExA(long long ptr ptr) FindWindowEx32A
@@ -332,7 +332,7 @@
0325 stub InternalGetWindowText
0326 stdcall IntersectRect(ptr ptr ptr) IntersectRect32
0327 stdcall InvalidateRect(long ptr long) InvalidateRect32
-0328 stdcall InvalidateRgn(long long long) InvalidateRgn
+0328 stdcall InvalidateRgn(long long long) InvalidateRgn32
0329 stdcall InvertRect(long ptr) InvertRect32
0330 stdcall IsCharAlphaA(long) IsCharAlpha32A
0331 stdcall IsCharAlphaNumericA(long) IsCharAlphaNumeric32A
@@ -553,7 +553,7 @@
0546 stub ToAsciiEx
0547 stub ToUnicode
0548 stdcall TrackPopupMenu(long long long long long long ptr) TrackPopupMenu32
-0549 stub TrackPopupMenuEx
+0549 stdcall TrackPopupMenuEx(long long long long long ptr) TrackPopupMenuEx
0550 stdcall TranslateAccelerator(long long ptr) TranslateAccelerator
0551 stdcall TranslateAcceleratorA(long long ptr) TranslateAccelerator
0552 stdcall TranslateAcceleratorW(long long ptr) TranslateAccelerator
@@ -575,15 +575,15 @@
0568 stub UserRealizePalette
0569 stub UserRegisterWowHandlers
0570 stdcall ValidateRect(long ptr) ValidateRect32
-0571 stdcall ValidateRgn(long long) ValidateRgn
+0571 stdcall ValidateRgn(long long) ValidateRgn32
0572 stdcall VkKeyScanA(long) VkKeyScan
0573 stub VkKeyScanExA
0574 stub VkKeyScanExW
0575 stub VkKeyScanW
0576 stub WaitForInputIdle
0577 stub WaitMessage
-0578 stdcall WinHelpA(long ptr long long) WIN32_WinHelpA
-0579 stub WinHelpW
+0578 stdcall WinHelpA(long ptr long long) WinHelp32A
+0579 stdcall WinHelpW(long ptr long long) WinHelp32W
0580 stdcall WindowFromDC(long) WindowFromDC32
0581 stdcall WindowFromPoint(long long) WindowFromPoint32
0582 stub keybd_event
diff --git a/if1632/wprocs.spec b/if1632/wprocs.spec
index 3522fec..70970d0 100644
--- a/if1632/wprocs.spec
+++ b/if1632/wprocs.spec
@@ -9,7 +9,6 @@
7 pascal PopupMenuWndProc(word word word long) PopupMenuWndProc
9 pascal DefDlgProc(word word word long) DefDlgProc16
10 pascal MDIClientWndProc(word word word long) MDIClientWndProc
-13 pascal SystemMessageBoxProc(word word word long) SystemMessageBoxProc
14 pascal FileOpenDlgProc(word word word long) FileOpenDlgProc
15 pascal FileSaveDlgProc(word word word long) FileSaveDlgProc
16 pascal ColorDlgProc(word word word long) ColorDlgProc
@@ -17,7 +16,6 @@
18 pascal ReplaceTextDlgProc(word word word long) ReplaceTextDlgProc
19 pascal PrintSetupDlgProc(word word word long) PrintSetupDlgProc
20 pascal PrintDlgProc(word word word long) PrintDlgProc
-21 pascal AboutDlgProc(word word word long) AboutDlgProc
22 pascal ComboLBoxWndProc(word word word long) ComboLBoxWndProc
24 pascal16 TASK_Reschedule() TASK_Reschedule
27 pascal EntryAddrProc(word word) MODULE_GetEntryPoint
@@ -26,263 +24,263 @@
# Interrupt vectors 0-255 are ordinals 100-355
# The 'word' parameter are the flags pushed on the stack by the interrupt
-100 register INT_Int00Handler(word) INT_DummyHandler
-101 register INT_Int01Handler(word) INT_DummyHandler
-102 register INT_Int02Handler(word) INT_DummyHandler
-103 register INT_Int03Handler(word) INT_DummyHandler
-104 register INT_Int04Handler(word) INT_DummyHandler
-105 register INT_Int05Handler(word) INT_DummyHandler
-106 register INT_Int06Handler(word) INT_DummyHandler
-107 register INT_Int07Handler(word) INT_DummyHandler
-108 register INT_Int08Handler(word) INT_DummyHandler
-109 register INT_Int09Handler(word) INT_DummyHandler
-110 register INT_Int0aHandler(word) INT_DummyHandler
-111 register INT_Int0bHandler(word) INT_DummyHandler
-112 register INT_Int0cHandler(word) INT_DummyHandler
-113 register INT_Int0dHandler(word) INT_DummyHandler
-114 register INT_Int0eHandler(word) INT_DummyHandler
-115 register INT_Int0fHandler(word) INT_DummyHandler
+100 register INT_Int00Handler(word) BUILTIN_DefaultIntHandler
+101 register INT_Int01Handler(word) BUILTIN_DefaultIntHandler
+102 register INT_Int02Handler(word) BUILTIN_DefaultIntHandler
+103 register INT_Int03Handler(word) BUILTIN_DefaultIntHandler
+104 register INT_Int04Handler(word) BUILTIN_DefaultIntHandler
+105 register INT_Int05Handler(word) BUILTIN_DefaultIntHandler
+106 register INT_Int06Handler(word) BUILTIN_DefaultIntHandler
+107 register INT_Int07Handler(word) BUILTIN_DefaultIntHandler
+108 register INT_Int08Handler(word) BUILTIN_DefaultIntHandler
+109 register INT_Int09Handler(word) BUILTIN_DefaultIntHandler
+110 register INT_Int0aHandler(word) BUILTIN_DefaultIntHandler
+111 register INT_Int0bHandler(word) BUILTIN_DefaultIntHandler
+112 register INT_Int0cHandler(word) BUILTIN_DefaultIntHandler
+113 register INT_Int0dHandler(word) BUILTIN_DefaultIntHandler
+114 register INT_Int0eHandler(word) BUILTIN_DefaultIntHandler
+115 register INT_Int0fHandler(word) BUILTIN_DefaultIntHandler
116 register INT_Int10Handler(word) INT_Int10Handler
117 register INT_Int11Handler(word) INT_Int11Handler
118 register INT_Int12Handler(word) INT_Int12Handler
119 register INT_Int13Handler(word) INT_Int13Handler
-120 register INT_Int14Handler(word) INT_DummyHandler
-121 register INT_Int15Handler(word) INT_Int15Handler
-122 register INT_Int16Handler(word) INT_Int16Handler
-123 register INT_Int17Handler(word) INT_DummyHandler
-124 register INT_Int18Handler(word) INT_DummyHandler
-125 register INT_Int19Handler(word) INT_DummyHandler
+120 register INT_Int14Handler(word) BUILTIN_DefaultIntHandler
+121 register INT_Int15Handler(word) BUILTIN_DefaultIntHandler
+122 register INT_Int16Handler(word) BUILTIN_DefaultIntHandler
+123 register INT_Int17Handler(word) BUILTIN_DefaultIntHandler
+124 register INT_Int18Handler(word) BUILTIN_DefaultIntHandler
+125 register INT_Int19Handler(word) BUILTIN_DefaultIntHandler
126 register INT_Int1aHandler(word) INT_Int1aHandler
-127 register INT_Int1bHandler(word) INT_DummyHandler
-128 register INT_Int1cHandler(word) INT_DummyHandler
-129 register INT_Int1dHandler(word) INT_DummyHandler
-130 register INT_Int1eHandler(word) INT_DummyHandler
-131 register INT_Int1fHandler(word) INT_DummyHandler
-132 register INT_Int20Handler(word) INT_DummyHandler
+127 register INT_Int1bHandler(word) BUILTIN_DefaultIntHandler
+128 register INT_Int1cHandler(word) BUILTIN_DefaultIntHandler
+129 register INT_Int1dHandler(word) BUILTIN_DefaultIntHandler
+130 register INT_Int1eHandler(word) BUILTIN_DefaultIntHandler
+131 register INT_Int1fHandler(word) BUILTIN_DefaultIntHandler
+132 register INT_Int20Handler(word) BUILTIN_DefaultIntHandler
133 register INT_Int21Handler(word) DOS3Call
-134 register INT_Int22Handler(word) INT_DummyHandler
-135 register INT_Int23Handler(word) INT_DummyHandler
-136 register INT_Int24Handler(word) INT_DummyHandler
+134 register INT_Int22Handler(word) BUILTIN_DefaultIntHandler
+135 register INT_Int23Handler(word) BUILTIN_DefaultIntHandler
+136 register INT_Int24Handler(word) BUILTIN_DefaultIntHandler
# Note: int 25 and 26 don't pop the flags from the stack
137 register INT_Int25Handler() INT_Int25Handler
138 register INT_Int26Handler() INT_Int26Handler
-139 register INT_Int27Handler(word) INT_DummyHandler
-140 register INT_Int28Handler(word) INT_DummyHandler
-141 register INT_Int29Handler(word) INT_DummyHandler
+139 register INT_Int27Handler(word) BUILTIN_DefaultIntHandler
+140 register INT_Int28Handler(word) BUILTIN_DefaultIntHandler
+141 register INT_Int29Handler(word) BUILTIN_DefaultIntHandler
142 register INT_Int2aHandler(word) INT_Int2aHandler
-143 register INT_Int2bHandler(word) INT_DummyHandler
-144 register INT_Int2cHandler(word) INT_DummyHandler
-145 register INT_Int2dHandler(word) INT_DummyHandler
-146 register INT_Int2eHandler(word) INT_DummyHandler
+143 register INT_Int2bHandler(word) BUILTIN_DefaultIntHandler
+144 register INT_Int2cHandler(word) BUILTIN_DefaultIntHandler
+145 register INT_Int2dHandler(word) BUILTIN_DefaultIntHandler
+146 register INT_Int2eHandler(word) BUILTIN_DefaultIntHandler
147 register INT_Int2fHandler(word) INT_Int2fHandler
-148 register INT_Int30Handler(word) INT_DummyHandler
+148 register INT_Int30Handler(word) BUILTIN_DefaultIntHandler
149 register INT_Int31Handler(word) INT_Int31Handler
-150 register INT_Int32Handler(word) INT_DummyHandler
-151 register INT_Int33Handler(word) INT_DummyHandler
-152 register INT_Int34Handler(word) INT_DummyHandler
-153 register INT_Int35Handler(word) INT_DummyHandler
-154 register INT_Int36Handler(word) INT_DummyHandler
-155 register INT_Int37Handler(word) INT_DummyHandler
-156 register INT_Int38Handler(word) INT_DummyHandler
-157 register INT_Int39Handler(word) INT_DummyHandler
-158 register INT_Int3aHandler(word) INT_DummyHandler
-159 register INT_Int3bHandler(word) INT_DummyHandler
-160 register INT_Int3cHandler(word) INT_DummyHandler
-161 register INT_Int3dHandler(word) INT_DummyHandler
-162 register INT_Int3eHandler(word) INT_DummyHandler
-163 register INT_Int3fHandler(word) INT_DummyHandler
-164 register INT_Int40Handler(word) INT_DummyHandler
-165 register INT_Int41Handler(word) INT_DummyHandler
-166 register INT_Int42Handler(word) INT_DummyHandler
-167 register INT_Int43Handler(word) INT_DummyHandler
-168 register INT_Int44Handler(word) INT_DummyHandler
-169 register INT_Int45Handler(word) INT_DummyHandler
-170 register INT_Int46Handler(word) INT_DummyHandler
-171 register INT_Int47Handler(word) INT_DummyHandler
-172 register INT_Int48Handler(word) INT_DummyHandler
-173 register INT_Int49Handler(word) INT_DummyHandler
-174 register INT_Int4aHandler(word) INT_DummyHandler
+150 register INT_Int32Handler(word) BUILTIN_DefaultIntHandler
+151 register INT_Int33Handler(word) BUILTIN_DefaultIntHandler
+152 register INT_Int34Handler(word) BUILTIN_DefaultIntHandler
+153 register INT_Int35Handler(word) BUILTIN_DefaultIntHandler
+154 register INT_Int36Handler(word) BUILTIN_DefaultIntHandler
+155 register INT_Int37Handler(word) BUILTIN_DefaultIntHandler
+156 register INT_Int38Handler(word) BUILTIN_DefaultIntHandler
+157 register INT_Int39Handler(word) BUILTIN_DefaultIntHandler
+158 register INT_Int3aHandler(word) BUILTIN_DefaultIntHandler
+159 register INT_Int3bHandler(word) BUILTIN_DefaultIntHandler
+160 register INT_Int3cHandler(word) BUILTIN_DefaultIntHandler
+161 register INT_Int3dHandler(word) BUILTIN_DefaultIntHandler
+162 register INT_Int3eHandler(word) BUILTIN_DefaultIntHandler
+163 register INT_Int3fHandler(word) BUILTIN_DefaultIntHandler
+164 register INT_Int40Handler(word) BUILTIN_DefaultIntHandler
+165 register INT_Int41Handler(word) BUILTIN_DefaultIntHandler
+166 register INT_Int42Handler(word) BUILTIN_DefaultIntHandler
+167 register INT_Int43Handler(word) BUILTIN_DefaultIntHandler
+168 register INT_Int44Handler(word) BUILTIN_DefaultIntHandler
+169 register INT_Int45Handler(word) BUILTIN_DefaultIntHandler
+170 register INT_Int46Handler(word) BUILTIN_DefaultIntHandler
+171 register INT_Int47Handler(word) BUILTIN_DefaultIntHandler
+172 register INT_Int48Handler(word) BUILTIN_DefaultIntHandler
+173 register INT_Int49Handler(word) BUILTIN_DefaultIntHandler
+174 register INT_Int4aHandler(word) BUILTIN_DefaultIntHandler
175 register INT_Int4bHandler(word) INT_Int4bHandler
-176 register INT_Int4cHandler(word) INT_DummyHandler
-177 register INT_Int4dHandler(word) INT_DummyHandler
-178 register INT_Int4eHandler(word) INT_DummyHandler
-179 register INT_Int4fHandler(word) INT_DummyHandler
-180 register INT_Int50Handler(word) INT_DummyHandler
-181 register INT_Int51Handler(word) INT_DummyHandler
-182 register INT_Int52Handler(word) INT_DummyHandler
-183 register INT_Int53Handler(word) INT_DummyHandler
-184 register INT_Int54Handler(word) INT_DummyHandler
-185 register INT_Int55Handler(word) INT_DummyHandler
-186 register INT_Int56Handler(word) INT_DummyHandler
-187 register INT_Int57Handler(word) INT_DummyHandler
-188 register INT_Int58Handler(word) INT_DummyHandler
-189 register INT_Int59Handler(word) INT_DummyHandler
-190 register INT_Int5aHandler(word) INT_DummyHandler
-191 register INT_Int5bHandler(word) INT_DummyHandler
+176 register INT_Int4cHandler(word) BUILTIN_DefaultIntHandler
+177 register INT_Int4dHandler(word) BUILTIN_DefaultIntHandler
+178 register INT_Int4eHandler(word) BUILTIN_DefaultIntHandler
+179 register INT_Int4fHandler(word) BUILTIN_DefaultIntHandler
+180 register INT_Int50Handler(word) BUILTIN_DefaultIntHandler
+181 register INT_Int51Handler(word) BUILTIN_DefaultIntHandler
+182 register INT_Int52Handler(word) BUILTIN_DefaultIntHandler
+183 register INT_Int53Handler(word) BUILTIN_DefaultIntHandler
+184 register INT_Int54Handler(word) BUILTIN_DefaultIntHandler
+185 register INT_Int55Handler(word) BUILTIN_DefaultIntHandler
+186 register INT_Int56Handler(word) BUILTIN_DefaultIntHandler
+187 register INT_Int57Handler(word) BUILTIN_DefaultIntHandler
+188 register INT_Int58Handler(word) BUILTIN_DefaultIntHandler
+189 register INT_Int59Handler(word) BUILTIN_DefaultIntHandler
+190 register INT_Int5aHandler(word) BUILTIN_DefaultIntHandler
+191 register INT_Int5bHandler(word) BUILTIN_DefaultIntHandler
192 register INT_Int5cHandler(word) NetBIOSCall
-193 register INT_Int5dHandler(word) INT_DummyHandler
-194 register INT_Int5eHandler(word) INT_DummyHandler
-195 register INT_Int5fHandler(word) INT_DummyHandler
-196 register INT_Int60Handler(word) INT_DummyHandler
-197 register INT_Int61Handler(word) INT_DummyHandler
-198 register INT_Int62Handler(word) INT_DummyHandler
-199 register INT_Int63Handler(word) INT_DummyHandler
-200 register INT_Int64Handler(word) INT_DummyHandler
-201 register INT_Int65Handler(word) INT_DummyHandler
-202 register INT_Int66Handler(word) INT_DummyHandler
-203 register INT_Int67Handler(word) INT_DummyHandler
-204 register INT_Int68Handler(word) INT_DummyHandler
-205 register INT_Int69Handler(word) INT_DummyHandler
-206 register INT_Int6aHandler(word) INT_DummyHandler
-207 register INT_Int6bHandler(word) INT_DummyHandler
-208 register INT_Int6cHandler(word) INT_DummyHandler
-209 register INT_Int6dHandler(word) INT_DummyHandler
-210 register INT_Int6eHandler(word) INT_DummyHandler
-211 register INT_Int6fHandler(word) INT_DummyHandler
-212 register INT_Int70Handler(word) INT_DummyHandler
-213 register INT_Int71Handler(word) INT_DummyHandler
-214 register INT_Int72Handler(word) INT_DummyHandler
-215 register INT_Int73Handler(word) INT_DummyHandler
-216 register INT_Int74Handler(word) INT_DummyHandler
-217 register INT_Int75Handler(word) INT_DummyHandler
-218 register INT_Int76Handler(word) INT_DummyHandler
-219 register INT_Int77Handler(word) INT_DummyHandler
-220 register INT_Int78Handler(word) INT_DummyHandler
-221 register INT_Int79Handler(word) INT_DummyHandler
-222 register INT_Int7aHandler(word) INT_DummyHandler
-223 register INT_Int7bHandler(word) INT_DummyHandler
-224 register INT_Int7cHandler(word) INT_DummyHandler
-225 register INT_Int7dHandler(word) INT_DummyHandler
-226 register INT_Int7eHandler(word) INT_DummyHandler
-227 register INT_Int7fHandler(word) INT_DummyHandler
-228 register INT_Int80Handler(word) INT_DummyHandler
-229 register INT_Int81Handler(word) INT_DummyHandler
-230 register INT_Int82Handler(word) INT_DummyHandler
-231 register INT_Int83Handler(word) INT_DummyHandler
-232 register INT_Int84Handler(word) INT_DummyHandler
-233 register INT_Int85Handler(word) INT_DummyHandler
-234 register INT_Int86Handler(word) INT_DummyHandler
-235 register INT_Int87Handler(word) INT_DummyHandler
-236 register INT_Int88Handler(word) INT_DummyHandler
-237 register INT_Int89Handler(word) INT_DummyHandler
-238 register INT_Int8aHandler(word) INT_DummyHandler
-239 register INT_Int8bHandler(word) INT_DummyHandler
-240 register INT_Int8cHandler(word) INT_DummyHandler
-241 register INT_Int8dHandler(word) INT_DummyHandler
-242 register INT_Int8eHandler(word) INT_DummyHandler
-243 register INT_Int8fHandler(word) INT_DummyHandler
-244 register INT_Int90Handler(word) INT_DummyHandler
-245 register INT_Int91Handler(word) INT_DummyHandler
-246 register INT_Int92Handler(word) INT_DummyHandler
-247 register INT_Int93Handler(word) INT_DummyHandler
-248 register INT_Int94Handler(word) INT_DummyHandler
-249 register INT_Int95Handler(word) INT_DummyHandler
-250 register INT_Int96Handler(word) INT_DummyHandler
-251 register INT_Int97Handler(word) INT_DummyHandler
-252 register INT_Int98Handler(word) INT_DummyHandler
-253 register INT_Int99Handler(word) INT_DummyHandler
-254 register INT_Int9aHandler(word) INT_DummyHandler
-255 register INT_Int9bHandler(word) INT_DummyHandler
-256 register INT_Int9cHandler(word) INT_DummyHandler
-257 register INT_Int9dHandler(word) INT_DummyHandler
-258 register INT_Int9eHandler(word) INT_DummyHandler
-259 register INT_Int9fHandler(word) INT_DummyHandler
-260 register INT_Inta0Handler(word) INT_DummyHandler
-261 register INT_Inta1Handler(word) INT_DummyHandler
-262 register INT_Inta2Handler(word) INT_DummyHandler
-263 register INT_Inta3Handler(word) INT_DummyHandler
-264 register INT_Inta4Handler(word) INT_DummyHandler
-265 register INT_Inta5Handler(word) INT_DummyHandler
-266 register INT_Inta6Handler(word) INT_DummyHandler
-267 register INT_Inta7Handler(word) INT_DummyHandler
-268 register INT_Inta8Handler(word) INT_DummyHandler
-269 register INT_Inta9Handler(word) INT_DummyHandler
-270 register INT_IntaaHandler(word) INT_DummyHandler
-271 register INT_IntabHandler(word) INT_DummyHandler
-272 register INT_IntacHandler(word) INT_DummyHandler
-273 register INT_IntadHandler(word) INT_DummyHandler
-274 register INT_IntaeHandler(word) INT_DummyHandler
-275 register INT_IntafHandler(word) INT_DummyHandler
-276 register INT_Intb0Handler(word) INT_DummyHandler
-277 register INT_Intb1Handler(word) INT_DummyHandler
-278 register INT_Intb2Handler(word) INT_DummyHandler
-279 register INT_Intb3Handler(word) INT_DummyHandler
-280 register INT_Intb4Handler(word) INT_DummyHandler
-281 register INT_Intb5Handler(word) INT_DummyHandler
-282 register INT_Intb6Handler(word) INT_DummyHandler
-283 register INT_Intb7Handler(word) INT_DummyHandler
-284 register INT_Intb8Handler(word) INT_DummyHandler
-285 register INT_Intb9Handler(word) INT_DummyHandler
-286 register INT_IntbaHandler(word) INT_DummyHandler
-287 register INT_IntbbHandler(word) INT_DummyHandler
-288 register INT_IntbcHandler(word) INT_DummyHandler
-289 register INT_IntbdHandler(word) INT_DummyHandler
-290 register INT_IntbeHandler(word) INT_DummyHandler
-291 register INT_IntbfHandler(word) INT_DummyHandler
-292 register INT_Intc0Handler(word) INT_DummyHandler
-293 register INT_Intc1Handler(word) INT_DummyHandler
-294 register INT_Intc2Handler(word) INT_DummyHandler
-295 register INT_Intc3Handler(word) INT_DummyHandler
-296 register INT_Intc4Handler(word) INT_DummyHandler
-297 register INT_Intc5Handler(word) INT_DummyHandler
-298 register INT_Intc6Handler(word) INT_DummyHandler
-299 register INT_Intc7Handler(word) INT_DummyHandler
-300 register INT_Intc8Handler(word) INT_DummyHandler
-301 register INT_Intc9Handler(word) INT_DummyHandler
-302 register INT_IntcaHandler(word) INT_DummyHandler
-303 register INT_IntcbHandler(word) INT_DummyHandler
-304 register INT_IntccHandler(word) INT_DummyHandler
-305 register INT_IntcdHandler(word) INT_DummyHandler
-306 register INT_IntceHandler(word) INT_DummyHandler
-307 register INT_IntcfHandler(word) INT_DummyHandler
-308 register INT_Intd0Handler(word) INT_DummyHandler
-309 register INT_Intd1Handler(word) INT_DummyHandler
-310 register INT_Intd2Handler(word) INT_DummyHandler
-311 register INT_Intd3Handler(word) INT_DummyHandler
-312 register INT_Intd4Handler(word) INT_DummyHandler
-313 register INT_Intd5Handler(word) INT_DummyHandler
-314 register INT_Intd6Handler(word) INT_DummyHandler
-315 register INT_Intd7Handler(word) INT_DummyHandler
-316 register INT_Intd8Handler(word) INT_DummyHandler
-317 register INT_Intd9Handler(word) INT_DummyHandler
-318 register INT_IntdaHandler(word) INT_DummyHandler
-319 register INT_IntdbHandler(word) INT_DummyHandler
-320 register INT_IntdcHandler(word) INT_DummyHandler
-321 register INT_IntddHandler(word) INT_DummyHandler
-322 register INT_IntdeHandler(word) INT_DummyHandler
-323 register INT_IntdfHandler(word) INT_DummyHandler
-324 register INT_Inte0Handler(word) INT_DummyHandler
-325 register INT_Inte1Handler(word) INT_DummyHandler
-326 register INT_Inte2Handler(word) INT_DummyHandler
-327 register INT_Inte3Handler(word) INT_DummyHandler
-328 register INT_Inte4Handler(word) INT_DummyHandler
-329 register INT_Inte5Handler(word) INT_DummyHandler
-330 register INT_Inte6Handler(word) INT_DummyHandler
-331 register INT_Inte7Handler(word) INT_DummyHandler
-332 register INT_Inte8Handler(word) INT_DummyHandler
-333 register INT_Inte9Handler(word) INT_DummyHandler
-334 register INT_InteaHandler(word) INT_DummyHandler
-335 register INT_IntebHandler(word) INT_DummyHandler
-336 register INT_IntecHandler(word) INT_DummyHandler
-337 register INT_IntedHandler(word) INT_DummyHandler
-338 register INT_InteeHandler(word) INT_DummyHandler
-339 register INT_IntefHandler(word) INT_DummyHandler
-340 register INT_Intf0Handler(word) INT_DummyHandler
-341 register INT_Intf1Handler(word) INT_DummyHandler
-342 register INT_Intf2Handler(word) INT_DummyHandler
-343 register INT_Intf3Handler(word) INT_DummyHandler
-344 register INT_Intf4Handler(word) INT_DummyHandler
-345 register INT_Intf5Handler(word) INT_DummyHandler
-346 register INT_Intf6Handler(word) INT_DummyHandler
-347 register INT_Intf7Handler(word) INT_DummyHandler
-348 register INT_Intf8Handler(word) INT_DummyHandler
-349 register INT_Intf9Handler(word) INT_DummyHandler
-350 register INT_IntfaHandler(word) INT_DummyHandler
-351 register INT_IntfbHandler(word) INT_DummyHandler
-352 register INT_IntfcHandler(word) INT_DummyHandler
-353 register INT_IntfdHandler(word) INT_DummyHandler
-354 register INT_IntfeHandler(word) INT_DummyHandler
-355 register INT_IntffHandler(word) INT_DummyHandler
+193 register INT_Int5dHandler(word) BUILTIN_DefaultIntHandler
+194 register INT_Int5eHandler(word) BUILTIN_DefaultIntHandler
+195 register INT_Int5fHandler(word) BUILTIN_DefaultIntHandler
+196 register INT_Int60Handler(word) BUILTIN_DefaultIntHandler
+197 register INT_Int61Handler(word) BUILTIN_DefaultIntHandler
+198 register INT_Int62Handler(word) BUILTIN_DefaultIntHandler
+199 register INT_Int63Handler(word) BUILTIN_DefaultIntHandler
+200 register INT_Int64Handler(word) BUILTIN_DefaultIntHandler
+201 register INT_Int65Handler(word) BUILTIN_DefaultIntHandler
+202 register INT_Int66Handler(word) BUILTIN_DefaultIntHandler
+203 register INT_Int67Handler(word) BUILTIN_DefaultIntHandler
+204 register INT_Int68Handler(word) BUILTIN_DefaultIntHandler
+205 register INT_Int69Handler(word) BUILTIN_DefaultIntHandler
+206 register INT_Int6aHandler(word) BUILTIN_DefaultIntHandler
+207 register INT_Int6bHandler(word) BUILTIN_DefaultIntHandler
+208 register INT_Int6cHandler(word) BUILTIN_DefaultIntHandler
+209 register INT_Int6dHandler(word) BUILTIN_DefaultIntHandler
+210 register INT_Int6eHandler(word) BUILTIN_DefaultIntHandler
+211 register INT_Int6fHandler(word) BUILTIN_DefaultIntHandler
+212 register INT_Int70Handler(word) BUILTIN_DefaultIntHandler
+213 register INT_Int71Handler(word) BUILTIN_DefaultIntHandler
+214 register INT_Int72Handler(word) BUILTIN_DefaultIntHandler
+215 register INT_Int73Handler(word) BUILTIN_DefaultIntHandler
+216 register INT_Int74Handler(word) BUILTIN_DefaultIntHandler
+217 register INT_Int75Handler(word) BUILTIN_DefaultIntHandler
+218 register INT_Int76Handler(word) BUILTIN_DefaultIntHandler
+219 register INT_Int77Handler(word) BUILTIN_DefaultIntHandler
+220 register INT_Int78Handler(word) BUILTIN_DefaultIntHandler
+221 register INT_Int79Handler(word) BUILTIN_DefaultIntHandler
+222 register INT_Int7aHandler(word) BUILTIN_DefaultIntHandler
+223 register INT_Int7bHandler(word) BUILTIN_DefaultIntHandler
+224 register INT_Int7cHandler(word) BUILTIN_DefaultIntHandler
+225 register INT_Int7dHandler(word) BUILTIN_DefaultIntHandler
+226 register INT_Int7eHandler(word) BUILTIN_DefaultIntHandler
+227 register INT_Int7fHandler(word) BUILTIN_DefaultIntHandler
+228 register INT_Int80Handler(word) BUILTIN_DefaultIntHandler
+229 register INT_Int81Handler(word) BUILTIN_DefaultIntHandler
+230 register INT_Int82Handler(word) BUILTIN_DefaultIntHandler
+231 register INT_Int83Handler(word) BUILTIN_DefaultIntHandler
+232 register INT_Int84Handler(word) BUILTIN_DefaultIntHandler
+233 register INT_Int85Handler(word) BUILTIN_DefaultIntHandler
+234 register INT_Int86Handler(word) BUILTIN_DefaultIntHandler
+235 register INT_Int87Handler(word) BUILTIN_DefaultIntHandler
+236 register INT_Int88Handler(word) BUILTIN_DefaultIntHandler
+237 register INT_Int89Handler(word) BUILTIN_DefaultIntHandler
+238 register INT_Int8aHandler(word) BUILTIN_DefaultIntHandler
+239 register INT_Int8bHandler(word) BUILTIN_DefaultIntHandler
+240 register INT_Int8cHandler(word) BUILTIN_DefaultIntHandler
+241 register INT_Int8dHandler(word) BUILTIN_DefaultIntHandler
+242 register INT_Int8eHandler(word) BUILTIN_DefaultIntHandler
+243 register INT_Int8fHandler(word) BUILTIN_DefaultIntHandler
+244 register INT_Int90Handler(word) BUILTIN_DefaultIntHandler
+245 register INT_Int91Handler(word) BUILTIN_DefaultIntHandler
+246 register INT_Int92Handler(word) BUILTIN_DefaultIntHandler
+247 register INT_Int93Handler(word) BUILTIN_DefaultIntHandler
+248 register INT_Int94Handler(word) BUILTIN_DefaultIntHandler
+249 register INT_Int95Handler(word) BUILTIN_DefaultIntHandler
+250 register INT_Int96Handler(word) BUILTIN_DefaultIntHandler
+251 register INT_Int97Handler(word) BUILTIN_DefaultIntHandler
+252 register INT_Int98Handler(word) BUILTIN_DefaultIntHandler
+253 register INT_Int99Handler(word) BUILTIN_DefaultIntHandler
+254 register INT_Int9aHandler(word) BUILTIN_DefaultIntHandler
+255 register INT_Int9bHandler(word) BUILTIN_DefaultIntHandler
+256 register INT_Int9cHandler(word) BUILTIN_DefaultIntHandler
+257 register INT_Int9dHandler(word) BUILTIN_DefaultIntHandler
+258 register INT_Int9eHandler(word) BUILTIN_DefaultIntHandler
+259 register INT_Int9fHandler(word) BUILTIN_DefaultIntHandler
+260 register INT_Inta0Handler(word) BUILTIN_DefaultIntHandler
+261 register INT_Inta1Handler(word) BUILTIN_DefaultIntHandler
+262 register INT_Inta2Handler(word) BUILTIN_DefaultIntHandler
+263 register INT_Inta3Handler(word) BUILTIN_DefaultIntHandler
+264 register INT_Inta4Handler(word) BUILTIN_DefaultIntHandler
+265 register INT_Inta5Handler(word) BUILTIN_DefaultIntHandler
+266 register INT_Inta6Handler(word) BUILTIN_DefaultIntHandler
+267 register INT_Inta7Handler(word) BUILTIN_DefaultIntHandler
+268 register INT_Inta8Handler(word) BUILTIN_DefaultIntHandler
+269 register INT_Inta9Handler(word) BUILTIN_DefaultIntHandler
+270 register INT_IntaaHandler(word) BUILTIN_DefaultIntHandler
+271 register INT_IntabHandler(word) BUILTIN_DefaultIntHandler
+272 register INT_IntacHandler(word) BUILTIN_DefaultIntHandler
+273 register INT_IntadHandler(word) BUILTIN_DefaultIntHandler
+274 register INT_IntaeHandler(word) BUILTIN_DefaultIntHandler
+275 register INT_IntafHandler(word) BUILTIN_DefaultIntHandler
+276 register INT_Intb0Handler(word) BUILTIN_DefaultIntHandler
+277 register INT_Intb1Handler(word) BUILTIN_DefaultIntHandler
+278 register INT_Intb2Handler(word) BUILTIN_DefaultIntHandler
+279 register INT_Intb3Handler(word) BUILTIN_DefaultIntHandler
+280 register INT_Intb4Handler(word) BUILTIN_DefaultIntHandler
+281 register INT_Intb5Handler(word) BUILTIN_DefaultIntHandler
+282 register INT_Intb6Handler(word) BUILTIN_DefaultIntHandler
+283 register INT_Intb7Handler(word) BUILTIN_DefaultIntHandler
+284 register INT_Intb8Handler(word) BUILTIN_DefaultIntHandler
+285 register INT_Intb9Handler(word) BUILTIN_DefaultIntHandler
+286 register INT_IntbaHandler(word) BUILTIN_DefaultIntHandler
+287 register INT_IntbbHandler(word) BUILTIN_DefaultIntHandler
+288 register INT_IntbcHandler(word) BUILTIN_DefaultIntHandler
+289 register INT_IntbdHandler(word) BUILTIN_DefaultIntHandler
+290 register INT_IntbeHandler(word) BUILTIN_DefaultIntHandler
+291 register INT_IntbfHandler(word) BUILTIN_DefaultIntHandler
+292 register INT_Intc0Handler(word) BUILTIN_DefaultIntHandler
+293 register INT_Intc1Handler(word) BUILTIN_DefaultIntHandler
+294 register INT_Intc2Handler(word) BUILTIN_DefaultIntHandler
+295 register INT_Intc3Handler(word) BUILTIN_DefaultIntHandler
+296 register INT_Intc4Handler(word) BUILTIN_DefaultIntHandler
+297 register INT_Intc5Handler(word) BUILTIN_DefaultIntHandler
+298 register INT_Intc6Handler(word) BUILTIN_DefaultIntHandler
+299 register INT_Intc7Handler(word) BUILTIN_DefaultIntHandler
+300 register INT_Intc8Handler(word) BUILTIN_DefaultIntHandler
+301 register INT_Intc9Handler(word) BUILTIN_DefaultIntHandler
+302 register INT_IntcaHandler(word) BUILTIN_DefaultIntHandler
+303 register INT_IntcbHandler(word) BUILTIN_DefaultIntHandler
+304 register INT_IntccHandler(word) BUILTIN_DefaultIntHandler
+305 register INT_IntcdHandler(word) BUILTIN_DefaultIntHandler
+306 register INT_IntceHandler(word) BUILTIN_DefaultIntHandler
+307 register INT_IntcfHandler(word) BUILTIN_DefaultIntHandler
+308 register INT_Intd0Handler(word) BUILTIN_DefaultIntHandler
+309 register INT_Intd1Handler(word) BUILTIN_DefaultIntHandler
+310 register INT_Intd2Handler(word) BUILTIN_DefaultIntHandler
+311 register INT_Intd3Handler(word) BUILTIN_DefaultIntHandler
+312 register INT_Intd4Handler(word) BUILTIN_DefaultIntHandler
+313 register INT_Intd5Handler(word) BUILTIN_DefaultIntHandler
+314 register INT_Intd6Handler(word) BUILTIN_DefaultIntHandler
+315 register INT_Intd7Handler(word) BUILTIN_DefaultIntHandler
+316 register INT_Intd8Handler(word) BUILTIN_DefaultIntHandler
+317 register INT_Intd9Handler(word) BUILTIN_DefaultIntHandler
+318 register INT_IntdaHandler(word) BUILTIN_DefaultIntHandler
+319 register INT_IntdbHandler(word) BUILTIN_DefaultIntHandler
+320 register INT_IntdcHandler(word) BUILTIN_DefaultIntHandler
+321 register INT_IntddHandler(word) BUILTIN_DefaultIntHandler
+322 register INT_IntdeHandler(word) BUILTIN_DefaultIntHandler
+323 register INT_IntdfHandler(word) BUILTIN_DefaultIntHandler
+324 register INT_Inte0Handler(word) BUILTIN_DefaultIntHandler
+325 register INT_Inte1Handler(word) BUILTIN_DefaultIntHandler
+326 register INT_Inte2Handler(word) BUILTIN_DefaultIntHandler
+327 register INT_Inte3Handler(word) BUILTIN_DefaultIntHandler
+328 register INT_Inte4Handler(word) BUILTIN_DefaultIntHandler
+329 register INT_Inte5Handler(word) BUILTIN_DefaultIntHandler
+330 register INT_Inte6Handler(word) BUILTIN_DefaultIntHandler
+331 register INT_Inte7Handler(word) BUILTIN_DefaultIntHandler
+332 register INT_Inte8Handler(word) BUILTIN_DefaultIntHandler
+333 register INT_Inte9Handler(word) BUILTIN_DefaultIntHandler
+334 register INT_InteaHandler(word) BUILTIN_DefaultIntHandler
+335 register INT_IntebHandler(word) BUILTIN_DefaultIntHandler
+336 register INT_IntecHandler(word) BUILTIN_DefaultIntHandler
+337 register INT_IntedHandler(word) BUILTIN_DefaultIntHandler
+338 register INT_InteeHandler(word) BUILTIN_DefaultIntHandler
+339 register INT_IntefHandler(word) BUILTIN_DefaultIntHandler
+340 register INT_Intf0Handler(word) BUILTIN_DefaultIntHandler
+341 register INT_Intf1Handler(word) BUILTIN_DefaultIntHandler
+342 register INT_Intf2Handler(word) BUILTIN_DefaultIntHandler
+343 register INT_Intf3Handler(word) BUILTIN_DefaultIntHandler
+344 register INT_Intf4Handler(word) BUILTIN_DefaultIntHandler
+345 register INT_Intf5Handler(word) BUILTIN_DefaultIntHandler
+346 register INT_Intf6Handler(word) BUILTIN_DefaultIntHandler
+347 register INT_Intf7Handler(word) BUILTIN_DefaultIntHandler
+348 register INT_Intf8Handler(word) BUILTIN_DefaultIntHandler
+349 register INT_Intf9Handler(word) BUILTIN_DefaultIntHandler
+350 register INT_IntfaHandler(word) BUILTIN_DefaultIntHandler
+351 register INT_IntfbHandler(word) BUILTIN_DefaultIntHandler
+352 register INT_IntfcHandler(word) BUILTIN_DefaultIntHandler
+353 register INT_IntfdHandler(word) BUILTIN_DefaultIntHandler
+354 register INT_IntfeHandler(word) BUILTIN_DefaultIntHandler
+355 register INT_IntffHandler(word) BUILTIN_DefaultIntHandler
# VxDs. The first Vxd is at 400
#
diff --git a/include/bitmap.h b/include/bitmap.h
index a27edc3..b4a731e 100644
--- a/include/bitmap.h
+++ b/include/bitmap.h
@@ -9,6 +9,7 @@
#include <X11/extensions/XShm.h>
#include "gdi.h"
+#include "xmalloc.h"
#ifdef PRELIMINARY_WING16_SUPPORT
diff --git a/include/commdlg.h b/include/commdlg.h
index db57549..e7a8eab 100644
--- a/include/commdlg.h
+++ b/include/commdlg.h
@@ -277,12 +277,12 @@
BOOL ChooseColor(LPCHOOSECOLOR lpChCol);
DWORD CommDlgExtendedError(void);
-BOOL FindText( SEGPTR find);
+HWND16 FindText( SEGPTR find);
short GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf);
BOOL GetOpenFileName(SEGPTR ofn);
BOOL GetSaveFileName(SEGPTR ofn);
BOOL PrintDlg( SEGPTR print);
-BOOL ReplaceText( SEGPTR find);
+HWND16 ReplaceText( SEGPTR find);
BOOL ChooseFont(LPCHOOSEFONT lpChFont);
LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam);
diff --git a/include/debug.h b/include/debug.h
index 8f2c028..14bc9d0 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -3,16 +3,6 @@
#define stddeb stdout
#define stdnimp stdout
-#ifdef DEBUG_RUNTIME
-#define api_assert(name,test) if (test) ; else \
- { \
- fprintf(stddeb,"API assertion failed for %s: %s\n", name, #test); \
- abort(); \
- }
-#else
-#define api_assert(name,test) ;
-#endif
-
/* Do not remove this line or change anything below this line */
#ifdef DEBUG_NONE_EXT
diff --git a/include/debugger.h b/include/debugger.h
index 306cb18..5a69215 100644
--- a/include/debugger.h
+++ b/include/debugger.h
@@ -7,9 +7,9 @@
#ifndef __WINE_DEBUGGER_H
#define __WINE_DEBUGGER_H
-#include "ldt.h"
-#include "registers.h"
-
+#include "winnt.h"
+#include "selectors.h"
+#include "sigcontext.h"
#include "pe_image.h"
#define STEP_FLAG 0x100 /* single step flag */
@@ -101,7 +101,7 @@
EXEC_STEP_INSTR /* Single-stepping an instruction */
};
-extern SIGCONTEXT *DEBUG_context; /* debugger/registers.c */
+extern CONTEXT DEBUG_context; /* debugger/registers.c */
extern unsigned int dbg_mode;
/* debugger/break.c */
@@ -111,10 +111,9 @@
extern void DEBUG_DelBreakpoint( int num );
extern void DEBUG_EnableBreakpoint( int num, BOOL32 enable );
extern void DEBUG_InfoBreakpoints(void);
-extern BOOL32 DEBUG_HandleTrap( SIGCONTEXT *context );
-extern BOOL32 DEBUG_ShouldContinue( SIGCONTEXT *context, enum exec_mode mode );
-extern void DEBUG_RestartExecution( SIGCONTEXT *context, enum exec_mode mode,
- int instr_len );
+extern BOOL32 DEBUG_HandleTrap(void);
+extern BOOL32 DEBUG_ShouldContinue( enum exec_mode mode );
+extern void DEBUG_RestartExecution( enum exec_mode mode, int instr_len );
/* debugger/db_disasm.c */
extern void DEBUG_Disasm( DBG_ADDR *addr );
@@ -163,6 +162,8 @@
extern int DEBUG_GetRegister( enum debug_regs reg );
extern void DEBUG_InfoRegisters(void);
extern BOOL32 DEBUG_ValidateRegisters(void);
+extern void DEBUG_SetSigContext( const SIGCONTEXT *sigcontext );
+extern void DEBUG_GetSigContext( SIGCONTEXT *sigcontext );
/* debugger/stack.c */
extern void DEBUG_InfoStack(void);
diff --git a/include/dialog.h b/include/dialog.h
index eb95f2f..b9cb5f4 100644
--- a/include/dialog.h
+++ b/include/dialog.h
@@ -38,5 +38,10 @@
#pragma pack(4)
extern BOOL32 DIALOG_Init(void);
+extern HWND32 DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
+ BOOL32 win32Template, HWND32 owner,
+ DLGPROC16 dlgProc, LPARAM param,
+ WINDOWPROCTYPE procType );
+extern INT32 DIALOG_DoDialogBox( HWND32 hwnd, HWND32 owner );
#endif /* DIALOG_H */
diff --git a/include/directory.h b/include/directory.h
deleted file mode 100644
index c9c34a8..0000000
--- a/include/directory.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * DOS directory handling declarations
- *
- * Copyright 1996 Alexandre Julliard
- */
-
-#ifndef __WINE_DIRECTORY_H
-#define __WINE_DIRECTORY_H
-
-extern int DIR_Init(void);
-extern UINT32 DIR_GetWindowsUnixDir( LPSTR path, UINT32 count );
-extern UINT32 DIR_GetSystemUnixDir( LPSTR path, UINT32 count );
-extern UINT32 DIR_GetTempUnixDir( LPSTR path, UINT32 count );
-extern UINT32 DIR_GetDosPath( INT32 element, LPSTR path, UINT32 count );
-extern UINT32 DIR_GetUnixPath( INT32 element, LPSTR path, UINT32 count );
-
-#endif /* __WINE_DIRECTORY_H */
diff --git a/include/dos_fs.h b/include/dos_fs.h
index 4bb2b7f..ec7a717 100644
--- a/include/dos_fs.h
+++ b/include/dos_fs.h
@@ -8,21 +8,10 @@
#define __WINE_DOS_FS_H
#include <time.h>
-#include "wintypes.h"
+#include "windows.h"
-#define MAX_FILENAME_LEN 256
#define MAX_PATHNAME_LEN 1024
-typedef struct
-{
- char name[12]; /* File name in FCB format */
- char unixname[MAX_FILENAME_LEN]; /* Unix file name */
- DWORD size; /* File size in bytes */
- WORD date; /* File date in DOS format */
- WORD time; /* File time in DOS format */
- BYTE attr; /* File DOS attributes */
-} DOS_DIRENT;
-
#define IS_END_OF_NAME(ch) (!(ch) || ((ch) == '/') || ((ch) == '\\'))
extern void DOSFS_ToDosDateTime( time_t unixtime, WORD *pDate, WORD *pTime );
@@ -30,17 +19,16 @@
extern const char *DOSFS_ToDosFCBFormat( const char *name );
extern const char *DOSFS_ToDosDTAFormat( const char *name );
extern const char *DOSFS_IsDevice( const char *name );
+extern BOOL32 DOSFS_FindUnixName( const char *path, const char *name,
+ char *buffer, int maxlen,
+ UINT32 drive_flags );
extern const char * DOSFS_GetUnixFileName( const char * name, int check_last );
extern const char * DOSFS_GetDosTrueName( const char *name, int unix_format );
extern int DOSFS_GetDosFileName( const char *name, char *buffer, int len );
-extern time_t DOSFS_FileTimeToUnixTime(LPFILETIME ft);
+extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft );
extern void DOSFS_UnixTimeToFileTime(time_t unixtime,LPFILETIME ft);
extern int DOSFS_FindNext( const char *path, const char *short_mask,
const char *long_mask, int drive, BYTE attr,
- int skip, DOS_DIRENT *entry );
-
-
-extern int DOS_GetFreeSpace(int drive, long *size, long *available);
-extern char *WineIniFileName(void);
+ int skip, WIN32_FIND_DATA32A *entry );
#endif /* __WINE_DOS_FS_H */
diff --git a/include/except.h b/include/except.h
index 0fbd40e..ff68c39 100644
--- a/include/except.h
+++ b/include/except.h
@@ -6,8 +6,7 @@
#ifndef __WINE_EXCEPT_H
#define __WINE_EXCEPT_H
-#include "wintypes.h"
-#include "registers.h"
+#include "winnt.h"
/*
* exception codes
*/
diff --git a/include/file.h b/include/file.h
index 048383a..4856df6 100644
--- a/include/file.h
+++ b/include/file.h
@@ -8,21 +8,28 @@
#define __WINE_FILE_H
#include "windows.h"
+#include "handle32.h"
+/* files/file.c */
+extern void FILE_Destroy( K32OBJ *ptr );
extern void FILE_SetDosError(void);
-extern void FILE_CloseAllFiles( HANDLE16 hPDB );
-extern HFILE FILE_DupUnixHandle( int fd );
-extern int FILE_Stat( LPCSTR unixName, BYTE *pattr, DWORD *psize,
- WORD *pdate, WORD *ptime );
-extern int FILE_GetDateTime( HFILE hFile, WORD *pdate, WORD *ptime,
- BOOL32 refresh );
-extern int FILE_SetDateTime( HFILE hFile, WORD date, WORD time );
-extern int FILE_Fstat( HFILE hFile, BYTE *pattr, DWORD *psize,
- WORD *pdate, WORD *ptime );
-extern HFILE FILE_Dup( HFILE hFile );
-extern HFILE FILE_Dup2( HFILE hFile1, HFILE hFile2 );
-extern HFILE FILE_Open( LPCSTR path, INT32 mode );
-extern BOOL32 FILE_SetFileType( HFILE hFile, DWORD type );
-extern HFILE _lcreat_uniq( LPCSTR path, INT32 attr );
+extern HFILE32 FILE_DupUnixHandle( int fd );
+extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
+extern HFILE32 FILE_Dup( HFILE32 hFile );
+extern HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 );
+extern HFILE32 FILE_Open( LPCSTR path, INT32 mode );
+extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
+extern HFILE32 _lcreat_uniq( LPCSTR path, INT32 attr );
+
+/* files/directory.c */
+extern int DIR_Init(void);
+extern UINT32 DIR_GetWindowsUnixDir( LPSTR path, UINT32 count );
+extern UINT32 DIR_GetSystemUnixDir( LPSTR path, UINT32 count );
+extern UINT32 DIR_GetTempUnixDir( LPSTR path, UINT32 count );
+extern UINT32 DIR_GetDosPath( INT32 element, LPSTR path, UINT32 count );
+extern UINT32 DIR_GetUnixPath( INT32 element, LPSTR path, UINT32 count );
+extern DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
+ DWORD buflen, LPSTR buffer, LPSTR *lastpart,
+ BOOL32 win32 );
#endif /* __WINE_FILE_H */
diff --git a/include/handle32.h b/include/handle32.h
index 3ad80e1..a589091 100644
--- a/include/handle32.h
+++ b/include/handle32.h
@@ -1,9 +1,49 @@
+/*
+ * KERNEL32 objects
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
#ifndef __WINE_HANDLE32_H
#define __WINE_HANDLE32_H
-#include <stdlib.h>
#include "wintypes.h"
+/* Object types */
+typedef enum
+{
+ K32OBJ_UNKNOWN = 0,
+ K32OBJ_SEMAPHORE,
+ K32OBJ_EVENT,
+ K32OBJ_MUTEX,
+ K32OBJ_CRITICAL_SECTION,
+ K32OBJ_PROCESS,
+ K32OBJ_THREAD,
+ K32OBJ_FILE,
+ K32OBJ_CHANGE,
+ K32OBJ_CONSOLE,
+ K32OBJ_SCREEN_BUFFER,
+ K32OBJ_MEM_MAPPED_FILE,
+ K32OBJ_SERIAL,
+ K32OBJ_DEVICE_IOCTL,
+ K32OBJ_PIPE,
+ K32OBJ_MAILSLOT,
+ K32OBJ_TOOLHELP_SNAPSHOT,
+ K32OBJ_SOCKET,
+ K32OBJ_NBOBJECTS
+} K32OBJ_TYPE;
+
+/* Kernel object */
+typedef struct
+{
+ K32OBJ_TYPE type;
+ DWORD refcount;
+} K32OBJ;
+
+extern void K32OBJ_IncCount( K32OBJ *ptr );
+extern void K32OBJ_DecCount( K32OBJ *ptr );
+
+
/* The _*_OBJECT structures contain information needed about each
* particular type of handle. This information is a combination of
* equivalent UNIX-style handles/descriptors and general information
@@ -17,63 +57,6 @@
unsigned long magic;
} KERNEL_OBJECT;
-typedef struct {
- KERNEL_OBJECT common;
- unsigned long thread_id;
- unsigned long process_id;
-} THREAD_OBJECT;
-
-typedef struct {
- KERNEL_OBJECT common;
- unsigned long process_id;
- unsigned long main_thread_id;
-} PROCESS_OBJECT;
-
-typedef struct {
- KERNEL_OBJECT common;
- HFILE hfile;
- int prot;
- unsigned long size;
-} FILEMAP_OBJECT;
-
-typedef struct {
- KERNEL_OBJECT common;
-} SEMAPHORE_OBJECT;
-
-typedef struct {
- KERNEL_OBJECT common;
-} EVENT_OBJECT;
-
-/* Should this even be here?
- */
-typedef struct {
- KERNEL_OBJECT common;
-} REGKEY_OBJECT;
-
-typedef struct _VRANGE_OBJECT{
- KERNEL_OBJECT common;
- DWORD start;
- DWORD size;
- struct _VRANGE_OBJECT *next;
-} VRANGE_OBJECT;
-
-struct _HEAPITEM_OBJECT;
-typedef struct{
- KERNEL_OBJECT common;
- LPVOID start;
- DWORD size;
- DWORD maximum;
- DWORD flags;
- struct _HEAPITEM_OBJECT *first,*last;
-} HEAP_OBJECT;
-
-typedef struct _HEAPITEM_OBJECT{
- KERNEL_OBJECT common;
- HEAP_OBJECT *heap;
- DWORD size; /* size including header */
- struct _HEAPITEM_OBJECT *next,*prev;
-} HEAPITEM_OBJECT;
-
/* Object number definitions. These numbers are used to
* validate the kernel object by comparison against the
@@ -101,8 +84,4 @@
#define CreateKernelObject(size) (malloc(size))
#define ReleaseKernelObject(ptr) (free(ptr))
-/* Prototypes for the Close*Handle functions
- */
-int CloseFileHandle(HFILE hFile);
-
#endif /* __WINE_HANDLE32_H */
diff --git a/include/heap.h b/include/heap.h
index 5cdfdeb..8459eba 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -15,6 +15,7 @@
extern int HEAP_IsInsideHeap( HANDLE32 heap, DWORD flags, LPCVOID ptr );
extern SEGPTR HEAP_GetSegptr( HANDLE32 heap, DWORD flags, LPCVOID ptr );
+extern LPVOID HEAP_xalloc( HANDLE32 heap, DWORD flags, DWORD size );
extern LPSTR HEAP_strdupA( HANDLE32 heap, DWORD flags, LPCSTR str );
extern LPWSTR HEAP_strdupW( HANDLE32 heap, DWORD flags, LPCWSTR str );
extern LPWSTR HEAP_strdupAtoW( HANDLE32 heap, DWORD flags, LPCSTR str );
diff --git a/include/menu.h b/include/menu.h
index bdb3b12..4cd9318 100644
--- a/include/menu.h
+++ b/include/menu.h
@@ -10,8 +10,8 @@
extern void MENU_InitSysMenuPopup(HMENU16 hmenu, DWORD style, DWORD clsStyle);
extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth,
int orgX, int orgY );
-extern void MENU_TrackMouseMenuBar( HWND hwnd, POINT16 pt );
-extern void MENU_TrackKbdMenuBar( WND*, UINT wParam, INT vkey);
+extern void MENU_TrackMouseMenuBar( WND* , INT16 ht, POINT16 pt );
+extern void MENU_TrackKbdMenuBar( WND*, UINT16 wParam, INT16 vkey);
extern UINT MENU_DrawMenuBar( HDC32 hDC, LPRECT16 lprect,
HWND hwnd, BOOL suppress_draw );
extern LRESULT PopupMenuWndProc( HWND hwnd, UINT message,
diff --git a/include/message.h b/include/message.h
index f51efd2..8a59d79 100644
--- a/include/message.h
+++ b/include/message.h
@@ -33,5 +33,7 @@
extern void EVENT_RegisterWindow( WND *pWnd );
extern void EVENT_DestroyWindow( WND *pWnd );
extern void EVENT_DummyMotionNotify(void);
+extern HWND32 EVENT_Capture( HWND32, INT16 );
+extern INT16 EVENT_GetCaptureInfo(void);
#endif /* __WINE_MESSAGE_H */
diff --git a/include/miscemu.h b/include/miscemu.h
index c876e60..bacc10e 100644
--- a/include/miscemu.h
+++ b/include/miscemu.h
@@ -8,38 +8,35 @@
#define __WINE_MISCEMU_H
#include <stdio.h>
-#include "wintypes.h"
-#include "registers.h"
+#include "winnt.h"
/* miscemu/dosmem.c */
extern BOOL32 DOSMEM_Init(void);
extern void DOSMEM_Tick(void);
extern void DOSMEM_FillBiosSegment(void);
-extern HANDLE16 DOSMEM_BiosSeg;
extern void DOSMEM_InitMemoryHandling();
extern LPVOID DOSMEM_RealMode2Linear(DWORD);
extern WORD DOSMEM_AllocSelector(WORD);
+extern HANDLE16 DOSMEM_BiosSeg;
+extern char *DOSMEM_dosmem;
extern DWORD DOSMEM_CollateTable;
-extern void DOSMEM_InitCollateTable();
- /* miscemu/instr.c */
-extern BOOL32 INSTR_EmulateInstruction( SIGCONTEXT *context );
-
- /* miscemu/interrupts.c */
+/* miscemu/interrupts.c */
extern BOOL32 INT_Init(void);
+
+/* msdos/interrupts.c */
extern FARPROC16 INT_GetHandler( BYTE intnum );
extern void INT_SetHandler( BYTE intnum, FARPROC16 handler );
- /* miscemu/int1a.c */
+/* msdos/ioports.c */
+extern DWORD IO_inport( int port, int count );
+extern void IO_outport( int port, int count, DWORD value );
+
+/* msdos/int1a.c */
extern DWORD INT1A_GetTicksSinceMidnight(void);
- /* miscemu/int21.c */
-extern BOOL32 INT21_Init(void);
-
- /* miscemu/ioports.c */
-extern DWORD inport( int port, int count );
-extern void outport( int port, int count, DWORD value );
-
+/* misc/cpu.c */
+extern int runtime_cpu(void);
#define INT_BARF(context,num) \
fprintf( stderr, "int%x: unknown/not implemented parameters:\n" \
@@ -47,6 +44,6 @@
"SI %04x, DI %04x, DS %04x, ES %04x\n", \
(num), (num), AX_reg(context), BX_reg(context), CX_reg(context), \
DX_reg(context), SI_reg(context), DI_reg(context), \
- DS_reg(context), ES_reg(context) )
+ (WORD)DS_reg(context), (WORD)ES_reg(context) )
#endif /* __WINE_MISCEMU_H */
diff --git a/include/msdos.h b/include/msdos.h
index 96a8732..355aed7 100644
--- a/include/msdos.h
+++ b/include/msdos.h
@@ -84,7 +84,8 @@
extern BYTE DOS_ErrorClass, DOS_ErrorAction, DOS_ErrorLocus;
#define DOS_ERROR(err,class,action,locus) \
- ( DOS_ErrorClass = (class), DOS_ErrorAction = (action), \
+ ( SetLastError(err), \
+ DOS_ErrorClass = (class), DOS_ErrorAction = (action), \
DOS_ErrorLocus = (locus), DOS_ExtendedError = (err) )
/* Error codes */
diff --git a/include/process.h b/include/process.h
new file mode 100644
index 0000000..ca5670c
--- /dev/null
+++ b/include/process.h
@@ -0,0 +1,105 @@
+/*
+ * Process definitions
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#ifndef __WINE_PROCESS_H
+#define __WINE_PROCESS_H
+
+#include "windows.h"
+#include "winbase.h"
+#include "handle32.h"
+
+/* Process handle entry */
+typedef struct
+{
+ DWORD flags; /* Handle flags */
+ K32OBJ *ptr; /* Object ptr */
+} HANDLE_ENTRY;
+
+/* Process handle table */
+typedef struct
+{
+ DWORD count;
+ HANDLE_ENTRY entries[1];
+} HANDLE_TABLE;
+
+/* Win32 process environment database */
+typedef struct
+{
+ LPSTR environ; /* 00 Process environment strings */
+ DWORD unknown1; /* 04 Unknown */
+ LPSTR cmd_line; /* 08 Command line */
+ LPSTR cur_dir; /* 0c Current directory */
+ STARTUPINFO32A *startup_info; /* 10 Startup information */
+ HANDLE32 hStdin; /* 14 Handle for standard input */
+ HANDLE32 hStdout; /* 18 Handle for standard output */
+ HANDLE32 hStderr; /* 1c Handle for standard error */
+ DWORD unknown2; /* 20 Unknown */
+ DWORD inherit_console; /* 24 Inherit console flag */
+ DWORD break_type; /* 28 Console events flag */
+ K32OBJ *break_sem; /* 2c SetConsoleCtrlHandler semaphore */
+ K32OBJ *break_event; /* 30 SetConsoleCtrlHandler event */
+ K32OBJ *break_thread; /* 34 SetConsoleCtrlHandler thread */
+ void *break_handlers; /* 38 List of console handlers */
+} ENVDB;
+
+/* Win32 process database */
+typedef struct _PDB32
+{
+ K32OBJ header; /* 00 Kernel object header */
+ DWORD unknown1; /* 08 Unknown */
+ K32OBJ *event; /* 0c Pointer to an event object */
+ DWORD exit_code; /* 10 Process exit code */
+ DWORD unknown2; /* 14 Unknown */
+ HANDLE32 heap; /* 18 Default process heap */
+ HANDLE32 mem_context; /* 1c Process memory context */
+ DWORD flags; /* 20 Flags */
+ void *pdb16; /* 24 DOS PSP */
+ WORD PSP_sel; /* 28 Selector to DOS PSP */
+ WORD module; /* 2a IMTE for the process module */
+ WORD threads; /* 2c Number of threads */
+ WORD running_threads; /* 2e Number of running threads */
+ WORD unknown3; /* 30 Unknown */
+ WORD ring0_threads; /* 32 Number of ring 0 threads */
+ HANDLE32 system_heap; /* 34 System heap to allocate handles */
+ HTASK32 task; /* 38 Win16 task */
+ void *mem_map_files; /* 3c Pointer to mem-mapped files */
+ ENVDB *env_DB; /* 40 Environment database */
+ HANDLE_TABLE *handle_table; /* 44 Handle table */
+ struct _PDB32 *parent; /* 48 Parent process */
+ void *modref_list; /* 4c MODREF list */
+ void *thread_list; /* 50 List of threads */
+ void *debuggee_CB; /* 54 Debuggee context block */
+ void *local_heap_free; /* 58 Head of local heap free list */
+ DWORD unknown4; /* 5c Unknown */
+ CRITICAL_SECTION crit_section; /* 60 Critical section */
+ DWORD unknown5[3]; /* 78 Unknown */
+ K32OBJ *console; /* 84 Console */
+ DWORD tls_bits[2]; /* 88 TLS in-use bits */
+ DWORD process_dword; /* 90 Unknown */
+ struct _PDB32 *group; /* 94 Process group */
+ void *exe_modref; /* 98 MODREF for the process EXE */
+ void *top_exc_filter; /* 9c Top exception filter */
+ DWORD priority; /* a0 Priority level */
+ HANDLE32 heap_list; /* a4 Head of process heap list */
+ void *heap_handles; /* a8 Head of heap handles list */
+ DWORD unknown6; /* ac Unknown */
+ K32OBJ *console_provider; /* b0 Console provider (??) */
+ WORD env_selector; /* b4 Selector to process environment */
+ WORD error_mode; /* b6 Error mode */
+ K32OBJ *load_done_evt; /* b8 Event for process loading done */
+ DWORD unknown7; /* bc Unknown */
+} PDB32;
+
+extern HANDLE32 PROCESS_AllocHandle( K32OBJ *ptr, DWORD flags);
+extern K32OBJ *PROCESS_GetObjPtr( HANDLE32 handle, K32OBJ_TYPE type );
+extern BOOL32 PROCESS_SetObjPtr( HANDLE32 handle, K32OBJ *ptr, DWORD flags );
+
+extern PDB32 *PROCESS_Create(void);
+extern void PROCESS_Destroy( K32OBJ *ptr );
+
+extern PDB32 *pCurrentProcess;
+
+#endif /* __WINE_PROCESS_H */
diff --git a/include/registers.h b/include/registers.h
deleted file mode 100644
index 6c93955..0000000
--- a/include/registers.h
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Register definitions
- *
- * Copyright 1995 Alexandre Julliard
- */
-
-#ifndef __WINE_REGISTERS_H
-#define __WINE_REGISTERS_H
-
-#include "wintypes.h"
-
-/* The Win32 register context */
-
-#define CONTEXT_i386 0x00010000
-#define CONTEXT_i486 CONTEXT_i386
-#define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
-#define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
-#define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
-#define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
-#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
-#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
-
-#define SIZE_OF_80387_REGISTERS 80
-
-typedef struct
-{
- DWORD ControlWord;
- DWORD StatusWord;
- DWORD TagWord;
- DWORD ErrorOffset;
- DWORD ErrorSelector;
- DWORD DataOffset;
- DWORD DataSelector;
- BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
- DWORD Cr0NpxState;
-} FLOATING_SAVE_AREA;
-
-typedef struct
-{
- DWORD ContextFlags;
-
- /* These are selected by CONTEXT_DEBUG_REGISTERS */
- DWORD Dr0;
- DWORD Dr1;
- DWORD Dr2;
- DWORD Dr3;
- DWORD Dr6;
- DWORD Dr7;
-
- /* These are selected by CONTEXT_FLOATING_POINT */
- FLOATING_SAVE_AREA FloatSave;
-
- /* These are selected by CONTEXT_SEGMENTS */
- DWORD SegGs;
- DWORD SegFs;
- DWORD SegEs;
- DWORD SegDs;
-
- /* These are selected by CONTEXT_INTEGER */
- DWORD Edi;
- DWORD Esi;
- DWORD Ebx;
- DWORD Edx;
- DWORD Ecx;
- DWORD Eax;
-
- /* These are selected by CONTEXT_CONTROL */
- DWORD Ebp;
- DWORD Eip;
- DWORD SegCs;
- DWORD EFlags;
- DWORD Esp;
- DWORD SegSs;
-} CONTEXT, *PCONTEXT;
-
-#ifndef WINELIB
-
-#ifdef i386
-extern int runtime_cpu (void);
-#else
-static inline int runtime_cpu(void) { return 3; }
-#endif
-
-#ifdef linux
-typedef struct
-{
- unsigned short sc_gs, __gsh;
- unsigned short sc_fs, __fsh;
- unsigned short sc_es, __esh;
- unsigned short sc_ds, __dsh;
- unsigned long sc_edi;
- unsigned long sc_esi;
- unsigned long sc_ebp;
- unsigned long sc_esp;
- unsigned long sc_ebx;
- unsigned long sc_edx;
- unsigned long sc_ecx;
- unsigned long sc_eax;
- unsigned long sc_trapno;
- unsigned long sc_err;
- unsigned long sc_eip;
- unsigned short sc_cs, __csh;
- unsigned long sc_eflags;
- unsigned long esp_at_signal;
- unsigned short sc_ss, __ssh;
- unsigned long i387;
- unsigned long oldmask;
- unsigned long cr2;
-} SIGCONTEXT;
-#define WINE_DATA_SELECTOR 0x2b
-#define WINE_CODE_SELECTOR 0x23
-#endif /* linux */
-
-#ifdef __NetBSD__
-#include <signal.h>
-typedef struct sigcontext SIGCONTEXT;
-#define WINE_DATA_SELECTOR 0x1f
-#define WINE_CODE_SELECTOR 0x17
-#endif /* NetBSD */
-
-#if defined(__svr4__) || defined(_SCO_DS)
-#include <signal.h>
-#ifdef _SCO_DS
-#include <sys/regset.h>
-#endif
-#include <sys/ucontext.h>
-typedef struct ucontext SIGCONTEXT;
-#define WINE_DATA_SELECTOR 0x1f
-#define WINE_CODE_SELECTOR 0x17
-#endif /* svr4 || SCO_DS */
-
-#ifdef __FreeBSD__
-#include <signal.h>
-typedef struct sigcontext SIGCONTEXT;
-#define WINE_DATA_SELECTOR 0x27
-#define WINE_CODE_SELECTOR 0x1f
-#endif /* FreeBSD */
-
-#if !defined(__svr4__) && !defined(_SCO_DS)
-
-#define EAX_reg(context) ((context)->sc_eax)
-#define EBX_reg(context) ((context)->sc_ebx)
-#define ECX_reg(context) ((context)->sc_ecx)
-#define EDX_reg(context) ((context)->sc_edx)
-#define ESI_reg(context) ((context)->sc_esi)
-#define EDI_reg(context) ((context)->sc_edi)
-#define EBP_reg(context) ((context)->sc_ebp)
-
-#define CS_reg(context) ((context)->sc_cs)
-#define DS_reg(context) ((context)->sc_ds)
-#define ES_reg(context) ((context)->sc_es)
-#define SS_reg(context) ((context)->sc_ss)
-
-#ifdef linux
-/* fs and gs are not supported on *BSD. Hopefully we won't need them. */
-#define FS_reg(context) ((context)->sc_fs)
-#define GS_reg(context) ((context)->sc_gs)
-#endif
-
-#ifndef __FreeBSD__
-#define EFL_reg(context) ((context)->sc_eflags)
-#else
-#define EFL_reg(context) ((context)->sc_efl)
-#endif
-
-#define EIP_reg(context) ((context)->sc_eip)
-#define ESP_reg(context) ((context)->sc_esp)
-
-#else /* __svr4__ || _SCO_DS */
-
-#ifdef _SCO_DS
-#define gregs regs
-#endif
-
-#define EAX_reg(context) ((context)->uc_mcontext.gregs[EAX])
-#define EBX_reg(context) ((context)->uc_mcontext.gregs[EBX])
-#define ECX_reg(context) ((context)->uc_mcontext.gregs[ECX])
-#define EDX_reg(context) ((context)->uc_mcontext.gregs[EDX])
-#define ESI_reg(context) ((context)->uc_mcontext.gregs[ESI])
-#define EDI_reg(context) ((context)->uc_mcontext.gregs[EDI])
-#define EBP_reg(context) ((context)->uc_mcontext.gregs[EBP])
-
-#define CS_reg(context) ((context)->uc_mcontext.gregs[CS])
-#define DS_reg(context) ((context)->uc_mcontext.gregs[DS])
-#define ES_reg(context) ((context)->uc_mcontext.gregs[ES])
-#define SS_reg(context) ((context)->uc_mcontext.gregs[SS])
-
-#define FS_reg(context) ((context)->uc_mcontext.gregs[FS])
-#define GS_reg(context) ((context)->uc_mcontext.gregs[GS])
-
-#define EFL_reg(context) ((context)->uc_mcontext.gregs[EFL])
-
-#define EIP_reg(context) ((context)->uc_mcontext.gregs[EIP])
-#ifdef R_ESP
-#define ESP_reg(context) ((context)->uc_mcontext.gregs[R_ESP])
-#else
-#define ESP_reg(context) ((context)->uc_mcontext.gregs[ESP])
-#endif
-
-#endif /* __svr4__ || _SCO_DS */
-
-#define AX_reg(context) (*(WORD*)&EAX_reg(context))
-#define BX_reg(context) (*(WORD*)&EBX_reg(context))
-#define CX_reg(context) (*(WORD*)&ECX_reg(context))
-#define DX_reg(context) (*(WORD*)&EDX_reg(context))
-#define SI_reg(context) (*(WORD*)&ESI_reg(context))
-#define DI_reg(context) (*(WORD*)&EDI_reg(context))
-#define BP_reg(context) (*(WORD*)&EBP_reg(context))
-
-#define AL_reg(context) (*(BYTE*)&EAX_reg(context))
-#define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
-#define BL_reg(context) (*(BYTE*)&EBX_reg(context))
-#define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
-#define CL_reg(context) (*(BYTE*)&ECX_reg(context))
-#define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
-#define DL_reg(context) (*(BYTE*)&EDX_reg(context))
-#define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
-
-#define IP_reg(context) (*(WORD*)&EIP_reg(context))
-#define SP_reg(context) (*(WORD*)&ESP_reg(context))
-
-#define FL_reg(context) (*(WORD*)&EFL_reg(context))
-
-#define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
-#define RESET_CFLAG(context) (EFL_reg(context) &= 0xfffffffe)
-
-#else /* ifndef WINELIB */
-
-typedef void SIGCONTEXT;
-#define WINE_DATA_SELECTOR 0x00
-#define WINE_CODE_SELECTOR 0x00
-
-#endif /* ifndef WINELIB */
-
-#endif /* __WINE_REGISTERS_H */
diff --git a/include/resource.h b/include/resource.h
index 2540faf..0898fed 100644
--- a/include/resource.h
+++ b/include/resource.h
@@ -54,5 +54,6 @@
extern HGLOBAL16 SYSRES_LoadResource( SYSTEM_RESOURCE id );
extern void SYSRES_FreeResource( HGLOBAL16 handle );
+extern LPCVOID SYSRES_GetResPtr( SYSTEM_RESOURCE id );
#endif /* __WINE_RESOURCE_H */
diff --git a/include/selectors.h b/include/selectors.h
index 66495c7..b8e1196 100644
--- a/include/selectors.h
+++ b/include/selectors.h
@@ -18,4 +18,33 @@
BOOL32 readonly );
extern void SELECTOR_FreeBlock( WORD sel, WORD count );
+#ifndef WINELIB
+
+#ifdef linux
+#define WINE_DATA_SELECTOR 0x2b
+#define WINE_CODE_SELECTOR 0x23
+#endif /* linux */
+
+#ifdef __NetBSD__
+#define WINE_DATA_SELECTOR 0x1f
+#define WINE_CODE_SELECTOR 0x17
+#endif /* NetBSD */
+
+#ifdef __FreeBSD__
+#define WINE_DATA_SELECTOR 0x27
+#define WINE_CODE_SELECTOR 0x1f
+#endif /* FreeBSD */
+
+#if defined(__svr4__) || defined(_SCO_DS)
+#define WINE_DATA_SELECTOR 0x1f
+#define WINE_CODE_SELECTOR 0x17
+#endif /* svr4 || SCO_DS */
+
+#else /* WINELIB */
+
+#define WINE_DATA_SELECTOR 0x00
+#define WINE_CODE_SELECTOR 0x00
+
+#endif /* WINELIB */
+
#endif /* __WINE_SELECTORS_H */
diff --git a/include/shell.h b/include/shell.h
index 4a7e0cd..49cade42 100644
--- a/include/shell.h
+++ b/include/shell.h
@@ -13,8 +13,6 @@
#define MAX_PATH 260
#endif
-extern INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
- HICON16 hIcon);
extern void SHELL_LoadRegistry();
extern void SHELL_SaveRegistry();
extern void SHELL_Init();
@@ -81,6 +79,6 @@
#define SE_ERR_DDEBUSY 30
#define SE_ERR_NOASSOC 31
-LRESULT AboutDlgProc(HWND hWnd,UINT msg,WPARAM16 wParam,LPARAM lParam);
+LRESULT AboutDlgProc(HWND32 hWnd,UINT32 msg,WPARAM16 wParam,LPARAM lParam);
#endif /* __WINE_SHELL_H */
diff --git a/include/sigcontext.h b/include/sigcontext.h
new file mode 100644
index 0000000..24e5a59
--- /dev/null
+++ b/include/sigcontext.h
@@ -0,0 +1,146 @@
+/*
+ * Signal context definitions
+ *
+ * Copyright 1995 Alexandre Julliard
+ */
+
+#ifndef __WINE_SIGCONTEXT_H
+#define __WINE_SIGCONTEXT_H
+
+#ifdef WINELIB
+#error This file must not be used in Winelib
+#endif
+
+#ifdef linux
+typedef struct
+{
+ unsigned short sc_gs, __gsh;
+ unsigned short sc_fs, __fsh;
+ unsigned short sc_es, __esh;
+ unsigned short sc_ds, __dsh;
+ unsigned long sc_edi;
+ unsigned long sc_esi;
+ unsigned long sc_ebp;
+ unsigned long sc_esp;
+ unsigned long sc_ebx;
+ unsigned long sc_edx;
+ unsigned long sc_ecx;
+ unsigned long sc_eax;
+ unsigned long sc_trapno;
+ unsigned long sc_err;
+ unsigned long sc_eip;
+ unsigned short sc_cs, __csh;
+ unsigned long sc_eflags;
+ unsigned long esp_at_signal;
+ unsigned short sc_ss, __ssh;
+ unsigned long i387;
+ unsigned long oldmask;
+ unsigned long cr2;
+} SIGCONTEXT;
+#endif /* linux */
+
+#ifdef __NetBSD__
+#include <signal.h>
+typedef struct sigcontext SIGCONTEXT;
+#endif /* NetBSD */
+
+#if defined(__svr4__) || defined(_SCO_DS)
+#include <signal.h>
+#ifdef _SCO_DS
+#include <sys/regset.h>
+#endif
+#include <sys/ucontext.h>
+typedef struct ucontext SIGCONTEXT;
+#endif /* svr4 || SCO_DS */
+
+#ifdef __FreeBSD__
+#include <signal.h>
+typedef struct sigcontext SIGCONTEXT;
+#endif /* FreeBSD */
+
+#if !defined(__svr4__) && !defined(_SCO_DS)
+
+#define EAX_sig(context) ((context)->sc_eax)
+#define EBX_sig(context) ((context)->sc_ebx)
+#define ECX_sig(context) ((context)->sc_ecx)
+#define EDX_sig(context) ((context)->sc_edx)
+#define ESI_sig(context) ((context)->sc_esi)
+#define EDI_sig(context) ((context)->sc_edi)
+#define EBP_sig(context) ((context)->sc_ebp)
+
+#define CS_sig(context) ((context)->sc_cs)
+#define DS_sig(context) ((context)->sc_ds)
+#define ES_sig(context) ((context)->sc_es)
+#define SS_sig(context) ((context)->sc_ss)
+
+#ifdef linux
+/* fs and gs are not supported on *BSD. Hopefully we won't need them. */
+#define FS_sig(context) ((context)->sc_fs)
+#define GS_sig(context) ((context)->sc_gs)
+#endif
+
+#ifndef __FreeBSD__
+#define EFL_sig(context) ((context)->sc_eflags)
+#else
+#define EFL_sig(context) ((context)->sc_efl)
+#endif
+
+#define EIP_sig(context) ((context)->sc_eip)
+#define ESP_sig(context) ((context)->sc_esp)
+
+#else /* __svr4__ || _SCO_DS */
+
+#ifdef _SCO_DS
+#define gregs regs
+#endif
+
+#define EAX_sig(context) ((context)->uc_mcontext.gregs[EAX])
+#define EBX_sig(context) ((context)->uc_mcontext.gregs[EBX])
+#define ECX_sig(context) ((context)->uc_mcontext.gregs[ECX])
+#define EDX_sig(context) ((context)->uc_mcontext.gregs[EDX])
+#define ESI_sig(context) ((context)->uc_mcontext.gregs[ESI])
+#define EDI_sig(context) ((context)->uc_mcontext.gregs[EDI])
+#define EBP_sig(context) ((context)->uc_mcontext.gregs[EBP])
+
+#define CS_sig(context) ((context)->uc_mcontext.gregs[CS])
+#define DS_sig(context) ((context)->uc_mcontext.gregs[DS])
+#define ES_sig(context) ((context)->uc_mcontext.gregs[ES])
+#define SS_sig(context) ((context)->uc_mcontext.gregs[SS])
+
+#define FS_sig(context) ((context)->uc_mcontext.gregs[FS])
+#define GS_sig(context) ((context)->uc_mcontext.gregs[GS])
+
+#define EFL_sig(context) ((context)->uc_mcontext.gregs[EFL])
+
+#define EIP_sig(context) ((context)->uc_mcontext.gregs[EIP])
+#ifdef R_ESP
+#define ESP_sig(context) ((context)->uc_mcontext.gregs[R_ESP])
+#else
+#define ESP_sig(context) ((context)->uc_mcontext.gregs[ESP])
+#endif
+
+#endif /* __svr4__ || _SCO_DS */
+
+#define AX_sig(context) (*(WORD*)&EAX_sig(context))
+#define BX_sig(context) (*(WORD*)&EBX_sig(context))
+#define CX_sig(context) (*(WORD*)&ECX_sig(context))
+#define DX_sig(context) (*(WORD*)&EDX_sig(context))
+#define SI_sig(context) (*(WORD*)&ESI_sig(context))
+#define DI_sig(context) (*(WORD*)&EDI_sig(context))
+#define BP_sig(context) (*(WORD*)&EBP_sig(context))
+
+#define AL_sig(context) (*(BYTE*)&EAX_sig(context))
+#define AH_sig(context) (*((BYTE*)&EAX_sig(context)+1))
+#define BL_sig(context) (*(BYTE*)&EBX_sig(context))
+#define BH_sig(context) (*((BYTE*)&EBX_sig(context)+1))
+#define CL_sig(context) (*(BYTE*)&ECX_sig(context))
+#define CH_sig(context) (*((BYTE*)&ECX_sig(context)+1))
+#define DL_sig(context) (*(BYTE*)&EDX_sig(context))
+#define DH_sig(context) (*((BYTE*)&EDX_sig(context)+1))
+
+#define IP_sig(context) (*(WORD*)&EIP_sig(context))
+#define SP_sig(context) (*(WORD*)&ESP_sig(context))
+
+#define FL_sig(context) (*(WORD*)&EFL_sig(context))
+
+#endif /* __WINE_SIGCONTEXT_H */
diff --git a/include/stackframe.h b/include/stackframe.h
index bc46ce0..736e104 100644
--- a/include/stackframe.h
+++ b/include/stackframe.h
@@ -51,7 +51,6 @@
/* Saved 32-bit stack for current process (Win16 only) */
extern DWORD IF1632_Saved32_esp;
-extern SEGPTR IF1632_Stack32_base;
/* Original Unix stack */
extern DWORD IF1632_Original32_esp;
diff --git a/include/string32.h b/include/string32.h
index f8f234d..371b5cc 100644
--- a/include/string32.h
+++ b/include/string32.h
@@ -10,7 +10,6 @@
#include "wintypes.h"
-LPSTR STRING32_DupUniToAnsi(LPCWSTR src);
LPWSTR STRING32_DupAnsiToUni(LPCSTR src);
LPWSTR STRING32_strdupW(LPCWSTR);
diff --git a/include/task.h b/include/task.h
index 04c48ba..df65c60 100644
--- a/include/task.h
+++ b/include/task.h
@@ -47,6 +47,7 @@
#define THUNK_MAGIC ('P' | ('T' << 8))
+struct _THDB;
/* Task database. See 'Windows Internals' p. 226 */
typedef struct
@@ -55,9 +56,8 @@
WORD sp; /* 02 Stack pointer of task */
WORD ss; /* 04 Stack segment of task */
WORD nEvents; /* 06 Events for this task */
- char priority; /* 08 Task priority, -32..15 */
- BYTE unused1; /* 09 */
- HGLOBAL16 hStack32; /* 0a Handle to 32-bit stack */
+ INT16 priority; /* 08 Task priority, -32..15 */
+ WORD unused1; /* 0a */
HTASK16 hSelf; /* 0c Selector of this TDB */
HANDLE16 hPrevInstance; /* 0e Previous instance of module */
DWORD esp; /* 10 32-bit stack pointer */
@@ -81,7 +81,9 @@
DWORD int3e WINE_PACKED; /* 46 int 3e (80x87 emu) handler */
DWORD int75 WINE_PACKED; /* 4a int 75 (80x87 error) handler */
DWORD compat_flags WINE_PACKED; /* 4e Compatibility flags */
- BYTE unused4[14]; /* 52 */
+ BYTE unused4[2]; /* 52 */
+ struct _THDB *thdb; /* 54 Pointer to thread database */
+ BYTE unused5[8]; /* 58 */
HANDLE16 hPDB; /* 60 Selector of PDB (i.e. PSP) */
SEGPTR dta WINE_PACKED; /* 62 Current DTA */
BYTE curdrive; /* 66 Current drive */
@@ -113,5 +115,6 @@
HANDLE16 hEnvironment, LPCSTR cmdLine,
UINT16 cmdShow );
extern void TASK_KillCurrentTask( INT16 exitCode );
+extern HTASK16 TASK_GetNextTask( HTASK16 hTask );
#endif /* _WINE_TASK_H */
diff --git a/include/thread.h b/include/thread.h
new file mode 100644
index 0000000..11d9cbb
--- /dev/null
+++ b/include/thread.h
@@ -0,0 +1,81 @@
+/*
+ * Thread definitions
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#ifndef __WINE_THREAD_H
+#define __WINE_THREAD_H
+
+#include "process.h"
+
+/* Thread exception block */
+typedef struct _TEB
+{
+ void *except; /* 00 Head of exception handling chain */
+ void *stack_top; /* 04 Top of thread stack */
+ void *stack_low; /* 08 Stack low-water mark */
+ HTASK16 htask16; /* 0c Win16 task handle */
+ WORD stack_sel; /* 0e 16-bit stack selector */
+ DWORD selman_list; /* 10 Selector manager list */
+ DWORD user_ptr; /* 14 User pointer */
+ struct _TEB *self; /* 18 Pointer to this structure */
+ WORD flags; /* 1c Flags */
+ WORD mutex_count; /* 1e Win16 mutex count */
+ DWORD debug_context; /* 20 Debug context */
+ DWORD *ppriority; /* 24 Pointer to current priority */
+ HQUEUE16 queue; /* 28 Message queue */
+ WORD pad1; /* 2a */
+ LPVOID *tls_ptr; /* 2c Pointer to TLS array */
+} TEB;
+
+/* Thread database */
+typedef struct _THDB
+{
+ K32OBJ header; /* 00 Kernel object header */
+ PDB32 *process; /* 08 Process owning this thread */
+ K32OBJ *event; /* 0c Thread event */
+ TEB teb; /* 10 Thread information block */
+ PDB32 *process2; /* 40 Same as offset 08 (?) */
+ DWORD flags; /* 44 Flags */
+ DWORD exit_code; /* 48 Termination status */
+ WORD teb_sel; /* 4c Selector to TEB */
+ WORD emu_sel; /* 4e 80387 emulator selector */
+ DWORD unknown1; /* 50 Unknown */
+ void *wait_list; /* 54 Event waiting list */
+ DWORD unknown2; /* 58 Unknown */
+ void *ring0_thread; /* 5c Pointer to ring 0 thread */
+ void *ptdbx; /* 60 Pointer to TDBX structure */
+ void *stack_base; /* 64 Base of the stack */
+ void *exit_stack; /* 68 Stack pointer on thread exit */
+ void *emu_data; /* 6c Related to 80387 emulation */
+ DWORD last_error; /* 70 Last error code */
+ void *debugger_CB; /* 74 Debugger context block */
+ DWORD debug_thread; /* 78 Thread debugging this one (?) */
+ void *context; /* 7c Thread register context */
+ DWORD unknown3[3]; /* 80 Unknown */
+ WORD current_ss; /* 8c Another 16-bit stack selector */
+ WORD pad2; /* 8e */
+ void *ss_table; /* 90 Pointer to info about 16-bit stack */
+ WORD thunk_ss; /* 94 Yet another 16-bit stack selector */
+ WORD pad3; /* 96 */
+ LPVOID tls_array[64]; /* 98 Thread local storage */
+ DWORD delta_priority; /* 198 Priority delta */
+ DWORD unknown4[7]; /* 19c Unknown */
+ void *create_data; /* 1b8 Pointer to creation structure */
+ DWORD suspend_count; /* 1bc SuspendThread() counter */
+ DWORD unknown5[9]; /* 1c0 Unknown */
+ K32OBJ *crit_section; /* 1e4 Some critical section */
+ K32OBJ *win16_mutex; /* 1e8 Pointer to Win16 mutex */
+ K32OBJ *win32_mutex; /* 1ec Pointer to KERNEL32 mutex */
+ K32OBJ *crit_section2; /* 1f0 Another critical section */
+ DWORD unknown6[2]; /* 1f4 Unknown */
+} THDB;
+
+
+extern THDB *THREAD_Create( PDB32 *pdb, DWORD stack_size );
+extern void THREAD_Destroy( K32OBJ *ptr );
+
+extern THDB *pCurrentThread;
+
+#endif /* __WINE_THREAD_H */
diff --git a/include/winbase.h b/include/winbase.h
index 411c42b..5b432c7 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -3,8 +3,6 @@
#include "windows.h"
-#define INVALID_HANDLE_VALUE ((HANDLE32) -1)
-
#define WAIT_FAILED 0xffffffff
#define WAIT_OBJECT_0 0
#define WAIT_ABANDONED STATUS_ABANDONED_WAIT_0
@@ -148,7 +146,6 @@
void DeleteCriticalSection(CRITICAL_SECTION *lpCrit);
void EnterCriticalSection(CRITICAL_SECTION *lpCrit);
-int GetCurrentProcessId(void);
void InitializeCriticalSection(CRITICAL_SECTION *lpCrit);
void LeaveCriticalSection(CRITICAL_SECTION *lpCrit);
HANDLE32 OpenProcess(DWORD access, BOOL32 inherit, DWORD id);
diff --git a/include/windows.h b/include/windows.h
index be336a8..e0d8cd4 100644
--- a/include/windows.h
+++ b/include/windows.h
@@ -6,7 +6,6 @@
#endif
#include "wintypes.h"
-#include "winuser.h"
#pragma pack(1)
@@ -432,6 +431,139 @@
#define SC_SCREENSAVE 0xf140
#define SC_HOTKEY 0xf150
+/****** Window classes ******/
+
+typedef struct
+{
+ UINT16 style;
+ WNDPROC16 lpfnWndProc WINE_PACKED;
+ INT16 cbClsExtra;
+ INT16 cbWndExtra;
+ HANDLE16 hInstance;
+ HICON16 hIcon;
+ HCURSOR16 hCursor;
+ HBRUSH16 hbrBackground;
+ SEGPTR lpszMenuName WINE_PACKED;
+ SEGPTR lpszClassName WINE_PACKED;
+} WNDCLASS16, *LPWNDCLASS16;
+
+typedef struct
+{
+ UINT32 style;
+ WNDPROC32 lpfnWndProc;
+ INT32 cbClsExtra;
+ INT32 cbWndExtra;
+ HINSTANCE32 hInstance;
+ HICON32 hIcon;
+ HCURSOR32 hCursor;
+ HBRUSH32 hbrBackground;
+ LPCSTR lpszMenuName;
+ LPCSTR lpszClassName;
+} WNDCLASS32A, *LPWNDCLASS32A;
+
+typedef struct
+{
+ UINT32 style;
+ WNDPROC32 lpfnWndProc;
+ INT32 cbClsExtra;
+ INT32 cbWndExtra;
+ HINSTANCE32 hInstance;
+ HICON32 hIcon;
+ HCURSOR32 hCursor;
+ HBRUSH32 hbrBackground;
+ LPCWSTR lpszMenuName;
+ LPCWSTR lpszClassName;
+} WNDCLASS32W, *LPWNDCLASS32W;
+
+DECL_WINELIB_TYPE_AW(WNDCLASS);
+DECL_WINELIB_TYPE_AW(LPWNDCLASS);
+
+typedef struct
+{
+ UINT32 cbSize;
+ UINT32 style;
+ WNDPROC16 lpfnWndProc;
+ INT16 cbClsExtra;
+ INT16 cbWndExtra;
+ HANDLE16 hInstance;
+ HICON16 hIcon;
+ HCURSOR16 hCursor;
+ HBRUSH16 hbrBackground;
+ SEGPTR lpszMenuName;
+ SEGPTR lpszClassName;
+ HICON16 hIconSm;
+} WNDCLASSEX16, *LPWNDCLASSEX16;
+
+typedef struct
+{
+ UINT32 cbSize;
+ UINT32 style;
+ WNDPROC32 lpfnWndProc;
+ INT32 cbClsExtra;
+ INT32 cbWndExtra;
+ HINSTANCE32 hInstance;
+ HICON32 hIcon;
+ HCURSOR32 hCursor;
+ HBRUSH32 hbrBackground;
+ LPCSTR lpszMenuName;
+ LPCSTR lpszClassName;
+ HICON32 hIconSm;
+} WNDCLASSEX32A, *LPWNDCLASSEX32A;
+
+typedef struct
+{
+ UINT32 cbSize;
+ UINT32 style;
+ WNDPROC32 lpfnWndProc;
+ INT32 cbClsExtra;
+ INT32 cbWndExtra;
+ HINSTANCE32 hInstance;
+ HICON32 hIcon;
+ HCURSOR32 hCursor;
+ HBRUSH32 hbrBackground;
+ LPCWSTR lpszMenuName;
+ LPCWSTR lpszClassName;
+ HICON32 hIconSm;
+} WNDCLASSEX32W, *LPWNDCLASSEX32W;
+
+DECL_WINELIB_TYPE_AW(WNDCLASSEX);
+DECL_WINELIB_TYPE_AW(LPWNDCLASSEX);
+
+#define CS_VREDRAW 0x0001
+#define CS_HREDRAW 0x0002
+#define CS_KEYCVTWINDOW 0x0004
+#define CS_DBLCLKS 0x0008
+#define CS_OWNDC 0x0020
+#define CS_CLASSDC 0x0040
+#define CS_PARENTDC 0x0080
+#define CS_NOKEYCVT 0x0100
+#define CS_NOCLOSE 0x0200
+#define CS_SAVEBITS 0x0800
+#define CS_BYTEALIGNCLIENT 0x1000
+#define CS_BYTEALIGNWINDOW 0x2000
+#define CS_GLOBALCLASS 0x4000
+
+ /* Offsets for GetClassLong() and GetClassWord() */
+#define GCL_MENUNAME (-8)
+#define GCW_HBRBACKGROUND (-10)
+#define GCL_HBRBACKGROUND GCW_HBRBACKGROUND
+#define GCW_HCURSOR (-12)
+#define GCL_HCURSOR GCW_HCURSOR
+#define GCW_HICON (-14)
+#define GCL_HICON GCW_HICON
+#define GCW_HMODULE (-16)
+#define GCL_HMODULE GCW_HMODULE
+#define GCW_CBWNDEXTRA (-18)
+#define GCL_CBWNDEXTRA GCW_CBWNDEXTRA
+#define GCW_CBCLSEXTRA (-20)
+#define GCL_CBCLSEXTRA GCW_CBCLSEXTRA
+#define GCL_WNDPROC (-24)
+#define GCW_STYLE (-26)
+#define GCL_STYLE GCW_STYLE
+#define GCW_ATOM (-32)
+#define GCW_HICONSM (-34)
+#define GCL_HICONSM GCW_HICONSM
+
/***** Window hooks *****/
/* Hook values */
@@ -1653,7 +1785,9 @@
#define DRIVE_CDROM 5
#define DRIVE_RAMDISK 6
-#define HFILE_ERROR -1
+#define HFILE_ERROR16 ((HFILE16)-1)
+#define HFILE_ERROR32 ((HFILE32)-1)
+#define HFILE_ERROR WINELIB_NAME(HFILE_ERROR)
#define DDL_READWRITE 0x0000
#define DDL_READONLY 0x0001
@@ -1717,6 +1851,10 @@
DECL_WINELIB_TYPE_AW(WIN32_FIND_DATA);
DECL_WINELIB_TYPE_AW(LPWIN32_FIND_DATA);
+#define INVALID_HANDLE_VALUE16 ((HANDLE16) -1)
+#define INVALID_HANDLE_VALUE32 ((HANDLE32) -1)
+#define INVALID_HANDLE_VALUE WINELIB_NAME(INVALID_HANDLE_VALUE)
+
/* comm */
#define CBR_110 0xFF10
@@ -2482,11 +2620,25 @@
#define HWND_NOTOPMOST ((HWND)-2)
/* Flags for TrackPopupMenu */
-#define TPM_LEFTBUTTON 0x0000
-#define TPM_RIGHTBUTTON 0x0002
-#define TPM_LEFTALIGN 0x0000
-#define TPM_CENTERALIGN 0x0004
-#define TPM_RIGHTALIGN 0x0008
+#define TPM_LEFTBUTTON 0x0000
+#define TPM_RIGHTBUTTON 0x0002
+#define TPM_LEFTALIGN 0x0000
+#define TPM_CENTERALIGN 0x0004
+#define TPM_RIGHTALIGN 0x0008
+#define TPM_TOPALIGN 0x0000
+#define TPM_VCENTERALIGN 0x0010
+#define TPM_BOTTOMALIGN 0x0020
+#define TPM_HORIZONTAL 0x0000
+#define TPM_VERTICAL 0x0040
+#define TPM_NONOTIFY 0x0080
+#define TPM_RETURNCMD 0x0100
+
+typedef struct
+{
+ UINT32 cbSize;
+ RECT32 rcExclude;
+} TPMPARAMS, *LPTPMPARAMS;
+
#define MF_INSERT 0x0000
#define MF_CHANGE 0x0080
@@ -3723,10 +3875,14 @@
/* Code page information.
*/
-typedef struct {
- DWORD MaxCharSize;
- BYTE DefaultChar[2];
- BYTE LeadBytes[5];
+#define MAX_LEADBYTES 12
+#define MAX_DEFAULTCHAR 2
+
+typedef struct
+{
+ UINT32 MaxCharSize;
+ BYTE DefaultChar[MAX_DEFAULTCHAR];
+ BYTE LeadByte[MAX_LEADBYTES];
} CPINFO, *LPCPINFO;
/* The 'overlapped' data structure used by async I/O functions.
@@ -3848,16 +4004,17 @@
/* File attribute flags
*/
-#define FILE_ATTRIBUTE_ARCHIVE 0x0020
-#define FILE_ATTRIBUTE_COMPRESSED 0x0800
-#define FILE_ATTRIBUTE_DIRECTORY 0x0010
-#define FILE_ATTRIBUTE_HIDDEN 0x0002
-#define FILE_ATTRIBUTE_NORMAL 0x0080
#define FILE_ATTRIBUTE_READONLY 0x0001
+#define FILE_ATTRIBUTE_HIDDEN 0x0002
#define FILE_ATTRIBUTE_SYSTEM 0x0004
+#define FILE_ATTRIBUTE_LABEL 0x0008 /* Not in Windows API */
+#define FILE_ATTRIBUTE_DIRECTORY 0x0010
+#define FILE_ATTRIBUTE_ARCHIVE 0x0020
+#define FILE_ATTRIBUTE_NORMAL 0x0080
#define FILE_ATTRIBUTE_TEMPORARY 0x0100
#define FILE_ATTRIBUTE_ATOMIC_WRITE 0x0200
#define FILE_ATTRIBUTE_XACTION_WRITE 0x0400
+#define FILE_ATTRIBUTE_COMPRESSED 0x0800
/* WinHelp internal structure */
@@ -3902,6 +4059,19 @@
#define HELP_MULTIKEY 0x0201
#define HELP_SETWINPOS 0x0203
+/* ExitWindows() flags */
+#define EW_RESTARTWINDOWS 0x0042
+#define EW_REBOOTSYSTEM 0x0043
+#define EW_EXITANDEXECAPP 0x0044
+
+/* ExitWindowsEx() flags */
+#define EWX_LOGOFF 0
+#define EWX_SHUTDOWN 1
+#define EWX_REBOOT 2
+#define EWX_FORCE 4
+#define EWX_POWEROFF 8
+
+
#define CCHDEVICENAME 32
#define CCHFORMNAME 32
@@ -4281,6 +4451,7 @@
VOID SetPriority(HTASK16,INT16);
WORD SetSelectorBase(WORD,DWORD);
WORD SetSelectorLimit(WORD,DWORD);
+LONG SetSwapAreaSize(WORD);
HQUEUE16 SetTaskQueue(HTASK16,HQUEUE16);
FARPROC16 SetTaskSignalProc(HTASK16,FARPROC16);
DWORD SetViewportExt(HDC16,INT16,INT16);
@@ -4302,8 +4473,9 @@
BOOL32 Beep(DWORD,DWORD);
BOOL32 ClearCommError(INT32,LPDWORD,LPCOMSTAT);
-HFILE CreateFile32A(LPCSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE32);
-HFILE CreateFile32W(LPCWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE32);
+BOOL32 CloseHandle(HANDLE32);
+HFILE32 CreateFile32A(LPCSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE32);
+HFILE32 CreateFile32W(LPCWSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE32);
#define CreateFile WINELIB_NAME_AW(CreateFile)
HANDLE32 CreateFileMapping32A(HANDLE32,LPSECURITY_ATTRIBUTES,DWORD,DWORD,DWORD,LPCSTR);
HANDLE32 CreateFileMapping32W(HANDLE32,LPSECURITY_ATTRIBUTES,DWORD,DWORD,DWORD,LPCWSTR);
@@ -4320,24 +4492,29 @@
#define EnumSystemLocales WINELIB_NAME_AW(EnumSystemLocales)
BOOL32 EnumThreadWindows(DWORD,WNDENUMPROC32,LPARAM);
void ExitProcess(DWORD);
-BOOL32 FileTimeToDosDateTime(LPFILETIME,LPWORD,LPWORD);
-BOOL32 FileTimeToLocalFileTime(LPFILETIME,LPFILETIME);
-BOOL32 FileTimeToSystemTime(LPFILETIME,LPSYSTEMTIME);
+BOOL32 ExitWindowsEx(UINT32,DWORD);
+BOOL32 FileTimeToDosDateTime(const FILETIME*,LPWORD,LPWORD);
+BOOL32 FileTimeToLocalFileTime(const FILETIME*,LPFILETIME);
+BOOL32 FileTimeToSystemTime(const FILETIME*,LPSYSTEMTIME);
HRSRC32 FindResourceEx32A(HINSTANCE32,LPCSTR,LPCSTR,WORD);
HRSRC32 FindResourceEx32W(HINSTANCE32,LPCWSTR,LPCWSTR,WORD);
#define FindResourceEx WINELIB_NAME_AW(FindResourceEx)
-BOOL32 FlushFileBuffers(HFILE);
+BOOL32 FlushFileBuffers(HFILE32);
UINT32 GetACP(void);
LPCSTR GetCommandLine32A();
LPCWSTR GetCommandLine32W();
#define GetCommandLine WINELIB_NAME_AW(GetCommandLine)
BOOL32 GetCommTimeouts(INT32,LPCOMMTIMEOUTS);
-DWORD GetCurrentThreadId(void);
+BOOL32 GetCPInfo(UINT32,LPCPINFO);
+HANDLE32 GetCurrentProcess(void);
+DWORD GetCurrentProcessId(void);
HANDLE32 GetCurrentThread(void);
+DWORD GetCurrentThreadId(void);
BOOL32 GetDCOrgEx(HDC32,LPPOINT32);
-DWORD GetFileInformationByHandle(HFILE,BY_HANDLE_FILE_INFORMATION*);
-DWORD GetFileSize(HFILE,LPDWORD);
-DWORD GetFileType(HFILE);
+DWORD GetFileInformationByHandle(HFILE32,BY_HANDLE_FILE_INFORMATION*);
+DWORD GetFileSize(HFILE32,LPDWORD);
+BOOL32 GetFileTime(HFILE32,LPFILETIME,LPFILETIME,LPFILETIME);
+DWORD GetFileType(HFILE32);
VOID GetLocalTime(LPSYSTEMTIME);
DWORD GetLogicalDrives(void);
UINT32 GetOEMCP(void);
@@ -4345,7 +4522,7 @@
DWORD GetShortPathName32A(LPCSTR,LPSTR,DWORD);
DWORD GetShortPathName32W(LPCWSTR,LPWSTR,DWORD);
#define GetShortPathName WINELIB_NAME_AW(GetShortPathName)
-HFILE GetStdHandle(DWORD);
+HFILE32 GetStdHandle(DWORD);
VOID GetSystemInfo(LPSYSTEM_INFO);
BOOL32 GetSystemPowerStatus(LPSYSTEM_POWER_STATUS);
VOID GetSystemTime(LPSYSTEMTIME);
@@ -4362,7 +4539,7 @@
BOOL32 HeapValidate(HANDLE32,DWORD,LPVOID);
BOOL32 IsWindowUnicode(HWND32);
BOOL32 IsValidLocale(DWORD,DWORD);
-BOOL32 LocalFileTimeToFileTime(LPFILETIME,LPFILETIME);
+BOOL32 LocalFileTimeToFileTime(const FILETIME*,LPFILETIME);
LPVOID MapViewOfFileEx(HANDLE32,DWORD,DWORD,DWORD,DWORD,DWORD);
BOOL32 MoveFile32A(LPCSTR,LPCSTR);
BOOL32 MoveFile32W(LPCWSTR,LPCWSTR);
@@ -4371,7 +4548,7 @@
BOOL32 ReadConsole32A(HANDLE32,LPVOID,DWORD,LPDWORD,LPVOID);
BOOL32 ReadConsole32W(HANDLE32,LPVOID,DWORD,LPDWORD,LPVOID);
#define ReadConsole WINELIB_NAME_AW(ReadConsole)
-BOOL32 ReadFile(HFILE,LPVOID,DWORD,LPDWORD,LPOVERLAPPED);
+BOOL32 ReadFile(HFILE32,LPVOID,DWORD,LPDWORD,LPOVERLAPPED);
DWORD RegCreateKeyEx32A(HKEY,LPCSTR,DWORD,LPSTR,DWORD,REGSAM,
LPSECURITY_ATTRIBUTES,LPHKEY,LPDWORD);
DWORD RegCreateKeyEx32W(HKEY,LPCWSTR,DWORD,LPWSTR,DWORD,REGSAM,
@@ -4400,27 +4577,32 @@
BOOL32 SetConsoleTitle32A(LPCSTR);
BOOL32 SetConsoleTitle32W(LPCWSTR);
#define SetConsoleTitle WINELIB_NAME_AW(SetConsoleTitle)
-BOOL32 SetEndOfFile(HFILE);
-DWORD SetFilePointer(HFILE,LONG,LPLONG,DWORD);
-BOOL32 SetFileTime(HFILE,LPFILETIME,LPFILETIME,LPFILETIME);
+BOOL32 SetEndOfFile(HFILE32);
+DWORD SetFilePointer(HFILE32,LONG,LPLONG,DWORD);
+BOOL32 SetFileTime(HFILE32,const FILETIME*,const FILETIME*,const FILETIME*);
+VOID SetLastErrorEx(DWORD,DWORD);
BOOL32 SetTimeZoneInformation(const LPTIME_ZONE_INFORMATION);
BOOL32 SetSystemPowerState(BOOL32,BOOL32);
BOOL32 SetSystemTime(const SYSTEMTIME*);
VOID Sleep(DWORD);
-BOOL32 SystemTimeToFileTime(LPSYSTEMTIME,LPFILETIME);
+BOOL32 SystemTimeToFileTime(const SYSTEMTIME*,LPFILETIME);
+BOOL32 TrackPopupMenuEx(HMENU32,UINT32,INT32,INT32,HWND32,LPTPMPARAMS);
+DWORD TlsAlloc(void);
+BOOL32 TlsFree(DWORD);
+LPVOID TlsGetValue(DWORD);
+BOOL32 TlsSetValue(DWORD,LPVOID);
LPVOID VirtualAlloc(LPVOID,DWORD,DWORD,DWORD);
BOOL32 VirtualFree(LPVOID,DWORD,DWORD);
BOOL32 WriteConsole32A(HANDLE32,LPVOID,DWORD,LPDWORD,LPVOID);
BOOL32 WriteConsole32W(HANDLE32,LPVOID,DWORD,LPDWORD,LPVOID);
#define WriteConsole WINELIB_NAME_AW(WriteConsole)
-BOOL32 WriteFile(HFILE,LPVOID,DWORD,LPDWORD,LPOVERLAPPED);
+BOOL32 WriteFile(HFILE32,LPVOID,DWORD,LPDWORD,LPOVERLAPPED);
/* Declarations for functions that are the same in Win16 and Win32 */
BOOL16 CheckDlgButton(HWND32,INT32,UINT32);
BOOL16 CheckRadioButton(HWND32,UINT32,UINT32,UINT32);
-LONG CopyLZFile(HFILE,HFILE);
HBITMAP16 CreateBitmap(INT32,INT32,UINT32,UINT32,LPCVOID);
BOOL16 CreateCaret(HWND32,HBITMAP32,INT32,INT32);
HBITMAP16 CreateCompatibleBitmap(HDC32,INT32,INT32);
@@ -4439,13 +4621,7 @@
WORD GetWindowWord(HWND32,INT32);
BOOL16 HideCaret(HWND32);
BOOL16 IsWindow(HWND32);
-void LZClose(HFILE);
-LONG LZCopy(HFILE,HFILE);
void LZDone(void);
-HFILE LZInit(HFILE);
-LONG LZSeek(HFILE,LONG,INT32);
-INT16 LZStart(void);
-HFILE OpenFile(LPCSTR,OFSTRUCT*,UINT32);
UINT16 RealizePalette(HDC32);
DWORD RegCloseKey(HKEY);
DWORD RegFlushKey(HKEY);
@@ -4456,18 +4632,11 @@
BOOL16 SetCaretPos(INT32,INT32);
WORD SetClassWord(HWND32,INT32,WORD);
VOID SetLastError(DWORD);
-VOID SetLastErrorEx(DWORD,DWORD);
VOID SetRectRgn(HRGN32,INT32,INT32,INT32,INT32);
COLORREF SetTextColor(HDC32,COLORREF);
WORD SetWindowWord(HWND32,INT32,WORD);
BOOL16 ShowCaret(HWND32);
VOID UpdateWindow(HWND32);
-LONG _hread(HFILE,LPVOID,LONG);
-HFILE _lclose(HFILE);
-HFILE _lcreat(LPCSTR,INT32);
-LONG _llseek(HFILE,LONG,INT32);
-HFILE _lopen(LPCSTR,INT32);
-LONG _hwrite(HFILE,LPCSTR,LONG);
/* Declarations for functions that change between Win16 and Win32 */
@@ -4583,6 +4752,9 @@
HICON16 CopyIcon16(HINSTANCE16,HICON16);
HICON32 CopyIcon32(HICON32);
#define CopyIcon WINELIB_NAME(CopyIcon)
+LONG CopyLZFile16(HFILE16,HFILE16);
+LONG CopyLZFile32(HFILE32,HFILE32);
+#define CopyLZFile WINELIB_NAME(CopyLZFile)
BOOL16 CopyRect16(RECT16*,const RECT16*);
BOOL32 CopyRect32(RECT32*,const RECT32*);
#define CopyRect WINELIB_NAME(CopyRect)
@@ -4835,6 +5007,9 @@
INT16 ExcludeClipRect16(HDC16,INT16,INT16,INT16,INT16);
INT32 ExcludeClipRect32(HDC32,INT32,INT32,INT32,INT32);
#define ExcludeClipRect WINELIB_NAME(ExcludeClipRect)
+BOOL16 ExitWindows16(DWORD,UINT16);
+#define ExitWindows32(a,b) ExitWindowsEx(EWX_LOGOFF,0xffffffff)
+#define ExitWindows WINELIB_NAME(ExitWindows)
BOOL16 ExtFloodFill16(HDC16,INT16,INT16,COLORREF,UINT16);
BOOL32 ExtFloodFill32(HDC32,INT32,INT32,COLORREF,UINT32);
#define ExtFloodFill WINELIB_NAME(ExtFloodFill)
@@ -4842,6 +5017,10 @@
BOOL32 ExtTextOut32A(HDC32,INT32,INT32,UINT32,const RECT32*,LPCSTR,UINT32,const INT32*);
BOOL32 ExtTextOut32W(HDC32,INT32,INT32,UINT32,const RECT32*,LPCWSTR,UINT32,const INT32*);
#define ExtTextOut WINELIB_NAME_AW(ExtTextOut)
+void FatalAppExit16(UINT16,LPCSTR);
+void FatalAppExit32A(UINT32,LPCSTR);
+void FatalAppExit32W(UINT32,LPCWSTR);
+#define FatalAppExit WINELIB_NAME_AW(FatalAppExit)
INT16 FillRect16(HDC16,const RECT16*,HBRUSH16);
INT32 FillRect32(HDC32,const RECT32*,HBRUSH32);
#define FillRect WINELIB_NAME(FillRect)
@@ -4851,11 +5030,11 @@
BOOL16 FindClose16(HANDLE16);
BOOL32 FindClose32(HANDLE32);
#define FindClose WINELIB_NAME(FindClose)
-HANDLE16 FindFirstFile16(LPCSTR,LPVOID);
+HANDLE16 FindFirstFile16(LPCSTR,LPWIN32_FIND_DATA32A);
HANDLE32 FindFirstFile32A(LPCSTR,LPWIN32_FIND_DATA32A);
HANDLE32 FindFirstFile32W(LPCWSTR,LPWIN32_FIND_DATA32W);
#define FindFirst WINELIB_NAME_AW(FindFirst)
-BOOL16 FindNextFile16(HANDLE16,LPVOID);
+BOOL16 FindNextFile16(HANDLE16,LPWIN32_FIND_DATA32A);
BOOL32 FindNextFile32A(HANDLE32,LPWIN32_FIND_DATA32A);
BOOL32 FindNextFile32W(HANDLE32,LPWIN32_FIND_DATA32W);
#define FindNext WINELIB_NAME_AW(FindNext)
@@ -5227,6 +5406,9 @@
void InvalidateRect16(HWND16,const RECT16*,BOOL16);
void InvalidateRect32(HWND32,const RECT32*,BOOL32);
#define InvalidateRect WINELIB_NAME(InvalidateRect)
+void InvalidateRgn16(HWND16,HRGN16,BOOL16);
+void InvalidateRgn32(HWND32,HRGN32,BOOL32);
+#define InvalidateRgn WINELIB_NAME(InvalidateRgn)
void InvertRect16(HDC16,const RECT16*);
void InvertRect32(HDC32,const RECT32*);
#define InvertRect WINELIB_NAME(InvertRect)
@@ -5277,13 +5459,16 @@
BOOL16 KillTimer16(HWND16,UINT16);
BOOL32 KillTimer32(HWND32,UINT32);
#define KillTimer WINELIB_NAME(KillTimer)
-HFILE LZOpenFile16(LPCSTR,LPOFSTRUCT,UINT16);
-HFILE LZOpenFile32A(LPCSTR,LPOFSTRUCT,UINT32);
-HFILE LZOpenFile32W(LPCWSTR,LPOFSTRUCT,UINT32);
+HFILE16 LZOpenFile16(LPCSTR,LPOFSTRUCT,UINT16);
+HFILE32 LZOpenFile32A(LPCSTR,LPOFSTRUCT,UINT32);
+HFILE32 LZOpenFile32W(LPCWSTR,LPOFSTRUCT,UINT32);
#define LZOpenFile WINELIB_NAME_AW(LZOpenFile)
-INT16 LZRead16(HFILE,SEGPTR,UINT16);
-INT32 LZRead32(HFILE,LPVOID,UINT32);
+INT16 LZRead16(HFILE16,LPVOID,UINT16);
+INT32 LZRead32(HFILE32,LPVOID,UINT32);
#define LZRead WINELIB_NAME(LZRead)
+INT16 LZStart16(void);
+INT32 LZStart32(void);
+#define LZStart WINELIB_NAME(LZStart)
VOID LineDDA16(INT16,INT16,INT16,INT16,LINEDDAPROC16,LPARAM);
BOOL32 LineDDA32(INT32,INT32,INT32,INT32,LINEDDAPROC32,LPARAM);
#define LineDDA WINELIB_NAME(LineDDA)
@@ -5364,6 +5549,18 @@
BOOL16 LPtoDP16(HDC16,LPPOINT16,INT16);
BOOL32 LPtoDP32(HDC32,LPPOINT32,INT32);
#define LPtoDP WINELIB_NAME(LPtoDP)
+void LZClose16(HFILE16);
+void LZClose32(HFILE32);
+#define LZClose WINELIB_NAME(LZClose)
+LONG LZCopy16(HFILE16,HFILE16);
+LONG LZCopy32(HFILE32,HFILE32);
+#define LZCopy WINELIB_NAME(LZCopy)
+HFILE16 LZInit16(HFILE16);
+HFILE32 LZInit32(HFILE32);
+#define LZInit WINELIB_NAME(LZInit)
+LONG LZSeek16(HFILE16,LONG,INT16);
+LONG LZSeek32(HFILE32,LONG,INT32);
+#define LZSeek WINELIB_NAME(LZSeek)
FARPROC16 MakeProcInstance16(FARPROC16,HANDLE16);
#define MakeProcInstance32(proc,inst) (proc)
#define MakeProcInstance WINELIB_NAME(MakeProcInstance)
@@ -5416,6 +5613,9 @@
BOOL16 OffsetWindowOrgEx16(HDC16,INT16,INT16,LPPOINT16);
BOOL32 OffsetWindowOrgEx32(HDC32,INT32,INT32,LPPOINT32);
#define OffsetWindowOrgEx WINELIB_NAME(OffsetWindowOrgEx)
+HFILE16 OpenFile16(LPCSTR,OFSTRUCT*,UINT16);
+HFILE32 OpenFile32(LPCSTR,OFSTRUCT*,UINT32);
+#define OpenFile WINELIB_NAME(OpenFile)
BOOL16 PaintRgn16(HDC16,HRGN16);
BOOL32 PaintRgn32(HDC32,HRGN32);
#define PaintRgn WINELIB_NAME(PaintRgn)
@@ -5720,6 +5920,10 @@
void SetWindowText32A(HWND32,LPCSTR);
void SetWindowText32W(HWND32,LPCWSTR);
#define SetWindowText WINELIB_NAME_AW(SetWindowText)
+BOOL16 ShellAbout16(HWND16,LPCSTR,LPCSTR,HICON16);
+BOOL32 ShellAbout32A(HWND32,LPCSTR,LPCSTR,HICON32);
+BOOL32 ShellAbout32W(HWND32,LPCWSTR,LPCWSTR,HICON32);
+#define ShellAbout WINELIB_NAME_AW(ShellAbout)
void ShowScrollBar16(HWND16,INT16,BOOL16);
BOOL32 ShowScrollBar32(HWND32,INT32,BOOL32);
#define ShowScrollBar WINELIB_NAME(ShowScrollBar)
@@ -5728,8 +5932,10 @@
BOOL32 StretchBlt32(HDC32,INT32,INT32,INT32,INT32,HDC32,INT32,INT32,
INT32,INT32,DWORD);
#define StretchBlt WINELIB_NAME(StretchBlt)
-INT16 StretchDIBits16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,const VOID*,const BITMAPINFO*,UINT16,DWORD);
-INT32 StretchDIBits32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,const VOID*,const BITMAPINFO*,UINT32,DWORD);
+INT16 StretchDIBits16(HDC16,INT16,INT16,INT16,INT16,INT16,INT16,INT16,
+ INT16,const VOID*,const BITMAPINFO*,UINT16,DWORD);
+INT32 StretchDIBits32(HDC32,INT32,INT32,INT32,INT32,INT32,INT32,INT32,
+ INT32,const VOID*,const BITMAPINFO*,UINT32,DWORD);
#define StretchDIBits WINELIB_NAME(StretchDIBits)
BOOL16 SubtractRect16(LPRECT16,const RECT16*,const RECT16*);
BOOL32 SubtractRect32(LPRECT32,const RECT32*,const RECT32*);
@@ -5770,6 +5976,9 @@
void ValidateRect16(HWND16,const RECT16*);
void ValidateRect32(HWND32,const RECT32*);
#define ValidateRect WINELIB_NAME(ValidateRect)
+VOID ValidateRgn16(HWND16,HRGN16);
+VOID ValidateRgn32(HWND32,HRGN32);
+#define ValidateRgn WINELIB_NAME(ValidateRgn)
DWORD VerFindFile16(UINT16,LPCSTR,LPCSTR,LPCSTR,LPSTR,UINT16*,LPSTR,UINT16*);
DWORD VerFindFile32A(UINT32,LPCSTR,LPCSTR,LPCSTR,LPSTR,UINT32*,LPSTR,UINT32*);
DWORD VerFindFile32W(UINT32,LPCWSTR,LPCWSTR,LPCWSTR,LPWSTR,UINT32*,LPWSTR,UINT32*);
@@ -5828,6 +6037,13 @@
INT32 lstrlen32A(LPCSTR);
INT32 lstrlen32W(LPCWSTR);
#define lstrlen WINELIB_NAME_AW(lstrlen)
+HINSTANCE16 WinExec16(LPCSTR,UINT16);
+HINSTANCE32 WinExec32(LPCSTR,UINT32);
+#define WinExec WINELIB_NAME(WinExec)
+BOOL16 WinHelp16(HWND16,LPCSTR,UINT16,DWORD);
+BOOL32 WinHelp32A(HWND32,LPCSTR,UINT32,DWORD);
+BOOL32 WinHelp32W(HWND32,LPCWSTR,UINT32,DWORD);
+#define WinHelp WINELIB_NAME_AW(WinHelp)
INT16 wsnprintf16(LPSTR,UINT16,LPCSTR,...);
INT32 wsnprintf32A(LPSTR,UINT32,LPCSTR,...);
INT32 wsnprintf32W(LPWSTR,UINT32,LPCWSTR,...);
@@ -5844,11 +6060,29 @@
INT32 wvsprintf32A(LPSTR,LPCSTR,LPCVOID);
INT32 wvsprintf32W(LPWSTR,LPCWSTR,LPCVOID);
#define wvsprintf WINELIB_NAME_AW(wvsprintf)
-UINT16 _lread16(HFILE,LPVOID,UINT16);
-UINT32 _lread32(HFILE,LPVOID,UINT32);
+LONG _hread16(HFILE16,LPVOID,LONG);
+LONG _hread32(HFILE32,LPVOID,LONG);
+#define _hread WINELIB_NAME(_hread)
+LONG _hwrite16(HFILE16,LPCSTR,LONG);
+LONG _hwrite32(HFILE32,LPCSTR,LONG);
+#define _hwrite WINELIB_NAME(_hwrite)
+HFILE16 _lcreat16(LPCSTR,INT16);
+HFILE32 _lcreat32(LPCSTR,INT32);
+#define _lcreat WINELIB_NAME(_lcreat)
+HFILE16 _lclose16(HFILE16);
+HFILE32 _lclose32(HFILE32);
+#define _lclose WINELIB_NAME(_lclose)
+LONG _llseek16(HFILE16,LONG,INT16);
+LONG _llseek32(HFILE32,LONG,INT32);
+#define _llseek WINELIB_NAME(_llseek)
+HFILE16 _lopen16(LPCSTR,INT16);
+HFILE32 _lopen32(LPCSTR,INT32);
+#define _lopen WINELIB_NAME(_lopen)
+UINT16 _lread16(HFILE16,LPVOID,UINT16);
+UINT32 _lread32(HFILE32,LPVOID,UINT32);
#define _lread WINELIB_NAME(_lread)
-UINT16 _lwrite16(HFILE,LPCSTR,UINT16);
-UINT32 _lwrite32(HFILE,LPCSTR,UINT32);
+UINT16 _lwrite16(HFILE16,LPCSTR,UINT16);
+UINT32 _lwrite32(HFILE32,LPCSTR,UINT32);
#define _lwrite WINELIB_NAME(_lwrite)
/* Extra functions that don't exist in the Windows API */
@@ -5942,9 +6176,7 @@
UINT16 EnumClipboardFormats(UINT16);
BOOL EnumMetaFile(HDC16,HMETAFILE16,MFENUMPROC16,LPARAM);
INT Escape(HDC16,INT,INT,SEGPTR,SEGPTR);
-BOOL ExitWindows(DWORD,WORD);
HICON16 ExtractIcon(HINSTANCE16,LPCSTR,WORD);
-void FatalAppExit(UINT,LPCSTR);
void FatalExit(int);
ATOM FindAtom(SEGPTR);
HINSTANCE16 FindExecutable(LPCSTR,LPCSTR,LPSTR);
@@ -6023,7 +6255,6 @@
BOOL HiliteMenuItem(HWND,HMENU16,UINT,UINT);
BOOL InSendMessage(void);
WORD InitAtomTable(WORD);
-void InvalidateRgn(HWND32,HRGN32,BOOL32);
BOOL IsChild(HWND,HWND);
BOOL IsClipboardFormatAvailable(WORD);
BOOL IsDialogMessage(HWND,LPMSG16);
@@ -6086,7 +6317,6 @@
HWND SetParent(HWND,HWND);
FARPROC16 SetResourceHandler(HINSTANCE16,LPSTR,FARPROC16);
int SetSoundNoise(int,int);
-LONG SetSwapAreaSize(WORD);
void SetSysColors(int,LPINT16,COLORREF*);
WORD SetSystemPaletteUse(HDC16,WORD);
int SetVoiceAccent(int,int,int,int,int);
@@ -6113,15 +6343,10 @@
BOOL TranslateMDISysAccel(HWND,LPMSG16);
BOOL TranslateMessage(LPMSG16);
int UpdateColors(HDC16);
-void ValidateCodeSegments(void);
-LPSTR ValidateFreeSpaces(void);
-void ValidateRgn(HWND32,HRGN32);
WORD VkKeyScan(WORD);
SEGPTR WIN16_LockResource(HGLOBAL16);
void WaitMessage(void);
int WaitSoundState(int);
-HINSTANCE16 WinExec(LPSTR,WORD);
-BOOL WinHelp(HWND,LPSTR,WORD,DWORD);
#endif /* NO_TRANSITION_TYPES */
diff --git a/include/winerror.h b/include/winerror.h
index cdca7ea..c48cc69 100644
--- a/include/winerror.h
+++ b/include/winerror.h
@@ -5,26 +5,28 @@
* All instances of ERROR_UNKNOWN should be tested under Win95/NT
* and replaced.
*/
-#define ERROR_UNKNOWN 99999
+#define ERROR_UNKNOWN 99999
-#define ERROR_SUCCESS 0
-#define ERROR_FILE_NOT_FOUND 2
-#define ERROR_TOO_MANY_OPEN_FILES 4
-#define ERROR_ACCESS_DENIED 5
-#define ERROR_INVALID_HANDLE 6
-#define ERROR_BAD_FORMAT 11
-#define ERROR_OUTOFMEMORY 14
-#define ERROR_FILE_EXISTS 80
-#define ERROR_INVALID_PARAMETER 87
-#define ERROR_BROKEN_PIPE 109
-#define ERROR_DISK_FULL 112
-#define ERROR_CALL_NOT_IMPLEMENTED 120
-#define ERROR_SEEK_ON_DEVICE 132
-#define ERROR_DIR_NOT_EMPTY 145
-#define ERROR_BUSY 170
-#define ERROR_FILENAME_EXCED_RANGE 206
-#define ERROR_MORE_DATA 234
-#define ERROR_NO_MORE_ITEMS 259
-#define ERROR_IO_DEVICE 1117
-#define ERROR_POSSIBLE_DEADLOCK 1131
-#define ERROR_BAD_DEVICE 1200
+#define ERROR_SUCCESS 0
+#define ERROR_FILE_NOT_FOUND 2
+#define ERROR_PATH_NOT_FOUND 3
+#define ERROR_TOO_MANY_OPEN_FILES 4
+#define ERROR_ACCESS_DENIED 5
+#define ERROR_INVALID_HANDLE 6
+#define ERROR_BAD_FORMAT 11
+#define ERROR_OUTOFMEMORY 14
+#define ERROR_NO_MORE_FILES 18
+#define ERROR_FILE_EXISTS 80
+#define ERROR_INVALID_PARAMETER 87
+#define ERROR_BROKEN_PIPE 109
+#define ERROR_DISK_FULL 112
+#define ERROR_CALL_NOT_IMPLEMENTED 120
+#define ERROR_SEEK_ON_DEVICE 132
+#define ERROR_DIR_NOT_EMPTY 145
+#define ERROR_BUSY 170
+#define ERROR_FILENAME_EXCED_RANGE 206
+#define ERROR_MORE_DATA 234
+#define ERROR_NO_MORE_ITEMS 259
+#define ERROR_IO_DEVICE 1117
+#define ERROR_POSSIBLE_DEADLOCK 1131
+#define ERROR_BAD_DEVICE 1200
diff --git a/include/winnt.h b/include/winnt.h
index 4a5d3bf..654ec46 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -7,6 +7,8 @@
#ifndef __WINE_WINNT_H
#define __WINE_WINNT_H
+#include "wintypes.h"
+
/* Heap flags */
#define HEAP_NO_SERIALIZE 0x00000001
#define HEAP_GROWABLE 0x00000002
@@ -21,4 +23,119 @@
#define HEAP_WINE_SEGPTR 0x01000000 /* Not a Win32 flag */
#define HEAP_WINE_CODESEG 0x02000000 /* Not a Win32 flag */
+/* The Win32 register context */
+
+#define CONTEXT_i386 0x00010000
+#define CONTEXT_i486 CONTEXT_i386
+#define CONTEXT_CONTROL (CONTEXT_i386 | 0x0001) /* SS:SP, CS:IP, FLAGS, BP */
+#define CONTEXT_INTEGER (CONTEXT_i386 | 0x0002) /* AX, BX, CX, DX, SI, DI */
+#define CONTEXT_SEGMENTS (CONTEXT_i386 | 0x0004) /* DS, ES, FS, GS */
+#define CONTEXT_FLOATING_POINT (CONTEXT_i386 | 0x0008L) /* 387 state */
+#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386 | 0x0010L) /* DB 0-3,6,7 */
+#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | CONTEXT_SEGMENTS)
+
+#define SIZE_OF_80387_REGISTERS 80
+
+typedef struct
+{
+ DWORD ControlWord;
+ DWORD StatusWord;
+ DWORD TagWord;
+ DWORD ErrorOffset;
+ DWORD ErrorSelector;
+ DWORD DataOffset;
+ DWORD DataSelector;
+ BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
+ DWORD Cr0NpxState;
+} FLOATING_SAVE_AREA;
+
+typedef struct
+{
+ DWORD ContextFlags;
+
+ /* These are selected by CONTEXT_DEBUG_REGISTERS */
+ DWORD Dr0;
+ DWORD Dr1;
+ DWORD Dr2;
+ DWORD Dr3;
+ DWORD Dr6;
+ DWORD Dr7;
+
+ /* These are selected by CONTEXT_FLOATING_POINT */
+ FLOATING_SAVE_AREA FloatSave;
+
+ /* These are selected by CONTEXT_SEGMENTS */
+ DWORD SegGs;
+ DWORD SegFs;
+ DWORD SegEs;
+ DWORD SegDs;
+
+ /* These are selected by CONTEXT_INTEGER */
+ DWORD Edi;
+ DWORD Esi;
+ DWORD Ebx;
+ DWORD Edx;
+ DWORD Ecx;
+ DWORD Eax;
+
+ /* These are selected by CONTEXT_CONTROL */
+ DWORD Ebp;
+ DWORD Eip;
+ DWORD SegCs;
+ DWORD EFlags;
+ DWORD Esp;
+ DWORD SegSs;
+} CONTEXT, *PCONTEXT;
+
+
+#ifdef __WINE__
+
+/* Macros for easier access to context registers */
+
+#define EAX_reg(context) ((context)->Eax)
+#define EBX_reg(context) ((context)->Ebx)
+#define ECX_reg(context) ((context)->Ecx)
+#define EDX_reg(context) ((context)->Edx)
+#define ESI_reg(context) ((context)->Esi)
+#define EDI_reg(context) ((context)->Edi)
+#define EBP_reg(context) ((context)->Ebp)
+
+#define CS_reg(context) ((context)->SegCs)
+#define DS_reg(context) ((context)->SegDs)
+#define ES_reg(context) ((context)->SegEs)
+#define FS_reg(context) ((context)->SegFs)
+#define GS_reg(context) ((context)->SegGs)
+#define SS_reg(context) ((context)->SegSs)
+
+#define EFL_reg(context) ((context)->EFlags)
+#define EIP_reg(context) ((context)->Eip)
+#define ESP_reg(context) ((context)->Esp)
+
+#define AX_reg(context) (*(WORD*)&EAX_reg(context))
+#define BX_reg(context) (*(WORD*)&EBX_reg(context))
+#define CX_reg(context) (*(WORD*)&ECX_reg(context))
+#define DX_reg(context) (*(WORD*)&EDX_reg(context))
+#define SI_reg(context) (*(WORD*)&ESI_reg(context))
+#define DI_reg(context) (*(WORD*)&EDI_reg(context))
+#define BP_reg(context) (*(WORD*)&EBP_reg(context))
+
+#define AL_reg(context) (*(BYTE*)&EAX_reg(context))
+#define AH_reg(context) (*((BYTE*)&EAX_reg(context)+1))
+#define BL_reg(context) (*(BYTE*)&EBX_reg(context))
+#define BH_reg(context) (*((BYTE*)&EBX_reg(context)+1))
+#define CL_reg(context) (*(BYTE*)&ECX_reg(context))
+#define CH_reg(context) (*((BYTE*)&ECX_reg(context)+1))
+#define DL_reg(context) (*(BYTE*)&EDX_reg(context))
+#define DH_reg(context) (*((BYTE*)&EDX_reg(context)+1))
+
+#define IP_reg(context) (*(WORD*)&EIP_reg(context))
+#define SP_reg(context) (*(WORD*)&ESP_reg(context))
+
+#define FL_reg(context) (*(WORD*)&EFL_reg(context))
+
+#define SET_CFLAG(context) (EFL_reg(context) |= 0x0001)
+#define RESET_CFLAG(context) (EFL_reg(context) &= 0xfffffffe)
+
+#endif /* __WINE__ */
+
#endif /* __WINE_WINNT_H */
diff --git a/include/wintypes.h b/include/wintypes.h
index 8565ad8..c6b69ab 100644
--- a/include/wintypes.h
+++ b/include/wintypes.h
@@ -93,7 +93,6 @@
typedef WORD *LPCATCHBUF;
typedef DWORD ACCESS_MASK;
typedef ACCESS_MASK REGSAM;
-typedef INT16 HFILE;
typedef HANDLE32 HHOOK;
typedef HANDLE32 HKEY;
typedef HANDLE32 HMIXEROBJ;
@@ -138,6 +137,7 @@
DECLARE_HANDLE(HDROP);
DECLARE_HANDLE(HDRVR);
DECLARE_HANDLE(HDWP);
+DECLARE_HANDLE(HFILE);
DECLARE_HANDLE(HFONT);
DECLARE_HANDLE(HGDIOBJ);
DECLARE_HANDLE(HGLOBAL);
@@ -234,6 +234,7 @@
DECL_WINELIB_TYPE(HDROP);
DECL_WINELIB_TYPE(HDRVR);
DECL_WINELIB_TYPE(HDWP);
+DECL_WINELIB_TYPE(HFILE);
DECL_WINELIB_TYPE(HFONT);
DECL_WINELIB_TYPE(HGDIOBJ);
DECL_WINELIB_TYPE(HGLOBAL);
diff --git a/include/winuser.h b/include/winuser.h
deleted file mode 100644
index 9cd6041..0000000
--- a/include/winuser.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * USER definitions
- *
- * Copyright 1996 Alexandre Julliard
- */
-
-#ifndef __WINE_WINUSER_H
-#define __WINE_WINUSER_H
-
-#include "wintypes.h"
-
-
-/* Window classes */
-
-typedef struct
-{
- UINT32 style;
- WNDPROC32 lpfnWndProc;
- INT32 cbClsExtra;
- INT32 cbWndExtra;
- HINSTANCE32 hInstance;
- HICON32 hIcon;
- HCURSOR32 hCursor;
- HBRUSH32 hbrBackground;
- LPCSTR lpszMenuName;
- LPCSTR lpszClassName;
-} WNDCLASS32A, *LPWNDCLASS32A;
-
-typedef struct
-{
- UINT32 style;
- WNDPROC32 lpfnWndProc;
- INT32 cbClsExtra;
- INT32 cbWndExtra;
- HINSTANCE32 hInstance;
- HICON32 hIcon;
- HCURSOR32 hCursor;
- HBRUSH32 hbrBackground;
- LPCWSTR lpszMenuName;
- LPCWSTR lpszClassName;
-} WNDCLASS32W, *LPWNDCLASS32W;
-
-#pragma pack(1)
-
-typedef struct
-{
- UINT16 style;
- WNDPROC16 lpfnWndProc WINE_PACKED;
- INT16 cbClsExtra;
- INT16 cbWndExtra;
- HANDLE16 hInstance;
- HICON16 hIcon;
- HCURSOR16 hCursor;
- HBRUSH16 hbrBackground;
- SEGPTR lpszMenuName WINE_PACKED;
- SEGPTR lpszClassName WINE_PACKED;
-} WNDCLASS16, *LPWNDCLASS16;
-
-#pragma pack(4)
-
-typedef struct
-{
- UINT32 cbSize;
- UINT32 style;
- WNDPROC32 lpfnWndProc;
- INT32 cbClsExtra;
- INT32 cbWndExtra;
- HINSTANCE32 hInstance;
- HICON32 hIcon;
- HCURSOR32 hCursor;
- HBRUSH32 hbrBackground;
- LPCSTR lpszMenuName;
- LPCSTR lpszClassName;
- HICON32 hIconSm;
-} WNDCLASSEX32A, *LPWNDCLASSEX32A;
-
-typedef struct
-{
- UINT32 cbSize;
- UINT32 style;
- WNDPROC32 lpfnWndProc;
- INT32 cbClsExtra;
- INT32 cbWndExtra;
- HINSTANCE32 hInstance;
- HICON32 hIcon;
- HCURSOR32 hCursor;
- HBRUSH32 hbrBackground;
- LPCWSTR lpszMenuName;
- LPCWSTR lpszClassName;
- HICON32 hIconSm;
-} WNDCLASSEX32W, *LPWNDCLASSEX32W;
-
-typedef struct
-{
- UINT32 cbSize;
- UINT32 style;
- WNDPROC16 lpfnWndProc;
- INT16 cbClsExtra;
- INT16 cbWndExtra;
- HANDLE16 hInstance;
- HICON16 hIcon;
- HCURSOR16 hCursor;
- HBRUSH16 hbrBackground;
- SEGPTR lpszMenuName;
- SEGPTR lpszClassName;
- HICON16 hIconSm;
-} WNDCLASSEX16, *LPWNDCLASSEX16;
-
-DECL_WINELIB_TYPE_AW(WNDCLASS);
-DECL_WINELIB_TYPE_AW(LPWNDCLASS);
-DECL_WINELIB_TYPE_AW(WNDCLASSEX);
-DECL_WINELIB_TYPE_AW(LPWNDCLASSEX);
-
-#define CS_VREDRAW 0x0001
-#define CS_HREDRAW 0x0002
-#define CS_KEYCVTWINDOW 0x0004
-#define CS_DBLCLKS 0x0008
-#define CS_OWNDC 0x0020
-#define CS_CLASSDC 0x0040
-#define CS_PARENTDC 0x0080
-#define CS_NOKEYCVT 0x0100
-#define CS_NOCLOSE 0x0200
-#define CS_SAVEBITS 0x0800
-#define CS_BYTEALIGNCLIENT 0x1000
-#define CS_BYTEALIGNWINDOW 0x2000
-#define CS_GLOBALCLASS 0x4000
-
- /* Offsets for GetClassLong() and GetClassWord() */
-#define GCL_MENUNAME (-8)
-#define GCW_HBRBACKGROUND (-10)
-#define GCL_HBRBACKGROUND GCW_HBRBACKGROUND
-#define GCW_HCURSOR (-12)
-#define GCL_HCURSOR GCW_HCURSOR
-#define GCW_HICON (-14)
-#define GCL_HICON GCW_HICON
-#define GCW_HMODULE (-16)
-#define GCL_HMODULE GCW_HMODULE
-#define GCW_CBWNDEXTRA (-18)
-#define GCL_CBWNDEXTRA GCW_CBWNDEXTRA
-#define GCW_CBCLSEXTRA (-20)
-#define GCL_CBCLSEXTRA GCW_CBCLSEXTRA
-#define GCL_WNDPROC (-24)
-#define GCW_STYLE (-26)
-#define GCL_STYLE GCW_STYLE
-#define GCW_ATOM (-32)
-#define GCW_HICONSM (-34)
-#define GCL_HICONSM GCW_HICONSM
-
-#endif /* __WINE_WINUSER_H */
diff --git a/library/miscstubs.c b/library/miscstubs.c
index 6a7cda1..e9c377f 100644
--- a/library/miscstubs.c
+++ b/library/miscstubs.c
@@ -11,7 +11,6 @@
#include "dde_mem.h"
#include "global.h"
#include "debug.h"
-#include "xmalloc.h"
void SIGNAL_MaskAsyncEvents( BOOL32 mask )
{
@@ -46,7 +45,6 @@
}
}
-extern LRESULT AboutDlgProc(HWND,UINT,WPARAM16,LPARAM);
extern LRESULT ColorDlgProc(HWND,UINT,WPARAM16,LPARAM);
extern LRESULT ComboBoxWndProc(HWND,UINT,WPARAM16,LPARAM);
extern LRESULT ComboLBoxWndProc(HWND,UINT,WPARAM16,LPARAM);
@@ -61,7 +59,6 @@
extern LRESULT ReplaceTextDlgProc(HWND,UINT,WPARAM16,LPARAM);
extern LRESULT ScrollBarWndProc(HWND,UINT,WPARAM16,LPARAM);
extern LRESULT StaticWndProc(HWND,UINT,WPARAM16,LPARAM);
-extern LRESULT SystemMessageBoxProc(HWND,UINT,WPARAM16,LPARAM);
extern LRESULT TASK_Reschedule(void);
/***********************************************************************
@@ -72,7 +69,6 @@
FARPROC16 MODULE_GetWndProcEntry16( char *name )
{
#define MAP_STR_TO_PROC(str,proc) if(!strcmp(name,str))return (FARPROC16)proc
- MAP_STR_TO_PROC("AboutDlgProc",AboutDlgProc);
MAP_STR_TO_PROC("ColorDlgProc",ColorDlgProc);
MAP_STR_TO_PROC("ComboBoxWndProc",ComboBoxWndProc);
MAP_STR_TO_PROC("ComboLBoxWndProc",ComboLBoxWndProc);
@@ -88,7 +84,6 @@
MAP_STR_TO_PROC("ReplaceTextDlgProc",ReplaceTextDlgProc);
MAP_STR_TO_PROC("ScrollBarWndProc",ScrollBarWndProc);
MAP_STR_TO_PROC("StaticWndProc",StaticWndProc);
- MAP_STR_TO_PROC("SystemMessageBoxProc",SystemMessageBoxProc);
MAP_STR_TO_PROC("TASK_Reschedule",TASK_Reschedule);
fprintf(stderr,"warning: No mapping for %s(), add one in library/miscstubs.c\n",name);
return NULL;
diff --git a/library/winestub.c b/library/winestub.c
index 33992cd..d1c53e6 100644
--- a/library/winestub.c
+++ b/library/winestub.c
@@ -26,7 +26,7 @@
for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
if(!MAIN_Init()) return 0; /* JBP: Needed for DosDrives[] structure, etc. */
- hInstance = WinExec( *argv, SW_SHOWNORMAL );
+ hInstance = WinExec32( *argv, SW_SHOWNORMAL );
TASK_Reschedule();
InitApp( hInstance );
diff --git a/loader/Makefile.in b/loader/Makefile.in
index 2e38a37..39f2b30 100644
--- a/loader/Makefile.in
+++ b/loader/Makefile.in
@@ -6,7 +6,6 @@
MODULE = loader
C_SRCS = \
- builtin.c \
main.c \
module.c \
ne_image.c \
diff --git a/loader/main.c b/loader/main.c
index b14f691..9b13e8f 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -18,14 +18,13 @@
#include "menu.h"
#include "atom.h"
#include "dialog.h"
-#include "directory.h"
#include "drive.h"
#include "queue.h"
#include "syscolor.h"
#include "sysmetrics.h"
+#include "file.h"
#include "gdi.h"
#include "heap.h"
-#include "debugger.h"
#include "miscemu.h"
#include "neexe.h"
#include "options.h"
@@ -39,6 +38,9 @@
#include "stddebug.h"
#include "debug.h"
+#ifndef WINELIB
+#include "debugger.h"
+#endif
/* Winelib run-time flag */
#ifdef WINELIB
@@ -70,6 +72,9 @@
/* Load the configuration file */
if (!PROFILE_LoadWineIni()) return 0;
+ /* Initialize DOS memory */
+ if (!DOSMEM_Init()) return 0;
+
#ifdef WINELIB
/* Create USER and GDI heap */
USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
@@ -83,15 +88,6 @@
/* Create built-in modules */
if (!BUILTIN_Init()) return 0;
- /* Initialize interrupt vectors */
- if (!INT_Init()) return 0;
-
- /* Initialize DOS memory */
- if (!DOSMEM_Init()) return 0;
-
- /* Initialize the DOS interrupt */
- if (!INT21_Init()) return 0;
-
/* Initialize signal handling */
if (!SIGNAL_Init()) return 0;
@@ -182,7 +178,7 @@
for (i = 1; i < argc; i++)
{
- if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
+ if ((handle = WinExec32( argv[i], SW_SHOWNORMAL )) < 32)
{
fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
switch (handle)
diff --git a/loader/module.c b/loader/module.c
index ed35931..d49c705 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -15,28 +15,23 @@
#include "dos_fs.h"
#include "file.h"
#include "global.h"
+#include "heap.h"
#include "hook.h"
-#include "ldt.h"
#include "module.h"
#include "neexe.h"
-#include "registers.h"
+#include "selectors.h"
#include "stackframe.h"
#include "task.h"
#include "toolhelp.h"
#include "stddebug.h"
#include "debug.h"
#include "callback.h"
-#include "xmalloc.h"
extern HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params );
static HMODULE16 hFirstModule = 0;
static HMODULE16 hCachedModule = 0; /* Module cached by MODULE_OpenFile */
-#ifndef WINELIB
-static HGLOBAL16 hInitialStack32 = 0;
-#endif
-
/***********************************************************************
* MODULE_GetPtr
@@ -281,8 +276,7 @@
/***********************************************************************
* MODULE_CreateSegments
*/
-#ifndef WINELIB32
-static BOOL MODULE_CreateSegments( HMODULE16 hModule )
+static BOOL32 MODULE_CreateSegments( HMODULE16 hModule )
{
SEGTABLEENTRY *pSegment;
NE_MODULE *pModule;
@@ -308,7 +302,6 @@
(pModule->dgroup - 1) * sizeof(SEGTABLEENTRY) : 0;
return TRUE;
}
-#endif
/***********************************************************************
@@ -443,7 +436,7 @@
/***********************************************************************
* MODULE_LoadExeHeader
*/
-static HMODULE16 MODULE_LoadExeHeader( HFILE hFile, OFSTRUCT *ofs )
+static HMODULE16 MODULE_LoadExeHeader( HFILE32 hFile, OFSTRUCT *ofs )
{
struct mz_header_s mz_header;
struct ne_header_s ne_header;
@@ -459,15 +452,15 @@
((fastload && ((offset) >= fastload_offset) && \
((offset)+(size) <= fastload_offset+fastload_length)) ? \
(memcpy( buffer, fastload+(offset)-fastload_offset, (size) ), TRUE) : \
- (_llseek( hFile, mz_header.ne_offset+(offset), SEEK_SET), \
+ (_llseek32( hFile, mz_header.ne_offset+(offset), SEEK_SET), \
_lread32( hFile, (buffer), (size) ) == (size)))
- _llseek( hFile, 0, SEEK_SET );
+ _llseek32( hFile, 0, SEEK_SET );
if ((_lread32(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
(mz_header.mz_magic != MZ_SIGNATURE))
return (HMODULE16)11; /* invalid exe */
- _llseek( hFile, mz_header.ne_offset, SEEK_SET );
+ _llseek32( hFile, mz_header.ne_offset, SEEK_SET );
if (_lread32( hFile, &ne_header, sizeof(ne_header) ) != sizeof(ne_header))
return (HMODULE16)11; /* invalid exe */
@@ -515,12 +508,12 @@
fastload_length=ne_header.fastload_length<<ne_header.align_shift_count;
dprintf_module( stddeb, "Using fast-load area offset=%x len=%d\n",
fastload_offset, fastload_length );
- if ((fastload = (char *)xmalloc( fastload_length )) != NULL)
+ if ((fastload = HeapAlloc( SystemHeap, 0, fastload_length )) != NULL)
{
- _llseek( hFile, mz_header.ne_offset + fastload_offset, SEEK_SET );
+ _llseek32( hFile, mz_header.ne_offset + fastload_offset, SEEK_SET);
if (_lread32(hFile, fastload, fastload_length) != fastload_length)
{
- free( fastload );
+ HeapFree( SystemHeap, 0, fastload );
fastload = NULL;
}
}
@@ -537,7 +530,8 @@
/* Get the segment table */
pModule->seg_table = (int)pData - (int)pModule;
- buffer = xmalloc( ne_header.n_segment_tab * sizeof(struct ne_segment_table_entry_s) );
+ buffer = HeapAlloc( SystemHeap, 0, ne_header.n_segment_tab *
+ sizeof(struct ne_segment_table_entry_s));
if (buffer)
{
int i;
@@ -545,17 +539,24 @@
if (!READ( ne_header.segment_tab_offset,
ne_header.n_segment_tab * sizeof(struct ne_segment_table_entry_s),
- buffer )) return (HMODULE16)11; /* invalid exe */
+ buffer ))
+ {
+ HeapFree( SystemHeap, 0, buffer );
+ HeapFree( SystemHeap, 0, fastload );
+ GlobalFree16( hModule );
+ return (HMODULE16)11; /* invalid exe */
+ }
pSeg = (struct ne_segment_table_entry_s *)buffer;
for (i = ne_header.n_segment_tab; i > 0; i--, pSeg++)
{
memcpy( pData, pSeg, sizeof(*pSeg) );
pData += sizeof(SEGTABLEENTRY);
}
- free( buffer );
+ HeapFree( SystemHeap, 0, buffer );
}
else
{
+ HeapFree( SystemHeap, 0, fastload );
GlobalFree16( hModule );
return (HMODULE16)11; /* invalid exe */
}
@@ -579,6 +580,7 @@
ne_header.moduleref_tab_offset - ne_header.rname_tab_offset,
pData ))
{
+ HeapFree( SystemHeap, 0, fastload );
GlobalFree16( hModule );
return (HMODULE16)11; /* invalid exe */
}
@@ -591,7 +593,12 @@
pModule->modref_table = (int)pData - (int)pModule;
if (!READ( ne_header.moduleref_tab_offset,
ne_header.n_mod_ref_tab * sizeof(WORD),
- pData )) return (HMODULE16)11; /* invalid exe */
+ pData ))
+ {
+ HeapFree( SystemHeap, 0, fastload );
+ GlobalFree16( hModule );
+ return (HMODULE16)11; /* invalid exe */
+ }
pData += ne_header.n_mod_ref_tab * sizeof(WORD);
}
else pModule->modref_table = 0; /* No module references */
@@ -603,6 +610,7 @@
ne_header.entry_tab_offset - ne_header.iname_tab_offset,
pData ))
{
+ HeapFree( SystemHeap, 0, fastload );
GlobalFree16( hModule );
return (HMODULE16)11; /* invalid exe */
}
@@ -615,11 +623,17 @@
ne_header.entry_tab_length,
pData ))
{
+ HeapFree( SystemHeap, 0, fastload );
GlobalFree16( hModule );
return (HMODULE16)11; /* invalid exe */
}
pData += ne_header.entry_tab_length;
+ /* Free the fast-load area */
+
+#undef READ
+ HeapFree( SystemHeap, 0, fastload );
+
/* Get the non-resident names table */
if (ne_header.nrname_tab_length)
@@ -632,7 +646,7 @@
return (HMODULE16)11; /* invalid exe */
}
buffer = GlobalLock16( pModule->nrname_handle );
- _llseek( hFile, ne_header.nrname_tab_offset, SEEK_SET );
+ _llseek32( hFile, ne_header.nrname_tab_offset, SEEK_SET );
if (_lread32( hFile, buffer, ne_header.nrname_tab_length )
!= ne_header.nrname_tab_length)
{
@@ -661,7 +675,6 @@
MODULE_RegisterModule( pModule );
return hModule;
-#undef READ
}
@@ -1007,7 +1020,7 @@
OFSTRUCT ofs;
#ifndef WINELIB
WORD *pModRef, *pDLLs;
- HFILE hFile;
+ HFILE32 hFile;
int i;
hModule = MODULE_FindModule( name );
@@ -1017,7 +1030,7 @@
/* Try to load the built-in first if not disabled */
if ((hModule = BUILTIN_LoadModule( name, FALSE ))) return hModule;
- if ((hFile = OpenFile( name, &ofs, OF_READ )) == HFILE_ERROR)
+ if ((hFile = OpenFile32( name, &ofs, OF_READ )) == HFILE_ERROR32)
{
/* Now try the built-in even if disabled */
if ((hModule = BUILTIN_LoadModule( name, TRUE )))
@@ -1035,7 +1048,7 @@
{
/* FIXME: Hack because PE_LoadModule is recursive */
int fd = dup( FILE_GetUnixHandle(hFile) );
- _lclose( hFile );
+ _lclose32( hFile );
if (hModule == 21) hModule = PE_LoadModule( fd, &ofs, paramBlock );
close( fd );
if (hModule < 32)
@@ -1043,7 +1056,7 @@
name, hModule );
return hModule;
}
- _lclose( hFile );
+ _lclose32( hFile );
pModule = MODULE_GetPtr( hModule );
/* Allocate the segments for this module */
@@ -1101,7 +1114,8 @@
if (pModule->flags & NE_FFLAGS_SELFLOAD)
{
- HFILE hf;
+ HFILE32 hf;
+ HGLOBAL16 hInitialStack32 = 0;
/* Handle self loading modules */
SEGTABLEENTRY * pSegTable = (SEGTABLEENTRY *) NE_SEG_TABLE(pModule);
SELFLOADHEADER *selfloadheader;
@@ -1139,17 +1153,17 @@
stack16Top->ip = 0;
stack16Top->cs = 0;
- if (!IF1632_Stack32_base) {
+ if (!IF1632_Saved32_esp)
+ {
STACK32FRAME* frame32;
char *stack32Top;
/* Setup an initial 32 bit stack frame */
- hInitialStack32 = GLOBAL_Alloc( GMEM_FIXED, 0x10000,
+ hInitialStack32 = GLOBAL_Alloc( GMEM_FIXED, 0x10000,
hModule, FALSE, FALSE,
FALSE );
/* Create the 32-bit stack frame */
- *(DWORD *)GlobalLock16(hInitialStack32) = 0xDEADBEEF;
stack32Top = (char*)GlobalLock16(hInitialStack32) +
0x10000;
frame32 = (STACK32FRAME *)stack32Top - 1;
@@ -1163,20 +1177,19 @@
frame32->retaddr = 0;
frame32->codeselector = WINE_CODE_SELECTOR;
/* pTask->esp = (DWORD)frame32; */
- IF1632_Stack32_base = WIN16_GlobalLock16(hInitialStack32);
-
}
hf = FILE_DupUnixHandle( MODULE_OpenFile( hModule ) );
CallTo16_word_ww( selfloadheader->BootApp, hModule, hf );
- _lclose(hf);
+ _lclose32(hf);
/* some BootApp procs overwrite the selector of dgroup */
pSegTable[pModule->dgroup - 1].selector = saved_dgroup;
IF1632_Saved16_ss = oldss;
IF1632_Saved16_sp = oldsp;
for (i = 2; i <= pModule->seg_count; i++) NE_LoadSegment( hModule, i );
- if (hInitialStack32){
+ if (hInitialStack32)
+ {
GlobalFree16(hInitialStack32);
- IF1632_Stack32_base = hInitialStack32 = 0;
+ hInitialStack32 = 0;
}
}
else
@@ -1389,9 +1402,18 @@
/***********************************************************************
- * WinExec (KERNEL.166)
+ * WinExec16 (KERNEL.166)
*/
-HINSTANCE16 WinExec( LPSTR lpCmdLine, WORD nCmdShow )
+HINSTANCE16 WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
+{
+ return WinExec32( lpCmdLine, nCmdShow );
+}
+
+
+/***********************************************************************
+ * WinExec32 (KERNEL32.566)
+ */
+HINSTANCE32 WinExec32( LPCSTR lpCmdLine, UINT32 nCmdShow )
{
LOADPARAMS params;
HGLOBAL16 cmdShowHandle, cmdLineHandle;
diff --git a/loader/ne_image.c b/loader/ne_image.c
index 3bf7849..9bbdf21 100644
--- a/loader/ne_image.c
+++ b/loader/ne_image.c
@@ -68,7 +68,7 @@
SELFLOADHEADER *selfloadheader;
STACK16FRAME *stack16Top;
WORD oldss, oldsp, oldselector, newselector;
- HFILE hf = FILE_DupUnixHandle( fd );
+ HFILE32 hf = FILE_DupUnixHandle( fd );
selfloadheader = (SELFLOADHEADER *)
PTR_SEG_OFF_TO_LIN(pSegTable->selector,0);
@@ -89,7 +89,7 @@
stack16Top->cs = 0;
newselector = CallTo16_word_www( selfloadheader->LoadAppSeg,
hModule, hf, segnum );
- _lclose( hf );
+ _lclose32( hf );
if (newselector != oldselector) {
/* Self loaders like creating their own selectors;
* they love asking for trouble to Wine developers
diff --git a/loader/ne_resource.c b/loader/ne_resource.c
index cd18408..5da7e3d 100644
--- a/loader/ne_resource.c
+++ b/loader/ne_resource.c
@@ -234,7 +234,7 @@
int NE_AccessResource( HMODULE16 hModule, HRSRC16 hRsrc )
{
NE_NAMEINFO *pNameInfo=NULL;
- int fd;
+ HFILE32 fd;
NE_MODULE *pModule = MODULE_GetPtr( hModule );
if (!pModule || !pModule->res_table) return -1;
@@ -242,10 +242,10 @@
pNameInfo = (NE_NAMEINFO*)((char*)pModule + hRsrc);
#endif
- if ((fd = _lopen( NE_MODULE_NAME(pModule), OF_READ )) != -1)
+ if ((fd = _lopen32( NE_MODULE_NAME(pModule), OF_READ )) != -1)
{
WORD sizeShift = *(WORD *)((char *)pModule + pModule->res_table);
- _llseek( fd, (int)pNameInfo->offset << sizeShift, SEEK_SET );
+ _llseek32( fd, (int)pNameInfo->offset << sizeShift, SEEK_SET );
}
return fd;
}
diff --git a/loader/pe_image.c b/loader/pe_image.c
index b8c321e..7f58b4d 100644
--- a/loader/pe_image.c
+++ b/loader/pe_image.c
@@ -28,7 +28,6 @@
#include "global.h"
#include "task.h"
#include "ldt.h"
-#include "registers.h"
#include "stddebug.h"
#include "debug.h"
#include "debugger.h"
@@ -419,7 +418,8 @@
load_addr = pe->load_addr = (int)xmalloc(pe->vma_size);
dprintf_win32(stddeb, "Load addr is really %x, range %x\n",
pe->load_addr, pe->vma_size);
-
+
+ memset( (void *)load_addr, 0, pe->vma_size);
for(i=0; i < pe->pe_header->coff.NumberOfSections; i++)
{
@@ -575,7 +575,6 @@
}
HINSTANCE16 MODULE_CreateInstance(HMODULE16 hModule,LOADPARAMS *params);
-void InitTask( SIGCONTEXT *context );
HINSTANCE16 PE_LoadModule( int fd, OFSTRUCT *ofs, LOADPARAMS* params )
{
@@ -636,49 +635,6 @@
}
}
-
-/* FIXME: This stuff is all on a "well it works" basis. An implementation
-based on some kind of documentation would be greatly appreciated :-) */
-
-typedef struct _TEB
-{
- void *Except; /* 00 */
- void *stack; /* 04 */
- int dummy1[4]; /* 08 */
- struct _TEB *TEBDSAlias; /* 18 */
- int dummy2[2]; /* 1C */
- int taskid; /* 24 */
- int dummy3[2]; /* 28 */
- LPBYTE process; /* 30 */ /* points to current process struct */
-} TEB;
-
-/* the current process structure. Only the processheap is of interest (off 0x18) */
-struct {
- DWORD dummy[6];
- HANDLE32 procheap; /* 18: Process Heap */
-} dummyprocess;
-
-void PE_InitTEB(int hTEB)
-{
- TDB *pTask;
- TEB *pTEB;
-
- pTask = (TDB *)(GlobalLock16(GetCurrentTask() & 0xffff));
- pTEB = (TEB *)(GlobalLock16(hTEB));
- pTEB->stack = (void *)pTask->esp;
- pTEB->Except = (void *)(-1);
- pTEB->TEBDSAlias = pTEB;
- pTEB->taskid = getpid();
-
- dummyprocess.procheap = GetProcessHeap();
- pTEB->process = &dummyprocess;
-}
-
-VOID
-NtCurrentTeb(CONTEXT *context) {
- context->Eax = GlobalLock16(LOWORD(context->SegFs));
-}
-
void PE_InitializeDLLs(HMODULE16 hModule)
{
NE_MODULE *pModule;
diff --git a/loader/signal.c b/loader/signal.c
index 9d11530..e88fada 100644
--- a/loader/signal.c
+++ b/loader/signal.c
@@ -22,9 +22,8 @@
#endif
#include "debugger.h"
-#include "miscemu.h"
#include "options.h"
-#include "registers.h"
+#include "sigcontext.h"
#include "win.h"
#include "winsock.h"
@@ -51,6 +50,7 @@
}
#endif
+extern BOOL32 INSTR_EmulateInstruction( SIGCONTEXT *context );
/**********************************************************************
* wine_timer
@@ -139,17 +139,17 @@
static void SIGNAL_fault(int signal, int code, SIGCONTEXT *context)
{
#endif
- if (CS_reg(context) == WINE_CODE_SELECTOR)
+ if (CS_sig(context) == WINE_CODE_SELECTOR)
{
fprintf( stderr, "Segmentation fault in Wine program (%x:%lx)."
" Please debug.\n",
- CS_reg(context), EIP_reg(context) );
+ CS_sig(context), EIP_sig(context) );
}
else
{
if (INSTR_EmulateInstruction( context )) return;
fprintf( stderr, "Segmentation fault in Windows program %x:%lx.\n",
- CS_reg(context), EIP_reg(context) );
+ CS_sig(context), EIP_sig(context) );
}
wine_debug( signal, context );
}
diff --git a/loader/task.c b/loader/task.c
index 1795097..9443dfa 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -11,10 +11,8 @@
#include "windows.h"
#include "task.h"
#include "callback.h"
-#include "directory.h"
#include "dos_fs.h"
#include "file.h"
-#include "debugger.h"
#include "global.h"
#include "instance.h"
#include "message.h"
@@ -24,19 +22,24 @@
#include "options.h"
#include "peexe.h"
#include "pe_image.h"
+#include "process.h"
#include "queue.h"
+#include "selectors.h"
#include "stackframe.h"
+#include "thread.h"
#include "toolhelp.h"
+#include "winnt.h"
#include "stddebug.h"
#include "debug.h"
#include "dde_proc.h"
+#ifndef WINELIB
+#include "debugger.h"
+#endif
+
/* Min. number of thunks allocated when creating a new segment */
#define MIN_THUNKS 32
- /* 32-bit stack size for each task */
-#define STACK32_SIZE 0x10000
-
extern void USER_AppExit( HTASK16, HINSTANCE16, HQUEUE16 );
/* Saved 16-bit stack for current process (Win16 only) */
@@ -45,7 +48,6 @@
/* Saved 32-bit stack for current process (Win16 only) */
DWORD IF1632_Saved32_esp = 0;
-SEGPTR IF1632_Stack32_base = 0;
/* Original Unix stack */
DWORD IF1632_Original32_esp;
@@ -279,7 +281,6 @@
*
* Allocate a thunk for MakeProcInstance().
*/
-#ifndef WINELIB32
static SEGPTR TASK_AllocThunk( HTASK16 hTask )
{
TDB *pTask;
@@ -308,7 +309,6 @@
pThunk->free = *(WORD *)((BYTE *)pThunk + pThunk->free);
return PTR_SEG_OFF_TO_SEGPTR( sel, base );
}
-#endif
/***********************************************************************
@@ -316,7 +316,6 @@
*
* Free a MakeProcInstance() thunk.
*/
-#ifndef WINELIB32
static BOOL TASK_FreeThunk( HTASK16 hTask, SEGPTR thunk )
{
TDB *pTask;
@@ -338,7 +337,6 @@
pThunk->free = LOWORD(thunk) - base;
return TRUE;
}
-#endif
/***********************************************************************
@@ -350,7 +348,7 @@
#ifndef WINELIB
static void TASK_CallToStart(void)
{
- int cs_reg, ds_reg, fs_reg, ip_reg;
+ int cs_reg, ds_reg, ip_reg;
int exit_code = 1;
TDB *pTask = (TDB *)GlobalLock16( hCurrentTask );
NE_MODULE *pModule = MODULE_GetPtr( pTask->hModule );
@@ -363,15 +361,12 @@
{
/* FIXME: all this is an ugly hack */
- extern void PE_InitTEB( int hTEB );
- extern void InitTask( SIGCONTEXT *context );
+ extern void InitTask( CONTEXT *context );
extern void PE_InitializeDLLs( HMODULE16 hModule );
InitTask( NULL );
InitApp( pTask->hModule );
- fs_reg = (int)GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, 0x10000 );
- PE_InitTEB( fs_reg );
- __asm__ __volatile__("movw %w0,%%fs"::"r" (fs_reg));
+ __asm__ __volatile__("movw %w0,%%fs"::"r" (pCurrentThread->teb_sel));
PE_InitializeDLLs( pTask->hModule );
exit_code = CallTaskStart32((FARPROC32)(pModule->pe_module->load_addr +
pModule->pe_module->pe_header->opt_coff.AddressOfEntryPoint) );
@@ -421,6 +416,7 @@
{
HTASK16 hTask;
TDB *pTask;
+ PDB32 *pdb32;
HGLOBAL16 hParentEnv;
NE_MODULE *pModule;
SEGTABLEENTRY *pSegTable;
@@ -505,10 +501,10 @@
pTask->pdb.dispatcher[0] = 0x9a; /* ljmp */
#ifndef WINELIB
*(FARPROC16 *)&pTask->pdb.dispatcher[1] = MODULE_GetEntryPoint( GetModuleHandle("KERNEL"), 102 ); /* KERNEL.102 is DOS3Call() */
+#endif
pTask->pdb.savedint22 = INT_GetHandler( 0x22 );
pTask->pdb.savedint23 = INT_GetHandler( 0x23 );
pTask->pdb.savedint24 = INT_GetHandler( 0x24 );
-#endif
pTask->pdb.fileHandlesPtr =
PTR_SEG_OFF_TO_SEGPTR( GlobalHandleToSel(pTask->hPDB),
(int)&((PDB *)0)->fileHandles );
@@ -537,15 +533,14 @@
pTask->dta = PTR_SEG_OFF_TO_SEGPTR( pTask->hPDB,
(int)&pTask->pdb.cmdLine - (int)&pTask->pdb );
- /* Allocate the 32-bit stack */
+ /* Create the Win32 part of the task */
- pTask->hStack32 = GLOBAL_Alloc( GMEM_FIXED, STACK32_SIZE, pTask->hPDB,
- FALSE, FALSE, FALSE );
+ pdb32 = PROCESS_Create();
+ pTask->thdb = THREAD_Create( pdb32, 0 );
- /* Create the 32-bit stack frame */
+ /* Create the 32-bit stack frame */
- *(DWORD *)GlobalLock16(pTask->hStack32) = 0xDEADBEEF;
- stack32Top = (char*)GlobalLock16(pTask->hStack32) + STACK32_SIZE;
+ stack32Top = (char*)pTask->thdb->teb.stack_top;
frame32 = (STACK32FRAME *)stack32Top - 1;
frame32->saved_esp = (DWORD)stack32Top;
frame32->edi = 0;
@@ -633,14 +628,15 @@
if (!(pTask = (TDB *)GlobalLock16( hTask ))) return;
hPDB = pTask->hPDB;
+ /* Delete the Win32 part of the task */
+
+ PROCESS_Destroy( &pTask->thdb->process->header );
+ THREAD_Destroy( &pTask->thdb->header );
+
/* Free the task module */
FreeModule16( pTask->hModule );
- /* Close all open files of this task */
-
- FILE_CloseAllFiles( pTask->hPDB );
-
/* Free the selector aliases */
GLOBAL_FreeBlock( pTask->hCSAlias );
@@ -667,10 +663,10 @@
*/
void TASK_KillCurrentTask( INT16 exitCode )
{
- extern void EXEC_ExitWindows( int retCode );
+ extern void EXEC_ExitWindows(void);
TDB* pTask = (TDB*) GlobalLock16( hCurrentTask );
- if (!pTask) EXEC_ExitWindows(0); /* No current task yet */
+ if (!pTask) EXEC_ExitWindows(); /* No current task yet */
/* Perform USER cleanup */
@@ -686,7 +682,7 @@
if (nTaskCount <= 1)
{
dprintf_task( stddeb, "Killing the last task, exiting\n" );
- EXEC_ExitWindows( 0 );
+ EXEC_ExitWindows();
}
/* Remove the task from the list to be sure we never switch back to it */
@@ -714,29 +710,6 @@
}
/***********************************************************************
- * TASK_YieldToSystem
- *
- * Scheduler interface, this way we ensure that all "unsafe" events are
- * processed outside the scheduler.
- */
-void TASK_YieldToSystem(TDB* pTask)
-{
- MESSAGEQUEUE* pQ;
-
- TASK_SCHEDULE();
-
- if( pTask )
- {
- pQ = (MESSAGEQUEUE*)GlobalLock16(pTask->hQueue);
- if( pQ && pQ->flags & QUEUE_FLAG_XEVENT )
- {
- pQ->flags &= ~QUEUE_FLAG_XEVENT;
- EVENT_WaitXEvent( FALSE, FALSE );
- }
- }
-}
-
-/***********************************************************************
* TASK_Reschedule
*
* This is where all the magic of task-switching happens!
@@ -830,21 +803,42 @@
/* Switch to the new stack */
hCurrentTask = hTask;
+ pCurrentThread = pNewTask->thdb;
+ pCurrentProcess = pCurrentThread->process;
IF1632_Saved16_ss = pNewTask->ss;
IF1632_Saved16_sp = pNewTask->sp;
IF1632_Saved32_esp = pNewTask->esp;
- IF1632_Stack32_base = WIN16_GlobalLock16( pNewTask->hStack32 );
+}
+
+
+/***********************************************************************
+ * TASK_YieldToSystem
+ *
+ * Scheduler interface, this way we ensure that all "unsafe" events are
+ * processed outside the scheduler.
+ */
+void TASK_YieldToSystem(TDB* pTask)
+{
+ MESSAGEQUEUE* pQ;
+
+ TASK_SCHEDULE();
+
+ if( pTask )
+ {
+ pQ = (MESSAGEQUEUE*)GlobalLock16(pTask->hQueue);
+ if( pQ && pQ->flags & QUEUE_FLAG_XEVENT )
+ {
+ pQ->flags &= ~QUEUE_FLAG_XEVENT;
+ EVENT_WaitXEvent( FALSE, FALSE );
+ }
+ }
}
/***********************************************************************
* InitTask (KERNEL.91)
*/
-#ifdef WINELIB
-void InitTask(void)
-#else
-void InitTask( SIGCONTEXT *context )
-#endif
+void InitTask( CONTEXT *context )
{
TDB *pTask;
NE_MODULE *pModule;
@@ -852,14 +846,13 @@
INSTANCEDATA *pinstance;
LONG stacklow, stackhi;
-#ifndef WINELIB
if (context) EAX_reg(context) = 0;
-#endif
if (!(pTask = (TDB *)GlobalLock16( hCurrentTask ))) return;
if (!(pModule = MODULE_GetPtr( pTask->hModule ))) return;
#ifndef WINELIB
NE_InitializeDLLs( pTask->hModule );
+#endif
if (context)
{
@@ -885,7 +878,6 @@
{
LocalInit( pTask->hInstance, 0, pModule->heap_size );
}
-#endif
/* Initialize the INSTANCEDATA structure */
pSegTable = NE_SEG_TABLE( pModule );
@@ -1039,12 +1031,10 @@
*/
FARPROC16 MakeProcInstance16( FARPROC16 func, HANDLE16 hInstance )
{
-#ifdef WINELIB
- return func; /* func can be called directly in Winelib */
-#else
BYTE *thunk;
SEGPTR thunkaddr;
+ if (__winelib) return func; /* func can be called directly in Winelib */
thunkaddr = TASK_AllocThunk( hCurrentTask );
if (!thunkaddr) return (FARPROC16)0;
thunk = PTR_SEG_TO_LIN( thunkaddr );
@@ -1058,7 +1048,6 @@
*thunk++ = 0xea; /* ljmp func */
*(DWORD *)thunk = (DWORD)func;
return (FARPROC16)thunkaddr;
-#endif
}
@@ -1067,10 +1056,8 @@
*/
void FreeProcInstance16( FARPROC16 func )
{
-#ifndef WINELIB
dprintf_task( stddeb, "FreeProcInstance(%08lx)\n", (DWORD)func );
- TASK_FreeThunk( hCurrentTask, (SEGPTR)func );
-#endif
+ if (!__winelib) TASK_FreeThunk( hCurrentTask, (SEGPTR)func );
}
@@ -1079,10 +1066,11 @@
*/
HANDLE16 GetCodeHandle( FARPROC16 proc )
{
-#ifndef WINELIB32
HANDLE16 handle;
BYTE *thunk = (BYTE *)PTR_SEG_TO_LIN( proc );
+ if (__winelib) return 0;
+
/* Return the code segment containing 'proc'. */
/* Not sure if this is really correct (shouldn't matter that much). */
@@ -1093,9 +1081,6 @@
handle = GlobalHandle16( HIWORD(proc) );
return handle;
-#else
- return (HANDLE16)proc;
-#endif
}
@@ -1174,7 +1159,7 @@
*
* Note: the function is declared as 'register' in the spec file in order
* to make sure all registers are preserved, but we don't use them in any
- * way, so we don't need a SIGCONTEXT* argument.
+ * way, so we don't need a CONTEXT* argument.
*/
void SwitchStackBack(void)
{
@@ -1217,7 +1202,7 @@
* GetTaskQueueDS (KERNEL.118)
*/
#ifndef WINELIB
-void GetTaskQueueDS( SIGCONTEXT *context )
+void GetTaskQueueDS( CONTEXT *context )
{
DS_reg(context) = GlobalHandleToSel( GetTaskQueue(0) );
}
@@ -1228,7 +1213,7 @@
* GetTaskQueueES (KERNEL.119)
*/
#ifndef WINELIB
-void GetTaskQueueES( SIGCONTEXT *context )
+void GetTaskQueueES( CONTEXT *context )
{
ES_reg(context) = GlobalHandleToSel( GetTaskQueue(0) );
}
diff --git a/memory/heap.c b/memory/heap.c
index 6924de4..39cf885 100644
--- a/memory/heap.c
+++ b/memory/heap.c
@@ -4,11 +4,11 @@
* Copyright 1996 Alexandre Julliard
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windows.h"
-#include "debugger.h"
#include "selectors.h"
#include "winbase.h"
#include "winerror.h"
@@ -187,7 +187,7 @@
if (debugging_heap && !HeapValidate( heap, 0, NULL ))
{
HEAP_Dump( heapPtr );
- DEBUG_EnterDebugger();
+ assert( FALSE );
SetLastError( ERROR_INVALID_HANDLE );
return NULL;
}
@@ -1204,12 +1204,28 @@
/***********************************************************************
+ * HEAP_xalloc
+ *
+ * Same as HeapAlloc(), but die on failure.
+ */
+LPVOID HEAP_xalloc( HANDLE32 heap, DWORD flags, DWORD size )
+{
+ LPVOID p = HeapAlloc( heap, flags, size );
+ if (!p)
+ {
+ fprintf( stderr, "Virtual memory exhausted.\n" );
+ exit(1);
+ }
+ return p;
+}
+
+
+/***********************************************************************
* HEAP_strdupA
*/
LPSTR HEAP_strdupA( HANDLE32 heap, DWORD flags, LPCSTR str )
{
- INT32 len = lstrlen32A(str) + 1;
- LPSTR p = HeapAlloc( heap, flags, len );
+ LPSTR p = HEAP_xalloc( heap, flags, lstrlen32A(str) + 1 );
lstrcpy32A( p, str );
return p;
}
@@ -1221,7 +1237,7 @@
LPWSTR HEAP_strdupW( HANDLE32 heap, DWORD flags, LPCWSTR str )
{
INT32 len = lstrlen32W(str) + 1;
- LPWSTR p = HeapAlloc( heap, flags, len * sizeof(WCHAR) );
+ LPWSTR p = HEAP_xalloc( heap, flags, len * sizeof(WCHAR) );
lstrcpy32W( p, str );
return p;
}
@@ -1235,11 +1251,7 @@
LPWSTR ret;
if (!str) return NULL;
- if (!(ret = HeapAlloc( heap, flags, (lstrlen32A(str)+1) * sizeof(WCHAR) )))
- {
- fprintf( stderr, "Virtual memory exhausted.\n" );
- exit(1);
- }
+ ret = HEAP_xalloc( heap, flags, (lstrlen32A(str)+1) * sizeof(WCHAR) );
lstrcpyAtoW( ret, str );
return ret;
}
@@ -1253,11 +1265,7 @@
LPSTR ret;
if (!str) return NULL;
- if (!(ret = HeapAlloc( heap, flags, lstrlen32W(str) + 1 )))
- {
- fprintf( stderr, "Virtual memory exhausted.\n" );
- exit(1);
- }
+ ret = HEAP_xalloc( heap, flags, lstrlen32W(str) + 1 );
lstrcpyWtoA( ret, str );
return ret;
}
diff --git a/memory/selector.c b/memory/selector.c
index 411186a..49a1309 100644
--- a/memory/selector.c
+++ b/memory/selector.c
@@ -271,14 +271,11 @@
base = GET_SEL_BASE(sel);
-#ifndef WINELIB
/* if base points into DOSMEM, assume we have to
* return pointer into physical lower 1MB
*/
- if ((base >= (DWORD)DOSMEM_dosmem) &&
- (base < ((DWORD)DOSMEM_dosmem+0x100000)))
- base = base - (DWORD)DOSMEM_dosmem;
-#endif
+ if ((base >= (DWORD)DOSMEM_dosmem) &&
+ (base < (DWORD)DOSMEM_dosmem+0x100000)) base -= (DWORD)DOSMEM_dosmem;
return base;
}
diff --git a/misc/Makefile.in b/misc/Makefile.in
index 6e34b27..702bb00 100644
--- a/misc/Makefile.in
+++ b/misc/Makefile.in
@@ -11,6 +11,7 @@
commdlg.c \
compobj.c \
crtdll.c \
+ cpu.c \
driver.c \
exec.c \
escape.c \
diff --git a/misc/comm.c b/misc/comm.c
index ea2735d..91b2161 100644
--- a/misc/comm.c
+++ b/misc/comm.c
@@ -739,7 +739,7 @@
{
dprintf_comm(stddeb,"SetCommEventMask:fd %d,mask %d\n",fd,fuEvtMask);
eventmask |= fuEvtMask;
- return (UINT *)&eventmask; /* FIXME, should be SEGPTR */
+ return (UINT16 *)&eventmask; /* FIXME, should be SEGPTR */
}
/*****************************************************************************
diff --git a/misc/commdlg.c b/misc/commdlg.c
index 42845d5..1b55460 100644
--- a/misc/commdlg.c
+++ b/misc/commdlg.c
@@ -12,6 +12,7 @@
#include "heap.h"
#include "message.h"
#include "commdlg.h"
+#include "dialog.h"
#include "dlgs.h"
#include "module.h"
#include "resource.h"
@@ -59,13 +60,22 @@
BOOL GetOpenFileName( SEGPTR ofn )
{
HINSTANCE16 hInst;
- HANDLE16 hDlgTmpl, hResInfo;
- BOOL bRet;
+ HANDLE16 hDlgTmpl = 0, hResInfo;
+ BOOL32 bRet = FALSE, win32Format = FALSE;
+ HWND32 hwndDialog;
LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(ofn);
+ LPCVOID template;
if (!lpofn || !FileDlg_Init()) return FALSE;
- if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) hDlgTmpl = lpofn->hInstance;
+ if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
+ {
+ if (!(template = LockResource16( lpofn->hInstance )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
+ }
else if (lpofn->Flags & OFN_ENABLETEMPLATE)
{
if (!(hResInfo = FindResource16(lpofn->hInstance,
@@ -74,25 +84,27 @@
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
- hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo );
+ if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
+ !(template = LockResource16( hDlgTmpl )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
}
- else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_OPEN_FILE );
- if (!hDlgTmpl)
+ else
{
- CommDlgLastError = CDERR_LOADRESFAILURE;
- return FALSE;
+ template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
+ win32Format = TRUE;
}
hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
- bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpofn->hwndOwner,
- (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
- ofn );
+ hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
+ lpofn->hwndOwner,
+ (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
+ ofn, WIN_PROC_16 );
+ if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
- if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
- {
- if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
- else SYSRES_FreeResource( hDlgTmpl );
- }
+ if (hDlgTmpl) FreeResource16( hDlgTmpl );
dprintf_commdlg(stddeb,"GetOpenFileName // return lpstrFile='%s' !\n",
(LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
@@ -106,35 +118,53 @@
BOOL GetSaveFileName( SEGPTR ofn)
{
HINSTANCE16 hInst;
- HANDLE16 hDlgTmpl, hResInfo;
- BOOL bRet;
+ HANDLE16 hDlgTmpl = 0;
+ BOOL32 bRet = FALSE, win32Format = FALSE;
LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(ofn);
-
+ LPCVOID template;
+ HWND32 hwndDialog;
+
if (!lpofn || !FileDlg_Init()) return FALSE;
- if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) hDlgTmpl = lpofn->hInstance;
+ if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
+ {
+ if (!(template = LockResource16( lpofn->hInstance )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
+ }
else if (lpofn->Flags & OFN_ENABLETEMPLATE)
{
- hInst = lpofn->hInstance;
+ HANDLE16 hResInfo;
if (!(hResInfo = FindResource16(lpofn->hInstance,
- lpofn->lpTemplateName, RT_DIALOG )))
+ lpofn->lpTemplateName, RT_DIALOG)))
{
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
- hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo );
+ if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
+ !(template = LockResource16( hDlgTmpl )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
}
- else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_SAVE_FILE );
+ else
+ {
+ template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
+ win32Format = TRUE;
+ }
hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
- bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpofn->hwndOwner,
- (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
- ofn );
- if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
- {
- if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
- else SYSRES_FreeResource( hDlgTmpl );
- }
+
+ hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
+ lpofn->hwndOwner,
+ (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
+ ofn, WIN_PROC_16 );
+ if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
+
+ if (hDlgTmpl) FreeResource16( hDlgTmpl );
dprintf_commdlg(stddeb, "GetSaveFileName // return lpstrFile='%s' !\n",
(LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
@@ -693,10 +723,9 @@
/***********************************************************************
* FindTextDlg (COMMDLG.11)
*/
-BOOL FindText( SEGPTR find )
+HWND16 FindText( SEGPTR find )
{
- HANDLE16 hInst, hDlgTmpl;
- BOOL bRet;
+ HANDLE16 hInst;
LPCVOID ptr;
LPFINDREPLACE lpFind = (LPFINDREPLACE)PTR_SEG_TO_LIN(find);
@@ -708,25 +737,20 @@
* FIXME : We should do error checking on the lpFind structure here
* and make CommDlgExtendedError() return the error condition.
*/
- hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_FIND_TEXT );
+ ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
- if (!(ptr = GlobalLock16( hDlgTmpl ))) return -1;
- bRet = CreateDialogIndirectParam16( hInst, ptr, lpFind->hwndOwner,
+ return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("FindTextDlgProc"),
- find );
- GlobalUnlock16( hDlgTmpl );
- SYSRES_FreeResource( hDlgTmpl );
- return bRet;
+ find, WIN_PROC_16 );
}
/***********************************************************************
- * ReplaceTextDlg (COMMDLG.12)
+ * ReplaceText (COMMDLG.12)
*/
-BOOL ReplaceText( SEGPTR find )
+HWND16 ReplaceText( SEGPTR find )
{
- HANDLE16 hInst, hDlgTmpl;
- BOOL bRet;
+ HANDLE16 hInst;
LPCVOID ptr;
LPFINDREPLACE lpFind = (LPFINDREPLACE)PTR_SEG_TO_LIN(find);
@@ -738,15 +762,11 @@
* FIXME : We should do error checking on the lpFind structure here
* and make CommDlgExtendedError() return the error condition.
*/
- hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_REPLACE_TEXT );
+ ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
- if (!(ptr = GlobalLock16( hDlgTmpl ))) return -1;
- bRet = CreateDialogIndirectParam16( hInst, ptr, lpFind->hwndOwner,
+ return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
- find );
- GlobalUnlock16( hDlgTmpl );
- SYSRES_FreeResource( hDlgTmpl );
- return bRet;
+ find, WIN_PROC_16 );
}
@@ -978,8 +998,10 @@
*/
BOOL PrintDlg( SEGPTR printdlg )
{
- HANDLE16 hInst, hDlgTmpl;
- BOOL bRet;
+ HANDLE16 hInst;
+ BOOL bRet = FALSE;
+ LPCVOID template;
+ HWND32 hwndDialog;
LPPRINTDLG lpPrint = (LPPRINTDLG)PTR_SEG_TO_LIN(printdlg);
dprintf_commdlg(stddeb,"PrintDlg(%p) // Flags=%08lX\n", lpPrint, lpPrint->Flags );
@@ -989,17 +1011,18 @@
return TRUE;
if (lpPrint->Flags & PD_PRINTSETUP)
- hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_PRINT_SETUP );
+ template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP );
else
- hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_PRINT );
+ template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT );
hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
- bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpPrint->hwndOwner,
+ hwndDialog = DIALOG_CreateIndirect( hInst, template, TRUE,
+ lpPrint->hwndOwner,
(DLGPROC16)((lpPrint->Flags & PD_PRINTSETUP) ?
MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
MODULE_GetWndProcEntry16("PrintDlgProc")),
- printdlg );
- SYSRES_FreeResource( hDlgTmpl );
+ printdlg, WIN_PROC_16 );
+ if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpPrint->hwndOwner);
return bRet;
}
@@ -1108,37 +1131,51 @@
BOOL ChooseColor(LPCHOOSECOLOR lpChCol)
{
HINSTANCE16 hInst;
- HANDLE16 hDlgTmpl, hResInfo;
- BOOL bRet;
+ HANDLE16 hDlgTmpl = 0;
+ BOOL bRet = FALSE, win32Format = FALSE;
+ LPCVOID template;
+ HWND32 hwndDialog;
dprintf_commdlg(stddeb,"ChooseColor\n");
if (!lpChCol) return FALSE;
- if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) hDlgTmpl = lpChCol->hInstance;
+
+ if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
+ {
+ if (!(template = LockResource16( lpChCol->hInstance )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
+ }
else if (lpChCol->Flags & CC_ENABLETEMPLATE)
{
+ HANDLE16 hResInfo;
if (!(hResInfo = FindResource16(lpChCol->hInstance,
lpChCol->lpTemplateName, RT_DIALOG)))
{
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
- hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo );
+ if (!(hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo )) ||
+ !(template = LockResource16( hDlgTmpl )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
}
- else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_COLOR );
- if (!hDlgTmpl)
+ else
{
- CommDlgLastError = CDERR_LOADRESFAILURE;
- return FALSE;
+ template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR );
+ win32Format = TRUE;
}
+
hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
- bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpChCol->hwndOwner,
+ hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
+ lpChCol->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("ColorDlgProc"),
- (DWORD)lpChCol);
- if (!(lpChCol->Flags & CC_ENABLETEMPLATEHANDLE))
- {
- if (lpChCol->Flags & CC_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
- else SYSRES_FreeResource( hDlgTmpl );
- }
+ (DWORD)lpChCol, WIN_PROC_16 );
+ if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner);
+ if (hDlgTmpl) FreeResource16( hDlgTmpl );
return bRet;
}
@@ -2189,37 +2226,52 @@
BOOL ChooseFont(LPCHOOSEFONT lpChFont)
{
HINSTANCE16 hInst;
- HANDLE16 hDlgTmpl, hResInfo;
- BOOL bRet;
+ HANDLE16 hDlgTmpl = 0;
+ BOOL bRet = FALSE, win32Format = FALSE;
+ LPCVOID template;
+ HWND32 hwndDialog;
dprintf_commdlg(stddeb,"ChooseFont\n");
if (!lpChFont) return FALSE;
- if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE) hDlgTmpl = lpChFont->hInstance;
+
+ if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
+ {
+ if (!(template = LockResource16( lpChFont->hInstance )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
+ }
else if (lpChFont->Flags & CF_ENABLETEMPLATE)
{
- if (!(hResInfo = FindResource16(lpChFont->hInstance,
- lpChFont->lpTemplateName, RT_DIALOG)))
+ HANDLE16 hResInfo;
+ if (!(hResInfo = FindResource16( lpChFont->hInstance,
+ lpChFont->lpTemplateName, RT_DIALOG)))
{
CommDlgLastError = CDERR_FINDRESFAILURE;
return FALSE;
}
- hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo );
+ if (!(hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo )) ||
+ !(template = LockResource16( hDlgTmpl )))
+ {
+ CommDlgLastError = CDERR_LOADRESFAILURE;
+ return FALSE;
+ }
}
- else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_FONT );
- if (!hDlgTmpl)
+ else
{
- CommDlgLastError = CDERR_LOADRESFAILURE;
- return FALSE;
+ template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
+ win32Format = TRUE;
}
+
hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
- bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpChFont->hwndOwner,
+
+ hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
+ lpChFont->hwndOwner,
(DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
- (DWORD)lpChFont);
- if (!(lpChFont->Flags & CF_ENABLETEMPLATEHANDLE))
- {
- if (lpChFont->Flags & CF_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
- else SYSRES_FreeResource( hDlgTmpl );
- }
+ (DWORD)lpChFont, WIN_PROC_16 );
+ if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
+ if (hDlgTmpl) FreeResource16( hDlgTmpl );
return bRet;
}
diff --git a/miscemu/cpu.c b/misc/cpu.c
similarity index 83%
rename from miscemu/cpu.c
rename to misc/cpu.c
index 63211bd..f5d10e8 100644
--- a/miscemu/cpu.c
+++ b/misc/cpu.c
@@ -11,6 +11,9 @@
int runtime_cpu (void)
{
+#ifndef __i386__
+ return 5; /* Might as well pretend to be a Pentium... */
+#else /* __i386__ */
static int cache = 0;
#ifdef linux
@@ -37,8 +40,8 @@
}
}
return cache;
-#else
+#endif /* linux */
/* FIXME: how do we do this on other systems? */
return 3;
-#endif
+#endif /* __i386__ */
}
diff --git a/misc/exec.c b/misc/exec.c
index c69416d..143dfe3 100644
--- a/misc/exec.c
+++ b/misc/exec.c
@@ -1,8 +1,8 @@
/*
-* Windows Exec & Help
-*
-*/
+ * Windows Exec & Help
+ */
+#define NO_TRANSITION_TYPES /* This file is Win32-clean */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -15,21 +15,6 @@
#include "debug.h"
#include "win.h"
-#define HELP_CONTEXT 0x0001
-#define HELP_QUIT 0x0002
-#define HELP_INDEX 0x0003
-#define HELP_CONTENTS 0x0003
-#define HELP_HELPONHELP 0x0004
-#define HELP_SETINDEX 0x0005
-#define HELP_SETCONTENTS 0x0005
-#define HELP_CONTEXTPOPUP 0x0008
-#define HELP_FORCEFILE 0x0009
-#define HELP_KEY 0x0101
-#define HELP_COMMAND 0x0102
-#define HELP_PARTIALKEY 0x0105
-#define HELP_MULTIKEY 0x0201
-#define HELP_SETWINPOS 0x0203
-
/***********************************************************************
* EXEC_ExitWindows
@@ -38,29 +23,35 @@
* This is the back-end of ExitWindows(), called when all windows
* have agreed to be terminated.
*/
-void EXEC_ExitWindows( int retCode )
+void EXEC_ExitWindows(void)
{
/* Do the clean-up stuff */
WriteOutProfiles();
SHELL_SaveRegistry();
- exit( retCode );
+ exit(0);
}
/***********************************************************************
- * ExitWindows (USER.7)
+ * ExitWindows16 (USER.7)
*/
-BOOL ExitWindows( DWORD dwReturnCode, WORD wReserved )
+BOOL16 ExitWindows16( DWORD dwReturnCode, UINT16 wReserved )
+{
+ return ExitWindowsEx( EWX_LOGOFF, 0xffffffff );
+}
+
+
+/***********************************************************************
+ * ExitWindowsEx (USER32.195)
+ */
+BOOL32 ExitWindowsEx( UINT32 flags, DWORD reserved )
{
int i;
- BOOL16 result;
+ BOOL32 result;
WND **list, **ppWnd;
- api_assert("ExitWindows", wReserved == 0);
- api_assert("ExitWindows", HIWORD(dwReturnCode) == 0);
-
/* We have to build a list of all windows first, as in EnumWindows */
if (!(list = WIN_BuildWinArray( WIN_GetDesktop() ))) return FALSE;
@@ -85,24 +76,35 @@
}
HeapFree( SystemHeap, 0, list );
- if (result) EXEC_ExitWindows( LOWORD(dwReturnCode) );
+ if (result) EXEC_ExitWindows();
return FALSE;
}
/**********************************************************************
- * WinHelp [USER.171]
+ * WinHelp16 (USER.171)
*/
-BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
+BOOL16 WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
+ DWORD dwData )
+{
+ return WinHelp32A( hWnd, lpHelpFile, wCommand,
+ (DWORD)PTR_SEG_TO_LIN(dwData) );
+}
+
+
+/**********************************************************************
+ * WinHelp32A (USER32.578)
+ */
+BOOL32 WinHelp32A( HWND32 hWnd, LPCSTR lpHelpFile, UINT32 wCommand,
+ DWORD dwData )
{
static WORD WM_WINHELP=0;
- HWND hDest;
+ HWND32 hDest;
LPWINHELP lpwh;
HGLOBAL16 hwh;
- void *data=0;
int size,dsize,nlen;
if (wCommand != HELP_QUIT) /* FIXME */
- if(WinExec("winhelp.exe -x",SW_SHOWNORMAL)<=32)
+ if(WinExec32("winhelp.exe -x",SW_SHOWNORMAL)<=32)
return FALSE;
/* FIXME: Should be directed yield, to let winhelp open the window */
Yield();
@@ -131,16 +133,13 @@
case HELP_KEY:
case HELP_PARTIALKEY:
case HELP_COMMAND:
- data = PTR_SEG_TO_LIN(dwData);
- dsize = strlen(data)+1;
+ dsize = strlen( (LPSTR)dwData )+1;
break;
case HELP_MULTIKEY:
- data = PTR_SEG_TO_LIN(dwData);
- dsize = ((LPMULTIKEYHELP)data) -> mkSize;
+ dsize = ((LPMULTIKEYHELP)dwData)->mkSize;
break;
case HELP_SETWINPOS:
- data = PTR_SEG_TO_LIN(dwData);
- dsize = ((LPHELPWININFO)data) -> wStructSize;
+ dsize = ((LPHELPWININFO)dwData)->wStructSize;
break;
default:
fprintf(stderr,"Unknown help command %d\n",wCommand);
@@ -160,10 +159,23 @@
strcpy(((char*)lpwh) + sizeof(WINHELP),lpHelpFile);
}
if(dsize) {
- memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,data,dsize);
+ memcpy(((char*)lpwh)+sizeof(WINHELP)+nlen,(LPSTR)dwData,dsize);
lpwh->ofsData = sizeof(WINHELP)+nlen;
} else
lpwh->ofsData = 0;
GlobalUnlock16(hwh);
return SendMessage16(hDest,WM_WINHELP,hWnd,hwh);
}
+
+
+/**********************************************************************
+ * WinHelp32W (USER32.579)
+ */
+BOOL32 WinHelp32W( HWND32 hWnd, LPCWSTR helpFile, UINT32 command,
+ DWORD dwData )
+{
+ LPSTR file = HEAP_strdupWtoA( GetProcessHeap(), 0, helpFile );
+ BOOL32 ret = WinHelp32A( hWnd, file, command, dwData );
+ HeapFree( GetProcessHeap(), 0, file );
+ return ret;
+}
diff --git a/misc/lstr.c b/misc/lstr.c
index 82d68b0..730b540 100644
--- a/misc/lstr.c
+++ b/misc/lstr.c
@@ -12,12 +12,12 @@
#include <ctype.h>
#include "windows.h"
+#include "heap.h"
#include "ldt.h"
#include "module.h"
#include "stddebug.h"
#include "debug.h"
#include "xmalloc.h"
-#include "string32.h"
#define ToUpper(c) toupper(c)
#define ToLower(c) tolower(c)
@@ -173,7 +173,7 @@
void OutputDebugString( LPCSTR str )
{
char *module;
- char *p, *buffer = xmalloc( strlen(str)+1 );
+ char *p, *buffer = HeapAlloc( GetProcessHeap(), 0, strlen(str)+1 );
/* Remove CRs */
for (p = buffer; *str; str++) if (*str != '\r') *p++ = *str;
*p = '\0';
@@ -181,7 +181,7 @@
module = MODULE_GetModuleName( GetExePtr(GetCurrentTask()) );
fprintf( stderr, "OutputDebugString: %s says '%s'\n",
module ? module : "???", buffer );
- free( buffer );
+ HeapFree( GetProcessHeap(), 0, buffer );
}
/***********************************************************************
@@ -506,7 +506,7 @@
fprintf(stdnimp," - line wrapping not supported.\n");
from = NULL;
if (dwFlags & FORMAT_MESSAGE_FROM_STRING)
- from = xstrdup((LPSTR)lpSource);
+ from = HEAP_strdupA( GetProcessHeap(), 0, (LPSTR)lpSource);
if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) {
/* gather information from system message tables ... */
fprintf(stdnimp," - FORMAT_MESSAGE_FROM_SYSTEM not implemented.\n");
@@ -517,11 +517,11 @@
dwMessageId &= 0xFFFF;
bufsize=LoadMessage32A(0,dwMessageId,dwLanguageId,NULL,100);
if (bufsize) {
- from = (char*)xmalloc(bufsize+1);
+ from = HeapAlloc( GetProcessHeap(), 0, bufsize + 1 );
LoadMessage32A(0,dwMessageId,dwLanguageId,from,bufsize+1);
}
}
- target = (char*)xmalloc(100);
+ target = HeapAlloc( GetProcessHeap(), 0, 100);
t = target;
talloced= 100;
*t = 0;
@@ -568,12 +568,12 @@
f++;
if (NULL!=(x=strchr(f,'!'))) {
*x='\0';
- fmtstr=(char*)xmalloc(strlen(f)+2);
+ fmtstr=HeapAlloc(GetProcessHeap(),0,strlen(f)+2);
sprintf(fmtstr,"%%%s",f);
f=x+1;
}
} else
- fmtstr=strdup("%s");
+ fmtstr=HEAP_strdupA(GetProcessHeap(),0,"%s");
if (dwFlags & FORMAT_MESSAGE_ARGUMENT_ARRAY)
argliststart=args+insertnr-1;
else
@@ -583,16 +583,16 @@
argliststart=((DWORD*)&args)+insertnr-1;
if (fmtstr[strlen(fmtstr)]=='s')
- sprintfbuf=(char*)xmalloc(strlen((LPSTR)argliststart[0])+1);
+ sprintfbuf=HeapAlloc(GetProcessHeap(),0,strlen((LPSTR)argliststart[0])+1);
else
- sprintfbuf=(char*)xmalloc(100);
+ sprintfbuf=HeapAlloc(GetProcessHeap(),0,100);
vsprintf(sprintfbuf,fmtstr,argliststart);
x=sprintfbuf;
while (*x) {
ADD_TO_T(*x++);
}
- free(sprintfbuf);
- free(fmtstr);
+ HeapFree(GetProcessHeap(),0,sprintfbuf);
+ HeapFree(GetProcessHeap(),0,fmtstr);
break;
case '0':
nolinefeed=1;
@@ -620,8 +620,8 @@
memcpy(*(LPSTR*)lpBuffer,target,talloced);
} else
strncpy(lpBuffer,target,nSize);
- free(target);
- if (from) free(from);
+ HeapFree(GetProcessHeap(),0,target);
+ if (from) HeapFree(GetProcessHeap(),0,from);
return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ?
strlen(*(LPSTR*)lpBuffer):
strlen(lpBuffer);
@@ -689,7 +689,7 @@
fprintf(stdnimp," - line wrapping not supported.\n");
from = NULL;
if (dwFlags & FORMAT_MESSAGE_FROM_STRING)
- from = STRING32_DupUniToAnsi((LPWSTR)lpSource);
+ from = HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR)lpSource);
if (dwFlags & FORMAT_MESSAGE_FROM_SYSTEM) {
/* gather information from system message tables ... */
fprintf(stdnimp," - FORMAT_MESSAGE_FROM_SYSTEM not implemented.\n");
@@ -699,12 +699,13 @@
dwMessageId &= 0xFFFF;
bufsize=LoadMessage32A(0,dwMessageId,dwLanguageId,NULL,100);
- if (bufsize) {
- from = (char*)xmalloc(bufsize+1);
- LoadMessage32A(0,dwMessageId,dwLanguageId,from,bufsize+1);
+ if (bufsize)
+ {
+ from = HeapAlloc( GetProcessHeap(), 0, bufsize + 1 );
+ LoadMessage32A(0,dwMessageId,dwLanguageId,from,bufsize+1);
}
}
- target = (char*)xmalloc(100);
+ target = HeapAlloc( GetProcessHeap(), 0, 100 );
t = target;
talloced= 100;
*t = 0;
@@ -749,14 +750,15 @@
}
if (*f=='!') {
f++;
- if (NULL!=(x=strchr(f,'!'))) {
- *x='\0';
- fmtstr=(char*)xmalloc(strlen(f)+2);
+ if (NULL!=(x=strchr(f,'!')))
+ {
+ *x='\0';
+ fmtstr=HeapAlloc( GetProcessHeap(), 0, strlen(f)+2);
sprintf(fmtstr,"%%%s",f);
f=x+1;
}
} else
- fmtstr=strdup("%s");
+ fmtstr=HEAP_strdupA( GetProcessHeap(),0,"%s");
if (dwFlags & FORMAT_MESSAGE_ARGUMENT_ARRAY)
argliststart=args+insertnr-1;
else
@@ -768,22 +770,22 @@
if (fmtstr[strlen(fmtstr)]=='s') {
DWORD xarr[3];
- xarr[0]=(DWORD)STRING32_DupUniToAnsi((LPWSTR)(*(argliststart+0)));
+ xarr[0]=(DWORD)HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR)(*(argliststart+0)));
/* possible invalid pointers */
xarr[1]=*(argliststart+1);
xarr[2]=*(argliststart+2);
- sprintfbuf=(char*)xmalloc(lstrlen32W((LPWSTR)argliststart[0])*2+1);
+ sprintfbuf=HeapAlloc(GetProcessHeap(),0,lstrlen32W((LPWSTR)argliststart[0])*2+1);
vsprintf(sprintfbuf,fmtstr,xarr);
} else {
- sprintfbuf=(char*)xmalloc(100);
+ sprintfbuf=HeapAlloc(GetProcessHeap(),0,100);
vsprintf(sprintfbuf,fmtstr,argliststart);
}
x=sprintfbuf;
while (*x) {
ADD_TO_T(*x++);
}
- free(sprintfbuf);
- free(fmtstr);
+ HeapFree(GetProcessHeap(),0,sprintfbuf);
+ HeapFree(GetProcessHeap(),0,fmtstr);
break;
case '0':
nolinefeed=1;
@@ -810,8 +812,8 @@
lstrcpynAtoW(*(LPWSTR*)lpBuffer,target,talloced);
} else
lstrcpynAtoW(lpBuffer,target,nSize);
- free(target);
- if (from) free(from);
+ HeapFree(GetProcessHeap(),0,target);
+ if (from) HeapFree(GetProcessHeap(),0,from);
return (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER) ?
lstrlen32W(*(LPWSTR*)lpBuffer):
lstrlen32W(lpBuffer);
diff --git a/misc/lzexpand.c b/misc/lzexpand.c
index a48fa0d..a149b2d 100644
--- a/misc/lzexpand.c
+++ b/misc/lzexpand.c
@@ -7,6 +7,7 @@
* FIXME: return values might be wrong
*/
+#define NO_TRANSITION_TYPES /* This file is Win32-clean */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -39,8 +40,8 @@
static BYTE LZMagic[8]={'S','Z','D','D',0x88,0xf0,0x27,0x33};
static struct lzstate {
- HFILE lzfd; /* the handle used by the program */
- HFILE realfd; /* the real filedescriptor */
+ HFILE32 lzfd; /* the handle used by the program */
+ HFILE32 realfd; /* the real filedescriptor */
CHAR lastchar; /* the last char of the filename */
DWORD reallength; /* the decompressed length of the file */
@@ -48,7 +49,7 @@
DWORD realwanted; /* the position the user wants to read from */
BYTE table[0x1000]; /* the rotating LZ table */
- UINT curtabent; /* CURrent TABle ENTry */
+ UINT32 curtabent; /* CURrent TABle ENTry */
BYTE stringlen; /* length and position of current string */
DWORD stringpos; /* from stringtable */
@@ -73,8 +74,8 @@
return 1;
} else {
int ret = _lread32(lzs->realfd,lzs->get,GETLEN);
- if (ret==HFILE_ERROR)
- return HFILE_ERROR;
+ if (ret==HFILE_ERROR32)
+ return HFILE_ERROR32;
if (ret==0)
return 0;
lzs->getlen = ret;
@@ -89,11 +90,11 @@
* return UNKNOWNALG for unknown algorithm
* returns lzfileheader in *head
*/
-static INT
-read_header(HFILE fd,struct lzfileheader *head) {
+static INT32 read_header(HFILE32 fd,struct lzfileheader *head)
+{
BYTE buf[14];
- if (_llseek(fd,0,SEEK_SET)==-1)
+ if (_llseek32(fd,0,SEEK_SET)==-1)
return LZERROR_BADINHANDLE;
/* We can't directly read the lzfileheader struct due to
@@ -114,18 +115,39 @@
return LZERROR_UNKNOWNALG;
return 1;
}
-/*
- * LZStart [LZEXPAND.7] [LZ32.6]
+
+/***********************************************************************
+ * LZStart16 (LZEXPAND.7)
*/
-INT16 LZStart(void)
+INT16 LZStart16(void)
{
- dprintf_file(stddeb,"LZStart(void)\n");
+ dprintf_file(stddeb,"LZStart16(void)\n");
return 1;
}
-/*
- * LZInit [LZEXPAND.3] [LZ32.2]
- *
+
+/***********************************************************************
+ * LZStart32 (LZ32.6)
+ */
+INT32 LZStart32(void)
+{
+ dprintf_file(stddeb,"LZStart32(void)\n");
+ return 1;
+}
+
+
+/***********************************************************************
+ * LZInit16 (LZEXPAND.3)
+ */
+HFILE16 LZInit16( HFILE16 hfSrc )
+{
+ return LZInit32( hfSrc );
+}
+
+
+/***********************************************************************
+ * LZInit32 (LZ32.2)
+ *
* initializes internal decompression buffers, returns lzfiledescriptor.
* (return value the same as hfSrc, if hfSrc is not compressed)
* on failure, returns error code <0
@@ -135,8 +157,9 @@
* since _llseek uses the same types as libc.lseek, we just use the macros of
* libc
*/
-HFILE
-LZInit(HFILE hfSrc) {
+HFILE32 LZInit32( HFILE32 hfSrc )
+{
+
struct lzfileheader head;
struct lzstate *lzs;
DWORD ret;
@@ -144,7 +167,7 @@
dprintf_file(stddeb,"LZInit(%d)\n",hfSrc);
ret=read_header(hfSrc,&head);
if (ret<=0) {
- _llseek(hfSrc,0,SEEK_SET);
+ _llseek32(hfSrc,0,SEEK_SET);
return ret?ret:hfSrc;
}
lzstates=xrealloc(lzstates,(++nroflzstates)*sizeof(struct lzstate));
@@ -167,17 +190,27 @@
return lzs->lzfd;
}
-/*
- * LZDone [LZEXPAND.9] [LZ32.8]
- */
-void
-LZDone(void) {
- dprintf_file(stddeb,"LZDone()\n");
+/***********************************************************************
+ * LZDone (LZEXPAND.9) (LZ32.8)
+ */
+void LZDone(void)
+{
+ dprintf_file(stddeb,"LZDone()\n");
}
-/*
- * GetExpandedName [LZEXPAND.10]
+
+/***********************************************************************
+ * GetExpandedName16 (LZEXPAND.10)
+ */
+INT16 GetExpandedName16( LPCSTR in, LPSTR out )
+{
+ return GetExpandedName32A( in, out );
+}
+
+
+/***********************************************************************
+ * GetExpandedName32A (LZ32.9)
*
* gets the full filename of the compressed file 'in' by opening it
* and reading the header
@@ -187,21 +220,21 @@
* "FILE.BL_" (with lastchar 'a') is being translated to "FILE.BLA"
*/
-INT16
-GetExpandedName16(LPCSTR in,LPSTR out) {
+INT32 GetExpandedName32A( LPCSTR in, LPSTR out )
+{
struct lzfileheader head;
- HFILE fd;
+ HFILE32 fd;
OFSTRUCT ofs;
- INT fnislowercased,ret,len;
+ INT32 fnislowercased,ret,len;
LPSTR s,t;
dprintf_file(stddeb,"GetExpandedName(%s)\n",in);
- fd=OpenFile(in,&ofs,OF_READ);
- if (fd==HFILE_ERROR)
+ fd=OpenFile32(in,&ofs,OF_READ);
+ if (fd==HFILE_ERROR32)
return LZERROR_BADINHANDLE;
ret=read_header(fd,&head);
if (ret<=0) {
- _lclose(fd);
+ _lclose32(fd);
return LZERROR_BADINHANDLE;
}
@@ -219,7 +252,7 @@
if (!*s) {
/* FIXME: hmm. shouldn't happen? */
fprintf(stddeb,__FILE__":GetExpandedFileName(), specified a directory or what? (%s)\n",in);
- _lclose(fd);
+ _lclose32(fd);
return 1;
}
/* see if we should use lowercase or uppercase on the last char */
@@ -250,15 +283,16 @@
t[len]=head.lastchar;
}
} /* else no modification necessary */
- _lclose(fd);
+ _lclose32(fd);
return 1;
}
-/*
- * GetExpandedNameW [LZ32.11]
+
+/***********************************************************************
+ * GetExpandedName32W (LZ32.11)
*/
-INT32
-GetExpandedName32W(LPCWSTR in,LPWSTR out) {
+INT32 GetExpandedName32W( LPCWSTR in, LPWSTR out )
+{
char *xin,*xout;
INT32 ret;
@@ -271,26 +305,21 @@
return ret;
}
-/*
- * GetExpandedNameA [LZ32.9]
+
+/***********************************************************************
+ * LZRead16 (LZEXPAND.5)
*/
-INT32
-GetExpandedName32A(LPCSTR in,LPSTR out) {
- return GetExpandedName16(in,out);
+INT16 LZRead16( HFILE16 fd, LPVOID buf, UINT16 toread )
+{
+ return LZRead32(fd,buf,toread);
}
-/*
- * LZRead [LZEXPAND.5] [LZ32.4]
- * just as normal read, but reads from LZ special fd and uncompresses.
- */
-INT16
-LZRead16(HFILE fd,SEGPTR segbuf,UINT16 toread) {
- dprintf_file(stddeb,"LZRead16(%d,%08lx,%d)\n",fd,(DWORD)segbuf,toread);
- return LZRead32(fd,(LPBYTE)PTR_SEG_TO_LIN(segbuf),toread);
-}
-INT32
-LZRead32(HFILE fd,LPVOID vbuf,UINT32 toread) {
+/***********************************************************************
+ * LZRead32 (LZ32.4)
+ */
+INT32 LZRead32( HFILE32 fd, LPVOID vbuf, UINT32 toread )
+{
int i,howmuch;
BYTE b,*buf;
struct lzstate *lzs;
@@ -358,7 +387,7 @@
*/
if (lzs->realcurrent>lzs->realwanted) {
/* flush decompressor state */
- _llseek(lzs->realfd,14,SEEK_SET);
+ _llseek32(lzs->realfd,14,SEEK_SET);
GET_FLUSH(lzs);
lzs->realcurrent= 0;
lzs->bytetype = 0;
@@ -381,14 +410,21 @@
#undef DECOMPRESS_ONE_BYTE
}
-/*
- * LZSeek [LZEXPAND.4] [LZ32.3]
- *
- * works as the usual _llseek
- */
-LONG
-LZSeek(HFILE fd,LONG off,INT32 type) {
+/***********************************************************************
+ * LZSeek16 (LZEXPAND.4)
+ */
+LONG LZSeek16( HFILE16 fd, LONG off, INT16 type )
+{
+ return LZSeek32( fd, off, type );
+}
+
+
+/***********************************************************************
+ * LZSeek32 (LZ32.3)
+ */
+LONG LZSeek32( HFILE32 fd, LONG off, INT32 type )
+{
int i;
struct lzstate *lzs;
LONG newwanted;
@@ -399,7 +435,7 @@
break;
/* not compressed? just use normal _llseek() */
if (i==nroflzstates)
- return _llseek(fd,off,type);
+ return _llseek32(fd,off,type);
lzs = lzstates+i;
newwanted = lzs->realwanted;
switch (type) {
@@ -421,20 +457,30 @@
return newwanted;
}
-/*
- * LZCopy [LZEXPAND.1] [LZ32.0]
+
+/***********************************************************************
+ * LZCopy16 (LZEXPAND.1)
+ */
+LONG LZCopy16( HFILE16 src, HFILE16 dest )
+{
+ return LZCopy32( src, dest );
+}
+
+
+/***********************************************************************
+ * LZCopy32 (LZ32.0)
*
* Copies everything from src to dest
* if src is a LZ compressed file, it will be uncompressed.
* will return the number of bytes written to dest or errors.
*/
-LONG
-LZCopy(HFILE src,HFILE dest) {
+LONG LZCopy32( HFILE32 src, HFILE32 dest )
+{
int i,ret,wret;
LONG len;
#define BUFLEN 1000
BYTE buf[BUFLEN];
- INT32 (*xread)(HFILE,LPVOID,UINT32);
+ INT32 (*xread)(HFILE32,LPVOID,UINT32);
dprintf_file(stddeb,"LZCopy(%d,%d)\n",src,dest);
for (i=0;i<nroflzstates;i++)
@@ -443,7 +489,7 @@
/* not compressed? just copy */
if (i==nroflzstates)
- xread=(INT32(*)(HFILE,LPVOID,UINT32))_lread32;
+ xread=(INT32(*)(HFILE32,LPVOID,UINT32))_lread32;
else
xread=LZRead32;
len=0;
@@ -482,54 +528,58 @@
return mfn;
}
-/*
- * LZOpenFile [LZEXPAND.2]
+
+/***********************************************************************
+ * LZOpenFile16 (LZEXPAND.2)
+ */
+HFILE16 LZOpenFile16( LPCSTR fn, LPOFSTRUCT ofs, UINT16 mode )
+{
+ return LZOpenFile32A( fn, ofs, mode );
+}
+
+
+/***********************************************************************
+ * LZOpenFile32A (LZ32.1)
+ *
* Opens a file. If not compressed, open it as a normal file.
*/
-HFILE
-LZOpenFile16(LPCSTR fn,LPOFSTRUCT ofs,UINT16 mode) {
- HFILE fd,cfd;
+HFILE32 LZOpenFile32A( LPCSTR fn, LPOFSTRUCT ofs, UINT32 mode )
+{
+ HFILE32 fd,cfd;
dprintf_file(stddeb,"LZOpenFile(%s,%p,%d)\n",fn,ofs,mode);
/* 0x70 represents all OF_SHARE_* flags, ignore them for the check */
- fd=OpenFile(fn,ofs,mode);
- if (fd==HFILE_ERROR)
+ fd=OpenFile32(fn,ofs,mode);
+ if (fd==HFILE_ERROR32)
{
LPSTR mfn = LZEXPAND_MangleName(fn);
- fd = OpenFile(mfn,ofs,mode);
+ fd = OpenFile32(mfn,ofs,mode);
free( mfn );
}
if ((mode&~0x70)!=OF_READ)
return fd;
- if (fd==HFILE_ERROR)
- return HFILE_ERROR;
- cfd=LZInit(fd);
+ if (fd==HFILE_ERROR32)
+ return HFILE_ERROR32;
+ cfd=LZInit32(fd);
if (cfd<=0)
return fd;
return cfd;
}
-/*
- * LZOpenFileA [LZ32.1]
- */
-HFILE
-LZOpenFile32A(LPCSTR fn,LPOFSTRUCT ofs,UINT32 mode) {
- return LZOpenFile16(fn,ofs,mode);
-}
-/*
- * LZOpenFileW [LZ32.10]
+/***********************************************************************
+ * LZOpenFile32W (LZ32.10)
*/
-HFILE
-LZOpenFile32W(LPCWSTR fn,LPOFSTRUCT ofs,UINT32 mode) {
+HFILE32 LZOpenFile32W( LPCWSTR fn, LPOFSTRUCT ofs, UINT32 mode )
+{
LPSTR xfn;
LPWSTR yfn;
- HFILE ret;
+ HFILE32 ret;
xfn = HEAP_strdupWtoA( GetProcessHeap(), 0, fn);
ret = LZOpenFile16(xfn,ofs,mode);
HeapFree( GetProcessHeap(), 0, xfn );
- if (ret!=HFILE_ERROR) {
+ if (ret!=HFILE_ERROR32) {
/* ofs->szPathName is an array with the OFSTRUCT */
yfn = HEAP_strdupAtoW( GetProcessHeap(), 0, ofs->szPathName );
memcpy(ofs->szPathName,yfn,lstrlen32W(yfn)*2+2);
@@ -538,11 +588,21 @@
return ret;
}
-/*
- * LZClose [LZEXPAND.6] [LZ32.5]
+
+/***********************************************************************
+ * LZClose16 (LZEXPAND.6)
*/
-void
-LZClose(HFILE fd) {
+void LZClose16( HFILE16 fd )
+{
+ return LZClose32( fd );
+}
+
+
+/***********************************************************************
+ * LZClose32 (LZ32.5)
+ */
+void LZClose32( HFILE32 fd )
+{
int i;
dprintf_file(stddeb,"LZClose(%d)\n",fd);
@@ -550,25 +610,35 @@
if (lzstates[i].lzfd==fd)
break;
if (i==nroflzstates) {
- _lclose(fd);
+ _lclose32(fd);
return;
}
if (lzstates[i].get)
free(lzstates[i].get);
- _lclose(lzstates[i].realfd);
+ _lclose32(lzstates[i].realfd);
memcpy(lzstates+i,lzstates+i+1,sizeof(struct lzstate)*(nroflzstates-i-1));
nroflzstates--;
lzstates=xrealloc(lzstates,sizeof(struct lzstate)*nroflzstates);
}
-/*
- * CopyLZFile [LZEXPAND.8] [LZ32.7]
+/***********************************************************************
+ * CopyLZFile16 (LZEXPAND.8)
+ */
+LONG CopyLZFile16( HFILE16 src, HFILE16 dest )
+{
+ dprintf_file(stddeb,"CopyLZFile16(%d,%d)\n",src,dest);
+ return LZCopy32(src,dest);
+}
+
+
+/***********************************************************************
+ * CopyLZFile32 (LZ32.7)
*
* Copy src to dest (including uncompressing src).
* NOTE: Yes. This is exactly the same function as LZCopy.
*/
-LONG
-CopyLZFile(HFILE src,HFILE dest) {
- dprintf_file(stddeb,"CopyLZFile(%d,%d)\n",src,dest);
- return LZCopy(src,dest);
+LONG CopyLZFile32( HFILE32 src, HFILE32 dest )
+{
+ dprintf_file(stddeb,"CopyLZFile32(%d,%d)\n",src,dest);
+ return LZCopy32(src,dest);
}
diff --git a/misc/main.c b/misc/main.c
index 754950e..5be6dbf 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -27,7 +27,6 @@
#include "winsock.h"
#include "options.h"
#include "desktop.h"
-#include "registers.h"
#include "shell.h"
#include "winbase.h"
#define DEBUG_DEFINE_VARIABLES
@@ -781,11 +780,7 @@
long result = 0;
/* There doesn't seem to be any Pentium flag. */
-#ifndef WINELIB
long cpuflag = cpuflags[MIN (runtime_cpu (), 4)];
-#else
- long cpuflag = cpuflags[4];
-#endif
switch(Options.mode) {
case MODE_STANDARD:
diff --git a/misc/registry.c b/misc/registry.c
index ece9fb0..9b7c209 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -201,7 +201,7 @@
int i,j,len;
LPWSTR ws;
- ws = strdupW(wp);
+ ws = HEAP_strdupW( SystemHeap, 0, wp );
*wpc = 1;
for (i=0;ws[i];i++) {
if (ws[i]=='\\') {
@@ -210,7 +210,7 @@
}
}
len = i;
- *wpv = (LPWSTR*)xmalloc(sizeof(LPWSTR)*(*wpc+2));
+ *wpv = (LPWSTR*)HeapAlloc( SystemHeap, 0, sizeof(LPWSTR)*(*wpc+2));
(*wpv)[0]= ws;
j = 1;
for (i=1;i<len;i++)
@@ -218,7 +218,7 @@
(*wpv)[j++]=ws+i;
(*wpv)[j]=NULL;
}
-#define FREE_KEY_PATH free(wps[0]);free(wps);
+#define FREE_KEY_PATH HeapFree(SystemHeap,0,wps[0]);HeapFree(SystemHeap,0,wps);
/*
* Shell initialisation, allocates keys.
@@ -1109,7 +1109,7 @@
};
struct _w95nr2da *nr2da;
- HFILE hfd;
+ HFILE32 hfd;
int lastmodified;
char magic[5];
unsigned long nr,pos,i,where,version,rgdbsection,end,off_next_rgdb;
@@ -1120,8 +1120,8 @@
BY_HANDLE_FILE_INFORMATION hfdinfo;
dprintf_reg(stddeb,"Loading Win95 registry database '%s'\n",fn);
- hfd=OpenFile(fn,&ofs,OF_READ);
- if (hfd==HFILE_ERROR)
+ hfd=OpenFile32(fn,&ofs,OF_READ);
+ if (hfd==HFILE_ERROR32)
return;
magic[4]=0;
if (4!=_lread32(hfd,magic,4))
@@ -1134,7 +1134,7 @@
return;
if (4!=_lread32(hfd,&rgdbsection,4))
return;
- if (-1==_llseek(hfd,0x20,SEEK_SET))
+ if (-1==_llseek32(hfd,0x20,SEEK_SET))
return;
if (4!=_lread32(hfd,magic,4))
return;
@@ -1144,7 +1144,7 @@
}
/* STEP 1: Keylink structures */
- if (-1==_llseek(hfd,0x40,SEEK_SET))
+ if (-1==_llseek32(hfd,0x40,SEEK_SET))
return;
where = 0x40;
end = rgdbsection;
@@ -1231,12 +1231,12 @@
end = hfdinfo.nFileSizeLow;
lastmodified = DOSFS_FileTimeToUnixTime(&(hfdinfo.ftLastWriteTime));
- if (-1==_llseek(hfd,rgdbsection,SEEK_SET))
+ if (-1==_llseek32(hfd,rgdbsection,SEEK_SET))
return;
data = (char*)xmalloc(end-rgdbsection);
if ((end-rgdbsection)!=_lread32(hfd,data,end-rgdbsection))
return;
- _lclose(hfd);
+ _lclose32(hfd);
curdata = data;
memcpy(magic,curdata,4);
memcpy(&off_next_rgdb,curdata+4,4);
@@ -1471,7 +1471,7 @@
void
_w31_loadreg() {
- HFILE hf;
+ HFILE32 hf;
struct _w31_header head;
struct _w31_tabent *tab;
unsigned char *txt;
@@ -1482,19 +1482,19 @@
HKEY hkey;
LPKEYSTRUCT lpkey;
- hf = OpenFile("reg.dat",&ofs,OF_READ);
- if (hf==HFILE_ERROR)
+ hf = OpenFile32("reg.dat",&ofs,OF_READ);
+ if (hf==HFILE_ERROR32)
return;
/* read & dump header */
if (sizeof(head)!=_lread32(hf,&head,sizeof(head))) {
dprintf_reg(stddeb,"_w31_loadreg:reg.dat is too short.\n");
- _lclose(hf);
+ _lclose32(hf);
return;
}
if (memcmp(head.cookie, "SHCC3.10", sizeof(head.cookie))!=0) {
dprintf_reg(stddeb,"_w31_loadreg:reg.dat has bad signature.\n");
- _lclose(hf);
+ _lclose32(hf);
return;
}
@@ -1504,24 +1504,24 @@
if (len!=_lread32(hf,tab,len)) {
dprintf_reg(stderr,"_w31_loadreg:couldn't read %d bytes.\n",len);
free(tab);
- _lclose(hf);
+ _lclose32(hf);
return;
}
/* read text */
txt = xmalloc(head.textsize);
- if (-1==_llseek(hf,head.textoff,SEEK_SET)) {
+ if (-1==_llseek32(hf,head.textoff,SEEK_SET)) {
dprintf_reg(stderr,"_w31_loadreg:couldn't seek to textblock.\n");
free(tab);
free(txt);
- _lclose(hf);
+ _lclose32(hf);
return;
}
if (head.textsize!=_lread32(hf,txt,head.textsize)) {
dprintf_reg(stderr,"_w31_loadreg:textblock too short (%d instead of %ld).\n",len,head.textsize);
free(tab);
free(txt);
- _lclose(hf);
+ _lclose32(hf);
return;
}
@@ -1529,7 +1529,7 @@
dprintf_reg(stderr,"_w31_loadreg:GetFileInformationByHandle failed?.\n");
free(tab);
free(txt);
- _lclose(hf);
+ _lclose32(hf);
return;
}
lastmodified = DOSFS_FileTimeToUnixTime(&(hfinfo.ftLastWriteTime));
@@ -1540,7 +1540,7 @@
__w31_dumptree(tab[0].w1,txt,tab,&head,lpkey,lastmodified,0);
free(tab);
free(txt);
- _lclose(hf);
+ _lclose32(hf);
return;
}
@@ -2800,9 +2800,9 @@
dprintf_reg(stddeb,"RegDeleteKey32A(%x,%s)\n",
hkey,lpszSubKey
);
- lpszSubKeyW=strdupA2W(lpszSubKey);
+ lpszSubKeyW=HEAP_strdupAtoW(GetProcessHeap(),0,lpszSubKey);
ret=RegDeleteKey32W(hkey,lpszSubKeyW);
- free(lpszSubKeyW);
+ HeapFree(GetProcessHeap(),0,lpszSubKeyW);
return ret;
}
@@ -2867,13 +2867,9 @@
DWORD ret;
dprintf_reg( stddeb, "RegDeleteValue32A(%x,%s)\n", hkey,lpszValue );
- if (lpszValue)
- lpszValueW=strdupA2W(lpszValue);
- else
- lpszValueW=NULL;
+ lpszValueW=HEAP_strdupAtoW(GetProcessHeap(),0,lpszValue);
ret=RegDeleteValue32W(hkey,lpszValueW);
- if (lpszValueW)
- free(lpszValueW);
+ HeapFree(GetProcessHeap(),0,lpszValueW);
return ret;
}
diff --git a/misc/shell.c b/misc/shell.c
index 486e733..40a4534 100644
--- a/misc/shell.c
+++ b/misc/shell.c
@@ -163,12 +163,8 @@
/* FIXME - should throw a warning, perhaps! */
return 2; /* File not found. Close enough, I guess. */
}
- if (SearchPath32A(lpDirectory,lpFile,NULL,sizeof(xlpFile),xlpFile,NULL))
- lpFile = xlpFile;
- else {
- if (SearchPath32A(lpDirectory,lpFile,".exe",sizeof(xlpFile),xlpFile,NULL))
- lpFile = xlpFile;
- }
+ if (SearchPath32A(lpDirectory,lpFile,".exe",sizeof(xlpFile),xlpFile,NULL))
+ lpFile = xlpFile;
/* First thing we need is the file's extension */
extension = strrchr( xlpFile, '.' ); /* Assume last "." is the one; */
@@ -321,7 +317,7 @@
}
dprintf_exec(stddeb,"ShellExecute:starting %s\n",cmd);
- return WinExec(cmd,iShowCmd);
+ return WinExec32(cmd,iShowCmd);
}
/*************************************************************************
@@ -351,105 +347,124 @@
return retval;
}
-static char AppName[128], AppMisc[1536];
+typedef struct
+{
+ LPCSTR szApp;
+ LPCSTR szOtherStuff;
+ HICON32 hIcon;
+} ABOUT_INFO;
+
/*************************************************************************
- * AboutDlgProc [SHELL.33]
+ * AboutDlgProc32 (not an exported API function)
*/
-LRESULT AboutDlgProc(HWND hWnd, UINT msg, WPARAM16 wParam, LPARAM lParam)
+LRESULT AboutDlgProc32( HWND32 hWnd, UINT32 msg, WPARAM32 wParam,
+ LPARAM lParam )
{
- char Template[512], AppTitle[512];
-
- switch(msg) {
- case WM_INITDIALOG:
- SendDlgItemMessage32A(hWnd,stc1,STM_SETICON,lParam,0);
- GetWindowText32A(hWnd, Template, sizeof(Template));
- sprintf(AppTitle, Template, AppName);
- SetWindowText32A(hWnd, AppTitle);
- SetWindowText32A(GetDlgItem(hWnd,100), AppMisc);
- return 1;
+ char Template[512], AppTitle[512];
+
+ switch(msg)
+ {
+ case WM_INITDIALOG:
+ {
+ ABOUT_INFO *info = (ABOUT_INFO *)lParam;
+ if (info)
+ {
+ SendDlgItemMessage32A(hWnd, stc1, STM_SETICON, info->hIcon, 0);
+ GetWindowText32A( hWnd, Template, sizeof(Template) );
+ sprintf( AppTitle, Template, info->szApp );
+ SetWindowText32A( hWnd, AppTitle );
+ SetWindowText32A( GetDlgItem(hWnd,100), info->szOtherStuff );
+ }
+ }
+ return 1;
- case WM_COMMAND:
- switch (wParam) {
- case IDOK:
- EndDialog(hWnd, TRUE);
- return TRUE;
+ case WM_COMMAND:
+ if (wParam == IDOK)
+ {
+ EndDialog(hWnd, TRUE);
+ return TRUE;
+ }
+ break;
}
- break;
- }
- return FALSE;
+ return 0;
+}
+
+
+/*************************************************************************
+ * AboutDlgProc16 (SHELL.33)
+ */
+LRESULT AboutDlgProc16( HWND16 hWnd, UINT16 msg, WPARAM16 wParam,
+ LPARAM lParam )
+{
+ return AboutDlgProc32( hWnd, msg, wParam, lParam );
+}
+
+
+/*************************************************************************
+ * ShellAbout16 (SHELL.22)
+ */
+BOOL16 ShellAbout16( HWND16 hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
+ HICON16 hIcon )
+{
+ return ShellAbout32A( hWnd, szApp, szOtherStuff, hIcon );
}
/*************************************************************************
- * ShellAbout [SHELL.22]
+ * ShellAbout32A (SHELL32.82)
*/
-INT ShellAbout(HWND hWnd, LPCSTR szApp, LPCSTR szOtherStuff, HICON16 hIcon)
+BOOL32 ShellAbout32A( HWND32 hWnd, LPCSTR szApp, LPCSTR szOtherStuff,
+ HICON32 hIcon )
{
- HGLOBAL16 handle;
- BOOL bRet;
-
- if (szApp) strncpy(AppName, szApp, sizeof(AppName));
- else *AppName = 0;
- AppName[sizeof(AppName)-1]=0;
-
- if (szOtherStuff) strncpy(AppMisc, szOtherStuff, sizeof(AppMisc));
- else *AppMisc = 0;
- AppMisc[sizeof(AppMisc)-1]=0;
-
- if (!hIcon) hIcon = LoadIcon16(0,MAKEINTRESOURCE(OIC_WINEICON));
- handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
- if (!handle) return FALSE;
- bRet = DialogBoxIndirectParam16( WIN_GetWindowInstance( hWnd ),
- handle, hWnd,
- (DLGPROC16)MODULE_GetWndProcEntry16("AboutDlgProc"),
- (LPARAM)hIcon );
- SYSRES_FreeResource( handle );
- return bRet;
+ ABOUT_INFO info;
+ info.szApp = szApp;
+ info.szOtherStuff = szOtherStuff;
+ info.hIcon = hIcon;
+ if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE(OIC_WINEICON) );
+ return DialogBoxIndirectParam32A( WIN_GetWindowInstance( hWnd ),
+ SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
+ hWnd, AboutDlgProc32, (LPARAM)&info );
}
+
/*************************************************************************
- * ShellAbout32W [SHELL32.83]
+ * ShellAbout32W (SHELL32.83)
*/
-INT32 ShellAbout32W(HWND32 hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff, HICON16 hIcon)
+BOOL32 ShellAbout32W( HWND32 hWnd, LPCWSTR szApp, LPCWSTR szOtherStuff,
+ HICON32 hIcon )
{
- HGLOBAL16 handle;
- BOOL bRet;
+ BOOL32 ret;
+ ABOUT_INFO info;
- if (szApp) lstrcpynWtoA(AppName, szApp, sizeof(AppName));
- else *AppName = 0;
- AppName[sizeof(AppName)-1]=0;
-
- if (szOtherStuff) lstrcpynWtoA(AppMisc, szOtherStuff, sizeof(AppMisc));
- else *AppMisc = 0;
- AppMisc[sizeof(AppMisc)-1]=0;
-
- if (!hIcon) hIcon = LoadIcon16(0,MAKEINTRESOURCE(OIC_WINEICON));
- handle = SYSRES_LoadResource( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX );
- if (!handle) return FALSE;
- bRet = DialogBoxIndirectParam16( WIN_GetWindowInstance( hWnd ),
- handle, hWnd,
- (DLGPROC16)MODULE_GetWndProcEntry16("AboutDlgProc"),
- (LPARAM)hIcon );
- SYSRES_FreeResource( handle );
- return bRet;
+ info.szApp = HEAP_strdupWtoA( GetProcessHeap(), 0, szApp );
+ info.szOtherStuff = HEAP_strdupWtoA( GetProcessHeap(), 0, szOtherStuff );
+ info.hIcon = hIcon;
+ if (!hIcon) info.hIcon = LoadIcon16( 0, MAKEINTRESOURCE(OIC_WINEICON) );
+ ret = DialogBoxIndirectParam32A( WIN_GetWindowInstance( hWnd ),
+ SYSRES_GetResPtr( SYSRES_DIALOG_SHELL_ABOUT_MSGBOX ),
+ hWnd, AboutDlgProc32, (LPARAM)&info );
+ HeapFree( GetProcessHeap(), 0, (LPSTR)info.szApp );
+ HeapFree( GetProcessHeap(), 0, (LPSTR)info.szOtherStuff );
+ return ret;
}
+
/*************************************************************************
* SHELL_GetResourceTable
*
* FIXME: Implement GetPEResourceTable in w32sys.c and call it here.
*/
-static BYTE* SHELL_GetResourceTable(HFILE hFile)
+static BYTE* SHELL_GetResourceTable(HFILE32 hFile)
{
struct mz_header_s mz_header;
struct ne_header_s ne_header;
int size;
- _llseek( hFile, 0, SEEK_SET );
+ _llseek32( hFile, 0, SEEK_SET );
if ((_lread32(hFile,&mz_header,sizeof(mz_header)) != sizeof(mz_header)) ||
(mz_header.mz_magic != MZ_SIGNATURE)) return (BYTE*)-1;
- _llseek( hFile, mz_header.ne_offset, SEEK_SET );
+ _llseek32( hFile, mz_header.ne_offset, SEEK_SET );
if (_lread32( hFile, &ne_header, sizeof(ne_header) ) != sizeof(ne_header))
return NULL;
@@ -467,7 +482,7 @@
if( !pTypeInfo ) return NULL;
- _llseek(hFile, mz_header.ne_offset+ne_header.resource_tab_offset, SEEK_SET);
+ _llseek32(hFile, mz_header.ne_offset+ne_header.resource_tab_offset, SEEK_SET);
if( _lread32( hFile, (char*)pTypeInfo, size) != size )
{ free(pTypeInfo); return NULL; }
return pTypeInfo;
@@ -480,14 +495,14 @@
/*************************************************************************
* SHELL_LoadResource
*/
-static HGLOBAL16 SHELL_LoadResource(HINSTANCE16 hInst, HFILE hFile, NE_NAMEINFO* pNInfo, WORD sizeShift)
+static HGLOBAL16 SHELL_LoadResource(HINSTANCE16 hInst, HFILE32 hFile, NE_NAMEINFO* pNInfo, WORD sizeShift)
{
BYTE* ptr;
HGLOBAL16 handle = DirectResAlloc( hInst, 0x10, (DWORD)pNInfo->length << sizeShift);
if( (ptr = (BYTE*)GlobalLock16( handle )) )
{
- _llseek( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
+ _llseek32( hFile, (DWORD)pNInfo->offset << sizeShift, SEEK_SET);
_lread32( hFile, (char*)ptr, pNInfo->length << sizeShift);
return handle;
}
@@ -497,14 +512,14 @@
/*************************************************************************
* ICO_LoadIcon
*/
-static HGLOBAL16 ICO_LoadIcon(HINSTANCE16 hInst, HFILE hFile, LPicoICONDIRENTRY lpiIDE)
+static HGLOBAL16 ICO_LoadIcon(HINSTANCE16 hInst, HFILE32 hFile, LPicoICONDIRENTRY lpiIDE)
{
BYTE* ptr;
HGLOBAL16 handle = DirectResAlloc( hInst, 0x10, lpiIDE->dwBytesInRes);
if( (ptr = (BYTE*)GlobalLock16( handle )) )
{
- _llseek( hFile, lpiIDE->dwImageOffset, SEEK_SET);
+ _llseek32( hFile, lpiIDE->dwImageOffset, SEEK_SET);
_lread32( hFile, (char*)ptr, lpiIDE->dwBytesInRes);
return handle;
}
@@ -516,13 +531,13 @@
*
* Read .ico file and build phony ICONDIR struct for GetIconID
*/
-static HGLOBAL16 ICO_GetIconDirectory(HINSTANCE16 hInst, HFILE hFile, LPicoICONDIR* lplpiID )
+static HGLOBAL16 ICO_GetIconDirectory(HINSTANCE16 hInst, HFILE32 hFile, LPicoICONDIR* lplpiID )
{
WORD id[3]; /* idReserved, idType, idCount */
LPicoICONDIR lpiID;
int i;
- _llseek( hFile, 0, SEEK_SET );
+ _llseek32( hFile, 0, SEEK_SET );
if( _lread32(hFile,(char*)id,sizeof(id)) != sizeof(id) ) return 0;
/* check .ICO header
@@ -573,12 +588,12 @@
HGLOBAL16* RetPtr = NULL;
BYTE* pData;
OFSTRUCT ofs;
- HFILE hFile = OpenFile( lpszExeFileName, &ofs, OF_READ );
+ HFILE32 hFile = OpenFile32( lpszExeFileName, &ofs, OF_READ );
dprintf_reg(stddeb, "InternalExtractIcon(%04x, file '%s', start from %d, extract %d\n",
hInstance, lpszExeFileName, nIconIndex, n);
- if( hFile == HFILE_ERROR || !n ) return 0;
+ if( hFile == HFILE_ERROR32 || !n ) return 0;
hRet = GlobalAlloc16( GMEM_FIXED | GMEM_ZEROINIT, sizeof(HICON16)*n);
RetPtr = (HICON16*)GlobalLock16(hRet);
@@ -661,7 +676,7 @@
if( icoFile ) free(lpiID);
else free(pData);
}
- _lclose( hFile );
+ _lclose32( hFile );
/* return array with icon handles */
diff --git a/misc/user.c b/misc/user.c
index 68a91a5..7fd72874 100644
--- a/misc/user.c
+++ b/misc/user.c
@@ -20,8 +20,6 @@
WORD USER_HeapSel = 0;
-
-extern HTASK16 TASK_GetNextTask(HTASK16);
extern BOOL32 MENU_SwitchTPWndTo(HTASK16);
/***********************************************************************
diff --git a/misc/ver.c b/misc/ver.c
index 84740c8..7eedf6d 100644
--- a/misc/ver.c
+++ b/misc/ver.c
@@ -23,21 +23,21 @@
#define LZREAD(what) \
if (sizeof(*what)!=LZRead32(lzfd,what,sizeof(*what))) return 0;
-#define LZTELL(lzfd) LZSeek(lzfd, 0, SEEK_CUR);
+#define LZTELL(lzfd) LZSeek32(lzfd, 0, SEEK_CUR);
int
-read_ne_header(HFILE lzfd,struct ne_header_s *nehd) {
+read_ne_header(HFILE32 lzfd,struct ne_header_s *nehd) {
struct mz_header_s mzh;
- LZSeek(lzfd,0,SEEK_SET);
+ LZSeek32(lzfd,0,SEEK_SET);
if (sizeof(mzh)!=LZRead32(lzfd,&mzh,sizeof(mzh)))
return 0;
if (mzh.mz_magic!=MZ_SIGNATURE)
return 0;
- LZSeek(lzfd,mzh.ne_offset,SEEK_SET);
+ LZSeek32(lzfd,mzh.ne_offset,SEEK_SET);
LZREAD(nehd);
if (nehd->ne_magic == NE_SIGNATURE) {
- LZSeek(lzfd,mzh.ne_offset,SEEK_SET);
+ LZSeek32(lzfd,mzh.ne_offset,SEEK_SET);
return 1;
}
/* must handle PE files too. Later. */
@@ -47,7 +47,7 @@
int
find_ne_resource(
- HFILE lzfd,struct ne_header_s *nehd,SEGPTR typeid,SEGPTR resid,
+ HFILE32 lzfd,struct ne_header_s *nehd,SEGPTR typeid,SEGPTR resid,
BYTE **resdata,int *reslen,DWORD *off
) {
NE_TYPEINFO ti;
@@ -57,7 +57,7 @@
DWORD nehdoffset;
nehdoffset = LZTELL(lzfd);
- LZSeek(lzfd,nehd->resource_tab_offset,SEEK_CUR);
+ LZSeek32(lzfd,nehd->resource_tab_offset,SEEK_CUR);
LZREAD(&shiftcount);
dprintf_ver(stddeb,"shiftcount is %d\n",shiftcount);
dprintf_ver(stddeb,"reading resource typeinfo dir.\n");
@@ -84,7 +84,7 @@
DWORD whereleft;
whereleft = LZTELL(lzfd);
- LZSeek(
+ LZSeek32(
lzfd,
nehdoffset+nehd->resource_tab_offset+ti.type_id,
SEEK_SET
@@ -99,11 +99,11 @@
if (lstrcmpi32A(str,(char*)PTR_SEG_TO_LIN(typeid)))
skipflag=1;
free(str);
- LZSeek(lzfd,whereleft,SEEK_SET);
+ LZSeek32(lzfd,whereleft,SEEK_SET);
}
}
if (skipflag) {
- LZSeek(lzfd,ti.count*sizeof(ni),SEEK_CUR);
+ LZSeek32(lzfd,ti.count*sizeof(ni),SEEK_CUR);
continue;
}
for (i=0;i<ti.count;i++) {
@@ -125,7 +125,7 @@
DWORD whereleft;
whereleft = LZTELL(lzfd);
- LZSeek(
+ LZSeek32(
lzfd,
nehdoffset+nehd->resource_tab_offset+ni.id,
SEEK_SET
@@ -140,12 +140,12 @@
if (!lstrcmpi32A(str,(char*)PTR_SEG_TO_LIN(typeid)))
skipflag=0;
free(str);
- LZSeek(lzfd,whereleft,SEEK_SET);
+ LZSeek32(lzfd,whereleft,SEEK_SET);
}
}
if (skipflag)
continue;
- LZSeek(lzfd,((int)ni.offset<<shiftcount),SEEK_SET);
+ LZSeek32(lzfd,((int)ni.offset<<shiftcount),SEEK_SET);
*off = (int)ni.offset<<shiftcount;
len = ni.length<<shiftcount;
rdata=(WORD*)xmalloc(len);
@@ -164,7 +164,7 @@
/* GetFileResourceSize [VER.2] */
DWORD
GetFileResourceSize(LPCSTR filename,SEGPTR restype,SEGPTR resid,LPDWORD off) {
- HFILE lzfd;
+ HFILE32 lzfd;
OFSTRUCT ofs;
BYTE *resdata;
int reslen;
@@ -173,19 +173,19 @@
dprintf_ver(stddeb,"GetFileResourceSize(%s,%lx,%lx,%p)\n",
filename,(LONG)restype,(LONG)resid,off
);
- lzfd=LZOpenFile16(filename,&ofs,OF_READ);
+ lzfd=LZOpenFile32A(filename,&ofs,OF_READ);
if (lzfd==0)
return 0;
if (!read_ne_header(lzfd,&nehd)) {
- LZClose(lzfd);
+ LZClose32(lzfd);
return 0;
}
if (!find_ne_resource(lzfd,&nehd,restype,resid,&resdata,&reslen,off)) {
- LZClose(lzfd);
+ LZClose32(lzfd);
return 0;
}
free(resdata);
- LZClose(lzfd);
+ LZClose32(lzfd);
return reslen;
}
@@ -194,7 +194,7 @@
GetFileResource(LPCSTR filename,SEGPTR restype,SEGPTR resid,
DWORD off,DWORD datalen,LPVOID data
) {
- HFILE lzfd;
+ HFILE32 lzfd;
OFSTRUCT ofs;
BYTE *resdata;
int reslen=datalen;
@@ -203,25 +203,25 @@
filename,(LONG)restype,(LONG)resid,off,datalen,data
);
- lzfd=LZOpenFile16(filename,&ofs,OF_READ);
+ lzfd=LZOpenFile32A(filename,&ofs,OF_READ);
if (lzfd==0)
return 0;
if (!off) {
if (!read_ne_header(lzfd,&nehd)) {
- LZClose(lzfd);
+ LZClose32(lzfd);
return 0;
}
if (!find_ne_resource(lzfd,&nehd,restype,resid,&resdata,&reslen,&off)) {
- LZClose(lzfd);
+ LZClose32(lzfd);
return 0;
}
free(resdata);
}
- LZSeek(lzfd,off,SEEK_SET);
+ LZSeek32(lzfd,off,SEEK_SET);
if (reslen>datalen)
reslen=datalen;
LZRead32(lzfd,data,reslen);
- LZClose(lzfd);
+ LZClose32(lzfd);
return reslen;
}
diff --git a/miscemu/Makefile.in b/miscemu/Makefile.in
index 3fd74e7..79950ea 100644
--- a/miscemu/Makefile.in
+++ b/miscemu/Makefile.in
@@ -6,24 +6,8 @@
MODULE = miscemu
C_SRCS = \
- cpu.c \
- dosmem.c \
- dpmi.c \
emulate.c \
- instr.c \
- int10.c \
- int13.c \
- int1a.c \
- int21.c \
- int25.c \
- int26.c \
- int2a.c \
- int2f.c \
- int4b.c \
- int5c.c \
- interrupts.c \
- ioports.c \
- vxd.c
+ instr.c
all: $(MODULE).o
diff --git a/miscemu/emulate.c b/miscemu/emulate.c
index 0fcdc7e..eee31e0 100644
--- a/miscemu/emulate.c
+++ b/miscemu/emulate.c
@@ -28,11 +28,11 @@
*/
/* FIXME: Only skeletal implementation for now */
-void WIN87_fpmath( SIGCONTEXT *context )
+void WIN87_fpmath( CONTEXT *context )
{
dprintf_int(stddeb, "_fpmath: (cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
- CS_reg(context), EIP_reg(context),
- ES_reg(context), BX_reg(context),
+ (WORD)CS_reg(context), EIP_reg(context),
+ (WORD)ES_reg(context), BX_reg(context),
AX_reg(context), DX_reg(context) );
switch(BX_reg(context))
diff --git a/miscemu/instr.c b/miscemu/instr.c
index e07fcb6..0d50be6 100644
--- a/miscemu/instr.c
+++ b/miscemu/instr.c
@@ -8,14 +8,15 @@
#include "windows.h"
#include "ldt.h"
#include "miscemu.h"
+#include "sigcontext.h"
-#define STACK_reg(context) \
- ((GET_SEL_FLAGS(SS_reg(context)) & LDT_FLAGS_32BIT) ? \
- ESP_reg(context) : SP_reg(context))
+#define STACK_sig(context) \
+ ((GET_SEL_FLAGS(SS_sig(context)) & LDT_FLAGS_32BIT) ? \
+ ESP_sig(context) : SP_sig(context))
#define STACK_PTR(context) \
- (PTR_SEG_OFF_TO_LIN(SS_reg(context),STACK_reg(context)))
+ (PTR_SEG_OFF_TO_LIN(SS_sig(context),STACK_sig(context)))
/***********************************************************************
* INSTR_ReplaceSelector
@@ -29,7 +30,7 @@
{
extern void SIGNAL_StartBIOSTimer(void);
fprintf( stderr, "Direct access to segment 0x40 (cs:ip=%04x:%04lx).\n",
- CS_reg(context), EIP_reg(context) );
+ CS_sig(context), EIP_sig(context) );
SIGNAL_StartBIOSTimer();
return DOSMEM_BiosSeg;
}
@@ -59,14 +60,14 @@
{
switch(rm)
{
- case 0: return (BYTE *)&EAX_reg(context);
- case 1: return (BYTE *)&ECX_reg(context);
- case 2: return (BYTE *)&EDX_reg(context);
- case 3: return (BYTE *)&EBX_reg(context);
- case 4: return (BYTE *)&ESP_reg(context);
- case 5: return (BYTE *)&EBP_reg(context);
- case 6: return (BYTE *)&ESI_reg(context);
- case 7: return (BYTE *)&EDI_reg(context);
+ case 0: return (BYTE *)&EAX_sig(context);
+ case 1: return (BYTE *)&ECX_sig(context);
+ case 2: return (BYTE *)&EDX_sig(context);
+ case 3: return (BYTE *)&EBX_sig(context);
+ case 4: return (BYTE *)&ESP_sig(context);
+ case 5: return (BYTE *)&EBP_sig(context);
+ case 6: return (BYTE *)&ESI_sig(context);
+ case 7: return (BYTE *)&EDI_sig(context);
}
}
@@ -80,27 +81,27 @@
ss = sib >> 6;
switch(sib >> 3)
{
- case 0: index = EAX_reg(context); break;
- case 1: index = ECX_reg(context); break;
- case 2: index = EDX_reg(context); break;
- case 3: index = EBX_reg(context); break;
+ case 0: index = EAX_sig(context); break;
+ case 1: index = ECX_sig(context); break;
+ case 2: index = EDX_sig(context); break;
+ case 3: index = EBX_sig(context); break;
case 4: index = 0; break;
- case 5: index = EBP_reg(context); break;
- case 6: index = ESI_reg(context); break;
- case 7: index = EDI_reg(context); break;
+ case 5: index = EBP_sig(context); break;
+ case 6: index = ESI_sig(context); break;
+ case 7: index = EDI_sig(context); break;
}
}
switch(rm)
{
- case 0: base = EAX_reg(context); seg = DS_reg(context); break;
- case 1: base = ECX_reg(context); seg = DS_reg(context); break;
- case 2: base = EDX_reg(context); seg = DS_reg(context); break;
- case 3: base = EBX_reg(context); seg = DS_reg(context); break;
- case 4: base = ESP_reg(context); seg = SS_reg(context); break;
- case 5: base = EBP_reg(context); seg = SS_reg(context); break;
- case 6: base = ESI_reg(context); seg = DS_reg(context); break;
- case 7: base = EDI_reg(context); seg = DS_reg(context); break;
+ case 0: base = EAX_sig(context); seg = DS_sig(context); break;
+ case 1: base = ECX_sig(context); seg = DS_sig(context); break;
+ case 2: base = EDX_sig(context); seg = DS_sig(context); break;
+ case 3: base = EBX_sig(context); seg = DS_sig(context); break;
+ case 4: base = ESP_sig(context); seg = SS_sig(context); break;
+ case 5: base = EBP_sig(context); seg = SS_sig(context); break;
+ case 6: base = ESI_sig(context); seg = DS_sig(context); break;
+ case 7: base = EDI_sig(context); seg = DS_sig(context); break;
}
switch (mod)
{
@@ -108,7 +109,7 @@
if (rm == 5) /* special case: ds:(disp32) */
{
GET_VAL( &base, DWORD );
- seg = DS_reg(context);
+ seg = DS_sig(context);
}
break;
@@ -128,36 +129,36 @@
switch(rm)
{
case 0: /* ds:(bx,si) */
- base = BX_reg(context) + SI_reg(context);
- seg = DS_reg(context);
+ base = BX_sig(context) + SI_sig(context);
+ seg = DS_sig(context);
break;
case 1: /* ds:(bx,di) */
- base = BX_reg(context) + DI_reg(context);
- seg = DS_reg(context);
+ base = BX_sig(context) + DI_sig(context);
+ seg = DS_sig(context);
break;
case 2: /* ss:(bp,si) */
- base = BP_reg(context) + SI_reg(context);
- seg = SS_reg(context);
+ base = BP_sig(context) + SI_sig(context);
+ seg = SS_sig(context);
break;
case 3: /* ss:(bp,di) */
- base = BP_reg(context) + DI_reg(context);
- seg = SS_reg(context);
+ base = BP_sig(context) + DI_sig(context);
+ seg = SS_sig(context);
break;
case 4: /* ds:(si) */
- base = SI_reg(context);
- seg = DS_reg(context);
+ base = SI_sig(context);
+ seg = DS_sig(context);
break;
case 5: /* ds:(di) */
- base = DI_reg(context);
- seg = DS_reg(context);
+ base = DI_sig(context);
+ seg = DS_sig(context);
break;
case 6: /* ss:(bp) */
- base = BP_reg(context);
- seg = SS_reg(context);
+ base = BP_sig(context);
+ seg = SS_sig(context);
break;
case 7: /* ds:(bx) */
- base = BX_reg(context);
- seg = DS_reg(context);
+ base = BX_sig(context);
+ seg = DS_sig(context);
break;
}
@@ -167,7 +168,7 @@
if (rm == 6) /* special case: ds:(disp16) */
{
GET_VAL( &base, WORD );
- seg = DS_reg(context);
+ seg = DS_sig(context);
}
break;
@@ -187,6 +188,7 @@
/* FIXME: should check limit of the segment here */
return (BYTE *)PTR_SEG_OFF_TO_LIN( seg, (base + (index << ss)) );
+#undef GET_VAL
}
@@ -214,36 +216,36 @@
switch((*regmodrm >> 3) & 7)
{
case 0:
- if (long_op) EAX_reg(context) = *(DWORD *)addr;
- else AX_reg(context) = *(WORD *)addr;
+ if (long_op) EAX_sig(context) = *(DWORD *)addr;
+ else AX_sig(context) = *(WORD *)addr;
break;
case 1:
- if (long_op) ECX_reg(context) = *(DWORD *)addr;
- else CX_reg(context) = *(WORD *)addr;
+ if (long_op) ECX_sig(context) = *(DWORD *)addr;
+ else CX_sig(context) = *(WORD *)addr;
break;
case 2:
- if (long_op) EDX_reg(context) = *(DWORD *)addr;
- else DX_reg(context) = *(WORD *)addr;
+ if (long_op) EDX_sig(context) = *(DWORD *)addr;
+ else DX_sig(context) = *(WORD *)addr;
break;
case 3:
- if (long_op) EBX_reg(context) = *(DWORD *)addr;
- else BX_reg(context) = *(WORD *)addr;
+ if (long_op) EBX_sig(context) = *(DWORD *)addr;
+ else BX_sig(context) = *(WORD *)addr;
break;
case 4:
- if (long_op) ESP_reg(context) = *(DWORD *)addr;
- else SP_reg(context) = *(WORD *)addr;
+ if (long_op) ESP_sig(context) = *(DWORD *)addr;
+ else SP_sig(context) = *(WORD *)addr;
break;
case 5:
- if (long_op) EBP_reg(context) = *(DWORD *)addr;
- else BP_reg(context) = *(WORD *)addr;
+ if (long_op) EBP_sig(context) = *(DWORD *)addr;
+ else BP_sig(context) = *(WORD *)addr;
break;
case 6:
- if (long_op) ESI_reg(context) = *(DWORD *)addr;
- else SI_reg(context) = *(WORD *)addr;
+ if (long_op) ESI_sig(context) = *(DWORD *)addr;
+ else SI_sig(context) = *(WORD *)addr;
break;
case 7:
- if (long_op) EDI_reg(context) = *(DWORD *)addr;
- else DI_reg(context) = *(WORD *)addr;
+ if (long_op) EDI_sig(context) = *(DWORD *)addr;
+ else DI_sig(context) = *(WORD *)addr;
break;
}
@@ -251,16 +253,16 @@
switch(*instr)
{
- case 0xc4: ES_reg(context) = seg; break; /* les */
- case 0xc5: DS_reg(context) = seg; break; /* lds */
+ case 0xc4: ES_sig(context) = seg; break; /* les */
+ case 0xc5: DS_sig(context) = seg; break; /* lds */
case 0x0f: switch(instr[1])
{
- case 0xb2: SS_reg(context) = seg; break; /* lss */
-#ifdef FS_reg
- case 0xb4: FS_reg(context) = seg; break; /* lfs */
+ case 0xb2: SS_sig(context) = seg; break; /* lss */
+#ifdef FS_sig
+ case 0xb4: FS_sig(context) = seg; break; /* lfs */
#endif
-#ifdef GS_reg
- case 0xb5: GS_reg(context) = seg; break; /* lgs */
+#ifdef GS_sig
+ case 0xb5: GS_sig(context) = seg; break; /* lgs */
#endif
}
break;
@@ -283,8 +285,8 @@
int prefix, segprefix, prefixlen, len, repX, long_op, long_addr;
BYTE *instr;
- long_op = long_addr = (GET_SEL_FLAGS(CS_reg(context)) & LDT_FLAGS_32BIT) != 0;
- instr = (BYTE *) PTR_SEG_OFF_TO_LIN( CS_reg(context), EIP_reg(context) );
+ long_op = long_addr = (GET_SEL_FLAGS(CS_sig(context)) & LDT_FLAGS_32BIT) != 0;
+ instr = (BYTE *) PTR_SEG_OFF_TO_LIN( CS_sig(context), EIP_sig(context) );
/* First handle any possible prefix */
@@ -297,25 +299,25 @@
switch(*instr)
{
case 0x2e:
- segprefix = CS_reg(context);
+ segprefix = CS_sig(context);
break;
case 0x36:
- segprefix = SS_reg(context);
+ segprefix = SS_sig(context);
break;
case 0x3e:
- segprefix = DS_reg(context);
+ segprefix = DS_sig(context);
break;
case 0x26:
- segprefix = ES_reg(context);
+ segprefix = ES_sig(context);
break;
-#ifdef FS_reg
+#ifdef FS_sig
case 0x64:
- segprefix = FS_reg(context);
+ segprefix = FS_sig(context);
break;
#endif
-#ifdef GS_reg
+#ifdef GS_sig
case 0x65:
- segprefix = GS_reg(context);
+ segprefix = GS_sig(context);
break;
#endif
case 0x66:
@@ -356,12 +358,12 @@
{
switch(*instr)
{
- case 0x07: ES_reg(context) = seg; break;
- case 0x17: SS_reg(context) = seg; break;
- case 0x1f: DS_reg(context) = seg; break;
+ case 0x07: ES_sig(context) = seg; break;
+ case 0x17: SS_sig(context) = seg; break;
+ case 0x1f: DS_sig(context) = seg; break;
}
- STACK_reg(context) += long_op ? 4 : 2;
- EIP_reg(context) += prefixlen + 1;
+ STACK_sig(context) += long_op ? 4 : 2;
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
}
}
@@ -370,47 +372,47 @@
case 0x0f: /* extended instruction */
switch(instr[1])
{
-#ifdef FS_reg
+#ifdef FS_sig
case 0xa1: /* pop fs */
{
WORD seg = *(WORD *)STACK_PTR( context );
if ((seg = INSTR_ReplaceSelector( context, seg )) != 0)
{
- FS_reg(context) = seg;
- STACK_reg(context) += long_op ? 4 : 2;
- EIP_reg(context) += prefixlen + 2;
+ FS_sig(context) = seg;
+ STACK_sig(context) += long_op ? 4 : 2;
+ EIP_sig(context) += prefixlen + 2;
return TRUE;
}
}
break;
-#endif /* FS_reg */
+#endif /* FS_sig */
-#ifdef GS_reg
+#ifdef GS_sig
case 0xa9: /* pop gs */
{
WORD seg = *(WORD *)STACK_PTR( context );
if ((seg = INSTR_ReplaceSelector( context, seg )) != 0)
{
- GS_reg(context) = seg;
- STACK_reg(context) += long_op ? 4 : 2;
- EIP_reg(context) += prefixlen + 2;
+ GS_sig(context) = seg;
+ STACK_sig(context) += long_op ? 4 : 2;
+ EIP_sig(context) += prefixlen + 2;
return TRUE;
}
}
break;
-#endif /* GS_reg */
+#endif /* GS_sig */
case 0xb2: /* lss addr,reg */
-#ifdef FS_reg
+#ifdef FS_sig
case 0xb4: /* lfs addr,reg */
#endif
-#ifdef GS_reg
+#ifdef GS_sig
case 0xb5: /* lgs addr,reg */
#endif
if (INSTR_EmulateLDS( context, instr, long_op,
long_addr, segprefix, &len ))
{
- EIP_reg(context) += prefixlen + len;
+ EIP_sig(context) += prefixlen + len;
return TRUE;
}
break;
@@ -425,10 +427,10 @@
int typ = *instr; /* Just in case it's overwritten. */
int outp = (typ >= 0x6e);
unsigned long count = repX ?
- (long_addr ? ECX_reg(context) : CX_reg(context)) : 1;
+ (long_addr ? ECX_sig(context) : CX_sig(context)) : 1;
int opsize = (typ & 1) ? (long_op ? 4 : 2) : 1;
- int step = (EFL_reg(context) & 0x400) ? -opsize : +opsize;
- int seg = outp ? DS_reg(context) : ES_reg(context); /* FIXME: is this right? */
+ int step = (EFL_sig(context) & 0x400) ? -opsize : +opsize;
+ int seg = outp ? DS_sig(context) : ES_sig(context); /* FIXME: is this right? */
if (outp)
/* FIXME: Check segment readable. */
@@ -439,9 +441,9 @@
if (repX)
if (long_addr)
- ECX_reg(context) = 0;
+ ECX_sig(context) = 0;
else
- CX_reg(context) = 0;
+ CX_sig(context) = 0;
while (count-- > 0)
{
@@ -449,41 +451,41 @@
if (outp)
{
data = PTR_SEG_OFF_TO_LIN (seg,
- long_addr ? ESI_reg(context) : SI_reg(context));
- if (long_addr) ESI_reg(context) += step;
- else SI_reg(context) += step;
+ long_addr ? ESI_sig(context) : SI_sig(context));
+ if (long_addr) ESI_sig(context) += step;
+ else SI_sig(context) += step;
}
else
{
data = PTR_SEG_OFF_TO_LIN (seg,
- long_addr ? EDI_reg(context) : DI_reg(context));
- if (long_addr) EDI_reg(context) += step;
- else DI_reg(context) += step;
+ long_addr ? EDI_sig(context) : DI_sig(context));
+ if (long_addr) EDI_sig(context) += step;
+ else DI_sig(context) += step;
}
switch (typ)
{
case 0x6c:
- *((BYTE *)data) = inport( DX_reg(context), 1);
+ *((BYTE *)data) = IO_inport( DX_sig(context), 1);
break;
case 0x6d:
if (long_op)
- *((DWORD *)data) = inport( DX_reg(context), 4);
+ *((DWORD *)data) = IO_inport( DX_sig(context), 4);
else
- *((WORD *)data) = inport( DX_reg(context), 2);
+ *((WORD *)data) = IO_inport( DX_sig(context), 2);
break;
case 0x6e:
- outport( DX_reg(context), 1, *((BYTE *)data));
- break;
+ IO_outport( DX_sig(context), 1, *((BYTE *)data));
+ break;
case 0x6f:
- if (long_op)
- outport( DX_reg(context), 4, *((DWORD *)data));
- else
- outport( DX_reg(context), 2, *((WORD *)data));
- break;
+ if (long_op)
+ IO_outport( DX_sig(context), 4, *((DWORD *)data));
+ else
+ IO_outport( DX_sig(context), 2, *((WORD *)data));
+ break;
}
}
- EIP_reg(context) += prefixlen + 1;
+ EIP_sig(context) += prefixlen + 1;
}
return TRUE;
@@ -501,29 +503,29 @@
switch((instr[1] >> 3) & 7)
{
case 0:
- ES_reg(context) = seg;
- EIP_reg(context) += prefixlen + len + 1;
+ ES_sig(context) = seg;
+ EIP_sig(context) += prefixlen + len + 1;
return TRUE;
case 1: /* cs */
break;
case 2:
- SS_reg(context) = seg;
- EIP_reg(context) += prefixlen + len + 1;
+ SS_sig(context) = seg;
+ EIP_sig(context) += prefixlen + len + 1;
return TRUE;
case 3:
- DS_reg(context) = seg;
- EIP_reg(context) += prefixlen + len + 1;
+ DS_sig(context) = seg;
+ EIP_sig(context) += prefixlen + len + 1;
return TRUE;
case 4:
-#ifdef FS_reg
- FS_reg(context) = seg;
- EIP_reg(context) += prefixlen + len + 1;
+#ifdef FS_sig
+ FS_sig(context) = seg;
+ EIP_sig(context) += prefixlen + len + 1;
return TRUE;
#endif
case 5:
-#ifdef GS_reg
- GS_reg(context) = seg;
- EIP_reg(context) += prefixlen + len + 1;
+#ifdef GS_sig
+ GS_sig(context) = seg;
+ EIP_sig(context) += prefixlen + len + 1;
return TRUE;
#endif
case 6: /* unused */
@@ -538,7 +540,7 @@
if (INSTR_EmulateLDS( context, instr, long_op,
long_addr, segprefix, &len ))
{
- EIP_reg(context) += prefixlen + len;
+ EIP_sig(context) += prefixlen + len;
return TRUE;
}
break; /* Unable to emulate it */
@@ -554,13 +556,13 @@
FARPROC16 addr = INT_GetHandler( instr[1] );
WORD *stack = (WORD *)STACK_PTR( context );
/* Push the flags and return address on the stack */
- *(--stack) = FL_reg(context);
- *(--stack) = CS_reg(context);
- *(--stack) = IP_reg(context) + prefixlen + 2;
- STACK_reg(context) -= 3 * sizeof(WORD);
+ *(--stack) = FL_sig(context);
+ *(--stack) = CS_sig(context);
+ *(--stack) = IP_sig(context) + prefixlen + 2;
+ STACK_sig(context) -= 3 * sizeof(WORD);
/* Jump to the interrupt handler */
- CS_reg(context) = HIWORD(addr);
- EIP_reg(context) = LOWORD(addr);
+ CS_sig(context) = HIWORD(addr);
+ EIP_sig(context) = LOWORD(addr);
}
return TRUE;
@@ -568,71 +570,71 @@
if (long_op)
{
DWORD *stack = (DWORD *)STACK_PTR( context );
- EIP_reg(context) = *stack++;
- CS_reg(context) = *stack++;
- EFL_reg(context) = *stack;
- STACK_reg(context) += 3*sizeof(DWORD); /* Pop the return address and flags */
+ EIP_sig(context) = *stack++;
+ CS_sig(context) = *stack++;
+ EFL_sig(context) = *stack;
+ STACK_sig(context) += 3*sizeof(DWORD); /* Pop the return address and flags */
}
else
{
WORD *stack = (WORD *)STACK_PTR( context );
- EIP_reg(context) = *stack++;
- CS_reg(context) = *stack++;
- FL_reg(context) = *stack;
- STACK_reg(context) += 3*sizeof(WORD); /* Pop the return address and flags */
+ EIP_sig(context) = *stack++;
+ CS_sig(context) = *stack++;
+ FL_sig(context) = *stack;
+ STACK_sig(context) += 3*sizeof(WORD); /* Pop the return address and flags */
}
return TRUE;
case 0xe4: /* inb al,XX */
- AL_reg(context) = inport( instr[1], 1 );
- EIP_reg(context) += prefixlen + 2;
+ AL_sig(context) = IO_inport( instr[1], 1 );
+ EIP_sig(context) += prefixlen + 2;
return TRUE;
case 0xe5: /* in (e)ax,XX */
- if (long_op) EAX_reg(context) = inport( instr[1], 4 );
- else AX_reg(context) = inport( instr[1], 2 );
- EIP_reg(context) += prefixlen + 2;
+ if (long_op) EAX_sig(context) = IO_inport( instr[1], 4 );
+ else AX_sig(context) = IO_inport( instr[1], 2 );
+ EIP_sig(context) += prefixlen + 2;
return TRUE;
case 0xe6: /* outb XX,al */
- outport( instr[1], 1, AL_reg(context) );
- EIP_reg(context) += prefixlen + 2;
+ IO_outport( instr[1], 1, AL_sig(context) );
+ EIP_sig(context) += prefixlen + 2;
return TRUE;
case 0xe7: /* out XX,(e)ax */
- if (long_op) outport( instr[1], 4, EAX_reg(context) );
- else outport( instr[1], 2, AX_reg(context) );
- EIP_reg(context) += prefixlen + 2;
+ if (long_op) IO_outport( instr[1], 4, EAX_sig(context) );
+ else IO_outport( instr[1], 2, AX_sig(context) );
+ EIP_sig(context) += prefixlen + 2;
return TRUE;
case 0xec: /* inb al,dx */
- AL_reg(context) = inport( DX_reg(context), 1 );
- EIP_reg(context) += prefixlen + 1;
+ AL_sig(context) = IO_inport( DX_sig(context), 1 );
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
case 0xed: /* in (e)ax,dx */
- if (long_op) EAX_reg(context) = inport( DX_reg(context), 4 );
- else AX_reg(context) = inport( DX_reg(context), 2 );
- EIP_reg(context) += prefixlen + 1;
+ if (long_op) EAX_sig(context) = IO_inport( DX_sig(context), 4 );
+ else AX_sig(context) = IO_inport( DX_sig(context), 2 );
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
case 0xee: /* outb dx,al */
- outport( DX_reg(context), 1, AL_reg(context) );
- EIP_reg(context) += prefixlen + 1;
+ IO_outport( DX_sig(context), 1, AL_sig(context) );
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
case 0xef: /* out dx,(e)ax */
- if (long_op) outport( DX_reg(context), 4, EAX_reg(context) );
- else outport( DX_reg(context), 2, AX_reg(context) );
- EIP_reg(context) += prefixlen + 1;
+ if (long_op) IO_outport( DX_sig(context), 4, EAX_sig(context) );
+ else IO_outport( DX_sig(context), 2, AX_sig(context) );
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
case 0xfa: /* cli, ignored */
- EIP_reg(context) += prefixlen + 1;
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
case 0xfb: /* sti, ignored */
- EIP_reg(context) += prefixlen + 1;
+ EIP_sig(context) += prefixlen + 1;
return TRUE;
}
fprintf(stderr, "Unexpected Windows program segfault"
diff --git a/miscemu/int4b.c b/miscemu/int4b.c
deleted file mode 100644
index ecf07fa..0000000
--- a/miscemu/int4b.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Int 4B handling
- *
- */
-
-#include "miscemu.h"
-
-/***********************************************************************
- * INT_Int4bHandler
- *
- */
-void INT_Int4bHandler( SIGCONTEXT *context )
-{
-
- switch(AH_reg(context))
- {
- case 0x81: /* Virtual DMA Spec (IBM SCSI interface) */
- if(AL_reg(context) != 0x02) /* if not install check */
- {
- SET_CFLAG(context);
- AL_reg(context) = 0x0f; /* function is not implemented */
- }
- break;
- default:
- INT_BARF(context, 0x4b);
- }
-}
-
diff --git a/miscemu/int5c.c b/miscemu/int5c.c
deleted file mode 100644
index 575d2e9..0000000
--- a/miscemu/int5c.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * NetBIOS interrupt handling
- *
- * Copyright 1995 Alexandre Julliard, Alex Korobka
- */
-
-#include "ldt.h"
-#include "miscemu.h"
-#include "stddebug.h"
-#include "debug.h"
-
-
-/***********************************************************************
- * NetBIOSCall (KERNEL.103)
- *
- * Also handler for interrupt 5c.
- */
-void NetBIOSCall( SIGCONTEXT *context )
-{
- BYTE* ptr;
-
- ptr = (BYTE*) PTR_SEG_OFF_TO_LIN(ES_reg(context),BX_reg(context));
-
- fprintf(stdnimp,"NetBIOSCall: command code %02x (ignored)\n",*ptr);
-
- AL_reg(context) = *(ptr+0x01) = 0xFB; /* NetBIOS emulator not found */
-}
-
diff --git a/miscemu/interrupts.c b/miscemu/interrupts.c
deleted file mode 100644
index 6fa7cb7..0000000
--- a/miscemu/interrupts.c
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Interrupt vectors emulation
- *
- * Copyright 1995 Alexandre Julliard
- */
-
-#include <sys/types.h>
-
-#include "windows.h"
-#include "drive.h"
-#include "miscemu.h"
-#include "msdos.h"
-#include "module.h"
-#include "stackframe.h"
-#include "stddebug.h"
-#include "debug.h"
-
-static FARPROC16 INT_Vectors[256];
-
- /* Ordinal number for interrupt 0 handler in WPROCS.DLL */
-#define FIRST_INTERRUPT_ORDINAL 100
-
-
-/**********************************************************************
- * INT_Init
- */
-BOOL32 INT_Init(void)
-{
- WORD vector;
- HMODULE16 hModule = GetModuleHandle( "WPROCS" );
-
- for (vector = 0; vector < 256; vector++)
- {
- if (!(INT_Vectors[vector] = MODULE_GetEntryPoint( hModule,
- FIRST_INTERRUPT_ORDINAL+vector )))
- {
- fprintf(stderr,"Internal error: no vector for int %02x\n",vector);
- return FALSE;
- }
- }
- return TRUE;
-}
-
-
-/**********************************************************************
- * INT_GetHandler
- *
- * Return the interrupt vector for a given interrupt.
- */
-FARPROC16 INT_GetHandler( BYTE intnum )
-{
- return INT_Vectors[intnum];
-}
-
-
-/**********************************************************************
- * INT_SetHandler
- *
- * Set the interrupt handler for a given interrupt.
- */
-void INT_SetHandler( BYTE intnum, FARPROC16 handler )
-{
- dprintf_int( stddeb, "Set interrupt vector %02x <- %04x:%04x\n",
- intnum, HIWORD(handler), LOWORD(handler) );
- INT_Vectors[intnum] = handler;
-}
-
-
-/**********************************************************************
- * INT_DummyHandler
- */
-void INT_DummyHandler( SIGCONTEXT *context )
-{
- WORD ordinal;
- STACK16FRAME *frame = CURRENT_STACK16;
- BUILTIN_GetEntryPoint16( frame->entry_cs, frame->entry_ip, &ordinal );
- INT_BARF( context, ordinal - FIRST_INTERRUPT_ORDINAL );
-}
-
-
-/**********************************************************************
- * INT_Int11Handler
- *
- * Handler for int 11h (get equipment list).
- */
-void INT_Int11Handler( SIGCONTEXT *context )
-{
- int diskdrives = 0;
- int parallelports = 0;
- int serialports = 0;
- int x;
-
-/* borrowed from Ralph Brown's interrupt lists
-
- bits 15-14: number of parallel devices
- bit 13: [Conv] Internal modem
- bit 12: reserved
- bits 11- 9: number of serial devices
- bit 8: reserved
- bits 7- 6: number of diskette drives minus one
- bits 5- 4: Initial video mode:
- 00b = EGA,VGA,PGA
- 01b = 40 x 25 color
- 10b = 80 x 25 color
- 11b = 80 x 25 mono
- bit 3: reserved
- bit 2: [PS] =1 if pointing device
- [non-PS] reserved
- bit 1: =1 if math co-processor
- bit 0: =1 if diskette available for boot
-*/
-/* Currently the only of these bits correctly set are:
- bits 15-14 } Added by William Owen Smith,
- bits 11-9 } wos@dcs.warwick.ac.uk
- bits 7-6
- bit 2 (always set)
-*/
-
- if (DRIVE_IsValid(0)) diskdrives++;
- if (DRIVE_IsValid(1)) diskdrives++;
- if (diskdrives) diskdrives--;
-
- for (x=0; x!=MAX_PORTS; x++)
- {
- if (COM[x].devicename)
- serialports++;
- if (LPT[x].devicename)
- parallelports++;
- }
- if (serialports > 7) /* 3 bits -- maximum value = 7 */
- serialports=7;
- if (parallelports > 3) /* 2 bits -- maximum value = 3 */
- parallelports=3;
-
- AX_reg(context) = (diskdrives << 6) | (serialports << 9) |
- (parallelports << 14) | 0x02;
-}
-
-
-/**********************************************************************
- * INT_Int12Handler
- *
- * Handler for int 12h (get memory size).
- */
-void INT_Int12Handler( SIGCONTEXT *context )
-{
- AX_reg(context) = 640;
-}
-
-
-/**********************************************************************
- * INT_Int15Handler
- *
- * Handler for int 15h.
- */
-void INT_Int15Handler( SIGCONTEXT *context )
-{
- INT_BARF( context, 0x15 );
-}
-
-
-/**********************************************************************
- * INT_Int16Handler
- *
- * Handler for int 16h (keyboard).
- */
-void INT_Int16Handler( SIGCONTEXT *context )
-{
- INT_BARF( context, 0x16 );
-}
diff --git a/msdos/Makefile.in b/msdos/Makefile.in
new file mode 100644
index 0000000..1c7682b
--- /dev/null
+++ b/msdos/Makefile.in
@@ -0,0 +1,31 @@
+DEFS = -D__WINE__ -DNO_TRANSITION_TYPES
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = msdos
+
+C_SRCS = \
+ dosmem.c \
+ dpmi.c \
+ int10.c \
+ int11.c \
+ int12.c \
+ int13.c \
+ int1a.c \
+ int21.c \
+ int25.c \
+ int26.c \
+ int2a.c \
+ int2f.c \
+ int4b.c \
+ int5c.c \
+ interrupts.c \
+ ioports.c \
+ vxd.c
+
+all: $(MODULE).o
+
+@MAKE_RULES@
+
+### Dependencies:
diff --git a/miscemu/dosmem.c b/msdos/dosmem.c
similarity index 80%
rename from miscemu/dosmem.c
rename to msdos/dosmem.c
index 8b454e7..55078af 100644
--- a/miscemu/dosmem.c
+++ b/msdos/dosmem.c
@@ -86,15 +86,36 @@
/***********************************************************************
+ * DOSMEM_InitCollateTable
+ *
+ * Initialises the collate table (character sorting, language dependend)
+ */
+DWORD DOSMEM_CollateTable;
+
+static void DOSMEM_InitCollateTable()
+{
+ DWORD x;
+ unsigned char *tbl;
+ int i;
+
+ x=GlobalDOSAlloc(258);
+ DOSMEM_CollateTable=MAKELONG(0,(x>>16));
+ tbl=DOSMEM_RealMode2Linear(DOSMEM_CollateTable);
+ *(WORD*)tbl = 0x100;
+ tbl+=2;
+ for (i=0;i<0x100;i++)
+ *tbl++=i;
+}
+
+
+/***********************************************************************
* DOSMEM_Init
*
* Create the dos memory segments, and store them into the KERNEL
- * exported values. BUILTIN_Init() must already have been called.
+ * exported values.
*/
BOOL32 DOSMEM_Init(void)
{
- HMODULE16 hModule = GetModuleHandle( "KERNEL" );
-
/* Allocate 1 MB dosmemory */
/* Yes, allocating 1 MB of memory, which is usually not even used, is a
* waste of memory. But I (MM) don't see any easy method to use
@@ -112,44 +133,11 @@
fprintf( stderr, "Could not allocate DOS memory.\n" );
return FALSE;
}
-
- MODULE_SetEntryPoint( hModule, 183, /* KERNEL.183: __0000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
DOSMEM_BiosSeg = GLOBAL_CreateBlock(GMEM_FIXED,DOSMEM_dosmem+0x400,0x100,
- hModule, FALSE, FALSE, FALSE, NULL );
-
- MODULE_SetEntryPoint( hModule, 193, /* KERNEL.193: __0040H */
- DOSMEM_BiosSeg );
- MODULE_SetEntryPoint( hModule, 174, /* KERNEL.174: __A000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xA0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 181, /* KERNEL.181: __B000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xB0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 182, /* KERNEL.182: __B800H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xB8000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 195, /* KERNEL.195: __C000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xC0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 179, /* KERNEL.179: __D000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xD0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 190, /* KERNEL.190: __E000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xE0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 173, /* KERNEL.173: __ROMBIOS */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xF0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
- MODULE_SetEntryPoint( hModule, 194, /* KERNEL.194: __F000H */
- GLOBAL_CreateBlock( GMEM_FIXED, DOSMEM_dosmem+0xF0000,
- 0x10000, hModule, FALSE, FALSE, FALSE, NULL ));
+ 0, FALSE, FALSE, FALSE, NULL );
DOSMEM_FillBiosSegment();
-
DOSMEM_InitMemoryHandling();
DOSMEM_InitCollateTable();
-
return TRUE;
}
@@ -216,29 +204,6 @@
}
/***********************************************************************
- * DOSMEM_InitCollateTable
- *
- * Initialises the collate table (character sorting, language dependend)
- */
-DWORD DOSMEM_CollateTable;
-
-void
-DOSMEM_InitCollateTable()
-{
- DWORD x;
- unsigned char *tbl;
- int i;
-
- x=GlobalDOSAlloc(258);
- DOSMEM_CollateTable=MAKELONG(0,(x>>16));
- tbl=DOSMEM_RealMode2Linear(DOSMEM_CollateTable);
- *(WORD*)tbl = 0x100;
- tbl+=2;
- for (i=0;i<0x100;i++)
- *tbl++=i;
-}
-
-/***********************************************************************
* GlobalDOSAlloc (KERNEL.184)
*
* Allocates a piece of DOS Memory, in the first 1 MB physical memory.
@@ -340,7 +305,7 @@
}
/***********************************************************************
- * DOSMEM_RealMode2Linear
+ * DOSMEM_AllocSelector
*
* Allocates a protected mode selector for a realmode segment.
*/
diff --git a/miscemu/dpmi.c b/msdos/dpmi.c
similarity index 98%
rename from miscemu/dpmi.c
rename to msdos/dpmi.c
index 1f8daa4..092d500 100644
--- a/miscemu/dpmi.c
+++ b/msdos/dpmi.c
@@ -43,14 +43,14 @@
WORD ss;
} REALMODECALL;
-extern void do_mscdex( SIGCONTEXT *context );
+extern void do_mscdex( CONTEXT *context );
/**********************************************************************
* INT_Int31Handler
*
* Handler for int 31h (DPMI).
*/
-void INT_Int31Handler( SIGCONTEXT *context )
+void INT_Int31Handler( CONTEXT *context )
{
DWORD dw;
BYTE *ptr;
@@ -78,12 +78,8 @@
/* set it to zero. */
if (!((DS_reg(context)^BX_reg(context)) & ~3)) DS_reg(context) = 0;
if (!((ES_reg(context)^BX_reg(context)) & ~3)) ES_reg(context) = 0;
-#ifdef FS_reg
if (!((FS_reg(context)^BX_reg(context)) & ~3)) FS_reg(context) = 0;
-#endif
-#ifdef GS_reg
if (!((GS_reg(context)^BX_reg(context)) & ~3)) GS_reg(context) = 0;
-#endif
}
break;
@@ -235,7 +231,6 @@
case 0x65:
switch (p->eax & 0xFF) {
case 06:{/* get collate table */
- extern DWORD DOSMEM_CollateTable;
char *table;
/* ES:DI is a REALMODE pointer to 5 byte dosmem
* we fill that with 0x6, realmode pointer to collateTB
@@ -353,8 +348,7 @@
" Function to call: %04x:%04x\n",
p->eax, p->ebx, p->ecx, p->edx,
p->esi, p->edi, p->es, p->ds, p->cs, p->ip,
- DS_reg(context),SI_reg(context)
- );
+ (WORD)DS_reg(context), SI_reg(context) );
SET_CFLAG(context);
}
break;
diff --git a/miscemu/int10.c b/msdos/int10.c
similarity index 88%
rename from miscemu/int10.c
rename to msdos/int10.c
index f9f7cf2..bb99f8e 100644
--- a/miscemu/int10.c
+++ b/msdos/int10.c
@@ -1,3 +1,7 @@
+/*
+ * BIOS interrupt 10h handler
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include "miscemu.h"
@@ -11,7 +15,7 @@
*
* Handler for int 10h (video).
*/
-void INT_Int10Handler( SIGCONTEXT *context )
+void INT_Int10Handler( CONTEXT *context )
{
switch(AH_reg(context))
{
diff --git a/msdos/int11.c b/msdos/int11.c
new file mode 100644
index 0000000..88b3041
--- /dev/null
+++ b/msdos/int11.c
@@ -0,0 +1,69 @@
+/*
+ * BIOS interrupt 11h handler
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "miscemu.h"
+#include "msdos.h"
+#include "drive.h"
+#include "stddebug.h"
+#include "debug.h"
+
+/**********************************************************************
+ * INT_Int11Handler
+ *
+ * Handler for int 11h (get equipment list).
+ */
+void INT_Int11Handler( CONTEXT *context )
+{
+ int diskdrives = 0;
+ int parallelports = 0;
+ int serialports = 0;
+ int x;
+
+/* borrowed from Ralph Brown's interrupt lists
+
+ bits 15-14: number of parallel devices
+ bit 13: [Conv] Internal modem
+ bit 12: reserved
+ bits 11- 9: number of serial devices
+ bit 8: reserved
+ bits 7- 6: number of diskette drives minus one
+ bits 5- 4: Initial video mode:
+ 00b = EGA,VGA,PGA
+ 01b = 40 x 25 color
+ 10b = 80 x 25 color
+ 11b = 80 x 25 mono
+ bit 3: reserved
+ bit 2: [PS] =1 if pointing device
+ [non-PS] reserved
+ bit 1: =1 if math co-processor
+ bit 0: =1 if diskette available for boot
+*/
+/* Currently the only of these bits correctly set are:
+ bits 15-14 } Added by William Owen Smith,
+ bits 11-9 } wos@dcs.warwick.ac.uk
+ bits 7-6
+ bit 2 (always set)
+*/
+
+ if (DRIVE_IsValid(0)) diskdrives++;
+ if (DRIVE_IsValid(1)) diskdrives++;
+ if (diskdrives) diskdrives--;
+
+ for (x=0; x!=MAX_PORTS; x++)
+ {
+ if (COM[x].devicename)
+ serialports++;
+ if (LPT[x].devicename)
+ parallelports++;
+ }
+ if (serialports > 7) /* 3 bits -- maximum value = 7 */
+ serialports=7;
+ if (parallelports > 3) /* 2 bits -- maximum value = 3 */
+ parallelports=3;
+
+ AX_reg(context) = (diskdrives << 6) | (serialports << 9) |
+ (parallelports << 14) | 0x02;
+}
diff --git a/msdos/int12.c b/msdos/int12.c
new file mode 100644
index 0000000..cff7f52
--- /dev/null
+++ b/msdos/int12.c
@@ -0,0 +1,15 @@
+/*
+ * BIOS interrupt 12h handler
+ */
+
+#include "miscemu.h"
+
+/**********************************************************************
+ * INT_Int12Handler
+ *
+ * Handler for int 12h (get memory size).
+ */
+void INT_Int12Handler( CONTEXT *context )
+{
+ AX_reg(context) = 640;
+}
diff --git a/miscemu/int13.c b/msdos/int13.c
similarity index 95%
rename from miscemu/int13.c
rename to msdos/int13.c
index 3fda6f2..9213897 100644
--- a/miscemu/int13.c
+++ b/msdos/int13.c
@@ -1,3 +1,7 @@
+/*
+ * BIOS interrupt 13h handler
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include "miscemu.h"
@@ -11,7 +15,7 @@
*
* Handler for int 13h (disk I/O).
*/
-void INT_Int13Handler( SIGCONTEXT *context )
+void INT_Int13Handler( CONTEXT *context )
{
switch(AH_reg(context))
{
diff --git a/miscemu/int1a.c b/msdos/int1a.c
similarity index 96%
rename from miscemu/int1a.c
rename to msdos/int1a.c
index 5017010..ddc52ef 100644
--- a/miscemu/int1a.c
+++ b/msdos/int1a.c
@@ -1,3 +1,7 @@
+/*
+ * BIOS interrupt 1ah handler
+ */
+
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
@@ -40,7 +44,7 @@
*
* Handler for int 1ah (date and time).
*/
-void INT_Int1aHandler( SIGCONTEXT *context )
+void INT_Int1aHandler( CONTEXT *context )
{
time_t ltime;
DWORD ticks;
diff --git a/miscemu/int21.c b/msdos/int21.c
similarity index 86%
rename from miscemu/int21.c
rename to msdos/int21.c
index d2a5fb5..609b908 100644
--- a/miscemu/int21.c
+++ b/msdos/int21.c
@@ -1,5 +1,5 @@
/*
- * (c) 1993, 1994 Erik Bos
+ * DOS interrupt 21h handler
*/
#include <time.h>
@@ -65,7 +65,6 @@
};
WORD CodePage = 437;
-struct DPB *dpb;
DWORD dpbsegptr;
struct DosHeap {
@@ -82,6 +81,20 @@
extern char TempDirectory[];
+static BOOL32 INT21_CreateHeap(void)
+{
+ if (!(DosHeapHandle = GlobalAlloc16(GMEM_FIXED,sizeof(struct DosHeap))))
+ {
+ fprintf( stderr, "INT21_Init: Out of memory\n");
+ return FALSE;
+ }
+ heap = (struct DosHeap *) GlobalLock16(DosHeapHandle);
+ dpbsegptr = PTR_SEG_OFF_TO_SEGPTR(DosHeapHandle,(int)&heap->dpb-(int)heap);
+ heap->InDosFlag = 0;
+ strcpy(heap->biosdate, "01/01/80");
+ return TRUE;
+}
+
BYTE *GetCurrentDTA(void)
{
TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
@@ -133,7 +146,7 @@
}
}
-static int INT21_GetFreeDiskSpace( SIGCONTEXT *context )
+static int INT21_GetFreeDiskSpace( CONTEXT *context )
{
DWORD cluster_sectors, sector_bytes, free_clusters, total_clusters;
char root[] = "A:\\";
@@ -148,23 +161,24 @@
return 1;
}
-static int INT21_GetDriveAllocInfo( SIGCONTEXT *context )
+static int INT21_GetDriveAllocInfo( CONTEXT *context )
{
if (!INT21_GetFreeDiskSpace( context )) return 0;
+ if (!heap && !INT21_CreateHeap()) return 0;
heap->mediaID = 0xf0;
DS_reg(context) = DosHeapHandle;
BX_reg(context) = (int)&heap->mediaID - (int)heap;
return 1;
}
-static void GetDrivePB( SIGCONTEXT *context, int drive )
+static void GetDrivePB( CONTEXT *context, int drive )
{
if(!DRIVE_IsValid(drive))
{
DOS_ERROR( ER_InvalidDrive, EC_MediaError, SA_Abort, EL_Disk );
AX_reg(context) = 0x00ff;
}
- else
+ else if (heap || INT21_CreateHeap())
{
dprintf_int(stddeb, "int21: GetDrivePB not fully implemented.\n");
@@ -175,23 +189,23 @@
* does worry me, though. Should we have a complete table of
* separate DPBs per drive? Probably, but I'm lazy. :-) -CH
*/
- dpb->drive_num = dpb->unit_num = drive; /* The same? */
- dpb->sector_size = 512;
- dpb->high_sector = 1;
- dpb->shift = drive < 2 ? 0 : 6; /* 6 for HD, 0 for floppy */
- dpb->reserved = 0;
- dpb->num_FAT = 1;
- dpb->dir_entries = 2;
- dpb->first_data = 2;
- dpb->high_cluster = 64000;
- dpb->sectors_in_FAT = 1;
- dpb->start_dir = 1;
- dpb->driver_head = 0;
- dpb->media_ID = (drive > 1) ? 0xF8 : 0xF0;
- dpb->access_flag = 0;
- dpb->next = 0;
- dpb->free_search = 0;
- dpb->free_clusters = 0xFFFF; /* unknown */
+ heap->dpb.drive_num = heap->dpb.unit_num = drive; /*The same?*/
+ heap->dpb.sector_size = 512;
+ heap->dpb.high_sector = 1;
+ heap->dpb.shift = drive < 2 ? 0 : 6; /*6 for HD, 0 for floppy*/
+ heap->dpb.reserved = 0;
+ heap->dpb.num_FAT = 1;
+ heap->dpb.dir_entries = 2;
+ heap->dpb.first_data = 2;
+ heap->dpb.high_cluster = 64000;
+ heap->dpb.sectors_in_FAT = 1;
+ heap->dpb.start_dir = 1;
+ heap->dpb.driver_head = 0;
+ heap->dpb.media_ID = (drive > 1) ? 0xF8 : 0xF0;
+ heap->dpb.access_flag = 0;
+ heap->dpb.next = 0;
+ heap->dpb.free_search = 0;
+ heap->dpb.free_clusters = 0xFFFF; /* unknown */
AL_reg(context) = 0x00;
DS_reg(context) = SELECTOROF(dpbsegptr);
@@ -200,7 +214,7 @@
}
-static void ioctlGetDeviceInfo( SIGCONTEXT *context )
+static void ioctlGetDeviceInfo( CONTEXT *context )
{
dprintf_int (stddeb, "int21: ioctl (%d, GetDeviceInfo)\n", BX_reg(context));
@@ -213,7 +227,7 @@
RESET_CFLAG(context);
}
-static void ioctlGenericBlkDevReq( SIGCONTEXT *context )
+static void ioctlGenericBlkDevReq( CONTEXT *context )
{
BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
int drive = DOS_GET_DRIVE( BL_reg(context) );
@@ -277,7 +291,7 @@
}
}
-static void GetSystemDate( SIGCONTEXT *context )
+static void GetSystemDate( CONTEXT *context )
{
struct tm *now;
time_t ltime;
@@ -290,7 +304,7 @@
AX_reg(context) = now->tm_wday;
}
-static void INT21_GetSystemTime( SIGCONTEXT *context )
+static void INT21_GetSystemTime( CONTEXT *context )
{
struct tm *now;
struct timeval tv;
@@ -305,11 +319,11 @@
/* Note hundredths of seconds */
}
-static void INT21_CreateFile( SIGCONTEXT *context )
+static void INT21_CreateFile( CONTEXT *context )
{
- AX_reg(context) = _lcreat( PTR_SEG_OFF_TO_LIN( DS_reg(context),
+ AX_reg(context) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
DX_reg(context) ), CX_reg(context) );
- if (AX_reg(context) == (WORD)HFILE_ERROR)
+ if (AX_reg(context) == (WORD)HFILE_ERROR16)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -317,11 +331,11 @@
}
-void OpenExistingFile( SIGCONTEXT *context )
+void OpenExistingFile( CONTEXT *context )
{
- AX_reg(context) = _lopen( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
+ AX_reg(context) = _lopen16( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
AL_reg(context) );
- if (AX_reg(context) == (WORD)HFILE_ERROR)
+ if (AX_reg(context) == (WORD)HFILE_ERROR16)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -398,16 +412,16 @@
#endif
}
-static void CloseFile( SIGCONTEXT *context )
+static void CloseFile( CONTEXT *context )
{
- if ((AX_reg(context) = _lclose( BX_reg(context) )) != 0)
+ if ((AX_reg(context) = _lclose16( BX_reg(context) )) != 0)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
}
}
-void ExtendedOpenCreateFile(SIGCONTEXT *context )
+void ExtendedOpenCreateFile(CONTEXT *context )
{
BYTE action=DL_reg(context);
dprintf_int(stddeb, "int21: extended open/create: file= %s \n",
@@ -497,7 +511,7 @@
}
-static int INT21_RenameFile( SIGCONTEXT *context )
+static int INT21_RenameFile( CONTEXT *context )
{
const char *newname, *oldname;
char *buffer;
@@ -530,7 +544,7 @@
}
-static void INT21_ChangeDir( SIGCONTEXT *context )
+static void INT21_ChangeDir( CONTEXT *context )
{
int drive;
char *dirname = PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context));
@@ -550,7 +564,7 @@
}
-static int INT21_FindFirst( SIGCONTEXT *context )
+static int INT21_FindFirst( CONTEXT *context )
{
const char *path, *unixPath, *mask;
char *p;
@@ -585,10 +599,10 @@
}
-static int INT21_FindNext( SIGCONTEXT *context )
+static int INT21_FindNext( CONTEXT *context )
{
FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA();
- DOS_DIRENT entry;
+ WIN32_FIND_DATA32A entry;
int count;
if (!dta->unixPath) return 0;
@@ -607,16 +621,16 @@
return 0;
}
dta->count += count;
- dta->fileattr = entry.attr;
- dta->filetime = entry.time;
- dta->filedate = entry.date;
- dta->filesize = entry.size;
- strcpy( dta->filename, DOSFS_ToDosDTAFormat( entry.name ) );
+ dta->fileattr = entry.dwFileAttributes;
+ dta->filesize = entry.nFileSizeLow;
+ FileTimeToDosDateTime( &entry.ftLastWriteTime,
+ &dta->filedate, &dta->filetime );
+ strcpy( dta->filename, entry.cAlternateFileName );
return 1;
}
-static int INT21_CreateTempFile( SIGCONTEXT *context )
+static int INT21_CreateTempFile( CONTEXT *context )
{
static int counter = 0;
char *name = PTR_SEG_OFF_TO_LIN( DS_reg(context), DX_reg(context) );
@@ -627,7 +641,7 @@
sprintf( p, "wine%04x.%03d", (int)getpid(), counter );
counter = (counter + 1) % 1000;
- if ((AX_reg(context) = _lcreat_uniq( name, 0 )) != (WORD)HFILE_ERROR)
+ if ((AX_reg(context) = _lcreat_uniq( name, 0 )) != (WORD)HFILE_ERROR16)
{
dprintf_int( stddeb, "INT21_CreateTempFile: created %s\n", name );
return 1;
@@ -637,7 +651,7 @@
}
-static int INT21_GetCurrentDirectory( SIGCONTEXT *context )
+static int INT21_GetCurrentDirectory( CONTEXT *context )
{
int drive = DOS_GET_DRIVE( DL_reg(context) );
char *ptr = (char *)PTR_SEG_OFF_TO_LIN( DS_reg(context), SI_reg(context) );
@@ -653,7 +667,7 @@
}
-static int INT21_GetDiskSerialNumber( SIGCONTEXT *context )
+static int INT21_GetDiskSerialNumber( CONTEXT *context )
{
BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
int drive = DOS_GET_DRIVE( BL_reg(context) );
@@ -672,7 +686,7 @@
}
-static int INT21_SetDiskSerialNumber( SIGCONTEXT *context )
+static int INT21_SetDiskSerialNumber( CONTEXT *context )
{
BYTE *dataptr = PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
int drive = DOS_GET_DRIVE( BL_reg(context) );
@@ -691,7 +705,7 @@
/* microsoft's programmers should be shot for using CP/M style int21
calls in Windows for Workgroup's winfile.exe */
-static int INT21_FindFirstFCB( SIGCONTEXT *context )
+static int INT21_FindFirstFCB( CONTEXT *context )
{
BYTE *fcb = (BYTE *)PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
FINDFILE_FCB *pFCB;
@@ -719,12 +733,12 @@
}
-static int INT21_FindNextFCB( SIGCONTEXT *context )
+static int INT21_FindNextFCB( CONTEXT *context )
{
BYTE *fcb = (BYTE *)PTR_SEG_OFF_TO_LIN(DS_reg(context), DX_reg(context));
FINDFILE_FCB *pFCB;
DOS_DIRENTRY_LAYOUT *pResult = (DOS_DIRENTRY_LAYOUT *)GetCurrentDTA();
- DOS_DIRENT entry;
+ WIN32_FIND_DATA32A entry;
BYTE attr;
int count;
@@ -750,18 +764,37 @@
}
pFCB->count += count;
- memcpy( pResult->filename, entry.name, sizeof(pResult->filename) );
- pResult->fileattr = entry.attr;
- memset( pResult->reserved, 0, sizeof(pResult->reserved) );
- pResult->filetime = entry.time;
- pResult->filedate = entry.date;
+ pResult->fileattr = entry.dwFileAttributes;
pResult->cluster = 0; /* what else? */
- pResult->filesize = entry.size;
+ pResult->filesize = entry.nFileSizeLow;
+ memset( pResult->reserved, 0, sizeof(pResult->reserved) );
+ FileTimeToDosDateTime( &entry.ftLastWriteTime,
+ &pResult->filedate, &pResult->filetime );
+
+ /* Convert file name to FCB format */
+
+ memset( pResult->filename, ' ', sizeof(pResult->filename) );
+ if (!strcmp( entry.cAlternateFileName, "." )) pResult->filename[0] = '.';
+ else if (!strcmp( entry.cAlternateFileName, ".." ))
+ pResult->filename[0] = pResult->filename[1] = '.';
+ else
+ {
+ char *p = strrchr( entry.cAlternateFileName, '.' );
+ if (p && p[1] && (p != entry.cAlternateFileName))
+ {
+ memcpy( pResult->filename, entry.cAlternateFileName,
+ MIN( (p - entry.cAlternateFileName), 8 ) );
+ memcpy( pResult->filename + 8, p + 1, MIN( strlen(p), 3 ) );
+ }
+ else
+ memcpy( pResult->filename, entry.cAlternateFileName,
+ MIN( strlen(entry.cAlternateFileName), 8 ) );
+ }
return 1;
}
-static void DeleteFileFCB( SIGCONTEXT *context )
+static void DeleteFileFCB( CONTEXT *context )
{
fprintf( stderr, "DeleteFileFCB: not implemented yet\n" );
#if 0
@@ -803,7 +836,7 @@
#endif
}
-static void RenameFileFCB( SIGCONTEXT *context )
+static void RenameFileFCB( CONTEXT *context )
{
fprintf( stderr, "RenameFileFCB: not implemented yet\n" );
#if 0
@@ -849,7 +882,7 @@
-static void fLock( SIGCONTEXT * context )
+static void fLock( CONTEXT * context )
{
#if 0
struct flock f;
@@ -900,14 +933,15 @@
}
-static int INT21_GetFileAttribute( SIGCONTEXT * context )
+static int INT21_GetFileAttribute( CONTEXT * context )
{
const char *unixName;
+ BY_HANDLE_FILE_INFORMATION info;
unixName = DOSFS_GetUnixFileName( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)), TRUE );
if (!unixName) return 0;
- if (!FILE_Stat( unixName, &CL_reg(context), NULL, NULL, NULL )) return 0;
- CH_reg(context) = 0;
+ if (!FILE_Stat( unixName, &info )) return 0;
+ CX_reg(context) = info.dwFileAttributes;
dprintf_int( stddeb, "INT21_GetFileAttributes(%s) = 0x%x\n",
unixName, CX_reg(context) );
return 1;
@@ -919,13 +953,14 @@
/***********************************************************************
* DOS3Call (KERNEL.102)
*/
-void DOS3Call( SIGCONTEXT *context )
+void DOS3Call( CONTEXT *context )
{
dprintf_int( stddeb, "int21: AX=%04x BX=%04x CX=%04x DX=%04x "
"SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
- DS_reg(context), ES_reg(context), EFL_reg(context));
+ (WORD)DS_reg(context), (WORD)ES_reg(context),
+ EFL_reg(context) );
if (AH_reg(context) == 0x59) /* Get extended error info */
{
@@ -1124,6 +1159,7 @@
break;
case 0x34: /* GET ADDRESS OF INDOS FLAG */
+ if (!heap) INT21_CreateHeap();
ES_reg(context) = DosHeapHandle;
BX_reg(context) = (int)&heap->InDosFlag - (int)heap;
break;
@@ -1168,9 +1204,9 @@
break;
case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
- AX_reg(context) = _lcreat( PTR_SEG_OFF_TO_LIN( DS_reg(context),
+ AX_reg(context) = _lcreat16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
DX_reg(context) ), CX_reg(context) );
- if (AX_reg(context) == (WORD)HFILE_ERROR)
+ if (AX_reg(context) == (WORD)HFILE_ERROR16)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -1182,7 +1218,7 @@
break;
case 0x3e: /* "CLOSE" - CLOSE FILE */
- if ((AX_reg(context) = _lclose( BX_reg(context) )) != 0)
+ if ((AX_reg(context) = _lclose16( BX_reg(context) )) != 0)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -1206,10 +1242,10 @@
case 0x40: /* "WRITE" - WRITE TO FILE OR DEVICE */
{
- LONG result = _hwrite( BX_reg(context),
- PTR_SEG_OFF_TO_LIN( DS_reg(context),
- DX_reg(context) ),
- CX_reg(context) );
+ LONG result = _hwrite16( BX_reg(context),
+ PTR_SEG_OFF_TO_LIN( DS_reg(context),
+ DX_reg(context) ),
+ CX_reg(context) );
if (result == -1)
{
AX_reg(context) = DOS_ExtendedError;
@@ -1230,10 +1266,10 @@
case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
{
- LONG status = _llseek( BX_reg(context),
- MAKELONG(DX_reg(context),CX_reg(context)),
- AL_reg(context) );
- if (status == HFILE_ERROR)
+ LONG status = _llseek16( BX_reg(context),
+ MAKELONG(DX_reg(context),CX_reg(context)),
+ AL_reg(context) );
+ if (status == -1)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -1357,7 +1393,7 @@
break;
case 0x45: /* "DUP" - DUPLICATE FILE HANDLE */
- if ((AX_reg(context) = FILE_Dup(BX_reg(context))) == (WORD)HFILE_ERROR)
+ if ((AX_reg(context) = FILE_Dup(BX_reg(context))) == (WORD)HFILE_ERROR16)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -1365,7 +1401,7 @@
break;
case 0x46: /* "DUP2", "FORCEDUP" - FORCE DUPLICATE FILE HANDLE */
- if (FILE_Dup2( BX_reg(context), CX_reg(context) ) == HFILE_ERROR)
+ if (FILE_Dup2( BX_reg(context), CX_reg(context) ) == HFILE_ERROR32)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -1389,9 +1425,9 @@
break;
case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
- AX_reg(context) = WinExec( PTR_SEG_OFF_TO_LIN( DS_reg(context),
- DX_reg(context) ),
- SW_NORMAL );
+ AX_reg(context) = WinExec16( PTR_SEG_OFF_TO_LIN( DS_reg(context),
+ DX_reg(context) ),
+ SW_NORMAL );
if (AX_reg(context) < 32) SET_CFLAG(context);
break;
@@ -1441,20 +1477,28 @@
switch (AL_reg(context))
{
case 0x00: /* Get */
- if (!FILE_GetDateTime( BX_reg(context), &DX_reg(context),
- &CX_reg(context), TRUE ))
{
- AX_reg(context) = DOS_ExtendedError;
- SET_CFLAG(context);
+ FILETIME filetime;
+ if (!GetFileTime( BX_reg(context), NULL, NULL, &filetime ))
+ {
+ AX_reg(context) = DOS_ExtendedError;
+ SET_CFLAG(context);
+ }
+ else FileTimeToDosDateTime( &filetime, &DX_reg(context),
+ &CX_reg(context) );
}
break;
case 0x01: /* Set */
- if (!FILE_SetDateTime( BX_reg(context), DX_reg(context),
- CX_reg(context) ))
{
- AX_reg(context) = DOS_ExtendedError;
- SET_CFLAG(context);
+ FILETIME filetime;
+ DosDateTimeToFileTime( DX_reg(context), CX_reg(context),
+ &filetime );
+ if (!SetFileTime( BX_reg(context), NULL, NULL, &filetime ))
+ {
+ AX_reg(context) = DOS_ExtendedError;
+ SET_CFLAG(context);
+ }
}
break;
}
@@ -1485,7 +1529,7 @@
break;
case 0x5b: /* CREATE NEW FILE */
- if ((AX_reg(context) = _lcreat_uniq( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)), 0 )) == (WORD)HFILE_ERROR)
+ if ((AX_reg(context) = _lcreat_uniq( PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)), 0 )) == (WORD)HFILE_ERROR16)
{
AX_reg(context) = DOS_ExtendedError;
SET_CFLAG(context);
@@ -1564,14 +1608,11 @@
*(WORD*)(dataptr+3) = WINE_LanguageId;
*(WORD*)(dataptr+5) = CodePage;
break;
- case 0x06: {
- extern DWORD DOSMEM_CollateTable;
-
+ case 0x06:
dataptr[0] = 0x06;
*(DWORD*)(dataptr+1) = MAKELONG(DOSMEM_CollateTable & 0xFFFF,DOSMEM_AllocSelector(DOSMEM_CollateTable>>16));
CX_reg(context) = 258;/*FIXME: size of table?*/
break;
- }
default:
INT_BARF( context, 0x21 );
SET_CFLAG(context);
@@ -1656,14 +1697,39 @@
SET_CFLAG(context);
}
break;
+ case 0x4e: /* Find first file */
+ /* FIXME: use attributes in CX */
+ if (!(AX_reg(context) = FindFirstFile16(
+ PTR_SEG_OFF_TO_LIN(DS_reg(context),DX_reg(context)),
+ (WIN32_FIND_DATA32A *)PTR_SEG_OFF_TO_LIN(ES_reg(context),
+ DI_reg(context)))))
+ {
+ AX_reg(context) = DOS_ExtendedError;
+ SET_CFLAG(context);
+ }
+ break;
+ case 0x4f: /* Find next file */
+ if (!FindNextFile16( BX_reg(context),
+ (WIN32_FIND_DATA32A *)PTR_SEG_OFF_TO_LIN(ES_reg(context),
+ DI_reg(context))))
+ {
+ AX_reg(context) = DOS_ExtendedError;
+ SET_CFLAG(context);
+ }
+ break;
+ case 0xa1: /* Find close */
+ if (!FindClose16( BX_reg(context) ))
+ {
+ AX_reg(context) = DOS_ExtendedError;
+ SET_CFLAG(context);
+ }
+ break;
case 0xa0:
break;
case 0x3b: /* Change directory */
case 0x41: /* Delete file */
case 0x43: /* Get/Set file attributes */
case 0x47: /* Get current directory */
- case 0x4e: /* Find first file */
- case 0x4f: /* Find next file */
case 0x56: /* Move (rename) file */
case 0x6c: /* Create/Open file */
default:
@@ -1697,22 +1763,6 @@
"SI=%04x DI=%04x DS=%04x ES=%04x EFL=%08lx\n",
AX_reg(context), BX_reg(context), CX_reg(context),
DX_reg(context), SI_reg(context), DI_reg(context),
- DS_reg(context), ES_reg(context), EFL_reg(context));
-}
-
-
-BOOL32 INT21_Init(void)
-{
- if (!(DosHeapHandle = GlobalAlloc16(GMEM_FIXED,sizeof(struct DosHeap))))
- {
- fprintf( stderr, "INT21_Init: Out of memory\n");
- return FALSE;
- }
- heap = (struct DosHeap *) GlobalLock16(DosHeapHandle);
-
- dpb = &heap->dpb;
- dpbsegptr = PTR_SEG_OFF_TO_SEGPTR(DosHeapHandle,(int)&heap->dpb-(int)heap);
- heap->InDosFlag = 0;
- strcpy(heap->biosdate, "01/01/80");
- return TRUE;
+ (WORD)DS_reg(context), (WORD)ES_reg(context),
+ EFL_reg(context));
}
diff --git a/miscemu/int25.c b/msdos/int25.c
similarity index 93%
rename from miscemu/int25.c
rename to msdos/int25.c
index f1b8052..7073bd8 100644
--- a/miscemu/int25.c
+++ b/msdos/int25.c
@@ -1,3 +1,7 @@
+/*
+ * DOS interrupt 25h handler
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -14,7 +18,7 @@
*
* Handler for int 25h (absolute disk read).
*/
-void INT_Int25Handler( SIGCONTEXT *context )
+void INT_Int25Handler( CONTEXT *context )
{
BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
DWORD begin, length;
diff --git a/miscemu/int26.c b/msdos/int26.c
similarity index 92%
rename from miscemu/int26.c
rename to msdos/int26.c
index 4009184..09ee526 100644
--- a/miscemu/int26.c
+++ b/msdos/int26.c
@@ -1,3 +1,7 @@
+/*
+ * DOS interrupt 26h handler
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include "msdos.h"
@@ -13,7 +17,7 @@
*
* Handler for int 26h (absolute disk read).
*/
-void INT_Int26Handler( SIGCONTEXT *context )
+void INT_Int26Handler( CONTEXT *context )
{
BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) );
DWORD begin, length;
diff --git a/miscemu/int2a.c b/msdos/int2a.c
similarity index 85%
rename from miscemu/int2a.c
rename to msdos/int2a.c
index c41b10d..02e37d8 100644
--- a/miscemu/int2a.c
+++ b/msdos/int2a.c
@@ -1,3 +1,7 @@
+/*
+ * DOS interrupt 2ah handler
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include "msdos.h"
@@ -11,7 +15,7 @@
*
* Handler for int 2ah (network).
*/
-void INT_Int2aHandler( SIGCONTEXT *context )
+void INT_Int2aHandler( CONTEXT *context )
{
switch(AH_reg(context))
{
diff --git a/miscemu/int2f.c b/msdos/int2f.c
similarity index 95%
rename from miscemu/int2f.c
rename to msdos/int2f.c
index b8b6277..23eb9ab 100644
--- a/miscemu/int2f.c
+++ b/msdos/int2f.c
@@ -1,3 +1,7 @@
+/*
+ * DOS interrupt 2fh handler
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -15,15 +19,15 @@
/* base WPROCS.DLL ordinal number for VxDs */
#define VXD_BASE 400
-static void do_int2f_16( SIGCONTEXT *context );
-void do_mscdex( SIGCONTEXT *context );
+static void do_int2f_16( CONTEXT *context );
+void do_mscdex( CONTEXT *context );
/**********************************************************************
* INT_Int2fHandler
*
* Handler for int 2fh (multiplex).
*/
-void INT_Int2fHandler( SIGCONTEXT *context )
+void INT_Int2fHandler( CONTEXT *context )
{
switch(AH_reg(context))
{
@@ -65,7 +69,7 @@
/**********************************************************************
* do_int2f_16
*/
-static void do_int2f_16( SIGCONTEXT *context )
+static void do_int2f_16( CONTEXT *context )
{
DWORD addr;
@@ -136,7 +140,7 @@
}
}
-void do_mscdex( SIGCONTEXT *context )
+void do_mscdex( CONTEXT *context )
{
int drive, count;
char *p;
diff --git a/msdos/int4b.c b/msdos/int4b.c
new file mode 100644
index 0000000..4f4e8c5
--- /dev/null
+++ b/msdos/int4b.c
@@ -0,0 +1,25 @@
+/*
+ * DOS interrupt 4bh handler
+ */
+
+#include "miscemu.h"
+
+/***********************************************************************
+ * INT_Int4bHandler
+ *
+ */
+void INT_Int4bHandler( CONTEXT *context )
+{
+ switch(AH_reg(context))
+ {
+ case 0x81: /* Virtual DMA Spec (IBM SCSI interface) */
+ if(AL_reg(context) != 0x02) /* if not install check */
+ {
+ SET_CFLAG(context);
+ AL_reg(context) = 0x0f; /* function is not implemented */
+ }
+ break;
+ default:
+ INT_BARF(context, 0x4b);
+ }
+}
diff --git a/msdos/int5c.c b/msdos/int5c.c
new file mode 100644
index 0000000..ab22059
--- /dev/null
+++ b/msdos/int5c.c
@@ -0,0 +1,25 @@
+/*
+ * NetBIOS interrupt handling
+ *
+ * Copyright 1995 Alexandre Julliard, Alex Korobka
+ */
+
+#include "ldt.h"
+#include "miscemu.h"
+#include "stddebug.h"
+#include "debug.h"
+
+
+/***********************************************************************
+ * NetBIOSCall (KERNEL.103)
+ *
+ * Also handler for interrupt 5c.
+ */
+void NetBIOSCall( CONTEXT *context )
+{
+ BYTE* ptr;
+ ptr = (BYTE*) PTR_SEG_OFF_TO_LIN(ES_reg(context),BX_reg(context));
+ fprintf(stdnimp,"NetBIOSCall: command code %02x (ignored)\n",*ptr);
+ AL_reg(context) = *(ptr+0x01) = 0xFB; /* NetBIOS emulator not found */
+}
+
diff --git a/msdos/interrupts.c b/msdos/interrupts.c
new file mode 100644
index 0000000..31710fd
--- /dev/null
+++ b/msdos/interrupts.c
@@ -0,0 +1,42 @@
+/*
+ * Interrupt vectors emulation
+ *
+ * Copyright 1995 Alexandre Julliard
+ */
+
+#include <sys/types.h>
+
+#include "windows.h"
+#include "drive.h"
+#include "miscemu.h"
+#include "msdos.h"
+#include "module.h"
+#include "stackframe.h"
+#include "stddebug.h"
+#include "debug.h"
+
+static FARPROC16 INT_Vectors[256];
+
+
+/**********************************************************************
+ * INT_GetHandler
+ *
+ * Return the interrupt vector for a given interrupt.
+ */
+FARPROC16 INT_GetHandler( BYTE intnum )
+{
+ return INT_Vectors[intnum];
+}
+
+
+/**********************************************************************
+ * INT_SetHandler
+ *
+ * Set the interrupt handler for a given interrupt.
+ */
+void INT_SetHandler( BYTE intnum, FARPROC16 handler )
+{
+ dprintf_int( stddeb, "Set interrupt vector %02x <- %04x:%04x\n",
+ intnum, HIWORD(handler), LOWORD(handler) );
+ INT_Vectors[intnum] = handler;
+}
diff --git a/miscemu/ioports.c b/msdos/ioports.c
similarity index 76%
rename from miscemu/ioports.c
rename to msdos/ioports.c
index 3ea012a..7e41ce8 100644
--- a/miscemu/ioports.c
+++ b/msdos/ioports.c
@@ -34,7 +34,10 @@
};
-DWORD inport( int port, int count )
+/**********************************************************************
+ * IO_inport
+ */
+DWORD IO_inport( int port, int count )
{
DWORD res = 0;
BYTE b;
@@ -52,7 +55,9 @@
b = cmosimage[cmosaddress & 0x3f];
break;
default:
- b = 0xff;
+ fprintf( stderr, "Direct I/O read attempted from port %x\n", port);
+ b = 0xff;
+ break;
}
res = (res << 8) | b;
}
@@ -60,7 +65,10 @@
}
-void outport( int port, int count, DWORD value )
+/**********************************************************************
+ * IO_outport
+ */
+void IO_outport( int port, int count, DWORD value )
{
BYTE b;
@@ -80,7 +88,8 @@
cmosimage[cmosaddress & 0x3f] = b;
break;
default:
- /* Rien du tout. */
+ fprintf( stderr, "Direct I/O write attempted to port %x\n", port );
+ break;
}
}
}
diff --git a/miscemu/vxd.c b/msdos/vxd.c
similarity index 94%
rename from miscemu/vxd.c
rename to msdos/vxd.c
index 92bf08e..a56c1e5 100644
--- a/miscemu/vxd.c
+++ b/msdos/vxd.c
@@ -19,12 +19,12 @@
"SI %04x, DI %04x, DS %04x, ES %04x\n", \
(name), (name), AX_reg(context), BX_reg(context), \
CX_reg(context), DX_reg(context), SI_reg(context), \
- DI_reg(context), DS_reg(context), ES_reg(context) )
+ DI_reg(context), (WORD)DS_reg(context), (WORD)ES_reg(context) )
/***********************************************************************
* VXD_PageFile
*/
-void VXD_PageFile( SIGCONTEXT *context )
+void VXD_PageFile( CONTEXT *context )
{
/* taken from Ralf Brown's Interrupt List */
@@ -69,7 +69,7 @@
/***********************************************************************
* VXD_Shell
*/
-void VXD_Shell( SIGCONTEXT *context )
+void VXD_Shell( CONTEXT *context )
{
dprintf_vxd(stddeb,"VxD Shell called ...\n");
@@ -127,7 +127,7 @@
/***********************************************************************
* VXD_Comm
*/
-void VXD_Comm( SIGCONTEXT *context )
+void VXD_Comm( CONTEXT *context )
{
dprintf_vxd(stddeb,"VxD Comm called ...\n");
diff --git a/multimedia/mmsystem.c b/multimedia/mmsystem.c
index 44c4bb4..a669a23 100644
--- a/multimedia/mmsystem.c
+++ b/multimedia/mmsystem.c
@@ -1901,19 +1901,19 @@
*/
HMMIO16 mmioOpen(LPSTR szFileName, MMIOINFO * lpmmioinfo, DWORD dwOpenFlags)
{
- int hFile;
+ HFILE32 hFile;
HMMIO16 hmmio;
OFSTRUCT ofs;
LPMMIOINFO lpmminfo;
dprintf_mmsys(stddeb, "mmioOpen('%s', %p, %08lX);\n", szFileName, lpmmioinfo, dwOpenFlags);
- hFile = OpenFile(szFileName, &ofs, dwOpenFlags);
+ hFile = OpenFile32(szFileName, &ofs, dwOpenFlags);
if (hFile == -1) return 0;
hmmio = GlobalAlloc16(GMEM_MOVEABLE, sizeof(MMIOINFO));
lpmminfo = (LPMMIOINFO)GlobalLock16(hmmio);
if (lpmminfo == NULL) return 0;
memset(lpmminfo, 0, sizeof(MMIOINFO));
lpmminfo->hmmio = hmmio;
- lpmminfo->dwReserved2 = MAKELONG(hFile, 0);
+ lpmminfo->dwReserved2 = hFile;
GlobalUnlock16(hmmio);
dprintf_mmsys(stddeb, "mmioOpen // return hmmio=%04X\n", hmmio);
return hmmio;
@@ -1929,7 +1929,7 @@
dprintf_mmsys(stddeb, "mmioClose(%04X, %04X);\n", hmmio, uFlags);
lpmminfo = (LPMMIOINFO)GlobalLock16(hmmio);
if (lpmminfo == NULL) return 0;
- _lclose(LOWORD(lpmminfo->dwReserved2));
+ _lclose32((HFILE32)lpmminfo->dwReserved2);
GlobalUnlock16(hmmio);
GlobalFree16(hmmio);
return 0;
@@ -1983,7 +1983,7 @@
dprintf_mmsys(stddeb, "mmioSeek // can't lock hmmio=%04X !\n", hmmio);
return 0;
}
- count = _llseek(LOWORD(lpmminfo->dwReserved2), lOffset, iOrigin);
+ count = _llseek32((HFILE32)lpmminfo->dwReserved2, lOffset, iOrigin);
GlobalUnlock16(hmmio);
return count;
}
@@ -2058,7 +2058,7 @@
}
lpmmioinfo->pchNext += count;
GlobalUnlock16(hmmio);
- lpmminfo->lDiskOffset = _llseek(LOWORD(lpmminfo->dwReserved2), 0, SEEK_CUR);
+ lpmminfo->lDiskOffset = _llseek32((HFILE32)lpmminfo->dwReserved2, 0, SEEK_CUR);
return 0;
}
@@ -2106,20 +2106,20 @@
if (lpmminfo == NULL) return 0;
dwfcc = lpck->ckid;
dprintf_mmio(stddeb, "mmioDescend // dwfcc=%08lX\n", dwfcc);
- dwOldPos = _llseek(LOWORD(lpmminfo->dwReserved2), 0, SEEK_CUR);
+ dwOldPos = _llseek32((HFILE32)lpmminfo->dwReserved2, 0, SEEK_CUR);
dprintf_mmio(stddeb, "mmioDescend // dwOldPos=%ld\n", dwOldPos);
if (lpckParent != NULL) {
dprintf_mmio(stddeb, "mmioDescend // seek inside parent at %ld !\n", lpckParent->dwDataOffset);
- dwOldPos = _llseek(LOWORD(lpmminfo->dwReserved2),
+ dwOldPos = _llseek32((HFILE32)lpmminfo->dwReserved2,
lpckParent->dwDataOffset, SEEK_SET);
}
if ((uFlags & MMIO_FINDCHUNK) || (uFlags & MMIO_FINDRIFF) ||
(uFlags & MMIO_FINDLIST)) {
dprintf_mmio(stddeb, "mmioDescend // MMIO_FINDxxxx dwfcc=%08lX !\n", dwfcc);
while (TRUE) {
- if (_lread32(LOWORD(lpmminfo->dwReserved2), (LPSTR)lpck,
+ if (_lread32((HFILE32)lpmminfo->dwReserved2, (LPSTR)lpck,
sizeof(MMCKINFO)) < sizeof(MMCKINFO)) {
- _llseek(LOWORD(lpmminfo->dwReserved2), dwOldPos, SEEK_SET);
+ _llseek32((HFILE32)lpmminfo->dwReserved2, dwOldPos, SEEK_SET);
GlobalUnlock16(hmmio);
return MMIOERR_CHUNKNOTFOUND;
}
@@ -2129,13 +2129,13 @@
dwOldPos += lpck->cksize + 2 * sizeof(DWORD);
if (lpck->ckid == FOURCC_RIFF || lpck->ckid == FOURCC_LIST)
dwOldPos += sizeof(DWORD);
- _llseek(LOWORD(lpmminfo->dwReserved2), dwOldPos, SEEK_SET);
+ _llseek32((HFILE32)lpmminfo->dwReserved2, dwOldPos, SEEK_SET);
}
}
else {
if (_lread32(LOWORD(lpmminfo->dwReserved2), (LPSTR)lpck,
sizeof(MMCKINFO)) < sizeof(MMCKINFO)) {
- _llseek(LOWORD(lpmminfo->dwReserved2), dwOldPos, SEEK_SET);
+ _llseek32((HFILE32)lpmminfo->dwReserved2, dwOldPos, SEEK_SET);
GlobalUnlock16(hmmio);
return MMIOERR_CHUNKNOTFOUND;
}
@@ -2143,8 +2143,8 @@
lpck->dwDataOffset = dwOldPos + 2 * sizeof(DWORD);
if (lpck->ckid == FOURCC_RIFF || lpck->ckid == FOURCC_LIST)
lpck->dwDataOffset += sizeof(DWORD);
- lpmminfo->lDiskOffset = _llseek(LOWORD(lpmminfo->dwReserved2),
- lpck->dwDataOffset, SEEK_SET);
+ lpmminfo->lDiskOffset = _llseek32((HFILE32)lpmminfo->dwReserved2,
+ lpck->dwDataOffset, SEEK_SET);
GlobalUnlock16(hmmio);
dprintf_mmio(stddeb, "mmioDescend // lpck->ckid=%08lX lpck->cksize=%ld !\n",
lpck->ckid, lpck->cksize);
diff --git a/objects/brush.c b/objects/brush.c
index 5480b85..70f7143 100644
--- a/objects/brush.c
+++ b/objects/brush.c
@@ -12,7 +12,6 @@
#include "color.h"
#include "stddebug.h"
#include "debug.h"
-#include "xmalloc.h"
#define NB_HATCH_STYLES 6
diff --git a/objects/color.c b/objects/color.c
index 8aaed5c..76a24cb 100644
--- a/objects/color.c
+++ b/objects/color.c
@@ -68,6 +68,7 @@
static int COLOR_gapStart = 256;
static int COLOR_gapEnd = -1;
static int COLOR_gapFilled = 0;
+static int COLOR_max = 256;
/* First free dynamic color cell, 0 = full palette, -1 = fixed palette */
static int COLOR_firstFree = 0;
@@ -231,8 +232,9 @@
if( COLOR_gapStart < COLOR_gapEnd && COLOR_PixelToPalette )
{
XColor xc;
- int r, g, b;
+ int r, g, b, max;
+ max = COLOR_max - (256 - (COLOR_gapEnd - COLOR_gapStart));
for ( i = 0, idx = COLOR_gapStart; i < 256 && idx <= COLOR_gapEnd; i++ )
if( COLOR_PixelToPalette[i] == 0 )
{
@@ -248,6 +250,7 @@
COLOR_PaletteToPixel[idx] = xc.pixel;
*(COLORREF*)(COLOR_sysPal + idx) = RGB(r, g, b);
COLOR_sysPal[idx++].peFlags |= PC_SYS_USED;
+ if( --max <= 0 ) break;
}
}
COLOR_gapFilled = idx - COLOR_gapStart;
@@ -317,16 +320,15 @@
unsigned long* pixDynMapping = NULL;
unsigned long plane_masks[1];
int i, j, warn = 0;
- int color_ini_max = 256;
int diff, r, g, b, max = 256, bp = 0, wp = 1;
int step = 1;
/* read "AllocSystemColors" from wine.conf */
- color_ini_max = PROFILE_GetWineIniInt( "options", "AllocSystemColors", 256);
- if (color_ini_max > 256) color_ini_max = 256;
- if (color_ini_max < 20) color_ini_max = 20;
- dprintf_palette(stddeb,"COLOR_Init: %d colors configured.\n",color_ini_max);
+ COLOR_max = PROFILE_GetWineIniInt( "options", "AllocSystemColors", 256);
+ if (COLOR_max > 256) COLOR_max = 256;
+ else if (COLOR_max < 20) COLOR_max = 20;
+ dprintf_palette(stddeb,"COLOR_Init: %d colors configured.\n", COLOR_max);
dprintf_palette(stddeb,"\tbuilding shared map - %i palette entries\n", cs->size);
@@ -425,8 +427,8 @@
}
}
- if( c_min > color_ini_max - NB_RESERVED_COLORS)
- c_min = color_ini_max - NB_RESERVED_COLORS;
+ if( c_min > COLOR_max - NB_RESERVED_COLORS)
+ c_min = COLOR_max - NB_RESERVED_COLORS;
c_min = (c_min/2) + (c_min/2); /* need even set for split palette */
diff --git a/objects/dc.c b/objects/dc.c
index cfe93a1..d3363de 100644
--- a/objects/dc.c
+++ b/objects/dc.c
@@ -16,7 +16,6 @@
#include "color.h"
#include "debug.h"
#include "font.h"
-#include "xmalloc.h"
extern void CLIPPING_UpdateGCRegion( DC * dc ); /* objects/clipping.c */
@@ -171,6 +170,7 @@
DC *DC_GetDCPtr( HDC32 hdc )
{
GDIOBJHDR *ptr = (GDIOBJHDR *)GDI_HEAP_LIN_ADDR( hdc );
+ if (!ptr) return NULL;
if ((ptr->wMagic == DC_MAGIC) || (ptr->wMagic == METAFILE_DC_MAGIC))
return (DC *)ptr;
return NULL;
diff --git a/objects/dib.c b/objects/dib.c
index 66f8d8f..d49b091 100644
--- a/objects/dib.c
+++ b/objects/dib.c
@@ -16,7 +16,6 @@
#include "stddebug.h"
#include "color.h"
#include "debug.h"
-#include "xmalloc.h"
extern void CLIPPING_UpdateGCRegion(DC* );
diff --git a/objects/font.c b/objects/font.c
index cc54c0b..945b380 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -482,7 +482,6 @@
if (!hfont) return 0;
fontPtr = (FONTOBJ *) GDI_HEAP_LIN_ADDR( hfont );
memcpy( &fontPtr->logfont, font, sizeof(LOGFONT16) );
- AnsiLower( fontPtr->logfont.lfFaceName );
dprintf_font(stddeb,"CreateFontIndirect(%p (%d,%d)); return %04x\n",
font, font->lfHeight, font->lfWidth, hfont);
return hfont;
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 0502c69..96f7e47 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -18,7 +18,6 @@
#include "region.h"
#include "stddebug.h"
#include "debug.h"
-#include "xmalloc.h"
WORD GDI_HeapSel = 0;
diff --git a/objects/metafile.c b/objects/metafile.c
index a912ce8..9610dc6 100644
--- a/objects/metafile.c
+++ b/objects/metafile.c
@@ -62,7 +62,7 @@
{
HMETAFILE16 hmf;
METAHEADER *mh;
- HFILE hFile;
+ HFILE32 hFile;
DWORD size;
dprintf_metafile(stddeb,"GetMetaFile: %s\n", lpFilename);
@@ -78,12 +78,12 @@
return 0;
}
- if ((hFile = _lopen(lpFilename, OF_READ)) == HFILE_ERROR) {
+ if ((hFile = _lopen32(lpFilename, OF_READ)) == HFILE_ERROR32) {
GlobalFree16(hmf);
return 0;
}
- if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR) {
+ if (_lread32(hFile, (char *)mh, MFHEADERSIZE) == HFILE_ERROR32) {
GlobalFree16(hmf);
return 0;
}
@@ -99,12 +99,12 @@
}
if (_lread32(hFile, (char*)mh + mh->mtHeaderSize * 2,
- size - mh->mtHeaderSize * 2) == HFILE_ERROR) {
+ size - mh->mtHeaderSize * 2) == HFILE_ERROR32) {
GlobalFree16(hmf);
return 0;
}
- _lclose(hFile);
+ _lclose32(hFile);
if (mh->mtType != 1) {
GlobalFree16(hmf);
@@ -126,7 +126,7 @@
HMETAFILE16 handle = 0;
METAHEADER *mh;
METAHEADER *mh2;
- HFILE hFile;
+ HFILE32 hFile;
dprintf_metafile(stddeb,"CopyMetaFile: %s\n", lpFilename);
@@ -138,12 +138,12 @@
if (lpFilename) /* disk based metafile */
{
int i,j;
- hFile = _lcreat(lpFilename, 0);
+ hFile = _lcreat32(lpFilename, 0);
j=mh->mtType;
mh->mtType=1; /* disk file version stores 1 here */
i=_lwrite32(hFile, (char *)mh, mh->mtSize * 2) ;
mh->mtType=j; /* restore old value [0 or 1] */
- _lclose(hFile);
+ _lclose32(hFile);
if (i == -1)
return 0;
}
diff --git a/programs/progman/License_En.c b/programs/progman/License_En.c
index efe3437..60c1128 100644
--- a/programs/progman/License_En.c
+++ b/programs/progman/License_En.c
@@ -1,4 +1,4 @@
-#include <windows.h>
+#include "windows.h"
#include "license.h"
static CHAR LicenseCaption_En[] = "LICENSE";
diff --git a/programs/progman/dialog.c b/programs/progman/dialog.c
index f35d425..76efc95 100644
--- a/programs/progman/dialog.c
+++ b/programs/progman/dialog.c
@@ -4,8 +4,8 @@
* Copyright 1996 Ulrich Schmid
*/
-#include <windows.h>
-#include <commdlg.h>
+#include "windows.h"
+#include "commdlg.h"
#include "progman.h"
static BOOL DIALOG_BrowsePrograms(HWND, LPSTR, INT);
diff --git a/programs/progman/group.c b/programs/progman/group.c
index a133b55..0fcbada 100644
--- a/programs/progman/group.c
+++ b/programs/progman/group.c
@@ -5,7 +5,7 @@
*/
#include <stdio.h>
-#include <windows.h>
+#include "windows.h"
#include "progman.h"
/***********************************************************************
diff --git a/programs/progman/grpfile.c b/programs/progman/grpfile.c
index 5e8b5b2..44f9f04 100644
--- a/programs/progman/grpfile.c
+++ b/programs/progman/grpfile.c
@@ -4,7 +4,7 @@
* Copyright 1996 Ulrich Schmid
*/
-#include <windows.h>
+#include "windows.h"
#include "progman.h"
#define MALLOCHUNK 1000
diff --git a/programs/progman/license.c b/programs/progman/license.c
index 14308cd..c73dc26 100644
--- a/programs/progman/license.c
+++ b/programs/progman/license.c
@@ -1,4 +1,4 @@
-#include <windows.h>
+#include "windows.h"
#include "license.h"
static LICENSE* SelectLanguage(LPCSTR Language)
diff --git a/programs/progman/main.c b/programs/progman/main.c
index 779eb37..abfc430 100644
--- a/programs/progman/main.c
+++ b/programs/progman/main.c
@@ -5,13 +5,13 @@
*/
#include <stdio.h>
-#include <windows.h>
+#include "windows.h"
#include "license.h"
#include "progman.h"
#ifdef WINELIB
-#include <resource.h>
-#include <options.h>
-#include <shell.h>
+#include "resource.h"
+#include "options.h"
+#include "shell.h"
void LIBWINE_Register_accel();
void LIBWINE_Register_De();
void LIBWINE_Register_En();
diff --git a/programs/progman/program.c b/programs/progman/program.c
index 7855dfe..871e939 100644
--- a/programs/progman/program.c
+++ b/programs/progman/program.c
@@ -4,7 +4,7 @@
* Copyright 1996 Ulrich Schmid
*/
-#include <windows.h>
+#include "windows.h"
#include "progman.h"
/***********************************************************************
diff --git a/programs/progman/string.c b/programs/progman/string.c
index 07dbf3d..6948aac 100644
--- a/programs/progman/string.c
+++ b/programs/progman/string.c
@@ -4,9 +4,9 @@
* Copyright 1996 Ulrich Schmid
*/
-#include <windows.h>
+#include "windows.h"
#ifdef WINELIB
-#include <options.h>
+#include "options.h"
#endif
#include "progman.h"
diff --git a/programs/winhelp/hlp2sgml.c b/programs/winhelp/hlp2sgml.c
index 699be73..2294c85 100644
--- a/programs/winhelp/hlp2sgml.c
+++ b/programs/winhelp/hlp2sgml.c
@@ -252,19 +252,19 @@
static FILE *file = 0;
-HFILE OpenFile( LPCSTR path, OFSTRUCT *ofs, UINT mode )
+HFILE OpenFile32( LPCSTR path, OFSTRUCT *ofs, UINT mode )
{
file = *path ? fopen(path, "r") : stdin;
return file ? 1 : HFILE_ERROR;
}
-HFILE _lclose( HFILE hFile )
+HFILE _lclose32( HFILE hFile )
{
fclose(file);
return 0;
}
-LONG _hread( HFILE hFile, SEGPTR buffer, LONG count )
+LONG _hread32( HFILE hFile, SEGPTR buffer, LONG count )
{
return fread(buffer, 1, count, file);
}
diff --git a/programs/winhelp/hlpfile.c b/programs/winhelp/hlpfile.c
index 2a6c36a..bc1cac3 100644
--- a/programs/winhelp/hlpfile.c
+++ b/programs/winhelp/hlpfile.c
@@ -5,7 +5,7 @@
*/
#include <stdio.h>
-#include <windows.h>
+#include "windows.h"
#include "winhelp.h"
static void Report(LPCSTR str)
diff --git a/programs/winhelp/macro.c b/programs/winhelp/macro.c
index 7355270..d33ddcc 100644
--- a/programs/winhelp/macro.c
+++ b/programs/winhelp/macro.c
@@ -5,10 +5,10 @@
*/
#include <stdio.h>
-#include <windows.h>
-#include <commdlg.h>
+#include "windows.h"
+#include "commdlg.h"
#ifdef WINELIB
-#include <shell.h>
+#include "shell.h"
#endif
#include "winhelp.h"
#include "macro.h"
diff --git a/programs/winhelp/macro.h b/programs/winhelp/macro.h
index f1b403b..cc34ece 100644
--- a/programs/winhelp/macro.h
+++ b/programs/winhelp/macro.h
@@ -4,7 +4,7 @@
* Copyright 1996 Ulrich Schmid
*/
-#include <windows.h>
+#include "windows.h"
VOID MACRO_ExecuteMacro(LPCSTR);
diff --git a/programs/winhelp/string.c b/programs/winhelp/string.c
index 647b968..b404e92 100644
--- a/programs/winhelp/string.c
+++ b/programs/winhelp/string.c
@@ -4,7 +4,7 @@
* Copyright 1996 Ulrich Schmid
*/
-#include <windows.h>
+#include "windows.h"
#include "winhelp.h"
/* Class names */
diff --git a/programs/winhelp/winhelp.c b/programs/winhelp/winhelp.c
index 54e0a8d..ff003d5 100644
--- a/programs/winhelp/winhelp.c
+++ b/programs/winhelp/winhelp.c
@@ -5,11 +5,11 @@
*/
#include <stdio.h>
-#include <windows.h>
+#include "windows.h"
#ifdef WINELIB
-#include <resource.h>
-#include <options.h>
-#include <shell.h>
+#include "resource.h"
+#include "options.h"
+#include "shell.h"
extern const char people[];
#endif
#include "winhelp.h"
diff --git a/rc/winerc.c b/rc/winerc.c
index 3f9edbe..9dbcf90 100644
--- a/rc/winerc.c
+++ b/rc/winerc.c
@@ -426,7 +426,7 @@
put_WORD(ret->res+12,cx);
put_WORD(ret->res+14,cy);
put_WORD(ret->res+16,id);
- ret->size=win32?24:17;
+ ret->size=24;
ret=insert_string(ret,label,20,0);
/* is it a predefined class? */
cl=0;
@@ -493,9 +493,18 @@
/* an ICON control was specified, whf contains width, height, and flags */
gen_res* add_icon(char* name,int id,int x,int y,gen_res* whf,gen_res* rest)
{
+ if (win32)
+ {
+ put_WORD(whf->res+8,x);
+ put_WORD(whf->res+10,y);
+ put_WORD(whf->res+16,id);
+ }
+ else
+ {
put_WORD(whf->res+0,x);
put_WORD(whf->res+2,y);
put_WORD(whf->res+8,id);
+ }
whf=label_control_desc(name,whf);
return add_control(CT_STATIC,SS_ICON,whf,rest);
}
@@ -503,6 +512,10 @@
/* insert the generic control into rest */
gen_res* add_generic_control(gen_res* ctl, gen_res* rest)
{
+ char zeros[4]={0,0,0,0};
+ /* WIN32: Control is on dword boundary */
+ if(win32 && ctl->size%4)
+ ctl=insert_bytes(ctl,zeros,ctl->size,4-ctl->size%4);
return insert_at_beginning(rest,ctl->res,ctl->size);
}
diff --git a/resources/Makefile.in b/resources/Makefile.in
index f4f1e5c..24251ec 100644
--- a/resources/Makefile.in
+++ b/resources/Makefile.in
@@ -4,7 +4,7 @@
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = resources
-RCFLAGS = -w16
+RCFLAGS = -w32
SYSRES_SRCS = \
sysres_Cz.c \
diff --git a/resources/sysres.c b/resources/sysres.c
index ca79f6a..8714ee1 100644
--- a/resources/sysres.c
+++ b/resources/sysres.c
@@ -38,6 +38,17 @@
/***********************************************************************
+ * SYSRES_GetResourcePtr
+ *
+ * Return a pointer to a system resource.
+ */
+LPCVOID SYSRES_GetResPtr( SYSTEM_RESOURCE id )
+{
+ return SYSRES_Resources[Options.language][id]->bytes;
+}
+
+
+/***********************************************************************
* SYSRES_LoadResource
*
* Create a global memory block for a system resource.
diff --git a/scheduler/Makefile.in b/scheduler/Makefile.in
new file mode 100644
index 0000000..f6327b1
--- /dev/null
+++ b/scheduler/Makefile.in
@@ -0,0 +1,16 @@
+DEFS = -D__WINE__
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ..
+SRCDIR = @srcdir@
+VPATH = @srcdir@
+MODULE = scheduler
+
+C_SRCS = \
+ process.c \
+ thread.c
+
+all: $(MODULE).o
+
+@MAKE_RULES@
+
+### Dependencies:
diff --git a/scheduler/process.c b/scheduler/process.c
new file mode 100644
index 0000000..c225531
--- /dev/null
+++ b/scheduler/process.c
@@ -0,0 +1,330 @@
+/*
+ * Win32 processes
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include <assert.h>
+#include "process.h"
+#include "heap.h"
+#include "task.h"
+#include "winerror.h"
+
+PDB32 *pCurrentProcess = NULL;
+
+#define HTABLE_SIZE 0x30 /* Handle table initial size */
+#define HTABLE_INC 0x10 /* Handle table increment */
+
+#define BOOT_HTABLE_SIZE 5
+
+static HANDLE_ENTRY boot_handles[BOOT_HTABLE_SIZE];
+
+/***********************************************************************
+ * PROCESS_AllocHandleTable
+ */
+static HANDLE_TABLE *PROCESS_AllocHandleTable( PDB32 *process )
+{
+ HANDLE_TABLE *table = HeapAlloc( process->system_heap, HEAP_ZERO_MEMORY,
+ sizeof(HANDLE_TABLE) +
+ (HTABLE_SIZE-1) * sizeof(HANDLE_ENTRY) );
+ if (!table) return NULL;
+ table->count = HTABLE_SIZE;
+ return table;
+}
+
+
+/***********************************************************************
+ * PROCESS_GrowHandleTable
+ */
+static BOOL32 PROCESS_GrowHandleTable( PDB32 *process )
+{
+ HANDLE_TABLE *table = process->handle_table;
+ table = HeapReAlloc( process->system_heap, HEAP_ZERO_MEMORY, table,
+ sizeof(HANDLE_TABLE) +
+ (table->count+HTABLE_INC-1) * sizeof(HANDLE_ENTRY) );
+ if (!table) return FALSE;
+ table->count += HTABLE_INC;
+ process->handle_table = table;
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * PROCESS_AllocBootHandle
+ *
+ * Allocate a handle from the boot table.
+ */
+static HANDLE32 PROCESS_AllocBootHandle( K32OBJ *ptr, DWORD flags )
+{
+ HANDLE32 h;
+ for (h = 0; h < BOOT_HTABLE_SIZE; h++)
+ if (!boot_handles[h].ptr) break;
+ assert( h < BOOT_HTABLE_SIZE );
+ K32OBJ_IncCount( ptr );
+ boot_handles[h].flags = flags;
+ boot_handles[h].ptr = ptr;
+ return h + 1; /* Avoid handle 0 */
+}
+
+
+/***********************************************************************
+ * PROCESS_CloseBootHandle
+ *
+ * Close a handle from the boot table.
+ */
+static BOOL32 PROCESS_CloseBootHandle( HANDLE32 handle )
+{
+ HANDLE_ENTRY *entry = &boot_handles[handle - 1];
+ assert( (handle > 0) && (handle <= BOOT_HTABLE_SIZE) );
+ assert( entry->ptr );
+ K32OBJ_DecCount( entry->ptr );
+ entry->flags = 0;
+ entry->ptr = NULL;
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * PROCESS_GetBootObjPtr
+ *
+ * Get a handle ptr from the boot table.
+ */
+static K32OBJ *PROCESS_GetBootObjPtr( HANDLE32 handle, K32OBJ_TYPE type )
+{
+ K32OBJ *ptr;
+
+ assert( (handle > 0) && (handle <= BOOT_HTABLE_SIZE) );
+ ptr = boot_handles[handle - 1].ptr;
+ assert (ptr && (ptr->type == type));
+ K32OBJ_IncCount( ptr );
+ return ptr;
+}
+
+
+/***********************************************************************
+ * PROCESS_SetBootObjPtr
+ *
+ * Set a handle ptr from the boot table.
+ */
+static BOOL32 PROCESS_SetBootObjPtr( HANDLE32 handle, K32OBJ *ptr, DWORD flags)
+{
+ K32OBJ *old_ptr;
+
+ assert( (handle > 0) && (handle <= BOOT_HTABLE_SIZE) );
+ K32OBJ_IncCount( ptr );
+ if ((old_ptr = boot_handles[handle - 1].ptr)) K32OBJ_DecCount( old_ptr );
+ boot_handles[handle - 1].flags = flags;
+ boot_handles[handle - 1].ptr = ptr;
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * PROCESS_AllocHandle
+ *
+ * Allocate a handle for a kernel object and increment its refcount.
+ */
+HANDLE32 PROCESS_AllocHandle( K32OBJ *ptr, DWORD flags )
+{
+ HANDLE32 h;
+ HANDLE_ENTRY *entry;
+
+ assert( ptr );
+ if (!pCurrentProcess) return PROCESS_AllocBootHandle( ptr, flags );
+ EnterCriticalSection( &pCurrentProcess->crit_section );
+ K32OBJ_IncCount( ptr );
+ entry = pCurrentProcess->handle_table->entries;
+ for (h = 0; h < pCurrentProcess->handle_table->count; h++, entry++)
+ if (!entry->ptr) break;
+ if ((h < pCurrentProcess->handle_table->count) ||
+ PROCESS_GrowHandleTable( pCurrentProcess ))
+ {
+ entry->flags = flags;
+ entry->ptr = ptr;
+ LeaveCriticalSection( &pCurrentProcess->crit_section );
+ return h + 1; /* Avoid handle 0 */
+ }
+ LeaveCriticalSection( &pCurrentProcess->crit_section );
+ SetLastError( ERROR_OUTOFMEMORY );
+ K32OBJ_DecCount( ptr );
+ return INVALID_HANDLE_VALUE32;
+}
+
+
+/***********************************************************************
+ * PROCESS_GetObjPtr
+ *
+ * Retrieve a pointer to a kernel object and increments its reference count.
+ * The refcount must be decremented when the pointer is no longer used.
+ */
+K32OBJ *PROCESS_GetObjPtr( HANDLE32 handle, K32OBJ_TYPE type )
+{
+ K32OBJ *ptr = NULL;
+ if (!pCurrentProcess) return PROCESS_GetBootObjPtr( handle, type );
+ EnterCriticalSection( &pCurrentProcess->crit_section );
+ if ((handle > 0) && (handle <= pCurrentProcess->handle_table->count))
+ {
+ ptr = pCurrentProcess->handle_table->entries[handle - 1].ptr;
+ if (ptr && ((type == K32OBJ_UNKNOWN) || (ptr->type == type)))
+ K32OBJ_IncCount( ptr );
+ else ptr = NULL;
+ }
+ LeaveCriticalSection( &pCurrentProcess->crit_section );
+ if (!ptr) SetLastError( ERROR_INVALID_HANDLE );
+ return ptr;
+}
+
+
+/***********************************************************************
+ * PROCESS_SetObjPtr
+ *
+ * Change the object pointer of a handle, and increment the refcount.
+ * Use with caution!
+ */
+BOOL32 PROCESS_SetObjPtr( HANDLE32 handle, K32OBJ *ptr, DWORD flags )
+{
+ BOOL32 ret = TRUE;
+ K32OBJ *old_ptr = NULL;
+
+ if (!pCurrentProcess) return PROCESS_SetBootObjPtr( handle, ptr, flags );
+ EnterCriticalSection( &pCurrentProcess->crit_section );
+ if ((handle > 0) && (handle <= pCurrentProcess->handle_table->count))
+ {
+ HANDLE_ENTRY*entry = &pCurrentProcess->handle_table->entries[handle-1];
+ old_ptr = entry->ptr;
+ K32OBJ_IncCount( ptr );
+ entry->flags = flags;
+ entry->ptr = ptr;
+ }
+ else
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ ret = FALSE;
+ }
+ LeaveCriticalSection( &pCurrentProcess->crit_section );
+ if (old_ptr) K32OBJ_DecCount( old_ptr );
+ return ret;
+}
+
+
+/*********************************************************************
+ * CloseHandle (KERNEL32.23)
+ */
+BOOL32 CloseHandle( HANDLE32 handle )
+{
+ BOOL32 ret = FALSE;
+ K32OBJ *ptr = NULL;
+
+ if (!pCurrentProcess) return PROCESS_CloseBootHandle( handle );
+ EnterCriticalSection( &pCurrentProcess->crit_section );
+ if ((handle > 0) && (handle <= pCurrentProcess->handle_table->count))
+ {
+ HANDLE_ENTRY*entry = &pCurrentProcess->handle_table->entries[handle-1];
+ if ((ptr = entry->ptr))
+ {
+ entry->flags = 0;
+ entry->ptr = NULL;
+ ret = TRUE;
+ }
+ }
+ LeaveCriticalSection( &pCurrentProcess->crit_section );
+ if (!ret) SetLastError( ERROR_INVALID_HANDLE );
+ if (ptr) K32OBJ_DecCount( ptr );
+ return ret;
+}
+
+
+/***********************************************************************
+ * PROCESS_Create
+ */
+PDB32 *PROCESS_Create(void)
+{
+ PDB32 *pdb = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, sizeof(PDB32) );
+ if (!pdb) return NULL;
+ pdb->header.type = K32OBJ_PROCESS;
+ pdb->header.refcount = 1;
+ pdb->exit_code = 0x103; /* STILL_ACTIVE */
+ pdb->threads = 1;
+ pdb->running_threads = 1;
+ pdb->ring0_threads = 1;
+ pdb->system_heap = SystemHeap;
+ pdb->parent = pCurrentProcess;
+ pdb->group = pdb;
+ pdb->priority = 8; /* Normal */
+ InitializeCriticalSection( &pdb->crit_section );
+ if (!(pdb->heap = HeapCreate( HEAP_GROWABLE, 0x10000, 0 ))) goto error;
+ if (!(pdb->env_DB = HeapAlloc(pdb->heap, HEAP_ZERO_MEMORY, sizeof(ENVDB))))
+ goto error;
+ if (!(pdb->handle_table = PROCESS_AllocHandleTable( pdb ))) goto error;
+ pdb->heap_list = pdb->heap;
+ return pdb;
+
+error:
+ if (pdb->env_DB) HeapFree( pdb->heap, 0, pdb->env_DB );
+ if (pdb->handle_table) HeapFree( pdb->system_heap, 0, pdb->handle_table );
+ if (pdb->heap) HeapDestroy( pdb->heap );
+ DeleteCriticalSection( &pdb->crit_section );
+ HeapFree( SystemHeap, 0, pdb );
+ return NULL;
+}
+
+
+/***********************************************************************
+ * PROCESS_Destroy
+ */
+void PROCESS_Destroy( K32OBJ *ptr )
+{
+ PDB32 *pdb = (PDB32 *)ptr;
+ HANDLE32 handle;
+ assert( ptr->type == K32OBJ_PROCESS );
+
+ /* Close all handles */
+ for (handle = 0; handle < pdb->handle_table->count; handle++)
+ if (pdb->handle_table->entries[handle].ptr) CloseHandle( handle );
+
+ /* Free everything */
+
+ ptr->type = K32OBJ_UNKNOWN;
+ HeapFree( pdb->heap, 0, pdb->env_DB );
+ HeapFree( pdb->system_heap, 0, pdb->handle_table );
+ HeapDestroy( pdb->heap );
+ DeleteCriticalSection( &pdb->crit_section );
+ HeapFree( SystemHeap, 0, pdb );
+}
+
+
+/***********************************************************************
+ * ExitProcess (KERNEL32.100)
+ */
+void ExitProcess( DWORD status )
+{
+ TASK_KillCurrentTask( status );
+}
+
+
+/***********************************************************************
+ * GetCurrentProcess (KERNEL32.198)
+ */
+HANDLE32 GetCurrentProcess(void)
+{
+ return 0x7fffffff;
+}
+
+
+/***********************************************************************
+ * GetCurrentProcessId (KERNEL32.199)
+ */
+DWORD GetCurrentProcessId(void)
+{
+ return (DWORD)pCurrentProcess;
+}
+
+
+/***********************************************************************
+ * GetProcessHeap (KERNEL32.259)
+ */
+HANDLE32 GetProcessHeap(void)
+{
+ if (!pCurrentProcess) return SystemHeap; /* For the boot-up code */
+ return pCurrentProcess->heap;
+}
diff --git a/scheduler/thread.c b/scheduler/thread.c
new file mode 100644
index 0000000..78b71f8
--- /dev/null
+++ b/scheduler/thread.c
@@ -0,0 +1,231 @@
+/*
+ * Win32 threads
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include <assert.h>
+#include "thread.h"
+#include "winerror.h"
+#include "heap.h"
+#include "selectors.h"
+#include "winnt.h"
+
+THDB *pCurrentThread = NULL;
+
+
+/***********************************************************************
+ * THREAD_Create
+ */
+THDB *THREAD_Create( PDB32 *pdb, DWORD stack_size )
+{
+ THDB *thdb = HeapAlloc( SystemHeap, HEAP_ZERO_MEMORY, sizeof(THDB) );
+ if (!thdb) return NULL;
+ thdb->header.type = K32OBJ_THREAD;
+ thdb->header.refcount = 1;
+ thdb->process = pdb;
+ thdb->teb.except = (void *)-1;
+ thdb->teb.htask16 = 0; /* FIXME */
+ thdb->teb.stack_sel = 0; /* FIXME */
+ thdb->teb.self = &thdb->teb;
+ thdb->teb.tls_ptr = thdb->tls_array;
+ thdb->process2 = pdb;
+ thdb->exit_code = 0x103; /* STILL_ACTIVE */
+
+ /* Allocate the stack */
+
+ if (!stack_size) stack_size = 1024 * 1024; /* default size = 1Mb */
+ thdb->stack_base = VirtualAlloc( NULL, stack_size, MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE );
+ if (!thdb->stack_base) goto error;
+ /* Un-commit the first page (FIXME: should use PAGE_GUARD instead) */
+ VirtualFree( thdb->stack_base, 1, MEM_DECOMMIT );
+ thdb->teb.stack_top = (char *)thdb->stack_base + stack_size;
+ thdb->teb.stack_low = thdb->teb.stack_top;
+ thdb->exit_stack = thdb->teb.stack_top;
+
+ /* Allocate the TEB selector (%fs register) */
+
+ thdb->teb_sel = SELECTOR_AllocBlock( &thdb->teb, 0x1000, SEGMENT_DATA,
+ TRUE, FALSE );
+ if (!thdb->teb_sel) goto error;
+ return thdb;
+
+error:
+ if (thdb->teb_sel) SELECTOR_FreeBlock( thdb->teb_sel, 1 );
+ if (thdb->stack_base) VirtualFree( thdb->stack_base, 0, MEM_RELEASE );
+ HeapFree( SystemHeap, 0, thdb );
+ return NULL;
+}
+
+
+/***********************************************************************
+ * THREAD_Destroy
+ */
+void THREAD_Destroy( K32OBJ *ptr )
+{
+ THDB *thdb = (THDB *)ptr;
+ assert( ptr->type == K32OBJ_THREAD );
+ ptr->type = K32OBJ_UNKNOWN;
+ SELECTOR_FreeBlock( thdb->teb_sel, 1 );
+ HeapFree( SystemHeap, 0, thdb );
+}
+
+
+/***********************************************************************
+ * GetCurrentThread (KERNEL32.200)
+ */
+HANDLE32 GetCurrentThread(void)
+{
+ return 0xFFFFFFFE;
+}
+
+
+/***********************************************************************
+ * GetCurrentThreadId (KERNEL32.201)
+ */
+DWORD GetCurrentThreadId(void)
+{
+ /* FIXME: should probably use %fs register here */
+ assert( pCurrentThread );
+ return (DWORD)pCurrentThread;
+}
+
+
+/**********************************************************************
+ * GetLastError (KERNEL.148) (KERNEL32.227)
+ */
+DWORD GetLastError(void)
+{
+ THDB *thread = (THDB *)GetCurrentThreadId();
+ return thread->last_error;
+}
+
+
+/**********************************************************************
+ * SetLastError (KERNEL.147) (KERNEL32.497)
+ */
+void SetLastError( DWORD error )
+{
+ THDB *thread;
+ if (!pCurrentThread) return; /* FIXME */
+ thread = (THDB *)GetCurrentThreadId();
+ thread->last_error = error;
+}
+
+
+/**********************************************************************
+ * SetLastErrorEx (USER32.484)
+ */
+void SetLastErrorEx( DWORD error, DWORD type )
+{
+ /* FIXME: what about 'type'? */
+ SetLastError( error );
+}
+
+
+/**********************************************************************
+ * TlsAlloc (KERNEL32.530)
+ */
+DWORD TlsAlloc(void)
+{
+ DWORD i, mask, ret = 0;
+ THDB *thread = (THDB *)GetCurrentThreadId();
+ DWORD *bits = thread->process->tls_bits;
+ EnterCriticalSection( &thread->process->crit_section );
+ if (*bits == 0xffffffff)
+ {
+ bits++;
+ ret = 32;
+ if (*bits == 0xffffffff)
+ {
+ LeaveCriticalSection( &thread->process->crit_section );
+ SetLastError( ERROR_NO_MORE_ITEMS );
+ return 0xffffffff;
+ }
+ }
+ for (i = 0, mask = 1; i < 32; i++, mask <<= 1) if (!(*bits & mask)) break;
+ *bits |= mask;
+ LeaveCriticalSection( &thread->process->crit_section );
+ return ret + i;
+}
+
+
+/**********************************************************************
+ * TlsFree (KERNEL32.531)
+ */
+BOOL32 TlsFree( DWORD index )
+{
+ DWORD mask;
+ THDB *thread = (THDB *)GetCurrentThreadId();
+ DWORD *bits = thread->process->tls_bits;
+ if (index >= 64)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+ EnterCriticalSection( &thread->process->crit_section );
+ if (index >= 32) bits++;
+ mask = (1 << (index & 31));
+ if (!(*bits & mask)) /* already free? */
+ {
+ LeaveCriticalSection( &thread->process->crit_section );
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+ *bits &= ~mask;
+ thread->tls_array[index] = 0;
+ /* FIXME: should zero all other thread values */
+ LeaveCriticalSection( &thread->process->crit_section );
+ return TRUE;
+}
+
+
+/**********************************************************************
+ * TlsGetValue (KERNEL32.532)
+ */
+LPVOID TlsGetValue( DWORD index )
+{
+ THDB *thread = (THDB *)GetCurrentThreadId();
+ if (index >= 64)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return NULL;
+ }
+ SetLastError( ERROR_SUCCESS );
+ return thread->tls_array[index];
+}
+
+
+/**********************************************************************
+ * TlsSetValue (KERNEL32.533)
+ */
+BOOL32 TlsSetValue( DWORD index, LPVOID value )
+{
+ THDB *thread = (THDB *)GetCurrentThreadId();
+ if (index >= 64)
+ {
+ SetLastError( ERROR_INVALID_PARAMETER );
+ return FALSE;
+ }
+ thread->tls_array[index] = value;
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * GetThreadContext (KERNEL32.294)
+ */
+BOOL32 GetThreadContext( HANDLE32 handle, CONTEXT *context )
+{
+ return FALSE;
+}
+
+
+/**********************************************************************
+ * NtCurrentTeb (NTDLL.89)
+ */
+void NtCurrentTeb( CONTEXT *context )
+{
+ EAX_reg(context) = GetSelectorBase( FS_reg(context) );
+}
diff --git a/tools/build.c b/tools/build.c
index bcb2697..95812d9 100644
--- a/tools/build.c
+++ b/tools/build.c
@@ -11,12 +11,12 @@
#include <string.h>
#include <ctype.h>
#include <unistd.h>
-#include "wintypes.h"
-#include "registers.h"
+#include "windows.h"
+#include "winnt.h"
#include "winerror.h" /* for ERROR_CALL_NOT_IMPLEMENTED */
#include "module.h"
#include "neexe.h"
-#include "windows.h"
+#include "selectors.h"
#ifdef NEED_UNDERSCORE_PREFIX
# define PREFIX "_"
@@ -132,10 +132,6 @@
static int debugging = 1;
- /* Offset of register relative to the end of the SIGCONTEXT struct */
-#define SIGCONTEXTOFFSET(reg) \
- ((int)®##_reg((SIGCONTEXT *)0) - sizeof(SIGCONTEXT))
-
/* Offset of register relative to the start of the CONTEXT struct */
#define CONTEXTOFFSET(reg) ((int)&((CONTEXT *)0)->reg)
@@ -1433,8 +1429,6 @@
* BuildContext16
*
* Build the context structure on the 32-bit stack.
- * The only valid registers in the context structure are:
- * eax, ebx, ecx, edx, esi, edi, ds, es, (some of the) flags
*/
static void BuildContext16( FILE *outfile )
{
@@ -1448,18 +1442,46 @@
/* Store the registers */
- fprintf( outfile, "\tpopl %d(%%ebx)\n", SIGCONTEXTOFFSET(EBX) ); /* Get ebx from stack*/
- fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n", SIGCONTEXTOFFSET(EAX) );
- fprintf( outfile, "\tmovl %%ecx,%d(%%ebx)\n", SIGCONTEXTOFFSET(ECX) );
- fprintf( outfile, "\tmovl %%edx,%d(%%ebx)\n", SIGCONTEXTOFFSET(EDX) );
- fprintf( outfile, "\tmovl %%esi,%d(%%ebx)\n", SIGCONTEXTOFFSET(ESI) );
- fprintf( outfile, "\tmovl %%edi,%d(%%ebx)\n", SIGCONTEXTOFFSET(EDI) );
- fprintf( outfile, "\tmovw -10(%%ebp),%%ax\n" ); /*Get saved ds from stack*/
- fprintf( outfile, "\tmovw %%ax,%d(%%ebx)\n", SIGCONTEXTOFFSET(DS) );
- fprintf( outfile, "\tmovw -6(%%ebp),%%ax\n" ); /*Get saved es from stack*/
- fprintf( outfile, "\tmovw %%ax,%d(%%ebx)\n", SIGCONTEXTOFFSET(ES) );
+ fprintf( outfile, "\tpopl %d(%%ebx)\n", /* Get ebx from stack*/
+ CONTEXTOFFSET(Ebx) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n",
+ CONTEXTOFFSET(Eax) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%ecx,%d(%%ebx)\n",
+ CONTEXTOFFSET(Ecx) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%edx,%d(%%ebx)\n",
+ CONTEXTOFFSET(Edx) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%esi,%d(%%ebx)\n",
+ CONTEXTOFFSET(Esi) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%edi,%d(%%ebx)\n",
+ CONTEXTOFFSET(Edi) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovzwl -10(%%ebp),%%eax\n" ); /* Get %ds from stack*/
+ fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n",
+ CONTEXTOFFSET(SegDs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovzwl -6(%%ebp),%%eax\n" ); /* Get %es from stack*/
+ fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n",
+ CONTEXTOFFSET(SegEs) - sizeof(CONTEXT) );
fprintf( outfile, "\tpushfl\n" );
- fprintf( outfile, "\tpopl %d(%%ebx)\n", SIGCONTEXTOFFSET(EFL) );
+ fprintf( outfile, "\tpopl %d(%%ebx)\n",
+ CONTEXTOFFSET(EFlags) - sizeof(CONTEXT) );
+#if 0
+ fprintf( outfile, "\tmovzwl 0(%%ebp),%%eax\n" ); /* Get %bp from stack */
+ fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n",
+ CONTEXTOFFSET(Ebp) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovzwl 2(%%ebp),%%eax\n" ); /* Get %ip from stack */
+ fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n",
+ CONTEXTOFFSET(Eip) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovzwl 4(%%ebp),%%eax\n" ); /* Get %cs from stack */
+ fprintf( outfile, "\tmovl %%eax,%d(%%ebx)\n",
+ CONTEXTOFFSET(SegCs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%fs,%d(%%ebx)\n",
+ CONTEXTOFFSET(SegFs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%gs,%d(%%ebx)\n",
+ CONTEXTOFFSET(SegGs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %%ss,%d(%%ebx)\n",
+ CONTEXTOFFSET(SegSs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tfsave %d(%%ebx)\n",
+ CONTEXTOFFSET(FloatSave) - sizeof(CONTEXT) );
+#endif
}
@@ -1476,18 +1498,27 @@
/* Restore the registers */
- fprintf( outfile, "\tmovl %d(%%ebx),%%ecx\n", SIGCONTEXTOFFSET(ECX) );
- fprintf( outfile, "\tmovl %d(%%ebx),%%edx\n", SIGCONTEXTOFFSET(EDX) );
- fprintf( outfile, "\tmovl %d(%%ebx),%%esi\n", SIGCONTEXTOFFSET(ESI) );
- fprintf( outfile, "\tmovl %d(%%ebx),%%edi\n", SIGCONTEXTOFFSET(EDI) );
+ fprintf( outfile, "\tmovl %d(%%ebx),%%ecx\n",
+ CONTEXTOFFSET(Ecx) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %d(%%ebx),%%edx\n",
+ CONTEXTOFFSET(Edx) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %d(%%ebx),%%esi\n",
+ CONTEXTOFFSET(Esi) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %d(%%ebx),%%edi\n",
+ CONTEXTOFFSET(Edi) - sizeof(CONTEXT) );
fprintf( outfile, "\tpopl %%eax\n" ); /* Remove old ds and ip from stack */
fprintf( outfile, "\tpopl %%eax\n" ); /* Remove old cs and es from stack */
- fprintf( outfile, "\tpushw %d(%%ebx)\n", SIGCONTEXTOFFSET(DS) ); /* Push new ds */
- fprintf( outfile, "\tpushw %d(%%ebx)\n", SIGCONTEXTOFFSET(ES) ); /*Push new es */
- fprintf( outfile, "\tpushl %d(%%ebx)\n", SIGCONTEXTOFFSET(EFL) );
+ fprintf( outfile, "\tpushw %d(%%ebx)\n", /* Push new ds */
+ CONTEXTOFFSET(SegDs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tpushw %d(%%ebx)\n", /* Push new es */
+ CONTEXTOFFSET(SegEs) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tpushl %d(%%ebx)\n",
+ CONTEXTOFFSET(EFlags) - sizeof(CONTEXT) );
fprintf( outfile, "\tpopfl\n" );
- fprintf( outfile, "\tmovl %d(%%ebx),%%eax\n", SIGCONTEXTOFFSET(EAX) );
- fprintf( outfile, "\tmovl %d(%%ebx),%%ebx\n", SIGCONTEXTOFFSET(EBX) );
+ fprintf( outfile, "\tmovl %d(%%ebx),%%eax\n",
+ CONTEXTOFFSET(Eax) - sizeof(CONTEXT) );
+ fprintf( outfile, "\tmovl %d(%%ebx),%%ebx\n",
+ CONTEXTOFFSET(Ebx) - sizeof(CONTEXT) );
}
@@ -1588,7 +1619,7 @@
fprintf( outfile, "\tpushw %%ds\n" );
fprintf( outfile, "\tpopw %%ss\n" );
fprintf( outfile, "\tleal -%d(%%ebp),%%esp\n",
- reg_func ? sizeof(SIGCONTEXT) : 4 * strlen(args) );
+ reg_func ? sizeof(CONTEXT) : 4 * strlen(args) );
if (reg_func) /* Push the address of the context struct */
fprintf( outfile, "\tpushl %%esp\n" );
@@ -2101,6 +2132,8 @@
/* Call the function */
+ fprintf( outfile, "\tpushw %%ds\n" );
+ fprintf( outfile, "\tpopw %%es\n" ); /* Set %es = %ds */
fprintf( outfile, "\tcall -4(%%ebp)\n" );
/* Print the debugging info */
diff --git a/win32/Makefile.in b/win32/Makefile.in
index e0c8162..e09e8ea 100644
--- a/win32/Makefile.in
+++ b/win32/Makefile.in
@@ -14,11 +14,10 @@
error.c \
except.c \
file.c \
- findfile.c \
init.c \
+ k32obj.c \
memory.c \
newfns.c \
- object_mgt.c \
process.c \
string32.c \
struct32.c \
diff --git a/win32/advapi.c b/win32/advapi.c
index 6ac2101..31a92d2 100644
--- a/win32/advapi.c
+++ b/win32/advapi.c
@@ -11,7 +11,6 @@
#include "advapi32.h"
#include "stddebug.h"
#include "debug.h"
-#include "xmalloc.h"
/***********************************************************************
* StartServiceCtrlDispatcherA [ADVAPI32.196]
diff --git a/win32/code_page.c b/win32/code_page.c
index da1d7e0..463505f 100644
--- a/win32/code_page.c
+++ b/win32/code_page.c
@@ -25,11 +25,36 @@
/***********************************************************************
* GetCPInfo (KERNEL32.154)
*/
-BOOL GetCPInfo(UINT codepage, LPCPINFO cpinfo)
+BOOL32 GetCPInfo( UINT32 codepage, LPCPINFO cpinfo )
{
- cpinfo->MaxCharSize = 1;
cpinfo->DefaultChar[0] = '?';
-
+ switch (codepage)
+ {
+ case 932 : /* Shift JIS (japan) */
+ cpinfo->MaxCharSize = 2;
+ cpinfo->LeadByte[0]= 0x81; cpinfo->LeadByte[1] = 0x9F;
+ cpinfo->LeadByte[2]= 0xE0; cpinfo->LeadByte[3] = 0xFC;
+ cpinfo->LeadByte[4]= 0x00; cpinfo->LeadByte[5] = 0x00;
+ break;
+ case 936 : /* GB2312 (Chinese) */
+ case 949 : /* KSC5601-1987 (Korean) */
+ case 950 : /* BIG5 (Chinese) */
+ cpinfo->MaxCharSize = 2;
+ cpinfo->LeadByte[0]= 0x81; cpinfo->LeadByte[1] = 0xFE;
+ cpinfo->LeadByte[2]= 0x00; cpinfo->LeadByte[3] = 0x00;
+ break;
+ case 1361 : /* Johab (Korean) */
+ cpinfo->MaxCharSize = 2;
+ cpinfo->LeadByte[0]= 0x84; cpinfo->LeadByte[1] = 0xD3;
+ cpinfo->LeadByte[2]= 0xD8; cpinfo->LeadByte[3] = 0xDE;
+ cpinfo->LeadByte[4]= 0xE0; cpinfo->LeadByte[5] = 0xF9;
+ cpinfo->LeadByte[6]= 0x00; cpinfo->LeadByte[7] = 0x00;
+ break;
+ default :
+ cpinfo->MaxCharSize = 1;
+ cpinfo->LeadByte[0]= 0x00; cpinfo->LeadByte[1] = 0x00;
+ break;
+ }
return 1;
}
@@ -86,6 +111,29 @@
return count;
}
+
+BOOL32 IsDBCSLeadByteEx(UINT32 codepage, BYTE testchar)
+{
+ CPINFO cpinfo;
+ int i;
+
+ GetCPInfo(codepage, &cpinfo);
+ for (i = 0 ; i < sizeof(cpinfo.LeadByte)/sizeof(cpinfo.LeadByte[0]); i+=2)
+ {
+ if (cpinfo.LeadByte[i] == 0)
+ return FALSE;
+ if (cpinfo.LeadByte[i] <= testchar && testchar <= cpinfo.LeadByte[i+1])
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL32 IsDBCSLeadByte(BYTE testchar)
+{
+ return IsDBCSLeadByteEx(GetACP(), testchar);
+}
+
+
/***********************************************************************
* EnumSystemCodePages32A (KERNEL32.92)
*/
diff --git a/win32/error.c b/win32/error.c
index 5e8bdb8..44e86f7 100644
--- a/win32/error.c
+++ b/win32/error.c
@@ -11,12 +11,6 @@
#include "stddebug.h"
#include "debug.h"
-/* WIN32_LastError contains the last error that occurred in the
- * Win32 API. This value should be stored separately for each
- * thread, when we eventually get thread support.
- */
-static int WIN32_LastError;
-
/* The errno_xlat_table contains the errno-to-Win32 error
* mapping. Since this is a single table, it can't easily
* take into account function-specific differences, so there
@@ -98,32 +92,6 @@
{ -1, 0 }
};
-/**********************************************************************
- * GetLastError (KERNEL.148) (KERNEL32.227)
- */
-DWORD GetLastError(void)
-{
- return WIN32_LastError;
-}
-
-/**********************************************************************
- * SetLastError (KERNEL.147) (KERNEL32.497)
- *
- * This is probably not used by apps too much, but it's useful for
- * our own internal use.
- */
-void SetLastError(DWORD error)
-{
- WIN32_LastError = error;
-}
-
-/**********************************************************************
- * SetLastErrorEx (USER32.484)
- */
-void SetLastErrorEx(DWORD error,DWORD type) {
- WIN32_LastError = error;
-}
-
DWORD ErrnoToLastError(int errno_num)
{
DWORD rc = ERROR_UNKNOWN;
diff --git a/win32/file.c b/win32/file.c
index 7b9ec58..165be9a 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -6,6 +6,7 @@
#include <errno.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -33,6 +34,12 @@
#define MAP_ANON 0
#endif
+typedef struct {
+ HFILE32 hfile;
+ int prot;
+ unsigned long size;
+} FILEMAP_OBJECT;
+
/***********************************************************************
* OpenFileMappingA (KERNEL32.397)
* FIXME: stub
@@ -57,17 +64,16 @@
);
if (sh) {
SetLastError(ErrnoToLastError(errno));
- return INVALID_HANDLE_VALUE;
+ return INVALID_HANDLE_VALUE32;
}
filemap_obj=(FILEMAP_OBJECT *)CreateKernelObject(sizeof(FILEMAP_OBJECT));
if(filemap_obj == NULL) {
SetLastError(ERROR_UNKNOWN);
return 0;
}
- if (h==INVALID_HANDLE_VALUE)
- h=_lcreat(lpName,1);/*FIXME*/
+ if (h==INVALID_HANDLE_VALUE32)
+ h=_lcreat32(lpName,1);/*FIXME*/
- filemap_obj->common.magic = KERNEL_OBJECT_FILEMAP;
filemap_obj->hfile = h;
filemap_obj->prot = TranslateProtectionFlags(pot);
filemap_obj->size = hlow;
@@ -125,75 +131,14 @@
/***********************************************************************
- * GetFileInformationByHandle (KERNEL32.219)
- */
-DWORD GetFileInformationByHandle(HFILE hFile,BY_HANDLE_FILE_INFORMATION *lpfi)
-{
- struct stat file_stat;
- int rc;
- int unixfd = FILE_GetUnixHandle(hFile);
-
- if (unixfd==-1)
- return 0;
- rc = fstat(unixfd,&file_stat);
- if(rc == -1) {
- SetLastError(ErrnoToLastError(errno));
- return 0;
- }
-
- /* Translate the file attributes.
- */
- lpfi->dwFileAttributes = 0;
- if(file_stat.st_mode & S_IFREG)
- lpfi->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL;
- if(file_stat.st_mode & S_IFDIR)
- lpfi->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
- if((file_stat.st_mode & S_IWRITE) == 0)
- lpfi->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
-
- /* Translate the file times. Use the last modification time
- * for both the creation time and write time.
- */
- DOSFS_UnixTimeToFileTime(file_stat.st_mtime, &(lpfi->ftCreationTime));
- DOSFS_UnixTimeToFileTime(file_stat.st_mtime, &(lpfi->ftLastWriteTime));
- DOSFS_UnixTimeToFileTime(file_stat.st_atime, &(lpfi->ftLastAccessTime));
-
- lpfi->nFileSizeLow = file_stat.st_size;
- lpfi->nNumberOfLinks = file_stat.st_nlink;
- lpfi->nFileIndexLow = file_stat.st_ino;
-
- /* Zero out currently unused fields.
- */
- lpfi->dwVolumeSerialNumber = 0;
- lpfi->nFileSizeHigh = 0;
- lpfi->nFileIndexHigh = 0;
-
- return 1;
-}
-
-/***********************************************************************
- * GetFileSize (KERNEL32.220)
- */
-DWORD GetFileSize(HFILE hf,LPDWORD filesizehigh) {
- BY_HANDLE_FILE_INFORMATION fi;
- DWORD res = GetFileInformationByHandle(hf,&fi);
-
- if (!res)
- return 0; /* FIXME: correct ? */
- if (filesizehigh)
- *filesizehigh = fi.nFileSizeHigh;
- return fi.nFileSizeLow;
-}
-
-/***********************************************************************
* GetStdHandle (KERNEL32.276)
* FIXME: We should probably allocate filehandles for stdin/stdout/stderr
* at task creation (with HFILE-handle 0,1,2 respectively) and
* return them here. Or at least look, if we created them already.
*/
-HFILE GetStdHandle(DWORD nStdHandle)
+HFILE32 GetStdHandle(DWORD nStdHandle)
{
- HFILE hfile;
+ HFILE32 hfile;
int unixfd;
switch(nStdHandle)
@@ -211,11 +156,11 @@
break;
default:
SetLastError(ERROR_INVALID_HANDLE);
- return HFILE_ERROR;
+ return HFILE_ERROR32;
}
hfile = FILE_DupUnixHandle(unixfd);
- if (hfile == HFILE_ERROR)
- return HFILE_ERROR;
+ if (hfile == HFILE_ERROR32)
+ return HFILE_ERROR32;
FILE_SetFileType( hfile, FILE_TYPE_CHAR );
return hfile;
}
@@ -227,7 +172,7 @@
* Luckily enough, this function maps almost directly into an lseek
* call, the exception being the use of 64-bit offsets.
*/
-DWORD SetFilePointer(HFILE hFile, LONG distance, LONG *highword,
+DWORD SetFilePointer(HFILE32 hFile, LONG distance, LONG *highword,
DWORD method)
{
LONG rc;
@@ -240,7 +185,7 @@
}
}
- rc = _llseek(hFile, distance, method);
+ rc = _llseek32(hFile, distance, method);
if(rc == -1)
SetLastError(ErrnoToLastError(errno));
return rc;
@@ -249,7 +194,7 @@
/***********************************************************************
* WriteFile (KERNEL32.578)
*/
-BOOL32 WriteFile(HFILE hFile, LPVOID lpBuffer, DWORD numberOfBytesToWrite,
+BOOL32 WriteFile(HFILE32 hFile, LPVOID lpBuffer, DWORD numberOfBytesToWrite,
LPDWORD numberOfBytesWritten, LPOVERLAPPED lpOverlapped)
{
LONG res;
@@ -267,7 +212,7 @@
/***********************************************************************
* ReadFile (KERNEL32.428)
*/
-BOOL32 ReadFile(HFILE hFile, LPVOID lpBuffer, DWORD numtoread,
+BOOL32 ReadFile(HFILE32 hFile, LPVOID lpBuffer, DWORD numtoread,
LPDWORD numread, LPOVERLAPPED lpOverlapped)
{
int actual_read;
@@ -290,9 +235,9 @@
* Doesn't support character devices, pipes, template files, or a
* lot of the 'attributes' flags yet.
*/
-HFILE CreateFile32A(LPCSTR filename, DWORD access, DWORD sharing,
- LPSECURITY_ATTRIBUTES security, DWORD creation,
- DWORD attributes, HANDLE32 template)
+HFILE32 CreateFile32A(LPCSTR filename, DWORD access, DWORD sharing,
+ LPSECURITY_ATTRIBUTES security, DWORD creation,
+ DWORD attributes, HANDLE32 template)
{
int access_flags, create_flags;
@@ -315,7 +260,7 @@
{
dprintf_file(stddeb, "CreateFile: UNC names not supported.\n");
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return HFILE_ERROR;
+ return HFILE_ERROR32;
}
/* If the name is either CONIN$ or CONOUT$, give them stdin
@@ -331,33 +276,17 @@
/*************************************************************************
* CreateFile32W (KERNEL32.48)
*/
-HFILE CreateFile32W(LPCWSTR filename, DWORD access, DWORD sharing,
- LPSECURITY_ATTRIBUTES security, DWORD creation,
- DWORD attributes, HANDLE32 template)
+HFILE32 CreateFile32W(LPCWSTR filename, DWORD access, DWORD sharing,
+ LPSECURITY_ATTRIBUTES security, DWORD creation,
+ DWORD attributes, HANDLE32 template)
{
LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
- HFILE res = CreateFile32A( afn, access, sharing, security, creation,
- attributes, template );
+ HFILE32 res = CreateFile32A( afn, access, sharing, security, creation,
+ attributes, template );
HeapFree( GetProcessHeap(), 0, afn );
return res;
}
-/*************************************************************************
- * SetHandleCount32 (KERNEL32.494)
- */
-UINT32 SetHandleCount32( UINT32 cHandles )
-{
- return SetHandleCount16(cHandles);
-}
-
-
-int CloseFileHandle(HFILE hFile)
-{
- if (!_lclose(hFile))
- return TRUE;
- return FALSE;
-}
-
static int TranslateAccessFlags(DWORD access_flags)
{
int rc = 0;
@@ -412,39 +341,11 @@
/**************************************************************************
- * GetFileAttributes32A (KERNEL32.217)
+ * SetFileAttributes16 (KERNEL.421)
*/
-DWORD GetFileAttributes32A(LPCSTR lpFileName)
+BOOL16 SetFileAttributes16( LPCSTR lpFileName, DWORD attributes )
{
- struct stat buf;
- DWORD res=0;
- char *fn;
-
- dprintf_file(stddeb,"GetFileAttributesA(%s)\n",lpFileName);
- fn=(LPSTR)DOSFS_GetUnixFileName(lpFileName,FALSE);
- /* fn points to a static buffer, don't free it */
- if(stat(fn,&buf)==-1) {
- SetLastError(ErrnoToLastError(errno));
- return 0xFFFFFFFF;
- }
- if(buf.st_mode & S_IFREG)
- res |= FILE_ATTRIBUTE_NORMAL;
- if(buf.st_mode & S_IFDIR)
- res |= FILE_ATTRIBUTE_DIRECTORY;
- if((buf.st_mode & S_IWRITE) == 0)
- res |= FILE_ATTRIBUTE_READONLY;
- return res;
-}
-
-/**************************************************************************
- * GetFileAttributes32W (KERNEL32.218)
- */
-DWORD GetFileAttributes32W(LPCWSTR lpFileName)
-{
- LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
- DWORD res = GetFileAttributes32A( afn );
- HeapFree( GetProcessHeap(), 0, afn );
- return res;
+ return SetFileAttributes32A( lpFileName, attributes );
}
@@ -487,24 +388,6 @@
}
/**************************************************************************
- * SetEndOfFile (KERNEL32.483)
- */
-BOOL32 SetEndOfFile(HFILE hFile)
-{
- int unixfd = FILE_GetUnixHandle(hFile);
-
- dprintf_file(stddeb,"SetEndOfFile(%lx)\n",(LONG)hFile);
- if (!unixfd)
- return 0;
- if (-1==ftruncate(unixfd,lseek(unixfd,0,SEEK_CUR))) {
- SetLastError(ErrnoToLastError(errno));
- return FALSE;
- }
- return TRUE;
-}
-
-
-/**************************************************************************
* MoveFileA (KERNEL32.387)
*/
BOOL32 MoveFile32A(LPCSTR fn1,LPCSTR fn2)
@@ -569,40 +452,38 @@
BOOL32 CopyFile32A(LPCSTR sourcefn,LPCSTR destfn,BOOL32 failifexists)
{
OFSTRUCT of;
- HFILE hf1,hf2;
+ HFILE32 hf1,hf2;
char buffer[2048];
int lastread,curlen;
fprintf(stddeb,"CopyFile: %s -> %s\n",sourcefn,destfn);
- hf1 = OpenFile(sourcefn,&of,OF_READ);
- if (hf1==HFILE_ERROR)
- return TRUE;
- if (failifexists) {
- hf2 = OpenFile(sourcefn,&of,OF_WRITE);
- if (hf2 != HFILE_ERROR)
- return FALSE;
- _lclose(hf2);
+ hf1 = OpenFile32(sourcefn,&of,OF_READ);
+ if (hf1==HFILE_ERROR32) return TRUE;
+ if (failifexists)
+ {
+ hf2 = OpenFile32(sourcefn,&of,OF_WRITE);
+ if (hf2 != HFILE_ERROR32) return FALSE;
+ _lclose32(hf2);
}
- hf2 = OpenFile(sourcefn,&of,OF_WRITE);
- if (hf2 == HFILE_ERROR)
- return FALSE;
+ hf2 = OpenFile32(sourcefn,&of,OF_WRITE);
+ if (hf2 == HFILE_ERROR32) return FALSE;
curlen = 0;
- while ((lastread=_lread16(hf1,buffer,sizeof(buffer)))>0) {
+ while ((lastread=_lread32(hf1,buffer,sizeof(buffer)))>0) {
curlen=0;
while (curlen<lastread) {
- int res = _lwrite16(hf2,buffer+curlen,lastread-curlen);
+ int res = _lwrite32(hf2,buffer+curlen,lastread-curlen);
if (res<=0) break;
curlen+=res;
}
}
- _lclose(hf1);
- _lclose(hf2);
+ _lclose32(hf1);
+ _lclose32(hf2);
return curlen > 0;
}
BOOL32
LockFile(
- HFILE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh,
+ HFILE32 hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToLockLow,DWORD nNumberOfBytesToLockHigh )
{
fprintf(stdnimp,"LockFile(%d,0x%08lx%08lx,0x%08lx%08lx),stub!\n",
@@ -614,7 +495,7 @@
BOOL32
UnlockFile(
- HFILE hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh,
+ HFILE32 hFile,DWORD dwFileOffsetLow,DWORD dwFileOffsetHigh,
DWORD nNumberOfBytesToUnlockLow,DWORD nNumberOfBytesToUnlockHigh )
{
fprintf(stdnimp,"UnlockFile(%d,0x%08lx%08lx,0x%08lx%08lx),stub!\n",
diff --git a/win32/findfile.c b/win32/findfile.c
deleted file mode 100644
index 799e5e1..0000000
--- a/win32/findfile.c
+++ /dev/null
@@ -1,389 +0,0 @@
-#include <sys/types.h>
-#include <dirent.h>
-#include <string.h>
-#include <ctype.h>
-#include <malloc.h>
-#include <errno.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include "xmalloc.h"
-#include "windows.h"
-#include "winerror.h"
-#include "dos_fs.h"
-#include "heap.h"
-#include "drive.h"
-#include "stddebug.h"
-#include "debug.h"
-
-
-
-#define PATH_LEN 260
-
-struct FindFileContext32 {
- DIR * dir;
- char mask[PATH_LEN];
- char path[PATH_LEN];
- char unixpath[PATH_LEN];
-};
-
-typedef struct FindFileContext32 FindFileContext32;
-
-const char *DOSFS_Hash(const char *, int, int);
-
-/* TODO/FIXME
- * 1) Check volume information to see if long file names supported
- * and do separate wildcard matching if so. Win95 has extended wildcard
- * matching - It can have wildcards like '*foo*'. These can match both
- * the long file name and the short file name.
- * 2) These file functions may be called from an interrupt
- * Interrupt 21h Function 714Eh FindFirstFile
- * Interrupt 21h Function 714Fh FindNextFile
- * Interrupt 21h Function 71A1h FindClose
- */
-
-static BOOL32 MatchWildCard(LPCSTR file, LPCSTR mask)
-{
- int len;
-
- len = strlen(file);
-
- if (strcmp(mask, "*.*") == 0)
- return TRUE;
-
- while (*file) {
- if (*mask == '*') {
- if (*(mask+1)) {
- while (*file && (toupper(*file) != *(mask+1))) file++;
- if (!*file)
- return FALSE;
- }
- else
- break;
- }
- else {
- if (*mask != '?' && *mask != toupper(*file)) {
- return FALSE;
- }
- file++;
- }
- mask++;
- }
- return (TRUE);
-}
-
-/* Functionality is same as GetFileInformationByHandle, but the structures
- * it fills out are different. This needs to be kept the same as the above
- * mentioned function.
- */
-
-
-static BOOL32 FINDFILE_GetFileInfo(const char *filename,
- LPWIN32_FIND_DATA32A finfo)
-{
- struct stat file_stat;
-
- if (stat(filename, &file_stat) == -1) {
- SetLastError(ErrnoToLastError(errno));
- return FALSE;
- }
- finfo->dwFileAttributes = 0;
- if (file_stat.st_mode & S_IFREG)
- finfo->dwFileAttributes |= FILE_ATTRIBUTE_NORMAL;
- if (file_stat.st_mode & S_IFDIR)
- finfo->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
- if ((file_stat.st_mode & S_IRUSR) == 0)
- finfo->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
-
- /* Translate the file times. Use the last modification time
- * for both the creation time and write time.
- */
- DOSFS_UnixTimeToFileTime(file_stat.st_mtime, &(finfo->ftCreationTime));
- DOSFS_UnixTimeToFileTime(file_stat.st_mtime, &(finfo->ftLastWriteTime));
- DOSFS_UnixTimeToFileTime(file_stat.st_atime, &(finfo->ftLastAccessTime));
-
- finfo->nFileSizeLow = file_stat.st_size;
-
- /* Zero out currently unused fields.
- */
- finfo->nFileSizeHigh = 0;
- finfo->dwReserved0 = 0;
- finfo->dwReserved1 = 0;
- return TRUE;
-
-}
-
-
-/*************************************************************************
- * FindNextFile32A (KERNEL32.126)
- */
-BOOL32 FindNextFile32A(HANDLE32 handle, LPWIN32_FIND_DATA32A data)
-{
- FindFileContext32 *context;
- struct dirent *dirent;
- char dosname[14];
- char fullfilename[PATH_LEN];
-
- memset(data, 0, sizeof(WIN32_FIND_DATA32A));
- context = (FindFileContext32 *) handle;
-
- while ((dirent = readdir(context->dir)) != NULL) {
- if (strcmp(dirent->d_name, "..") == 0 ||
- strcmp(dirent->d_name, ".") == 0)
- continue;
-
- lstrcpy32A(dosname, DOSFS_Hash(dirent->d_name, FALSE, FALSE));
-
- if (MatchWildCard(dirent->d_name, context->mask)) {
- /* fill in file information */
- lstrcpy32A(fullfilename, context->unixpath);
- if (context->unixpath[strlen(context->unixpath)-1] != '/')
- strcat(fullfilename, "/");
- strcat(fullfilename, dirent->d_name);
- FINDFILE_GetFileInfo(fullfilename, data);
-
- /* long file name */
- lstrcpy32A(data->cFileName, dirent->d_name);
-
- /* file name expressed in 8.3 format */
- lstrcpy32A(data->cAlternateFileName, dosname);
-
- dprintf_file(stddeb, "FindNextFile32A: %s (%s)\n",
- data->cFileName, data->cAlternateFileName);
- return (TRUE);
- }
- }
-
- return (FALSE);
-}
-
-/*************************************************************************
- * FindNextFile32W (KERNEL32.127)
- */
-BOOL32 FindNextFile32W(HANDLE32 handle, LPWIN32_FIND_DATA32W data)
-{
- WIN32_FIND_DATA32A adata;
- BOOL32 res;
-
- adata.dwFileAttributes = data->dwFileAttributes;
- adata.ftCreationTime = data->ftCreationTime;
- adata.ftLastAccessTime = data->ftLastAccessTime;
- adata.ftLastWriteTime = data->ftLastWriteTime;
- adata.nFileSizeHigh = data->nFileSizeHigh;
- adata.nFileSizeLow = data->nFileSizeLow;
- adata.dwReserved0 = data->dwReserved0;
- adata.dwReserved1 = data->dwReserved1;
- lstrcpyWtoA(adata.cFileName,data->cFileName);
- lstrcpyWtoA(adata.cAlternateFileName,data->cAlternateFileName);
- res=FindNextFile32A(handle,&adata);
- if (res) {
- data->dwFileAttributes = adata.dwFileAttributes;
- data->ftCreationTime = adata.ftCreationTime;
- data->ftLastAccessTime = adata.ftLastAccessTime;
- data->ftLastWriteTime = adata.ftLastWriteTime;
- data->nFileSizeHigh = adata.nFileSizeHigh;
- data->nFileSizeLow = adata.nFileSizeLow;
- data->dwReserved0 = adata.dwReserved0;
- data->dwReserved1 = adata.dwReserved1;
- lstrcpyAtoW(data->cFileName,adata.cFileName);
- lstrcpyAtoW(data->cAlternateFileName,adata.cAlternateFileName);
- }
- return res;
-}
-
-/*************************************************************************
- * FindFirstFile32A (KERNEL32.123)
- */
-
-HANDLE32 FindFirstFile32A(LPCSTR lpfilename_in,
- LPWIN32_FIND_DATA32A lpFindFileData)
-{
- const char *unixpath;
- char *slash, *p;
- FindFileContext32 *context;
- char lpfilename[PATH_LEN];
- INT32 len;
-
- context = HeapAlloc(SystemHeap, 0, sizeof(FindFileContext32));
- if (!context)
- return (INVALID_HANDLE_VALUE);
-
- /* These type of cases
- * A;\*.*
- * A;stuff\*.*
- * *.*
- * \stuff\*.*
- */
- lstrcpy32A(lpfilename, lpfilename_in);
- if (lpfilename[1] != ':' &&
- lpfilename[0] != '\\') {
- /* drive and root path are not set */
- len = GetCurrentDirectory32A(PATH_LEN, lpfilename);
- if (lpfilename[len-1] != '\\')
- strcat(lpfilename, "\\");
- strcat(lpfilename, lpfilename_in);
- }
- else if (lpfilename[1] != ':') {
- /* drive not set, but path is rooted */
- memmove(&lpfilename[2], lpfilename, strlen(lpfilename));
- lpfilename[0] = DRIVE_GetCurrentDrive();
- lpfilename[1] = ':';
- }
- else if (lpfilename[1] == ':' &&
- lpfilename[2] != '\\') {
- /* drive is set, but not root path */
- lstrcpy32A(lpfilename, DRIVE_GetDosCwd(lpfilename[0]));
- strcat(lpfilename, lpfilename_in);
- }
-
- dprintf_file(stddeb, "FindFirstFile32A: %s -> %s .\n",
- lpfilename_in, lpfilename);
-
- slash = strrchr(lpfilename, '\\');
-
- if (slash) {
- lstrcpyn32A(context->path, lpfilename, slash - lpfilename + 1);
- context->path[slash - lpfilename + 1] = '\0';
- unixpath = DOSFS_GetUnixFileName(context->path, FALSE);
- if (!unixpath) {
- /* FIXME: SetLastError(??) */
- HeapFree(SystemHeap, 0, context);
- return INVALID_HANDLE_VALUE;
- }
- lstrcpy32A(context->mask, slash+1);
- }
- else {
- /* shouldn't really get here now */
- context->path[0] = '\0';
- unixpath = ".";
- lstrcpy32A(context->mask, lpfilename);
- }
-
- lstrcpy32A(context->unixpath, unixpath);
- context->dir = opendir(unixpath);
- if (!context->dir) {
- /* FIXME: SetLastError(??) */
- HeapFree(SystemHeap, 0, context);
- return INVALID_HANDLE_VALUE;
- }
-
- /* uppercase mask in place */
- for (p = context->mask ; *p; p++)
- *p = toupper(*p);
-
- if (!FindNextFile32A((HANDLE32) context, lpFindFileData))
- return (INVALID_HANDLE_VALUE);
- return ((HANDLE32) context);
-}
-
-/*************************************************************************
- * FindFirstFile32W (KERNEL32.124)
- */
-HANDLE32 FindFirstFile32W(LPCWSTR filename,LPWIN32_FIND_DATA32W data)
-{
- WIN32_FIND_DATA32A adata;
- LPSTR afn = HEAP_strdupWtoA( GetProcessHeap(), 0, filename );
- HANDLE32 res = FindFirstFile32A(afn,&adata);
- if (res)
- {
- data->dwFileAttributes = adata.dwFileAttributes;
- data->ftCreationTime = adata.ftCreationTime;
- data->ftLastAccessTime = adata.ftLastAccessTime;
- data->ftLastWriteTime = adata.ftLastWriteTime;
- data->nFileSizeHigh = adata.nFileSizeHigh;
- data->nFileSizeLow = adata.nFileSizeLow;
- data->dwReserved0 = adata.dwReserved0;
- data->dwReserved1 = adata.dwReserved1;
- lstrcpyAtoW(data->cFileName,adata.cFileName);
- lstrcpyAtoW(data->cAlternateFileName,adata.cAlternateFileName);
- }
- HeapFree( GetProcessHeap(), 0, afn );
- return res;
-}
-
-/*************************************************************************
- * FindClose32 (KERNEL32.119)
- */
-BOOL32 FindClose32(HANDLE32 handle)
-{
- FindFileContext32 *context;
-
- /* Windows95 ignores an invalid handle. */
- if (handle == INVALID_HANDLE_VALUE)
- {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
- context = (FindFileContext32 *) handle;
- if (context->dir)
- closedir(context->dir);
- HeapFree(SystemHeap, 0, context);
- return (TRUE);
-}
-
-/* 16 bit versions of find functions */
-/*************************************************************************
- * FindFirstFile16 (KERNEL.413)
- */
-
-HANDLE16
-FindFirstFile16(LPCSTR lpFileName, LPVOID lpdata)
-{
- WIN32_FIND_DATA32A *findData = (WIN32_FIND_DATA32A *) lpdata;
- HANDLE32 h32;
- HGLOBAL16 h16;
- HANDLE32 *ptr;
-
- /* get a handle to the real pointer */
-
-
- h32 = FindFirstFile32A(lpFileName, findData);
- if (h32 > 0) {
- h16 = GlobalAlloc16(0, sizeof(h32));
- ptr = GlobalLock16(h16);
- *ptr = h32;
- return (h16);
- }
- else
- return ((HANDLE16) h32);
-}
-
-/*************************************************************************
- * FindNextFile16 (KERNEL.414)
- */
-
-BOOL16
-FindNextFile16(HANDLE16 handle, LPVOID lpdata)
-{
- WIN32_FIND_DATA32A *findData = (WIN32_FIND_DATA32A *) lpdata;
- HANDLE32 *lph32;
-
- lph32 = GlobalLock16(handle);
- if (FindNextFile32A(*lph32, findData)) {
- return TRUE;
- }
- else
- return FALSE;
-}
-
-/*************************************************************************
- * FindClose16 (KERNEL.415)
- */
-
-BOOL16
-FindClose16(HANDLE16 handle)
-{
- HANDLE32 *lph32;
- BOOL16 ret;
-
- if (handle == (HANDLE16) INVALID_HANDLE_VALUE) {
- SetLastError(ERROR_INVALID_HANDLE);
- return FALSE;
- }
-
- lph32 = GlobalLock16(handle);
- ret = FindClose32(*lph32);
- GlobalFree16(handle);
- return (ret);
-}
-
-
diff --git a/win32/init.c b/win32/init.c
index 3eb9ed3..7509da9 100644
--- a/win32/init.c
+++ b/win32/init.c
@@ -21,36 +21,6 @@
*/
int WIN32_LastError;
-/*********************************************************************
- * CloseHandle (KERNEL32.23)
- */
-BOOL CloseHandle(KERNEL_OBJECT *handle)
-{
- if ((int)handle<0x1000) /* FIXME: hack */
- return CloseFileHandle((int)handle);
- if ((int)handle==0xFFFFFFFF)
- return FALSE;
- switch(handle->magic)
- {
- case KERNEL_OBJECT_UNUSED:
- SetLastError(ERROR_INVALID_HANDLE);
- return 0;
-/* FIXME
- case KERNEL_OBJECT_FILE:
- rc = CloseFileHandle((FILE_OBJECT *)handle);
- break;
- */
-
- default:
- dprintf_win32(stddeb, "CloseHandle: type %ld not implemented yet.\n",
- handle->magic);
- break;
- }
-
- ReleaseKernelObject(handle);
- return 0;
-}
-
/***********************************************************************
* GetModuleHandle (KERNEL32.237)
*/
diff --git a/win32/k32obj.c b/win32/k32obj.c
new file mode 100644
index 0000000..93919c3
--- /dev/null
+++ b/win32/k32obj.c
@@ -0,0 +1,62 @@
+/*
+ * KERNEL32 objects
+ *
+ * Copyright 1996 Alexandre Julliard
+ */
+
+#include <assert.h>
+#include "handle32.h"
+#include "heap.h"
+#include "file.h"
+#include "process.h"
+#include "thread.h"
+
+typedef void (*destroy_object)(K32OBJ *);
+
+static const destroy_object K32OBJ_Destroy[K32OBJ_NBOBJECTS] =
+{
+ NULL,
+ NULL, /* K32OBJ_SEMAPHORE */
+ NULL, /* K32OBJ_EVENT */
+ NULL, /* K32OBJ_MUTEX */
+ NULL, /* K32OBJ_CRITICAL_SECTION */
+ PROCESS_Destroy, /* K32OBJ_PROCESS */
+ THREAD_Destroy, /* K32OBJ_THREAD */
+ FILE_Destroy, /* K32OBJ_FILE */
+ NULL, /* K32OBJ_CHANGE */
+ NULL, /* K32OBJ_CONSOLE */
+ NULL, /* K32OBJ_SCREEN_BUFFER */
+ NULL, /* K32OBJ_MEM_MAPPED_FILE */
+ NULL, /* K32OBJ_SERIAL */
+ NULL, /* K32OBJ_DEVICE_IOCTL */
+ NULL, /* K32OBJ_PIPE */
+ NULL, /* K32OBJ_MAILSLOT */
+ NULL, /* K32OBJ_TOOLHELP_SNAPSHOT */
+ NULL /* K32OBJ_SOCKET */
+};
+
+
+/***********************************************************************
+ * K32OBJ_IncCount
+ */
+void K32OBJ_IncCount( K32OBJ *ptr )
+{
+ /* FIXME: not atomic */
+ assert( ptr->type && ((unsigned)ptr->type < K32OBJ_NBOBJECTS) );
+ ptr->refcount++;
+}
+
+
+/***********************************************************************
+ * K32OBJ_DecCount
+ */
+void K32OBJ_DecCount( K32OBJ *ptr )
+{
+ /* FIXME: not atomic */
+ assert( ptr->type && ((unsigned)ptr->type < K32OBJ_NBOBJECTS) );
+ assert( ptr->refcount );
+ if (--ptr->refcount) return;
+ /* Free the object */
+ if (K32OBJ_Destroy[ptr->type]) K32OBJ_Destroy[ptr->type]( ptr );
+}
+
diff --git a/win32/memory.c b/win32/memory.c
index a08b07f..e8d055c 100644
--- a/win32/memory.c
+++ b/win32/memory.c
@@ -28,6 +28,13 @@
long size;
} virtual_mem_t;
+typedef struct _VRANGE_OBJECT
+{
+ DWORD start;
+ DWORD size;
+ struct _VRANGE_OBJECT *next;
+} VRANGE_OBJECT;
+
virtual_mem_t *mem = 0;
int mem_count = 0;
int mem_used = 0;
@@ -132,7 +139,6 @@
VRANGE_OBJECT *MEMORY_AllocVrange(int start,int size)
{
VRANGE_OBJECT *ret=CreateKernelObject(sizeof(VRANGE_OBJECT));
- ret->common.magic=KERNEL_OBJECT_VRANGE;
MEMORY_InsertVrange(ret);
return ret;
}
diff --git a/win32/newfns.c b/win32/newfns.c
index c7fb4c1..4bea247 100644
--- a/win32/newfns.c
+++ b/win32/newfns.c
@@ -13,16 +13,6 @@
#include "stddebug.h"
#include "debug.h"
-/***********************************************************************
- * WinHelpA (USER32.578)
- */
-BOOL WIN32_WinHelpA(HWND hWnd,LPCSTR lpszHelp,UINT uCommand, DWORD dwData)
-{
- /* Should do parameter conversion here, but WinHelp is not working,
- anyways */
- return WinHelp(hWnd,lpszHelp,uCommand,dwData);
-}
-
/****************************************************************************
* QueryPerformanceCounter (KERNEL32.415)
*/
diff --git a/win32/object_mgt.c b/win32/object_mgt.c
deleted file mode 100644
index 6495694..0000000
--- a/win32/object_mgt.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * object_mgt.c - Kernel object management functions
- *
- * Revision History:
- *
- * Oct 28 1995 C. Heide
- * First created.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "handle32.h"
-
-int ValidateKernelObject(KERNEL_OBJECT *ptr)
-{
- return (!ptr || (short int)(int)ptr==-1);
-}
-
diff --git a/win32/process.c b/win32/process.c
index 2b6f501..a8534ff 100644
--- a/win32/process.c
+++ b/win32/process.c
@@ -11,21 +11,9 @@
#include "winerror.h"
#include "heap.h"
#include "handle32.h"
-#include "task.h"
#include "stddebug.h"
#include "debug.h"
-static HANDLE32 ProcessHeap = 0; /* FIXME: should be in process database */
-
-/***********************************************************************
- * ExitProcess (KERNEL32.100)
- */
-
-void ExitProcess(DWORD status)
-{
- TASK_KillCurrentTask( status );
-}
-
/***********************************************************************
* CreateMutexA (KERNEL32.52)
*/
@@ -79,22 +67,7 @@
*d = b;
return 1;
}
-/***********************************************************************
- * GetCurrentProcess (KERNEL32.198)
- */
-HANDLE32 GetCurrentProcess(void)
-{
- return 0;
-}
-/***********************************************************************
- * GetProcessHeap (KERNEL32.259)
- */
-HANDLE32 GetProcessHeap(void)
-{
- if (!ProcessHeap) ProcessHeap = HeapCreate( 0, 0x10000, 0 );
- return ProcessHeap;
-}
/***********************************************************************
* LoadLibraryA (KERNEL32.365)
diff --git a/win32/string32.c b/win32/string32.c
index f4a317b..253ab60 100644
--- a/win32/string32.c
+++ b/win32/string32.c
@@ -15,13 +15,6 @@
#include "string32.h"
#include "xmalloc.h"
-LPSTR STRING32_DupUniToAnsi(LPCWSTR src)
-{
- LPSTR dest=xmalloc(lstrlen32W(src)+1);
- lstrcpyWtoA(dest,src);
- return dest;
-}
-
LPWSTR STRING32_DupAnsiToUni(LPCSTR src)
{
LPWSTR dest=xmalloc(2*strlen(src)+2);
@@ -29,14 +22,6 @@
return dest;
}
-/* not an API function */
-
-WCHAR STRING32_tolowerW(WCHAR c)
-{
- /* FIXME: Unicode */
- return tolower(c);
-}
-
LPWSTR
STRING32_lstrchrW(LPCWSTR a,WCHAR c) {
while(*a) {
diff --git a/win32/thread.c b/win32/thread.c
index ae020f7..6c0559f 100644
--- a/win32/thread.c
+++ b/win32/thread.c
@@ -14,31 +14,6 @@
#include "debug.h"
#include "xmalloc.h"
-/***********************************************************************
- * GetCurrentThreadId (KERNEL32.201)
- */
-
-DWORD GetCurrentThreadId(void)
-{
- /* Windows 95 returns the address of the thread database (sorta) */
- return MAKELONG(GetCurrentTask(), 0);
-}
-
-/***********************************************************************
- * GetThreadContext (KERNEL32.294)
- */
-BOOL GetThreadContext(HANDLE32 hThread, void *lpContext)
-{
- return FALSE;
-}
-/***********************************************************************
- * GetCurrentThread (KERNEL32.200)
- */
-HANDLE32 GetCurrentThread(void)
-{
- return 0xFFFFFFFE; /* that's -2 */
-}
-
/**********************************************************************
* Critical Sections are currently ignored
*/
@@ -76,53 +51,6 @@
/* hmm */
}
-/***********************************************************************
- * Tls is available only for the single thread
- * (BTW: TLS means Thread Local Storage)
- */
-static LPVOID* Tls=0;
-static int TlsCount=0;
-
-DWORD TlsAlloc()
-{
- if(!Tls){
- TlsCount++;
- Tls=xmalloc(sizeof(LPVOID));
- /* Tls needs to be zero initialized */
- Tls[0]=0;
- return 0;
- }
- Tls=xrealloc(Tls,sizeof(LPVOID)*(++TlsCount));
- Tls[TlsCount-1]=0;
- return TlsCount-1;
-}
-
-void TlsFree(DWORD index)
-{
- /*FIXME: should remember that it has been freed */
- return;
-}
-
-LPVOID TlsGetValue(DWORD index)
-{
- if(index>=TlsCount)
- {
- /* FIXME: Set last error*/
- return 0;
- }
- return Tls[index];
-}
-
-BOOL32 TlsSetValue(DWORD index,LPVOID value)
-{
- if(index>=TlsCount)
- {
- /* FIXME: Set last error*/
- return FALSE;
- }
- Tls[index]=value;
- return TRUE;
-}
/* FIXME: This is required to work cross-addres space as well */
static CRITICAL_SECTION interlocked;
diff --git a/win32/user32.c b/win32/user32.c
index 89c1a40..4d64343 100644
--- a/win32/user32.c
+++ b/win32/user32.c
@@ -13,7 +13,6 @@
#include "windows.h"
#include "winerror.h"
#include "heap.h"
-#include "xmalloc.h"
#include "handle32.h"
#include "struct32.h"
#include "win.h"
diff --git a/windows/caret.c b/windows/caret.c
index ca11b7e..da49ee4 100644
--- a/windows/caret.c
+++ b/windows/caret.c
@@ -11,7 +11,6 @@
/* #define DEBUG_CARET */
#include "debug.h"
-
typedef struct
{
HWND32 hwnd;
@@ -35,16 +34,24 @@
static CARET Caret = { 0, 0, FALSE, 0, 0, 2, 12, 0, 500, 0 };
-
/*****************************************************************
* CARET_GetHwnd
*/
-HWND32 CARET_GetHwnd()
+HWND32 CARET_GetHwnd(void)
{
return Caret.hwnd;
}
/*****************************************************************
+ * CARET_GetRect
+ */
+void CARET_GetRect(LPRECT32 lprc)
+{
+ lprc->right = (lprc->left = Caret.x) + Caret.width - 1;
+ lprc->bottom = (lprc->top = Caret.y) + Caret.height - 1;
+}
+
+/*****************************************************************
* CARET_DisplayCaret
*/
static void CARET_DisplayCaret( DISPLAY_CARET status )
diff --git a/windows/dialog.c b/windows/dialog.c
index bd03f44..20437e1 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -458,9 +458,10 @@
/***********************************************************************
* DIALOG_CreateIndirect
*/
-static HWND DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
- HWND owner, DLGPROC16 dlgProc,
- LPARAM param, WINDOWPROCTYPE procType )
+HWND32 DIALOG_CreateIndirect( HINSTANCE32 hInst, LPCSTR dlgTemplate,
+ BOOL32 win32Template, HWND32 owner,
+ DLGPROC16 dlgProc, LPARAM param,
+ WINDOWPROCTYPE procType )
{
HMENU16 hMenu = 0;
HFONT16 hFont = 0;
@@ -475,7 +476,7 @@
/* Parse dialog template */
if (!dlgTemplate) return 0;
- if (procType != WIN_PROC_16)
+ if (win32Template)
dlgTemplate = DIALOG_ParseTemplate32( dlgTemplate, &template );
else
dlgTemplate = DIALOG_ParseTemplate16( dlgTemplate, &template );
@@ -593,7 +594,7 @@
/* Create controls */
if (!DIALOG_CreateControls( wndPtr, dlgTemplate, template.nbItems,
- hInst, (procType != WIN_PROC_16) ))
+ hInst, win32Template ))
{
DestroyWindow( hwnd );
return 0;
@@ -692,7 +693,7 @@
HWND16 owner, DLGPROC16 dlgProc,
LPARAM param )
{
- return DIALOG_CreateIndirect( hInst, dlgTemplate, owner,
+ return DIALOG_CreateIndirect( hInst, dlgTemplate, FALSE, owner,
dlgProc, param, WIN_PROC_16 );
}
@@ -704,7 +705,7 @@
HWND32 owner, DLGPROC32 dlgProc,
LPARAM param )
{
- return DIALOG_CreateIndirect( hInst, dlgTemplate, owner,
+ return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
(DLGPROC16)dlgProc, param, WIN_PROC_32A );
}
@@ -716,7 +717,7 @@
HWND32 owner, DLGPROC32 dlgProc,
LPARAM param )
{
- return DIALOG_CreateIndirect( hInst, dlgTemplate, owner,
+ return DIALOG_CreateIndirect( hInst, dlgTemplate, TRUE, owner,
(DLGPROC16)dlgProc, param, WIN_PROC_32W );
}
@@ -724,7 +725,7 @@
/***********************************************************************
* DIALOG_DoDialogBox
*/
-static INT32 DIALOG_DoDialogBox( HWND hwnd, HWND owner )
+INT32 DIALOG_DoDialogBox( HWND32 hwnd, HWND32 owner )
{
WND * wndPtr;
DIALOGINFO * dlgInfo;
@@ -832,7 +833,7 @@
* DialogBoxIndirectParam32A (USER32.135)
*/
INT32 DialogBoxIndirectParam32A( HINSTANCE32 hInstance, LPCVOID template,
- HWND32 owner, DLGPROC32 dlgProc ,LPARAM param)
+ HWND32 owner, DLGPROC32 dlgProc, LPARAM param)
{
HWND32 hwnd = CreateDialogIndirectParam32A( hInstance, template,
owner, dlgProc, param );
@@ -845,7 +846,7 @@
* DialogBoxIndirectParam32W (USER32.137)
*/
INT32 DialogBoxIndirectParam32W( HINSTANCE32 hInstance, LPCVOID template,
- HWND32 owner, DLGPROC32 dlgProc ,LPARAM param)
+ HWND32 owner, DLGPROC32 dlgProc, LPARAM param)
{
HWND32 hwnd = CreateDialogIndirectParam32W( hInstance, template,
owner, dlgProc, param );
diff --git a/windows/event.c b/windows/event.c
index d01c38b..ac851e3 100644
--- a/windows/event.c
+++ b/windows/event.c
@@ -20,13 +20,13 @@
#include <X11/Xatom.h>
#include "windows.h"
+#include "winnt.h"
#include "gdi.h"
#include "heap.h"
#include "queue.h"
#include "win.h"
#include "class.h"
#include "clipboard.h"
-#include "debugger.h"
#include "message.h"
#include "module.h"
#include "options.h"
@@ -35,7 +35,6 @@
#include "drive.h"
#include "dos_fs.h"
#include "shell.h"
-#include "registers.h"
#include "xmalloc.h"
#include "keyboard.h"
#include "stddebug.h"
@@ -65,7 +64,7 @@
BOOL AsyncMouseButtonsStates[NB_BUTTONS];
BYTE InputKeyStateTable[256];
-
+static INT16 captureHT = HTCLIENT;
static HWND32 captureWnd = 0;
static BOOL32 InputEnabled = TRUE;
@@ -542,10 +541,12 @@
keysym, ksname, ascii_chars, Str[0], Str);
}
+#if 0
/* Ctrl-Alt-Return enters the debugger */
if ((keysym == XK_Return) && (event->type == KeyPress) &&
(event->state & ControlMask) && (event->state & Mod1Mask))
DEBUG_EnterDebugger();
+#endif
xkey = LOWORD(keysym);
key_type = HIBYTE(xkey);
@@ -585,8 +586,8 @@
case XK_Delete :
case XK_Home :
case XK_End :
- case XK_Page_Up :
- case XK_Page_Down :
+ case XK_Prior :
+ case XK_Next :
case XK_Left :
case XK_Up :
case XK_Right :
@@ -1082,20 +1083,13 @@
return;
}
-
/**********************************************************************
- * SetCapture16 (USER.18)
+ * EVENT_Capture
+ *
+ * We need this to be able to generate double click messages
+ * when menu code captures mouse in the window without CS_DBLCLK style.
*/
-HWND16 SetCapture16( HWND16 hwnd )
-{
- return (HWND16)SetCapture32( hwnd );
-}
-
-
-/**********************************************************************
- * SetCapture32 (USER32.463)
- */
-HWND32 SetCapture32( HWND32 hwnd )
+HWND32 EVENT_Capture(HWND32 hwnd, INT16 ht)
{
Window win;
HWND32 old_capture_wnd = captureWnd;
@@ -1105,17 +1099,45 @@
ReleaseCapture();
return old_capture_wnd;
}
- if (!(win = WIN_GetXWindow( hwnd ))) return 0;
- if (XGrabPointer(display, win, False,
+ if ((win = WIN_GetXWindow( hwnd )))
+ {
+ if (XGrabPointer(display, win, False,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync,
None, None, CurrentTime ) == GrabSuccess)
- {
- dprintf_win(stddeb, "SetCapture: %04x\n", hwnd);
- captureWnd = hwnd;
- return old_capture_wnd;
+ {
+ dprintf_win(stddeb, "SetCapture: %04x\n", hwnd);
+ captureWnd = hwnd;
+ captureHT = ht;
+ return old_capture_wnd;
+ }
}
- else return 0;
+ return 0;
+}
+
+/**********************************************************************
+ * EVENT_GetCaptureInfo
+ */
+INT16 EVENT_GetCaptureInfo()
+{
+ return captureHT;
+}
+
+/**********************************************************************
+ * SetCapture16 (USER.18)
+ */
+HWND16 SetCapture16( HWND16 hwnd )
+{
+ return (HWND16)EVENT_Capture( hwnd, HTCLIENT );
+}
+
+
+/**********************************************************************
+ * SetCapture32 (USER32.463)
+ */
+HWND32 SetCapture32( HWND32 hwnd )
+{
+ return EVENT_Capture( hwnd, HTCLIENT );
}
@@ -1163,8 +1185,7 @@
/***********************************************************************
* Mouse_Event (USER.299)
*/
-#ifndef WINELIB
-void Mouse_Event( SIGCONTEXT *context )
+void Mouse_Event( CONTEXT *context )
{
/* Register values:
* AX = mouse event
@@ -1199,7 +1220,6 @@
hardware_event( WM_RBUTTONUP, EVENT_XStateToKeyState( state ), 0L,
rootX - desktopX, rootY - desktopY, GetTickCount(), 0);
}
-#endif
/**********************************************************************
diff --git a/windows/mdi.c b/windows/mdi.c
index e0b2474..f780b72 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -838,7 +838,6 @@
BOOL MDI_AugmentFrameMenu(MDICLIENTINFO* ci, WND *frame, HWND hChild)
{
WND* child = WIN_FindWndPtr(hChild);
- HGLOBAL16 handle;
HMENU16 hSysPopup = 0;
dprintf_mdi(stddeb,"MDI_AugmentFrameMenu: frame %p,child %04x\n",frame,hChild);
@@ -847,9 +846,8 @@
/* create a copy of sysmenu popup and insert it into frame menu bar */
- if (!(handle = SYSRES_LoadResource( SYSRES_MENU_SYSMENU ))) return 0;
- hSysPopup = LoadMenuIndirect16( GlobalLock16( handle ) );
- SYSRES_FreeResource( handle );
+ if (!(hSysPopup = LoadMenuIndirect32A(SYSRES_GetResPtr(SYSRES_MENU_SYSMENU))))
+ return 0;
dprintf_mdi(stddeb,"\t\tgot popup %04x\n in sysmenu %04x",hSysPopup,child->hSysMenu);
diff --git a/windows/message.c b/windows/message.c
index dcfec8d..70b3043 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -32,7 +32,8 @@
#define HWND_BROADCAST16 ((HWND16)0xffff)
#define HWND_BROADCAST32 ((HWND32)0xffffffff)
-typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP, SYSQ_MSG_ACCEPT } SYSQ_STATUS;
+typedef enum { SYSQ_MSG_ABANDON, SYSQ_MSG_SKIP,
+ SYSQ_MSG_ACCEPT, SYSQ_MSG_CONTINUE } SYSQ_STATUS;
extern BOOL MouseButtonsStates[3];
extern BOOL AsyncMouseButtonsStates[3];
@@ -50,62 +51,64 @@
static INT32 debugSMRL = 0; /* intertask SendMessage() recursion level */
/***********************************************************************
+ * MSG_CheckFilter
+ */
+BOOL32 MSG_CheckFilter(WORD uMsg, DWORD filter)
+{
+ if( filter )
+ return (uMsg >= LOWORD(filter) && uMsg <= HIWORD(filter));
+ return TRUE;
+}
+
+/***********************************************************************
* MSG_TranslateMouseMsg
*
* Translate an mouse hardware event into a real mouse message.
* Return value indicates whether the translated message must be passed
- * to the user.
- * Actions performed:
- * - Find the window for this message.
- * - Translate button-down messages in double-clicks.
- * - Send the WM_NCHITTEST message to find where the cursor is.
- * - Activate the window if needed.
- * - Translate the message into a non-client message, or translate
- * the coordinates to client coordinates.
- * - Send the WM_SETCURSOR message.
+ * to the user, left in the queue, or skipped entirely (in this case
+ * HIWORD contains hit test code).
*/
-static SYSQ_STATUS MSG_TranslateMouseMsg( MSG16 *msg, BOOL remove )
+static DWORD MSG_TranslateMouseMsg( HWND16 hWndScope, DWORD filter,
+ MSG16 *msg, BOOL32 remove )
{
- WND *pWnd;
- BOOL eatMsg = FALSE;
- INT16 hittest;
- MOUSEHOOKSTRUCT16 *hook;
- BOOL32 ret;
- static DWORD lastClickTime = 0;
- static WORD lastClickMsg = 0;
- static POINT16 lastClickPos = { 0, 0 };
- POINT16 pt = msg->pt;
- MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16(GetTaskQueue(0));
+ static DWORD dblclk_time_limit = 0;
+ static UINT16 clk_message = 0;
+ static HWND16 clk_hwnd = 0;
+ static POINT16 clk_pos = { 0, 0 };
- BOOL mouseClick = ((msg->message == WM_LBUTTONDOWN) ||
- (msg->message == WM_RBUTTONDOWN) ||
- (msg->message == WM_MBUTTONDOWN));
+ WND *pWnd;
+ HWND16 hWnd;
+ INT16 ht, hittest, sendSC = 0;
+ UINT16 message = msg->message;
+ POINT16 screen_pt, pt;
+ HANDLE16 hQ = GetTaskQueue(0);
+ MESSAGEQUEUE *queue = (MESSAGEQUEUE *)GlobalLock16(hQ);
+ BOOL32 eatMsg = FALSE;
+ BOOL32 mouseClick = ((message == WM_LBUTTONDOWN) ||
+ (message == WM_RBUTTONDOWN) ||
+ (message == WM_MBUTTONDOWN))?1:0;
+ SYSQ_STATUS ret = 0;
/* Find the window */
- if ((msg->hwnd = GetCapture16()) != 0)
+ ht = hittest = HTCLIENT;
+ hWnd = GetCapture16();
+ if( !hWnd )
{
- BOOL32 ret;
-
- ScreenToClient16( msg->hwnd, &pt );
- msg->lParam = MAKELONG( pt.x, pt.y );
- /* No need to further process the message */
-
- if (!HOOK_IsHooked( WH_MOUSE ) ||
- !(hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16)))
- return SYSQ_MSG_ACCEPT;
- hook->pt = msg->pt;
- hook->hwnd = msg->hwnd;
- hook->wHitTestCode = HTCLIENT;
- hook->dwExtraInfo = 0;
- ret = !HOOK_CallHooks16( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
- msg->message, (LPARAM)SEGPTR_GET(hook));
- SEGPTR_FREE(hook);
- return ret ? SYSQ_MSG_ACCEPT : SYSQ_MSG_SKIP ;
+ sendSC = 1;
+ ht = hittest = WINPOS_WindowFromPoint( WIN_GetDesktop(), msg->pt, &pWnd );
+ if( !pWnd ) pWnd = WIN_GetDesktop();
+ hWnd = pWnd->hwndSelf;
+ }
+ else
+ {
+ pWnd = WIN_FindWndPtr(hWnd);
+ ht = EVENT_GetCaptureInfo();
}
-
- hittest = WINPOS_WindowFromPoint( WIN_GetDesktop(), msg->pt, &pWnd );
- if (pWnd->hmemTaskQ != GetTaskQueue(0))
+
+ /* stop if not the right queue */
+
+ if (pWnd->hmemTaskQ != hQ)
{
/* Not for the current task */
if (queue) QUEUE_ClearWakeBit( queue, QS_MOUSE );
@@ -114,127 +117,147 @@
if (queue) QUEUE_SetWakeBit( queue, QS_MOUSE );
return SYSQ_MSG_ABANDON;
}
- pCursorQueue = queue;
- msg->hwnd = pWnd->hwndSelf;
- if ((hittest != HTERROR) && mouseClick)
+ /* check if hWnd is within hWndScope */
+
+ if( hWndScope && hWnd != hWndScope )
+ if( !IsChild(hWndScope, hWnd) ) return SYSQ_MSG_CONTINUE;
+
+ if( mouseClick )
{
- HWND hwndTop = WIN_GetTopParent( msg->hwnd );
+ /* translate double clicks -
+ * note that ...MOUSEMOVEs can slip in between
+ * ...BUTTONDOWN and ...BUTTONDBLCLK messages */
- /* Send the WM_PARENTNOTIFY message */
-
- WIN_SendParentNotify( msg->hwnd, msg->message, 0,
- MAKELPARAM( msg->pt.x, msg->pt.y ) );
-
- /* Activate the window if needed */
-
- if (msg->hwnd != GetActiveWindow() &&
- msg->hwnd != GetDesktopWindow16())
- {
- LONG ret = SendMessage16( msg->hwnd, WM_MOUSEACTIVATE, hwndTop,
- MAKELONG( hittest, msg->message ) );
-
- if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
- eatMsg = TRUE;
-
- if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
- && hwndTop != GetActiveWindow() )
- WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE );
- }
- }
-
- /* Send the WM_SETCURSOR message */
-
- SendMessage16( msg->hwnd, WM_SETCURSOR, (WPARAM16)msg->hwnd,
- MAKELONG( hittest, msg->message ));
- if (eatMsg) return SYSQ_MSG_SKIP;
-
- /* Check for double-click */
-
- if (mouseClick)
- {
- BOOL dbl_click = FALSE;
-
- if ((msg->message == lastClickMsg) &&
- (msg->time - lastClickTime < doubleClickSpeed) &&
- (abs(msg->pt.x - lastClickPos.x) < SYSMETRICS_CXDOUBLECLK/2) &&
- (abs(msg->pt.y - lastClickPos.y) < SYSMETRICS_CYDOUBLECLK/2))
- dbl_click = TRUE;
-
- if (dbl_click && (hittest == HTCLIENT))
+ if( pWnd->class->style & CS_DBLCLKS || ht != HTCLIENT )
{
- /* Check whether window wants the double click message. */
- dbl_click = (pWnd->class->style & CS_DBLCLKS) != 0;
- }
-
- if (dbl_click) switch(msg->message)
- {
- case WM_LBUTTONDOWN: msg->message = WM_LBUTTONDBLCLK; break;
- case WM_RBUTTONDOWN: msg->message = WM_RBUTTONDBLCLK; break;
- case WM_MBUTTONDOWN: msg->message = WM_MBUTTONDBLCLK; break;
- }
-
- if (remove)
- {
- lastClickTime = msg->time;
- lastClickMsg = msg->message;
- lastClickPos = msg->pt;
+ if ((message == clk_message) && (hWnd == clk_hwnd) &&
+ (msg->time - dblclk_time_limit < doubleClickSpeed) &&
+ (abs(msg->pt.x - clk_pos.x) < SYSMETRICS_CXDOUBLECLK/2) &&
+ (abs(msg->pt.y - clk_pos.y) < SYSMETRICS_CYDOUBLECLK/2))
+ {
+ message += (WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
+ mouseClick++; /* == 2 */
+ }
}
}
+ screen_pt = pt = msg->pt;
- /* Build the translated message */
-
- if (hittest == HTCLIENT)
- ScreenToClient16( msg->hwnd, &pt );
- else
+ if (hittest != HTCLIENT)
{
+ message += ((INT16)WM_NCMOUSEMOVE - WM_MOUSEMOVE);
msg->wParam = hittest;
- msg->message += WM_NCLBUTTONDOWN - WM_LBUTTONDOWN;
}
- msg->lParam = MAKELONG( pt.x, pt.y );
+ else ScreenToClient16( hWnd, &pt );
- /* Call the WH_MOUSE hook */
+ /* check message filter */
- if (!HOOK_IsHooked( WH_MOUSE ) ||
- !(hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16)))
- return SYSQ_MSG_ACCEPT;
+ if (!MSG_CheckFilter(message, filter)) return SYSQ_MSG_CONTINUE;
- hook->pt = msg->pt;
- hook->hwnd = msg->hwnd;
- hook->wHitTestCode = hittest;
- hook->dwExtraInfo = 0;
- ret = !HOOK_CallHooks16( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
- msg->message, (LPARAM)SEGPTR_GET(hook) );
- SEGPTR_FREE(hook);
- return ret ? SYSQ_MSG_ACCEPT : SYSQ_MSG_SKIP;
+ pCursorQueue = queue;
+
+ /* call WH_MOUSE */
+
+ if (HOOK_IsHooked( WH_MOUSE ))
+ {
+ MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
+ if( hook )
+ {
+ hook->pt = screen_pt;
+ hook->hwnd = hWnd;
+ hook->wHitTestCode = hittest;
+ hook->dwExtraInfo = 0;
+ ret = HOOK_CallHooks16( WH_MOUSE, remove ? HC_ACTION : HC_NOREMOVE,
+ message, (LPARAM)SEGPTR_GET(hook) );
+ SEGPTR_FREE(hook);
+ }
+ if( ret ) return MAKELONG((INT16)SYSQ_MSG_SKIP, hittest);
+ }
+
+ if ((hittest == HTERROR) || (hittest == HTNOWHERE))
+ eatMsg = sendSC = 1;
+ else if( remove && mouseClick )
+ {
+ HWND hwndTop = WIN_GetTopParent( hWnd );
+
+ if( mouseClick == 1 )
+ {
+ /* set conditions */
+ dblclk_time_limit = msg->time;
+ clk_message = msg->message;
+ clk_hwnd = hWnd;
+ clk_pos = screen_pt;
+ } else
+ /* got double click - zero them out */
+ dblclk_time_limit = clk_hwnd = 0;
+
+ if( sendSC )
+ {
+ /* Send the WM_PARENTNOTIFY,
+ * note that even for double/nonclient clicks
+ * notification message is still WM_L/M/RBUTTONDOWN.
+ */
+
+ WIN_SendParentNotify( hWnd, msg->message, 0,
+ MAKELPARAM( screen_pt.x, screen_pt.y ) );
+
+ /* Activate the window if needed */
+
+ if (hWnd != GetActiveWindow() && hWnd != GetDesktopWindow16())
+ {
+ LONG ret = SendMessage16( hWnd, WM_MOUSEACTIVATE, hwndTop,
+ MAKELONG( hittest, message ) );
+
+ if ((ret == MA_ACTIVATEANDEAT) || (ret == MA_NOACTIVATEANDEAT))
+ eatMsg = TRUE;
+
+ if (((ret == MA_ACTIVATE) || (ret == MA_ACTIVATEANDEAT))
+ && hwndTop != GetActiveWindow() )
+ if (!WINPOS_SetActiveWindow( hwndTop, TRUE , TRUE ))
+ eatMsg = TRUE;
+ }
+ }
+ } else sendSC = (remove && sendSC);
+
+ /* Send the WM_SETCURSOR message */
+
+ if (sendSC)
+ SendMessage16( hWnd, WM_SETCURSOR, (WPARAM16)hWnd,
+ MAKELONG( hittest, message ));
+ if (eatMsg) return MAKELONG( (UINT16)SYSQ_MSG_SKIP, hittest);
+
+ msg->hwnd = hWnd;
+ msg->message = message;
+ msg->lParam = MAKELONG( pt.x, pt.y );
+ return SYSQ_MSG_ACCEPT;
}
/***********************************************************************
- * MSG_TranslateKeyboardMsg
+ * MSG_TranslateKbdMsg
*
* Translate an keyboard hardware event into a real message.
- * Return value indicates whether the translated message must be passed
- * to the user.
*/
-static SYSQ_STATUS MSG_TranslateKeyboardMsg( MSG16 *msg, BOOL remove )
+static DWORD MSG_TranslateKbdMsg( HWND16 hWndScope, DWORD filter,
+ MSG16 *msg, BOOL32 remove )
{
+ WORD message = msg->message;
+ HWND16 hWnd = GetFocus16();
WND *pWnd;
/* Should check Ctrl-Esc and PrintScreen here */
- msg->hwnd = GetFocus16();
- if (!msg->hwnd)
+ if (!hWnd)
{
/* Send the message to the active window instead, */
/* translating messages to their WM_SYS equivalent */
- msg->hwnd = GetActiveWindow();
+ hWnd = GetActiveWindow();
- if( msg->message < WM_SYSKEYDOWN )
- msg->message += WM_SYSKEYDOWN - WM_KEYDOWN;
+ if( message < WM_SYSKEYDOWN )
+ message += WM_SYSKEYDOWN - WM_KEYDOWN;
}
- pWnd = WIN_FindWndPtr( msg->hwnd );
+ pWnd = WIN_FindWndPtr( hWnd );
if (pWnd && (pWnd->hmemTaskQ != GetTaskQueue(0)))
{
/* Not for the current task */
@@ -245,6 +268,14 @@
if (queue) QUEUE_SetWakeBit( queue, QS_KEY );
return SYSQ_MSG_ABANDON;
}
+
+ if (hWndScope && hWnd != hWndScope)
+ if (!IsChild(hWndScope, hWnd)) return SYSQ_MSG_CONTINUE;
+ if (!MSG_CheckFilter(message, filter)) return SYSQ_MSG_CONTINUE;
+
+ msg->hwnd = hWnd;
+ msg->message = message;
+
return (HOOK_CallHooks16( WH_KEYBOARD, remove ? HC_ACTION : HC_NOREMOVE,
msg->wParam, msg->lParam )
? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT);
@@ -365,7 +396,13 @@
(LPARAM)SEGPTR_GET(tmpMsg));
}
else
- result= QS_MOUSE | QS_KEY;
+ {
+ if( tmpMsg->message == WM_QUEUESYNC )
+ if (HOOK_IsHooked( WH_CBT ))
+ HOOK_CallHooks16( WH_CBT, HCBT_QS, 0, 0L);
+
+ result= QS_MOUSE | QS_KEY; /* ? */
+ }
SEGPTR_FREE(tmpMsg);
}
return result;
@@ -376,35 +413,34 @@
*
* Peek for a hardware message matching the hwnd and message filters.
*/
-static BOOL MSG_PeekHardwareMsg( MSG16 *msg, HWND hwnd, WORD first, WORD last,
- BOOL remove )
+static BOOL32 MSG_PeekHardwareMsg( MSG16 *msg, HWND16 hwnd, DWORD filter, BOOL32 remove )
{
- SYSQ_STATUS status = SYSQ_MSG_ACCEPT;
+ DWORD status = SYSQ_MSG_ACCEPT;
MESSAGEQUEUE *sysMsgQueue = QUEUE_GetSysQueue();
- int i, pos = sysMsgQueue->nextMessage;
+ int i, kbd_msg, pos = sysMsgQueue->nextMessage;
/* If the queue is empty, attempt to fill it */
if (!sysMsgQueue->msgCount && XPending(display))
EVENT_WaitXEvent( FALSE, FALSE );
- for (i = 0; i < sysMsgQueue->msgCount; i++, pos++)
+ for (i = kbd_msg = 0; i < sysMsgQueue->msgCount; i++, pos++)
{
if (pos >= sysMsgQueue->queueSize) pos = 0;
*msg = sysMsgQueue->messages[pos].msg;
- /* Translate message; return FALSE immediately on SYSQ_MSG_ABANDON */
+ /* Translate message */
if ((msg->message >= WM_MOUSEFIRST) && (msg->message <= WM_MOUSELAST))
{
- if ((status = MSG_TranslateMouseMsg(msg,remove)) == SYSQ_MSG_ABANDON)
- return FALSE;
+ status = MSG_TranslateMouseMsg(hwnd, filter, msg, remove);
+ kbd_msg = 0;
}
else if ((msg->message >= WM_KEYFIRST) && (msg->message <= WM_KEYLAST))
{
- if ((status = MSG_TranslateKeyboardMsg(msg,remove)) == SYSQ_MSG_ABANDON)
- return FALSE;
+ status = MSG_TranslateKbdMsg(hwnd, filter, msg, remove);
+ kbd_msg = 1;
}
- else /* Non-standard hardware event */
+ else /* Non-standard hardware event */
{
HARDWAREHOOKSTRUCT16 *hook;
if ((hook = SEGPTR_NEW(HARDWAREHOOKSTRUCT16)))
@@ -418,56 +454,55 @@
remove ? HC_ACTION : HC_NOREMOVE,
0, (LPARAM)SEGPTR_GET(hook) );
SEGPTR_FREE(hook);
- status = ret ? SYSQ_MSG_SKIP : SYSQ_MSG_ACCEPT;
+ if (ret)
+ {
+ QUEUE_RemoveMsg( sysMsgQueue, pos );
+ continue;
+ }
+ status = SYSQ_MSG_ACCEPT;
}
}
- if (status == SYSQ_MSG_SKIP)
- {
- if (remove) QUEUE_RemoveMsg( sysMsgQueue, pos );
- /* FIXME: call CBT_CLICKSKIPPED from here */
- continue;
- }
+ switch (LOWORD(status))
+ {
+ case SYSQ_MSG_ACCEPT:
+ break;
- /* Check message against filters */
+ case SYSQ_MSG_SKIP:
+ if (HOOK_IsHooked( WH_CBT ))
+ if( kbd_msg )
+ HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
+ msg->wParam, msg->lParam );
+ else
+ {
+ MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
+ if (hook)
+ {
+ hook->pt = msg->pt;
+ hook->hwnd = msg->hwnd;
+ hook->wHitTestCode = HIWORD(status);
+ hook->dwExtraInfo = 0;
+ HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message,
+ (LPARAM)SEGPTR_GET(hook) );
+ SEGPTR_FREE(hook);
+ }
+ }
- if (hwnd && (msg->hwnd != hwnd)) continue;
- if ((first || last) &&
- ((msg->message < first) || (msg->message > last))) continue;
+ if (remove)
+ QUEUE_RemoveMsg( sysMsgQueue, pos );
+ /* continue */
+
+ case SYSQ_MSG_CONTINUE:
+ continue;
+
+ case SYSQ_MSG_ABANDON:
+ return FALSE;
+ }
+
if (remove)
{
- if (HOOK_IsHooked( WH_JOURNALRECORD ))
- MSG_JournalRecordMsg( msg );
+ if (HOOK_IsHooked( WH_JOURNALRECORD )) MSG_JournalRecordMsg( msg );
QUEUE_RemoveMsg( sysMsgQueue, pos );
-
- /* call CBT hook _after_ message removed from queue */
- if (HOOK_IsHooked( WH_CBT ))
- {
- if (((msg->message >= WM_MOUSEFIRST) &&
- (msg->message <= WM_MOUSELAST)) ||
- ((msg->message >= WM_NCMOUSEFIRST) &&
- (msg->message <= WM_NCMOUSELAST)))
- {
- MOUSEHOOKSTRUCT16 *hook = SEGPTR_NEW(MOUSEHOOKSTRUCT16);
- if (hook)
- {
- hook->pt = msg->pt;
- hook->hwnd = msg->hwnd;
- hook->wHitTestCode = (INT16)SendMessage16( msg->hwnd,
- WM_NCHITTEST, 0,
- MAKELONG( msg->pt.x, msg->pt.y ) );
- hook->dwExtraInfo = 0;
- HOOK_CallHooks16( WH_CBT, HCBT_CLICKSKIPPED ,msg->message,
- (LPARAM)SEGPTR_GET(hook) );
- SEGPTR_FREE(hook);
- }
- }
- else
- if ((msg->message >= WM_KEYFIRST) &&
- (msg->message <= WM_KEYLAST))
- HOOK_CallHooks16( WH_CBT, HCBT_KEYSKIPPED,
- msg->wParam, msg->lParam );
- }
}
return TRUE;
}
@@ -692,7 +727,7 @@
/* Now find a hardware event */
if (((msgQueue->wakeBits & mask) & (QS_MOUSE | QS_KEY)) &&
- MSG_PeekHardwareMsg( msg, hwnd, first, last, flags & PM_REMOVE ))
+ MSG_PeekHardwareMsg( msg, hwnd, MAKELONG(first,last), flags & PM_REMOVE ))
{
/* Got one */
msgQueue->GetMessageTimeVal = msg->time;
diff --git a/windows/msgbox.c b/windows/msgbox.c
index 9708381..40d9344 100644
--- a/windows/msgbox.c
+++ b/windows/msgbox.c
@@ -2,11 +2,10 @@
* Message boxes
*
* Copyright 1995 Bernd Schmidt
- *
*/
+#define NO_TRANSITION_TYPES /* This file is Win32-clean */
#include <stdio.h>
-#include <malloc.h>
#include "windows.h"
#include "dlgs.h"
#include "heap.h"
@@ -15,19 +14,27 @@
#include "resource.h"
#include "task.h"
-typedef struct {
- LPCSTR title;
- LPCSTR text;
- WORD type;
+typedef struct
+{
+ LPCSTR title;
+ LPCSTR text;
+ UINT32 type;
} MSGBOX, *LPMSGBOX;
-LRESULT SystemMessageBoxProc(HWND hwnd,UINT message,WPARAM16 wParam,LPARAM lParam)
+
+/**************************************************************************
+ * MSGBOX_DlgProc
+ *
+ * Dialog procedure for message boxes.
+ */
+static LRESULT MSGBOX_DlgProc( HWND32 hwnd, UINT32 message,
+ WPARAM32 wParam, LPARAM lParam )
{
LPMSGBOX lpmb;
- RECT16 rect, textrect;
- HWND hItem;
+ RECT32 rect, textrect;
+ HWND32 hItem;
HDC32 hdc;
- LONG lRet;
+ LRESULT lRet;
int i, buttons, bwidth, bheight, theight, wwidth, bpos;
int borheight, iheight, tiheight;
@@ -86,21 +93,21 @@
}
/* Position everything */
- GetWindowRect16(hwnd, &rect);
+ GetWindowRect32(hwnd, &rect);
borheight = rect.bottom - rect.top;
wwidth = rect.right - rect.left;
- GetClientRect16(hwnd, &rect);
+ GetClientRect32(hwnd, &rect);
borheight -= rect.bottom - rect.top;
/* Get the icon height */
- GetWindowRect16(GetDlgItem(hwnd, 1088), &rect);
+ GetWindowRect32(GetDlgItem(hwnd, 1088), &rect);
iheight = rect.bottom - rect.top;
/* Get the number of visible buttons and their width */
- GetWindowRect16(GetDlgItem(hwnd, 2), &rect);
+ GetWindowRect32(GetDlgItem(hwnd, 2), &rect);
bheight = rect.bottom - rect.top;
bwidth = rect.left;
- GetWindowRect16(GetDlgItem(hwnd, 1), &rect);
+ GetWindowRect32(GetDlgItem(hwnd, 1), &rect);
bwidth -= rect.left;
for (buttons = 0, i = 1; i < 8; i++)
{
@@ -110,13 +117,13 @@
/* Get the text size */
hItem = GetDlgItem(hwnd, 100);
- GetWindowRect16(hItem, &textrect);
- MapWindowPoints16(0, hwnd, (LPPOINT16)&textrect, 2);
+ GetWindowRect32(hItem, &textrect);
+ MapWindowPoints32(0, hwnd, (LPPOINT32)&textrect, 2);
- GetClientRect16(hItem, &rect);
+ GetClientRect32(hItem, &rect);
hdc = GetDC32(hItem);
- lRet = DrawText16( hdc, lpmb->text, -1, &rect,
- DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
+ lRet = DrawText32A( hdc, lpmb->text, -1, &rect,
+ DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
theight = rect.bottom - rect.top;
tiheight = 16 + MAX(iheight, theight);
ReleaseDC32(hItem, hdc);
@@ -128,8 +135,8 @@
/* Position the icon */
hItem = GetDlgItem(hwnd, 1088);
- GetWindowRect16(hItem, &rect);
- MapWindowPoints16(0, hwnd, (LPPOINT16)&rect, 2);
+ GetWindowRect32(hItem, &rect);
+ MapWindowPoints32(0, hwnd, (LPPOINT32)&rect, 2);
SetWindowPos(hItem, 0, rect.left, (tiheight - iheight) / 2, 0, 0,
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW);
@@ -139,7 +146,7 @@
/* Position the buttons */
bpos = (wwidth - bwidth * buttons) / 2;
- GetWindowRect16(GetDlgItem(hwnd, 1), &rect);
+ GetWindowRect32(GetDlgItem(hwnd, 1), &rect);
for (buttons = i = 0; i < 7; i++) {
/* some arithmetic to get the right order for YesNoCancel windows */
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
@@ -157,7 +164,8 @@
break;
case WM_COMMAND:
- switch (wParam) {
+ switch (wParam)
+ {
case IDOK:
case IDCANCEL:
case IDABORT:
@@ -173,6 +181,7 @@
return 0;
}
+
/**************************************************************************
* MessageBox16 (USER.1)
*/
@@ -181,61 +190,60 @@
return MessageBox32A( hwnd, text, title, type );
}
+
/**************************************************************************
* MessageBox32A (USER32.390)
*/
INT32 MessageBox32A( HWND32 hWnd, LPCSTR text, LPCSTR title, UINT32 type )
{
- HANDLE16 handle;
MSGBOX mbox;
- int ret;
-
mbox.title = title;
mbox.text = text;
mbox.type = type;
-
- handle = SYSRES_LoadResource( SYSRES_DIALOG_MSGBOX );
- if (!handle) return 0;
- ret = DialogBoxIndirectParam16( WIN_GetWindowInstance(hWnd),
- handle, hWnd,
- MODULE_GetWndProcEntry16("SystemMessageBoxProc"),
- (LONG)&mbox );
- SYSRES_FreeResource( handle );
- return ret;
+ return DialogBoxIndirectParam32A( WIN_GetWindowInstance(hWnd),
+ SYSRES_GetResPtr( SYSRES_DIALOG_MSGBOX ),
+ hWnd, MSGBOX_DlgProc, (LPARAM)&mbox );
}
+
/**************************************************************************
* MessageBox32W (USER32.395)
*/
-INT32 MessageBox32W( HWND32 hWnd, LPCWSTR text, LPCWSTR title, UINT32 type )
+INT32 MessageBox32W( HWND32 hwnd, LPCWSTR text, LPCWSTR title, UINT32 type )
{
- HANDLE16 handle;
- MSGBOX mbox;
- int ret;
-
- mbox.title = HEAP_strdupWtoA( GetProcessHeap(), 0, title );
- mbox.text = HEAP_strdupWtoA( GetProcessHeap(), 0, text );
- mbox.type = type;
-
- fprintf(stderr,"MessageBox(%s,%s)\n",mbox.text,mbox.title);
- handle = SYSRES_LoadResource( SYSRES_DIALOG_MSGBOX );
- if (!handle) return 0;
- ret = DialogBoxIndirectParam16( WIN_GetWindowInstance(hWnd),
- handle, hWnd,
- MODULE_GetWndProcEntry16("SystemMessageBoxProc"),
- (LONG)&mbox );
- SYSRES_FreeResource( handle );
- HeapFree( GetProcessHeap(), 0, mbox.title );
- HeapFree( GetProcessHeap(), 0, mbox.text );
+ LPSTR titleA = HEAP_strdupWtoA( GetProcessHeap(), 0, title );
+ LPSTR textA = HEAP_strdupWtoA( GetProcessHeap(), 0, text );
+ INT32 ret = MessageBox32A( hwnd, textA, titleA, type );
+ HeapFree( GetProcessHeap(), 0, titleA );
+ HeapFree( GetProcessHeap(), 0, textA );
return ret;
}
-/**************************************************************************
- * FatalAppExit [USER.137]
- */
-void FatalAppExit(UINT fuAction, LPCSTR str)
+/**************************************************************************
+ * FatalAppExit16 (KERNEL.137)
+ */
+void FatalAppExit16( UINT16 action, LPCSTR str )
{
- MessageBox16(0, str, NULL, MB_SYSTEMMODAL | MB_OK);
- TASK_KillCurrentTask(0);
+ FatalAppExit32A( action, str );
+}
+
+
+/**************************************************************************
+ * FatalAppExit32A (KERNEL32.108)
+ */
+void FatalAppExit32A( UINT32 action, LPCSTR str )
+{
+ MessageBox32A( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
+ TASK_KillCurrentTask(0);
+}
+
+
+/**************************************************************************
+ * FatalAppExit32W (KERNEL32.109)
+ */
+void FatalAppExit32W( UINT32 action, LPCWSTR str )
+{
+ MessageBox32W( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
+ TASK_KillCurrentTask(0);
}
diff --git a/windows/nonclient.c b/windows/nonclient.c
index 4c6a2d5..20e2c6f 100644
--- a/windows/nonclient.c
+++ b/windows/nonclient.c
@@ -433,7 +433,7 @@
/***********************************************************************
* NC_DrawSysButton
*/
-void NC_DrawSysButton( HWND hwnd, HDC16 hdc, BOOL down )
+void NC_DrawSysButton( HWND hwnd, HDC16 hdc, BOOL32 down )
{
RECT16 rect;
HDC32 hdcMem;
@@ -844,17 +844,24 @@
/***********************************************************************
* NC_GetSysPopupPos
*/
-BOOL NC_GetSysPopupPos( WND* wndPtr, RECT16* rect )
+BOOL32 NC_GetSysPopupPos( WND* wndPtr, RECT16* rect )
{
- if( !wndPtr->hSysMenu ) return FALSE;
-
- NC_GetInsideRect( wndPtr->hwndSelf, rect );
- OffsetRect16( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top );
- if (wndPtr->dwStyle & WS_CHILD)
- ClientToScreen16( wndPtr->parent->hwndSelf, (POINT16 *)rect );
- rect->right = rect->left + SYSMETRICS_CXSIZE;
- rect->bottom = rect->top + SYSMETRICS_CYSIZE;
- return TRUE;
+ if( wndPtr->hSysMenu )
+ {
+ if( wndPtr->dwStyle & WS_MINIMIZE )
+ GetWindowRect16( wndPtr->hwndSelf, rect );
+ else
+ {
+ NC_GetInsideRect( wndPtr->hwndSelf, rect );
+ OffsetRect16( rect, wndPtr->rectWindow.left, wndPtr->rectWindow.top );
+ if (wndPtr->dwStyle & WS_CHILD)
+ ClientToScreen16( wndPtr->parent->hwndSelf, (POINT16 *)rect );
+ rect->right = rect->left + SYSMETRICS_CXSIZE;
+ rect->bottom = rect->top + SYSMETRICS_CYSIZE;
+ }
+ return TRUE;
+ }
+ return FALSE;
}
/***********************************************************************
@@ -862,29 +869,53 @@
*
* Track a mouse button press on the system menu.
*/
-static void NC_TrackSysMenu( HWND hwnd, HDC16 hdc, POINT16 pt )
+static void NC_TrackSysMenu( HWND hwnd, POINT16 pt )
{
- RECT16 rect;
- WND *wndPtr = WIN_FindWndPtr( hwnd );
- int iconic = wndPtr->dwStyle & WS_MINIMIZE;
- HMENU16 hmenu;
+ WND* wndPtr = WIN_FindWndPtr( hwnd );
- if (!(wndPtr->dwStyle & WS_SYSMENU)) return;
-
- /* If window has a menu, track the menu bar normally if it not minimized */
- if (HAS_MENU(wndPtr) && !iconic) MENU_TrackMouseMenuBar( hwnd, pt );
- else
+ if (wndPtr->dwStyle & WS_SYSMENU)
{
- /* Otherwise track the system menu like a normal popup menu */
+ int iconic, on = 1;
- NC_GetSysPopupPos( wndPtr, &rect );
- if (!iconic) NC_DrawSysButton( hwnd, hdc, TRUE );
- hmenu = GetSystemMenu(hwnd, 0);
- MENU_InitSysMenuPopup(hmenu, wndPtr->dwStyle,
- wndPtr->class->style);
- TrackPopupMenu16( hmenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
- rect.left, rect.bottom, 0, hwnd, &rect );
- if (!iconic) NC_DrawSysButton( hwnd, hdc, FALSE );
+ iconic = wndPtr->dwStyle & WS_MINIMIZE;
+
+ if( !iconic )
+ {
+ HDC16 hdc = GetWindowDC32(hwnd);
+ RECT16 rect, rTrack;
+ BOOL32 bNew, bTrack = TRUE;
+ MSG16 msg;
+
+ NC_GetSysPopupPos( wndPtr, &rect );
+ rTrack = rect;
+ MapWindowPoints16( 0, hwnd, (LPPOINT16)&rTrack, 2 );
+
+ /* track mouse while waiting for WM_LBUTTONUP */
+
+ NC_DrawSysButton( hwnd, hdc, bTrack );
+ SetCapture32(hwnd);
+ do
+ {
+ msg.message = WM_NULL;
+ PeekMessage16( &msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE);
+ if( msg.message == WM_MOUSEMOVE )
+ {
+ if( (bNew = PtInRect16(&rTrack, MAKEPOINT16(msg.lParam))) )
+ { if( bTrack ) continue; }
+ else
+ { if(!bTrack ) continue; }
+ NC_DrawSysButton( hwnd, hdc, bTrack = bNew);
+ }
+ } while( msg.message != WM_LBUTTONUP );
+
+ ReleaseCapture();
+ ReleaseDC32(hwnd, hdc);
+ on = PtInRect16(&rTrack, MAKEPOINT16(msg.lParam));
+ }
+
+ if( on )
+ SendMessage16( hwnd, WM_SYSCOMMAND,
+ SC_MOUSEMENU + HTSYSMENU, *((LPARAM*)&pt));
}
}
@@ -1170,7 +1201,7 @@
if (!moved && (wndPtr->dwStyle & WS_MINIMIZE))
{
- NC_TrackSysMenu( hwnd, hdc, pt );
+ NC_TrackSysMenu( hwnd, pt );
return;
}
@@ -1293,8 +1324,6 @@
*/
LONG NC_HandleNCLButtonDown( HWND32 hwnd, WPARAM16 wParam, LPARAM lParam )
{
- HDC32 hdc;
-
switch(wParam) /* Hit test */
{
case HTCAPTION:
@@ -1302,9 +1331,7 @@
break;
case HTSYSMENU:
- hdc = GetWindowDC32( hwnd );
- NC_TrackSysMenu( hwnd, hdc, MAKEPOINT16(lParam) );
- ReleaseDC32( hwnd, hdc );
+ NC_TrackSysMenu( hwnd, MAKEPOINT16(lParam) );
break;
case HTMENU:
@@ -1413,10 +1440,6 @@
ShowWindow( hwnd, SW_RESTORE );
break;
- case SC_NEXTWINDOW:
- case SC_PREVWINDOW:
- break;
-
case SC_CLOSE:
return SendMessage16( hwnd, WM_CLOSE, 0, 0 );
@@ -1427,30 +1450,31 @@
break;
case SC_MOUSEMENU:
- MENU_TrackMouseMenuBar( hwnd, pt );
+ MENU_TrackMouseMenuBar( wndPtr, wParam & 0x000F, pt );
break;
case SC_KEYMENU:
MENU_TrackKbdMenuBar( wndPtr , wParam , pt.x );
break;
- case SC_ARRANGE:
- break;
-
case SC_TASKLIST:
- WinExec( "taskman.exe", SW_SHOWNORMAL );
- break;
-
- case SC_HOTKEY:
+ WinExec32( "taskman.exe", SW_SHOWNORMAL );
break;
case SC_SCREENSAVE:
if (wParam == SC_ABOUTWINE)
{
- extern const char people[];
- ShellAbout(hwnd,"WINE",people,0);
+ extern const char people[];
+ ShellAbout32A(hwnd,"Wine",people,0);
}
break;
+
+ case SC_HOTKEY:
+ case SC_ARRANGE:
+ case SC_NEXTWINDOW:
+ case SC_PREVWINDOW:
+ /* FIXME: unimplemented */
+ break;
}
return 0;
}
diff --git a/windows/painting.c b/windows/painting.c
index e3dfda3..42dacc6 100644
--- a/windows/painting.c
+++ b/windows/painting.c
@@ -491,9 +491,18 @@
/***********************************************************************
- * InvalidateRgn (USER.126) (USER32.328)
+ * InvalidateRgn16 (USER.126)
*/
-void InvalidateRgn( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
+void InvalidateRgn16( HWND16 hwnd, HRGN16 hrgn, BOOL16 erase )
+{
+ RedrawWindow32(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
+}
+
+
+/***********************************************************************
+ * InvalidateRgn32 (USER32.328)
+ */
+void InvalidateRgn32( HWND32 hwnd, HRGN32 hrgn, BOOL32 erase )
{
RedrawWindow32(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
}
@@ -518,9 +527,18 @@
/***********************************************************************
- * ValidateRgn (USER.128) (USER32.571)
+ * ValidateRgn16 (USER.128)
*/
-void ValidateRgn( HWND32 hwnd, HRGN32 hrgn )
+void ValidateRgn16( HWND16 hwnd, HRGN16 hrgn )
+{
+ RedrawWindow32( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
+}
+
+
+/***********************************************************************
+ * ValidateRgn32 (USER32.571)
+ */
+void ValidateRgn32( HWND32 hwnd, HRGN32 hrgn )
{
RedrawWindow32( hwnd, NULL, hrgn, RDW_VALIDATE | RDW_NOCHILDREN );
}
diff --git a/windows/scroll.c b/windows/scroll.c
index b416537..8689f90 100644
--- a/windows/scroll.c
+++ b/windows/scroll.c
@@ -9,21 +9,21 @@
#define NO_TRANSITION_TYPES /* This file is Win32-clean */
#include <stdlib.h>
-#include "wintypes.h"
+#include "windows.h"
#include "class.h"
#include "win.h"
#include "gdi.h"
+#include "dce.h"
#include "region.h"
+#include "graphics.h"
#include "sysmetrics.h"
#include "stddebug.h"
#include "debug.h"
extern HWND32 CARET_GetHwnd(); /* windows/caret.c */
+extern void CARET_GetRect(LPRECT32);
extern void CLIPPING_UpdateGCRegion(DC* ); /* objects/clipping.c */
-static int RgnType;
-
-
/*************************************************************************
* ScrollWindow16 (USER.61)
*/
@@ -38,7 +38,6 @@
clipRect ? &clipRect32 : NULL );
}
-
/*************************************************************************
* ScrollWindow32 (USER32.449)
*/
@@ -109,7 +108,14 @@
RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW, RDW_C_USEHRGN );
DeleteObject32( hrgnUpdate );
- if( hCaretWnd ) ShowCaret(hCaretWnd);
+ if( hCaretWnd )
+ {
+ POINT32 pt;
+ GetCaretPos32(&pt);
+ pt.x += dx; pt.y += dy;
+ SetCaretPos(pt.x, pt.y);
+ ShowCaret(hCaretWnd);
+ }
return TRUE;
}
@@ -134,44 +140,72 @@
/*************************************************************************
* ScrollDC32 (USER32.448)
+ *
+ * Both 'rc' and 'rLClip' are in logical units but update info is
+ * returned in device coordinates.
*/
BOOL32 ScrollDC32( HDC32 hdc, INT32 dx, INT32 dy, const RECT32 *rc,
- const RECT32 *cliprc, HRGN32 hrgnUpdate, LPRECT32 rcUpdate )
+ const RECT32 *prLClip, HRGN32 hrgnUpdate, LPRECT32 rcUpdate )
{
+ RECT32 rDClip, rLClip;
HRGN32 hrgnClip = 0;
HRGN32 hrgnScrollClip = 0;
- RECT32 rectClip;
POINT32 src, dest;
- INT32 width, height;
+ INT32 ldx, ldy;
DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
- dprintf_scroll(stddeb,"ScrollDC: dx=%d dy=%d, hrgnUpdate=%04x rcUpdate = %p cliprc = %p, rc=%d %d %d %d\n",
- dx, dy, hrgnUpdate, rcUpdate, cliprc, rc ? rc->left : 0,
- rc ? rc->top : 0, rc ? rc->right : 0, rc ? rc->bottom : 0 );
+ dprintf_scroll(stddeb,"ScrollDC: %04x %d,%d hrgnUpdate=%04x rcUpdate = %p cliprc = (%d,%d-%d,%d), rc=(%d,%d-%d,%d)\n",
+ (HDC16)hdc, dx, dy, hrgnUpdate, rcUpdate,
+ prLClip ? prLClip->left : 0, prLClip ? prLClip->top : 0, prLClip ? prLClip->right : 0, prLClip ? prLClip->bottom : 0,
+ rc ? rc->left : 0, rc ? rc->top : 0, rc ? rc->right : 0, rc ? rc->bottom : 0 );
if ( !dc || !hdc ) return FALSE;
- /* set clipping region */
+/*
+ printf(stddeb,"\t[wndOrgX=%i, wndExtX=%i, vportOrgX=%i, vportExtX=%i]\n",
+ dc->wndOrgX, dc->wndExtX, dc->vportOrgX, dc->vportExtX );
+ printf(stddeb,"\t[wndOrgY=%i, wndExtY=%i, vportOrgY=%i, vportExtY=%i]\n",
+ dc->wndOrgY, dc->wndExtY, dc->vportOrgY, dc->vportExtY );
+*/
- if ( !rc ) GetClipBox32( hdc, &rectClip );
- else rectClip = *rc;
+ /* compute device clipping region */
- if (cliprc)
- IntersectRect32(&rectClip,&rectClip,cliprc);
+ if ( rc )
+ {
+ rLClip = *rc;
+ rDClip.left = XLPTODP(dc, rc->left); rDClip.right = XLPTODP(dc, rc->right);
+ rDClip.top = YLPTODP(dc, rc->top); rDClip.bottom = YLPTODP(dc, rc->bottom);
+ }
+ else /* maybe we should just return FALSE? */
+ {
+ GetClipBox32( hdc, &rDClip );
+ rLClip.left = XDPTOLP(dc, rDClip.left); rLClip.right = XDPTOLP(dc, rDClip.right);
+ rLClip.top = YDPTOLP(dc, rDClip.top); rLClip.bottom = YDPTOLP(dc, rDClip.bottom);
+ }
- if( rectClip.left >= rectClip.right || rectClip.top >= rectClip.bottom )
+ if (prLClip)
+ {
+ RECT32 r;
+
+ r.left = XLPTODP(dc, prLClip->left); r.right = XLPTODP(dc, prLClip->right);
+ r.top = YLPTODP(dc, prLClip->top); r.bottom = YLPTODP(dc, prLClip->bottom);
+ IntersectRect32(&rLClip,&rLClip,prLClip);
+ IntersectRect32(&rDClip,&rDClip,&r);
+ }
+
+ if( rDClip.left >= rDClip.right || rDClip.top >= rDClip.bottom )
return FALSE;
hrgnClip = GetClipRgn16(hdc);
- hrgnScrollClip = CreateRectRgnIndirect32(&rectClip);
+ hrgnScrollClip = CreateRectRgnIndirect32(&rDClip);
if( hrgnClip )
{
- /* save a copy and change cliprgn directly */
+ /* change device clipping region directly */
CombineRgn32( hrgnScrollClip, hrgnClip, 0, RGN_COPY );
- SetRectRgn( hrgnClip, rectClip.left, rectClip.top,
- rectClip.right, rectClip.bottom );
+ SetRectRgn( hrgnClip, rDClip.left, rDClip.top,
+ rDClip.right, rDClip.bottom );
CLIPPING_UpdateGCRegion( dc );
}
@@ -180,80 +214,80 @@
/* translate coordinates */
- if (dx > 0)
- {
- src.x = XDPTOLP(dc, rectClip.left);
- dest.x = XDPTOLP(dc, rectClip.left + abs(dx));
- }
- else
- {
- src.x = XDPTOLP(dc, rectClip.left + abs(dx));
- dest.x = XDPTOLP(dc, rectClip.left);
- }
- if (dy > 0)
- {
- src.y = YDPTOLP(dc, rectClip.top);
- dest.y = YDPTOLP(dc, rectClip.top + abs(dy));
- }
- else
- {
- src.y = YDPTOLP(dc, rectClip.top + abs(dy));
- dest.y = YDPTOLP(dc, rectClip.top);
- }
+ ldx = dx * dc->wndExtX / dc->vportExtX;
+ ldy = dy * dc->wndExtY / dc->vportExtY;
- width = rectClip.right - rectClip.left - abs(dx);
- height = rectClip.bottom - rectClip.top - abs(dy);
+ if (dx > 0)
+ dest.x = (src.x = rLClip.left) + ldx;
+ else
+ src.x = (dest.x = rLClip.left) - ldx;
+
+ if (dy > 0)
+ dest.y = (src.y = rLClip.top) + ldy;
+ else
+ src.y = (dest.y = rLClip.top) - ldy;
/* copy bits */
- if (!BitBlt32( hdc, dest.x, dest.y, width, height, hdc, src.x, src.y,
- SRCCOPY))
- return FALSE;
+ if( rDClip.right - rDClip.left > dx &&
+ rDClip.bottom - rDClip.top > dy )
+ {
+ ldx = rLClip.right - rLClip.left - ldx;
+ ldy = rLClip.bottom - rLClip.top - ldy;
+
+ if (!BitBlt32( hdc, dest.x, dest.y, ldx, ldy,
+ hdc, src.x, src.y, SRCCOPY))
+ return FALSE;
+ }
+
+ /* restore clipping region */
+
+ if( hrgnClip )
+ {
+ CombineRgn32( hrgnClip, hrgnScrollClip, 0, RGN_COPY );
+ CLIPPING_UpdateGCRegion( dc );
+ SetRectRgn( hrgnScrollClip, rDClip.left, rDClip.top,
+ rDClip.right, rDClip.bottom );
+ }
+ else
+ SelectClipRgn32( hdc, 0 );
/* compute update areas */
if (hrgnUpdate || rcUpdate)
{
- HRGN32 hrgn1 = (hrgnUpdate) ? hrgnUpdate : CreateRectRgn32( 0,0,0,0 );
+ HRGN32 hrgn = (hrgnUpdate) ? hrgnUpdate : CreateRectRgn32( 0,0,0,0 );
if( dc->w.hVisRgn )
{
- CombineRgn32( hrgn1, dc->w.hVisRgn, 0, RGN_COPY );
- CombineRgn32( hrgn1, hrgn1, hrgnClip ? hrgnClip : hrgnScrollClip,
- RGN_AND );
- OffsetRgn32( hrgn1, dx, dy );
- CombineRgn32( hrgn1, dc->w.hVisRgn, hrgn1, RGN_DIFF );
- RgnType = CombineRgn32( hrgn1, hrgn1,
- hrgnClip ? hrgnClip : hrgnScrollClip,
- RGN_AND );
+ CombineRgn32( hrgn, dc->w.hVisRgn, hrgnScrollClip, RGN_AND );
+ OffsetRgn32( hrgn, dx, dy );
+ CombineRgn32( hrgn, dc->w.hVisRgn, hrgn, RGN_DIFF );
+ CombineRgn32( hrgn, hrgn, hrgnScrollClip, RGN_AND );
}
else
{
RECT32 rect;
- rect = rectClip; /* vertical band */
+ rect = rDClip; /* vertical band */
if (dx > 0) rect.right = rect.left + dx;
else if (dx < 0) rect.left = rect.right + dx;
else SetRectEmpty32( &rect );
- SetRectRgn( hrgn1, rect.left, rect.top, rect.right, rect.bottom );
+ SetRectRgn( hrgn, rect.left, rect.top, rect.right, rect.bottom );
- rect = rectClip; /* horizontal band */
+ rect = rDClip; /* horizontal band */
if (dy > 0) rect.bottom = rect.top + dy;
else if (dy < 0) rect.top = rect.bottom + dy;
else SetRectEmpty32( &rect );
- RgnType = REGION_UnionRectWithRgn( hrgn1, &rect );
+ REGION_UnionRectWithRgn( hrgn, &rect );
}
- if (rcUpdate) GetRgnBox32( hrgn1, rcUpdate );
- if (!hrgnUpdate) DeleteObject32( hrgn1 );
+ if (rcUpdate) GetRgnBox32( hrgn, rcUpdate );
+ if (!hrgnUpdate) DeleteObject32( hrgn );
}
- /* restore clipping region */
-
- SelectClipRgn32( hdc, hrgnClip ? hrgnScrollClip : 0 );
DeleteObject32( hrgnScrollClip );
-
return TRUE;
}
@@ -272,49 +306,156 @@
if (clipRect) CONV_RECT16TO32( clipRect, &clipRect32 );
ret = ScrollWindowEx32( hwnd, dx, dy, rect ? &rect32 : NULL,
clipRect ? &clipRect32 : NULL, hrgnUpdate,
- &rcUpdate32, flags );
+ (rcUpdate) ? &rcUpdate32 : NULL, flags );
if (rcUpdate) CONV_RECT32TO16( &rcUpdate32, rcUpdate );
return ret;
}
+/*************************************************************************
+ * SCROLL_FixCaret
+ */
+BOOL32 SCROLL_FixCaret(HWND32 hWnd, LPRECT32 lprc, UINT32 flags)
+{
+ HWND32 hCaret = CARET_GetHwnd();
+
+ if( hCaret )
+ {
+ RECT32 rc;
+ CARET_GetRect( &rc );
+ if( hCaret == hWnd ||
+ (flags & SW_SCROLLCHILDREN && IsChild(hWnd, hCaret)) )
+ {
+ POINT32 pt;
+
+ pt.x = rc.left; pt.y = rc.top;
+ MapWindowPoints32( hCaret, hWnd, (LPPOINT32)&rc, 2 );
+ if( IntersectRect32(lprc, lprc, &rc) )
+ {
+ HideCaret(0);
+ lprc->left = pt.x; lprc->top = pt.y;
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
/*************************************************************************
* ScrollWindowEx32 (USER32.450)
- *
- * FIXME: broken, is there a program that actually uses it?
- *
*/
INT32 ScrollWindowEx32( HWND32 hwnd, INT32 dx, INT32 dy, const RECT32 *rect,
const RECT32 *clipRect, HRGN32 hrgnUpdate,
LPRECT32 rcUpdate, UINT32 flags )
{
- HDC32 hdc;
+ INT32 retVal = NULLREGION;
+ BOOL32 bCaret = FALSE, bOwnRgn = TRUE;
RECT32 rc, cliprc;
+ WND* wnd = WIN_FindWndPtr( hwnd );
- fprintf( stderr, "ScrollWindowEx: not fully implemented\n" );
+ if( !wnd || !WIN_IsWindowDrawable( wnd, TRUE )) return ERROR;
- dprintf_scroll(stddeb,"ScrollWindowEx: dx=%d, dy=%d, wFlags=%04x\n",
- dx, dy, flags);
+ if (rect == NULL) GetClientRect32(hwnd, &rc);
+ else rc = *rect;
- hdc = GetDC32(hwnd);
+ if (clipRect) IntersectRect32(&cliprc,&rc,clipRect);
+ else cliprc = rc;
- if (rect == NULL)
- GetClientRect32(hwnd, &rc);
- else
- CopyRect32(&rc, rect);
- if (clipRect == NULL)
- GetClientRect32(hwnd, &cliprc);
- else
- CopyRect32(&cliprc, clipRect);
-
- ScrollDC32( hdc, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate );
-
- if (flags | SW_INVALIDATE)
+ if (!IsRectEmpty32(&cliprc) && (dx || dy))
{
- PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
- ((flags & SW_ERASE) ? RDW_ERASENOW : 0), 0 );
- }
+ DC* dc;
+ HDC32 hDC;
+ BOOL32 bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
+ HRGN32 hrgnClip = CreateRectRgnIndirect32(&cliprc);
- ReleaseDC32(hwnd, hdc);
- return RgnType;
+dprintf_scroll(stddeb,"ScrollWindowEx: %04x, %d,%d hrgnUpdate=%04x rcUpdate = %p \
+cliprc = (%d,%d-%d,%d), rc=(%d,%d-%d,%d) %04x\n",
+(HWND16)hwnd, dx, dy, hrgnUpdate, rcUpdate,
+clipRect?clipRect->left:0, clipRect?clipRect->top:0, clipRect?clipRect->right:0, clipRect?clipRect->bottom:0,
+rect?rect->left:0, rect?rect->top:0, rect ?rect->right:0, rect ?rect->bottom:0, (UINT16)flags );
+
+ rc = cliprc;
+ bCaret = SCROLL_FixCaret(hwnd, &rc, flags);
+
+ if( hrgnUpdate ) bOwnRgn = FALSE;
+ else if( bUpdate ) hrgnUpdate = CreateRectRgn32( 0, 0, 0, 0 );
+
+ hDC = GetDCEx32( hwnd, hrgnClip, DCX_CACHE | DCX_USESTYLE |
+ (flags & SW_SCROLLCHILDREN) ? DCX_NOCLIPCHILDREN : 0 );
+ if( (dc = (DC *)GDI_GetObjPtr(hDC, DC_MAGIC)) )
+ {
+ POINT32 dst, src;
+
+ if( dx > 0 ) dst.x = (src.x = dc->w.DCOrgX + cliprc.left) + dx;
+ else src.x = (dst.x = dc->w.DCOrgX + cliprc.left) - dx;
+
+ if( dy > 0 ) dst.y = (src.y = dc->w.DCOrgY + cliprc.top) + dy;
+ else src.y = (dst.y = dc->w.DCOrgY + cliprc.top) - dy;
+
+ if( bUpdate )
+ XSetGraphicsExposures( display, dc->u.x.gc, True );
+ XSetFunction( display, dc->u.x.gc, GXcopy );
+ XCopyArea( display, dc->u.x.drawable, dc->u.x.drawable, dc->u.x.gc,
+ src.x, src.y, cliprc.right - cliprc.left - abs(dx),
+ cliprc.bottom - cliprc.top - abs(dy), dst.x, dst.y );
+ if( bUpdate )
+ XSetGraphicsExposures( display, dc->u.x.gc, False );
+
+ if( dc->w.hVisRgn && bUpdate )
+ {
+ CombineRgn32( hrgnUpdate, dc->w.hVisRgn, hrgnClip, RGN_AND );
+ OffsetRgn32( hrgnUpdate, dx, dy );
+ CombineRgn32( hrgnUpdate, dc->w.hVisRgn, hrgnUpdate, RGN_DIFF );
+ CombineRgn32( hrgnUpdate, hrgnUpdate, hrgnClip, RGN_AND );
+
+ if( rcUpdate ) GetRgnBox32( hrgnUpdate, rcUpdate );
+ }
+ ReleaseDC32(hwnd, hDC);
+ }
+
+ if( wnd->hrgnUpdate > 1 )
+ {
+ if( rect || clipRect )
+ {
+ if( (CombineRgn32( hrgnClip, hrgnClip,
+ wnd->hrgnUpdate, RGN_AND ) != NULLREGION) )
+ {
+ CombineRgn32( wnd->hrgnUpdate, wnd->hrgnUpdate, hrgnClip, RGN_DIFF );
+ OffsetRgn32( hrgnClip, dx, dy );
+ CombineRgn32( wnd->hrgnUpdate, wnd->hrgnUpdate, hrgnClip, RGN_OR );
+ }
+ }
+ else
+ OffsetRgn32( wnd->hrgnUpdate, dx, dy );
+ }
+
+ if( flags & SW_SCROLLCHILDREN )
+ {
+ RECT32 r;
+ WND* w;
+ for( w = wnd->child; w; w = w->next )
+ {
+ CONV_RECT16TO32( &w->rectWindow, &r );
+ if( IntersectRect32(&r, &r, &cliprc) )
+ SetWindowPos(w->hwndSelf, 0, w->rectWindow.left + dx,
+ w->rectWindow.top + dy, 0,0, SWP_NOZORDER |
+ SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOREDRAW |
+ SWP_DEFERERASE );
+ }
+ }
+
+ if( flags & (SW_INVALIDATE | SW_ERASE) )
+ PAINT_RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE |
+ ((flags & SW_ERASE) ? RDW_ERASENOW : 0), 0 );
+
+ if( bCaret )
+ {
+ SetCaretPos( rc.left + dx, rc.top + dy );
+ ShowCaret(0);
+ }
+
+ if( bOwnRgn && hrgnUpdate ) DeleteObject32( hrgnUpdate );
+ DeleteObject32( hrgnClip );
+ }
+ return retVal;
}
+
diff --git a/windows/winpos.c b/windows/winpos.c
index 3142e14..9061686 100644
--- a/windows/winpos.c
+++ b/windows/winpos.c
@@ -1346,7 +1346,7 @@
{
while( w != wndPtr->owner )
{
- hwndLocalPrev = w->hwndSelf;
+ if (w != wndPtr) hwndLocalPrev = w->hwndSelf;
if( hwndLocalPrev == hwndInsertAfter ) break;
w = w->next;
}
diff --git a/windows/winproc.c b/windows/winproc.c
index 6cbe823..e8946ee 100644
--- a/windows/winproc.c
+++ b/windows/winproc.c
@@ -9,8 +9,7 @@
#include "windows.h"
#include "callback.h"
#include "heap.h"
-#include "ldt.h"
-#include "registers.h"
+#include "selectors.h"
#include "stackframe.h"
#include "struct32.h"
#include "win.h"