Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
windows_types.h
Go to the documentation of this file.
1// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// This file contains defines and typedefs that allow popular Windows types to
6// be used without the overhead of including windows.h.
7
8#ifndef BASE_WIN_WINDOWS_TYPES_H_
9#define BASE_WIN_WINDOWS_TYPES_H_
10
11// Needed for function prototypes.
12#include <concurrencysal.h>
13#include <sal.h>
14#include <specstrings.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20// typedef and define the most commonly used Windows integer types.
21
22typedef unsigned long DWORD;
23typedef long LONG;
24typedef __int64 LONGLONG;
25typedef unsigned __int64 ULONGLONG;
26
27#define VOID void
28typedef char CHAR;
29typedef short SHORT;
30typedef long LONG;
31typedef int INT;
32typedef unsigned int UINT;
33typedef unsigned int* PUINT;
34typedef void* LPVOID;
35typedef void* PVOID;
36typedef void* HANDLE;
37typedef int BOOL;
38typedef unsigned char BYTE;
39typedef BYTE BOOLEAN;
40typedef DWORD ULONG;
41typedef unsigned short WORD;
42typedef WORD UWORD;
43typedef WORD ATOM;
44
45#if defined(_WIN64)
46typedef __int64 INT_PTR, *PINT_PTR;
47typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
48
49typedef __int64 LONG_PTR, *PLONG_PTR;
50typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
51#else
52typedef __w64 int INT_PTR, *PINT_PTR;
53typedef __w64 unsigned int UINT_PTR, *PUINT_PTR;
54
55typedef __w64 long LONG_PTR, *PLONG_PTR;
56typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR;
57#endif
58
62#define LRESULT LONG_PTR
63typedef _Return_type_success_(return >= 0) long HRESULT;
64
67
70
71typedef LONG NTSTATUS;
72
73// As defined in guiddef.h.
74#ifndef _REFGUID_DEFINED
75#define _REFGUID_DEFINED
76#define REFGUID const GUID&
77#endif
78
79// Forward declare Windows compatible handles.
80
81#define CHROME_DECLARE_HANDLE(name) \
82 struct name##__; \
83 typedef struct name##__* name
93#undef CHROME_DECLARE_HANDLE
94
96typedef HINSTANCE HMODULE;
99
100// Forward declare some Windows struct/typedef sets.
101
102typedef struct _OVERLAPPED OVERLAPPED;
103typedef struct tagMSG MSG, *PMSG, *NPMSG, *LPMSG;
104
105typedef struct _RTL_SRWLOCK RTL_SRWLOCK;
107
108typedef struct _GUID GUID;
109typedef GUID CLSID;
110
111typedef struct tagLOGFONTW LOGFONTW, *PLOGFONTW, *NPLOGFONTW, *LPLOGFONTW;
113
114typedef struct _FILETIME FILETIME;
115
116typedef struct tagMENUITEMINFOW MENUITEMINFOW, MENUITEMINFO;
117
118typedef struct tagNMHDR NMHDR;
119
120typedef struct _SP_DEVINFO_DATA SP_DEVINFO_DATA;
121
122typedef PVOID PSID;
123
124// Declare Chrome versions of some Windows structures. These are needed for
125// when we need a concrete type but don't want to pull in Windows.h. We can't
126// declare the Windows types so we declare our types and cast to the Windows
127// types in a few places.
128
132
136
137// Define some commonly used Windows constants. Note that the layout of these
138// macros - including internal spacing - must be 100% consistent with windows.h.
139
140// clang-format off
141
142#ifndef INVALID_HANDLE_VALUE
143// Work around there being two slightly different definitions in the SDK.
144#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1)
145#endif
146#define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
147#define HTNOWHERE 0
148#define MAX_PATH 260
149#define CS_GLOBALCLASS 0x4000
150
151#define ERROR_SUCCESS 0L
152#define ERROR_FILE_NOT_FOUND 2L
153#define ERROR_ACCESS_DENIED 5L
154#define ERROR_INVALID_HANDLE 6L
155#define ERROR_SHARING_VIOLATION 32L
156#define ERROR_LOCK_VIOLATION 33L
157#define REG_BINARY ( 3ul )
158
159#define STATUS_PENDING ((DWORD )0x00000103L)
160#define STILL_ACTIVE STATUS_PENDING
161#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
162#define FAILED(hr) (((HRESULT)(hr)) < 0)
163
164#define HKEY_CLASSES_ROOT (( HKEY ) (ULONG_PTR)((LONG)0x80000000) )
165#define HKEY_LOCAL_MACHINE (( HKEY ) (ULONG_PTR)((LONG)0x80000002) )
166#define HKEY_CURRENT_USER (( HKEY ) (ULONG_PTR)((LONG)0x80000001) )
167#define KEY_QUERY_VALUE (0x0001)
168#define KEY_SET_VALUE (0x0002)
169#define KEY_CREATE_SUB_KEY (0x0004)
170#define KEY_ENUMERATE_SUB_KEYS (0x0008)
171#define KEY_NOTIFY (0x0010)
172#define KEY_CREATE_LINK (0x0020)
173#define KEY_WOW64_32KEY (0x0200)
174#define KEY_WOW64_64KEY (0x0100)
175#define KEY_WOW64_RES (0x0300)
176
177#define READ_CONTROL (0x00020000L)
178#define SYNCHRONIZE (0x00100000L)
179
180#define STANDARD_RIGHTS_READ (READ_CONTROL)
181#define STANDARD_RIGHTS_WRITE (READ_CONTROL)
182#define STANDARD_RIGHTS_ALL (0x001F0000L)
183
184#define KEY_READ ((STANDARD_RIGHTS_READ |\
185 KEY_QUERY_VALUE |\
186 KEY_ENUMERATE_SUB_KEYS |\
187 KEY_NOTIFY) \
188 & \
189 (~SYNCHRONIZE))
190
191
192#define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
193 KEY_SET_VALUE |\
194 KEY_CREATE_SUB_KEY) \
195 & \
196 (~SYNCHRONIZE))
197
198#define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
199 KEY_QUERY_VALUE |\
200 KEY_SET_VALUE |\
201 KEY_CREATE_SUB_KEY |\
202 KEY_ENUMERATE_SUB_KEYS |\
203 KEY_NOTIFY |\
204 KEY_CREATE_LINK) \
205 & \
206 (~SYNCHRONIZE))
207
208// clang-format on
209
210// Define some macros needed when prototyping Windows functions.
211
212#define DECLSPEC_IMPORT __declspec(dllimport)
213#define WINBASEAPI DECLSPEC_IMPORT
214#define WINUSERAPI DECLSPEC_IMPORT
215#define WINAPI __stdcall
216#define CALLBACK __stdcall
217
218// Needed for LockImpl.
219WINBASEAPI _Releases_exclusive_lock_(*SRWLock) VOID WINAPI
222
223// Needed to support protobuf's GetMessage macro magic.
225 _In_opt_ HWND hWnd,
226 _In_ UINT wMsgFilterMin,
227 _In_ UINT wMsgFilterMax);
228
229// Needed for thread_local_storage.h
231
232// Needed for scoped_handle.h
233WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI
235
237
238#ifdef __cplusplus
239}
240#endif
241
242// These macros are all defined by windows.h and are also used as the names of
243// functions in the Chromium code base. Add to this list as needed whenever
244// there is a Windows macro which causes a function call to be renamed. This
245// ensures that the same renaming will happen everywhere. Includes of this file
246// can be added wherever needed to ensure this consistent renaming.
247
248#define CopyFile CopyFileW
249#define CreateDirectory CreateDirectoryW
250#define CreateEvent CreateEventW
251#define CreateFile CreateFileW
252#define CreateService CreateServiceW
253#define DeleteFile DeleteFileW
254#define DispatchMessage DispatchMessageW
255#define DrawText DrawTextW
256#define FindFirstFile FindFirstFileW
257#define FindNextFile FindNextFileW
258#define GetComputerName GetComputerNameW
259#define GetCurrentDirectory GetCurrentDirectoryW
260#define GetCurrentTime() GetTickCount()
261#define GetFileAttributes GetFileAttributesW
262#define GetMessage GetMessageW
263#define GetUserName GetUserNameW
264#define LoadIcon LoadIconW
265#define LoadImage LoadImageW
266#define PostMessage PostMessageW
267#define RemoveDirectory RemoveDirectoryW
268#define ReplaceFile ReplaceFileW
269#define ReportEvent ReportEventW
270#define SendMessage SendMessageW
271#define SendMessageCallback SendMessageCallbackW
272#define SetCurrentDirectory SetCurrentDirectoryW
273#define StartService StartServiceW
274#define UpdateResource UpdateResourceW
275
276#endif // BASE_WIN_WINDOWS_TYPES_H_
ULONG_PTR * PSIZE_T
DWORD ACCESS_MASK
int BOOL
PVOID HDEVINFO
struct tagMSG * LPMSG
__w64 unsigned int UINT_PTR
LOGFONTW LOGFONT
WORD ATOM
unsigned short WORD
__w64 unsigned int * PUINT_PTR
LONG_PTR SSIZE_T
struct tagMSG MSG
RTL_SRWLOCK * PSRWLOCK
long LONG
typedef _Return_type_success_(return >=0) long HRESULT
void * PVOID
BYTE BOOLEAN
LPVOID HINTERNET
unsigned int UINT
int INT
LONG_PTR LPARAM
struct tagLOGFONTW * LPLOGFONTW
unsigned char BYTE
__w64 unsigned long * PULONG_PTR
struct tagLOGFONTW * PLOGFONTW
WINBASEAPI BOOLEAN WINAPI TryAcquireSRWLockExclusive(_Inout_ PSRWLOCK SRWLock)
WORD UWORD
WINUSERAPI BOOL WINAPI GetMessageW(_Out_ LPMSG lpMsg, _In_opt_ HWND hWnd, _In_ UINT wMsgFilterMin, _In_ UINT wMsgFilterMax)
__int64 LONGLONG
LONG NTSTATUS
PVOID PSID
__w64 long * PLONG_PTR
#define CHROME_DECLARE_HANDLE(name)
struct tagMSG * NPMSG
#define VOID
WINBASEAPI _Releases_exclusive_lock_ SRWLock VOID WINAPI ReleaseSRWLockExclusive(_Inout_ PSRWLOCK SRWLock)
WINBASEAPI LPVOID WINAPI TlsGetValue(_In_ DWORD dwTlsIndex)
RTL_SRWLOCK SRWLOCK
__w64 long LONG_PTR
WINBASEAPI VOID WINAPI SetLastError(_In_ DWORD dwErrCode)
__w64 int INT_PTR
struct _FILETIME FILETIME
unsigned int * PUINT
short SHORT
LONG_PTR * PSSIZE_T
#define WINAPI
struct tagLOGFONTW LOGFONTW
#define WINBASEAPI
struct tagNMHDR NMHDR
struct _RTL_SRWLOCK RTL_SRWLOCK
WINBASEAPI _Check_return_ _Post_equals_last_error_ DWORD WINAPI GetLastError(VOID)
struct tagMSG * PMSG
UINT_PTR WPARAM
void * HANDLE
struct _OVERLAPPED OVERLAPPED
DWORD ULONG
void * LPVOID
#define LRESULT
__w64 unsigned long ULONG_PTR
ACCESS_MASK REGSAM
__w64 int * PINT_PTR
unsigned __int64 ULONGLONG
struct tagLOGFONTW * NPLOGFONTW
unsigned long DWORD
GUID CLSID
struct _GUID GUID
struct tagMENUITEMINFOW MENUITEMINFO
struct _SP_DEVINFO_DATA SP_DEVINFO_DATA
HINSTANCE HMODULE
char CHAR
ULONG_PTR SIZE_T
PVOID LSA_HANDLE
struct tagMENUITEMINFOW MENUITEMINFOW
#define WINUSERAPI