Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # /// script
- # requires-python = ">=3.10"
- # dependencies = [
- # "pywin32",
- # ]
- # ///
- import win32api
- import win32security
- import ctypes
- import sys
- def enable_privilege_pywin32():
- try:
- # Открываем токен текущего процесса для изменения привилегий
- h_token = win32security.OpenProcessToken(
- win32api.GetCurrentProcess(),
- win32security.TOKEN_ADJUST_PRIVILEGES | win32security.TOKEN_QUERY
- )
- # Находим LUID нужной привилегии
- luid = win32security.LookupPrivilegeValue(None, "SeProfileSingleProcessPrivilege")
- # Включаем её (атрибут SE_PRIVILEGE_ENABLED)
- win32security.AdjustTokenPrivileges(h_token, 0, [(luid, win32security.SE_PRIVILEGE_ENABLED)])
- return True
- except Exception as e:
- print(f"Ошибка активации через pywin32: {e}")
- return False
- def clear_standby_list(command_code):
- ntdll = ctypes.windll.ntdll
- ntdll.NtSetSystemInformation.argtypes = [ctypes.c_int, ctypes.c_void_p, ctypes.c_ulong]
- ntdll.NtSetSystemInformation.restype = ctypes.c_uint32
- command = ctypes.c_ulong(command_code)
- status = ntdll.NtSetSystemInformation(80, ctypes.byref(command), ctypes.sizeof(command))
- print(f"Код ответа от ядра для команды {command_code}: {hex(status)}")
- return status == 0
- if __name__ == "__main__":
- if not enable_privilege_pywin32():
- print("Не удалось получить права уровня ядра. Попробуйте запустить консоль от Администратора.")
- sys.exit(1)
- print("Очистка Standby List...")
- # 4 - Очистить весь кэш (standbylist)
- if clear_standby_list(4):
- print("[ОК] Standby List успешно очищен.")
- else:
- print("[Ошибка] Не удалось очистить Standby List. Возможно, список уже пуст.")
- # 5 - Очистить низкоприоритетный кэш (priority0standbylist)
- if clear_standby_list(5):
- print("[ОК] Низкоприоритетный Standby List очищен.")
- else:
- print("[Ошибка] Не удалось очистить низкоприоритетный Standby List.")
Advertisement
Add Comment
Please, Sign In to add comment