MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / GetOSProductName

Function GetOSProductName

LegacyUpdate/ProductName.cpp:180–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178};
179
180HRESULT GetOSProductName(LPVARIANT productName) {
181 if (_productName.vt == VT_EMPTY) {
182 VariantInit(&_productName);
183
184 // Handle the absolute disaster of Windows XP/Server 2003 edition branding
185 WORD winver = GetWinVer();
186 if (HIBYTE(winver) == 5 && LOBYTE(winver) != 0) {
187 _IsOS $IsOS = (_IsOS)GetProcAddress(LoadLibrary(L"shlwapi.dll"), MAKEINTRESOURCEA(437));
188 if (!$IsOS) {
189 return E_FAIL;
190 }
191
192 SYSTEM_INFO systemInfo;
193 OurGetNativeSystemInfo(&systemInfo);
194
195 WinNT5Variant variant = {};
196 for (DWORD i = 0; i < ARRAYSIZE(nt5Variants); i++) {
197 WinNT5Variant thisVariant = nt5Variants[i];
198 if ((thisVariant.version == MAXDWORD || thisVariant.version == winver) &&
199 (thisVariant.archFlag == MAXWORD || thisVariant.archFlag == systemInfo.wProcessorArchitecture) &&
200 (thisVariant.osFlag == MAXDWORD || $IsOS(thisVariant.osFlag))) {
201 variant = thisVariant;
202 break;
203 }
204 }
205
206 if (variant.version != 0) {
207 WCHAR brandStr[1024];
208 ZeroMemory(brandStr, ARRAYSIZE(brandStr));
209
210 for (DWORD i = 0; variant.stringIDs[i] != 0; i++) {
211 UINT id = variant.stringIDs[i];
212
213 // If Server 2003 R2, override to R2 string
214 if (id == STR_SRV03 && $IsOS(OS_SERVERR2)) {
215 id = STR_SRV03R2;
216 }
217
218 // If XP Tablet PC SP2, override to 2005 string
219 if (id == STR_TABLETPC && GetVersionInfo()->wServicePackMajor >= 2) {
220 id = STR_TABLETPC2005;
221 }
222
223 WinNT5BrandString brandString = nt5BrandStrings[id];
224 WCHAR str[340];
225 HMODULE dll = LoadLibraryEx(brandString.library, NULL, LOAD_LIBRARY_AS_DATAFILE);
226 if (dll) {
227 LoadString(dll, brandString.stringID, str, ARRAYSIZE(str));
228 FreeLibrary(dll);
229 }
230
231 // If Server 2003 (except SBS), add comma
232 if (i == 1) {
233 UINT lastID = variant.stringIDs[i - 1];
234 if (lastID == STR_SRV03 && !$IsOS(OS_SMALLBUSINESSSERVER)) {
235 StringCchCat(brandStr, ARRAYSIZE(brandStr), L",");
236 }
237 }

Callers 1

GetOSVersionInfoMethod · 0.85

Calls 4

GetWinVerFunction · 0.85
OurGetNativeSystemInfoFunction · 0.85
QueryWMIPropertyFunction · 0.85
GetRegistryStringFunction · 0.85

Tested by

no test coverage detected