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.

136 lines
2.6 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. ObjectHeader = (POBJECT_HEADER)(((ULONG_PTR)(ObjectTableEntry->Object)) & ~OBJ_HANDLE_ATTRIBUTES);
  46. Object = &ObjectHeader->Body;
  47. if (ObjectHeader->Type == IoFileObjectType) {
  48. //
  49. // File Object
  50. //
  51. PFILE_OBJECT FileObject = (PFILE_OBJECT) Object;
  52. PerfInfoAddToFileHash(HashTable, FileObject);
  53. #if 0
  54. } else if (ObjectHeader->Type == ObpDirectoryObjectType) {
  55. } else if (ObjectHeader->Type == MmSectionObjectType) {
  56. #endif
  57. }
  58. return FALSE;
  59. }
  60. VOID
  61. ObPerfHandleTableWalk (
  62. PEPROCESS Process,
  63. PPERFINFO_ENTRY_TABLE HashTable
  64. )
  65. /*++
  66. Routine Description:
  67. This routine adds files in the handle table to the hash table.
  68. Arguments:
  69. Process - Process to walk through.
  70. If NULL, walk through the ObpKernelHandleTable;
  71. HashTable - HashTable in which to add the file
  72. Return Value:
  73. None.
  74. --*/
  75. {
  76. PHANDLE_TABLE ObjectTable;
  77. if (Process) {
  78. ObjectTable = ObReferenceProcessHandleTable (Process);
  79. if ( !ObjectTable ) {
  80. return ;
  81. }
  82. } else {
  83. //
  84. //
  85. //
  86. ObjectTable = ObpKernelHandleTable;
  87. }
  88. ExEnumHandleTable( ObjectTable,
  89. ObPerfDumpHandleEntry,
  90. (PVOID) HashTable,
  91. (PHANDLE)NULL );
  92. if (Process) {
  93. ObDereferenceProcessHandleTable( Process );
  94. }
  95. }