home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / winnt / perftool / perfdlls / perfgen / perfutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-05  |  2.6 KB  |  105 lines

  1. /*++ BUILD Version: 0001    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1995-1997 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     perfutil.h  
  8.  
  9. Abstract:
  10.  
  11.     This file supports routines used to parse and
  12.     create Performance Monitor Data Structures.
  13.     It actually supports Performance Object types with
  14.     multiple instances
  15.  
  16. Author:
  17.  
  18.     Bob Watson  28-Jul-1995
  19.  
  20. Revision History:
  21.  
  22.  
  23. --*/
  24. #ifndef _PERFUTIL_H_
  25. #define _PERFUTIL_H_
  26.  
  27. // enable this define to log process heap data to the event log
  28. #ifdef PROBE_HEAP_USAGE
  29. #undef PROBE_HEAP_USAGE
  30. #endif
  31. //
  32. //  Utility macro.  This is used to reserve a DWORD multiple of
  33. //  bytes for Unicode strings embedded in the definitional data,
  34. //  viz., object instance names.
  35. //
  36. #define DWORD_MULTIPLE(x) (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
  37.  
  38. //    (assumes dword is 4 bytes long and pointer is a dword in size)
  39. #define ALIGN_ON_DWORD(x) ((VOID *)( ((DWORD) x & 0x00000003) ? ( ((DWORD) x & 0xFFFFFFFC) + 4 ) : ( (DWORD) x ) ))
  40.  
  41. extern WCHAR  GLOBAL_STRING[];      // Global command (get all local ctrs)
  42. extern WCHAR  FOREIGN_STRING[];           // get data from foreign computers
  43. extern WCHAR  COSTLY_STRING[];      
  44. extern WCHAR  NULL_STRING[];
  45.  
  46. #define QUERY_GLOBAL    1
  47. #define QUERY_ITEMS     2
  48. #define QUERY_FOREIGN   3
  49. #define QUERY_COSTLY    4
  50.  
  51. //
  52. // The definition of the only routine of perfutil.c, It builds part of a 
  53. // performance data instance (PERF_INSTANCE_DEFINITION) as described in 
  54. // winperf.h
  55. //
  56.  
  57. HANDLE MonOpenEventLog ();
  58. VOID MonCloseEventLog ();
  59. DWORD GetQueryType (IN LPWSTR);
  60. BOOL IsNumberInUnicodeList (DWORD, LPWSTR);
  61.  
  62. BOOL
  63. MonBuildInstanceDefinition(
  64.     PERF_INSTANCE_DEFINITION *pBuffer,
  65.     PVOID *pBufferNext,
  66.     DWORD ParentObjectTitleIndex,
  67.     DWORD ParentObjectInstance,
  68.     DWORD UniqueID,
  69.     LPWSTR Name
  70.     );
  71.  
  72. typedef struct _LOCAL_HEAP_INFO_BLOCK {
  73.     DWORD   AllocatedEntries;
  74.     DWORD   AllocatedBytes;
  75.     DWORD   FreeEntries;
  76.     DWORD   FreeBytes;
  77. } LOCAL_HEAP_INFO, *PLOCAL_HEAP_INFO;
  78.  
  79.  
  80. //
  81. //  Memory Probe macro
  82. //
  83. #ifdef PROBE_HEAP_USAGE
  84.  
  85. #define HEAP_PROBE()    { \
  86.     DWORD   dwHeapStatus[5]; \
  87.     NTSTATUS CallStatus; \
  88.     dwHeapStatus[4] = __LINE__; \
  89.     if (!(CallStatus = memprobe (dwHeapStatus, 16L, NULL))) { \
  90.         REPORT_INFORMATION_DATA (TCP_HEAP_STATUS, LOG_DEBUG,    \
  91.             &dwHeapStatus, sizeof(dwHeapStatus));  \
  92.     } else {  \
  93.         REPORT_ERROR_DATA (TCP_HEAP_STATUS_ERROR, LOG_DEBUG, \
  94.             &CallStatus, sizeof (DWORD)); \
  95.     } \
  96. }
  97.  
  98. #else
  99.  
  100. #define HEAP_PROBE()    ;
  101.  
  102. #endif
  103.  
  104. #endif  //_PERFUTIL_H_
  105.