📄 monitor.c
字号:
//
// Display same data in ascii
//
case HALF_SIZE:
//EdbgOutputDebugString("%04x ",*(volatile PUSHORT)Address);
EdbgOutputDebugString("%x ",*(volatile PUSHORT)Address);
break;
case WORD_SIZE:
//EdbgOutputDebugString("%08lx ",*(volatile PULONG)Address);
EdbgOutputDebugString("%x ",*(volatile PULONG)Address);
break;
}
}
BOOLEAN
DumpCommand(
IN PCHAR Argv[],
PULONG pregTable
)
/*++
Routine Description:
This routine will implement the DUMP command given the
arguments in the argc,Argv form.
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if the command is valid, FALSE otherwise.
--*/
{
ULONG Start,End;
ULONG i,LineLength;
ULONG DataLine[16];
//
// Set the right range of addresses. If none specified use last
// set of addresses+128.
//
if (Argc == 1) {
Start = DefaultAddress;
End = Start + 128;
} else {
if (GetAddressRange(Argv,&Start,&End,pregTable) == FALSE) {
return FALSE;
}
//
// if after getting the range not all the argument were processsed.
//
if (CurrentArg != Argc) {
EdbgOutputDebugString(MON_INVALID_ARGUMENT_COUNT_MSG);
return FALSE;
}
}
//
// Check for proper alignment.
//
if ((DataSizeMask&Start) || (DataSizeMask&End)) {
EdbgOutputDebugString(MON_UNALIGNED_ADDRESS_MSG);
return FALSE;
} else {
//
// Set new addresses
//
DefaultAddress = End;
}
while (Start < End) {
//
// Print address of line.
//
//EdbgOutputDebugString("0x%08lx: ",Start);
EdbgOutputDebugString("0x%x: ",Start);
LineLength = End-Start;
if (LineLength > 16) {
LineLength = 16;
}
for (i=0;i<LineLength;i+=DataSize) {
InputValue(Start,&DataLine[i]);
Start+=DataSize;
}
if (DataSize == 1) {
//
// If bytes display same data in ASCII
//
for (i=LineLength; i<=16; i++) {
EdbgOutputDebugString(" ");
}
for (i=0;i<LineLength;i++) {
if ( (((UCHAR)DataLine[i]) <= '~')
&& (((UCHAR)DataLine[i]) >= ' ') )
{
EdbgOutputDebugString("%c",DataLine[i]);
} else EdbgOutputDebugString(".");
}
}
EdbgOutputDebugString(FW_CRLF_MSG);
}
return TRUE;
}
BOOLEAN
ZeroCommand(
IN PCHAR Argv[],
PULONG pregTable
)
/*++
Routine Description:
This routine will implement the Zero command given the
arguments in the argc,Argv form.
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if the command is valid, FALSE otherwise.
--*/
{
ULONG Start,End;
//
// Set the right range of addresses. If none specified use last
// set of addresses+128.
//
if (Argc == 1) {
Start = DefaultAddress;
End = Start + 128;
} else {
if (GetAddressRange(Argv,&Start,&End,pregTable) == FALSE) {
return FALSE;
}
//
// if after getting the range not all the argument were processsed.
//
if (CurrentArg != Argc) {
EdbgOutputDebugString(MON_INVALID_ARGUMENT_COUNT_MSG);
return FALSE;
}
}
//
// Check for proper alignment.
//
if ((0xF&Start) || (0xF&End)) {
EdbgOutputDebugString(MON_UNALIGNED_ADDRESS_MSG);
return FALSE;
} else {
//
// Set new addresses
//
DefaultAddress = End;
}
for (;Start < End;Start++)
*((PCHAR)Start) = 0;
return TRUE;
}
BOOLEAN
OutputValue(
IN PCHAR AsciiValue,
IN ULONG Address
)
/*++
Routine Description:
This routine writes the converted value to the specified
address. DataSize is set to the size of the data to be written.
Arguments:
AsciiValue - Supplies a pointer to a string that contains an hexadecimal
value.
Address - Supplies the address where the value is to be written to.
Return Value:
TRUE if the value is successfully converted.
FALSE otherwise.
--*/
{
ULONG Value;
PCHAR Terminator;
//
// Conver value to integer
//
Value = StrToUlong(AsciiValue,&Terminator);
if (*Terminator != '\0') {
//
// Not the whole string was converted.
//
EdbgOutputDebugString(Terminator);
EdbgOutputDebugString(MON_INVALID_VALUE_MSG);
return FALSE;
} else {
//
// Store the value.
//
switch (DataSize) {
case BYTE_SIZE:*(volatile PUCHAR)Address = (UCHAR)Value;
break;
case HALF_SIZE:*(volatile PUSHORT)Address = (USHORT)Value;
break;
case WORD_SIZE: *(volatile PULONG)Address = (ULONG)Value;
break;
}
}
return TRUE;
}
BOOLEAN
OutputCommand(
IN PCHAR Argv[],
IN PULONG pRegTable
)
/*++
Routine Description:
This routine will implement the OUTPUT command given the
arguments in the argc,Argv form.
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if the command is valid, FALSE otherwise.
--*/
{
ULONG Start;
if (Argc!=3) {
EdbgOutputDebugString(MON_INVALID_ARGUMENT_COUNT_MSG);
return FALSE;
}
if (GetAddress(Argv[1],&Start,pRegTable) == FALSE) {
return FALSE;
}
//
// Check for proper alignment.
//
if (DataSizeMask & Start) {
EdbgOutputDebugString(MON_UNALIGNED_ADDRESS_MSG);
return FALSE;
}
if (OutputValue(Argv[2],Start) == TRUE) {
//
// Set new default addresses
//
DefaultAddress = Start+DataSize;
}
return TRUE;
}
BOOLEAN
InputCommand(
IN PCHAR Argv[],
IN PULONG pRegTable
)
/*++
Routine Description:
This routine will implement the INPUT command given the
arguments in the argc,Argv form.
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if the command is valid, FALSE otherwise.
--*/
{
ULONG Start;
ULONG Trash;
if (Argc!=2) {
EdbgOutputDebugString(MON_INVALID_ARGUMENT_COUNT_MSG);
return FALSE;
}
if (GetAddress(Argv[1],&Start,pRegTable) == FALSE) {
return FALSE;
}
//
// Check for proper alignment.
//
if (DataSizeMask & Start) {
EdbgOutputDebugString(MON_UNALIGNED_ADDRESS_MSG);
return FALSE;
}
//EdbgOutputDebugString("0x%08lx: ",Start);
EdbgOutputDebugString("0x%x: ",Start);
InputValue(Start,&Trash);
EdbgOutputDebugString(FW_CRLF_MSG);
//
// Set new default addresses
//
DefaultAddress = Start+DataSize;
return TRUE;
}
BOOLEAN
EnterCommand(
IN PCHAR Argv[],
IN PULONG pRegTable
)
/*++
Routine Description:
This routine will implement the ENTER command given the
arguments in the argc,Argv form.
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if the command is valid, FALSE otherwise.
--*/
{
ULONG Start;
CHAR String[32];
GETSTRING_ACTION Action;
//
// Set the right range of addresses. If none specified use last
// set of addresses+128.
//
switch(Argc) {
case 1:
Start = DefaultAddress;
break;
case 2:
if (GetAddress(Argv[1],&Start,pRegTable) == FALSE) {
return FALSE;
}
break;
case 3:
//
// This is equivalent to the output command
//
return OutputCommand(Argv,pRegTable);
default:
EdbgOutputDebugString(MON_INVALID_ARGUMENT_COUNT_MSG);
return FALSE;
}
//
// Check for proper alignment.
//
if (DataSizeMask & Start) {
EdbgOutputDebugString(MON_UNALIGNED_ADDRESS_MSG);
return FALSE;
}
for (;;) {
//
// Print address of line.
//
//EdbgOutputDebugString("0x%08lx: ",Start);
EdbgOutputDebugString("0x%x: ",Start);
switch (DataSize) {
case BYTE_SIZE:
//EdbgOutputDebugString("%02x . ",*(PUCHAR)Start);
EdbgOutputDebugString("%x . ",*(PUCHAR)Start);
break;
case HALF_SIZE:
//EdbgOutputDebugString("%04x . ",*(PUSHORT)Start);
EdbgOutputDebugString("%x . ",*(PUSHORT)Start);
break;
case WORD_SIZE:
//EdbgOutputDebugString("%08lx . ",*(PULONG)Start);
EdbgOutputDebugString("%x . ",*(PULONG)Start);
break;
}
do {
Action = FwGetString(String,10,NULL);
} while (Action != GetStringSuccess);
EdbgOutputDebugString(FW_CRLF_MSG);
if (String[0] == '\0') { // carriage return exit enter command
//
// set new default address.
//
DefaultAddress = Start;
return TRUE;
}
if (String[0] == ' ') { // blank = next data element.
Start+=DataSize;
continue;
}
if (String[0] == '-') { // hypen = previous data element.
Start-=DataSize;
continue;
}
if (OutputValue(String,Start) == TRUE) { // deposit the value.
Start+=DataSize;
}
}
return TRUE;
}
BOOLEAN
FillCommand(
IN PCHAR Argv[],
IN PULONG pRegTable
)
/*++
Routine Description:
This routine will implement the FILL command given the
arguments in the argc,Argv form.
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if the command is valid, FALSE otherwise.
--*/
{
ULONG Start,End,Values[16];
ULONG Index,Count;
PCHAR Terminator;
if (GetAddressRange(Argv,&Start,&End,pRegTable) == FALSE) {
return FALSE;
}
//
// if there are no more arguments we don't know what to fill with.
//
if (CurrentArg == Argc) {
EdbgOutputDebugString(MON_INVALID_ARGUMENT_COUNT_MSG);
return FALSE;
}
//
// Convert the values
//
for (Count=0;CurrentArg < Argc; CurrentArg++) {
Values[Count++] = StrToUlong(Argv[CurrentArg],&Terminator);
if (*Terminator != '\0') {
//
// Not the whole string was converted.
//
EdbgOutputDebugString(Terminator);
EdbgOutputDebugString(MON_INVALID_VALUE_MSG);
return FALSE;
}
}
Index = 0;
for (;Start < End;Start+=sizeof(ULONG)) {
// *((PCHAR)Start) = Values[Index++];
*((PULONG)Start) = Values[Index++];
if (Index == Count) {
Index=0;
}
}
return TRUE;
}
BOOLEAN
JumpCommand(
IN PCHAR Argv[]
)
/*++
Routine Description:
This routine will call a subroutine at address supplied by command line
Arguments:
Argv - array of zero terminated argument strings.
Return Value:
Returns TRUE if command is valid
--*/
{
VOID (*Jump)(ULONG,ULONG,ULONG,ULONG);
ULONG Arg1 = 0;
ULONG Arg2 = 0;
ULONG Arg3 = 0;
ULONG Arg4 = 0;
CHAR * Dummy;
if (Argc > 2) {
Arg1 = StrToUlong(Argv[2],&Dummy);
}
if (Argc > 3) {
Arg2 = StrToUlong(Argv[3],&Dummy);
}
if (Argc > 4) {
Arg3 = StrToUlong(Argv[4],&Dummy);
}
if (Argc > 5) {
Arg4 = StrToUlong(Argv[5],&Dummy);
}
if (Argc > 1) {
Jump = (VOID (*)(ULONG,ULONG,ULONG,ULONG))StrToUlong(Argv[1],&Dummy);
Jump(Arg1,Arg2,Arg3,Arg4);
return TRUE;
} else {
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -