mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
This commit is contained in:
362
Plugins/PluginAdvancedCPU/AdvancedCPU.cpp
Normal file
362
Plugins/PluginAdvancedCPU/AdvancedCPU.cpp
Normal file
@ -0,0 +1,362 @@
|
||||
/*
|
||||
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 "AdvancedCPU.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
//ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName);
|
||||
void UpdateProcesses();
|
||||
|
||||
struct CPUMeasure
|
||||
{
|
||||
std::vector< std::wstring > includes;
|
||||
std::vector< std::wstring > excludes;
|
||||
int topProcess;
|
||||
std::wstring topProcessName;
|
||||
LONGLONG topProcessValue;
|
||||
};
|
||||
|
||||
struct ProcessValues
|
||||
{
|
||||
std::wstring name;
|
||||
LONGLONG oldValue;
|
||||
LONGLONG newValue;
|
||||
bool found;
|
||||
};
|
||||
|
||||
static CPerfTitleDatabase g_CounterTitles( PERF_TITLE_COUNTER );
|
||||
std::vector< ProcessValues > g_Processes;
|
||||
static std::map<UINT, CPUMeasure*> g_CPUMeasures;
|
||||
|
||||
void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
{
|
||||
WCHAR* token;
|
||||
|
||||
token = wcstok(names, L";");
|
||||
while(token != NULL)
|
||||
{
|
||||
splittedNames.push_back(token);
|
||||
token = wcstok(NULL, L";");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
WCHAR buffer[4096];
|
||||
CPUMeasure* measure = new CPUMeasure;
|
||||
measure->topProcess = 0;
|
||||
measure->topProcessValue = 0;
|
||||
|
||||
LPCTSTR data = ReadConfigString(section, L"CPUInclude", L"");
|
||||
if (data)
|
||||
{
|
||||
wcsncpy(buffer, data, 4096);
|
||||
buffer[4095] = 0;
|
||||
SplitName(buffer, measure->includes);
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"CPUExclude", L"");
|
||||
if (data)
|
||||
{
|
||||
wcsncpy(buffer, data, 4096);
|
||||
buffer[4095] = 0;
|
||||
SplitName(buffer, measure->excludes);
|
||||
}
|
||||
|
||||
measure->topProcess = 0;
|
||||
data = ReadConfigString(section, L"TopProcess", L"0");
|
||||
if (data)
|
||||
{
|
||||
measure->topProcess = _wtoi(data);
|
||||
}
|
||||
|
||||
g_CPUMeasures[id] = measure;
|
||||
|
||||
return 10000000; // The values are 100 * 100000
|
||||
}
|
||||
|
||||
bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
|
||||
{
|
||||
if (measure->includes.empty())
|
||||
{
|
||||
for (int i = 0; i < measure->excludes.size(); i++)
|
||||
{
|
||||
if (wcsicmp(measure->excludes[i].c_str(), name.c_str()) == 0)
|
||||
{
|
||||
return false; // Exclude
|
||||
}
|
||||
}
|
||||
return true; // Include
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < measure->includes.size(); i++)
|
||||
{
|
||||
if (wcsicmp(measure->includes[i].c_str(), name.c_str()) == 0)
|
||||
{
|
||||
return true; // Include
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
static DWORD oldTime = 0;
|
||||
|
||||
// Only update twice per second
|
||||
DWORD time = GetTickCount();
|
||||
if (oldTime == 0 || time - oldTime > 500)
|
||||
{
|
||||
UpdateProcesses();
|
||||
oldTime = time;
|
||||
}
|
||||
|
||||
LONGLONG newValue = 0;
|
||||
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
{
|
||||
for (int i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
// Check process include/exclude
|
||||
if (CheckProcess(measure, g_Processes[i].name))
|
||||
{
|
||||
if (g_Processes[i].oldValue != 0)
|
||||
{
|
||||
if (measure->topProcess == 0)
|
||||
{
|
||||
// Add all values together
|
||||
newValue += g_Processes[i].newValue - g_Processes[i].oldValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the top process
|
||||
if (newValue < g_Processes[i].newValue - g_Processes[i].oldValue)
|
||||
{
|
||||
newValue = g_Processes[i].newValue - g_Processes[i].oldValue;
|
||||
measure->topProcessName = g_Processes[i].name;
|
||||
measure->topProcessValue = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LONGLONG newValue = 0;
|
||||
// ULONGLONG longvalue = 0;
|
||||
//
|
||||
// if (measure->includes.empty())
|
||||
// {
|
||||
// // First get the total CPU value
|
||||
// longvalue = GetPerfData(L"Processor", L"_Total", L"% Processor Time");
|
||||
// newValue = longvalue;
|
||||
//
|
||||
// // Then substract the excluded processes
|
||||
// std::vector< std::wstring >::iterator j = measure->excludes.begin();
|
||||
// for( ; j != measure->excludes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue; // Adding means actually substraction
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// {
|
||||
// int val = 10000000 - (UINT)(newValue - measure->oldValue);
|
||||
// if (val < 0) val = 0;
|
||||
// value = val;
|
||||
// }
|
||||
// measure->oldValue = newValue;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Add the included processes
|
||||
// std::vector< std::wstring >::iterator j = measure->includes.begin();
|
||||
// for( ; j != measure->includes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue;
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// {
|
||||
// value = (UINT)(newValue - measure->oldValue);
|
||||
// }
|
||||
// measure->oldValue = newValue;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
return (double)newValue;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if (measure->topProcess == 2)
|
||||
{
|
||||
return measure->topProcessName.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
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, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_CPUMeasures.erase(i);
|
||||
}
|
||||
|
||||
CPerfSnapshot::CleanUp();
|
||||
}
|
||||
|
||||
/*
|
||||
This updates the process status
|
||||
*/
|
||||
void UpdateProcesses()
|
||||
{
|
||||
CPerfObject* pPerfObj;
|
||||
CPerfObjectInstance* pObjInst;
|
||||
CPerfCounter* pPerfCntr;
|
||||
BYTE data[256];
|
||||
WCHAR name[256];
|
||||
|
||||
std::vector< ProcessValues > newProcesses;
|
||||
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(L"Process"))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(L"Process");
|
||||
|
||||
if(pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if (wcscmp(name, L"_Total") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time");
|
||||
if(pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
ProcessValues values;
|
||||
values.name = name;
|
||||
values.oldValue = 0;
|
||||
|
||||
// Check if we can find the old value
|
||||
for (int i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
if (!g_Processes[i].found && g_Processes[i].name == name)
|
||||
{
|
||||
values.oldValue = g_Processes[i].newValue;
|
||||
g_Processes[i].found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
values.newValue = *(ULONGLONG*)data;
|
||||
values.found = false;
|
||||
newProcesses.push_back(values);
|
||||
|
||||
// LSLog(LOG_DEBUG, L"Rainmeter", name); // DEBUG
|
||||
}
|
||||
|
||||
delete pPerfCntr;
|
||||
}
|
||||
}
|
||||
delete pObjInst;
|
||||
}
|
||||
delete pPerfObj;
|
||||
}
|
||||
}
|
||||
|
||||
g_Processes = newProcesses;
|
||||
}
|
||||
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1005;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
||||
|
42
Plugins/PluginAdvancedCPU/AdvancedCPU.h
Normal file
42
Plugins/PluginAdvancedCPU/AdvancedCPU.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef __ADVANCEDCPU_H__
|
||||
#define __ADVANCEDCPU_H__
|
||||
|
||||
#include "../PluginPerfMon/titledb.h"
|
||||
#include "../PluginPerfMon/perfsnap.h"
|
||||
#include "../PluginPerfMon/objlist.h"
|
||||
#include "../PluginPerfMon/perfobj.h"
|
||||
#include "../PluginPerfMon/objinst.h"
|
||||
#include "../PluginPerfMon/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 ) double Update2(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
#endif
|
157
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.dsp
Normal file
157
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.dsp
Normal file
@ -0,0 +1,157 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginAdvancedCPU" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginAdvancedCPU - 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 "PluginAdvancedCPU.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 "PluginAdvancedCPU.mak" CFG="PluginAdvancedCPU - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginAdvancedCPU - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginAdvancedCPU - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginAdvancedCPU - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginAdvancedCPU"
|
||||
# PROP Scc_LocalPath ".."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginAdvancedCPU - 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 "PluginAdvancedCPU_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginAdvancedCPU_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/AdvancedCPU.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginAdvancedCPU - 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 "PluginAdvancedCPU_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 "PluginAdvancedCPU_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/AdvancedCPU.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginAdvancedCPU - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginAdvancedCPU___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginAdvancedCPU___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 "PluginAdvancedCPU_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginAdvancedCPU_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/AdvancedCPU.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/AdvancedCPU.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginAdvancedCPU - Win32 Release"
|
||||
# Name "PluginAdvancedCPU - Win32 Debug"
|
||||
# Name "PluginAdvancedCPU - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AdvancedCPU.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AdvancedCPU.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\MakePtr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\ObjInst.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\ObjList.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\PerfCntr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\PerfObj.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\PerfSnap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\Titledb.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
388
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.vcproj
Normal file
388
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.vcproj
Normal file
@ -0,0 +1,388 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginAdvancedCPU"
|
||||
SccProjectName="PluginAdvancedCPU"
|
||||
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;PluginAdvancedCPU_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginAdvancedCPU.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/AdvancedCPU.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/AdvancedCPU.pdb"
|
||||
ImportLibrary=".\x64/Release/AdvancedCPU.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginAdvancedCPU.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="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;PluginAdvancedCPU_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginAdvancedCPU.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/AdvancedCPU.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/AdvancedCPU.pdb"
|
||||
ImportLibrary=".\x32/Release/AdvancedCPU.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginAdvancedCPU.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;PluginAdvancedCPU_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginAdvancedCPU.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/AdvancedCPU.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/AdvancedCPU.pdb"
|
||||
ImportLibrary=".\x32/Debug/AdvancedCPU.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginAdvancedCPU.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>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="AdvancedCPU.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="AdvancedCPU.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\MakePtr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\ObjInst.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\ObjList.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\PerfCntr.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\PerfObj.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\PerfSnap.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\Titledb.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
140
Plugins/PluginExample/ExamplePlugin.c
Normal file
140
Plugins/PluginExample/ExamplePlugin.c
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginExample/ExamplePlugin.c,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: ExamplePlugin.c,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.3 2004/06/05 10:49:50 rainy
|
||||
Added new interface.
|
||||
Uses config parser.
|
||||
|
||||
Revision 1.2 2001/12/23 10:04:51 rainy
|
||||
Added ID to the interface.
|
||||
|
||||
Revision 1.1 2001/10/28 09:05:05 rainy
|
||||
Inital version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* The exported functions */
|
||||
__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();
|
||||
|
||||
/* Couple of globals */
|
||||
static UINT g_Phase = 100;
|
||||
static UINT g_CurrentPhase = 0;
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
/*
|
||||
Read our own settings from the ini-file
|
||||
The ReadConfigString can be used for this purpose. Plugins
|
||||
can also read the config some other way (e.g. with
|
||||
GetPrivateProfileInt, but in that case the variables
|
||||
do not work.
|
||||
*/
|
||||
LPCTSTR data = ReadConfigString(section, L"PhaseShift", L"0");
|
||||
if (data)
|
||||
{
|
||||
g_CurrentPhase = _wtoi(data);
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"Phase", L"100");
|
||||
if (data)
|
||||
{
|
||||
g_Phase = _wtoi(data);
|
||||
}
|
||||
|
||||
return 1000; /* We'll return values from 0 to 1000 */
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
/*
|
||||
This measure doesn't measure anything. It's just an
|
||||
example how to create Rainmeter plugins. We'll just
|
||||
return sine curve so that the meter shows something.
|
||||
*/
|
||||
|
||||
double value = 6.283185 * ((double)g_CurrentPhase / (double)g_Phase);
|
||||
value = sin(value);
|
||||
|
||||
g_CurrentPhase++;
|
||||
if(g_CurrentPhase > g_Phase)
|
||||
{
|
||||
g_CurrentPhase = 0;
|
||||
}
|
||||
|
||||
return (UINT)((value + 1.0) * 500.0);
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
/* Nothing to do here */
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the version number of the plugin. The value
|
||||
can be calculated like this: Major * 1000 + Minor.
|
||||
So, e.g. 2.31 would be 2031.
|
||||
*/
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the author of the plugin for the about dialog.
|
||||
*/
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
125
Plugins/PluginExample/PluginExample.dsp
Normal file
125
Plugins/PluginExample/PluginExample.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginExample" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginExample - 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 "PluginExample.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 "PluginExample.mak" CFG="PluginExample - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginExample - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginExample - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginExample - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginExample"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginExample - 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 "PLUGINEXAMPLE_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PLUGINEXAMPLE_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/ExamplePlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginExample - 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 "PLUGINEXAMPLE_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 "PLUGINEXAMPLE_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/ExamplePlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginExample - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginExample___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginExample___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 "PLUGINEXAMPLE_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PLUGINEXAMPLE_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/ExamplePlugin.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/ExamplePlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginExample - Win32 Release"
|
||||
# Name "PluginExample - Win32 Debug"
|
||||
# Name "PluginExample - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ExamplePlugin.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
232
Plugins/PluginExample/PluginExample.vcproj
Normal file
232
Plugins/PluginExample/PluginExample.vcproj
Normal file
@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginExample"
|
||||
SccProjectName="PluginExample"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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;PLUGINEXAMPLE_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginExample.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/ExamplePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/ExamplePlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/ExamplePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginExample.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;PLUGINEXAMPLE_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginExample.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/ExamplePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/ExamplePlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/ExamplePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginExample.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 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;PLUGINEXAMPLE_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginExample.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/ExamplePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/ExamplePlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/ExamplePlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginExample.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="ExamplePlugin.c">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
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
|
328
Plugins/PluginPing/Ping.cpp
Normal file
328
Plugins/PluginPing/Ping.cpp
Normal file
@ -0,0 +1,328 @@
|
||||
/*
|
||||
Copyright (C) 2005 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginPing/Ping.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Ping.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include <Ipexport.h>
|
||||
#include <Windns.h>
|
||||
#include <stdlib.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* 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 ) double Update2(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
struct pingData
|
||||
{
|
||||
IPAddr destAddr;
|
||||
DWORD timeout;
|
||||
double timeoutValue;
|
||||
DWORD updateRate;
|
||||
DWORD updateCounter;
|
||||
HANDLE threadHandle;
|
||||
double value;
|
||||
};
|
||||
|
||||
typedef struct tagIPINFO
|
||||
{
|
||||
u_char nTtl; // Time To Live
|
||||
u_char nTos; // Type Of Service
|
||||
u_char nIPFlags; // IP flags
|
||||
u_char nOptSize; // Size of options data
|
||||
u_char FAR* pOptions; // Options data buffer
|
||||
|
||||
} IPINFO;
|
||||
|
||||
typedef IPINFO* PIPINFO;
|
||||
|
||||
static std::map<UINT, pingData*> g_Values;
|
||||
static CRITICAL_SECTION g_CriticalSection;
|
||||
static bool g_Initialized = false;
|
||||
static HINSTANCE g_ICMPInstance = NULL;
|
||||
|
||||
typedef HANDLE (WINAPI *IcmpCreateFile)(VOID);
|
||||
typedef BOOL (WINAPI *IcmpCloseHandle)(HANDLE);
|
||||
typedef DWORD (WINAPI *IcmpSendEcho)(HANDLE, DWORD, LPVOID, WORD, PIPINFO, LPVOID, DWORD, DWORD);
|
||||
typedef DWORD (WINAPI *IcmpSendEcho2)(HANDLE, HANDLE, FARPROC, PVOID, IPAddr, LPVOID, WORD, PIP_OPTION_INFORMATION, LPVOID, DWORD, DWORD);
|
||||
|
||||
static IcmpCreateFile g_IcmpCreateFile = NULL;
|
||||
static IcmpCloseHandle g_IcmpCloseHandle = NULL;
|
||||
static IcmpSendEcho g_IcmpSendEcho = NULL;
|
||||
static IcmpSendEcho2 g_IcmpSendEcho2 = NULL;
|
||||
|
||||
std::string ConvertToAscii(LPCTSTR str)
|
||||
{
|
||||
std::string szAscii;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = (wcslen(str) + 1);
|
||||
char* tmpSz = new char[len * 2];
|
||||
WideCharToMultiByte(CP_ACP, 0, str, -1, tmpSz, (int)len * 2, NULL, FALSE);
|
||||
szAscii = tmpSz;
|
||||
delete tmpSz;
|
||||
}
|
||||
return szAscii;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
bool valid = false;
|
||||
pingData* pData = new pingData;
|
||||
|
||||
if (!g_Initialized)
|
||||
{
|
||||
InitializeCriticalSection(&g_CriticalSection);
|
||||
|
||||
g_ICMPInstance = LoadLibrary(L"ICMP.DLL");
|
||||
|
||||
if (g_ICMPInstance)
|
||||
{
|
||||
g_IcmpCreateFile = (IcmpCreateFile)GetProcAddress(g_ICMPInstance, "IcmpCreateFile");
|
||||
g_IcmpCloseHandle = (IcmpCloseHandle)GetProcAddress(g_ICMPInstance, "IcmpCloseHandle");
|
||||
g_IcmpSendEcho = (IcmpSendEcho)GetProcAddress(g_ICMPInstance,"IcmpSendEcho");
|
||||
g_IcmpSendEcho2 = (IcmpSendEcho2)GetProcAddress(g_ICMPInstance,"IcmpSendEcho2");
|
||||
}
|
||||
|
||||
g_Initialized = true;
|
||||
}
|
||||
|
||||
memset(pData, 0, sizeof(pingData));
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR data = ReadConfigString(section, L"DestAddress", NULL);
|
||||
if (data)
|
||||
{
|
||||
std::string szData = ConvertToAscii(data);
|
||||
|
||||
pData->destAddr = inet_addr(szData.c_str());
|
||||
if (pData->destAddr == INADDR_NONE)
|
||||
{
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(0x0101, &wsaData) == 0)
|
||||
{
|
||||
LPHOSTENT pHost;
|
||||
|
||||
pHost = gethostbyname(szData.c_str());
|
||||
if (pHost)
|
||||
{
|
||||
pData->destAddr = *(DWORD*)pHost->h_addr;
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to get the host by name.");
|
||||
}
|
||||
|
||||
WSACleanup();
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Unable to initialize Windows Sockets");
|
||||
}
|
||||
}
|
||||
valid = true;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"UpdateRate", L"1");
|
||||
if (data)
|
||||
{
|
||||
pData->updateRate = _wtoi(data);
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"Timeout", L"30000");
|
||||
if (data)
|
||||
{
|
||||
pData->timeout = _wtoi(data);
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"TimeoutValue", L"30000");
|
||||
if (data)
|
||||
{
|
||||
pData->timeoutValue = wcstod(data, NULL);
|
||||
}
|
||||
|
||||
if (valid)
|
||||
{
|
||||
g_Values[id] = pData;
|
||||
}
|
||||
|
||||
return pData->timeout;
|
||||
}
|
||||
|
||||
DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
{
|
||||
if (g_IcmpCreateFile && g_IcmpCloseHandle && g_IcmpSendEcho)
|
||||
{
|
||||
pingData* pData = (pingData*)pParam;
|
||||
|
||||
BYTE reply[sizeof(ICMP_ECHO_REPLY) + 12];
|
||||
|
||||
HANDLE hIcmpFile;
|
||||
hIcmpFile = g_IcmpCreateFile();
|
||||
|
||||
if (hIcmpFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
DWORD res = g_IcmpSendEcho(
|
||||
hIcmpFile,
|
||||
pData->destAddr,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
reply,
|
||||
sizeof(reply),
|
||||
pData->timeout);
|
||||
|
||||
g_IcmpCloseHandle(hIcmpFile);
|
||||
}
|
||||
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
ICMP_ECHO_REPLY* pReply = (ICMP_ECHO_REPLY*)reply;
|
||||
if (pReply->Status == IP_REQ_TIMED_OUT)
|
||||
{
|
||||
pData->value = pData->timeoutValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData->value = pReply->RoundTripTime;
|
||||
}
|
||||
|
||||
CloseHandle(pData->threadHandle);
|
||||
pData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
double value = 0.0;
|
||||
|
||||
std::map<UINT, pingData*>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
pingData* pData = (*i).second;
|
||||
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
value = pData->value;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
if (pData->threadHandle == NULL)
|
||||
{
|
||||
if (pData->updateCounter == 0)
|
||||
{
|
||||
// Launch a new thread to fetch the web data
|
||||
DWORD id;
|
||||
pData->threadHandle = CreateThread(NULL, 0, NetworkThreadProc, pData, 0, &id);
|
||||
}
|
||||
|
||||
pData->updateCounter++;
|
||||
if (pData->updateCounter >= pData->updateRate)
|
||||
{
|
||||
pData->updateCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
std::map<UINT, pingData*>::iterator i1 = g_Values.find(id);
|
||||
if (i1 != g_Values.end())
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
if ((*i1).second->threadHandle)
|
||||
{
|
||||
// Should really wait until the thread finishes instead terminating it...
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"PingPlugin: Thread still running -> Terminate.");
|
||||
TerminateThread((*i1).second->threadHandle, 0);
|
||||
}
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
delete (*i1).second;
|
||||
g_Values.erase(i1);
|
||||
}
|
||||
|
||||
// Last instance deletes the critical section
|
||||
if (g_Values.empty())
|
||||
{
|
||||
if (g_ICMPInstance)
|
||||
{
|
||||
FreeLibrary(g_ICMPInstance);
|
||||
g_ICMPInstance = NULL;
|
||||
}
|
||||
|
||||
if (g_Initialized)
|
||||
{
|
||||
DeleteCriticalSection(&g_CriticalSection);
|
||||
g_Initialized = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1002;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
125
Plugins/PluginPing/PluginPing.dsp
Normal file
125
Plugins/PluginPing/PluginPing.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginPing" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginPing - 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 "PluginPing.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 "PluginPing.mak" CFG="PluginPing - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginPing - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginPing - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginPing - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginPing"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginPing - 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 "PluginPing_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPing_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 Ws2_32.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:I386 /out:"../../TestBench/x32/Release/Plugins/PingPlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginPing - 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 "PluginPing_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 "PluginPing_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 Ws2_32.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 /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/PingPlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginPing - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginPing___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginPing___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 "PluginPing_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPing_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 Ws2_32.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:I386 /out:"../../TestBench/x32/Release/Plugins/PingPlugin.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib Ws2_32.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/PingPlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginPing - Win32 Release"
|
||||
# Name "PluginPing - Win32 Debug"
|
||||
# Name "PluginPing - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Ping.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
234
Plugins/PluginPing/PluginPing.vcproj
Normal file
234
Plugins/PluginPing/PluginPing.vcproj
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginPing"
|
||||
SccProjectName="PluginPing"
|
||||
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;PluginPing_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginPing.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 Ws2_32.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/PingPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/PingPlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/PingPlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginPing.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;PluginPing_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginPing.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Ws2_32.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/PingPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/PingPlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/PingPlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginPing.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;PluginPing_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginPing.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Ws2_32.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/PingPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/PingPlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/PingPlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginPing.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="Ping.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPing_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPing_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPing_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
125
Plugins/PluginPower/PluginPower.dsp
Normal file
125
Plugins/PluginPower/PluginPower.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginPower" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginPower - 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 "PluginPower.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 "PluginPower.mak" CFG="PluginPower - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginPower - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginPower - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginPower - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginPower"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginPower - 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 "PluginPower_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPower_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/PowerPlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginPower - 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 "PluginPower_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 "PluginPower_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/PowerPlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginPower - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginPower___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginPower___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 "PluginPower_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginPower_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/PowerPlugin.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/PowerPlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginPower - Win32 Release"
|
||||
# Name "PluginPower - Win32 Debug"
|
||||
# Name "PluginPower - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\PowerPlugin.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
232
Plugins/PluginPower/PluginPower.vcproj
Normal file
232
Plugins/PluginPower/PluginPower.vcproj
Normal file
@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginPower"
|
||||
SccProjectName="PluginPower"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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;PluginPower_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginPower.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/PowerPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/PowerPlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/PowerPlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginPower.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;PluginPower_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginPower.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/PowerPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/PowerPlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/PowerPlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginPower.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="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;PluginPower_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginPower.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/PowerPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/PowerPlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/PowerPlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginPower.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="PowerPlugin.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPower_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPower_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginPower_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
324
Plugins/PluginPower/PowerPlugin.cpp
Normal file
324
Plugins/PluginPower/PowerPlugin.cpp
Normal file
@ -0,0 +1,324 @@
|
||||
/*
|
||||
Copyright (C) 2002 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginPower/PowerPlugin.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: PowerPlugin.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/07/11 17:10:42 rainy
|
||||
The plugin is cleaned up correctly.
|
||||
|
||||
Revision 1.3 2004/06/05 10:56:07 rainy
|
||||
Added new interface.
|
||||
Uses config parser.
|
||||
|
||||
Revision 1.2 2003/03/22 20:39:42 rainy
|
||||
The max value for status is now correct.
|
||||
|
||||
Revision 1.1 2002/09/07 08:17:11 rainy
|
||||
Intial version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <Powrprof.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
typedef struct _PROCESSOR_POWER_INFORMATION
|
||||
{
|
||||
ULONG Number;
|
||||
ULONG MaxMhz;
|
||||
ULONG CurrentMhz;
|
||||
ULONG MhzLimit;
|
||||
ULONG MaxIdleState;
|
||||
ULONG CurrentIdleState;
|
||||
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
|
||||
|
||||
typedef LONG (WINAPI *FPCALLNTPOWERINFORMATION)(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG);
|
||||
|
||||
/* 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 ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) UINT Update(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
enum POWER_STATE
|
||||
{
|
||||
POWER_UNKNOWN,
|
||||
POWER_ACLINE,
|
||||
POWER_STATUS,
|
||||
POWER_STATUS2,
|
||||
POWER_LIFETIME,
|
||||
POWER_PERCENT,
|
||||
POWER_MHZ
|
||||
};
|
||||
|
||||
std::map<UINT, POWER_STATE> g_States;
|
||||
std::map<UINT, std::wstring> g_Formats;
|
||||
HINSTANCE hDLL = NULL;
|
||||
FPCALLNTPOWERINFORMATION fpCallNtPowerInformation = NULL;
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
if (hDLL == NULL)
|
||||
{
|
||||
hDLL = LoadLibrary(L"powrprof.dll");
|
||||
if (hDLL)
|
||||
{
|
||||
fpCallNtPowerInformation = (FPCALLNTPOWERINFORMATION)GetProcAddress(hDLL, "CallNtPowerInformation");
|
||||
}
|
||||
}
|
||||
|
||||
POWER_STATE powerState = POWER_UNKNOWN;
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"PowerState", L"");
|
||||
if(type)
|
||||
{
|
||||
if (wcsicmp(L"ACLINE", type) == 0)
|
||||
{
|
||||
powerState = POWER_ACLINE;
|
||||
}
|
||||
else if (wcsicmp(L"STATUS", type) == 0)
|
||||
{
|
||||
powerState = POWER_STATUS;
|
||||
}
|
||||
else if (wcsicmp(L"STATUS2", type) == 0)
|
||||
{
|
||||
powerState = POWER_STATUS2;
|
||||
}
|
||||
else if (wcsicmp(L"LIFETIME", type) == 0)
|
||||
{
|
||||
powerState= POWER_LIFETIME;
|
||||
|
||||
LPCTSTR format = ReadConfigString(section, L"Format", L"%H:%M");
|
||||
if (format)
|
||||
{
|
||||
g_Formats[id] = format;
|
||||
}
|
||||
}
|
||||
else if (wcsicmp(L"MHZ", type) == 0)
|
||||
{
|
||||
powerState= POWER_MHZ;
|
||||
}
|
||||
else if (wcsicmp(L"PERCENT", type) == 0)
|
||||
{
|
||||
powerState = POWER_PERCENT;
|
||||
}
|
||||
|
||||
g_States[id] = powerState;
|
||||
}
|
||||
|
||||
switch(powerState)
|
||||
{
|
||||
case POWER_ACLINE:
|
||||
return 1;
|
||||
|
||||
case POWER_STATUS:
|
||||
return 4;
|
||||
|
||||
case POWER_STATUS2:
|
||||
return 255;
|
||||
|
||||
case POWER_LIFETIME:
|
||||
{
|
||||
SYSTEM_POWER_STATUS status;
|
||||
if (GetSystemPowerStatus(&status))
|
||||
{
|
||||
return status.BatteryFullLifeTime;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POWER_PERCENT:
|
||||
return 100;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
SYSTEM_POWER_STATUS status;
|
||||
if (GetSystemPowerStatus(&status))
|
||||
{
|
||||
std::map<UINT, POWER_STATE>::iterator i = g_States.find(id);
|
||||
if (i != g_States.end())
|
||||
{
|
||||
switch((*i).second)
|
||||
{
|
||||
case POWER_ACLINE:
|
||||
return status.ACLineStatus == 1 ? 1 : 0;
|
||||
|
||||
case POWER_STATUS:
|
||||
if (status.BatteryFlag & 128)
|
||||
{
|
||||
return 0; // No battery
|
||||
}
|
||||
else if (status.BatteryFlag & 8)
|
||||
{
|
||||
return 1; // Charging
|
||||
}
|
||||
else if (status.BatteryFlag & 4)
|
||||
{
|
||||
return 2; // Critical
|
||||
}
|
||||
else if (status.BatteryFlag & 2)
|
||||
{
|
||||
return 3; // Low
|
||||
}
|
||||
else if (status.BatteryFlag & 1)
|
||||
{
|
||||
return 4; // High
|
||||
}
|
||||
break;
|
||||
|
||||
case POWER_STATUS2:
|
||||
return status.BatteryFlag;
|
||||
|
||||
case POWER_LIFETIME:
|
||||
return status.BatteryLifeTime;
|
||||
|
||||
case POWER_PERCENT:
|
||||
return status.BatteryLifePercent > 100 ? 100 : status.BatteryLifePercent;
|
||||
|
||||
case POWER_MHZ:
|
||||
if (fpCallNtPowerInformation)
|
||||
{
|
||||
PROCESSOR_POWER_INFORMATION ppi[8]; // Assume that 8 processors are enough
|
||||
memset(ppi, 0, sizeof(PROCESSOR_POWER_INFORMATION) * 8);
|
||||
fpCallNtPowerInformation(ProcessorInformation, NULL, 0, ppi, sizeof(PROCESSOR_POWER_INFORMATION) * 8);
|
||||
return ppi[0].CurrentMhz;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[256];
|
||||
|
||||
std::map<UINT, POWER_STATE>::iterator i = g_States.find(id);
|
||||
if (i != g_States.end())
|
||||
{
|
||||
if ((*i).second == POWER_LIFETIME)
|
||||
{
|
||||
SYSTEM_POWER_STATUS status;
|
||||
if (GetSystemPowerStatus(&status))
|
||||
{
|
||||
// Change it to time string
|
||||
if (status.BatteryLifeTime == -1)
|
||||
{
|
||||
return L"Unknown";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::map<UINT, std::wstring>::iterator iter = g_Formats.find(id);
|
||||
if (iter != g_Formats.end())
|
||||
{
|
||||
tm time;
|
||||
memset(&time, 0, sizeof(tm));
|
||||
time.tm_sec = status.BatteryLifeTime % 60;
|
||||
time.tm_min = (status.BatteryLifeTime / 60) % 60;
|
||||
time.tm_hour = status.BatteryLifeTime / 60 / 60;
|
||||
|
||||
wcsftime(buffer, 256, (*iter).second.c_str(), &time);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsprintf(buffer, L"%i:%02i:%02i", status.BatteryLifeTime / 60 / 60, (status.BatteryLifeTime / 60) % 60, status.BatteryLifeTime % 60);
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, POWER_STATE>::iterator i = g_States.find(id);
|
||||
if (i != g_States.end())
|
||||
{
|
||||
g_States.erase(i);
|
||||
}
|
||||
|
||||
std::map<UINT, std::wstring>::iterator i2 = g_Formats.find(id);
|
||||
if (i2 != g_Formats.end())
|
||||
{
|
||||
g_Formats.erase(i2);
|
||||
}
|
||||
|
||||
if (hDLL != NULL)
|
||||
{
|
||||
FreeLibrary(hDLL);
|
||||
hDLL = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1003;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
125
Plugins/PluginQuote/PluginQuote.dsp
Normal file
125
Plugins/PluginQuote/PluginQuote.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginQuote" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginQuote - 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 "PluginQuote.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 "PluginQuote.mak" CFG="PluginQuote - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginQuote - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginQuote - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginQuote - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginQuote"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginQuote - 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 "PluginQuote_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginQuote_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 shlwapi.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:I386 /out:"../../TestBench/x32/Release/Plugins/QuotePlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginQuote - 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 "PluginQuote_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 "PluginQuote_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 shlwapi.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 /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/QuotePlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginQuote - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginQuote___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginQuote___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 "PluginQuote_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginQuote_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 shlwapi.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:I386 /out:"../../TestBench/x32/Release/Plugins/QuotePlugin.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib shlwapi.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/QuotePlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginQuote - Win32 Release"
|
||||
# Name "PluginQuote - Win32 Debug"
|
||||
# Name "PluginQuote - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Quote.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
234
Plugins/PluginQuote/PluginQuote.vcproj
Normal file
234
Plugins/PluginQuote/PluginQuote.vcproj
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginQuote"
|
||||
SccProjectName="PluginQuote"
|
||||
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;PluginQuote_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginQuote.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 shlwapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/QuotePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/QuotePlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/QuotePlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginQuote.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="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;PluginQuote_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginQuote.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/QuotePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/QuotePlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/QuotePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginQuote.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;PluginQuote_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginQuote.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="shlwapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/QuotePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/QuotePlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/QuotePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginQuote.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>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="Quote.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginQuote_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginQuote_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginQuote_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
455
Plugins/PluginQuote/Quote.cpp
Normal file
455
Plugins/PluginQuote/Quote.cpp
Normal file
@ -0,0 +1,455 @@
|
||||
/*
|
||||
Copyright (C) 2005 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginQuote/Quote.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Quote.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include <tchar.h>
|
||||
#include <shlwapi.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* 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 ) double Update2(UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
struct quoteData
|
||||
{
|
||||
std::wstring pathname;
|
||||
std::wstring separator;
|
||||
std::vector<std::wstring> fileFilters;
|
||||
std::vector<std::wstring> files;
|
||||
std::wstring value;
|
||||
};
|
||||
|
||||
void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path);
|
||||
|
||||
static std::map<UINT, quoteData> g_Values;
|
||||
|
||||
std::string ConvertToAscii(LPCTSTR str)
|
||||
{
|
||||
std::string szAscii;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = (wcslen(str) + 1);
|
||||
char* tmpSz = new char[len * 2];
|
||||
WideCharToMultiByte(CP_ACP, 0, str, -1, tmpSz, (int)len * 2, NULL, FALSE);
|
||||
szAscii = tmpSz;
|
||||
delete tmpSz;
|
||||
}
|
||||
return szAscii;
|
||||
}
|
||||
|
||||
std::wstring ConvertToWide(LPCSTR str)
|
||||
{
|
||||
std::wstring szWide;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
WCHAR* wideSz = new WCHAR[len * 2];
|
||||
MultiByteToWideChar(CP_ACP, 0, str, (int)len, wideSz, (int)len * 2);
|
||||
szWide = wideSz;
|
||||
delete wideSz;
|
||||
}
|
||||
return szWide;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
quoteData qData;
|
||||
LPCTSTR data;
|
||||
bool bSubfolders = false;
|
||||
|
||||
data = ReadConfigString(section, L"Subfolders", L"0");
|
||||
if (data && _ttoi(data) == 1)
|
||||
{
|
||||
bSubfolders = true;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"Separator", L"\n");
|
||||
if (data)
|
||||
{
|
||||
qData.separator = data;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"FileFilter", L"");
|
||||
if (data && wcslen(data) > 0)
|
||||
{
|
||||
std::wstring ext = data;
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = ext.find(L';');
|
||||
while (pos != std::wstring::npos)
|
||||
{
|
||||
qData.fileFilters.push_back(ext.substr(start, pos - start));
|
||||
start = pos + 1;
|
||||
pos = ext.find(L';', pos + 1);
|
||||
}
|
||||
qData.fileFilters.push_back(ext.substr(start));
|
||||
|
||||
qData.separator = data;
|
||||
}
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
data = ReadConfigString(section, L"PathName", L"");
|
||||
if (data && wcslen(data) > 0)
|
||||
{
|
||||
qData.pathname = data;
|
||||
|
||||
if (qData.pathname.find(':') == -1) // Not found
|
||||
{
|
||||
std::wstring path = iniFile;
|
||||
size_t pos = path.rfind('\\');
|
||||
if (pos >= 0)
|
||||
{
|
||||
path.erase(pos + 1);
|
||||
qData.pathname = path + qData.pathname;
|
||||
}
|
||||
}
|
||||
|
||||
if (PathIsDirectory(qData.pathname.c_str()))
|
||||
{
|
||||
if (qData.pathname[qData.pathname.size() - 1] != L'\\')
|
||||
{
|
||||
qData.pathname += L"\\";
|
||||
}
|
||||
|
||||
// Scan files
|
||||
ScanFolder(qData, bSubfolders, qData.pathname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!qData.pathname.empty())
|
||||
{
|
||||
g_Values[id] = qData;
|
||||
}
|
||||
|
||||
// TODO: Random=0, load stuff sequentially (store to somewhere)
|
||||
|
||||
srand( (unsigned)time( NULL ) );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ScanFolder(quoteData& qData, bool bSubfolders, const std::wstring& path)
|
||||
{
|
||||
// Get folder listing
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
std::wstring searchPath = path + L"*";
|
||||
|
||||
hSearch = FindFirstFile(searchPath.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
if (bSubfolders)
|
||||
{
|
||||
if (wcscmp(fileData.cFileName, L".") != 0 && wcscmp(fileData.cFileName, L"..") != 0)
|
||||
{
|
||||
ScanFolder(qData, bSubfolders, path + fileData.cFileName + L"\\");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!qData.fileFilters.empty())
|
||||
{
|
||||
for (int i = 0; i < qData.fileFilters.size(); i++)
|
||||
{
|
||||
if (!qData.fileFilters[i].empty() && PathMatchSpec(fileData.cFileName, qData.fileFilters[i].c_str()))
|
||||
{
|
||||
qData.files.push_back(path + fileData.cFileName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qData.files.push_back(path + fileData.cFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
while(FindNextFile(hSearch, &fileData));
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
quoteData& qData = (*i).second;
|
||||
|
||||
if (qData.files.empty())
|
||||
{
|
||||
BYTE buffer[BUFFER_SIZE + 2];
|
||||
buffer[BUFFER_SIZE] = 0;
|
||||
|
||||
// Read the file
|
||||
FILE* file = _wfopen(qData.pathname.c_str(), L"r");
|
||||
if (file)
|
||||
{
|
||||
// Check if the file is unicode or ascii
|
||||
fread(buffer, sizeof(WCHAR), 1, file);
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
int size = ftell(file);
|
||||
|
||||
// Go to a random place
|
||||
int pos = rand() % size;
|
||||
fseek(file, (pos / 2) * 2, SEEK_SET);
|
||||
|
||||
qData.value.erase();
|
||||
|
||||
if (0xFEFF == *(WCHAR*)buffer)
|
||||
{
|
||||
// It's unicode
|
||||
WCHAR* wBuffer = (WCHAR*)buffer;
|
||||
|
||||
// Read until we find the first separator
|
||||
WCHAR* sepPos1 = NULL;
|
||||
WCHAR* sepPos2 = NULL;
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
buffer[len + 1] = 0;
|
||||
|
||||
sepPos1 = wcsstr(wBuffer, qData.separator.c_str());
|
||||
if (sepPos1 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read from start
|
||||
fseek(file, 2, SEEK_SET);
|
||||
len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
buffer[len + 1] = 0;
|
||||
sepPos1 = wBuffer;
|
||||
}
|
||||
// else continue reading
|
||||
}
|
||||
else
|
||||
{
|
||||
sepPos1 += qData.separator.size();
|
||||
}
|
||||
}
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
{
|
||||
sepPos2 = wcsstr(sepPos1, qData.separator.c_str());
|
||||
if (sepPos2 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read the rest
|
||||
qData.value += sepPos1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
qData.value += sepPos1;
|
||||
|
||||
// else continue reading
|
||||
size_t len = fread(buffer, sizeof(BYTE), BUFFER_SIZE, file);
|
||||
buffer[len] = 0;
|
||||
buffer[len + 1] = 0;
|
||||
sepPos1 = wBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sepPos2)
|
||||
{
|
||||
*sepPos2 = 0;
|
||||
}
|
||||
|
||||
// Read until we find the second separator
|
||||
qData.value += sepPos1;
|
||||
}
|
||||
}
|
||||
while (sepPos2 == NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's ascii
|
||||
char* aBuffer = (char*)buffer;
|
||||
|
||||
// Read until we find the first separator
|
||||
char* sepPos1 = NULL;
|
||||
char* sepPos2 = NULL;
|
||||
do
|
||||
{
|
||||
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
|
||||
sepPos1 = strstr(aBuffer, ConvertToAscii(qData.separator.c_str()).c_str());
|
||||
if (sepPos1 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read from start
|
||||
fseek(file, 0, SEEK_SET);
|
||||
len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
sepPos1 = aBuffer;
|
||||
}
|
||||
// else continue reading
|
||||
}
|
||||
else
|
||||
{
|
||||
sepPos1 += qData.separator.size();
|
||||
}
|
||||
}
|
||||
while (sepPos1 == NULL);
|
||||
|
||||
// Find the second separator
|
||||
do
|
||||
{
|
||||
sepPos2 = strstr(sepPos1, ConvertToAscii(qData.separator.c_str()).c_str());
|
||||
if (sepPos2 == NULL)
|
||||
{
|
||||
// The separator wasn't found
|
||||
if (feof(file))
|
||||
{
|
||||
// End of file reached -> read the rest
|
||||
qData.value += ConvertToWide(sepPos1);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
qData.value += ConvertToWide(sepPos1);
|
||||
|
||||
// else continue reading
|
||||
size_t len = fread(buffer, sizeof(char), BUFFER_SIZE, file);
|
||||
aBuffer[len] = 0;
|
||||
sepPos1 = aBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sepPos2)
|
||||
{
|
||||
*sepPos2 = 0;
|
||||
}
|
||||
|
||||
// Read until we find the second separator
|
||||
qData.value += ConvertToWide(sepPos1);
|
||||
}
|
||||
}
|
||||
while (sepPos2 == NULL);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the filename
|
||||
if (qData.files.size() > 0)
|
||||
{
|
||||
qData.value = qData.files[rand() % qData.files.size()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
return ((*i).second).value.c_str();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, quoteData>::iterator i1 = g_Values.find(id);
|
||||
if (i1 != g_Values.end())
|
||||
{
|
||||
g_Values.erase(i1);
|
||||
}
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
125
Plugins/PluginResMon/PluginResMon.dsp
Normal file
125
Plugins/PluginResMon/PluginResMon.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginResMon" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginResMon - 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 "PluginResMon.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 "PluginResMon.mak" CFG="PluginResMon - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginResMon - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginResMon - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginResMon - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginResMon"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginResMon - 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 "PluginResMon_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginResMon_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 Psapi.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:I386 /out:"../../TestBench/x32/Release/Plugins/ResMon.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginResMon - 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 "PluginResMon_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 "PluginResMon_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 Psapi.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 /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/ResMon.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginResMon - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginResMon___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginResMon___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 "PluginResMon_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginResMon_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 Psapi.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:I386 /out:"../../TestBench/x32/Release/Plugins/ResMon.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib Psapi.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/ResMon.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginResMon - Win32 Release"
|
||||
# Name "PluginResMon - Win32 Debug"
|
||||
# Name "PluginResMon - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ResMon.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
234
Plugins/PluginResMon/PluginResMon.vcproj
Normal file
234
Plugins/PluginResMon/PluginResMon.vcproj
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginResMon"
|
||||
SccProjectName="PluginResMon"
|
||||
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;PluginResMon_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginResMon.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 Psapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/ResMon.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/ResMon.pdb"
|
||||
ImportLibrary=".\x64/Release/ResMon.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginResMon.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="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;PluginResMon_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginResMon.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Psapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/ResMon.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/ResMon.pdb"
|
||||
ImportLibrary=".\x32/Release/ResMon.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginResMon.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;PluginResMon_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginResMon.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Psapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/ResMon.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/ResMon.pdb"
|
||||
ImportLibrary=".\x32/Debug/ResMon.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginResMon.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>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="ResMon.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginResMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginResMon_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginResMon_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
275
Plugins/PluginResMon/ResMon.cpp
Normal file
275
Plugins/PluginResMon/ResMon.cpp
Normal file
@ -0,0 +1,275 @@
|
||||
/*
|
||||
Copyright (C) 2004 David Negstad
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginResMon/ResMon.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: ResMon.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.2 2004/07/11 17:10:42 rainy
|
||||
The plugin is cleaned up correctly.
|
||||
|
||||
Revision 1.1 2004/06/05 10:56:56 rainy
|
||||
Added new interfaces for plugin version and author.
|
||||
Added possibility to measure a single process.
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
Requires Win2k or later. Sorry to anyone still using 9x or ME.
|
||||
All my results seem to agree with Task Manager (it gets tedious adding up
|
||||
the different process values). Already proved useful in identifying
|
||||
resource leaks in itself (all fixed). There's irony for you!
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
#pragma warning(disable: 4786)
|
||||
|
||||
#define _WIN32_WINNT 0x0501
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <psapi.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) UINT Update(UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
// system resources that can be counted
|
||||
enum COUNTER
|
||||
{
|
||||
GDI_COUNT,
|
||||
USER_COUNT,
|
||||
HANDLE_COUNT,
|
||||
WINDOW_COUNT
|
||||
};
|
||||
|
||||
// list of counter types corresponding to gauges
|
||||
static std::map<UINT, COUNTER> g_Counters;
|
||||
static std::map<UINT, std::wstring> g_ProcessNames;
|
||||
|
||||
// used to track the number of existing windows
|
||||
UINT g_WindowCount = 0;
|
||||
|
||||
// count the child windows of a system window
|
||||
BOOL CALLBACK EnumChildProc ( HWND hWndChild, LPARAM lParam )
|
||||
{
|
||||
++g_WindowCount;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// count the system windows
|
||||
BOOL CALLBACK EnumWindowProc ( HWND hWnd, LPARAM lParam )
|
||||
{
|
||||
++g_WindowCount;
|
||||
EnumChildWindows ( hWnd, EnumChildProc, lParam );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
LPCTSTR type = ReadConfigString(section, L"ResCountType", L"GDI");
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
if (type)
|
||||
{
|
||||
if ( wcsicmp ( L"GDI", type ) == 0 )
|
||||
{
|
||||
g_Counters[id] = GDI_COUNT;
|
||||
}
|
||||
else if ( wcsicmp ( L"USER", type ) == 0 )
|
||||
{
|
||||
g_Counters[id] = USER_COUNT;
|
||||
}
|
||||
else if ( wcsicmp ( L"HANDLE", type ) == 0 )
|
||||
{
|
||||
g_Counters[id] = HANDLE_COUNT;
|
||||
}
|
||||
else if ( wcsicmp ( L"WINDOW", type ) == 0 )
|
||||
{
|
||||
g_Counters[id] = WINDOW_COUNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"No such GDICountType: ";
|
||||
error += type;
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
LPCTSTR process = ReadConfigString(section, L"ProcessName", L"");
|
||||
if (process && wcslen(process) > 0)
|
||||
{
|
||||
g_ProcessNames[id] = process;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
std::map<UINT, COUNTER>::iterator countItor = g_Counters.find ( id );
|
||||
if ( countItor == g_Counters.end () )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
COUNTER counter = ( *countItor ).second;
|
||||
|
||||
// count the existing window objects
|
||||
if ( counter == WINDOW_COUNT )
|
||||
{
|
||||
g_WindowCount = 0;
|
||||
EnumChildWindows ( NULL, EnumWindowProc, 0 );
|
||||
return g_WindowCount;
|
||||
}
|
||||
|
||||
const WCHAR* processName = NULL;
|
||||
std::map<UINT, std::wstring>::iterator processItor = g_ProcessNames.find ( id );
|
||||
if ( processItor != g_ProcessNames.end () )
|
||||
{
|
||||
processName = ((*processItor).second).c_str();
|
||||
}
|
||||
|
||||
DWORD aProcesses[1024];
|
||||
DWORD bytesNeeded;
|
||||
WCHAR buffer[1024];
|
||||
HMODULE hMod[1024];
|
||||
DWORD cbNeeded;
|
||||
|
||||
if ( !EnumProcesses ( aProcesses, sizeof ( aProcesses ), &bytesNeeded ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// step through the running processes
|
||||
DWORD flags = PROCESS_QUERY_INFORMATION;
|
||||
|
||||
if (processName)
|
||||
{
|
||||
flags |= PROCESS_VM_READ;
|
||||
}
|
||||
|
||||
UINT resourceCount = 0;
|
||||
for ( UINT i = 0; i < bytesNeeded / sizeof ( DWORD ); ++i )
|
||||
{
|
||||
HANDLE hProcess = OpenProcess ( flags, true, aProcesses[i] );
|
||||
if ( hProcess != NULL )
|
||||
{
|
||||
if (processName)
|
||||
{
|
||||
if(EnumProcessModules(hProcess, hMod, sizeof(hMod), &cbNeeded))
|
||||
{
|
||||
if (GetModuleBaseName(hProcess, hMod[0], buffer, sizeof(buffer)))
|
||||
{
|
||||
if (wcsicmp(buffer, processName) != 0)
|
||||
{
|
||||
CloseHandle ( hProcess );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseHandle ( hProcess );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseHandle ( hProcess );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( counter == GDI_COUNT )
|
||||
{
|
||||
resourceCount += GetGuiResources ( hProcess, GR_GDIOBJECTS );
|
||||
}
|
||||
else if ( counter == USER_COUNT )
|
||||
{
|
||||
resourceCount += GetGuiResources ( hProcess, GR_USEROBJECTS );
|
||||
}
|
||||
else if ( counter == HANDLE_COUNT )
|
||||
{
|
||||
DWORD tempHandleCount = 0;
|
||||
GetProcessHandleCount ( hProcess, &tempHandleCount );
|
||||
resourceCount += tempHandleCount;
|
||||
}
|
||||
}
|
||||
CloseHandle ( hProcess );
|
||||
}
|
||||
|
||||
return resourceCount;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, COUNTER>::iterator i1 = g_Counters.find(id);
|
||||
if (i1 != g_Counters.end())
|
||||
{
|
||||
g_Counters.erase(i1);
|
||||
}
|
||||
|
||||
std::map<UINT, std::wstring>::iterator i2 = g_ProcessNames.find(id);
|
||||
if (i2 != g_ProcessNames.end())
|
||||
{
|
||||
g_ProcessNames.erase(i2);
|
||||
}
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1003;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"David Negstad";
|
||||
}
|
125
Plugins/PluginSpeedFan/PluginSpeedFan.dsp
Normal file
125
Plugins/PluginSpeedFan/PluginSpeedFan.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginSpeedFan" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginSpeedFan - 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 "PluginSpeedFan.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 "PluginSpeedFan.mak" CFG="PluginSpeedFan - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginSpeedFan - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginSpeedFan - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginSpeedFan - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginSpeedFan"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginSpeedFan - 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 "PluginSpeedFan_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginSpeedFan_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/SpeedFanPlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginSpeedFan - 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 "PluginSpeedFan_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 "PluginSpeedFan_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/SpeedFanPlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginSpeedFan - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginSpeedFan___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginSpeedFan___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 "PluginSpeedFan_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginSpeedFan_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/SpeedFanPlugin.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/SpeedFanPlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginSpeedFan - Win32 Release"
|
||||
# Name "PluginSpeedFan - Win32 Debug"
|
||||
# Name "PluginSpeedFan - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SpeedFanPlugin.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
232
Plugins/PluginSpeedFan/PluginSpeedFan.vcproj
Normal file
232
Plugins/PluginSpeedFan/PluginSpeedFan.vcproj
Normal file
@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginSpeedFan"
|
||||
SccProjectName="PluginSpeedFan"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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;PluginSpeedFan_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginSpeedFan.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/SpeedFanPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/SpeedFanPlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/SpeedFanPlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginSpeedFan.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;PluginSpeedFan_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginSpeedFan.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/SpeedFanPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/SpeedFanPlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/SpeedFanPlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginSpeedFan.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 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;PluginSpeedFan_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginSpeedFan.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/SpeedFanPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/SpeedFanPlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/SpeedFanPlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginSpeedFan.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="SpeedFanPlugin.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginSpeedFan_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginSpeedFan_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginSpeedFan_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
230
Plugins/PluginSpeedFan/SpeedFanPlugin.cpp
Normal file
230
Plugins/PluginSpeedFan/SpeedFanPlugin.cpp
Normal file
@ -0,0 +1,230 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginSpeedFan/SpeedFanPlugin.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: SpeedFanPlugin.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* 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 ) double Update2(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
struct SpeedFanData
|
||||
{
|
||||
WORD version;
|
||||
WORD flags;
|
||||
INT MemSize;
|
||||
DWORD handle;
|
||||
WORD NumTemps;
|
||||
WORD NumFans;
|
||||
WORD NumVolts;
|
||||
INT temps[32];
|
||||
INT fans[32];
|
||||
INT volts[32];
|
||||
};
|
||||
|
||||
enum SensorType
|
||||
{
|
||||
TYPE_TEMP,
|
||||
TYPE_FAN,
|
||||
TYPE_VOLT
|
||||
};
|
||||
|
||||
bool ReadSharedData(SensorType type, UINT number, double* value);
|
||||
|
||||
static std::map<UINT, SensorType> g_Types;
|
||||
static std::map<UINT, UINT> g_Numbers;
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"SpeedFanType", L"TEMPERATURE");
|
||||
if (type)
|
||||
{
|
||||
if (wcsicmp(L"TEMPERATURE", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_TEMP;
|
||||
}
|
||||
else if (wcsicmp(L"FAN", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_FAN;
|
||||
}
|
||||
else if (wcsicmp(L"VOLTAGE", type) == 0)
|
||||
{
|
||||
g_Types[id] = TYPE_VOLT;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"No such SpeedFanType: ";
|
||||
error += type;
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
LPCTSTR data = ReadConfigString(section, L"SpeedFanNumber", L"0");
|
||||
if (data)
|
||||
{
|
||||
g_Numbers[id] = _wtoi(data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
double value = 0;
|
||||
|
||||
std::map<UINT, SensorType>::iterator type = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator number = g_Numbers.find(id);
|
||||
|
||||
if(type == g_Types.end() || number == g_Numbers.end())
|
||||
{
|
||||
return 0; // No id in the map. How this can be ????
|
||||
}
|
||||
|
||||
if (ReadSharedData((*type).second, (*number).second, &value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, SensorType>::iterator i1 = g_Types.find(id);
|
||||
if (i1 != g_Types.end())
|
||||
{
|
||||
g_Types.erase(i1);
|
||||
}
|
||||
|
||||
std::map<UINT, UINT>::iterator i2 = g_Numbers.find(id);
|
||||
if (i2 != g_Numbers.end())
|
||||
{
|
||||
g_Numbers.erase(i2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Get the data from shared memory.
|
||||
*/
|
||||
bool ReadSharedData(SensorType type, UINT number, double* value)
|
||||
{
|
||||
SpeedFanData* ptr;
|
||||
HANDLE hData;
|
||||
|
||||
hData = OpenFileMapping(FILE_MAP_READ, FALSE, L"SFSharedMemory_ALM");
|
||||
if (hData == NULL) return false;
|
||||
|
||||
ptr = (SpeedFanData*)MapViewOfFile(hData, FILE_MAP_READ, 0, 0, 0);
|
||||
if (ptr == 0)
|
||||
{
|
||||
CloseHandle(hData);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ptr->version == 1)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case TYPE_TEMP:
|
||||
if (number < ptr->NumTemps)
|
||||
{
|
||||
*value = ptr->temps[number];
|
||||
*value /= 100.0;
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_FAN:
|
||||
if (number < ptr->NumTemps)
|
||||
{
|
||||
*value = ptr->fans[number];
|
||||
}
|
||||
break;
|
||||
|
||||
case TYPE_VOLT:
|
||||
if (number < ptr->NumVolts)
|
||||
{
|
||||
*value = ptr->volts[number];
|
||||
*value /= 100.0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"SpeedFanPlugin: The shared memory has incorrect version.");
|
||||
}
|
||||
|
||||
UnmapViewOfFile(ptr);
|
||||
CloseHandle(hData);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
125
Plugins/PluginSysInfo/PluginSysInfo.dsp
Normal file
125
Plugins/PluginSysInfo/PluginSysInfo.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginSysInfo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginSysInfo - 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 "PluginSysInfo.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 "PluginSysInfo.mak" CFG="PluginSysInfo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginSysInfo - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginSysInfo - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginSysInfo - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginSysInfo"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginSysInfo - 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 "PluginSysInfo_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginSysInfo_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 Rasapi32.lib Iphlpapi.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:I386 /out:"../../TestBench/x32/Release/Plugins/SysInfo.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginSysInfo - 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 "PluginSysInfo_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 "PluginSysInfo_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 Rasapi32.lib Iphlpapi.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 /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/SysInfo.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginSysInfo - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginSysInfo___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginSysInfo___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 "PluginSysInfo_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginSysInfo_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 Rasapi32.lib Iphlpapi.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:I386 /out:"../../TestBench/x32/Release/Plugins/SysInfo.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib Rasapi32.lib Iphlpapi.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/SysInfo.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginSysInfo - Win32 Release"
|
||||
# Name "PluginSysInfo - Win32 Debug"
|
||||
# Name "PluginSysInfo - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SysInfo.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
234
Plugins/PluginSysInfo/PluginSysInfo.vcproj
Normal file
234
Plugins/PluginSysInfo/PluginSysInfo.vcproj
Normal file
@ -0,0 +1,234 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginSysInfo"
|
||||
SccProjectName="PluginSysInfo"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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;PluginSysInfo_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginSysInfo.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Rasapi32.lib Iphlpapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/SysInfo.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/SysInfo.pdb"
|
||||
ImportLibrary=".\x32/Release/SysInfo.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginSysInfo.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;PluginSysInfo_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginSysInfo.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Rasapi32.lib Iphlpapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/SysInfo.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/SysInfo.pdb"
|
||||
ImportLibrary=".\x32/Debug/SysInfo.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginSysInfo.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 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;PluginSysInfo_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginSysInfo.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 Rasapi32.lib Iphlpapi.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/SysInfo.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/SysInfo.pdb"
|
||||
ImportLibrary=".\x64/Release/SysInfo.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginSysInfo.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="SysInfo.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginSysInfo_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginSysInfo_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginSysInfo_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
458
Plugins/PluginSysInfo/SysInfo.cpp
Normal file
458
Plugins/PluginSysInfo/SysInfo.cpp
Normal file
@ -0,0 +1,458 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginSysInfo/SysInfo.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: SysInfo.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/07/11 17:10:42 rainy
|
||||
The plugin is cleaned up correctly.
|
||||
|
||||
Revision 1.3 2004/06/05 10:57:05 rainy
|
||||
Added new interface.
|
||||
Uses config parser.
|
||||
|
||||
Revision 1.2 2002/12/23 14:24:46 rainy
|
||||
Added secondary dns server return value.
|
||||
|
||||
Revision 1.1 2002/07/01 15:36:03 rainy
|
||||
Intial version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <Ras.h>
|
||||
#include <Iphlpapi.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
BOOL CheckConnection();
|
||||
void GetOSVersion(WCHAR* buffer);
|
||||
|
||||
enum TYPE
|
||||
{
|
||||
COMPUTER_NAME,
|
||||
USER_NAME,
|
||||
WORK_AREA,
|
||||
SCREEN_SIZE,
|
||||
RAS_STATUS,
|
||||
OS_VERSION,
|
||||
ADAPTER_DESCRIPTION,
|
||||
NET_MASK,
|
||||
IP_ADDRESS,
|
||||
GATEWAY_ADDRESS,
|
||||
HOST_NAME,
|
||||
DOMAIN_NAME,
|
||||
DNS_SERVER,
|
||||
};
|
||||
|
||||
static std::map<UINT, TYPE> g_Types;
|
||||
static std::map<UINT, UINT> g_Datas;
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR type = ReadConfigString(section, L"SysInfoType", L"");
|
||||
if(type)
|
||||
{
|
||||
if (wcsicmp(L"COMPUTER_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = COMPUTER_NAME;
|
||||
}
|
||||
else if (wcsicmp(L"USER_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = USER_NAME;
|
||||
}
|
||||
else if (wcsicmp(L"WORK_AREA", type) == 0)
|
||||
{
|
||||
g_Types[id] = WORK_AREA;
|
||||
}
|
||||
else if (wcsicmp(L"SCREEN_SIZE", type) == 0)
|
||||
{
|
||||
g_Types[id] = SCREEN_SIZE;
|
||||
}
|
||||
else if (wcsicmp(L"RAS_STATUS", type) == 0)
|
||||
{
|
||||
g_Types[id] = RAS_STATUS;
|
||||
}
|
||||
else if (wcsicmp(L"OS_VERSION", type) == 0)
|
||||
{
|
||||
g_Types[id] = OS_VERSION;
|
||||
}
|
||||
else if (wcsicmp(L"ADAPTER_DESCRIPTION", type) == 0)
|
||||
{
|
||||
g_Types[id] = ADAPTER_DESCRIPTION;
|
||||
}
|
||||
else if (wcsicmp(L"NET_MASK", type) == 0)
|
||||
{
|
||||
g_Types[id] = NET_MASK;
|
||||
}
|
||||
else if (wcsicmp(L"IP_ADDRESS", type) == 0)
|
||||
{
|
||||
g_Types[id] = IP_ADDRESS;
|
||||
}
|
||||
else if (wcsicmp(L"GATEWAY_ADDRESS", type) == 0)
|
||||
{
|
||||
g_Types[id] = GATEWAY_ADDRESS;
|
||||
}
|
||||
else if (wcsicmp(L"HOST_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = HOST_NAME;
|
||||
}
|
||||
else if (wcsicmp(L"DOMAIN_NAME", type) == 0)
|
||||
{
|
||||
g_Types[id] = DOMAIN_NAME;
|
||||
}
|
||||
else if (wcsicmp(L"DNS_SERVER", type) == 0)
|
||||
{
|
||||
g_Types[id] = DNS_SERVER;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"No such SysInfoType: ";
|
||||
error += type;
|
||||
MessageBox(NULL, error.c_str(), L"Rainmeter", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
LPCTSTR data = ReadConfigString(section, L"SysInfoData", L"0");
|
||||
if (data)
|
||||
{
|
||||
g_Datas[id] = _wtoi(data);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::wstring ConvertToWide(LPCSTR str)
|
||||
{
|
||||
std::wstring szWide;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
WCHAR* wideSz = new WCHAR[len * 2];
|
||||
MultiByteToWideChar(CP_ACP, 0, str, (int)len, wideSz, (int)len * 2);
|
||||
szWide = wideSz;
|
||||
delete wideSz;
|
||||
}
|
||||
return szWide;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[4096];
|
||||
UINT data;
|
||||
DWORD len = 4095;
|
||||
std::map<UINT, TYPE>::iterator typeIter = g_Types.find(id);
|
||||
std::map<UINT, UINT>::iterator dataIter = g_Datas.find(id);
|
||||
|
||||
if(typeIter == g_Types.end()) return NULL;
|
||||
if(dataIter == g_Datas.end())
|
||||
{
|
||||
data = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = (*dataIter).second;
|
||||
}
|
||||
|
||||
switch((*typeIter).second)
|
||||
{
|
||||
case COMPUTER_NAME:
|
||||
GetComputerName(buffer, &len);
|
||||
return buffer;
|
||||
|
||||
case USER_NAME:
|
||||
GetUserName(buffer, &len);
|
||||
return buffer;
|
||||
|
||||
case WORK_AREA:
|
||||
wsprintf(buffer, L"%i x %i", GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN));
|
||||
return buffer;
|
||||
|
||||
case SCREEN_SIZE:
|
||||
wsprintf(buffer, L"%i x %i", GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
|
||||
return buffer;
|
||||
|
||||
case RAS_STATUS:
|
||||
wsprintf(buffer, L"%s", CheckConnection()?"Online":"Offline");
|
||||
return buffer;
|
||||
|
||||
case OS_VERSION:
|
||||
GetOSVersion(buffer);
|
||||
return buffer;
|
||||
|
||||
case ADAPTER_DESCRIPTION:
|
||||
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)buffer, &len))
|
||||
{
|
||||
PIP_ADAPTER_INFO info = (IP_ADAPTER_INFO*)buffer;
|
||||
int i = 0;
|
||||
while (info)
|
||||
{
|
||||
if (i == data)
|
||||
{
|
||||
wcscpy(buffer, ConvertToWide(info->Description).c_str());
|
||||
return buffer;
|
||||
}
|
||||
info = info->Next;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IP_ADDRESS:
|
||||
if (NO_ERROR == GetIpAddrTable((PMIB_IPADDRTABLE)buffer, &len, FALSE))
|
||||
{
|
||||
PMIB_IPADDRTABLE ipTable = (PMIB_IPADDRTABLE)buffer;
|
||||
if (data < ipTable->dwNumEntries)
|
||||
{
|
||||
DWORD ip = ipTable->table[data].dwAddr;
|
||||
wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NET_MASK:
|
||||
if (NO_ERROR == GetIpAddrTable((PMIB_IPADDRTABLE)buffer, &len, FALSE))
|
||||
{
|
||||
PMIB_IPADDRTABLE ipTable = (PMIB_IPADDRTABLE)buffer;
|
||||
if (data < ipTable->dwNumEntries)
|
||||
{
|
||||
DWORD ip = ipTable->table[data].dwMask;
|
||||
wsprintf(buffer, L"%i.%i.%i.%i", ip%256, (ip>>8)%256, (ip>>16)%256, (ip>>24)%256);
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GATEWAY_ADDRESS:
|
||||
if (ERROR_SUCCESS == GetAdaptersInfo((IP_ADAPTER_INFO*)buffer, &len))
|
||||
{
|
||||
PIP_ADAPTER_INFO info = (IP_ADAPTER_INFO*)buffer;
|
||||
int i = 0;
|
||||
while (info)
|
||||
{
|
||||
if (i == data)
|
||||
{
|
||||
wcscpy(buffer, ConvertToWide(info->GatewayList.IpAddress.String).c_str());
|
||||
return buffer;
|
||||
}
|
||||
info = info->Next;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case HOST_NAME:
|
||||
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)buffer, &len))
|
||||
{
|
||||
PFIXED_INFO info = (PFIXED_INFO)buffer;
|
||||
wcscpy(buffer, ConvertToWide(info->HostName).c_str());
|
||||
return buffer;
|
||||
}
|
||||
break;
|
||||
|
||||
case DOMAIN_NAME:
|
||||
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)buffer, &len))
|
||||
{
|
||||
PFIXED_INFO info = (PFIXED_INFO)buffer;
|
||||
wcscpy(buffer, ConvertToWide(info->DomainName).c_str());
|
||||
return buffer;
|
||||
}
|
||||
break;
|
||||
|
||||
case DNS_SERVER:
|
||||
if (ERROR_SUCCESS == GetNetworkParams((PFIXED_INFO)buffer, &len))
|
||||
{
|
||||
PFIXED_INFO info = (PFIXED_INFO)buffer;
|
||||
if (info->CurrentDnsServer)
|
||||
{
|
||||
wcscpy(buffer, ConvertToWide(info->CurrentDnsServer->IpAddress.String).c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(buffer, ConvertToWide(info->DnsServerList.IpAddress.String).c_str());
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, TYPE>::iterator i1 = g_Types.find(id);
|
||||
if (i1 != g_Types.end())
|
||||
{
|
||||
g_Types.erase(i1);
|
||||
}
|
||||
|
||||
std::map<UINT, UINT>::iterator i2 = g_Datas.find(id);
|
||||
if (i2 != g_Datas.end())
|
||||
{
|
||||
g_Datas.erase(i2);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Fills the buffer with OS version
|
||||
*/
|
||||
void GetOSVersion(WCHAR* buffer)
|
||||
{
|
||||
OSVERSIONINFO version;
|
||||
version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
||||
GetVersionEx(&version);
|
||||
|
||||
if (version.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
{
|
||||
if (version.dwMajorVersion <= 4)
|
||||
{
|
||||
wcscpy(buffer, L"Windows NT");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version.dwMinorVersion == 2)
|
||||
{
|
||||
wcscpy(buffer, L"Windows 2003");
|
||||
}
|
||||
else if (version.dwMinorVersion == 1)
|
||||
{
|
||||
wcscpy(buffer, L"Windows XP");
|
||||
}
|
||||
else if (version.dwMinorVersion == 0)
|
||||
{
|
||||
wcscpy(buffer, L"Windows 2000");
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(buffer, L"Unknown");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (version.dwMinorVersion < 10)
|
||||
{
|
||||
wcscpy(buffer, L"Windows 95");
|
||||
}
|
||||
else if (version.dwMinorVersion < 90)
|
||||
{
|
||||
wcscpy(buffer, L"Windows 98");
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(buffer, L"Windows ME");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Tests if there is a RAS connection or not. Don't know
|
||||
If this works or not (especially on Win9x):-(
|
||||
*/
|
||||
BOOL CheckConnection()
|
||||
{
|
||||
static HRASCONN g_hRasConn=NULL;
|
||||
RASCONNSTATUS rasStatus;
|
||||
LPRASCONN lpRasConn=NULL;
|
||||
DWORD cbBuf=0;
|
||||
DWORD cConn=1;
|
||||
DWORD dwRet=0;
|
||||
|
||||
if(g_hRasConn==NULL) {
|
||||
// Enumerate connections
|
||||
cbBuf=sizeof(RASCONN);
|
||||
if(((lpRasConn=(LPRASCONN)malloc((UINT)cbBuf))!= NULL)) {
|
||||
lpRasConn->dwSize=sizeof(RASCONN);
|
||||
if(0==RasEnumConnections(lpRasConn, &cbBuf, &cConn)) {
|
||||
if(cConn!=0) {
|
||||
g_hRasConn=lpRasConn->hrasconn;
|
||||
}
|
||||
}
|
||||
free(lpRasConn);
|
||||
}
|
||||
}
|
||||
|
||||
if(g_hRasConn!=NULL) {
|
||||
// get connection status
|
||||
rasStatus.dwSize=sizeof(RASCONNSTATUS);
|
||||
dwRet=RasGetConnectStatus(g_hRasConn, &rasStatus );
|
||||
if(dwRet==0) {
|
||||
// Check for connection
|
||||
if(rasStatus.rasconnstate==RASCS_Connected) return TRUE;
|
||||
} else {
|
||||
g_hRasConn=NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1003;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
217
Plugins/PluginWebParser/PluginWebParser.dsp
Normal file
217
Plugins/PluginWebParser/PluginWebParser.dsp
Normal file
@ -0,0 +1,217 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginWebParser" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginWebParser - 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 "PluginWebParser.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 "PluginWebParser.mak" CFG="PluginWebParser - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginWebParser - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginWebParser - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginWebParser - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginWebParser"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginWebParser - 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 "PluginWebParser_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginWebParser_EXPORTS" /D "SUPPORT_UTF8" /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 Urlmon.lib Wininet.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:I386 /out:"../../TestBench/x32/Release/Plugins/WebParser.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginWebParser - 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 "PluginWebParser_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 "PluginWebParser_EXPORTS" /D "SUPPORT_UTF8" /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 Urlmon.lib Wininet.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 /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/WebParser.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginWebParser - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginWebParser___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginWebParser___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 "PluginWebParser_EXPORTS" /D "SUPPORT_UTF8" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginWebParser_EXPORTS" /D "SUPPORT_UTF8" /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 Urlmon.lib Wininet.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:I386 /out:"../../TestBench/x32/Release/Plugins/WebParser.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib Urlmon.lib Wininet.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/WebParser.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginWebParser - Win32 Release"
|
||||
# Name "PluginWebParser - Win32 Debug"
|
||||
# Name "PluginWebParser - Win32 Release 64"
|
||||
# Begin Group "pcre"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\chartables.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_compile.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_config.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_dfa_exec.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_exec.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_fullinfo.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_get.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_globals.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_info.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_internal.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_maketables.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_ord2utf8.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_refcount.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_scanner.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_study.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_tables.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_try_flipped.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_ucp_findchar.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_valid_utf8.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_version.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcre_xclass.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\pcre-6.4\pcreposix.c"
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WebParser.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
744
Plugins/PluginWebParser/PluginWebParser.vcproj
Normal file
744
Plugins/PluginWebParser/PluginWebParser.vcproj
Normal file
@ -0,0 +1,744 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginWebParser"
|
||||
SccProjectName="PluginWebParser"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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;PluginWebParser_EXPORTS;SUPPORT_UTF8"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginWebParser.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Urlmon.lib Wininet.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/WebParser.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/WebParser.pdb"
|
||||
ImportLibrary=".\x32/Debug/WebParser.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginWebParser.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;PluginWebParser_EXPORTS;SUPPORT_UTF8"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginWebParser.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Urlmon.lib Wininet.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/WebParser.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/WebParser.pdb"
|
||||
ImportLibrary=".\x32/Release/WebParser.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginWebParser.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="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;PluginWebParser_EXPORTS;SUPPORT_UTF8"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginWebParser.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 Urlmon.lib Wininet.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/WebParser.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/WebParser.pdb"
|
||||
ImportLibrary=".\x64/Release/WebParser.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginWebParser.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>
|
||||
<Filter
|
||||
Name="pcre"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath="pcre-6.4\chartables.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_compile.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_config.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_dfa_exec.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_exec.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_fullinfo.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_get.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_globals.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_info.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_internal.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_maketables.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_ord2utf8.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_refcount.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_scanner.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_study.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_tables.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_try_flipped.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_ucp_findchar.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_valid_utf8.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_version.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcre_xclass.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="pcre-6.4\pcreposix.c">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="WebParser.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWebParser_EXPORTS;SUPPORT_UTF8;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
952
Plugins/PluginWebParser/WebParser.cpp
Normal file
952
Plugins/PluginWebParser/WebParser.cpp
Normal file
@ -0,0 +1,952 @@
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginWebParser/WebParser.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: WebParser.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/07/11 17:11:04 rainy
|
||||
Added option to download files.
|
||||
|
||||
Revision 1.3 2004/06/05 10:57:13 rainy
|
||||
Added new interface.
|
||||
Uses config parser.
|
||||
|
||||
Revision 1.2 2003/03/22 20:38:59 rainy
|
||||
Should work now.
|
||||
|
||||
Revision 1.1 2003/03/14 10:19:51 rainy
|
||||
Initial version
|
||||
|
||||
*/
|
||||
|
||||
// Note: To compile this you need the PCRE library (http://www.pcre.org/).
|
||||
// See: http://www.perldoc.com/perl5.8.0/pod/perlre.html
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <Wininet.h>
|
||||
#include "pcre-6.4/pcre.h"
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) double Update2(UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
struct UrlData
|
||||
{
|
||||
std::wstring url;
|
||||
std::wstring regExp;
|
||||
std::wstring resultString;
|
||||
std::wstring errorString;
|
||||
std::wstring proxy;
|
||||
int codepage;
|
||||
int stringIndex;
|
||||
int stringIndex2;
|
||||
UINT updateRate;
|
||||
UINT updateCounter;
|
||||
std::wstring section;
|
||||
std::wstring finishAction;
|
||||
bool download;
|
||||
std::wstring downloadedFile;
|
||||
std::wstring iniFile;
|
||||
int debug;
|
||||
HANDLE threadHandle;
|
||||
HANDLE dlThreadHandle;
|
||||
};
|
||||
|
||||
BYTE* DownloadUrl(std::wstring& url, DWORD* dwSize);
|
||||
void ShowError(int lineNumber, WCHAR* errorMsg = NULL);
|
||||
DWORD WINAPI NetworkThreadProc(LPVOID pParam);
|
||||
DWORD WINAPI NetworkDownloadThreadProc(LPVOID pParam);
|
||||
void Log(const WCHAR* string);
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData);
|
||||
|
||||
CRITICAL_SECTION g_CriticalSection;
|
||||
bool g_Initialized = false;
|
||||
|
||||
static std::map<UINT, UrlData*> g_UrlData;
|
||||
static bool g_Debug = false;
|
||||
static HINTERNET hRootHandle = NULL;
|
||||
|
||||
#define OVECCOUNT 300 // should be a multiple of 3
|
||||
#define MUTEX_ERROR "Unable to obtain the mutex."
|
||||
|
||||
std::string ConvertToUTF8(LPCWSTR str)
|
||||
{
|
||||
std::string szAscii;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = (wcslen(str) + 1);
|
||||
char* tmpSz = new char[len * 2];
|
||||
tmpSz[0] = 0;
|
||||
WideCharToMultiByte(CP_UTF8, 0, str, -1, tmpSz, (int)len * 2, NULL, FALSE);
|
||||
szAscii = tmpSz;
|
||||
delete tmpSz;
|
||||
}
|
||||
return szAscii;
|
||||
}
|
||||
|
||||
std::string ConvertToUTF8(LPCSTR str, int codepage)
|
||||
{
|
||||
std::string szUTF8;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
WCHAR* wideSz = new WCHAR[len * 2];
|
||||
wideSz[0] = 0;
|
||||
MultiByteToWideChar(codepage, 0, str, (int)len, wideSz, (int)len * 2);
|
||||
szUTF8 = ConvertToUTF8(wideSz);
|
||||
delete wideSz;
|
||||
}
|
||||
return szUTF8;
|
||||
}
|
||||
|
||||
std::wstring ConvertToWide(LPCSTR str)
|
||||
{
|
||||
std::wstring szWide;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
WCHAR* wideSz = new WCHAR[len * 2];
|
||||
wideSz[0] = 0;
|
||||
MultiByteToWideChar(CP_UTF8, 0, str, (int)len, wideSz, (int)len * 2);
|
||||
szWide = wideSz;
|
||||
delete wideSz;
|
||||
}
|
||||
return szWide;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
LPCTSTR tmpSz;
|
||||
|
||||
if (!g_Initialized)
|
||||
{
|
||||
InitializeCriticalSection(&g_CriticalSection);
|
||||
g_Initialized = true;
|
||||
}
|
||||
|
||||
UrlData* data = new UrlData;
|
||||
data->section = section;
|
||||
data->updateRate = 1;
|
||||
data->updateCounter = 0;
|
||||
data->iniFile = iniFile;
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
|
||||
data->url = ReadConfigString(section, L"Url", L"");
|
||||
data->regExp = ReadConfigString(section, L"RegExp", L"");
|
||||
data->finishAction = ReadConfigString(section, L"FinishAction", L"");
|
||||
data->errorString = ReadConfigString(section, L"ErrorString", L"");
|
||||
data->proxy = ReadConfigString(section, L"ProxyServer", L"");
|
||||
|
||||
tmpSz = ReadConfigString(section, L"StringIndex", L"0");
|
||||
if (tmpSz)
|
||||
{
|
||||
data->stringIndex = _wtoi(tmpSz);
|
||||
}
|
||||
|
||||
tmpSz = ReadConfigString(section, L"StringIndex2", L"0");
|
||||
if (tmpSz)
|
||||
{
|
||||
data->stringIndex2 = _wtoi(tmpSz);
|
||||
}
|
||||
|
||||
tmpSz = ReadConfigString(section, L"UpdateRate", L"1");
|
||||
if (tmpSz)
|
||||
{
|
||||
data->updateRate = _wtoi(tmpSz);
|
||||
}
|
||||
|
||||
tmpSz = ReadConfigString(section, L"Download", L"0");
|
||||
if (tmpSz)
|
||||
{
|
||||
data->download = 1 == _wtoi(tmpSz);
|
||||
}
|
||||
|
||||
tmpSz = ReadConfigString(section, L"Debug", L"0");
|
||||
if (tmpSz)
|
||||
{
|
||||
data->debug = _wtoi(tmpSz);
|
||||
}
|
||||
|
||||
tmpSz = ReadConfigString(section, L"CodePage", L"0");
|
||||
if (tmpSz)
|
||||
{
|
||||
data->codepage = _wtoi(tmpSz);
|
||||
}
|
||||
|
||||
if (hRootHandle == NULL)
|
||||
{
|
||||
if (data->proxy.empty())
|
||||
{
|
||||
hRootHandle = InternetOpen(L"Rainmeter WebParser plugin",
|
||||
INTERNET_OPEN_TYPE_PRECONFIG,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
hRootHandle = InternetOpen(L"Rainmeter WebParser plugin",
|
||||
INTERNET_OPEN_TYPE_PROXY,
|
||||
data->proxy.c_str(),
|
||||
NULL,
|
||||
0);
|
||||
}
|
||||
|
||||
if (hRootHandle == NULL)
|
||||
{
|
||||
ShowError(__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
data->threadHandle = 0;
|
||||
data->dlThreadHandle = 0;
|
||||
|
||||
// During initialization there is no threads yet so no need to do any locking
|
||||
g_UrlData[id] = data;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
double value = 0;
|
||||
UrlData* urlData = NULL;
|
||||
|
||||
// Find the data for this instance (the data structure is not changed by anyone so this should be safe)
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
if(urlIter != g_UrlData.end())
|
||||
{
|
||||
urlData = (*urlIter).second;
|
||||
}
|
||||
|
||||
if (urlData)
|
||||
{
|
||||
if (urlData->download && urlData->regExp.empty() && urlData->url.find(L'[') == std::wstring::npos)
|
||||
{
|
||||
// If RegExp is empty download the file that is pointed by the Url
|
||||
if (urlData->dlThreadHandle == 0)
|
||||
{
|
||||
if (urlData->updateCounter == 0)
|
||||
{
|
||||
// Launch a new thread to fetch the web data
|
||||
DWORD id;
|
||||
urlData->dlThreadHandle = CreateThread(NULL, 0, NetworkDownloadThreadProc, urlData, 0, &id);
|
||||
}
|
||||
|
||||
urlData->updateCounter++;
|
||||
if (urlData->updateCounter >= urlData->updateRate)
|
||||
{
|
||||
urlData->updateCounter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Else download the file pointed by the result string (this is done later)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Make sure that the thread is not writing to the result at the same time
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
if (!urlData->resultString.empty())
|
||||
{
|
||||
value = wcstod(urlData->resultString.c_str(), NULL);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
if (urlData->url.size() > 0 && urlData->url.find(L'[') == std::wstring::npos)
|
||||
{
|
||||
// This is not a reference; need to update.
|
||||
if (urlData->threadHandle == 0)
|
||||
{
|
||||
if (urlData->updateCounter == 0)
|
||||
{
|
||||
// Launch a new thread to fetch the web data
|
||||
DWORD id;
|
||||
urlData->threadHandle = CreateThread(NULL, 0, NetworkThreadProc, urlData, 0, &id);
|
||||
}
|
||||
|
||||
urlData->updateCounter++;
|
||||
if (urlData->updateCounter >= urlData->updateRate)
|
||||
{
|
||||
urlData->updateCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Thread that fetches the data from the net and parses the page.
|
||||
*/
|
||||
DWORD WINAPI NetworkThreadProc(LPVOID pParam)
|
||||
{
|
||||
UrlData* urlData = (UrlData*)pParam;
|
||||
DWORD dwSize = 0;
|
||||
|
||||
BYTE* data = DownloadUrl(urlData->url, &dwSize);
|
||||
|
||||
if (data)
|
||||
{
|
||||
if (urlData->debug == 2)
|
||||
{
|
||||
// Dump to a file
|
||||
FILE* file = fopen("C:\\WebParserDump.txt", "wb");
|
||||
fwrite(data, sizeof(BYTE), dwSize, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
ParseData(urlData, (LPCSTR)data);
|
||||
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
CloseHandle(urlData->threadHandle);
|
||||
urlData->threadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
void ParseData(UrlData* urlData, LPCSTR parseData)
|
||||
{
|
||||
size_t dwSize = 0;
|
||||
|
||||
// Parse the value from the data
|
||||
pcre* re;
|
||||
const char* error;
|
||||
int erroffset;
|
||||
int ovector[OVECCOUNT];
|
||||
int rc;
|
||||
int flags = PCRE_UTF8;
|
||||
|
||||
if (urlData->codepage == 0)
|
||||
{
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
// Compile the regular expression in the first argument
|
||||
re = pcre_compile(
|
||||
ConvertToUTF8(urlData->regExp.c_str()).c_str(), // the pattern
|
||||
flags, // default options
|
||||
&error, // for error message
|
||||
&erroffset, // for error offset
|
||||
NULL); // use default character tables
|
||||
|
||||
if (re != NULL)
|
||||
{
|
||||
// Compilation succeeded: match the subject in the second argument
|
||||
std::string utf8Data;
|
||||
|
||||
if (urlData->codepage != CP_UTF8 && urlData->codepage != 0) // 0 = CP_ACP
|
||||
{
|
||||
// Must convert the data to utf8
|
||||
utf8Data = ConvertToUTF8(parseData, urlData->codepage);
|
||||
parseData = utf8Data.c_str();
|
||||
}
|
||||
|
||||
dwSize = strlen(parseData);
|
||||
|
||||
rc = pcre_exec(
|
||||
re, // the compiled pattern
|
||||
NULL, // no extra data - we didn't study the pattern
|
||||
parseData, // the subject string
|
||||
dwSize, // the length of the subject
|
||||
0, // start at offset 0 in the subject
|
||||
0, // default options
|
||||
ovector, // output vector for substring information
|
||||
OVECCOUNT); // number of elements in the output vector
|
||||
|
||||
|
||||
if (rc >= 0)
|
||||
{
|
||||
if (rc == 0)
|
||||
{
|
||||
// The output vector wasn't big enough
|
||||
Log(L"WebParser: Too many substrings!");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (urlData->stringIndex < rc)
|
||||
{
|
||||
if (urlData->debug != 0)
|
||||
{
|
||||
for (int i = 0; i < rc; i++)
|
||||
{
|
||||
WCHAR buffer[1024];
|
||||
char* substring_start = (char*)(parseData + ovector[2 * i]);
|
||||
int substring_length = ovector[2 * i + 1] - ovector[2 * i];
|
||||
substring_length = min(substring_length, 256);
|
||||
std::string tmpStr(substring_start, substring_length);
|
||||
wsprintf(buffer, L"WebParser: (Index %2d) %hs", i, tmpStr.c_str());
|
||||
Log(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
const char* substring_start = parseData + ovector[2 * urlData->stringIndex];
|
||||
int substring_length = ovector[2 * urlData->stringIndex + 1] - ovector[2 * urlData->stringIndex];
|
||||
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
std::string szResult((char*)substring_start, substring_length);
|
||||
urlData->resultString = ConvertToWide(szResult.c_str());
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(L"WebParser: Not enough substrings!");
|
||||
}
|
||||
|
||||
// Update the references
|
||||
std::map<UINT, UrlData*>::iterator i = g_UrlData.begin();
|
||||
std::wstring compareStr = L"[";
|
||||
compareStr += urlData->section;
|
||||
compareStr += L"]";
|
||||
for ( ; i != g_UrlData.end(); i++)
|
||||
{
|
||||
if ((((*i).second)->url.find(compareStr) != std::wstring::npos) && (urlData->iniFile == ((*i).second)->iniFile))
|
||||
{
|
||||
if (((*i).second)->stringIndex < rc)
|
||||
{
|
||||
const char* substring_start = parseData + ovector[2 * ((*i).second)->stringIndex];
|
||||
int substring_length = ovector[2 * ((*i).second)->stringIndex + 1] - ovector[2 * ((*i).second)->stringIndex];
|
||||
|
||||
std::string szResult((char*)substring_start, substring_length);
|
||||
|
||||
if (!((*i).second)->regExp.empty())
|
||||
{
|
||||
// Change the index and parse the substring
|
||||
int index = (*i).second->stringIndex;
|
||||
(*i).second->stringIndex = (*i).second->stringIndex2;
|
||||
ParseData((*i).second, szResult.c_str());
|
||||
(*i).second->stringIndex = index;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the result
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
// Substitude the [measure] with szResult
|
||||
std::wstring wzResult = ConvertToWide(szResult.c_str());
|
||||
std::wstring wzUrl = ((*i).second)->url;
|
||||
|
||||
wzUrl.replace(wzUrl.find(compareStr), compareStr.size(), wzResult);
|
||||
((*i).second)->resultString = wzUrl;
|
||||
|
||||
// Start download threads for the references
|
||||
if (((*i).second)->download)
|
||||
{
|
||||
// Start the download thread
|
||||
DWORD id;
|
||||
((*i).second)->dlThreadHandle = CreateThread(NULL, 0, NetworkDownloadThreadProc, ((*i).second), 0, &id);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(L"WebParser: Not enough substrings!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Matching failed: handle error cases
|
||||
WCHAR buffer[1024];
|
||||
wsprintf(buffer, L"WebParser: Matching error! (%d)\n", rc);
|
||||
Log(buffer);
|
||||
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
urlData->resultString = urlData->errorString;
|
||||
|
||||
// Update the references
|
||||
std::map<UINT, UrlData*>::iterator i = g_UrlData.begin();
|
||||
std::wstring compareStr = L"[";
|
||||
compareStr += urlData->section;
|
||||
compareStr += L"]";
|
||||
for ( ; i != g_UrlData.end(); i++)
|
||||
{
|
||||
if ((((*i).second)->url.find(compareStr) != std::wstring::npos) && (urlData->iniFile == ((*i).second)->iniFile))
|
||||
{
|
||||
((*i).second)->resultString = ((*i).second)->errorString;
|
||||
}
|
||||
}
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compilation failed: print the error message and exit
|
||||
WCHAR buffer[1024];
|
||||
wsprintf(buffer, L"WebParser: PCRE compilation failed at offset %d: %s\n", erroffset, error);
|
||||
Log(buffer);
|
||||
}
|
||||
|
||||
if (urlData->download)
|
||||
{
|
||||
// Start the download thread
|
||||
DWORD id;
|
||||
urlData->dlThreadHandle = CreateThread(NULL, 0, NetworkDownloadThreadProc, urlData, 0, &id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!urlData->finishAction.empty())
|
||||
{
|
||||
HWND wnd = FindWindow(L"RainmeterMeterWindow", NULL);
|
||||
|
||||
if (wnd != NULL)
|
||||
{
|
||||
COPYDATASTRUCT copyData;
|
||||
|
||||
copyData.dwData = 1;
|
||||
copyData.cbData = (DWORD)(urlData->finishAction.size() + 1) * sizeof(WCHAR);
|
||||
copyData.lpData = (void*)urlData->finishAction.c_str();
|
||||
|
||||
// Send the bang to the Rainlendar window
|
||||
SendMessage(wnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)©Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Thread that downloads the file from the new.
|
||||
*/
|
||||
DWORD WINAPI NetworkDownloadThreadProc(LPVOID pParam)
|
||||
{
|
||||
UrlData* urlData = (UrlData*)pParam;
|
||||
|
||||
std::wstring url;
|
||||
|
||||
if (urlData->regExp.empty() && urlData->resultString.empty())
|
||||
{
|
||||
url = urlData->url;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
url = urlData->resultString;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
size_t pos = url.find(':');
|
||||
if (pos == -1 && !url.empty()) // No protocol
|
||||
{
|
||||
// Add the base url to the string
|
||||
if (url[0] == '/')
|
||||
{
|
||||
// Absolute path
|
||||
pos = urlData->url.find('/', 7); // Assume "http://" (=7)
|
||||
if (pos != -1)
|
||||
{
|
||||
std::wstring path(urlData->url.substr(0, pos));
|
||||
url = path + url;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Relative path
|
||||
|
||||
pos = urlData->url.rfind('/');
|
||||
if (pos != -1)
|
||||
{
|
||||
std::wstring path(urlData->url.substr(0, pos + 1));
|
||||
url = path + url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!url.empty())
|
||||
{
|
||||
// Create the filename
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetTempPath(MAX_PATH, buffer);
|
||||
wcscat(buffer, L"Rainmeter-Cache\\");
|
||||
CreateDirectory(buffer, NULL); // Make sure that the folder exists
|
||||
|
||||
size_t pos = url.rfind('/');
|
||||
if (pos != -1)
|
||||
{
|
||||
std::wstring filename(url.substr(pos + 1));
|
||||
wcscat(buffer, filename.c_str());
|
||||
|
||||
// Write some log info
|
||||
std::wstring info;
|
||||
info = L"WebParser: Downloading url ";
|
||||
info += url;
|
||||
info += L" to ";
|
||||
info += buffer;
|
||||
info += L"\n";
|
||||
Log(info.c_str());
|
||||
|
||||
if (!urlData->downloadedFile.empty())
|
||||
{
|
||||
DeleteFile(urlData->downloadedFile.c_str());
|
||||
}
|
||||
|
||||
// Download the file
|
||||
if (S_OK == URLDownloadToFile(NULL, url.c_str(), buffer, NULL, NULL))
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
urlData->downloadedFile = buffer;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
if (!urlData->finishAction.empty())
|
||||
{
|
||||
HWND wnd = FindWindow(L"RainmeterMeterWindow", NULL);
|
||||
|
||||
if (wnd != NULL)
|
||||
{
|
||||
COPYDATASTRUCT copyData;
|
||||
|
||||
copyData.dwData = 1;
|
||||
copyData.cbData = (DWORD)(urlData->finishAction.size() + 1) * sizeof(WCHAR);
|
||||
copyData.lpData = (void*)urlData->finishAction.c_str();
|
||||
|
||||
// Send the bang to the Rainlendar window
|
||||
SendMessage(wnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)©Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"WebParser: Download failed: ";
|
||||
error += url;
|
||||
Log(error.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring error = L"WebParser: No filename in the url: ";
|
||||
error += url;
|
||||
Log(error.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log(L"WebParser: The url is empty.\n");
|
||||
}
|
||||
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
CloseHandle(urlData->dlThreadHandle);
|
||||
urlData->dlThreadHandle = 0;
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return 0; // thread completed successfully
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static std::wstring resultString;
|
||||
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
{
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
if (((*urlIter).second)->download)
|
||||
{
|
||||
resultString = ((*urlIter).second)->downloadedFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
resultString = ((*urlIter).second)->resultString;
|
||||
}
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
|
||||
return resultString.c_str();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, UrlData*>::iterator urlIter = g_UrlData.find(id);
|
||||
|
||||
if(urlIter != g_UrlData.end())
|
||||
{
|
||||
if (((*urlIter).second)->threadHandle)
|
||||
{
|
||||
// Thread is killed inside critical section so that itself is not inside one when it is terminated
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
TerminateThread(((*urlIter).second)->threadHandle, 0);
|
||||
(*urlIter).second->threadHandle = NULL;
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
if (((*urlIter).second)->dlThreadHandle)
|
||||
{
|
||||
// Thread is killed inside critical section so that itself is not inside one when it is terminated
|
||||
EnterCriticalSection(&g_CriticalSection);
|
||||
|
||||
TerminateThread(((*urlIter).second)->dlThreadHandle, 0);
|
||||
(*urlIter).second->dlThreadHandle = NULL;
|
||||
|
||||
LeaveCriticalSection(&g_CriticalSection);
|
||||
}
|
||||
|
||||
if (!((*urlIter).second)->downloadedFile.empty())
|
||||
{
|
||||
// Delete the file
|
||||
DeleteFile(((*urlIter).second)->downloadedFile.c_str());
|
||||
}
|
||||
|
||||
delete (*urlIter).second;
|
||||
g_UrlData.erase(urlIter);
|
||||
}
|
||||
|
||||
if (g_UrlData.empty())
|
||||
{
|
||||
// Last one, close all handles
|
||||
if (hRootHandle)
|
||||
{
|
||||
InternetCloseHandle(hRootHandle);
|
||||
hRootHandle = NULL;
|
||||
}
|
||||
|
||||
// Last instance deletes the critical section
|
||||
DeleteCriticalSection(&g_CriticalSection);
|
||||
g_Initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Downloads the given url and returns the webpage as dynamically allocated string.
|
||||
You need to delete the returned string after use!
|
||||
*/
|
||||
BYTE* DownloadUrl(std::wstring& url, DWORD* dwDataSize)
|
||||
{
|
||||
HINTERNET hUrlDump;
|
||||
DWORD dwSize;
|
||||
BYTE* lpData;
|
||||
BYTE* lpOutPut;
|
||||
BYTE* lpHolding = NULL;
|
||||
int nCounter = 1;
|
||||
int nBufferSize;
|
||||
const int CHUNK_SIZE = 8192;
|
||||
|
||||
std::wstring err = L"WebParser: Fetching URL: ";
|
||||
err += url;
|
||||
Log(err.c_str());
|
||||
|
||||
hUrlDump = InternetOpenUrl(hRootHandle, url.c_str(), NULL, NULL, INTERNET_FLAG_RELOAD, 0);
|
||||
if (hUrlDump == NULL)
|
||||
{
|
||||
ShowError(__LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*dwDataSize = 0;
|
||||
|
||||
do
|
||||
{
|
||||
// Allocate the buffer.
|
||||
lpData = new BYTE[CHUNK_SIZE];
|
||||
|
||||
// Read the data.
|
||||
if (!InternetReadFile(hUrlDump, (LPVOID)lpData, CHUNK_SIZE, &dwSize))
|
||||
{
|
||||
ShowError(__LINE__);
|
||||
delete [] lpData;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if all of the data has been read. This should
|
||||
// never get called on the first time through the loop.
|
||||
if (dwSize == 0)
|
||||
{
|
||||
// Delete the existing buffers.
|
||||
delete [] lpData;
|
||||
break;
|
||||
}
|
||||
|
||||
// Determine the buffer size to hold the new data and the data
|
||||
// already written (if any).
|
||||
nBufferSize = nCounter * CHUNK_SIZE;
|
||||
|
||||
// Allocate the output buffer.
|
||||
lpOutPut = new BYTE[nBufferSize + 2];
|
||||
|
||||
// Make sure the buffer is not the initial buffer.
|
||||
if (lpHolding != NULL)
|
||||
{
|
||||
// Copy the data in the holding buffer.
|
||||
memcpy(lpOutPut, lpHolding, *dwDataSize);
|
||||
|
||||
// Delete the old buffer
|
||||
delete [] lpHolding;
|
||||
|
||||
lpHolding = lpOutPut;
|
||||
lpOutPut = lpOutPut + *dwDataSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
lpHolding = lpOutPut;
|
||||
}
|
||||
|
||||
// Copy the data buffer.
|
||||
memcpy(lpOutPut, lpData, dwSize);
|
||||
|
||||
*dwDataSize += dwSize;
|
||||
|
||||
// End with double null
|
||||
lpOutPut[dwSize] = 0;
|
||||
lpOutPut[dwSize + 1] = 0;
|
||||
|
||||
// Increment the number of buffers read.
|
||||
nCounter++;
|
||||
|
||||
// Delete the buffer
|
||||
delete [] lpData;
|
||||
}
|
||||
} while (TRUE);
|
||||
|
||||
// Close the HINTERNET handle.
|
||||
InternetCloseHandle(hUrlDump);
|
||||
|
||||
err = L"WebParser: Finished URL: ";
|
||||
err += url;
|
||||
Log(err.c_str());
|
||||
|
||||
// Return.
|
||||
return lpHolding;
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the last error to log.
|
||||
*/
|
||||
void ShowError(int lineNumber, WCHAR* errorMsg)
|
||||
{
|
||||
WCHAR szBuffer[4096];
|
||||
LPVOID lpMsgBuf = NULL;
|
||||
|
||||
WCHAR buffer[16];
|
||||
wsprintf(buffer, L"%i", lineNumber);
|
||||
|
||||
std::wstring err = L"WebParser (";
|
||||
err += buffer;
|
||||
err += L") ";
|
||||
|
||||
if (errorMsg == NULL)
|
||||
{
|
||||
if (GetLastError() == ERROR_INTERNET_EXTENDED_ERROR)
|
||||
{
|
||||
DWORD dwError, dwLen = 4096;
|
||||
if (InternetGetLastResponseInfo(&dwError, szBuffer, &dwLen))
|
||||
{
|
||||
err += szBuffer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD dwErr = GetLastError();
|
||||
|
||||
FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
dwErr,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
||||
(LPTSTR) &lpMsgBuf,
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (lpMsgBuf == NULL)
|
||||
{
|
||||
err += L"Unknown error: ";
|
||||
wsprintf(buffer, L"%i", dwErr);
|
||||
err += buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
err += (LPTSTR)lpMsgBuf;
|
||||
LocalFree(lpMsgBuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err += errorMsg;
|
||||
}
|
||||
|
||||
Log(err.c_str());
|
||||
}
|
||||
|
||||
/*
|
||||
Writes the log to a file (logging is thread safe (I think...)).
|
||||
*/
|
||||
void Log(const WCHAR* string)
|
||||
{
|
||||
// Todo: put logging into critical section
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", string);
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1010;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
125
Plugins/PluginWindowMessage/PluginWindowMessage.dsp
Normal file
125
Plugins/PluginWindowMessage/PluginWindowMessage.dsp
Normal file
@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginWindowMessage" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginWindowMessage - 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 "PluginWindowMessage.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 "PluginWindowMessage.mak" CFG="PluginWindowMessage - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginWindowMessage - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginWindowMessage - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginWindowMessage - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginWindowMessage"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginWindowMessage - 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 "PluginWindowMessage_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginWindowMessage_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/WindowMessagePlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginWindowMessage - 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 "PluginWindowMessage_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 "PluginWindowMessage_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/WindowMessagePlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginWindowMessage - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginWindowMessage___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginWindowMessage___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 "PluginWindowMessage_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginWindowMessage_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/WindowMessagePlugin.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/WindowMessagePlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginWindowMessage - Win32 Release"
|
||||
# Name "PluginWindowMessage - Win32 Debug"
|
||||
# Name "PluginWindowMessage - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\WindowMessagePlugin.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
232
Plugins/PluginWindowMessage/PluginWindowMessage.vcproj
Normal file
232
Plugins/PluginWindowMessage/PluginWindowMessage.vcproj
Normal file
@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginWindowMessage"
|
||||
SccProjectName="PluginWindowMessage"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<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;PluginWindowMessage_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginWindowMessage.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/WindowMessagePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/WindowMessagePlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/WindowMessagePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginWindowMessage.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 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;PluginWindowMessage_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginWindowMessage.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/WindowMessagePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/WindowMessagePlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/WindowMessagePlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginWindowMessage.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="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;PluginWindowMessage_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginWindowMessage.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/WindowMessagePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/WindowMessagePlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/WindowMessagePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginWindowMessage.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="WindowMessagePlugin.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
241
Plugins/PluginWindowMessage/WindowMessagePlugin.cpp
Normal file
241
Plugins/PluginWindowMessage/WindowMessagePlugin.cpp
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
Copyright (C) 2005 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginWindowMessage/WindowMessagePlugin.cpp,v 1.1.1.1 2005/07/10 18:51:07 rainy Exp $
|
||||
|
||||
$Log: WindowMessagePlugin.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:07 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* 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 ) double Update2(UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
__declspec( dllexport ) void ExecuteBang(LPCTSTR args, UINT id);
|
||||
}
|
||||
|
||||
struct windowData
|
||||
{
|
||||
std::wstring windowName;
|
||||
std::wstring windowClass;
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
DWORD uMsg;
|
||||
std::wstring value;
|
||||
DWORD result;
|
||||
};
|
||||
|
||||
static std::map<UINT, windowData> g_Values;
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
windowData wData;
|
||||
|
||||
wData.uMsg = 0;
|
||||
wData.wParam = 0;
|
||||
wData.lParam = 0;
|
||||
wData.result = 0;
|
||||
|
||||
/* Read our own settings from the ini-file */
|
||||
LPCTSTR data = ReadConfigString(section, L"WindowName", NULL);
|
||||
if (data)
|
||||
{
|
||||
wData.windowName = data;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"WindowClass", NULL);
|
||||
if (data)
|
||||
{
|
||||
wData.windowClass = data;
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"WindowMessage", NULL);
|
||||
if (data)
|
||||
{
|
||||
DWORD uMsg, wParam, lParam;
|
||||
if (3 == swscanf(data, L"%u %u %u", &uMsg, &wParam, &lParam))
|
||||
{
|
||||
wData.uMsg = uMsg;
|
||||
wData.wParam = wParam;
|
||||
wData.lParam = lParam;
|
||||
}
|
||||
}
|
||||
|
||||
g_Values[id] = wData;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
std::map<UINT, windowData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
std::wstring& winName = (*i).second.windowName;
|
||||
std::wstring& winClass = (*i).second.windowClass;
|
||||
HWND hwnd = FindWindow(winClass.empty() ? NULL : winClass.c_str(), winName.empty() ? NULL : winName.c_str());
|
||||
if (hwnd)
|
||||
{
|
||||
if ((*i).second.uMsg == 0)
|
||||
{
|
||||
// Get window text
|
||||
WCHAR buffer[1024];
|
||||
buffer[0] = 0;
|
||||
GetWindowText(hwnd, buffer, 1024);
|
||||
(*i).second.value = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*i).second.result = (DWORD)SendMessage(hwnd, (*i).second.uMsg, (*i).second.wParam, (*i).second.lParam);
|
||||
return (int)((*i).second.result);
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR buffer[256];
|
||||
|
||||
std::map<UINT, windowData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
if (((*i).second).value.empty())
|
||||
{
|
||||
_itow(((*i).second).result, buffer, 10);
|
||||
return buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((*i).second).value.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
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)
|
||||
{
|
||||
std::map<UINT, windowData>::iterator i1 = g_Values.find(id);
|
||||
if (i1 != g_Values.end())
|
||||
{
|
||||
g_Values.erase(i1);
|
||||
}
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
||||
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::wstring wholeBang = args;
|
||||
|
||||
size_t pos = wholeBang.find(' ');
|
||||
if (pos != -1)
|
||||
{
|
||||
std::wstring bang = wholeBang.substr(0, pos);
|
||||
wholeBang.erase(0, pos + 1);
|
||||
|
||||
if (wcsicmp(bang.c_str(), L"SendMessage") == 0)
|
||||
{
|
||||
// Parse parameters
|
||||
DWORD uMsg, wParam, lParam;
|
||||
if (3 == swscanf(wholeBang.c_str(), L"%u %u %u", &uMsg, &wParam, &lParam))
|
||||
{
|
||||
std::map<UINT, windowData>::iterator i = g_Values.find(id);
|
||||
if (i != g_Values.end())
|
||||
{
|
||||
std::wstring& winName = (*i).second.windowName;
|
||||
std::wstring& winClass = (*i).second.windowClass;
|
||||
HWND hwnd = FindWindow(winClass.empty() ? NULL : winClass.c_str(), winName.empty() ? NULL : winName.c_str());
|
||||
if (hwnd)
|
||||
{
|
||||
PostMessage(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unable to find the window!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unable to find the window data!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Incorrect number of arguments for the bang!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unknown bang!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"WindowMessagePlugin: Unable to parse the bang!");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user