Release 960114
Sun Jan 14 13:45:22 1996 Alexandre Julliard <julliard@sunsite.unc.edu>
* [configure.in]
Added check for gcc strength-reduce bug.
* [controls/listbox.c]
Changed ListBoxDirectory() to use the new DOS file functions.
* [controls/menu.c]
Fixed parameters for DeleteMenu() call in ChangeMenu().
* [debugger/stack.c]
Also display current frame in back-trace.
* [files/directory.c] [files/dos_fs.c] [files/drive.c] [files/file.c]
Complete rewrite of the DOS file handling.
Implemented per-task file handles.
Removed default Z: drive; needs to be put explicitely in wine.ini
if desired.
* [loader/module.c]
Fixed file descriptor leak in LoadModule().
* [loader/task.c]
Initialise PDB file handle table in TASK_CreateTask().
Close file handles on task termination.
Implemented SetErrorMode().
* [misc/network.c]
Fixed WNetGetConnection() to use GetDriveType().
* [misc/xmalloc.c]
Added function xstrdup().
* [miscemu/int21.c]
Many changes for new DOS file functions.
* [miscemu/interrupts.c]
Moved DOS_GetEquipment() function into INT_Int11Handler().
* [windows/win.c]
Bug fix: create system menu before sending WM_NCCREATE.
* [*/*.c]
Replaced strcasecmp and strncasecmp by lstrcmpi and lstrncmpi for
better portability.
Sat Jan 13 16:13:02 1996 Jim Peterson <jspeter@birch.ee.vt.edu>
* [include/wintypes.h]
Added 'typedef HGLOBAL GOBALHANDLE;'. This is not precisely in line
with the true windows 'typedef HANDLE GLOBALHANDLE;', but I believe
it should suffice.
* [include/winsock.h]
Added '#include <arpa/inet.h>' for various declarations. '#ifdef'-ed
out some old style internet address #define's.
* [loader/task.c]
Made MakeProcInstance() return first parameter #ifdef WINELIB32.
Made FreeProcInstance() do nothing #ifdef WINELIB32.
'#ifdef'-ed out TASK_AllocThunk(), as it was unused in WINELIB32.
* [library/miscstubs.c]
Made GetWndProcEntry16() return ACTIVATEAPP_callback() when called
with name="ActivateAppProc". This hardly seems correct, but it's my
best guess as to how the emulator responds.
Sat Jan 6 17:57:45 1996 Martin von Loewis <loewis@informatik.hu-berlin.de>
* [if1632/kernel32.spec][win32/process.c]
WIN32_GetProcAddress, LoadLibraryA: new functions
* [if1632/relay32.c]
RELAY32_GetEntryPoint: Removed code to load PE DLLs
* [include/pe_image.h][include/pe_exe.h]
struct pe_data: new fields base_addr,load_addr,vma_size,pe_reloc
struct PE_Reloc_Block: new structure
* [loader/module.c]
MODULE_RegisterModule: new function
* [loader/pe_image.c]
PE_FindExportedFunction,PE_GetProcAddress: new functions
fixup_imports: expect struct w_files* now, fill dlls_to_init,
load PE DLLs
do_relocations: new functions
calc_vma_size: renamed from dump_table
PE_LoadImage: use malloc to allocate memory for image
PE_InitDLL: expect HMODULE
PE_InitializeDLLs: new function
* [loader/task.c]
NE_InitializeDLLs: branch to PE_InitializeDLLs for PE modules
GetExePtr: Accept PE modules
* [misc/commdlg.c]
FILEDLG_WMCommand: unpack WIN32 WM_COMMAND appropriately for WineLib
Thu Jan 4 11:36:21 1996 Manfred Weichel <Manfred.Weichel@mch.sni.de>
* [misc/port.c]
New file with usleep() function for SVR4.
* [configure.in]
Check for usleep() function.
Tue Jan 02 14:00:00 1996 Anand Kumria <akumria@ozemail.com.au>
* [if1632/toolhelp.spec] [include/toolhelp.h]
[misc/user.c] [windows/message.c]
Implement TOOLHELP.80 TimerCount. Fix GetTickCount.
* [winsocket.c]
Fixed ENOENT error.
* [miscemu/dpmi.c]
Implement DPMI Get Page Size (AX=0604, INT 31)
* [memory/global.c]
Implement TOOLHELP.72 GetMemManInfo.
Mon Jan 2 10:33:00 1996 Thomas Sandford <t.d.g.sandford@prds-grn.demon.co.uk>
* [if1632/callback.c]
CallWindowProc() - When calling RELAY32_CallWindowProc, check
whether lParam should be a SEGPTR, and if so convert it to one.
* [if1632/gdi.spec] [if1632/kernel32.spec] [if1632/user32.spec]
Numerous functions added, mostly calls to original (win16)
functions. Note that some (many) of these are probably not
strictly correct, but with these additions freecell will at least
display its main window though it is garbled.
* [if1632/winprocs.spec]
Completely rewritten - all WndProcs now have win32 versions to
help with the lparam SEGPTR fix in callback.c
* [include/kernel32.h]
LPTCSTR defined.
* [include/peexe.h]
Definition of PE_Export_Directory amended.
* [include/resource32.h]
New file.
* [include/stackframe.h]
Definition of MAKE_SEGPTR macro #ifdef'd out and replaced with
prototype for replacement function in memory/selector.c which
can operate on any given memory address. This is currently
required for win32 support. It is a dreadful cludge, and will
certainly slow down other programs. If you are not interested
in win32 development you may wish to reverse this patch.
* [include/windows.h]
Definition of SW_SHOWDEFAULT added.
* [loader/pe_image.c]
Extensive rewrites of xmmap() fixup_imports().
PE_LoadImage() - initialisation of bss added, extraction of
module name fixed, initialisation of DLL added.
PE_InitDLL() - now does something.
PE_Win32CallToStart() - initialisation of TEB pointed to by
fs added.
PE_InitTEB() created to perform TEB initialisation.
* [memory/selector.c]
New function MAKE_SEGPTR() - see include/stackframe.h above.
* [misc/user32.c]
USER32_RegisterClassA(), CreateWindowExA() memory allocation
method changed. This is probably now unnecessary with the
new MAKE_SEGPTR handling code.
USER32_DefWndProcA() removed to win32/winprocs.c
USER32_TranslateMessage added.
* [tools/build.c]
handling of win32 spec files changed to support gcc2.6.X
this requires optimisations to be disabled.
* [win32/resource.c] [win32/newfns.c] [win32/heap.c] [win32/winprocs.c]
New files.
* [win32/Makefile.in]
New files heap.c, newfns.c, resource.c and winprocs.c added to build.
* [win32/file.c]
New function W32_SetHandleCount.
* [win32/init.c]
WIN32_GetModuleHandle() - now returns handle of running process
if called with NULL.
GetStartupInfoA() - set cbReserved2 to 0.
* [win32/memory.c]
VirtualAlloc() - set mmap() file parameter to -1 instead of 0 to make
it work with FreeBSD. Also check for return value. Removed extra
return.
* [windows/winpos.c]
ShowWindow() - SW_SHOWDEFAULT handling kludged in.
diff --git a/loader/task.c b/loader/task.c
index e7f2835..5e45faf 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -10,7 +10,9 @@
#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"
@@ -75,11 +77,10 @@
{
static const char program_name[] = "KRNL386.EXE";
char **e, *p;
- int initial_size, size;
+ int initial_size, size, i, winpathlen, windirlen, sysdirlen;
HANDLE handle;
extern char **environ;
- extern char WindowsDirectory[], SystemDirectory[];
/* DOS environment format:
* ASCIIZ string 1
@@ -95,20 +96,27 @@
/* First compute the size of the fixed part of the environment */
- initial_size = 5 + /* PATH= */
- strlen(WindowsPath) + 1 + /* path value */
- 7 + /* windir= */
- strlen(WindowsDirectory) + 1 + /* windir value */
- 1 + /* BYTE 0 at end */
- sizeof(WORD) + /* WORD 1 */
- strlen(SystemDirectory) + 1 + /* program directory */
- strlen(program_name) + 1; /* program name */
+ for (i = winpathlen = 0; ; i++)
+ {
+ int len = DIR_GetDosPath( i, NULL, 0 );
+ if (!len) break;
+ winpathlen += len + 1;
+ }
+ if (!winpathlen) winpathlen = 1;
+ windirlen = GetWindowsDirectory( NULL, 0 ) + 1;
+ sysdirlen = GetSystemDirectory( NULL, 0 ) + 1;
+ initial_size = 5 + winpathlen + /* PATH=xxxx */
+ 7 + windirlen + /* windir=xxxx */
+ 1 + /* BYTE 0 at end */
+ sizeof(WORD) + /* WORD 1 */
+ sysdirlen + /* program directory */
+ strlen(program_name) + 1; /* program name */
/* Compute the total size of the Unix environment (except path) */
for (e = environ, size = initial_size; *e; e++)
{
- if (strncasecmp(*e, "path=", 5))
+ if (lstrncmpi(*e, "path=", 5))
{
int len = strlen(*e) + 1;
if (size + len >= 32767)
@@ -130,7 +138,7 @@
for (e = environ, size = initial_size; *e; e++)
{
- if (strncasecmp(*e, "path=", 5))
+ if (lstrncmpi(*e, "path=", 5))
{
int len = strlen(*e) + 1;
if (size + len >= 32767) break;
@@ -143,19 +151,25 @@
/* Now add the path and Windows directory */
strcpy( p, "PATH=" );
- strcat( p, WindowsPath );
- p += strlen(p) + 1;
+ for (i = 0, p += 5; ; i++)
+ {
+ if (!DIR_GetDosPath( i, p, winpathlen )) break;
+ p += strlen(p);
+ *p++ = ';';
+ }
+ if (p[-1] == ';') p[-1] = '\0';
+ else p++;
strcpy( p, "windir=" );
- strcat( p, WindowsDirectory );
- p += strlen(p) + 1;
+ GetWindowsDirectory( p + 7, windirlen );
+ p += 7 + windirlen;
/* Now add the program name */
*p++ = '\0';
*(WORD *)p = 1;
p += sizeof(WORD);
- strcpy( p, SystemDirectory );
+ GetSystemDirectory( p, sysdirlen );
strcat( p, "\\" );
strcat( p, program_name );
@@ -247,6 +261,7 @@
*
* Allocate a thunk for MakeProcInstance().
*/
+#ifndef WINELIB32
static SEGPTR TASK_AllocThunk( HTASK hTask )
{
TDB *pTask;
@@ -275,6 +290,7 @@
pThunk->free = *(WORD *)((BYTE *)pThunk + pThunk->free);
return MAKELONG( base, sel );
}
+#endif
/***********************************************************************
@@ -282,6 +298,7 @@
*
* Free a MakeProcInstance() thunk.
*/
+#ifndef WINELIB32
static BOOL TASK_FreeThunk( HTASK hTask, SEGPTR thunk )
{
TDB *pTask;
@@ -303,6 +320,7 @@
pThunk->free = LOWORD(thunk) - base;
return TRUE;
}
+#endif
/***********************************************************************
@@ -335,10 +353,7 @@
cs_reg = pSegTable[pModule->cs - 1].selector;
ip_reg = pModule->ip;
ds_reg = pSegTable[pModule->dgroup - 1].selector;
-#ifndef WINELIB
-/* JBP: I doubt a CallTo16_regs_ is possible in libwine.a, and IF1632 is not
- * allowed.
- */
+
IF1632_Saved16_ss = pTask->ss;
IF1632_Saved16_sp = pTask->sp;
dprintf_task( stddeb, "Starting main program: cs:ip=%04x:%04x ds=%04x ss:sp=%04x:%04x\n",
@@ -349,11 +364,7 @@
pTask->hPDB /*es*/, 0 /*bp*/, 0 /*ax*/,
pModule->stack_size /*bx*/, pModule->heap_size /*cx*/,
0 /*dx*/, 0 /*si*/, ds_reg /*di*/ );
-#else
- fprintf(stderr, "JBP: Ignoring main program: cs:ip=%04x:%04x ds=%04x ss:sp=%04x:%04x\n",
- cs_reg, ip_reg, ds_reg,
- pTask->ss, pTask->sp);
-#endif
+
/* This should never return */
fprintf( stderr, "TASK_CallToStart: Main program returned!\n" );
TASK_KillCurrentTask( 1 );
@@ -426,12 +437,13 @@
pTask->hParent = hCurrentTask;
#ifdef WINELIB
pTask->curdrive = 'C' - 'A' + 0x80;
+ strcpy( pTask->curdir, "\\" );
#else
pTask->curdrive = filename[0] - 'A' + 0x80;
+ strcpy( pTask->curdir, filename+2 );
#endif
pTask->magic = TDB_MAGIC;
pTask->nCmdShow = cmdShow;
- strcpy( pTask->curdir, filename+2 );
/* Create the thunks block */
@@ -442,30 +454,35 @@
name = MODULE_GetModuleName( hModule );
strncpy( pTask->module_name, name, sizeof(pTask->module_name) );
+ /* Allocate a selector for the PDB */
+
+ pTask->hPDB = GLOBAL_CreateBlock( GMEM_FIXED, &pTask->pdb, sizeof(PDB),
+ hModule, FALSE, FALSE, FALSE, NULL );
+
/* Fill the PDB */
pTask->pdb.int20 = 0x20cd;
+#ifndef WINELIB
pTask->pdb.dispatcher[0] = 0x9a; /* ljmp */
*(DWORD *)&pTask->pdb.dispatcher[1] = MODULE_GetEntryPoint( GetModuleHandle("KERNEL"), 102 ); /* KERNEL.102 is DOS3Call() */
-#ifndef WINELIB
pTask->pdb.savedint22 = INT_GetHandler( 0x22 );
pTask->pdb.savedint23 = INT_GetHandler( 0x23 );
pTask->pdb.savedint24 = INT_GetHandler( 0x24 );
+ pTask->pdb.fileHandlesPtr = (SEGPTR)MAKELONG( 0x18,
+ GlobalHandleToSel(pTask->hPDB) );
+#else
+ pTask->pdb.fileHandlesPtr = pTask->pdb.fileHandles;
#endif
- pTask->pdb.environment = hEnvironment;
- strncpy( pTask->pdb.cmdLine + 1, cmdLine, 126 );
- pTask->pdb.cmdLine[127] = '\0';
+ memset( pTask->pdb.fileHandles, 0xff, sizeof(pTask->pdb.fileHandles) );
+ pTask->pdb.environment = hEnvironment;
+ pTask->pdb.nbFiles = 20;
+ lstrcpyn( pTask->pdb.cmdLine + 1, cmdLine, 127 );
pTask->pdb.cmdLine[0] = strlen( pTask->pdb.cmdLine + 1 );
/* Get the compatibility flags */
pTask->compat_flags = GetProfileInt( name, "Compatibility", 0 );
- /* Allocate a selector for the PDB */
-
- pTask->hPDB = GLOBAL_CreateBlock( GMEM_FIXED, &pTask->pdb, sizeof(PDB),
- hModule, FALSE, FALSE, FALSE, NULL );
-
/* Allocate a code segment alias for the TDB */
pTask->hCSAlias = GLOBAL_CreateBlock( GMEM_FIXED, (void *)pTask,
@@ -561,6 +578,10 @@
if (!(pTask = (TDB *)GlobalLock( hTask ))) return;
+ /* Close all open files of this task */
+
+ FILE_CloseAllFiles( pTask->hPDB );
+
/* Free the task module */
FreeModule( pTask->hModule );
@@ -718,7 +739,11 @@
/***********************************************************************
* InitTask (KERNEL.91)
*/
+#ifdef WINELIB
+void InitTask(void)
+#else
void InitTask( struct sigcontext_struct context )
+#endif
{
static int firstTask = 1;
TDB *pTask;
@@ -727,7 +752,9 @@
INSTANCEDATA *pinstance;
LONG stacklow, stackhi;
+#ifndef WINELIB
EAX_reg(&context) = 0;
+#endif
if (!(pTask = (TDB *)GlobalLock( hCurrentTask ))) return;
if (!(pModule = (NE_MODULE *)GlobalLock( pTask->hModule ))) return;
@@ -782,7 +809,7 @@
pinstance = (INSTANCEDATA *)PTR_SEG_OFF_TO_LIN(CURRENT_DS, 0);
pinstance->stackbottom = stackhi; /* yup, that's right. Confused me too. */
pinstance->stacktop = stacklow;
-#ifndef WINELIB /* FIXME: JBP: IF1632 not allowed in libwine.a */
+#ifndef WINELIB
pinstance->stackmin = IF1632_Saved16_sp;
#endif
}
@@ -857,7 +884,7 @@
/***********************************************************************
* IsTaskLocked (KERNEL.122)
*/
-WORD IsTaskLocked(void)
+HTASK IsTaskLocked(void)
{
return hLockedTask;
}
@@ -905,6 +932,9 @@
*/
FARPROC MakeProcInstance( FARPROC func, HANDLE hInstance )
{
+#ifdef WINELIB32
+ return func; /* func can be called directly in Win32 */
+#else
BYTE *thunk;
SEGPTR thunkaddr;
@@ -916,13 +946,12 @@
(SEGPTR)func, hInstance, (SEGPTR)thunkaddr );
*thunk++ = 0xb8; /* movw instance, %ax */
-#ifndef WINELIB
*thunk++ = (BYTE)(hInstance & 0xff);
*thunk++ = (BYTE)(hInstance >> 8);
-#endif
*thunk++ = 0xea; /* ljmp func */
*(DWORD *)thunk = (DWORD)func;
return (FARPROC)thunkaddr;
+#endif
}
@@ -931,8 +960,10 @@
*/
void FreeProcInstance( FARPROC func )
{
+#ifndef WINELIB32
dprintf_task( stddeb, "FreeProcInstance("SPFMT")\n", (SEGPTR)func );
TASK_FreeThunk( hCurrentTask, (SEGPTR)func );
+#endif
}
@@ -953,8 +984,6 @@
else
handle = GlobalHandle( HIWORD(proc) );
- printf( "STUB: GetCodeHandle(%08lx) returning "NPFMT"\n",
- (DWORD)proc, handle );
return handle;
}
@@ -1050,6 +1079,21 @@
/***********************************************************************
+ * SetErrorMode (KERNEL.107)
+ */
+UINT SetErrorMode( UINT mode )
+{
+ TDB *pTask;
+ UINT oldMode;
+
+ if (!(pTask = (TDB *)GlobalLock( hCurrentTask ))) return 0;
+ oldMode = pTask->error_mode;
+ pTask->error_mode = mode;
+ return oldMode;
+}
+
+
+/***********************************************************************
* GetDOSEnvironment (KERNEL.131)
*/
SEGPTR GetDOSEnvironment(void)
@@ -1108,6 +1152,8 @@
if (!(ptr = GlobalLock( handle ))) return 0;
if (((NE_MODULE *)ptr)->magic == NE_SIGNATURE) return handle;
+ /* Fake modules describing PE modules have a PE signature */
+ if (((NE_MODULE *)ptr)->magic == PE_SIGNATURE) return handle;
/* Check the owner for module handle */
@@ -1115,10 +1161,10 @@
owner = FarGetOwner( handle );
#else
owner = NULL;
- fprintf(stderr,"JBP: FarGetOwner() ignored.\n");
#endif
if (!(ptr = GlobalLock( owner ))) return 0;
if (((NE_MODULE *)ptr)->magic == NE_SIGNATURE) return owner;
+ if (((NE_MODULE *)ptr)->magic == PE_SIGNATURE) return owner;
/* Search for this handle and its owner inside all tasks */