mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- Added the function that measures the CPU usage for multi core/processors.
For instance: [MeasureCPU] Measure=CPU [MeasureCPU1] Measure=CPU Processor=1 [MeasureCPU2] Measure=CPU Processor=2 MeasureCPU returns the average of the CPU usage across all core/processors. This is same as Processor=0. MeasureCPU1/2 returns the CPU usage of each core/processor. ----- - Fixed the problem that the correct value is not returned if the Interface=0 in NetIn/NetOut/NetTotal measure. The cause of this problem is because the value of all filter devices is summed in Vista or newer. ----- - Added the option (Debug) for debug logging. This must be put under [Rainmeter]-section in Rainmeter.ini. This option specifies whether extra debugging log from Rainmeter.dll is output to Rainmeter.log. [Rainmeter] Debug=1 Default is 0. ----- - Application: Fixed a wrong return value type from MainWndProc.
This commit is contained in:
@ -22,6 +22,142 @@
|
||||
#include "Measure.h"
|
||||
#include <Iphlpapi.h>
|
||||
|
||||
//
|
||||
// Medium the Ndis Driver is running on (OID_GEN_MEDIA_SUPPORTED/ OID_GEN_MEDIA_IN_USE).
|
||||
//
|
||||
typedef enum _NDIS_MEDIUM
|
||||
{
|
||||
NdisMedium802_3,
|
||||
NdisMedium802_5,
|
||||
NdisMediumFddi,
|
||||
NdisMediumWan,
|
||||
NdisMediumLocalTalk,
|
||||
NdisMediumDix, // defined for convenience, not a real medium
|
||||
NdisMediumArcnetRaw,
|
||||
NdisMediumArcnet878_2,
|
||||
NdisMediumAtm,
|
||||
NdisMediumWirelessWan,
|
||||
NdisMediumIrda,
|
||||
NdisMediumBpc,
|
||||
NdisMediumCoWan,
|
||||
NdisMedium1394,
|
||||
NdisMediumInfiniBand,
|
||||
#if ((NTDDI_VERSION >= NTDDI_LONGHORN) || NDIS_SUPPORT_NDIS6)
|
||||
NdisMediumTunnel,
|
||||
NdisMediumNative802_11,
|
||||
NdisMediumLoopback,
|
||||
#endif // (NTDDI_VERSION >= NTDDI_LONGHORN)
|
||||
NdisMediumMax // Not a real medium, defined as an upper-bound
|
||||
} NDIS_MEDIUM, *PNDIS_MEDIUM;
|
||||
|
||||
//
|
||||
// Physical Medium Type definitions. Used with OID_GEN_PHYSICAL_MEDIUM.
|
||||
//
|
||||
typedef enum _NDIS_PHYSICAL_MEDIUM
|
||||
{
|
||||
NdisPhysicalMediumUnspecified,
|
||||
NdisPhysicalMediumWirelessLan,
|
||||
NdisPhysicalMediumCableModem,
|
||||
NdisPhysicalMediumPhoneLine,
|
||||
NdisPhysicalMediumPowerLine,
|
||||
NdisPhysicalMediumDSL, // includes ADSL and UADSL (G.Lite)
|
||||
NdisPhysicalMediumFibreChannel,
|
||||
NdisPhysicalMedium1394,
|
||||
NdisPhysicalMediumWirelessWan,
|
||||
NdisPhysicalMediumNative802_11,
|
||||
NdisPhysicalMediumBluetooth,
|
||||
NdisPhysicalMediumInfiniband,
|
||||
NdisPhysicalMediumWiMax,
|
||||
NdisPhysicalMediumUWB,
|
||||
NdisPhysicalMedium802_3,
|
||||
NdisPhysicalMedium802_5,
|
||||
NdisPhysicalMediumIrda,
|
||||
NdisPhysicalMediumWiredWAN,
|
||||
NdisPhysicalMediumWiredCoWan,
|
||||
NdisPhysicalMediumOther,
|
||||
NdisPhysicalMediumMax // Not a real physical type, defined as an upper-bound
|
||||
} NDIS_PHYSICAL_MEDIUM, *PNDIS_PHYSICAL_MEDIUM;
|
||||
|
||||
typedef struct _MIB_IF_ROW2 {
|
||||
//
|
||||
// Key structure. Sorted by preference.
|
||||
//
|
||||
NET_LUID InterfaceLuid;
|
||||
NET_IFINDEX InterfaceIndex;
|
||||
|
||||
//
|
||||
// Read-Only fields.
|
||||
//
|
||||
GUID InterfaceGuid;
|
||||
WCHAR Alias[IF_MAX_STRING_SIZE + 1];
|
||||
WCHAR Description[IF_MAX_STRING_SIZE + 1];
|
||||
ULONG PhysicalAddressLength;
|
||||
UCHAR PhysicalAddress[IF_MAX_PHYS_ADDRESS_LENGTH];
|
||||
UCHAR PermanentPhysicalAddress[IF_MAX_PHYS_ADDRESS_LENGTH];
|
||||
|
||||
ULONG Mtu;
|
||||
IFTYPE Type; // Interface Type.
|
||||
TUNNEL_TYPE TunnelType; // Tunnel Type, if Type = IF_TUNNEL.
|
||||
NDIS_MEDIUM MediaType;
|
||||
NDIS_PHYSICAL_MEDIUM PhysicalMediumType;
|
||||
NET_IF_ACCESS_TYPE AccessType;
|
||||
NET_IF_DIRECTION_TYPE DirectionType;
|
||||
struct {
|
||||
BOOLEAN HardwareInterface : 1;
|
||||
BOOLEAN FilterInterface : 1;
|
||||
BOOLEAN ConnectorPresent : 1;
|
||||
BOOLEAN NotAuthenticated : 1;
|
||||
BOOLEAN NotMediaConnected : 1;
|
||||
BOOLEAN Paused : 1;
|
||||
BOOLEAN LowPower : 1;
|
||||
BOOLEAN EndPointInterface : 1;
|
||||
} InterfaceAndOperStatusFlags;
|
||||
|
||||
IF_OPER_STATUS OperStatus;
|
||||
NET_IF_ADMIN_STATUS AdminStatus;
|
||||
NET_IF_MEDIA_CONNECT_STATE MediaConnectState;
|
||||
NET_IF_NETWORK_GUID NetworkGuid;
|
||||
NET_IF_CONNECTION_TYPE ConnectionType;
|
||||
|
||||
//
|
||||
// Statistics.
|
||||
//
|
||||
ULONG64 TransmitLinkSpeed;
|
||||
ULONG64 ReceiveLinkSpeed;
|
||||
|
||||
ULONG64 InOctets;
|
||||
ULONG64 InUcastPkts;
|
||||
ULONG64 InNUcastPkts;
|
||||
ULONG64 InDiscards;
|
||||
ULONG64 InErrors;
|
||||
ULONG64 InUnknownProtos;
|
||||
ULONG64 InUcastOctets;
|
||||
ULONG64 InMulticastOctets;
|
||||
ULONG64 InBroadcastOctets;
|
||||
ULONG64 OutOctets;
|
||||
ULONG64 OutUcastPkts;
|
||||
ULONG64 OutNUcastPkts;
|
||||
ULONG64 OutDiscards;
|
||||
ULONG64 OutErrors;
|
||||
ULONG64 OutUcastOctets;
|
||||
ULONG64 OutMulticastOctets;
|
||||
ULONG64 OutBroadcastOctets;
|
||||
ULONG64 OutQLen;
|
||||
} MIB_IF_ROW2, *PMIB_IF_ROW2;
|
||||
|
||||
typedef struct _MIB_IF_TABLE2 {
|
||||
ULONG NumEntries;
|
||||
MIB_IF_ROW2 Table[ANY_SIZE];
|
||||
} MIB_IF_TABLE2, *PMIB_IF_TABLE2;
|
||||
|
||||
typedef enum _MIB_IF_TABLE_LEVEL {
|
||||
MibIfTableNormal,
|
||||
MibIfTableRaw
|
||||
} MIB_IF_TABLE_LEVEL, *PMIB_IF_TABLE_LEVEL;
|
||||
|
||||
typedef NETIO_STATUS (NETIOAPI_API_ * FPGETIFTABLE2EX)(MIB_IF_TABLE_LEVEL Level, PMIB_IF_TABLE2* Table);
|
||||
typedef VOID (NETIOAPI_API_ * FPFREEMIBTABLE)(PVOID Memory);
|
||||
|
||||
class CMeasureNet : public CMeasure
|
||||
{
|
||||
public:
|
||||
@ -43,10 +179,13 @@ public:
|
||||
static void ReadStats(const std::wstring& iniFile);
|
||||
static void WriteStats(const std::wstring& iniFile);
|
||||
|
||||
static void InitializeNewApi();
|
||||
static void FinalizeNewApi();
|
||||
|
||||
protected:
|
||||
void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net);
|
||||
DWORD GetNetOctets(NET net);
|
||||
LARGE_INTEGER GetNetStatsValue(NET net);
|
||||
ULONG64 GetNetOctets(NET net);
|
||||
ULONG64 GetNetStatsValue(NET net);
|
||||
|
||||
double m_CurrentTraffic;
|
||||
double m_TrafficValue;
|
||||
@ -54,10 +193,15 @@ protected:
|
||||
bool m_Cumulative;
|
||||
std::wstring m_TrafficAction;
|
||||
|
||||
static std::vector<DWORD> c_OldStatValues;
|
||||
static std::vector<LARGE_INTEGER> c_StatValues;
|
||||
static MIB_IFTABLE* c_Table;
|
||||
static std::vector<ULONG64> c_OldStatValues;
|
||||
static std::vector<ULONG64> c_StatValues;
|
||||
static BYTE* c_Table;
|
||||
static UINT c_NumOfTables;
|
||||
|
||||
static HINSTANCE c_IpHlpApiLibrary;
|
||||
static FPGETIFTABLE2EX c_GetIfTable2Ex;
|
||||
static FPFREEMIBTABLE c_FreeMibTable;
|
||||
static bool c_UseNewApi;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user