ReactOS  r76032
parse.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1998-2001 Klaus P. Gerlicher
4 
5 Module Name:
6 
7  parse.c
8 
9 Abstract:
10 
11  execution of debugger commands
12 
13 Environment:
14 
15  Kernel mode only
16 
17 Author:
18 
19  Klaus P. Gerlicher
20 
21 Revision History:
22 
23  19-Aug-1998: created
24  15-Nov-2000: general cleanup of source files
25 
26 Copyright notice:
27 
28  This file may be distributed under the terms of the GNU Public License.
29 
30 --*/
31 
33 // INCLUDES
35 #include "remods.h"
36 #include "precomp.h"
37 #include "pci_ids.h"
38 
40 // GLOBALS
41 
50 
53 
54 //extern unsigned long sys_call_table[];
55 
56 BOOLEAN (*DisplayMemory)(PARGS) = DisplayMemoryDword;
57 
58 char szCurrentFile[256]="";
61 
62 // suppresses passing on of function keys while stepping code
66 
68  {"eax",&CurrentEAX,sizeof(ULONG)},
69  {"ebx",&CurrentEBX,sizeof(ULONG)},
70  {"ecx",&CurrentECX,sizeof(ULONG)},
71  {"edx",&CurrentEDX,sizeof(ULONG)},
72  {"edi",&CurrentEDI,sizeof(ULONG)},
73  {"esi",&CurrentESI,sizeof(ULONG)},
74  {"ebp",&CurrentEBP,sizeof(ULONG)},
75  {"esp",&CurrentESP,sizeof(ULONG)},
76  {"eip",&CurrentEIP,sizeof(ULONG)},
77  {NULL,0,0}
78 };
79 
81  {"cs",&CurrentCS,sizeof(USHORT)},
82  {"ds",&CurrentDS,sizeof(USHORT)},
83  {"es",&CurrentES,sizeof(USHORT)},
84  {"fs",&CurrentFS,sizeof(USHORT)},
85  {"gs",&CurrentGS,sizeof(USHORT)},
86  {"ss",&CurrentSS,sizeof(USHORT)},
87  {NULL,0,0}
88 };
89 
91  {"on",&ValueTrue,sizeof(ULONG)},
92  {"off",&ValueFalse,sizeof(ULONG)},
93  {NULL,0,0}
94 };
95 
97  {"process",&CurrentProcess,sizeof(ULONG)},
98  {NULL,0,0}
99 };
100 
102 {
103  "EAX",
104  "ECX",
105  "EDX",
106  "EBX",
107  "ESP",
108  "EBP",
109  "ESI",
110  "EDI",
111  "EIP",
112  "EFL",
113  "CS",
114  "SS",
115  "DS",
116  "ES",
117  "FS",
118  "GS"
119 };
120 
121 
122 #define COMMAND_HAS_NO_PARAMS (0)
123 #define COMMAND_HAS_PARAMS (1<<0)
124 #define COMMAND_HAS_SWITCHES (1<<1)
125 //
126 #define PARAM_CAN_BE_SYMBOLIC (1<<0)
127 #define PARAM_CAN_BE_SEG_OFFSET (1<<1)
128 #define PARAM_CAN_BE_MODULE (1<<2)
129 #define PARAM_CAN_BE_PRNAME (1<<3)
130 #define PARAM_CAN_BE_PID (1<<4)
131 #define PARAM_CAN_BE_SRC_FILE (1<<5)
132 #define PARAM_CAN_BE_NUMERIC (1<<6)
133 #define PARAM_CAN_BE_REG_KEYWORD (1<<7)
134 #define PARAM_CAN_BE_ONOFF_KEYWORD (1<<8)
135 #define PARAM_CAN_BE_SPECIAL_KEYWORD (1<<9)
136 #define PARAM_CAN_BE_ASTERISK (1<<10)
137 #define PARAM_CAN_BE_ONOFF (1<<11)
138 #define PARAM_CAN_BE_VIRTUAL_SYMBOLIC (1<<12)
139 #define PARAM_CAN_BE_SRCLINE (1<<13)
140 #define PARAM_CAN_BE_PARTIAL_SYM_NAME (1<<14)
141 #define PARAM_CAN_BE_ANY_STRING (1<<15)
142 #define PARAM_CAN_BE_DECIMAL (1<<16)
143 #define PARAM_CAN_BE_SIZE_DESC (1<<17)
144 #define PARAM_CAN_BE_LETTER (1<<18)
145 //
146 #define COMMAND_GROUP_HELP (0)
147 #define COMMAND_GROUP_FLOW (1)
148 #define COMMAND_GROUP_STRUCT (2)
149 #define COMMAND_GROUP_OS (3)
150 #define COMMAND_GROUP_MEM (4)
151 #define COMMAND_GROUP_BREAKPOINT (5)
152 #define COMMAND_GROUP_WINDOW (6)
153 #define COMMAND_GROUP_DEBUG (7)
154 #define COMMAND_GROUP_INFO (8)
155 #define COMMAND_GROUP_STATE (9)
156 #define COMMAND_GROUP_HELP_ONLY (10)
157 #define COMMAND_GROUP_LAST (11)
158 
160 {
161  "HELP",
162  "FLOW CONTROL",
163  "STRUCTURES",
164  "OS SPECIFIC",
165  "MEMORY",
166  "BREAKPOINTS",
167  "WINDOW",
168  "DEBUGGING",
169  "INFORMATION",
170  "STATE",
171  "EDITOR",
172  NULL
173 };
174 // table of command handlers
176  {"gdt",ShowGdt,"display current global descriptor table" ,0,{0,0,0,0,0},"",COMMAND_GROUP_STRUCT},
177  {"idt",ShowIdt,"display current interrupt descriptor table" ,0,{0,0,0,0,0},"",COMMAND_GROUP_STRUCT},
178  {"x",LeaveIce,"return to ReactOS" ,0,{0,0,0,0,0},"",COMMAND_GROUP_FLOW},
179  {"t",SingleStep,"single step one instruction" ,0,{0,0,0,0,0},"",COMMAND_GROUP_FLOW},
180  {"vma",ShowVirtualMemory,"displays VMAs" ,0,{0,0,0,0,0},"",COMMAND_GROUP_OS},
181  {"h",ShowHelp,"list help on commands" ,0,{0,0,0,0,0},"",COMMAND_GROUP_HELP},
182  {"page",ShowPageDirs,"dump page directories" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC|PARAM_CAN_BE_REG_KEYWORD,0,0,0,0},"",COMMAND_GROUP_STRUCT},
183  {"proc",ShowProcesses,"list all processes" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_PRNAME|PARAM_CAN_BE_PID,0,0,0,0},"",COMMAND_GROUP_OS},
184  {"dd",DisplayMemoryDword,"display dword memory" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC|PARAM_CAN_BE_SYMBOLIC|PARAM_CAN_BE_REG_KEYWORD,0,0,0,0},"",COMMAND_GROUP_MEM},
185  {"db",DisplayMemoryByte,"display byte memory " ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC|PARAM_CAN_BE_SYMBOLIC|PARAM_CAN_BE_REG_KEYWORD,0,0,0,0},"",COMMAND_GROUP_MEM},
186  {"dpd",DisplayPhysMemDword,"display dword physical memory" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC,0,0,0,0},"",COMMAND_GROUP_MEM},
188  {"mod",ShowModules,"displays all modules" ,0,{0,0,0,0,0},"",COMMAND_GROUP_OS},
190  {"bl",ListBreakpoints,"list breakpoints" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC,0,0,0,0},"",COMMAND_GROUP_BREAKPOINT},
191  {"bc",ClearBreakpoints,"clear breakpoints" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC|PARAM_CAN_BE_ASTERISK,0,0,0,0},"",COMMAND_GROUP_BREAKPOINT},
192  {"ver",Ver,"display pICE version and state information" ,0,{0,0,0,0,0},"",COMMAND_GROUP_INFO},
193  {"hboot",Hboot,"hard boot the system" ,0,{0,0,0,0,0},"",COMMAND_GROUP_FLOW},
194  {"code",SetCodeDisplay,"toggle code display" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_ONOFF,0,0,0,0},"",COMMAND_GROUP_STATE},
195  {"cpu",ShowCPU,"display CPU special registers" ,0,{0,0,0,0,0},"",COMMAND_GROUP_STRUCT},
196  {"stack",WalkStack,"display call stack" ,0,{0,0,0,0,0},"",COMMAND_GROUP_STRUCT},
197  {"peek",PeekMemory,"peek at physical memory" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_SIZE_DESC,PARAM_CAN_BE_NUMERIC,0,0,0},"",COMMAND_GROUP_MEM},
198  {"poke",PokeMemory,"poke to physical memory" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_SIZE_DESC,PARAM_CAN_BE_NUMERIC,PARAM_CAN_BE_NUMERIC,0,0},"",COMMAND_GROUP_MEM},
199  {".",UnassembleAtCurrentEip,"unassemble at current instruction" ,0,{0,0,0,0,0},"",COMMAND_GROUP_MEM},
200  {"p",StepOver,"single step over call" ,0,{0,0,0,0,0},"",COMMAND_GROUP_FLOW},
201  {"i",StepInto,"single step into call" ,0,{0,0,0,0,0},"",COMMAND_GROUP_FLOW},
202  {"locals",ShowLocals,"display local symbols" ,0,{0,0,0,0,0},"",COMMAND_GROUP_MEM},
203  {"table",SwitchTables,"display loaded symbol tables" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_MODULE,0,0,0,0},"",COMMAND_GROUP_DEBUG},
204  {"file",SwitchFiles,"display source files in symbol table" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_SRC_FILE,0,0,0,0},"",COMMAND_GROUP_DEBUG},
205  {"sym",ShowSymbols,"list known symbol information" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_PARTIAL_SYM_NAME,0,0,0,0},"",COMMAND_GROUP_DEBUG},
206  {"?",EvaluateExpression,"evaluate an expression" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_ANY_STRING,0,0,0,0},"",COMMAND_GROUP_DEBUG},
207  {"src",SetSrcDisplay,"sets disassembly mode" ,0,{0,0,0,0,0},"",COMMAND_GROUP_DEBUG},
208  {"wc",SizeCodeWindow,"change size of code window" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_DECIMAL,0,0,0,0},"",COMMAND_GROUP_WINDOW},
209  {"wd",SizeDataWindow,"change size of data window" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_DECIMAL,0,0,0,0},"",COMMAND_GROUP_WINDOW},
210  {"r",SetGetRegisters,"sets or displays registers" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_REG_KEYWORD,PARAM_CAN_BE_NUMERIC,0,0,0},"",COMMAND_GROUP_STRUCT},
211  {"cls",ClearScreen,"clear output window" ,0,{0,0,0,0,0},"",COMMAND_GROUP_WINDOW},
212  {"phys",ShowMappings,"show all mappings for linear address" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_NUMERIC,0,0,0,0},"",COMMAND_GROUP_MEM},
213  {"timers",ShowTimers,"show all active timers" ,0,{0,0,0,0,0},"",COMMAND_GROUP_OS},
215  {"next",NextInstr,"advance EIP to next instruction" ,0,{0,0,0,0,0},""},
216  {"i3here",I3here,"catch INT 3s" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_ONOFF,0,0,0,0},"",COMMAND_GROUP_FLOW},
217  {"layout",SetKeyboardLayout,"sets keyboard layout" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_ANY_STRING,0,0,0,0},"",COMMAND_GROUP_FLOW},
218  {"syscall",ShowSysCallTable,"displays syscall (table)" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_DECIMAL,0,0,0,0},"",COMMAND_GROUP_FLOW},
219  {"altkey",SetAltKey,"set alternate break key" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_LETTER,0,0,0,0},"",COMMAND_GROUP_FLOW},
220  {"addr",ShowContext,"show/set address contexts" ,COMMAND_HAS_PARAMS,{PARAM_CAN_BE_PRNAME,0,0,0,0},"",COMMAND_GROUP_FLOW},
221  {"arrow up",NULL,"" ,0,{0,0,0,0,0},"",COMMAND_GROUP_HELP_ONLY},
222  {NULL,0,NULL}
223 };
224 
225 char tempCmd[1024];
226 
227 char HexDigit[] = { '0', '1', '2', '3', '4', '5', '6', '7',
228  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
229 
230 
232  {"DR0",&CurrentDR0},
233  {"DR1",&CurrentDR1},
234  {"DR2",&CurrentDR2},
235  {"DR3",&CurrentDR3},
236  {"DR6",&CurrentDR6},
237  {"DR7",&CurrentDR7},
238  {"EFLAGS",&CurrentEFL},
239  {"CR0",&CurrentCR0},
240  {"CR2",&CurrentCR2},
241  {"CR3",&CurrentCR3},
242  {"",NULL},
243 };
244 
245 BP Bp[4]={
246  {0,0,0,FALSE,FALSE,FALSE,"",""},
247  {0,0,0,FALSE,FALSE,FALSE,"",""},
248  {0,0,0,FALSE,FALSE,FALSE,"",""},
249  {0,0,0,FALSE,FALSE,FALSE,"",""}
250 };
251 
255 
257 {
258  "Data RO",
259  "Data RO accessed",
260  "Data RW",
261  "Data RW accessed",
262  "Data RO expand-dwon",
263  "Data RO expand-down, accessed",
264  "Data RW expand-dwon",
265  "Data RW expand-down, accessed",
266  "Code EO",
267  "Code EO accessed",
268  "Code ER",
269  "Code ER accessed",
270  "Code EO conforming",
271  "Code EO conforming, accessed",
272  "Code ER conforming",
273  "Code ER conforming, accessed"
274 };
275 
277 {
278  "reserved0",
279  "16-bit TSS (available)",
280  "LDT",
281  "16-bit TSS (busy)",
282  "16-bit call gate",
283  "task gate",
284  "16-bit interrupt gate",
285  "16-bit trap gate",
286  "reserved1",
287  "32-bit TSS (available)",
288  "reserved2",
289  "32-bit TSS (busy)",
290  "32-bit call gate",
291  "reserved3",
292  "32-bit interrupt gate",
293  "32-bit trap gate"
294 };
295 
297 // FUNCTIONS
299 
300 //*************************************************************************
301 // RepaintSource()
302 //
303 //*************************************************************************
304 void RepaintSource(void)
305 {
306  ARGS Args;
307 
308  ENTER_FUNC();
309 
310  // disassembly from current address
311  PICE_memset(&Args,0,sizeof(ARGS));
312  // make unassembler refresh all again
314  Args.Count=0;
315  Unassemble(&Args);
316 
317  LEAVE_FUNC();
318 }
319 
320 //*************************************************************************
321 // RepaintDesktop()
322 //
323 //*************************************************************************
324 void RepaintDesktop(void)
325 {
326  ARGS Args;
327 
328  ENTER_FUNC();
329 
330  PrintTemplate();
331 
332  DisplayRegs();
333 
334  // display data window
335  Args.Value[0]=OldSelector;
336  Args.Value[1]=OldOffset;
337  Args.Count=2;
338  DisplayMemory(&Args);
339 
340  // disassembly from current address
341  PICE_memset(&Args,0,sizeof(ARGS));
342  // make unassembler refresh all again
344  Args.Count=0;
345  Unassemble(&Args);
346 
348  Print(OUTPUT_WINDOW,"");
349 
350  ShowStoppedMsg();
351  ShowStatusLine();
352 
353  LEAVE_FUNC();
354 }
355 
356 //*************************************************************************
357 // PutStatusText()
358 //
359 //*************************************************************************
361 {
362  ENTER_FUNC();
363 
365  PutChar(p,1,wWindow[OUTPUT_WINDOW].y-1);
366 
367  LEAVE_FUNC();
368 }
369 
370 //*************************************************************************
371 // WaitForKey()
372 //
373 //*************************************************************************
375 {
377 
378  if(ulCountForWaitKey == 0)
380 
382 
384  {
386 
388 
389  ulCountForWaitKey = 0;
390 
393  PutChar(" Press any key to continue listing or press ESC to stop... ",1,wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].cy);
396  {
398  }
400  // if ESCAPE then indicate retreat
402  {
403  result=FALSE;
404  }
406  }
407 
408 
409  return result;
410 }
411 
413 // command handlers
415 
416 //*************************************************************************
417 // SingleStep()
418 //
419 //*************************************************************************
420 COMMAND_PROTOTYPE(SingleStep)
421 {
422  ULONG ulLineNumber;
423  LPSTR pSrcStart,pSrcEnd,pFilename;
424 
425  ENTER_FUNC();
426 
427  if(FindSourceLineForAddress(GetLinearAddress(CurrentCS,CurrentEIP),&ulLineNumber,&pSrcStart,&pSrcEnd,&pFilename))
428  {
429  DPRINT((0,"SingleStep(): stepping into source\n"));
430  StepInto(NULL);
431  }
432  else
433  {
434  // modify trace flag
435  CurrentEFL|=0x100; // set trace flag (TF)
436 
439  }
440 
441  bStepping = TRUE;
442 
443  LEAVE_FUNC();
444 
445  return TRUE;
446 }
447 
448 
449 //*************************************************************************
450 // StepOver()
451 //
452 // step over calls
453 //*************************************************************************
455 {
456  char tempDisasm[256];
457  ULONG dwBreakAddress;
458  ULONG ulLineNumber;
459  LPSTR pSrcStart,pSrcEnd,pFilename;
460 
461  ENTER_FUNC();
462 
463  DPRINT((0,"StepOver():\n"));
464 
465  // only no arguments supplied
466  // when we have source and current disassembly mod is SOURCE
467  // we have to analyse the code block for the source line
468  if(FindSourceLineForAddress(GetLinearAddress(CurrentCS,CurrentEIP),&ulLineNumber,&pSrcStart,&pSrcEnd,&pFilename))
469  {
470  DPRINT((0,"StepOver(): we have source here!\n"));
471  DPRINT((0,"StepOver(): line #%u in file = %s!\n",ulLineNumber,pFilename));
472 
473  g_ulLineNumberStart = ulLineNumber;
475 
476  // deinstall the INT3 in kernel's printk()
478 
479  goto proceed_as_normal;
480  }
481  else
482  {
483  DPRINT((0,"StepOver(): no source here!\n"));
484 
485 proceed_as_normal:
486  // if there is some form of call instruction at EIP we need to find
487  // the return address
488  if(IsCallInstrAtEIP())
489  {
490  // get address of next instruction
491  dwBreakAddress=GetLinearAddress(CurrentCS,CurrentEIP);
492 
493  Disasm(&dwBreakAddress,tempDisasm);
494 
495  DPRINT((0,"address of break = %.4X:%.8X\n",CurrentCS,dwBreakAddress));
496 
497  dwBreakAddress=GetLinearAddress(CurrentCS,dwBreakAddress);
498 
499  DPRINT((0,"linear address of break = %.8X\n",dwBreakAddress));
500 
501  DPRINT((0,"setting DR0=%.8X\n",dwBreakAddress));
502 
503  SetHardwareBreakPoint(dwBreakAddress,0);
504 
505  bSingleStep = FALSE;
507  }
508  else
509  {
510  DPRINT((0,"no call at breakpoint\n"));
511  // modify trace flag
512  CurrentEFL|=0x100; // set trace flag (TF)
513 
516  }
517  }
518 
519  bStepInto = FALSE;
520 
521  bStepping = TRUE;
522 
523  LEAVE_FUNC();
524 
525  return TRUE;
526 }
527 
528 //*************************************************************************
529 // StepInto()
530 //
531 // step into calls
532 //*************************************************************************
534 {
535  ULONG ulLineNumber;
536  LPSTR pSrcStart,pSrcEnd,pFilename;
537 
538  ENTER_FUNC();
539 
540  // only no arguments supplied
541  // when we have source and current disassembly mod is SOURCE
542  // we have to analyse the code block for the source line
543  if(FindSourceLineForAddress(GetLinearAddress(CurrentCS,CurrentEIP),&ulLineNumber,&pSrcStart,&pSrcEnd,&pFilename))
544  {
545  DPRINT((0,"StepOver(): we have source here!\n"));
546  DPRINT((0,"StepOver(): line #%u in file = %s!\n",ulLineNumber,pFilename));
547 
548  g_ulLineNumberStart = ulLineNumber;
550 
551  // deinstall the INT3 in kernel's printk()
553 
554  goto proceed_as_normal_into;
555  }
556  else
557  {
558  DPRINT((0,"StepInto(): no source here!\n"));
559 
560 proceed_as_normal_into:
561 
562  // modify trace flag
563  CurrentEFL|=0x100; // set trace flag (TF)
564 
567  }
568 
569  bStepInto = TRUE;
570 
571  bStepping = TRUE;
572 
573  LEAVE_FUNC();
574 
575  return TRUE;
576 }
577 
578 //*************************************************************************
579 // SetBreakpoint()
580 //
581 //*************************************************************************
582 COMMAND_PROTOTYPE(SetBreakpoint)
583 {
584  ULONG addr,addrorg;
585  USHORT segment;
586 
587  if(pArgs->Count<=2)
588  {
589  if(pArgs->bNotTranslated[0]==FALSE)
590  {
591  if(gCurrentSelector)
592  {
593  addr=pArgs->Value[0];
594  addrorg=gCurrentOffset;
595  segment=gCurrentSelector;
596  }
597  else
598  {
599  addrorg=addr=pArgs->Value[0];
600  segment=CurrentCS;
601  }
602 
603  if(InstallSWBreakpoint(GetLinearAddress(segment,addr),FALSE,NULL) )
604  {
605  PICE_sprintf(tempCmd,"BP #%u set to %.4X:%.8X\n",0,segment,addr);
606  }
607  else
608  {
609  PICE_sprintf(tempCmd,"BP #%u NOT set (either page not valid OR already used)\n",0);
610  }
611  Print(OUTPUT_WINDOW,tempCmd);
612  }
613  else
614  {
615  if(InstallVirtualSWBreakpoint((LPSTR)pArgs->Value[0],(LPSTR)pArgs->Value[1]) )
616  {
617  PICE_sprintf(tempCmd,"BP #%u virtually set to %s!%s\n",0,(LPSTR)pArgs->Value[0],(LPSTR)pArgs->Value[1]);
618  }
619  else
620  {
621  PICE_sprintf(tempCmd,"BP #%u NOT set (maybe no symbols loaded)\n",0);
622  }
623  Print(OUTPUT_WINDOW,tempCmd);
624  }
625 
626  RepaintSource();
627 
628  }
629  return TRUE;
630 }
631 
632 //*************************************************************************
633 // ListBreakpoints()
634 //
635 //*************************************************************************
636 COMMAND_PROTOTYPE(ListBreakpoints)
637 {
638  ULONG i;
639 
641 
642  for(i=0;i<4;i++)
643  {
644  if(Bp[i].Used)
645  {
646  PICE_sprintf(tempCmd,"(%u) %s %.4X:%.8X(linear %.8X)\n",i,Bp[i].Active?"*":" ",Bp[i].Segment,Bp[i].Offset,Bp[i].LinearAddress);
647  Print(OUTPUT_WINDOW,tempCmd);
648  }
649  }
650  return TRUE;
651 }
652 
653 //*************************************************************************
654 // ClearBreakpoints()
655 //
656 //*************************************************************************
657 COMMAND_PROTOTYPE(ClearBreakpoints)
658 {
659  if(pArgs->Count)
660  {
661  if(pArgs->Value[0]<4)
662  {
663  Bp[pArgs->Value[0]].Used=Bp[pArgs->Value[0]].Active=FALSE;
664  }
665  RepaintSource();
666  }
667  else
668  {
669  ULONG i;
670 
672 
673  for(i=0;i<4;i++)Bp[i].Used=Bp[i].Active=FALSE;
674  RepaintSource();
675  }
676  return TRUE;
677 }
678 
679 //*************************************************************************
680 // LeaveIce()
681 //
682 //*************************************************************************
684 {
685  // SetHardwareBreakPoints();
686 
689  return TRUE;
690 }
691 
692 //*************************************************************************
693 // ShowGdt()
694 //
695 //*************************************************************************
697 {
698  ULONG gdtr[2];
699  USHORT i;
700  PGDT pGdt;
701  static ULONG addr=0;
702  LPSTR pVerbose;
703 
704  // get GDT register
705  __asm__ ("sgdt %0\n"
706  :"=m" (gdtr));
707 
708  // info out
709  PICE_sprintf(tempCmd,"Address=%.8X Limit=%.4X\n",(gdtr[1]<<16)|(gdtr[0]>>16),gdtr[0]&0xFFFF);
710  Print(OUTPUT_WINDOW,tempCmd);
711  WaitForKey();
712 
713  // make pointer to GDT
714  pGdt=(PGDT)(((ULONG)(gdtr[1]<<16))|((ULONG)(gdtr[0]>>16)));
715  if(pArgs->Count==1)
716  {
717  ULONG limit=((pGdt[addr].Limit_19_16<<16)|pGdt[addr].Limit_15_0);
718 
719  addr=pArgs->Value[0];
720  addr&=(~0x7);
721  if(pGdt[addr>>3].Gran)limit=(limit*4096)|0xfff;
722 
723  if(!pGdt[addr>>3].DescType)
724  pVerbose = SystemSegmentTypes[pGdt[addr>>3].SegType];
725  else
726  pVerbose = NonSystemSegmentTypes[pGdt[addr>>3].SegType];
727 
728  PICE_sprintf(tempCmd,"%.4X %.8X %.8X %s %u %s\n",
729  addr,
730  (pGdt[addr>>3].Base_31_24<<24)|(pGdt[addr>>3].Base_23_16<<16)|(pGdt[addr>>3].Base_15_0),
731  limit,
732  pGdt[addr>>3].Present?" P":"NP",
733  pGdt[addr>>3].Dpl,
734  pVerbose);
735  Print(OUTPUT_WINDOW,tempCmd);
736  }
737  else if(pArgs->Count==0)
738  {
739  for(i=0;i<((gdtr[0]&0xFFFF)>>3);i++)
740  {
741  ULONG limit=((pGdt[i].Limit_19_16<<16)|pGdt[i].Limit_15_0);
742 
743  if(!pGdt[i].DescType)
744  pVerbose = SystemSegmentTypes[pGdt[i].SegType];
745  else
746  pVerbose = NonSystemSegmentTypes[pGdt[i].SegType];
747 
748  if(pGdt[i].Gran)limit=(limit*4096)|0xfff;
749 
750  PICE_sprintf(tempCmd,"%.4X %.8X %.8X %s %u %s\n",
751  i<<3,
752  (pGdt[i].Base_31_24<<24)|(pGdt[i].Base_23_16<<16)|(pGdt[i].Base_15_0),
753  limit,
754  pGdt[i].Present?" P":"NP",
755  pGdt[i].Dpl,
756  pVerbose);
757  Print(OUTPUT_WINDOW,tempCmd);
758  if(WaitForKey()==FALSE)break;
759  }
760  }
761  return TRUE;
762 }
763 
764 //*************************************************************************
765 // OutputIdtEntry()
766 //
767 //*************************************************************************
769 {
770  USHORT seg;
771  ULONG offset;
772  LPSTR pSym;
773 
774  seg = (USHORT)pIdt[i].Selector;
775  offset = (pIdt[i].Offset_31_16<<16)|(pIdt[i].Offset_15_0);
776 
777  switch(pIdt[i].DescType)
778  {
779  // task gate
780  case 0x5:
781  PICE_sprintf(tempCmd,"(%0.4X) %0.4X:%0.8X %u [task]\n",i,
782  seg,
783  GetLinearAddress((USHORT)seg,0),
784  pIdt[i].Dpl);
785  break;
786  // interrupt gate
787  case 0x6:
788  case 0xE:
789  if(ScanExportsByAddress(&pSym,GetLinearAddress((USHORT)seg,offset)))
790  {
791  PICE_sprintf(tempCmd,"(%0.4X) %0.4X:%0.8X %u [int] (%s)\n",i,
792  seg,
793  offset,
794  pIdt[i].Dpl,
795  pSym);
796  }
797  else
798  {
799  PICE_sprintf(tempCmd,"(%0.4X) %0.4X:%0.8X %u [int]\n",i,
800  seg,
801  offset,
802  pIdt[i].Dpl);
803  }
804  break;
805  // trap gate
806  case 0x7:
807  case 0xF:
808  if(ScanExportsByAddress(&pSym,GetLinearAddress((USHORT)seg,offset)))
809  {
810  PICE_sprintf(tempCmd,"(%0.4X) %0.4X:%0.8X %u [trap] (%s)\n",i,
811  seg,
812  offset,
813  pIdt[i].Dpl,
814  pSym);
815  }
816  else
817  {
818  PICE_sprintf(tempCmd,"(%0.4X) %0.4X:%0.8X %u [trap]\n",i,
819  seg,
820  offset,
821  pIdt[i].Dpl);
822  }
823  break;
824  default:
825  PICE_sprintf(tempCmd,"(%0.4X) INVALID\n",i);
826  break;
827  }
828  Print(OUTPUT_WINDOW,tempCmd);
829 }
830 
831 //*************************************************************************
832 // ShowIdt()
833 //
834 //*************************************************************************
836 {
837  ULONG idtr[2];
838  USHORT i;
839  PIDT pIdt;
840  ULONG addr=0;
841 
842  ENTER_FUNC();
843 
844  // get GDT register
845  __asm__ ("sidt %0\n"
846  :"=m" (idtr));
847  // info out
848  PICE_sprintf(tempCmd,"Address=%.8X Limit=%.4X\n",(idtr[1]<<16)|(idtr[0]>>16),idtr[0]&0xFFFF);
849  Print(OUTPUT_WINDOW,tempCmd);
850  WaitForKey();
851  // make pointer to GDT
852  pIdt=(PIDT)(((ULONG)(idtr[1]<<16))|((ULONG)(idtr[0]>>16)));
853  if(pArgs->Count==1)
854  {
855  addr=pArgs->Value[0];
856  addr&=(~0x7);
857 
858  }
859  else if(pArgs->Count==0)
860  {
861  for(i=0;i<((idtr[0]&0xFFFF)>>3);i++)
862  {
863  OutputIdtEntry(pIdt,i);
864  if(WaitForKey()==FALSE)break;
865  }
866  }
867  LEAVE_FUNC();
868  return TRUE;
869 }
870 
871 //*************************************************************************
872 // ShowHelp()
873 //
874 //*************************************************************************
876 {
877  ULONG i,j;
878 
879  PutStatusText("COMMAND KEYWORD DESCRIPTION");
880  for(j=0;j<COMMAND_GROUP_LAST;j++)
881  {
882  PICE_sprintf(tempCmd,"= %-20s =====================================\n",CommandGroups[j]);
883  Print(OUTPUT_WINDOW,tempCmd);
884  WaitForKey();
885 
886  for(i=0;CmdTable[i].Cmd!=NULL;i++)
887  {
888  if(CmdTable[i].CommandGroup == j)
889  {
890  PICE_sprintf(tempCmd,"%-20s %s\n",CmdTable[i].Cmd,CmdTable[i].Help);
891  Print(OUTPUT_WINDOW,tempCmd);
892  if(WaitForKey()==FALSE)return TRUE;
893  }
894  }
895  }
896  return TRUE;
897 }
898 
899 //*************************************************************************
900 // ShowPageDirs()
901 //
902 //*************************************************************************
903 COMMAND_PROTOTYPE(ShowPageDirs)
904 {
905  ULONG i;
906  PPAGEDIR pPageDir;
907  PULONG pPGD;
908  PULONG pPTE;
909  PEPROCESS my_current = IoGetCurrentProcess();
910 
911  ENTER_FUNC();
912 
913  DPRINT((0,"ShowPageDirs(): my_current = %.8X\n",(ULONG)my_current));
914 
915  // don't touch if not valid process
916  if(my_current)
917  {
918  // no arguments supplied -> show all page directories
919  if(!pArgs->Count)
920  {
921  PutStatusText("Linear Physical Attributes");
922  // there are 1024 page directories each mapping 1024*4k of address space
923  for(i=0;i<1024;i++)
924  {
925  ULONG ulAddress = i<<22;
926  // from the mm_struct get pointer to page directory for this address
927  pPGD = ADDR_TO_PDE(ulAddress);
928  // create a structurized pointer from PGD
929  pPageDir = (PPAGEDIR)pPGD;
930 
931  if(pPageDir->PTBase)
932  {
933 
934  PICE_sprintf(tempCmd,"%.8X-%.8X %.8X %s %s %s\n",
935  ulAddress, ulAddress + 0x400000,
936  (pPageDir->PTBase<<12),
937  pPageDir->P?"P ":"NP",
938  pPageDir->RW?"RW":"R ",
939  pPageDir->US?"U":"S");
940  Print(OUTPUT_WINDOW,tempCmd);
941 
942  if(WaitForKey()==FALSE)break;
943  }
944  }
945  }
946 
947  // one arg supplied -> show individual page
948  else if(pArgs->Count == 1)
949  {
950  pPGD = ADDR_TO_PDE((ULONG)pArgs->Value[0]);
951 
952  DPRINT((0,"ShowPageDirs(): VA = %.8X\n",pArgs->Value[0]));
953  DPRINT((0,"ShowPageDirs(): pPGD = %.8X\n",(ULONG)pPGD));
954 
955  if(pPGD && ((*pPGD)&_PAGE_PRESENT))
956  {
957  // 4M page
958  if((*pPGD)&_PAGE_4M)
959  {
960  PPAGEDIR pPage = (PPAGEDIR)pPGD;
961 
962  PutStatusText("Linear Physical Attributes");
963 
964  PICE_sprintf(tempCmd,"%.8X %.8X %s %s %s (LARGE PAGE PTE @ %.8X)\n",
965  pArgs->Value[0],
966  (pPage->PTBase<<12)|(pArgs->Value[0]&0x7FFFFF),
967  pPage->P?"P ":"NP",
968  pPage->RW?"RW":"R ",
969  pPage->US?"U":"S",
970  (ULONG)pPGD);
971  }
972  else
973  {
974  pPTE = ADDR_TO_PTE(pArgs->Value[0]);
975  DPRINT((0,"ShowPageDirs(): pPTE = %.8X\n",(ULONG)pPTE));
976  if(pPTE)
977  {
978  PPAGEDIR pPage = (PPAGEDIR)pPTE;
979  DPRINT((0,"ShowPageDirs(): pPage->PTBase = %.8X\n",(ULONG)pPage->PTBase));
980 
981  PutStatusText("Linear Physical Attributes");
982 
983  PICE_sprintf(tempCmd,"%.8X %.8X %s %s %s (PTE @ %.8X)\n",
984  pArgs->Value[0],
985  (pPage->PTBase<<12)|(pArgs->Value[0]&(_PAGE_SIZE-1)),
986  (pPage->P==1)?"P ":"NP",
987  pPage->RW?"RW":"R ",
988  pPage->US?"U":"S",
989  (ULONG)pPTE);
990  }
991 
992  }
993  Print(OUTPUT_WINDOW,tempCmd);
994  }
995  else
996  {
997  PICE_sprintf(tempCmd,"page at %.8X not present.\n",pArgs->Value[0]);
998  Print(OUTPUT_WINDOW,tempCmd);
999  }
1000 
1001  }
1002  }
1003  return TRUE;
1004 }
1005 
1006 //*************************************************************************
1007 // ShowProcesses()
1008 //
1009 //*************************************************************************
1010 COMMAND_PROTOTYPE(ShowProcesses)
1011 {
1012  PEPROCESS my_current = IoGetCurrentProcess();
1013  PLIST_ENTRY current_entry;
1014  PEPROCESS currentps;
1015 
1016  ENTER_FUNC();
1017 
1018  current_entry = pPsProcessListHead->Flink;
1019 
1020  if( current_entry ){
1021 
1022  PutStatusText("NAME TASK PID");
1023 
1024  while( current_entry != pPsProcessListHead ){
1025  currentps = CONTAINING_RECORD(current_entry,
1026  EPROCESS,
1027  ProcessListEntry);
1028  DPRINT((0,"currentps = %x\n",currentps));
1029  //ei would be nice to mark current process!
1030  PICE_sprintf(tempCmd,"%-16.16s %-12x %x\n",currentps->ImageFileName,
1031  (ULONG)currentps,currentps->UniqueProcessId);
1032  Print(OUTPUT_WINDOW,tempCmd);
1033  if(WaitForKey()==FALSE)
1034  break;
1035  current_entry = current_entry->Flink;
1036  }
1037  }
1038  LEAVE_FUNC();
1039  return TRUE;
1040 }
1041 
1042 //*************************************************************************
1043 // DisplayMemoryDword()
1044 //
1045 //*************************************************************************
1046 COMMAND_PROTOTYPE(DisplayMemoryDword)
1047 {
1048  ULONG i,j,k;
1049  static ULONG addr=0,addrorg;
1050  static USHORT segment;
1051  char temp[8];
1052  LPSTR pSymbolName;
1053 
1054  ENTER_FUNC();
1055  DPRINT((0,"DisplayMemoryDword()\n"));
1056  if(pArgs->Count==2)
1057  {
1058  segment=(USHORT)pArgs->Value[0];
1059  if(!segment)segment=GLOBAL_DATA_SEGMENT;
1060  addr=pArgs->Value[1];
1061  OldSelector = segment;
1062  OldOffset = addr;
1063  addrorg=addr;
1064  addr=GetLinearAddress(segment,addr);
1065  }
1066  else if(pArgs->Count==1)
1067  {
1068  segment=CurrentDS;
1069  addr=pArgs->Value[0];
1070  OldOffset = addr;
1071  addrorg=addr;
1072  addr=GetLinearAddress(segment,addr);
1073  }
1074  else if(pArgs->Count==0)
1075  {
1076  addr += sizeof(ULONG)*4*4;
1077  OldOffset = addr;
1078  }
1079 
1080  if(ScanExportsByAddress(&pSymbolName,addr))
1081  {
1082  PICE_sprintf(tempCmd," %s ",pSymbolName);
1086  ResetColor();
1087  }
1088 
1090 
1091  if(DisplayMemory != DisplayMemoryDword)
1092  {
1093  Clear(DATA_WINDOW);
1094  DisplayMemory = DisplayMemoryDword;
1095  }
1096  else
1097  Home(DATA_WINDOW);
1098 
1099  for(k=0;k<wWindow[DATA_WINDOW].cy;k++) // 4 lines
1100  {
1101  PICE_sprintf(tempCmd,"%.4X:%.8X: ",segment,addrorg+k*16);
1102  Print(1,tempCmd);
1103  for(i=0;i<4;i++) // 4 dwords
1104  {
1105  tempCmd[0]=0;
1106  Print(1," ");
1107  for(j=0;j<4;j++) // 1 dword = 4 bytes
1108  {
1109  if(IsAddressValid(addr+i*4+j+k*16))
1110  {
1111  PICE_sprintf(temp,"%.2x",*(PUCHAR)(addr+i*4+j+k*16));
1112  PICE_strrev(temp);
1113  PICE_strcat(tempCmd,temp);
1114  }
1115  else
1116  {
1117  PICE_strcat(tempCmd,"??");
1118  }
1119  }
1120  PICE_strrev(tempCmd);
1121  Print(1,tempCmd);
1122  }
1123  Print(1," ");
1124  tempCmd[0]=0;
1125  for(j=0;j<16;j++) // 1 dword = 4 bytes
1126  {
1128  if(IsAddressValid(addr+j+k*16))
1129  {
1130  PICE_sprintf(temp,"%c",PICE_isprint(*(PUCHAR)(addr+j+k*16))?(*(PUCHAR)(addr+j+k*16)):'.');
1131  PICE_strcat(tempCmd,temp);
1132  }
1133  else
1134  {
1135  PICE_strcat(tempCmd,"?");
1136  }
1137  }
1138  Print(1,tempCmd);
1139  Print(1,"\n");
1140  }
1142  addr+=16*4;
1143  return TRUE;
1144 }
1145 
1146 //*************************************************************************
1147 // DisplayMemoryByte()
1148 //
1149 //*************************************************************************
1150 COMMAND_PROTOTYPE(DisplayMemoryByte)
1151 {
1152  ULONG j,k;
1153  static ULONG addr=0,addrorg;
1154  static USHORT segment;
1155  char temp[8];
1156  LPSTR pSymbolName;
1157 
1158  if(pArgs->Count==2)
1159  {
1160  segment=(USHORT)pArgs->Value[0];
1161  if(!segment)segment=GLOBAL_DATA_SEGMENT;
1162  addr=pArgs->Value[1];
1163  OldSelector = segment;
1164  OldOffset = addr;
1165  addrorg=addr;
1166  addr=GetLinearAddress(segment,addr);
1167  }
1168  else if(pArgs->Count==1)
1169  {
1170  segment=CurrentDS;
1171  addr=pArgs->Value[0];
1172  OldOffset = addr;
1173  addrorg=addr;
1174  addr=GetLinearAddress(segment,addr);
1175  }
1176  else if(pArgs->Count==0)
1177  {
1178  addr += sizeof(ULONG)*4*4;
1179  OldOffset = addr;
1180  }
1181 
1182  if(DisplayMemory != DisplayMemoryByte)
1183  {
1184  Clear(DATA_WINDOW);
1185  DisplayMemory = DisplayMemoryByte;
1186  }
1187  else
1188  Home(DATA_WINDOW);
1189 
1190  if(ScanExportsByAddress(&pSymbolName,addr))
1191  {
1192  PICE_sprintf(tempCmd," %s ",pSymbolName);
1196  ResetColor();
1197  }
1198 
1200  for(k=0;k<wWindow[DATA_WINDOW].cy;k++) // 4 lines
1201  {
1202  PICE_sprintf(tempCmd,"%.4X:%.8X: ",segment,addrorg+k*16);
1203  Print(1,tempCmd);
1204  tempCmd[0]=0;
1205  Print(1," ");
1206  for(j=0;j<16;j++) // 1 dword = 4 bytes
1207  {
1208  if(IsAddressValid(addr+j+k*16))
1209  {
1210  PICE_sprintf(temp,"%.2x ",*(PUCHAR)(addr+j+k*16));
1211  PICE_strcat(tempCmd,temp);
1212  }
1213  else
1214  {
1215  PICE_strcat(tempCmd,"?? ");
1216  }
1217  }
1218  Print(1,tempCmd);
1219  Print(1," ");
1220  tempCmd[0]=0;
1221  for(j=0;j<16;j++) // 1 dword = 4 bytes
1222  {
1224  if(IsAddressValid(addr+j+k*16))
1225  {
1226  PICE_sprintf(temp,"%c",PICE_isprint(*(PUCHAR)(addr+j+k*16))?(*(PUCHAR)(addr+j+k*16)):'.');
1227  PICE_strcat(tempCmd,temp);
1228  }
1229  else
1230  {
1231  PICE_strcat(tempCmd,"?");
1232  }
1233  }
1234  Print(1,tempCmd);
1235  Print(1,"\n");
1236  }
1238  addr+=16*4;
1239  return TRUE;
1240 }
1241 
1242 //*************************************************************************
1243 // DisplayPhysMemDword()
1244 //
1245 //*************************************************************************
1246 COMMAND_PROTOTYPE(DisplayPhysMemDword)
1247 {
1248  ULONG i,j,k;
1249  static ULONG addr=0,addrorg;
1250  static USHORT segment;
1251  char temp[8];
1252 
1253  ENTER_FUNC();
1254  DPRINT((0,"DisplayPhysMemDword()\n"));
1255 
1256  if(pArgs->Count==1)
1257  {
1258  segment=CurrentDS;
1259  addr=pArgs->Value[0];
1260  OldOffset = addr;
1261  addrorg=addr;
1262  addr=GetLinearAddress(segment,addr);
1263  }
1264  else if(pArgs->Count==0)
1265  {
1266  addr += sizeof(ULONG)*4*4;
1267  OldOffset = addr;
1268  }
1269 
1271 
1272  if(DisplayMemory != DisplayPhysMemDword)
1273  {
1274  Clear(DATA_WINDOW);
1275  DisplayMemory = DisplayPhysMemDword;
1276  }
1277  else
1278  Home(DATA_WINDOW);
1279 
1280  for(k=0;k<wWindow[DATA_WINDOW].cy;k++) // 4 lines
1281  {
1282  PICE_sprintf(tempCmd,"PHYS:%.8X: ",addrorg+k*16);
1283  Print(1,tempCmd);
1284  for(i=0;i<4;i++) // 4 dwords
1285  {
1286  tempCmd[0]=0;
1287  PICE_sprintf(tempCmd," %.8X",ReadPhysMem(addr+i*4+k*16,sizeof(ULONG)));
1288  Print(1,tempCmd);
1289  }
1290  Print(1," ");
1291  tempCmd[0]=0;
1292  for(j=0;j<16;j++) // 1 dword = 4 bytes
1293  {
1294  UCHAR ucData;
1296  ucData = ReadPhysMem(addr+j+k*16,sizeof(UCHAR));
1297  PICE_sprintf(temp,"%c",PICE_isprint(ucData)?ucData:'.');
1298  PICE_strcat(tempCmd,temp);
1299  }
1300  Print(1,tempCmd);
1301  Print(1,"\n");
1302  }
1304  addr+=16*4;
1305  return TRUE;
1306 }
1307 
1308 
1309 //*************************************************************************
1310 // DisplaySourceFile()
1311 //
1312 //*************************************************************************
1313 void DisplaySourceFile(LPSTR pSrcLine,LPSTR pSrcEnd,ULONG ulLineNumber,ULONG ulLineNumberToInvert)
1314 {
1315  ULONG i;
1316  LPSTR pTemp;
1317  ULONG j = ulLineNumber-1;
1318 
1319  DPRINT((0,"DisplaySourceFile(%.8X,%u,%u)\n",pSrcLine,ulLineNumber,ulLineNumberToInvert));
1320 
1321  // go to line
1322  while(j--)
1323  {
1324  // goto end of current line
1325  while(*pSrcLine!=0x0a && *pSrcLine!=0x0d)
1326  pSrcLine++;
1327 
1328  // skip over the line end
1329  if(*pSrcLine == 0x0d)
1330  pSrcLine++;
1331  if(*pSrcLine == 0x0a)
1332  pSrcLine++;
1333  }
1334 
1337  for(i=0;i<wWindow[SOURCE_WINDOW].cy;i++)
1338  {
1339  pTemp = tempCmd;
1340 
1341  if(pSrcLine<pSrcEnd)
1342  {
1343  PICE_sprintf(tempCmd,".%.5u ",ulLineNumber+i);
1344  pTemp = tempCmd + PICE_strlen(tempCmd);
1345 
1346  while(pSrcLine<pSrcEnd && *pSrcLine!=0x0a && *pSrcLine!=0x0d)
1347  {
1348  if(*pSrcLine==0x9) // TAB
1349  {
1350  *pTemp++ = 0x20;
1351  *pTemp++ = 0x20;
1352  *pTemp++ = 0x20;
1353  *pTemp++ = 0x20;
1354  pSrcLine++;
1355  }
1356  else
1357  {
1358  *pTemp++ = *pSrcLine++;
1359  }
1360  }
1361 
1362  if(pSrcLine<pSrcEnd)
1363  {
1364  // skip over the line end
1365  if(*pSrcLine == 0x0d)
1366  pSrcLine++;
1367  if(*pSrcLine == 0x0a)
1368  pSrcLine++;
1369  }
1370 
1371  *pTemp++ = '\n';
1372  *pTemp = 0;
1373 
1374  if(PICE_strlen(tempCmd)>GLOBAL_SCREEN_WIDTH-1)
1375  {
1376  tempCmd[GLOBAL_SCREEN_WIDTH-2]='\n';
1377  tempCmd[GLOBAL_SCREEN_WIDTH-1]=0;
1378  }
1379 
1380  if( (ulLineNumberToInvert!=-1) &&
1381  ((int)(ulLineNumberToInvert-ulLineNumber)>=0) &&
1382  ((ulLineNumberToInvert-ulLineNumber)<wWindow[SOURCE_WINDOW].cy) &&
1383  (i==(ulLineNumberToInvert-ulLineNumber)) )
1384  {
1387  }
1388 
1389  Print(SOURCE_WINDOW,tempCmd);
1390 
1391  if( (ulLineNumberToInvert!=-1) &&
1392  ((int)(ulLineNumberToInvert-ulLineNumber)>=0) &&
1393  ((ulLineNumberToInvert-ulLineNumber)<wWindow[SOURCE_WINDOW].cy) &&
1394  (i==(ulLineNumberToInvert-ulLineNumber)) )
1395  {
1396  ResetColor();
1397  }
1398 
1399  }
1400  else
1401  {
1402  Print(SOURCE_WINDOW,"---- End of source file --------------\n");
1403  break;
1404  }
1405  }
1407 }
1408 
1409 //*************************************************************************
1410 // UnassembleOneLineDown()
1411 //
1412 //*************************************************************************
1414 {
1415  ULONG addr,addrorg;
1416 
1417  DPRINT((0,"UnassembleOneLineDown()\n"));
1418 
1420 
1421  DPRINT((0,"UnassembleOneLineDown(): addr = %.8X\n",addr));
1422 
1423  tempCmd[0]=0;
1424  Disasm(&addr,tempCmd);
1425 
1426  DPRINT((0,"UnassembleOneLineDown(): addr after = %.8X\n",addr));
1427 
1428  ulOldDisasmOffset += (addr - addrorg);
1429  RepaintSource();
1430 }
1431 
1432 //*************************************************************************
1433 // UnassembleOnePageDown()
1434 //
1435 //*************************************************************************
1437 {
1438  ULONG addr,addrorg,i;
1439 
1440  DPRINT((0,"UnassembleOnePageDown()\n"));
1441 
1443 
1444  DPRINT((0,"UnassembleOnePageDown(): addr = %.8X\n",addr));
1445 
1446  tempCmd[0]=0;
1447  for(i=0;i<page;i++)
1448  Disasm(&addr,tempCmd);
1449 
1450  DPRINT((0,"UnassembleOnePageDown(): addr after = %.8X\n",addr));
1451 
1452  ulOldDisasmOffset += (addr - addrorg);
1453  RepaintSource();
1454 }
1455 
1456 //*************************************************************************
1457 // UnassembleOneLineUp()
1458 //
1459 //*************************************************************************
1461 {
1462  ULONG addr,addrorg,addrbefore,start,end,addrstart;
1463  LONG offset;
1464  LPSTR pSymbol;
1465 
1466  DPRINT((0,"UnassembleOneLineUp()\n"));
1467 
1469 
1470  DPRINT((0,"UnassembleOneLineUp(): addrorg = %.8X\n",addr));
1471 
1472  offset = 1;
1473 
1474  if((pSymbol = FindFunctionByAddress(addrorg-offset,&start,&end)) )
1475  {
1476  offset = addrorg - start;
1477  DPRINT((0,"UnassembleOneLineUp(): %s @ offset = %u\n",pSymbol,offset));
1478  }
1479  else
1480  {
1481  // max instruction length is 15 bytes
1482  offset = 15;
1483  }
1484 
1485  addrstart = addrorg;
1486 
1487  // start at current address less offset
1488  addr = addrorg - offset;
1489  do
1490  {
1491  DPRINT((0,"UnassembleOneLineUp(): offset = %u addrorg %x addr %x\n",offset,addrorg,addr));
1492  // disassemble while not reaching current instruction
1493  addrbefore = addr;
1494  tempCmd[0]=0;
1495  Disasm(&addr,tempCmd);
1496  DPRINT((0,"%.8X: %s\n",addrbefore,tempCmd));
1497  }while((addr != addrorg) && (addrbefore < addrorg));
1498 
1499  if((addrorg - addrstart)<=0)
1501  else
1502  ulOldDisasmOffset -= (addrorg - addrbefore);
1503 
1504  DPRINT((0,"UnassembleOneLineUp(): new addr = %.4X:%.8X\n",usOldDisasmSegment,ulOldDisasmOffset));
1505 
1506  RepaintSource();
1507 }
1508 
1509 //*************************************************************************
1510 // UnassembleOneLineUp()
1511 //
1512 //*************************************************************************
1514 {
1515  ULONG addr,addrorg,addrbefore,start,end,i,addrstart;
1516  LONG offset;
1517  LPSTR pSymbol;
1518 
1519  DPRINT((0,"UnassembleOnePageUp()\n"));
1520 
1521  for(i=0;i<page;i++)
1522  {
1524 
1525  DPRINT((0,"UnassembleOnePageUp(): addrorg = %.8X\n",addr));
1526 
1527  offset = 1;
1528 
1529  if((pSymbol = FindFunctionByAddress(addrorg-offset,&start,&end)) )
1530  {
1531  offset = addrorg - start;
1532  DPRINT((0,"UnassembleOnePageUp(): %s @ offset = %u\n",pSymbol,offset));
1533  }
1534  else
1535  {
1536  // max instruction length is 15 bytes
1537  offset = 15;
1538  }
1539 
1540  // start at current address less offset
1541  addr = addrorg - offset;
1542  addrstart = addrorg;
1543  do
1544  {
1545  DPRINT((0,"UnassembleOnePageUp(): offset = %u addrorg %x addr %x\n",offset,addrorg,addr));
1546  addrbefore = addr;
1547  // disassemble while not reaching current instruction
1548  tempCmd[0]=0;
1549  Disasm(&addr,tempCmd);
1550  DPRINT((0,"%.8X: %s\n",addrbefore,tempCmd));
1551  }while((addr != addrorg) && (addrbefore < addrorg));
1552 
1553  if((addrorg - addrstart)<=0)
1555  else
1556  ulOldDisasmOffset -= (addrorg - addrbefore);
1557 
1558  }
1559 
1560  DPRINT((0,"UnassembleOnePageUp(): new addr = %.4X:%.8X\n",usOldDisasmSegment,ulOldDisasmOffset));
1561 
1562  RepaintSource();
1563 }
1564 
1565 //*************************************************************************
1566 // Unassemble()
1567 //
1568 //*************************************************************************
1570 {
1571  ULONG i;
1572  ULONG addr=0,addrorg,addrstart,ulLineNumber;
1573  USHORT segment=0;
1574  ULONG addrbefore;
1575  LPSTR pSymbolName;
1576  BOOLEAN bSWBpAtAddr;
1577  LPSTR pSrc,pFilename,pSrcStart,pSrcEnd;
1578  BOOLEAN bForceDisassembly = FALSE;
1579 
1580  DPRINT((0,"Unassemble: CountSwitches: %u, count: %u\n", pArgs->CountSwitches, pArgs->Count));
1581  if(pArgs->CountSwitches>1)
1582  return TRUE;
1583 
1584  if(pArgs->CountSwitches==1)
1585  {
1586  if(pArgs->Switch[0] == 'f')
1587  bForceDisassembly = TRUE;
1588  }
1589 
1590  // we have args
1591  if(pArgs->Count==2)
1592  {
1593  addr=pArgs->Value[1];
1594  segment=(USHORT)pArgs->Value[0];
1595  addrorg=addrstart=addr;
1596  addr=GetLinearAddress(segment,addr);
1597 
1600  }
1601  else if(pArgs->Count==1)
1602  {
1603  addr=pArgs->Value[0];
1604  segment=CurrentCS;
1605  addrorg=addrstart=addr;
1606  addr=GetLinearAddress(segment,addr);
1607 
1610  }
1611  else if(pArgs->Count==0)
1612  {
1613  segment = usOldDisasmSegment;
1614  addrorg=addrstart=addr;
1616  }
1617  else
1618  return TRUE;
1619 
1620 
1621  DPRINT((0,"Unassemble(%0.4X:%0.8X), lastst: %x, lastend:%x\n",segment,addr,ulLastDisassStartAddress,ulLastDisassEndAddress));
1622 
1623  //
1624  // unassemble
1625  //
1627 
1628  // if we're inside last disassembly range we only need to move to highlight
1630  addr<ulLastDisassEndAddress )
1631  {
1633  }
1634  else
1635  {
1637  }
1638 
1641 
1643 
1644  ResetColor();
1645 
1646  if(ScanExportsByAddress(&pSymbolName,addr))
1647  {
1650  PICE_sprintf(tempCmd," %s ",pSymbolName);
1652  ResetColor();
1653  }
1654 
1655  pCurrentMod = FindModuleFromAddress(addr);
1656  if(pCurrentMod)
1657  {
1658  ULONG mod_addr;
1659  DPRINT((0,"Unassemble(): pCurrentMod->name = %S\n",pCurrentMod->name));
1660  mod_addr = (ULONG)pCurrentMod->BaseAddress;
1661 
1662  pCurrentSymbols = FindModuleSymbols(mod_addr);
1663  DPRINT((0,"Unassemble(): pCurrentSymbols = %x\n",(ULONG)pCurrentSymbols));
1664  }
1665  DPRINT((0,"Unassemble(): pCurrentMod = %x, showsrc: %d\n",pCurrentMod, bShowSrc));
1666 
1668 
1669  if(bShowSrc && bForceDisassembly == FALSE && (pSrc = FindSourceLineForAddress(addr,&ulLineNumber,&pSrcStart,&pSrcEnd,&pFilename)) )
1670  {
1671  DPRINT((0,"FoundSourceLineForAddress: file: %s line: %d\n", pFilename, ulLineNumber));
1672  PICE_strcpy(szCurrentFile,pFilename);
1673 
1674  ulCurrentlyDisplayedLineNumber = ulLineNumber;
1675 
1677 
1678  // display file name
1681 
1682  if(PICE_strlen(pFilename)<GLOBAL_SCREEN_WIDTH/2)
1683  {
1684  PutChar(pFilename,1,wWindow[SOURCE_WINDOW].y-1);
1685  }
1686  else
1687  {
1688  LPSTR p;
1689 
1690  p = strrchr(pFilename,'/');
1691  if(!p)
1692  {
1693  p = pFilename;
1694  }
1695  else
1696  {
1697  p++;
1698  }
1699 
1700  PutChar(p,1,wWindow[SOURCE_WINDOW].y-1);
1701  }
1702 
1703  ResetColor();
1704 
1705  // display the source
1706  if(ulLineNumber>(wWindow[SOURCE_WINDOW].cy/2) )
1707  {
1708  DisplaySourceFile(pSrcStart,pSrcEnd,ulLineNumber-(wWindow[SOURCE_WINDOW].cy/2),ulLineNumber);
1709  }
1710  else
1711  {
1712  DisplaySourceFile(pSrcStart,pSrcEnd,ulLineNumber,ulLineNumber);
1713  }
1714  }
1715  else
1716  {
1717  *szCurrentFile = 0;
1718  DPRINT((0,"Couldn't find source for file\n"));
1720  // for each line in the disassembly window
1721  for(i=0;i<wWindow[SOURCE_WINDOW].cy;i++)
1722  {
1723  extern ULONG ulWindowOffset;
1724 
1725  bSWBpAtAddr = FALSE;
1726  // if there is a potential SW breakpoint at address
1727  // we might have to put back the original opcode
1728  // in order to disassemble correctly.
1729  if(IsSwBpAtAddress(addr))
1730  {
1731  // if INT3 is there, remove it while disassembling
1732  if((bSWBpAtAddr = IsSwBpAtAddressInstalled(addr)))
1733  {
1734  DeInstallSWBreakpoint(addr);
1735  }
1736  }
1737 
1739 
1740  // invert the line that we're about to execute
1741  if(addr==CurrentEIP)
1742  {
1746  }
1747 
1748  // output segment:offset address
1749  PICE_sprintf(tempCmd,"%0.4X:%0.8X ",segment,addr);
1750  Print(SOURCE_WINDOW,tempCmd);
1751 
1752  // disassemble a line
1753  addrbefore=addr;
1754  if(bCodeOn)
1755  {
1756  tempCmd[30]=0;
1757  Disasm(&addr,&tempCmd[30]);
1758  }
1759  else
1760  {
1761  tempCmd[0]=0;
1762  Disasm(&addr,tempCmd);
1763  }
1764  addrorg+=(addr-addrbefore);
1765 
1766  // want to display opcode bytes
1767  if(bCodeOn)
1768  {
1769  ULONG j;
1770 
1771  for(j=0;j<15;j++)
1772  {
1773  if(j<addr-addrbefore)
1774  {
1775  if(IsAddressValid(addrbefore+j))
1776  {
1777  tempCmd[j*2]=HexDigit[((*(PUCHAR)(addrbefore+j)&0xF0)>>4)];
1778  tempCmd[j*2+1]=HexDigit[((*(PUCHAR)(addrbefore+j)&0xF))];
1779  }
1780  else
1781  {
1782  tempCmd[j*2]='?';
1783  tempCmd[j*2+1]='?';
1784  }
1785  }
1786  else
1787  {
1788  tempCmd[j*2]=' ';
1789  tempCmd[j*2+1]=' ';
1790  }
1791  }
1792  }
1793  PICE_strcat(tempCmd,"\n");
1794 
1795  if(ulWindowOffset)
1796  {
1797  LONG len = PICE_strlen(tempCmd);
1798  if(ulWindowOffset < len)
1799  PICE_memcpy(tempCmd,&tempCmd[ulWindowOffset],len-ulWindowOffset);
1800  else
1801  tempCmd[0]='\n';
1802  }
1803 
1804  Print(SOURCE_WINDOW,tempCmd);
1805 
1806  if(addrbefore==CurrentEIP)
1807  {
1808  ResetColor();
1809  }
1810 
1811  // if potential SW breakpoint, undo marked text
1812  if(IsSwBpAtAddress(addrbefore))
1813  {
1815  }
1816 
1817  // if breakpoint was installed before disassembly, put it back
1818  if(bSWBpAtAddr)
1819  {
1820  ReInstallSWBreakpoint(addrbefore);
1821  }
1822 
1823  }
1824 
1826  {
1827  ulLastDisassStartAddress=addrstart;
1829  }
1830 
1831  if(!IsAddressValid(addrstart))
1832  {
1835  }
1836 
1837  }
1838 
1840 
1841  return TRUE;
1842 }
1843 
1844 //*************************************************************************
1845 // ShowModules()
1846 //
1847 //*************************************************************************
1848 COMMAND_PROTOTYPE(ShowModules)
1849 {
1850  PDEBUG_MODULE pMod;
1851  DPRINT((0,"ShowModules()\n"));
1852 
1853  if(BuildModuleList())
1854  {
1855  pMod = pdebug_module_head;
1856  do
1857  {
1858  if(pMod->size)
1859  {
1860  if(pMod == pCurrentMod)
1861  {
1862  PICE_sprintf(tempCmd,"%.8X - %.8X *%-32S\n",
1863  (unsigned int)pMod->BaseAddress,
1864  (unsigned int) ((unsigned int)pMod->BaseAddress+pMod->size),pMod->name);
1865  }
1866  else
1867  {
1868  PICE_sprintf(tempCmd,"%.8X - %.8X %-32S\n",
1869  (unsigned int)pMod->BaseAddress,
1870  (unsigned int) ((unsigned int)pMod->BaseAddress+pMod->size),
1871  pMod->name);
1872  }
1873  }
1874  Print(OUTPUT_WINDOW,tempCmd);
1875  if(WaitForKey()==FALSE)
1876  break;
1877  }while((pMod = pMod->next)!=pdebug_module_tail);
1878  }
1879  return TRUE;
1880 }
1881 
1882 //*************************************************************************
1883 // DecodeVmFlags()
1884 //
1885 //*************************************************************************
1886 //ei FIX THIS!!!!!!!!!!!!!!!!!!
1888 {
1889  ULONG i;
1890 /*
1891 #define VM_READ 0x0001
1892 #define VM_WRITE 0x0002
1893 #define VM_EXEC 0x0004
1894 #define VM_SHARED 0x0008
1895 
1896 #define VM_MAYREAD 0x0010
1897 #define VM_MAYWRITE 0x0020
1898 #define VM_MAYEXEC 0x0040
1899 #define VM_MAYSHARE 0x0080
1900 
1901 #define VM_GROWSDOWN 0x0100
1902 #define VM_GROWSUP 0x0200
1903 #define VM_SHM 0x0400
1904 #define VM_DENYWRITE 0x0800
1905 
1906 #define VM_EXECUTABLE 0x1000
1907 #define VM_LOCKED 0x2000
1908 #define VM_IO 0x4000
1909 
1910 #define VM_STACK_FLAGS 0x0177
1911 */
1912  static LPSTR flags_syms_on[]={"R","W","X","S","MR","MW","MX","MS","GD","GU","SHM","exe","LOCK","IO",""};
1913  static char temp[256];
1914 
1915  // terminate string
1916  *temp = 0;
1917 //ei fix fix fix
1918 #if 0
1919 
1920  if(flags == VM_STACK_FLAGS)
1921  {
1922  PICE_strcpy(temp," (STACK)");
1923  }
1924  else
1925  {
1926  for(i=0;i<15;i++)
1927  {
1928  if(flags&0x1)
1929  {
1930  PICE_strcat(temp," ");
1931  PICE_strcat(temp,flags_syms_on[i]);
1932  }
1933  flags >>= 1;
1934  }
1935  }
1936 #endif
1937  return temp;
1938 }
1939 
1940 //*************************************************************************
1941 // ShowVirtualMemory()
1942 //
1943 //*************************************************************************
1944 COMMAND_PROTOTYPE(ShowVirtualMemory)
1945 {
1946  PEPROCESS my_current = IoGetCurrentProcess();
1947  PLIST_ENTRY current_entry;
1948  PMADDRESS_SPACE vma = NULL;
1950  char filename[64];
1951 
1952  DPRINT((0,"ShowVirtualMemory()\n"));
1953  if( my_current )
1954  vma = &(my_current->AddressSpace);
1955  if( !vma )
1956  vma = my_init_mm;
1957  while( vma )
1958  {
1959  if(pArgs->Count == 0)
1960  {
1961  PutStatusText("START END LENGTH VMA TYPE ATTR");
1962  current_entry = vma->MAreaListHead.Flink;
1963  while (current_entry != &vma->MAreaListHead)
1964  {
1965  *filename = 0;
1966 
1967  current = CONTAINING_RECORD(current_entry,
1968  MEMORY_AREA,
1969  Entry);
1970  // find the filename
1971  if(((current->Type == MEMORY_AREA_SECTION_VIEW) ) &&
1972  current->Data.SectionData.Section->FileObject)
1973  {
1974  if(IsAddressValid((ULONG)current->Data.SectionData.Section->FileObject->FileName.Buffer) )
1975  PICE_sprintf(filename,"%.64S",current->Data.SectionData.Section->FileObject->FileName.Buffer);
1976  }
1977 
1978  PICE_sprintf(tempCmd,"%.8X %.8X %.8X %.8X %x %x %s\n",
1979  (ULONG)current->BaseAddress,
1980  (ULONG)current->BaseAddress+current->Length,
1981  current->Length,
1982  (ULONG)current,
1983  current->Type, current->Attributes,//DecodeVmFlags(current->Type, current->Attributes),
1984  filename);
1985  Print(OUTPUT_WINDOW,tempCmd);
1986 
1987  if(WaitForKey()==FALSE)
1988  break;
1989  current_entry = current_entry->Flink;
1990  }
1991  }
1992  if( vma == &(my_current->AddressSpace) )
1993  vma = my_init_mm; // switch to kernel memory area
1994  else vma = 0; // if we already did kernel, end loop
1995  }
1996  return TRUE;
1997 }
1998 
1999 //*************************************************************************
2000 // Ver()
2001 //
2002 //*************************************************************************
2004 {
2005  //ei add kernel version info??!!
2006  PICE_sprintf(tempCmd,"pICE: version %u.%u (build %u) for ReactOS\n",
2009  PICE_BUILD);
2010 
2011  Print(OUTPUT_WINDOW,tempCmd);
2012 
2013 /* PICE_sprintf(tempCmd,"pICE: loaded on %s kernel release %s\n",
2014  system_utsname.sysname,
2015  system_utsname.release);
2016  */
2017  Print(OUTPUT_WINDOW,tempCmd);
2018  Print(OUTPUT_WINDOW,"pICE: written by Klaus P. Gerlicher and Goran Devic.\n");
2019  Print(OUTPUT_WINDOW,"pICE: ported to ReactOS by Eugene Ingerman.\n");
2020 
2021  return TRUE;
2022 }
2023 
2024 //*************************************************************************
2025 // Hboot()
2026 //
2027 //*************************************************************************
2029 {
2030  // nudge the reset line through keyboard controller
2031  __asm__("\n\t \
2032  movb $0xFE,%al\n\t \
2033  outb %al,$0x64");
2034  // never gets here
2035  return TRUE;
2036 }
2037 
2038 //*************************************************************************
2039 // SetSrcDisplay()
2040 //
2041 //*************************************************************************
2042 COMMAND_PROTOTYPE(SetSrcDisplay)
2043 {
2044  ARGS Args;
2045 
2046  if(pArgs->Count==0)
2047  {
2048  bShowSrc=bShowSrc?FALSE:TRUE;
2049  PICE_memset(&Args,0,sizeof(ARGS));
2050  // make unassembler refresh all again
2052  Args.Count=0;
2053  Unassemble(&Args);
2054  }
2055  return TRUE;
2056 }
2057 
2058 //*************************************************************************
2059 // I3here()
2060 //
2061 //*************************************************************************
2063 {
2064  if(pArgs->Count==1)
2065  {
2066  if(pArgs->Value[0]==1)
2067  {
2068  if(!bInt3Here)
2069  {
2070  bInt3Here=TRUE;
2071  Print(OUTPUT_WINDOW,"I3HERE is now ON\n");
2072  }
2073  else
2074  Print(OUTPUT_WINDOW,"I3HERE is already ON\n");
2075  }
2076  else if(pArgs->Value[0]==0)
2077  {
2078  if(bInt3Here)
2079  {
2080  bInt3Here=FALSE;
2081  Print(OUTPUT_WINDOW,"I3HERE is now OFF\n");
2082  }
2083  else
2084  Print(OUTPUT_WINDOW,"I3HERE is already OFF\n");
2085  }
2086  }
2087  else if(pArgs->Count==0)
2088  {
2089  if(bInt3Here)
2090  {
2091  Print(OUTPUT_WINDOW,"I3HERE is ON\n");
2092  }
2093  else
2094  {
2095  Print(OUTPUT_WINDOW,"I3HERE is OFF\n");
2096  }
2097  }
2098  // never gets here
2099  return TRUE;
2100 }
2101 
2103 {
2104  if(pArgs->Count==1)
2105  {
2106  if(pArgs->Value[0]==1)
2107  {
2108  if(!bInt1Here)
2109  {
2110  bInt1Here=TRUE;
2111  Print(OUTPUT_WINDOW,"I1HERE is now ON\n");
2112  }
2113  else
2114  Print(OUTPUT_WINDOW,"I1HERE is already ON\n");
2115  }
2116  else if(pArgs->Value[0]==0)
2117  {
2118  if(bInt1Here)
2119  {
2120  bInt1Here=FALSE;
2121  Print(OUTPUT_WINDOW,"I1HERE is now OFF\n");
2122  }
2123  else
2124  Print(OUTPUT_WINDOW,"I1HERE is already OFF\n");
2125  }
2126  }
2127  else if(pArgs->Count==0)
2128  {
2129  if(bInt1Here)
2130  {
2131  Print(OUTPUT_WINDOW,"I1HERE is ON\n");
2132  }
2133  else
2134  {
2135  Print(OUTPUT_WINDOW,"I1HERE is OFF\n");
2136  }
2137  }
2138  // never gets here
2139  return TRUE;
2140 }
2141 
2143 {
2144  static char tempDisasm[256];
2145  ULONG addr,addrbefore;
2146 
2147  bNeedToFillBuffer=FALSE;
2148 
2149  if(!pArgs->Count)
2150  {
2151  addr=addrbefore=GetLinearAddress(CurrentCS,CurrentEIP);
2152  DPRINT((0,"addr before %.8X\n",addrbefore));
2153  Disasm(&addr,tempDisasm);
2154  DPRINT((0,"addr after %.8X\n",addr));
2155  CurrentEIP=CurrentEIP+(addr-addrbefore);
2156  // display register contents
2157  DisplayRegs();
2158  // unassemble
2159  DPRINT((0,"new CS:EIP %04.x:%.8X\n",CurrentCS,CurrentEIP));
2160  PICE_memset(pArgs,0,sizeof(ARGS));
2161  // make unassembler refresh all again
2163  pArgs->Count=2;
2164  pArgs->Value[0]=(ULONG)CurrentCS;
2165  pArgs->Value[1]=CurrentEIP;
2166  Unassemble(pArgs);
2167  }
2168  bNeedToFillBuffer=TRUE;
2169  return TRUE;
2170 }
2171 
2172 COMMAND_PROTOTYPE(SetGetRegisters)
2173 {
2174  ULONG i;
2175 
2176  if(pArgs->Count==0)
2177  {
2178  // display whole set
2179  for(i=0;RegKeyWords[i].pValue!=0;i++)
2180  {
2181  switch(RegKeyWords[i].ulSize)
2182  {
2183  case 1:
2184  PICE_sprintf(tempCmd,"%s = %.8X\n",RegKeyWords[i].KeyWord,*(PUCHAR)(RegKeyWords[i].pValue));
2185  break;
2186  case 2:
2187  PICE_sprintf(tempCmd,"%s = %.8X\n",RegKeyWords[i].KeyWord,*(PUSHORT)(RegKeyWords[i].pValue));
2188  break;
2189  case 4:
2190  PICE_sprintf(tempCmd,"%s = %.8X\n",RegKeyWords[i].KeyWord,*(PULONG)(RegKeyWords[i].pValue));
2191  break;
2192  }
2193  Print(OUTPUT_WINDOW,tempCmd);
2194  if(WaitForKey()==FALSE)break;
2195  }
2196  }
2197  else if(pArgs->Count==1)
2198  {
2199  // display selected register
2200  for(i=0;RegKeyWords[i].pValue!=0;i++)
2201  {
2202  if(PICE_strcmpi(pArgs->pToken[0],RegKeyWords[i].KeyWord)==0)
2203  {
2204  switch(RegKeyWords[i].ulSize)
2205  {
2206  case 1:
2207  PICE_sprintf(tempCmd,"%s = %.2X\n",RegKeyWords[i].KeyWord,*(PUCHAR)(RegKeyWords[i].pValue));
2208  break;
2209  case 2:
2210  PICE_sprintf(tempCmd,"%s = %.4X\n",RegKeyWords[i].KeyWord,*(PUSHORT)(RegKeyWords[i].pValue));
2211  break;
2212  case 4:
2213  PICE_sprintf(tempCmd,"%s = %.8X\n",RegKeyWords[i].KeyWord,*(PULONG)(RegKeyWords[i].pValue));
2214  break;
2215  }
2216  Print(OUTPUT_WINDOW,tempCmd);
2217  break;
2218  }
2219  }
2220  }
2221  else if(pArgs->Count==2)
2222  {
2223  // set selected register to value
2224  for(i=0;RegKeyWords[i].pValue!=0;i++)
2225  {
2226  if(PICE_strcmpi(pArgs->pToken[0],RegKeyWords[i].KeyWord)==0)
2227  {
2228  switch(RegKeyWords[i].ulSize)
2229  {
2230  case 1:
2231  *(PUCHAR)(RegKeyWords[i].pValue)=(UCHAR)pArgs->Value[1];
2232  break;
2233  case 2:
2234  *(PUSHORT)(RegKeyWords[i].pValue)=(USHORT)pArgs->Value[1];
2235  break;
2236  case 4:
2237  *(PULONG)(RegKeyWords[i].pValue)=(ULONG)pArgs->Value[1];
2238  break;
2239  }
2240  DisplayRegs();
2241  RepaintSource();
2242  break;
2243  }
2244  }
2245  }
2246  return TRUE;
2247 }
2248 
2249 //*************************************************************************
2250 // SetCodeDisplay()
2251 //
2252 //*************************************************************************
2253 COMMAND_PROTOTYPE(SetCodeDisplay)
2254 {
2255  ARGS Args;
2256 
2257  if(pArgs->Count==0)
2258  {
2259  bCodeOn=bCodeOn?FALSE:TRUE;
2260 
2261  PICE_memset(&Args,0,sizeof(ARGS));
2262  Args.Count=0;
2263  // make unassembler refresh all again
2265  Unassemble(&Args);
2266  }
2267  else if(pArgs->Count==1)
2268  {
2269  bCodeOn=(pArgs->Value[0]==0)?FALSE:TRUE;
2270 
2271  PICE_memset(&Args,0,sizeof(ARGS));
2272  Args.Count=0;
2273  // make unassembler refresh all again
2275  Unassemble(&Args);
2276  }
2277  return TRUE;
2278 }
2279 
2280 //*************************************************************************
2281 // ShowCPU()
2282 //
2283 //*************************************************************************
2285 {
2286 ULONG i;
2287 
2288  for(i=0;CPUInfo[i].pValue!=NULL;i++)
2289  {
2290  PICE_sprintf(tempCmd,"%s = %.8X\n",CPUInfo[i].Name,*(CPUInfo[i].pValue));
2291  Print(OUTPUT_WINDOW,tempCmd);
2292  if(WaitForKey()==FALSE)break;
2293  }
2294  return TRUE;
2295 }
2296 
2297 //*************************************************************************
2298 // WalkStack()
2299 //
2300 //*************************************************************************
2302 {
2303  if(!pArgs->Count)
2304  {
2306  }
2307 
2308  return TRUE;
2309 }
2310 
2311 //*************************************************************************
2312 // PokeDword()
2313 //
2314 //*************************************************************************
2316 {
2317  ULONG ulData;
2318 
2319  // read old data
2320  ulData = ReadPhysMem(pArgs->Value[1],sizeof(ULONG));
2321  PICE_sprintf(tempCmd,"value @ %.8X was %.8X\n",pArgs->Value[1],ulData);
2322  Print(OUTPUT_WINDOW,tempCmd);
2323 
2324  // write new data
2325  WritePhysMem(pArgs->Value[1],pArgs->Value[2],sizeof(ULONG));
2326 
2327  // read check
2328  ulData = ReadPhysMem(pArgs->Value[1],sizeof(ULONG));
2329  PICE_sprintf(tempCmd,"value @ %.8X = %.8X\n",pArgs->Value[1],ulData);
2330  Print(OUTPUT_WINDOW,tempCmd);
2331 
2332  return TRUE;
2333 }
2334 
2335 //*************************************************************************
2336 // PokeMemory()
2337 //
2338 //*************************************************************************
2340 {
2341  DPRINT((0,"PokeMemory()\n"));
2342  DPRINT((0,"PokeMemory(): value[0] = %.8X value[1] = %.8X value[3] = %.8X count = %.8X\n",pArgs->Value[0],pArgs->Value[1],pArgs->Value[2],pArgs->Count));
2343 
2344  // must be three parameters
2345  if(pArgs->Count == 3)
2346  {
2347  switch(pArgs->Value[0])
2348  {
2349  case 4:
2350  return PokeDword(pArgs);
2351  default:
2352  case 1:
2353  case 2:
2354  break;
2355  }
2356  }
2357  else
2358  {
2359  Print(OUTPUT_WINDOW,"you need to supply a physical address and datum to write!\n");
2360  }
2361 
2362  return TRUE;
2363 }
2364 
2365 
2366 //*************************************************************************
2367 // PeekDword()
2368 //
2369 //*************************************************************************
2371 {
2372  ULONG ulData;
2373 
2374  ulData = ReadPhysMem(pArgs->Value[1],sizeof(ULONG));
2375  PICE_sprintf(tempCmd,"%.8X\n",ulData);
2376  Print(OUTPUT_WINDOW,tempCmd);
2377 
2378  return TRUE;
2379 }
2380 
2381 //*************************************************************************
2382 // PeekWord()
2383 //
2384 //*************************************************************************
2386 {
2387  USHORT usData;
2388 
2389  usData = (USHORT)ReadPhysMem(pArgs->Value[1],sizeof(USHORT));
2390  PICE_sprintf(tempCmd,"%.4X\n",usData);
2391  Print(OUTPUT_WINDOW,tempCmd);
2392 
2393  return TRUE;
2394 }
2395 
2396 //*************************************************************************
2397 // PeekByte()
2398 //
2399 //*************************************************************************
2401 {
2402  UCHAR ucData;
2403 
2404  ucData = (UCHAR)ReadPhysMem(pArgs->Value[1],sizeof(UCHAR));
2405  PICE_sprintf(tempCmd,"%.2X\n",ucData);
2406  Print(OUTPUT_WINDOW,tempCmd);
2407 
2408  return TRUE;
2409 }
2410 
2411 //*************************************************************************
2412 // PeekMemory()
2413 //
2414 //*************************************************************************
2416 {
2417  DPRINT((0,"PeekMemory()\n"));
2418  DPRINT((0,"PeekMemory(): value[0] = %.8X value[1] = %.8X count = %.8X\n",pArgs->Value[0],pArgs->Value[1],pArgs->Count));
2419 
2420  if(pArgs->Count == 2)
2421  {
2422  switch(pArgs->Value[0])
2423  {
2424  case 1:
2425  return PeekByte(pArgs);
2426  case 2:
2427  return PeekWord(pArgs);
2428  case 4:
2429  return PeekDword(pArgs);
2430  default:
2431  break;
2432  }
2433  }
2434 
2435  return TRUE;
2436 }
2437 
2438 //*************************************************************************
2439 // UnassembleAtCurrentEip()
2440 //
2441 //*************************************************************************
2442 COMMAND_PROTOTYPE(UnassembleAtCurrentEip)
2443 {
2444  PICE_memset(pArgs,0,sizeof(ARGS));
2445  pArgs->Count = 2;
2446  pArgs->Value[0] = CurrentCS;
2447  pArgs->Value[1] = CurrentEIP;
2448  Unassemble(pArgs);
2449  return TRUE;
2450 }
2451 
2452 //*************************************************************************
2453 // SwitchTables()
2454 //
2455 //*************************************************************************
2456 COMMAND_PROTOTYPE(SwitchTables)
2457 {
2458  ULONG i;
2459 
2460  DPRINT((0,"SwitchTables()\n"));
2461 
2462  // no arguments -> display load symbol tables
2463  if(!pArgs->Count)
2464  {
2465  for(i=0;i<DIM(apSymbols);i++)
2466  {
2467  if(apSymbols[i])
2468  {
2469  if(apSymbols[i] == pCurrentSymbols)
2470  PICE_sprintf(tempCmd,"*%-32S @ %.8X (%5u source files)\n",apSymbols[i]->name,(ULONG)apSymbols[i],apSymbols[i]->ulNumberOfSrcFiles);
2471  else
2472  PICE_sprintf(tempCmd," %-32S @ %.8X (%5u source files)\n",apSymbols[i]->name,(ULONG)apSymbols[i],apSymbols[i]->ulNumberOfSrcFiles);
2473  Print(OUTPUT_WINDOW,tempCmd);
2474  if(WaitForKey()==FALSE)break;
2475  }
2476  }
2477  }
2478  // 1 argument -> set new current symbols
2479  else if(pArgs->Count == 1)
2480  {
2481  PDEBUG_MODULE pTempMod;
2483 
2484  pCurrentSymbols = (PICE_SYMBOLFILE_HEADER*)pArgs->Value[0];
2485  CopyWideToAnsi( temp, pCurrentSymbols->name );
2486 
2487  DPRINT((0,"TableSwitchSym: pCurrentSymbols: %x, Name: %s\n", pCurrentSymbols, temp));
2488 
2489  pTempMod = IsModuleLoaded(temp);
2490  if( pTempMod )
2491  pCurrentMod = pTempMod;
2492  }
2493 
2494  return TRUE;
2495 }
2496 
2497 //*************************************************************************
2498 // SwitchFiles()
2499 //
2500 //*************************************************************************
2501 COMMAND_PROTOTYPE(SwitchFiles)
2502 {
2503  PICE_SYMBOLFILE_SOURCE* pSrc;
2504  ULONG i;
2505  LPSTR p;
2506 
2507  DPRINT((0,"SwitchFiles()\n"));
2508  // no arguments -> show files for current symbols
2509  if(!pArgs->Count)
2510  {
2511  if(pCurrentSymbols && pCurrentSymbols->ulNumberOfSrcFiles)
2512  {
2513  LPSTR pCurrentFile=NULL;
2514 
2515  // find out the current file name
2516  if(*szCurrentFile!=0)
2517  {
2518  if((pCurrentFile = strrchr(szCurrentFile,'/')) )
2519  {
2520  pCurrentFile++;
2521  }
2522  else
2523  {
2524  pCurrentFile = szCurrentFile;
2525  }
2526  }
2527 
2528  pSrc = (PICE_SYMBOLFILE_SOURCE*)((ULONG)pCurrentSymbols + pCurrentSymbols->ulOffsetToSrcFiles);
2529 
2530  for(i=0;i<pCurrentSymbols->ulNumberOfSrcFiles;i++)
2531  {
2532  if(pCurrentFile)
2533  {
2534  if((p = strrchr(pSrc->filename,'/')) )
2535  {
2536  if(PICE_strcmpi(p+1,pCurrentFile)==0)
2537  PICE_sprintf(tempCmd,"*%-32s @ %.8X\n",p+1,(ULONG)pSrc);
2538  else
2539  PICE_sprintf(tempCmd," %-32s @ %.8X\n",p+1,(ULONG)pSrc);
2540  }
2541  else
2542  {
2543  if(PICE_strcmpi(pSrc->filename,pCurrentFile)==0)
2544  PICE_sprintf(tempCmd,"*%-32s @ %.8X\n",pSrc->filename,(ULONG)pSrc);
2545  else
2546  PICE_sprintf(tempCmd," %-32s @ %.8X\n",pSrc->filename,(ULONG)pSrc);
2547  }
2548  }
2549  else
2550  {
2551  if((p = strrchr(pSrc->filename,'/')) )
2552  {
2553  PICE_sprintf(tempCmd,"%-32s @ %.8X\n",p+1,(ULONG)pSrc);
2554  }
2555  else
2556  {
2557  PICE_sprintf(tempCmd,"%-32s @ %.8X\n",pSrc->filename,(ULONG)pSrc);
2558  }
2559  }
2560  Print(OUTPUT_WINDOW,tempCmd);
2561 
2562  if(WaitForKey()==FALSE)break;
2563  (LPSTR)pSrc += pSrc->ulOffsetToNext;
2564  }
2565  }
2566  else
2567  Print(OUTPUT_WINDOW,"No source files available!\n");
2568  }
2569  // 1 argument -> argument is pointer PICE_SYMBOLFILE_SOURCE struct ->
2570  // set current file and show it
2571  else if(pArgs->Count == 1)
2572  {
2573  PICE_SYMBOLFILE_SOURCE* pSrc = (PICE_SYMBOLFILE_SOURCE*)pArgs->Value[0];
2574  LPSTR pFilename = pSrc->filename;
2575 
2577 
2578  if(PICE_strlen(pFilename)<GLOBAL_SCREEN_WIDTH/2)
2579  {
2580  PutChar(pFilename,1,wWindow[SOURCE_WINDOW].y-1);
2581  }
2582  else
2583  {
2584  LPSTR p;
2585 
2586  p = strrchr(pFilename,'/');
2587  if(!p)
2588  {
2589  p = pFilename;
2590  }
2591  else
2592  {
2593  p++;
2594  }
2595 
2596  PutChar(p,1,wWindow[SOURCE_WINDOW].y-1);
2597  }
2598 
2599  // set new current file
2600  PICE_strcpy(szCurrentFile,pFilename);
2601 
2603 
2605  (LPSTR)pSrc+pSrc->ulOffsetToNext,
2606  1,
2607  -1);
2608  }
2609 
2610  return TRUE;
2611 }
2612 
2613 //*************************************************************************
2614 // ShowLocals()
2615 //
2616 //*************************************************************************
2618 {
2620 
2621  if(pArgs->Count==0)
2622  {
2624  DPRINT((0,"ShowLocals: %x\n", p));
2625  if(p)
2626  {
2627  DPRINT((0,"ShowLocals: name %s, type_name %s\n", p->name, p->type_name));
2628  while(PICE_strlen(p->name))
2629  {
2630  if(!p->bRegister)
2631  {
2632  PICE_sprintf(tempCmd,"[EBP%.4d / #%u] %x %s %s \n",p->offset,p->line,p->value,p->type_name,p->name);
2633  }
2634  else
2635  {
2636  PICE_sprintf(tempCmd,"[%-8s / #%u] %x %s %s #%u\n",LocalVarRegs[p->offset],p->line,p->value,p->type_name,p->name);
2637  }
2638  Print(OUTPUT_WINDOW,tempCmd);
2639  p++;
2640  }
2641  }
2642  }
2643  return TRUE;
2644 }
2645 
2646 //*************************************************************************
2647 // ShowSymbols()
2648 //
2649 //*************************************************************************
2650 COMMAND_PROTOTYPE(ShowSymbols)
2651 {
2652  PICE_SYMBOLFILE_HEADER* pSymbols;
2653  ULONG index,addr;
2654  LPSTR pSearchString,pName,pFind;
2655 
2656  // no args -> list full symbols for current module
2657  if(!pArgs->Count)
2658  {
2659  // have current module ?
2660  if(pCurrentMod)
2661  {
2662  DPRINT((0,"ShowSymbols(): full listing of symbols for %S\n",pCurrentMod->name));
2663  addr = (ULONG)pCurrentMod->BaseAddress;
2664 
2665  if((pSymbols = FindModuleSymbols(addr)) )
2666  {
2667  PICE_sprintf(tempCmd,"symbols for module \"%S\"\n",pCurrentMod->name);
2668  Print(OUTPUT_WINDOW,tempCmd);
2669 
2670  index = 0;
2671  while((index = ListSymbolStartingAt(pCurrentMod,pSymbols,index,tempCmd)))
2672  {
2673  Print(OUTPUT_WINDOW,tempCmd);
2674  if(WaitForKey()==FALSE)break;
2675  }
2676  }
2677  }
2678  }
2679  // partial name
2680  else if(pArgs->Count == 1)
2681  {
2682  if(pCurrentMod)
2683  {
2684  addr = (ULONG)pCurrentMod->BaseAddress;
2685 
2686  if((pSymbols = FindModuleSymbols(addr)))
2687  {
2688  pSearchString = (LPSTR)pArgs->Value[0];
2689 
2690  PICE_sprintf(tempCmd,"symbols for module \"%S\" (searching for \"%s\")\n",pCurrentMod->name,pSearchString);
2691  Print(OUTPUT_WINDOW,tempCmd);
2692 
2693  if(pSearchString)
2694  {
2695  if(*pSearchString=='*' && pSearchString[PICE_strlen(pSearchString)-1]=='*')
2696  {
2697  pSearchString[PICE_strlen(pSearchString)-1] = 0;
2698  pSearchString++;
2699  index = 0;
2700  while((index = ListSymbolStartingAt(pCurrentMod,pSymbols,index,tempCmd)))
2701  {
2702  pName = strrchr(tempCmd,' ');
2703  pName++;
2704  pFind = strstr(pName,pSearchString);
2705  if(pFind)
2706  {
2707  Print(OUTPUT_WINDOW,tempCmd);
2708  if(WaitForKey()==FALSE)break;
2709  }
2710  }
2711  // TODO
2712  }
2713  else if(pSearchString[PICE_strlen(pSearchString)-1]=='*')
2714  {
2715  pSearchString[PICE_strlen(pSearchString)-1] = 0;
2716  index = 0;
2717 
2718  index = ListSymbolStartingAt(pCurrentMod,pSymbols,index,tempCmd);
2719  if(index)
2720  {
2721  do
2722  {
2723  pName = strrchr(tempCmd,' ');
2724  pName++;
2725  pFind = strstr(pName,pSearchString);
2726  if(pFind && (((ULONG)pName-(ULONG)pFind)==0) )
2727  {
2728  Print(OUTPUT_WINDOW,tempCmd);
2729  if(WaitForKey()==FALSE)break;
2730  }
2731  }while((index = ListSymbolStartingAt(pCurrentMod,pSymbols,index,tempCmd)));
2732  }
2733  }
2734  }
2735  }
2736  }
2737  }
2738 
2739  return TRUE;
2740 }
2741 
2742 //*************************************************************************
2743 // EvaluateExpression()
2744 //
2745 //*************************************************************************
2747 {
2748  PICE_SYMBOLFILE_HEADER* pSymbols;
2749  ULONG addr;
2750 
2751  if(pArgs->Count == 1)
2752  {
2753  if(pCurrentMod)
2754  {
2755  addr = (ULONG)pCurrentMod->BaseAddress;
2756 
2757  if( (pSymbols = FindModuleSymbols(addr) ) )
2758  {
2759  DPRINT((0,"EvaluateExpression: %s\n", (LPSTR)pArgs->Value[0]));
2760  Evaluate(pSymbols,(LPSTR)pArgs->Value[0]);
2761  }
2762  }
2763  }
2764  return TRUE;
2765 }
2766 
2767 //*************************************************************************
2768 // SizeCodeWindow()
2769 //
2770 //*************************************************************************
2771 COMMAND_PROTOTYPE(SizeCodeWindow)
2772 {
2773  ULONG NewHeight,TotalHeight;
2774 
2775  if(pArgs->Count == 1)
2776  {
2777  NewHeight = pArgs->Value[0];
2778 
2779  TotalHeight = wWindow[SOURCE_WINDOW].cy +
2781 
2782  if(NewHeight < TotalHeight)
2783  {
2784  if(wWindow[SOURCE_WINDOW].cy != NewHeight)
2785  {
2786  wWindow[SOURCE_WINDOW].cy = NewHeight;
2788  wWindow[OUTPUT_WINDOW].cy = TotalHeight - NewHeight;
2789 
2790  RepaintDesktop();
2791  }
2792  }
2793  }
2794  else
2795  {
2796  PICE_sprintf(tempCmd,"code window at position %u has %u lines \n",wWindow[SOURCE_WINDOW].y,wWindow[SOURCE_WINDOW].cy);
2797  Print(OUTPUT_WINDOW,tempCmd);
2798  }
2799 
2800  return TRUE;
2801 }
2802 
2803 //*************************************************************************
2804 // SizeDataWindow()
2805 //
2806 //*************************************************************************
2807 COMMAND_PROTOTYPE(SizeDataWindow)
2808 {
2809  ULONG NewHeight,TotalHeight;
2810 
2811  if(pArgs->Count)
2812  {
2813  NewHeight = pArgs->Value[0];
2814 
2815  TotalHeight = wWindow[DATA_WINDOW].cy +
2817 
2818  if(NewHeight < TotalHeight)
2819  {
2820  if(wWindow[DATA_WINDOW].cy != NewHeight)
2821  {
2822  wWindow[DATA_WINDOW].cy = NewHeight;
2824  wWindow[SOURCE_WINDOW].cy = TotalHeight - NewHeight;
2825 
2826  RepaintDesktop();
2827  }
2828  }
2829  }
2830  else
2831  {
2832  PICE_sprintf(tempCmd,"data window has %u lines \n",wWindow[DATA_WINDOW].cy);
2833  Print(OUTPUT_WINDOW,tempCmd);
2834  }
2835 
2836  return TRUE;
2837 }
2838 
2839 //*************************************************************************
2840 // ClearScreen()
2841 //
2842 //*************************************************************************
2844 {
2845  EmptyRingBuffer();
2846 
2848  CheckRingBuffer();
2849 
2850  return TRUE;
2851 }
2852 
2853 //*************************************************************************
2854 // ShowMappings()
2855 //
2856 //*************************************************************************
2857 COMMAND_PROTOTYPE(ShowMappings)
2858 {
2859 #if 0
2860  ULONG ulPageDir;
2861  ULONG ulPageTable;
2862  ULONG address;
2863  ULONG phys_addr;
2864  pgd_t * pPGD;
2865  pmd_t * pPMD;
2866  pte_t * pPTE;
2867  struct mm_struct* p = NULL;
2868  struct task_struct* my_current = (struct task_struct*)0xFFFFE000;
2869 
2870  DPRINT((0,"ShowMappings()\n"));
2871 
2872  if(pArgs->Count == 1)
2873  {
2874  // We're in DebuggerShell(), so we live on a different stack
2875  (ULONG)my_current &= ulRealStackPtr;
2876 
2877  // in case we have a user context we use it's mm_struct
2878  if(my_current->mm)
2879  {
2880  p = my_current->mm;
2881  }
2882  // no user context -> use kernel's context
2883  else
2884  {
2885  p = my_init_mm;
2886  }
2887 
2888  // get the requested address from arguments
2889  phys_addr = pArgs->Value[0];
2890 
2891  DPRINT((0,"ShowMappings(): p = %X phys_addr = %X\n",(ULONG)p,phys_addr));
2892 
2893  // for every page directory
2894  for(ulPageDir=0;ulPageDir<1024;ulPageDir++)
2895  {
2896  address = (ulPageDir<<22);
2897 
2898  // get the page directory for the address
2899  pPGD = pgd_offset(p,address);
2900  // if page dir present
2901  if(pPGD && pgd_val(*pPGD)&_PAGE_PRESENT)
2902  {
2903  DPRINT((0,"ShowMappings(): page directory present for %x\n",address));
2904  // not large page
2905  if(!(pgd_val(*pPGD)&_PAGE_4M))
2906  {
2907  DPRINT((0,"ShowMappings(): page directory for 4k pages\n"));
2908  for(ulPageTable=0;ulPageTable<1024;ulPageTable++)
2909  {
2910  address = (ulPageDir<<22)|(ulPageTable<<12);
2911 
2912  pPMD = pmd_offset(pPGD,address);
2913  if(pPMD)
2914  {
2915  pPTE = pte_offset(pPMD,address);
2916  if(pPTE)
2917  {
2918  if(*(PULONG)pPTE & _PAGE_PRESENT)
2919  {
2920  ULONG ulPte = *(PULONG)pPTE & 0xFFFFF000;
2921 
2922  if(ulPte == (phys_addr & 0xFFFFF000))
2923  {
2924  PICE_sprintf(tempCmd,"%.8X\n",address+(phys_addr&0xFFF));
2925  Print(OUTPUT_WINDOW,tempCmd);
2926  if(WaitForKey()==FALSE)return TRUE;
2927  }
2928  }
2929  }
2930  }
2931  }
2932  }
2933  // large page
2934  else
2935  {
2936  address = (ulPageDir<<22);
2937  if((pgd_val(*pPGD)&0xFFC00000) == (phys_addr & 0xFFC00000) )
2938  {
2939  if( ((address|(phys_addr&0x7FFFFF))&~TASK_SIZE) == phys_addr)
2940  PICE_sprintf(tempCmd,"%.8X (identity map %.8X+%.8X)\n",address|(phys_addr&0x7FFFFF),TASK_SIZE,phys_addr);
2941  else
2942  PICE_sprintf(tempCmd,"%.8X\n",address|(phys_addr&0x7FFFFF));
2943  Print(OUTPUT_WINDOW,tempCmd);
2944  if(WaitForKey()==FALSE)return TRUE;
2945  }
2946  }
2947  }
2948  }
2949  }
2950 #endif
2951  PICE_sprintf(tempCmd,"Not implemented yet!\n");
2952  Print(OUTPUT_WINDOW,tempCmd);
2953  return TRUE;
2954 }
2955 
2956 //*************************************************************************
2957 // ShowTimers()
2958 //
2959 //*************************************************************************
2961 {
2962 
2963  return TRUE;
2964 }
2965 
2966 //*************************************************************************
2967 // FindPCIVendorName()
2968 //
2969 //*************************************************************************
2971 {
2972  ULONG i;
2973 
2974  for(i=0;i<DIM(PCIVendorIDs);i++)
2975  {
2976  if(vendorid == PCIVendorIDs[i].vendorid)
2977  return PCIVendorIDs[i].vendor_name;
2978  }
2979 
2980  return NULL;
2981 }
2982 
2983 //*************************************************************************
2984 // ShowPCI()
2985 //
2986 //*************************************************************************
2988 {
2989  ULONG oldCF8,data,bus,dev,reg,i,ulNumBaseAddresses,bus_req=0,dev_req=0;
2990  PCI_NUMBER pciNumber;
2991  PCI_COMMON_CONFIG pciConfig,*ppciConfig;
2992  PULONG p;
2993  LPSTR pVendorName;
2994  char temp[32];
2995  BOOLEAN bShowAll = FALSE,bUseDev=TRUE,bUseBus=TRUE;
2996 
2997 
2998  DPRINT((0,"ShowPCI()\n"));
2999 
3000  if(pArgs->CountSwitches>1)
3001  return TRUE;
3002 
3003  if(pArgs->CountSwitches==1)
3004  {
3005  if(pArgs->Switch[0] == 'a')
3006  bShowAll = TRUE;
3007  }
3008 
3009  if(pArgs->Count < 3)
3010  {
3011  if(pArgs->Count > 0)
3012  {
3013  bUseBus = FALSE;
3014  bus_req = pArgs->Value[0];
3015  }
3016  if(pArgs->Count > 1)
3017  {
3018  bUseDev = FALSE;
3019  dev_req = pArgs->Value[1];
3020  }
3021 
3022  // save old config space selector
3023  oldCF8 = inl((PULONG)0xcf8);
3024 
3025  for(bus=0;bus<256;bus++)
3026  {
3027  for(dev=0;dev<32;dev++)
3028  {
3029  if(!((bUseDev || dev == dev_req) &&
3030  (bUseBus || bus == bus_req) ))
3031  continue;
3032 
3033  pciNumber.u.AsUlong = 0;
3034  pciNumber.u.bits.dev = dev;
3035  pciNumber.u.bits.bus = bus;
3036  pciNumber.u.bits.func = 0;
3037  pciNumber.u.bits.ce = 1;
3038  outl(pciNumber.u.AsUlong,(PULONG)0xcf8);
3039  data = inl((PULONG)0xcfc);
3040 
3041  if(data != 0xFFFFFFFF) // valid device
3042  {
3043  if((pVendorName = FindPCIVendorName((USHORT)data)) )
3044  {
3045  PICE_sprintf(tempCmd,"Bus%-8uDev%-8u === %.4X %.4X %s ====\n",bus,dev,(USHORT)data,(USHORT)(data>>16),pVendorName);
3046  }
3047  else
3048  {
3049  PICE_sprintf(tempCmd,"Bus%-8uDev%-8u === %.4X %.4X N/A ====\n",bus,dev,(USHORT)data,(USHORT)(data>>16));
3050  }
3051  Print(OUTPUT_WINDOW,tempCmd);
3052  if(WaitForKey()==FALSE)goto CommonShowPCIExit;
3053 
3054  p = (PULONG)&pciConfig;
3055  for(reg=0;reg<sizeof(PCI_COMMON_CONFIG)/sizeof(ULONG);reg++)
3056  {
3057  pciNumber.u.AsUlong = 0;
3058  pciNumber.u.bits.dev = dev;
3059  pciNumber.u.bits.bus = bus;
3060  pciNumber.u.bits.func = 0;
3061  pciNumber.u.bits.reg = reg;
3062  pciNumber.u.bits.ce = 1;
3063 
3064  outl(pciNumber.u.AsUlong,(PULONG)0xcf8);
3065  *p++ = inl((PULONG)0xcfc);
3066  }
3067  PICE_sprintf(tempCmd,"SubVendorId %.4X SubSystemId %.4X\n",pciConfig.u.type0.SubVendorID,pciConfig.u.type0.SubSystemID);
3068  Print(OUTPUT_WINDOW,tempCmd);
3069  if(WaitForKey()==FALSE)goto CommonShowPCIExit;
3070 
3071  if(bShowAll)
3072  {
3073  for(ulNumBaseAddresses=0,i=0;i<6;i++)
3074  {
3075  if(pciConfig.u.type0.BaseAddresses[i] != 0)
3076  ulNumBaseAddresses++;
3077  }
3078  if(ulNumBaseAddresses)
3079  {
3080  Print(OUTPUT_WINDOW,"BaseAddresses:");
3081  tempCmd[0] = 0;
3082  for(i=0;i<6;i++)
3083  {
3084  if(pciConfig.u.type0.BaseAddresses[i] != 0)
3085  {
3086  PICE_sprintf(temp," %u:%.8X",i,pciConfig.u.type0.BaseAddresses[i]);
3087  PICE_strcat(tempCmd,temp);
3088  }
3089  }
3090  Print(OUTPUT_WINDOW,tempCmd);
3091  Print(OUTPUT_WINDOW,"\n");
3092  if(WaitForKey()==FALSE)goto CommonShowPCIExit;
3093  }
3094  ppciConfig = &pciConfig;
3095  #if 0
3096  // sedwards
3097  SHOW_FIELD_WORD(ppciConfig,Status,TRUE);
3098  SHOW_FIELD_WORD(ppciConfig,Command,TRUE);
3099  SHOW_FIELD_BYTE(ppciConfig,RevisionID,TRUE);
3100  SHOW_FIELD_BYTE(ppciConfig,ProgIf,TRUE);
3101  SHOW_FIELD_BYTE(ppciConfig,BaseClass,TRUE);
3102  SHOW_FIELD_BYTE(ppciConfig,SubClass,TRUE);
3103  SHOW_FIELD_BYTE(ppciConfig,CacheLineSize,TRUE);
3104  SHOW_FIELD_BYTE(ppciConfig,LatencyTimer,TRUE);
3105  #endif
3106  }
3107  }
3108  }
3109  }
3110 
3111 CommonShowPCIExit:
3112  // restore old config space selector
3113  outl(oldCF8,(PULONG)0xcf8);
3114 
3115  }
3116  else if(pArgs->Count == 1)
3117  {
3118  }
3119 
3120  return TRUE;
3121 }
3122 
3123 //*************************************************************************
3124 // SetKeyboardLayout()
3125 //
3126 //*************************************************************************
3128 {
3130 
3131  ENTER_FUNC();
3132 
3133  layout = GetKeyboardLayout();
3134 
3135  switch(pArgs->Count)
3136  {
3137  case 0:
3138  PICE_sprintf(tempCmd,"current layout = %s\n", layout->name);
3139  Print(OUTPUT_WINDOW,tempCmd);
3140  break;
3141  case 1:
3142  layout = SetKeyboardLayoutByName((LPSTR)pArgs->Value[0]);
3143  PICE_sprintf(tempCmd,"current layout = %s\n", layout->name);
3144  Print(OUTPUT_WINDOW,tempCmd);
3145  break;
3146  }
3147 
3148  LEAVE_FUNC();
3149 
3150  return TRUE;
3151 }
3152 
3153 //*************************************************************************
3154 // ShowSysCallTable()
3155 //
3156 //*************************************************************************
3157 COMMAND_PROTOTYPE(ShowSysCallTable)
3158 {
3159 #if 0
3160  LPSTR pName;
3161  ULONG i;
3162 
3163  ENTER_FUNC();
3164 
3165  if(pArgs->Count == 0)
3166  {
3167  PICE_sprintf(tempCmd,"%u system calls\n",190);
3168  Print(OUTPUT_WINDOW,tempCmd);
3169  if(WaitForKey()!=FALSE)
3170  for(i=0;i<190;i++)
3171  {
3172  if((pName = FindFunctionByAddress(sys_call_table[i],NULL,NULL)) )
3173  {
3174  PICE_sprintf(tempCmd,"%-.3u: %.8X (%s)\n",i,sys_call_table[i],pName);
3175  }
3176  else
3177  {
3178  PICE_sprintf(tempCmd,"%-.3u: %.8X (%s)\n",i,sys_call_table[i],pName);
3179  }
3180  Print(OUTPUT_WINDOW,tempCmd);
3181  if(WaitForKey()==FALSE)
3182  break;
3183  }
3184  }
3185  else if(pArgs->Count == 1)
3186  {
3187  i = pArgs->Value[0];
3188  if(i<190)
3189  {
3190  if((pName = FindFunctionByAddress(sys_call_table[i],NULL,NULL)) )
3191  {
3192  PICE_sprintf(tempCmd,"%-.3u: %.8X (%s)\n",i,sys_call_table[i],pName);
3193  }
3194  else
3195  {
3196  PICE_sprintf(tempCmd,"%-.3u: %.8X (%s)\n",i,sys_call_table[i],pName);
3197  }
3198  Print(OUTPUT_WINDOW,tempCmd);
3199  }
3200  }
3201 
3202  LEAVE_FUNC();
3203 #endif
3204  PICE_sprintf(tempCmd,"Not implemented yet!\n");
3205  Print(OUTPUT_WINDOW,tempCmd);
3206  return TRUE;
3207 }
3208 
3209 //*************************************************************************
3210 // SetAltKey()
3211 //
3212 //*************************************************************************
3214 {
3215  if(pArgs->Count == 1)
3216  {
3217  ucBreakKey = (UCHAR)pArgs->Value[0];
3218 
3219  PICE_sprintf(tempCmd,"new break key is CTRL-%c\n",ucBreakKey);
3220  Print(OUTPUT_WINDOW,tempCmd);
3221  }
3222  else if(pArgs->Count == 0)
3223  {
3224  PICE_sprintf(tempCmd,"current break key is CTRL-%c\n",ucBreakKey);
3225  Print(OUTPUT_WINDOW,tempCmd);
3226  }
3227 
3228 
3229  COMMAND_RET;
3230 }
3231 
3232 //*************************************************************************
3233 // ShowContext()
3234 //
3235 //*************************************************************************
3236 COMMAND_PROTOTYPE(ShowContext)
3237 {
3238  COMMAND_RET;
3239 }
3240 
3241 //*************************************************************************
3242 //
3243 // utility functions for parsing
3244 //
3245 //*************************************************************************
3246 
3247 
3248 //*************************************************************************
3249 // FindCommand()
3250 //
3251 //*************************************************************************
3253 {
3254  ULONG i,j,k=0;
3255  LPSTR result=NULL;
3256 
3257  tempCmd[0]=0;
3258  for(j=0,i=0;CmdTable[i].Cmd!=NULL;i++)
3259  {
3260  if(PICE_strncmpi(CmdTable[i].Cmd,p,PICE_strlen(p)) == 0 &&
3261  CmdTable[i].CommandGroup != COMMAND_GROUP_HELP_ONLY)
3262  {
3263  if(PICE_strlen(tempCmd))
3264  PICE_strcat(tempCmd,", ");
3265  PICE_strcat(tempCmd,CmdTable[i].Cmd);
3266  j++;
3267  k=i;
3268  }
3269  }
3270  if(PICE_strlen(tempCmd))
3271  {
3276  if(j==1)
3277  {
3278  PICE_sprintf(tempCmd,"%s",CmdTable[k].Help);
3280  result=CmdTable[k].Cmd;
3281  }
3282  ResetColor();
3283  }
3284  return result;
3285 }
3286 
3287 
3288 //*************************************************************************
3289 // CompactString()
3290 //
3291 //*************************************************************************
3293 {
3294 ULONG i;
3295 
3296  for(i=1;i<PICE_strlen(p);i++)
3297  {
3298  if(p[i]==' ' && p[i-1]==' ')
3299  {
3300  PICE_strcpy(&p[i-1],&p[i]);
3301  i=1;
3302  }
3303  }
3304 }
3305 
3306 //*************************************************************************
3307 // PICE_strtok()
3308 //
3309 //*************************************************************************
3310 char* PICE_strtok(char *szInputString)
3311 {
3312 static char* szCurrString;
3313 char *szTempString;
3314 ULONG currlength;
3315 ULONG i;
3316 
3317  if(szInputString)
3318  {
3319  szCurrString=szInputString;
3320  CompactString(szCurrString);
3321  }
3322 
3323  currlength=PICE_strlen(szCurrString);
3324  if(!currlength)
3325  {
3326  szCurrString=0;
3327  return NULL;
3328  }
3329  for(i=0;i<currlength;i++)
3330  {
3331  if(szCurrString[i]==' ')
3332  {
3333  szCurrString[i]=0;
3334  break;
3335  }
3336  }
3337  szTempString=szCurrString;
3338  szCurrString=szCurrString+i+1;
3339  return szTempString;
3340 }
3341 
3342 //*************************************************************************
3343 // ConvertTokenToHex()
3344 //
3345 //*************************************************************************
3347 {
3348 ULONG result=0,i;
3349 
3350  gCurrentSelector=0;
3351  gCurrentOffset=0;
3352  for(i=0;i<8 && p[i]!=0 && p[i]!=' ' && p[i]!=':';i++)
3353  {
3354  if(p[i]>='0' && p[i]<='9')
3355  {
3356  result<<=4;
3357  result|=(ULONG)(UCHAR)(p[i]-'0');
3358  }
3359  else if(p[i]>='A' && p[i]<='F')
3360  {
3361  result<<=4;
3362  result|=(ULONG)(UCHAR)(p[i]-'A'+10);
3363  }
3364  else if(p[i]>='a' && p[i]<='f')
3365  {
3366  result<<=4;
3367  result|=(ULONG)(UCHAR)(p[i]-'a'+10);
3368  }
3369  else
3370  return FALSE;
3371  }
3372  p+=(i+1);
3373  if(p[i]==':')
3374  {
3375  ULONG ulSelector=result;
3376  if(ulSelector>0xFFFF)
3377  return FALSE;
3378  for(i=0;i<8 && p[i]!=0 && p[i]!=' ' && p[i]!=':';i++)
3379  {
3380  if(p[i]>='0' && p[i]<='9')
3381  {
3382  result<<=4;
3383  result|=(ULONG)(UCHAR)(p[i]-'0');
3384  }
3385  else if(p[i]>='A' && p[i]<='F')
3386  {
3387  result<<=4;
3388  result|=(ULONG)(UCHAR)(p[i]-'A'+10);
3389  }
3390  else if(p[i]>='a' && p[i]<='f')
3391  {
3392  result<<=4;
3393  result|=(ULONG)(UCHAR)(p[i]-'a'+10);
3394  }
3395  else
3396  return FALSE;
3397  }
3398  gCurrentSelector=(USHORT)ulSelector;
3400  result = GetLinearAddress((USHORT)ulSelector,result);
3401  }
3402  *pValue=result;
3403  return TRUE;
3404 }
3405 
3406 //*************************************************************************
3407 // ConvertTokenToDec()
3408 //
3409 //*************************************************************************
3411 {
3412  ULONG result=0;
3413  char c;
3414 
3415  while((c = *p))
3416  {
3417  if(c >= '0' && c <= '9')
3418  {
3419  result *= 10;
3420  result += (ULONG)(c - '0');
3421  }
3422  else
3423  return FALSE;
3424 
3425  p++;
3426  }
3427  *pValue = result;
3428  return TRUE;
3429 }
3430 
3431 //*************************************************************************
3432 // ConvertTokenToSymbol()
3433 //
3434 //*************************************************************************
3436 {
3437  LPSTR pEx;
3438  char temp[64];
3439  LPSTR p;
3440  PDEBUG_MODULE pModFound;
3441 
3442  DPRINT((0,"ConvertTokenToSymbol()\n"));
3443 
3444  PICE_strcpy(temp,pToken);
3445  p = temp;
3446 
3447  // test for module!symbol string
3448  pEx = PICE_strchr(p,'!');
3449  if(pEx)
3450  {
3451  DPRINT((0,"ConvertTokenToSymbol(): module!symbol syntax detected\n"));
3452  // terminate module name
3453  *pEx = 0;
3454  // now we have two pointers
3455  pEx++;
3456  DPRINT((0,"ConvertTokenToSymbol(): module = %s symbol = %s\n",p,pEx));
3457 
3458  if( pModFound=IsModuleLoaded(p) )
3459  {
3460  if((*pValue = FindFunctionInModuleByName(pEx,pModFound)))
3461  return TRUE;
3462  }
3463  }
3464  else
3465  {
3466  if(pCurrentMod)
3467  {
3468  if((*pValue = FindFunctionInModuleByName(p,pCurrentMod)))
3469  return TRUE;
3470  }
3471  return ScanExports(p,pValue);
3472  }
3473  return FALSE;
3474 }
3475 
3476 //*************************************************************************
3477 // ConvertTokenToModuleAndName()
3478 //
3479 //*************************************************************************
3480 BOOLEAN ConvertTokenToModuleAndName(LPSTR pToken,PULONG pulModuleName,PULONG pulFunctionName)
3481 {
3482  LPSTR pEx;
3483  char temp[64];
3484  LPSTR p;
3485  static char module_name[128];
3486  static char function_name[128];
3487 
3488  // test for module!symbol string
3489  PICE_strcpy(temp,pToken);
3490  p = temp;
3491 
3492  DPRINT((0,"ConvertTokenToModuleAndName(%s)\n",p));
3493 
3494  pEx = PICE_strchr(p,'!');
3495  if(pEx)
3496  {
3497  DPRINT((0,"ConvertTokenToModuleAndName(): module!symbol syntax detected\n"));
3498  // terminate module name
3499  *pEx = 0;
3500  // now we have two pointers
3501  pEx++;
3502  DPRINT((0,"ConvertTokenToModuleAndName(): module = %s symbol = %s\n",p,pEx));
3503  PICE_strcpy(module_name,p);
3504  PICE_strcpy(function_name,pEx);
3505  *pulModuleName = (ULONG)module_name;
3506  *pulFunctionName = (ULONG)function_name;
3507  return TRUE;
3508 
3509  }
3510  return FALSE;
3511 }
3512 
3513 //*************************************************************************
3514 // ConvertTokenToModule()
3515 //
3516 // convert an argument module name to a pointer to the module's symbols
3517 //*************************************************************************
3519 {
3520  ULONG i;
3522 
3523  for(i=0;i<DIM(apSymbols);i++)
3524  {
3525  if(apSymbols[i])
3526  {
3527  CopyWideToAnsi(temp,apSymbols[i]->name);
3528  if(PICE_strcmpi(p,temp)==0)
3529  {
3530  *pValue = (ULONG)apSymbols[i];
3531  return TRUE;
3532  }
3533  }
3534  }
3535 
3536  for(i=0;i<DIM(apSymbols);i++)
3537  {
3538  if(apSymbols[i])
3539  {
3540  CopyWideToAnsi(temp,apSymbols[i]->name);
3541  if(PICE_strncmpi(temp,p,PICE_strlen(p))==0)
3542  {
3543  *pValue = (ULONG)apSymbols[i];
3544  return TRUE;
3545  }
3546  }
3547  }
3548 
3549  return FALSE;
3550 }
3551 
3552 //*************************************************************************
3553 // ConvertTokenToProcess()
3554 //
3555 //*************************************************************************
3557 {
3558  return FALSE;
3559 }
3560 
3561 //*************************************************************************
3562 // ReplaceKeywordWithValue()
3563 //
3564 //*************************************************************************
3566 {
3567  ULONG i;
3568 
3569  for(i=0;pKeyWords[i].KeyWord!=NULL;i++)
3570  {
3571  if(PICE_strcmpi(p,pKeyWords[i].KeyWord)==0)
3572  {
3573  switch(pKeyWords[i].ulSize)
3574  {
3575  case sizeof(USHORT):
3576  *pValue=(ULONG)*(PUSHORT)(pKeyWords[i].pValue);
3577  break;
3578  case sizeof(ULONG):
3579  *pValue=*(PULONG)(pKeyWords[i].pValue);
3580  break;
3581  }
3582  return TRUE;
3583  }
3584  }
3585  return FALSE;
3586 }
3587 
3588 //*************************************************************************
3589 // ConvertTokenToKeyword()
3590 //
3591 //*************************************************************************
3593 {
3594  char Name[256];
3595  ULONG count;
3596 
3597  DPRINT((0,"ConvertTokenToKeyword()\n"));
3598  count=StrLenUpToWhiteChar(p," ");
3599  PICE_strncpy(Name,p,count);
3600  Name[count]=0;
3601  if(ReplaceKeywordWithValue(Name,pValue,RegKeyWords))
3602  {
3603  DPRINT((0,"ConvertTokenToKeyword(): success\n"));
3604  return TRUE;
3605  }
3606  return FALSE;
3607 }
3608 
3609 //*************************************************************************
3610 // ConvertTokenToSpecialKeyword()
3611 //
3612 //*************************************************************************
3614 {
3615  char Name[256];
3616  ULONG count;
3617 
3618  count=StrLenUpToWhiteChar(p," ");
3619  PICE_strncpy(Name,p,count);
3620  Name[count]=0;
3621  if(ReplaceKeywordWithValue(Name,pValue,SpecialKeyWords))
3622  {
3623  return TRUE;
3624  }
3625  return FALSE;
3626 }
3627 
3628 //*************************************************************************
3629 // ConvertTokenToOnOff()
3630 //
3631 //*************************************************************************
3633 {
3634  char Name[256];
3635  ULONG count;
3636 
3637  count=StrLenUpToWhiteChar(p," ");
3638  PICE_strncpy(Name,p,count);
3639  Name[count]=0;
3640  if(ReplaceKeywordWithValue(Name,pValue,OnOffKeyWords))
3641  {
3642  return TRUE;
3643  }
3644  return FALSE;
3645 }
3646 
3647 //*************************************************************************
3648 // ConvertSizeToKeyword()
3649 //
3650 //*************************************************************************
3652 {
3653  ULONG count;
3654 
3655  count=StrLenUpToWhiteChar(p," ");
3656  if(count > 1)
3657  return FALSE;
3658 
3659  switch(*p)
3660  {
3661  // BYTE
3662  case 'b':
3663  case 'B':
3664  *pValue = 1;
3665  break;
3666  // WORD
3667  case 'w':
3668  case 'W':
3669  *pValue = 2;
3670  break;
3671  // DWORD
3672  case 'd':
3673  case 'D':
3674  *pValue = 4;
3675  break;
3676  // QWORD
3677  case 'q':
3678  case 'Q':
3679  *pValue = 4;
3680  break;
3681  default:
3682  return FALSE;
3683  }
3684 
3685  return TRUE;
3686 }
3687 
3688 
3689 //*************************************************************************
3690 // ConvertTokenToSrcFile()
3691 //
3692 //*************************************************************************
3694 {
3695  PICE_SYMBOLFILE_SOURCE* pSrc;
3696  LPSTR pFilename,pFilenameSrc;
3697  ULONG i;
3698 
3699  DPRINT((0,"ConvertTokenToSrcFile(%s)\n",p));
3700 
3701  if(pCurrentSymbols && pCurrentSymbols->ulNumberOfSrcFiles)
3702  {
3703  DPRINT((0,"ConvertTokenToSrcFile(): current symbols for %S\n",pCurrentSymbols->name));
3704 
3705  pSrc = (PICE_SYMBOLFILE_SOURCE*)((ULONG)pCurrentSymbols + pCurrentSymbols->ulOffsetToSrcFiles);
3706 
3707  for(i=0;i<pCurrentSymbols->ulNumberOfSrcFiles;i++)
3708  {
3709  pFilename = strrchr(pSrc->filename,'/');
3710  if(!pFilename)
3711  pFilename = pSrc->filename;
3712  else
3713  pFilename++;
3714 
3715  pFilenameSrc = strrchr(p,'/');
3716  if(!pFilenameSrc )
3717  pFilenameSrc = p;
3718  else
3719  pFilenameSrc++;
3720 
3721  DPRINT((0,"ConvertTokenToSrcFile(): %s\n",pFilename));
3722 
3723  if(PICE_strcmpi(pFilename,pFilenameSrc) == 0)
3724  {
3725  DPRINT((0,"ConvertTokenToSrcFile(): found %s\n",pFilename));
3726 
3727  *pValue = (ULONG)pSrc;
3728  return TRUE;
3729  }
3730 
3731  // go to next file
3732  (LPSTR)pSrc += pSrc->ulOffsetToNext;
3733  }
3734 
3735  pSrc = (PICE_SYMBOLFILE_SOURCE*)((ULONG)pCurrentSymbols + pCurrentSymbols->ulOffsetToSrcFiles);
3736 
3737  // if not found now do a lookup for partials
3738  for(i=0;i<pCurrentSymbols->ulNumberOfSrcFiles;i++)
3739  {
3740  pFilename = strrchr(pSrc->filename,'/');
3741  if(!pFilename)
3742  pFilename = pSrc->filename;
3743  else
3744  pFilename++;
3745 
3746  DPRINT((0,"ConvertTokenToSrcFile(): %s\n",pFilename));
3747 
3748  if(PICE_strncmpi(pFilename,p,PICE_strlen(p)) == 0)
3749  {
3750  DPRINT((0,"ConvertTokenToSrcFile(): found %s\n",pFilename));
3751 
3752  *pValue = (ULONG)pSrc;
3753  return TRUE;
3754  }
3755 
3756  // go to next file
3757  (LPSTR)pSrc += pSrc->ulOffsetToNext;
3758  }
3759 
3760  }
3761  return FALSE;
3762 }
3763 
3764 //*************************************************************************
3765 // ConvertTokenToLineNumber()
3766 //
3767 //*************************************************************************
3769 {
3770  ULONG ulDecimal;
3771 
3772  DPRINT((0,"ConvertTokenToLineNumber()\n"));
3773  if(*p++ == '.')
3774  {
3775  ulDecimal = ExtractNumber(p);
3776  DPRINT((0,"ConvertTokenToLineNumber(): ulDecimal = %u\n",ulDecimal));
3777  if(ulDecimal)
3778  {
3779  DPRINT((0,"ConvertTokenToLineNumber(): current file = %s\n",szCurrentFile));
3780  if(pCurrentMod && PICE_strlen(szCurrentFile))
3781  {
3782  DPRINT((0,"ConvertTokenToLineNumber(): current file %S\n",pCurrentMod->name));
3783  if(FindAddressForSourceLine(ulDecimal,szCurrentFile,pCurrentMod,pValue))
3784  {
3785  DPRINT((0,"ConvertTokenToLineNumber(): value = %x\n",*pValue));
3786  return TRUE;
3787  }
3788  }
3789  }
3790  }
3791 
3792  return FALSE;
3793 }
3794 
3795 
3796 //*************************************************************************
3797 // IsWhiteChar()
3798 //
3799 //*************************************************************************
3800 BOOLEAN IsWhiteChar(char c,LPSTR WhiteChars)
3801 {
3802  USHORT lenWhiteChar = PICE_strlen(WhiteChars);
3803  USHORT i;
3804  for(i=0;i<lenWhiteChar;i++)
3805  {
3806  if(c == WhiteChars[i])
3807  return TRUE;
3808  }
3809  return FALSE;
3810 }
3811 
3812 //*************************************************************************
3813 // StrLenUpToWhiteChar()
3814 //
3815 //*************************************************************************
3817 {
3818  ULONG i;
3819 
3820  for(i=0;p[i]!=0 && !IsWhiteChar(p[i],WhiteChars);i++);
3821 
3822  return i;
3823 }
3824 
3825 //
3826 // command line parser
3827 //
3828 void Parse(LPSTR pCmdLine,BOOLEAN bInvokedByFkey)
3829 {
3830  ULONG i,j;
3832  char *pToken;
3833  ARGS Arguments;
3834  CMDTABLE *pCurrentCommand=NULL;
3835 
3836  ulCountForWaitKey = 0;
3837 
3838  if(!bInvokedByFkey)
3839  {
3841  }
3842 
3843  PICE_memset(&Arguments,0,sizeof(ARGS));
3844 
3845  for(j=0,i=0;CmdTable[i].Cmd!=NULL;i++)
3846  {
3847  if(PICE_strncmpi(CmdTable[i].Cmd,pCmdLine,PICE_strlen(CmdTable[i].Cmd))==0 &&
3848  PICE_strlen(CmdTable[i].Cmd)==StrLenUpToWhiteChar(pCmdLine," ") &&
3849  CmdTable[i].CommandGroup != COMMAND_GROUP_HELP_ONLY)
3850  {
3851  pCurrentCommand=&CmdTable[i];
3852  break;
3853  }
3854  }
3855  if(pCurrentCommand==NULL)
3856  {
3857  Print(OUTPUT_WINDOW," <-- command not found\n");
3858  Print(OUTPUT_WINDOW,":");
3859  goto CommonParseReturnPoint;
3860  }
3861 
3862  pToken = PICE_strtok( pCmdLine);
3863  // get the args and convert them into numbers
3864  i=0;
3865  j=0;
3866  do
3867  {
3868  pToken=PICE_strtok( NULL);
3869  DPRINT((0,"pToken = %s\n",pToken));
3870  if(pToken)
3871  {
3872  if(*pToken == '-' && PICE_strlen(pToken)==2)
3873  {
3874  DPRINT((0,"might be a switch\n"));
3875  if(pCurrentCommand->Flags & COMMAND_HAS_SWITCHES)
3876  {
3877  // token starts with '-' and is 2 chars long
3878  // must be a switch
3879  if(PICE_strchr(pCurrentCommand->pszRecognizedSwitches,*(pToken+1)) )
3880  {
3881  DPRINT((0,"is a switch!\n"));
3882  Arguments.Switch[j++]=*(pToken+1);
3883  continue;
3884  }
3885  // not a valid switch
3886  else
3887  {
3888  PICE_sprintf(tempCmd," <-- %s is not a valid switch\n",pToken);
3889  Print(OUTPUT_WINDOW,tempCmd);
3890  Print(OUTPUT_WINDOW,":");
3891  goto CommonParseReturnPoint;
3892  }
3893  }
3894  else
3895  {
3896  PICE_sprintf(tempCmd," <-- %s can't have any switches\n",pCurrentCommand->Cmd);
3897  Print(OUTPUT_WINDOW,tempCmd);
3898  Print(OUTPUT_WINDOW,":");
3899  goto CommonParseReturnPoint;
3900  }
3901  }
3902 
3903  if(pCurrentCommand->Flags & COMMAND_HAS_PARAMS)
3904  {
3905  if(!pCurrentCommand->ParamFlags[i])
3906  {
3907  PICE_sprintf(tempCmd," <-- %s can't have more than %u parameters\n",pCurrentCommand->Cmd,i);
3908  Print(OUTPUT_WINDOW,tempCmd);
3909  Print(OUTPUT_WINDOW,":");
3910  goto CommonParseReturnPoint;
3911  }
3912  DPRINT((0,"Parse(): PARAM_CAN_BE_SRCLINE\n"));
3913  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_SRCLINE)
3914  {
3915  if(ConvertTokenToLineNumber(pToken,&Arguments.Value[i]))
3916  {
3917  i++;
3918  continue;
3919  }
3920  if(*pToken == '.')
3921  {
3922  PICE_sprintf(tempCmd," <-- no line number %s found\n",pToken);
3923  Print(OUTPUT_WINDOW,tempCmd);
3924  Print(OUTPUT_WINDOW,":");
3925  goto CommonParseReturnPoint;
3926  }
3927  }
3928  DPRINT((0,"Parse(): PARAM_CAN_BE_NUMERIC\n"));
3929  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_NUMERIC)
3930  {
3931  if(ConvertTokenToHex(pToken,&Arguments.Value[i]))
3932  {
3933  i++;
3934  continue;
3935  }
3936  }
3937  DPRINT((0,"Parse(): PARAM_CAN_BE_DECIMAL\n"));
3938  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_DECIMAL)
3939  {
3940  if(ConvertTokenToDec(pToken,&Arguments.Value[i]))
3941  {
3942  i++;
3943  continue;
3944  }
3945  }
3946  DPRINT((0,"Parse(): PARAM_CAN_BE_REG_KEYWORD\n"));
3947  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_REG_KEYWORD)
3948  {
3949  if(ConvertTokenToKeyword(pToken,&Arguments.Value[i]))
3950  {
3951  Arguments.pToken[i] = pToken;
3952  i++;
3953  continue;
3954  }
3955  }
3956  DPRINT((0,"Parse(): PARAM_CAN_BE_SYMBOLIC\n"));
3957  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_SYMBOLIC)
3958  {
3959  if(ConvertTokenToSymbol(pToken,&Arguments.Value[i]))
3960  {
3961  i++;
3962  continue;
3963  }
3964  }
3965  DPRINT((0,"Parse(): PARAM_CAN_BE_VIRTUAL_SYMBOLIC\n"));
3966  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_VIRTUAL_SYMBOLIC)
3967  {
3968  DPRINT((0,"might be a virtual modname!symbol syntax!\n"));
3969  if(ConvertTokenToModuleAndName(pToken,&Arguments.Value[i],&Arguments.Value[i+1]))
3970  {
3971  Arguments.bNotTranslated[i]=TRUE;
3972  Arguments.bNotTranslated[i+1]=TRUE;
3973  i+=2;
3974  continue;
3975  }
3976  }
3977  DPRINT((0,"Parse(): PARAM_CAN_BE_MODULE\n"));
3978  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_MODULE)
3979  {
3980  if(ConvertTokenToModule(pToken,&Arguments.Value[i]))
3981  {
3982  i++;
3983  continue;
3984  }
3985  }
3986  DPRINT((0,"Parse(): PARAM_CAN_BE_PRNAME\n"));
3987  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_PRNAME)
3988  {
3989  if(ConvertTokenToProcess(pToken,&Arguments.Value[i]))
3990  {
3991  i++;
3992  continue;
3993  }
3994  }
3995  DPRINT((0,"Parse(): PARAM_CAN_BE_SRC_FILE\n"));
3996  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_SRC_FILE)
3997  {
3998  if(ConvertTokenToSrcFile(pToken,&Arguments.Value[i]))
3999  {
4000  i++;
4001  continue;
4002  }
4003  }
4004  DPRINT((0,"Parse(): PARAM_CAN_BE_ASTERISK\n"));
4005  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_ASTERISK)
4006  {
4007  if(PICE_strlen(pToken)==1 && pToken[0]=='*')
4008  {
4009  Arguments.Value[i]=-1;
4010  i++;
4011  continue;
4012  }
4013  }
4014  DPRINT((0,"Parse(): PARAM_CAN_BE_LETTER\n"));
4015  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_LETTER)
4016  {
4017  if(PICE_strlen(pToken)==1 && PICE_isprint(pToken[0]))
4018  {
4019  Arguments.Value[i]=(ULONG)pToken[0];
4020  i++;
4021  continue;
4022  }
4023  }
4024  DPRINT((0,"Parse(): PARAM_CAN_BE_ONOFF\n"));
4025  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_ONOFF)
4026  {
4027  if(ConvertTokenToOnOff(pToken,&Arguments.Value[i]))
4028  {
4029  i++;
4030  continue;
4031  }
4032  }
4033  DPRINT((0,"Parse(): PARAM_CAN_BE_PARTIAL_SYM_NAME\n"));
4034  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_PARTIAL_SYM_NAME)
4035  {
4036  Arguments.Value[i] = (ULONG)pToken;
4037  i++;
4038  continue;
4039  }
4040  DPRINT((0,"Parse(): PARAM_CAN_BE_ANY_STRING\n"));
4041  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_ANY_STRING)
4042  {
4043  Arguments.Value[i] = (ULONG)pToken;
4044  i++;
4045  continue;
4046  }
4047  DPRINT((0,"Parse(): PARAM_CAN_BE_SIZE_DESC\n"));
4048  if(pCurrentCommand->ParamFlags[i] & PARAM_CAN_BE_SIZE_DESC)
4049  {
4050  if(ConvertSizeToKeyword(pToken,&Arguments.Value[i]))
4051  {
4052  Arguments.pToken[i] = pToken;
4053  i++;
4054  continue;
4055  }
4056  }
4057  PICE_sprintf(tempCmd," <-- syntax error in parameter %u!\n",i);
4058  Print(OUTPUT_WINDOW,tempCmd);
4059  Print(OUTPUT_WINDOW,":");
4060  goto CommonParseReturnPoint;
4061  }
4062  else
4063  {
4064  PICE_sprintf(tempCmd," <-- %s has no parameters\n",pCurrentCommand->Cmd);
4065  Print(OUTPUT_WINDOW,tempCmd);
4066  Print(OUTPUT_WINDOW,":");
4067  goto CommonParseReturnPoint;
4068  }
4069  // next token
4070  i++;
4071  }
4072  }while(pToken && i<MAX_ARGS);
4073 
4074  Arguments.Count=i;
4075  Arguments.CountSwitches=j;
4076 
4077  if(pCurrentCommand)
4078  {
4079  DPRINT((0,"Parse(): command %s switches %u\n",pCurrentCommand->Cmd,Arguments.CountSwitches));
4080 
4081  if(!bInvokedByFkey)
4082  {
4083  DPRINT((0,"Parse(): adding new line\n"));
4084  Print(OUTPUT_WINDOW,"\n");
4085  }
4086 
4087  // call the command handler
4088  result=pCurrentCommand->Handler(&Arguments);
4089 
4090  if(result && !bInvokedByFkey && pCurrentCommand->Handler!=LeaveIce && pCurrentCommand->Handler!=SingleStep )
4091  {
4092  DPRINT((0,"Parse(): adding colon\n"));
4093  Print(OUTPUT_WINDOW,":");
4094  }
4095  }
4096 
4097 CommonParseReturnPoint:
4100 
4101  ShowStatusLine();
4102 }
#define COMMAND_HAS_SWITCHES
Definition: parse.c:124
ULONG P
Definition: utils.h:147
ULONG CurrentDR6
Definition: shell.c:117
USHORT CurrentCS
Definition: shell.c:116
static void segment(struct gl_context *ctx, struct LineInfo *line, plot_func plot, GLfloat t0, GLfloat t1)
Definition: s_aaline.c:326
BOOLEAN ConvertTokenToLineNumber(LPSTR p, PULONG pValue)
Definition: parse.c:3768
struct tagIdt * PIDT
ULONG Count
Definition: parse.h:34
void SetForegroundColor(ECOLORS c)
Definition: hardware.c:576
BOOLEAN PICE_isprint(char c)
Definition: utils.c:248
char * KeyWord
Definition: parse.h:64
KEYWORDS SpecialKeyWords[]
Definition: parse.c:96
LIST_ENTRY * pPsProcessListHead
Definition: utils.h:301
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble const GLfloat const GLdouble const GLfloat GLenum GLint GLint GLint GLint GLint GLint j
Definition: glfuncs.h:98
void PutStatusText(LPSTR p)
Definition: parse.c:360
PDEBUG_MODULE IsModuleLoaded(LPSTR p)
Definition: symbols.c:296
#define TRUE
Definition: types.h:120
ULONG CountSwitches
Definition: parse.h:36
char * SystemSegmentTypes[]
Definition: parse.c:276
#define PARAM_CAN_BE_SRCLINE
Definition: parse.c:139
BOOLEAN(* DisplayMemory)(PARGS)
Definition: parse.c:56
BOOLEAN FindAddressForSourceLine(ULONG ulLineNumber, LPSTR pFilename, PDEBUG_MODULE pMod, PULONG pValue)
Definition: symbols.c:1689
#define PARAM_CAN_BE_VIRTUAL_SYMBOLIC
Definition: parse.c:138
void UnassembleOnePageUp(ULONG page)
Definition: parse.c:1513
union _MEMORY_AREA::@1561 Data
#define _PAGE_4M
Definition: utils.h:268
void UnassembleOneLineDown(void)
Definition: parse.c:1413
void EnableScroll(USHORT Window)
Definition: hardware.c:532
volatile UCHAR ucKeyPressedWhileIdle
Definition: shell.c:78
ULONG Type
Definition: mm.h:210
LPSTR LocalVarRegs[]
Definition: parse.c:101
void RepaintSource(void)
Definition: parse.c:304
#define COMMAND_GROUP_DEBUG
Definition: parse.c:153
#define COMMAND_GROUP_OS
Definition: parse.c:149
ULONG ulRealStackPtr
Definition: shell.c:82
void EmptyRingBuffer(void)
Definition: hardware.c:104
PICE_SYMBOLFILE_HEADER * apSymbols[32]
Definition: symbols.c:53
BOOLEAN ConvertTokenToKeyword(LPSTR p, PULONG pValue)
Definition: parse.c:3592
static LPCWSTR LPCWSTR module_name
Definition: db.cpp:157
LONG ExtractNumber(LPSTR p)
Definition: symbols.c:2436
#define PARAM_CAN_BE_PARTIAL_SYM_NAME
Definition: parse.c:140
void PrintTemplate(void)
Definition: hardware.c:741
BOOLEAN bStepInto
Definition: shell.c:65
#define PARAM_CAN_BE_ASTERISK
Definition: parse.c:136
PDEBUG_MODULE pCurrentMod
Definition: parse.c:59
void Evaluate(PICE_SYMBOLFILE_HEADER *pSymbols, LPSTR p)
Definition: symbols.c:2918
#define COMMAND_GROUP_HELP_ONLY
Definition: parse.c:156
BOOLEAN bInt1Here
Definition: parse.c:65
USHORT CurrentSS
Definition: shell.c:116
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
PDEBUG_MODULE FindModuleFromAddress(ULONG addr)
Definition: symbols.c:507
ULONG GLOBAL_SCREEN_WIDTH
Definition: hardware.c:62
ULONG ParamFlags[MAX_ARGS]
Definition: parse.h:57
ULONG ulOffsetToSrcFiles
Definition: shared.h:89
unsigned char * PUCHAR
Definition: retypes.h:3
ULONG OldOffset
Definition: shell.c:90
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3706
LPSTR FindCommand(LPSTR p)
Definition: parse.c:3252
#define GLOBAL_DATA_SEGMENT
Definition: utils.h:247
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
BOOLEAN bCodeOn
Definition: parse.c:253
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
BOOLEAN ConvertTokenToSpecialKeyword(LPSTR p, PULONG pValue)
Definition: parse.c:3613
#define PARAM_CAN_BE_DECIMAL
Definition: parse.c:142
USHORT cy
Definition: hardware.h:33
#define COMMAND_HAS_PARAMS
Definition: parse.c:123
KEYWORDS RegKeyWords[]
Definition: parse.c:67
BOOLEAN ReplaceKeywordWithValue(LPSTR p, PULONG pValue, KEYWORDS *pKeyWords)
Definition: parse.c:3565
CMDTABLE CmdTable[]
Definition: parse.c:175
BOOLEAN InstallVirtualSWBreakpoint(LPSTR ModName, LPSTR FunctionName)
Definition: bp.c:300
ULONG ulLastInvertedAddress
Definition: parse.c:43
#define SHOW_FIELD_BYTE(ptr, field, wait)
Definition: utils.h:68
#define LEAVE_FUNC()
Definition: debug.h:43
ULONG PICE_strncmpi(char *s1, char *s2, ULONG len)
Definition: utils.c:362
BOOLEAN bNeedToFillBuffer
Definition: parse.c:254
#define PICE_MAJOR_VERSION
Definition: pice_ver.h:32
ULONG ulNumberOfSrcFiles
Definition: shared.h:89
#define COMMAND_GROUP_FLOW
Definition: parse.c:147
ULONG CurrentESI
Definition: shell.c:115
GLuint GLuint end
Definition: gl.h:1545
char * PICE_strchr(char *s, char c)
Definition: utils.c:262
#define PARAM_CAN_BE_REG_KEYWORD
Definition: parse.c:133
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
Definition: shell.h:41
#define PARAM_CAN_BE_PRNAME
Definition: parse.c:129
ULONG SegType
Definition: utils.h:165
ULONG offset
Definition: symbols.h:36
#define COMMAND_GROUP_WINDOW
Definition: parse.c:152
char * LPSTR
Definition: xmlstorage.h:182
Definition: parse.h:75
void HatchLine(ULONG line)
Definition: hardware.c:652
__asm__("\t.globl GetPhys\n""GetPhys:\t\n""mflr 0\n\t""stwu 0,-16(1)\n\t""mfmsr 5\n\t""andi. 6,5,0xffef\n\t""mtmsr 6\n\t""isync\n\t""sync\n\t""lwz 3,0(3)\n\t""mtmsr 5\n\t""isync\n\t""sync\n\t""lwz 0,0(1)\n\t""addi 1,1,16\n\t""mtlr 0\n\t""blr")
struct _DEBUG_MODULE_ * next
Definition: symbols.h:49
char * PICE_strtok(char *szInputString)
Definition: parse.c:3310
void CompactString(LPSTR p)
Definition: parse.c:3292
void DisplaySourceFile(LPSTR pSrcLine, LPSTR pSrcEnd, ULONG ulLineNumber, ULONG ulLineNumberToInvert)
Definition: parse.c:1313
HANDLE UniqueProcessId
Definition: pstypes.h:1199
ULONG CurrentDR3
Definition: shell.c:117
BOOLEAN bStepping
Definition: parse.c:63
static int dev
Definition: mkdosfs.c:536
#define SCANCODE_ESC
Definition: scancodes.h:35
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
#define PARAM_CAN_BE_ONOFF
Definition: parse.c:137
GLint limit
Definition: glext.h:10326
PDEBUG_MODULE pdebug_module_head
Definition: init.c:46
void RepaintDesktop(void)
Definition: parse.c:324
char * PICE_strcpy(char *s1, char *s2)
Definition: utils.c:302
Definition: ansiprsr.h:4
BOOLEAN bShowSrc
Definition: parse.c:252
_In_ USHORT _In_ UCHAR RevisionID
Definition: iotypes.h:859
int EvaluateExpression(char *pExpression, char **pNext)
Definition: hpp.c:253
void UnassembleOnePageDown(ULONG page)
Definition: parse.c:1436
ULONG CurrentCR3
Definition: shell.c:118
ULONG ulOldDisasmOffset
Definition: parse.c:48
PMADDRESS_SPACE my_init_mm
Definition: utils.h:300
#define ADDR_TO_PTE(v)
Definition: parse.h:181
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define PARAM_CAN_BE_MODULE
Definition: parse.c:128
BOOLEAN InstallSWBreakpoint(ULONG ulAddress, BOOLEAN bPermanent, void(*SWBreakpointCallback)(void))
Definition: bp.c:236
char * Cmd
Definition: parse.h:53
BOOLEAN ConvertTokenToDec(LPSTR p, PULONG pValue)
Definition: parse.c:3410
#define SHOW_FIELD_WORD(ptr, field, wait)
Definition: utils.h:76
LPSTR FindFunctionByAddress(ULONG ulValue, PULONG pulstart, PULONG pulend)
Definition: symbols.c:767
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define FALSE
Definition: types.h:117
BOOLEAN ConvertTokenToSymbol(LPSTR pToken, PULONG pValue)
Definition: parse.c:3435
PICE_SYMBOLFILE_HEADER * pCurrentSymbols
Definition: parse.c:60
LPCSTR filename
Definition: alphablend.c:63
long LONG
Definition: pedump.c:60
#define DEBUG_MODULE_NAME_LEN
Definition: shared.h:79
ULONG inl(PULONG port)
Definition: utils.c:2184
char szCurrentFile[256]
Definition: parse.c:58
#define PICE_MINOR_VERSION
Definition: pice_ver.h:33
union _PCI_NUMBER::@1380 u
volatile BOOLEAN bSingleStep
Definition: shell.c:129
char * PICE_strrev(char *s)
Definition: utils.c:527
#define MAX_ARGS
Definition: dispex.c:21
#define COMMAND_GROUP_INFO
Definition: parse.c:154
void DeInstallPrintkHook(void)
Definition: output.c:278
UCHAR ucBreakKey
Definition: patch.c:56
struct _PCI_NUMBER::@1380::@1381 bits
#define COMMAND_GROUP_MEM
Definition: parse.c:150
#define PARAM_CAN_BE_SRC_FILE
Definition: parse.c:131
void Home(USHORT Window)
Definition: hardware.c:693
COMMAND_PROTOTYPE(SingleStep)
Definition: parse.c:420
LPSTR CommandGroups[]
Definition: parse.c:159
char filename[256]
Definition: shared.h:103
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
void Parse(LPSTR pCmdLine, BOOLEAN bInvokedByFkey)
Definition: parse.c:3828
ULONG CurrentDR7
Definition: shell.c:117
static ULONG ulCountForWaitKey
Definition: parse.c:49
PICE_SYMBOLFILE_HEADER * FindModuleSymbols(ULONG addr)
Definition: symbols.c:463
char * PICE_strncpy(char *s1, char *s2, int len)
Definition: utils.c:286
#define COLOR_TEXT
Definition: hardware.h:158
smooth NULL
Definition: ftsmooth.c:557
ULONG CurrentEDI
Definition: shell.c:115
LONG ulCurrentlyDisplayedLineNumber
Definition: parse.c:46
WCHAR name[DEBUG_MODULE_NAME_LEN]
Definition: shared.h:83
ULONG size
Definition: symbols.h:50
static VOID ClearScreen(IN HANDLE hConOut, IN PCONSOLE_SCREEN_BUFFER_INFO pcsbi)
Definition: mode.c:242
void ClrLine(ULONG line)
Definition: hardware.c:662
USHORT CurrentFS
Definition: shell.c:116
void DPRINT(...)
Definition: polytest.cpp:61
Definition: module.h:566
char ** Args
Definition: acdebug.h:342
WINDOW wWindow[4]
Definition: hardware.c:59
Definition: sacdrv.h:288
ULONG US
Definition: utils.h:149
#define MEMORY_AREA_SECTION_VIEW
Definition: mm.h:69
ULONG RW
Definition: utils.h:148
#define COMMAND_GROUP_STRUCT
Definition: parse.c:148
PVOID pValue
Definition: parse.h:65
_Inout_ PVOID Segment
Definition: exfuncs.h:893
#define COLOR_FOREGROUND
Definition: hardware.h:160
Definition: utils.h:160
Definition: utils.h:177
ULONG CurrentCR0
Definition: shell.c:118
PLOCAL_VARIABLE FindLocalsByAddress(ULONG addr)
Definition: symbols.c:1317
BOOLEAN bNotTranslated[16]
Definition: parse.h:37
BOOLEAN WaitForKey(void)
Definition: parse.c:374
char HexDigit[]
Definition: parse.c:227
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
unsigned char BOOLEAN
static LPSTR pName
Definition: security.c:78
ULONG CurrentProcess
Definition: shell.c:125
char * PICE_strcat(char *s1, char *s2)
Definition: utils.c:315
#define _PAGE_PRESENT
Definition: compat.h:67
void IntelStackWalk(ULONG pc, ULONG ebp, ULONG esp)
Definition: utils.c:1530
PEPROCESS NTAPI IoGetCurrentProcess(VOID)
Definition: util.c:112
char name[64]
Definition: symbols.h:35
#define _PAGE_SIZE
Definition: utils.h:269
BOOLEAN ConvertTokenToOnOff(LPSTR p, PULONG pValue)
Definition: parse.c:3632
ULONG CurrentDR2
Definition: shell.c:117
#define COMMAND_GROUP_HELP
Definition: parse.c:146
ULONG ulLastDisassStartAddress
Definition: parse.c:43
BOOLEAN Active
Definition: parse.h:80
USHORT CurrentDS
Definition: shell.c:116
const GLubyte * c
Definition: glext.h:8905
#define PARAM_CAN_BE_SIZE_DESC
Definition: parse.c:143
unsigned short * PUSHORT
Definition: retypes.h:2
struct tagGdt * PGDT
GLuint address
Definition: glext.h:9393
#define PARAM_CAN_BE_ANY_STRING
Definition: parse.c:141
GLuint GLuint GLsizei count
Definition: gl.h:1545
BOOLEAN ConvertTokenToHex(LPSTR p, PULONG pValue)
Definition: parse.c:3346
void PICE_memcpy(void *t, void *s, int sz)
Definition: utils.c:239
Definition: parse.h:31
KEYWORDS OnOffKeyWords[]
Definition: parse.c:90
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BOOLEAN RemoveAllSWBreakpoints(BOOLEAN bEvenPermanents)
Definition: bp.c:463
GLbitfield flags
Definition: glext.h:7161
#define PICE_BUILD
Definition: pice_ver.h:36
#define COMMAND_GROUP_LAST
Definition: parse.c:157
_In_ PUNICODE_STRING Name
Definition: mrx.h:218
#define PARAM_CAN_BE_NUMERIC
Definition: parse.c:132
struct _PCI_VENDOR_IDS PCIVendorIDs[]
unsigned char UCHAR
Definition: xmlstorage.h:181
void ShowStatusLine(void)
Definition: shell.c:216
ULONG CurrentEDX
Definition: shell.c:114
ULONG value
Definition: symbols.h:36
GLenum const GLvoid * addr
Definition: glext.h:9621
#define index(s, c)
Definition: various.h:29
#define PARAM_CAN_BE_SYMBOLIC
Definition: parse.c:126
ULONG GetLinearAddress(USHORT Segment, ULONG Offset)
Definition: utils.c:782
ULONG PTBase
Definition: utils.h:157
ULONG CurrentCR2
Definition: shell.c:118
ULONG ValueTrue
Definition: parse.c:42
Definition: sacdrv.h:278
#define PARAM_CAN_BE_PID
Definition: parse.c:130
BOOLEAN Used
Definition: parse.h:79
struct _PCI_COMMON_CONFIG PCI_COMMON_CONFIG
ULONG Flags
Definition: parse.h:56
static DWORD layout
Definition: bitmap.c:47
struct TagArgs * PARGS
BOOLEAN Disasm(PULONG pOffset, PUCHAR pchDst)
Definition: disassembler.c:705
USHORT usOldDisasmSegment
Definition: parse.c:47
ULONG CurrentECX
Definition: shell.c:114
USHORT y
Definition: hardware.h:33
ULONG ReadPhysMem(ULONG Address, ULONG ulSize)
Definition: utils.c:1633
GLenum GLsizei len
Definition: glext.h:6722
BOOLEAN bRegister
Definition: symbols.h:37
Definition: typedefs.h:117
BOOLEAN IsWhiteChar(char c, LPSTR WhiteChars)
Definition: parse.c:3800
static stack_node_t temp
Definition: rpn.c:18
void ShowStoppedMsg(void)
Definition: utils.c:861
void PrintRingBuffer(ULONG ulLines)
Definition: hardware.c:315
seg
Definition: i386-dis.c:3857
LPSTR DecodeVmFlags(ULONG flags)
Definition: parse.c:1887
BOOLEAN ConvertTokenToModule(LPSTR p, PULONG pValue)
Definition: parse.c:3518
BOOLEAN ConvertTokenToProcess(LPSTR p, PULONG pValue)
Definition: parse.c:3556
void DisplayRegs(void)
Definition: utils.c:1097
void CopyWideToAnsi(LPSTR pAnsi, PWSTR pWide)
Definition: utils.c:591
#define ADDR_TO_PDE(v)
Definition: parse.h:179
void SetHardwareBreakPoint(ULONG ulAddress, ULONG ulReg)
Definition: utils.c:878
ULONG ulLastDisassEndAddress
Definition: parse.c:43
struct _MEMORY_AREA::@1561::@1562 SectionData
BOOLEAN BuildModuleList(void)
Definition: symbols.c:266
Status
Definition: gdiplustypes.h:24
struct tagPageDir * PPAGEDIR
void WritePhysMem(ULONG Address, ULONG Datum, ULONG ulSize)
Definition: utils.c:1680
USHORT CurrentGS
Definition: shell.c:116
BOOLEAN ReInstallSWBreakpoint(ULONG ulAddress)
Definition: bp.c:197
ULONG Offset_31_16
Definition: utils.h:185
UCHAR GetKeyPolled(void)
Definition: hardware.c:926
LPSTR FindSourceLineForAddress(ULONG addr, PULONG pulLineNumber, LPSTR *ppSrcStart, LPSTR *ppSrcEnd, LPSTR *ppFilename)
Definition: symbols.c:1476
ULONG CurrentDR0
Definition: shell.c:117
BOOLEAN bStepThroughSource
Definition: shell.c:64
void PutChar(LPSTR p, ULONG x, ULONG y)
Definition: hardware.c:604
char tempCmd[1024]
Definition: parse.c:225
BOOLEAN bInt3Here
Definition: parse.c:64
void DisableScroll(USHORT Window)
Definition: hardware.c:543
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN IsSwBpAtAddress(ULONG ulAddress)
Definition: bp.c:133
PFN Handler
Definition: parse.h:54
USHORT usCurX
Definition: hardware.h:34
ULONG Value[16]
Definition: parse.h:33
GLuint start
Definition: gl.h:1545
#define PARAM_CAN_BE_LETTER
Definition: parse.c:144
ULONG g_ulLineNumberStart
Definition: shell.c:62
PCHAR Help
Definition: kdb_cli.c:134
CPUINFO CPUInfo[]
Definition: parse.c:231
BOOLEAN ScanExports(const char *pFind, PULONG pValue)
Definition: symbols.c:327
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
ULONG CurrentEIP
Definition: shell.c:113
VOID outl(ULONG data, PULONG port)
Definition: utils.c:2164
ULONG CurrentEBX
Definition: shell.c:114
PKEYBOARD_LAYOUT SetKeyboardLayoutByName(LPSTR Name)
Definition: utils.c:208
static USHORT PeekByte(PUCHAR ReadDataPort)
Definition: hardware.c:211
ULONG CurrentEBP
Definition: shell.c:115
unsigned int * PULONG
Definition: retypes.h:1
ULONG CurrentDR1
Definition: shell.c:117
BOOLEAN DeInstallSWBreakpoint(ULONG ulAddress)
Definition: bp.c:428
void CheckRingBuffer(void)
Definition: hardware.c:133
static int reg
Definition: i386-dis.c:1275
void SetBackgroundColor(ECOLORS c)
Definition: hardware.c:590
void SuspendPrintRingBuffer(BOOLEAN bSuspend)
Definition: hardware.c:93
ULONG ulWindowOffset
Definition: shell.c:63
void UnassembleOneLineUp(void)
Definition: parse.c:1460
char type_name[64]
Definition: symbols.h:34
USHORT gCurrentSelector
Definition: parse.c:44
BOOLEAN IsSwBpAtAddressInstalled(ULONG ulAddress)
Definition: bp.c:113
#define DIM
Definition: s_texfetch.c:44
LPSTR pToken[16]
Definition: parse.h:38
BOOLEAN ConvertTokenToSrcFile(LPSTR p, PULONG pValue)
De