summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/windows
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-01-06 19:09:16 +1100
committer Vas Crabb <vas@vastheman.com>2021-01-06 19:09:16 +1100
commit8228719f036324734b804b1488c6233fe14b0b36 (patch)
tree3957e5e8515d11eabc00558690f7b83cc23743fb /src/osd/windows
parent542cf128ba89e8554c6d595264b2b7b68b7fb25a (diff)
Tidy up loose ends:
* Fixed a couple of fixed-size buffers in Windows OSD code. * Marked MAME as aware of long paths in Windows manifest. * Made a cleaner, thread-safe API for getting volume names. * Added compile-time option to disable recompiler W^X mode. * NuBus image device current directory doesn't need to be pinned.
Diffstat (limited to 'src/osd/windows')
-rw-r--r--src/osd/windows/winutil.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/osd/windows/winutil.cpp b/src/osd/windows/winutil.cpp
index b662974cfd1..a9358c67737 100644
--- a/src/osd/windows/winutil.cpp
+++ b/src/osd/windows/winutil.cpp
@@ -103,15 +103,19 @@ BOOL win_is_gui_application()
//============================================================
void osd_subst_env(std::string &dst, const std::string &src)
{
- TCHAR buffer[MAX_PATH];
-
- osd::text::tstring t_src = osd::text::to_tstring(src);
-#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
- ExpandEnvironmentStrings(t_src.c_str(), buffer, ARRAY_LENGTH(buffer));
-#else
- wcsncpy(buffer, t_src.c_str(), ARRAY_LENGTH(buffer));
-#endif
- osd::text::from_tstring(dst, buffer);
+ std::wstring const w_src = osd::text::to_wstring(src);
+ std::vector<wchar_t> buffer(w_src.size() + 2);
+ DWORD length(ExpandEnvironmentStringsW(w_src.c_str(), &buffer[0], buffer.size()));
+ while (length && (buffer.size() < length))
+ {
+ buffer.clear();
+ buffer.resize(length + 1);
+ length = ExpandEnvironmentStringsW(w_src.c_str(), &buffer[0], buffer.size());
+ }
+ if (length)
+ osd::text::from_wstring(dst, &buffer[0]);
+ else
+ dst.clear();
}
//-------------------------------------------------