From b908be7d183dbcbd88acf76af85f836a640d1726 Mon Sep 17 00:00:00 2001 From: ahsouza Date: Sat, 15 Apr 2023 22:06:30 -0300 Subject: [PATCH 1/8] methods header to battery --- include/hwares/scan_battery.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/hwares/scan_battery.h b/include/hwares/scan_battery.h index 57b06e0..8a744ad 100644 --- a/include/hwares/scan_battery.h +++ b/include/hwares/scan_battery.h @@ -38,6 +38,9 @@ namespace bscan { std::string& serialNumber(); std::string& technology(); uint32_t energyFull(); + uint32_t energyNow(); + uint32_t voltage(); + uint32_t estimatedTime(); double capacity(); @@ -46,6 +49,9 @@ namespace bscan { [[nodiscard]] std::string getSerialNumber() const; [[nodiscard]] std::string getTechnology() const; [[nodiscard]] uint32_t getEnergyFull() const; + [[nodiscard]] uint32_t getEnergyNow() const; + [[nodiscard]] uint32_t getVoltage() const; + [[nodiscard]] uint32_t getEstimatedTime() const; [[nodiscard]] uint32_t energyNow() const; [[nodiscard]] bool charging() const; @@ -58,6 +64,9 @@ namespace bscan { std::string _serialNumber; std::string _technology; uint32_t _energyFull = 0; + uint32_t _energyNow = 0; + uint32_t _voltage = 0; + uint32_t _estimatedTime = 0; }; std::vector getAllBatteries(); From 652dfc543dd01e0cbdd916faed60df1202a0044d Mon Sep 17 00:00:00 2001 From: ahsouza Date: Sat, 15 Apr 2023 22:08:35 -0300 Subject: [PATCH 2/8] feat: new resources to battery --- src/libs/info/scan_battery.cpp | 21 +++++++++++++++++++++ src/libs/info/windows/scan_battery.cpp | 21 ++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/libs/info/scan_battery.cpp b/src/libs/info/scan_battery.cpp index f220321..8e48f1a 100644 --- a/src/libs/info/scan_battery.cpp +++ b/src/libs/info/scan_battery.cpp @@ -58,6 +58,27 @@ namespace bscan { return _energyFull; } + uint32_t Battery::energyNow() { + if (_energyNow == 0) { + _energyNow = getEnergyNow(); + } + return _energyNow; + } + + uint32_t Battery::voltage() { + if (_voltage == 0) { + _voltage = getVoltage(); + } + return _voltage; + } + + uint32_t Battery::estimatedTime() { + if (_estimatedTime == 0) { + _estimatedTime = getEstimatedTime(); + } + return _estimatedTime; + } + double Battery::capacity() { return static_cast(energyNow()) / energyFull(); } }; \ No newline at end of file diff --git a/src/libs/info/windows/scan_battery.cpp b/src/libs/info/windows/scan_battery.cpp index 4632fe1..8274085 100644 --- a/src/libs/info/windows/scan_battery.cpp +++ b/src/libs/info/windows/scan_battery.cpp @@ -32,7 +32,26 @@ namespace bscan { std::string Battery::getSerialNumber() const { return ""; } std::string Battery::getTechnology() const { return ""; } uint32_t Battery::getEnergyFull() const { return 0; } - uint32_t Battery::energyNow() const { return 0; } + uint32_t Battery::getEnergyNow() const { + std::vector energyNow{}; + wmi::queryWMI("Win32_Battery", "EstimatedChargeRemaining", energyNow); + + return static_cast(energyNow[0]); + } + //volts + uint32_t Battery::getVoltage() const { + std::vector voltage{}; + wmi::queryWMI("Win32_Battery", "DesignVoltage", voltage); + + return static_cast(voltage[0]); + } + //time + uint32_t Battery::getEstimatedTime() const { + std::vector estimatedTime{}; + wmi::queryWMI("Win32_Battery", "EstimatedRunTime", estimatedTime); + + return static_cast(estimatedTime[0]); + } bool Battery::charging() const { return false; } bool Battery::discharging() const { return false; } std::vector getAllBatteries() { From 1111469071a52d0d967efe61f0fee67ad5f8f0a3 Mon Sep 17 00:00:00 2001 From: ahsouza Date: Sun, 16 Apr 2023 00:21:03 -0300 Subject: [PATCH 3/8] update header bios --- include/swares/scan_bios.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/swares/scan_bios.h b/include/swares/scan_bios.h index 03a93ae..2b3b17b 100644 --- a/include/swares/scan_bios.h +++ b/include/swares/scan_bios.h @@ -37,6 +37,9 @@ namespace bscan { const std::string& sku, const std::string& breachDescription, const std::string& version, + const std::string& smbiosVersion, + const std::string& buildNumber, + const std::string& currentLanguage, bool poweredOn, bool hotSwappable, bool removable, @@ -44,6 +47,8 @@ namespace bscan { bool audibleAlarm, bool lockPresent, bool visibleAlarm, + int64_t biosMajorVersion, + int64_t biosMinorVersion, int64_t securityBreach, int64_t heatGeneration, int64_t numberOfPowerCords); @@ -59,6 +64,9 @@ namespace bscan { std::string& sku(); std::string& breachDescription(); std::string& version(); + std::string& smbiosVersion(); + std::string& buildNumber(); + std::string& currentLanguage(); bool poweredOn(); bool hotSwappable(); bool removable(); @@ -66,6 +74,8 @@ namespace bscan { bool audibleAlarm(); bool lockPresent(); bool visibleAlarm(); + int64_t biosMajorVersion(); + int64_t biosMinorVersion(); int64_t securityBreach(); int64_t heatGeneration(); int64_t numberOfPowerCords(); @@ -80,6 +90,9 @@ namespace bscan { static std::string getSku(); static std::string getBreachDescription(); static std::string getVersion(); + static std::string getSMBIOSVersion(); + static std::string getBuildNumber(); + static std::string getCurrentLanguage(); static bool getPoweredOn(); static bool getHotSwappable(); static bool getRemovable(); @@ -87,6 +100,8 @@ namespace bscan { static bool getAudibleAlarm(); static bool getLockPresent(); static bool getVisibleAlarm(); + static int64_t getBiosMajorVersion(); + static int64_t getBiosMinorVersion(); static int64_t getSecurityBreach(); static int64_t getHeatGeneration(); static int64_t getNumberOfPowerCords(); @@ -102,6 +117,9 @@ namespace bscan { std::string& _sku; std::string& _breachDescription; std::string& _version; + std::string& _smbiosVersion; + std::string& _buildNumber; + std::string& _currentLanguage; bool _poweredOn; bool _hotSwappable; bool _removable; @@ -109,6 +127,8 @@ namespace bscan { bool _audibleAlarm; bool _lockPresent; bool _visibleAlarm; + int64_t _biosMajorVersion = -1; + int64_t _biosMinorVersion = -1; int64_t _securityBreach = -1; int64_t _heatGeneration = -1; int64_t _numberOfPowerCords = -1; From 6228ff4d7e99d04437fb7ef28362b641e475fee1 Mon Sep 17 00:00:00 2001 From: ahsouza Date: Sun, 16 Apr 2023 00:21:35 -0300 Subject: [PATCH 4/8] feat: new resources to bios --- src/libs/info/scan_bios.cpp | 44 ++++++++++++++++++++++++++-- src/libs/info/windows/scan_bios.cpp | 45 +++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/src/libs/info/scan_bios.cpp b/src/libs/info/scan_bios.cpp index f2afab8..7fbd78f 100644 --- a/src/libs/info/scan_bios.cpp +++ b/src/libs/info/scan_bios.cpp @@ -34,7 +34,7 @@ using namespace std; namespace bscan { - BIOS::BIOS(const string& description, const std::string& name, const std::string& status, const std::string& manufacturer, const std::string& otherIdentifyingInfo, const std::string& partNumber, const std::string& serialNumber, const std::string& sku, const std::string& breachDescription, const std::string& version, bool poweredOn, bool hotSwappable, bool removable, bool replaceable, bool audibleAlarm, bool lockPresent, bool visibleAlarm, int64_t securityBreach, int64_t heatGeneration, int64_t numberOfPowerCords) + BIOS::BIOS(const string& description, const std::string& name, const std::string& status, const std::string& manufacturer, const std::string& otherIdentifyingInfo, const std::string& partNumber, const std::string& serialNumber, const std::string& sku, const std::string& breachDescription, const std::string& version, const std::string& smbiosVersion, const std::string& buildNumber, const std::string& currentLanguage, bool poweredOn, bool hotSwappable, bool removable, bool replaceable, bool audibleAlarm, bool lockPresent, bool visibleAlarm, int64_t securityBreach, int64_t heatGeneration, int64_t biosMajorVersion, int64_t biosMinorVersion, int64_t numberOfPowerCords) : _description(_description), _name(_name), _status(_status), @@ -44,7 +44,10 @@ namespace bscan { _serialNumber(_serialNumber), _sku(_sku), _breachDescription(_breachDescription), - _version(_version) { + _version(_version), + _smbiosVersion(_smbiosVersion), + _buildNumber(_buildNumber), + _currentLanguage(_currentLanguage) { _poweredOn = poweredOn, _hotSwappable = hotSwappable, _removable = removable, @@ -53,6 +56,8 @@ namespace bscan { _lockPresent = lockPresent, _visibleAlarm = visibleAlarm, _securityBreach = securityBreach, + _biosMajorVersion = biosMajorVersion, + _biosMinorVersion = biosMinorVersion, _heatGeneration = heatGeneration, _numberOfPowerCords = numberOfPowerCords; } @@ -127,6 +132,27 @@ namespace bscan { return _version; } + std::string& BIOS::smbiosVersion() { + if (_smbiosVersion.empty()) { + _smbiosVersion = getSMBIOSVersion(); + } + return _smbiosVersion; + } + + std::string& BIOS::buildNumber() { + if (_buildNumber.empty()) { + _buildNumber = getBuildNumber(); + } + return _buildNumber; + } + + std::string& BIOS::currentLanguage() { + if (_currentLanguage.empty()) { + _currentLanguage = getCurrentLanguage(); + } + return _currentLanguage; + } + bool BIOS::poweredOn() { _poweredOn = getPoweredOn(); return _poweredOn; @@ -162,6 +188,20 @@ namespace bscan { return _visibleAlarm; } + int64_t BIOS::biosMajorVersion() { + if (_biosMajorVersion == -1) { + _biosMajorVersion = getBiosMajorVersion(); + } + return _biosMajorVersion; + } + + int64_t BIOS::biosMinorVersion() { + if (_biosMinorVersion == -1) { + _biosMinorVersion = getBiosMinorVersion(); + } + return _biosMinorVersion; + } + int64_t BIOS::securityBreach() { if (_securityBreach == -1) { _securityBreach = getSecurityBreach(); diff --git a/src/libs/info/windows/scan_bios.cpp b/src/libs/info/windows/scan_bios.cpp index 3feb89b..3629a02 100644 --- a/src/libs/info/windows/scan_bios.cpp +++ b/src/libs/info/windows/scan_bios.cpp @@ -137,6 +137,39 @@ namespace bscan { return {tmp.begin(), tmp.end()}; } + std::string BIOS::getSMBIOSVersion() { + std::vector smbiosVersion{}; + wmi::queryWMI("Win32_BIOS", "SMBIOSBIOSVersion", smbiosVersion); + auto ret = smbiosVersion[0]; + if (!ret) { + return ""; + } + std::wstring tmp(ret); + return {tmp.begin(), tmp.end()}; + } + + std::string BIOS::getBuildNumber() { + std::vector buildNumber{}; + wmi::queryWMI("Win32_BIOS", "BuildNumber", buildNumber); + auto ret = buildNumber[0]; + if (!ret) { + return ""; + } + std::wstring tmp(ret); + return {tmp.begin(), tmp.end()}; + } + + std::string BIOS::getCurrentLanguage() { + std::vector currentLanguage{}; + wmi::queryWMI("Win32_BIOS", "CurrentLanguage", currentLanguage); + auto ret = currentLanguage[0]; + if (!ret) { + return ""; + } + std::wstring tmp(ret); + return {tmp.begin(), tmp.end()}; + } + bool BIOS::getPoweredOn() { std::vector poweredOn{}; wmi::queryWMI("CIM_Chassis", "PoweredOn", poweredOn); @@ -179,6 +212,18 @@ namespace bscan { return static_cast(visibleAlarm[0] * 2); }; + int64_t BIOS::getBiosMajorVersion() { + std::vector biosMajorVersion{}; + wmi::queryWMI("Win32_BIOS", "SMBIOSMajorVersion", biosMajorVersion); + return static_cast(biosMajorVersion[0] * 2); + } + + int64_t BIOS::getBiosMinorVersion() { + std::vector biosMinorVersion{}; + wmi::queryWMI("Win32_BIOS", "SMBIOSMinorVersion", biosMinorVersion); + return static_cast(biosMinorVersion[0] * 2); + } + int64_t BIOS::getSecurityBreach() { std::vector securityBreach{}; wmi::queryWMI("CIM_Chassis", "SecurityBreach", securityBreach); From 0e32306d6dacaf77c4842269e95cc05c963522a1 Mon Sep 17 00:00:00 2001 From: ahsouza Date: Tue, 18 Apr 2023 10:44:56 -0300 Subject: [PATCH 5/8] update swares --- include/swares/swares.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/swares/swares.h b/include/swares/swares.h index 578a346..bbb9d0e 100644 --- a/include/swares/swares.h +++ b/include/swares/swares.h @@ -20,6 +20,7 @@ #pragma once #include "swares/scan_system.h" +#include "swares/scan_bios.h" #include "swares/scan_os.h" #include "swares/scan_browser.h" #include "swares/scan_datasource.h" From 93cbfadd1bfd0c92081037121e914edf87300886 Mon Sep 17 00:00:00 2001 From: ahsouza Date: Tue, 18 Apr 2023 10:45:17 -0300 Subject: [PATCH 6/8] feat: header methods to scan net --- include/hwares/scan_net.h | 75 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 include/hwares/scan_net.h diff --git a/include/hwares/scan_net.h b/include/hwares/scan_net.h new file mode 100644 index 0000000..bc96a37 --- /dev/null +++ b/include/hwares/scan_net.h @@ -0,0 +1,75 @@ +/************************************************************************************ + + * Copyright (C) 2021 - 2023, Barca, Inc. + + * Email: GitHub: @BarcaWebCloud. + * Project: BSCAN to scanner MotherBoards. CPU, Memory Ram, SO and more + + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://project-barca.github.io/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + **************************************************************************************/ +#pragma once + +#include +#include + +namespace bscan { + +class Net { + friend std::vector getAllNets(); + + public: + Net( + std::string& name, + std::string& manufacturer, + std::string& permanentAddress, + std::string& dnsHostname, + std::string& serviceName, + std::string& driverPath, + std::string& status, + std::string& macAddress, + std::string& ipAddress, + std::string& subnet, + std::string& gateway + ); + ~Net() = default; + + [[nodiscard]] const std::string& name() const; + [[nodiscard]] const std::string& manufacturer() const; + [[nodiscard]] const std::string& permanentAddress() const; + [[nodiscard]] const std::string& dnsHostname() const; + [[nodiscard]] const std::string& serviceName() const; + [[nodiscard]] const std::string& driverPath() const; + [[nodiscard]] const std::string& status() const; + [[nodiscard]] const std::string& macAddress() const; + [[nodiscard]] const std::string& ipAddress() const; + [[nodiscard]] const std::string& subnet() const; + [[nodiscard]] const std::string& gateway() const; + + private: + Net() = default; + std::string _name; + std::string _manufacturer; + std::string _permanentAddress; + std::string _dnsHostname; + std::string _serviceName; + std::string _driverPath; + std::string _status; + std::string _macAddress; + std::string _ipAddress; + std::string _subnet; + std::string _gateway; +}; + +std::vector getAllNets(); + +}; \ No newline at end of file From f2494291319db7cb66fc3df50591820a914001b0 Mon Sep 17 00:00:00 2001 From: ahsouza Date: Tue, 18 Apr 2023 10:46:30 -0300 Subject: [PATCH 7/8] feat: new resources to scan networks on widows system --- include/hwares/hwares.h | 1 + src/libs/info/scan_net.cpp | 63 +++++++++ src/libs/info/windows/scan_net.cpp | 199 +++++++++++++++++++++++++++++ 3 files changed, 263 insertions(+) create mode 100644 src/libs/info/scan_net.cpp create mode 100644 src/libs/info/windows/scan_net.cpp diff --git a/include/hwares/hwares.h b/include/hwares/hwares.h index c68609e..d65c30e 100644 --- a/include/hwares/hwares.h +++ b/include/hwares/hwares.h @@ -26,3 +26,4 @@ #include "hwares/scan_mainboard.h" #include "hwares/scan_ram.h" #include "hwares/scan_network.h" +#include "hwares/scan_net.h" diff --git a/src/libs/info/scan_net.cpp b/src/libs/info/scan_net.cpp new file mode 100644 index 0000000..c709887 --- /dev/null +++ b/src/libs/info/scan_net.cpp @@ -0,0 +1,63 @@ +/************************************************************************************ + + * Copyright (C) 2021 - 2023, Barca, Inc. + + * Email: GitHub: @BarcaWebCloud. + * Project: BSCAN to scanner MotherBoards. CPU, Memory Ram, SO and more + + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://project-barca.github.io/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + **************************************************************************************/ +#include "hwares/scan_net.h" +#include "utils/stringutils.h" + +namespace bscan { + + Net::Net( + std::string& name, + std::string& manufacturer, + std::string& permanentAddress, + std::string& dnsHostname, + std::string& serviceName, + std::string& driverPath, + std::string& status, + std::string& macAddress, + std::string& ipAddress, + std::string& subnet, + std::string& gateway + + ) + : _name(name), + _manufacturer(manufacturer), + _permanentAddress(permanentAddress), + _dnsHostname(dnsHostname), + _serviceName(serviceName), + _driverPath(driverPath), + _status(status), + _macAddress(macAddress), + _ipAddress(ipAddress), + _subnet(subnet), + _gateway(gateway) + {} + const std::string& Net::name() const { return _name; } + const std::string& Net::manufacturer() const { return _manufacturer; } + const std::string& Net::permanentAddress() const { return _permanentAddress; } + const std::string& Net::dnsHostname() const { return _dnsHostname; } + const std::string& Net::serviceName() const { return _serviceName; } + const std::string& Net::driverPath() const { return _driverPath; } + const std::string& Net::status() const { return _status; } + const std::string& Net::macAddress() const { return _macAddress; } + const std::string& Net::ipAddress() const { return _ipAddress; } + const std::string& Net::subnet() const { return _subnet; } + const std::string& Net::gateway() const { return _gateway; } + +}; diff --git a/src/libs/info/windows/scan_net.cpp b/src/libs/info/windows/scan_net.cpp new file mode 100644 index 0000000..7c6b669 --- /dev/null +++ b/src/libs/info/windows/scan_net.cpp @@ -0,0 +1,199 @@ +/************************************************************************************ + + * Copyright (C) 2021 - 2023, Barca, Inc. + + * Email: GitHub: @BarcaWebCloud. + * Project: BSCAN to scanner MotherBoards. CPU, Memory Ram, SO and more + + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at https://project-barca.github.io/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + **************************************************************************************/ +#include "platform.h" +#ifdef BSCAN_WINDOWS +#include +#include "WMIwrapper.h" +#include "hwares/scan_net.h" +#include "utils/stringutils.h" + +#include + +#include + +#include +#pragma comment(lib,"wbemuuid") +#include +using namespace std; + +namespace bscan { + +char* BSTRtoChar(BSTR String) { + int n, i; + char* FinalChar; + n = SysStringLen(String); // length of input + FinalChar = (char*) malloc(n+1); + for (i = 0; i < n; i++) + { + FinalChar[i] = (char) String[i]; + } + FinalChar[i] = 0; + return FinalChar; +} +std::vector getAllNets() { + std::vector nets; + std::vector res{}; + + int n, i; + char* mychar; + string net_name; + string net_gateway; + string net_ipaddress; + string net_subnet; + string net_mac; + string net_dns; + string net_db_path; + string net_service_name; + + CoInitializeEx(0, 0); + CoInitializeSecurity(0, -1, 0, 0, 0, 3, 0, 0, 0); + IWbemLocator *locator = 0; + CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (void **)&locator); + IWbemServices * services = 0; + wchar_t *name = L"root\\cimv2"; + if (SUCCEEDED(locator->ConnectServer(name, 0, 0, 0, 0, 0, 0, &services))){ + // get system information + CoSetProxyBlanket(services, 10, 0, 0, 3, 3, 0, 0); + wchar_t *language = L"WQL"; + wchar_t *query = L"SELECT * from Win32_NetworkAdapterConfiguration where IPEnabled ='TRUE'"; + IEnumWbemClassObject *e = 0; + if (SUCCEEDED(services->ExecQuery(language, query, WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, 0, &e))){ + + IWbemClassObject *object = 0; + ULONG u = 0; + // lets enumerate all data from this table + while (e){ + e->Next(WBEM_INFINITE, 1, &object, &u); + if (!u) break;//no more data,end enumeration + VARIANT data; + // network adapter name + if (SUCCEEDED(object->Get(L"Caption", 0, &data, 0, 0))){ + if (V_VT(&data) == VT_BSTR) + // convert BSTR to CHAR + n = SysStringLen(data.bstrVal); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(data.bstrVal); + // split char + std::string delimiter = "] "; + std::vector val = split(mychar, delimiter); + net_name = val[1].c_str(); + + nets.push_back(Net()); + nets.back()._name = net_name; + } + // default gateway (Router) + if (SUCCEEDED(object->Get(L"DefaultIPGateway", 0, &data, 0, 0))) { + //VT_ARRAY|VT_BSTR = 8200 + SAFEARRAY *safe = NULL; + safe = V_ARRAY(&data); + BSTR element; + long i = 0; + SafeArrayGetElement(safe, &i, (void*)&element); + // convert BSTR to CHAR + n = SysStringLen(element); + mychar = (char*) malloc(n+1); + + mychar=BSTRtoChar(element); + net_gateway = mychar; + + nets.back()._gateway = net_gateway; + + } + // ip address + if (SUCCEEDED(object->Get(L"IpAddress", 0, &data, 0, 0))){ + //Or if you don't want to use the SAFEARRAY method :)) + // convert BSTR to CHAR + n = SysStringLen(((BSTR*)(data.parray->pvData))[0]); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(((BSTR*)(data.parray->pvData))[0]); + + net_ipaddress = mychar; + nets.back()._ipAddress = net_ipaddress; + } + // subnet + if (SUCCEEDED(object->Get(L"IPSubnet", 0, &data, 0, 0))){ + // convert BSTR to CHAR + n = SysStringLen(((BSTR*)(data.parray->pvData))[0]); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(((BSTR*)(data.parray->pvData))[0]); + + net_subnet = mychar; + nets.back()._subnet = net_subnet; + } + // MAC address + if (SUCCEEDED(object->Get(L"MACAddress", 0, &data, 0, 0))){ + // convert BSTR to CHAR + n = SysStringLen(data.bstrVal); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(data.bstrVal); + net_mac = mychar; + + cout << "MAC: " << net_mac << endl; + nets.back()._macAddress = net_mac; + } + //DNS HostName + if (SUCCEEDED(object->Get(L"DNSHostName", 0, &data, 0, 0))){ + // convert BSTR to CHAR + n = SysStringLen(data.bstrVal); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(data.bstrVal); + net_dns = mychar; + + nets.back()._dnsHostname = net_dns; + } + // db Path + if (SUCCEEDED(object->Get(L"DatabasePath", 0, &data, 0, 0))){ + // convert BSTR to CHAR + n = SysStringLen(data.bstrVal); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(data.bstrVal); + net_db_path = mychar; + + nets.back()._driverPath = net_db_path; + } + // service name + if (SUCCEEDED(object->Get(L"ServiceName", 0, &data, 0, 0))){ + // convert BSTR to CHAR + n = SysStringLen(data.bstrVal); + mychar = (char*) malloc(n+1); + mychar=BSTRtoChar(data.bstrVal); + net_service_name = mychar; + + nets.back()._serviceName = net_service_name; + } + VariantClear(&data); + } + } + else + printf("error executing query!\n"); + } + else + printf("connection error!\n"); + + services->Release(); + locator->Release(); + CoUninitialize(); + + return nets; +} + +}; + +#endif // END BSCAN_WINDOWS From 9b759a9fddd3c00354c4952c92b193e15dee4bca Mon Sep 17 00:00:00 2001 From: ahsouza Date: Tue, 18 Apr 2023 10:53:42 -0300 Subject: [PATCH 8/8] up v0.2.3 --- CHANGELOG.md | 19 ++++++++++++++++++- CMakeLists.txt | 4 ++-- README.md | 2 +- package.json | 2 +- src/libs/info/CMakeLists.txt | 6 ++++-- 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9384c6..f05405a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ # Changelog -## v0.2.2-BETA +## v0.2.3-BETA ### BScan @@ -10,6 +10,23 @@ This is the latest version introduces the use of the module and its features.
+## v0.2.3 [2023-04-18] + +### Features + +- [#30](https://github.com/BarcaWebCloud/bscan/pull/30): New features for windows. Gratitude @ahsouza! + + +### Release Notes + +Add features for **Windows** platform: + + +- **Get Information All About Network Adapter** [only Windows on moment] +- **Get IP Address, MAC Address, Subnet, Gateway, DNS Hostname and more** [only Windows on moment] + +
+ ## v0.2.2 [2023-04-15] ### Features diff --git a/CMakeLists.txt b/CMakeLists.txt index 31dd50d..d355dd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ # Barca, Inc., Vitória/ES, BRA | email: opensource@barca.com | GitHub: @BarcaWebCloud cmake_minimum_required(VERSION 3.16) -project(bscan VERSION 0.2.2 DESCRIPTION "A library for collecting information about a computing device's Hardware & Software" HOMEPAGE_URL "https://store.barca.com/overview/modules/bscan" LANGUAGES CXX C) +project(bscan VERSION 0.2.3 DESCRIPTION "A library for collecting information about a computing device's Hardware & Software" HOMEPAGE_URL "https://store.barca.com/overview/modules/bscan" LANGUAGES CXX C) message(STATUS "cmake version ${CMAKE_VERSION}\n\nproject: ${PROJECT_NAME}\nversion: ${PROJECT_VERSION}\ndescription: ${PROJECT_DESCRIPTION}\n${PROJECT_NAME}-api: https://api.bwc-${PROJECT_NAME}.com/v${PROJECT_VERSION_MAJOR}/") @@ -266,7 +266,7 @@ find_path(_check_include "hwares/scan_gpu.h", "hwares/scan_mainboard.h", "hwares/scan_monitor.h", - "hwares/scan_network.h", + "hwares/scan_net.h", "hwares/scan_ram.h", # softwares header "swares/swares.h", diff --git a/README.md b/README.md index e7a97d1..339b942 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# BSCAN v0.2.2-beta +# BSCAN v0.2.3-beta **BSCAN** is a library cross-platform that provides information about the **hardwares** and **softwares** where to have a computing device & **atmospheric environment**. Enabling developers to utilize digitization capabilities in their Web and mobile applications with their preferred languages ​​such as: *Python, JavaScript/TypeScript, JAVA, Ruby, PHP, GO, Rust* and more. diff --git a/package.json b/package.json index db3b227..9dcbe58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bscan", - "version": "0.2.2", + "version": "0.2.3", "description": " Library Cross-Platform that provides information about the Hardwares and Software of a Computing Device & Atmospheric Environment for NodeJS", "keywords": [ "nodejs", diff --git a/src/libs/info/CMakeLists.txt b/src/libs/info/CMakeLists.txt index 7606227..ef274dc 100644 --- a/src/libs/info/CMakeLists.txt +++ b/src/libs/info/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(BScan scan_temperature.cpp scan_bios.cpp scan_disk.cpp + scan_net.cpp scan_browser.cpp scan_datasource.cpp # apple OS @@ -25,7 +26,7 @@ add_library(BScan linux/scan_ram.cpp linux/scan_os.cpp linux/scan_mainboard.cpp - linux/scan_network.cpp + linux/scan_net.cpp linux/scan_disk.cpp # windows OS windows/scan_battery.cpp @@ -36,9 +37,10 @@ add_library(BScan windows/scan_bios.cpp windows/scan_os.cpp windows/scan_mainboard.cpp - windows/scan_network.cpp + windows/scan_net.cpp windows/scan_disk.cpp windows/scan_browser.cpp + windows/scan_net.cpp windows/scan_datasource.cpp )