MCPcopy Create free account
hub / github.com/Selectively11/CloudRedirect / SerializeMessage

Function SerializeMessage

src/platform/linux/cloud_hooks.cpp:213–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213static std::vector<uint8_t> SerializeMessage(void* msg) {
214 if (!msg || !g_serializeToArray) return {};
215
216 // vtable[9] = ByteSizeLong (offset +36 on 32-bit)
217 uint32_t* vtable = *(uint32_t**)msg;
218 if (!vtable || !vtable[9]) return {};
219 using ByteSizeFn = int(__attribute__((cdecl)) *)(void*);
220 ProtoCrashGuard guard;
221 int sig = sigsetjmp(g_protoJmpBuf, 1);
222 if (sig != 0) {
223 LOG("[Hook] SerializeToArray helper crashed with signal %d", sig);
224 return {};
225 }
226
227 int size = ((ByteSizeFn)vtable[9])(msg);
228 if (size <= 0 || size > 64 * 1024 * 1024) return {};
229
230 std::vector<uint8_t> buf(size);
231 g_serializeToArray(msg, buf.data());
232 return buf;
233}
234
235static bool ParseIntoMessage(void* msg, const uint8_t* data, size_t len) {
236 if (!msg || !g_parseFromArray || !data || len == 0) return false;

Callers 5

SerializeBodyTLFunction · 0.85
EnsureInitializedFunction · 0.85
hook_BYieldingSendFunction · 0.85
hook_NotificationDirectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected