Skip to content

Commit

Permalink
Merge pull request #76 from CherryPill/issue_75
Browse files Browse the repository at this point in the history
Issue 75
  • Loading branch information
CherryPill authored Jun 22, 2020
2 parents 80bee17 + f9fcb4f commit daf05c3
Show file tree
Hide file tree
Showing 42 changed files with 1,095 additions and 396 deletions.
2 changes: 2 additions & 0 deletions SystemInfo.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.28729.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SystemInfo", "SystemInfo\SystemInfo.vcxproj", "{48DC8C62-89CF-4F86-BFE0-42AA4080A9B8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00560159-1600-41C9-BB56-BE1CE22C58BD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down
Binary file removed SystemInfo/Icons/icon2.ico
Binary file not shown.
Binary file added SystemInfo/Icons/utilization/utilization_0.ico
Binary file not shown.
Binary file added SystemInfo/Icons/utilization/utilization_1.ico
Binary file not shown.
Binary file added SystemInfo/Icons/utilization/utilization_2.ico
Binary file not shown.
Binary file added SystemInfo/Icons/utilization/utilization_3.ico
Binary file not shown.
Binary file added SystemInfo/Icons/utilization/utilization_4.ico
Binary file not shown.
Binary file added SystemInfo/Icons/utilization/utilization_5.ico
Binary file not shown.
Binary file modified SystemInfo/SystemInfo.aps
Binary file not shown.
Binary file modified SystemInfo/SystemInfo.rc
Binary file not shown.
13 changes: 12 additions & 1 deletion SystemInfo/SystemInfo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,17 @@
<ClCompile Include="export\screenCapture.cpp" />
<ClCompile Include="glb\globalVars.cpp" />
<ClCompile Include="import\binImport.cpp" />
<ClCompile Include="logger\logger.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="mainWindowProcedure.cpp" />
<ClCompile Include="meta\SoftwareInfo.cpp" />
<ClCompile Include="network\common\network.cpp" />
<ClCompile Include="network\rest\rest.cpp" />
<ClCompile Include="pugi\pugixml.cpp" />
<ClCompile Include="SMBIOS.cpp" />
<ClCompile Include="util\controlManager.cpp" />
<ClCompile Include="util\utility.cpp" />
<ClCompile Include="WMIWBEMINFO.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="const\appconst.h" />
Expand All @@ -182,6 +185,7 @@
<ClInclude Include="export\screenCapture.h" />
<ClInclude Include="glb\globalVars.h" />
<ClInclude Include="import\binImport.h" />
<ClInclude Include="logger\logger.h" />
<ClInclude Include="mainWindowProcedure.h" />
<ClInclude Include="meta\SoftwareInfo.h" />
<ClInclude Include="network\common\network.h" />
Expand All @@ -190,7 +194,9 @@
<ClInclude Include="pugi\pugixml.hpp" />
<ClInclude Include="resource.h" />
<ClInclude Include="SMBIOS.h" />
<ClInclude Include="util\controlManager.h" />
<ClInclude Include="util\utility.h" />
<ClInclude Include="WMIWBEMINFO.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SystemInfo.rc" />
Expand All @@ -199,7 +205,6 @@
<Image Include="Icons\bios.ico" />
<Image Include="Icons\cpu.ico" />
<Image Include="Icons\GPU.ico" />
<Image Include="icons\icon2.ico" />
<Image Include="Icons\mainIcon.ico" />
<Image Include="Icons\mb.ico" />
<Image Include="Icons\monitor.ico" />
Expand All @@ -210,6 +215,12 @@
<Image Include="Icons\sound.ico" />
<Image Include="Icons\storage.ico" />
<Image Include="Icons\uptime.ico" />
<Image Include="Icons\utilization\utilization_0.ico" />
<Image Include="Icons\utilization\utilization_1.ico" />
<Image Include="Icons\utilization\utilization_2.ico" />
<Image Include="Icons\utilization\utilization_3.ico" />
<Image Include="Icons\utilization\utilization_4.ico" />
<Image Include="Icons\utilization\utilization_5.ico" />
</ItemGroup>
<ItemGroup>
<Manifest Include="SystemInfo.manifest">
Expand Down
42 changes: 39 additions & 3 deletions SystemInfo/SystemInfo.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<Filter Include="util">
<UniqueIdentifier>{6978f6a2-6a74-4303-8e45-40d49674e069}</UniqueIdentifier>
</Filter>
<Filter Include="logger">
<UniqueIdentifier>{d1cbdcf0-8a30-40f3-8555-149fa60d0ab0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand Down Expand Up @@ -99,6 +102,15 @@
<ClCompile Include="dialog\scrUploadDialog.cpp">
<Filter>dialog</Filter>
</ClCompile>
<ClCompile Include="WMIWBEMINFO.cpp">
<Filter>core</Filter>
</ClCompile>
<ClCompile Include="logger\logger.cpp">
<Filter>logger</Filter>
</ClCompile>
<ClCompile Include="util\controlManager.cpp">
<Filter>util</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="mainWindowProcedure.h">
Expand Down Expand Up @@ -161,6 +173,15 @@
<ClInclude Include="dialog\scrUploadDialog.h">
<Filter>dialog</Filter>
</ClInclude>
<ClInclude Include="WMIWBEMINFO.h">
<Filter>core</Filter>
</ClInclude>
<ClInclude Include="logger\logger.h">
<Filter>logger</Filter>
</ClInclude>
<ClInclude Include="util\controlManager.h">
<Filter>util</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="SystemInfo.rc">
Expand Down Expand Up @@ -201,15 +222,30 @@
<Image Include="Icons\uptime.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="icons\icon2.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\bios.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\network.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\utilization\utilization_0.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\utilization\utilization_1.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\utilization\utilization_2.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\utilization\utilization_3.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\utilization\utilization_5.ico">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Icons\utilization\utilization_4.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Manifest Include="SystemInfo.manifest" />
Expand Down
29 changes: 29 additions & 0 deletions SystemInfo/WMIWBEMINFO.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include "WMIWBEMINFO.h"


WMIWBEMINFO* WMIWBEMINFO::currentInstance;

WMIWBEMINFO* WMIWBEMINFO::getWMIWBEMINFOInstance() {
if (currentInstance == nullptr) {
currentInstance = new WMIWBEMINFO();
}
return currentInstance;
}

IWbemLocator* WMIWBEMINFO::getWbemLocator() {
return this->pLoc;
}

IWbemServices* WMIWBEMINFO::getWbemServices() {
return this->pSvc;
}

HRESULT WMIWBEMINFO::getHres() {
return this->hres;
}

WMIWBEMINFO::~WMIWBEMINFO() {
this->pSvc->Release();
this->pLoc->Release();
CoUninitialize();
}
115 changes: 115 additions & 0 deletions SystemInfo/WMIWBEMINFO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#pragma once

#include <Wbemidl.h>
#include <tchar.h>
#include <comdef.h>
#include <exception>
class WMIWBEMINFO
{
private:
static WMIWBEMINFO* currentInstance;
HRESULT hres;
IWbemServices* pSvc;
IWbemLocator* pLoc;
WMIWBEMINFO() {

// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------

hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres)) {
throw std::exception("Failed to initialize COM library");
}

// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------

hres = CoInitializeSecurity(
NULL,
-1, // COM authentication
NULL, // Authentication services
NULL, // Reserved
RPC_C_AUTHN_LEVEL_DEFAULT, // Default authentication
RPC_C_IMP_LEVEL_IMPERSONATE, // Default Impersonation
NULL, // Authentication info
EOAC_NONE, // Additional capabilities
NULL // Reserved
);


if (FAILED(hres)) {
CoUninitialize();
throw std::exception("Failed to initialize COM security levels");
}

//obtain the initial locator to WMI

this->pLoc = NULL;

hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID*)& pLoc);

if (FAILED(hres)) {
CoUninitialize();
throw std::exception("Failed to create IWbemLocator object");
}

// Step 4: -----------------------------------------------------
// Connect to WMI through the IWbemLocator::ConnectServer method

this->pSvc = NULL;

// Connect to the root\cimv2 namespace with
// the current user and obtain pointer pSvc
// to make IWbemServices calls.
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\CIMV2"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (for example, Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);

if (FAILED(hres)) {
pLoc->Release();
CoUninitialize();
throw std::exception("Could not connect to root/cimv2 namespace");
}


// Step 5: --------------------------------------------------
// Set security levels on the proxy -------------------------

hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);

if (FAILED(hres)) {
pSvc->Release();
pLoc->Release();
CoUninitialize();
throw std::exception("Could not set proxy blanket");
}
}

public:
static WMIWBEMINFO* getWMIWBEMINFOInstance();
IWbemLocator *getWbemLocator();
IWbemServices* getWbemServices();
HRESULT getHres();
~WMIWBEMINFO();
};

2 changes: 2 additions & 0 deletions SystemInfo/const/appconst.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
#define ITEM_INFO_HEIGHT 60
#define ITEM_INFO_INITIAL_HEIGTH 15
#define ITEM_ICON_SIZE 16
#define ITEM_UTIL_ICON_RENDER_SIZE_WIDTH 12
#define ITEM_UTIL_ICON_RENDER_SIZE_HEIGHT 14
#define MOUSE_WHEEL_SCROLL 120
#endif
7 changes: 5 additions & 2 deletions SystemInfo/const/itemIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define MONITOR_LABEL 6
#define STORAGE_LABEL 7
#define OPTICAL_LABEL 8
#define AUDIO_LABEL 9
#define NETWORK_LABEL 10
#define NETWORK_LABEL 9
#define AUDIO_LABEL 10
#define UPTIME_LABEL 11
#define BIOS_INFO 12
#define OS_INFO 13
Expand All @@ -28,6 +28,9 @@
#define END_INFO 24

#define AUX_IP_TOGGLE 720
#define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_ICON 820
#define AUX_CPU_INFO_TOTAL_UTILIZATION_PERCENTAGE_STRING 920


#define INFO_ID_OFFSET 12
#define ICON_ID_OFFSET 60
Expand Down
1 change: 1 addition & 0 deletions SystemInfo/core/SystemInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "SystemInfo.h"
#pragma comment (lib,"Gdiplus.lib")
wstring SystemInfo::getCPU() {
return (*this).CPU;
}
Expand Down
1 change: 1 addition & 0 deletions SystemInfo/core/SystemInfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <Windows.h>
#include <gdiplus.h>
#include <iostream>
#include <vector>
#include <string.h>
Expand Down
14 changes: 14 additions & 0 deletions SystemInfo/core/WMIWBEMINFO.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "WMIWBEMINFO.h"



WMIWBEMINFO* WMIWBEMINFO::getWMIWBEMInfoInstance() {
if (!currentInstance) {
currentInstance = new WMIWBEMINFO();
}
return currentInstance;
}

WMIWBEMINFO::~WMIWBEMINFO()
{
}
Loading

0 comments on commit daf05c3

Please sign in to comment.