tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

scoped_handle.cc (1957B)


      1 // Copyright 2012 The Chromium Authors
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "base/win/scoped_handle.h"
      6 #include "base/win/scoped_handle_verifier.h"
      7 #include "base/win/windows_types.h"
      8 
      9 namespace base {
     10 namespace win {
     11 
     12 using base::win::internal::ScopedHandleVerifier;
     13 
     14 std::ostream& operator<<(std::ostream& os, HandleOperation operation) {
     15  switch (operation) {
     16    case HandleOperation::kHandleAlreadyTracked:
     17      return os << "Handle Already Tracked";
     18    case HandleOperation::kCloseHandleNotTracked:
     19      return os << "Closing an untracked handle";
     20    case HandleOperation::kCloseHandleNotOwner:
     21      return os << "Closing a handle owned by something else";
     22    case HandleOperation::kCloseHandleHook:
     23      return os << "CloseHandleHook validation failure";
     24    case HandleOperation::kDuplicateHandleHook:
     25      return os << "DuplicateHandleHook validation failure";
     26  }
     27 }
     28 
     29 // Static.
     30 bool HandleTraits::CloseHandle(HANDLE handle) {
     31  return ScopedHandleVerifier::Get()->CloseHandle(handle);
     32 }
     33 
     34 // Static.
     35 void VerifierTraits::StartTracking(HANDLE handle,
     36                                   const void* owner,
     37                                   const void* pc1,
     38                                   const void* pc2) {
     39  return ScopedHandleVerifier::Get()->StartTracking(handle, owner, pc1, pc2);
     40 }
     41 
     42 // Static.
     43 void VerifierTraits::StopTracking(HANDLE handle,
     44                                  const void* owner,
     45                                  const void* pc1,
     46                                  const void* pc2) {
     47  return ScopedHandleVerifier::Get()->StopTracking(handle, owner, pc1, pc2);
     48 }
     49 
     50 void DisableHandleVerifier() {
     51  return ScopedHandleVerifier::Get()->Disable();
     52 }
     53 
     54 void OnHandleBeingClosed(HANDLE handle, HandleOperation operation) {
     55  return ScopedHandleVerifier::Get()->OnHandleBeingClosed(handle, operation);
     56 }
     57 
     58 }  // namespace win
     59 }  // namespace base