7 #if defined(__NetBSD__)
9 #include <sys/sysctl.h>
11 #if defined(__FreeBSD__)
12 #include <sys/param.h>
13 #include <sys/sysctl.h>
15 #if defined(__DragonFly__)
16 #include <sys/param.h>
17 #include <sys/sysctl.h>
19 #if defined(__OpenBSD__)
20 #include <sys/sysctl.h>
23 #if defined(__HAIKU__)
24 #include <kernel/image.h>
25 #include <sys/param.h>
27 #include <sys/types.h>
40 #if HAVE_ENVIRON || __APPLE__
45 extern char ***_NSGetEnviron(
void);
46 #ifndef PROC_PIDPATHINFO_MAXSIZE
47 #define PROC_PIDPATHINFO_MAXSIZE 1024
53 #include <sys/utsname.h>
67 #include <VersionHelpers.h>
69 #define TMP_BUFSIZE 4096
81 #define RZ_SYS_ASM_START_ROP() \
82 eprintf("rz_sys_run_rop: Unsupported arch\n");
84 #define RZ_SYS_ASM_START_ROP() \
85 __asm__ __volatile__("leaq %0, %%rsp; ret" \
91 #define RZ_SYS_ASM_START_ROP() \
93 __asm lea esp, bufptr\
97 #define RZ_SYS_ASM_START_ROP() \
98 __asm__ __volatile__("leal %0, %%esp; ret" \
103 #define RZ_SYS_ASM_START_ROP() \
104 eprintf("rz_sys_run_rop: Unsupported arch\n");
107 static const struct {
137 struct sigaction sigact = {};
144 sigact.sa_handler = handler;
145 sigemptyset(&sigact.sa_mask);
147 for (
i = 0; sig[
i] != 0;
i++) {
148 sigaddset(&sigact.sa_mask, sig[
i]);
151 for (
i = 0; sig[
i] != 0;
i++) {
152 ret = sigaction(sig[
i], &sigact,
NULL);
154 eprintf(
"Failed to set signal handler for signal '%d': %s\n", sig[
i], strerror(errno));
167 for (
i = 0; sig[
i] != 0;
i++) {
169 if (ret == SIG_ERR) {
170 eprintf(
"Failed to set signal handler for signal '%d': %s\n", sig[
i], strerror(errno));
179 int s[2] = { sig, 0 };
194 wchar_t dir[MAX_PATH];
196 static bool win_ver_initialized =
false;
197 static bool is_win_7_or_greater =
false;
198 if (!win_ver_initialized) {
199 is_win_7_or_greater = IsWindows7OrGreater();
200 win_ver_initialized =
true;
202 if (!(wcpath = rz_utf8_to_utf16(
path))) {
205 swprintf(dir, MAX_PATH,
L"%ls\\*.*", wcpath);
207 return FindFirstFileExW(dir, is_win_7_or_greater ? FindExInfoBasic : FindExInfoStandard,
entry, FindExSearchNameMatch,
NULL, 0);
212 return opendir(
path);
219 WIN32_FIND_DATAW
entry;
229 if ((cfname = rz_utf16_to_utf8(
entry.cFileName))) {
232 }
while (FindNextFileW(
fh, &
entry));
253 char *ret,
cmd[4096];
268 size_t size = backtrace(array, 10);
270 backtrace_symbols_fd(array,
size, 2);
272 void **fp = (
void **)__builtin_frame_address(0);
273 void *saved_pc = __builtin_return_address(0);
274 void *saved_fp = __builtin_frame_address(1);
277 eprintf(
"[%d] pc == %p fp == %p\n", depth++, saved_pc, saved_fp);
285 saved_pc = *(fp + 2);
286 eprintf(
"[%d] pc == %p fp == %p\n", depth++, saved_pc, saved_fp);
290 #pragma message("TODO: rz_sys_bt : unimplemented")
292 #warning TODO: rz_sys_bt : unimplemented
301 #if HAVE_CLOCK_NANOSLEEP && defined(CLOCK_MONOTONIC)
305 return clock_nanosleep(CLOCK_MONOTONIC, 0, &rqtp,
NULL);
318 #if HAVE_CLOCK_NANOSLEEP && defined(CLOCK_MONOTONIC)
320 rqtp.
tv_sec = usecs / 1000000;
322 return clock_nanosleep(CLOCK_MONOTONIC, 0, &rqtp,
NULL);
324 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__) && (__GLIBC__ <= 2) && (__GLIBC_MINOR__ <= 2)
329 return usleep(usecs);
348 #if __APPLE__ && !HAVE_ENVIRON
369 LPWCH
env = GetEnvironmentStringsW();
372 wchar_t *
eq = wcschr(var,
L'=');
374 FreeEnvironmentStringsW(
env);
377 const size_t len =
eq - var;
379 var += wcslen(var) + 1;
386 wcsncpy(
v, var,
len);
387 if (_wputenv_s(
v,
L"")) {
392 var += wcslen(var) + 1;
394 FreeEnvironmentStringsW(
env);
396 #warning rz_sys_clearenv : unimplemented for this platform
418 bool ret = !_wputenv_s(key_, value_);
425 #warning rz_sys_setenv : unimplemented for this platform
431 static char *crash_handler_cmd =
NULL;
435 if (!crash_handler_cmd) {
443 static int checkcmd(
const char *
c) {
447 if (*
c !=
'd' && *
c !=
'%') {
459 int sig[] = { SIGINT, SIGSEGV, SIGBUS, SIGQUIT,
SIGHUP, 0 };
461 if (!checkcmd(
cmd)) {
470 free(crash_handler_cmd);
475 #pragma message("rz_sys_crash_handler : unimplemented for this platform")
489 wchar_t *wkey = rz_utf8_to_utf16(
key);
495 char *ret = rz_utf16_to_utf8(
val);
513 const bool res = (
env && *
env ==
'1');
523 return _getcwd(
NULL, 0);
525 return getcwd(
NULL, 0);
536 int ret =
chdir(homepath);
549 const char *
rva =
"/proc/sys/kernel/randomize_va_space";
555 eprintf(
"Failed to set RVA\n");
560 #elif __FreeBSD__ && __FreeBSD_version >= 1300000
561 size_t vlen =
sizeof(
val);
562 if (sysctlbyname(
"kern.elf32.aslr.enable",
NULL, 0, &
val, vlen) == -1) {
563 eprintf(
"Failed to set RVA 32 bits\n");
568 if (sysctlbyname(
"kern.elf64.aslr.enable",
NULL, 0, &
val, vlen) == -1) {
569 eprintf(
"Failed to set RVA 64 bits\n");
574 size_t vlen =
sizeof(
val);
575 if (sysctlbyname(
"security.pax.aslr.enabled",
NULL, 0, &
val, vlen) == -1) {
576 eprintf(
"Failed to set RVA\n");
580 size_t vlen =
sizeof(
val);
581 if (sysctlbyname(
"vm.randomize_mmap",
NULL, 0, &
val, vlen) == -1) {
582 eprintf(
"Failed to set RVA\n");
598 .args = (
const char **)&
argv[1],
599 .args_size = argc - 1,
661 #pragma message("rz_sys_cmdbg is not implemented for this platform")
663 #warning rz_sys_cmdbg is not implemented for this platform
682 wchar_t *dir_utf16 = rz_utf8_to_utf16(dir);
683 ret = _wmkdir(dir_utf16) != -1;
686 ret =
mkdir(dir, 0755) != -1;
696 eprintf(
"rz_sys_mkdirp: Unable to allocate memory\n");
704 char *
p = strstr(ptr,
":\\");
712 for (; *ptr; ptr++) {
713 if (*ptr ==
'/' || *ptr ==
'\\') {
723 eprintf(
"rz_sys_mkdirp: fail '%s' of '%s'\n",
path, dir);
739 #pragma push_macro("perror")
742 #pragma pop_macro("perror")
745 DWORD dw = GetLastError();
747 if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
748 FORMAT_MESSAGE_FROM_SYSTEM |
749 FORMAT_MESSAGE_IGNORE_INSERTS,
752 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
755 char *
err = rz_sys_conv_win_to_utf8(lpMsgBuf);
770 if (!archstr || !
arch || !*archstr || !*
arch) {
773 if (!strcmp(archstr,
"*") || !strcmp(archstr,
"any")) {
776 if (!strcmp(archstr,
arch)) {
779 if ((ptr = strstr(archstr,
arch))) {
780 char p = ptr[strlen(
arch)];
781 if (!
p ||
p ==
',') {
811 int pdelta, ret, (*cb)();
818 pdelta = ((
size_t)(
p)) & (4096 - 1);
820 ptr += (4096 - pdelta);
823 eprintf(
"rz_sys_run: Cannot run empty buffer\n");
846 waitpid(
pid, &st, 0);
847 if (WIFSIGNALED(st)) {
848 int num = WTERMSIG(st);
852 ret = WEXITSTATUS(st);
868 eprintf(
"rz_sys_run_rop: Cannot allocate buffer\n");
873 eprintf(
"rz_sys_run_rop: Cannot execute empty rop chain\n");
892 if (waitpid(
pid, &st, 0) == -1) {
893 eprintf(
"rz_sys_run_rop: waitpid failed\n");
897 if (WIFSIGNALED(st)) {
898 int num = WTERMSIG(st);
902 ret = WEXITSTATUS(st);
924 const DWORD maxlength = MAX_PATH;
928 processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
FALSE,
pid);
929 if (!processHandle) {
930 eprintf(
"rz_sys_pid_to_path: Cannot open process.\n");
936 length = GetProcessImageFileNameW(processHandle,
filename, maxlength);
937 CloseHandle(processHandle);
939 eprintf(
"rz_sys_pid_to_path: Error calling GetProcessImageFileName\n");
945 eprintf(
"rz_sys_pid_to_path: Error converting to utf8\n");
948 char *
tmp = strchr(
name + 1,
'\\');
951 eprintf(
"rz_sys_pid_to_path: Malformed NT path\n");
954 tmp = strchr(
tmp + 1,
'\\');
957 eprintf(
"rz_sys_pid_to_path: Malformed NT path\n");
964 eprintf(
"rz_sys_pid_to_path: Error allocating memory\n");
969 WCHAR device[MAX_PATH];
970 for (WCHAR drv[] =
L"A:"; drv[0] <=
L'Z'; drv[0]++) {
971 if (QueryDosDeviceW(drv, device, maxlength) > 0) {
972 char *dvc = rz_utf16_to_utf8(device);
976 eprintf(
"rz_sys_pid_to_path: Error converting to utf8\n");
979 if (!strcmp(
tmp, dvc)) {
982 char *
d = rz_utf16_to_utf8(drv);
985 eprintf(
"rz_sys_pid_to_path: Error converting to utf8\n");
992 eprintf(
"rz_sys_pid_to_path: Error calling rz_str_newf\n");
1004 CloseHandle(processHandle);
1005 result = rz_utf16_to_utf8(
filename);
1009 char pathbuf[PROC_PIDPATHINFO_MAXSIZE];
1011 int ret = proc_pidpath(
pid, pathbuf,
sizeof(pathbuf));
1018 #if __FreeBSD__ || __DragonFly__
1019 char pathbuf[PATH_MAX];
1020 size_t pathbufl =
sizeof(pathbuf);
1021 int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME,
pid };
1022 ret = sysctl(mib, 4, pathbuf, &pathbufl,
NULL, 0);
1028 char pathbuf[PATH_MAX];
1029 int mib[4] = { CTL_KERN, KERN_PROC_ARGS,
pid, KERN_PROC_ARGV };
1043 const char *comm =
argv[0];
1045 if (*comm ==
'/' || *comm ==
'.') {
1046 if (!realpath(comm, pathbuf)) {
1053 char *
path = strtok_r(xpath,
":", &
sp);
1063 if (!
stat(pathbuf, &st) && (st.st_mode & S_IXUSR)) {
1073 char *
p = strrchr(pathbuf,
'/');
1080 char pathbuf[MAXPATHLEN];
1084 while (get_next_image_info((team_id)
pid, &group, &ii) == B_OK) {
1085 if (ii.type == B_APP_IMAGE) {
1090 if (ii.type == B_APP_IMAGE) {
1096 char buf[128], pathbuf[1024];
1098 ret =
readlink(
buf, pathbuf,
sizeof(pathbuf) - 1);
1116 #if __APPLE__ && !HAVE_ENVIRON
1117 env = *_NSGetEnviron();
1130 #if __APPLE__ && !HAVE_ENVIRON
1131 *_NSGetEnviron() =
e;
1137 char *
val = strchr(var,
'=');
1138 wchar_t *val_utf16 =
NULL;
1156 int hasbuf = (
buf) ? 1 : 0;
1168 return GetCurrentProcessId();
1170 #warning rz_sys_getpid not implemented for this platform
1177 struct utsname un = { { 0 } };
1178 if (
uname(&un) != -1) {
1182 si->nodename =
strdup(un.nodename);
1195 char tmp[256] = { 0 };
1201 if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0,
1202 KEY_QUERY_VALUE, &
key) != ERROR_SUCCESS) {
1209 if (RegQueryValueExA(
key,
"ProductName",
NULL, &
type,
1210 (LPBYTE)&
tmp, &
size) != ERROR_SUCCESS ||
1217 if (RegQueryValueExA(
key,
"CurrentMajorVersionNumber",
NULL, &
type,
1218 (LPBYTE)&
major, &
size) != ERROR_SUCCESS ||
1219 type != REG_DWORD) {
1223 if (RegQueryValueExA(
key,
"CurrentMinorVersionNumber",
NULL, &
type,
1224 (LPBYTE)&
minor, &
size) != ERROR_SUCCESS ||
1225 type != REG_DWORD) {
1230 if (RegQueryValueExA(
key,
"CurrentBuild",
NULL, &
type,
1231 (LPBYTE)&
tmp, &
size) != ERROR_SUCCESS ||
1238 if (RegQueryValueExA(
key,
"ReleaseId",
NULL, &
type,
1239 (LPBYTE)
tmp, &
size) != ERROR_SUCCESS ||
1260 #if __UNIX__ && HAVE_PIPE2
1265 return pipe2(pipefd, close_on_exec ?
O_CLOEXEC : 0);
1271 #elif __UNIX__ && HAVE_PIPE && defined(O_CLOEXEC)
1275 static bool is_child =
false;
1277 #ifdef RZ_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
1278 #pragma RZ_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(sys_pipe_constructor)
1280 RZ_DEFINE_CONSTRUCTOR(sys_pipe_constructor)
1281 static void sys_pipe_constructor(
void) {
1285 #ifdef RZ_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
1286 #pragma RZ_DEFINE_DESTRUCTOR_PRAGMA_ARGS(sys_pipe_destructor)
1288 RZ_DEFINE_DESTRUCTOR(sys_pipe_destructor)
1289 static void sys_pipe_destructor(
void) {
1293 static bool set_close_on_exec(
int fd) {
1302 static void parent_lock_enter(
void) {
1308 static void parent_lock_leave(
void) {
1323 parent_lock_enter();
1324 if ((res =
pipe(pipefd)) == -1) {
1328 if (close_on_exec && (!set_close_on_exec(pipefd[0]) || !set_close_on_exec(pipefd[1]))) {
1329 perror(
"close-on-exec");
1335 parent_lock_leave();
1346 #elif __UNIX__ && HAVE_PIPE
1348 static HtUU *fd2close;
1352 static bool is_child =
false;
1354 #ifdef RZ_DEFINE_CONSTRUCTOR_NEEDS_PRAGMA
1355 #pragma RZ_DEFINE_CONSTRUCTOR_PRAGMA_ARGS(sys_pipe_constructor)
1357 RZ_DEFINE_CONSTRUCTOR(sys_pipe_constructor)
1358 static void sys_pipe_constructor(
void) {
1360 fd2close = ht_uu_new0();
1363 #ifdef RZ_DEFINE_DESTRUCTOR_NEEDS_PRAGMA
1364 #pragma RZ_DEFINE_DESTRUCTOR_PRAGMA_ARGS(sys_pipe_destructor)
1366 RZ_DEFINE_DESTRUCTOR(sys_pipe_destructor)
1367 static void sys_pipe_destructor(
void) {
1368 ht_uu_free(fd2close);
1372 static void parent_lock_enter(
void) {
1378 static void parent_lock_leave(
void) {
1384 static bool set_close_on_exec(
int fd,
bool close_on_exec) {
1385 bool res = ht_uu_insert(fd2close,
fd, close_on_exec);
1390 static bool close_on_exec_fd_cb(
void *user,
const ut64 key,
const ut64 val) {
1391 bool close_on_exec = (
bool)
val;
1392 if (close_on_exec) {
1398 static void close_fds(
void) {
1399 ht_uu_foreach(fd2close, close_on_exec_fd_cb,
NULL);
1411 parent_lock_enter();
1412 if ((res =
pipe(pipefd)) == -1) {
1416 if (!set_close_on_exec(pipefd[0], close_on_exec) || !set_close_on_exec(pipefd[1], close_on_exec)) {
1417 perror(
"close-on-exec");
1423 parent_lock_leave();
1434 parent_lock_enter();
1435 bool deleted = ht_uu_delete(fd2close,
fd);
1438 parent_lock_leave();
1443 return pipe(pipefd);
1451 return _pipe(pipefd, 0x1000, O_TEXT);
1467 #if __UNIX__ && HAVE_EXECV && HAVE_PIPE && defined(O_CLOEXEC) && !HAVE_PIPE2
1469 parent_lock_enter();
1471 parent_lock_leave();
1474 #elif __UNIX__ && HAVE_EXECV && HAVE_PIPE && !HAVE_PIPE2
1476 parent_lock_enter();
1479 parent_lock_leave();
1488 #if __UNIX__ && HAVE_EXECVE && HAVE_PIPE && defined(O_CLOEXEC) && !HAVE_PIPE2
1490 parent_lock_enter();
1492 parent_lock_leave();
1495 #elif __UNIX__ && HAVE_EXECVE && HAVE_PIPE && !HAVE_PIPE2
1497 parent_lock_enter();
1500 parent_lock_leave();
1509 #if __UNIX__ && HAVE_EXECVP && HAVE_PIPE && defined(O_CLOEXEC) && !HAVE_PIPE2
1511 parent_lock_enter();
1513 parent_lock_leave();
1516 #elif __UNIX__ && HAVE_EXECVP && HAVE_PIPE && !HAVE_PIPE2
1518 parent_lock_enter();
1521 parent_lock_leave();
1530 #if __UNIX__ && HAVE_EXECL && HAVE_PIPE && defined(O_CLOEXEC) && !HAVE_PIPE2
1532 va_list count_args,
args;
1534 va_copy(count_args,
args);
1536 while (va_arg(count_args,
char *) !=
NULL) {
1542 for (
i = 1;
i <= argc;
i++) {
1546 parent_lock_enter();
1548 parent_lock_leave();
1551 #elif __UNIX__ && HAVE_EXECL && HAVE_PIPE && !HAVE_PIPE2
1553 va_list count_args,
args;
1555 va_copy(count_args,
args);
1557 while (va_arg(count_args,
char *) !=
NULL) {
1563 for (
i = 1;
i <= argc;
i++) {
1568 parent_lock_enter();
1571 parent_lock_leave();
1580 #if __UNIX__ && HAVE_SYSTEM && HAVE_PIPE && defined(O_CLOEXEC) && !HAVE_PIPE2
1582 parent_lock_enter();
1584 parent_lock_leave();
1587 #elif __UNIX__ && HAVE_SYSTEM && HAVE_PIPE && !HAVE_PIPE2
1589 parent_lock_enter();
1592 parent_lock_leave();
1595 #elif !HAVE_SYSTEM && APPLE_SDK_IPHONEOS
1607 return WEXITSTATUS(
s);
1610 #elif !HAVE_SYSTEM && HAVE_FORK
1616 char *isbg = strchr(
cmd,
'&');
1640 eprintf(
"Error parsing command arguments\n");
1648 return waitpid(child,
NULL, 0);
1665 #if __UNIX__ && HAVE_PIPE && !HAVE_PIPE2
1666 parent_lock_enter();
1668 pid_t child = fork();
1669 #if __UNIX__ && HAVE_PIPE && !HAVE_PIPE2
1672 }
else if (child > 0) {
1673 parent_lock_leave();
1745 if (!strcmp(
path,
"/dev/null")) {
1750 DWORD sharing = FILE_SHARE_READ;
1751 if (perm & O_RANDOM) {
1752 flags = FILE_FLAG_RANDOM_ACCESS;
1753 }
else if (perm & O_SEQUENTIAL) {
1754 flags = FILE_FLAG_SEQUENTIAL_SCAN;
1756 if (perm & O_TEMPORARY) {
1757 flags |= FILE_FLAG_DELETE_ON_CLOSE | FILE_ATTRIBUTE_TEMPORARY;
1758 sharing |= FILE_SHARE_DELETE;
1759 }
else if (perm & _O_SHORT_LIVED) {
1760 flags |= FILE_ATTRIBUTE_TEMPORARY;
1762 flags |= FILE_ATTRIBUTE_NORMAL;
1765 bool read_only =
false;
1768 creation = CREATE_NEW;
1770 creation = OPEN_ALWAYS;
1772 if (
mode & S_IREAD && !(
mode & S_IWRITE)) {
1773 flags = FILE_ATTRIBUTE_READONLY;
1777 creation = TRUNCATE_EXISTING;
1779 if (!creation || !strcasecmp(
"NUL",
path)) {
1780 creation = OPEN_EXISTING;
1782 DWORD permission = 0;
1784 permission = GENERIC_WRITE;
1785 }
else if (perm &
O_RDWR) {
1786 permission = GENERIC_WRITE | GENERIC_READ;
1788 permission = GENERIC_READ;
1791 permission |= FILE_APPEND_DATA;
1794 sharing |= FILE_SHARE_WRITE;
1797 wchar_t *wepath = rz_utf8_to_utf16(epath);
1804 ret = _open_osfhandle((
intptr_t)
h, perm);
1809 ret = open(epath, perm,
mode);
1821 wchar_t *wepath = rz_utf8_to_utf16(epath);
1826 wchar_t *wmode = rz_utf8_to_utf16(
mode);
1832 ret = _wfopen(wepath, wmode);
1836 ret = fopen(epath,
mode);
static ut64 rva(RzBinObject *o, ut64 paddr, ut64 vaddr, int va)
static static fork const void static count static fd const char const char static newpath const char static path const char path
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence ftruncate
static static fork const void static count static fd const char const char static newpath chdir
static static fork const void static count close
static static sync static getppid static getegid const char static filename char static len readlink
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len key
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags fcntl
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define INVALID_HANDLE_VALUE
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static void list(RzEgg *egg)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API RZ_OWN RzList * rz_list_new(void)
Returns a new initialized RzList pointer (free method is not initialized)
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
void * malloc(size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig mkdir
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset truncate
static static fork const void static count static fd const char const char static newpath execve
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char static mode static oldfd struct tms static buf static getgid static geteuid const char static filename static arg static mask struct ustat static ubuf static getppid static setsid static egid sigset_t static set struct timeval struct timezone static tz fd_set fd_set fd_set struct timeval static timeout const char char static bufsiz const char static swapflags void static offset const char static length static mode static who const char struct statfs static buf unsigned unsigned num
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc kill
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc static sig const char pathname
static static fork const void static count static fd const char const char static newpath char char char static envp time_t static t const char static mode static whence const char static dir time_t static t unsigned static seconds const char struct utimbuf static buf static inc pid
static static fork const void static count static fd const char const char static newpath char char argv
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment signal
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment static handler static getegid char static len static pgid const char static path static newfd static getpgrp static euid const sigset_t static mask const char static len const gid_t static list const char const char static newpath const char static library readdir
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname pipe
static const char struct stat static buf struct stat static buf static vhangup int status
static static fork const void static count static fd const char static mode const char static pathname const char static path const char static dev const char static group static getpid static getuid void void static data static pause const char static mode static sync const char const char static newpath const char static pathname unsigned long static filedes void static end_data_segment signum
static const char struct stat static buf struct stat static buf static vhangup int struct rusage static rusage struct sysinfo static info unsigned static __unused uname
#define rz_warn_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API char * rz_file_binsh(void)
RZ_API bool rz_file_is_regular(const char *str)
RZ_API char * rz_file_path(const char *bin)
RZ_API void * rz_lib_dl_sym(void *handler, const char *name)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API int rz_mem_protect(void *ptr, int size, const char *prot)
RZ_API RZ_OWN char * rz_path_home_expand(RZ_NULLABLE const char *path)
Return a new path with the ~ char expanded to the home directory.
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API size_t rz_str_ncpy(char *dst, const char *src, size_t n)
Secure string copy with null terminator.
RZ_API char ** rz_str_argv(const char *str, int *_argc)
RZ_API bool rz_str_endswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string ends with a specifc sequence of characters (case sensitive)
RZ_API void rz_str_argv_free(char **argv)
RZ_API RzSubprocessWaitReason rz_subprocess_wait(RzSubprocess *proc, ut64 timeout_ms)
RZ_API void rz_subprocess_free(RzSubprocess *proc)
RZ_API ut8 * rz_subprocess_out(RzSubprocess *proc, int *length)
RZ_API RzSubprocess * rz_subprocess_start_opt(RzSubprocessOpt *opt)
RZ_API void rz_subprocess_fini(void)
RZ_API ut8 * rz_subprocess_err(RzSubprocess *proc, int *length)
RZ_API ssize_t rz_subprocess_stdin_write(RzSubprocess *proc, const ut8 *buf, size_t buf_size)
RZ_API bool rz_subprocess_init(void)
@ RZ_SUBPROCESS_PIPE_NONE
No pipe should be created. It can be used for stdin, stdout and stderr.
@ RZ_SUBPROCESS_PIPE_CREATE
Re-use the same pipe as stdout. It can be used for stderr only.
#define rz_sys_mkdir_failed()
static struct sockaddr static addrlen static backlog const void static flags void flags
const char * file
< Name of the executable to run. It is searched also in PATH
void signal_handler(uv_signal_t *req, int signum)
RZ_API bool rz_sys_mkdirp(const char *dir)
RZ_API int rz_sys_execv(const char *pathname, char *const argv[])
RZ_API int rz_sys_execve(const char *pathname, char *const argv[], char *const envp[])
RZ_API bool rz_sys_stop(void)
Send SIGTSTP signal to every process in this process group.
RZ_API int rz_sys_cmdbg(const char *str)
#define RZ_SYS_ASM_START_ROP()
RZ_API bool rz_sys_aslr(int val)
Enable or disable ASLR for the calling process.
RZ_API char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
RZ_API void rz_sys_set_environ(char **e)
RZ_API int rz_sys_execl(const char *pathname, const char *arg,...)
RZ_API int rz_sys_setenv(const char *key, const char *value)
Set an environment variable in the calling process.
RZ_API void rz_sys_perror_str(const char *fun)
RZ_API char * rz_sys_cmd_strf(const char *fmt,...)
RZ_API char * rz_sys_whoami(char *buf)
RZ_API int rz_sys_truncate_fd(int fd, ut64 length)
RZ_API int rz_sys_pipe(int pipefd[2], bool close_on_exec)
RZ_API void rz_sys_exit(int status, bool nocleanup)
RZ_API int rz_sys_run_rop(const ut8 *buf, int len)
RZ_API int rz_sys_open(const char *path, int perm, int mode)
RZ_API void rz_sys_env_init(void)
RZ_API bool rz_sys_getenv_asbool(const char *key)
Return true if the environment variable has the value 1, false otherwise.
RZ_API RzList * rz_sys_dir(const char *path)
static const struct @334 arch_bit_array[]
RZ_API int rz_sys_clearenv(void)
Clean all environment variables in the calling process.
RZ_API int rz_sys_fork(void)
RZ_API int rz_sys_pipe_close(int fd)
RZ_API int rz_sys_kill(int pid, int sig)
Send signal sig to process with pid pid.
RZ_API int rz_sys_truncate(const char *file, int sz)
RZ_API int rz_sys_getpid(void)
RZ_API FILE * rz_sys_fopen(const char *path, const char *mode)
RZ_API char * rz_sys_cmd_str(const char *cmd, const char *input, int *len)
RZ_API bool rz_sys_mkdir(const char *dir)
RZ_API int rz_sys_execvp(const char *file, char *const argv[])
RZ_API bool rz_sys_chdir(RZ_NONNULL const char *s)
Change current directory to s, taking care of home expansion ~.
RZ_API int rz_sys_system(const char *command)
RZ_API void rz_sys_info_free(RSysInfo *si)
RZ_API char * rz_sys_pid_to_path(int pid)
RZ_API int rz_sys_usleep(int usecs)
Sleep for usecs microseconds.
RZ_API int rz_sys_cmdf(const char *fmt,...)
RZ_API bool rz_is_heap(void *p)
RZ_API RSysInfo * rz_sys_info(void)
RZ_API int rz_sys_signal(int sig, void(*handler)(int))
RZ_API int rz_sys_cmd_str_full(const char *cmd, const char *input, char **output, int *len, char **sterr)
RZ_API char * rz_sys_getdir(void)
Get current working directory.
RZ_API int rz_sys_run(const ut8 *buf, int len)
RZ_API int rz_sys_crash_handler(const char *cmd)
RZ_API int rz_sys_sleep(int secs)
Sleep for secs seconds.
RZ_API int rz_sys_open_perms(int rizin_perms)
Convert rizin permissions (RZ_PERM_*) to posix permissions that can be passed to rz_sys_open .
RZ_API char ** rz_sys_get_environ(void)
RZ_API bool rz_sys_arch_match(const char *archstr, const char *arch)
RZ_API const char * rz_sys_arch_str(int arch)
RZ_API void rz_sys_backtrace(void)
Print the backtrace at the point this function is called from.
RZ_API int rz_sys_arch_id(const char *arch)
static DIR * sys_opendir(const char *path)
RZ_API int rz_sys_sigaction(int *sig, void(*handler)(int))
RZ_API void rz_th_lock_leave(RZ_NONNULL RzThreadLock *thl)
Releases a RzThreadLock structure.
RZ_API void rz_th_lock_free(RZ_NULLABLE RzThreadLock *thl)
Frees a RzThreadLock structure.
RZ_API RZ_OWN RzThreadLock * rz_th_lock_new(bool recursive)
Allocates and initialize a RzThreadLock structure.
RZ_API void rz_th_lock_enter(RZ_NONNULL RzThreadLock *thl)
Acquires a RzThreadLock structure.
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static const z80_opcode fd[]
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)