20 Jul
2023
20 Jul
'23
1:37 p.m.
On Thu Jul 20 12:58:01 2023 +0000, Maxim Karasev wrote:
Without `\0` it prints through all resource strings: ``` $ wine i386-windows/klist.exe dsjfkjds Usage: klist <tickets | tgt | purge | get [service principal name]> Unknown error Start TimEnd Time Renew Time Ticket FlagsCached TicketsServerKerbTicket Encryption TypeCurrent LogonId is ``` Right, when you call LoadString() with 0 buffer size it will return a pointer to an unterminated string. You would need to use the length returned to make a copy or introduce some kind of helper to print messages. Easiest is to use a buffer instead like most other programs do:
static WCHAR msg_buf[1024];
static const WCHAR *load_resource(UINT id)
{
if (!LoadStringW(GetModuleHandleW(NULL), id, msg_buf, ARRAY_SIZE(msg_buf)))
ERR("LoadString failed with %lu\n", GetLastError());
return msg_buf;
}
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/3347#note_39613