Source code of Windows XP (NT5)
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.

170 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. query.c
  5. Abstract:
  6. This module contains the NT service to query the debug print enable
  7. for a specified component and level.
  8. Author:
  9. David N. Cutler (davec) 29-Jan-2000
  10. Revision History:
  11. --*/
  12. #include "kdp.h"
  13. #pragma hdrstop
  14. #pragma alloc_text (PAGE, NtSetDebugFilterState)
  15. NTSTATUS
  16. NtQueryDebugFilterState(
  17. IN ULONG ComponentId,
  18. IN ULONG Level
  19. )
  20. /*++
  21. Routine Description:
  22. This function queries the debug print enable for a specified component
  23. level.
  24. Arguments:
  25. ComponentId - Supplies the component id.
  26. Level - Supplies the debug filter level number or mask.
  27. Return Value:
  28. STATUS_INVALID_PARAMETER_1 is returned if the component id is not
  29. valid.
  30. TRUE is returned if output is enabled for the specified component
  31. and level or is enabled for the system.
  32. FALSE is returned if output is not enabled for the specified component
  33. and level and is not enabled for the system.
  34. --*/
  35. {
  36. ULONG Mask;
  37. PULONG Value;
  38. //
  39. // If the component id is out of range, then return an invalid parameter
  40. // status. Otherwise, if output is enabled for the specified component
  41. // and level or is enabled for the system, then return TRUE. Otherwise,
  42. // return FALSE.
  43. //
  44. Value = &Kd_WIN2000_Mask;
  45. if (ComponentId < KdComponentTableSize) {
  46. Value = KdComponentTable[ComponentId];
  47. } else if (ComponentId != -1) {
  48. return STATUS_INVALID_PARAMETER_1;
  49. }
  50. if (Level > 31) {
  51. Mask = Level;
  52. } else {
  53. Mask = 1 << Level;
  54. }
  55. if (((Mask & Kd_WIN2000_Mask) == 0) &&
  56. ((Mask & *Value) == 0)) {
  57. return FALSE;
  58. } else {
  59. return TRUE;
  60. }
  61. }
  62. NTSTATUS
  63. NtSetDebugFilterState(
  64. IN ULONG ComponentId,
  65. IN ULONG Level,
  66. IN BOOLEAN State
  67. )
  68. /*++
  69. Routine Description:
  70. This function sets the state of the debug print enable for a specified
  71. component and level. The debug print enable state for the system is set
  72. by specifying the distinguished value -1 for the component id.
  73. Arguments:
  74. ComponentId - Supplies the component id.
  75. Level - Supplies the debug filter level number or mask.
  76. State - Supplies a boolean value that determines the new state.
  77. Return Value:
  78. STATUS_ACCESS_DENIED is returned if the required privilege is not held.
  79. STATUS_INVALID_PARAMETER_1 is returned if the component id is not
  80. valid.
  81. STATUS_SUCCESS is returned if the debug print enable state is set for
  82. the specified component.
  83. --*/
  84. {
  85. ULONG Enable;
  86. ULONG Mask;
  87. PULONG Value;
  88. //
  89. // If the required privilege is not held, then return a status of access
  90. // denied. Otherwise, if the component id is out of range, then return an
  91. // invalid parameter status. Otherwise, the debug print enable state is
  92. // set for the specified component and a success status is returned.
  93. //
  94. if (SeSinglePrivilegeCheck(SeDebugPrivilege, KeGetPreviousMode()) != FALSE) {
  95. Value = &Kd_WIN2000_Mask;
  96. if (ComponentId < KdComponentTableSize) {
  97. Value = KdComponentTable[ComponentId];
  98. } else if (ComponentId != - 1) {
  99. return STATUS_INVALID_PARAMETER_1;
  100. }
  101. if (Level > 31) {
  102. Mask = Level;
  103. } else {
  104. Mask = 1 << Level;
  105. }
  106. Enable = Mask;
  107. if (State == FALSE) {
  108. Enable = 0;
  109. }
  110. *Value = (*Value & ~Mask) | Enable;
  111. return STATUS_SUCCESS;
  112. } else {
  113. return STATUS_ACCESS_DENIED;
  114. }
  115. }