|
|
1.1 ! root 1: ! 2: /******************************************************************************\ ! 3: * This is a part of the Microsoft Source Code Samples. ! 4: * Copyright (C) 1993 Microsoft Corporation. ! 5: * All rights reserved. ! 6: * This source code is only intended as a supplement to ! 7: * Microsoft Development Tools and/or WinHelp documentation. ! 8: * See these sources for detailed information regarding the ! 9: * Microsoft samples programs. ! 10: \******************************************************************************/ ! 11: ! 12: ! 13: /****************************************************************************** ! 14: ! 15: O B J E C T D A T A ! 16: ! 17: Name: objdata.c ! 18: ! 19: Description: ! 20: This module contains functions that access objects in performance ! 21: data. ! 22: ! 23: Functions: ! 24: FirstObject ! 25: NextObject ! 26: FindObject ! 27: FindObjectN ! 28: ! 29: ******************************************************************************/ ! 30: ! 31: #include <windows.h> ! 32: #include <winperf.h> ! 33: #include "perfdata.h" ! 34: ! 35: ! 36: ! 37: ! 38: //********************************************************************* ! 39: // ! 40: // FirstObject ! 41: // ! 42: // Returns pointer to the first object in pData. ! 43: // If pData is NULL then NULL is returned. ! 44: // ! 45: PPERF_OBJECT FirstObject (PPERF_DATA pData) ! 46: { ! 47: if (pData) ! 48: return ((PPERF_OBJECT) ((PBYTE) pData + pData->HeaderLength)); ! 49: else ! 50: return NULL; ! 51: } ! 52: ! 53: ! 54: ! 55: ! 56: //********************************************************************* ! 57: // ! 58: // NextObject ! 59: // ! 60: // Returns pointer to the next object following pObject. ! 61: // ! 62: // If pObject is the last object, bogus data maybe returned. ! 63: // The caller should do the checking. ! 64: // ! 65: // If pObject is NULL, then NULL is returned. ! 66: // ! 67: PPERF_OBJECT NextObject (PPERF_OBJECT pObject) ! 68: { ! 69: if (pObject) ! 70: return ((PPERF_OBJECT) ((PBYTE) pObject + pObject->TotalByteLength)); ! 71: else ! 72: return NULL; ! 73: } ! 74: ! 75: ! 76: ! 77: ! 78: //********************************************************************* ! 79: // ! 80: // FindObject ! 81: // ! 82: // Returns pointer to object with TitleIndex. If not found, NULL ! 83: // is returned. ! 84: // ! 85: PPERF_OBJECT FindObject (PPERF_DATA pData, DWORD TitleIndex) ! 86: { ! 87: PPERF_OBJECT pObject; ! 88: DWORD i = 0; ! 89: ! 90: if (pObject = FirstObject (pData)) ! 91: while (i < pData->NumObjectTypes) ! 92: { ! 93: if (pObject->ObjectNameTitleIndex == TitleIndex) ! 94: return pObject; ! 95: ! 96: pObject = NextObject (pObject); ! 97: i++; ! 98: } ! 99: ! 100: return NULL; ! 101: } ! 102: ! 103: ! 104: ! 105: ! 106: //********************************************************************* ! 107: // ! 108: // FindObjectN ! 109: // ! 110: // Find the Nth object in pData. If not found, NULL is returned. ! 111: // 0 <= N < NumObjectTypes. ! 112: // ! 113: PPERF_OBJECT FindObjectN (PPERF_DATA pData, DWORD N) ! 114: { ! 115: PPERF_OBJECT pObject; ! 116: DWORD i = 0; ! 117: ! 118: if (!pData) ! 119: return NULL; ! 120: else if (N >= pData->NumObjectTypes) ! 121: return NULL; ! 122: else ! 123: { ! 124: pObject = FirstObject (pData); ! 125: ! 126: while (i != N) ! 127: { ! 128: pObject = NextObject (pObject); ! 129: i++; ! 130: } ! 131: ! 132: return pObject; ! 133: } ! 134: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.