Leaked source code of windows server 2003
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.

192 lines
3.8 KiB

  1. //++
  2. //
  3. // Copyright (c) 1990 Microsoft Corporation
  4. //
  5. // Module Name:
  6. //
  7. // debug3.c
  8. //
  9. // Abstract:
  10. //
  11. // This module implements architecture specific functions to support debugging NT.
  12. //
  13. // Author:
  14. //
  15. // Steven R. Wood (stevewo) 3-Aug-1989
  16. //
  17. // Environment:
  18. //
  19. // Any mode.
  20. //
  21. // Revision History:
  22. //
  23. //--
  24. #include "stdarg.h"
  25. #include "stdio.h"
  26. #include "string.h"
  27. #include "ntrtlp.h"
  28. //
  29. // Prototype for local procedure
  30. //
  31. NTSTATUS
  32. DebugService(
  33. ULONG ServiceClass,
  34. PVOID Arg1,
  35. PVOID Arg2,
  36. PVOID Arg3,
  37. PVOID Arg4
  38. );
  39. NTSTATUS
  40. DebugService(
  41. ULONG ServiceClass,
  42. PVOID Arg1,
  43. PVOID Arg2,
  44. PVOID Arg3,
  45. PVOID Arg4
  46. )
  47. //++
  48. //
  49. // Routine Description:
  50. //
  51. // Allocate an ExceptionRecord, fill in data to allow exception
  52. // dispatch code to do the right thing with the service, and
  53. // call RtlRaiseException (NOT ExRaiseException!!!).
  54. //
  55. // Arguments:
  56. // ServiceClass - which call is to be performed
  57. // Arg1 - generic first argument
  58. // Arg2 - generic second argument
  59. // Arg3 - generic third argument
  60. // Arg4 - generic fourth argument
  61. //
  62. // Returns:
  63. // Whatever the exception returns in eax
  64. //
  65. //--
  66. {
  67. NTSTATUS RetValue;
  68. #if defined(BUILD_WOW6432)
  69. extern NTSTATUS NtWow64DebuggerCall(ULONG, PVOID, PVOID, PVOID, PVOID);
  70. RetValue = NtWow64DebuggerCall(ServiceClass, Arg1, Arg2, Arg3, Arg4);
  71. #else
  72. _asm {
  73. push edi
  74. push ebx
  75. mov eax, ServiceClass
  76. mov ecx, Arg1
  77. mov edx, Arg2
  78. mov ebx, Arg3
  79. mov edi, Arg4
  80. int 2dh ; Raise exception
  81. int 3 ; DO NOT REMOVE (See KiDebugService)
  82. pop ebx
  83. pop edi
  84. mov RetValue, eax
  85. }
  86. #endif
  87. return RetValue;
  88. }
  89. VOID
  90. DebugService2(
  91. PVOID Arg1,
  92. PVOID Arg2,
  93. ULONG ServiceClass
  94. )
  95. //++
  96. //
  97. // Routine Description:
  98. //
  99. // Generic exception dispatcher for the debugger
  100. //
  101. // Arguments:
  102. // Arg1 - generic first argument
  103. // Arg2 - generic second argument
  104. // ServiceClass - which call is to be performed
  105. //
  106. // Returns:
  107. // Whatever the exception returns in eax
  108. //
  109. //--
  110. {
  111. #if defined(BUILD_WOW6432)
  112. extern NTSTATUS NtWow64DebuggerCall(ULONG, PVOID, PVOID, PVOID, PVOID);
  113. NtWow64DebuggerCall(ServiceClass, Arg1, Arg2, 0, 0);
  114. #else
  115. _asm {
  116. //push edi
  117. //push ebx
  118. mov eax, ServiceClass
  119. mov ecx, Arg1
  120. mov edx, Arg2
  121. //mov ebx, Arg3
  122. //mov edi, Arg4
  123. int 2dh ; Raise exception
  124. int 3 ; DO NOT REMOVE (See KiDebugService)
  125. //pop ebx
  126. //pop edi
  127. }
  128. #endif
  129. return;
  130. }
  131. // DebugPrint must appear after DebugSerive. Moved
  132. // it down below DebugService, so BBT would have a label after DebugService.
  133. // A label after the above _asm is necessary so BBT can treat DebugService
  134. // as "KnownDataRange". Otherwise, the two 'int' instructions could get broken up
  135. // by BBT's optimizer.
  136. //
  137. NTSTATUS
  138. DebugPrint(
  139. IN PSTRING Output,
  140. IN ULONG ComponentId,
  141. IN ULONG Level
  142. )
  143. {
  144. return DebugService(BREAKPOINT_PRINT,
  145. Output->Buffer,
  146. (PVOID)Output->Length,
  147. (PVOID)ComponentId,
  148. (PVOID)Level);
  149. }
  150. ULONG
  151. DebugPrompt(
  152. IN PSTRING Output,
  153. IN PSTRING Input
  154. )
  155. {
  156. return DebugService(BREAKPOINT_PROMPT,
  157. Output->Buffer,
  158. (PVOID)Output->Length,
  159. Input->Buffer,
  160. (PVOID)Input->MaximumLength);
  161. }