template <uint32_t StringSpace = kProcessargsInterpStringSpace, uint32_t MaxHandles = ZX_CHANNEL_MAX_MSG_HANDLES>
struct ProcessargsBuffer
Defined at line 76 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
This helps manage a buffer to receive a message on the bootstrap channel in
the legacy
<zircon
/processargs.h> protocol. For the PT_INTERP message
received by a startup dynamic linker, it can use small fixed buffer sizes.
For the general processargs message (sent second when there is a PT_INTERP)
that may be much larger, this can be used with 0 sizes and embedded as the
first member in a larger buffer of dynamic size (or just `reinterpret_cast`
from a sufficiently-aligned and -sized byte buffer pointer). Sizing and
allocating the zx_handle_t buffer for the channel read is not handled here.
Public Members
zx_proc_args header
std::array<uint32_t, MaxHandles> handle_info_space
std::array<char, StringSpace> string_space
Public Methods
bool Valid (Actual actual)
Returns true if the buffer starting with this and extending for a total of
actual_bytes and with actual_handles corresponding handles (as read from
the bootstrap channel) is a valid message in the
<zircon
/processargs.h>
protocol. If so, it's safe to use the other accessor methods and public
members below.
Defined at line 89 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
zx::result<> Wait (zx::unowned_channel bootstrap)
Make sure the channel has a message ready to be read. The parent or
service that started the process might have started this process before
sending its bootstrap message.
Defined at line 118 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
zx::result<Actual> Read (zx::unowned_channel bootstrap, std::span<zx_handle_t> handles, uint32_t num_bytes)
Wait as necessary and read the message into the buffer formed by this
object and optional additional buffer space after it if the optional
num_bytes argument is passed with the total buffer size starting at this.
The buffer size (sizeof(*this) or implicit) must be large enough for a
message that could fill all of handles.size() with handles. On successful
return, the Actual::handles leading subspan of handles have been filled
along with the Actual::bytes of this buffer. The message must be checked
with Valid() before the accessor methods below are used.
Defined at line 136 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
zx::result<Actual> Peek (zx::unowned_channel bootstrap)
Wait as necessary and then peek to see how much buffer space is needed for
the pending message.
Defined at line 155 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
zx::result<> ReadAfterPeek (zx::unowned_channel bootstrap, Actual num, std::span<zx_handle_t> handles)
Read after successful Peek(), where the Actual Read() would return on
success is already known.
Defined at line 169 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
std::string_view message_chars (uint32_t actual_bytes)
Get the whole message buffer as raw chars.
Defined at line 183 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
std::span<const uint32_t> handle_info (uint32_t actual_handles)
Get the whole handle info table in the message.
Defined at line 188 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
std::span<uint32_t> handle_info (uint32_t actual_handles)
Defined at line 192 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
std::string_view environ_chars (uint32_t actual_bytes)
This returns chars containing at least the environ strings, but
possibly more. This can be used to scan the NUL-terminated sequences
directly rather than splitting into the expected number of strings via
the environ_strings() method.
Defined at line 201 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
template <auto take>
uint32_t GetArgsStrings (uint32_t actual_bytes, std::invocable<std::string_view> auto take)
Defined at line 208 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
template <auto take>
uint32_t GetEnvStrings (uint32_t actual_bytes, std::invocable<std::string_view> auto take)
Defined at line 213 of file ../../sdk/lib/ld/include/lib/ld/processargs.h
template <auto take>
uint32_t GetNameStrings (uint32_t actual_bytes, std::invocable<std::string_view> auto take)
Defined at line 218 of file ../../sdk/lib/ld/include/lib/ld/processargs.h