-
Notifications
You must be signed in to change notification settings - Fork 2
/
Node.py
56 lines (56 loc) · 1.46 KB
/
Node.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
import struct
class Node(object):
ln_Succ = 0
ln_Pred = 4
ln_Type = 8
ln_Pri = 9
ln_Name = 10
lh_Head = 0
lh_Tail = 4
lh_TailPred = 8
lh_Type = 12
lh_Pad = 13
#for LN_TYPE
NT_UNKNOWN = 0
NT_TASK = 1
NT_INTERRUPT = 2
NT_DEVICE = 3
NT_MSGPORT = 4
NT_MESSAGE = 5
NT_FREEMSG = 6
NT_REPLYMSG = 7
NT_RESOURCE = 8
NT_LIBRARY = 9
NT_MEMORY = 10
NT_SOFTINT = 11
NT_FONT = 12
NT_PROCESS = 13
NT_SEMAPHORE = 14
NT_SIGNALSEM = 15
NT_BOOTNODE = 16
NT_KICKMEM = 17
NT_GRAPHICS = 18
NT_DEATHMESSAGE = 19
NT_USER = 254
NT_EXTENDED = 255
def nodes(self, ln):
while True:
lnsucc = self.amiga.peek32(ln + self.ln_Succ)
if not lnsucc:
break
lnpred = self.amiga.peek32(ln + self.ln_Pred)
if not lnpred:
ln = lnsucc
continue
yield ln
ln = lnsucc
def nodeheaders(self, lh):
for ln in self.nodes(lh):
yield (ln, self.amiga.readmem(ln, 14))
def nodeheader(self, ln):
(lnsucc, lnpred, lntype, lnpri, lnname) = struct.unpack(">IIBBI", ln)
return (lnsucc, lnpred, lntype, lnpri, lnname)
def nodeheaderwithname(self, ln):
(lnsucc, lnpred, lntype, lnpri, lnnameptr) = self.nodeheader(ln)
lnname = self.amiga.readstr(lnnameptr)
return (lnsucc, lnpred, lntype, lnpri, lnnameptr, lnname)