static USHORT ReadBuffer( void *dst, USHORT segv, ULONG offv, USHORT size ) { USHORT length; bool iugs; USHORT resdata; ULONG flat; BYTE *data = dst; if( segv < 4 ) { return( 0 ); } length = size; if( Pid != 0 ) { iugs = IsUnknownGDTSeg( segv ); if( !iugs ) { flat = MakeItFlatNumberOne( segv, offv ); ReadLinear( data, flat, size ); if( Buff.Cmd == DBG_N_Success ) { return( size ); } } while( length != 0 ) { if( iugs || offv > KERNEL_MEM_OFFSET ) { if( !TaskReadWord( segv, offv, &resdata ) ) { break; } } else { Buff.Cmd = DBG_C_ReadMem_D; Buff.Addr = MakeItFlatNumberOne( segv, offv ); CallDosDebug(&Buff); if( Buff.Cmd != DBG_N_Success ) { break; } resdata = Buff.Value; } *data = resdata & 0xff; data++; offv++; length--; if( length != 0 ) { *data = resdata >> 8; data++; offv++; length--; } }
USHORT WriteBuffer( void *src, USHORT segv, ULONG offv, USHORT size ) { USHORT length; bool iugs; USHORT resdata; ULONG flat; BYTE *data = src; if( segv < 4 ) { return( 0 ); } length = size; if( Pid != 0 ) { iugs = IsUnknownGDTSeg( segv ); if( !iugs ) { flat = MakeItFlatNumberOne( segv, offv ); WriteLinear( data, flat, size ); if( Buff.Cmd == DBG_N_Success ) { return( size ); } } while( length != 0 ) { Buff.Cmd = DBG_C_WriteMem_D; if( length == 1 ) { /* Don't want to write anything in the kernel area - that means no breakpoints! */ if( iugs /*|| offv > KERNEL_MEM_OFFSET*/ ) { if( !TaskReadWord( segv, offv, &resdata ) ) { break; } resdata &= 0xff00; resdata |= *data; if( !TaskWriteWord( segv, offv, resdata ) ) { break; } } else { Buff.Cmd = DBG_C_ReadMem_D; Buff.Addr = MakeItFlatNumberOne( segv, offv ); CallDosDebug( &Buff ); Buff.Cmd = DBG_C_WriteMem_D; Buff.Addr = MakeItFlatNumberOne( segv, offv ); Buff.Value &= 0xff00; Buff.Value |= *data; CallDosDebug( &Buff ); if( Buff.Cmd != DBG_N_Success ) { break; } } data++; length--; offv++; } else { resdata = *data; data++; resdata |= *data << 8; data++; if( iugs ) { if( !TaskWriteWord( segv, offv, resdata ) ) { break; } } else { Buff.Value = resdata; Buff.Addr = MakeItFlatNumberOne( segv, offv ); CallDosDebug( &Buff ); if( Buff.Cmd != DBG_N_Success ) { break; } } length -= 2; offv += 2; } } } return( size - length ); /* return amount written */ }
USHORT WriteBuffer( byte __far *data, USHORT segv, ULONG offv, USHORT size ) { USHORT length; bool iugs; USHORT resdata; ULONG flat; if( segv < 4 ) { return( 0 ); } length = size; if( Pid != 0 ) { iugs = IsUnknownGDTSeg( segv ); if( !iugs ) { flat = MakeItFlatNumberOne( segv, offv ); WriteLinear( data, flat, size ); if( Buff.Cmd == DBG_N_Success ) { return( size ); } } while( length != 0 ) { Buff.Cmd = DBG_C_WriteMem_D; if( length == 1 ) { if( iugs ) { if( !TaskReadWord( segv, offv, &resdata ) ) { break; } resdata &= 0xff00; resdata |= *data; if( !TaskWriteWord( segv, offv, resdata ) ) { break; } } else { Buff.Cmd = DBG_C_ReadMem_D; Buff.Addr = MakeItFlatNumberOne( segv, offv ); CallDosDebug( &Buff ); Buff.Cmd = DBG_C_WriteMem_D; Buff.Addr = MakeItFlatNumberOne( segv, offv ); Buff.Value &= 0xff00; Buff.Value |= *data; CallDosDebug( &Buff ); if( Buff.Cmd != DBG_N_Success ) { break; } } data++; length--; offv++; } else { resdata = *data; data++; resdata |= *data << 8; data++; if( iugs ) { if( !TaskWriteWord( segv, offv, resdata ) ) { break; } } else { Buff.Value = resdata; Buff.Addr = MakeItFlatNumberOne( segv, offv ); CallDosDebug( &Buff ); if( Buff.Cmd != DBG_N_Success ) { break; } } length -= 2; offv += 2; } } } return( size - length ); /* return amount written */ }