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.

138 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. obperf.c
  5. Abstract:
  6. This module contains ob support routines for performance hooks.
  7. Author:
  8. Stephen Hsiao (shsiao) 11-May-2000
  9. Revision History:
  10. --*/
  11. #include "obp.h"
  12. BOOLEAN
  13. ObPerfDumpHandleEntry (
  14. IN PHANDLE_TABLE_ENTRY ObjectTableEntry,
  15. IN HANDLE HandleId,
  16. IN PVOID EnumParameter
  17. );
  18. #ifdef ALLOC_PRAGMA
  19. #pragma alloc_text(PAGEWMI, ObPerfDumpHandleEntry)
  20. #pragma alloc_text(PAGEWMI, ObPerfHandleTableWalk)
  21. #endif
  22. BOOLEAN
  23. ObPerfDumpHandleEntry (
  24. IN PHANDLE_TABLE_ENTRY ObjectTableEntry,
  25. IN HANDLE HandleId,
  26. IN PVOID EnumParameter
  27. )
  28. /*++
  29. Routine Description:
  30. This routine checks a HandleTableEntry and see if it a file
  31. Arguments:
  32. ObjectTableEntry - Points to the handle table entry of interest.
  33. HandleId - Supplies the handle.
  34. EnumParameter - The HashTable to be used
  35. Return Value:
  36. FALSE, which tells ExEnumHandleTable to continue iterating through the
  37. handle table.
  38. --*/
  39. {
  40. extern POBJECT_TYPE ObpDirectoryObjectType;
  41. extern POBJECT_TYPE IoFileObjectType;
  42. POBJECT_HEADER ObjectHeader;
  43. PVOID Object;
  44. PPERFINFO_ENTRY_TABLE HashTable = EnumParameter;
  45. UNREFERENCED_PARAMETER (HandleId);
  46. ObjectHeader = (POBJECT_HEADER)(((ULONG_PTR)(ObjectTableEntry->Object)) & ~OBJ_HANDLE_ATTRIBUTES);
  47. Object = &ObjectHeader->Body;
  48. if (ObjectHeader->Type == IoFileObjectType) {
  49. //
  50. // File Object
  51. //
  52. PFILE_OBJECT FileObject = (PFILE_OBJECT) Object;
  53. PerfInfoAddToFileHash(HashTable, FileObject);
  54. #if 0
  55. } else if (ObjectHeader->Type == ObpDirectoryObjectType) {
  56. } else if (ObjectHeader->Type == MmSectionObjectType) {
  57. #endif
  58. }
  59. return FALSE;
  60. }
  61. VOID
  62. ObPerfHandleTableWalk (
  63. PEPROCESS Process,
  64. PPERFINFO_ENTRY_TABLE HashTable
  65. )
  66. /*++
  67. Routine Description:
  68. This routine adds files in the handle table to the hash table.
  69. Arguments:
  70. Process - Process to walk through.
  71. If NULL, walk through the ObpKernelHandleTable;
  72. HashTable - HashTable in which to add the file
  73. Return Value:
  74. None.
  75. --*/
  76. {
  77. PHANDLE_TABLE ObjectTable;
  78. if (Process) {
  79. ObjectTable = ObReferenceProcessHandleTable (Process);
  80. if ( !ObjectTable ) {
  81. return ;
  82. }
  83. } else {
  84. //
  85. //
  86. //
  87. ObjectTable = ObpKernelHandleTable;
  88. }
  89. ExEnumHandleTable( ObjectTable,
  90. ObPerfDumpHandleEntry,
  91. (PVOID) HashTable,
  92. (PHANDLE)NULL );
  93. if (Process) {
  94. ObDereferenceProcessHandleTable( Process );
  95. }
  96. }