8void *copy_stack(
void *dst) {
11 snprintf(buff,
sizeof(buff),
"/proc/self/task/%d/maps", tid);
12 FILE *
file = fopen(buff,
"r");
13 if (!
file)
file = fopen(
"/proc/self/maps",
"r");
14 if (!
file)
return nullptr;
16 uintptr_t stack_start = 0, stack_end = 0;
18 while (fgets(buff,
sizeof(buff),
file)) {
19 if (strstr(buff,
"[stack]")) {
21 stack_start = strtoul(buff, &end, 16);
22 stack_end = strtoul(end + 1, &end, 16);
29 memcpy(dst, (
void*)stack_start, stack_end - stack_start);
30 return (
void*)stack_end;