We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Windows versions: let NVDA recognize Windows 10/11 Version 22H2
### Background:
As of November 2021, Microsoft has moved to annual update cycle for Windows 10 and 11. This means there is no YYH1 updates, making it a bit easier to predict what the next version of Windows 10 and 11 will be. This also incresaes uncertainty somewhat as feature update builds can be a bit unpredictable:

* Windows 10: Windows 10 is in maintenance mode (Vibranium releases). While people can guess what the build number can be (see below), we don't know when the final feature update will be released (I'm guessing 2023 based on support lifecycle for Home/Pro versus Enterprise/Education).
* Windows 11: build prediction is unpredictable as Microsoft can sign off on a build some time in northern spring with refresh branches used to prepare cumulative updates for the base build (compare co_release vs. co_refresh branches from last year).

### Is your feature request related to a problem? Please describe.
With the impending release of Windows 10 and 11 Version 22H2, let NVDA recognize 22H2 builds. This can aid in detecting Sun Valley 2 (SV2) builds for UIA console and other work.

### Describe the solution you'd like
Recognize the following builds:

* Windows 10 Version 22H2: 19045
* Windows 11 Version 22H2 (nickel/SV2): 22621

In addition, update AppX manifest to state that the last tested version is 10.0.22621.0 and ask folks to use Windows 11 SDK build 22621 (now available).

### Describe alternatives you've considered
Leave things as is.

### Additional context
Typically, new Windows builds are recognized once builds move to release preview channel. For Windows 11, this took place on June 7, 2022, and for Windows 10, it is being worked on internally.

### Pull request strategy:
Choose from one of the following paths assuming that a PR is created:

1. Merge the upcoming PR.
2. Wait until Windows 10 Version 22H2 is released to release preview Insiders before merging the upcoming PR.

Thanks.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `source/winVersion.py`
Content:
```
1 # A part of NonVisual Desktop Access (NVDA)
2 # Copyright (C) 2006-2022 NV Access Limited, Bill Dengler, Joseph Lee
3 # This file is covered by the GNU General Public License.
4 # See the file COPYING for more details.
5 
6 """A module used to record Windows versions.
7 It is also used to define feature checks such as
8 making sure NVDA can run on a minimum supported version of Windows.
9 """
10 
11 from typing import Optional
12 import sys
13 import os
14 import functools
15 import winreg
16 
17 
18 # Records a mapping between Windows builds and release names.
19 # These include build 10240 for Windows 10 1507 and releases with multiple release builds.
20 # These are applicable to Windows 10 and later as they report the same system version (10.0).
21 _BUILDS_TO_RELEASE_NAMES = {
22 	10240: "Windows 10 1507",
23 	10586: "Windows 10 1511",
24 	14393: "Windows 10 1607",
25 	15063: "Windows 10 1703",
26 	16299: "Windows 10 1709",
27 	17134: "Windows 10 1803",
28 	17763: "Windows 10 1809",
29 	18362: "Windows 10 1903",
30 	18363: "Windows 10 1909",
31 	19041: "Windows 10 2004",
32 	19042: "Windows 10 20H2",
33 	19043: "Windows 10 21H1",
34 	19044: "Windows 10 21H2",
35 	20348: "Windows Server 2022",
36 	22000: "Windows 11 21H2",
37 }
38 
39 
40 @functools.lru_cache(maxsize=1)
41 def _getRunningVersionNameFromWinReg() -> str:
42 	"""Returns the Windows release name defined in Windows Registry.
43 	This is applicable on Windows 10 Version 1511 (build 10586) and later.
44 	"""
45 	# Cache the version in use on the system.
46 	with winreg.OpenKey(
47 		winreg.HKEY_LOCAL_MACHINE, r"Software\Microsoft\Windows NT\CurrentVersion"
48 	) as currentVersion:
49 		# Version 20H2 and later where a separate display version string is used.
50 		try:
51 			releaseId = winreg.QueryValueEx(currentVersion, "DisplayVersion")[0]
52 		except OSError:
53 			# Don't set anything if this is Windows 10 1507 or earlier.
54 			try:
55 				releaseId = winreg.QueryValueEx(currentVersion, "ReleaseID")[0]
56 			except OSError:
57 				raise RuntimeError(
58 					"Release name is not recorded in Windows Registry on this version of Windows"
59 				) from None
60 	return releaseId
61 
62 
63 @functools.total_ordering
64 class WinVersion(object):
65 	"""
66 	Represents a Windows release.
67 	Includes version major, minor, build, service pack information,
68 	as well as tools such as checking for specific Windows 10 releases.
69 	"""
70 
71 	def __init__(
72 			self,
73 			major: int = 0,
74 			minor: int = 0,
75 			build: int = 0,
76 			releaseName: Optional[str] = None,
77 			servicePack: str = "",
78 			productType: str = ""
79 	):
80 		self.major = major
81 		self.minor = minor
82 		self.build = build
83 		if releaseName:
84 			self.releaseName = releaseName
85 		else:
86 			self.releaseName = self._getWindowsReleaseName()
87 		self.servicePack = servicePack
88 		self.productType = productType
89 
90 	def _getWindowsReleaseName(self) -> str:
91 		"""Returns the public release name for a given Windows release based on major, minor, and build.
92 		This is useful if release names are not defined when constructing this class.
93 		For example, 6.1 will return 'Windows 7'.
94 		For Windows 10, feature update release name will be included.
95 		On server systems, unless noted otherwise, client release names will be returned.
96 		For example, 'Windows 10 1809' will be returned on Server 2019 systems.
97 		"""
98 		if (self.major, self.minor) == (6, 1):
99 			return "Windows 7"
100 		elif (self.major, self.minor) == (6, 2):
101 			return "Windows 8"
102 		elif (self.major, self.minor) == (6, 3):
103 			return "Windows 8.1"
104 		elif self.major == 10:
105 			# From Version 1511 (build 10586), release Id/display version comes from Windows Registry.
106 			# However there are builds with no release name (Version 1507/10240)
107 			# or releases with different builds.
108 			# Look these up first before asking Windows Registry.
109 			if self.build in _BUILDS_TO_RELEASE_NAMES:
110 				return _BUILDS_TO_RELEASE_NAMES[self.build]
111 			return "Windows 10 unknown"
112 		else:
113 			return "Windows release unknown"
114 
115 	def __repr__(self):
116 		winVersionText = [self.releaseName]
117 		winVersionText.append(f"({self.major}.{self.minor}.{self.build})")
118 		if self.servicePack != "":
119 			winVersionText.append(f"service pack {self.servicePack}")
120 		if self.productType != "":
121 			winVersionText.append(self.productType)
122 		return " ".join(winVersionText)
123 
124 	def __eq__(self, other):
125 		return (
126 			(self.major, self.minor, self.build)
127 			== (other.major, other.minor, other.build)
128 		)
129 
130 	def __ge__(self, other):
131 		return (
132 			(self.major, self.minor, self.build)
133 			>= (other.major, other.minor, other.build)
134 		)
135 
136 
137 # Windows releases to WinVersion instances for easing comparisons.
138 WIN7 = WinVersion(major=6, minor=1, build=7600)
139 WIN7_SP1 = WinVersion(major=6, minor=1, build=7601, servicePack="1")
140 WIN8 = WinVersion(major=6, minor=2, build=9200)
141 WIN81 = WinVersion(major=6, minor=3, build=9600)
142 WIN10 = WIN10_1507 = WinVersion(major=10, minor=0, build=10240)
143 WIN10_1511 = WinVersion(major=10, minor=0, build=10586)
144 WIN10_1607 = WinVersion(major=10, minor=0, build=14393)
145 WIN10_1703 = WinVersion(major=10, minor=0, build=15063)
146 WIN10_1709 = WinVersion(major=10, minor=0, build=16299)
147 WIN10_1803 = WinVersion(major=10, minor=0, build=17134)
148 WIN10_1809 = WinVersion(major=10, minor=0, build=17763)
149 WIN10_1903 = WinVersion(major=10, minor=0, build=18362)
150 WIN10_1909 = WinVersion(major=10, minor=0, build=18363)
151 WIN10_2004 = WinVersion(major=10, minor=0, build=19041)
152 WIN10_20H2 = WinVersion(major=10, minor=0, build=19042)
153 WIN10_21H1 = WinVersion(major=10, minor=0, build=19043)
154 WIN10_21H2 = WinVersion(major=10, minor=0, build=19044)
155 WINSERVER_2022 = WinVersion(major=10, minor=0, build=20348)
156 WIN11 = WIN11_21H2 = WinVersion(major=10, minor=0, build=22000)
157 
158 
159 @functools.lru_cache(maxsize=1)
160 def getWinVer():
161 	"""Returns a record of current Windows version NVDA is running on.
162 	"""
163 	winVer = sys.getwindowsversion()
164 	# #12509: on Windows 10, fetch whatever Windows Registry says for the current build.
165 	# #12626: note that not all Windows 10 releases are labeled "Windows 10"
166 	# (build 22000 is Windows 11 despite major.minor being 10.0).
167 	try:
168 		if WinVersion(
169 			major=winVer.major,
170 			minor=winVer.minor,
171 			build=winVer.build
172 		) >= WIN11:
173 			releaseName = f"Windows 11 {_getRunningVersionNameFromWinReg()}"
174 		else:
175 			releaseName = f"Windows 10 {_getRunningVersionNameFromWinReg()}"
176 	except RuntimeError:
177 		releaseName = None
178 	return WinVersion(
179 		major=winVer.major,
180 		minor=winVer.minor,
181 		build=winVer.build,
182 		releaseName=releaseName,
183 		servicePack=winVer.service_pack,
184 		productType=("workstation", "domain controller", "server")[winVer.product_type - 1]
185 	)
186 
187 
188 def isSupportedOS():
189 	# NVDA can only run on Windows 7 Service pack 1 and above
190 	return getWinVer() >= WIN7_SP1
191 
192 
193 UWP_OCR_DATA_PATH = os.path.expandvars(r"$windir\OCR")
194 
195 
196 def isUwpOcrAvailable():
197 	return os.path.isdir(UWP_OCR_DATA_PATH)
198 
199 
200 def isFullScreenMagnificationAvailable() -> bool:
201 	"""
202 	Technically this is always False. The Magnification API has been marked by MS as unsupported for
203 	WOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our
204 	testing our specific usage of the API with each Windows version since Windows 8
205 	"""
206 	return getWinVer() >= WIN8
207
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/source/winVersion.py b/source/winVersion.py
--- a/source/winVersion.py
+++ b/source/winVersion.py
@@ -32,6 +32,7 @@
 	19042: "Windows 10 20H2",
 	19043: "Windows 10 21H1",
 	19044: "Windows 10 21H2",
+	19045: "Windows 10 22H2",
 	20348: "Windows Server 2022",
 	22000: "Windows 11 21H2",
 }
@@ -152,6 +153,7 @@
 WIN10_20H2 = WinVersion(major=10, minor=0, build=19042)
 WIN10_21H1 = WinVersion(major=10, minor=0, build=19043)
 WIN10_21H2 = WinVersion(major=10, minor=0, build=19044)
+WIN10_22H2 = WinVersion(major=10, minor=0, build=19045)
 WINSERVER_2022 = WinVersion(major=10, minor=0, build=20348)
 WIN11 = WIN11_21H2 = WinVersion(major=10, minor=0, build=22000)

{"golden_diff": "diff --git a/source/winVersion.py b/source/winVersion.py\n--- a/source/winVersion.py\n+++ b/source/winVersion.py\n@@ -32,6 +32,7 @@\n \t19042: \"Windows 10 20H2\",\r\n \t19043: \"Windows 10 21H1\",\r\n \t19044: \"Windows 10 21H2\",\r\n+\t19045: \"Windows 10 22H2\",\r\n \t20348: \"Windows Server 2022\",\r\n \t22000: \"Windows 11 21H2\",\r\n }\r\n@@ -152,6 +153,7 @@\n WIN10_20H2 = WinVersion(major=10, minor=0, build=19042)\r\n WIN10_21H1 = WinVersion(major=10, minor=0, build=19043)\r\n WIN10_21H2 = WinVersion(major=10, minor=0, build=19044)\r\n+WIN10_22H2 = WinVersion(major=10, minor=0, build=19045)\r\n WINSERVER_2022 = WinVersion(major=10, minor=0, build=20348)\r\n WIN11 = WIN11_21H2 = WinVersion(major=10, minor=0, build=22000)\n", "issue": "Windows versions: let NVDA recognize Windows 10/11 Version 22H2\n### Background:\r\nAs of November 2021, Microsoft has moved to annual update cycle for Windows 10 and 11. This means there is no YYH1 updates, making it a bit easier to predict what the next version of Windows 10 and 11 will be. This also incresaes uncertainty somewhat as feature update builds can be a bit unpredictable:\r\n\r\n* Windows 10: Windows 10 is in maintenance mode (Vibranium releases). While people can guess what the build number can be (see below), we don't know when the final feature update will be released (I'm guessing 2023 based on support lifecycle for Home/Pro versus Enterprise/Education).\r\n* Windows 11: build prediction is unpredictable as Microsoft can sign off on a build some time in northern spring with refresh branches used to prepare cumulative updates for the base build (compare co_release vs. co_refresh branches from last year).\r\n\r\n### Is your feature request related to a problem? Please describe.\r\nWith the impending release of Windows 10 and 11 Version 22H2, let NVDA recognize 22H2 builds. This can aid in detecting Sun Valley 2 (SV2) builds for UIA console and other work.\r\n\r\n### Describe the solution you'd like\r\nRecognize the following builds:\r\n\r\n* Windows 10 Version 22H2: 19045\r\n* Windows 11 Version 22H2 (nickel/SV2): 22621\r\n\r\nIn addition, update AppX manifest to state that the last tested version is 10.0.22621.0 and ask folks to use Windows 11 SDK build 22621 (now available).\r\n\r\n### Describe alternatives you've considered\r\nLeave things as is.\r\n\r\n### Additional context\r\nTypically, new Windows builds are recognized once builds move to release preview channel. For Windows 11, this took place on June 7, 2022, and for Windows 10, it is being worked on internally.\r\n\r\n### Pull request strategy:\r\nChoose from one of the following paths assuming that a PR is created:\r\n\r\n1. Merge the upcoming PR.\r\n2. Wait until Windows 10 Version 22H2 is released to release preview Insiders before merging the upcoming PR.\r\n\r\nThanks.\n", "before_files": [{"content": "# A part of NonVisual Desktop Access (NVDA)\r\n# Copyright (C) 2006-2022 NV Access Limited, Bill Dengler, Joseph Lee\r\n# This file is covered by the GNU General Public License.\r\n# See the file COPYING for more details.\r\n\r\n\"\"\"A module used to record Windows versions.\r\nIt is also used to define feature checks such as\r\nmaking sure NVDA can run on a minimum supported version of Windows.\r\n\"\"\"\r\n\r\nfrom typing import Optional\r\nimport sys\r\nimport os\r\nimport functools\r\nimport winreg\r\n\r\n\r\n# Records a mapping between Windows builds and release names.\r\n# These include build 10240 for Windows 10 1507 and releases with multiple release builds.\r\n# These are applicable to Windows 10 and later as they report the same system version (10.0).\r\n_BUILDS_TO_RELEASE_NAMES = {\r\n\t10240: \"Windows 10 1507\",\r\n\t10586: \"Windows 10 1511\",\r\n\t14393: \"Windows 10 1607\",\r\n\t15063: \"Windows 10 1703\",\r\n\t16299: \"Windows 10 1709\",\r\n\t17134: \"Windows 10 1803\",\r\n\t17763: \"Windows 10 1809\",\r\n\t18362: \"Windows 10 1903\",\r\n\t18363: \"Windows 10 1909\",\r\n\t19041: \"Windows 10 2004\",\r\n\t19042: \"Windows 10 20H2\",\r\n\t19043: \"Windows 10 21H1\",\r\n\t19044: \"Windows 10 21H2\",\r\n\t20348: \"Windows Server 2022\",\r\n\t22000: \"Windows 11 21H2\",\r\n}\r\n\r\n\r\n@functools.lru_cache(maxsize=1)\r\ndef _getRunningVersionNameFromWinReg() -> str:\r\n\t\"\"\"Returns the Windows release name defined in Windows Registry.\r\n\tThis is applicable on Windows 10 Version 1511 (build 10586) and later.\r\n\t\"\"\"\r\n\t# Cache the version in use on the system.\r\n\twith winreg.OpenKey(\r\n\t\twinreg.HKEY_LOCAL_MACHINE, r\"Software\\Microsoft\\Windows NT\\CurrentVersion\"\r\n\t) as currentVersion:\r\n\t\t# Version 20H2 and later where a separate display version string is used.\r\n\t\ttry:\r\n\t\t\treleaseId = winreg.QueryValueEx(currentVersion, \"DisplayVersion\")[0]\r\n\t\texcept OSError:\r\n\t\t\t# Don't set anything if this is Windows 10 1507 or earlier.\r\n\t\t\ttry:\r\n\t\t\t\treleaseId = winreg.QueryValueEx(currentVersion, \"ReleaseID\")[0]\r\n\t\t\texcept OSError:\r\n\t\t\t\traise RuntimeError(\r\n\t\t\t\t\t\"Release name is not recorded in Windows Registry on this version of Windows\"\r\n\t\t\t\t) from None\r\n\treturn releaseId\r\n\r\n\r\n@functools.total_ordering\r\nclass WinVersion(object):\r\n\t\"\"\"\r\n\tRepresents a Windows release.\r\n\tIncludes version major, minor, build, service pack information,\r\n\tas well as tools such as checking for specific Windows 10 releases.\r\n\t\"\"\"\r\n\r\n\tdef __init__(\r\n\t\t\tself,\r\n\t\t\tmajor: int = 0,\r\n\t\t\tminor: int = 0,\r\n\t\t\tbuild: int = 0,\r\n\t\t\treleaseName: Optional[str] = None,\r\n\t\t\tservicePack: str = \"\",\r\n\t\t\tproductType: str = \"\"\r\n\t):\r\n\t\tself.major = major\r\n\t\tself.minor = minor\r\n\t\tself.build = build\r\n\t\tif releaseName:\r\n\t\t\tself.releaseName = releaseName\r\n\t\telse:\r\n\t\t\tself.releaseName = self._getWindowsReleaseName()\r\n\t\tself.servicePack = servicePack\r\n\t\tself.productType = productType\r\n\r\n\tdef _getWindowsReleaseName(self) -> str:\r\n\t\t\"\"\"Returns the public release name for a given Windows release based on major, minor, and build.\r\n\t\tThis is useful if release names are not defined when constructing this class.\r\n\t\tFor example, 6.1 will return 'Windows 7'.\r\n\t\tFor Windows 10, feature update release name will be included.\r\n\t\tOn server systems, unless noted otherwise, client release names will be returned.\r\n\t\tFor example, 'Windows 10 1809' will be returned on Server 2019 systems.\r\n\t\t\"\"\"\r\n\t\tif (self.major, self.minor) == (6, 1):\r\n\t\t\treturn \"Windows 7\"\r\n\t\telif (self.major, self.minor) == (6, 2):\r\n\t\t\treturn \"Windows 8\"\r\n\t\telif (self.major, self.minor) == (6, 3):\r\n\t\t\treturn \"Windows 8.1\"\r\n\t\telif self.major == 10:\r\n\t\t\t# From Version 1511 (build 10586), release Id/display version comes from Windows Registry.\r\n\t\t\t# However there are builds with no release name (Version 1507/10240)\r\n\t\t\t# or releases with different builds.\r\n\t\t\t# Look these up first before asking Windows Registry.\r\n\t\t\tif self.build in _BUILDS_TO_RELEASE_NAMES:\r\n\t\t\t\treturn _BUILDS_TO_RELEASE_NAMES[self.build]\r\n\t\t\treturn \"Windows 10 unknown\"\r\n\t\telse:\r\n\t\t\treturn \"Windows release unknown\"\r\n\r\n\tdef __repr__(self):\r\n\t\twinVersionText = [self.releaseName]\r\n\t\twinVersionText.append(f\"({self.major}.{self.minor}.{self.build})\")\r\n\t\tif self.servicePack != \"\":\r\n\t\t\twinVersionText.append(f\"service pack {self.servicePack}\")\r\n\t\tif self.productType != \"\":\r\n\t\t\twinVersionText.append(self.productType)\r\n\t\treturn \" \".join(winVersionText)\r\n\r\n\tdef __eq__(self, other):\r\n\t\treturn (\r\n\t\t\t(self.major, self.minor, self.build)\r\n\t\t\t== (other.major, other.minor, other.build)\r\n\t\t)\r\n\r\n\tdef __ge__(self, other):\r\n\t\treturn (\r\n\t\t\t(self.major, self.minor, self.build)\r\n\t\t\t>= (other.major, other.minor, other.build)\r\n\t\t)\r\n\r\n\r\n# Windows releases to WinVersion instances for easing comparisons.\r\nWIN7 = WinVersion(major=6, minor=1, build=7600)\r\nWIN7_SP1 = WinVersion(major=6, minor=1, build=7601, servicePack=\"1\")\r\nWIN8 = WinVersion(major=6, minor=2, build=9200)\r\nWIN81 = WinVersion(major=6, minor=3, build=9600)\r\nWIN10 = WIN10_1507 = WinVersion(major=10, minor=0, build=10240)\r\nWIN10_1511 = WinVersion(major=10, minor=0, build=10586)\r\nWIN10_1607 = WinVersion(major=10, minor=0, build=14393)\r\nWIN10_1703 = WinVersion(major=10, minor=0, build=15063)\r\nWIN10_1709 = WinVersion(major=10, minor=0, build=16299)\r\nWIN10_1803 = WinVersion(major=10, minor=0, build=17134)\r\nWIN10_1809 = WinVersion(major=10, minor=0, build=17763)\r\nWIN10_1903 = WinVersion(major=10, minor=0, build=18362)\r\nWIN10_1909 = WinVersion(major=10, minor=0, build=18363)\r\nWIN10_2004 = WinVersion(major=10, minor=0, build=19041)\r\nWIN10_20H2 = WinVersion(major=10, minor=0, build=19042)\r\nWIN10_21H1 = WinVersion(major=10, minor=0, build=19043)\r\nWIN10_21H2 = WinVersion(major=10, minor=0, build=19044)\r\nWINSERVER_2022 = WinVersion(major=10, minor=0, build=20348)\r\nWIN11 = WIN11_21H2 = WinVersion(major=10, minor=0, build=22000)\r\n\r\n\r\n@functools.lru_cache(maxsize=1)\r\ndef getWinVer():\r\n\t\"\"\"Returns a record of current Windows version NVDA is running on.\r\n\t\"\"\"\r\n\twinVer = sys.getwindowsversion()\r\n\t# #12509: on Windows 10, fetch whatever Windows Registry says for the current build.\r\n\t# #12626: note that not all Windows 10 releases are labeled \"Windows 10\"\r\n\t# (build 22000 is Windows 11 despite major.minor being 10.0).\r\n\ttry:\r\n\t\tif WinVersion(\r\n\t\t\tmajor=winVer.major,\r\n\t\t\tminor=winVer.minor,\r\n\t\t\tbuild=winVer.build\r\n\t\t) >= WIN11:\r\n\t\t\treleaseName = f\"Windows 11 {_getRunningVersionNameFromWinReg()}\"\r\n\t\telse:\r\n\t\t\treleaseName = f\"Windows 10 {_getRunningVersionNameFromWinReg()}\"\r\n\texcept RuntimeError:\r\n\t\treleaseName = None\r\n\treturn WinVersion(\r\n\t\tmajor=winVer.major,\r\n\t\tminor=winVer.minor,\r\n\t\tbuild=winVer.build,\r\n\t\treleaseName=releaseName,\r\n\t\tservicePack=winVer.service_pack,\r\n\t\tproductType=(\"workstation\", \"domain controller\", \"server\")[winVer.product_type - 1]\r\n\t)\r\n\r\n\r\ndef isSupportedOS():\r\n\t# NVDA can only run on Windows 7 Service pack 1 and above\r\n\treturn getWinVer() >= WIN7_SP1\r\n\r\n\r\nUWP_OCR_DATA_PATH = os.path.expandvars(r\"$windir\\OCR\")\r\n\r\n\r\ndef isUwpOcrAvailable():\r\n\treturn os.path.isdir(UWP_OCR_DATA_PATH)\r\n\r\n\r\ndef isFullScreenMagnificationAvailable() -> bool:\r\n\t\"\"\"\r\n\tTechnically this is always False. The Magnification API has been marked by MS as unsupported for\r\n\tWOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our\r\n\ttesting our specific usage of the API with each Windows version since Windows 8\r\n\t\"\"\"\r\n\treturn getWinVer() >= WIN8\r\n", "path": "source/winVersion.py"}], "after_files": [{"content": "# A part of NonVisual Desktop Access (NVDA)\r\n# Copyright (C) 2006-2022 NV Access Limited, Bill Dengler, Joseph Lee\r\n# This file is covered by the GNU General Public License.\r\n# See the file COPYING for more details.\r\n\r\n\"\"\"A module used to record Windows versions.\r\nIt is also used to define feature checks such as\r\nmaking sure NVDA can run on a minimum supported version of Windows.\r\n\"\"\"\r\n\r\nfrom typing import Optional\r\nimport sys\r\nimport os\r\nimport functools\r\nimport winreg\r\n\r\n\r\n# Records a mapping between Windows builds and release names.\r\n# These include build 10240 for Windows 10 1507 and releases with multiple release builds.\r\n# These are applicable to Windows 10 and later as they report the same system version (10.0).\r\n_BUILDS_TO_RELEASE_NAMES = {\r\n\t10240: \"Windows 10 1507\",\r\n\t10586: \"Windows 10 1511\",\r\n\t14393: \"Windows 10 1607\",\r\n\t15063: \"Windows 10 1703\",\r\n\t16299: \"Windows 10 1709\",\r\n\t17134: \"Windows 10 1803\",\r\n\t17763: \"Windows 10 1809\",\r\n\t18362: \"Windows 10 1903\",\r\n\t18363: \"Windows 10 1909\",\r\n\t19041: \"Windows 10 2004\",\r\n\t19042: \"Windows 10 20H2\",\r\n\t19043: \"Windows 10 21H1\",\r\n\t19044: \"Windows 10 21H2\",\r\n\t19045: \"Windows 10 22H2\",\r\n\t20348: \"Windows Server 2022\",\r\n\t22000: \"Windows 11 21H2\",\r\n}\r\n\r\n\r\n@functools.lru_cache(maxsize=1)\r\ndef _getRunningVersionNameFromWinReg() -> str:\r\n\t\"\"\"Returns the Windows release name defined in Windows Registry.\r\n\tThis is applicable on Windows 10 Version 1511 (build 10586) and later.\r\n\t\"\"\"\r\n\t# Cache the version in use on the system.\r\n\twith winreg.OpenKey(\r\n\t\twinreg.HKEY_LOCAL_MACHINE, r\"Software\\Microsoft\\Windows NT\\CurrentVersion\"\r\n\t) as currentVersion:\r\n\t\t# Version 20H2 and later where a separate display version string is used.\r\n\t\ttry:\r\n\t\t\treleaseId = winreg.QueryValueEx(currentVersion, \"DisplayVersion\")[0]\r\n\t\texcept OSError:\r\n\t\t\t# Don't set anything if this is Windows 10 1507 or earlier.\r\n\t\t\ttry:\r\n\t\t\t\treleaseId = winreg.QueryValueEx(currentVersion, \"ReleaseID\")[0]\r\n\t\t\texcept OSError:\r\n\t\t\t\traise RuntimeError(\r\n\t\t\t\t\t\"Release name is not recorded in Windows Registry on this version of Windows\"\r\n\t\t\t\t) from None\r\n\treturn releaseId\r\n\r\n\r\n@functools.total_ordering\r\nclass WinVersion(object):\r\n\t\"\"\"\r\n\tRepresents a Windows release.\r\n\tIncludes version major, minor, build, service pack information,\r\n\tas well as tools such as checking for specific Windows 10 releases.\r\n\t\"\"\"\r\n\r\n\tdef __init__(\r\n\t\t\tself,\r\n\t\t\tmajor: int = 0,\r\n\t\t\tminor: int = 0,\r\n\t\t\tbuild: int = 0,\r\n\t\t\treleaseName: Optional[str] = None,\r\n\t\t\tservicePack: str = \"\",\r\n\t\t\tproductType: str = \"\"\r\n\t):\r\n\t\tself.major = major\r\n\t\tself.minor = minor\r\n\t\tself.build = build\r\n\t\tif releaseName:\r\n\t\t\tself.releaseName = releaseName\r\n\t\telse:\r\n\t\t\tself.releaseName = self._getWindowsReleaseName()\r\n\t\tself.servicePack = servicePack\r\n\t\tself.productType = productType\r\n\r\n\tdef _getWindowsReleaseName(self) -> str:\r\n\t\t\"\"\"Returns the public release name for a given Windows release based on major, minor, and build.\r\n\t\tThis is useful if release names are not defined when constructing this class.\r\n\t\tFor example, 6.1 will return 'Windows 7'.\r\n\t\tFor Windows 10, feature update release name will be included.\r\n\t\tOn server systems, unless noted otherwise, client release names will be returned.\r\n\t\tFor example, 'Windows 10 1809' will be returned on Server 2019 systems.\r\n\t\t\"\"\"\r\n\t\tif (self.major, self.minor) == (6, 1):\r\n\t\t\treturn \"Windows 7\"\r\n\t\telif (self.major, self.minor) == (6, 2):\r\n\t\t\treturn \"Windows 8\"\r\n\t\telif (self.major, self.minor) == (6, 3):\r\n\t\t\treturn \"Windows 8.1\"\r\n\t\telif self.major == 10:\r\n\t\t\t# From Version 1511 (build 10586), release Id/display version comes from Windows Registry.\r\n\t\t\t# However there are builds with no release name (Version 1507/10240)\r\n\t\t\t# or releases with different builds.\r\n\t\t\t# Look these up first before asking Windows Registry.\r\n\t\t\tif self.build in _BUILDS_TO_RELEASE_NAMES:\r\n\t\t\t\treturn _BUILDS_TO_RELEASE_NAMES[self.build]\r\n\t\t\treturn \"Windows 10 unknown\"\r\n\t\telse:\r\n\t\t\treturn \"Windows release unknown\"\r\n\r\n\tdef __repr__(self):\r\n\t\twinVersionText = [self.releaseName]\r\n\t\twinVersionText.append(f\"({self.major}.{self.minor}.{self.build})\")\r\n\t\tif self.servicePack != \"\":\r\n\t\t\twinVersionText.append(f\"service pack {self.servicePack}\")\r\n\t\tif self.productType != \"\":\r\n\t\t\twinVersionText.append(self.productType)\r\n\t\treturn \" \".join(winVersionText)\r\n\r\n\tdef __eq__(self, other):\r\n\t\treturn (\r\n\t\t\t(self.major, self.minor, self.build)\r\n\t\t\t== (other.major, other.minor, other.build)\r\n\t\t)\r\n\r\n\tdef __ge__(self, other):\r\n\t\treturn (\r\n\t\t\t(self.major, self.minor, self.build)\r\n\t\t\t>= (other.major, other.minor, other.build)\r\n\t\t)\r\n\r\n\r\n# Windows releases to WinVersion instances for easing comparisons.\r\nWIN7 = WinVersion(major=6, minor=1, build=7600)\r\nWIN7_SP1 = WinVersion(major=6, minor=1, build=7601, servicePack=\"1\")\r\nWIN8 = WinVersion(major=6, minor=2, build=9200)\r\nWIN81 = WinVersion(major=6, minor=3, build=9600)\r\nWIN10 = WIN10_1507 = WinVersion(major=10, minor=0, build=10240)\r\nWIN10_1511 = WinVersion(major=10, minor=0, build=10586)\r\nWIN10_1607 = WinVersion(major=10, minor=0, build=14393)\r\nWIN10_1703 = WinVersion(major=10, minor=0, build=15063)\r\nWIN10_1709 = WinVersion(major=10, minor=0, build=16299)\r\nWIN10_1803 = WinVersion(major=10, minor=0, build=17134)\r\nWIN10_1809 = WinVersion(major=10, minor=0, build=17763)\r\nWIN10_1903 = WinVersion(major=10, minor=0, build=18362)\r\nWIN10_1909 = WinVersion(major=10, minor=0, build=18363)\r\nWIN10_2004 = WinVersion(major=10, minor=0, build=19041)\r\nWIN10_20H2 = WinVersion(major=10, minor=0, build=19042)\r\nWIN10_21H1 = WinVersion(major=10, minor=0, build=19043)\r\nWIN10_21H2 = WinVersion(major=10, minor=0, build=19044)\r\nWIN10_22H2 = WinVersion(major=10, minor=0, build=19045)\r\nWINSERVER_2022 = WinVersion(major=10, minor=0, build=20348)\r\nWIN11 = WIN11_21H2 = WinVersion(major=10, minor=0, build=22000)\r\n\r\n\r\n@functools.lru_cache(maxsize=1)\r\ndef getWinVer():\r\n\t\"\"\"Returns a record of current Windows version NVDA is running on.\r\n\t\"\"\"\r\n\twinVer = sys.getwindowsversion()\r\n\t# #12509: on Windows 10, fetch whatever Windows Registry says for the current build.\r\n\t# #12626: note that not all Windows 10 releases are labeled \"Windows 10\"\r\n\t# (build 22000 is Windows 11 despite major.minor being 10.0).\r\n\ttry:\r\n\t\tif WinVersion(\r\n\t\t\tmajor=winVer.major,\r\n\t\t\tminor=winVer.minor,\r\n\t\t\tbuild=winVer.build\r\n\t\t) >= WIN11:\r\n\t\t\treleaseName = f\"Windows 11 {_getRunningVersionNameFromWinReg()}\"\r\n\t\telse:\r\n\t\t\treleaseName = f\"Windows 10 {_getRunningVersionNameFromWinReg()}\"\r\n\texcept RuntimeError:\r\n\t\treleaseName = None\r\n\treturn WinVersion(\r\n\t\tmajor=winVer.major,\r\n\t\tminor=winVer.minor,\r\n\t\tbuild=winVer.build,\r\n\t\treleaseName=releaseName,\r\n\t\tservicePack=winVer.service_pack,\r\n\t\tproductType=(\"workstation\", \"domain controller\", \"server\")[winVer.product_type - 1]\r\n\t)\r\n\r\n\r\ndef isSupportedOS():\r\n\t# NVDA can only run on Windows 7 Service pack 1 and above\r\n\treturn getWinVer() >= WIN7_SP1\r\n\r\n\r\nUWP_OCR_DATA_PATH = os.path.expandvars(r\"$windir\\OCR\")\r\n\r\n\r\ndef isUwpOcrAvailable():\r\n\treturn os.path.isdir(UWP_OCR_DATA_PATH)\r\n\r\n\r\ndef isFullScreenMagnificationAvailable() -> bool:\r\n\t\"\"\"\r\n\tTechnically this is always False. The Magnification API has been marked by MS as unsupported for\r\n\tWOW64 applications such as NVDA. For our usages, support has been added since Windows 8, relying on our\r\n\ttesting our specific usage of the API with each Windows version since Windows 8\r\n\t\"\"\"\r\n\treturn getWinVer() >= WIN8\r\n", "path": "source/winVersion.py"}]}