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.

283 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1996 Intel Corporation
  3. Copyright (c) 1990 Microsoft Corporation
  4. Module Name:
  5. miscc.c
  6. Abstract:
  7. This module implements the functions that get the memory stack
  8. and backing store limits.
  9. Author:
  10. William K. Cheung (wcheung) 09-Aug-1996
  11. Environment:
  12. Any mode.
  13. Revision History:
  14. --*/
  15. #include "ntrtlp.h"
  16. VOID
  17. DebugLoadImageSymbols(
  18. IN PSTRING FileName,
  19. IN PKD_SYMBOLS_INFO SymbolInfo
  20. );
  21. VOID
  22. DebugUnLoadImageSymbols(
  23. IN PSTRING FileName,
  24. IN PKD_SYMBOLS_INFO SymbolInfo
  25. );
  26. VOID
  27. DebugCommandString(
  28. IN PSTRING Name,
  29. IN PSTRING Command
  30. );
  31. VOID
  32. RtlpFlushRSE (
  33. OUT PULONGLONG BackingStore,
  34. OUT PULONGLONG RNat
  35. );
  36. VOID
  37. RtlpCaptureRnats (
  38. IN OUT PCONTEXT ContextRecord
  39. )
  40. /*++
  41. Routine Description:
  42. This function captures Nat bits of all the stacked registers in
  43. the RSE frame specified in the context record.
  44. --*/
  45. {
  46. ULONGLONG Rnat;
  47. ULONGLONG Bsp;
  48. ULONGLONG TopRnatAddress;
  49. RtlpFlushRSE(&Bsp, &Rnat);
  50. TopRnatAddress =
  51. (ULONGLONG) RtlpRseRNatAddress(
  52. RtlpRseGrowBySOF(ContextRecord->RsBSP, ContextRecord->StIFS) - sizeof(ULONGLONG)
  53. );
  54. if (TopRnatAddress < Bsp) {
  55. ContextRecord->RsRNAT = *(PULONGLONG)TopRnatAddress;
  56. } else {
  57. ContextRecord->RsRNAT = Rnat;
  58. }
  59. }
  60. VOID
  61. Rtlp64GetBStoreLimits (
  62. OUT PULONGLONG LowBStoreLimit,
  63. OUT PULONGLONG HighBStoreLimit
  64. )
  65. /*++
  66. Routine Description:
  67. This function returns the current backing store limits based on the
  68. current processor mode.
  69. Arguments:
  70. LowBStoreLimit - Supplies a pointer to a variable that is to receive
  71. the low limit of the backing store.
  72. HighBStoreLimit - Supplies a pointer to a variable that is to receive
  73. the high limit of the backing store.
  74. Return Value:
  75. None.
  76. --*/
  77. {
  78. #if defined(NTOS_KERNEL_RUNTIME)
  79. //
  80. // Kernel Mode
  81. //
  82. *LowBStoreLimit = (ULONGLONG)(PCR->InitialBStore);
  83. *HighBStoreLimit = (ULONGLONG)(PCR->BStoreLimit);
  84. #else
  85. //
  86. // User Mode
  87. //
  88. PTEB CurrentTeb = NtCurrentTeb();
  89. *HighBStoreLimit = (ULONGLONG)CurrentTeb->BStoreLimit;
  90. *LowBStoreLimit = (ULONGLONG)CurrentTeb->NtTib.StackBase;
  91. #endif // defined(NTOS_KERNEL_RUNTIME)
  92. }
  93. VOID
  94. RtlpGetStackLimits (
  95. OUT PULONG_PTR LowStackLimit,
  96. OUT PULONG_PTR HighStackLimit
  97. )
  98. /*++
  99. Routine Description:
  100. This function returns the current memory stack limits based on the
  101. current processor mode.
  102. Arguments:
  103. LowStackLimit - Supplies a pointer to a variable that is to receive
  104. the low limit of the memory stack.
  105. HighStackLimit - Supplies a pointer to a variable that is to receive
  106. the high limit of the memory stack.
  107. Return Value:
  108. None.
  109. --*/
  110. {
  111. #if defined(NTOS_KERNEL_RUNTIME)
  112. //
  113. // Kernel Mode
  114. //
  115. *HighStackLimit = (ULONG_PTR)PCR->InitialStack;
  116. *LowStackLimit = (ULONG_PTR)PCR->StackLimit;
  117. #else
  118. //
  119. // User Mode
  120. //
  121. PTEB CurrentTeb = NtCurrentTeb();
  122. *HighStackLimit = (ULONG_PTR)CurrentTeb->NtTib.StackBase;
  123. *LowStackLimit = (ULONG_PTR)CurrentTeb->NtTib.StackLimit;
  124. #endif // defined(NTOS_KERNEL_RUNTIME)
  125. }
  126. VOID
  127. Rtlp64GetStackLimits (
  128. OUT PULONGLONG LowStackLimit,
  129. OUT PULONGLONG HighStackLimit
  130. )
  131. /*++
  132. Routine Description:
  133. This function returns the current memory stack limits based on the
  134. current processor mode.
  135. Arguments:
  136. LowStackLimit - Supplies a pointer to a variable that is to receive
  137. the low limit of the memory stack.
  138. HighStackLimit - Supplies a pointer to a variable that is to receive
  139. the high limit of the memory stack.
  140. Return Value:
  141. None.
  142. --*/
  143. {
  144. #if defined(NTOS_KERNEL_RUNTIME)
  145. //
  146. // Kernel Mode
  147. //
  148. *HighStackLimit = (ULONG_PTR)PCR->InitialStack;
  149. *LowStackLimit = (ULONG_PTR)PCR->StackLimit;
  150. #else
  151. //
  152. // User Mode
  153. //
  154. PTEB CurrentTeb = NtCurrentTeb();
  155. *HighStackLimit = (ULONGLONG)CurrentTeb->NtTib.StackBase;
  156. *LowStackLimit = (ULONGLONG)CurrentTeb->NtTib.StackLimit;
  157. #endif // defined(NTOS_KERNEL_RUNTIME)
  158. }
  159. VOID
  160. DebugService2(
  161. PVOID Arg1,
  162. PVOID Arg2,
  163. ULONG ServiceClass
  164. )
  165. //++
  166. //
  167. // Routine Description:
  168. //
  169. // Generic exception dispatcher for the debugger
  170. //
  171. // Arguments:
  172. // Arg1 - generic first argument
  173. // Arg2 - generic second argument
  174. // ServiceClass - which call is to be performed
  175. //
  176. // Returns:
  177. // Whatever the exception returns in eax
  178. //
  179. //--
  180. {
  181. switch (ServiceClass)
  182. {
  183. case BREAKPOINT_COMMAND_STRING:
  184. DebugCommandString(Arg1, Arg2);
  185. return;
  186. case BREAKPOINT_LOAD_SYMBOLS:
  187. DebugLoadImageSymbols(Arg1, Arg2);
  188. return;
  189. case BREAKPOINT_UNLOAD_SYMBOLS:
  190. DebugUnLoadImageSymbols(Arg1, Arg2);
  191. return;
  192. default:
  193. return;
  194. }
  195. return;
  196. }