diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-07-31 15:50:41 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-08-30 12:35:23 +0000 |
commit | 7b2ffa587235a47d4094787d72f38102089f402a (patch) | |
tree | 30e82af9cbab08a7fa028bb18f4f2987a3f74dfa /chromium/base/win/win_util.h | |
parent | d94af01c90575348c4e81a418257f254b6f8d225 (diff) |
BASELINE: Update Chromium to 76.0.3809.94
Change-Id: I321c3f5f929c105aec0f98c5091ef6108822e647
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/base/win/win_util.h')
-rw-r--r-- | chromium/base/win/win_util.h | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/chromium/base/win/win_util.h b/chromium/base/win/win_util.h index 1806689e995..0c16d9fbd7f 100644 --- a/chromium/base/win/win_util.h +++ b/chromium/base/win/win_util.h @@ -31,12 +31,16 @@ #include "base/base_export.h" #include "base/macros.h" #include "base/strings/string16.h" +#include "base/strings/string_piece.h" struct IPropertyStore; struct _tagpropertykey; typedef _tagpropertykey PROPERTYKEY; namespace base { + +struct NativeLibraryLoadError; + namespace win { inline uint32_t HandleToUint32(HANDLE h) { @@ -54,7 +58,7 @@ inline HANDLE Uint32ToHandle(uint32_t h) { // Returns the string representing the current user sid. Does not modify // |user_sid| on failure. -BASE_EXPORT bool GetUserSidString(std::wstring* user_sid); +BASE_EXPORT bool GetUserSidString(string16* user_sid); // Returns false if user account control (UAC) has been disabled with the // EnableLUA registry flag. Returns true if user account control is enabled. @@ -74,7 +78,7 @@ BASE_EXPORT bool SetBooleanValueForPropertyStore( BASE_EXPORT bool SetStringValueForPropertyStore( IPropertyStore* property_store, const PROPERTYKEY& property_key, - const wchar_t* property_string_value); + const char16* property_string_value); // Sets the CLSID value for a given key in a given IPropertyStore. BASE_EXPORT bool SetClsidForPropertyStore(IPropertyStore* property_store, @@ -85,11 +89,12 @@ BASE_EXPORT bool SetClsidForPropertyStore(IPropertyStore* property_store, // for tagging application/chromium shortcut, browser window and jump list for // Win7. BASE_EXPORT bool SetAppIdForPropertyStore(IPropertyStore* property_store, - const wchar_t* app_id); + const char16* app_id); // Adds the specified |command| using the specified |name| to the AutoRun key. // |root_key| could be HKCU or HKLM or the root of any user hive. -BASE_EXPORT bool AddCommandToAutoRun(HKEY root_key, const string16& name, +BASE_EXPORT bool AddCommandToAutoRun(HKEY root_key, + const string16& name, const string16& command); // Removes the command specified by |name| from the AutoRun key. |root_key| // could be HKCU or HKLM or the root of any user hive. @@ -149,8 +154,8 @@ BASE_EXPORT bool IsKeyboardPresentOnSlate(std::string* reason, HWND hwnd); // This is necessary to set compatible struct sizes for different versions // of certain Windows APIs (e.g. SystemParametersInfo). #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ - offsetof(struct_name, member) + \ - (sizeof static_cast<struct_name*>(NULL)->member) + offsetof(struct_name, member) + \ + (sizeof static_cast<struct_name*>(NULL)->member) // Returns true if the machine is enrolled to a domain. BASE_EXPORT bool IsEnrolledToDomain(); @@ -160,9 +165,17 @@ BASE_EXPORT bool IsDeviceRegisteredWithManagement(); // Returns true if the current process can make USER32 or GDI32 calls such as // CreateWindow and CreateDC. Windows 8 and above allow the kernel component -// of these calls to be disabled which can cause undefined behaviour such as -// crashes. This function can be used to guard areas of code using these calls -// and provide a fallback path if necessary. +// of these calls to be disabled (also known as win32k lockdown) which can +// cause undefined behaviour such as crashes. This function can be used to +// guard areas of code using these calls and provide a fallback path if +// necessary. +// Because they are not always needed (and not needed at all in processes that +// have the win32k lockdown), USER32 and GDI32 are delayloaded. Attempts to +// load them in those processes will cause a crash. Any code which uses USER32 +// or GDI32 and may run in a locked-down process MUST be guarded using this +// method. Before the dlls were delayloaded, method calls into USER32 and GDI32 +// did not work, so adding calls to this method to guard them simply avoids +// unnecessary method calls. BASE_EXPORT bool IsUser32AndGdi32Available(); // Takes a snapshot of the modules loaded in the |process|. The returned @@ -184,6 +197,32 @@ BASE_EXPORT bool IsProcessPerMonitorDpiAware(); // Enable high-DPI support for the current process. BASE_EXPORT void EnableHighDPISupport(); +// Returns a string representation of |rguid|. +BASE_EXPORT string16 String16FromGUID(REFGUID rguid); + +// Attempts to pin user32.dll to ensure it remains loaded. If it isn't loaded +// yet, the module will first be loaded and then the pin will be attempted. If +// pinning is successful, returns true. If the module cannot be loaded and/or +// pinned, |error| is set and the method returns false. +BASE_EXPORT bool PinUser32(NativeLibraryLoadError* error = nullptr); + +// Gets a pointer to a function within user32.dll, if available. If user32.dll +// cannot be loaded or the function cannot be found, this function returns +// nullptr and sets |error|. Once loaded, user32.dll is pinned, and therefore +// the function pointer returned by this function will never change and can be +// cached. +BASE_EXPORT void* GetUser32FunctionPointer( + const char* function_name, + NativeLibraryLoadError* error = nullptr); + +// Returns the name of a desktop or a window station. +BASE_EXPORT string16 GetWindowObjectName(HANDLE handle); + +// Checks if the calling thread is running under a desktop with the name +// given by |desktop_name|. |desktop_name| is ASCII case insensitive (non-ASCII +// characters will be compared with exact matches). +BASE_EXPORT bool IsRunningUnderDesktopName(StringPiece16 desktop_name); + // Allows changing the domain enrolled state for the life time of the object. // The original state is restored upon destruction. class BASE_EXPORT ScopedDomainStateForTesting { |