parameters: ()
docstring: WinRing0 is used for reading MSRs.
docstring_summary: WinRing0 is used for reading MSRs.
docstring_tokens: WinRing0 is used for reading MSRs .
function: def _InstallWinRing0():
    """WinRing0 is used for reading MSRs."""
    executable_dir = os.path.dirname(sys.executable)
  
    python_is_64_bit = sys.maxsize > 2 ** 32
    dll_file_name = 'WinRing0x64.dll' if python_is_64_bit else 'WinRing0.dll'
    dll_path = os.path.join(executable_dir, dll_file_name)
  
    os_is_64_bit = platform.machine().endswith('64')
    driver_file_name = 'WinRing0x64.sys' if os_is_64_bit else 'WinRing0.sys'
    driver_path = os.path.join(executable_dir, driver_file_name)
  
    # Check for WinRing0 and download if needed.
    if not (os.path.exists(dll_path) and os.path.exists(driver_path)):
      win_binary_dir = os.path.join(
          path.GetTelemetryDir(), 'bin', 'win', 'AMD64')
      zip_path = os.path.join(win_binary_dir, 'winring0.zip')
      cloud_storage.GetIfChanged(zip_path, bucket=cloud_storage.PUBLIC_BUCKET)
      try:
        with zipfile.ZipFile(zip_path, 'r') as zip_file:
          error_message = (
              'Failed to extract %s into %s. If python claims that '
              'the zip file is locked, this may be a lie. The problem may be '
              'that python does not have write permissions to the destination '
              'directory.'
          )
          # Install DLL.
          if not os.path.exists(dll_path):
            try:
              zip_file.extract(dll_file_name, executable_dir)
            except:
              logging.error(error_message % (dll_file_name, executable_dir))
              raise
  
          # Install kernel driver.
          if not os.path.exists(driver_path):
            try:
              zip_file.extract(driver_file_name, executable_dir)
            except:
              logging.error(error_message % (driver_file_name, executable_dir))
              raise
      finally:
        os.remove(zip_path)
function_tokens: def _InstallWinRing0 ( ) : executable_dir = os . path . dirname ( sys . executable ) python_is_64_bit = sys . maxsize > 2 ** 32 dll_file_name = 'WinRing0x64.dll' if python_is_64_bit else 'WinRing0.dll' dll_path = os . path . join ( executable_dir , dll_file_name ) os_is_64_bit = platform . machine ( ) . endswith ( '64' ) driver_file_name = 'WinRing0x64.sys' if os_is_64_bit else 'WinRing0.sys' driver_path = os . path . join ( executable_dir , driver_file_name ) # Check for WinRing0 and download if needed. if not ( os . path . exists ( dll_path ) and os . path . exists ( driver_path ) ) : win_binary_dir = os . path . join ( path . GetTelemetryDir ( ) , 'bin' , 'win' , 'AMD64' ) zip_path = os . path . join ( win_binary_dir , 'winring0.zip' ) cloud_storage . GetIfChanged ( zip_path , bucket = cloud_storage . PUBLIC_BUCKET ) try : with zipfile . ZipFile ( zip_path , 'r' ) as zip_file : error_message = ( 'Failed to extract %s into %s. If python claims that ' 'the zip file is locked, this may be a lie. The problem may be ' 'that python does not have write permissions to the destination ' 'directory.' ) # Install DLL. if not os . path . exists ( dll_path ) : try : zip_file . extract ( dll_file_name , executable_dir ) except : logging . error ( error_message % ( dll_file_name , executable_dir ) ) raise # Install kernel driver. if not os . path . exists ( driver_path ) : try : zip_file . extract ( driver_file_name , executable_dir ) except : logging . error ( error_message % ( driver_file_name , executable_dir ) ) raise finally : os . remove ( zip_path )