Common: Slim down RedtapeWindows and correct case

This commit is contained in:
Connor McLaughlin 2022-11-27 12:51:57 +10:00 committed by refractionpcsx2
parent 2c88cd7ac0
commit 89c0d95a94
12 changed files with 36 additions and 33 deletions

View File

@ -25,12 +25,11 @@
#endif #endif
// We require Windows 10+. // We require Windows 10+.
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0A00 // Windows 10 #define _WIN32_WINNT 0x0A00 // Windows 10
#include <windows.h> #include <Windows.h>
#include <versionhelpers.h>
#include <shtypes.h>
#include <timeapi.h>
#include <tchar.h>
#endif #endif

View File

@ -25,8 +25,8 @@
#include "fmt/core.h" #include "fmt/core.h"
#include <mmsystem.h> #include <mmsystem.h>
#include <timeapi.h>
#pragma comment(lib, "User32.lib") #include <VersionHelpers.h>
alignas(16) static LARGE_INTEGER lfreq; alignas(16) static LARGE_INTEGER lfreq;
@ -67,7 +67,7 @@ std::string GetOSVersionString()
if (IsWindows10OrGreater()) if (IsWindows10OrGreater())
{ {
retval = "Microsoft "; retval = "Microsoft ";
retval += IsWindowsServer() ? "Windows Server 2016" : "Windows 10"; retval += IsWindowsServer() ? "Windows Server 2016+" : "Windows 10+";
} }
else else

View File

@ -19,7 +19,9 @@
#include "common/Assertions.h" #include "common/Assertions.h"
#include "common/emitter/tools.h" #include "common/emitter/tools.h"
#include "common/RedtapeWindows.h" #include "common/RedtapeWindows.h"
#include <mmsystem.h>
#include <process.h> #include <process.h>
#include <timeapi.h>
__fi void Threading::Sleep(int ms) __fi void Threading::Sleep(int ms)
{ {

View File

@ -15,9 +15,8 @@
#pragma once #pragma once
#if defined(_WIN32) #ifdef _WIN32
#define NOMINMAX #include "common/RedtapeWindows.h"
#include <windows.h>
#endif #endif
#include <mutex> #include <mutex>

View File

@ -21,8 +21,7 @@
#ifdef _WIN32 #ifdef _WIN32
#include "common/RedtapeWindows.h" #include "common/RedtapeWindows.h"
#include <Winioctl.h> #include <winioctl.h>
#include <windows.h>
#else #else
#include <sys/types.h> #include <sys/types.h>
#include <sys/mman.h> #include <sys/mman.h>

View File

@ -31,7 +31,7 @@
#ifdef _WIN32 #ifdef _WIN32
#define usleep(x) Sleep(x / 1000) #define usleep(x) Sleep(x / 1000)
#include <windows.h> #include "common/RedtapeWindows.h"
#include <windowsx.h> #include <windowsx.h>
#include <winioctl.h> #include <winioctl.h>

View File

@ -21,9 +21,8 @@
#include "fmt/core.h" #include "fmt/core.h"
#include <stdio.h> #include <stdio.h>
#include <windows.h> #include <WinSock2.h>
#include <winsock2.h> #include <WS2tcpip.h>
#include <ws2ipdef.h>
#include <iphlpapi.h> #include <iphlpapi.h>
#include <Netcfgx.h> #include <Netcfgx.h>

View File

@ -19,12 +19,10 @@
#include <memory> #include <memory>
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include "common/RedtapeWindows.h"
#include <windows.h>
#include <iphlpapi.h>
//#include <ws2tcpip.h>
//#include <comdef.h>
#include "common/StringUtil.h" #include "common/StringUtil.h"
#include <WinSock2.h>
#include <iphlpapi.h>
#elif defined(__linux__) #elif defined(__linux__)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <net/if.h> #include <net/if.h>

View File

@ -472,26 +472,26 @@ static std::string GetDriverVersionFromLUID(const LUID& luid)
std::string ret; std::string ret;
HKEY hKey; HKEY hKey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), 0, KEY_READ, &hKey) == ERROR_SUCCESS) if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\DirectX", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{ {
DWORD max_key_len = 0, adapter_count = 0; DWORD max_key_len = 0, adapter_count = 0;
if (RegQueryInfoKey(hKey, nullptr, nullptr, nullptr, &adapter_count, &max_key_len, if (RegQueryInfoKeyW(hKey, nullptr, nullptr, nullptr, &adapter_count, &max_key_len,
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) nullptr, nullptr, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS)
{ {
std::vector<TCHAR> current_name(max_key_len + 1); std::vector<TCHAR> current_name(max_key_len + 1);
for (DWORD i = 0; i < adapter_count; ++i) for (DWORD i = 0; i < adapter_count; ++i)
{ {
DWORD subKeyLength = static_cast<DWORD>(current_name.size()); DWORD subKeyLength = static_cast<DWORD>(current_name.size());
if (RegEnumKeyEx(hKey, i, current_name.data(), &subKeyLength, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) if (RegEnumKeyExW(hKey, i, current_name.data(), &subKeyLength, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS)
{ {
LUID current_luid = {}; LUID current_luid = {};
DWORD current_luid_size = sizeof(uint64_t); DWORD current_luid_size = sizeof(uint64_t);
if (RegGetValue(hKey, current_name.data(), _T("AdapterLuid"), RRF_RT_QWORD, nullptr, &current_luid, &current_luid_size) == ERROR_SUCCESS && if (RegGetValueW(hKey, current_name.data(), L"AdapterLuid", RRF_RT_QWORD, nullptr, &current_luid, &current_luid_size) == ERROR_SUCCESS &&
current_luid.HighPart == luid.HighPart && current_luid.LowPart == luid.LowPart) current_luid.HighPart == luid.HighPart && current_luid.LowPart == luid.LowPart)
{ {
LARGE_INTEGER driver_version = {}; LARGE_INTEGER driver_version = {};
DWORD driver_version_size = sizeof(driver_version); DWORD driver_version_size = sizeof(driver_version);
if (RegGetValue(hKey, current_name.data(), _T("DriverVersion"), RRF_RT_QWORD, nullptr, &driver_version, &driver_version_size) == ERROR_SUCCESS) if (RegGetValueW(hKey, current_name.data(), L"DriverVersion", RRF_RT_QWORD, nullptr, &driver_version, &driver_version_size) == ERROR_SUCCESS)
{ {
WORD nProduct = HIWORD(driver_version.HighPart); WORD nProduct = HIWORD(driver_version.HighPart);
WORD nVersion = LOWORD(driver_version.HighPart); WORD nVersion = LOWORD(driver_version.HighPart);

View File

@ -348,7 +348,7 @@ static std::string GetDriverVersionFromLUID(const LUID& luid)
std::string ret; std::string ret;
HKEY hKey; HKEY hKey;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), 0, KEY_READ, &hKey) == ERROR_SUCCESS) if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\DirectX", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{ {
DWORD max_key_len = 0, adapter_count = 0; DWORD max_key_len = 0, adapter_count = 0;
if (RegQueryInfoKey(hKey, nullptr, nullptr, nullptr, &adapter_count, &max_key_len, if (RegQueryInfoKey(hKey, nullptr, nullptr, nullptr, &adapter_count, &max_key_len,
@ -358,16 +358,16 @@ static std::string GetDriverVersionFromLUID(const LUID& luid)
for (DWORD i = 0; i < adapter_count; ++i) for (DWORD i = 0; i < adapter_count; ++i)
{ {
DWORD subKeyLength = static_cast<DWORD>(current_name.size()); DWORD subKeyLength = static_cast<DWORD>(current_name.size());
if (RegEnumKeyEx(hKey, i, current_name.data(), &subKeyLength, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) if (RegEnumKeyExW(hKey, i, current_name.data(), &subKeyLength, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS)
{ {
LUID current_luid = {}; LUID current_luid = {};
DWORD current_luid_size = sizeof(uint64_t); DWORD current_luid_size = sizeof(uint64_t);
if (RegGetValue(hKey, current_name.data(), _T("AdapterLuid"), RRF_RT_QWORD, nullptr, &current_luid, &current_luid_size) == ERROR_SUCCESS && if (RegGetValueW(hKey, current_name.data(), L"AdapterLuid", RRF_RT_QWORD, nullptr, &current_luid, &current_luid_size) == ERROR_SUCCESS &&
current_luid.HighPart == luid.HighPart && current_luid.LowPart == luid.LowPart) current_luid.HighPart == luid.HighPart && current_luid.LowPart == luid.LowPart)
{ {
LARGE_INTEGER driver_version = {}; LARGE_INTEGER driver_version = {};
DWORD driver_version_size = sizeof(driver_version); DWORD driver_version_size = sizeof(driver_version);
if (RegGetValue(hKey, current_name.data(), _T("DriverVersion"), RRF_RT_QWORD, nullptr, &driver_version, &driver_version_size) == ERROR_SUCCESS) if (RegGetValueW(hKey, current_name.data(), L"DriverVersion", RRF_RT_QWORD, nullptr, &driver_version, &driver_version_size) == ERROR_SUCCESS)
{ {
WORD nProduct = HIWORD(driver_version.HighPart); WORD nProduct = HIWORD(driver_version.HighPart);
WORD nVersion = LOWORD(driver_version.HighPart); WORD nVersion = LOWORD(driver_version.HighPart);

View File

@ -15,13 +15,18 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "Global.h"
#include "SndOut.h"
#include "common/Console.h" #include "common/Console.h"
#include "common/StringUtil.h" #include "common/StringUtil.h"
#include "common/RedtapeWindows.h" #include "common/RedtapeWindows.h"
#include "cubeb/cubeb.h" #include "cubeb/cubeb.h"
#include "Global.h" #ifdef _WIN32
#include "SndOut.h" #include <objbase.h>
#endif
#ifdef PCSX2_CORE #ifdef PCSX2_CORE

View File

@ -67,6 +67,8 @@
#ifdef _WIN32 #ifdef _WIN32
#include "common/RedtapeWindows.h" #include "common/RedtapeWindows.h"
#include <objbase.h>
#include <timeapi.h>
#endif #endif
namespace VMManager namespace VMManager