| | |
| | | endif() |
| | | endif(THREADS_HAVE_PTHREAD_ARG) |
| | | |
| | | #Zlib required when openssl version < 1.0.1f (centos 7) |
| | | #Zlib required with old openssl version < 1.0.1f in centos 7 |
| | | IF(OPENSSL_VERSION VERSION_LESS_EQUAL 1.0.2) |
| | | SET ( ZLIB_USE_STATIC_LIBS ON ) |
| | | find_package(ZLIB REQUIRED) |
| | |
| | | string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") |
| | | SET(Boost_USE_STATIC_RUNTIME ON) |
| | | endif(${STATIC_RUNTIME}) |
| | | |
| | | add_definitions("/D _CRT_SECURE_NO_WARNINGS") |
| | | list(APPEND EXTERNAL_LIBS "bcrypt" "crypt32" "ws2_32" "iphlpapi") |
| | | else(MSVC) |
| | | if(MINGW) |
| | | list(APPEND EXTERNAL_LIBS "-lcrypt32 -lbcrypt -lws2_32 -liphlpapi") |
| | | SET(CMAKE_EXE_LINKER_FLAGS "-static") |
| | | #super ugly bug when cross compiling in cmake 3.16 |
| | | #IF(CMAKE_CROSSCOMPILING) |
| | | # link_directories(BEFORE /usr/lib/gcc/x86_64-w64-mingw32/7.3-win32) |
| | | #ENDIF() |
| | | if(MINGW) |
| | | list(APPEND EXTERNAL_LIBS "-lbcrypt" "-lcrypt32" "-lws2_32" "-liphlpapi") |
| | | SET(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++") |
| | | endif(MINGW) |
| | | endif(MSVC) |
| | | set(main_lib_dest "${PROJECT_NAME}") |
| | |
| | | |
| | | linux cross compile for windows openssl |
| | | |
| | | ./Configure no-zlib no-shared --prefix=$PWD/dist-win-64 --cross-compile-prefix=x86_64-w64-mingw32- mingw64 |
| | | ./Configure no-zlib no-shared --prefix=$PWD/dist-win-64 --cross-compile-prefix=x86_64-w64-mingw32- mingw64 |
| | | /usr/local/bin/cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain-ubuntu-mingw64.cmake -DCMAKE_INSTALL_PREFIX=../../install -DBOOST_ROOT=$PWD/../../boost_1_69_0/dist-win-x64/ -DOPENSSL_ROOT_DIR=$PWD/../../openssl-OpenSSL_1_1_1d/dist-win-64/ -DBoost_ARCHITECTURE="-x64" -DCMAKE_CXX_COMPILER_ARCHITECTURE_ID="x64" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DCMAKE_VERBOSE_MAKEFILE=ON -DLOGS_DISABLED=ON .. |
| | |
| | | using namespace std; |
| | | using namespace license::os; |
| | | |
| | | const map<int, string> stringByStrategyId = {{STRATEGY_DEFAULT, "DEFAULT"}, {STRATEGY_ETHERNET, "MAC"}, |
| | | {STRATEGY_IP_ADDRESS, "IP"}, {STRATEGY_DISK_NUM, "Disk1"}, |
| | | {STRATEGY_DISK_LABEL, "Disk2"}, {STRATEGY_NONE, "Custom"}}; |
| | | |
| | | const map<int, string> stringByStrategyId = {{STRATEGY_DEFAULT, "DEFAULT"}, |
| | | {STRATEGY_ETHERNET, "MAC"}, |
| | | {STRATEGY_IP_ADDRESS, "IP"}, |
| | | {STRATEGY_DISK_NUM, "Disk1"}, |
| | | {STRATEGY_DISK_LABEL, "Disk2"}}; |
| | | |
| | | const unordered_map<int, string> descByVirtDetail = {{BARE_TO_METAL, "No virtualization"}, |
| | | {VMWARE, "Vmware"}, |
| | |
| | | int cb = 0;
|
| | | int charNo;
|
| | | int pad = 0;
|
| | | int len = tmp_str.size();
|
| | | size_t len = tmp_str.size();
|
| | |
|
| | | if (len < 2) { // 2 accesses below would be OOB.
|
| | | // catch empty string, return NULL as result.
|
| | |
| | | if (safeAsciiPtr[len - 1] == '=') ++pad;
|
| | | if (safeAsciiPtr[len - 2] == '=') ++pad;
|
| | |
|
| | | unsigned int flen = 3 * len / 4 - pad;
|
| | | size_t flen = 3 * len / 4 - pad;
|
| | | bin.reserve(flen);
|
| | |
|
| | | for (charNo = 0; charNo <= len - 4 - pad; charNo += 4) {
|
| | |
| | | linux/cpu_info.cpp |
| | | linux/network.cpp |
| | | linux/os-linux.cpp) |
| | | |
| | | target_link_libraries(os PUBLIC OpenSSL::Crypto) |
| | | ELSE(UNIX) |
| | | #windows and openssl |
| | | add_library(os OBJECT |
| | | cpu_info_common.cpp windows/cpu_info.cpp |
| | | openssl/signature_verifier.cpp |
| | |
| | | windows/isvm/BIOSReader.cpp |
| | | windows/os-win.cpp |
| | | windows/network.cpp) |
| | | |
| | | target_link_libraries(os PUBLIC OpenSSL::Crypto) |
| | | ENDIF(UNIX) |
| | | target_include_directories(os PUBLIC ${OPENSSL_INCLUDE_DIR}) |
| | | ELSE(UNIX OR OPENSSL_FOUND) |
| | | #windows no openssl |
| | | add_library(os OBJECT |
| | |
| | | return true; |
| | | } |
| | | |
| | | void *LocateSMBIOS(uint32_t *smbios_size) |
| | | { |
| | | void *LocateSMBIOS(uint32_t *smbios_size) { |
| | | void *buf = NULL; |
| | | const DWORD tableSignature = ('R' << 24) | ('S' << 16) | ('M' << 8) | 'B'; |
| | | |
| | | if (bIsWindowsXPLater) |
| | | { |
| | | uint32_t size = 0; |
| | | size = Win32GetSystemFirmwareTable('RSMB', 0, buf, size); |
| | | size = Win32GetSystemFirmwareTable(tableSignature, 0, buf, size); |
| | | if (0 == size) |
| | | { |
| | | return NULL; |
| | |
| | | buf = malloc(size); |
| | | if (buf) |
| | | { |
| | | if (0 == Win32GetSystemFirmwareTable('RSMB', 0, buf, size)) |
| | | if (0 == Win32GetSystemFirmwareTable(tableSignature, 0, buf, size)) |
| | | { |
| | | free(buf); |
| | | buf = NULL; |
| | |
| | | /*#ifdef _MSC_VER |
| | | #include <Windows.h> |
| | | #endif*/ |
| | | #include "../../base/logger.h" |
| | | #include "../os.h" |
| | | |
| | | #define NOMINMAX |
| | | #include <windows.h> |
| | | #include <algorithm> |
| | | #include <licensecc/datatypes.h> |
| | | #include <iphlpapi.h> |
| | | #include <stdio.h> |
| | | //#pragma comment(lib, "IPHLPAPI.lib") |
| | | |
| | | unsigned char* unbase64(const char* ascii, int len, int *flen); |
| | | #include "../../base/logger.h" |
| | | #include "../os.h" |
| | | using namespace std; |
| | | |
| | | FUNCTION_RETURN getMachineName(unsigned char identifier[6]) { |
| | | FUNCTION_RETURN result = FUNC_RET_ERROR; |
| | |
| | | //bug check return with diskinfos == null func_ret_ok |
| | | FUNCTION_RETURN getDiskInfos(DiskInfo * diskInfos, size_t * disk_info_size) { |
| | | DWORD fileMaxLen; |
| | | int ndrives = 0; |
| | | size_t ndrives = 0; |
| | | DWORD fileFlags; |
| | | char volName[MAX_PATH], fileSysName[MAX_PATH]; |
| | | DWORD volSerial = 0; |
| | |
| | | LOG_DEBUG("Filesystem : %s", fileSysName); |
| | | if (diskInfos != NULL) { |
| | | if (ndrives < (int)*disk_info_size) { |
| | | diskInfos[ndrives].id = ndrives; |
| | | strncpy(diskInfos[ndrives].device, volName, cmin(MAX_PATH, sizeof(volName)) - 1); |
| | | diskInfos[ndrives].id = (int)ndrives; |
| | | strncpy(diskInfos[ndrives].device, volName, |
| | | min(std::size_t{MAX_PATH}, sizeof(volName)) - 1); |
| | | strncpy(diskInfos[ndrives].label, fileSysName, |
| | | cmin(sizeof(diskInfos[ndrives].label), sizeof(fileSysName)) - 1); |
| | | min(sizeof(diskInfos[ndrives].label), sizeof(fileSysName)) - 1); |
| | | memcpy(diskInfos[ndrives].disk_sn, &volSerial, sizeof(DWORD)); |
| | | diskInfos[ndrives].preferred = (szSingleDrive[0] == 'C'); |
| | | } else { |
| | |
| | | } |
| | | *disk_info_size = ndrives; |
| | | } else { |
| | | *disk_info_size = cmin(ndrives, *disk_info_size); |
| | | *disk_info_size = min(ndrives, *disk_info_size); |
| | | } |
| | | return return_value; |
| | | } |
| | |
| | | Boost::system |
| | | ) |
| | | |
| | | if(CODE_COVERAGE AND UNIX) |
| | | target_link_libraries(test_event_registry gcov) |
| | | endif(CODE_COVERAGE AND UNIX) |
| | | |
| | | ADD_TEST(NAME test_license_reader COMMAND test_license_reader) |
| | | ADD_TEST(NAME test_license_locator COMMAND test_license_locator) |
| | | ADD_TEST(NAME test_event_registry COMMAND test_event_registry) |
| | |
| | | |
| | | #include <licensecc_properties.h> |
| | | #include <licensecc_properties_test.h> |
| | | #include "../../src/library/base/StringUtils.h" |
| | | #include "../../src/library/os/network.hpp" |
| | | #include "../../src/library/os/execution_environment.hpp" |
| | | #include "../../../src/library/base/StringUtils.h" |
| | | #include "../../../src/library/os/network.hpp" |
| | | #include "../../../src/library/os/execution_environment.hpp" |
| | | |
| | | namespace license { |
| | | namespace os { |
| | |
| | | |
| | | #include <licensecc_properties.h> |
| | | #include <licensecc_properties_test.h> |
| | | #include "../../src/library/base/StringUtils.h" |
| | | #include "../../src/library/os/network.hpp" |
| | | #include "../../src/library/os/execution_environment.hpp" |
| | | #include "../../../src/library/base/StringUtils.h" |
| | | #include "../../../src/library/os/network.hpp" |
| | | #include "../../../src/library/os/execution_environment.hpp" |
| | | |
| | | namespace license { |
| | | namespace os { |