This repository was archived by the owner on Jul 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -429,6 +429,7 @@ struct CoTaskMemFreePolicy {
429429SetThreadDpiAwarenessContextProc WinUtils::sSetThreadDpiAwarenessContext = NULL ;
430430EnableNonClientDpiScalingProc WinUtils::sEnableNonClientDpiScaling = NULL ;
431431GetSystemMetricsForDpiProc WinUtils::sGetSystemMetricsForDpi = NULL ;
432+ bool WinUtils::sHasPackageIdentity = false ;
432433
433434/* static */
434435void WinUtils::Initialize () {
@@ -461,6 +462,24 @@ void WinUtils::Initialize() {
461462 user32Dll, " GetSystemMetricsForDpi" );
462463 }
463464 }
465+
466+ if (IsWin8OrLater ()) {
467+ HMODULE kernel32Dll = ::GetModuleHandleW (L" kernel32" );
468+ if (kernel32Dll) {
469+ typedef LONG (WINAPI * GetCurrentPackageIdProc)(UINT32 *, BYTE *);
470+ GetCurrentPackageIdProc pGetCurrentPackageId =
471+ (GetCurrentPackageIdProc)::GetProcAddress (kernel32Dll,
472+ " GetCurrentPackageId" );
473+
474+ // If there was any package identity to retrieve, we get
475+ // ERROR_INSUFFICIENT_BUFFER. If there had been no package identity it
476+ // would instead return APPMODEL_ERROR_NO_PACKAGE.
477+ UINT32 packageNameSize = 0 ;
478+ sHasPackageIdentity = pGetCurrentPackageId &&
479+ (pGetCurrentPackageId (&packageNameSize, nullptr ) ==
480+ ERROR_INSUFFICIENT_BUFFER );
481+ }
482+ }
464483}
465484
466485// static
Original file line number Diff line number Diff line change @@ -145,6 +145,9 @@ class WinUtils {
145145 static EnableNonClientDpiScalingProc sEnableNonClientDpiScaling ;
146146 static GetSystemMetricsForDpiProc sGetSystemMetricsForDpi ;
147147
148+ // Set on Initialize().
149+ static bool sHasPackageIdentity ;
150+
148151 public:
149152 class AutoSystemDpiAware {
150153 public:
@@ -218,6 +221,8 @@ class WinUtils {
218221 */
219222 static gfx::MarginDouble GetUnwriteableMarginsForDeviceInInches (HDC aHdc);
220223
224+ static bool HasPackageIdentity () { return sHasPackageIdentity ; }
225+
221226 /* *
222227 * Logging helpers that dump output to prlog module 'Widget', console, and
223228 * OutputDebugString. Note these output in both debug and release builds.
Original file line number Diff line number Diff line change 3434# include " nsDirectoryServiceDefs.h"
3535# include " nsDirectoryServiceUtils.h"
3636# include " nsWindowsHelpers.h"
37+ # include " WinUtils.h"
3738
3839#endif
3940
@@ -932,6 +933,12 @@ nsresult nsSystemInfo::Init() {
932933 return rv;
933934 }
934935
936+ rv = SetPropertyAsBool (u" hasWinPackageId" _ns,
937+ widget::WinUtils::HasPackageIdentity ());
938+ if (NS_WARN_IF (NS_FAILED (rv))) {
939+ return rv;
940+ }
941+
935942# ifndef __MINGW32__
936943 nsAutoString avInfo, antiSpyInfo, firewallInfo;
937944 if (NS_SUCCEEDED (
You can’t perform that action at this time.
0 commit comments