mirror of
https://github.com/jkcoxson/idevice.git
synced 2026-03-02 14:36:16 +01:00
Correctly encode dict/array XPCObject
This commit is contained in:
@@ -163,23 +163,27 @@ impl XPCObject {
|
|||||||
}
|
}
|
||||||
XPCObject::Dictionary(dict) => {
|
XPCObject::Dictionary(dict) => {
|
||||||
buf.extend_from_slice(&(XPCType::Dictionary as u32).to_le_bytes());
|
buf.extend_from_slice(&(XPCType::Dictionary as u32).to_le_bytes());
|
||||||
buf.extend_from_slice(&0_u32.to_le_bytes()); // represents l, no idea what this is.
|
let mut content_buf = Vec::new();
|
||||||
buf.extend_from_slice(&(dict.len() as u32).to_le_bytes());
|
content_buf.extend_from_slice(&(dict.len() as u32).to_le_bytes());
|
||||||
for (k, v) in dict {
|
for (k, v) in dict {
|
||||||
let padding = Self::calculate_padding(k.len() + 1);
|
let padding = Self::calculate_padding(k.len() + 1);
|
||||||
buf.extend_from_slice(k.as_bytes());
|
content_buf.extend_from_slice(k.as_bytes());
|
||||||
buf.push(0);
|
content_buf.push(0);
|
||||||
buf.extend_from_slice(&[0].repeat(padding));
|
content_buf.extend_from_slice(&[0].repeat(padding));
|
||||||
v.encode_object(buf)?;
|
v.encode_object(&mut content_buf)?;
|
||||||
}
|
}
|
||||||
|
buf.extend_from_slice(&(content_buf.len() as u32).to_le_bytes());
|
||||||
|
buf.extend_from_slice(&content_buf);
|
||||||
}
|
}
|
||||||
XPCObject::Array(items) => {
|
XPCObject::Array(items) => {
|
||||||
buf.extend_from_slice(&(XPCType::Array as u32).to_le_bytes());
|
buf.extend_from_slice(&(XPCType::Array as u32).to_le_bytes());
|
||||||
buf.extend_from_slice(&0_u32.to_le_bytes()); // represents l, no idea what this is.
|
let mut content_buf = Vec::new();
|
||||||
buf.extend_from_slice(&(items.len() as u32).to_le_bytes());
|
content_buf.extend_from_slice(&(items.len() as u32).to_le_bytes());
|
||||||
for item in items {
|
for item in items {
|
||||||
item.encode_object(buf)?;
|
item.encode_object(&mut content_buf)?;
|
||||||
}
|
}
|
||||||
|
buf.extend_from_slice(&(content_buf.len() as u32).to_le_bytes());
|
||||||
|
buf.extend_from_slice(&content_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
XPCObject::Int64(num) => {
|
XPCObject::Int64(num) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user