From 8b65251303e790cabaad6a1dcb95622fdf737a06 Mon Sep 17 00:00:00 2001 From: Peter Repukat Date: Sat, 24 Sep 2022 18:18:22 +0200 Subject: [PATCH] HidHide: Fix device name sizing issue --- GlosSITarget/HidHide.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/GlosSITarget/HidHide.cpp b/GlosSITarget/HidHide.cpp index 1655e32..7b5d498 100644 --- a/GlosSITarget/HidHide.cpp +++ b/GlosSITarget/HidHide.cpp @@ -169,7 +169,7 @@ void HidHide::UnPatchValveHooks() for (const auto& name : ORIGINAL_BYTES | std::views::keys) { if (name.starts_with("Hid")) { UnPatchHook(name, hiddll); - } + } } } } @@ -187,7 +187,7 @@ void HidHide::UnPatchHook(const std::string& name, HMODULE module) DWORD dw_old_protect, dw_bkup; const auto len = bytes.size(); VirtualProtect(address, len, PAGE_EXECUTE_READWRITE, &dw_old_protect); // Change permissions of memory.. - for (DWORD i = 0; i < len; i++) //unpatch Valve's hook + for (DWORD i = 0; i < len; i++) // unpatch Valve's hook { *(address + i) = bytes[i]; } @@ -496,6 +496,12 @@ HidHide::SmallHidInfo HidHide::GetDeviceInfo(const DeviceInstancePath& instance_ res.name = (HidD_GetProductString(device_object.get(), buffer.data(), static_cast(sizeof(WCHAR) * buffer.size())) ? buffer : L""); + for (size_t i = 0; i < res.name.size(); ++i) { + if (res.name[i] == L'\0') { + res.name.resize(i + 1); + break; + } + } // Valve emulated gamepad PID/VID; mirrord by ViGEm if (attributes.VendorID == 0x28de /* && attributes.ProductID == 0x11FF*/) { res.name = std::wstring(L"ViGEm Emulated: ") + res.name;