ReactOS  r73918
shell.c File Reference
#include "remods.h"
#include "precomp.h"
Include dependency graph for shell.c:

Go to the source code of this file.

Macros

#define LINES_IN_COMMAND_BUFFER   (64)
 

Functions

ULONG GetLinesInCommandHistory (void)
 
void AddToCommandLineHistory (LPSTR s)
 
LPSTR GetFromCommandLineHistory (ULONG ulCurrentCommandPos)
 
void ShowStatusLine (void)
 
void ProcessBootParams (void)
 
BOOLEAN __inline bNoCtrlKeys (void)
 
void DebuggerShell (void)
 
void RealIsr (ULONG dwReasonForBreak)
 
 __asm__ (".global NewInt31Handler\n\t \ NewInt31Handler:\n\t \ cli\n\t \ cld\n\t \ \n\t \ pushl %eax\n\t \ pushl %ds\n\t \ \n\t \ movw %ss,%ax\n\t \ mov %ax,%ds\n\t \ \n\t \ mov 0x4(%esp),%eax\n\t \ movl %eax,_CurrentEAX\n\t \ movl %ebx,_CurrentEBX\n\t \ movl %ecx,_CurrentECX\n\t \ movl %edx,_CurrentEDX\n\t \ movl %esi,_CurrentESI\n\t \ movl %edi,_CurrentEDI\n\t \ movl %ebp,_CurrentEBP\n\t \ movl (%esp),%eax\n\t \ movw %ax,_CurrentDS\n\t \ \n\t \ // test for V86 mode\n\t \ testl $0x20000,5*4(%esp)\n\t \ jz notV86\n\t \ \n\t \ int $0x03\n\t \ \n\t \ notV86:\n\t \ // test if stack switched (ring3->ring0 transition)\n\t \ // stack is switched if orig. SS is not global kernel code segment\n\t \ movl 4*4(%esp),%eax\n\t \ cmpw $"STR(GLOBAL_CODE_SEGMENT)",%ax\n\t \ je notswitched\n\t \ \n\t \ // switched stack\n\t \ movl 6*4(%esp),%eax\n\t \ mov %eax,_CurrentESP\n\t \ mov 7*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ jmp afterswitch\n\t \ \n\t \ notswitched:\n\t \ // didn't switch stack\n\t \ movl %esp,_CurrentESP\n\t \ addl $24,_CurrentESP\n\t \ movw %ss,%ax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ \n\t \ afterswitch:\n\t \ // save EIP\n\t \ mov 3*4(%esp),%eax\n\t \ mov %eax,_CurrentEIP\n\t \ //save CS\n\t \ mov 4*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ movw %ax,_CurrentCS\n\t \ // save flags\n\t \ movl 5*4(%esp),%eax\n\t \ andl $0xFFFFFEFF,%eax\n\t \ movl %eax,_CurrentEFL\n\t \ \n\t \ pushal\n\t \ \n\t \ // get reason code\n\t \ mov 0x28(%esp),%ebx\n\t \ \n\t \ /*\n\t \ * Load the PCR selector.\n\t \ */\n\t \ \n\t \ movl %fs, %eax\n\t \ movl %eax, _OLD_PCR\n\t \ movl _PCR_SEL, %eax\n\t \ movl %eax, %fs\n\t \ \n\t \ // setup a large work stack\n\t \ movl %esp,%eax\n\t \ movl %eax,_ulRealStackPtr\n\t \ \n\t \ pushl %ebx\n\t \ call _RealIsr\n\t \ addl $4,%esp\n\t \ \n\t \ pushl %eax\n\t \ movl _OLD_PCR, %eax\n\t \ movl %eax, %fs\n\t \ popl %eax\n\t \ \n\t \ // restore all regs\n\t \ popal\n\t \ \n\t \ // do an EOI to IRQ controller (because we definitely pressed some key)\n\t \ // TODO: SMP APIC support\n\t \ movb $0x20,%al\n\t \ outb %al,$0x20\n\t \ \n\t \ popl %ds\n\t \ popl %eax\n\t \ \n\t \ // remove reason code\n\t \ addl $4,%esp\n\t \ \n\t \ // make EAX available\n\t \ pushl %eax\n\t \ \n\t \ // modify or restore EFLAGS\n\t \ .byte 0x2e\n\t \ mov _CurrentEFL,%eax\n\t \ mov %eax,3*4(%esp)\n\t \ .byte 0x2e\n\t \ movzwl _CurrentCS,%eax\n\t \ mov %eax,2*4(%esp)\n\t \ .byte 0x2e\n\t \ mov _CurrentEIP,%eax\n\t \ mov %eax,1*4(%esp)\n\t \ \n\t \ // restore EAX\n\t \ popl %eax\n\t \ \n\t \ // do we need to call old INT1 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt1Handler\n\t \ je do_iret2\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt1Handler\n\t \ \n\t \ do_iret2:\n\t \ // do we need to call old INT3 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt3Handler\n\t \ je do_iret1\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt3Handler\n\t \ \n\t \ do_iret1:\n\t \ // do we need to call old pagefault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldIntEHandler\n\t \ je do_iret3\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldIntEHandler\n\t \ \n\t \ do_iret3:\n\t \ // do we need to call old general protection fault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldGPFaultHandler\n\t \ je do_iret\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldGPFaultHandler\n\t \ \n\t \ do_iret:\n\t \ //ei\n\t \ //int3\n\t \ iretl ")
 
 __asm__ ("\n\t \ NewGlobalInt31Handler:\n\t \ .byte 0x2e\n\t \ cmpb $0,_bEnterNow\n\t \ jne dotheenter\n\t \ \n\t \ // chain to old handler\n\t \ .byte 0x2e\n\t \ jmp *_OldGlobalInt31Handler\n\t \ \n\t \ dotheenter:\n\t \ pushl $"STR(REASON_CTRLF)"\n\t \ jmp NewInt31Handler ")
 
void InstallGlobalKeyboardHook (void)
 
void DeInstallGlobalKeyboardHook (void)
 

Variables

ULONG bPreviousCommandWasGo = FALSE
 
ULONG dwCallOldInt1Handler = 0
 
ULONG dwCallOldInt3Handler = 0
 
ULONG dwCallOldIntEHandler = 0
 
ULONG dwCallOldGPFaultHandler = 0
 
ULONG g_ulLineNumberStart =0
 
ULONG ulWindowOffset = 0
 
BOOLEAN bStepThroughSource =FALSE
 
BOOLEAN bStepInto = FALSE
 
UCHAR ucConverted
 
volatile BOOLEAN bControl =FALSE
 
volatile BOOLEAN bShift =FALSE
 
volatile BOOLEAN bAlt =FALSE
 
volatile ULONG OldInt31Handler
 
volatile ULONG OldGlobalInt31Handler
 
volatile BOOLEAN bEnterNow =FALSE
 
volatile BOOLEAN bNotifyToExit =FALSE
 
volatile BOOLEAN bSkipMainLoop =FALSE
 
volatile UCHAR ucKeyPressedWhileIdle =0
 
volatile BOOLEAN bInDebuggerShell =FALSE
 
BOOLEAN bIrqStateAtBreak
 
ULONG ulRealStackPtr
 
static ULONG PCR_SEL = PCR_SELECTOR
 
static ULONG OLD_PCR
 
char tempShell [256]
 
USHORT OldSelector =0
 
ULONG OldOffset =0
 
ULONG ulLastLineDisplayedOffset = 0
 
charszFunctionKeys [10]
 
ULONG aulNewStack [0x20000]
 
ULONG ulOldStack
 
ULONG CurrentEIP
 
ULONG CurrentEFL
 
ULONG CurrentEAX
 
ULONG CurrentEBX
 
ULONG CurrentECX
 
ULONG CurrentEDX
 
ULONG CurrentESP
 
ULONG CurrentEBP
 
ULONG CurrentESI
 
ULONG CurrentEDI
 
USHORT CurrentCS
 
USHORT CurrentDS =0
 
USHORT CurrentES
 
USHORT CurrentFS
 
USHORT CurrentGS
 
USHORT CurrentSS
 
ULONG CurrentDR0
 
ULONG CurrentDR1
 
ULONG CurrentDR2
 
ULONG CurrentDR3
 
ULONG CurrentDR6
 
ULONG CurrentDR7
 
ULONG CurrentCR0
 
ULONG CurrentCR2
 
ULONG CurrentCR3
 
ULONG OldEIP =0
 
ULONG OldEFL
 
ULONG OldEAX
 
ULONG OldEBX
 
ULONG OldECX
 
ULONG OldEDX
 
ULONG OldESP
 
ULONG OldEBP
 
ULONG OldESI
 
ULONG OldEDI
 
USHORT OldCS =0
 
USHORT OldDS
 
USHORT OldES
 
USHORT OldFS
 
USHORT OldGS
 
USHORT OldSS
 
ULONG CurrentProcess
 
UCHAR ucCommandBuffer [256]
 
USHORT usCurrentPosInInputBuffer =0
 
volatile BOOLEAN bSingleStep =FALSE
 
char aszCommandLines [LINES_IN_COMMAND_BUFFER][sizeof(ucCommandBuffer)+2]
 
ULONG ulCommandInPos =0
 
ULONG ulCommandLastPos =0
 
ULONG ulCommandCurrentPos =0
 
ULONG KeyboardIRQL
 

Macro Definition Documentation

#define LINES_IN_COMMAND_BUFFER   (64)

Definition at line 44 of file shell.c.

Referenced by AddToCommandLineHistory(), and GetLinesInCommandHistory().

Function Documentation

__asm__ ( ".global NewInt31Handler\n\t \NewInt31Handler:\n\t \ cli\n\t \ cld\n\t \\n\t \ pushl %eax\n\t \ pushl %ds\n\t \\n\t \ movw %  ss,
%ax\n\t\mov%  ax,
%ds\n\t\\n\t\mov   0x4%esp,
%eax\n\t\movl eax,
_CurrentEAX\n\t\movl ebx,
_CurrentEBX\n\t\movl ecx,
_CurrentECX\n\t\movl edx,
_CurrentEDX\n\t\movl esi,
_CurrentESI\n\t\movl edi,
_CurrentEDI\n\t\movl ebp,
_CurrentEBP\n\t\  movl%esp,
%eax\n\t\movw%  ax,
_CurrentDS\n\t\\n\t\//test for V86 mode\n\t\testl  $0x20000,
5 *  4%esp)\n\t\jz notV86\n\t\\n\t\int $0x03\n\t\\n\t\notV86:\n\t\//test if stack switched(ring3->ring0 transition)\n\t\//stack is switched if orig.SS is not global kernel code segment\n\t\movl 4 *4(%esp,
%eax\n\t\cmpw $"STR(GLOBAL_CODE_SEGMENT)"  ,
%ax\n\t\je notswitched\n\t\\n\t\//switched stack\n\t\movl 6 *  4%esp,
%eax\n\t\mov%  eax,
_CurrentESP\n\t\mov 7 *  4%esp,
%eax\n\t\movzwl%  ax,
%eax\n\t\mov%  ax,
_CurrentSS\n\t\jmp afterswitch\n\t\\n\t\notswitched:\n\t\//didn't switch stack\n\t\movl esp,
_CurrentESP\n\t\addl  $24,
_CurrentESP\n\t\movw%  ss,
%ax\n\t\movzwl%  ax,
%eax\n\t\mov%  ax,
_CurrentSS\n\t\\n\t\afterswitch:\n\t\//save EIP\n\t\mov 3 *  4%esp,
%eax\n\t\mov%  eax,
_CurrentEIP\n\t\//save CS\n\t\mov 4 *  4%esp,
%eax\n\t\movzwl%  ax,
%eax\n\t\movw%  ax,
_CurrentCS\n\t\//save flags\n\t\movl 5 *  4%esp,
%eax\n\t\andl  $0xFFFFFEFF,
%eax\n\t\movl eax,
_CurrentEFL\n\t\\n\t\pushal\n\t\\n\t\//get reason code\n\t\mov   0x28%esp,
%ebx\n\t\\n\t\/*\n\t\*Load the PCR selector.\n\t\*/\n\t\\n\t\movl fs,
%eax\n\t\movl eax,
_OLD_PCR\n\t\movl  _PCR_SEL,
%eax\n\t\movl eax,
%fs\n\t\\n\t\//setup a large work stack\n\t\movl esp,
%eax\n\t\movl eax,
_ulRealStackPtr\n\t\\n\t\pushl%ebx\n\t\call _RealIsr\n\t\addl  $4,
%esp\n\t\\n\t\pushl%eax\n\t\movl  _OLD_PCR,
%eax\n\t\movl eax,
%fs\n\t\popl%eax\n\t\\n\t\//restore all regs\n\t\popal\n\t\\n\t\//do an EOI to IRQ controller(because we definitely pressed some key)\n\t\//TODO:SMP APIC support\n\t\movb  $0x20,
%al\n\t\outb%  al,
  $0x20\n\t\\n\t\popl%ds\n\t\popl%eax\n\t\\n\t\//remove reason code\n\t\addl,
%esp\n\t\\n\t\//make EAX available\n\t\pushl%eax\n\t\\n\t\//modify or restore EFLAGS\n\t\.byte 0x2e\n\t\mov  _CurrentEFL,
%eax\n\t\mov%  eax,
3 *4(%esp)\n\t\.byte 0x2e\n\t\movzwl  _CurrentCS,
%eax\n\t\mov%  eax,
2 *4(%esp)\n\t\.byte 0x2e\n\t\mov  _CurrentEIP,
%eax\n\t\mov%  eax,
1 *4(%esp)\n\t\\n\t\//restore EAX\n\t\popl%eax\n\t\\n\t\//do we need to call old INT1 handler\n\t\.byte 0x2e\n\t\cmp  $0,
_dwCallOldInt1Handler\n\t\je do_iret2\n\t\\n\t\//call INT3 handler\n\t\.byte 0x2e\n\t\jmp *_OldInt1Handler\n\t\\n\t\do_iret2:\n\t\//do we need to call old INT3 handler\n\t\.byte 0x2e\n\t\cmp  $0,
_dwCallOldInt3Handler\n\t\je do_iret1\n\t\\n\t\//call INT3 handler\n\t\.byte 0x2e\n\t\jmp *_OldInt3Handler\n\t\\n\t\do_iret1:\n\t\//do we need to call old pagefault handler\n\t\.byte 0x2e\n\t\cmp  $0,
_dwCallOldIntEHandler\n\t\je do_iret3\n\t\\n\t\//call old pagefault handler\n\t\.byte 0x2e\n\t\pushl _error_code\n\t\.byte 0x2e\n\t\jmp *_OldIntEHandler\n\t\\n\t\do_iret3:\n\t\//do we need to call old general protection fault handler\n\t\.byte 0x2e\n\t\cmp  $0,
_dwCallOldGPFaultHandler\n\t\je do_iret\n\t\\n\t\//call old pagefault handler\n\t\.byte 0x2e\n\t\pushl _error_code\n\t\.byte 0x2e\n\t\jmp *_OldGPFaultHandler\n\t\\n\t\do_iret:\n\t\//ei\n\t\//int3\n\t\iretl"   
)
__asm__ ( "\n\t \NewGlobalInt31Handler:\n\t \ .byte 0x2e\n\t \ cmpb  $0,
_bEnterNow\n\t\jne dotheenter\n\t\\n\t\//chain to old handler\n\t\.byte 0x2e\n\t\jmp *_OldGlobalInt31Handler\n\t\\n\t\dotheenter:\n\t\pushl $"STR(REASON_CTRLF)"\n\t\jmp NewInt31Handler"   
)
void AddToCommandLineHistory ( LPSTR  s)

Definition at line 160 of file shell.c.

Referenced by DebuggerShell().

161 {
162  ULONG i;
163 
164  ENTER_FUNC();
165  DPRINT((0,"AddToCommandLineHistory(%s)\n",s));
166 
167  if(PICE_strlen(s))
168  {
169  for(i=0;i<LINES_IN_COMMAND_BUFFER;i++)
170  {
171  if(PICE_strcmpi(&aszCommandLines[i][1],s) == 0)
172  {
173  DPRINT((0,"AddToCommandLineHistory(): command line already exists\n"));
174  LEAVE_FUNC();
175  return;
176  }
177  }
180  ulCommandCurrentPos = ulCommandInPos = (ulCommandInPos +1)%LINES_IN_COMMAND_BUFFER;
182  {
183  ulCommandLastPos = (ulCommandLastPos+1)%LINES_IN_COMMAND_BUFFER;
184  }
185  }
186 
187  LEAVE_FUNC();
188 }
ULONG ulCommandCurrentPos
Definition: shell.c:134
#define LINES_IN_COMMAND_BUFFER
Definition: shell.c:44
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
#define LEAVE_FUNC()
Definition: debug.h:43
char * PICE_strcpy(char *s1, char *s2)
Definition: utils.c:302
GLenum GLclampf GLint i
Definition: glfuncs.h:14
char aszCommandLines[LINES_IN_COMMAND_BUFFER][sizeof(ucCommandBuffer)+2]
Definition: shell.c:132
void DPRINT(...)
Definition: polytest.cpp:61
GLdouble s
Definition: gl.h:2039
ULONG ulCommandInPos
Definition: shell.c:133
ULONG ulCommandLastPos
Definition: shell.c:133
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
ULONG PICE_strcmpi(char *s1, char *s2)
Definition: utils.c:387
BOOLEAN __inline bNoCtrlKeys ( void  )

Definition at line 296 of file shell.c.

Referenced by DebuggerShell().

297 {
298  return (!bControl && !bAlt && !bShift);
299 }
volatile BOOLEAN bShift
Definition: shell.c:71
volatile BOOLEAN bControl
Definition: shell.c:70
volatile BOOLEAN bAlt
Definition: shell.c:72
void DebuggerShell ( void  )

Definition at line 307 of file shell.c.

Referenced by RealIsr().

308 {
309  ARGS Args;
310  UCHAR speaker;
311  PEPROCESS pCurrentProcess;
312 
313  ENTER_FUNC();
314 
315  // save the graphics state
317 
318  // tell USER we are stopped
319  ShowStoppedMsg();
320 
322 
323  CheckRingBuffer();
324 
325  // kill the speakers annoying beep
326  speaker = inb_p((PCHAR)0x61);
327  speaker &= 0xFC;
328  outb_p(speaker,(PCHAR)0x61);
329 
331 
332  DPRINT((0,"DebuggerShell(): DisplayRegs()\n"));
333  // display register contents
334  DisplayRegs();
335 
336  DPRINT((0,"DebuggerShell(): DisplayMemory()\n"));
337  // display data window
338  Args.Value[0]=OldSelector;
339  Args.Value[1]=OldOffset;
340  Args.Count=2;
341  DisplayMemory(&Args);
342 
343  DPRINT((0,"DebuggerShell(): Unassemble()\n"));
344 
345  // disassembly from current address
346  PICE_memset(&Args,0,sizeof(ARGS));
347  Args.Value[0]=CurrentCS;
348  Args.Value[1]=CurrentEIP;
349  Args.Count=2;
350  Unassemble(&Args);
351 
352  // try to find current process's name
353  pCurrentProcess = IoGetCurrentProcess();
354  CurrentProcess = (ULONG)pCurrentProcess;
355 
356  // display status line
357  ShowStatusLine();
358 
359  // switch on cursor
360  ShowCursor();
361 
362  // while we are not told to exit
363  while(bNotifyToExit==FALSE)
364  {
365  // emulate graphics cursor
367 
368  // we have a key press
370  {
371  DPRINT((0,"DebuggerShell(): key = %x control = %u shift = %u\n",ucKeyPressedWhileIdle,bControl,bShift));
372 
373  // if cursor reversed, normalize it again (only graphics)
374  if(bRev)
375  {
376  PrintCursor(TRUE);
377  }
378 
379  // convert key to ANSI, if success add to command buffer and try to
380  // find a command that fits the already entered letters
382 
383 #if 0
386 #endif
387 
388  if(!bControl && !bAlt && ucConverted)
389  {
390  DPRINT((0,"DebuggerShell(): normal key\n"));
391  if(!(usCurrentPosInInputBuffer==0 && ucConverted==' '))
392  {
393  // if we have space in the command buffer
394  // put the character there
396  {
398  // output the character
402  }
403  // if we have something in command buffer
404  // try to find command help that fits
406  {
408  }
409  else ShowStoppedMsg();
410  }
411  }
412  // normal key while holding down CONTROL
413  else if(bControl && !bAlt && !bShift && ucConverted)
414  {
415  if(ucConverted == 'f')
417  }
418  // normal key while holding down ALT
419  else if(!bControl && bAlt && !bShift && ucConverted)
420  {
421  }
422  // normal key while holding down ALT & CONTROL
423  else if(bControl && bAlt && !bShift && ucConverted)
424  {
425  }
426  // we didn't get a converted key
427  // so this must be a control key
428  else
429  {
430  // RETURN
432  {
433  DPRINT((0,"DebuggerShell(): RETURN\n"));
435  if(ucCommandBuffer[0])
436  {
441  // setup a safe stack for parsing
442  __asm__ __volatile__("\n\t \
443  movl %2,%%eax\n\t \
444  movl %%esp,%%ebx\n\t \
445  mov %%ebx,%0\n\t \
446  leal _aulNewStack,%%ebx\n\t \
447  addl $0x1FFF0,%%ebx\n\t \
448  movl %%ebx,%%esp\n\t \
449  pushl $0\n\t \
450  pushl %%eax\n\t \
451  call _Parse\n\t \
452  movl %0,%%ebx\n\t \
453  movl %%ebx,%%esp"
454  :"=m" (ulOldStack)
455  :"m" (ulOldStack),"m" (ucCommandBuffer)
456  :"eax","ebx");
457 
458  ShowStoppedMsg();
459  }
460  else
461  {
463  {
466  }
467  }
470  }
471  // backspace
473  {
474  DPRINT((0,"DebuggerShell(): BACKSPACE\n"));
476  {
479  else
480  ShowStoppedMsg();
481 
484  Print(OUTPUT_WINDOW,"\b");
485  }
486  }
487  // Tab
489  {
490  DPRINT((0,"DebuggerShell(): TAB\n"));
492  {
493  LPSTR pCmd;
494 
495  if((pCmd=FindCommand(ucCommandBuffer)) )
496  {
497  ULONG i;
498 
499  // clear the displayed command line
500  for(i=0;i<usCurrentPosInInputBuffer;i++)
501  Print(OUTPUT_WINDOW,"\b");
502  // clear command buffer
504  // copy the found command into command buffer
507  usCurrentPosInInputBuffer = PICE_strlen(ucCommandBuffer);
509  }
510  }
511  }
512  else
513  {
514  // function keys
516  {
517  DPRINT((0,"DebuggerShell(): FUNCTION %u\n",ucKeyPressedWhileIdle-59));
518  PICE_sprintf(tempShell,":");
525  if(ucCommandBuffer[0])
526  {
529 
530  // setup a safe stack for parsing
531  __asm__ __volatile__("\n\t \
532  movl %2,%%eax\n\t \
533  movl %%esp,%%ebx\n\t \
534  mov %%ebx,%0\n\t \
535  leal _aulNewStack,%%ebx\n\t \
536  addl $0x1FFF0,%%ebx\n\t \
537  movl %%ebx,%%esp\n\t \
538  pushl $1\n\t \
539  pushl %%eax\n\t \
540  call _Parse\n\t \
541  movl %0,%%ebx\n\t \
542  movl %%ebx,%%esp"
543  :"=m" (ulOldStack)
544  :"m" (ulOldStack),"m" (ucCommandBuffer)
545  :"eax","ebx");
548  }
549  }
550  else
551  {
552  switch(ucKeyPressedWhileIdle)
553  {
554  case SCANCODE_ESC:
556  {
557  PICE_sprintf(tempShell,":");
561  Print(OUTPUT_WINDOW,"");
562  ShowStoppedMsg();
563  }
564  break;
565  case SCANCODE_HOME: // home
566  DPRINT((0,"DebuggerShell(): HOME\n"));
567  // memory window
568  if(bAlt)
569  {
570  DPRINT((0,"DebuggerShell(): data window home\n"));
571  OldOffset=0x0;
572  // display data window
573  Args.Value[0]=OldSelector;
574  Args.Value[1]=OldOffset;
575  Args.Count=2;
576  DisplayMemory(&Args);
577  }
578  // output window
579  else if(bShift)
580  {
581  DPRINT((0,"DebuggerShell(): output window home\n"));
583  {
586  }
587  }
588  // source window home
589  else if(bControl)
590  {
592  {
594 
596  {
598 
600  (LPSTR)pSrc+pSrc->ulOffsetToNext,
601  1,-1);
602  }
603  }
604  }
605  else if(!bShift && !bControl && !bAlt)
606  {
607  }
608  break;
609  case SCANCODE_END: // end
610  DPRINT((0,"DebuggerShell(): END\n"));
611  // memory window
612  if(bAlt)
613  {
614  DPRINT((0,"DebuggerShell(): data window end\n"));
615  OldOffset=0xFFFFFFFF-0x10*4;
616  // display data window
617  Args.Value[0]=OldSelector;
618  Args.Value[1]=OldOffset;
619  Args.Count=2;
620  DisplayMemory(&Args);
621  }
622  // output window
623  else if(bShift)
624  {
625  DPRINT((0,"DebuggerShell(): output window end\n"));
627  {
629 
631  }
632  }
633  else if(!bShift && !bControl && !bAlt)
634  {
635  }
636  break;
637  case SCANCODE_UP: // up
638  DPRINT((0,"DebuggerShell(): UP\n"));
639  // memory window
640  if(bAlt)
641  {
642  DPRINT((0,"DebuggerShell(): data window up\n"));
643  OldOffset-=0x10;
644  // display data window
645  Args.Value[0]=OldSelector;
646  Args.Value[1]=OldOffset;
647  Args.Count=2;
648  DisplayMemory(&Args);
649  }
650  // output window
651  else if(bShift)
652  {
653  DPRINT((0,"DebuggerShell(): output window up ulLastLineDisplayedOffset = %u\n",ulLastLineDisplayedOffset));
654 
656  {
658 
660  }
661  }
662  // source window up
663  else if(bControl)
664  {
666  {
668 
670  {
673  (LPSTR)pSrc+pSrc->ulOffsetToNext,
675  }
676  }
677  else
678  {
680  }
681  }
682  // command line history
683  else if(!bShift && !bControl && !bAlt)
684  {
685  LPSTR pCurrentCmd;
686  ULONG len;
687 
688  DPRINT((0,"DebuggerShell(): command line up\n"));
689 
690  // only if anything in history
692  {
693  // go to next entry in history
696  else
698  DPRINT((0,"DebuggerShell(): current history pos = %u\n",ulCommandCurrentPos));
699  // get this entry
701  // if it has a string attached
702  if((len = PICE_strlen(pCurrentCmd)))
703  {
704  // replace the current command line
705  PICE_sprintf(tempShell,":");
708  PICE_strcpy(ucCommandBuffer,pCurrentCmd);
710  Print(OUTPUT_WINDOW,pCurrentCmd);
711  }
712  }
713  }
714  break;
715  case SCANCODE_DOWN: // down
716  DPRINT((0,"DebuggerShell(): DOWN\n"));
717  // memory window
718  if(bAlt)
719  {
720  DPRINT((0,"DebuggerShell(): data window down\n"));
721  OldOffset+=0x10;
722  // display data window
723  Args.Value[0]=OldSelector;
724  Args.Value[1]=OldOffset;
725  Args.Count=2;
726  DisplayMemory(&Args);
727  }
728  // output window
729  else if(bShift)
730  {
731  DPRINT((0,"DebuggerShell(): output window down ulLastLineDisplayedOffset = %u\n",ulLastLineDisplayedOffset));
733  {
735 
737  {
740  }
741  }
742  }
743  // source window down
744  else if(bControl)
745  {
747  {
749 
751  {
754  (LPSTR)pSrc+pSrc->ulOffsetToNext,
756  }
757  }
758  else
759  {
761  }
762  }
763  // command line history
764  else if(!bShift && !bControl && !bAlt)
765  {
766  LPSTR pCurrentCmd;
767  ULONG len;
768 
769  DPRINT((0,"DebuggerShell(): command line down\n"));
770 
771  // only if anything in history
773  {
774  // go to next entry in history
776  DPRINT((0,"DebuggerShell(): current history pos = %u\n",ulCommandCurrentPos));
777  // get this entry
779  // if it has a string attached
780  if((len = PICE_strlen(pCurrentCmd)))
781  {
782  // replace the current command line
783  PICE_sprintf(tempShell,":");
786  PICE_strcpy(ucCommandBuffer,pCurrentCmd);
788  Print(OUTPUT_WINDOW,pCurrentCmd);
789  }
790  }
791  }
792  break;
793  case SCANCODE_LEFT: // left
794  DPRINT((0,"DebuggerShell(): LEFT\n"));
795  // memory window
796  if(bAlt)
797  {
798  DPRINT((0,"DebuggerShell(): data window left\n"));
799 
800  OldOffset-=0x1;
801  // display data window
802  Args.Value[0]=OldSelector;
803  Args.Value[1]=OldOffset;
804  Args.Count=2;
805  DisplayMemory(&Args);
806  }
807  else if(!bShift && !bControl && !bAlt)
808  {
809  }
810  else if(bControl)
811  {
812  if(ulWindowOffset > 0)
813  ulWindowOffset--;
814  PICE_memset(&Args,0,sizeof(ARGS));
815  Args.Count=0;
816  Unassemble(&Args);
817  }
818  break;
819  case SCANCODE_RIGHT: // right
820  // memory window
821  if(bAlt)
822  {
823  DPRINT((0,"DebuggerShell(): data window right\n"));
824 
825  OldOffset+=0x1;
826  // display data window
827  Args.Value[0]=OldSelector;
828  Args.Value[1]=OldOffset;
829  Args.Count=2;
830  DisplayMemory(&Args);
831  }
832  else if(!bShift && !bControl && !bAlt)
833  {
834  }
835  else if(bControl)
836  {
837  if(ulWindowOffset < 80)
838  ulWindowOffset++;
839  PICE_memset(&Args,0,sizeof(ARGS));
840  Args.Count=0;
841  Unassemble(&Args);
842  }
843  break;
844  case SCANCODE_PGUP: // page up
845  DPRINT((0,"DebuggerShell(): PAGEUP\n"));
846  // memory window
847  if(bAlt)
848  {
850  // display data window
851  Args.Value[0]=OldSelector;
852  Args.Value[1]=OldOffset;
853  Args.Count=2;
854  DisplayMemory(&Args);
855  }
856  // output window
857  else if(bShift)
858  {
860  {
862 
864  }
865  else
866  {
868  {
871  }
872  }
873  }
874  // source window page up
875  else if(bControl)
876  {
878  {
880  {
882 
884  {
886 
888  (LPSTR)pSrc+pSrc->ulOffsetToNext,
890  }
891  }
892  else
893  {
895 
897  {
899 
901  (LPSTR)pSrc+pSrc->ulOffsetToNext,
903  }
904  }
905  }
906  else
907  {
909  }
910 
911  }
912  else if(!bShift && !bControl && !bAlt)
913  {
914  }
915  break;
916  case SCANCODE_PGDN: // page down
917  DPRINT((0,"DebuggerShell(): PAGEDOWN\n"));
918  // memory window
919  if(bAlt)
920  {
922  // display data window
923  Args.Value[0]=OldSelector;
924  Args.Value[1]=OldOffset;
925  Args.Count=2;
926  DisplayMemory(&Args);
927  }
928  else if(bShift)
929  {
931  {
933 
935  }
936  else
937  {
939  {
942  }
943  }
944  }
945  else if(bControl)
946  {
948  {
950  {
952 
954  {
956 
958  (LPSTR)pSrc+pSrc->ulOffsetToNext,
960  }
961  }
962  else
963  {
965 
967  {
969 
971  (LPSTR)pSrc+pSrc->ulOffsetToNext,
973  }
974  }
975  }
976  else
977  {
979  }
980  }
981  else if(!bShift && !bControl && !bAlt)
982  {
983  }
984  break;
985  }
986  }
987  }
988  }
990  }
991  }
992 
993  SaveOldRegs();
994 
995  PrintLogo(TRUE);
996 
997  ShowRunningMsg();
998 
999  if(bRev)
1000  PrintCursor(TRUE);
1001 
1002  // hide the cursor
1003  HideCursor();
1004 
1006 
1008 
1009  LEAVE_FUNC();
1010 }
USHORT CurrentCS
Definition: shell.c:116
ULONG Count
Definition: parse.h:34
void AddToCommandLineHistory(LPSTR s)
Definition: shell.c:160
#define SCANCODE_PGDN
Definition: scancodes.h:76
ULONG LinesInRingBuffer(void)
Definition: hardware.c:116
char * szFunctionKeys[10]
Definition: shell.c:95
void HideCursor(void)
Definition: hardware.c:566
BOOLEAN(* DisplayMemory)(PARGS)
Definition: parse.c:56
void UnassembleOnePageUp(ULONG page)
Definition: parse.c:1513
void UnassembleOneLineDown(void)
Definition: parse.c:1413
volatile UCHAR ucKeyPressedWhileIdle
Definition: shell.c:78
#define SCANCODE_BACKSPACE
Definition: scancodes.h:36
BOOLEAN bRev
Definition: hercules.c:53
#define SCANCODE_PGUP
Definition: scancodes.h:70
BOOLEAN PrintRingBufferHome(ULONG ulLines)
Definition: hardware.c:447
ULONG ulCommandCurrentPos
Definition: shell.c:134
void SaveOldRegs(void)
Definition: utils.c:1324
ULONG GLOBAL_SCREEN_WIDTH
Definition: hardware.c:62
ULONG OldOffset
Definition: shell.c:90
LPSTR FindCommand(LPSTR p)
Definition: parse.c:3252
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
USHORT cy
Definition: hardware.h:33
#define TRUE
Definition: numbers.c:17
volatile BOOLEAN bShift
Definition: shell.c:71
#define SCANCODE_ENTER
Definition: scancodes.h:39
BOOLEAN PrintRingBufferOffset(ULONG ulLines, ULONG ulOffset)
Definition: hardware.c:378
#define LEAVE_FUNC()
Definition: debug.h:43
void ShowCursor(void)
Definition: hardware.c:556
char * LPSTR
Definition: xmlstorage.h:182
void DisplaySourceFile(LPSTR pSrcLine, LPSTR pSrcEnd, ULONG ulLineNumber, ULONG ulLineNumberToInvert)
Definition: parse.c:1313
#define SCANCODE_ESC
Definition: scancodes.h:35
ULONG GetLinesInCommandHistory(void)
Definition: shell.c:143
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
#define SCANCODE_LEFT
Definition: scancodes.h:71
char * PICE_strcpy(char *s1, char *s2)
Definition: utils.c:302
void UnassembleOnePageDown(ULONG page)
Definition: parse.c:1436
__asm__(".global NewInt31Handler\n\t \ NewInt31Handler:\n\t \ cli\n\t \ cld\n\t \ \n\t \ pushl %eax\n\t \ pushl %ds\n\t \ \n\t \ movw %ss,%ax\n\t \ mov %ax,%ds\n\t \ \n\t \ mov 0x4(%esp),%eax\n\t \ movl %eax,_CurrentEAX\n\t \ movl %ebx,_CurrentEBX\n\t \ movl %ecx,_CurrentECX\n\t \ movl %edx,_CurrentEDX\n\t \ movl %esi,_CurrentESI\n\t \ movl %edi,_CurrentEDI\n\t \ movl %ebp,_CurrentEBP\n\t \ movl (%esp),%eax\n\t \ movw %ax,_CurrentDS\n\t \ \n\t \ // test for V86 mode\n\t \ testl $0x20000,5*4(%esp)\n\t \ jz notV86\n\t \ \n\t \ int $0x03\n\t \ \n\t \ notV86:\n\t \ // test if stack switched (ring3->ring0 transition)\n\t \ // stack is switched if orig. SS is not global kernel code segment\n\t \ movl 4*4(%esp),%eax\n\t \ cmpw $"STR(GLOBAL_CODE_SEGMENT)",%ax\n\t \ je notswitched\n\t \ \n\t \ // switched stack\n\t \ movl 6*4(%esp),%eax\n\t \ mov %eax,_CurrentESP\n\t \ mov 7*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ jmp afterswitch\n\t \ \n\t \ notswitched:\n\t \ // didn't switch stack\n\t \ movl %esp,_CurrentESP\n\t \ addl $24,_CurrentESP\n\t \ movw %ss,%ax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ \n\t \ afterswitch:\n\t \ // save EIP\n\t \ mov 3*4(%esp),%eax\n\t \ mov %eax,_CurrentEIP\n\t \ //save CS\n\t \ mov 4*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ movw %ax,_CurrentCS\n\t \ // save flags\n\t \ movl 5*4(%esp),%eax\n\t \ andl $0xFFFFFEFF,%eax\n\t \ movl %eax,_CurrentEFL\n\t \ \n\t \ pushal\n\t \ \n\t \ // get reason code\n\t \ mov 0x28(%esp),%ebx\n\t \ \n\t \ /*\n\t \ * Load the PCR selector.\n\t \ */\n\t \ \n\t \ movl %fs, %eax\n\t \ movl %eax, _OLD_PCR\n\t \ movl _PCR_SEL, %eax\n\t \ movl %eax, %fs\n\t \ \n\t \ // setup a large work stack\n\t \ movl %esp,%eax\n\t \ movl %eax,_ulRealStackPtr\n\t \ \n\t \ pushl %ebx\n\t \ call _RealIsr\n\t \ addl $4,%esp\n\t \ \n\t \ pushl %eax\n\t \ movl _OLD_PCR, %eax\n\t \ movl %eax, %fs\n\t \ popl %eax\n\t \ \n\t \ // restore all regs\n\t \ popal\n\t \ \n\t \ // do an EOI to IRQ controller (because we definitely pressed some key)\n\t \ // TODO: SMP APIC support\n\t \ movb $0x20,%al\n\t \ outb %al,$0x20\n\t \ \n\t \ popl %ds\n\t \ popl %eax\n\t \ \n\t \ // remove reason code\n\t \ addl $4,%esp\n\t \ \n\t \ // make EAX available\n\t \ pushl %eax\n\t \ \n\t \ // modify or restore EFLAGS\n\t \ .byte 0x2e\n\t \ mov _CurrentEFL,%eax\n\t \ mov %eax,3*4(%esp)\n\t \ .byte 0x2e\n\t \ movzwl _CurrentCS,%eax\n\t \ mov %eax,2*4(%esp)\n\t \ .byte 0x2e\n\t \ mov _CurrentEIP,%eax\n\t \ mov %eax,1*4(%esp)\n\t \ \n\t \ // restore EAX\n\t \ popl %eax\n\t \ \n\t \ // do we need to call old INT1 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt1Handler\n\t \ je do_iret2\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt1Handler\n\t \ \n\t \ do_iret2:\n\t \ // do we need to call old INT3 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt3Handler\n\t \ je do_iret1\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt3Handler\n\t \ \n\t \ do_iret1:\n\t \ // do we need to call old pagefault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldIntEHandler\n\t \ je do_iret3\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldIntEHandler\n\t \ \n\t \ do_iret3:\n\t \ // do we need to call old general protection fault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldGPFaultHandler\n\t \ je do_iret\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldGPFaultHandler\n\t \ \n\t \ do_iret:\n\t \ //ei\n\t \ //int3\n\t \ iretl ")
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void outb_p(UCHAR data, PUCHAR port)
Definition: utils.c:2159
UCHAR AsciiFromScan(UCHAR s)
Definition: utils.c:2069
#define SCANCODE_HOME
Definition: scancodes.h:68
#define SCANCODE_RIGHT
Definition: scancodes.h:73
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define SCANCODE_TAB
Definition: scancodes.h:37
LONG ulCurrentlyDisplayedLineNumber
Definition: parse.c:46
void ProcessBootParams(void)
Definition: shell.c:255
void ClrLine(ULONG line)
Definition: hardware.c:662
void DPRINT(...)
Definition: polytest.cpp:61
char ** Args
Definition: acdebug.h:342
WINDOW wWindow[4]
Definition: hardware.c:59
void ShowRunningMsg(void)
Definition: utils.c:843
TCHAR szCurrentFile[MAX_PATH]
Definition: mplay32.c:23
char tempShell[256]
Definition: shell.c:86
volatile BOOLEAN bControl
Definition: shell.c:70
ULONG CurrentProcess
Definition: shell.c:125
char * PICE_strcat(char *s1, char *s2)
Definition: utils.c:315
PEPROCESS NTAPI IoGetCurrentProcess(VOID)
Definition: util.c:112
#define SCANCODE_UP
Definition: scancodes.h:69
void RestoreGraphicsState(void)
Definition: hardware.c:906
UCHAR ucConverted
Definition: shell.c:68
void ReplaceRingBufferCurrent(LPSTR s)
Definition: hardware.c:301
BOOLEAN __inline bNoCtrlKeys(void)
Definition: shell.c:296
#define SCANCODE_DOWN
Definition: scancodes.h:75
Definition: parse.h:31
volatile BOOLEAN bAlt
Definition: shell.c:72
unsigned char UCHAR
Definition: xmlstorage.h:181
void ShowStatusLine(void)
Definition: shell.c:216
GLenum GLsizei len
Definition: glext.h:6722
void FlushKeyboardQueue(void)
Definition: hardware.c:935
void ShowStoppedMsg(void)
Definition: utils.c:861
void PrintRingBuffer(ULONG ulLines)
Definition: hardware.c:315
ULONG ulOldStack
Definition: shell.c:110
void DisplayRegs(void)
Definition: utils.c:1097
void SaveGraphicsState(void)
Definition: hardware.c:897
UCHAR GetKeyPolled(void)
Definition: hardware.c:926
void PutChar(LPSTR p, ULONG x, ULONG y)
Definition: hardware.c:604
USHORT usCurrentPosInInputBuffer
Definition: shell.c:128
UCHAR inb_p(PUCHAR port)
Definition: utils.c:2179
USHORT usCurX
Definition: hardware.h:34
ULONG Value[16]
Definition: parse.h:33
LPSTR GetFromCommandLineHistory(ULONG ulCurrentCommandPos)
Definition: shell.c:194
ULONG CurrentEIP
Definition: shell.c:113
unsigned int * PULONG
Definition: retypes.h:1
void CheckRingBuffer(void)
Definition: hardware.c:133
ULONG ulWindowOffset
Definition: shell.c:63
void UnassembleOneLineUp(void)
Definition: parse.c:1460
BOOLEAN ConvertTokenToSrcFile(LPSTR p, PULONG pValue)
Definition: parse.c:3693
signed char * PCHAR
Definition: retypes.h:7
#define FALSE
Definition: numbers.c:16
unsigned int ULONG
Definition: retypes.h:1
#define SCANCODE_END
Definition: scancodes.h:74
#define ENTER_FUNC()
Definition: debug.h:42
UCHAR ucCommandBuffer[256]
Definition: shell.c:127
USHORT OldSelector
Definition: shell.c:89
INT INT y
Definition: msvc.h:62
volatile BOOLEAN bNotifyToExit
Definition: shell.c:76
void PrintLogo(BOOLEAN bShow)
Definition: hardware.c:778
ULONG ulLastLineDisplayedOffset
Definition: shell.c:92
void PICE_memset(void *p, unsigned char c, int sz)
Definition: utils.c:228
void PrintCursor(BOOLEAN bForce)
Definition: hardware.c:788
void DeInstallGlobalKeyboardHook ( void  )

Definition at line 1677 of file shell.c.

Referenced by CleanUpPICE().

1678 {
1679  ENTER_FUNC();
1680 
1681  MaskIrqs();
1683  {
1686  }
1687  UnmaskIrqs();
1688 
1689  LEAVE_FUNC();
1690 }
ULONG SetGlobalInt(ULONG dwInt, ULONG NewIntHandler)
Definition: hooks.c:95
#define LEAVE_FUNC()
Definition: debug.h:43
void MaskIrqs(void)
Definition: hooks.c:68
volatile ULONG OldGlobalInt31Handler
Definition: shell.c:74
ULONG KeyboardIRQL
Definition: init.c:50
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
void UnmaskIrqs(void)
Definition: hooks.c:82
LPSTR GetFromCommandLineHistory ( ULONG  ulCurrentCommandPos)

Definition at line 194 of file shell.c.

Referenced by DebuggerShell().

195 {
196  LPSTR pRet;
197 
198  ENTER_FUNC();
199 
200  DPRINT((0,"GetFromCommandLineHistory(): current = %u\n",ulCurrentCommandPos));
201 
202  // skip leading ':'
203  pRet = aszCommandLines[ulCurrentCommandPos] + 1;
204 
205  DPRINT((0,"GetFromCommandLineHistory(%s)\n",pRet));
206 
207  LEAVE_FUNC();
208 
209  return pRet;
210 }
#define LEAVE_FUNC()
Definition: debug.h:43
char * LPSTR
Definition: xmlstorage.h:182
char aszCommandLines[LINES_IN_COMMAND_BUFFER][sizeof(ucCommandBuffer)+2]
Definition: shell.c:132
void DPRINT(...)
Definition: polytest.cpp:61
#define ENTER_FUNC()
Definition: debug.h:42
ULONG GetLinesInCommandHistory ( void  )

Definition at line 143 of file shell.c.

Referenced by DebuggerShell().

144 {
146 
147  ENTER_FUNC();
148 
149  DPRINT((0,"GetLinesInCommandHistory() returns %u (ulIn %u ulLast %u)\n",ulResult,ulCommandInPos,ulCommandLastPos));
150 
151  LEAVE_FUNC();
152 
153  return ulResult;
154 }
#define LINES_IN_COMMAND_BUFFER
Definition: shell.c:44
#define LEAVE_FUNC()
Definition: debug.h:43
void DPRINT(...)
Definition: polytest.cpp:61
ULONG ulCommandInPos
Definition: shell.c:133
ULONG ulCommandLastPos
Definition: shell.c:133
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
void InstallGlobalKeyboardHook ( void  )

Definition at line 1657 of file shell.c.

Referenced by InitPICE().

1658 {
1659  ULONG LocalNewGlobalInt31Handler;
1660 
1661  ENTER_FUNC();
1662 
1663  MaskIrqs();
1665  {
1666  __asm__("mov $NewGlobalInt31Handler,%0"
1667  :"=r" (LocalNewGlobalInt31Handler)
1668  :
1669  :"eax");
1670  OldGlobalInt31Handler=SetGlobalInt(KeyboardIRQL,(ULONG)LocalNewGlobalInt31Handler);
1671  }
1672  UnmaskIrqs();
1673 
1674  LEAVE_FUNC();
1675 }
ULONG SetGlobalInt(ULONG dwInt, ULONG NewIntHandler)
Definition: hooks.c:95
#define LEAVE_FUNC()
Definition: debug.h:43
__asm__(".global NewInt31Handler\n\t \ NewInt31Handler:\n\t \ cli\n\t \ cld\n\t \ \n\t \ pushl %eax\n\t \ pushl %ds\n\t \ \n\t \ movw %ss,%ax\n\t \ mov %ax,%ds\n\t \ \n\t \ mov 0x4(%esp),%eax\n\t \ movl %eax,_CurrentEAX\n\t \ movl %ebx,_CurrentEBX\n\t \ movl %ecx,_CurrentECX\n\t \ movl %edx,_CurrentEDX\n\t \ movl %esi,_CurrentESI\n\t \ movl %edi,_CurrentEDI\n\t \ movl %ebp,_CurrentEBP\n\t \ movl (%esp),%eax\n\t \ movw %ax,_CurrentDS\n\t \ \n\t \ // test for V86 mode\n\t \ testl $0x20000,5*4(%esp)\n\t \ jz notV86\n\t \ \n\t \ int $0x03\n\t \ \n\t \ notV86:\n\t \ // test if stack switched (ring3->ring0 transition)\n\t \ // stack is switched if orig. SS is not global kernel code segment\n\t \ movl 4*4(%esp),%eax\n\t \ cmpw $"STR(GLOBAL_CODE_SEGMENT)",%ax\n\t \ je notswitched\n\t \ \n\t \ // switched stack\n\t \ movl 6*4(%esp),%eax\n\t \ mov %eax,_CurrentESP\n\t \ mov 7*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ jmp afterswitch\n\t \ \n\t \ notswitched:\n\t \ // didn't switch stack\n\t \ movl %esp,_CurrentESP\n\t \ addl $24,_CurrentESP\n\t \ movw %ss,%ax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ \n\t \ afterswitch:\n\t \ // save EIP\n\t \ mov 3*4(%esp),%eax\n\t \ mov %eax,_CurrentEIP\n\t \ //save CS\n\t \ mov 4*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ movw %ax,_CurrentCS\n\t \ // save flags\n\t \ movl 5*4(%esp),%eax\n\t \ andl $0xFFFFFEFF,%eax\n\t \ movl %eax,_CurrentEFL\n\t \ \n\t \ pushal\n\t \ \n\t \ // get reason code\n\t \ mov 0x28(%esp),%ebx\n\t \ \n\t \ /*\n\t \ * Load the PCR selector.\n\t \ */\n\t \ \n\t \ movl %fs, %eax\n\t \ movl %eax, _OLD_PCR\n\t \ movl _PCR_SEL, %eax\n\t \ movl %eax, %fs\n\t \ \n\t \ // setup a large work stack\n\t \ movl %esp,%eax\n\t \ movl %eax,_ulRealStackPtr\n\t \ \n\t \ pushl %ebx\n\t \ call _RealIsr\n\t \ addl $4,%esp\n\t \ \n\t \ pushl %eax\n\t \ movl _OLD_PCR, %eax\n\t \ movl %eax, %fs\n\t \ popl %eax\n\t \ \n\t \ // restore all regs\n\t \ popal\n\t \ \n\t \ // do an EOI to IRQ controller (because we definitely pressed some key)\n\t \ // TODO: SMP APIC support\n\t \ movb $0x20,%al\n\t \ outb %al,$0x20\n\t \ \n\t \ popl %ds\n\t \ popl %eax\n\t \ \n\t \ // remove reason code\n\t \ addl $4,%esp\n\t \ \n\t \ // make EAX available\n\t \ pushl %eax\n\t \ \n\t \ // modify or restore EFLAGS\n\t \ .byte 0x2e\n\t \ mov _CurrentEFL,%eax\n\t \ mov %eax,3*4(%esp)\n\t \ .byte 0x2e\n\t \ movzwl _CurrentCS,%eax\n\t \ mov %eax,2*4(%esp)\n\t \ .byte 0x2e\n\t \ mov _CurrentEIP,%eax\n\t \ mov %eax,1*4(%esp)\n\t \ \n\t \ // restore EAX\n\t \ popl %eax\n\t \ \n\t \ // do we need to call old INT1 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt1Handler\n\t \ je do_iret2\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt1Handler\n\t \ \n\t \ do_iret2:\n\t \ // do we need to call old INT3 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt3Handler\n\t \ je do_iret1\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt3Handler\n\t \ \n\t \ do_iret1:\n\t \ // do we need to call old pagefault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldIntEHandler\n\t \ je do_iret3\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldIntEHandler\n\t \ \n\t \ do_iret3:\n\t \ // do we need to call old general protection fault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldGPFaultHandler\n\t \ je do_iret\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldGPFaultHandler\n\t \ \n\t \ do_iret:\n\t \ //ei\n\t \ //int3\n\t \ iretl ")
void MaskIrqs(void)
Definition: hooks.c:68
volatile ULONG OldGlobalInt31Handler
Definition: shell.c:74
ULONG KeyboardIRQL
Definition: init.c:50
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
void UnmaskIrqs(void)
Definition: hooks.c:82
void ProcessBootParams ( void  )

Definition at line 255 of file shell.c.

Referenced by DebuggerShell().

256 {
257  LPSTR p1,p2;
258 
259  ENTER_FUNC();
260  if(*szBootParams)
261  {
262  DPRINT((0,"ProcessBootParams()\n"));
263 
264  p1 = szBootParams;
265 
266  while(*p1)
267  {
268  p2 = ucCommandBuffer;
269  DPRINT((0,"ProcessBootParams(): boot params = %s\n",p1));
270  while(*p1 && *p1!=';')
271  {
272  *p2++ = *p1++;
273  }
274  *p2=0;
275  DPRINT((0,"ProcessBootParams(): cmd buf = %s\n",ucCommandBuffer));
276  if(*p1 != ';')
277  {
278  DPRINT((0,"ProcessBootParams(): error in cmd buf\n"));
279  break;
280  }
281  p1++;
282  DPRINT((0,"ProcessBootParams(): next cmd buf = %s\n",p1));
283 
285  }
287  *szBootParams = 0;
288  }
289  LEAVE_FUNC();
290 }
struct Parse Parse
Definition: dwarfinfo.c:330
#define TRUE
Definition: numbers.c:17
#define LEAVE_FUNC()
Definition: debug.h:43
char * LPSTR
Definition: xmlstorage.h:182
const GLfloat * p2
Definition: s_aatritemp.h:44
void DPRINT(...)
Definition: polytest.cpp:61
#define ENTER_FUNC()
Definition: debug.h:42
UCHAR ucCommandBuffer[256]
Definition: shell.c:127
const GLfloat * p1
Definition: s_aatritemp.h:43
void PICE_memset(void *p, unsigned char c, int sz)
Definition: utils.c:228
char szBootParams[1024]
Definition: init.c:41
void RealIsr ( ULONG  dwReasonForBreak)

Definition at line 1016 of file shell.c.

Referenced by InitPICE().

1017 {
1018  BOOLEAN ReinstallPermanentBp = FALSE;
1019 
1020  DPRINT((0,"reason: %u#################################################################\n", dwReasonForBreak));
1021  ENTER_FUNC();
1022 
1023  // in handler
1025 
1026  bStepping = FALSE;
1027 
1028  // don't assume we must call original handlers yet
1030  bSkipMainLoop = FALSE;
1031  bEnterNow = FALSE;
1032 
1033  // reset trace flag (TF) on the stack
1034  CurrentEFL&=(~0x100);
1035 
1037 
1038  // control is not depressed
1039  bControl=FALSE;
1040 
1041  bIrqStateAtBreak = ((CurrentEFL&(1<<9))!=0);
1042 
1043  DPRINT((0,"\nbInDebuggerShell %x, dwReasonForBreak: %x, bIrqStateAtBreak: %d\n", bInDebuggerShell, dwReasonForBreak, bIrqStateAtBreak));
1044  DPRINT((0,"CurrentEIP: %x, CurrentESP: %x\n", CurrentEIP, CurrentESP));
1045 
1046  // came in because TF flag was set
1047  if(dwReasonForBreak == REASON_SINGLESTEP)
1048  {
1049  ULONG ulAddress,ulAddressCurrent;
1050 
1051  DPRINT((0,"REASON_SINGLESTEP: bSingleStep: %u\n", bSingleStep));
1052 
1053  if(!bSingleStep)
1054  {
1056  DPRINT((0,"no single step requested: %u!\n", dwCallOldInt1Handler));
1057  goto common_return_point;
1058  }
1059 
1060  ulAddress = GetLinearAddress(OldCS,OldEIP);
1061  ulAddressCurrent = GetLinearAddress(CurrentCS,CurrentEIP);
1062 
1063  // if we came in because we needed to skip past a permanent
1064  // INT3 hook, we need to put the INT3 back in place and
1065  // simply restart the system.
1066  if(NeedToReInstallSWBreakpoints(ulAddress,TRUE) )
1067  {
1068  DPRINT((0,"reinstalling INT3 @ %.4X:%.8X\n",OldCS,OldEIP));
1069 
1070  ReInstallSWBreakpoint(ulAddress);
1071 
1072  // previous command was go i.e. we did not single-step over a location
1073  // where a permanent breakpoint was installed (Printk() etc.) we simply restart
1074  // else we must stop the system.
1076  {
1079 
1080  if(bStepThroughSource)
1081  {
1082  // set TF flag
1083  CurrentEFL |= 0x100;
1084  }
1085 
1086  LEAVE_FUNC();
1087  DPRINT((0,"singlestep-----------------------------------------------------------------\n"));
1088  return;
1089  }
1091  }
1092 
1093  if(IsSwBpAtAddressInstalled(ulAddressCurrent))
1094  DeInstallSWBreakpoint(ulAddressCurrent);
1095 
1096  // we came here while stepping through source code block
1097  if(bStepThroughSource)
1098  {
1099  ULONG ulLineNumber;
1100  LPSTR pSrc,pFileName;
1101 
1102  DPRINT((0,"RealIsr(): stepping through source!\n"));
1103 
1104  // look up the corresponding source line
1105  // if there isn't any or the source line number has changed
1106  // we break back into the debugger
1107  if(bShowSrc)
1108  pSrc = FindSourceLineForAddress(ulAddressCurrent,&ulLineNumber,NULL,NULL,&pFileName);
1109  else pSrc = NULL;
1110 
1111  DPRINT((0,"RealIsr(): line #%u pSrc=%x (old line #%u)\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart));
1112 
1113  // if we have found a source line there
1114  if(pSrc && ulLineNumber==g_ulLineNumberStart)
1115  {
1116  DPRINT((0,"RealIsr(): stepping through line #%u in file = %s!\n",ulLineNumber,pFileName));
1117 
1118  if(bStepInto)
1119  StepInto(NULL);
1120  else
1121  StepOver(NULL);
1122 
1124  LEAVE_FUNC();
1125  DPRINT((0,"singstep-----------------------------------------------------------------\n"));
1126  return;
1127  }
1129  bNotifyToExit = FALSE;
1130  bSkipMainLoop = FALSE;
1131  }
1132  }
1133  // came in because hardware register triggered a breakpoint
1134  else if(dwReasonForBreak == REASON_HARDWARE_BP)
1135  {
1136  ULONG ulReason;
1137 
1138  DPRINT((0,"REASON_HARDWARE_BP\n"));
1139 
1140  // disable HW breakpoints
1141  __asm__("\n\t \
1142  movl %%dr6,%%eax\n\t \
1143  movl %%eax,%0\n\t \
1144  xorl %%eax,%%eax\n\t \
1145  movl %%eax,%%dr6\n\t \
1146  movl %%eax,%%dr7"
1147  :"=m" (ulReason)
1148  :
1149  :"eax"
1150  );
1151 
1152  DPRINT((0,"REASON_HARDWARE_BP: %x\n",(ulReason&0xF)));
1153 
1154  // HW breakpoint DR1 (skip: only used in init_module detection)
1155  if(ulReason&0x2)
1156  {
1157  CurrentEFL |=(1<<16); // set resume flag
1158 
1159  bSkipMainLoop = TRUE;
1160 
1162  }
1163  // HW breakpoint DR0
1164  else if(ulReason&0x1)
1165  {
1166  ULONG ulAddressCurrent;
1167 
1168  ulAddressCurrent = GetLinearAddress(CurrentCS,CurrentEIP);
1169 
1170  // we came here while stepping through source code block
1171  if(bStepThroughSource)
1172  {
1173  ULONG ulLineNumber;
1174  LPSTR pSrc,pFileName;
1175 
1176  DPRINT((0,"RealIsr(): stepping through source! [2]\n"));
1177 
1178  // look up the corresponding source line
1179  // if there isn't any or the source line number has changed
1180  // we break back into the debugger
1181  if(bShowSrc)
1182  pSrc = FindSourceLineForAddress(ulAddressCurrent,&ulLineNumber,NULL,NULL,&pFileName);
1183  else
1184  pSrc = NULL;
1185 
1186  DPRINT((0,"RealIsr(): line #%u pSrc=%x (old line #%u) [2]\n",ulLineNumber,(ULONG)pSrc,g_ulLineNumberStart));
1187 
1188  // if we have found a source line there
1189  if(pSrc && ulLineNumber==g_ulLineNumberStart)
1190  {
1191  DPRINT((0,"RealIsr(): stepping through line #%u in file = %s! [2]\n",ulLineNumber,pFileName));
1192 
1193  if(bStepInto)
1194  StepInto(NULL);
1195  else
1196  StepOver(NULL);
1197 
1199  LEAVE_FUNC();
1200  DPRINT((0,"rrr-----------------------------------------------------------------\n"));
1201  return;
1202  }
1203  bNotifyToExit = FALSE;
1204  bSkipMainLoop = FALSE;
1206  }
1207  }
1208  }
1209  else if(dwReasonForBreak==REASON_INT3)
1210  {
1211  ULONG ulAddress;
1212 
1213  DPRINT((0,"REASON_INT3\n"));
1214 
1215  // must subtract one cause INT3s are generated after instructions execution
1216  CurrentEIP--;
1217 
1218  // make a flat address
1219  ulAddress = GetLinearAddress(CurrentCS,CurrentEIP);
1220 
1221  DPRINT((0,"INT3 @ %.8X\n",ulAddress));
1222 
1223  // if there's a breakpoint installed at current EIP remove it
1224  if(DeInstallSWBreakpoint(ulAddress) )
1225  {
1226  PSW_BP p;
1227 
1228  DPRINT((0,"INT3 @ %.8X removed\n",ulAddress));
1229 
1230  // if it's permanent (must be Printk() ) skip the DebuggerShell() and
1231  // do a callback
1232  if( (p = IsPermanentSWBreakpoint(ulAddress)) )
1233  {
1234  DPRINT((0,"permanent breakpoint\n"));
1235 
1236  ReinstallPermanentBp = TRUE;
1237 
1238  OldCS = CurrentCS;
1239  OldEIP = CurrentEIP;
1240 
1241  bSkipMainLoop = TRUE;
1242  DPRINT((0,"callback at %x\n",p->Callback));
1243  if(p->Callback)
1244  p->Callback();
1245  }
1246  else
1247  {
1248  LPSTR pFind;
1250  {
1251  PICE_sprintf(tempShell,"pICE: SW Breakpoint at %s (%.4X:%.8X)\n",pFind,CurrentCS,CurrentEIP);
1252  }
1253  else
1254  {
1255  PICE_sprintf(tempShell,"pICE: SW Breakpoint at %.4X:%.8X\n",CurrentCS,CurrentEIP);
1256  }
1258  }
1259  CurrentEFL &= ~(1<<16); // clear resume flag
1260  }
1261  else
1262  {
1263  LPSTR pFind;
1264  PEPROCESS my_current = IoGetCurrentProcess();
1265 
1266  DPRINT((0,"can't deinstall, somebody else's breakpoint\n"));
1267 
1268 
1269  // if no other debugger is running on this process and the address is
1270  // above TASK_SIZE we assume this to be a hard embedded INT3
1271 /*
1272 #if REAL_LINUX_VERSION_CODE < 0x020400
1273  if(ulAddress<TASK_SIZE && !(my_current->flags & PF_PTRACED) )
1274 #else
1275  if(ulAddress<TASK_SIZE && !(my_current->ptrace & PT_PTRACED) )
1276 #endif
1277 */
1278  if( ulAddress )
1279  {
1281  {
1282  PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at %s (%.4X:%.8X)\n",pFind,CurrentCS,CurrentEIP);
1283  }
1284  else
1285  {
1286  PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at user-mode address %.4X:%.8X\n",CurrentCS,CurrentEIP);
1287  }
1289  CurrentEFL &= ~(1<<16); // clear resume flag
1290  }
1291  // well someone is already debugging this, we must pass the INT3 on to old handler
1292  // but only when it's a user-mode address
1293 /*
1294  else
1295  {
1296  if(ulAddress<TASK_SIZE || !bInt3Here)
1297  {
1298  DPRINT((0,"SW Breakpoint but debugged by other process at %.4X:%.8X\n",CurrentCS,CurrentEIP));
1299  // call the old handler on return from RealIsr()
1300  dwCallOldInt3Handler = 1;
1301  // and skip DebuggerShell()
1302  bSkipMainLoop = TRUE;
1303  }
1304  else
1305  {
1306  if(ScanExportsByAddress(&pFind,GetLinearAddress(CurrentCS,CurrentEIP)))
1307  {
1308  PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at (%s) %.4X:%.8X\n",
1309  pFind,CurrentCS,CurrentEIP);
1310  }
1311  else
1312  {
1313  PICE_sprintf(tempShell,"pICE: break due to embedded INT 3 at kernel-mode address %.4X:%.8X\n",
1314  CurrentCS,CurrentEIP);
1315  }
1316  Print(OUTPUT_WINDOW,tempShell);
1317  CurrentEFL &= ~(1<<16); // clear resume flag
1318  }
1319  }
1320 */
1321  // skip INT3
1322  CurrentEIP++;
1323  }
1324  }
1325  else if(dwReasonForBreak == REASON_PAGEFAULT)
1326  {
1327  LPSTR pSymbolName;
1328 
1329  DPRINT((0,"REASON_PAGEFAULT\n"));
1330 
1332  {
1333  PICE_sprintf(tempShell,"pICE: Breakpoint due to page fault at %.4X:%.8X (%s)\n",CurrentCS,CurrentEIP,pSymbolName);
1334  }
1335  else
1336  {
1337  PICE_sprintf(tempShell,"pICE: Breakpoint due to page fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
1338  }
1340  PICE_sprintf(tempShell,"pICE: memory referenced %x\n",CurrentCR2);
1343  }
1344  else if(dwReasonForBreak == REASON_GP_FAULT)
1345  {
1346  LPSTR pSymbolName;
1347 
1348  DPRINT((0,"REASON_GPFAULT\n"));
1349 
1351  {
1352  PICE_sprintf(tempShell,"pICE: Breakpoint due to general protection fault at %.4X:%.8X (%s)\n",CurrentCS,CurrentEIP,pSymbolName);
1353  }
1354  else
1355  {
1356  PICE_sprintf(tempShell,"pICE: Breakpoint due to general protection fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
1357  }
1360  }
1361  else if(dwReasonForBreak == REASON_CTRLF)
1362  {
1363  DPRINT((0,"REASON_CTRLF\n"));
1364  // nothing to do
1365  }
1366  else if(dwReasonForBreak == REASON_DOUBLE_FAULT)
1367  {
1368  DPRINT((0,"REASON_DOUBLE_FAULT\n"));
1369 
1370  PICE_sprintf(tempShell,"pICE: Breakpoint due to double fault at %.4X:%.8X\n",CurrentCS,CurrentEIP);
1372  }
1373  else if(dwReasonForBreak == REASON_INTERNAL_ERROR)
1374  {
1375  DPRINT((0,"REASON_INTERNAL_ERROR\n"));
1376 
1377  Print(OUTPUT_WINDOW,"pICE: Please report this error to klauspg@diamondmm.com!\n");
1378 // Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n");
1379 // __asm__ __volatile__("hlt");
1380  }
1381  else
1382  {
1383  DPRINT((0,"REASON_UNKNOWN\n"));
1384 
1385  PICE_sprintf(tempShell,"pICE: Breakpoint due to unknown reason at %.4X:%.8X (code %x)\n",CurrentCS,CurrentEIP,dwReasonForBreak);
1387  Print(OUTPUT_WINDOW,"pICE: Please report this error to klauspg@diamondmm.com!\n");
1388  Print(OUTPUT_WINDOW,"pICE: !!! SYSTEM HALTED !!!\n");
1389  __asm__ __volatile__("hlt");
1390  }
1391 
1392  // we don't single-step yet
1393  DPRINT((0,"RealIsr(): not stepping yet\n"));
1395 
1396  // process commands
1397  if(bSkipMainLoop == FALSE)
1398  {
1399  DPRINT((0,"RealIsr(): saving registers\n"));
1400  // save the extended regs
1401  __asm__ __volatile__
1402  ("\n\t \
1403  pushl %eax\n\t \
1404  movw %es,%ax\n\t \
1405  movw %ax,_CurrentES\n\t \
1406  //movw %fs,%ax\n\t \
1407  //movw %ax,_CurrentFS\n\t \
1408  movw %gs,%ax\n\t \
1409  movw %ax,_CurrentGS\n\t \
1410  movl %dr0,%eax\n\t \
1411  movl %eax,_CurrentDR0\n\t \
1412  movl %dr1,%eax\n\t \
1413  movl %eax,_CurrentDR1\n\t \
1414  movl %dr2,%eax\n\t \
1415  movl %eax,_CurrentDR2\n\t \
1416  movl %dr3,%eax\n\t \
1417  movl %eax,_CurrentDR3\n\t \
1418  movl %dr6,%eax\n\t \
1419  movl %eax,_CurrentDR6\n\t \
1420  movl %dr7,%eax\n\t \
1421  movl %eax,_CurrentDR7\n\t \
1422  movl %cr0,%eax\n\t \
1423  movl %eax,_CurrentCR0\n\t \
1424  movl %cr2,%eax\n\t \
1425  movl %eax,_CurrentCR2\n\t \
1426  movl %cr3,%eax\n\t \
1427  movl %eax,_CurrentCR3\n\t \
1428  popl %eax"
1429  );
1430 
1431  CurrentFS = OLD_PCR;
1432  DPRINT((0,"RealIsr(): adding colon to output()\n"));
1433  Print(OUTPUT_WINDOW,":");
1434 
1435  DPRINT((0,"RealIsr(): calling DebuggerShell()\n"));
1436  DebuggerShell();
1437  }
1438 
1439  // if there was a SW breakpoint at CS:EIP
1441  {
1442  DPRINT((0,"need to reinstall INT3\n"));
1443  // remember how we restarted last time
1445  // do a single step to reinstall breakpoint
1446  // modify trace flag
1447  CurrentEFL|=0x100; // set trace flag (TF)
1448 
1449  bSingleStep=TRUE;
1451  }
1452 
1453 common_return_point:
1454 
1455  // reset the global flags
1456  bNotifyToExit = FALSE;
1457  bSkipMainLoop = FALSE;
1458 
1459  // not in handler anymore
1461 
1462  LEAVE_FUNC();
1463  DPRINT((0,"common return-----------------------------------------------------------------\n"));
1464 }
USHORT CurrentCS
Definition: shell.c:116
volatile BOOLEAN bEnterNow
Definition: shell.c:75
volatile BOOLEAN bInDebuggerShell
Definition: shell.c:79
#define REASON_DOUBLE_FAULT
Definition: shell.h:77
volatile BOOLEAN bSkipMainLoop
Definition: shell.c:77
BOOLEAN bStepInto
Definition: shell.c:65
ULONG OldEIP
Definition: shell.c:120
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
ULONG dwCallOldInt1Handler
Definition: shell.c:57
#define TRUE
Definition: numbers.c:17
#define LEAVE_FUNC()
Definition: debug.h:43
char * LPSTR
Definition: xmlstorage.h:182
Definition: bp.h:31
BOOLEAN bStepping
Definition: parse.c:63
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
BOOLEAN bShowSrc
Definition: parse.c:252
#define REASON_GP_FAULT
Definition: shell.h:75
#define REASON_INTERNAL_ERROR
Definition: shell.h:79
__asm__(".global NewInt31Handler\n\t \ NewInt31Handler:\n\t \ cli\n\t \ cld\n\t \ \n\t \ pushl %eax\n\t \ pushl %ds\n\t \ \n\t \ movw %ss,%ax\n\t \ mov %ax,%ds\n\t \ \n\t \ mov 0x4(%esp),%eax\n\t \ movl %eax,_CurrentEAX\n\t \ movl %ebx,_CurrentEBX\n\t \ movl %ecx,_CurrentECX\n\t \ movl %edx,_CurrentEDX\n\t \ movl %esi,_CurrentESI\n\t \ movl %edi,_CurrentEDI\n\t \ movl %ebp,_CurrentEBP\n\t \ movl (%esp),%eax\n\t \ movw %ax,_CurrentDS\n\t \ \n\t \ // test for V86 mode\n\t \ testl $0x20000,5*4(%esp)\n\t \ jz notV86\n\t \ \n\t \ int $0x03\n\t \ \n\t \ notV86:\n\t \ // test if stack switched (ring3->ring0 transition)\n\t \ // stack is switched if orig. SS is not global kernel code segment\n\t \ movl 4*4(%esp),%eax\n\t \ cmpw $"STR(GLOBAL_CODE_SEGMENT)",%ax\n\t \ je notswitched\n\t \ \n\t \ // switched stack\n\t \ movl 6*4(%esp),%eax\n\t \ mov %eax,_CurrentESP\n\t \ mov 7*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ jmp afterswitch\n\t \ \n\t \ notswitched:\n\t \ // didn't switch stack\n\t \ movl %esp,_CurrentESP\n\t \ addl $24,_CurrentESP\n\t \ movw %ss,%ax\n\t \ movzwl %ax,%eax\n\t \ mov %ax,_CurrentSS\n\t \ \n\t \ afterswitch:\n\t \ // save EIP\n\t \ mov 3*4(%esp),%eax\n\t \ mov %eax,_CurrentEIP\n\t \ //save CS\n\t \ mov 4*4(%esp),%eax\n\t \ movzwl %ax,%eax\n\t \ movw %ax,_CurrentCS\n\t \ // save flags\n\t \ movl 5*4(%esp),%eax\n\t \ andl $0xFFFFFEFF,%eax\n\t \ movl %eax,_CurrentEFL\n\t \ \n\t \ pushal\n\t \ \n\t \ // get reason code\n\t \ mov 0x28(%esp),%ebx\n\t \ \n\t \ /*\n\t \ * Load the PCR selector.\n\t \ */\n\t \ \n\t \ movl %fs, %eax\n\t \ movl %eax, _OLD_PCR\n\t \ movl _PCR_SEL, %eax\n\t \ movl %eax, %fs\n\t \ \n\t \ // setup a large work stack\n\t \ movl %esp,%eax\n\t \ movl %eax,_ulRealStackPtr\n\t \ \n\t \ pushl %ebx\n\t \ call _RealIsr\n\t \ addl $4,%esp\n\t \ \n\t \ pushl %eax\n\t \ movl _OLD_PCR, %eax\n\t \ movl %eax, %fs\n\t \ popl %eax\n\t \ \n\t \ // restore all regs\n\t \ popal\n\t \ \n\t \ // do an EOI to IRQ controller (because we definitely pressed some key)\n\t \ // TODO: SMP APIC support\n\t \ movb $0x20,%al\n\t \ outb %al,$0x20\n\t \ \n\t \ popl %ds\n\t \ popl %eax\n\t \ \n\t \ // remove reason code\n\t \ addl $4,%esp\n\t \ \n\t \ // make EAX available\n\t \ pushl %eax\n\t \ \n\t \ // modify or restore EFLAGS\n\t \ .byte 0x2e\n\t \ mov _CurrentEFL,%eax\n\t \ mov %eax,3*4(%esp)\n\t \ .byte 0x2e\n\t \ movzwl _CurrentCS,%eax\n\t \ mov %eax,2*4(%esp)\n\t \ .byte 0x2e\n\t \ mov _CurrentEIP,%eax\n\t \ mov %eax,1*4(%esp)\n\t \ \n\t \ // restore EAX\n\t \ popl %eax\n\t \ \n\t \ // do we need to call old INT1 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt1Handler\n\t \ je do_iret2\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt1Handler\n\t \ \n\t \ do_iret2:\n\t \ // do we need to call old INT3 handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldInt3Handler\n\t \ je do_iret1\n\t \ \n\t \ // call INT3 handler\n\t \ .byte 0x2e\n\t \ jmp *_OldInt3Handler\n\t \ \n\t \ do_iret1:\n\t \ // do we need to call old pagefault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldIntEHandler\n\t \ je do_iret3\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldIntEHandler\n\t \ \n\t \ do_iret3:\n\t \ // do we need to call old general protection fault handler\n\t \ .byte 0x2e\n\t \ cmp $0,_dwCallOldGPFaultHandler\n\t \ je do_iret\n\t \ \n\t \ // call old pagefault handler\n\t \ .byte 0x2e\n\t \ pushl _error_code\n\t \ .byte 0x2e\n\t \ jmp *_OldGPFaultHandler\n\t \ \n\t \ do_iret:\n\t \ //ei\n\t \ //int3\n\t \ iretl ")
USHORT OldCS
Definition: shell.c:123
#define REASON_HARDWARE_BP
Definition: shell.h:76
volatile BOOLEAN bSingleStep
Definition: shell.c:129
#define NULL
Definition: mystdio.h:57
ULONG dwCallOldGPFaultHandler
Definition: shell.c:60
USHORT CurrentFS
Definition: shell.c:116
void DPRINT(...)
Definition: polytest.cpp:61
ULONG dwCallOldInt3Handler
Definition: shell.c:58
char tempShell[256]
Definition: shell.c:86
unsigned char BOOLEAN
volatile BOOLEAN bControl
Definition: shell.c:70
PEPROCESS NTAPI IoGetCurrentProcess(VOID)
Definition: util.c:112
void(* Callback)(void)
Definition: bp.h:42
ULONG dwCallOldIntEHandler
Definition: shell.c:59
void TryToInstallVirtualSWBreakpoints(void)
Definition: bp.c:331
ULONG GetLinearAddress(USHORT Segment, ULONG Offset)
Definition: utils.c:782
ULONG CurrentCR2
Definition: shell.c:118
void InstallPrintkHook(void)
Definition: output.c:252
#define REASON_SINGLESTEP
Definition: shell.h:72
BOOLEAN ReInstallSWBreakpoint(ULONG ulAddress)
Definition: bp.c:197
PSW_BP IsPermanentSWBreakpoint(ULONG ulAddress)
Definition: bp.c:520
LPSTR FindSourceLineForAddress(ULONG addr, PULONG pulLineNumber, LPSTR *ppSrcStart, LPSTR *ppSrcEnd, LPSTR *ppFilename)
Definition: symbols.c:1476
BOOLEAN bStepThroughSource
Definition: shell.c:64
BOOLEAN bIrqStateAtBreak
Definition: shell.c:80
ULONG g_ulLineNumberStart
Definition: shell.c:62
void DebuggerShell(void)
Definition: shell.c:307
static ULONG OLD_PCR
Definition: shell.c:84
ULONG CurrentEIP
Definition: shell.c:113
BOOLEAN NeedToReInstallSWBreakpoints(ULONG ulAddress, BOOLEAN bUseAddress)
Definition: bp.c:150
BOOLEAN DeInstallSWBreakpoint(ULONG ulAddress)
Definition: bp.c:428
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
BOOLEAN IsSwBpAtAddressInstalled(ULONG ulAddress)
Definition: bp.c:113
#define FALSE
Definition: numbers.c:16
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
ULONG CurrentESP
Definition: shell.c:115
BOOLEAN ScanExportsByAddress(LPSTR *pFind, ULONG ulValue)
Definition: symbols.c:599
ULONG CurrentEFL
Definition: shell.c:113
GLfloat GLfloat p
Definition: glext.h:8902
ULONG bPreviousCommandWasGo
Definition: shell.c:54
volatile BOOLEAN bNotifyToExit
Definition: shell.c:76
#define REASON_INT3
Definition: shell.h:71
#define REASON_CTRLF
Definition: shell.h:73
#define REASON_PAGEFAULT
Definition: shell.h:74
void ShowStatusLine ( void  )

Definition at line 216 of file shell.c.

Referenced by DebuggerShell(), Parse(), and RepaintDesktop().

217 {
218  PEPROCESS pCurrentProcess = IoGetCurrentProcess();
219  LPSTR pProcessName;
220 
221  ENTER_FUNC();
222 
223  if(IsAddressValid((ULONG)pCurrentProcess))
224  {
227 
229 
230  pProcessName = pCurrentProcess->ImageFileName;
231  if(IsAddressValid((ULONG)pProcessName) )
232  {
234  " PROCESS(%.8X \"%s\") ",
235  (ULONG)pCurrentProcess,pProcessName);
236  }
237  else
238  {
240  " PROCESS(%.8X) ",
241  (ULONG)pCurrentProcess);
242  }
244 
245  ResetColor();
246  }
247 
248  LEAVE_FUNC();
249 }
void SetForegroundColor(ECOLORS c)
Definition: hardware.c:576
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
#define LEAVE_FUNC()
Definition: debug.h:43
char * LPSTR
Definition: xmlstorage.h:182
#define COLOR_TEXT
Definition: hardware.h:158
void ClrLine(ULONG line)
Definition: hardware.c:662
WINDOW wWindow[4]
Definition: hardware.c:59
char tempShell[256]
Definition: shell.c:86
PEPROCESS NTAPI IoGetCurrentProcess(VOID)
Definition: util.c:112
void PutChar(LPSTR p, ULONG x, ULONG y)
Definition: hardware.c:604
void SetBackgroundColor(ECOLORS c)
Definition: hardware.c:590
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
void ResetColor(void)
Definition: hardware.c:500
#define COLOR_CAPTION
Definition: hardware.h:156
INT INT y
Definition: msvc.h:62
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

Variable Documentation

Definition at line 132 of file shell.c.

Referenced by AddToCommandLineHistory(), and GetFromCommandLineHistory().

ULONG aulNewStack[0x20000]

Definition at line 109 of file shell.c.

volatile BOOLEAN bControl =FALSE

Definition at line 70 of file shell.c.

Referenced by bNoCtrlKeys(), DebuggerShell(), KeyboardGetKeyPolled(), PiceKbdIsr(), and RealIsr().

volatile BOOLEAN bEnterNow =FALSE

Definition at line 75 of file shell.c.

Referenced by PiceKbdIsr(), and RealIsr().

volatile BOOLEAN bInDebuggerShell =FALSE

Definition at line 79 of file shell.c.

Referenced by HandlePageFault(), and RealIsr().

BOOLEAN bIrqStateAtBreak

Definition at line 80 of file shell.c.

Referenced by RealIsr().

volatile BOOLEAN bNotifyToExit =FALSE

Definition at line 76 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), DebuggerShell(), and RealIsr().

ULONG bPreviousCommandWasGo = FALSE

Definition at line 54 of file shell.c.

Referenced by RealIsr().

volatile BOOLEAN bSingleStep =FALSE

Definition at line 129 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), and RealIsr().

volatile BOOLEAN bSkipMainLoop =FALSE

Definition at line 77 of file shell.c.

Referenced by RealIsr().

BOOLEAN bStepInto = FALSE

Definition at line 65 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), and RealIsr().

BOOLEAN bStepThroughSource =FALSE

Definition at line 64 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), and RealIsr().

ULONG CurrentCR0

Definition at line 118 of file shell.c.

ULONG CurrentCR2

Definition at line 118 of file shell.c.

Referenced by RealIsr().

ULONG CurrentCR3

Definition at line 118 of file shell.c.

ULONG CurrentDR0

Definition at line 117 of file shell.c.

ULONG CurrentDR1

Definition at line 117 of file shell.c.

ULONG CurrentDR2

Definition at line 117 of file shell.c.

ULONG CurrentDR3

Definition at line 117 of file shell.c.

ULONG CurrentDR6

Definition at line 117 of file shell.c.

ULONG CurrentDR7

Definition at line 117 of file shell.c.

USHORT CurrentDS =0

Definition at line 116 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), DisplayRegs(), InitPICE(), and SaveOldRegs().

ULONG CurrentEAX

Definition at line 114 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentEBX

Definition at line 114 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentECX

Definition at line 114 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentEDI

Definition at line 115 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentEDX

Definition at line 114 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentEFL

Definition at line 113 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), DisplayRegs(), RealIsr(), and SaveOldRegs().

USHORT CurrentES

Definition at line 116 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentESI

Definition at line 115 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG CurrentESP

Definition at line 115 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), DisplayRegs(), PrintkCallback(), RealIsr(), and SaveOldRegs().

USHORT CurrentFS

Definition at line 116 of file shell.c.

Referenced by DisplayRegs(), RealIsr(), and SaveOldRegs().

USHORT CurrentGS

Definition at line 116 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

USHORT CurrentSS

Definition at line 116 of file shell.c.

Referenced by DisplayRegs(), InitPICE(), PrintkCallback(), and SaveOldRegs().

ULONG dwCallOldGPFaultHandler = 0

Definition at line 60 of file shell.c.

Referenced by RealIsr().

ULONG dwCallOldInt1Handler = 0

Definition at line 57 of file shell.c.

Referenced by RealIsr().

ULONG dwCallOldInt3Handler = 0

Definition at line 58 of file shell.c.

Referenced by RealIsr().

ULONG dwCallOldIntEHandler = 0

Definition at line 59 of file shell.c.

Referenced by RealIsr().

ULONG g_ulLineNumberStart =0

Definition at line 62 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), and RealIsr().

ULONG KeyboardIRQL

Definition at line 50 of file init.c.

Referenced by DeInstallGlobalKeyboardHook(), InitPICE(), and InstallGlobalKeyboardHook().

ULONG OLD_PCR
static

Definition at line 84 of file shell.c.

Referenced by RealIsr().

USHORT OldCS =0

Definition at line 123 of file shell.c.

Referenced by DisplayRegs(), RealIsr(), and SaveOldRegs().

USHORT OldDS

Definition at line 123 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEAX

Definition at line 121 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEBP

Definition at line 122 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEBX

Definition at line 121 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldECX

Definition at line 121 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEDI

Definition at line 122 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEDX

Definition at line 121 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEFL

Definition at line 120 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldEIP =0

Definition at line 120 of file shell.c.

Referenced by DisplayRegs(), RealIsr(), and SaveOldRegs().

USHORT OldES

Definition at line 123 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldESI

Definition at line 122 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG OldESP

Definition at line 122 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

USHORT OldFS

Definition at line 123 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

volatile ULONG OldGlobalInt31Handler

Definition at line 74 of file shell.c.

Referenced by DeInstallGlobalKeyboardHook(), and InstallGlobalKeyboardHook().

USHORT OldGS

Definition at line 123 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

volatile ULONG OldInt31Handler

Definition at line 73 of file shell.c.

ULONG OldOffset =0
USHORT OldSelector =0

Definition at line 89 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), DebuggerShell(), and RepaintDesktop().

USHORT OldSS

Definition at line 123 of file shell.c.

Referenced by DisplayRegs(), and SaveOldRegs().

ULONG PCR_SEL = PCR_SELECTOR
static

Definition at line 83 of file shell.c.

char* szFunctionKeys[10]
Initial value:
={
"mod",
"proc",
"src",
"code",
"x",
"vma",
"",
"t",
"",
"p"
}

Definition at line 95 of file shell.c.

Referenced by DebuggerShell().

char tempShell[256]

Definition at line 86 of file shell.c.

Referenced by DebuggerShell(), RealIsr(), and ShowStatusLine().

UCHAR ucCommandBuffer[256]

Definition at line 127 of file shell.c.

Referenced by DebuggerShell(), and ProcessBootParams().

UCHAR ucConverted

Definition at line 68 of file shell.c.

Referenced by DebuggerShell().

volatile UCHAR ucKeyPressedWhileIdle =0

Definition at line 78 of file shell.c.

Referenced by DebuggerShell(), and WaitForKey().

ULONG ulCommandCurrentPos =0

Definition at line 134 of file shell.c.

Referenced by AddToCommandLineHistory(), and DebuggerShell().

ULONG ulCommandInPos =0

Definition at line 133 of file shell.c.

Referenced by AddToCommandLineHistory(), and GetLinesInCommandHistory().

ULONG ulCommandLastPos =0

Definition at line 133 of file shell.c.

Referenced by AddToCommandLineHistory(), and GetLinesInCommandHistory().

ULONG ulLastLineDisplayedOffset = 0

Definition at line 92 of file shell.c.

Referenced by DebuggerShell().

ULONG ulOldStack

Definition at line 110 of file shell.c.

Referenced by DebuggerShell().

ULONG ulRealStackPtr

Definition at line 82 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), and HandleInDebuggerFault().

ULONG ulWindowOffset = 0

Definition at line 63 of file shell.c.

Referenced by COMMAND_PROTOTYPE(), and DebuggerShell().

USHORT usCurrentPosInInputBuffer =0

Definition at line 128 of file shell.c.

Referenced by DebuggerShell().