winfw 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- winfw-1.0.0/LICENSE +21 -0
- winfw-1.0.0/PKG-INFO +35 -0
- winfw-1.0.0/setup.cfg +4 -0
- winfw-1.0.0/setup.py +35 -0
- winfw-1.0.0/winfw/__init__.py +558 -0
- winfw-1.0.0/winfw.egg-info/PKG-INFO +35 -0
- winfw-1.0.0/winfw.egg-info/SOURCES.txt +8 -0
- winfw-1.0.0/winfw.egg-info/dependency_links.txt +1 -0
- winfw-1.0.0/winfw.egg-info/not-zip-safe +1 -0
- winfw-1.0.0/winfw.egg-info/top_level.txt +1 -0
winfw-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Suleiman
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
winfw-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: winfw
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The best Windows System Library for System Developing.
|
|
5
|
+
Home-page: https://github.com/YourName/winfw
|
|
6
|
+
Author: Suleiman
|
|
7
|
+
Author-email: your@email.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/YourName/winfw/issues
|
|
9
|
+
Project-URL: Source, https://github.com/YourName/winfw
|
|
10
|
+
Keywords: windows,system,automation,mouse,keyboard,processes,registry,system32
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 7
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 8
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
18
|
+
Classifier: Development Status :: 4 - Beta
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.6
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: keywords
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: project-url
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
winfw-1.0.0/setup.cfg
ADDED
winfw-1.0.0/setup.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
setup(
|
|
5
|
+
name="winfw",
|
|
6
|
+
version="1.0.0",
|
|
7
|
+
author="Suleiman",
|
|
8
|
+
author_email="your@email.com",
|
|
9
|
+
description="The best Windows System Library for System Developing.",
|
|
10
|
+
long_description_content_type="text/markdown",
|
|
11
|
+
url="https://github.com/YourName/winfw",
|
|
12
|
+
packages=find_packages(),
|
|
13
|
+
classifiers=[
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: Microsoft :: Windows",
|
|
17
|
+
"Operating System :: Microsoft :: Windows :: Windows 7",
|
|
18
|
+
"Operating System :: Microsoft :: Windows :: Windows 8",
|
|
19
|
+
"Operating System :: Microsoft :: Windows :: Windows 10",
|
|
20
|
+
"Operating System :: Microsoft :: Windows :: Windows 11",
|
|
21
|
+
"Development Status :: 4 - Beta",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
"Topic :: System :: Systems Administration",
|
|
25
|
+
"Topic :: Utilities",
|
|
26
|
+
],
|
|
27
|
+
python_requires=">=3.6",
|
|
28
|
+
keywords="windows, system, automation, mouse, keyboard, processes, registry, system32",
|
|
29
|
+
project_urls={
|
|
30
|
+
"Bug Reports": "https://github.com/YourName/winfw/issues",
|
|
31
|
+
"Source": "https://github.com/YourName/winfw",
|
|
32
|
+
},
|
|
33
|
+
zip_safe=False,
|
|
34
|
+
include_package_data=True,
|
|
35
|
+
)
|
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import time
|
|
4
|
+
import subprocess
|
|
5
|
+
import ctypes
|
|
6
|
+
import ctypes.wintypes
|
|
7
|
+
import shutil
|
|
8
|
+
from ctypes import wintypes, byref, windll
|
|
9
|
+
|
|
10
|
+
user32 = ctypes.windll.user32
|
|
11
|
+
kernel32 = ctypes.windll.kernel32
|
|
12
|
+
psapi = ctypes.windll.psapi
|
|
13
|
+
|
|
14
|
+
class mouse:
|
|
15
|
+
mouseeventf_move = 0x0001
|
|
16
|
+
mouseeventf_leftdown = 0x0002
|
|
17
|
+
mouseeventf_leftup = 0x0004
|
|
18
|
+
mouseeventf_rightdown = 0x0008
|
|
19
|
+
mouseeventf_rightup = 0x0010
|
|
20
|
+
mouseeventf_absolute = 0x8000
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def move(x, y):
|
|
24
|
+
screen_width = user32.GetSystemMetrics(0)
|
|
25
|
+
screen_height = user32.GetSystemMetrics(1)
|
|
26
|
+
abs_x = int(x * 65535 / screen_width)
|
|
27
|
+
abs_y = int(y * 65535 / screen_height)
|
|
28
|
+
user32.mouse_event(mouse.mouseeventf_move | mouse.mouseeventf_absolute, abs_x, abs_y, 0, 0)
|
|
29
|
+
|
|
30
|
+
@staticmethod
|
|
31
|
+
def rclick():
|
|
32
|
+
user32.mouse_event(mouse.mouseeventf_rightdown, 0, 0, 0, 0)
|
|
33
|
+
user32.mouse_event(mouse.mouseeventf_rightup, 0, 0, 0, 0)
|
|
34
|
+
|
|
35
|
+
@staticmethod
|
|
36
|
+
def lclick():
|
|
37
|
+
user32.mouse_event(mouse.mouseeventf_leftdown, 0, 0, 0, 0)
|
|
38
|
+
user32.mouse_event(mouse.mouseeventf_leftup, 0, 0, 0, 0)
|
|
39
|
+
|
|
40
|
+
@staticmethod
|
|
41
|
+
def get_pos():
|
|
42
|
+
point = ctypes.wintypes.POINT()
|
|
43
|
+
user32.GetCursorPos(ctypes.byref(point))
|
|
44
|
+
return (point.x, point.y)
|
|
45
|
+
|
|
46
|
+
class tasks:
|
|
47
|
+
@staticmethod
|
|
48
|
+
def kill(pid):
|
|
49
|
+
handle = kernel32.OpenProcess(0x0001, False, pid)
|
|
50
|
+
if handle:
|
|
51
|
+
kernel32.TerminateProcess(handle, 0)
|
|
52
|
+
kernel32.CloseHandle(handle)
|
|
53
|
+
return True
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
@staticmethod
|
|
57
|
+
def start(path_to_bat_or_exe_or_cmd):
|
|
58
|
+
try:
|
|
59
|
+
subprocess.Popen(path_to_bat_or_exe_or_cmd, shell=True)
|
|
60
|
+
return True
|
|
61
|
+
except:
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def get_all_tasks():
|
|
66
|
+
processes = []
|
|
67
|
+
pids = (ctypes.wintypes.DWORD * 1024)()
|
|
68
|
+
bytes_returned = ctypes.wintypes.DWORD()
|
|
69
|
+
psapi.EnumProcesses(ctypes.byref(pids), ctypes.sizeof(pids), ctypes.byref(bytes_returned))
|
|
70
|
+
num_processes = bytes_returned.value // ctypes.sizeof(ctypes.wintypes.DWORD)
|
|
71
|
+
for i in range(num_processes):
|
|
72
|
+
pid = pids[i]
|
|
73
|
+
handle = kernel32.OpenProcess(0x0400 | 0x0010, False, pid)
|
|
74
|
+
if handle:
|
|
75
|
+
name = ctypes.create_string_buffer(260)
|
|
76
|
+
psapi.GetModuleBaseNameA(handle, None, name, 260)
|
|
77
|
+
processes.append({
|
|
78
|
+
'pid': pid,
|
|
79
|
+
'name': name.value.decode('utf-8', errors='ignore')
|
|
80
|
+
})
|
|
81
|
+
kernel32.CloseHandle(handle)
|
|
82
|
+
return processes
|
|
83
|
+
|
|
84
|
+
@staticmethod
|
|
85
|
+
def get_by_name(name):
|
|
86
|
+
all_tasks = tasks.get_all_tasks()
|
|
87
|
+
result = []
|
|
88
|
+
for task in all_tasks:
|
|
89
|
+
if name.lower() in task['name'].lower():
|
|
90
|
+
result.append(task)
|
|
91
|
+
return result
|
|
92
|
+
|
|
93
|
+
@staticmethod
|
|
94
|
+
def get_current():
|
|
95
|
+
return os.getpid()
|
|
96
|
+
|
|
97
|
+
class word:
|
|
98
|
+
@staticmethod
|
|
99
|
+
def open(docxword):
|
|
100
|
+
try:
|
|
101
|
+
os.startfile(docxword)
|
|
102
|
+
return True
|
|
103
|
+
except:
|
|
104
|
+
return False
|
|
105
|
+
|
|
106
|
+
@staticmethod
|
|
107
|
+
def create(filename):
|
|
108
|
+
try:
|
|
109
|
+
with open(filename, 'w') as f:
|
|
110
|
+
pass
|
|
111
|
+
os.startfile(filename)
|
|
112
|
+
return True
|
|
113
|
+
except:
|
|
114
|
+
return False
|
|
115
|
+
|
|
116
|
+
@staticmethod
|
|
117
|
+
def write(filename, text):
|
|
118
|
+
try:
|
|
119
|
+
with open(filename, 'w', encoding='utf-8') as f:
|
|
120
|
+
f.write(text)
|
|
121
|
+
return True
|
|
122
|
+
except:
|
|
123
|
+
return False
|
|
124
|
+
|
|
125
|
+
@staticmethod
|
|
126
|
+
def read(filename):
|
|
127
|
+
try:
|
|
128
|
+
with open(filename, 'r', encoding='utf-8') as f:
|
|
129
|
+
return f.read()
|
|
130
|
+
except:
|
|
131
|
+
return None
|
|
132
|
+
|
|
133
|
+
class registry:
|
|
134
|
+
@staticmethod
|
|
135
|
+
def read(key, subkey, value):
|
|
136
|
+
try:
|
|
137
|
+
import winreg
|
|
138
|
+
handle = winreg.OpenKey(key, subkey)
|
|
139
|
+
data, _ = winreg.QueryValueEx(handle, value)
|
|
140
|
+
winreg.CloseKey(handle)
|
|
141
|
+
return data
|
|
142
|
+
except:
|
|
143
|
+
return None
|
|
144
|
+
|
|
145
|
+
@staticmethod
|
|
146
|
+
def write(key, subkey, value, data):
|
|
147
|
+
try:
|
|
148
|
+
import winreg
|
|
149
|
+
handle = winreg.OpenKey(key, subkey, 0, winreg.KEY_SET_VALUE)
|
|
150
|
+
winreg.SetValueEx(handle, value, 0, winreg.REG_SZ, data)
|
|
151
|
+
winreg.CloseKey(handle)
|
|
152
|
+
return True
|
|
153
|
+
except:
|
|
154
|
+
return False
|
|
155
|
+
|
|
156
|
+
@staticmethod
|
|
157
|
+
def delete(key, subkey, value):
|
|
158
|
+
try:
|
|
159
|
+
import winreg
|
|
160
|
+
handle = winreg.OpenKey(key, subkey, 0, winreg.KEY_SET_VALUE)
|
|
161
|
+
winreg.DeleteValue(handle, value)
|
|
162
|
+
winreg.CloseKey(handle)
|
|
163
|
+
return True
|
|
164
|
+
except:
|
|
165
|
+
return False
|
|
166
|
+
|
|
167
|
+
class screen:
|
|
168
|
+
@staticmethod
|
|
169
|
+
def get_size():
|
|
170
|
+
return (user32.GetSystemMetrics(0), user32.GetSystemMetrics(1))
|
|
171
|
+
|
|
172
|
+
@staticmethod
|
|
173
|
+
def get_dpi():
|
|
174
|
+
try:
|
|
175
|
+
return ctypes.windll.shcore.GetDpiForMonitor(0, 0)
|
|
176
|
+
except:
|
|
177
|
+
return 96
|
|
178
|
+
|
|
179
|
+
@staticmethod
|
|
180
|
+
def set_resolution(width, height):
|
|
181
|
+
try:
|
|
182
|
+
import win32api, win32con
|
|
183
|
+
win32api.ChangeDisplaySettings(None, 0)
|
|
184
|
+
return True
|
|
185
|
+
except:
|
|
186
|
+
return False
|
|
187
|
+
|
|
188
|
+
class keyboard:
|
|
189
|
+
@staticmethod
|
|
190
|
+
def key_down(key):
|
|
191
|
+
vk_code = {
|
|
192
|
+
'enter': 0x0d, 'space': 0x20, 'esc': 0x1b,
|
|
193
|
+
'ctrl': 0x11, 'alt': 0x12, 'shift': 0x10,
|
|
194
|
+
'tab': 0x09, 'backspace': 0x08, 'delete': 0x2e,
|
|
195
|
+
'a': 0x41, 'b': 0x42, 'c': 0x43, 'd': 0x44,
|
|
196
|
+
'e': 0x45, 'f': 0x46, 'g': 0x47, 'h': 0x48,
|
|
197
|
+
'i': 0x49, 'j': 0x4a, 'k': 0x4b, 'l': 0x4c,
|
|
198
|
+
'm': 0x4d, 'n': 0x4e, 'o': 0x4f, 'p': 0x50,
|
|
199
|
+
'q': 0x51, 'r': 0x52, 's': 0x53, 't': 0x54,
|
|
200
|
+
'u': 0x55, 'v': 0x56, 'w': 0x57, 'x': 0x58,
|
|
201
|
+
'y': 0x59, 'z': 0x5a,
|
|
202
|
+
'0': 0x30, '1': 0x31, '2': 0x32, '3': 0x33,
|
|
203
|
+
'4': 0x34, '5': 0x35, '6': 0x36, '7': 0x37,
|
|
204
|
+
'8': 0x38, '9': 0x39
|
|
205
|
+
}
|
|
206
|
+
vk = vk_code.get(key.lower(), 0)
|
|
207
|
+
if vk:
|
|
208
|
+
user32.keybd_event(vk, 0, 0, 0)
|
|
209
|
+
return True
|
|
210
|
+
return False
|
|
211
|
+
|
|
212
|
+
@staticmethod
|
|
213
|
+
def key_up(key):
|
|
214
|
+
vk_code = {
|
|
215
|
+
'enter': 0x0d, 'space': 0x20, 'esc': 0x1b,
|
|
216
|
+
'ctrl': 0x11, 'alt': 0x12, 'shift': 0x10,
|
|
217
|
+
'tab': 0x09, 'backspace': 0x08, 'delete': 0x2e,
|
|
218
|
+
'a': 0x41, 'b': 0x42, 'c': 0x43, 'd': 0x44,
|
|
219
|
+
'e': 0x45, 'f': 0x46, 'g': 0x47, 'h': 0x48,
|
|
220
|
+
'i': 0x49, 'j': 0x4a, 'k': 0x4b, 'l': 0x4c,
|
|
221
|
+
'm': 0x4d, 'n': 0x4e, 'o': 0x4f, 'p': 0x50,
|
|
222
|
+
'q': 0x51, 'r': 0x52, 's': 0x53, 't': 0x54,
|
|
223
|
+
'u': 0x55, 'v': 0x56, 'w': 0x57, 'x': 0x58,
|
|
224
|
+
'y': 0x59, 'z': 0x5a,
|
|
225
|
+
'0': 0x30, '1': 0x31, '2': 0x32, '3': 0x33,
|
|
226
|
+
'4': 0x34, '5': 0x35, '6': 0x36, '7': 0x37,
|
|
227
|
+
'8': 0x38, '9': 0x39
|
|
228
|
+
}
|
|
229
|
+
vk = vk_code.get(key.lower(), 0)
|
|
230
|
+
if vk:
|
|
231
|
+
user32.keybd_event(vk, 0, 0x0002, 0)
|
|
232
|
+
return True
|
|
233
|
+
return False
|
|
234
|
+
|
|
235
|
+
@staticmethod
|
|
236
|
+
def press(key):
|
|
237
|
+
keyboard.key_down(key)
|
|
238
|
+
time.sleep(0.05)
|
|
239
|
+
keyboard.key_up(key)
|
|
240
|
+
|
|
241
|
+
class sound:
|
|
242
|
+
@staticmethod
|
|
243
|
+
def beep(freq=1000, duration=500):
|
|
244
|
+
try:
|
|
245
|
+
import winsound
|
|
246
|
+
winsound.Beep(freq, duration)
|
|
247
|
+
return True
|
|
248
|
+
except:
|
|
249
|
+
return False
|
|
250
|
+
|
|
251
|
+
@staticmethod
|
|
252
|
+
def play(path):
|
|
253
|
+
try:
|
|
254
|
+
import winsound
|
|
255
|
+
winsound.PlaySound(path, winsound.SND_FILENAME)
|
|
256
|
+
return True
|
|
257
|
+
except:
|
|
258
|
+
return False
|
|
259
|
+
|
|
260
|
+
class system:
|
|
261
|
+
@staticmethod
|
|
262
|
+
def shutdown():
|
|
263
|
+
os.system('shutdown /s /t 0')
|
|
264
|
+
|
|
265
|
+
@staticmethod
|
|
266
|
+
def restart():
|
|
267
|
+
os.system('shutdown /r /t 0')
|
|
268
|
+
|
|
269
|
+
@staticmethod
|
|
270
|
+
def logout():
|
|
271
|
+
os.system('shutdown /l')
|
|
272
|
+
|
|
273
|
+
@staticmethod
|
|
274
|
+
def sleep():
|
|
275
|
+
os.system('rundll32.exe powrprof.dll,SetSuspendState 0,1,0')
|
|
276
|
+
|
|
277
|
+
@staticmethod
|
|
278
|
+
def get_username():
|
|
279
|
+
return os.environ.get('username', 'unknown')
|
|
280
|
+
|
|
281
|
+
@staticmethod
|
|
282
|
+
def get_computername():
|
|
283
|
+
return os.environ.get('computername', 'unknown')
|
|
284
|
+
|
|
285
|
+
@staticmethod
|
|
286
|
+
def get_os_version():
|
|
287
|
+
return sys.getwindowsversion()
|
|
288
|
+
|
|
289
|
+
@staticmethod
|
|
290
|
+
def get_drives():
|
|
291
|
+
drives = []
|
|
292
|
+
for letter in 'abcdefghijklmnopqrstuvwxyz':
|
|
293
|
+
path = letter + ':\\'
|
|
294
|
+
if os.path.exists(path):
|
|
295
|
+
drives.append(path)
|
|
296
|
+
return drives
|
|
297
|
+
|
|
298
|
+
class file:
|
|
299
|
+
@staticmethod
|
|
300
|
+
def read(path):
|
|
301
|
+
try:
|
|
302
|
+
with open(path, 'r', encoding='utf-8') as f:
|
|
303
|
+
return f.read()
|
|
304
|
+
except:
|
|
305
|
+
return None
|
|
306
|
+
|
|
307
|
+
@staticmethod
|
|
308
|
+
def write(path, data):
|
|
309
|
+
try:
|
|
310
|
+
with open(path, 'w', encoding='utf-8') as f:
|
|
311
|
+
f.write(data)
|
|
312
|
+
return True
|
|
313
|
+
except:
|
|
314
|
+
return False
|
|
315
|
+
|
|
316
|
+
@staticmethod
|
|
317
|
+
def append(path, data):
|
|
318
|
+
try:
|
|
319
|
+
with open(path, 'a', encoding='utf-8') as f:
|
|
320
|
+
f.write(data)
|
|
321
|
+
return True
|
|
322
|
+
except:
|
|
323
|
+
return False
|
|
324
|
+
|
|
325
|
+
@staticmethod
|
|
326
|
+
def delete(path):
|
|
327
|
+
try:
|
|
328
|
+
os.remove(path)
|
|
329
|
+
return True
|
|
330
|
+
except:
|
|
331
|
+
return False
|
|
332
|
+
|
|
333
|
+
@staticmethod
|
|
334
|
+
def exists(path):
|
|
335
|
+
return os.path.exists(path)
|
|
336
|
+
|
|
337
|
+
@staticmethod
|
|
338
|
+
def copy(src, dst):
|
|
339
|
+
try:
|
|
340
|
+
shutil.copy2(src, dst)
|
|
341
|
+
return True
|
|
342
|
+
except:
|
|
343
|
+
return False
|
|
344
|
+
|
|
345
|
+
@staticmethod
|
|
346
|
+
def move(src, dst):
|
|
347
|
+
try:
|
|
348
|
+
shutil.move(src, dst)
|
|
349
|
+
return True
|
|
350
|
+
except:
|
|
351
|
+
return False
|
|
352
|
+
|
|
353
|
+
@staticmethod
|
|
354
|
+
def get_size(path):
|
|
355
|
+
try:
|
|
356
|
+
return os.path.getsize(path)
|
|
357
|
+
except:
|
|
358
|
+
return -1
|
|
359
|
+
|
|
360
|
+
@staticmethod
|
|
361
|
+
def get_modified(path):
|
|
362
|
+
try:
|
|
363
|
+
return os.path.getmtime(path)
|
|
364
|
+
except:
|
|
365
|
+
return -1
|
|
366
|
+
|
|
367
|
+
class network:
|
|
368
|
+
@staticmethod
|
|
369
|
+
def ping(host):
|
|
370
|
+
try:
|
|
371
|
+
result = subprocess.run(['ping', '-n', '1', host], capture_output=True, timeout=5)
|
|
372
|
+
return result.returncode == 0
|
|
373
|
+
except:
|
|
374
|
+
return False
|
|
375
|
+
|
|
376
|
+
@staticmethod
|
|
377
|
+
def get_ip():
|
|
378
|
+
try:
|
|
379
|
+
import socket
|
|
380
|
+
return socket.gethostbyname(socket.gethostname())
|
|
381
|
+
except:
|
|
382
|
+
return None
|
|
383
|
+
|
|
384
|
+
@staticmethod
|
|
385
|
+
def get_hostname():
|
|
386
|
+
try:
|
|
387
|
+
import socket
|
|
388
|
+
return socket.gethostname()
|
|
389
|
+
except:
|
|
390
|
+
return None
|
|
391
|
+
|
|
392
|
+
class system32:
|
|
393
|
+
system32_path = os.path.join(os.environ.get('SystemRoot', 'C:\\Windows'), 'System32')
|
|
394
|
+
|
|
395
|
+
@staticmethod
|
|
396
|
+
def get_path():
|
|
397
|
+
return system32.system32_path
|
|
398
|
+
|
|
399
|
+
@staticmethod
|
|
400
|
+
def list_files(filter='*.*'):
|
|
401
|
+
try:
|
|
402
|
+
import glob
|
|
403
|
+
return glob.glob(os.path.join(system32.system32_path, filter))
|
|
404
|
+
except:
|
|
405
|
+
return []
|
|
406
|
+
|
|
407
|
+
@staticmethod
|
|
408
|
+
def list_dlls():
|
|
409
|
+
return system32.list_files('*.dll')
|
|
410
|
+
|
|
411
|
+
@staticmethod
|
|
412
|
+
def list_exes():
|
|
413
|
+
return system32.list_files('*.exe')
|
|
414
|
+
|
|
415
|
+
@staticmethod
|
|
416
|
+
def list_drivers():
|
|
417
|
+
driver_path = os.path.join(system32.system32_path, 'drivers')
|
|
418
|
+
try:
|
|
419
|
+
return [os.path.join(driver_path, f) for f in os.listdir(driver_path) if f.endswith('.sys')]
|
|
420
|
+
except:
|
|
421
|
+
return []
|
|
422
|
+
|
|
423
|
+
@staticmethod
|
|
424
|
+
def file_exists(filename):
|
|
425
|
+
return os.path.exists(os.path.join(system32.system32_path, filename))
|
|
426
|
+
|
|
427
|
+
@staticmethod
|
|
428
|
+
def get_file_version(filename):
|
|
429
|
+
try:
|
|
430
|
+
path = os.path.join(system32.system32_path, filename)
|
|
431
|
+
info = ctypes.windll.version.GetFileVersionInfoSizeW(path, None)
|
|
432
|
+
if info:
|
|
433
|
+
buffer = ctypes.create_string_buffer(info)
|
|
434
|
+
ctypes.windll.version.GetFileVersionInfoW(path, 0, info, buffer)
|
|
435
|
+
return buffer.raw
|
|
436
|
+
return None
|
|
437
|
+
except:
|
|
438
|
+
return None
|
|
439
|
+
|
|
440
|
+
@staticmethod
|
|
441
|
+
def run_dll(dll_name, entry_point='DllMain'):
|
|
442
|
+
try:
|
|
443
|
+
dll_path = os.path.join(system32.system32_path, dll_name)
|
|
444
|
+
ctypes.windll.LoadLibraryW(dll_path)
|
|
445
|
+
return True
|
|
446
|
+
except:
|
|
447
|
+
return False
|
|
448
|
+
|
|
449
|
+
@staticmethod
|
|
450
|
+
def get_dll_exports(dll_name):
|
|
451
|
+
try:
|
|
452
|
+
import pefile
|
|
453
|
+
dll_path = os.path.join(system32.system32_path, dll_name)
|
|
454
|
+
pe = pefile.PE(dll_path)
|
|
455
|
+
exports = []
|
|
456
|
+
if hasattr(pe, 'DIRECTORY_ENTRY_EXPORT'):
|
|
457
|
+
for exp in pe.DIRECTORY_ENTRY_EXPORT.symbols:
|
|
458
|
+
exports.append(exp.name.decode('utf-8') if exp.name else '')
|
|
459
|
+
return exports
|
|
460
|
+
except:
|
|
461
|
+
return []
|
|
462
|
+
|
|
463
|
+
@staticmethod
|
|
464
|
+
def run_command(cmd):
|
|
465
|
+
try:
|
|
466
|
+
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
|
|
467
|
+
return result.stdout
|
|
468
|
+
except:
|
|
469
|
+
return None
|
|
470
|
+
|
|
471
|
+
@staticmethod
|
|
472
|
+
def get_system_info():
|
|
473
|
+
try:
|
|
474
|
+
info = {}
|
|
475
|
+
info['path'] = system32.system32_path
|
|
476
|
+
info['dll_count'] = len(system32.list_dlls())
|
|
477
|
+
info['exe_count'] = len(system32.list_exes())
|
|
478
|
+
info['driver_count'] = len(system32.list_drivers())
|
|
479
|
+
return info
|
|
480
|
+
except:
|
|
481
|
+
return None
|
|
482
|
+
|
|
483
|
+
@staticmethod
|
|
484
|
+
def backup_file(filename, backup_dir=None):
|
|
485
|
+
try:
|
|
486
|
+
src = os.path.join(system32.system32_path, filename)
|
|
487
|
+
if not os.path.exists(src):
|
|
488
|
+
return False
|
|
489
|
+
if backup_dir is None:
|
|
490
|
+
backup_dir = os.path.join(os.environ.get('TEMP', 'C:\\Temp'), 'system32_backup')
|
|
491
|
+
os.makedirs(backup_dir, exist_ok=True)
|
|
492
|
+
dst = os.path.join(backup_dir, filename)
|
|
493
|
+
shutil.copy2(src, dst)
|
|
494
|
+
return dst
|
|
495
|
+
except:
|
|
496
|
+
return False
|
|
497
|
+
|
|
498
|
+
@staticmethod
|
|
499
|
+
def restore_file(filename, backup_dir=None):
|
|
500
|
+
try:
|
|
501
|
+
if backup_dir is None:
|
|
502
|
+
backup_dir = os.path.join(os.environ.get('TEMP', 'C:\\Temp'), 'system32_backup')
|
|
503
|
+
src = os.path.join(backup_dir, filename)
|
|
504
|
+
dst = os.path.join(system32.system32_path, filename)
|
|
505
|
+
if not os.path.exists(src):
|
|
506
|
+
return False
|
|
507
|
+
shutil.copy2(src, dst)
|
|
508
|
+
return True
|
|
509
|
+
except:
|
|
510
|
+
return False
|
|
511
|
+
|
|
512
|
+
@staticmethod
|
|
513
|
+
def is_system_file(filename):
|
|
514
|
+
system_files = [
|
|
515
|
+
'ntoskrnl.exe', 'winload.exe', 'winlogon.exe',
|
|
516
|
+
'csrss.exe', 'lsass.exe', 'services.exe',
|
|
517
|
+
'svchost.exe', 'explorer.exe', 'cmd.exe',
|
|
518
|
+
'powershell.exe', 'regedit.exe', 'msconfig.exe',
|
|
519
|
+
'taskmgr.exe', 'notepad.exe', 'calc.exe'
|
|
520
|
+
]
|
|
521
|
+
return filename.lower() in [f.lower() for f in system_files]
|
|
522
|
+
|
|
523
|
+
@staticmethod
|
|
524
|
+
def get_file_info(filename):
|
|
525
|
+
try:
|
|
526
|
+
path = os.path.join(system32.system32_path, filename)
|
|
527
|
+
if not os.path.exists(path):
|
|
528
|
+
return None
|
|
529
|
+
info = {
|
|
530
|
+
'name': filename,
|
|
531
|
+
'path': path,
|
|
532
|
+
'size': os.path.getsize(path),
|
|
533
|
+
'modified': os.path.getmtime(path),
|
|
534
|
+
'is_system': system32.is_system_file(filename),
|
|
535
|
+
'is_dll': filename.lower().endswith('.dll'),
|
|
536
|
+
'is_exe': filename.lower().endswith('.exe')
|
|
537
|
+
}
|
|
538
|
+
return info
|
|
539
|
+
except:
|
|
540
|
+
return None
|
|
541
|
+
|
|
542
|
+
@staticmethod
|
|
543
|
+
def get_known_dlls():
|
|
544
|
+
known_dlls = [
|
|
545
|
+
'kernel32.dll', 'user32.dll', 'gdi32.dll', 'advapi32.dll',
|
|
546
|
+
'shell32.dll', 'ole32.dll', 'comctl32.dll', 'comdlg32.dll',
|
|
547
|
+
'ws2_32.dll', 'wininet.dll', 'urlmon.dll', 'msvcrt.dll',
|
|
548
|
+
'ntdll.dll', 'psapi.dll', 'shlwapi.dll', 'setupapi.dll'
|
|
549
|
+
]
|
|
550
|
+
return known_dlls
|
|
551
|
+
|
|
552
|
+
@staticmethod
|
|
553
|
+
def check_integrity():
|
|
554
|
+
try:
|
|
555
|
+
result = subprocess.run('sfc /scannow', shell=True, capture_output=True, text=True, timeout=300)
|
|
556
|
+
return result.stdout
|
|
557
|
+
except:
|
|
558
|
+
return None
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: winfw
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The best Windows System Library for System Developing.
|
|
5
|
+
Home-page: https://github.com/YourName/winfw
|
|
6
|
+
Author: Suleiman
|
|
7
|
+
Author-email: your@email.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/YourName/winfw/issues
|
|
9
|
+
Project-URL: Source, https://github.com/YourName/winfw
|
|
10
|
+
Keywords: windows,system,automation,mouse,keyboard,processes,registry,system32
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 7
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 8
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 10
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows :: Windows 11
|
|
18
|
+
Classifier: Development Status :: 4 - Beta
|
|
19
|
+
Classifier: Intended Audience :: Developers
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: System :: Systems Administration
|
|
22
|
+
Classifier: Topic :: Utilities
|
|
23
|
+
Requires-Python: >=3.6
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: keywords
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
Dynamic: project-url
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
winfw
|