Skip to main content

macho_core/format/io/pod/
objc.rs

1//! Raw 64-bit Objective-C runtime structures.
2
3use zerocopy::{FromBytes, Immutable, KnownLayout};
4
5#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
6#[repr(C)]
7/// The RawObjCClass64 type.
8pub struct RawObjCClass64 {
9    /// The isa field.
10    pub isa: u64,
11    /// The superclass field.
12    pub superclass: u64,
13    /// The cache field.
14    pub cache: u64,
15    /// The vtable field.
16    pub vtable: u64,
17    /// The data field.
18    pub data: u64, // pointer to class_ro_t (bit 0 = swift flag in some ABIs)
19}
20
21#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
22#[repr(C)]
23/// The RawClassRoT64 type.
24pub struct RawClassRoT64 {
25    /// The flags field.
26    pub flags: u32,
27    /// The instance_start field.
28    pub instance_start: u32,
29    /// The instance_size field.
30    pub instance_size: u32,
31    /// The reserved field.
32    pub reserved: u32,
33    /// The ivar_layout field.
34    pub ivar_layout: u64,
35    /// The name field.
36    pub name: u64,
37    /// The base_methods field.
38    pub base_methods: u64,
39    /// The base_protocols field.
40    pub base_protocols: u64,
41    /// The ivars field.
42    pub ivars: u64,
43    /// The weak_ivar_layout field.
44    pub weak_ivar_layout: u64,
45    /// The base_properties field.
46    pub base_properties: u64,
47}
48
49#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
50#[repr(C)]
51/// The RawMethodListHeader type.
52pub struct RawMethodListHeader {
53    /// The entsize_and_flags field.
54    pub entsize_and_flags: u32,
55    /// The count field.
56    pub count: u32,
57}
58
59#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
60#[repr(C)]
61/// The RawMethodT type.
62pub struct RawMethodT {
63    /// The name field.
64    pub name: u64,
65    /// The types field.
66    pub types: u64,
67    /// The imp field.
68    pub imp: u64,
69}
70
71#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
72#[repr(C)]
73/// The RawRelativeMethodT type.
74pub struct RawRelativeMethodT {
75    /// The name_offset field.
76    pub name_offset: i32,
77    /// The types_offset field.
78    pub types_offset: i32,
79    /// The imp_offset field.
80    pub imp_offset: i32,
81}
82
83#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
84#[repr(C)]
85/// The RawIvarT64 type.
86pub struct RawIvarT64 {
87    /// The offset_ptr field.
88    pub offset_ptr: u64,
89    /// The name field.
90    pub name: u64,
91    /// The type_encoding field.
92    pub type_encoding: u64,
93    /// The alignment field.
94    pub alignment: u32,
95    /// The size field.
96    pub size: u32,
97}
98
99#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
100#[repr(C)]
101/// The RawPropertyT type.
102pub struct RawPropertyT {
103    /// The name field.
104    pub name: u64,
105    /// The attributes field.
106    pub attributes: u64,
107}
108
109#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
110#[repr(C)]
111/// The RawProtocolT64 type.
112pub struct RawProtocolT64 {
113    /// The isa field.
114    pub isa: u64,
115    /// The name field.
116    pub name: u64,
117    /// The protocols field.
118    pub protocols: u64,
119    /// The instance_methods field.
120    pub instance_methods: u64,
121    /// The class_methods field.
122    pub class_methods: u64,
123    /// The optional_instance_methods field.
124    pub optional_instance_methods: u64,
125    /// The optional_class_methods field.
126    pub optional_class_methods: u64,
127    /// The instance_properties field.
128    pub instance_properties: u64,
129    /// The size field.
130    pub size: u32,
131    /// The flags field.
132    pub flags: u32,
133}
134
135#[derive(Debug, Clone, Copy, FromBytes, Immutable, KnownLayout)]
136#[repr(C)]
137/// The RawCategoryT64 type.
138pub struct RawCategoryT64 {
139    /// The name field.
140    pub name: u64,
141    /// The cls field.
142    pub cls: u64,
143    /// The instance_methods field.
144    pub instance_methods: u64,
145    /// The class_methods field.
146    pub class_methods: u64,
147    /// The protocols field.
148    pub protocols: u64,
149}