Fixed line endings and applied gitignore

This commit is contained in:
2014-07-26 09:43:40 +03:00
parent 0c57cabe56
commit 7cba5cc109
542 changed files with 112014 additions and 119759 deletions

View File

@ -1,98 +1,98 @@
#include <windows.h>
#include "CoreTempProxy.h"
CoreTempProxy::CoreTempProxy(void)
{
memset(&this->m_pCoreTempData, 0, sizeof(CORE_TEMP_SHARED_DATA));
}
CoreTempProxy::~CoreTempProxy(void)
{
}
UINT CoreTempProxy::GetCoreLoad(int i_Index) const
{
return this->m_pCoreTempData.uiLoad[i_Index];
}
UINT CoreTempProxy::GetTjMax(int i_Index) const
{
return this->m_pCoreTempData.uiTjMax[i_Index];
}
UINT CoreTempProxy::GetCoreCount() const
{
return this->m_pCoreTempData.uiCoreCnt;
}
UINT CoreTempProxy::GetCPUCount() const
{
return this->m_pCoreTempData.uiCPUCnt;
}
float CoreTempProxy::GetTemp(int i_Index) const
{
return this->m_pCoreTempData.fTemp[i_Index];
}
float CoreTempProxy::GetVID() const
{
return this->m_pCoreTempData.fVID;
}
float CoreTempProxy::GetCPUSpeed() const
{
return this->m_pCoreTempData.fCPUSpeed;
}
float CoreTempProxy::GetFSBSpeed() const
{
return this->m_pCoreTempData.fFSBSpeed;
}
float CoreTempProxy::GetMultiplier() const
{
return this->m_pCoreTempData.fMultipier;
}
LPCSTR CoreTempProxy::GetCPUName() const
{
return this->m_pCoreTempData.sCPUName;
}
bool CoreTempProxy::IsFahrenheit() const
{
return this->m_pCoreTempData.ucFahrenheit != 0;
}
bool CoreTempProxy::IsDistanceToTjMax() const
{
return this->m_pCoreTempData.ucDeltaToTjMax != 0;
}
const CORE_TEMP_SHARED_DATA &CoreTempProxy::GetDataStruct() const
{
return this->m_pCoreTempData;
}
bool CoreTempProxy::GetData()
{
return this->m_SharedMem.ReadSharedMem(&this->m_pCoreTempData);
}
LPCWSTR CoreTempProxy::GetErrorMessage()
{
DWORD lastError;
lastError = ::GetLastError();
if ((lastError & UNKNOWN_EXCEPTION) > 0)
{
wcscpy_s(this->m_ErrorMessage, L"Unknown error occured while copying shared memory.");
}
else
{
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, lastError, 0, this->m_ErrorMessage, 99, nullptr);
}
return this->m_ErrorMessage;
#include <windows.h>
#include "CoreTempProxy.h"
CoreTempProxy::CoreTempProxy(void)
{
memset(&this->m_pCoreTempData, 0, sizeof(CORE_TEMP_SHARED_DATA));
}
CoreTempProxy::~CoreTempProxy(void)
{
}
UINT CoreTempProxy::GetCoreLoad(int i_Index) const
{
return this->m_pCoreTempData.uiLoad[i_Index];
}
UINT CoreTempProxy::GetTjMax(int i_Index) const
{
return this->m_pCoreTempData.uiTjMax[i_Index];
}
UINT CoreTempProxy::GetCoreCount() const
{
return this->m_pCoreTempData.uiCoreCnt;
}
UINT CoreTempProxy::GetCPUCount() const
{
return this->m_pCoreTempData.uiCPUCnt;
}
float CoreTempProxy::GetTemp(int i_Index) const
{
return this->m_pCoreTempData.fTemp[i_Index];
}
float CoreTempProxy::GetVID() const
{
return this->m_pCoreTempData.fVID;
}
float CoreTempProxy::GetCPUSpeed() const
{
return this->m_pCoreTempData.fCPUSpeed;
}
float CoreTempProxy::GetFSBSpeed() const
{
return this->m_pCoreTempData.fFSBSpeed;
}
float CoreTempProxy::GetMultiplier() const
{
return this->m_pCoreTempData.fMultipier;
}
LPCSTR CoreTempProxy::GetCPUName() const
{
return this->m_pCoreTempData.sCPUName;
}
bool CoreTempProxy::IsFahrenheit() const
{
return this->m_pCoreTempData.ucFahrenheit != 0;
}
bool CoreTempProxy::IsDistanceToTjMax() const
{
return this->m_pCoreTempData.ucDeltaToTjMax != 0;
}
const CORE_TEMP_SHARED_DATA &CoreTempProxy::GetDataStruct() const
{
return this->m_pCoreTempData;
}
bool CoreTempProxy::GetData()
{
return this->m_SharedMem.ReadSharedMem(&this->m_pCoreTempData);
}
LPCWSTR CoreTempProxy::GetErrorMessage()
{
DWORD lastError;
lastError = ::GetLastError();
if ((lastError & UNKNOWN_EXCEPTION) > 0)
{
wcscpy_s(this->m_ErrorMessage, L"Unknown error occured while copying shared memory.");
}
else
{
::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, lastError, 0, this->m_ErrorMessage, 99, nullptr);
}
return this->m_ErrorMessage;
}

View File

@ -1,34 +1,34 @@
#pragma once
#include "SharedMem.h"
#define UNKNOWN_EXCEPTION 0x20000000
class CoreTempProxy
{
public:
CoreTempProxy(void);
virtual ~CoreTempProxy(void);
UINT GetCoreLoad(int i_Index) const;
UINT GetTjMax(int i_Index) const;
UINT GetCoreCount() const;
UINT GetCPUCount() const;
float GetTemp(int i_Index) const;
float GetVID() const;
float GetCPUSpeed() const;
float GetFSBSpeed() const;
float GetMultiplier() const;
LPCSTR GetCPUName() const;
bool IsFahrenheit() const;
bool IsDistanceToTjMax() const;
const CORE_TEMP_SHARED_DATA &GetDataStruct() const;
bool GetData();
DWORD GetDllError() const { return GetLastError(); }
LPCWSTR GetErrorMessage();
private:
CSharedMemClient m_SharedMem;
CORE_TEMP_SHARED_DATA m_pCoreTempData;
WCHAR m_ErrorMessage[100];
};
#pragma once
#include "SharedMem.h"
#define UNKNOWN_EXCEPTION 0x20000000
class CoreTempProxy
{
public:
CoreTempProxy(void);
virtual ~CoreTempProxy(void);
UINT GetCoreLoad(int i_Index) const;
UINT GetTjMax(int i_Index) const;
UINT GetCoreCount() const;
UINT GetCPUCount() const;
float GetTemp(int i_Index) const;
float GetVID() const;
float GetCPUSpeed() const;
float GetFSBSpeed() const;
float GetMultiplier() const;
LPCSTR GetCPUName() const;
bool IsFahrenheit() const;
bool IsDistanceToTjMax() const;
const CORE_TEMP_SHARED_DATA &GetDataStruct() const;
bool GetData();
DWORD GetDllError() const { return GetLastError(); }
LPCWSTR GetErrorMessage();
private:
CSharedMemClient m_SharedMem;
CORE_TEMP_SHARED_DATA m_pCoreTempData;
WCHAR m_ErrorMessage[100];
};

View File

@ -1,212 +1,212 @@
/*
Copyright (C) 2011 Arthur Liberman
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <windows.h>
#include <wchar.h>
#include "CoreTempProxy.h"
#include "../../Library/Export.h" // Rainmeter's exported functions
typedef enum eMeasureType
{
MeasureTemperature,
MeasureMaxTemperature,
MeasureTjMax,
MeasureLoad,
MeasureVid,
MeasureCpuSpeed,
MeasureBusSpeed,
MeasureBusMultiplier,
MeasureCpuName
};
struct MeasureData
{
eMeasureType type;
int index;
MeasureData() : type(), index() {}
};
CoreTempProxy proxy;
eMeasureType convertStringToMeasureType(LPCWSTR i_String);
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2);
float getHighestTemp();
PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
MeasureData* measure = new MeasureData;
*data = measure;
}
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
MeasureData* measure = (MeasureData*)data;
LPCWSTR value = RmReadString(rm, L"CoreTempType", L"Temperature");
measure->type = convertStringToMeasureType(value);
if (measure->type == MeasureTemperature || measure->type == MeasureTjMax || measure->type == MeasureLoad)
{
measure->index = RmReadInt(rm, L"CoreTempIndex", 0);
}
}
PLUGIN_EXPORT double Update(void* data)
{
MeasureData* measure = (MeasureData*)data;
double result = 0;
if (proxy.GetData())
{
switch (measure->type)
{
case MeasureTemperature:
result = proxy.GetTemp(measure->index);
break;
case MeasureMaxTemperature:
result = getHighestTemp();
break;
case MeasureTjMax:
result = proxy.GetTjMax(measure->index);
break;
case MeasureLoad:
result = proxy.GetCoreLoad(measure->index);
break;
case MeasureVid:
result = proxy.GetVID();
break;
case MeasureCpuSpeed:
result = proxy.GetCPUSpeed();
break;
case MeasureBusSpeed:
result = proxy.GetFSBSpeed();
break;
case MeasureBusMultiplier:
result = proxy.GetMultiplier();
break;
}
}
return result;
}
PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
MeasureData* measure = (MeasureData*)data;
static WCHAR buffer[128];
switch (measure->type)
{
case MeasureVid:
_snwprintf_s(buffer, _TRUNCATE, L"%.4f", proxy.GetVID());
break;
case MeasureCpuName:
_snwprintf_s(buffer, _TRUNCATE, L"%S", proxy.GetCPUName());
break;
default:
return nullptr;
}
return buffer;
}
PLUGIN_EXPORT void Finalize(void* data)
{
MeasureData* measure = (MeasureData*)data;
delete measure;
}
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2)
{
return _wcsicmp(i_String1, i_Strting2) == 0;
}
eMeasureType convertStringToMeasureType(LPCWSTR i_String)
{
eMeasureType result;
if (areStringsEqual(i_String, L"Temperature"))
{
result = MeasureTemperature;
}
else if (areStringsEqual(i_String, L"MaxTemperature"))
{
result = MeasureMaxTemperature;
}
else if (areStringsEqual(i_String, L"TjMax"))
{
result = MeasureTjMax;
}
else if (areStringsEqual(i_String, L"Load"))
{
result = MeasureLoad;
}
else if (areStringsEqual(i_String, L"Vid"))
{
result = MeasureVid;
}
else if (areStringsEqual(i_String, L"CpuSpeed"))
{
result = MeasureCpuSpeed;
}
else if (areStringsEqual(i_String, L"BusSpeed"))
{
result = MeasureBusSpeed;
}
else if (areStringsEqual(i_String, L"BusMultiplier"))
{
result = MeasureBusMultiplier;
}
else if (areStringsEqual(i_String, L"CpuName"))
{
result = MeasureCpuName;
}
else
{
result = MeasureTemperature;
RmLog(LOG_WARNING, L"CoreTemp.dll: Invalid CoreTempType");
}
return result;
}
float getHighestTemp()
{
float temp = -255;
UINT coreCount = proxy.GetCoreCount();
for (UINT i = 0; i < coreCount; ++i)
{
if (temp < proxy.GetTemp(i))
{
temp = proxy.GetTemp(i);
}
}
return temp;
}
/*
Copyright (C) 2011 Arthur Liberman
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <windows.h>
#include <wchar.h>
#include "CoreTempProxy.h"
#include "../../Library/Export.h" // Rainmeter's exported functions
typedef enum eMeasureType
{
MeasureTemperature,
MeasureMaxTemperature,
MeasureTjMax,
MeasureLoad,
MeasureVid,
MeasureCpuSpeed,
MeasureBusSpeed,
MeasureBusMultiplier,
MeasureCpuName
};
struct MeasureData
{
eMeasureType type;
int index;
MeasureData() : type(), index() {}
};
CoreTempProxy proxy;
eMeasureType convertStringToMeasureType(LPCWSTR i_String);
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2);
float getHighestTemp();
PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
MeasureData* measure = new MeasureData;
*data = measure;
}
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
MeasureData* measure = (MeasureData*)data;
LPCWSTR value = RmReadString(rm, L"CoreTempType", L"Temperature");
measure->type = convertStringToMeasureType(value);
if (measure->type == MeasureTemperature || measure->type == MeasureTjMax || measure->type == MeasureLoad)
{
measure->index = RmReadInt(rm, L"CoreTempIndex", 0);
}
}
PLUGIN_EXPORT double Update(void* data)
{
MeasureData* measure = (MeasureData*)data;
double result = 0;
if (proxy.GetData())
{
switch (measure->type)
{
case MeasureTemperature:
result = proxy.GetTemp(measure->index);
break;
case MeasureMaxTemperature:
result = getHighestTemp();
break;
case MeasureTjMax:
result = proxy.GetTjMax(measure->index);
break;
case MeasureLoad:
result = proxy.GetCoreLoad(measure->index);
break;
case MeasureVid:
result = proxy.GetVID();
break;
case MeasureCpuSpeed:
result = proxy.GetCPUSpeed();
break;
case MeasureBusSpeed:
result = proxy.GetFSBSpeed();
break;
case MeasureBusMultiplier:
result = proxy.GetMultiplier();
break;
}
}
return result;
}
PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
MeasureData* measure = (MeasureData*)data;
static WCHAR buffer[128];
switch (measure->type)
{
case MeasureVid:
_snwprintf_s(buffer, _TRUNCATE, L"%.4f", proxy.GetVID());
break;
case MeasureCpuName:
_snwprintf_s(buffer, _TRUNCATE, L"%S", proxy.GetCPUName());
break;
default:
return nullptr;
}
return buffer;
}
PLUGIN_EXPORT void Finalize(void* data)
{
MeasureData* measure = (MeasureData*)data;
delete measure;
}
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2)
{
return _wcsicmp(i_String1, i_Strting2) == 0;
}
eMeasureType convertStringToMeasureType(LPCWSTR i_String)
{
eMeasureType result;
if (areStringsEqual(i_String, L"Temperature"))
{
result = MeasureTemperature;
}
else if (areStringsEqual(i_String, L"MaxTemperature"))
{
result = MeasureMaxTemperature;
}
else if (areStringsEqual(i_String, L"TjMax"))
{
result = MeasureTjMax;
}
else if (areStringsEqual(i_String, L"Load"))
{
result = MeasureLoad;
}
else if (areStringsEqual(i_String, L"Vid"))
{
result = MeasureVid;
}
else if (areStringsEqual(i_String, L"CpuSpeed"))
{
result = MeasureCpuSpeed;
}
else if (areStringsEqual(i_String, L"BusSpeed"))
{
result = MeasureBusSpeed;
}
else if (areStringsEqual(i_String, L"BusMultiplier"))
{
result = MeasureBusMultiplier;
}
else if (areStringsEqual(i_String, L"CpuName"))
{
result = MeasureCpuName;
}
else
{
result = MeasureTemperature;
RmLog(LOG_WARNING, L"CoreTemp.dll: Invalid CoreTempType");
}
return result;
}
float getHighestTemp()
{
float temp = -255;
UINT coreCount = proxy.GetCoreCount();
for (UINT i = 0; i < coreCount; ++i)
{
if (temp < proxy.GetTemp(i))
{
temp = proxy.GetTemp(i);
}
}
return temp;
}

View File

@ -1,40 +1,40 @@
#include <VerRsrc.h>
#include "../../Version.h"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT_UNKNOWN
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileVersion", "1.0.0.0"
VALUE "LegalCopyright", "<22> 2011 - Arthur Liberman"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
#else
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
#endif //_WIN64
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}
#include <VerRsrc.h>
#include "../../Version.h"
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,0
PRODUCTVERSION PRODUCTVER
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT_UNKNOWN
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "FileVersion", "1.0.0.0"
VALUE "LegalCopyright", "<22> 2011 - Arthur Liberman"
VALUE "ProductName", "Rainmeter"
#ifdef _WIN64
VALUE "ProductVersion", STRPRODUCTVER " (64-bit)"
#else
VALUE "ProductVersion", STRPRODUCTVER " (32-bit)"
#endif //_WIN64
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x409, 1252
}
}

View File

@ -1,41 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}</ProjectGuid>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<TargetName>CoreTemp</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CoreTempProxy.cpp" />
<ClCompile Include="PluginCoreTemp.cpp" />
<ClCompile Include="SharedMem.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CoreTempProxy.h" />
<ClInclude Include="SharedMem.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="PluginCoreTemp.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{F32FA418-8DF4-4E94-B92B-EBD502F5DC07}</ProjectGuid>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<TargetName>CoreTemp</TargetName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\Rainmeter.Cpp.props" />
<Import Project="$(SolutionDir)Build\VS\RainmeterPlugin.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CoreTempProxy.cpp" />
<ClCompile Include="PluginCoreTemp.cpp" />
<ClCompile Include="SharedMem.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CoreTempProxy.h" />
<ClInclude Include="SharedMem.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="PluginCoreTemp.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,66 +1,66 @@
#include <windows.h>
#include "SharedMem.h"
CSharedMemClient::CSharedMemClient(void)
{
}
CSharedMemClient::~CSharedMemClient(void)
{
}
bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
{
bool bRet = false;
PCORE_TEMP_SHARED_DATA pSharedData;
HANDLE hdlMemory;
HANDLE hdlMutex;
hdlMutex = CreateMutex(nullptr,FALSE,CORE_TEMP_MUTEX_OBJECT);
if (hdlMutex == nullptr)
{
return false;
}
WaitForSingleObject(hdlMutex, INFINITE);
hdlMemory = OpenFileMapping(
FILE_MAP_READ, // Read only permission.
TRUE,
CORE_TEMP_MAPPING_OBJECT); // "CoreTempMappingObject"
if (hdlMemory == nullptr)
{
ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex);
return false;
}
pSharedData = (PCORE_TEMP_SHARED_DATA)MapViewOfFile(hdlMemory, FILE_MAP_READ, 0, 0, 0);
if (pSharedData == nullptr)
{
CloseHandle(hdlMemory);
hdlMemory = nullptr;
ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex);
return false;
}
__try
{
memcpy_s(i_SharedData, sizeof(core_temp_shared_data), pSharedData, sizeof(core_temp_shared_data));
bRet = true;
}
__except(1)
{
bRet = false;
SetLastError(0x20000000); //Unknown error
}
UnmapViewOfFile(pSharedData);
CloseHandle(hdlMemory);
ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex);
return bRet;
#include <windows.h>
#include "SharedMem.h"
CSharedMemClient::CSharedMemClient(void)
{
}
CSharedMemClient::~CSharedMemClient(void)
{
}
bool CSharedMemClient::ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData)
{
bool bRet = false;
PCORE_TEMP_SHARED_DATA pSharedData;
HANDLE hdlMemory;
HANDLE hdlMutex;
hdlMutex = CreateMutex(nullptr,FALSE,CORE_TEMP_MUTEX_OBJECT);
if (hdlMutex == nullptr)
{
return false;
}
WaitForSingleObject(hdlMutex, INFINITE);
hdlMemory = OpenFileMapping(
FILE_MAP_READ, // Read only permission.
TRUE,
CORE_TEMP_MAPPING_OBJECT); // "CoreTempMappingObject"
if (hdlMemory == nullptr)
{
ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex);
return false;
}
pSharedData = (PCORE_TEMP_SHARED_DATA)MapViewOfFile(hdlMemory, FILE_MAP_READ, 0, 0, 0);
if (pSharedData == nullptr)
{
CloseHandle(hdlMemory);
hdlMemory = nullptr;
ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex);
return false;
}
__try
{
memcpy_s(i_SharedData, sizeof(core_temp_shared_data), pSharedData, sizeof(core_temp_shared_data));
bRet = true;
}
__except(1)
{
bRet = false;
SetLastError(0x20000000); //Unknown error
}
UnmapViewOfFile(pSharedData);
CloseHandle(hdlMemory);
ReleaseMutex(hdlMutex);
CloseHandle(hdlMutex);
return bRet;
}

View File

@ -1,41 +1,41 @@
// Common.h:
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMMON_H__B302F7F1_E8D6_4EF2_9D89_A634D14922BF__INCLUDED_)
#define AFX_COMMON_H__B302F7F1_E8D6_4EF2_9D89_A634D14922BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define CORE_TEMP_MAPPING_OBJECT L"CoreTempMappingObject"
#define CORE_TEMP_MUTEX_OBJECT L"CoreTempMutexObject"
typedef struct core_temp_shared_data
{
unsigned int uiLoad[256];
unsigned int uiTjMax[128];
unsigned int uiCoreCnt;
unsigned int uiCPUCnt;
float fTemp[256];
float fVID;
float fCPUSpeed;
float fFSBSpeed;
float fMultipier;
char sCPUName[100];
unsigned char ucFahrenheit;
unsigned char ucDeltaToTjMax;
}CORE_TEMP_SHARED_DATA,*PCORE_TEMP_SHARED_DATA,**PPCORE_TEMP_SHARED_DATA;
class CSharedMemClient
{
// Construction
public:
CSharedMemClient(void); // standard constructor
virtual ~CSharedMemClient(void);
bool ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData);
};
#endif // !defined(AFX_COMMON_H__B302F7F1_E8D6_4EF2_9D89_A634D14922BF__INCLUDED_)
// Common.h:
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMMON_H__B302F7F1_E8D6_4EF2_9D89_A634D14922BF__INCLUDED_)
#define AFX_COMMON_H__B302F7F1_E8D6_4EF2_9D89_A634D14922BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define CORE_TEMP_MAPPING_OBJECT L"CoreTempMappingObject"
#define CORE_TEMP_MUTEX_OBJECT L"CoreTempMutexObject"
typedef struct core_temp_shared_data
{
unsigned int uiLoad[256];
unsigned int uiTjMax[128];
unsigned int uiCoreCnt;
unsigned int uiCPUCnt;
float fTemp[256];
float fVID;
float fCPUSpeed;
float fFSBSpeed;
float fMultipier;
char sCPUName[100];
unsigned char ucFahrenheit;
unsigned char ucDeltaToTjMax;
}CORE_TEMP_SHARED_DATA,*PCORE_TEMP_SHARED_DATA,**PPCORE_TEMP_SHARED_DATA;
class CSharedMemClient
{
// Construction
public:
CSharedMemClient(void); // standard constructor
virtual ~CSharedMemClient(void);
bool ReadSharedMem(PCORE_TEMP_SHARED_DATA i_SharedData);
};
#endif // !defined(AFX_COMMON_H__B302F7F1_E8D6_4EF2_9D89_A634D14922BF__INCLUDED_)