This repository was archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrflags.c
More file actions
87 lines (76 loc) · 2.82 KB
/
rflags.c
File metadata and controls
87 lines (76 loc) · 2.82 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
83
84
85
86
/* pyxed - Python bindings for Intel's XED2
* huku <huku@grhack.net>
*
* rflags.c - Exports a Python class, called `Rflags', that represents the CPU
* flags register contents.
*/
#include "includes.h"
#include "rflags.h"
/* CPU flags along with a brief description. */
static PyMemberDef members[] =
{
{"_if", T_UINT, offsetof(rflags_t, _if), 0, "Interrupt enable flag"},
{"ac", T_UINT, offsetof(rflags_t, ac), 0, "Alignment check flag"},
{"af", T_UINT, offsetof(rflags_t, af), 0, "Adjust flag"},
{"cf", T_UINT, offsetof(rflags_t, cf), 0, "Carry flag"},
{"df", T_UINT, offsetof(rflags_t, df), 0, "Direction flag"},
{"id", T_UINT, offsetof(rflags_t, id), 0, "Identification flag"},
{"nt", T_UINT, offsetof(rflags_t, nt), 0, "Nested task flag"},
{"of", T_UINT, offsetof(rflags_t, of), 0, "Overflow flag"},
{"pf", T_UINT, offsetof(rflags_t, pf), 0, "Parity flag"},
{"rf", T_UINT, offsetof(rflags_t, rf), 0, "Resume flag"},
{"sf", T_UINT, offsetof(rflags_t, sf), 0, "Sign flag"},
{"tf", T_UINT, offsetof(rflags_t, tf), 0, "Trap flag"},
{"vif", T_UINT, offsetof(rflags_t, vif), 0, "Virtual interrupt flag"},
{"vip", T_UINT, offsetof(rflags_t, vip), 0, "Virtual interrupt pending flag"},
{"vm", T_UINT, offsetof(rflags_t, vm), 0, "Virtual 8086 mode flag"},
{"zf", T_UINT, offsetof(rflags_t, zf), 0, "Zero flag"},
{NULL, 0, 0, 0, NULL}
};
static PyTypeObject type;
/* Allocate and initialize a new `Rflags' object given a `xed_flag_set_t'. */
rflags_t *new_rflags(const xed_flag_set_t *flags)
{
rflags_t *rflags = (rflags_t *)PyType_GenericNew(&type, NULL, NULL);
rflags->_if = flags->s._if;
rflags->ac = flags->s.ac;
rflags->af = flags->s.af;
rflags->cf = flags->s.cf;
rflags->df = flags->s.df;
rflags->id = flags->s.id;
rflags->nt = flags->s.nt;
rflags->of = flags->s.of;
rflags->pf = flags->s.pf;
rflags->rf = flags->s.rf;
rflags->sf = flags->s.sf;
rflags->tf = flags->s.tf;
rflags->vif = flags->s.vif;
rflags->vip = flags->s.vip;
rflags->vm = flags->s.vm;
rflags->zf = flags->s.zf;
return rflags;
}
/* Initialization of `pyxed.Rflags' type should go here. */
static void initialize_rflags_type(PyTypeObject *type)
{
/* See comment in "decoder.c" for more information. */
static PyObject type_base[] =
{
PYOBJECT_INITIALIZER
};
*(PyObject *)type = type_base[0];
type->tp_name = "pyxed.Rflags";
type->tp_basicsize = sizeof(rflags_t);
type->tp_flags = Py_TPFLAGS_DEFAULT;
type->tp_doc = "Represents EFLAGS/RFLAGS register contents.";
type->tp_members = members;
}
void register_rflags_object(PyObject *module)
{
initialize_rflags_type(&type);
if(PyType_Ready(&type) == 0)
{
Py_INCREF(&type);
PyModule_AddObject(module, "Rflags", (PyObject *)&type);
}
}