
Shared Memory
Introduction:
An application with a Shared Memory block allows all running processes on the system to have access to a part of it's memory.
It is often used to enable third party software to use information that is not easily obtained via code.
There is usually no dependency between the two processes and each one is completely independent. One process simply
harnesses the shared information of the other for its own uses, like visual display, monitoring and logging.
Shared memory implementation in Core Temp:
Core Temp shares the following structure:
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;
unsigned int is a 32bit unsigned integer.
unsigned char is 8bit (1 byte) in size.
ucFahrenheit and ucDeltaToTjMax represent boolean values. 0 = false, 1 = true.
If ucFahrenheit is set, the temperature is reported in Fahrenheit.
If ucDeltaToTjMax is set, the temperature reported respresents the distance from TjMax.
Core Temp's shared area is named: "CoreTempMappingObject".
C++ Dynamic Link Library:
This DLL was written in C++, and it can be easily used with most programming languages.
There is only a single function. Here is the internal function declaration:
bool __declspec(dllimport) fnGetCoreTempInfo(CORE_TEMP_SHARED_DATA *&pData);
You can declare it in your program in the following manner:
typedef bool (*fnGetCoreTempInfo)(CORE_TEMP_SHARED_DATA *&pData);
fnGetCoreTempInfo GetCoreTempInfo;
For compatibility with some programming languages a function was added.
It uses Win32 API calling convention and is declared as follows:
bool WINAPI fnGetCoreTempInfoAlt(CORE_TEMP_SHARED_DATA *pData);
typedef bool (*fnGetCoreTempInfoAlt)(CORE_TEMP_SHARED_DATA *pData);
fnGetCoreTempInfoAlt GetCoreTempInfo;
Usage:
-
Declare a pointer to CORE_TEMP_SHARED_DATA structure and allocate it.
It is also recommended
to fill the allocated memory with NULL to avoid possible problems.
-
Call the function using the pointer to CORE_TEMP_SHARED_DATA structure as an argument.
The function will fill the structure if the shared memory was successfully read.
-
The function returns 'true' if succeeded and 'false' if it failed. You can use GetLastError() in case
the function fails.
-
In case the function fails due to an exception GetLastError() returns UNKNOWN_EXCEPTION (0x20000000)
The DLL now comes in both x86 and x64 versions.
Download C++ DLL only
Download C++ demo project
.NET Framework 2.0 Dynamic Link Library:
This DLL was written in C# with the project set to .NET Framework 2.0.
The namespace is "GetCoreTempInfoNET".
Class name is "CoreTempInfo".
Usage:
-
Create an instance of "CoreTempInfo" class.
-
It is a good idea to sign up for the ReportError event, fired whenever an error occurs, containing an error code and
the error message.
-
The function returns 'true' if succeeded and 'false' if it failed. You can use GetLastError property in case
the function fails. The return value is of enum type "ErrorCodes".
-
In case the function fails due to an exception GetLastError returns Data_Retrieve_Failed (0x0).
-
You can use the GetErrorMessage() function to retrieve a string containing a textual error message.
Download .NET Framework 2.0 DLL only
Download .NET Framework 2.0 demo project
Delphi Library:
Developed and contributed by Michal Kokorceny from http://74.cz/.
Use this library to gain access to Core Temp's shared memory easily.
Download Delphi PAS file only
Download Delphi demo project
|