标签:div exit elf rect ace pat dir code win
1 #!/usr/bin/env python 2 # encoding: utf-8 3 import ctypes 4 import os 5 class disable_file_system_redirection: 6 """ 7 关闭64位系统的driver目录重定向 8 """ 9 try: 10 _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection 11 _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection 12 except Exception as e: 13 print(str(e)) 14 15 def __enter__(self): 16 self.old_value = ctypes.c_long() 17 self.success = self._disable(ctypes.byref(self.old_value)) 18 19 def __exit__(self, type, value, traceback): 20 if self.success: 21 self._revert(self.old_value) 22 23 with disable_file_system_redirection(): 24 if os.path.exists(r‘C:\Windows\System32\drivers\test.sys‘): 25 print "yes"
【Windows学习】解决python无法访问win64系统drivers目录重定向文件问题
标签:div exit elf rect ace pat dir code win
原文地址:https://www.cnblogs.com/gtea/p/13088525.html