ReactOS  0.4.12-dev-14-gd0c8636
utils.h File Reference
#include <stdarg.h>
#include "../../../../ntoskrnl/include/internal/ps.h"
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagSCANTOASCII
 
struct  tagKEYBOARD_LAYOUT
 
struct  _FRAME
 
struct  _PCI_NUMBER
 
struct  tagPageDir
 
struct  tagGdt
 
struct  tagIdt
 
struct  tagDESCRIPTOR
 

Macros

#define __STR(x)   #x
 
#define STR(x)   __STR(x)
 
#define SHOW_FIELD_BYTE(ptr, field, wait)
 
#define SHOW_FIELD_WORD(ptr, field, wait)
 
#define SHOW_FIELD_DWORD(ptr, field, wait)
 
#define SHOW_FIELD_SEG_OFS(ptr, field1, field2, wait)
 
#define OUTPUT_BUFFER_FULL   0x01
 
#define INPUT_BUFFER_FULL   0x02
 
#define MOUSE_OUTPUT_BUFFER_FULL   0x20
 
#define GLOBAL_CODE_SEGMENT   (KERNEL_CS)
 
#define GLOBAL_DATA_SEGMENT   (KERNEL_DS)
 
#define _PAGE_PRESENT   0x001
 
#define _PAGE_RW   0x002
 
#define _PAGE_USER   0x004
 
#define _PAGE_PWT   0x008
 
#define _PAGE_PCD   0x010
 
#define _PAGE_ACCESSED   0x020
 
#define _PAGE_DIRTY   0x040
 
#define _PAGE_PSE   0x080
 
#define _PAGE_4M   _PAGE_PSE
 
#define _PAGE_SIZE   0x1000
 
#define save_flags(x)   __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)
 
#define restore_flags(x)   __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")
 
#define cli()   __asm__ __volatile__("cli": : :"memory")
 
#define sti()   __asm__ __volatile__("sti": : :"memory")
 
#define ASSERT(x)   if (!(x)) { DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__); KeBugCheck(0); }
 
#define PAGEDPOOL   (1)
 
#define NONPAGEDPOOL   (0)
 

Typedefs

typedef struct tagSCANTOASCII SCANTOASCII
 
typedef struct tagSCANTOASCIIPSCANTOASCII
 
typedef struct tagKEYBOARD_LAYOUT KEYBOARD_LAYOUT
 
typedef struct tagKEYBOARD_LAYOUTPKEYBOARD_LAYOUT
 
typedef struct _FRAME FRAME
 
typedef struct _PCI_NUMBER PCI_NUMBER
 
typedef struct tagPageDir PAGEDIR
 
typedef struct tagPageDirPPAGEDIR
 
typedef struct tagGdt GDT
 
typedef struct tagGdtPGDT
 
typedef struct tagIdt IDT
 
typedef struct tagIdtPIDT
 
typedef struct tagDESCRIPTOR DESCRIPTOR
 
typedef struct tagDESCRIPTORPDESCRIPTOR
 

Enumerations

enum  KeyboardLayout { kbDE, kbUS, kbDK, kbMaximum }
 

Functions

PKEYBOARD_LAYOUT GetKeyboardLayout ()
 
PKEYBOARD_LAYOUT SetKeyboardLayoutByName (LPSTR Name)
 
void PICE_memset (void *p, unsigned char c, int sz)
 
void PICE_memcpy (void *t, void *s, int sz)
 
charPICE_strrev (char *)
 
ULONG PICE_strcmp (char *s1, char *s2)
 
ULONG PICE_strcmpi (char *s1, char *s2)
 
ULONG PICE_strncmpi (char *s1, char *s2, ULONG len)
 
USHORT PICE_strlen (const char *s)
 
charPICE_strcat (char *s1, char *s2)
 
BOOLEAN PICE_isprint (char c)
 
charPICE_strcpy (char *s1, char *s2)
 
charPICE_strncpy (char *s1, char *s2, int len)
 
charPICE_strchr (char *s, char c)
 
int PICE_isdigit (int c)
 
int PICE_isxdigit (int c)
 
int PICE_islower (int c)
 
int PICE_isalpha (int c)
 
int PICE_sprintf (char *buf, const char *fmt,...)
 
int PICE_vsprintf (char *buf, const char *fmt, va_list args)
 
BOOLEAN IsAddressValid (ULONG Addr)
 
BOOLEAN IsAddressWriteable (ULONG Addr)
 
BOOLEAN SetAddressWriteable (ULONG address, BOOLEAN bSet)
 
BOOLEAN IsRangeValid (ULONG addr, ULONG Length)
 
void IntelStackWalk (ULONG pc, ULONG ebp, ULONG esp)
 
ULONG ReadPhysMem (ULONG Address, ULONG ulSize)
 
void WritePhysMem (ULONG Address, ULONG Datum, ULONG ulSize)
 
BOOLEAN IsRetAtEIP (void)
 
BOOLEAN IsCallInstrAtEIP (void)
 
ULONG GetLinearAddress (USHORT Segment, ULONG Offset)
 
void ShowStoppedMsg (void)
 
void ShowRunningMsg (void)
 
void SetHardwareBreakPoints (void)
 
void SetHardwareBreakPoint (ULONG ulAddress, ULONG ulReg)
 
BOOLEAN Disasm (PULONG pOffset, PUCHAR pchDst)
 
void DisplayRegs (void)
 
void SaveOldRegs (void)
 
BOOLEAN CheckLoadAbort (void)
 
UCHAR KeyboardGetKeyPolled (void)
 
void KeyboardFlushKeyboardQueue (void)
 
UCHAR AsciiFromScan (UCHAR s)
 
UCHAR AsciiToScan (UCHAR s)
 
void outportb (PUCHAR port, UCHAR data)
 
UCHAR inportb (PUCHAR port)
 
void outb_p (UCHAR data, PUCHAR port)
 
UCHAR inb_p (PUCHAR port)
 
VOID outl (ULONG l, PULONG port)
 
ULONG inl (PULONG port)
 
void EnablePassThrough (void)
 
voidPICE_malloc (size_t numBytes, BOOLEAN fromPaged)
 
void PICE_free (void *p)
 
HANDLE PICE_open (LPCWSTR lpPathName, int iReadWrite)
 
long PICE_read (HANDLE hFile, LPVOID lpBuffer, long lBytes)
 
int PICE_close (HANDLE hFile)
 
size_t PICE_len (HANDLE hFile)
 
WCHARPICE_wcscpy (WCHAR *str1, const WCHAR *str2)
 
INT WINAPI PICE_MultiByteToWideChar (UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cchMultiByte, LPWSTR lpWideCharStr, int cchWideChar)
 

Variables

PKEYBOARD_LAYOUT CurrentKeyboard
 
PMADDRESS_SPACE my_init_mm
 
LIST_ENTRYpPsProcessListHead
 

Macro Definition Documentation

◆ __STR

#define __STR (   x)    #x

Definition at line 33 of file utils.h.

◆ _PAGE_4M

◆ _PAGE_ACCESSED

#define _PAGE_ACCESSED   0x020

Definition at line 265 of file utils.h.

◆ _PAGE_DIRTY

#define _PAGE_DIRTY   0x040

Definition at line 266 of file utils.h.

◆ _PAGE_PCD

#define _PAGE_PCD   0x010

Definition at line 264 of file utils.h.

◆ _PAGE_PRESENT

#define _PAGE_PRESENT   0x001

Definition at line 260 of file utils.h.

◆ _PAGE_PSE

#define _PAGE_PSE   0x080

Definition at line 267 of file utils.h.

Referenced by IsAddressValid(), IsAddressWriteable(), and SetAddressWriteable().

◆ _PAGE_PWT

#define _PAGE_PWT   0x008

Definition at line 263 of file utils.h.

◆ _PAGE_RW

#define _PAGE_RW   0x002

Definition at line 261 of file utils.h.

◆ _PAGE_SIZE

#define _PAGE_SIZE   0x1000

◆ _PAGE_USER

#define _PAGE_USER   0x004

Definition at line 262 of file utils.h.

◆ ASSERT

#define ASSERT (   x)    if (!(x)) { DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__); KeBugCheck(0); }

Definition at line 293 of file utils.h.

◆ cli

#define cli ( )    __asm__ __volatile__("cli": : :"memory")

Definition at line 287 of file utils.h.

◆ GLOBAL_CODE_SEGMENT

#define GLOBAL_CODE_SEGMENT   (KERNEL_CS)

Definition at line 246 of file utils.h.

Referenced by InitPICE(), and RealIsr().

◆ GLOBAL_DATA_SEGMENT

#define GLOBAL_DATA_SEGMENT   (KERNEL_DS)

Definition at line 247 of file utils.h.

Referenced by COMMAND_PROTOTYPE(), and InitPICE().

◆ INPUT_BUFFER_FULL

#define INPUT_BUFFER_FULL   0x02

Definition at line 232 of file utils.h.

◆ MOUSE_OUTPUT_BUFFER_FULL

#define MOUSE_OUTPUT_BUFFER_FULL   0x20

Definition at line 233 of file utils.h.

Referenced by KeyboardGetKeyPolled().

◆ NONPAGEDPOOL

#define NONPAGEDPOOL   (0)

◆ OUTPUT_BUFFER_FULL

#define OUTPUT_BUFFER_FULL   0x01

Definition at line 231 of file utils.h.

Referenced by KeyboardFlushKeyboardQueue(), and KeyboardGetKeyPolled().

◆ PAGEDPOOL

#define PAGEDPOOL   (1)

Definition at line 305 of file utils.h.

◆ restore_flags

#define restore_flags (   x)    __asm__ __volatile__("pushl %0 ; popfl": /* no output */ :"g" (x):"memory", "cc")

Definition at line 286 of file utils.h.

Referenced by EnablePassThrough(), PICE_KdpPrintString(), printk(), test_write_watch(), and UnmaskIrqs().

◆ save_flags

#define save_flags (   x)    __asm__ __volatile__("pushfl ; popl %0":"=g" (x): /* no input */)

◆ SHOW_FIELD_BYTE

#define SHOW_FIELD_BYTE (   ptr,
  field,
  wait 
)
Value:
{\
if(wait && WaitForKey()==FALSE)\
return TRUE;\
PICE_sprintf(tempCmd,#field" = %.2x\n",ptr->##field);\
}
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
Definition: parser.c:43
char tempCmd[1024]
Definition: parse.c:225
static VOID WaitForKey(VOID)
Definition: hardware.c:84

Definition at line 68 of file utils.h.

Referenced by COMMAND_PROTOTYPE().

◆ SHOW_FIELD_DWORD

#define SHOW_FIELD_DWORD (   ptr,
  field,
  wait 
)
Value:
{\
if(wait && WaitForKey()==FALSE)\
return TRUE;\
PICE_sprintf(tempCmd,#field" = %.8x\n",ptr->##field);\
}
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
Definition: parser.c:43
char tempCmd[1024]
Definition: parse.c:225
static VOID WaitForKey(VOID)
Definition: hardware.c:84

Definition at line 84 of file utils.h.

◆ SHOW_FIELD_SEG_OFS

#define SHOW_FIELD_SEG_OFS (   ptr,
  field1,
  field2,
  wait 
)
Value:
{\
if(wait && WaitForKey()==FALSE)\
return TRUE;\
PICE_sprintf(tempCmd,#field1":"#field2" = %.4x:%.8x\n",ptr->##field1,ptr->##field2);\
}
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
char tempCmd[1024]
Definition: parse.c:225
static VOID WaitForKey(VOID)
Definition: hardware.c:84

Definition at line 92 of file utils.h.

◆ SHOW_FIELD_WORD

#define SHOW_FIELD_WORD (   ptr,
  field,
  wait 
)
Value:
{\
if(wait && WaitForKey()==FALSE)\
return TRUE;\
PICE_sprintf(tempCmd,#field" = %.4x\n",ptr->##field);\
}
#define TRUE
Definition: types.h:120
static PVOID ptr
Definition: dispmode.c:27
Definition: parser.c:43
char tempCmd[1024]
Definition: parse.c:225
static VOID WaitForKey(VOID)
Definition: hardware.c:84

Definition at line 76 of file utils.h.

Referenced by COMMAND_PROTOTYPE().

◆ sti

#define sti ( )    __asm__ __volatile__("sti": : :"memory")

◆ STR

#define STR (   x)    __STR(x)

Definition at line 34 of file utils.h.

Typedef Documentation

◆ DESCRIPTOR

◆ FRAME

typedef struct _FRAME FRAME

◆ GDT

typedef struct tagGdt GDT

◆ IDT

typedef struct tagIdt IDT

◆ KEYBOARD_LAYOUT

◆ PAGEDIR

◆ PCI_NUMBER

◆ PDESCRIPTOR

◆ PGDT

typedef struct tagGdt* PGDT

◆ PIDT

typedef struct tagIdt* PIDT

◆ PKEYBOARD_LAYOUT

◆ PPAGEDIR

◆ PSCANTOASCII

◆ SCANTOASCII

Enumeration Type Documentation

◆ KeyboardLayout

Enumerator
kbDE 
kbUS 
kbDK 
kbMaximum 

Definition at line 36 of file utils.h.

36  {
37  kbDE,
38  kbUS,
39  kbDK,
40  kbMaximum
Definition: utils.h:38
Definition: utils.h:37
Definition: utils.h:39
KeyboardLayout
Definition: utils.h:36

Function Documentation

◆ AsciiFromScan()

UCHAR AsciiFromScan ( UCHAR  s)

Definition at line 2069 of file utils.c.

Referenced by DebuggerShell().

2070 {
2072  ULONG i;
2073 
2074  ENTER_FUNC();
2075 
2076  if (bShift)
2077  {
2078  table = GetKeyboardLayout()->shifted;
2079  }
2080  else if(bAlt)
2081  {
2082  table = GetKeyboardLayout()->alted;
2083  }
2084  else
2085  {
2086  table = GetKeyboardLayout()->normal;
2087  }
2088 
2089 
2090  if (table)
2091  {
2092  for(i=0;table[i].s != 0;i++)
2093  {
2094  if(table[i].s==s)
2095  {
2096  LEAVE_FUNC();
2097  return table[i].a;
2098  }
2099  }
2100  }
2101 
2102  DPRINT((0,"AsciiFromScan(): no translation for key\n"));
2103  LEAVE_FUNC();
2104  return 0;
2105 }
volatile BOOLEAN bShift
Definition: shell.c:71
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define LEAVE_FUNC()
Definition: debug.h:43
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void DPRINT(...)
Definition: polytest.cpp:61
PSCANTOASCII alted
Definition: utils.h:55
volatile BOOLEAN bAlt
Definition: shell.c:72
GLdouble s
Definition: gl.h:2039
PSCANTOASCII normal
Definition: utils.h:53
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
PSCANTOASCII shifted
Definition: utils.h:54

◆ AsciiToScan()

UCHAR AsciiToScan ( UCHAR  s)

Definition at line 2113 of file utils.c.

Referenced by PiceKbdIsr().

2114 {
2116  ULONG i;
2117 
2118  ENTER_FUNC();
2119 
2120  if (bShift)
2121  {
2122  table = GetKeyboardLayout()->shifted;
2123  }
2124  else if(bAlt)
2125  {
2126  table = GetKeyboardLayout()->alted;
2127  }
2128  else
2129  {
2130  table = GetKeyboardLayout()->normal;
2131  }
2132 
2133  if (table)
2134  {
2135  for(i=0;table[i].s != 0;i++)
2136  {
2137  if(table[i].a==s)
2138  {
2139  LEAVE_FUNC();
2140  return table[i].s;
2141  }
2142  }
2143  }
2144 
2145  DPRINT((0,"AsciiToScan(): no translation for ASCII code\n"));
2146  LEAVE_FUNC();
2147  return 0;
2148 }
volatile BOOLEAN bShift
Definition: shell.c:71
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define LEAVE_FUNC()
Definition: debug.h:43
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void DPRINT(...)
Definition: polytest.cpp:61
PSCANTOASCII alted
Definition: utils.h:55
volatile BOOLEAN bAlt
Definition: shell.c:72
GLdouble s
Definition: gl.h:2039
PSCANTOASCII normal
Definition: utils.h:53
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
PSCANTOASCII shifted
Definition: utils.h:54

◆ CheckLoadAbort()

BOOLEAN CheckLoadAbort ( void  )

Definition at line 1471 of file utils.c.

1472 {
1473 ULONG i;
1474 UCHAR ucKey;
1475 
1476  MaskIrqs();
1477 
1479 
1481 
1482  PrintLogo(TRUE);
1483 
1484  for(i=0;i<5000;i++)
1485  {
1486  if(!(i%1000) )
1487  {
1488  PICE_sprintf(tempUtil,"\n LOAD WILL CONTINUE IN %u SEC (HIT 'C' TO CONTINUE OR ANY OTHER KEY TO ABORT)\n",5-i/1000);
1491  PrintLogo(TRUE);
1492  }
1493 
1494  ucKey = GetKeyPolled();
1495 
1496  if(ucKey)
1497  {
1498  if((ucKey&0x7f)!=46)
1499  {
1501  UnmaskIrqs();
1502  return FALSE;
1503  }
1504  else
1505  goto load;
1506  }
1508  }
1509 load:
1511  PrintLogo(TRUE);
1512 
1513  tempUtil[0] = 0;
1515 
1517 
1518  UnmaskIrqs();
1519 
1520  return TRUE;
1521 }
#define TRUE
Definition: types.h:120
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void MaskIrqs(void)
Definition: hooks.c:68
char tempUtil[1024]
Definition: utils.c:42
void RestoreGraphicsState(void)
Definition: hardware.c:906
unsigned char UCHAR
Definition: xmlstorage.h:181
void FlushKeyboardQueue(void)
Definition: hardware.c:935
void SaveGraphicsState(void)
Definition: hardware.c:897
UCHAR GetKeyPolled(void)
Definition: hardware.c:926
unsigned int ULONG
Definition: retypes.h:1
int load
Definition: msacm.c:1353
void Clear(USHORT Window)
Definition: hardware.c:705
void PrintLogo(BOOLEAN bShow)
Definition: hardware.c:778
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
void UnmaskIrqs(void)
Definition: hooks.c:82

◆ Disasm()

BOOLEAN Disasm ( PULONG  pOffset,
PUCHAR  pchDst 
)

Definition at line 705 of file disassembler.c.

Referenced by COMMAND_PROTOTYPE(), InstallSWBreakpoint(), TryToInstallVirtualSWBreakpoints(), UnassembleOneLineDown(), UnassembleOneLineUp(), UnassembleOnePageDown(), and UnassembleOnePageUp().

706 {
707  TDisassembler dis;
708 
710  dis.bpTarget = (UCHAR*)*pOffset;
711  dis.szDisasm = pchDst;
712  dis.wSel = CurrentCS;
713 
714  *pOffset += (ULONG)Disassembler( &dis);
715  return TRUE;
716 }
USHORT CurrentCS
Definition: shell.c:116
#define TRUE
Definition: types.h:120
UCHAR * bpTarget
Definition: disassembler.c:55
unsigned char UCHAR
Definition: xmlstorage.h:181
#define DIS_ADDRESS32
Definition: disassembler.c:71
#define DIS_DATA32
Definition: disassembler.c:69
UCHAR Disassembler(TDisassembler *pDis)
Definition: disassembler.c:175
unsigned int ULONG
Definition: retypes.h:1
UCHAR * szDisasm
Definition: disassembler.c:56

◆ DisplayRegs()

void DisplayRegs ( void  )

Definition at line 1097 of file utils.c.

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

1098 {
1099  char tempDisplayRegs[48];
1100 
1101  ENTER_FUNC();
1102 
1103 // Clear(REGISTER_WINDOW);
1105  // EAX
1106  Print(REGISTER_WINDOW,"EAX=");
1107  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentEAX);
1108  if(OldEAX!=CurrentEAX)
1109  {
1111  }
1112  Print(REGISTER_WINDOW,tempDisplayRegs);
1113  if(OldEAX!=CurrentEAX)
1114  {
1115  ResetColor();
1116  }
1117 
1118  // EBX
1119  Print(REGISTER_WINDOW," EBX=");
1120  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentEBX);
1121  if(OldEBX!=CurrentEBX)
1122  {
1124  }
1125  Print(REGISTER_WINDOW,tempDisplayRegs);
1126  if(OldEBX!=CurrentEBX)
1127  {
1128  ResetColor();
1129  }
1130 
1131  // ECX
1132  Print(REGISTER_WINDOW," ECX=");
1133  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentECX);
1134  if(OldECX!=CurrentECX)
1135  {
1137  }
1138  Print(REGISTER_WINDOW,tempDisplayRegs);
1139  if(OldECX!=CurrentECX)
1140  {
1141  ResetColor();
1142  }
1143 
1144  // EDX
1145  Print(REGISTER_WINDOW," EDX=");
1146  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentEDX);
1147  if(OldEDX!=CurrentEDX)
1148  {
1150  }
1151  Print(REGISTER_WINDOW,tempDisplayRegs);
1152  if(OldEDX!=CurrentEDX)
1153  {
1154  ResetColor();
1155  }
1156 
1157  // ESI
1158  Print(REGISTER_WINDOW," ESI=");
1159  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentESI);
1160  if(OldESI!=CurrentESI)
1161  {
1163  }
1164  Print(REGISTER_WINDOW,tempDisplayRegs);
1165  if(OldESI!=CurrentESI)
1166  {
1167  ResetColor();
1168  }
1169 
1170  // EDI
1171  Print(REGISTER_WINDOW," EDI=");
1172  PICE_sprintf(tempDisplayRegs,"%.8X\n",CurrentEDI);
1173  if(OldEDI!=CurrentEDI)
1174  {
1176  }
1177  Print(REGISTER_WINDOW,tempDisplayRegs);
1178  if(OldEDI!=CurrentEDI)
1179  {
1180  ResetColor();
1181  }
1182 
1183  // EBP
1184  Print(REGISTER_WINDOW,"EBP=");
1185  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentEBP);
1186  if(OldEBP!=CurrentEBP)
1187  {
1189  }
1190  Print(REGISTER_WINDOW,tempDisplayRegs);
1191  if(OldEBP!=CurrentEBP)
1192  {
1193  ResetColor();
1194  }
1195 
1196  // ESP
1197  Print(REGISTER_WINDOW," ESP=");
1198  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentESP);
1199  if(OldESP!=CurrentESP)
1200  {
1202  }
1203  Print(REGISTER_WINDOW,tempDisplayRegs);
1204  if(OldESP!=CurrentESP)
1205  {
1206  ResetColor();
1207  }
1208 
1209  // EIP
1210  Print(REGISTER_WINDOW," EIP=");
1211  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentEIP);
1212  if(OldEIP!=CurrentEIP)
1213  {
1215  }
1216  Print(REGISTER_WINDOW,tempDisplayRegs);
1217  if(OldEIP!=CurrentEIP)
1218  {
1219  ResetColor();
1220  }
1221 
1222  // EFL
1223  Print(REGISTER_WINDOW," EFLAGS=");
1224  PICE_sprintf(tempDisplayRegs,"%.8X",CurrentEFL);
1225  if(OldEFL!=CurrentEFL)
1226  {
1228  }
1229  Print(REGISTER_WINDOW,tempDisplayRegs);
1230  if(OldEFL!=CurrentEFL)
1231  {
1232  ResetColor();
1233  }
1234 
1235  // visual flags
1236  PICE_sprintf(tempDisplayRegs," %s\n",VisualizeFlags(CurrentEFL));
1237  Print(REGISTER_WINDOW,tempDisplayRegs);
1238 
1239  // CS
1240  Print(REGISTER_WINDOW,"CS=");
1241  PICE_sprintf(tempDisplayRegs,"%.4X",CurrentCS);
1242  if(OldCS!=CurrentCS)
1243  {
1245  }
1246  Print(REGISTER_WINDOW,tempDisplayRegs);
1247  if(OldCS!=CurrentCS)
1248  {
1249  ResetColor();
1250  }
1251 
1252  // DS
1253  Print(REGISTER_WINDOW," DS=");
1254  PICE_sprintf(tempDisplayRegs,"%.4X",CurrentDS);
1255  if(OldDS!=CurrentDS)
1256  {
1258  }
1259  Print(REGISTER_WINDOW,tempDisplayRegs);
1260  if(OldDS!=CurrentDS)
1261  {
1262  ResetColor();
1263  }
1264 
1265  // ES
1266  Print(REGISTER_WINDOW," ES=");
1267  PICE_sprintf(tempDisplayRegs,"%.4X",CurrentES);
1268  if(OldES!=CurrentES)
1269  {
1271  }
1272  Print(REGISTER_WINDOW,tempDisplayRegs);
1273  if(OldES!=CurrentES)
1274  {
1275  ResetColor();
1276  }
1277 
1278  // FS
1279  Print(REGISTER_WINDOW," FS=");
1280  PICE_sprintf(tempDisplayRegs,"%.4X",CurrentFS);
1281  if(OldFS!=CurrentFS)
1282  {
1284  }
1285  Print(REGISTER_WINDOW,tempDisplayRegs);
1286  if(OldFS!=CurrentFS)
1287  {
1288  ResetColor();
1289  }
1290 
1291  // GS
1292  Print(REGISTER_WINDOW," GS=");
1293  PICE_sprintf(tempDisplayRegs,"%.4X",CurrentGS);
1294  if(OldGS!=CurrentGS)
1295  {
1296  ResetColor();
1297  }
1298  Print(REGISTER_WINDOW,tempDisplayRegs);
1299  if(OldGS!=CurrentGS)
1300  {
1301  ResetColor();
1302  }
1303 
1304  // SS
1305  Print(REGISTER_WINDOW," SS=");
1306  PICE_sprintf(tempDisplayRegs,"%.4X",CurrentSS);
1307  if(OldSS!=CurrentSS)
1308  {
1310  }
1311  Print(REGISTER_WINDOW,tempDisplayRegs);
1312  if(OldSS!=CurrentSS)
1313  {
1314  ResetColor();
1315  }
1316 
1317  LEAVE_FUNC();
1318 }
USHORT CurrentCS
Definition: shell.c:116
ULONG OldESP
Definition: shell.c:122
void SetForegroundColor(ECOLORS c)
Definition: hardware.c:576
ULONG OldESI
Definition: shell.c:122
USHORT CurrentSS
Definition: shell.c:116
USHORT OldGS
Definition: shell.c:123
ULONG OldEIP
Definition: shell.c:120
ULONG OldEDX
Definition: shell.c:121
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
ULONG OldEDI
Definition: shell.c:122
USHORT OldFS
Definition: shell.c:123
#define LEAVE_FUNC()
Definition: debug.h:43
ULONG CurrentESI
Definition: shell.c:115
ULONG OldEAX
Definition: shell.c:121
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
USHORT OldCS
Definition: shell.c:123
USHORT OldSS
Definition: shell.c:123
void Home(USHORT Window)
Definition: hardware.c:693
ULONG CurrentEDI
Definition: shell.c:115
USHORT CurrentFS
Definition: shell.c:116
ULONG OldEBP
Definition: shell.c:122
USHORT OldDS
Definition: shell.c:123
USHORT CurrentDS
Definition: shell.c:116
LPSTR VisualizeFlags(ULONG EFlags)
Definition: utils.c:1069
ULONG CurrentEDX
Definition: shell.c:114
ULONG CurrentECX
Definition: shell.c:114
ULONG OldEBX
Definition: shell.c:121
USHORT CurrentGS
Definition: shell.c:116
ULONG OldECX
Definition: shell.c:121
#define COLOR_HILITE
Definition: hardware.h:166
USHORT OldES
Definition: shell.c:123
ULONG OldEFL
Definition: shell.c:120
ULONG CurrentEIP
Definition: shell.c:113
ULONG CurrentEBX
Definition: shell.c:114
ULONG CurrentEBP
Definition: shell.c:115
#define ENTER_FUNC()
Definition: debug.h:42
ULONG CurrentESP
Definition: shell.c:115
void ResetColor(void)
Definition: hardware.c:500
ULONG CurrentEFL
Definition: shell.c:113
USHORT CurrentES
Definition: shell.c:116
Definition: ansiprsr.h:4
ULONG CurrentEAX
Definition: shell.c:114

◆ EnablePassThrough()

void EnablePassThrough ( void  )

Definition at line 2194 of file utils.c.

Referenced by InitPICE().

2195 {
2196  ULONG oldCF8,flags;
2197 
2198  save_flags(flags);
2199  cli();
2200 
2201  oldCF8 = inl((PULONG)0xcf8);
2202  outl(0x80000050,(PULONG)0xcf8);
2203  outl(inl((PULONG)0xcfc)|0x00000020,(PULONG)0xcfc);
2204  outl(oldCF8,(PULONG)0xcf8);
2205 
2206  restore_flags(flags);
2207 }
#define save_flags(x)
Definition: utils.h:285
ULONG inl(PULONG port)
Definition: utils.c:2184
RECT cli
Definition: sndrec32.cpp:79
GLbitfield flags
Definition: glext.h:7161
VOID outl(ULONG data, PULONG port)
Definition: utils.c:2164
unsigned int * PULONG
Definition: retypes.h:1
#define restore_flags(x)
Definition: utils.h:286
unsigned int ULONG
Definition: retypes.h:1

◆ GetKeyboardLayout()

◆ GetLinearAddress()

ULONG GetLinearAddress ( USHORT  Segment,
ULONG  Offset 
)

Definition at line 782 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), ConvertTokenToHex(), IsCallInstrAtEIP(), IsRetAtEIP(), OutputIdtEntry(), PrintkCallback(), RealIsr(), UnassembleOneLineDown(), UnassembleOneLineUp(), UnassembleOnePageDown(), and UnassembleOnePageUp().

783 {
784  PGDT pGdt;
785  ULONG result=0;
786  PDESCRIPTOR pSel;
787  USHORT OriginalSegment=Segment;
788 
789  ENTER_FUNC();
790 
791  pSel=(struct tagDESCRIPTOR*)&Segment;
792 
793  // get GDT pointer
794  pGdt=GetGDTPtr();
795  DPRINT((0,"GetLinearAddress(): pGDT = %.8X\n",pGdt));
796  DPRINT((0,"GetLinearAddress(): original Segment:Offset = %.4X:%.8X\n",Segment,Offset));
797 
798  // see if segment selector is in LDT
799  if(pSel->Ti)
800  {
801  DPRINT((0,"GetLinearAddress(): Segment is in LDT\n"));
802  // get LDT selector
803  __asm__("\n\t \
804  sldt %%ax\n\t \
805  mov %%ax,%0"
806  :"=m" (Segment));
807  if(Segment)
808  {
809  DPRINT((0,"GetLinearAddress(): no LDT\n"));
810  // get LDT selector
811  pGdt=(PGDT)((pGdt[pSel->Val].Base_31_24<<24)|
812  (pGdt[pSel->Val].Base_23_16<<16)|
813  (pGdt[pSel->Val].Base_15_0));
814  if(!IsRangeValid((ULONG)pGdt,0x8) )
815  pGdt=0;
816  }
817  else
818  {
819  pGdt=0;
820  }
821  }
822 
823  if(pGdt && Segment)
824  {
825  DPRINT((0,"GetLinearAddress(): Segment:Offset = %.4X:%.8X\n",Segment,Offset));
826  result=pGdt[OriginalSegment>>3].Base_15_0|
827  (pGdt[OriginalSegment>>3].Base_23_16<<16)|
828  (pGdt[OriginalSegment>>3].Base_31_24<<24);
829  result+=Offset;
830  }
831  DPRINT((0,"GetLinearAddress(%.4X:%.8X)=%.8X\n",OriginalSegment,Offset,result));
832 
833  LEAVE_FUNC();
834 
835  return result;
836 }
#define LEAVE_FUNC()
Definition: debug.h:43
ULONG Base_15_0
Definition: utils.h:163
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
void DPRINT(...)
Definition: polytest.cpp:61
_Inout_ PVOID Segment
Definition: exfuncs.h:893
Definition: utils.h:160
BOOLEAN IsRangeValid(ULONG Addr, ULONG Length)
Definition: utils.c:735
struct tagGdt * PGDT
__asm__("\globl GetPhys\ "GetPhys:\\" "mflr 0\\" "stwu 0,-16(1)\\" "mfmsr 5\\" "andi. 6, 5, 0xffef\\" "mtmsr 6\\" "isync\\" "sync\\" "lwz 3, 0(3)\\" "mtmsr 5\\" "isync\\" "sync\\" "lwz 0, 0(1)\\" "addi 1, 1, 16\\" "mtlr 0\\" "blr")
PGDT GetGDTPtr(void)
Definition: utils.c:762
unsigned short USHORT
Definition: pedump.c:61
USHORT Ti
Definition: utils.h:191
ULONG Base_31_24
Definition: utils.h:174
USHORT Val
Definition: utils.h:192
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
ULONG Base_23_16
Definition: utils.h:164
GLuint64EXT * result
Definition: glext.h:11304

◆ inb_p()

UCHAR inb_p ( PUCHAR  port)

Definition at line 2179 of file utils.c.

Referenced by DebuggerShell(), GetKeyData(), GetKeyStatus(), HideCursorVga(), RestoreGraphicsStateVga(), SaveGraphicsStateVga(), and ShowCursorVga().

2180 {
2181  return READ_PORT_UCHAR((PUCHAR)port);
2182 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
USHORT port
Definition: uri.c:227

◆ inl()

ULONG inl ( PULONG  port)

Definition at line 2184 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), and EnablePassThrough().

2185 {
2186  return READ_PORT_ULONG(port);
2187 }
ULONG NTAPI READ_PORT_ULONG(IN PULONG Port)
Definition: portio.c:70
USHORT port
Definition: uri.c:227

◆ inportb()

UCHAR inportb ( PUCHAR  port)

Definition at line 2174 of file utils.c.

Referenced by read_vga_reg(), SerialReadByte(), SerialSendByte(), SerialSetOthers(), and SerialSetSpeed().

2175 {
2176  return READ_PORT_UCHAR((PUCHAR)port);
2177 }
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR NTAPI READ_PORT_UCHAR(PUCHAR Address)
Definition: mach.c:535
USHORT port
Definition: uri.c:227

◆ IntelStackWalk()

void IntelStackWalk ( ULONG  pc,
ULONG  ebp,
ULONG  esp 
)

Definition at line 1530 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), and HandleInDebuggerFault().

1531 {
1532  PULONG pFrame, pPrevFrame;
1533  LPSTR pSymbolName;
1534 
1535  DPRINT((0,"IntelStackWalk(): pc = %X ebp = %X esp = %X\n",pc,ebp,esp));
1536 
1537  pFrame = pPrevFrame = (PULONG)ebp;
1538 
1539  PutStatusText("EIP FRAME NAME\n");
1540  while(1)
1541  {
1542  DPRINT((0,"IntelStackWalk(): pFrame = %X pPrevFrame = %X pc =%X\n",(ULONG)pFrame,(ULONG)pPrevFrame,pc));
1543  if ( ( (ULONG)pFrame & 3 ) ||
1544  ( (pFrame <= pPrevFrame) ) )
1545  {
1546  DPRINT((0,"IntelStackWalk(): pFrame is either unaligned or not less than previous\n"));
1547  if( !IsRangeValid((ULONG)pFrame, sizeof(PVOID)*2) )
1548  {
1549  DPRINT((0,"IntelStackWalk(): pFrame not valid pointer!\n"));
1550  break;
1551  }
1552  }
1553 
1554  if((pSymbolName = FindFunctionByAddress(pc,NULL,NULL)) )
1555  PICE_sprintf(tempUtil,"%08X %08X %s\n",pc, (ULONG)pFrame,pSymbolName);
1556  else
1557  PICE_sprintf(tempUtil,"%08X %08X\n",pc, (ULONG)pFrame);
1559  if(WaitForKey()==FALSE)break;
1560 
1561  pc = pFrame[1];
1562 
1563  pPrevFrame = pFrame;
1564 
1565  pFrame = (PULONG)pFrame[0]; // proceed to next higher frame on stack
1566  }
1567 }
void PutStatusText(LPSTR p)
Definition: parse.c:360
ecx edi ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 mm1 mm5 paddd mm0 paddd mm4 mm0 mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 mm1 paddd mm0 mm0 packssdw mm0 movd eax movw edi esi edx esi ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 mm1 mm5 paddd mm1 paddd mm5 mm1 mm5 packssdw mm1 packssdw mm5 psubd mm0 psubd mm4 psubsw mm0 psubsw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 mm1 paddd mm1 mm1 packssdw mm1 psubd mm0 psubsw mm0 movd eax movw edi emms popl ebx popl esi popl edi mov ebp
Definition: synth_sse3d.h:248
int PICE_sprintf(char *buf, const char *fmt,...)
Definition: utils.c:2053
char * LPSTR
Definition: xmlstorage.h:182
void Print(USHORT Window, LPSTR p)
Definition: hardware.c:797
LPSTR FindFunctionByAddress(ULONG ulValue, PULONG pulstart, PULONG pulend)
Definition: symbols.c:767
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
char tempUtil[1024]
Definition: utils.c:42
BOOLEAN IsRangeValid(ULONG Addr, ULONG Length)
Definition: utils.c:735
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
static VOID WaitForKey(VOID)
Definition: hardware.c:84

◆ IsAddressValid()

BOOLEAN IsAddressValid ( ULONG  Addr)

Definition at line 611 of file utils.c.

Referenced by BuildModuleList(), COMMAND_PROTOTYPE(), DeInstallSWBreakpoint(), ExtractNumber(), ExtractStructMembers(), ExtractTypeName(), FindFunctionByAddress(), FindSourceLineForAddress(), GetUCHAR(), HandlePageFault(), InstallSWBreakpoint(), IsRangeValid(), ListSymbolStartingAt(), ListUserModules(), NeedToReInstallSWBreakpoints(), PICE_fncmp(), PICE_fnncmp(), PICE_strchr(), PICE_strcmp(), PICE_strcmpi(), PICE_strlen(), PICE_strncmpi(), PICE_strnlen(), PICE_wcsicmp(), PrintkCallback(), ReInstallSWBreakpoint(), RemoveAllSWBreakpoints(), RemoveSWBreakpoint(), RevirtualizeBreakpointsForModule(), ScanExportsByAddress(), ShowStatusLine(), and TryToInstallVirtualSWBreakpoints().

612 {
613  PULONG pPGD;
614  PULONG pPTE;
615  BOOLEAN bResult = FALSE;
616 
617  address &= (~(_PAGE_SIZE-1));
618 
619  pPGD = ADDR_TO_PDE(address);
620  if(pPGD && ((*pPGD)&_PAGE_PRESENT))
621  {
622  // not large page
623  if(!((*pPGD)&_PAGE_4M))
624  {
625  pPTE = ADDR_TO_PTE(address);
626  if(pPTE)
627  {
628  bResult = (*pPTE)&(_PAGE_PRESENT | _PAGE_PSE);
629  }
630  }
631  // large page
632  else
633  {
634  bResult = TRUE;
635  }
636  }
637 
638  return bResult;
639 }
#define TRUE
Definition: types.h:120
#define _PAGE_4M
Definition: utils.h:268
#define ADDR_TO_PTE(v)
Definition: parse.h:181
unsigned char BOOLEAN
#define _PAGE_PRESENT
Definition: compat.h:67
#define _PAGE_SIZE
Definition: utils.h:269
GLuint address
Definition: glext.h:9393
#define _PAGE_PSE
Definition: utils.h:267
#define ADDR_TO_PDE(v)
Definition: parse.h:179
unsigned int * PULONG
Definition: retypes.h:1

◆ IsAddressWriteable()

BOOLEAN IsAddressWriteable ( ULONG  Addr)

Definition at line 650 of file utils.c.

Referenced by DeInstallSWBreakpoint(), InstallSWBreakpoint(), ReInstallSWBreakpoint(), RemoveAllSWBreakpoints(), RemoveSWBreakpoint(), RevirtualizeBreakpointsForModule(), and TryToInstallVirtualSWBreakpoints().

651 {
652  PULONG pPGD;
653  PULONG pPTE;
654 
655  //address &= (~(_PAGE_SIZE-1));
656  pPGD = ADDR_TO_PDE(address);
657  if(pPGD && ((*pPGD)&_PAGE_PRESENT))
658  {
659  // not large page
660  if(!((*pPGD)&_PAGE_4M))
661  {
662  if(!((*pPGD) & _PAGE_RW))
663  return FALSE;
664 
665  pPTE = ADDR_TO_PTE(address);
666  if(pPTE)
667  {
668  if( ((*pPTE)&(_PAGE_PRESENT | _PAGE_PSE)) &&
669  ((*pPTE) & _PAGE_RW))
670  return TRUE;
671  else
672  return FALSE;
673  }
674  }
675  // large page
676  else
677  return ((*pPGD) & _PAGE_RW);
678  }
679 
680  return FALSE;
681 }
#define TRUE
Definition: types.h:120
#define _PAGE_4M
Definition: utils.h:268
#define ADDR_TO_PTE(v)
Definition: parse.h:181
#define _PAGE_PRESENT
Definition: compat.h:67
GLuint address
Definition: glext.h:9393
#define _PAGE_PSE
Definition: utils.h:267
#define ADDR_TO_PDE(v)
Definition: parse.h:179
unsigned int * PULONG
Definition: retypes.h:1
#define _PAGE_RW
Definition: compat.h:71

◆ IsCallInstrAtEIP()

BOOLEAN IsCallInstrAtEIP ( void  )

Definition at line 1008 of file utils.c.

Referenced by COMMAND_PROTOTYPE().

1009 {
1010 PUCHAR linear;
1012 
1013  ENTER_FUNC();
1014  DPRINT((0,"IsCallInstrAtEIP()\n"));
1015 
1017  if(IsRangeValid((ULONG)linear,2))
1018  {
1019  if(*linear== 0xE8 || // call
1020  (*linear== 0xFF && ( ((*(linear+1)>>3)&0x7)==0x2 || ((*(linear+1)>>3)&0x7)==0x3) ) || // call
1021  *linear== 0x9A || // call
1022  *linear== 0xF2 || // REP
1023  *linear== 0xF3) // REP
1024  result=TRUE;
1025  }
1026 
1027  LEAVE_FUNC();
1028 
1029  return result;
1030 }
USHORT CurrentCS
Definition: shell.c:116
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
#define LEAVE_FUNC()
Definition: debug.h:43
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
BOOLEAN IsRangeValid(ULONG Addr, ULONG Length)
Definition: utils.c:735
ULONG GetLinearAddress(USHORT Segment, ULONG Offset)
Definition: utils.c:782
ULONG CurrentEIP
Definition: shell.c:113
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3706
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
GLuint64EXT * result
Definition: glext.h:11304

◆ IsRangeValid()

BOOLEAN IsRangeValid ( ULONG  addr,
ULONG  Length 
)

Definition at line 735 of file utils.c.

Referenced by EvaluateSymbol(), ExtractStructMembers(), FindFunctionByAddress(), GetLinearAddress(), IntelStackWalk(), IsCallInstrAtEIP(), ListSymbolStartingAt(), RestoreIdt(), RevirtualizeBreakpointsForModule(), ScanExportsByAddress(), TakeIdtSnapshot(), and ValidityCheckSymbols().

736 {
737 ULONG i,NumPages,PageNum;
738 
739  // need to only touch one byte per page
740  // calculate PICE_number of pages to touch
741  NumPages=(Length+(_PAGE_SIZE-1))>>12;
742 
743  // calculate PICE_number of page
744  PageNum=Addr>>PAGE_SHIFT;
745 
746  // touch all pages containing range
747  for(i=0;i<NumPages;i++)
748  {
749  // if any one page is invalid range is invalid
750  if(!IsAddressValid((ULONG)((PageNum+i)*_PAGE_SIZE)) )
751  return FALSE;
752  }
753 
754  return TRUE;
755 }
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
#define TRUE
Definition: types.h:120
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define _PAGE_SIZE
Definition: utils.h:269
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

◆ IsRetAtEIP()

BOOLEAN IsRetAtEIP ( void  )

Definition at line 1038 of file utils.c.

1039 {
1040  PUCHAR linear;
1041  BOOLEAN bResult = FALSE;
1042 
1043  ENTER_FUNC();
1044  DPRINT((0,"IsRetAtEIP()\n"));
1045 
1047 
1048  switch(*linear)
1049  {
1050  case 0xc2:
1051  case 0xc3:
1052  case 0xca:
1053  case 0xcb:
1054  case 0xcf: // IRET/IRETD
1055  bResult = TRUE;
1056  break;
1057  }
1058 
1059  LEAVE_FUNC();
1060 
1061  return bResult;
1062 }
USHORT CurrentCS
Definition: shell.c:116
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
#define LEAVE_FUNC()
Definition: debug.h:43
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
ULONG GetLinearAddress(USHORT Segment, ULONG Offset)
Definition: utils.c:782
ULONG CurrentEIP
Definition: shell.c:113
#define ENTER_FUNC()
Definition: debug.h:42

◆ KeyboardFlushKeyboardQueue()

void KeyboardFlushKeyboardQueue ( void  )

Definition at line 1455 of file utils.c.

Referenced by ConsoleInitHercules(), and ConsoleInitVga().

1456 {
1457  //__udelay(10);
1460  {
1461  GetKeyData();
1462  //__udelay(10);
1464  }
1465 }
#define OUTPUT_BUFFER_FULL
Definition: utils.h:231
UCHAR GetKeyStatus(void)
Definition: utils.c:1353
UCHAR GetKeyData(void)
Definition: utils.c:1364
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99

◆ KeyboardGetKeyPolled()

UCHAR KeyboardGetKeyPolled ( void  )

Definition at line 1375 of file utils.c.

Referenced by ConsoleInitHercules(), and ConsoleInitVga().

1376 {
1377  UCHAR ucKey;
1378  UCHAR ucStatus;
1379  static BOOLEAN bExtended = FALSE;
1380 
1381  while(ucKey=0,(ucStatus=GetKeyStatus())&OUTPUT_BUFFER_FULL)
1382  {
1383  ucKey = 0;
1384  ucKey = GetKeyData();
1385 
1386  if(ucStatus&MOUSE_OUTPUT_BUFFER_FULL)
1387  continue;
1388 
1389  DPRINT((1,"GetKeyPolled(): key = %x bExtended=%s\n",ucKey,bExtended?"TRUE":"FALSE"));
1390 
1391  if(SCANCODE_EXTENDED == ucKey)
1392  {
1393  DPRINT((1,"extended switched ON\n"));
1394  bExtended = TRUE;
1395  continue;
1396  }
1397  else
1398  {
1399  if(!(ucKey&0x80)) // keypress
1400  {
1401  switch(ucKey&0x7f)
1402  {
1403  case SCANCODE_L_CTRL:
1404  case SCANCODE_R_CTRL:
1405  if(!bExtended)
1406  bControl=TRUE;
1407  break;
1408  case SCANCODE_L_SHIFT:
1409  case SCANCODE_R_SHIFT:
1410  if(!bExtended)
1411  bShift=TRUE;
1412  break;
1413  case SCANCODE_L_ALT:
1414  case SCANCODE_R_ALT:
1415  if(!bExtended)
1416  bAlt=TRUE;
1417  break;
1418  default:
1419  DPRINT((0,"GetKeyPolled(): control = %u shift = %u alt = %u\n",bControl,bShift,bAlt));
1420  return ucKey;
1421  }
1422  }
1423  else
1424  {
1425  switch(ucKey&0x7f)
1426  {
1427  case SCANCODE_L_CTRL:
1428  case SCANCODE_R_CTRL:
1429  if(!bExtended)
1430  bControl=FALSE;
1431  break;
1432  case SCANCODE_L_SHIFT:
1433  case SCANCODE_R_SHIFT:
1434  if(!bExtended)
1435  bShift=FALSE;
1436  break;
1437  case SCANCODE_L_ALT:
1438  case SCANCODE_R_ALT:
1439  if(!bExtended)
1440  bAlt=FALSE;
1441  break;
1442  }
1443  }
1444  }
1445  bExtended=FALSE;
1446  }
1447 
1448  return ucKey;
1449 }
#define SCANCODE_L_CTRL
Definition: scancodes.h:40
#define TRUE
Definition: types.h:120
volatile BOOLEAN bShift
Definition: shell.c:71
#define SCANCODE_L_SHIFT
Definition: scancodes.h:42
#define SCANCODE_R_CTRL
Definition: scancodes.h:41
#define MOUSE_OUTPUT_BUFFER_FULL
Definition: utils.h:233
unsigned char BOOLEAN
void DPRINT(...)
Definition: polytest.cpp:61
#define SCANCODE_R_ALT
Definition: scancodes.h:45
volatile BOOLEAN bControl
Definition: shell.c:70
#define SCANCODE_EXTENDED
Definition: scancodes.h:24
volatile BOOLEAN bAlt
Definition: shell.c:72
unsigned char UCHAR
Definition: xmlstorage.h:181
#define SCANCODE_R_SHIFT
Definition: scancodes.h:43
#define OUTPUT_BUFFER_FULL
Definition: utils.h:231
UCHAR GetKeyStatus(void)
Definition: utils.c:1353
UCHAR GetKeyData(void)
Definition: utils.c:1364
#define SCANCODE_L_ALT
Definition: scancodes.h:44

◆ outb_p()

void outb_p ( UCHAR  data,
PUCHAR  port 
)

Definition at line 2159 of file utils.c.

Referenced by ConsoleInitHercules(), ConsoleShutdownHercules(), DebuggerShell(), HideCursorVga(), PrintCursorVga(), RestoreGraphicsStateVga(), SaveGraphicsStateVga(), and ShowCursorVga().

2160 {
2162 }
unsigned char * PUCHAR
Definition: retypes.h:3
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539
USHORT port
Definition: uri.c:227

◆ outl()

VOID outl ( ULONG  l,
PULONG  port 
)

Definition at line 2164 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), and EnablePassThrough().

2165 {
2167 }
VOID NTAPI WRITE_PORT_ULONG(IN PULONG Port, IN ULONG Value)
Definition: portio.c:123
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
USHORT port
Definition: uri.c:227

◆ outportb()

void outportb ( PUCHAR  port,
UCHAR  data 
)

Definition at line 2154 of file utils.c.

Referenced by read_vga_reg(), SerialSendByte(), SerialSetOthers(), SerialSetSpeed(), and write_vga_reg().

2155 {
2157 }
unsigned char * PUCHAR
Definition: retypes.h:3
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void WRITE_PORT_UCHAR(PUCHAR Address, UCHAR Value)
Definition: mach.c:539
USHORT port
Definition: uri.c:227

◆ PICE_close()

int PICE_close ( HANDLE  hFile)

Definition at line 2300 of file utils.c.

Referenced by LoadExports(), LoadSymbols(), and LoadSymbolsFromConfig().

2301 {
2302  if (NT_SUCCESS( ZwClose((HANDLE)hFile)))
2303  {
2304  return 0;
2305  }
2306  DPRINT((0,"ZwClose failed:\n"));
2307  return -1;
2308 }
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24

◆ PICE_free()

void PICE_free ( void p)

Definition at line 2222 of file utils.c.

Referenced by ConsoleShutdownSerial(), ConsoleShutdownVga(), LoadSymbols(), UnloadExports(), and UnloadSymbols().

2223 {
2224  ASSERT( p );
2225  ExFreePool( p );
2226 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ PICE_isalpha()

int PICE_isalpha ( int  c)

Definition at line 352 of file utils.c.

Referenced by ExtractToken().

353 {
354  return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
355 }
const GLubyte * c
Definition: glext.h:8905

◆ PICE_isdigit()

int PICE_isdigit ( int  c)

Definition at line 337 of file utils.c.

Referenced by AddToRingBuffer(), EvaluateSymbol(), ExtractNumber(), ExtractToken(), PICE_isxdigit(), and simple_strtoul().

338 {
339  return ((c>=0x30) && (c<=0x39));
340 }
const GLubyte * c
Definition: glext.h:8905

◆ PICE_islower()

int PICE_islower ( int  c)

Definition at line 347 of file utils.c.

Referenced by simple_strtoul().

348 {
349  return ((c>=0x61) && (c<=0x7a));
350 }
const GLubyte * c
Definition: glext.h:8905

◆ PICE_isprint()

BOOLEAN PICE_isprint ( char  c)

Definition at line 248 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), and Parse().

249 {
250  BOOLEAN bResult = FALSE;
251 
252  if((ULONG)c>=0x20 && (ULONG)c<=0x7f)
253  bResult = TRUE;
254 
255  return bResult;
256 }
#define TRUE
Definition: types.h:120
unsigned char BOOLEAN
const GLubyte * c
Definition: glext.h:8905
unsigned int ULONG
Definition: retypes.h:1

◆ PICE_isxdigit()

int PICE_isxdigit ( int  c)

Definition at line 342 of file utils.c.

Referenced by simple_strtoul().

343 {
344  return (PICE_isdigit(c) || ((c>=0x41) && (c<=0x46)) || ((c>=0x61) && (c<=0x66)));
345 }
int PICE_isdigit(int c)
Definition: utils.c:337
const GLubyte * c
Definition: glext.h:8905

◆ PICE_len()

size_t PICE_len ( HANDLE  hFile)

Definition at line 2310 of file utils.c.

Referenced by LoadExports(), LoadSymbols(), and LoadSymbolsFromConfig().

2311 {
2314  NTSTATUS status;
2315 
2316  status = ZwQueryInformationFile( hFile, &iosb, &fs, sizeof fs, FileStandardInformation );
2317  if( !NT_SUCCESS( status ) ){
2318  DPRINT((0,"PICE_len: ZwQueryInformationFile error: %x\n", status));
2319  return 0;
2320  }
2321  //ASSERT(fs.EndOfFile.u.HighPart == 0);
2322  return (size_t)fs.EndOfFile.u.LowPart;
2323 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
struct _LARGE_INTEGER::@2193 u
LONG NTSTATUS
Definition: precomp.h:26
LARGE_INTEGER EndOfFile
Definition: nt_native.h:948
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define fs
Definition: i386-dis.c:435
static SERVICE_STATUS status
Definition: service.c:31

◆ PICE_malloc()

void* PICE_malloc ( size_t  numBytes,
BOOLEAN  fromPaged 
)

Definition at line 2212 of file utils.c.

Referenced by ConsoleInitSerial(), ConsoleInitVga(), LoadExports(), LoadSymbols(), and LoadSymbolsFromConfig().

2213 {
2214  void* res = ExAllocatePool( (fromPaged)?PagedPool:NonPagedPool, numBytes );
2215  ASSERT(res);
2216  return res;
2217 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
GLuint res
Definition: glext.h:9613

◆ PICE_memcpy()

void PICE_memcpy ( void t,
void s,
int  sz 
)

◆ PICE_memset()

◆ PICE_MultiByteToWideChar()

INT WINAPI PICE_MultiByteToWideChar ( UINT  CodePage,
DWORD  dwFlags,
LPCSTR  lpMultiByteStr,
int  cchMultiByte,
LPWSTR  lpWideCharStr,
int  cchWideChar 
)

Definition at line 2335 of file utils.c.

Referenced by FindModuleByName(), FindModuleSymbolsByModuleName(), and LoadSymbols().

2343 {
2344  int InStringLength = 0;
2345  BOOL InIsNullTerminated = TRUE;
2346  PCHAR r;
2347  PWCHAR w;
2348  int cchConverted;
2349 
2350  /*
2351  * Check the parameters.
2352  */
2353  if ( /* --- CODE PAGE --- */
2354  ( (CP_ACP != CodePage)
2355  && (CP_MACCP != CodePage)
2356  && (CP_OEMCP != CodePage))
2357  /* --- FLAGS --- */
2358  /*|| (dwFlags ^ ( MB_PRECOMPOSED
2359  | MB_COMPOSITE
2360  | MB_ERR_INVALID_CHARS
2361  | MB_USEGLYPHCHARS
2362  )
2363  )*/
2364  /* --- INPUT BUFFER --- */
2365  || (NULL == lpMultiByteStr)
2366  )
2367  {
2368  DPRINT((0,"ERROR_INVALID_PARAMETER\n"));
2369  return 0;
2370  }
2371  /*
2372  * Compute the input buffer length.
2373  */
2374  if (-1 == cchMultiByte)
2375  {
2376  InStringLength = PICE_strlen(lpMultiByteStr);
2377  }
2378  else
2379  {
2380  InIsNullTerminated = FALSE;
2381  InStringLength = cchMultiByte;
2382  }
2383  /*
2384  * Does caller query for output
2385  * buffer size?
2386  */
2387  if (0 == cchWideChar)
2388  {
2389  DPRINT((0,"ERROR_SUCCESS\n"));
2390  return InStringLength;
2391  }
2392  /*
2393  * Is space provided for the translated
2394  * string enough?
2395  */
2396  if (cchWideChar < InStringLength)
2397  {
2398  DPRINT((0,"ERROR_INSUFFICIENT_BUFFER: cchWideChar: %d, InStringLength: %d\n", cchWideChar, InStringLength));
2399  return 0;
2400  }
2401  /*
2402  * Raw 8- to 16-bit conversion.
2403  */
2404  for ( cchConverted = 0,
2405  r = (PCHAR) lpMultiByteStr,
2406  w = (PWCHAR) lpWideCharStr;
2407 
2408  ((*r) && (cchConverted < cchWideChar));
2409 
2410  r++, w++,
2411  cchConverted++
2412  )
2413  {
2414  *w = (WCHAR) *r;
2415  }
2416  /*
2417  * Is the input string NULL terminated?
2418  */
2419  if (TRUE == InIsNullTerminated)
2420  {
2421  *w = L'\0';
2422  ++cchConverted;
2423  }
2424  /*
2425  * Return how many characters we
2426  * wrote in the output buffer.
2427  */
2428  return cchConverted;
2429 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define CP_ACP
Definition: compat.h:99
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
uint16_t * PWCHAR
Definition: typedefs.h:54
#define WCHAR
Definition: msvc.h:43
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
unsigned int BOOL
Definition: ntddk_ex.h:94
static const WCHAR L[]
Definition: oid.c:1087
#define CP_OEMCP
Definition: winnls.h:219
#define CP_MACCP
Definition: winnls.h:220

◆ PICE_open()

HANDLE PICE_open ( LPCWSTR  lpPathName,
int  iReadWrite 
)

Definition at line 2250 of file utils.c.

Referenced by LoadExports(), LoadSymbols(), and LoadSymbolsFromConfig().

2251 {
2252  DWORD dwAccessMask = 0;
2253  DWORD dwShareMode = 0;
2254  UNICODE_STRING TmpFileName;
2256  IO_STATUS_BLOCK StatusBlock;
2257  HANDLE hfile;
2258  NTSTATUS status;
2259 
2260 
2261  DPRINT((0,"PICE_open: %S\n", lpPathName));
2262 
2263  if ( (iReadWrite & OF_READWRITE ) == OF_READWRITE )
2264  dwAccessMask = GENERIC_READ | GENERIC_WRITE;
2265  else if ( (iReadWrite & OF_READ ) == OF_READ )
2266  dwAccessMask = GENERIC_READ;
2267  else if ( (iReadWrite & OF_WRITE ) == OF_WRITE )
2268  dwAccessMask = GENERIC_WRITE;
2269 
2270  if ((iReadWrite & OF_SHARE_COMPAT) == OF_SHARE_COMPAT )
2272  else if ((iReadWrite & OF_SHARE_DENY_NONE) == OF_SHARE_DENY_NONE)
2274  else if ((iReadWrite & OF_SHARE_DENY_READ) == OF_SHARE_DENY_READ)
2275  dwShareMode = FILE_SHARE_WRITE | FILE_SHARE_DELETE;
2276  else if ((iReadWrite & OF_SHARE_DENY_WRITE) == OF_SHARE_DENY_WRITE )
2277  dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
2278  else if ((iReadWrite & OF_SHARE_EXCLUSIVE) == OF_SHARE_EXCLUSIVE)
2279  dwShareMode = 0;
2280 
2281  RtlInitUnicodeString (&TmpFileName, lpPathName);
2282  InitializeObjectAttributes(&ObjectAttributes,
2283  &TmpFileName,
2284  0,
2285  NULL,
2286  NULL);
2287 
2288  status = NtOpenFile( &hfile,
2289  dwAccessMask,
2290  &ObjectAttributes,
2291  &StatusBlock, dwShareMode, FILE_NO_INTERMEDIATE_BUFFERING);
2292  //BUG BUG check status!!!
2293  if( !NT_SUCCESS( status ) ){
2294  DPRINT((0,"PICE_open: NtOpenFile error: %x\n", status));
2295  return 0;
2296  }
2297  return hfile;
2298 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define OF_READ
Definition: winbase.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define OF_SHARE_DENY_WRITE
Definition: winbase.h:122
#define FILE_SHARE_READ
Definition: compat.h:125
#define FILE_NO_INTERMEDIATE_BUFFERING
Definition: from_kernel.h:28
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define OF_SHARE_DENY_READ
Definition: winbase.h:121
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3929
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define OF_WRITE
Definition: winbase.h:118
#define GENERIC_READ
Definition: compat.h:124
#define OF_READWRITE
Definition: winbase.h:117
#define OF_SHARE_COMPAT
Definition: winbase.h:119
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define OF_SHARE_DENY_NONE
Definition: winbase.h:120
static SERVICE_STATUS status
Definition: service.c:31
#define OF_SHARE_EXCLUSIVE
Definition: winbase.h:123

◆ PICE_read()

long PICE_read ( HANDLE  hFile,
LPVOID  lpBuffer,
long  lBytes 
)

Definition at line 2228 of file utils.c.

Referenced by LoadExports(), LoadSymbols(), and LoadSymbolsFromConfig().

2229 {
2230  DWORD NumberOfBytesRead;
2232 
2233  ASSERT( lpBuffer );
2234 
2235  if (!NT_SUCCESS(NtReadFile(
2236  hFile,
2237  NULL, NULL, NULL, &iosb,
2238  lpBuffer,
2239  (DWORD) lBytes,
2240  NULL,
2241  NULL
2242  )))
2243  {
2244  return -1;
2245  }
2246  NumberOfBytesRead = iosb.Information;
2247  return NumberOfBytesRead;
2248 }
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)

◆ PICE_sprintf()

int PICE_sprintf ( char buf,
const char fmt,
  ... 
)

Definition at line 2053 of file utils.c.

Referenced by CheckLoadAbort(), COMMAND_PROTOTYPE(), DebuggerShell(), Disassembler(), DisplayRegs(), DisplaySourceFile(), Evaluate(), FindCommand(), FindFunctionByAddress(), IntelStackWalk(), ListSWBreakpoints(), ListSymbolStartingAt(), LoadExports(), OutputIdtEntry(), Parse(), pice_ioctl(), PICE_number(), PiceRunningTimer(), RealIsr(), RevirtualizeBreakpointsForModule(), ScanExportsByAddress(), and ShowStatusLine().

2054 {
2055  va_list args;
2056  int i;
2057 
2058  va_start(args, fmt);
2059  i = PICE_vsprintf(buf,fmt,args);
2060  va_end(args);
2061  return i;
2062 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
int PICE_vsprintf(char *buf, const char *fmt, va_list args)
Definition: utils.c:1850
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define args
Definition: format.c:66
Definition: dsound.c:943

◆ PICE_strcat()

char* PICE_strcat ( char s1,
char s2 
)

Definition at line 315 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), DebuggerShell(), DecodeVmFlags(), FindAddressForSourceLine(), FindCommand(), FindGlobalStabSymbol(), FindLocalsByAddress(), FindTypeDefinition(), and FindTypeDefinitionForCombinedTypes().

316 {
317  ULONG len1 = PICE_strlen(s1);
318  ULONG len2 = PICE_strlen(s2);
319 
320  PICE_memcpy(&s1[len1],s2,len2+1);
321 
322  return s1;
323 }
struct S2 s2
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
struct S1 s1
void PICE_memcpy(void *t, void *s, int sz)
Definition: utils.c:239
unsigned int ULONG
Definition: retypes.h:1

◆ PICE_strchr()

char* PICE_strchr ( char s,
char  c 
)

Definition at line 262 of file utils.c.

Referenced by ConvertTokenToModuleAndName(), ConvertTokenToSymbol(), EvaluateSymbol(), ExtractArray(), ExtractStructMembers(), ExtractTypeNumber(), FindGlobalStabSymbol(), FindTypeDefinition(), FindTypeDefinitionForCombinedTypes(), and Parse().

263 {
264  while(IsAddressValid((ULONG)s) && *s)
265  {
266  if(*s == c)
267  return s;
268  s++;
269  }
270 #ifdef DEBUG
271  if(!IsAddressValid((ULONG)s) )
272  {
273  DPRINT((0,"PICE_strchr(): ********************\n"));
274  DPRINT((0,"PICE_strchr(): EXCEPTION @ %.8X\n",(ULONG)s));
275  DPRINT((0,"PICE_strchr(): ********************\n"));
276  }
277 #endif
278 
279  return NULL;
280 }
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
const GLubyte * c
Definition: glext.h:8905
GLdouble s
Definition: gl.h:2039
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

◆ PICE_strcmp()

ULONG PICE_strcmp ( char s1,
char s2 
)

Definition at line 410 of file utils.c.

411 {
412  ULONG result=1;
413 
414  while(IsAddressValid((ULONG)s1) && *s1 && // not end of string
415  IsAddressValid((ULONG)s2) && *s2 && // not end of string
416  (*s1)==(*s2) )
417  {
418  s1++;
419  s2++;
420  }
421  // strings same length
422  if(*s1==0 && *s2==0)
423  result=0;
424 
425  return result;
426 }
struct S2 s2
struct S1 s1
unsigned int ULONG
Definition: retypes.h:1
GLuint64EXT * result
Definition: glext.h:11304
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

◆ PICE_strcmpi()

ULONG PICE_strcmpi ( char s1,
char s2 
)

Definition at line 387 of file utils.c.

Referenced by AddToCommandLineHistory(), COMMAND_PROTOTYPE(), ConvertTokenToModule(), ConvertTokenToSrcFile(), FindAddressForSourceLine(), FindGlobalStabSymbol(), FindSourceLineForAddress(), FindVirtualSwBp(), IsModuleLoaded(), LoadSymbolsFromConfig(), ReplaceKeywordWithValue(), and SetKeyboardLayoutByName().

388 {
389 ULONG result=1;
390 
391  while(IsAddressValid((ULONG)s1) && *s1 && // not end of string
392  IsAddressValid((ULONG)s2) && *s2 && // not end of string
393  PICE_toupper(*s1)==PICE_toupper(*s2) ) // char are the same except case
394  {
395  s1++;
396  s2++;
397  }
398  // strings same length
399  if(*s1==0 && *s2==0)
400  result=0;
401 
402  return result;
403 }
struct S2 s2
struct S1 s1
char PICE_toupper(char c)
Definition: utils.c:329
unsigned int ULONG
Definition: retypes.h:1
GLuint64EXT * result
Definition: glext.h:11304
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

◆ PICE_strcpy()

◆ PICE_strlen()

◆ PICE_strncmpi()

ULONG PICE_strncmpi ( char s1,
char s2,
ULONG  len 
)

Definition at line 362 of file utils.c.

Referenced by AddToRingBuffer(), ConvertTokenToModule(), ConvertTokenToSrcFile(), FindCommand(), and Parse().

363 {
364 ULONG result=1;
365 
366  while(len &&
367  IsAddressValid((ULONG)s1) && *s1 && // not end of string
368  IsAddressValid((ULONG)s2) && *s2 && // not end of string
369  PICE_toupper(*s1)==PICE_toupper(*s2) ) // char are the same except case
370  {
371  s1++;
372  s2++;
373  len--;
374  }
375  // strings same length
376  if(len==0)
377  result=0;
378 
379  return result;
380 }
struct S2 s2
struct S1 s1
GLenum GLsizei len
Definition: glext.h:6722
char PICE_toupper(char c)
Definition: utils.c:329
unsigned int ULONG
Definition: retypes.h:1
GLuint64EXT * result
Definition: glext.h:11304
BOOLEAN IsAddressValid(ULONG address)
Definition: utils.c:611

◆ PICE_strncpy()

char* PICE_strncpy ( char s1,
char s2,
int  len 
)

Definition at line 286 of file utils.c.

Referenced by ConvertTokenToKeyword(), ConvertTokenToOnOff(), ConvertTokenToSpecialKeyword(), ExtractStructMembers(), FindAddressForSourceLine(), FindGlobalStabSymbol(), FindLocalsByAddress(), and FindSourceLineForAddress().

287 {
288  ULONG len2 = PICE_strlen(s2);
289 
290  if(len<len2)
291  PICE_memcpy(s1,s2,len2+1);
292  else
293  PICE_memcpy(s1,s2,len);
294 
295  return s1;
296 }
struct S2 s2
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
struct S1 s1
void PICE_memcpy(void *t, void *s, int sz)
Definition: utils.c:239
GLenum GLsizei len
Definition: glext.h:6722
unsigned int ULONG
Definition: retypes.h:1

◆ PICE_strrev()

char* PICE_strrev ( char )

Definition at line 527 of file utils.c.

Referenced by COMMAND_PROTOTYPE(), and VisualizeFlags().

528 {
529 ULONG i,j,len=PICE_strlen(s)-1;
530 char c;
531 
532  for(i=0,j=len;i<j;i++,j--)
533  {
534  c=s[i]; s[i]=s[j]; s[j]=c;
535  }
536 
537  return s;
538 }
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
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
#define c
Definition: ke_i.h:80
unsigned int ULONG
Definition: retypes.h:1

◆ PICE_vsprintf()

int PICE_vsprintf ( char buf,
const char fmt,
va_list  args 
)

Definition at line 1850 of file utils.c.

Referenced by PICE_sprintf(), and printk().

1851 {
1852  int len;
1853  unsigned long num;
1854  int i, base;
1855  char * str;
1856  const char *s;
1857  const wchar_t *sw;
1858 
1859  int flags; /* flags to PICE_number() */
1860 
1861  int field_width; /* width of output field */
1862  int precision; /* min. # of digits for integers; max
1863  PICE_number of chars for from string */
1864  int qualifier; /* 'h', 'l', or 'L' for integer fields */
1865 
1866  for (str=buf ; *fmt ; ++fmt) {
1867  if (*fmt != '%') {
1868  *str++ = *fmt;
1869  continue;
1870  }
1871 
1872  /* process flags */
1873  flags = 0;
1874  repeat:
1875  ++fmt; /* this also skips first '%' */
1876  switch (*fmt) {
1877  case '-': flags |= NUM_LEFT; goto repeat;
1878  case '+': flags |= NUM_PLUS; goto repeat;
1879  case ' ': flags |= NUM_SPACE; goto repeat;
1880  case '#': flags |= NUM_SPECIAL; goto repeat;
1881  case '0': flags |= NUM_ZEROPAD; goto repeat;
1882  }
1883 
1884  /* get field width */
1885  field_width = -1;
1886  if (is_digit(*fmt))
1887  field_width = skip_atoi(&fmt);
1888  else if (*fmt == '*') {
1889  ++fmt;
1890  /* it's the next argument */
1891  field_width = va_arg(args, int);
1892  if (field_width < 0) {
1893  field_width = -field_width;
1894  flags |= NUM_LEFT;
1895  }
1896  }
1897 
1898  /* get the precision */
1899  precision = -1;
1900  if (*fmt == '.') {
1901  ++fmt;
1902  if (is_digit(*fmt))
1903  precision = skip_atoi(&fmt);
1904  else if (*fmt == '*') {
1905  ++fmt;
1906  /* it's the next argument */
1907  precision = va_arg(args, int);
1908  }
1909  if (precision < 0)
1910  precision = 0;
1911  }
1912 
1913  /* get the conversion qualifier */
1914  qualifier = -1;
1915  if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') {
1916  qualifier = *fmt;
1917  ++fmt;
1918  }
1919 
1920  /* default base */
1921  base = 10;
1922 
1923  switch (*fmt) {
1924  case 'c':
1925  if (!(flags & NUM_LEFT))
1926  while (--field_width > 0)
1927  *str++ = ' ';
1928  *str++ = (unsigned char) va_arg(args, int);
1929  while (--field_width > 0)
1930  *str++ = ' ';
1931  continue;
1932 
1933  case 's':
1934  s = va_arg(args, char *);
1935  if (!s)
1936  s = "<NULL>";
1937 
1938  len = PICE_strnlen(s, precision);
1939 
1940  if (!(flags & NUM_LEFT))
1941  while (len < field_width--)
1942  *str++ = ' ';
1943  for (i = 0; i < len; ++i)
1944  *str++ = *s++;
1945  while (len < field_width--)
1946  *str++ = ' ';
1947  continue;
1948 
1949  case 'S':
1950  if (qualifier == 'h') {
1951  /* print ascii string */
1952  s = va_arg(args, char *);
1953  if (s == NULL)
1954  s = "<NULL>";
1955 
1956  len = PICE_strlen (s);
1957  if ((unsigned int)len > (unsigned int)precision)
1958  len = precision;
1959 
1960  if (!(flags & NUM_LEFT))
1961  while (len < field_width--)
1962  *str++ = ' ';
1963  for (i = 0; i < len; ++i)
1964  *str++ = *s++;
1965  while (len < field_width--)
1966  *str++ = ' ';
1967  } else {
1968  /* print unicode string */
1969  sw = va_arg(args, wchar_t *);
1970  if (sw == NULL)
1971  sw = L"<NULL>";
1972 
1973  len = wcslen (sw);
1974  if ((unsigned int)len > (unsigned int)precision)
1975  len = precision;
1976 
1977  if (!(flags & NUM_LEFT))
1978  while (len < field_width--)
1979  *str++ = ' ';
1980  for (i = 0; i < len; ++i)
1981  *str++ = (unsigned char)(*sw++);
1982  while (len < field_width--)
1983  *str++ = ' ';
1984  }
1985  continue;
1986 
1987  case 'p':
1988  if (field_width == -1) {
1989  field_width = 2*sizeof(void *);
1990  flags |= NUM_ZEROPAD;
1991  }
1992  str = PICE_number(str,
1993  (unsigned long) va_arg(args, void *), 16,
1994  field_width, precision, flags);
1995  continue;
1996 
1997 
1998  case 'n':
1999  if (qualifier == 'l') {
2000  long * ip = va_arg(args, long *);
2001  *ip = (str - buf);
2002  } else {
2003  int * ip = va_arg(args, int *);
2004  *ip = (str - buf);
2005  }
2006  continue;
2007 
2008  case '%':
2009  *str++ = '%';
2010  continue;
2011 
2012  /* integer PICE_number formats - set up the flags and "break" */
2013  case 'o':
2014  base = 8;
2015  break;
2016 
2017  case 'X':
2018  flags |= NUM_LARGE;
2019  case 'x':
2020  base = 16;
2021  break;
2022 
2023  case 'd':
2024  case 'i':
2025  flags |= NUM_SIGN;
2026  case 'u':
2027  break;
2028 
2029  default:
2030  *str++ = '%';
2031  if (*fmt)
2032  *str++ = *fmt;
2033  else
2034  --fmt;
2035  continue;
2036  }
2037  if (qualifier == 'l')
2038  num = va_arg(args, unsigned long);
2039  else if (qualifier == 'h') {
2040  num = (unsigned short) va_arg(args, int);
2041  if (flags & NUM_SIGN)
2042  num = (short) num;
2043  } else if (flags & NUM_SIGN)
2044  num = va_arg(args, int);
2045  else
2046  num = va_arg(args, unsigned int);
2047  str = PICE_number(str, num, base, field_width, precision, flags);
2048  }
2049  *str = '\0';
2050  return str-buf;
2051 }
#define NUM_SPECIAL
Definition: utils.c:1771
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
USHORT PICE_strlen(const char *s)
Definition: utils.c:547
const char * fmt
Definition: wsprintf.c:30
#define NUM_ZEROPAD
Definition: utils.c:1766
Definition: match.c:390
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:91
GLenum GLclampf GLint i
Definition: glfuncs.h:14
GLuint base
Definition: 3dtext.c:35
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
static APTTYPEQUALIFIER * qualifier
Definition: compobj.c:80
unsigned char
Definition: typeof.h:27
GLenum GLint GLint * precision
Definition: glext.h:7539
#define NUM_SPACE
Definition: utils.c:1769
#define NUM_PLUS
Definition: utils.c:1768
Definition: dhcpd.h:61
GLuint GLuint num
Definition: glext.h:9618
GLbitfield flags
Definition: glext.h:7161
static const WCHAR L[]
Definition: oid.c:1087
GLenum GLsizei len
Definition: glext.h:6722
GLdouble s
Definition: gl.h:2039
static int repeat
Definition: xmllint.c:143
#define NUM_LARGE
Definition: utils.c:1772
#define va_arg(ap, T)
Definition: acmsvcex.h:89
static int skip_atoi(const char **s)
Definition: utils.c:1747
#define is_digit(c)
Definition: utils.c:1745
#define NUM_SIGN
Definition: utils.c:1767
Definition: dsound.c:943
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define NUM_LEFT
Definition: utils.c:1770
static char * PICE_number(char *str, long num, int base, int size, int precision, int type)
Definition: utils.c:1780
size_t PICE_strnlen(const char *s, size_t count)
Definition: utils.c:1756

◆ PICE_wcscpy()

WCHAR* PICE_wcscpy ( WCHAR str1,
const WCHAR str2 
)

Definition at line 559 of file utils.c.

Referenced by ListDriverModules(), and ListUserModules().

560 {
561  WCHAR *save = str1;
562 
563  for (; (*str1 = *str2); ++str2, ++str1);
564  return save;
565 }
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ ReadPhysMem()

ULONG ReadPhysMem ( ULONG  Address,
ULONG  ulSize 
)

Definition at line 1633 of file utils.c.

Referenced by COMMAND_PROTOTYPE().

1634 {
1636  PULONG pPTE;
1637  ULONG temp = 0;
1638  ULONG oldPTE;
1639 
1640  ENTER_FUNC();
1641  DPRINT((0,"ReadPhysMem(%.8X,%u)\n",Address,ulSize));
1642  DPRINT((0,"ReadPhysMem(): Page = %.8X\n",Page));
1643  pPTE = (PULONG)FindPteForLinearAddress(Page);
1644  DPRINT((0,"ReadPhysMem(): pPTE = %.8X\n",pPTE));
1645  if(pPTE)
1646  {
1647  oldPTE = *pPTE;
1648  DPRINT((0,"ReadPhysMem(): oldPTE = %.8X\n",oldPTE));
1649  temp = (Address & ~(_PAGE_SIZE-1));
1650  DPRINT((0,"ReadPhysMem(): page-aligned Address = %.8X\n",temp));
1651  *pPTE = temp|0x1;
1652  DPRINT((0,"ReadPhysMem(): new PTE = %.8X\n",*pPTE));
1653  InvalidateLB();
1654  switch(ulSize)
1655  {
1656  case sizeof(UCHAR): // BYTE
1657  temp = *(PUCHAR)(Page + (Address & (_PAGE_SIZE-1)));
1658  temp = (UCHAR)temp;
1659  break;
1660  case sizeof(USHORT): // WORD
1661  temp = *(PUSHORT)(Page + (Address & (_PAGE_SIZE-1)));
1662  temp = (USHORT)temp;
1663  break;
1664  case sizeof(ULONG): // DWORD
1665  temp = *(PULONG)(Page + (Address & (_PAGE_SIZE-1)));
1666  break;
1667  }
1668  *pPTE = oldPTE;
1669  InvalidateLB();
1670  }
1671  LEAVE_FUNC();
1672 
1673  return temp;
1674 }
unsigned char * PUCHAR
Definition: retypes.h:3
#define LEAVE_FUNC()
Definition: debug.h:43
static WCHAR Address[46]
Definition: ping.c:68
void DPRINT(...)
Definition: polytest.cpp:61
#define _PAGE_SIZE
Definition: utils.h:269
PULONG FindPteForLinearAddress(ULONG address)
Definition: utils.c:1573
ULONG TwoPagesForPhysMem[2 *_PAGE_SIZE]
Definition: utils.c:47
unsigned char UCHAR
Definition: xmlstorage.h:181
static stack_node_t temp
Definition: rpn.c:18
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
void InvalidateLB(void)
Definition: utils.c:1616
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
unsigned short * PUSHORT
Definition: retypes.h:2

◆ SaveOldRegs()

void SaveOldRegs ( void  )

Definition at line 1324 of file utils.c.

Referenced by DebuggerShell().

1325 {
1326 
1327  ENTER_FUNC();
1328 
1339  OldCS=CurrentCS;
1340  OldDS=CurrentDS;
1341  OldES=CurrentES;
1342  OldFS=CurrentFS;
1343  OldGS=CurrentGS;
1344  OldSS=CurrentSS;
1345 
1346  LEAVE_FUNC();
1347 }
USHORT CurrentCS
Definition: shell.c:116
ULONG OldESP
Definition: shell.c:122
ULONG OldESI
Definition: shell.c:122
USHORT CurrentSS
Definition: shell.c:116
USHORT OldGS
Definition: shell.c:123
ULONG OldEIP
Definition: shell.c:120
ULONG OldEDX
Definition: shell.c:121
ULONG OldEDI
Definition: shell.c:122
USHORT OldFS
Definition: shell.c:123
#define LEAVE_FUNC()
Definition: debug.h:43
ULONG CurrentESI
Definition: shell.c:115
ULONG OldEAX
Definition: shell.c:121
USHORT OldCS
Definition: shell.c:123
USHORT OldSS
Definition: shell.c:123
ULONG CurrentEDI
Definition: shell.c:115
USHORT CurrentFS
Definition: shell.c:116
ULONG OldEBP
Definition: shell.c:122
USHORT OldDS
Definition: shell.c:123
USHORT CurrentDS
Definition: shell.c:116
ULONG CurrentEDX
Definition: shell.c:114
ULONG CurrentECX
Definition: shell.c:114
ULONG OldEBX
Definition: shell.c:121
USHORT CurrentGS
Definition: shell.c:116
ULONG OldECX
Definition: shell.c:121
USHORT OldES
Definition: shell.c:123
ULONG OldEFL
Definition: shell.c:120
ULONG CurrentEIP
Definition: shell.c:113
ULONG CurrentEBX
Definition: shell.c:114
ULONG CurrentEBP
Definition: shell.c:115
#define ENTER_FUNC()
Definition: debug.h:42
ULONG CurrentESP
Definition: shell.c:115
ULONG CurrentEFL
Definition: shell.c:113
USHORT CurrentES
Definition: shell.c:116
ULONG CurrentEAX
Definition: shell.c:114

◆ SetAddressWriteable()

BOOLEAN SetAddressWriteable ( ULONG  address,
BOOLEAN  bSet 
)

Definition at line 688 of file utils.c.

Referenced by DeInstallSWBreakpoint(), InstallSWBreakpoint(), ReInstallSWBreakpoint(), RemoveAllSWBreakpoints(), RemoveSWBreakpoint(), RevirtualizeBreakpointsForModule(), and TryToInstallVirtualSWBreakpoints().

689 {
690  PULONG pPGD;
691  PULONG pPTE;
692 
693  //address &= (~(_PAGE_SIZE-1));
694 
695  pPGD = ADDR_TO_PDE(address);
696  if(pPGD && ((*pPGD)&_PAGE_PRESENT))
697  {
698  // not large page
699  if(!((*pPGD)&_PAGE_4M))
700  {
701  pPTE = ADDR_TO_PTE(address);
702  if(pPTE)
703  {
704  if( (*pPTE)&(_PAGE_PRESENT | _PAGE_PSE) )
705  {
706  if( bSet ){
707  *pPTE |= _PAGE_RW;
708  }
709  else{
710  *pPTE &= ~_PAGE_RW;
711  }
712  FLUSH_TLB;
713  return TRUE;
714  }
715  }
716  }
717  // large page
718  else
719  {
720  if( bSet )
721  *pPGD |= _PAGE_RW;
722  else
723  *pPGD &= ~_PAGE_RW;
724  FLUSH_TLB;
725  return TRUE;
726  }
727  }
728  return FALSE;
729 }
#define TRUE
Definition: types.h:120
#define _PAGE_4M
Definition: utils.h:268
#define ADDR_TO_PTE(v)
Definition: parse.h:181
#define _PAGE_PRESENT
Definition: compat.h:67
GLuint address
Definition: glext.h:9393
#define _PAGE_PSE
Definition: utils.h:267
#define ADDR_TO_PDE(v)
Definition: parse.h:179
unsigned int * PULONG
Definition: retypes.h:1
#define _PAGE_RW
Definition: compat.h:71

◆ SetHardwareBreakPoint()

void SetHardwareBreakPoint ( ULONG  ulAddress,
ULONG  ulReg 
)

Definition at line 878 of file utils.c.

Referenced by COMMAND_PROTOTYPE().

879 {
880  ULONG mask = 0x300;
881  ULONG enable_mask = 0x3;
882 
883  DPRINT((0,"SetHardwareBreakPoint(%x,DR%x)\n",ulAddress,ulReg));
884 
885  enable_mask <<= (ulReg*2);
886  mask |= enable_mask;
887 
888  DPRINT((0,"mask = %x\n",mask));
889 
890  __asm__ __volatile__
891  ("\n\t \
892  xorl %%eax,%%eax\n\t \
893  mov %%eax,%%dr6\n\t \
894  mov %%dr7,%%eax\n\t \
895  orl %0,%%eax\n\t \
896  mov %%eax,%%dr7\n\t \
897  "
898  :
899  :"m" (mask)
900  :"eax");
901 
902  switch(ulReg)
903  {
904  case 0:
905  __asm__ __volatile__
906  ("\n\t \
907  mov %0,%%eax\n\t \
908  mov %%eax,%%dr0\n\t \
909  "
910  :
911  :"m" (ulAddress)
912  :"eax");
913  break;
914  case 1:
915  __asm__ __volatile__
916  ("\n\t \
917  mov %0,%%eax\n\t \
918  mov %%eax,%%dr1\n\t \
919  "
920  :
921  :"m" (ulAddress)
922  :"eax");
923  break;
924  case 2:
925  __asm__ __volatile__
926  ("\n\t \
927  mov %0,%%eax\n\t \
928  mov %%eax,%%dr2\n\t \
929  "
930  :
931  :"m" (ulAddress)
932  :"eax");
933  break;
934  case 3:
935  __asm__ __volatile__
936  ("\n\t \
937  mov %0,%%eax\n\t \
938  mov %%eax,%%dr3\n\t \
939  "
940  :
941  :"m" (ulAddress)
942  :"eax");
943  break;
944  }
945 }
GLenum GLint GLuint mask
Definition: glext.h:6028
void DPRINT(...)
Definition: polytest.cpp:61
__asm__("\globl GetPhys\ "GetPhys:\\" "mflr 0\\" "stwu 0,-16(1)\\" "mfmsr 5\\" "andi. 6, 5, 0xffef\\" "mtmsr 6\\" "isync\\" "sync\\" "lwz 3, 0(3)\\" "mtmsr 5\\" "isync\\" "sync\\" "lwz 0, 0(1)\\" "addi 1, 1, 16\\" "mtlr 0\\" "blr")
unsigned int ULONG
Definition: retypes.h:1

◆ SetHardwareBreakPoints()

void SetHardwareBreakPoints ( void  )

Definition at line 952 of file utils.c.

953 {
954 ULONG i;
955 ULONG mask;
956 ULONG LinAddr0,LinAddr1,LinAddr2,LinAddr3;
957 PULONG LinAddr[4]={&LinAddr0,&LinAddr1,&LinAddr2,&LinAddr3};
958 
959  ENTER_FUNC();
960 
961  // cancel all debug activity
962  __asm__("\n\t \
963  pushl %eax\n\t \
964  xorl %eax,%eax\n\t \
965  mov %eax,%dr6\n\t \
966  mov %eax,%dr7\n\t \
967  popl %eax");
968  // build DR7 mask
969  for(mask=0,i=0;i<4;i++)
970  {
971  mask<<=2;
972  if(Bp[i].Active && Bp[i].Used && !Bp[i].Virtual)
973  {
974  mask|=0x03;
975  *LinAddr[3-i]=Bp[i].LinearAddress;
976  DPRINT((0,"breakpoint %u at %.8X\n",i,Bp[i].LinearAddress));
977  }
978  }
979  if(mask)
980  {
981  __asm__("\n\t \
982  pushl %%eax\n\t \
983  movl %0,%%eax\n\t \
984  andl $0x000000FF,%%eax\n\t \
985  orl $0x300,%%eax\n\t \
986  mov %%eax,%%dr7\n\t \
987  mov %1,%%eax\n\t \
988  mov %%eax,%%dr0\n\t \
989  mov %2,%%eax\n\t \
990  mov %%eax,%%dr1\n\t \
991  mov %3,%%eax\n\t \
992  mov %%eax,%%dr2\n\t \
993  mov %4,%%eax\n\t \
994  mov %%eax,%%dr3\n\t \
995  popl %%eax"
996  :
997  :"m" (mask),"m" (LinAddr0),"m" (LinAddr1),"m" (LinAddr2),"m" (LinAddr3));
998  }
999 
1000  LEAVE_FUNC();
1001 }
#define LEAVE_FUNC()
Definition: debug.h:43
GLuint const GLubyte mask[]
Definition: s_context.h:57
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void DPRINT(...)
Definition: polytest.cpp:61
Definition: sacdrv.h:288
__asm__("\globl GetPhys\ "GetPhys:\\" "mflr 0\\" "stwu 0,-16(1)\\" "mfmsr 5\\" "andi. 6, 5, 0xffef\\" "mtmsr 6\\" "isync\\" "sync\\" "lwz 3, 0(3)\\" "mtmsr 5\\" "isync\\" "sync\\" "lwz 0, 0(1)\\" "addi 1, 1, 16\\" "mtlr 0\\" "blr")
ULONG LinearAddress
Definition: parse.h:77
unsigned int * PULONG
Definition: retypes.h:1
BP Bp[4]
Definition: parse.c:245
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42

◆ SetKeyboardLayoutByName()

PKEYBOARD_LAYOUT SetKeyboardLayoutByName ( LPSTR  Name)

Definition at line 208 of file utils.c.

Referenced by COMMAND_PROTOTYPE().

209 {
210  CHAR tempCmd[256];
211  ULONG i;
212 
213  for(i=0;ucKeyboard[i].name != NULL;i++)
214  {
215  if(PICE_strcmpi(ucKeyboard[i].name, Name) == 0)
216  {
218  return CurrentKeyboard;
219  }
220  }
221  return GetKeyboardLayout();
222 }
PKEYBOARD_LAYOUT CurrentKeyboard
Definition: utils.c:183
char CHAR
Definition: xmlstorage.h:175
GLenum GLclampf GLint i
Definition: glfuncs.h:14
smooth NULL
Definition: ftsmooth.c:416
KEYBOARD_LAYOUT ucKeyboard[]
Definition: utils.c:175
char tempCmd[1024]
Definition: parse.c:225
PKEYBOARD_LAYOUT GetKeyboardLayout()
Definition: utils.c:194
Definition: name.c:36
unsigned int ULONG
Definition: retypes.h:1
ULONG PICE_strcmpi(char *s1, char *s2)
Definition: utils.c:387

◆ ShowRunningMsg()

void ShowRunningMsg ( void  )

Definition at line 843 of file utils.c.

Referenced by DebuggerShell(), and PrintTemplate().

844 {
845  ENTER_FUNC();
846 
850  PutChar(" ReactOS is running... (Press CTRL-D to stop) ",1,wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].cy);
851  ResetColor();
852 
853  LEAVE_FUNC();
854 }
void SetForegroundColor(ECOLORS c)
Definition: hardware.c:576
#define LEAVE_FUNC()
Definition: debug.h:43
INT INT y
Definition: msvc.h:62
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define COLOR_TEXT
Definition: hardware.h:158
void ClrLine(ULONG line)
Definition: hardware.c:662
WINDOW wWindow[4]
Definition: hardware.c:59
void PutChar(LPSTR p, ULONG x, ULONG y)
Definition: hardware.c:604
void SetBackgroundColor(ECOLORS c)
Definition: hardware.c:590
#define ENTER_FUNC()
Definition: debug.h:42
void ResetColor(void)
Definition: hardware.c:500
#define COLOR_CAPTION
Definition: hardware.h:156

◆ ShowStoppedMsg()

void ShowStoppedMsg ( void  )

Definition at line 861 of file utils.c.

Referenced by DebuggerShell(), and RepaintDesktop().

862 {
863  ENTER_FUNC();
864 
868  PutChar(" Stopped... (Type 'x' to continue) ",1,wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].cy);
869  ResetColor();
870 
871  LEAVE_FUNC();
872 }
void SetForegroundColor(ECOLORS c)
Definition: hardware.c:576
#define LEAVE_FUNC()
Definition: debug.h:43
INT INT y
Definition: msvc.h:62
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:570
#define COLOR_TEXT
Definition: hardware.h:158
void ClrLine(ULONG line)
Definition: hardware.c:662
WINDOW wWindow[4]
Definition: hardware.c:59
void PutChar(LPSTR p, ULONG x, ULONG y)
Definition: hardware.c:604
void SetBackgroundColor(ECOLORS c)
Definition: hardware.c:590
#define ENTER_FUNC()
Definition: debug.h:42
void ResetColor(void)
Definition: hardware.c:500
#define COLOR_CAPTION
Definition: hardware.h:156

◆ WritePhysMem()

void WritePhysMem ( ULONG  Address,
ULONG  Datum,
ULONG  ulSize 
)

Definition at line 1680 of file utils.c.

Referenced by COMMAND_PROTOTYPE().

1681 {
1683  PULONG pPTE;
1684  ULONG temp;
1685  ULONG oldPTE;
1686 
1687  pPTE = (PULONG)FindPteForLinearAddress(Page);
1688  if(pPTE)
1689  {
1690  oldPTE = *pPTE;
1691  temp = (Address & ~(_PAGE_SIZE-1));
1692  *pPTE = temp | 0x3; // present and writable
1693  InvalidateLB();
1694  switch(ulSize)
1695  {
1696  case sizeof(UCHAR): // BYTE
1697  *(PUCHAR)(Page + (Address & (_PAGE_SIZE-1))) = (UCHAR)Datum;
1698  break;
1699  case sizeof(USHORT): // WORD
1700  *(PUSHORT)(Page + (Address & (_PAGE_SIZE-1))) = (USHORT)Datum;
1701  break;
1702  case sizeof(ULONG): // DWORD
1703  *(PULONG)(Page + (Address & (_PAGE_SIZE-1))) = Datum;
1704  break;
1705  }
1706  *pPTE = oldPTE;
1707  InvalidateLB();
1708  }
1709 }
unsigned char * PUCHAR
Definition: retypes.h:3
static WCHAR Address[46]
Definition: ping.c:68
#define _PAGE_SIZE
Definition: utils.h:269
PULONG FindPteForLinearAddress(ULONG address)
Definition: utils.c:1573
ULONG TwoPagesForPhysMem[2 *_PAGE_SIZE]
Definition: utils.c:47
unsigned char UCHAR
Definition: xmlstorage.h:181
static stack_node_t temp
Definition: rpn.c:18
unsigned short USHORT
Definition: pedump.c:61
unsigned int * PULONG
Definition: retypes.h:1
void InvalidateLB(void)
Definition: utils.c:1616
unsigned int ULONG
Definition: retypes.h:1
unsigned short * PUSHORT
Definition: retypes.h:2

Variable Documentation

◆ CurrentKeyboard

PKEYBOARD_LAYOUT CurrentKeyboard

Definition at line 183 of file utils.c.

Referenced by GetKeyboardLayout(), and SetKeyboardLayoutByName().

◆ my_init_mm

PMADDRESS_SPACE my_init_mm

Definition at line 300 of file utils.h.

Referenced by COMMAND_PROTOTYPE(), HandlePageFault(), and InitPICE().

◆ pPsProcessListHead

LIST_ENTRY* pPsProcessListHead

Definition at line 301 of file utils.h.

Referenced by COMMAND_PROTOTYPE(), and InitPICE().