forked from code-gopher/DnfHelper-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory.py
More file actions
66 lines (53 loc) · 2.17 KB
/
memory.py
File metadata and controls
66 lines (53 loc) · 2.17 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
from pymem import Pymem
class Memory:
# 全局进程id
processId = int
# 读写对象
pm = Pymem
def __int__(self):
pass
def set_process_id(self, process_id):
self.pm = Pymem(process_id)
self.processId = process_id
def read_int(self, address: int) -> int:
try:
return self.pm.read_int(address)
except Exception as e:
print("read_int 地址:{},错误:{}".format(address, e.args))
def read_long(self, address: int) -> int:
try:
return self.pm.read_longlong(address)
except Exception as e:
print("read_longlong 地址:{},错误:{}".format(address, e.args))
def read_float(self, address: int) -> float:
try:
return self.pm.read_float(address)
except Exception as e:
print("read_float 地址:{},错误:{}".format(address, e.args))
def read_bytes(self, address: int, length: int) -> bytes:
try:
return self.pm.read_bytes(address, length)
except Exception as e:
print("read_bytes 地址:{},错误:{}".format(address, e.args))
def write_int(self, address: int, value: int):
try:
return self.pm.write_int(address, value)
except Exception as e:
print("write_int 地址:{} 值:{},错误:{}".format(address, value, e.args))
def write_long(self, address: int, value: int):
try:
return self.pm.write_longlong(address, value)
except Exception as e:
print("write_longlong 地址:{} 值:{},错误:{}".format(address, value, e.args))
def write_float(self, address: int, value: float):
try:
return self.pm.write_float(address, value)
except Exception as e:
print("write_float 地址:{} 值:{},错误:{}".format(address, value, e.args))
def write_bytes(self, address: int, value: bytes):
try:
return self.pm.write_bytes(address, value, len(value))
except Exception as e:
print("write_bytes 地址:{} 值:{},错误:{}".format(address, value, e.args))
def allocate(self, length) -> int:
return self.pm.allocate(length)