UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WindowsPlatformMisc.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
8
9#define UE_DEBUG_BREAK_IMPL() PLATFORM_BREAK()
10
12struct FGuid;
14
15#if PLATFORM_CPU_X86_FAMILY
16namespace ECPUFeatureBits_X86
17{
18 inline constexpr uint32 SSE2 = 1U << 2;
19 inline constexpr uint32 SSSE3 = 1U << 3;
20 inline constexpr uint32 SSE42 = 1U << 4;
21 inline constexpr uint32 AVX = 1U << 5;
22 inline constexpr uint32 BMI1 = 1U << 6; // Bit Manipulation Instructions - 1
23 inline constexpr uint32 BMI2 = 1U << 7; // Bit Manipulation Instructions - 2
24 inline constexpr uint32 AVX2 = 1U << 8;
25 inline constexpr uint32 F16C = 1U << 9; // Float16 conversion instructions
26 inline constexpr uint32 AVX512 = 1U << 10; // Skylake feature set : AVXF512{ F,VL,BW,DQ}.
27 inline constexpr uint32 AVX512_NOCAVEATS = 1U << 11; // Set when we have AVX512 without caveats like throttling.
28}
29#endif
30
45
51enum class ECOMModel : uint8
52{
53 Singlethreaded = 0,
55};
56
61{
63 Unknown = 0,
65 HDD = 1,
67 SSD = 2,
69 NVMe = 3,
71 Hybrid = 4,
72
73 Other = 0xff
74};
75
77
92
98{
99 static CORE_API void PlatformPreInit();
100 static CORE_API void PlatformInit();
101 static CORE_API void PlatformTearDown();
108
109 UE_DEPRECATED(4.21, "void FPlatformMisc::GetEnvironmentVariable(Name, Result, Length) is deprecated. Use FString FPlatformMisc::GetEnvironmentVariable(Name) instead.")
111
112 static CORE_API FString GetEnvironmentVariable(const TCHAR* VariableName);
113 static CORE_API void SetEnvironmentVar(const TCHAR* VariableName, const TCHAR* Value);
114
117
118#if !UE_BUILD_SHIPPING
119 static CORE_API bool IsDebuggerPresent();
121#endif
122
123 inline static void MemoryBarrier()
124 {
125#if PLATFORM_CPU_X86_FAMILY
126 _mm_sfence();
127#elif PLATFORM_CPU_ARM_FAMILY
129#endif
130 }
131
133
138
139 static CORE_API bool IsRemoteSession();
140
141 static CORE_API void SetUTF8Output();
142 static CORE_API void LocalPrint(const TCHAR *Message);
143
145 {
146 //returning true when the debugger is attached is to allow
147 //printing of log lines immediately to the output window.
148 //return false in not attached because OutputDebuString is slow.
149 return IsDebuggerPresent();
150 }
151
152 static CORE_API void RequestExitWithStatus(bool Force, uint8 ReturnCode, const TCHAR* CallSite = nullptr);
153 static CORE_API void RequestExit(bool Force, const TCHAR* CallSite = nullptr);
155 static CORE_API void CreateGuid(struct FGuid& Result);
157 static CORE_API bool CommandLineCommands();
158 static CORE_API bool Is64bitOperatingSystem();
159 static CORE_API bool IsValidAbsolutePathFormat(const FString& Path);
164
166
167 static CORE_API FString GetDefaultLanguage();
168 static CORE_API FString GetDefaultLocale();
169
171 static CORE_API void SetLastError(uint32 ErrorCode);
173 static CORE_API bool SetStoredValue(const FString& InStoreId, const FString& InSectionName, const FString& InKeyName, const FString& InValue);
174 static CORE_API bool GetStoredValue(const FString& InStoreId, const FString& InSectionName, const FString& InKeyName, FString& OutValue);
175 static CORE_API bool DeleteStoredValue(const FString& InStoreId, const FString& InSectionName, const FString& InKeyName);
176 static CORE_API bool DeleteStoredSection(const FString& InStoreId, const FString& InSectionName);
177
179 static CORE_API void CoUninitialize();
180
190 static CORE_API bool OsExecute(const TCHAR* CommandType, const TCHAR* Command, const TCHAR* CommandLine = NULL);
191
202
211 static CORE_API bool VerifyWindowsVersion(uint32 MajorVersion, uint32 MinorVersion, uint32 BuildNumber = 0);
212
218 static CORE_API bool IsWine();
219
220#if !UE_BUILD_SHIPPING
221 static CORE_API void PromptForRemoteDebugging(bool bIsEnsure);
222#endif //#if !UE_BUILD_SHIPPING
223
224
230 static CORE_API bool HasCPUIDInstruction();
231
232#if PLATFORM_CPU_X86_FAMILY
233 // Query the CPUID and parse out various feature bits. This is safe to call multiple times and caches the result internally for rapid access.
234 // Bits are all from the ECPUFeatureBits_X86 namespace.
238#endif
239
246
247 static CORE_API bool HasTPM2Support();
248 static CORE_API bool HasSecureBootSupport();
253 static CORE_API bool SupportsWindows11();
254
255 static CORE_API FString GetCPUVendor();
256 static CORE_API FString GetCPUBrand();
259
260 static CORE_API FString GetPrimaryGPUBrand();
261 static CORE_API struct FGPUDriverInfo GetGPUDriverInfo(const FString& DeviceDescription, bool bVerbose = true);
262 static CORE_API void GetOSVersions( FString& out_OSVersionLabel, FString& out_OSSubVersionLabel );
263 static CORE_API FString GetOSVersion();
267
282 static CORE_API uint32 GetCPUInfo();
283
289 static CORE_API bool HasTimedPauseCPUFeature();
290
292 static CORE_API FString GetHostArchitecture();
293
304 static CORE_API bool QueryRegKey( const Windows::HKEY InKey, const TCHAR* InSubKey, const TCHAR* InValueName, FString& OutData );
305
314 static CORE_API bool GetVSComnTools(int32 Version, FString& OutData);
315
316 UE_DEPRECATED(5.2, "Please use PLATFORM_CACHE_LINE_SIZE instead, runtime query of cache line size not supported")
322
325
330 {
331 // for now return true
332 return true;
333 }
334
339 static CORE_API bool IsDeviceHandheld();
340
344 static CORE_API bool IsRunningOnBattery();
345
349 static CORE_API int GetBatteryLevel();
350
354 static CORE_API bool IsUsingBatterySaver();
355
357 {
358 // needs to match GRHIHDRDisplayOutputFormat chosen in FD3D12DynamicRHI::Init
359#if WITH_EDITOR
360 // ScRGB, 1000 or 2000 nits
362 // Rec709
364#else
365 // ST-2084, 1000 or 2000 nits
367 // Rec2020
369#endif
370 }
371
375 static CORE_API FString GetOperatingSystemId();
376
378
380
382
383 static CORE_API uint64 GetFileVersion(const FString &FileName);
384
386
388 static CORE_API void UpdateDriveFreeSpace();
389
392};
393
394
395#if defined(WINDOWS_USE_FEATURE_PLATFORMMISC_CLASS) && WINDOWS_USE_FEATURE_PLATFORMMISC_CLASS
397#endif
#define NULL
Definition oodle2base.h:134
FAndroidMisc FPlatformMisc
Definition AndroidPlatformMisc.h:371
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::WIDECHAR WIDECHAR
A wide character. Normally a signed type.
Definition Platform.h:1133
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
EConvertibleLaptopMode
Definition GenericPlatformMisc.h:223
EDisplayColorGamut
Definition GenericPlatformMisc.h:518
EDisplayOutputFormat
Definition GenericPlatformMisc.h:499
EProcessDiagnosticFlags
Definition GenericPlatformMisc.h:400
ECrashHandlingType
Definition GenericPlatformMisc.h:83
EInputOutputFlags
Definition GenericPlatformMisc.h:482
EPageFaultFlags
Definition GenericPlatformMisc.h:443
CORE_API const TCHAR * LexToString(EStorageDeviceType StorageType)
Definition WindowsPlatformMisc.cpp:714
ECOMModel
Definition WindowsPlatformMisc.h:52
@ Singlethreaded
Single-Threaded Apartment (STA)
@ Multithreaded
Multi-Threaded Apartment (MTA)
EStorageDeviceType
Definition WindowsPlatformMisc.h:61
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Text.h:385
Definition GenericApplication.h:437
Definition GenericPlatformChunkInstall.h:129
Definition Array.h:670
Type
Definition GenericPlatformMisc.h:306
Type
Definition GenericPlatformMisc.h:325
Definition GenericPlatformMisc.h:270
HWND__ * HWND
Definition MinimalWindowsApi.h:81
HKEY__ * HKEY
Definition MinimalWindowsApi.h:82
Definition GenericPlatformDriver.h:156
Definition GenericPlatformMisc.h:561
Definition Guid.h:109
Definition GenericPlatformMisc.h:428
Definition WindowsPlatformMisc.h:82
uint64 FreeBytes
Definition WindowsPlatformMisc.h:88
uint64 UsedBytes
Definition WindowsPlatformMisc.h:86
EStorageDeviceType DriveType
Definition WindowsPlatformMisc.h:90
TCHAR DriveName
Definition WindowsPlatformMisc.h:84
Definition GenericPlatformMisc.h:458
Definition GenericPlatformMisc.h:418
Definition WindowsPlatformMisc.h:33
ErrorCodes
Definition WindowsPlatformMisc.h:35
@ ERROR_GETVERSIONEX_FAILED
Definition WindowsPlatformMisc.h:39
@ ERROR_GETWINDOWSGT62VERSIONS_FAILED
Definition WindowsPlatformMisc.h:40
@ SUCCEEDED
Definition WindowsPlatformMisc.h:36
@ ERROR_GETPRODUCTINFO_FAILED
Definition WindowsPlatformMisc.h:38
@ ERROR_UNKNOWNVERSION
Definition WindowsPlatformMisc.h:37
static CORE_API int32 GetOSVersions(FString &OutOSVersion, FString &OutOSSubVersion)
Definition WindowsPlatformMisc.cpp:364
Definition WindowsPlatformMisc.h:98
static CORE_API uint32 GetLastError()
Definition WindowsPlatformMisc.cpp:2833
static CORE_API void SetUTF8Output()
Definition WindowsPlatformMisc.cpp:1311
static CORE_API EConvertibleLaptopMode GetConvertibleLaptopMode()
Definition WindowsPlatformMisc.cpp:4447
static CORE_API bool DeleteStoredValue(const FString &InStoreId, const FString &InSectionName, const FString &InKeyName)
Definition WindowsPlatformMisc.cpp:2747
static CORE_API bool HasNonoptionalCPUFeatures()
Definition WindowsPlatformMisc.cpp:4184
static CORE_API bool IsRunningOnBattery()
Definition WindowsPlatformMisc.cpp:4370
static CORE_API FString GetDefaultLanguage()
Definition WindowsPlatformMisc.cpp:2799
static CORE_API const TCHAR * GetDefaultPathSeparator()
Definition WindowsPlatformMisc.cpp:4294
static CORE_API Windows::HWND GetTopLevelWindowHandle(uint32 ProcessId)
Definition WindowsPlatformMisc.cpp:2686
static CORE_API const TCHAR * GetPlatformFeaturesModuleName()
Definition WindowsPlatformMisc.cpp:2601
static CORE_API bool VerifyWindowsVersion(uint32 MajorVersion, uint32 MinorVersion, uint32 BuildNumber=0)
Definition WindowsPlatformMisc.cpp:2349
UE_DEPRECATED(4.21, "void FPlatformMisc::GetEnvironmentVariable(Name, Result, Length) is deprecated. Use FString FPlatformMisc::GetEnvironmentVariable(Name) instead.") static CORE_API void GetEnvironmentVariable(const TCHAR *VariableName
static CORE_API void CallGracefulTerminationHandler()
Definition WindowsPlatformMisc.cpp:1093
static CORE_API int32 NumberOfCoresIncludingHyperthreads()
Definition WindowsPlatformMisc.cpp:2569
static CORE_API FString GetPrimaryGPUBrand()
Definition WindowsPlatformMisc.cpp:3553
static CORE_API FText GetFileManagerName()
Definition WindowsPlatformMisc.cpp:4299
static CORE_API void PumpMessagesOutsideMainLoop()
Definition WindowsPlatformMisc.cpp:4496
static CORE_API TArray< uint8 > GetMacAddress()
Definition WindowsPlatformMisc.cpp:1198
static bool HasActiveWiFiConnection()
Definition WindowsPlatformMisc.h:329
static CORE_API ECrashHandlingType GetCrashHandlingType()
Definition WindowsPlatformMisc.cpp:1100
static CORE_API bool IsUsingBatterySaver()
Definition WindowsPlatformMisc.cpp:4394
static CORE_API FString GetHostArchitecture()
Definition WindowsPlatformMisc.cpp:4414
static CORE_API bool HasAVX2InstructionSupport()
Definition WindowsPlatformMisc.cpp:3421
static CORE_API uint32 GetCPUMicrocodeRevision()
Definition WindowsPlatformMisc.cpp:3236
TCHAR * Result
Definition WindowsPlatformMisc.h:110
static void MemoryBarrier()
Definition WindowsPlatformMisc.h:123
static CORE_API const FProcessorGroupDesc & GetProcessorGroupDesc()
Definition WindowsPlatformMisc.cpp:2563
static CORE_API FString GetDefaultLocale()
Definition WindowsPlatformMisc.cpp:2822
static CORE_API void UpdateDriveFreeSpace()
Definition WindowsPlatformMisc.cpp:4547
static CORE_API bool GetStoredValue(const FString &InStoreId, const FString &InSectionName, const FString &InKeyName, FString &OutValue)
Definition WindowsPlatformMisc.cpp:2735
static CORE_API void RequestExit(bool Force, const TCHAR *CallSite=nullptr)
Definition WindowsPlatformMisc.cpp:1350
static CORE_API bool SupportsWindows11()
Definition WindowsPlatformMisc.cpp:3530
static CORE_API int32 GetMaxPathLength()
Definition WindowsPlatformMisc.cpp:1111
static CORE_API struct FGPUDriverInfo GetGPUDriverInfo(const FString &DeviceDescription, bool bVerbose=true)
Definition WindowsPlatformMisc.cpp:3859
static CORE_API FString GetOperatingSystemId()
Definition WindowsPlatformMisc.cpp:4406
static CORE_API bool QueryRegKey(const Windows::HKEY InKey, const TCHAR *InSubKey, const TCHAR *InValueName, FString &OutData)
Definition WindowsPlatformMisc.cpp:4206
static CORE_API bool IsValidAbsolutePathFormat(const FString &Path)
Definition WindowsPlatformMisc.cpp:2390
static CORE_API bool CommandLineCommands()
Definition WindowsPlatformMisc.cpp:2317
static CORE_API bool DeleteStoredSection(const FString &InStoreId, const FString &InSectionName)
Definition WindowsPlatformMisc.cpp:2788
static CORE_API void SetEnvironmentVar(const TCHAR *VariableName, const TCHAR *Value)
Definition WindowsPlatformMisc.cpp:1184
static CORE_API void SubmitErrorReport(const TCHAR *InErrorHist, EErrorReportMode::Type InMode)
Definition WindowsPlatformMisc.cpp:1247
static CORE_API bool IsDeviceHandheld()
Definition WindowsPlatformMisc.cpp:4304
static CORE_API EProcessDiagnosticFlags GetProcessDiagnostics()
Definition WindowsPlatformMisc.cpp:1261
static CORE_API void CreateGuid(struct FGuid &Result)
Definition WindowsPlatformMisc.cpp:1431
static UE_FORCEINLINE_HINT void AsymmetricThreadFenceLight()
Definition WindowsPlatformMisc.h:134
static CORE_API bool HasSecureBootSupport()
Definition WindowsPlatformMisc.cpp:3487
static CORE_API void SetLastError(uint32 ErrorCode)
Definition WindowsPlatformMisc.cpp:2838
static bool IsLocalPrintThreadSafe()
Definition WindowsPlatformMisc.h:144
static CORE_API void RaiseException(uint32 ExceptionCode)
Definition WindowsPlatformMisc.cpp:2699
static CORE_API int32 NumberOfWorkerThreadsToSpawn()
Definition WindowsPlatformMisc.cpp:2626
static CORE_API int32 GetExternalAppMaxPathLength()
Definition WindowsPlatformMisc.cpp:1145
static CORE_API bool SetStoredValue(const FString &InStoreId, const FString &InSectionName, const FString &InKeyName, const FString &InValue)
Definition WindowsPlatformMisc.cpp:2707
static CORE_API int GetBatteryLevel()
Definition WindowsPlatformMisc.cpp:4380
static CORE_API bool HasCPUIDInstruction()
Definition WindowsPlatformMisc.cpp:3198
static CORE_API void AsymmetricThreadFenceHeavy()
UE_BUILD_SHIPPING.
Definition WindowsPlatformMisc.cpp:1297
static CORE_API FString GetCPUBrand()
Definition WindowsPlatformMisc.cpp:3208
static CORE_API IPlatformChunkInstall * GetPlatformChunkInstall()
Definition WindowsPlatformMisc.cpp:4462
static CORE_API uint32 GetCPUModelID()
Definition WindowsPlatformMisc.cpp:3213
static CORE_API uint64 GetFileVersion(const FString &FileName)
Definition WindowsPlatformMisc.cpp:4506
static CORE_API uint32 GetCPUInfo()
Definition WindowsPlatformMisc.cpp:4179
static CORE_API void PlatformPreInit()
Definition WindowsPlatformMisc.cpp:896
static CORE_API void SetGracefulTerminationHandler()
Definition WindowsPlatformMisc.cpp:1048
static CORE_API void LocalPrint(const TCHAR *Message)
Definition WindowsPlatformMisc.cpp:1318
static CORE_API int32 GetCacheLineSize()
Definition WindowsPlatformMisc.cpp:4201
static CORE_API int32 GetMaxRefreshRate()
Definition WindowsPlatformMisc.cpp:4526
static CORE_API bool CoInitialize(ECOMModel Model=ECOMModel::Singlethreaded)
Definition WindowsPlatformMisc.cpp:2843
static CORE_API void PromptForRemoteDebugging(bool bIsEnsure)
Definition WindowsPlatformMisc.cpp:2857
static CORE_API bool NeedsNonoptionalCPUFeaturesCheck()
Definition WindowsPlatformMisc.cpp:4190
static CORE_API int32 NumberOfCores()
Definition WindowsPlatformMisc.cpp:2521
static CORE_API void PlatformInit()
Definition WindowsPlatformMisc.cpp:946
static CORE_API FString GetOSVersion()
Definition WindowsPlatformMisc.cpp:4106
static CORE_API FString GetCPUVendor()
Definition WindowsPlatformMisc.cpp:3203
static CORE_API bool IsDebuggerPresent()
Definition WindowsPlatformMisc.cpp:1256
static CORE_API bool HasTPM2Support()
Definition WindowsPlatformMisc.cpp:3432
static CORE_API FString GetEnvironmentVariable(const TCHAR *VariableName)
Definition WindowsPlatformMisc.cpp:1151
static CORE_API bool HasTimedPauseCPUFeature()
Definition WindowsPlatformMisc.cpp:4196
static CORE_API const FPlatformDriveStats * GetDriveStats(WIDECHAR DriveLetter)
Definition WindowsPlatformMisc.cpp:4561
static CORE_API void RequestExitWithStatus(bool Force, uint8 ReturnCode, const TCHAR *CallSite=nullptr)
Definition WindowsPlatformMisc.cpp:1366
static CORE_API bool GetPageFaultStats(FPageFaultStats &OutStats, EPageFaultFlags Flags=EPageFaultFlags::All)
Definition WindowsPlatformMisc.cpp:4135
static CORE_API void CoUninitialize()
Definition WindowsPlatformMisc.cpp:2849
static CORE_API const TCHAR * GetSystemErrorMessage(TCHAR *OutBuffer, int32 BufferCount, int32 Error)
Definition WindowsPlatformMisc.cpp:1409
static CORE_API ECrashHandlingType SetCrashHandlingType(ECrashHandlingType)
Definition WindowsPlatformMisc.cpp:1105
static void ChooseHDRDeviceAndColorGamut(uint32 DeviceId, uint32 DisplayNitLevel, EDisplayOutputFormat &OutputDevice, EDisplayColorGamut &ColorGamut)
Definition WindowsPlatformMisc.h:356
static CORE_API bool GetDiskTotalAndFreeSpace(const FString &InPath, uint64 &TotalNumberOfBytes, uint64 &NumberOfFreeBytes)
Definition WindowsPlatformMisc.cpp:4124
static CORE_API bool IsRemoteSession()
Definition WindowsPlatformMisc.cpp:1306
static CORE_API bool OsExecute(const TCHAR *CommandType, const TCHAR *Command, const TCHAR *CommandLine=NULL)
Definition WindowsPlatformMisc.cpp:2649
static CORE_API bool GetBlockingIOStats(FProcessIOStats &OutStats, EInputOutputFlags Flags=EInputOutputFlags::All)
Definition WindowsPlatformMisc.cpp:4154
static CORE_API void GetOSVersions(FString &out_OSVersionLabel, FString &out_OSSubVersionLabel)
Definition WindowsPlatformMisc.cpp:4086
static CORE_API bool GetVSComnTools(int32 Version, FString &OutData)
Definition WindowsPlatformMisc.cpp:4269
static CORE_API bool Is64bitOperatingSystem()
Definition WindowsPlatformMisc.cpp:2327
static CORE_API void PlatformTearDown()
Definition WindowsPlatformMisc.cpp:979
static CORE_API bool IsWine()
Definition WindowsPlatformMisc.cpp:2365
TCHAR int32 ResultLength
Definition WindowsPlatformMisc.h:110
static CORE_API EAppReturnType::Type MessageBoxExt(EAppMsgType::Type MsgType, const TCHAR *Text, const TCHAR *Caption)
Definition WindowsPlatformMisc.cpp:2003