-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.py
More file actions
82 lines (68 loc) · 3.11 KB
/
Copy pathcore.py
File metadata and controls
82 lines (68 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os
import shutil
class HackerCore:
def __init__(self):
self.user_dir = os.path.expanduser("~")
self.config_path = os.path.join(self.user_dir, "AppData", "Roaming", "Seewo", "EasiNote5", "Data", "Configs.fkv")
def get_config_path(self):
return self.config_path
def kill_process(self):
"""Terminates the EasiNote process."""
try:
os.system("taskkill /f /im EasiNote.exe")
return True, "进程已成功终止。"
except Exception as e:
return False, str(e)
def check_status(self):
"""
Checks if IWB mode is currently enabled.
Returns:
bool: True if IWB mode is enabled, False otherwise.
str: Status message or error.
"""
if not os.path.exists(self.config_path):
return False, "未找到配置文件。"
try:
with open(self.config_path, 'r', encoding='utf-8') as file:
content = file.read()
# Check for IWB indicators
is_gen7 = 'DeviceCache.IsGeneration7Device\nTrue' in content
is_iwb = 'DeviceCache.IsIwb\nTrue' in content
if is_gen7 and is_iwb:
return True, "一体机模式已激活"
else:
return False, "普通模式已激活"
except Exception as e:
return False, f"读取配置文件出错: {e}"
def toggle_mode(self, enable):
"""
Toggles the IWB mode.
Args:
enable (bool): True to enable IWB mode, False to disable.
Returns:
bool: True if successful, False otherwise.
str: Result message.
"""
if not os.path.exists(self.config_path):
return False, "未找到配置文件。"
# Ensure process is killed before modifying files
self.kill_process()
try:
with open(self.config_path, 'r', encoding='utf-8') as file:
content = file.read()
if enable:
# Enable IWB Mode
new_content = content.replace('DeviceCache.IsGeneration7Device\nFalse', 'DeviceCache.IsGeneration7Device\nTrue')
new_content = new_content.replace('DeviceCache.IsIwb\nFalse', 'DeviceCache.IsIwb\nTrue')
# Also handle cases where it might already be True but we want to ensure it
# (Though strictly speaking, replace only works if match found.
# If already True, these replacements won't do anything, which is fine)
else:
# Disable IWB Mode (Reset to Normal)
new_content = content.replace('DeviceCache.IsGeneration7Device\nTrue', 'DeviceCache.IsGeneration7Device\nFalse')
new_content = new_content.replace('DeviceCache.IsIwb\nTrue', 'DeviceCache.IsIwb\nFalse')
with open(self.config_path, 'w', encoding='utf-8') as file:
file.write(new_content)
return True, "模式切换成功。"
except Exception as e:
return False, f"修改配置文件出错: {e}"