Alexandre Julliard af0bae5873 Release 951003
Sun Oct  1 15:48:34 1995  Alexandre Julliard  <julliard@sunsite.unc>

	* [controls/menu.c]
	Fixed GetMenuString() for non-string items.

	* [debugger/*.c]
	First attempt to check validity of pointers before memory
	accesses. For now only segmented pointers are checked.

	* [debugger/dbg.y] [memory/ldt.c]
	Added possibility to dump only one segment with 'info segment'.

	* [include/bitmaps/ocr_*]
	Added all OEM cursors as XPM bitmaps.

	* [include/cursoricon.h] [objects/cursoricon.c]
	Rewrote all cursor and icon management to use the same memory
 	layout as Windows, and to factor common code between icons and
	cursors. Implemented icon directory lookup to find the best
	matching icon (i.e. the color one).
  	Implemented CopyCursor() and DumpIcon().

	* [loader/module.c]
	For disabled built-in modules, we now try to load the Windows DLL
	first, and if this fails we fall back to using the built-in module
	anyway.

	* [memory/global.c]
	Fixed GlobalHandle() to return the correct selector in the high
	word even if we are passed a handle in the first place.

	* [miscemu/instr.c]
	Take into account the size of the operand and of the stack segment
	when incrementing the stack pointer.
	Avoid referencing FS_reg and GS_reg on *BSD.

	* [objects/dib.c]
	All DIB functions now accept a BITMAPCOREHEADER format bitmap.
	Monochrome DIBs are created as monochrome bitmap iff they are
	black and white.

	* [objects/oembitmap.c]
	Added support for OEM cursors, changed OBM_LoadIcon to use the new
	icon memory layout.

	* [rc/sysres_Fr.rc]
	Added French [Fr] language support.

	* [win32/environment.c]
	Fixed GetCommandLineA() to use current PDB.

	* [windows/event.c] [windows/winpos.c]
	Simulate a mouse motion event upon SetWindowPos() to force the
	cursor to be set correctly.

Sat Sep 30 17:49:32  Cameron Heide  (heide@ee.ualberta.ca)

	* [win32/*]
        New Win32 kernel functions: GetACP, GetCPInfo,
 	GetEnvironmentVariableA, GetFileType, GetLastError, GetOEMCP,
 	GetStartupInfoA, GetTimeZoneInformation, SetEnvironmentVariable,
 	SetFilePointer, SetLastError, VirtualAlloc, VirtualFree,
 	WriteFile.  Completed implementations of GetCommandLineA.

	* [include/kernel32.h]
        New file.

	* [loader/main.c]
        Call initialization function for Win32 data (doesn't currently do
 	anything).

	* [misc/main.c]
	Implemented GetEnvironmentVariableA, SetEnvironmentVariableA.

Sat Sep 30 00:26:56 1995  Niels de Carpentier  <niels@cindy.et.tudelft.nl>

	* [windows/winpos.c][miscemu/emulate.c][loader/module.c]
	  [misc/commdlg.c]
	Misc. bug fixes

Fri Sep 29 16:16:13 1995  Jim Peterson <jspeter@birch.ee.vt.edu>

	* [*/*]
	For Winelib, explicit casts have been placed where warnings were
 	usually generated.
	printf formats which give the format for printing a handle as
 	"%04x" or something similar have been changed to use the NPFMT
 	macro defined in include/wintypes.h.  Some times, explicit casts
 	were also necessary.
     	Parameter, field, and variable declarations have been made more
 	exact, such as converting 'WORD wParam' to 'WPARAM wParam' or
 	'WORD hFont' to 'HFONT hFont'.
     	Any call of the form GetWindowWord(hwnd,GWW_HINSTANCE) has been
 	replaced with a call to WIN_GetWindowInstance(hwnd).

	* [controls/combo.c]
	Added WINELIB32 support in CLBoxGetCombo().

	* [include/dialog.h]
	Commented out the '#ifndef WINELIB' around the '#pragma pack(1)'.
	winelib needs the packing as well (e.g. when accessing resources
	like sysres_DIALOG_SHELL_ABOUT_MSGBOX).

	* [include/windows.h]
	Got rid of the F[a-k] macros, which were cluttering up the global
	namespace.

	* [include/windows.h] [windows/defwnd.c]
	Added Win32 messages WM_CTLCOLOR*.

	* [include/wintypes.h]
	Put in preprocessor '#define WINELIB32' if appropriate and changed
	the types of some typedefs (WPARAM, HANDLE) based on this.
	
	* [loader/module.c] [toolkit/miscstubs.c]
	Added #ifdef'd portion in LoadModule to handle loading a WINElib
	module (already loaded, just init values).  '#ifdef'ed out the
	definition for GetWndProcEntry16 and added a new version to
	toolkit/miscstubs.c.

	* [misc/shell.c]
	Adjusted the lengths of AppName and AppMisc from 512,512 to 128,906.
	Same amount of total storage, but much more reasonable.  Also, changed
	calls to strcpy() in ShellAbout() to calls to strncpy() instead.
	This was a difficult bug to track down, but the AppMisc field was
	being initialized with the contributers text, which was much larger
	than 512 characters.

	* [toolkit/atom.c]
	New file for atom-handling functions.  Copied from memory/atom.c and
	then heavily modified.  Right now, it's just a linked list of atoms.
	Consider it as a hash table with just one entry.  It's easily changed
	later.

	* [toolkit/heap.c]
	Commented out the heap functions with a "#ifdef WINELIB16" and put in
	a Win32 version (which is basically a modified copy).

	* [toolkit/sup.c] [toolkit/miscstubs.c]
	Moved the stuff I put in toolkit/sup.c into toolkit/miscstubs.c and
	added quite a few more stubs.

	* [toolkit/winmain.c]
	Rearranged startup code in _WinMain.  I think this will work.

	* [toolkit/Makefile.in]
	Added targets for 'hello' and 'hello2' in case anyone cares to try
	out the sample programs.

Wed Sep 27 23:13:43 1995  Anand Kumria <akumria@ozemail.com.au>
	
	* [miscemu/int2f.c] [miscemu/vxd.c] [if1632/winprocs.spec]
	First attempt at support for some VxDs. Comm, Shell and Pagefile.

Tue Sep 26 21:34:45 1995  Hans de Graaff  <graaff@twi72.twi.tudelft.nl>

	* [misc/dos_fs.c]
	DOS_SimplifyPath: Also remove "/./" from path. (Happens when
 	starting applications like 'wine ./excel.exe')

Sat Sep 23 23:32:40 1995  Morten Welinder  <terra@diku.dk>

	* [configure.in]
	Avoid relative path for wine.ini.

	* [rc/sysres_Da.rc]
	Support for Danish [Da] language.

	* [misc/main.c] [miscemu/cpu.c]
	Return the processor we're running on correctly.

	* [miscemu/int2f.c]
	Minor stuff in int 0x2f, function 0x16.

Sat Sep 23 1995 17:58:04  Marcus Meissner  <msmeissn@faui01.informatik.uni-erlangen.de>

	* [misc/shell.c] [misc/main.c]
	Implement saving and loading of the registry database (needed for
	OLE). Very experimental. Fixed ShellExecute().
	
	* [miscemu/int21.c]
	EEXIST is not a critical error condition for mkdir().

Fri Sep 22 01:33:34 1995  Alex Korobka  <alex@phm6.pharm.sunysb.edu>

	* [include/shell.h] [misc/shell.c]
	Implemented 4 drag/drop functions with documented functionality.

        * [multimedia/time.c]
        "Fixed" MMSysTimeCallback kludge so Excel5 loads up without crashing.

	* [*/*] 
        Added new files, more message definitions, structures, debug info,
 	etc.  Rewrote message logging functions to produce output similar
 	to WinSight.  Check out -debugmsg +message option.

	* [misc/file.c]
        Fixed GetDriveType return value.  

        * [windows/message.c] 
        Hooks are invoked in normal order.

        * [miscemu/*]
        Added some functions and interrupts.

        * [misc/shell.c]
        Implemented Drag... functions.

Thu Sep 21 23:50:12 1995  Jukka Iivonen <iivonen@cc.helsinki.fi>

	* [rc/sysres_Fi.rc] [rc/sysres.rc]
	First attempt at Finnish [Fi] language support.
1995-10-03 17:06:08 +00:00

351 lines
9.8 KiB
C

/*
* Debugger break-points handling
*
* Copyright 1994 Martin von Loewis
* Copyright 1995 Alexandre Julliard
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
#include "windows.h"
#include "debugger.h"
#define INT3 0xcc /* int 3 opcode */
#define STEP_FLAG 0x100 /* single-step flag */
#define MAX_BREAKPOINTS 25
typedef struct
{
DBG_ADDR addr;
BYTE addrlen;
BYTE opcode;
BOOL enabled;
BOOL in_use;
} BREAKPOINT;
static BREAKPOINT breakpoints[MAX_BREAKPOINTS];
static int next_bp = 1; /* breakpoint 0 is reserved for step-over */
/***********************************************************************
* DEBUG_ChangeOpcode
*
* Change the opcode at segment:addr.
*/
static void DEBUG_SetOpcode( const DBG_ADDR *addr, BYTE op )
{
if (addr->seg)
{
*(BYTE *)PTR_SEG_OFF_TO_LIN( addr->seg, addr->off ) = op;
}
else /* 32-bit code, so we have to change the protection first */
{
/* There are a couple of problems with this. On Linux prior to
1.1.62, this call fails (ENOACCESS) due to a bug in fs/exec.c.
This code is currently not tested at all on BSD.
How do I determine the page size in a more symbolic manner?
And why does mprotect need that start address of the page
in the first place?
Not that portability matters, this code is i386 only anyways...
How do I get the old protection in order to restore it later on?
*/
if (mprotect((caddr_t)(addr->off & (~4095)), 4096,
PROT_READ | PROT_WRITE | PROT_EXEC) == -1)
{
perror( "Can't set break point" );
return;
}
*(BYTE *)addr->off = op;
mprotect((caddr_t)(addr->off & ~4095), 4096,
PROT_READ | PROT_EXEC );
}
}
/***********************************************************************
* DEBUG_IsStepOverInstr
*
* 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 BOOL DEBUG_IsStepOverInstr( struct sigcontext_struct *context )
{
BYTE *instr = (BYTE *)PTR_SEG_OFF_TO_LIN(CS_reg(context),EIP_reg(context));
for (;;)
{
switch(*instr)
{
/* Skip all prefixes */
case 0x2e: /* cs: */
case 0x36: /* ss: */
case 0x3e: /* ds: */
case 0x26: /* es: */
case 0x64: /* fs: */
case 0x65: /* gs: */
case 0x66: /* opcode size prefix */
case 0x67: /* addr size prefix */
case 0xf0: /* lock */
case 0xf2: /* repne */
case 0xf3: /* repe */
instr++;
continue;
/* Handle call instructions */
case 0xe8: /* call <offset> */
case 0x9a: /* lcall <seg>:<off> */
return TRUE;
case 0xff: /* call <regmodrm> */
return (((instr[1] & 0x38) == 0x10) ||
((instr[1] & 0x38) == 0x18));
/* Handle string instructions */
case 0x6c: /* insb */
case 0x6d: /* insw */
case 0x6e: /* outsb */
case 0x6f: /* outsw */
case 0xa4: /* movsb */
case 0xa5: /* movsw */
case 0xa6: /* cmpsb */
case 0xa7: /* cmpsw */
case 0xaa: /* stosb */
case 0xab: /* stosw */
case 0xac: /* lodsb */
case 0xad: /* lodsw */
case 0xae: /* scasb */
case 0xaf: /* scasw */
return TRUE;
default:
return FALSE;
}
}
}
/***********************************************************************
* DEBUG_SetBreakpoints
*
* Set or remove all the breakpoints.
*/
void DEBUG_SetBreakpoints( BOOL set )
{
int i;
for (i = 0; i < MAX_BREAKPOINTS; i++)
{
if (breakpoints[i].in_use && breakpoints[i].enabled)
{
if (DEBUG_IsBadWritePtr( &breakpoints[i].addr, 1 ))
{
fprintf( stderr, "Invalid address for breakpoint %d, disabling it\n", i );
breakpoints[i].enabled = FALSE;
}
else DEBUG_SetOpcode( &breakpoints[i].addr,
set ? INT3 : breakpoints[i].opcode );
}
}
}
/***********************************************************************
* DEBUG_FindBreakpoint
*
* Find the breakpoint for a given address. Return the breakpoint
* number or -1 if none.
*/
int DEBUG_FindBreakpoint( const DBG_ADDR *addr )
{
int i;
for (i = 0; i < MAX_BREAKPOINTS; i++)
{
if (breakpoints[i].in_use && breakpoints[i].enabled &&
breakpoints[i].addr.seg == addr->seg &&
breakpoints[i].addr.off == addr->off) return i;
}
return -1;
}
/***********************************************************************
* DEBUG_AddBreakpoint
*
* Add a breakpoint.
*/
void DEBUG_AddBreakpoint( const DBG_ADDR *address )
{
DBG_ADDR addr = *address;
int num;
BYTE *p;
DBG_FIX_ADDR_SEG( &addr, CS_reg(DEBUG_context) );
if (next_bp < MAX_BREAKPOINTS)
num = next_bp++;
else /* try to find an empty slot */
{
for (num = 1; num < MAX_BREAKPOINTS; num++)
if (!breakpoints[num].in_use) break;
if (num >= MAX_BREAKPOINTS)
{
fprintf( stderr, "Too many breakpoints. Please delete some.\n" );
return;
}
}
if (!DBG_CHECK_READ_PTR( &addr, 1 )) return;
p = DBG_ADDR_TO_LIN( &addr );
breakpoints[num].addr = addr;
breakpoints[num].addrlen = !addr.seg ? 32 :
(GET_SEL_FLAGS(addr.seg) & LDT_FLAGS_32BIT) ? 32 : 16;
breakpoints[num].opcode = *p;
breakpoints[num].enabled = TRUE;
breakpoints[num].in_use = TRUE;
fprintf( stderr, "Breakpoint %d at ", num );
DEBUG_PrintAddress( &breakpoints[num].addr, breakpoints[num].addrlen );
fprintf( stderr, "\n" );
}
/***********************************************************************
* DEBUG_DelBreakpoint
*
* Delete a breakpoint.
*/
void DEBUG_DelBreakpoint( int num )
{
if ((num <= 0) || (num >= next_bp) || !breakpoints[num].in_use)
{
fprintf( stderr, "Invalid breakpoint number %d\n", num );
return;
}
breakpoints[num].enabled = FALSE;
breakpoints[num].in_use = FALSE;
}
/***********************************************************************
* DEBUG_EnableBreakpoint
*
* Enable or disable a break point.
*/
void DEBUG_EnableBreakpoint( int num, BOOL enable )
{
if ((num <= 0) || (num >= next_bp) || !breakpoints[num].in_use)
{
fprintf( stderr, "Invalid breakpoint number %d\n", num );
return;
}
breakpoints[num].enabled = enable;
}
/***********************************************************************
* DEBUG_InfoBreakpoints
*
* Display break points information.
*/
void DEBUG_InfoBreakpoints(void)
{
int i;
fprintf( stderr, "Breakpoints:\n" );
for (i = 1; i < next_bp; i++)
{
if (breakpoints[i].in_use)
{
fprintf( stderr, "%d: %c ", i, breakpoints[i].enabled ? 'y' : 'n');
DEBUG_PrintAddress( &breakpoints[i].addr, breakpoints[i].addrlen );
fprintf( stderr, "\n" );
}
}
}
/***********************************************************************
* DEBUG_ShouldContinue
*
* Determine if we should continue execution after a SIGTRAP signal when
* executing in the given mode.
*/
BOOL DEBUG_ShouldContinue( struct sigcontext_struct *context,
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)--;
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 */
if ((bpnum != 0) && (bpnum != -1))
{
fprintf( stderr, "Stopped on breakpoint %d at ", bpnum );
DEBUG_PrintAddress( &breakpoints[bpnum].addr,
breakpoints[bpnum].addrlen );
fprintf( stderr, "\n" );
return FALSE;
}
/* no breakpoint, continue if in continuous mode */
return (mode == EXEC_CONT);
}
/***********************************************************************
* DEBUG_RestartExecution
*
* Set the breakpoints to the correct state to restart execution
* in the given mode.
*/
void DEBUG_RestartExecution( struct sigcontext_struct *context,
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);
if (DEBUG_FindBreakpoint( &addr ) != -1)
mode = EXEC_STEP_INSTR; /* If there's a breakpoint, skip it */
switch(mode)
{
case EXEC_CONT: /* Continuous execution */
EFL_reg(DEBUG_context) &= ~STEP_FLAG;
DEBUG_SetBreakpoints( TRUE );
break;
case EXEC_STEP_OVER: /* Stepping over a call */
if (DEBUG_IsStepOverInstr(DEBUG_context))
{
EFL_reg(DEBUG_context) &= ~STEP_FLAG;
addr.off += instr_len;
breakpoints[0].addr = addr;
breakpoints[0].enabled = TRUE;
breakpoints[0].in_use = TRUE;
breakpoints[0].opcode = *(BYTE *)DBG_ADDR_TO_LIN( &addr );
DEBUG_SetBreakpoints( TRUE );
break;
}
/* else fall through to single-stepping */
case EXEC_STEP_INSTR: /* Single-stepping an instruction */
EFL_reg(DEBUG_context) |= STEP_FLAG;
break;
}
}