⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shell.c

📁 一个类似与Windows环境下的softice的源代码
💻 C
字号:
/****************************************************************************** * * Copyright (c) 2003 Gerhard W. Gruber * * PROJECT: pICE * $Source: /cvsroot/pice/pice/module/shell.c,v $ * $Revision: 1.3 $ * $Date: 2004/02/17 23:07:37 $ * $Author: lightweave $ * $Name:  $ * * $Log: shell.c,v $ * Revision 1.3  2004/02/17 23:07:37  lightweave * * Improved the DEBUG facillity and replaced the configuration handler with a * new code which now can read MS Windows INI style files. See CHANGES.txt for * more details. * Also added a macro which prevents compiling for kernels before 2.4.19. * * Revision 1.2  2003/06/18 22:00:22  lightweave * DEBUG and DEBUG_SERIAL added * * *****************************************************************************/static char *ident = "$Header: /cvsroot/pice/pice/module/shell.c,v 1.3 2004/02/17 23:07:37 lightweave Exp $";/*++Copyright (c) 1998-2001 Klaus P. GerlicherModule Name:    shell.cAbstract:    user interface for debuggerEnvironment:    Kernel mode onlyAuthor:    Klaus P. GerlicherRevision History:    16-Jul-1998:	created    22-Sep-1998:	rewrite of keyboard hooking through patching the original keyboard driver	29-Sep-1998:	started documentation on project    15-Nov-2000:    general cleanup of source filesCopyright notice:  This file may be distributed under the terms of the GNU Public License.--*/////////////////////////////////////////////////////// INCLUDES////#include "remods.h"#include <asm/io.h>#include <linux/interrupt.h>#include <asm/smplock.h>#include "precomp.h"#include "editor_output.h"////////////////////////////////////////////////////// DEFINES////////////////////////////////////////////////////////// PROTOTYPES////////////////////////////////////////////////////////// GLOBALS////// flags to set when we need to pass things to the old INT handlersULONG g_ulLineNumberStart=0;// key handlingUCHAR ucConverted; // key converted from scancode to ANSI// keyboard layoutUCHAR ucKeyboardLayout = USA;BOOLEAN bControl=FALSE; // TRUE when CTRL key was pressedBOOLEAN bShift=FALSE; // TRUE when SHIFT key was pressedBOOLEAN bAlt=FALSE; // TRUE when ALT key was pressedchar tempShell[256]; // temporary string container// old address of display memoryUSHORT OldSelector=0;ULONG OldOffset=0;void (*DebuggerEditor)(EXCEPTION_FRAME* pFrame) = DebuggerEditorOutput;//*************************************************************************// ShowStatusLine()////*************************************************************************void ShowStatusLine(EXCEPTION_FRAME* pFrame){	 LPSTR pProcessName;	 char temp[64];	 ENTER_FUNC();	 if(IsAddressValid((ULONG)current))	 {		  SetForegroundColor(COLOR_TEXT);		  SetBackgroundColor(COLOR_CAPTION);		  		  ClrLines(wWindow[OUTPUT_WINDOW].y-1,1);		  pProcessName = current->comm;        if(IsAddressValid((ULONG)pProcessName) )        {		    PICE_sprintf(temp," (%.8s) PROCESS(%.8X \"%s\") CPU #%u ",						 kernel_locked()?"LOCKED":"UNLOCKED",						(ULONG)current,						pProcessName,						current->processor);        }        else        {		    PICE_sprintf(temp," (%.8s) PROCESS(%.8X) CPU #%u ",						 kernel_locked()?"LOCKED":"UNLOCKED",						 (ULONG)current,						 current->processor);        }		PutChar(temp,1,wWindow[OUTPUT_WINDOW].y-1);        ResetColor();    }    LEAVE_FUNC();}//*************************************************************************// ProcessBootParams()////*************************************************************************BOOLEAN ProcessBootParams(EXCEPTION_FRAME* pFrame){    LPSTR p1,p2;	BOOLEAN bNotfiyToExit = FALSE;	UCHAR buffer[256];    ENTER_FUNC();    if(*szBootParams)    {        p1 = szBootParams;        while(*p1)        {            p2 = buffer;            DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "boot params = %s\n",p1);            while(*p1 && *p1!=';')            {                *p2++ = *p1++;            }            *p2=0;            DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "cmd buf = %s\n",buffer);            if(*p1 != ';')            {                DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "error in cmd buf\n");                break;            }            p1++;            DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "next cmd buf = %s\n",p1);    		bNotfiyToExit |= Parse(pFrame,buffer,TRUE);        }        PICE_memset(buffer,0,sizeof(buffer));        *szBootParams = 0;    }    LEAVE_FUNC();	return bNotifyToExit;}//*************************************************************************// DebuggerShell()//// handle user interface when stopped system //*************************************************************************void DebuggerShell(EXCEPTION_FRAME* pFrame) { 	ARGS Args;    UCHAR speaker;    ENTER_FUNC();    // flush input device buffer    FlushKeyboardQueue();    // see if there's something left to output	CheckRingBuffer();    // kill the speakers annoying beep 	speaker = inb_p(0x61);	speaker &= 0xFC;	outb_p(speaker,0x61);    DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "DisplayRegs()\n");     // display register contents	DisplayRegs(pFrame);    DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "DisplayMemory()\n"); 	// display data window	Args.Value[0]=OldSelector;	Args.Value[1]=OldOffset;	Args.Count=2;	DisplayMemory(pFrame,&Args);    DPRINT(PICE_DEBUG, DBT_SHELL, DBL_INFO, "Unassemble()\n");     // disassembly from current address    PICE_memset(&Args,0,sizeof(ARGS));	Args.Value[0]=pFrame->cs;	Args.Value[1]=pFrame->eip;	Args.Count=2;	Unassemble(pFrame,&Args);    // display status line    ShowStatusLine(pFrame);	// tell USER we are stopped     ShowStoppedMsg(); 	// save the graphics state	SaveGraphicsState();	// switch on cursor 	ShowCursor();     // while we are not told to exit	while(bNotifyToExit==FALSE || bDebuggerHaltState)	{		// emulate graphics cursor		PrintCursor(FALSE);		(*DebuggerEditor)(pFrame);	}    SaveOldRegs(pFrame);    PrintLogo(TRUE);    ShowRunningMsg();     if(bRev)		PrintCursor(TRUE);	// hide the cursor 	HideCursor();     FlushKeyboardQueue(); 	// show normal console again	RestoreGraphicsState();	LEAVE_FUNC();} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -