diff options
author | Pierre Ossman <ossman@cendio.se> | 2022-11-17 15:04:20 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-02-04 14:03:13 +0100 |
commit | 07e541678ca8c55c39780f7960c559a3e9c7ee1e (patch) | |
tree | 89f0f53831a9e546e35fdc0cd77451548ffe6874 /win | |
parent | d98720b736eb908d63c1ecb3779fc2a3cd9f4914 (diff) | |
download | tigervnc-07e541678ca8c55c39780f7960c559a3e9c7ee1e.tar.gz tigervnc-07e541678ca8c55c39780f7960c559a3e9c7ee1e.zip |
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.
Diffstat (limited to 'win')
-rw-r--r-- | win/rfb_win32/Registry.cxx | 6 | ||||
-rw-r--r-- | win/rfb_win32/Win32Util.cxx | 6 |
2 files changed, 7 insertions, 5 deletions
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); |