1999-04-16 03:35:26 +02:00
|
|
|
#include <dfs.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <time.h>
|
|
|
|
#include <conio.h>
|
|
|
|
#include <advanced.h>
|
|
|
|
#include <debugapi.h>
|
|
|
|
#include <process.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include "i386.h"
|
|
|
|
|
|
|
|
extern char *mem2hex (void *mem, char *buf, int count, int may_fault);
|
|
|
|
extern char *hex2mem (char *buf, void *mem, int count, int may_fault);
|
|
|
|
extern int computeSignal (int exceptionVector);
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
flush_i_cache (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the registers out of the frame information. */
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
frame_to_registers (struct StackFrame *frame, char *regs)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
/* Copy EAX -> EDI */
|
|
|
|
mem2hex (&frame->ExceptionEAX, ®s[0 * 4 * 2], 4 * 8, 0);
|
|
|
|
|
|
|
|
/* Copy EIP & PS */
|
|
|
|
mem2hex (&frame->ExceptionPC, ®s[8 * 4 * 2], 4 * 2, 0);
|
|
|
|
|
|
|
|
/* Copy CS, SS, DS */
|
|
|
|
mem2hex (&frame->ExceptionCS, ®s[10 * 4 * 2], 4 * 3, 0);
|
|
|
|
|
|
|
|
/* Copy ES */
|
|
|
|
mem2hex (&frame->ExceptionES, ®s[13 * 4 * 2], 4 * 1, 0);
|
|
|
|
|
|
|
|
/* Copy FS & GS */
|
|
|
|
mem2hex (&frame->ExceptionFS, ®s[14 * 4 * 2], 4 * 2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Put the registers back into the frame information. */
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
registers_to_frame (char *regs, struct StackFrame *frame)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
/* Copy EAX -> EDI */
|
|
|
|
hex2mem (®s[0 * 4 * 2], &frame->ExceptionEAX, 4 * 8, 0);
|
|
|
|
|
|
|
|
/* Copy EIP & PS */
|
|
|
|
hex2mem (®s[8 * 4 * 2], &frame->ExceptionPC, 4 * 2, 0);
|
|
|
|
|
|
|
|
/* Copy CS, SS, DS */
|
|
|
|
hex2mem (®s[10 * 4 * 2], &frame->ExceptionCS, 4 * 3, 0);
|
|
|
|
|
|
|
|
/* Copy ES */
|
|
|
|
hex2mem (®s[13 * 4 * 2], &frame->ExceptionES, 4 * 1, 0);
|
|
|
|
|
|
|
|
/* Copy FS & GS */
|
|
|
|
hex2mem (®s[14 * 4 * 2], &frame->ExceptionFS, 4 * 2, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
set_step_traps (struct StackFrame *frame)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
frame->ExceptionSystemFlags |= 0x100;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
clear_step_traps (struct StackFrame *frame)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
frame->ExceptionSystemFlags &= ~0x100;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-07-30 03:48:28 +02:00
|
|
|
do_status (char *ptr, struct StackFrame *frame)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
|
|
|
int sigval;
|
|
|
|
|
|
|
|
sigval = computeSignal (frame->ExceptionNumber);
|
|
|
|
|
|
|
|
sprintf (ptr, "T%02x", sigval);
|
|
|
|
ptr += 3;
|
|
|
|
|
|
|
|
sprintf (ptr, "%02x:", PC_REGNUM);
|
|
|
|
ptr = mem2hex (&frame->ExceptionPC, ptr + 3, 4, 0);
|
|
|
|
*ptr++ = ';';
|
|
|
|
|
|
|
|
sprintf (ptr, "%02x:", SP_REGNUM);
|
|
|
|
ptr = mem2hex (&frame->ExceptionESP, ptr + 3, 4, 0);
|
|
|
|
*ptr++ = ';';
|
|
|
|
|
|
|
|
sprintf (ptr, "%02x:", FP_REGNUM);
|
|
|
|
ptr = mem2hex (&frame->ExceptionEBP, ptr + 3, 4, 0);
|
|
|
|
*ptr++ = ';';
|
|
|
|
|
|
|
|
*ptr = '\000';
|
|
|
|
}
|