mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
8bbf8180e5
Wed Sep 11 18:08:30 1996 Albrecht Kleine <kleine@ak.sax.de> * [windows/event.c] Minor improvements in setting event time in MSG struct. * [windows/hook.c] Removed an useless 'unimplemented hook' message. * [windows/win.c] Added a WH_CBT hook call during window creation: good for CTL3D.DLL Wed Sep 11 11:19:56 1996 Marcus Meissner <msmeissn@cip.informatik.uni-erlangen.de> * [loader/pe_image.c] Fixed imports with no name/ordinal list (MFC30.DLL). Added borland style - ordinal import (wsock32.dll). * [files/file.c] [win32/file.c] [if1632/kernel.spec] [if1632/kernel32.spec] [include/windows.h] Win32 and Win16 code use the same filehandles/HFILEs. Added SetEndOfFile, MoveFile*, diverse *W functions. * [loader/pe_image.c] Fixed argument 2 to DllEntry. * [misc/comm.c] Adapt to filehandling changes, win32 code still broken. * [misc/registry.c] Use Wine filehandling. StartupRegistry to add startup-detected registry entries. * [miscemu/dpmi.c] [miscemu/int21.c] Some missing interrupt-functions added. * [if1632/gdi32.spec][if1632/user32.spec] Some thunks to 16 bit equivalent functions added. Sat Sep 7 11:36:57 EDT 1996 Matthew Ghio <ghio@netcom.com> * [misc/winsocket.c] Rewrote WINSOCK_select() and WSAFDIsSet() to properly convert Windows fd_set structs. * [if1632/winsock.spec] Corrected arguments to select().
215 lines
6.2 KiB
C
215 lines
6.2 KiB
C
/*
|
|
* Debugger memory handling
|
|
*
|
|
* Copyright 1993 Eric Youngdale
|
|
* Copyright 1995 Alexandre Julliard
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "windows.h"
|
|
#include "debugger.h"
|
|
|
|
|
|
/***********************************************************************
|
|
* DEBUG_IsBadReadPtr
|
|
*
|
|
* Check if we are allowed to read memory at 'address'.
|
|
*/
|
|
BOOL32 DEBUG_IsBadReadPtr( const DBG_ADDR *address, int size )
|
|
{
|
|
if (address->seg) /* segmented addr */
|
|
return IsBadReadPtr16( (SEGPTR)MAKELONG( (WORD)address->off,
|
|
(WORD)address->seg ), size );
|
|
/* FIXME: should check if resulting linear addr is readable */
|
|
else /* linear address */
|
|
return FALSE; /* FIXME: should do some checks here */
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DEBUG_IsBadWritePtr
|
|
*
|
|
* Check if we are allowed to write memory at 'address'.
|
|
*/
|
|
BOOL32 DEBUG_IsBadWritePtr( const DBG_ADDR *address, int size )
|
|
{
|
|
if (address->seg) /* segmented addr */
|
|
/* Note: we use IsBadReadPtr here because we are */
|
|
/* always allowed to write to read-only segments */
|
|
return IsBadReadPtr16( (SEGPTR)MAKELONG( (WORD)address->off,
|
|
(WORD)address->seg ), size );
|
|
/* FIXME: should check if resulting linear addr is writable */
|
|
else /* linear address */
|
|
return FALSE; /* FIXME: should do some checks here */
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DEBUG_ReadMemory
|
|
*
|
|
* Read a memory value.
|
|
*/
|
|
int DEBUG_ReadMemory( const DBG_ADDR *address )
|
|
{
|
|
DBG_ADDR addr = *address;
|
|
|
|
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 );
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DEBUG_WriteMemory
|
|
*
|
|
* Store a value in memory.
|
|
*/
|
|
void DEBUG_WriteMemory( const DBG_ADDR *address, int value )
|
|
{
|
|
DBG_ADDR addr = *address;
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
/***********************************************************************
|
|
* DEBUG_ExamineMemory
|
|
*
|
|
* Implementation of the 'x' command.
|
|
*/
|
|
void DEBUG_ExamineMemory( const DBG_ADDR *address, int count, char format )
|
|
{
|
|
DBG_ADDR addr = *address;
|
|
unsigned char * pnt;
|
|
unsigned int * dump;
|
|
unsigned short int * wdump;
|
|
int i;
|
|
|
|
DBG_FIX_ADDR_SEG( &addr, (format == 'i') ?
|
|
CS_reg(DEBUG_context) : DS_reg(DEBUG_context) );
|
|
|
|
if (format != 'i' && count > 1)
|
|
{
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
}
|
|
|
|
pnt = DBG_ADDR_TO_LIN( &addr );
|
|
|
|
switch(format)
|
|
{
|
|
case 's':
|
|
if (count == 1) count = 256;
|
|
while (count--)
|
|
{
|
|
if (!DBG_CHECK_READ_PTR( &addr, sizeof(char) )) return;
|
|
if (!*pnt) break;
|
|
addr.off++;
|
|
fputc( *pnt++, stderr );
|
|
}
|
|
fprintf(stderr,"\n");
|
|
return;
|
|
|
|
case 'i':
|
|
while (count--)
|
|
{
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
if (!DBG_CHECK_READ_PTR( &addr, 1 )) return;
|
|
DEBUG_Disasm( &addr );
|
|
fprintf(stderr,"\n");
|
|
}
|
|
return;
|
|
case 'x':
|
|
dump = (unsigned int *)pnt;
|
|
for(i=0; i<count; i++)
|
|
{
|
|
if (!DBG_CHECK_READ_PTR( &addr, sizeof(int) )) return;
|
|
fprintf(stderr," %8.8x", *dump++);
|
|
addr.off += sizeof(int);
|
|
if ((i % 8) == 7)
|
|
{
|
|
fprintf(stderr,"\n");
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
}
|
|
}
|
|
fprintf(stderr,"\n");
|
|
return;
|
|
|
|
case 'd':
|
|
dump = (unsigned int *)pnt;
|
|
for(i=0; i<count; i++)
|
|
{
|
|
if (!DBG_CHECK_READ_PTR( &addr, sizeof(int) )) return;
|
|
fprintf(stderr," %d", *dump++);
|
|
addr.off += sizeof(int);
|
|
if ((i % 8) == 7)
|
|
{
|
|
fprintf(stderr,"\n");
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
}
|
|
}
|
|
fprintf(stderr,"\n");
|
|
return;
|
|
|
|
case 'w':
|
|
wdump = (unsigned short *)pnt;
|
|
for(i=0; i<count; i++)
|
|
{
|
|
if (!DBG_CHECK_READ_PTR( &addr, sizeof(short) )) return;
|
|
fprintf(stderr," %04x", *wdump++);
|
|
addr.off += sizeof(short);
|
|
if ((i % 8) == 7)
|
|
{
|
|
fprintf(stderr,"\n");
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
}
|
|
}
|
|
fprintf(stderr,"\n");
|
|
return;
|
|
|
|
case 'c':
|
|
for(i=0; i<count; i++)
|
|
{
|
|
if (!DBG_CHECK_READ_PTR( &addr, sizeof(char) )) return;
|
|
if(*pnt < 0x20)
|
|
{
|
|
fprintf(stderr," ");
|
|
pnt++;
|
|
}
|
|
else fprintf(stderr," %c", *pnt++);
|
|
addr.off++;
|
|
if ((i % 32) == 31)
|
|
{
|
|
fprintf(stderr,"\n");
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
}
|
|
}
|
|
fprintf(stderr,"\n");
|
|
return;
|
|
|
|
case 'b':
|
|
for(i=0; i<count; i++)
|
|
{
|
|
if (!DBG_CHECK_READ_PTR( &addr, sizeof(char) )) return;
|
|
fprintf(stderr," %02x", (*pnt++) & 0xff);
|
|
addr.off++;
|
|
if ((i % 16) == 15)
|
|
{
|
|
fprintf(stderr,"\n");
|
|
DEBUG_PrintAddress( &addr, dbg_mode );
|
|
fprintf(stderr,": ");
|
|
}
|
|
}
|
|
fprintf(stderr,"\n");
|
|
return;
|
|
}
|
|
}
|