From 78efd885b76f683a945dcf5d2ff4912f6a39a490 Mon Sep 17 00:00:00 2001 From: goaaats <16760685+goaaats@users.noreply.github.com> Date: Thu, 23 Dec 2021 15:57:26 +0100 Subject: [PATCH] fix: add is_veh_enabled func --- Dalamud.Boot/dllmain.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Dalamud.Boot/dllmain.cpp b/Dalamud.Boot/dllmain.cpp index 689f114d9..bf092fd81 100644 --- a/Dalamud.Boot/dllmain.cpp +++ b/Dalamud.Boot/dllmain.cpp @@ -35,6 +35,25 @@ bool is_running_on_linux() return pwine_get_version != nullptr || pwine_get_host_version != nullptr; } +bool is_veh_enabled() +{ + size_t required_size; + getenv_s(&required_size, nullptr, 0, "DALAMUD_NO_VEH"); + if (required_size > 0) + { + if (char* is_no_veh = static_cast(malloc(required_size * sizeof(char)))) + { + getenv_s(&required_size, is_no_veh, required_size, "DALAMUD_NO_VEH"); + auto result = _stricmp(is_no_veh, "true"); + free(is_no_veh); + if (result == 0) + return false; + } + } + + return true; +} + DllExport DWORD WINAPI Initialize(LPVOID lpParam) { #ifndef NDEBUG @@ -74,8 +93,7 @@ DllExport DWORD WINAPI Initialize(LPVOID lpParam) // ============================== VEH ======================================== // printf("Initializing VEH... "); - GetEnvironmentVariableW(L"DALAMUD_NO_VEH", nullptr, 0); - if(is_running_on_linux() || GetLastError() != ERROR_ENVVAR_NOT_FOUND) + if(is_running_on_linux() || !is_veh_enabled()) { printf("VEH was disabled manually!\n"); }