Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: base/win/win_util.cc

Issue 2722323002: Free mdm library after use. (Closed)
Patch Set: Remove namespace Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/win/win_util.h" 5 #include "base/win/win_util.h"
6 6
7 #include <aclapi.h> 7 #include <aclapi.h>
8 #include <cfgmgr32.h> 8 #include <cfgmgr32.h>
9 #include <powrprof.h> 9 #include <powrprof.h>
10 #include <shobjidl.h> // Must be before propkey. 10 #include <shobjidl.h> // Must be before propkey.
(...skipping 15 matching lines...) Expand all
26 #include <tpcshrd.h> 26 #include <tpcshrd.h>
27 #include <uiviewsettingsinterop.h> 27 #include <uiviewsettingsinterop.h>
28 #include <windows.ui.viewmanagement.h> 28 #include <windows.ui.viewmanagement.h>
29 #include <winstring.h> 29 #include <winstring.h>
30 #include <wrl/wrappers/corewrappers.h> 30 #include <wrl/wrappers/corewrappers.h>
31 31
32 #include <memory> 32 #include <memory>
33 33
34 #include "base/base_switches.h" 34 #include "base/base_switches.h"
35 #include "base/command_line.h" 35 #include "base/command_line.h"
36 #include "base/files/file_path.h"
36 #include "base/logging.h" 37 #include "base/logging.h"
37 #include "base/macros.h" 38 #include "base/macros.h"
39 #include "base/scoped_native_library.h"
38 #include "base/strings/string_util.h" 40 #include "base/strings/string_util.h"
39 #include "base/strings/stringprintf.h" 41 #include "base/strings/stringprintf.h"
40 #include "base/strings/utf_string_conversions.h" 42 #include "base/strings/utf_string_conversions.h"
41 #include "base/threading/thread_restrictions.h" 43 #include "base/threading/thread_restrictions.h"
42 #include "base/win/registry.h" 44 #include "base/win/registry.h"
43 #include "base/win/scoped_comptr.h" 45 #include "base/win/scoped_comptr.h"
44 #include "base/win/scoped_handle.h" 46 #include "base/win/scoped_handle.h"
45 #include "base/win/scoped_propvariant.h" 47 #include "base/win/scoped_propvariant.h"
46 #include "base/win/windows_version.h" 48 #include "base/win/windows_version.h"
47 49
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 IsOS(OS_DOMAINMEMBER) ? 494 IsOS(OS_DOMAINMEMBER) ?
493 ENROLLED : NOT_ENROLLED, 495 ENROLLED : NOT_ENROLLED,
494 UNKNOWN); 496 UNKNOWN);
495 } 497 }
496 498
497 return g_domain_state == ENROLLED; 499 return g_domain_state == ENROLLED;
498 } 500 }
499 501
500 bool IsDeviceRegisteredWithManagement() { 502 bool IsDeviceRegisteredWithManagement() {
501 static bool is_device_registered_with_management = []() { 503 static bool is_device_registered_with_management = []() {
502 HMODULE mdm_dll = ::LoadLibrary(L"MDMRegistration.dll"); 504 ScopedNativeLibrary library(
503 if (!mdm_dll) 505 FilePath::FromUTF8Unsafe(GetNativeLibraryName("MDMRegistration")));
grt (UTC plus 2) 2017/03/03 09:31:35 since this isn't cross-platform code, please simpl
Roger Tawa OOO till Jul 10th 2017/03/03 15:18:46 Done.
506 if (!library.is_valid())
504 return false; 507 return false;
505 508
506 using IsDeviceRegisteredWithManagementFunction = 509 using IsDeviceRegisteredWithManagementFunction =
507 decltype(&::IsDeviceRegisteredWithManagement); 510 decltype(&::IsDeviceRegisteredWithManagement);
508 IsDeviceRegisteredWithManagementFunction 511 IsDeviceRegisteredWithManagementFunction
509 is_device_registered_with_management_function = 512 is_device_registered_with_management_function =
510 reinterpret_cast<IsDeviceRegisteredWithManagementFunction>( 513 reinterpret_cast<IsDeviceRegisteredWithManagementFunction>(
511 ::GetProcAddress(mdm_dll, "IsDeviceRegisteredWithManagement")); 514 library.GetFunctionPointer("IsDeviceRegisteredWithManagement"));
512 if (!is_device_registered_with_management_function) 515 if (!is_device_registered_with_management_function)
513 return false; 516 return false;
514 517
515 BOOL is_managed = false; 518 BOOL is_managed = false;
516 HRESULT hr = 519 HRESULT hr =
517 is_device_registered_with_management_function(&is_managed, 0, nullptr); 520 is_device_registered_with_management_function(&is_managed, 0, nullptr);
518 return SUCCEEDED(hr) && is_managed; 521 return SUCCEEDED(hr) && is_managed;
519 }(); 522 }();
520 return is_device_registered_with_management; 523 return is_device_registered_with_management;
521 } 524 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 awareness == PROCESS_PER_MONITOR_DPI_AWARE) 639 awareness == PROCESS_PER_MONITOR_DPI_AWARE)
637 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; 640 per_monitor_dpi_aware = PerMonitorDpiAware::PER_MONITOR_DPI_AWARE;
638 } 641 }
639 } 642 }
640 } 643 }
641 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE; 644 return per_monitor_dpi_aware == PerMonitorDpiAware::PER_MONITOR_DPI_AWARE;
642 } 645 }
643 646
644 } // namespace win 647 } // namespace win
645 } // namespace base 648 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698