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
use std::fmt;
use std::path::PathBuf;
use nom::HexDisplay;
bitflags! {
pub(crate) struct Flags: u64 {
const BYTE_COUNT_MASK = 0x4000_0000;
const BYTE_COUNT_VMASK = 0x4000;
const CLASS_MASK = 0x8000_0000;
const NEW_CLASSTAG = 0xFFFF_FFFF;
}
}
bitflags! {
pub(crate) struct TObjectFlags: u32 {
const IS_ON_HEAP = 0x0100_0000;
const IS_REFERENCED = 1 << 4;
}
}
#[derive(Debug)]
pub enum ClassInfo {
New(String),
Exists(u64),
References(u64),
}
#[derive(Debug, Clone)]
pub struct TObject {
pub(crate) ver: u16,
pub(crate) id: u32,
pub(crate) bits: TObjectFlags,
}
#[derive(Debug, Clone)]
pub struct TNamed {
pub name: String,
pub title: String,
}
#[derive(Debug)]
pub struct TList<'a> {
pub(crate) ver: u16,
pub(crate) tobj: TObject,
pub(crate) name: String,
pub(crate) len: usize,
pub(crate) objs: Vec<Raw<'a>>
}
pub struct Raw<'s> {
pub(crate) classinfo: String,
pub(crate) obj: &'s[u8]
}
#[derive(Debug)]
pub struct Context<'s> {
pub path: PathBuf,
pub offset: u64,
pub s: &'s[u8],
}
impl<'s> fmt::Debug for Raw<'s> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} \n {}", self.classinfo, self.obj.to_hex(16))
}
}