From 6f87611767ea9072a2680154b26dd8d3f2dd0222 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Wed, 27 Feb 2013 20:27:22 -0600 Subject: [PATCH] Fix "Core" to build with "Unicode". --- Source/Core/Core/Core.vcxproj | 6 +-- Source/Core/Core/Src/ConfigManager.cpp | 6 +-- Source/Core/Core/Src/Console.cpp | 4 +- Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.cpp | 46 +++++++++---------- Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.h | 14 +++--- Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp | 6 +-- .../Core/Src/HW/WiimoteReal/WiimoteReal.h | 2 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp | 5 +- 8 files changed, 41 insertions(+), 48 deletions(-) diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index 1dd547b2ea..17495de740 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -44,7 +44,7 @@ false StaticLibrary - MultiByte + Unicode StaticLibrary @@ -54,7 +54,7 @@ false StaticLibrary - MultiByte + Unicode StaticLibrary @@ -602,4 +602,4 @@ - + \ No newline at end of file diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index 85ecc7143f..8c7872119e 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -137,7 +137,7 @@ void SConfig::SaveSettings() ini.Get("General", "GCMPathes", &oldPaths, 0); for (int i = numPaths; i < oldPaths; i++) { - TCHAR tmp[16]; + char tmp[16]; sprintf(tmp, "GCMPath%i", i); ini.DeleteKey("General", tmp); } @@ -146,7 +146,7 @@ void SConfig::SaveSettings() for (int i = 0; i < numPaths; i++) { - TCHAR tmp[16]; + char tmp[16]; sprintf(tmp, "GCMPath%i", i); ini.Set("General", tmp, m_ISOFolder[i]); } @@ -284,7 +284,7 @@ void SConfig::LoadSettings() { for (int i = 0; i < numGCMPaths; i++) { - TCHAR tmp[16]; + char tmp[16]; sprintf(tmp, "GCMPath%i", i); std::string tmpPath; ini.Get("General", tmp, &tmpPath, ""); diff --git a/Source/Core/Core/Src/Console.cpp b/Source/Core/Core/Src/Console.cpp index 759dc46bc5..b0ef416a84 100644 --- a/Source/Core/Core/Src/Console.cpp +++ b/Source/Core/Core/Src/Console.cpp @@ -98,8 +98,8 @@ void Console_Submit(const char *cmd) } CASE("dump") { - TCHAR temp[256]; - TCHAR filename[256]; + char temp[256]; + char filename[256]; u32 start; u32 end; sscanf(cmd, "%s %08x %08x %s", temp, &start, &end, filename); diff --git a/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.cpp b/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.cpp index 87ebd90344..03332d3012 100644 --- a/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.cpp +++ b/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.cpp @@ -25,7 +25,7 @@ namespace Win32TAPHelper { -bool IsTAPDevice(const char *guid) +bool IsTAPDevice(const TCHAR *guid) { HKEY netcard_key; LONG status; @@ -39,13 +39,13 @@ bool IsTAPDevice(const char *guid) for (;;) { - char enum_name[256]; - char unit_string[256]; + TCHAR enum_name[256]; + TCHAR unit_string[256]; HKEY unit_key; - char component_id_string[] = "ComponentId"; - char component_id[256]; - char net_cfg_instance_id_string[] = "NetCfgInstanceId"; - char net_cfg_instance_id[256]; + TCHAR component_id_string[] = _T("ComponentId"); + TCHAR component_id[256]; + TCHAR net_cfg_instance_id_string[] = _T("NetCfgInstanceId"); + TCHAR net_cfg_instance_id[256]; DWORD data_type; len = sizeof(enum_name); @@ -56,7 +56,7 @@ bool IsTAPDevice(const char *guid) else if (status != ERROR_SUCCESS) return false; - snprintf(unit_string, sizeof(unit_string), "%s\\%s", ADAPTER_KEY, enum_name); + _sntprintf(unit_string, sizeof(unit_string), _T("%s\\%s"), ADAPTER_KEY, enum_name); status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, unit_string, 0, KEY_READ, &unit_key); @@ -78,8 +78,8 @@ bool IsTAPDevice(const char *guid) if (status == ERROR_SUCCESS && data_type == REG_SZ) { - if (!strcmp(component_id, TAP_COMPONENT_ID) && - !strcmp(net_cfg_instance_id, guid)) + if (!_tcscmp(component_id, TAP_COMPONENT_ID) && + !_tcscmp(net_cfg_instance_id, guid)) { RegCloseKey(unit_key); RegCloseKey(netcard_key); @@ -96,7 +96,7 @@ bool IsTAPDevice(const char *guid) return false; } -bool GetGUIDs(std::vector& guids) +bool GetGUIDs(std::vector>& guids) { LONG status; HKEY control_net_key; @@ -111,12 +111,12 @@ bool GetGUIDs(std::vector& guids) while (!found_all) { - char enum_name[256]; - char connection_string[256]; + TCHAR enum_name[256]; + TCHAR connection_string[256]; HKEY connection_key; - char name_data[256]; + TCHAR name_data[256]; DWORD name_type; - const char name_string[] = "Name"; + const TCHAR name_string[] = _T("Name"); len = sizeof(enum_name); status = RegEnumKeyEx(control_net_key, i, enum_name, @@ -127,8 +127,8 @@ bool GetGUIDs(std::vector& guids) else if (status != ERROR_SUCCESS) return false; - snprintf(connection_string, sizeof(connection_string), - "%s\\%s\\Connection", NETWORK_CONNECTIONS_KEY, enum_name); + _sntprintf(connection_string, sizeof(connection_string), + _T("%s\\%s\\Connection"), NETWORK_CONNECTIONS_KEY, enum_name); status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, connection_string, 0, KEY_READ, &connection_key); @@ -165,15 +165,11 @@ bool GetGUIDs(std::vector& guids) return true; } -bool OpenTAP(HANDLE& adapter, const std::string device_guid) +bool OpenTAP(HANDLE& adapter, const std::basic_string& device_guid) { - char device_path[256]; + auto const device_path = USERMODEDEVICEDIR + device_guid + TAPSUFFIX; - /* Open Windows TAP-Win32 adapter */ - snprintf(device_path, sizeof(device_path), "%s%s%s", - USERMODEDEVICEDIR, device_guid.c_str(), TAPSUFFIX); - - adapter = CreateFile(device_path, GENERIC_READ | GENERIC_WRITE, 0, 0, + adapter = CreateFile(device_path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0); if (adapter == INVALID_HANDLE_VALUE) @@ -192,7 +188,7 @@ bool CEXIETHERNET::Activate() return true; DWORD len; - std::vector device_guids; + std::vector> device_guids; if (!Win32TAPHelper::GetGUIDs(device_guids)) { diff --git a/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.h b/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.h index 2676a3fc7e..2a5bc52ffa 100644 --- a/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.h +++ b/Source/Core/Core/Src/HW/BBA-TAP/TAP_Win32.h @@ -65,18 +65,18 @@ // Registry keys //================= -#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}" +#define ADAPTER_KEY _T("SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}") -#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}" +#define NETWORK_CONNECTIONS_KEY _T("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}") //====================== // Filesystem prefixes //====================== -#define USERMODEDEVICEDIR "\\\\.\\Global\\" -#define SYSDEVICEDIR "\\Device\\" -#define USERDEVICEDIR "\\DosDevices\\Global\\" -#define TAPSUFFIX ".tap" +#define USERMODEDEVICEDIR _T("\\\\.\\Global\\") +#define SYSDEVICEDIR _T("\\Device\\") +#define USERDEVICEDIR _T("\\DosDevices\\Global\\") +#define TAPSUFFIX _T(".tap") //========================================================= // TAP_COMPONENT_ID -- This string defines the TAP driver @@ -84,4 +84,4 @@ // simultaneously. //========================================================= -#define TAP_COMPONENT_ID "tap0901" +#define TAP_COMPONENT_ID _T("tap0901") diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp index 2ae34a7ca5..2407d697a4 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -464,9 +463,6 @@ int Wiimote::IOWrite(const u8* buf, int len) template void ProcessWiimotes(bool new_scan, T& callback) { - // match strings like "Nintendo RVL-WBC-01", "Nintendo RVL-CNT-01", "Nintendo RVL-CNT-01-TR" - const std::wregex wiimote_device_name(L"Nintendo RVL-.*"); - BLUETOOTH_DEVICE_SEARCH_PARAMS srch; srch.dwSize = sizeof(srch); srch.fReturnAuthenticated = true; @@ -509,7 +505,7 @@ void ProcessWiimotes(bool new_scan, T& callback) DEBUG_LOG(WIIMOTE, "authed %i connected %i remembered %i ", btdi.fAuthenticated, btdi.fConnected, btdi.fRemembered); - if (std::regex_match(btdi.szName, wiimote_device_name)) + if (IsValidBluetoothName(UTF16ToUTF8(btdi.szName))) { callback(hRadio, radioInfo, btdi); } diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h index 793a13ceb0..cfc66106b4 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h @@ -91,7 +91,7 @@ public: int int_sock; // Interrupt socket #elif defined(_WIN32) - std::string devicepath; // Unique wiimote reference + std::basic_string devicepath; // Unique wiimote reference //ULONGLONG btaddr; // Bluetooth address HANDLE dev_handle; // HID handle OVERLAPPED hid_overlap_read, hid_overlap_write; // Overlap handle diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index 3eb0096929..363176e18a 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -58,6 +58,7 @@ #include "CommonPaths.h" #include "IPC_HLE/WII_IPC_HLE_Device_usb.h" #include "../Movie.h" +#include "StringUtil.h" #ifdef _WIN32 #include @@ -926,7 +927,7 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz) else { #ifdef _WIN32 - MoveFile(savePath.c_str(), (savePath + "../backup/").c_str()); + MoveFile(UTF8ToTStr(savePath).c_str(), UTF8ToTStr(savePath + "../backup/").c_str()); #else File::CopyDir(savePath.c_str(),(savePath + "../backup/").c_str()); File::DeleteDirRecursively(savePath.c_str()); @@ -940,7 +941,7 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(u8* _pTMD, u32 _sz) if (File::Exists((savePath + "banner.bin").c_str())) File::DeleteDirRecursively(savePath); #ifdef _WIN32 - MoveFile((savePath + "../backup/").c_str(), savePath.c_str()); + MoveFile(UTF8ToTStr(savePath + "../backup/").c_str(), UTF8ToTStr(savePath).c_str()); #else File::CopyDir((savePath + "../backup/").c_str(), savePath.c_str()); File::DeleteDirRecursively((savePath + "../backup/").c_str());