Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
2.3 KiB

4 years ago
  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. igrep.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Ramon J San Andres (ramonsa) 5-Nov-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. CHAR igrepLastPattern[256];
  14. DWORD igrepSearchStartAddress;
  15. DWORD igrepLastPc;
  16. DECLARE_API( igrep )
  17. /*++
  18. Routine Description:
  19. Grep for disassembled pattern
  20. Arguments:
  21. args - [pattern [addr]]
  22. Return Value:
  23. None
  24. --*/
  25. {
  26. DWORD dwNextGrepAddr;
  27. DWORD dwCurrGrepAddr;
  28. CHAR SourceLine[256];
  29. BOOL NewPc;
  30. DWORD d;
  31. LPSTR pc;
  32. LPSTR Pattern;
  33. LPSTR Expression;
  34. CHAR Symbol[64];
  35. DWORD Displacement;
  36. if ( igrepLastPc && igrepLastPc == dwCurrentPc ) {
  37. NewPc = FALSE;
  38. } else {
  39. igrepLastPc = dwCurrentPc;
  40. NewPc = TRUE;
  41. }
  42. //
  43. // check for pattern.
  44. //
  45. pc = args;
  46. Pattern = NULL;
  47. Expression = NULL;
  48. if ( *pc ) {
  49. Pattern = pc;
  50. while (*pc > ' ') {
  51. pc++;
  52. }
  53. //
  54. // check for an expression
  55. //
  56. if ( *pc != '\0' ) {
  57. *pc = '\0';
  58. pc++;
  59. if ( *pc <= ' ') {
  60. while (*pc <= ' '){
  61. pc++;
  62. }
  63. }
  64. if ( *pc ) {
  65. Expression = pc;
  66. }
  67. }
  68. }
  69. if ( Pattern ) {
  70. strcpy(igrepLastPattern,Pattern);
  71. if ( Expression ) {
  72. igrepSearchStartAddress = GetExpression(Expression);
  73. if ( !igrepSearchStartAddress ) {
  74. igrepSearchStartAddress = igrepLastPc;
  75. return;
  76. }
  77. } else {
  78. igrepSearchStartAddress = igrepLastPc;
  79. }
  80. }
  81. dwNextGrepAddr = igrepSearchStartAddress;
  82. dwCurrGrepAddr = dwNextGrepAddr;
  83. d = Disassm(&dwNextGrepAddr,SourceLine,FALSE);
  84. while(d) {
  85. if (strstr(SourceLine,igrepLastPattern)) {
  86. igrepSearchStartAddress = dwNextGrepAddr;
  87. GetSymbol((LPVOID)dwCurrGrepAddr,Symbol,&Displacement);
  88. dprintf("%s",SourceLine);
  89. return;
  90. }
  91. if ( CheckControlC() ) {
  92. return;
  93. }
  94. dwCurrGrepAddr = dwNextGrepAddr;
  95. d = Disassm(&dwNextGrepAddr,SourceLine,FALSE);
  96. }
  97. }