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.

77 lines
2.1 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: debug.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains random debugging related functions.
  7. *
  8. * History:
  9. * 17-May-1991 DarrinM Created.
  10. * 22-Jan-1992 IanJa ANSI/Unicode neutral (all debug output is ANSI)
  11. \***************************************************************************/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. /**************************************************************************\
  15. * ActivateDebugger
  16. *
  17. * Force an exception on the active application's context so it will break
  18. * into the debugger.
  19. *
  20. * History:
  21. * 05-10-91 DarrinM Created.
  22. \***************************************************************************/
  23. ULONG SrvActivateDebugger(
  24. IN OUT PCSR_API_MSG m,
  25. IN OUT PCSR_REPLY_STATUS ReplyStatus)
  26. {
  27. PACTIVATEDEBUGGERMSG a = (PACTIVATEDEBUGGERMSG)&m->u.ApiMessageData;
  28. PCSR_THREAD Thread;
  29. NTSTATUS Status;
  30. UNREFERENCED_PARAMETER(ReplyStatus);
  31. /*
  32. * If the process is CSR, break
  33. */
  34. if (a->ClientId.UniqueProcess == NtCurrentTeb()->ClientId.UniqueProcess) {
  35. DbgBreakPoint();
  36. return STATUS_SUCCESS;
  37. }
  38. /*
  39. * Impersonate the client if this is a user mode request.
  40. */
  41. if (m->h.u2.s2.Type == LPC_REQUEST) {
  42. if (!CsrImpersonateClient(NULL)) {
  43. return STATUS_UNSUCCESSFUL;
  44. }
  45. }
  46. /*
  47. * Lock the client thread
  48. */
  49. Status = CsrLockThreadByClientId(a->ClientId.UniqueThread, &Thread);
  50. if (NT_SUCCESS(Status)) {
  51. ASSERT(a->ClientId.UniqueProcess == Thread->ClientId.UniqueProcess);
  52. Status = DbgUiIssueRemoteBreakin (Thread->Process->ProcessHandle);
  53. UserAssert(NT_SUCCESS(Status));
  54. Status = NtAlertThread(Thread->ThreadHandle);
  55. UserAssert(NT_SUCCESS(Status));
  56. CsrUnlockThread(Thread);
  57. }
  58. /*
  59. * Stop impersonating the client.
  60. */
  61. if (m->h.u2.s2.Type == LPC_REQUEST) {
  62. CsrRevertToSelf();
  63. }
  64. return Status;
  65. }