Bug 1448426 - Wrap windows.h to avoid problematic define statements, r=froydnj,glandium
☠☠ backed out by 9bfe29337ffe ☠ ☠
authorNika Layzell <nika@thelayzells.com>
Tue, 25 Sep 2018 17:34:53 +0200
changeset 504874 e0f95dd96d5458f60980f1e8b3f846beed6e5817
parent 504873 c60fa11538dba13f2eced54a835a4a0ff65a0ebd
child 504875 0bad27401ddb5372cabc01e63d4ea0a2f9743e6f
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, glandium
bugs1448426
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1448426 - Wrap windows.h to avoid problematic define statements, r=froydnj,glandium By default, windows.h exposes a large number of problematic define statements which are UpperCamelCase, such as a define from `CreateWindow` to `CreateWindow{A,W}`. As many of these names are generic (e.g. CreateFile, CreateWindow), they can mess up Gecko code that may legitimately have its own methods with the same names. The header also defines some traditional SCREAMING_SNAKE_CASE defines which can mess up our code by conflicting with local values. This patch adds a simple code generator which generates wrappers for these defines, and uses them to wrap the windows.h wrapper using the `stl_wrappers` mechanism, allowing us to use windows.h in more places. Differential Revision: https://phabricator.services.mozilla.com/D10932
config/make-stl-wrappers.py
config/make-windows-h-wrapper.py
config/moz.build
config/system_header_util.py
config/windows-h-constant.decls.h
config/windows-h-unicode.decls.h
config/windows-h-wrapper.template.h
dom/base/moz.build
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowOuter.cpp
gfx/cairo/cairo/src/moz.build
gfx/thebes/gfxDWriteFonts.cpp
gfx/vr/service/openvr/moz.build
python/mozbuild/mozbuild/backend/common.py
--- a/config/make-stl-wrappers.py
+++ b/config/make-stl-wrappers.py
@@ -1,34 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import print_function
 import os
 import string
 from mozbuild.util import FileAvoidWrite
-
-
-def find_in_path(file, searchpath):
-    for dir in searchpath.split(os.pathsep):
-        f = os.path.join(dir, file)
-        if os.path.exists(f):
-            return f
-    return ''
-
+from system_header_util import header_path
 
-def header_path(header, compiler):
-    if compiler == 'gcc':
-        # we use include_next on gcc
-        return header
-    elif compiler == 'msvc':
-        return find_in_path(header, os.environ.get('INCLUDE', ''))
-    else:
-        # hope someone notices this ...
-        raise NotImplementedError(compiler)
 
 # The 'unused' arg is the output file from the file_generate action. We actually
 # generate all the files in header_list
 
 
 def gen_wrappers(unused, outdir, compiler, template_file, *header_list):
     template = open(template_file, 'r').read()
 
new file mode 100644
--- /dev/null
+++ b/config/make-windows-h-wrapper.py
@@ -0,0 +1,86 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+import re
+import textwrap
+import string
+from system_header_util import header_path
+
+comment_re = re.compile(r'//[^\n]*\n|/\*.*\*/', re.S)
+decl_re = re.compile(r'''^(.+)\s+        # type
+                         (\w+)\s*        # name
+                         (?:\((.*)\))?$  # optional param tys
+                         ''', re.X | re.S)
+
+
+def read_decls(filename):
+    """Parse & yield C-style decls from an input file"""
+    with open(filename, 'r') as fd:
+        # Strip comments from the source text.
+        text = comment_re.sub('', fd.read())
+
+        # Parse individual declarations.
+        raw_decls = [d.strip() for d in text.split(';') if d.strip()]
+        for raw in raw_decls:
+            match = decl_re.match(raw)
+            if match is None:
+                raise "Invalid decl: %s" % raw
+
+            ty, name, params = match.groups()
+            if params is not None:
+                params = [a.strip() for a in params.split(',') if a.strip()]
+            yield ty, name, params
+
+
+def generate(fd, consts_path, unicodes_path, template_path, compiler):
+    # Parse the template
+    with open(template_path, 'r') as template_fd:
+        template = string.Template(template_fd.read())
+
+    decls = ''
+
+    # Each constant should be saved to a temporary, and then re-assigned to a
+    # constant with the correct name, allowing the value to be determined by
+    # the actual definition.
+    for ty, name, args in read_decls(consts_path):
+        assert args is None, "parameters in const decl!"
+
+        decls += textwrap.dedent("""
+            #ifdef {name}
+            constexpr {ty} _tmp_{name} = {name};
+            #undef {name}
+            constexpr {ty} {name} = _tmp_{name};
+            #endif
+            """.format(ty=ty, name=name))
+
+    # Each unicode declaration defines a static inline function with the
+    # correct types which calls the 'A' or 'W'-suffixed versions of the
+    # function. Full types are required here to ensure that '0' to 'nullptr'
+    # coersions are preserved.
+    for ty, name, args in read_decls(unicodes_path):
+        assert args is not None, "argument list required for unicode decl"
+
+        # Parameter & argument string list
+        params = ', '.join('%s a%d' % (ty, i) for i, ty in enumerate(args))
+        args = ', '.join('a%d' % i for i in range(len(args)))
+
+        decls += textwrap.dedent("""
+            #ifdef {name}
+            #undef {name}
+            static inline {ty} WINAPI
+            {name}({params})
+            {{
+            #ifdef UNICODE
+              return {name}W({args});
+            #else
+              return {name}A({args});
+            #endif
+            }}
+            #endif
+            """.format(ty=ty, name=name, params=params, args=args))
+
+    path = header_path('windows.h', compiler)
+
+    # Write out the resulting file
+    fd.write(template.substitute(header_path=path, decls=decls))
--- a/config/moz.build
+++ b/config/moz.build
@@ -58,16 +58,29 @@ if CONFIG['WRAP_STL_INCLUDES']:
         # the files in gen_wrappers()
         outputs = tuple(['stl.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers])
         GENERATED_FILES += [outputs]
         stl = GENERATED_FILES[outputs]
         stl.script = 'make-stl-wrappers.py:gen_wrappers'
         stl.flags = [output_dir, stl_compiler, template_file]
         stl.flags.extend(stl_headers)
 
+    # Wrap <windows.h> to make it easier to use correctly
+    # NOTE: If we aren't wrapping STL includes, we're building part of the browser
+    # which won't need this wrapper, such as L10N. Just don't try to generate the
+    # wrapper in that case.
+    if CONFIG['OS_ARCH'] == 'WINNT':
+        GENERATED_FILES += ['../dist/stl_wrappers/windows.h']
+        windows_h = GENERATED_FILES['../dist/stl_wrappers/windows.h']
+        windows_h.script = 'make-windows-h-wrapper.py:generate'
+        windows_h.inputs = ['windows-h-constant.decls.h',
+                            'windows-h-unicode.decls.h',
+                            'windows-h-wrapper.template.h']
+        windows_h.flags = [stl_compiler]
+
 if CONFIG['WRAP_SYSTEM_INCLUDES']:
     include('system-headers.mozbuild')
     output_dir = '../dist/system_wrappers'
     outputs = tuple(['system-header.sentinel'] + ['%s/%s' % (output_dir, h) for h in stl_headers + system_headers])
     GENERATED_FILES += [outputs]
     system = GENERATED_FILES[outputs]
     system.script = 'make-system-wrappers.py:gen_wrappers'
     system.flags = [output_dir]
new file mode 100644
--- /dev/null
+++ b/config/system_header_util.py
@@ -0,0 +1,20 @@
+import os
+
+
+def find_in_path(file, searchpath):
+    for dir in searchpath.split(os.pathsep):
+        f = os.path.join(dir, file)
+        if os.path.exists(f):
+            return f
+    return ''
+
+
+def header_path(header, compiler):
+    if compiler == 'gcc':
+        # we use include_next on gcc
+        return header
+    elif compiler == 'msvc':
+        return find_in_path(header, os.environ.get('INCLUDE', ''))
+    else:
+        # hope someone notices this ...
+        raise NotImplementedError(compiler)
new file mode 100644
--- /dev/null
+++ b/config/windows-h-constant.decls.h
@@ -0,0 +1,57 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * This file contains a series of C-style declarations for constants defined in
+ * windows.h using #define. Adding a new constant should be a simple as adding
+ * its name (and optionally type) to this file.
+ *
+ * This file is processed by generate-windows-h-wrapper.py to generate a wrapper
+ * for the header which removes the defines usually implementing these constants.
+ *
+ * Wrappers defined in this file will be declared as `constexpr` values,
+ * and will have their value derived from the windows.h define.
+ *
+ * NOTE: This is *NOT* a real C header, but rather an input to the avove script.
+ * Only basic declarations in the form found here are allowed.
+ */
+
+// XXX(nika): There are a lot of these (>30k)!
+// This is just a set of ones I saw in a quick scan which looked problematic.
+
+auto CREATE_NEW;
+auto CREATE_ALWAYS;
+auto OPEN_EXISTING;
+auto OPEN_ALWAYS;
+auto TRUNCATE_EXISTING;
+auto INVALID_FILE_SIZE;
+auto INVALID_SET_FILE_POINTER;
+auto INVALID_FILE_ATTRIBUTES;
+
+auto ANSI_NULL;
+auto UNICODE_NULL;
+
+auto MINCHAR;
+auto MAXCHAR;
+auto MINSHORT;
+auto MAXSHORT;
+auto MINLONG;
+auto MAXLONG;
+auto MAXBYTE;
+auto MAXWORD;
+auto MAXDWORD;
+
+auto DELETE;
+auto READ_CONTROL;
+auto WRITE_DAC;
+auto WRITE_OWNER;
+auto SYNCHRONIZE;
+
+auto MAXIMUM_ALLOWED;
+auto GENERIC_READ;
+auto GENERIC_WRITE;
+auto GENERIC_EXECUTE;
+auto GENERIC_ALL;
new file mode 100644
--- /dev/null
+++ b/config/windows-h-unicode.decls.h
@@ -0,0 +1,1052 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/*
+ * This file contains a series of C-style function prototypes for A/W-suffixed
+ * Win32 APIs defined by windows.h.
+ *
+ * This file is processed by generate-windows-h-wrapper.py to generate a wrapper
+ * for the header which removes the defines usually implementing these aliases.
+ *
+ * Wrappers defined in this file will have the 'stdcall' calling convention,
+ * will be defined as 'inline', and will only be defined if the corresponding
+ * #define directive has not been #undef-ed.
+ *
+ * NOTE: This is *NOT* a real C header, but rather an input to the avove script.
+ * Only basic declarations in the form found here are allowed.
+ */
+
+LPTSTR GetCommandLine();
+
+BOOL FreeEnvironmentStrings(LPTCH);
+
+DWORD GetEnvironmentVariable(LPCTSTR, LPTSTR, DWORD);
+
+BOOL SetEnvironmentVariable(LPCTSTR, LPCTSTR);
+
+DWORD ExpandEnvironmentStrings(LPCTSTR, LPTSTR, DWORD);
+
+BOOL SetCurrentDirectory(LPCTSTR);
+
+DWORD GetCurrentDirectory(DWORD, LPTSTR);
+
+DWORD SearchPath(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, LPTSTR, LPTSTR*);
+
+BOOL NeedCurrentDirectoryForExePath(LPCTSTR);
+
+BOOL CreateDirectory(LPCTSTR, LPSECURITY_ATTRIBUTES);
+
+HANDLE CreateFile(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE);
+
+BOOL DeleteFile(LPCTSTR);
+
+HANDLE FindFirstChangeNotification(LPCTSTR, BOOL, DWORD);
+
+HANDLE FindFirstFile(LPCTSTR, LPWIN32_FIND_DATA);
+
+HANDLE FindFirstFileEx(LPCTSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD);
+
+BOOL FindNextFile(HANDLE, LPWIN32_FIND_DATA);
+
+BOOL GetDiskFreeSpace(LPCTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD);
+
+BOOL GetDiskFreeSpaceEx(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER);
+
+UINT GetDriveType(LPCTSTR);
+
+DWORD GetFileAttributes(LPCTSTR);
+
+BOOL GetFileAttributesEx(LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID);
+
+DWORD GetFinalPathNameByHandle(HANDLE, LPTSTR, DWORD, DWORD);
+
+DWORD GetFullPathName(LPCTSTR, DWORD, LPTSTR, LPTSTR*);
+
+DWORD GetLongPathName(LPCTSTR, LPTSTR, DWORD);
+
+BOOL RemoveDirectory(LPCTSTR);
+
+BOOL SetFileAttributes(LPCTSTR, DWORD);
+
+DWORD GetCompressedFileSize(LPCTSTR, LPDWORD);
+
+DWORD GetTempPath(DWORD, LPTSTR);
+
+BOOL GetVolumeInformation(LPCTSTR, LPTSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPTSTR, DWORD);
+
+UINT GetTempFileName(LPCTSTR, LPCTSTR, UINT, LPTSTR);
+
+void OutputDebugString(LPCTSTR);
+
+void FatalAppExit(UINT, LPCTSTR);
+
+HANDLE CreateMutex(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR);
+
+HANDLE CreateEvent(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCTSTR);
+
+HANDLE OpenEvent(DWORD, BOOL, LPCTSTR);
+
+HANDLE CreateMutexEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD);
+
+HANDLE CreateEventEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD);
+
+BOOL CreateProcess(LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION);
+
+BOOL CreateProcessAsUser(HANDLE, LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION);
+
+UINT GetSystemDirectory(LPTSTR, UINT);
+
+UINT GetWindowsDirectory(LPTSTR, UINT);
+
+UINT GetSystemWindowsDirectory(LPTSTR, UINT);
+
+BOOL GetComputerNameEx(COMPUTER_NAME_FORMAT, LPTSTR, LPDWORD);
+
+BOOL GetVersionEx(LPOSVERSIONINFO);
+
+BOOL SetComputerName(LPCTSTR);
+
+BOOL SetComputerNameEx(COMPUTER_NAME_FORMAT, LPCTSTR);
+
+BOOL LoadEnclaveImage(LPVOID, LPCTSTR);
+
+UINT GetSystemWow64Directory(LPTSTR, UINT);
+
+DWORD GetModuleFileName(HMODULE, LPTSTR, DWORD);
+
+HMODULE GetModuleHandle(LPCTSTR);
+
+BOOL GetModuleHandleEx(DWORD, LPCTSTR, HMODULE*);
+
+HMODULE LoadLibraryEx(LPCTSTR, HANDLE, DWORD);
+
+int LoadString(HINSTANCE, UINT, LPTSTR, int);
+
+BOOL EnumResourceLanguagesEx(HMODULE, LPCTSTR, LPCTSTR, ENUMRESLANGPROC, LONG_PTR, DWORD, LANGID);
+
+BOOL EnumResourceNamesEx(HMODULE, LPCTSTR, ENUMRESNAMEPROC, LONG_PTR, DWORD, LANGID);
+
+BOOL EnumResourceTypesEx(HMODULE, ENUMRESTYPEPROC, LONG_PTR, DWORD, LANGID);
+
+HMODULE LoadLibrary(LPCTSTR);
+
+BOOL GetBinaryType(LPCTSTR, LPDWORD);
+
+DWORD GetShortPathName(LPCTSTR, LPTSTR, DWORD);
+
+DWORD GetLongPathNameTransacted(LPCTSTR, LPTSTR, DWORD, HANDLE);
+
+BOOL SetEnvironmentStrings(LPTCH);
+
+BOOL SetFileShortName(HANDLE, LPCTSTR);
+
+DWORD FormatMessage(DWORD, LPCVOID, DWORD, DWORD, LPTSTR, DWORD, va_list *);
+
+HANDLE CreateMailslot(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+
+BOOL EncryptFile(LPCTSTR);
+
+BOOL DecryptFile(LPCTSTR, DWORD);
+
+BOOL FileEncryptionStatus(LPCTSTR, LPDWORD);
+
+DWORD OpenEncryptedFileRaw(LPCTSTR, ULONG, PVOID *);
+
+HANDLE OpenMutex(DWORD, BOOL, LPCTSTR);
+
+HANDLE CreateSemaphore(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCTSTR);
+
+HANDLE OpenSemaphore(DWORD, BOOL, LPCTSTR);
+
+HANDLE CreateWaitableTimer(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR);
+
+HANDLE OpenWaitableTimer(DWORD, BOOL, LPCTSTR);
+
+HANDLE CreateSemaphoreEx(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCTSTR, DWORD, DWORD);
+
+HANDLE CreateWaitableTimerEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD);
+
+HANDLE CreateFileMapping(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCTSTR);
+
+HANDLE CreateFileMappingNuma(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCTSTR, DWORD);
+
+HANDLE OpenFileMapping(DWORD, BOOL, LPCTSTR);
+
+DWORD GetLogicalDriveStrings(DWORD, LPTSTR);
+
+void GetStartupInfo(LPSTARTUPINFO);
+
+DWORD GetFirmwareEnvironmentVariable(LPCTSTR, LPCTSTR, PVOID, DWORD);
+
+BOOL SetFirmwareEnvironmentVariable(LPCTSTR, LPCTSTR, PVOID, DWORD);
+
+HRSRC FindResource(HMODULE, LPCTSTR, LPCTSTR);
+
+HRSRC FindResourceEx(HMODULE, LPCTSTR, LPCTSTR, WORD);
+
+BOOL EnumResourceTypes(HMODULE, ENUMRESTYPEPROC, LONG_PTR);
+
+BOOL EnumResourceNames(HMODULE, LPCTSTR, ENUMRESNAMEPROC, LONG_PTR);
+
+BOOL EnumResourceLanguages(HMODULE, LPCTSTR, LPCTSTR, ENUMRESLANGPROC, LONG_PTR);
+
+HANDLE BeginUpdateResource(LPCTSTR, BOOL);
+
+BOOL UpdateResource(HANDLE, LPCTSTR, LPCTSTR, WORD, LPVOID, DWORD);
+
+BOOL EndUpdateResource(HANDLE, BOOL);
+
+ATOM GlobalAddAtom(LPCTSTR);
+
+ATOM GlobalAddAtomEx(LPCTSTR, DWORD);
+
+ATOM GlobalFindAtom(LPCTSTR);
+
+UINT GlobalGetAtomName(ATOM, LPTSTR, int);
+
+ATOM AddAtom(LPCTSTR);
+
+ATOM FindAtom(LPCTSTR);
+
+UINT GetAtomName(ATOM, LPTSTR, int);
+
+UINT GetProfileInt(LPCTSTR, LPCTSTR, INT);
+
+DWORD GetProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD);
+
+BOOL WriteProfileString(LPCTSTR, LPCTSTR, LPCTSTR);
+
+DWORD GetProfileSection(LPCTSTR, LPTSTR, DWORD);
+
+BOOL WriteProfileSection(LPCTSTR, LPCTSTR);
+
+UINT GetPrivateProfileInt(LPCTSTR, LPCTSTR, INT, LPCTSTR);
+
+DWORD GetPrivateProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD, LPCTSTR);
+
+BOOL WritePrivateProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR);
+
+DWORD GetPrivateProfileSection(LPCTSTR, LPTSTR, DWORD, LPCTSTR);
+
+BOOL WritePrivateProfileSection(LPCTSTR, LPCTSTR, LPCTSTR);
+
+DWORD GetPrivateProfileSectionNames(LPTSTR, DWORD, LPCTSTR);
+
+BOOL GetPrivateProfileStruct(LPCTSTR, LPCTSTR, LPVOID, UINT, LPCTSTR);
+
+BOOL WritePrivateProfileStruct(LPCTSTR, LPCTSTR, LPVOID, UINT, LPCTSTR);
+
+BOOL SetDllDirectory(LPCTSTR);
+
+DWORD GetDllDirectory(DWORD, LPTSTR);
+
+BOOL CreateDirectoryEx(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES);
+
+BOOL CreateDirectoryTransacted(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES, HANDLE);
+
+BOOL RemoveDirectoryTransacted(LPCTSTR, HANDLE);
+
+DWORD GetFullPathNameTransacted(LPCTSTR, DWORD, LPTSTR, LPTSTR *, HANDLE);
+
+BOOL DefineDosDevice(DWORD, LPCTSTR, LPCTSTR);
+
+DWORD QueryDosDevice(LPCTSTR, LPTSTR, DWORD);
+
+HANDLE CreateFileTransacted(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE, HANDLE, PUSHORT, PVOID);
+
+BOOL SetFileAttributesTransacted(LPCTSTR, DWORD, HANDLE);
+
+BOOL GetFileAttributesTransacted(LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID, HANDLE);
+
+DWORD GetCompressedFileSizeTransacted(LPCTSTR, LPDWORD, HANDLE);
+
+BOOL DeleteFileTransacted(LPCTSTR, HANDLE);
+
+BOOL CheckNameLegalDOS8Dot3(LPCTSTR, LPSTR, DWORD, PBOOL, PBOOL);
+
+HANDLE FindFirstFileTransacted(LPCTSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD, HANDLE);
+
+BOOL CopyFile(LPCTSTR, LPCTSTR, BOOL);
+
+BOOL CopyFileEx(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD);
+
+BOOL CopyFileTransacted(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD, HANDLE);
+
+BOOL MoveFile(LPCTSTR, LPCTSTR);
+
+BOOL MoveFileEx(LPCTSTR, LPCTSTR, DWORD);
+
+BOOL MoveFileWithProgress(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, DWORD);
+
+BOOL MoveFileTransacted(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, DWORD, HANDLE);
+
+BOOL ReplaceFile(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, LPVOID, LPVOID);
+
+BOOL CreateHardLink(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES);
+
+BOOL CreateHardLinkTransacted(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES, HANDLE);
+
+HANDLE CreateNamedPipe(LPCTSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES);
+
+BOOL GetNamedPipeHandleState(HANDLE, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPTSTR, DWORD);
+
+BOOL CallNamedPipe(LPCTSTR, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, DWORD);
+
+BOOL WaitNamedPipe(LPCTSTR, DWORD);
+
+BOOL GetNamedPipeClientComputerName(HANDLE, LPTSTR, ULONG);
+
+BOOL SetVolumeLabel(LPCTSTR, LPCTSTR);
+
+BOOL ClearEventLog(HANDLE, LPCTSTR);
+
+BOOL BackupEventLog(HANDLE, LPCTSTR);
+
+HANDLE OpenEventLog(LPCTSTR, LPCTSTR);
+
+HANDLE RegisterEventSource(LPCTSTR, LPCTSTR);
+
+HANDLE OpenBackupEventLog(LPCTSTR, LPCTSTR);
+
+BOOL ReadEventLog(HANDLE, DWORD, DWORD, LPVOID, DWORD, DWORD *, DWORD *);
+
+BOOL ReportEvent(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCTSTR *, LPVOID);
+
+BOOL AccessCheckAndAuditAlarm(LPCTSTR, LPVOID, LPTSTR, LPTSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPBOOL, LPBOOL);
+
+BOOL AccessCheckByTypeAndAuditAlarm(LPCTSTR, LPVOID, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPBOOL, LPBOOL);
+
+BOOL AccessCheckByTypeResultListAndAuditAlarm(LPCTSTR, LPVOID, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPDWORD, LPBOOL);
+
+BOOL AccessCheckByTypeResultListAndAuditAlarmByHandle(LPCTSTR, LPVOID, HANDLE, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPDWORD, LPBOOL);
+
+BOOL ObjectOpenAuditAlarm(LPCTSTR, LPVOID, LPTSTR, LPTSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, LPBOOL);
+
+BOOL ObjectPrivilegeAuditAlarm(LPCTSTR, LPVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL);
+
+BOOL ObjectCloseAuditAlarm(LPCTSTR, LPVOID, BOOL);
+
+BOOL ObjectDeleteAuditAlarm(LPCTSTR, LPVOID, BOOL);
+
+BOOL PrivilegedServiceAuditAlarm(LPCTSTR, LPCTSTR, HANDLE, PPRIVILEGE_SET, BOOL);
+
+BOOL SetFileSecurity(LPCTSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR);
+
+BOOL GetFileSecurity(LPCTSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, LPDWORD);
+
+BOOL IsBadStringPtr(LPCTSTR, UINT_PTR);
+
+BOOL LookupAccountSid(LPCTSTR, PSID, LPTSTR, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE);
+
+BOOL LookupAccountName(LPCTSTR, LPCTSTR, PSID, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE);
+
+BOOL LookupAccountNameLocal(LPCTSTR, PSID, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE);
+
+BOOL LookupAccountSidLocal(PSID, LPTSTR, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE);
+
+BOOL LookupPrivilegeValue(LPCTSTR, LPCTSTR, PLUID);
+
+BOOL LookupPrivilegeName(LPCTSTR, PLUID, LPTSTR, LPDWORD);
+
+BOOL LookupPrivilegeDisplayName(LPCTSTR, LPCTSTR, LPTSTR, LPDWORD, LPDWORD);
+
+BOOL BuildCommDCB(LPCTSTR, LPDCB);
+
+BOOL BuildCommDCBAndTimeouts(LPCTSTR, LPDCB, LPCOMMTIMEOUTS);
+
+BOOL CommConfigDialog(LPCTSTR, HWND, LPCOMMCONFIG);
+
+BOOL GetDefaultCommConfig(LPCTSTR, LPCOMMCONFIG, LPDWORD);
+
+BOOL SetDefaultCommConfig(LPCTSTR, LPCOMMCONFIG, DWORD);
+
+BOOL GetComputerName(LPTSTR, LPDWORD);
+
+BOOL DnsHostnameToComputerName(LPCTSTR, LPTSTR, LPDWORD);
+
+BOOL GetUserName(LPTSTR, LPDWORD);
+
+BOOL LogonUser(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, DWORD, PHANDLE);
+
+BOOL LogonUserEx(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, DWORD, PHANDLE, PSID *, PVOID *, LPDWORD, PQUOTA_LIMITS);
+
+HANDLE CreatePrivateNamespace(LPSECURITY_ATTRIBUTES, LPVOID, LPCTSTR);
+
+HANDLE OpenPrivateNamespace(LPVOID, LPCTSTR);
+
+HANDLE CreateBoundaryDescriptor(LPCTSTR, ULONG);
+
+BOOL GetCurrentHwProfile(LPHW_PROFILE_INFO);
+
+BOOL VerifyVersionInfo(LPOSVERSIONINFOEX, DWORD, DWORDLONG);
+
+HANDLE CreateJobObject(LPSECURITY_ATTRIBUTES, LPCTSTR);
+
+HANDLE OpenJobObject(DWORD, BOOL, LPCTSTR);
+
+HANDLE FindFirstVolume(LPTSTR, DWORD);
+
+BOOL FindNextVolume(HANDLE, LPTSTR, DWORD);
+
+HANDLE FindFirstVolumeMountPoint(LPCTSTR, LPTSTR, DWORD);
+
+BOOL FindNextVolumeMountPoint(HANDLE, LPTSTR, DWORD);
+
+BOOL SetVolumeMountPoint(LPCTSTR, LPCTSTR);
+
+BOOL DeleteVolumeMountPoint(LPCTSTR);
+
+BOOL GetVolumeNameForVolumeMountPoint(LPCTSTR, LPTSTR, DWORD);
+
+BOOL GetVolumePathName(LPCTSTR, LPTSTR, DWORD);
+
+BOOL GetVolumePathNamesForVolumeName(LPCTSTR, LPTCH, DWORD, PDWORD);
+
+HANDLE CreateActCtx(PCACTCTX);
+
+BOOL FindActCtxSectionString(DWORD, const GUID *, ULONG, LPCTSTR, PACTCTX_SECTION_KEYED_DATA);
+
+BOOLEAN CreateSymbolicLink(LPCTSTR, LPCTSTR, DWORD);
+
+BOOLEAN CreateSymbolicLinkTransacted(LPCTSTR, LPCTSTR, DWORD, HANDLE);
+
+int AddFontResource(LPCTSTR);
+
+HMETAFILE CopyMetaFile(HMETAFILE, LPCTSTR);
+
+HDC CreateDC(LPCTSTR, LPCTSTR, LPCTSTR, const DEVMODE *);
+
+HFONT CreateFontIndirect(const LOGFONT *);
+
+HFONT CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR);
+
+HDC CreateIC(LPCTSTR, LPCTSTR, LPCTSTR, const DEVMODE *);
+
+HDC CreateMetaFile(LPCTSTR);
+
+BOOL CreateScalableFontResource(DWORD, LPCTSTR, LPCTSTR, LPCTSTR);
+
+int DeviceCapabilities(LPCTSTR, LPCTSTR, WORD, LPTSTR, const DEVMODE *);
+
+int EnumFontFamiliesEx(HDC, LPLOGFONT, FONTENUMPROC, LPARAM, DWORD);
+
+int EnumFontFamilies(HDC, LPCTSTR, FONTENUMPROC, LPARAM);
+
+int EnumFonts(HDC, LPCTSTR, FONTENUMPROC, LPARAM);
+
+BOOL GetCharWidth(HDC, UINT, UINT, LPINT);
+
+BOOL GetCharWidth32(HDC, UINT, UINT, LPINT);
+
+BOOL GetCharWidthFloat(HDC, UINT, UINT, PFLOAT);
+
+BOOL GetCharABCWidths(HDC, UINT, UINT, LPABC);
+
+BOOL GetCharABCWidthsFloat(HDC, UINT, UINT, LPABCFLOAT);
+
+DWORD GetGlyphOutline(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, LPVOID, const MAT2 *);
+
+HMETAFILE GetMetaFile(LPCTSTR);
+
+UINT GetOutlineTextMetrics(HDC, UINT, LPOUTLINETEXTMETRIC);
+
+BOOL GetTextExtentPoint(HDC, LPCTSTR, int, LPSIZE);
+
+BOOL GetTextExtentPoint32(HDC, LPCTSTR, int, LPSIZE);
+
+BOOL GetTextExtentExPoint(HDC, LPCTSTR, int, int, LPINT, LPINT, LPSIZE);
+
+DWORD GetCharacterPlacement(HDC, LPCTSTR, int, int, LPGCP_RESULTS, DWORD);
+
+DWORD GetGlyphIndices(HDC, LPCTSTR, int, LPWORD, DWORD);
+
+int AddFontResourceEx(LPCTSTR, DWORD, PVOID);
+
+BOOL RemoveFontResourceEx(LPCTSTR, DWORD, PVOID);
+
+HFONT CreateFontIndirectEx(const ENUMLOGFONTEXDV *);
+
+HDC ResetDC(HDC, const DEVMODE *);
+
+BOOL RemoveFontResource(LPCTSTR);
+
+HENHMETAFILE CopyEnhMetaFile(HENHMETAFILE, LPCTSTR);
+
+HDC CreateEnhMetaFile(HDC, LPCTSTR, const RECT *, LPCTSTR);
+
+HENHMETAFILE GetEnhMetaFile(LPCTSTR);
+
+UINT GetEnhMetaFileDescription(HENHMETAFILE, UINT, LPTSTR);
+
+BOOL GetTextMetrics(HDC, LPTEXTMETRIC);
+
+int StartDoc(HDC, const DOCINFO *);
+
+int GetObject(HANDLE, int, LPVOID);
+
+BOOL TextOut(HDC, int, int, LPCTSTR, int);
+
+BOOL ExtTextOut(HDC, int, int, UINT, const RECT *, LPCTSTR, UINT, const INT *);
+
+BOOL PolyTextOut(HDC, const POLYTEXT *, int);
+
+int GetTextFace(HDC, int, LPTSTR);
+
+DWORD GetKerningPairs(HDC, DWORD, LPKERNINGPAIR);
+
+BOOL GetLogColorSpace(HCOLORSPACE, LPLOGCOLORSPACE, DWORD);
+
+HCOLORSPACE CreateColorSpace(LPLOGCOLORSPACE);
+
+BOOL GetICMProfile(HDC, LPDWORD, LPTSTR);
+
+BOOL SetICMProfile(HDC, LPTSTR);
+
+int EnumICMProfiles(HDC, ICMENUMPROC, LPARAM);
+
+BOOL UpdateICMRegKey(DWORD, LPTSTR, LPTSTR, UINT);
+
+HKL LoadKeyboardLayout(LPCTSTR, UINT);
+
+BOOL GetKeyboardLayoutName(LPTSTR);
+
+HDESK CreateDesktop(LPCTSTR, LPCTSTR, DEVMODE*, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES);
+
+HDESK CreateDesktopEx(LPCTSTR, LPCTSTR, DEVMODE*, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES, ULONG, PVOID);
+
+HDESK OpenDesktop(LPCTSTR, DWORD, BOOL, ACCESS_MASK);
+
+BOOL EnumDesktops(HWINSTA, DESKTOPENUMPROC, LPARAM);
+
+HWINSTA CreateWindowStation(LPCTSTR, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES);
+
+HWINSTA OpenWindowStation(LPCTSTR, BOOL, ACCESS_MASK);
+
+BOOL EnumWindowStations(WINSTAENUMPROC, LPARAM);
+
+BOOL GetUserObjectInformation(HANDLE, int, PVOID, DWORD, LPDWORD);
+
+BOOL SetUserObjectInformation(HANDLE, int, PVOID, DWORD);
+
+UINT RegisterWindowMessage(LPCTSTR);
+
+BOOL GetMessage(LPMSG, HWND, UINT, UINT);
+
+LRESULT DispatchMessage(const MSG *);
+
+BOOL PeekMessage(LPMSG, HWND, UINT, UINT, UINT);
+
+LRESULT SendMessage(HWND, UINT, WPARAM, LPARAM);
+
+LRESULT SendMessageTimeout(HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR);
+
+BOOL SendNotifyMessage(HWND, UINT, WPARAM, LPARAM);
+
+BOOL SendMessageCallback(HWND, UINT, WPARAM, LPARAM, SENDASYNCPROC, ULONG_PTR);
+
+long BroadcastSystemMessageEx(DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO);
+
+long BroadcastSystemMessage(DWORD, LPDWORD, UINT, WPARAM, LPARAM);
+
+HDEVNOTIFY RegisterDeviceNotification(HANDLE, LPVOID, DWORD);
+
+BOOL PostMessage(HWND, UINT, WPARAM, LPARAM);
+
+BOOL PostThreadMessage(DWORD, UINT, WPARAM, LPARAM);
+
+BOOL PostAppMessage(DWORD, UINT, WPARAM, LPARAM);
+
+LRESULT DefWindowProc(HWND, UINT, WPARAM, LPARAM);
+
+LRESULT CallWindowProc(WNDPROC, HWND, UINT, WPARAM, LPARAM);
+
+ATOM RegisterClass(const WNDCLASS *);
+
+BOOL UnregisterClass(LPCTSTR, HINSTANCE);
+
+BOOL GetClassInfo(HINSTANCE, LPCTSTR, LPWNDCLASS);
+
+ATOM RegisterClassEx(const WNDCLASSEX *);
+
+BOOL GetClassInfoEx(HINSTANCE, LPCTSTR, LPWNDCLASSEX);
+
+HWND CreateWindowEx(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
+
+HWND CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
+
+HWND CreateDialogParam(HINSTANCE, LPCTSTR, HWND, DLGPROC, LPARAM);
+
+HWND CreateDialogIndirectParam(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM);
+
+HWND CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC);
+
+HWND CreateDialogIndirect(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC);
+
+INT_PTR DialogBoxParam(HINSTANCE, LPCTSTR, HWND, DLGPROC, LPARAM);
+
+INT_PTR DialogBoxIndirectParam(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM);
+
+INT_PTR DialogBox(HINSTANCE, LPCTSTR, HWND, DLGPROC);
+
+INT_PTR DialogBoxIndirect(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC);
+
+BOOL SetDlgItemText(HWND, int, LPCTSTR);
+
+UINT GetDlgItemText(HWND, int, LPTSTR, int);
+
+LRESULT SendDlgItemMessage(HWND, int, UINT, WPARAM, LPARAM);
+
+LRESULT DefDlgProc(HWND, UINT, WPARAM, LPARAM);
+
+BOOL CallMsgFilter(LPMSG, int);
+
+UINT RegisterClipboardFormat(LPCTSTR);
+
+int GetClipboardFormatName(UINT, LPTSTR, int);
+
+BOOL CharToOem(LPCTSTR, LPSTR);
+
+BOOL OemToChar(LPCSTR, LPTSTR);
+
+BOOL CharToOemBuff(LPCTSTR, LPSTR, DWORD);
+
+BOOL OemToCharBuff(LPCSTR, LPTSTR, DWORD);
+
+LPTSTR CharUpper(LPTSTR);
+
+DWORD CharUpperBuff(LPTSTR, DWORD);
+
+LPTSTR CharLower(LPTSTR);
+
+DWORD CharLowerBuff(LPTSTR, DWORD);
+
+LPTSTR CharNext(LPCTSTR);
+
+LPTSTR CharPrev(LPCTSTR, LPCTSTR);
+
+BOOL IsCharAlpha(CHAR);
+
+BOOL IsCharAlphaNumeric(CHAR);
+
+BOOL IsCharUpper(CHAR);
+
+BOOL IsCharLower(CHAR);
+
+int GetKeyNameText(LONG, LPTSTR, int);
+
+SHORT VkKeyScan(CHAR);
+
+SHORT VkKeyScanEx(CHAR, HKL);
+
+UINT MapVirtualKey(UINT, UINT);
+
+UINT MapVirtualKeyEx(UINT, UINT, HKL);
+
+HACCEL LoadAccelerators(HINSTANCE, LPCTSTR);
+
+HACCEL CreateAcceleratorTable(LPACCEL, int);
+
+int CopyAcceleratorTable(HACCEL, LPACCEL, int);
+
+int TranslateAccelerator(HWND, HACCEL, LPMSG);
+
+HMENU LoadMenu(HINSTANCE, LPCTSTR);
+
+HMENU LoadMenuIndirect(const MENUTEMPLATE *);
+
+BOOL ChangeMenu(HMENU, UINT, LPCTSTR, UINT, UINT);
+
+int GetMenuString(HMENU, UINT, LPTSTR, int, UINT);
+
+BOOL InsertMenu(HMENU, UINT, UINT, UINT_PTR, LPCTSTR);
+
+BOOL AppendMenu(HMENU, UINT, UINT_PTR, LPCTSTR);
+
+BOOL ModifyMenu(HMENU, UINT, UINT, UINT_PTR, LPCTSTR);
+
+BOOL InsertMenuItem(HMENU, UINT, BOOL, LPCMENUITEMINFO);
+
+BOOL GetMenuItemInfo(HMENU, UINT, BOOL, LPMENUITEMINFO);
+
+BOOL SetMenuItemInfo(HMENU, UINT, BOOL, LPCMENUITEMINFO);
+
+int DrawText(HDC, LPCTSTR, int, LPRECT, UINT);
+
+int DrawTextEx(HDC, LPTSTR, int, LPRECT, UINT, LPDRAWTEXTPARAMS);
+
+BOOL GrayString(HDC, HBRUSH, GRAYSTRINGPROC, LPARAM, int, int, int, int, int);
+
+BOOL DrawState(HDC, HBRUSH, DRAWSTATEPROC, LPARAM, WPARAM, int, int, int, int, UINT);
+
+LONG TabbedTextOut(HDC, int, int, LPCTSTR, int, int, const INT *, int);
+
+DWORD GetTabbedTextExtent(HDC, LPCTSTR, int, int, const INT *);
+
+BOOL SetProp(HWND, LPCTSTR, HANDLE);
+
+HANDLE GetProp(HWND, LPCTSTR);
+
+HANDLE RemoveProp(HWND, LPCTSTR);
+
+int EnumPropsEx(HWND, PROPENUMPROCEX, LPARAM);
+
+int EnumProps(HWND, PROPENUMPROC);
+
+BOOL SetWindowText(HWND, LPCTSTR);
+
+int GetWindowText(HWND, LPTSTR, int);
+
+int GetWindowTextLength(HWND);
+
+int MessageBox(HWND, LPCTSTR, LPCTSTR, UINT);
+
+int MessageBoxEx(HWND, LPCTSTR, LPCTSTR, UINT, WORD);
+
+int MessageBoxIndirect(const MSGBOXPARAMS *);
+
+LONG GetWindowLong(HWND, int);
+
+LONG SetWindowLong(HWND, int, LONG);
+
+LONG_PTR GetWindowLongPtr(HWND, int);
+
+LONG_PTR SetWindowLongPtr(HWND, int, LONG_PTR);
+
+DWORD GetClassLong(HWND, int);
+
+DWORD SetClassLong(HWND, int, LONG);
+
+ULONG_PTR GetClassLongPtr(HWND, int);
+
+ULONG_PTR SetClassLongPtr(HWND, int, LONG_PTR);
+
+HWND FindWindow(LPCTSTR, LPCTSTR);
+
+HWND FindWindowEx(HWND, HWND, LPCTSTR, LPCTSTR);
+
+int GetClassName(HWND, LPTSTR, int);
+
+HHOOK SetWindowsHook(int, HOOKPROC);
+
+HHOOK SetWindowsHookEx(int, HOOKPROC, HINSTANCE, DWORD);
+
+HBITMAP LoadBitmap(HINSTANCE, LPCTSTR);
+
+HCURSOR LoadCursor(HINSTANCE, LPCTSTR);
+
+HCURSOR LoadCursorFromFile(LPCTSTR);
+
+HICON LoadIcon(HINSTANCE, LPCTSTR);
+
+UINT PrivateExtractIcons(LPCTSTR, int, int, int, HICON *, UINT *, UINT, UINT);
+
+HANDLE LoadImage(HINSTANCE, LPCTSTR, UINT, int, int, UINT);
+
+BOOL GetIconInfoEx(HICON, PICONINFOEX);
+
+BOOL IsDialogMessage(HWND, LPMSG);
+
+int DlgDirList(HWND, LPTSTR, int, int, UINT);
+
+BOOL DlgDirSelectEx(HWND, LPTSTR, int, int);
+
+int DlgDirListComboBox(HWND, LPTSTR, int, int, UINT);
+
+BOOL DlgDirSelectComboBoxEx(HWND, LPTSTR, int, int);
+
+LRESULT DefFrameProc(HWND, HWND, UINT, WPARAM, LPARAM);
+
+LRESULT DefMDIChildProc(HWND, UINT, WPARAM, LPARAM);
+
+HWND CreateMDIWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HINSTANCE, LPARAM);
+
+BOOL WinHelp(HWND, LPCTSTR, UINT, ULONG_PTR);
+
+LONG ChangeDisplaySettings(DEVMODE*, DWORD);
+
+LONG ChangeDisplaySettingsEx(LPCTSTR, DEVMODE*, HWND, DWORD, LPVOID);
+
+BOOL EnumDisplaySettings(LPCTSTR, DWORD, DEVMODE*);
+
+BOOL EnumDisplaySettingsEx(LPCTSTR, DWORD, DEVMODE*, DWORD);
+
+BOOL EnumDisplayDevices(LPCTSTR, DWORD, PDISPLAY_DEVICE, DWORD);
+
+BOOL SystemParametersInfo(UINT, UINT, PVOID, UINT);
+
+BOOL GetMonitorInfo(HMONITOR, LPMONITORINFO);
+
+UINT GetWindowModuleFileName(HWND, LPTSTR, UINT);
+
+UINT RealGetWindowClass(HWND, LPTSTR, UINT);
+
+BOOL GetAltTabInfo(HWND, int, PALTTABINFO, LPTSTR, UINT);
+
+UINT GetRawInputDeviceInfo(HANDLE, UINT, LPVOID, PUINT);
+
+int GetDateFormat(LCID, DWORD, const SYSTEMTIME*, LPCTSTR, LPTSTR, int);
+
+int GetTimeFormat(LCID, DWORD, const SYSTEMTIME*, LPCTSTR, LPTSTR, int);
+
+BOOL GetCPInfoEx(UINT, DWORD, LPCPINFOEX);
+
+int CompareString(LCID, DWORD, PCNZTCH, int, PCNZTCH, int);
+
+int GetLocaleInfo(LCID, LCTYPE, LPTSTR, int);
+
+BOOL SetLocaleInfo(LCID, LCTYPE, LPCTSTR);
+
+int GetCalendarInfo(LCID, CALID, CALTYPE, LPTSTR, int, LPDWORD);
+
+BOOL SetCalendarInfo(LCID, CALID, CALTYPE, LPCTSTR);
+
+int GetNumberFormat(LCID, DWORD, LPCTSTR, const NUMBERFMT *, LPTSTR, int);
+
+int GetCurrencyFormat(LCID, DWORD, LPCTSTR, const CURRENCYFMT *, LPTSTR, int);
+
+BOOL EnumCalendarInfo(CALINFO_ENUMPROC, LCID, CALID, CALTYPE);
+
+BOOL EnumCalendarInfoEx(CALINFO_ENUMPROCEX, LCID, CALID, CALTYPE);
+
+BOOL EnumTimeFormats(TIMEFMT_ENUMPROC, LCID, DWORD);
+
+BOOL EnumDateFormats(DATEFMT_ENUMPROC, LCID, DWORD);
+
+BOOL EnumDateFormatsEx(DATEFMT_ENUMPROCEX, LCID, DWORD);
+
+int GetGeoInfo(GEOID, GEOTYPE, LPTSTR, int, LANGID);
+
+BOOL GetStringTypeEx(LCID, DWORD, LPCTSTR, int, LPWORD);
+
+int FoldString(DWORD, LPCTSTR, int, LPTSTR, int);
+
+BOOL EnumSystemLocales(LOCALE_ENUMPROC, DWORD);
+
+BOOL EnumSystemLanguageGroups(LANGUAGEGROUP_ENUMPROC, DWORD, LONG_PTR);
+
+BOOL EnumLanguageGroupLocales(LANGGROUPLOCALE_ENUMPROC, LGRPID, DWORD, LONG_PTR);
+
+BOOL EnumUILanguages(UILANGUAGE_ENUMPROC, DWORD, LONG_PTR);
+
+BOOL EnumSystemCodePages(CODEPAGE_ENUMPROC, DWORD);
+
+BOOL ReadConsoleInput(HANDLE, PINPUT_RECORD, DWORD, LPDWORD);
+
+BOOL PeekConsoleInput(HANDLE, PINPUT_RECORD, DWORD, LPDWORD);
+
+BOOL ReadConsole(HANDLE, LPVOID, DWORD, LPDWORD, PCONSOLE_READCONSOLE_CONTROL);
+
+BOOL WriteConsole(HANDLE, const void*, DWORD, LPDWORD, LPVOID);
+
+BOOL FillConsoleOutputCharacter(HANDLE, CHAR, DWORD, COORD, LPDWORD);
+
+BOOL WriteConsoleOutputCharacter(HANDLE, LPCTSTR, DWORD, COORD, LPDWORD);
+
+BOOL ReadConsoleOutputCharacter(HANDLE, LPTSTR, DWORD, COORD, LPDWORD);
+
+BOOL WriteConsoleInput(HANDLE, const INPUT_RECORD*, DWORD, LPDWORD);
+
+BOOL ScrollConsoleScreenBuffer(HANDLE, const SMALL_RECT*, const SMALL_RECT*, COORD, const CHAR_INFO*);
+
+BOOL WriteConsoleOutput(HANDLE, const CHAR_INFO*, COORD, COORD, PSMALL_RECT);
+
+BOOL ReadConsoleOutput(HANDLE, PCHAR_INFO, COORD, COORD, PSMALL_RECT);
+
+DWORD GetConsoleTitle(LPTSTR, DWORD);
+
+DWORD GetConsoleOriginalTitle(LPTSTR, DWORD);
+
+BOOL SetConsoleTitle(LPCTSTR);
+
+BOOL AddConsoleAlias(LPTSTR, LPTSTR, LPTSTR);
+
+DWORD GetConsoleAlias(LPTSTR, LPTSTR, DWORD, LPTSTR);
+
+DWORD GetConsoleAliasesLength(LPTSTR);
+
+DWORD GetConsoleAliasExesLength();
+
+DWORD GetConsoleAliases(LPTSTR, DWORD, LPTSTR);
+
+DWORD GetConsoleAliasExes(LPTSTR, DWORD);
+
+void ExpungeConsoleCommandHistory(LPTSTR);
+
+BOOL SetConsoleNumberOfCommands(DWORD, LPTSTR);
+
+DWORD GetConsoleCommandHistoryLength(LPTSTR);
+
+DWORD GetConsoleCommandHistory(LPTSTR, DWORD, LPTSTR);
+
+DWORD VerFindFile(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, PUINT, LPTSTR, PUINT);
+
+DWORD VerInstallFile(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, PUINT);
+
+DWORD GetFileVersionInfoSize(LPCTSTR, LPDWORD);
+
+BOOL GetFileVersionInfo(LPCTSTR, DWORD, DWORD, LPVOID);
+
+DWORD GetFileVersionInfoSizeEx(DWORD, LPCTSTR, LPDWORD);
+
+BOOL GetFileVersionInfoEx(DWORD, LPCTSTR, DWORD, DWORD, LPVOID);
+
+DWORD VerLanguageName(DWORD, LPTSTR, DWORD);
+
+BOOL VerQueryValue(LPCVOID, LPCTSTR, LPVOID *, PUINT);
+
+LSTATUS RegConnectRegistry(LPCTSTR, HKEY, PHKEY);
+
+LSTATUS RegConnectRegistryEx(LPCTSTR, HKEY, ULONG, PHKEY);
+
+LSTATUS RegCreateKey(HKEY, LPCTSTR, PHKEY);
+
+LSTATUS RegCreateKeyEx(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, const LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD);
+
+LSTATUS RegCreateKeyTransacted(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, const LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD, HANDLE, PVOID);
+
+LSTATUS RegDeleteKey(HKEY, LPCTSTR);
+
+LSTATUS RegDeleteKeyEx(HKEY, LPCTSTR, REGSAM, DWORD);
+
+LSTATUS RegDeleteKeyTransacted(HKEY, LPCTSTR, REGSAM, DWORD, HANDLE, PVOID);
+
+LSTATUS RegDeleteValue(HKEY, LPCTSTR);
+
+LSTATUS RegEnumKey(HKEY, DWORD, LPTSTR, DWORD);
+
+LSTATUS RegEnumKeyEx(HKEY, DWORD, LPTSTR, LPDWORD, LPDWORD, LPTSTR, LPDWORD, PFILETIME);
+
+LSTATUS RegEnumValue(HKEY, DWORD, LPTSTR, LPDWORD, LPDWORD, LPDWORD, LPBYTE, LPDWORD);
+
+LSTATUS RegLoadKey(HKEY, LPCTSTR, LPCTSTR);
+
+LSTATUS RegOpenKey(HKEY, LPCTSTR, PHKEY);
+
+LSTATUS RegOpenKeyEx(HKEY, LPCTSTR, DWORD, REGSAM, PHKEY);
+
+LSTATUS RegOpenKeyTransacted(HKEY, LPCTSTR, DWORD, REGSAM, PHKEY, HANDLE, PVOID);
+
+LSTATUS RegQueryInfoKey(HKEY, LPTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, PFILETIME);
+
+LSTATUS RegQueryValue(HKEY, LPCTSTR, LPTSTR, PLONG);
+
+LSTATUS RegQueryMultipleValues(HKEY, PVALENT, DWORD, LPTSTR, LPDWORD);
+
+LSTATUS RegQueryValueEx(HKEY, LPCTSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD);
+
+LSTATUS RegReplaceKey(HKEY, LPCTSTR, LPCTSTR, LPCTSTR);
+
+LSTATUS RegRestoreKey(HKEY, LPCTSTR, DWORD);
+
+LSTATUS RegSaveKey(HKEY, LPCTSTR, const LPSECURITY_ATTRIBUTES);
+
+LSTATUS RegSetValue(HKEY, LPCTSTR, DWORD, LPCTSTR, DWORD);
+
+LSTATUS RegSetValueEx(HKEY, LPCTSTR, DWORD, DWORD, const BYTE*, DWORD);
+
+LSTATUS RegUnLoadKey(HKEY, LPCTSTR);
+
+LSTATUS RegDeleteKeyValue(HKEY, LPCTSTR, LPCTSTR);
+
+LSTATUS RegSetKeyValue(HKEY, LPCTSTR, LPCTSTR, DWORD, LPCVOID, DWORD);
+
+LSTATUS RegDeleteTree(HKEY, LPCTSTR);
+
+LSTATUS RegCopyTree(HKEY, LPCTSTR, HKEY);
+
+LSTATUS RegGetValue(HKEY, LPCTSTR, LPCTSTR, DWORD, LPDWORD, PVOID, LPDWORD);
+
+LSTATUS RegLoadMUIString(HKEY, LPCTSTR, LPTSTR, DWORD, LPDWORD, DWORD, LPCTSTR);
+
+LSTATUS RegLoadAppKey(LPCTSTR, PHKEY, REGSAM, DWORD, DWORD);
+
+BOOL InitiateSystemShutdown(LPTSTR, LPTSTR, DWORD, BOOL, BOOL);
+
+BOOL AbortSystemShutdown(LPTSTR);
+
+BOOL InitiateSystemShutdownEx(LPTSTR, LPTSTR, DWORD, BOOL, BOOL, DWORD);
+
+DWORD InitiateShutdown(LPTSTR, LPTSTR, DWORD, DWORD, DWORD);
+
+LSTATUS RegSaveKeyEx(HKEY, LPCTSTR, const LPSECURITY_ATTRIBUTES, DWORD);
+
+DWORD MultinetGetConnectionPerformance(LPNETRESOURCE, LPNETCONNECTINFOSTRUCT);
+
+BOOL ChangeServiceConfig(SC_HANDLE, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR);
+
+BOOL ChangeServiceConfig2(SC_HANDLE, DWORD, LPVOID);
+
+SC_HANDLE CreateService(SC_HANDLE, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR);
+
+BOOL EnumDependentServices(SC_HANDLE, DWORD, LPENUM_SERVICE_STATUS, DWORD, LPDWORD, LPDWORD);
+
+BOOL EnumServicesStatus(SC_HANDLE, DWORD, DWORD, LPENUM_SERVICE_STATUS, DWORD, LPDWORD, LPDWORD, LPDWORD);
+
+BOOL EnumServicesStatusEx(SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD, LPDWORD, LPCTSTR);
+
+BOOL GetServiceKeyName(SC_HANDLE, LPCTSTR, LPTSTR, LPDWORD);
+
+BOOL GetServiceDisplayName(SC_HANDLE, LPCTSTR, LPTSTR, LPDWORD);
+
+SC_HANDLE OpenSCManager(LPCTSTR, LPCTSTR, DWORD);
+
+SC_HANDLE OpenService(SC_HANDLE, LPCTSTR, DWORD);
+
+BOOL QueryServiceConfig(SC_HANDLE, LPQUERY_SERVICE_CONFIG, DWORD, LPDWORD);
+
+BOOL QueryServiceConfig2(SC_HANDLE, DWORD, LPBYTE, DWORD, LPDWORD);
+
+BOOL QueryServiceLockStatus(SC_HANDLE, LPQUERY_SERVICE_LOCK_STATUS, DWORD, LPDWORD);
+
+SERVICE_STATUS_HANDLE RegisterServiceCtrlHandler(LPCTSTR, LPHANDLER_FUNCTION);
+
+SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerEx(LPCTSTR, LPHANDLER_FUNCTION_EX, LPVOID);
+
+BOOL StartServiceCtrlDispatcher(const SERVICE_TABLE_ENTRY *);
+
+BOOL StartService(SC_HANDLE, DWORD, LPCTSTR *);
+
+DWORD NotifyServiceStatusChange(SC_HANDLE, DWORD, PSERVICE_NOTIFY);
+
+BOOL ControlServiceEx(SC_HANDLE, DWORD, DWORD, PVOID);
+
+HKL ImmInstallIME(LPCTSTR, LPCTSTR);
+
+UINT ImmGetDescription(HKL, LPTSTR, UINT);
+
+UINT ImmGetIMEFileName(HKL, LPTSTR, UINT);
+
+LONG ImmGetCompositionString(HIMC, DWORD, LPVOID, DWORD);
+
+BOOL ImmSetCompositionString(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD);
+
+DWORD ImmGetCandidateListCount(HIMC, LPDWORD);
+
+DWORD ImmGetCandidateList(HIMC, DWORD, LPCANDIDATELIST, DWORD);
+
+DWORD ImmGetGuideLine(HIMC, DWORD, LPTSTR, DWORD);
+
+BOOL ImmGetCompositionFont(HIMC, LPLOGFONT);
+
+BOOL ImmSetCompositionFont(HIMC, LPLOGFONT);
+
+BOOL ImmConfigureIME(HKL, HWND, DWORD, LPVOID);
+
+LRESULT ImmEscape(HKL, HIMC, UINT, LPVOID);
+
+DWORD ImmGetConversionList(HKL, HIMC, LPCTSTR, LPCANDIDATELIST, DWORD, UINT);
+
+BOOL ImmIsUIMessage(HWND, UINT, WPARAM, LPARAM);
+
+BOOL ImmRegisterWord(HKL, LPCTSTR, DWORD, LPCTSTR);
+
+BOOL ImmUnregisterWord(HKL, LPCTSTR, DWORD, LPCTSTR);
+
+UINT ImmGetRegisterWordStyle(HKL, UINT, LPSTYLEBUF);
+
+UINT ImmEnumRegisterWord(HKL, REGISTERWORDENUMPROC, LPCTSTR, DWORD, LPCTSTR, LPVOID);
+
+DWORD ImmGetImeMenuItems(HIMC, DWORD, DWORD, LPIMEMENUITEMINFO, LPIMEMENUITEMINFO, DWORD);
new file mode 100644
--- /dev/null
+++ b/config/windows-h-wrapper.template.h
@@ -0,0 +1,55 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_windows_h
+#define mozilla_windows_h
+
+// Include the "real" windows.h header. On clang/gcc, this can be done with the
+// `include_next` feature, however MSVC requires a direct include path.
+//
+// Also turn off deprecation warnings, as we may be wrapping deprecated fns.
+
+#if defined(__GNUC__) || defined(__clang__)
+#  pragma GCC system_header
+#  include_next <windows.h>
+
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#else
+#  include <${header_path}>
+
+#  pragma warning(push)
+#  pragma warning(disable: 4996 4995)
+#endif // defined(__GNUC__) || defined(__clang__)
+
+// Check if the header should be disabled
+#if defined(MOZ_DISABLE_WINDOWS_WRAPPER)
+#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled"
+
+#elif !defined(__cplusplus)
+#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file"
+
+#elif !defined(__GNUC__) && !defined(__clang__) && !defined(_DLL)
+#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-dynamic RTL"
+
+#else
+// We're allowed to wrap in the current context. Define `MOZ_WRAPPED_WINDOWS_H`
+// to note that fact, and perform the wrapping.
+#define MOZ_WRAPPED_WINDOWS_H
+extern "C++" {
+
+${decls}
+
+} // extern "C++"
+#endif // enabled
+
+#if defined(__GNUC__) || defined(__clang__)
+#  pragma GCC diagnostic pop
+#else
+#  pragma warning(pop)
+#endif // defined(__GNUC__) || defined(__clang__)
+
+#endif // !defined(mozilla_windows_h)
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -419,17 +419,17 @@ SOURCES += [
     # Several conflicts with other bindings.
     'DOMIntersectionObserver.cpp',
     # Because of OS X headers.
     'nsContentUtils.cpp',
     # this file doesn't like windows.h
     'nsDOMWindowUtils.cpp',
     # Conflicts with windows.h's definition of SendMessage.
     'nsFrameMessageManager.cpp',
-    # These files have a #error "Never include windows.h in this file!"
+    # These files have a #error "Never include unwrapped windows.h in this file!"
     'nsGlobalWindowInner.cpp',
     'nsGlobalWindowOuter.cpp',
     # Conflicts with windows.h's definition of LoadImage.
     'nsImageLoadingContent.cpp',
     # Because of OS X headers.
     'nsObjectLoadingContent.cpp',
     # nsPluginArray.cpp includes npapi.h indirectly, and that includes a lot of system headers
     'nsPluginArray.cpp',
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -7827,18 +7827,19 @@ nsGlobalWindowInner::FireOnNewGlobalObje
 {
   // AutoEntryScript required to invoke debugger hook, which is a
   // Gecko-specific concept at present.
   AutoEntryScript aes(this, "nsGlobalWindowInner report new global");
   JS::Rooted<JSObject*> global(aes.cx(), GetWrapper());
   JS_FireOnNewGlobalObject(aes.cx(), global);
 }
 
-#ifdef _WINDOWS_
-#error "Never include windows.h in this file!"
+#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)
+#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)
+#error "Never include unwrapped windows.h in this file!"
 #endif
 
 already_AddRefed<Promise>
 nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
                                        const ImageBitmapSource& aImage,
                                        ErrorResult& aRv)
 {
   return ImageBitmap::Create(this, aImage, Nothing(), aRv);
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -7729,18 +7729,19 @@ nsGlobalWindowOuter::ReportLargeAllocSta
 
   nsContentUtils::ReportToConsole(errorFlags,
                                   NS_LITERAL_CSTRING("DOM"),
                                   mDoc,
                                   nsContentUtils::eDOM_PROPERTIES,
                                   message);
 }
 
-#ifdef _WINDOWS_
-#error "Never include windows.h in this file!"
+#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)
+#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)
+#error "Never include unwrapped windows.h in this file!"
 #endif
 
 // Helper called by methods that move/resize the window,
 // to ensure the presContext (if any) is aware of resolution
 // change that may happen in multi-monitor configuration.
 void
 nsGlobalWindowOuter::CheckForDPIChange()
 {
--- a/gfx/cairo/cairo/src/moz.build
+++ b/gfx/cairo/cairo/src/moz.build
@@ -29,16 +29,17 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] not in (
         'cairo-pdf-surface.c',
         'cairo-truetype-subset.c',
         # cairo-type1-subset.c should be here, but it's only supported on freetype platforms
         'cairo-type1-fallback.c',
         'cairo-type3-glyph-surface.c',
     ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+    DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True
     EXPORTS.cairo += [
         'cairo-win32.h',
     ]
     SOURCES += [
         'cairo-dwrite-font.cpp',
     ]
     if CONFIG['MOZ_ENABLE_D2D_SURFACE']:
         SOURCES += [
--- a/gfx/thebes/gfxDWriteFonts.cpp
+++ b/gfx/thebes/gfxDWriteFonts.cpp
@@ -256,17 +256,17 @@ gfxDWriteFont::ComputeMetrics(AntialiasO
         }
     }
 
     mMetrics->internalLeading = std::max(mMetrics->maxHeight - mMetrics->emHeight, 0.0);
     mMetrics->externalLeading = ceil(fontMetrics.lineGap * mFUnitsConvFactor);
 
     UINT32 ucs = L' ';
     UINT16 glyph;
-    HRESULT hr = mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph);
+    HRESULT hr = mFontFace->GetGlyphIndices(&ucs, 1, &glyph);
     if (FAILED(hr)) {
         mMetrics->spaceWidth = 0;
     } else {
         mSpaceGlyph = glyph;
         mMetrics->spaceWidth = MeasureGlyphWidth(glyph);
     }
 
     // try to get aveCharWidth from the OS/2 table, fall back to measuring 'x'
@@ -286,27 +286,27 @@ gfxDWriteFont::ComputeMetrics(AntialiasO
                 mMetrics->aveCharWidth =
                     int16_t(os2->xAvgCharWidth) * mFUnitsConvFactor;
             }
         }
     }
 
     if (mMetrics->aveCharWidth < 1) {
         ucs = L'x';
-        if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) {
+        if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) {
             mMetrics->aveCharWidth = MeasureGlyphWidth(glyph);
         }
         if (mMetrics->aveCharWidth < 1) {
             // Let's just assume the X is square.
             mMetrics->aveCharWidth = fontMetrics.xHeight * mFUnitsConvFactor;
         }
     }
 
     ucs = L'0';
-    if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) {
+    if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) {
         mMetrics->zeroOrAveCharWidth = MeasureGlyphWidth(glyph);
     }
     if (mMetrics->zeroOrAveCharWidth < 1) {
         mMetrics->zeroOrAveCharWidth = mMetrics->aveCharWidth;
     }
 
     mMetrics->underlineOffset =
         fontMetrics.underlinePosition * mFUnitsConvFactor;
--- a/gfx/vr/service/openvr/moz.build
+++ b/gfx/vr/service/openvr/moz.build
@@ -3,16 +3,19 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 FINAL_LIBRARY = 'xul'
 
 DEFINES['VR_API_PUBLIC'] = True
 
+# Windows.h wrappers conflict with internal methods in openvr
+DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True
+
 if CONFIG['OS_ARCH'] == 'WINNT':
     if CONFIG['HAVE_64BIT_BUILD']:
         DEFINES['WIN64'] = True
     else:
         DEFINES['WIN32'] = True
 
 if CONFIG['OS_ARCH'] == 'Darwin':
     DEFINES['POSIX'] = True
--- a/python/mozbuild/mozbuild/backend/common.py
+++ b/python/mozbuild/mozbuild/backend/common.py
@@ -362,18 +362,19 @@ class CommonBackend(BuildBackend):
     def _write_unified_file(self, unified_file, source_filenames,
                             output_directory, poison_windows_h=False):
         with self._write_file(mozpath.join(output_directory, unified_file)) as f:
             f.write('#define MOZ_UNIFIED_BUILD\n')
             includeTemplate = '#include "%(cppfile)s"'
             if poison_windows_h:
                 includeTemplate += (
                     '\n'
-                    '#ifdef _WINDOWS_\n'
-                    '#error "%(cppfile)s included windows.h"\n'
+                    '#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)\n'
+                    '#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)\n'
+                    '#error "%(cppfile)s included unwrapped windows.h"\n'
                     "#endif")
             includeTemplate += (
                 '\n'
                 '#ifdef PL_ARENA_CONST_ALIGN_MASK\n'
                 '#error "%(cppfile)s uses PL_ARENA_CONST_ALIGN_MASK, '
                 'so it cannot be built in unified mode."\n'
                 '#undef PL_ARENA_CONST_ALIGN_MASK\n'
                 '#endif\n'