mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
This commit is contained in:
10
Plugins/PluginPerfMon/MakePtr.h
Normal file
10
Plugins/PluginPerfMon/MakePtr.h
Normal file
@ -0,0 +1,10 @@
|
||||
// MakePtr is a macro that allows you to easily add two values (including
|
||||
// pointers) together without dealing with C's pointer arithmetic. It
|
||||
// essentially treats the last two parameters as DWORDs. The first
|
||||
// parameter is used to typecast the result to the appropriate pointer type.
|
||||
#ifdef _WIN64
|
||||
#define MakePtr(cast, ptr, addValue) (cast)( (DWORD64)(ptr) + (DWORD64)(addValue))
|
||||
#else
|
||||
#define MakePtr(cast, ptr, addValue) (cast)( (DWORD)(ptr) + (DWORD)(addValue))
|
||||
#endif
|
||||
|
138
Plugins/PluginPerfMon/ObjInst.cpp
Normal file
138
Plugins/PluginPerfMon/ObjInst.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
//====================================
|
||||
// File: OBJINST.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", April 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#pragma hdrstop
|
||||
#include "titledb.h"
|
||||
#include "objinst.h"
|
||||
#include "perfcntr.h"
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectInstance::CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
{
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObjectInstance::GetObjectInstanceName(
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
{
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef )
|
||||
{
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByIndex( DWORD index )
|
||||
{
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetFirstCounter( void )
|
||||
{
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetNextCounter( void )
|
||||
{
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByName( PCTSTR const pszName )
|
||||
{
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
59
Plugins/PluginPerfMon/ObjInst.h
Normal file
59
Plugins/PluginPerfMon/ObjInst.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef __Obinst_h__
|
||||
#define __Objinst_h__
|
||||
|
||||
#ifndef _WINDOWS_
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef _WINPERF_
|
||||
#include <winperf.h>
|
||||
#endif
|
||||
|
||||
class CPerfTitleDatabase;
|
||||
class CPerfCounter;
|
||||
|
||||
class CPerfObjectInstance
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef, DWORD nCounters,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase, BOOL fDummy );
|
||||
|
||||
~CPerfObjectInstance( void ){ }
|
||||
|
||||
BOOL GetObjectInstanceName( PTSTR pszObjInstName, DWORD nSize );
|
||||
|
||||
// Functions that return CPerfCounter pointers. Caller is
|
||||
// responsible for deleting the CPerfCounter * when done with it.
|
||||
|
||||
CPerfCounter * GetFirstCounter( void );
|
||||
|
||||
CPerfCounter * GetNextCounter( void );
|
||||
|
||||
CPerfCounter * GetCounterByName( PCTSTR const pszName );
|
||||
|
||||
protected:
|
||||
|
||||
PPERF_INSTANCE_DEFINITION m_pPerfInstDef;
|
||||
|
||||
unsigned m_nCounters;
|
||||
|
||||
unsigned m_currentCounter;
|
||||
|
||||
PPERF_COUNTER_DEFINITION m_pPerfCntrDef;
|
||||
|
||||
CPerfTitleDatabase * m_pPerfCounterTitles;
|
||||
|
||||
CPerfCounter * MakeCounter( PPERF_COUNTER_DEFINITION const pCounter );
|
||||
|
||||
CPerfCounter * GetCounterByIndex( DWORD index );
|
||||
|
||||
CPerfTitleDatabase *m_pCounterTitleDatabase;
|
||||
|
||||
BOOL m_fDummy; // FALSE normally, TRUE when an object with no instances
|
||||
};
|
||||
|
||||
typedef CPerfObjectInstance * PCPerfObjectInstance;
|
||||
|
||||
#endif
|
84
Plugins/PluginPerfMon/ObjList.cpp
Normal file
84
Plugins/PluginPerfMon/ObjList.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
//====================================
|
||||
// File: OBJLIST.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", April 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#pragma hdrstop
|
||||
#include "titledb.h"
|
||||
#include "objlist.h"
|
||||
#include "perfobj.h"
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectList::CPerfObjectList(
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
{
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetFirstPerfObject( void )
|
||||
{
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetNextPerfObject( void )
|
||||
{
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName )
|
||||
{
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
46
Plugins/PluginPerfMon/ObjList.h
Normal file
46
Plugins/PluginPerfMon/ObjList.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef __Objlist_h__
|
||||
#define __Objlist_h__
|
||||
|
||||
#ifndef _WINDOWS_
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef _WINPERF_
|
||||
#include <winperf.h>
|
||||
#endif
|
||||
#ifndef __Perfsnap_h__
|
||||
#include "perfsnap.h"
|
||||
#endif
|
||||
|
||||
class CPerfObject;
|
||||
|
||||
class CPerfObjectList
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfObjectList(CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase );
|
||||
|
||||
~CPerfObjectList( void ){ };
|
||||
|
||||
// Functions that return CPerfObject pointers. Caller is responsible
|
||||
// for deleting the CPerfObject * when done with it.
|
||||
|
||||
CPerfObject * GetFirstPerfObject( void );
|
||||
|
||||
CPerfObject * GetNextPerfObject( void );
|
||||
|
||||
CPerfObject * GetPerfObject( PCTSTR const pszObjListName );
|
||||
|
||||
protected:
|
||||
|
||||
CPerfSnapshot * m_pPerfSnapshot;
|
||||
|
||||
CPerfTitleDatabase * m_pPerfCounterTitles;
|
||||
|
||||
unsigned m_currentObjectListIndex;
|
||||
|
||||
PPERF_OBJECT_TYPE m_pCurrObjectType; // current first/next object ptr
|
||||
};
|
||||
|
||||
typedef CPerfObjectList * PCPerfObjectList;
|
||||
#endif
|
124
Plugins/PluginPerfMon/PerfCntr.cpp
Normal file
124
Plugins/PluginPerfMon/PerfCntr.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
//====================================
|
||||
// File: PERFCNTR.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", APRIL 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <tchar.h>
|
||||
#pragma hdrstop
|
||||
#include "perfcntr.h"
|
||||
|
||||
CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData )
|
||||
{
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
}
|
||||
|
||||
CPerfCounter::~CPerfCounter( void )
|
||||
{
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType )
|
||||
{
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex )
|
||||
{
|
||||
// Do better formatting!!! Check length!!!
|
||||
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
break;
|
||||
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
}
|
35
Plugins/PluginPerfMon/PerfCntr.h
Normal file
35
Plugins/PluginPerfMon/PerfCntr.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef __Perfcntr_h__
|
||||
#define __Perfcntr_h__
|
||||
|
||||
class CPerfCounter
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData );
|
||||
|
||||
~CPerfCounter( void );
|
||||
|
||||
PTSTR GetName( void ) { return m_pszName; }
|
||||
|
||||
DWORD GetType( void ) { return m_type; }
|
||||
|
||||
DWORD GetSize( void ) { return m_cbData; }
|
||||
|
||||
BOOL GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType );
|
||||
|
||||
BOOL Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex = FALSE );
|
||||
|
||||
protected:
|
||||
|
||||
PTSTR m_pszName;
|
||||
|
||||
DWORD m_type;
|
||||
|
||||
PBYTE m_pData;
|
||||
|
||||
DWORD m_cbData;
|
||||
};
|
||||
|
||||
typedef CPerfCounter * PCPerfCounter;
|
||||
#endif
|
261
Plugins/PluginPerfMon/PerfData.cpp
Normal file
261
Plugins/PluginPerfMon/PerfData.cpp
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
Copyright (C) 2004 Kimmo Pekkola
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include "PerfData.h"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <crtdbg.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName);
|
||||
|
||||
struct PerfMeasure
|
||||
{
|
||||
std::wstring ObjectName;
|
||||
std::wstring CounterName;
|
||||
std::wstring InstanceName;
|
||||
bool Difference;
|
||||
ULONGLONG OldValue;
|
||||
bool FirstTime;
|
||||
};
|
||||
|
||||
static CPerfTitleDatabase g_CounterTitles( PERF_TITLE_COUNTER );
|
||||
static std::map<UINT, PerfMeasure*> g_Measures;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
The return value can also be 0, which means that Rainmeter will
|
||||
track the maximum value automatically. The parameters for this
|
||||
function are:
|
||||
|
||||
instance The instance of this DLL
|
||||
iniFile The name of the ini-file (usually Rainmeter.ini)
|
||||
section The name of the section in the ini-file for this measure
|
||||
id The identifier for the measure. This is used to identify the measures that use the same plugin.
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
PerfMeasure* measure = new PerfMeasure;
|
||||
measure->Difference = false;
|
||||
measure->FirstTime = true;
|
||||
measure->OldValue = 0;
|
||||
|
||||
LPCTSTR buffer = ReadConfigString(section, L"PerfMonObject", L"");
|
||||
if (buffer)
|
||||
{
|
||||
measure->ObjectName = buffer;
|
||||
}
|
||||
|
||||
buffer = ReadConfigString(section, L"PerfMonCounter", L"");
|
||||
if (buffer)
|
||||
{
|
||||
measure->CounterName = buffer;
|
||||
}
|
||||
|
||||
buffer = ReadConfigString(section, L"PerfMonInstance", L"");
|
||||
if (buffer)
|
||||
{
|
||||
measure->InstanceName = buffer;
|
||||
}
|
||||
|
||||
buffer = ReadConfigString(section, L"PerfMonDifference", L"1");
|
||||
if (buffer)
|
||||
{
|
||||
measure->Difference = 1==_wtoi(buffer);
|
||||
}
|
||||
|
||||
// Store the measure
|
||||
g_Measures[id] = measure;
|
||||
|
||||
int maxVal = 0;
|
||||
buffer = ReadConfigString(section, L"PerfMonMaxValue", L"0");
|
||||
if (buffer)
|
||||
{
|
||||
maxVal = _wtoi(buffer);
|
||||
}
|
||||
|
||||
return maxVal;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
UINT value = 0;
|
||||
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
{
|
||||
PerfMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
{
|
||||
// Check the platform
|
||||
OSVERSIONINFO osvi;
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
if(GetVersionEx((OSVERSIONINFO*)&osvi) && osvi.dwPlatformId == VER_PLATFORM_WIN32_NT && osvi.dwMajorVersion > 4)
|
||||
{
|
||||
ULONGLONG longvalue = 0;
|
||||
longvalue = GetPerfData(measure->ObjectName.c_str(),
|
||||
measure->InstanceName.c_str(),
|
||||
measure->CounterName.c_str());
|
||||
|
||||
if(measure->Difference)
|
||||
{
|
||||
// Compare with the old value
|
||||
if(!measure->FirstTime)
|
||||
{
|
||||
value = (UINT)(longvalue - measure->OldValue);
|
||||
}
|
||||
measure->OldValue = longvalue;
|
||||
measure->FirstTime = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = (UINT)longvalue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"PerfMon plugin works only in Win2K/XP.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
If the measure needs to free resources before quitting.
|
||||
The plugin can export Finalize function, which is called
|
||||
when Rainmeter quits (or refreshes).
|
||||
*/
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, PerfMeasure*>::iterator i = g_Measures.find(id);
|
||||
if(i != g_Measures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_Measures.erase(i);
|
||||
}
|
||||
|
||||
CPerfSnapshot::CleanUp();
|
||||
}
|
||||
|
||||
/*
|
||||
This method gets value of the given perfmon counter.
|
||||
*/
|
||||
ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName)
|
||||
{
|
||||
CPerfObject* pPerfObj;
|
||||
CPerfObjectInstance* pObjInst;
|
||||
CPerfCounter* pPerfCntr;
|
||||
BYTE data[256];
|
||||
WCHAR name[256];
|
||||
ULONGLONG value = 0;
|
||||
|
||||
if(ObjectName == NULL || CounterName == NULL || wcslen(ObjectName) == 0 || wcslen(CounterName) == 0)
|
||||
{
|
||||
// Unable to continue
|
||||
return 0;
|
||||
}
|
||||
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(ObjectName))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(ObjectName);
|
||||
|
||||
if(pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if (InstanceName != NULL && wcslen(InstanceName) > 0)
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if(_wcsicmp(InstanceName, name) != 0)
|
||||
{
|
||||
delete pObjInst;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
delete pObjInst;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(CounterName);
|
||||
if(pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 1)
|
||||
{
|
||||
value = *(BYTE*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 2)
|
||||
{
|
||||
value = *(WORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 4)
|
||||
{
|
||||
value = *(DWORD*)data;
|
||||
}
|
||||
else if(pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
value = *(ULONGLONG*)data;
|
||||
}
|
||||
|
||||
delete pPerfCntr;
|
||||
delete pObjInst;
|
||||
break; // No need to continue
|
||||
}
|
||||
delete pObjInst;
|
||||
}
|
||||
delete pPerfObj;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1002;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
||||
|
||||
|
23
Plugins/PluginPerfMon/PerfData.h
Normal file
23
Plugins/PluginPerfMon/PerfData.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __Perfdata_h__
|
||||
#define __Perfdata_h__
|
||||
|
||||
#include "titledb.h"
|
||||
#include "perfsnap.h"
|
||||
#include "objlist.h"
|
||||
#include "perfobj.h"
|
||||
#include "objinst.h"
|
||||
#include "perfcntr.h"
|
||||
|
||||
#pragma warning ( disable: 4786 )
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) UINT Update(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
#endif
|
97
Plugins/PluginPerfMon/PerfObj.cpp
Normal file
97
Plugins/PluginPerfMon/PerfObj.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
//====================================
|
||||
// File: PERFOBJ.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", APRIL 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#pragma hdrstop
|
||||
#include "titledb.h"
|
||||
#include "perfobj.h"
|
||||
#include "objinst.h"
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObject::CPerfObject( PPERF_OBJECT_TYPE const pObjectList,
|
||||
CPerfTitleDatabase * const pPerfCounterTitles)
|
||||
{
|
||||
m_pObjectList = pObjectList;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetFirstObjectInstance( void )
|
||||
{
|
||||
m_currentObjectInstance = 0;
|
||||
if ( m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Point at the first PERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition =
|
||||
MakePtr( PPERF_INSTANCE_DEFINITION, m_pObjectList,
|
||||
m_pObjectList->DefinitionLength );
|
||||
|
||||
return new CPerfObjectInstance(
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList, m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
m_pObjectList->NumInstances ==
|
||||
PERF_NO_INSTANCES ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
CPerfObjectInstance *
|
||||
CPerfObject::GetNextObjectInstance( void )
|
||||
{
|
||||
if ( m_pObjectList->NumInstances == PERF_NO_INSTANCES )
|
||||
return 0;
|
||||
|
||||
if ( ++m_currentObjectInstance >= GetObjectInstanceCount() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_INSTANCE_DEFINITION in the list. However,
|
||||
// following the current PERF_INSTANCE_DEFINITION is the counter data,
|
||||
// which is also of variable length. So, we gotta take that into
|
||||
// account when finding the next PERF_INSTANCE_DEFINITION
|
||||
|
||||
// First, get a pointer to the counter data size field
|
||||
PDWORD pCounterDataSize
|
||||
= MakePtr(PDWORD, m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength);
|
||||
|
||||
// Now we can point at the next PPERF_INSTANCE_DEFINITION
|
||||
m_pCurrentObjectInstanceDefinition = MakePtr(PPERF_INSTANCE_DEFINITION,
|
||||
m_pCurrentObjectInstanceDefinition,
|
||||
m_pCurrentObjectInstanceDefinition->ByteLength
|
||||
+ *pCounterDataSize);
|
||||
|
||||
// Create a CPerfObjectInstance based around the PPERF_INSTANCE_DEFINITION
|
||||
return new CPerfObjectInstance(m_pCurrentObjectInstanceDefinition,
|
||||
MakePtr(PPERF_COUNTER_DEFINITION,
|
||||
m_pObjectList,
|
||||
m_pObjectList->HeaderLength),
|
||||
m_pObjectList->NumCounters,
|
||||
m_pPerfCounterTitles,
|
||||
FALSE );
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObject::GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize )
|
||||
{
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
m_pObjectList->ObjectNameTitleIndex );
|
||||
|
||||
if ( !pszName )
|
||||
return FALSE;
|
||||
|
||||
lstrcpyn( pszObjTypeName, pszName, nSize );
|
||||
return TRUE;
|
||||
}
|
45
Plugins/PluginPerfMon/PerfObj.h
Normal file
45
Plugins/PluginPerfMon/PerfObj.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __Perfobj_h__
|
||||
#define __Perfobj_h__
|
||||
|
||||
#ifndef _WINDOWS_
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef _WINPERF_
|
||||
#include <winperf.h>
|
||||
#endif
|
||||
|
||||
class CPerfObjectInstance;
|
||||
|
||||
class CPerfObject
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfObject( PPERF_OBJECT_TYPE const pObjectList,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase );
|
||||
|
||||
~CPerfObject( void ){ }
|
||||
|
||||
// Functions that return CPerfObjectInstance pointers. Caller is
|
||||
// responsible for deleting the CPerfObjectInstance * when done with it.
|
||||
|
||||
CPerfObjectInstance * GetFirstObjectInstance( void );
|
||||
|
||||
CPerfObjectInstance * GetNextObjectInstance( void );
|
||||
|
||||
unsigned GetObjectInstanceCount(void){return m_pObjectList->NumInstances;}
|
||||
|
||||
BOOL GetObjectTypeName( PTSTR pszObjTypeName, DWORD nSize );
|
||||
|
||||
protected:
|
||||
|
||||
PPERF_OBJECT_TYPE m_pObjectList;
|
||||
|
||||
unsigned m_currentObjectInstance;
|
||||
|
||||
PPERF_INSTANCE_DEFINITION m_pCurrentObjectInstanceDefinition;
|
||||
|
||||
CPerfTitleDatabase * m_pPerfCounterTitles;
|
||||
};
|
||||
|
||||
typedef CPerfObject * PCPerfObject;
|
||||
#endif
|
166
Plugins/PluginPerfMon/PerfSnap.cpp
Normal file
166
Plugins/PluginPerfMon/PerfSnap.cpp
Normal file
@ -0,0 +1,166 @@
|
||||
//============================================================================
|
||||
// File: PERFSNAP.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal, "Under the Hood", March 1996
|
||||
//============================================================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#include <tchar.h>
|
||||
#pragma hdrstop
|
||||
#include "titledb.h"
|
||||
#include "perfsnap.h"
|
||||
#include "makeptr.h"
|
||||
|
||||
PBYTE CPerfSnapshot::c_pBuffer = NULL;
|
||||
DWORD CPerfSnapshot::c_cbBufferSize = 0;
|
||||
|
||||
CPerfSnapshot::CPerfSnapshot(
|
||||
CPerfTitleDatabase * pCounterTitles )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
m_pCounterTitles = pCounterTitles;
|
||||
}
|
||||
|
||||
CPerfSnapshot::~CPerfSnapshot( void )
|
||||
{
|
||||
DisposeSnapshot();
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::TakeSnapshot( PCTSTR pszSnapshotItems )
|
||||
{
|
||||
DisposeSnapshot(); // Clear out any current snapshot
|
||||
|
||||
// Convert the input string (e.g., "Process") into the form required
|
||||
// by the HKEY_PERFORMANCE_DATA key (e.g., "232")
|
||||
|
||||
TCHAR szConvertedItemNames[ 256 ];
|
||||
if ( !ConvertSnapshotItemName( pszSnapshotItems, szConvertedItemNames,
|
||||
sizeof(szConvertedItemNames) ) )
|
||||
return FALSE;
|
||||
|
||||
DWORD cbAllocSize = 0;
|
||||
LONG retValue;
|
||||
|
||||
while ( 1 ) // Loop until we get the data, or we fail unexpectedly
|
||||
{
|
||||
retValue = RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
szConvertedItemNames, 0, 0,
|
||||
c_pBuffer, &c_cbBufferSize );
|
||||
|
||||
if ( retValue == ERROR_SUCCESS ) // We apparently got the snapshot
|
||||
{
|
||||
m_pPerfDataHeader = (PPERF_DATA_BLOCK)c_pBuffer;
|
||||
|
||||
// Verify that the signature is a unicode "PERF"
|
||||
if ( memcmp( m_pPerfDataHeader->Signature, L"PERF", 8 ) )
|
||||
break;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if ( retValue != ERROR_MORE_DATA ) // Anything other failure
|
||||
break; // code means something
|
||||
// bad happened, so bail out.
|
||||
|
||||
// If we get here, our buffer wasn't big enough. Delete it and
|
||||
// try again with a bigger buffer.
|
||||
delete [] c_pBuffer;
|
||||
|
||||
// The new buffer size will be 4096 bytes bigger than the larger
|
||||
// of: 1) The previous allocation size, or 2) The size that the
|
||||
// RegQueryValueEx call said was necessary.
|
||||
if ( c_cbBufferSize > cbAllocSize )
|
||||
cbAllocSize = c_cbBufferSize + 4096;
|
||||
else
|
||||
cbAllocSize += 4096;
|
||||
|
||||
// Allocate a new, larger buffer in preparation to try again.
|
||||
c_pBuffer = new BYTE[ cbAllocSize ];
|
||||
if ( !c_pBuffer )
|
||||
break;
|
||||
|
||||
c_cbBufferSize = cbAllocSize;
|
||||
}
|
||||
|
||||
// If we get here, the RegQueryValueEx failed unexpectedly.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::DisposeSnapshot( void )
|
||||
{
|
||||
m_pPerfDataHeader = 0;
|
||||
}
|
||||
|
||||
void
|
||||
CPerfSnapshot::CleanUp( void )
|
||||
{
|
||||
delete [] c_pBuffer;
|
||||
c_pBuffer = 0;
|
||||
c_cbBufferSize = 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
CPerfSnapshot::GetNumObjectTypes( void )
|
||||
{
|
||||
return m_pPerfDataHeader ? m_pPerfDataHeader->NumObjectTypes: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::GetSystemName( PTSTR pszSystemName, DWORD nSize )
|
||||
{
|
||||
if ( !m_pPerfDataHeader ) // If no snapshot data, bail out.
|
||||
return FALSE;
|
||||
|
||||
// Make sure the input buffer size is big enough
|
||||
if ( nSize < m_pPerfDataHeader->SystemNameLength )
|
||||
return FALSE;
|
||||
|
||||
// Make a unicode string point to the system name string
|
||||
// that's stored in the PERF_DATA_BLOCK
|
||||
LPWSTR lpwszName = MakePtr( LPWSTR, m_pPerfDataHeader,
|
||||
m_pPerfDataHeader->SystemNameOffset );
|
||||
|
||||
#ifdef UNICODE // Copy the PERF_DATA_BLOCK string to the input buffer
|
||||
lstrcpy( pszSystemName, lpwszName );
|
||||
#else
|
||||
wcstombs( pszSystemName, lpwszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
PVOID
|
||||
CPerfSnapshot::GetPostHeaderPointer( void )
|
||||
{
|
||||
// Returns a header to the first byte following the PERF_DATA_BLOCK
|
||||
// (including the variable length system name string at the end)
|
||||
return m_pPerfDataHeader ?
|
||||
MakePtr(PVOID, m_pPerfDataHeader,m_pPerfDataHeader->HeaderLength)
|
||||
: 0;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfSnapshot::ConvertSnapshotItemName( PCTSTR pszIn,
|
||||
PTSTR pszOut, DWORD nSize )
|
||||
{
|
||||
if ( IsBadStringPtr( pszIn, 0xFFFFFFFF ) )
|
||||
return FALSE;
|
||||
|
||||
|
||||
DWORD objectID = m_pCounterTitles->GetIndexFromTitleString(pszIn);
|
||||
|
||||
if ( objectID )
|
||||
pszOut += wsprintf( pszOut, TEXT("%u "), objectID );
|
||||
else
|
||||
pszOut += wsprintf( pszOut, TEXT("%s "), pszIn );
|
||||
|
||||
return TRUE;
|
||||
}
|
43
Plugins/PluginPerfMon/PerfSnap.h
Normal file
43
Plugins/PluginPerfMon/PerfSnap.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef __Perfsnap_h__
|
||||
#define __Perfsnap_h__
|
||||
|
||||
#ifndef _WINPERF_
|
||||
#include <winperf.h>
|
||||
#endif
|
||||
|
||||
class CPerfTitleDatabase;
|
||||
|
||||
class CPerfSnapshot
|
||||
{
|
||||
private:
|
||||
|
||||
static PBYTE c_pBuffer;
|
||||
static DWORD c_cbBufferSize;
|
||||
|
||||
PPERF_DATA_BLOCK m_pPerfDataHeader; // Points to snapshot data
|
||||
CPerfTitleDatabase * m_pCounterTitles; // The title conversion object
|
||||
|
||||
// Private function to convert the ASCII strings passedto TakeSnapshot()
|
||||
// into a suitable form for the RegQueryValue call
|
||||
BOOL ConvertSnapshotItemName( PCTSTR pszIn, PTSTR pszOut, DWORD nSize );
|
||||
|
||||
public:
|
||||
|
||||
CPerfSnapshot( CPerfTitleDatabase * pCounterTitles );
|
||||
|
||||
~CPerfSnapshot( void );
|
||||
|
||||
BOOL TakeSnapshot( PCTSTR pszSnapshotItems );
|
||||
|
||||
void DisposeSnapshot( void );
|
||||
|
||||
DWORD GetNumObjectTypes( void ); // # of objects the snapshot includes
|
||||
|
||||
BOOL GetSystemName( PTSTR pszSystemName, DWORD nSize );
|
||||
|
||||
PVOID GetPostHeaderPointer( void ); // Pointer to data following header
|
||||
|
||||
static void CleanUp( void );
|
||||
};
|
||||
|
||||
#endif
|
181
Plugins/PluginPerfMon/PluginPerfMon.dsp
Normal file
181
Plugins/PluginPerfMon/PluginPerfMon.dsp
Normal file
@ -0,0 +1,181 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginPerfMon" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginPerfMon - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginPerfMon.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginPerfMon.mak" CFG="PluginPerfMon - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginPerfMon - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginPerfMon - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginPerfMon - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginPerfMon"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginPerfMon - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x32/Release"
|
||||
# PROP Intermediate_Dir "x32/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PluginPerfMon_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPerfMon_EXPORTS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/PerfMon.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginPerfMon - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x32/Debug"
|
||||
# PROP Intermediate_Dir "x32/Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PluginPerfMon_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPerfMon_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "_DEBUG"
|
||||
# ADD RSC /l 0x40b /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/PerfMon.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginPerfMon - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginPerfMon___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginPerfMon___Win32_Release_64"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64/Release"
|
||||
# PROP Intermediate_Dir "x64/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPerfMon_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPerfMon_EXPORTS" /FD /GL /EHsc /Wp64 /GA /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/PerfMon.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:IX86 /out:"../../TestBench/x64/Release/Plugins/PerfMon.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginPerfMon - Win32 Release"
|
||||
# Name "PluginPerfMon - Win32 Debug"
|
||||
# Name "PluginPerfMon - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MakePtr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ObjInst.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ObjInst.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ObjList.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ObjList.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfCntr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfCntr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfData.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfData.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfObj.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfObj.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfSnap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PerfSnap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Titledb.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Titledb.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
406
Plugins/PluginPerfMon/PluginPerfMon.vcproj
Normal file
406
Plugins/PluginPerfMon/PluginPerfMon.vcproj
Normal file
@ -0,0 +1,406 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginPerfMon"
|
||||
SccProjectName="PluginPerfMon"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release 64|Win32"
|
||||
OutputDirectory=".\x64/Release"
|
||||
IntermediateDirectory=".\x64/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /Wp64 /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginPerfMon_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginPerfMon.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="bufferoverflowU.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/PerfMon.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/PerfMon.pdb"
|
||||
ImportLibrary=".\x64/Release/PerfMon.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginPerfMon.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\x32/Debug"
|
||||
IntermediateDirectory=".\x32/Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PluginPerfMon_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginPerfMon.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/PerfMon.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/PerfMon.pdb"
|
||||
ImportLibrary=".\x32/Debug/PerfMon.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginPerfMon.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\x32/Release"
|
||||
IntermediateDirectory=".\x32/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginPerfMon_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginPerfMon.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/PerfMon.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/PerfMon.pdb"
|
||||
ImportLibrary=".\x32/Release/PerfMon.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginPerfMon.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="MakePtr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ObjInst.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ObjInst.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ObjList.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ObjList.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfCntr.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfCntr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfData.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfData.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfObj.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfSnap.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="PerfSnap.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Titledb.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPerfMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Titledb.h">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
159
Plugins/PluginPerfMon/Titledb.cpp
Normal file
159
Plugins/PluginPerfMon/Titledb.cpp
Normal file
@ -0,0 +1,159 @@
|
||||
//===========================================================================
|
||||
// File: CTITLEDB.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal, "Under the Hood", March 1996
|
||||
//===========================================================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <winperf.h>
|
||||
#include <tchar.h>
|
||||
#pragma hdrstop
|
||||
#include "Titledb.h"
|
||||
|
||||
CPerfTitleDatabase::CPerfTitleDatabase(
|
||||
PERFORMANCE_TITLE_TYPE titleType )
|
||||
{
|
||||
m_nLastIndex = 0;
|
||||
m_TitleStrings = 0;
|
||||
m_pszRawStrings = 0;
|
||||
|
||||
// Determine the appropriate strings to pass to RegOpenKeyEx
|
||||
PTSTR psz009RegValue, pszLastIndexRegValue;
|
||||
if ( PERF_TITLE_COUNTER == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Counter 009");
|
||||
pszLastIndexRegValue = TEXT("Last Counter");
|
||||
}
|
||||
else if ( PERF_TITLE_EXPLAIN == titleType )
|
||||
{
|
||||
psz009RegValue = TEXT("Explain 009");
|
||||
pszLastIndexRegValue = TEXT("Last Help");
|
||||
}
|
||||
else
|
||||
return;
|
||||
|
||||
// Find out the max number of entries
|
||||
HKEY hKeyPerflib = 0;
|
||||
DWORD cbLastIndex;
|
||||
|
||||
// Open the registry key that has the values for the maximum number
|
||||
// of title strings
|
||||
if ( ERROR_SUCCESS != RegOpenKeyEx(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
TEXT("software\\microsoft\\windows nt\\currentversion\\perflib"),
|
||||
0, KEY_READ, &hKeyPerflib ) )
|
||||
return;
|
||||
|
||||
// Read in the number of title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx(
|
||||
hKeyPerflib, pszLastIndexRegValue, 0, 0,
|
||||
(PBYTE)&m_nLastIndex, &cbLastIndex ) )
|
||||
{
|
||||
RegCloseKey( hKeyPerflib );
|
||||
return;
|
||||
}
|
||||
|
||||
RegCloseKey( hKeyPerflib );
|
||||
|
||||
//
|
||||
// Now go find and process the raw string data
|
||||
//
|
||||
|
||||
// Determine how big the raw data in the REG_MULTI_SZ value is
|
||||
DWORD cbTitleStrings;
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA, psz009RegValue, 0,0,0, &cbTitleStrings))
|
||||
return;
|
||||
|
||||
// Allocate memory for the raw registry title string data
|
||||
m_pszRawStrings = new TCHAR[cbTitleStrings];
|
||||
|
||||
// Read in the raw title strings
|
||||
if ( ERROR_SUCCESS != RegQueryValueEx( HKEY_PERFORMANCE_DATA,
|
||||
psz009RegValue, 0, 0, (PBYTE)m_pszRawStrings,
|
||||
&cbTitleStrings ) )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
// allocate memory for an array of string pointers.
|
||||
m_TitleStrings = new PTSTR[ m_nLastIndex+1 ];
|
||||
if ( !m_TitleStrings )
|
||||
{
|
||||
delete []m_pszRawStrings;
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize the m_TitleStrings to all NULLs, since there may
|
||||
// be some array slots that aren't used.
|
||||
memset( m_TitleStrings, 0, sizeof(PTSTR) * (m_nLastIndex+1) );
|
||||
|
||||
// The raw data entries are an ASCII string index (e.g., "242"), followed
|
||||
// by the corresponding string. Fill in the appropriate slot in the
|
||||
// m_TitleStrings array with the pointer to the string name. The end
|
||||
// of the list is indicated by a double NULL.
|
||||
|
||||
PTSTR pszWorkStr = (PTSTR)m_pszRawStrings;
|
||||
unsigned cbCurrStr;
|
||||
|
||||
// While the length of the current string isn't 0...
|
||||
while ( 0 != (cbCurrStr = lstrlen( pszWorkStr)) )
|
||||
{
|
||||
// Convert the first string to a binary representation
|
||||
unsigned index = _ttoi( pszWorkStr ); // _ttoi -> atoi()
|
||||
|
||||
if ( index > m_nLastIndex )
|
||||
break;
|
||||
|
||||
// Now point to the string following it. This is the title string
|
||||
pszWorkStr += cbCurrStr + 1;
|
||||
|
||||
// Fill in the appropriate slot in the title strings array.
|
||||
m_TitleStrings[index] = pszWorkStr;
|
||||
|
||||
// Advance to the next index/title pair
|
||||
pszWorkStr += lstrlen(pszWorkStr) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
CPerfTitleDatabase::~CPerfTitleDatabase( )
|
||||
{
|
||||
delete []m_TitleStrings;
|
||||
m_TitleStrings = 0;
|
||||
delete []m_pszRawStrings;
|
||||
m_pszRawStrings = 0;
|
||||
m_nLastIndex = 0;
|
||||
}
|
||||
|
||||
PTSTR
|
||||
CPerfTitleDatabase::GetTitleStringFromIndex( unsigned index )
|
||||
{
|
||||
if ( index > m_nLastIndex ) // Is index within range?
|
||||
return 0;
|
||||
|
||||
return m_TitleStrings[ index ];
|
||||
}
|
||||
|
||||
unsigned
|
||||
CPerfTitleDatabase::GetIndexFromTitleString( PCTSTR pszTitleString )
|
||||
{
|
||||
if ( IsBadStringPtr(pszTitleString, 0xFFFFFFFF) )
|
||||
return 0;
|
||||
|
||||
// Loop through all the non-null string array entries, doing a case-
|
||||
// insensitive comparison. If found, return the correpsonding index
|
||||
for ( unsigned i = 1; i <= m_nLastIndex; i++ )
|
||||
{
|
||||
if ( m_TitleStrings[i] )
|
||||
if ( 0 == _tcsicmp( pszTitleString, m_TitleStrings[i] ) )
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
24
Plugins/PluginPerfMon/Titledb.h
Normal file
24
Plugins/PluginPerfMon/Titledb.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __Ctitledb_h__
|
||||
#define __Ctitledb_h__
|
||||
|
||||
enum PERFORMANCE_TITLE_TYPE { PERF_TITLE_COUNTER, PERF_TITLE_EXPLAIN };
|
||||
|
||||
class CPerfTitleDatabase
|
||||
{
|
||||
private:
|
||||
|
||||
unsigned m_nLastIndex;
|
||||
PTSTR * m_TitleStrings;
|
||||
PTSTR m_pszRawStrings;
|
||||
|
||||
public:
|
||||
|
||||
CPerfTitleDatabase( PERFORMANCE_TITLE_TYPE titleType );
|
||||
~CPerfTitleDatabase( );
|
||||
|
||||
unsigned GetLastTitleIndex(void) { return m_nLastIndex; }
|
||||
PTSTR GetTitleStringFromIndex( unsigned index );
|
||||
unsigned GetIndexFromTitleString( PCTSTR pszTitleString );
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user