From 07e541678ca8c55c39780f7960c559a3e9c7ee1e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 17 Nov 2022 15:04:20 +0100 Subject: Move hex conversion helpers to util These are used here and there so let's make them more general rather than hiding them in the stream classes. --- win/rfb_win32/Registry.cxx | 6 ++++-- win/rfb_win32/Win32Util.cxx | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'win') diff --git a/win/rfb_win32/Registry.cxx b/win/rfb_win32/Registry.cxx index f046188f..cb4e6688 100644 --- a/win/rfb_win32/Registry.cxx +++ b/win/rfb_win32/Registry.cxx @@ -175,7 +175,9 @@ TCHAR* RegKey::getString(const TCHAR* valname, const TCHAR* def) const { void RegKey::getBinary(const TCHAR* valname, void** data, size_t* length) const { TCharArray hex(getRepresentation(valname)); - if (!rdr::HexInStream::hexStrToBin(CStr(hex.buf), (char**)data, length)) + *data = hexToBin(CStr(hex.buf), strlen(CStr(hex.buf))); + *length = strlen(CStr(hex.buf))/2; + if (*data == NULL) throw rdr::Exception("getBinary failed"); } void RegKey::getBinary(const TCHAR* valname, void** data, size_t* length, void* def, size_t deflen) const { @@ -233,7 +235,7 @@ TCHAR* RegKey::getRepresentation(const TCHAR* valname) const { switch (type) { case REG_BINARY: { - TCharArray hex(rdr::HexOutStream::binToHexStr(data.buf, length)); + TCharArray hex(binToHex((const uint8_t*)data.buf, length)); return hex.takeBuf(); } case REG_SZ: diff --git a/win/rfb_win32/Win32Util.cxx b/win/rfb_win32/Win32Util.cxx index fc66274f..2fbce0dd 100644 --- a/win/rfb_win32/Win32Util.cxx +++ b/win/rfb_win32/Win32Util.cxx @@ -61,13 +61,13 @@ FileVersionInfo::FileVersionInfo(const TCHAR* filename) { } const TCHAR* FileVersionInfo::getVerString(const TCHAR* name, DWORD langId) { - char langIdBuf[sizeof(langId)]; + uint8_t langIdBuf[sizeof(langId)]; for (int i=sizeof(langIdBuf)-1; i>=0; i--) { - langIdBuf[i] = (char) (langId & 0xff); + langIdBuf[i] = (langId & 0xff); langId = langId >> 8; } - TCharArray langIdStr(rdr::HexOutStream::binToHexStr(langIdBuf, sizeof(langId))); + TCharArray langIdStr(binToHex(langIdBuf, sizeof(langId))); TCharArray infoName(_tcslen(_T("StringFileInfo")) + 4 + _tcslen(name) + _tcslen(langIdStr.buf)); _stprintf(infoName.buf, _T("\\StringFileInfo\\%s\\%s"), langIdStr.buf, name); -- cgit v1.2.3