From 831e7a2268d16d1fd132d6c864e72d6e41edbec9 Mon Sep 17 00:00:00 2001 From: Andrew Tonner Date: Wed, 12 Feb 2020 21:29:44 -0800 Subject: [PATCH] Merge fixes to SheepShaver --- .../src/Windows/user_strings_windows.cpp | 19 ++++++++++++++----- SheepShaver/src/macos_util.cpp | 4 ++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/SheepShaver/src/Windows/user_strings_windows.cpp b/SheepShaver/src/Windows/user_strings_windows.cpp index 32e52d25..eb12de57 100755 --- a/SheepShaver/src/Windows/user_strings_windows.cpp +++ b/SheepShaver/src/Windows/user_strings_windows.cpp @@ -20,7 +20,7 @@ #include "sysdeps.h" #include "user_strings.h" - +#include "util_windows.h" // Platform-specific string definitions user_string_def platform_strings[] = { @@ -86,7 +86,11 @@ static const char *get_volume_name(void) HKEY hHelpKey; DWORD key_type, cbData; - static char volume[256]; + #ifdef _UNICODE + static char out_volume[256]; + #endif + + static TCHAR volume[256]; memset(volume, 0, sizeof(volume)); // Try Windows 2000 key first @@ -123,14 +127,19 @@ static const char *get_volume_name(void) } // Fix the error that some "tweak" apps do. - if (stricmp(volume, "%USERNAME% on %COMPUTER%") == 0) - volume[0] = '\0'; + if (_tcsicmp(volume, TEXT("%USERNAME% on %COMPUTER%")) == 0) + volume[0] = TEXT('\0'); // No volume name found, default to "My Computer" if (volume[0] == 0) - strcpy(volume, "My Computer"); + _tcscpy(volume, TEXT("My Computer")); + #ifdef _UNICODE + strlcpy(out_volume, volume, 256); + return out_volume; + #else return volume; + #endif } diff --git a/SheepShaver/src/macos_util.cpp b/SheepShaver/src/macos_util.cpp index 87eabb3d..6a3f9644 100644 --- a/SheepShaver/src/macos_util.cpp +++ b/SheepShaver/src/macos_util.cpp @@ -327,6 +327,10 @@ uint32 TimeToMacTime(time_t t) // Convert to number of seconds elapsed since 1-Jan-1904 #ifdef WIN32 + if (t == -1) { + // failsafe as this will segfault + return 0; + } struct tm *local = localtime(&t); #else struct tm result;