-
Notifications
You must be signed in to change notification settings - Fork 3
/
linux_struct.py
executable file
·160 lines (146 loc) · 4.17 KB
/
linux_struct.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
__author__ = 'ling'
from ctypes import *
from cpuinfo import *
# From /usr/include/asm-i386/user.h
class user_regs_struct(Structure):
"""
if CPU_PPC32:
_fields_ = (
("gpr0", c_ulong),
("gpr1", c_ulong),
("gpr2", c_ulong),
("gpr3", c_ulong),
("gpr4", c_ulong),
("gpr5", c_ulong),
("gpr6", c_ulong),
("gpr7", c_ulong),
("gpr8", c_ulong),
("gpr9", c_ulong),
("gpr10", c_ulong),
("gpr11", c_ulong),
("gpr12", c_ulong),
("gpr13", c_ulong),
("gpr14", c_ulong),
("gpr15", c_ulong),
("gpr16", c_ulong),
("gpr17", c_ulong),
("gpr18", c_ulong),
("gpr19", c_ulong),
("gpr20", c_ulong),
("gpr21", c_ulong),
("gpr22", c_ulong),
("gpr23", c_ulong),
("gpr24", c_ulong),
("gpr25", c_ulong),
("gpr26", c_ulong),
("gpr27", c_ulong),
("gpr28", c_ulong),
("gpr29", c_ulong),
("gpr30", c_ulong),
("gpr31", c_ulong),
("nip", c_ulong),
("msr", c_ulong),
("orig_gpr3", c_ulong),
("ctr", c_ulong),
("link", c_ulong),
("xer", c_ulong),
("ccr", c_ulong),
("mq", c_ulong), # FIXME: ppc64 => softe
("trap", c_ulong),
("dar", c_ulong),
("dsisr", c_ulong),
("result", c_ulong),
)
elif CPU_ARM:
_fields_ = tuple(("r%i" % reg, c_ulong) for reg in range(18))
elif CPU_64BITS:
"""
if CPU_64BITS:
_fields_ = (
("r15", c_ulong),
("r14", c_ulong),
("r13", c_ulong),
("r12", c_ulong),
("rbp", c_ulong),
("rbx", c_ulong),
("r11", c_ulong),
("r10", c_ulong),
("r9", c_ulong),
("r8", c_ulong),
("rax", c_ulong),
("rcx", c_ulong),
("rdx", c_ulong),
("rsi", c_ulong),
("rdi", c_ulong),
("orig_rax", c_ulong),
("rip", c_ulong),
("cs", c_ulong),
("eflags", c_ulong),
("rsp", c_ulong),
("ss", c_ulong),
("fs_base", c_ulong),
("gs_base", c_ulong),
("ds", c_ulong),
("es", c_ulong),
("fs", c_ulong),
("gs", c_ulong)
)
else:
_fields_ = (
("ebx", c_ulong),
("ecx", c_ulong),
("edx", c_ulong),
("esi", c_ulong),
("edi", c_ulong),
("ebp", c_ulong),
("eax", c_ulong),
("ds", c_ushort),
("__ds", c_ushort),
("es", c_ushort),
("__es", c_ushort),
("fs", c_ushort),
("__fs", c_ushort),
("gs", c_ushort),
("__gs", c_ushort),
("orig_eax", c_ulong),
("eip", c_ulong),
("cs", c_ushort),
("__cs", c_ushort),
("eflags", c_ulong),
("esp", c_ulong),
("ss", c_ushort),
("__ss", c_ushort),
)
class _sifields_sigfault_t(Union):
_fields_ = (
("_addr", c_void_p),
)
pid_t = c_int
uid_t = c_ushort
clock_t = c_uint
class _sifields_sigchld_t(Structure):
_fields_ = (
("pid", pid_t),
("uid", uid_t),
("status", c_int),
("utime", clock_t),
("stime", clock_t),
)
class _sifields_t(Union):
_fields_ = (
("pad", c_char * (128 - 3 * sizeof(c_int))),
("_sigchld", _sifields_sigchld_t),
("_sigfault", _sifields_sigfault_t),
# ("_kill", _sifields_kill_t),
# ("_timer", _sifields_timer_t),
# ("_rt", _sifields_rt_t),
# ("_sigpoll", _sifields_sigpoll_t),
)
class siginfo(Structure):
_fields_ = (
("si_signo", c_int),
("si_errno", c_int),
("si_code", c_int),
("_sifields", _sifields_t)
)
_anonymous_ = ("_sifields",)