UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MinimalWindowsApi.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3//=====================================================================================================================
4// Implementation of a minimal subset of the Windows API required for inline function definitions and platform-specific
5// interfaces in Core. Use of this file allows avoiding including large platform headers in the public engine API.
6//
7// Win32 API functions are declared in the "Windows" namespace to avoid conflicts if the real Windows.h is included
8// later, but are mapped to the same imported symbols by the linker due to C-style linkage.
9//=====================================================================================================================
10
11#pragma once
12
13#include "CoreTypes.h"
14
15#ifdef __clang__
16 #define MINIMAL_WINDOWS_API CORE_API
17#else
18 #define MINIMAL_WINDOWS_API extern "C" __declspec(dllimport)
19#endif
20
21// The 10.0.18362.0 SDK introduces an error if the packing isn't the default for the platform.
23
24// Undefine Windows types that we're going to redefine. This should be done by HideWindowsPlatformTypes.h after including any system headers,
25// but it's less friction to just undefine them here.
26#pragma push_macro("TRUE")
27#pragma push_macro("FALSE")
28#undef TRUE
29#undef FALSE
30
31// Use strongly typed handles
32#ifndef STRICT
33#define STRICT
34#endif
35
36// With STRICT enabled, handles are implemented as opaque struct pointers. We can prototype these structs here and
37// typedef them under the Windows namespace below. Since typedefs are only aliases rather than types in their own
38// right, this allows using handles from the Windows:: namespace interchangably with their native definition.
39struct HINSTANCE__;
40struct HWND__;
41struct HKEY__;
42struct HDC__;
43struct HICON__;
44struct _RTL_SRWLOCK;
45
46// Other types
49struct _OVERLAPPED;
51union _LARGE_INTEGER;
52
53// Global constants
54#define WINDOWS_MAX_PATH 260
55#define WINDOWS_PF_COMPARE_EXCHANGE128 14
56
57// Standard calling convention for Win32 functions
58#define WINAPI __stdcall
59
60// Minimal subset of the Windows API required for interfaces and inline functions
61namespace Windows
62{
63 // Typedefs for basic Windows types
64 typedef int32 BOOL;
65 typedef unsigned char BYTE;
66 typedef BYTE BOOLEAN;
67 typedef unsigned long DWORD;
68 typedef DWORD* LPDWORD;
69 typedef long LONG;
70 typedef long* LPLONG;
71 typedef int64 LONGLONG;
73 typedef void* LPVOID;
74 typedef const void* LPCVOID;
75 typedef const wchar_t* LPCTSTR;
76
77 // Typedefs for standard handles
78 typedef void* HANDLE;
81 typedef HWND__* HWND;
82 typedef HKEY__* HKEY;
83 typedef HDC__* HDC;
84 typedef HICON__* HICON;
85 typedef HICON__* HCURSOR;
86
87 // Other typedefs
93
96
98
99
100 // Opaque SRWLOCK structure
101 struct SRWLOCK
102 {
103 void* Ptr;
104 };
105
106 // Constants
107 inline constexpr BOOL TRUE = 1;
108 inline constexpr BOOL FALSE = 0;
109
110 // Modules
113
114 // Critical sections
122
130
135
140
145
150
155
160
165
166 // I/O
171
172 // Timing
174
175 // Thread-local storage functions
181
182 // Fiber-local storage functions
187
188 // System
190
191 // For structures which are opaque
192 struct CRITICAL_SECTION { void* Opaque1[1]; long Opaque2[2]; void* Opaque3[3]; };
193 struct OVERLAPPED { void *Opaque[3]; unsigned long Opaque2[2]; };
195
200
205
210
215
220
225
230
235
240
245
250
255}
256
257// Restore the definitions for TRUE and FALSE
258#pragma pop_macro("FALSE")
259#pragma pop_macro("TRUE")
260
261// Restore the packing setting
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PRAGMA_POP_PLATFORM_DEFAULT_PACKING
Definition MSVCPlatformCompilerPreSetup.h:229
#define PRAGMA_PUSH_PLATFORM_DEFAULT_PACKING
Definition MSVCPlatformCompilerPreSetup.h:223
#define WINAPI
Definition MinimalWindowsApi.h:58
#define MINIMAL_WINDOWS_API
Definition MinimalWindowsApi.h:18
Definition MinimalWindowsApi.h:62
MINIMAL_WINDOWS_API BOOL WINAPI FlsSetValue(DWORD dwFlsIndex, LPVOID lpFlsValue)
void(* PFLS_CALLBACK_FUNCTION)(void *lpFlsData)
Definition MinimalWindowsApi.h:97
MINIMAL_WINDOWS_API void WINAPI AcquireSRWLockExclusive(PSRWLOCK SRWLock)
long LONG
Definition MinimalWindowsApi.h:69
int64 LONGLONG
Definition MinimalWindowsApi.h:71
MINIMAL_WINDOWS_API BOOL WINAPI TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
MINIMAL_WINDOWS_API void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
MINIMAL_WINDOWS_API BOOL WINAPI QueryPerformanceCounter(LPLARGE_INTEGER Cycles)
unsigned long DWORD
Definition MinimalWindowsApi.h:67
_RTL_SRWLOCK * PRTL_SRWLOCK
Definition MinimalWindowsApi.h:94
MINIMAL_WINDOWS_API BOOL WINAPI FlsFree(DWORD dwTlsIndex)
MINIMAL_WINDOWS_API BOOL WINAPI FreeLibrary(HMODULE hModule)
MINIMAL_WINDOWS_API DWORD WINAPI GetCurrentThreadId()
MINIMAL_WINDOWS_API LPVOID WINAPI TlsGetValue(DWORD dwTlsIndex)
MINIMAL_WINDOWS_API void WINAPI InitializeCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
tagPROCESSENTRY32W PROCESSENTRY32
Definition MinimalWindowsApi.h:88
constexpr BOOL TRUE
Definition MinimalWindowsApi.h:107
MINIMAL_WINDOWS_API BOOLEAN WINAPI TryAcquireSRWLockShared(PSRWLOCK SRWLock)
HICON__ * HICON
Definition MinimalWindowsApi.h:84
MINIMAL_WINDOWS_API BOOL WINAPI TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
LONGLONG * LPLONGLONG
Definition MinimalWindowsApi.h:72
MINIMAL_WINDOWS_API BOOL WINAPI InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount)
long * LPLONG
Definition MinimalWindowsApi.h:70
BYTE BOOLEAN
Definition MinimalWindowsApi.h:66
HDC__ * HDC
Definition MinimalWindowsApi.h:83
MINIMAL_WINDOWS_API HMODULE WINAPI LoadLibraryW(LPCTSTR lpFileName)
MINIMAL_WINDOWS_API void WINAPI AcquireSRWLockShared(PSRWLOCK SRWLock)
_LARGE_INTEGER * LPLARGE_INTEGER
Definition MinimalWindowsApi.h:92
_EXCEPTION_POINTERS * LPEXCEPTION_POINTERS
Definition MinimalWindowsApi.h:89
void * HANDLE
Definition MinimalWindowsApi.h:78
const void * LPCVOID
Definition MinimalWindowsApi.h:74
HWND__ * HWND
Definition MinimalWindowsApi.h:81
MINIMAL_WINDOWS_API void WINAPI ReleaseSRWLockShared(PSRWLOCK SRWLock)
MINIMAL_WINDOWS_API BOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped)
DWORD * LPDWORD
Definition MinimalWindowsApi.h:68
RTL_SRWLOCK * PSRWLOCK
Definition MinimalWindowsApi.h:95
_RTL_SRWLOCK RTL_SRWLOCK
Definition MinimalWindowsApi.h:94
MINIMAL_WINDOWS_API BOOLEAN WINAPI TryAcquireSRWLockExclusive(PSRWLOCK SRWLock)
_RTL_CRITICAL_SECTION * LPCRITICAL_SECTION
Definition MinimalWindowsApi.h:90
MINIMAL_WINDOWS_API BOOL WINAPI GetOverlappedResult(HANDLE hFile, LPOVERLAPPED lpOverlapped, LPDWORD lpNumberOfBytesTransferred, BOOL bWait)
MINIMAL_WINDOWS_API void WINAPI ReleaseSRWLockExclusive(PSRWLOCK SRWLock)
unsigned char BYTE
Definition MinimalWindowsApi.h:65
const wchar_t * LPCTSTR
Definition MinimalWindowsApi.h:75
MINIMAL_WINDOWS_API BOOL WINAPI TlsFree(DWORD dwTlsIndex)
HINSTANCE HMODULE
Definition MinimalWindowsApi.h:80
MINIMAL_WINDOWS_API void WINAPI EnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
MINIMAL_WINDOWS_API DWORD WINAPI SetCriticalSectionSpinCount(LPCRITICAL_SECTION lpCriticalSection, DWORD dwSpinCount)
MINIMAL_WINDOWS_API BOOL WINAPI IsProcessorFeaturePresent(DWORD ProcessorFeature)
int32 BOOL
Definition MinimalWindowsApi.h:64
MINIMAL_WINDOWS_API LPVOID WINAPI FlsGetValue(DWORD dwFlsIndex)
MINIMAL_WINDOWS_API BOOL WINAPI ConnectNamedPipe(HANDLE hNamedPipe, LPOVERLAPPED lpOverlapped)
void * LPVOID
Definition MinimalWindowsApi.h:73
constexpr BOOL FALSE
Definition MinimalWindowsApi.h:108
MINIMAL_WINDOWS_API void WINAPI InitializeSRWLock(PSRWLOCK SRWLock)
HICON__ * HCURSOR
Definition MinimalWindowsApi.h:85
_OVERLAPPED * LPOVERLAPPED
Definition MinimalWindowsApi.h:91
HINSTANCE__ * HINSTANCE
Definition MinimalWindowsApi.h:79
MINIMAL_WINDOWS_API DWORD WINAPI TlsAlloc()
MINIMAL_WINDOWS_API DWORD WINAPI FlsAlloc(PFLS_CALLBACK_FUNCTION lpCallback)
HKEY__ * HKEY
Definition MinimalWindowsApi.h:82
MINIMAL_WINDOWS_API BOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped)
MINIMAL_WINDOWS_API void WINAPI DeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
Definition MinimalWindowsApi.h:192
void * Opaque3[3]
Definition MinimalWindowsApi.h:192
void * Opaque1[1]
Definition MinimalWindowsApi.h:192
long Opaque2[2]
Definition MinimalWindowsApi.h:192
Definition MinimalWindowsApi.h:193
void * Opaque[3]
Definition MinimalWindowsApi.h:193
unsigned long Opaque2[2]
Definition MinimalWindowsApi.h:193
Definition MinimalWindowsApi.h:102
void * Ptr
Definition MinimalWindowsApi.h:103
Definition MinimalWindowsApi.h:194
LONGLONG QuadPart
Definition MinimalWindowsApi.h:194
DWORD LowPart
Definition MinimalWindowsApi.h:194
LONG HighPart
Definition MinimalWindowsApi.h:194