diff --git a/lib/libimhex/CMakeLists.txt b/lib/libimhex/CMakeLists.txt index 27ee93d95..5389198ac 100644 --- a/lib/libimhex/CMakeLists.txt +++ b/lib/libimhex/CMakeLists.txt @@ -134,6 +134,7 @@ if (NOT IMHEX_EXTERNAL_PLUGIN_BUILD) if (WIN32) set_target_properties(libimhex PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE) target_link_options(libimhex PRIVATE -Wl,--export-all-symbols) + target_link_libraries(libimhex PRIVATE Netapi32.lib) elseif (APPLE) find_library(FOUNDATION NAMES Foundation) target_link_libraries(libimhex PUBLIC ${FOUNDATION}) diff --git a/lib/libimhex/include/hex/api/imhex_api.hpp b/lib/libimhex/include/hex/api/imhex_api.hpp index cff2a5f22..a00c3c9d8 100644 --- a/lib/libimhex/include/hex/api/imhex_api.hpp +++ b/lib/libimhex/include/hex/api/imhex_api.hpp @@ -582,6 +582,14 @@ namespace hex { */ const std::string& getGLRenderer(); + /** + * @brief Checks if ImHex is being run in a "Corporate Environment" + * This function simply checks for common telltale signs such as if the machine is joined a + * domain. It's not super accurate, but it's still useful for statistics + * @return True if it is + */ + bool isCorporateEnvironment(); + /** * @brief Checks if ImHex is running in portable mode * @return Whether ImHex is running in portable mode diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index cf61085c1..ee65644c0 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -23,6 +23,7 @@ #if defined(OS_WINDOWS) #include + #include #else #include #include @@ -730,6 +731,27 @@ namespace hex { return impl::s_glRenderer; } + bool isCorporateEnvironment() { + #if defined(OS_WINDOWS) + { + DSROLE_PRIMARY_DOMAIN_INFO_BASIC * info; + if ((DsRoleGetPrimaryDomainInformation(NULL, DsRolePrimaryDomainInfoBasic, (PBYTE *)&info) == ERROR_SUCCESS) && (info != nullptr)) + { + bool result = std::wstring(info->DomainNameFlat).empty(); + DsRoleFreeMemory(info); + + return result; + } else { + DWORD size = 1024; + ::GetComputerNameExA(ComputerNameDnsDomain, nullptr, &size); + return size > 0; + } + } + #else + return false; + #endif + } + bool isPortableVersion() { static std::optional portable; if (portable.has_value()) diff --git a/plugins/builtin/source/content/init_tasks.cpp b/plugins/builtin/source/content/init_tasks.cpp index 5992c3e97..3e8e92def 100644 --- a/plugins/builtin/source/content/init_tasks.cpp +++ b/plugins/builtin/source/content/init_tasks.cpp @@ -75,7 +75,8 @@ namespace hex::plugin::builtin { { "os", ImHexApi::System::getOSName() }, { "os_version", ImHexApi::System::getOSVersion() }, { "arch", ImHexApi::System::getArchitecture() }, - { "gpu_vendor", ImHexApi::System::getGPUVendor() } + { "gpu_vendor", ImHexApi::System::getGPUVendor() }, + { "corporate_env", ImHexApi::System::isCorporateEnvironment() } }; HttpRequest telemetryRequest("POST", ImHexApiURL + "/telemetry"s); diff --git a/plugins/builtin/source/content/out_of_box_experience.cpp b/plugins/builtin/source/content/out_of_box_experience.cpp index 4c74aa6bb..8ae2aa331 100644 --- a/plugins/builtin/source/content/out_of_box_experience.cpp +++ b/plugins/builtin/source/content/out_of_box_experience.cpp @@ -308,11 +308,12 @@ namespace hex::plugin::builtin { ImGui::TableNextColumn(); ImGui::TextUnformatted("hex.builtin.oobe.server_contact.data_collected.os"_lang); ImGui::TableNextColumn(); - ImGuiExt::TextFormattedWrapped("{}\n{}\n{}\n{}", + ImGuiExt::TextFormattedWrapped("{}\n{}\n{}\n{}\nCorporate Environment: {}", ImHexApi::System::getOSName(), ImHexApi::System::getOSVersion(), ImHexApi::System::getArchitecture(), - ImHexApi::System::getGPUVendor()); + ImHexApi::System::getGPUVendor(), + ImHexApi::System::isCorporateEnvironment() ? "Yes" : "No"); ImGui::EndTable(); }