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.

231 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. remote.cxx
  5. Abstract:
  6. This file contains the thunk routines to make
  7. wdbgext api calls from a remote client.
  8. Author:
  9. Jason Hartman (JasonHa) 2000-10-27
  10. Environment:
  11. User Mode
  12. --*/
  13. #include "precomp.hxx"
  14. VOID
  15. RemoteWarn(PCSTR pszAPI)
  16. {
  17. ExtApiClass ExtApi(NULL);
  18. if (ExtApi.Client != NULL)
  19. {
  20. ExtWarn("Extension using WinDbg Extension API, %s, which isn't remote compatible.\n", pszAPI);
  21. }
  22. }
  23. VOID
  24. WDBGAPIV
  25. RemoteThunkOutputRoutine(
  26. PCSTR lpFormat,
  27. ...
  28. )
  29. {
  30. ExtApiClass ExtApi(NULL);
  31. // RemoteWarn("dprintf");
  32. va_list Args;
  33. if (g_pExtControl == NULL)
  34. {
  35. DbgPrint("g_pExtControl is NULL.\n");
  36. return;
  37. }
  38. va_start(Args, lpFormat);
  39. g_pExtControl->OutputVaList(DEBUG_OUTPUT_NORMAL, lpFormat, Args);
  40. va_end(Args);
  41. }
  42. ULONG64
  43. WDBGAPI
  44. RemoteThunkGetExpressionRoutine(
  45. PCSTR lpExpression
  46. )
  47. {
  48. ExtApiClass ExtApi(NULL);
  49. // RemoteWarn("GetExpression");
  50. DEBUG_VALUE Value;
  51. if (g_pExtControl != NULL)
  52. {
  53. if (g_pExtControl->Evaluate(lpExpression, DEBUG_VALUE_INT64, &Value, NULL) == S_OK)
  54. {
  55. return Value.I64;
  56. }
  57. }
  58. return 0;
  59. }
  60. //PWINDBG_GET_SYMBOL64
  61. VOID
  62. WDBGAPI
  63. RemoteThunkGetSymbolRoutine(
  64. ULONG64 offset,
  65. PCHAR pchBuffer,
  66. PULONG64 pDisplacement
  67. )
  68. {
  69. RemoteWarn("GetSymbol");
  70. if (pchBuffer != NULL) ((PSTR)pchBuffer)[0] = '\0';
  71. if (pDisplacement != NULL) *pDisplacement = 0;
  72. return;
  73. }
  74. ULONG
  75. WDBGAPI
  76. RemoteThunkDisasmRoutine(
  77. ULONG64 *lpOffset,
  78. PCSTR lpBuffer,
  79. ULONG fShowEffectiveAddress
  80. )
  81. {
  82. RemoteWarn("Disasm");
  83. return FALSE;
  84. }
  85. ULONG
  86. WDBGAPI
  87. RemoteThunkCheckControlCRoutine(
  88. VOID
  89. )
  90. {
  91. ExtApiClass ExtApi(NULL);
  92. RemoteWarn("CheckControlC");
  93. return (g_pExtControl != NULL) ?
  94. (g_pExtControl->GetInterrupt() == S_OK) :
  95. FALSE;
  96. }
  97. ULONG
  98. WDBGAPI
  99. RemoteThunkReadProcessMemoryRoutine(
  100. ULONG64 offset,
  101. PVOID lpBuffer,
  102. ULONG cb,
  103. PULONG lpcbBytesRead
  104. )
  105. {
  106. RemoteWarn("ReadMemory");
  107. if (lpBuffer != NULL) RtlZeroMemory(lpBuffer, cb);
  108. if (lpcbBytesRead != NULL) *lpcbBytesRead = 0;
  109. return FALSE;
  110. }
  111. ULONG
  112. WDBGAPI
  113. RemoteThunkWriteProcessMemoryRoutine(
  114. ULONG64 offset,
  115. LPCVOID lpBuffer,
  116. ULONG cb,
  117. PULONG lpcbBytesWritten
  118. )
  119. {
  120. RemoteWarn("WriteMemory");
  121. if (lpcbBytesWritten != NULL) *lpcbBytesWritten = 0;
  122. return FALSE;
  123. }
  124. ULONG
  125. WDBGAPI
  126. RemoteThunkGetThreadContextRoutine(
  127. ULONG Processor,
  128. PCONTEXT lpContext,
  129. ULONG cbSizeOfContext
  130. )
  131. {
  132. RemoteWarn("GetContext");
  133. if (lpContext != NULL) RtlZeroMemory(lpContext, cbSizeOfContext);
  134. return FALSE;
  135. }
  136. ULONG
  137. WDBGAPI
  138. RemoteThunkSetThreadContextRoutine(
  139. ULONG Processor,
  140. PCONTEXT lpContext,
  141. ULONG cbSizeOfContext
  142. )
  143. {
  144. RemoteWarn("SetContext");
  145. return FALSE;
  146. }
  147. ULONG
  148. WDBGAPI
  149. RemoteThunkIoctlRoutine(
  150. USHORT IoctlType,
  151. PVOID lpvData,
  152. ULONG cbSize
  153. )
  154. {
  155. RemoteWarn("Ioctl");
  156. return 0;
  157. }
  158. ULONG
  159. RemoteThunkStackTraceRoutine(
  160. ULONG64 FramePointer,
  161. ULONG64 StackPointer,
  162. ULONG64 ProgramCounter,
  163. PEXTSTACKTRACE64 StackFrames,
  164. ULONG Frames
  165. )
  166. {
  167. RemoteWarn("StackTrace");
  168. return 0;
  169. }
  170. void GetRemoteWindbgExtApis(
  171. PWINDBG_EXTENSION_APIS64 ExtensionApis
  172. )
  173. {
  174. ExtensionApis->lpOutputRoutine = RemoteThunkOutputRoutine;
  175. ExtensionApis->lpGetExpressionRoutine = RemoteThunkGetExpressionRoutine;
  176. ExtensionApis->lpGetSymbolRoutine = RemoteThunkGetSymbolRoutine;
  177. ExtensionApis->lpDisasmRoutine = RemoteThunkDisasmRoutine;
  178. ExtensionApis->lpCheckControlCRoutine = RemoteThunkCheckControlCRoutine;
  179. ExtensionApis->lpReadProcessMemoryRoutine = RemoteThunkReadProcessMemoryRoutine;
  180. ExtensionApis->lpWriteProcessMemoryRoutine = RemoteThunkWriteProcessMemoryRoutine;
  181. ExtensionApis->lpGetThreadContextRoutine = RemoteThunkGetThreadContextRoutine;
  182. ExtensionApis->lpSetThreadContextRoutine = RemoteThunkSetThreadContextRoutine;
  183. ExtensionApis->lpIoctlRoutine = RemoteThunkIoctlRoutine;
  184. ExtensionApis->lpStackTraceRoutine = RemoteThunkStackTraceRoutine;
  185. }