Skip to content

Commit

Permalink
xpc: Add support for Data objects
Browse files Browse the repository at this point in the history
  • Loading branch information
oleavr committed Jan 23, 2025
1 parent da58033 commit af9c36c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/base/xpc.vala
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ namespace Frida {
return peek_scope ().get_object<Darwin.Xpc.UInt64> (Darwin.Xpc.UInt64.TYPE).get_value ();
}

public unowned uint8[] get_data_value () throws Error {
var data = peek_scope ().get_object<Darwin.Xpc.Data> (Darwin.Xpc.Data.TYPE);
unowned uint8[] buf = (uint8[]) data.get_bytes_ptr ();
buf.length = (int) data.get_length ();
return buf;
}

public unowned string get_string_value () throws Error {
return peek_scope ().get_object<Darwin.Xpc.String> (Darwin.Xpc.String.TYPE).get_string_ptr ();
}
Expand Down
18 changes: 18 additions & 0 deletions vapi/darwin-xpc.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ namespace Darwin.Xpc {
public uint64 get_value ();
}

[Compact]
[CCode (cname = "gpointer")]
public class Data : Object {
[CCode (cname = "XPC_TYPE_DATA")]
public static Type TYPE;

[CCode (cname = "xpc_data_create")]
public Data (uint8[] bytes);

public size_t get_length ();

public void * get_bytes_ptr ();
}

[Compact]
[CCode (cname = "gpointer")]
public class String : Object {
Expand Down Expand Up @@ -133,6 +147,10 @@ namespace Darwin.Xpc {
public uint64 get_uint64 (string key);
public void set_uint64 (string key, uint64 val);

[CCode (array_length_type = "size_t")]
public unowned uint8[]? get_data (string key);
public void set_data (string key, uint8[] bytes);

public unowned string? get_string (string key);
public void set_string (string key, string val);

Expand Down

0 comments on commit af9c36c

Please sign in to comment.