Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_userconf.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <rz_types.h>
#include <rz_util.h>
#include <rz_lib.h>
Go to the source code of this file.
Macros | |
#define | RZ_SYS_ASM_START_ROP() eprintf("rz_sys_run_rop: Unsupported arch\n"); |
#define | USE_FORK 0 |
Variables | |
static char ** | env = NULL |
struct { | |
const char * name | |
ut64 bit | |
} | arch_bit_array [] |
RZ_LIB_VERSION | ( | rz_util | ) |
Definition at line 788 of file sys.c.
References arch, arch_bit_array, and i.
Referenced by rz_core_rtr_gdb_run(), rz_debug_gdb_attach(), rz_debug_gdb_reg_profile(), rz_debug_qnx_attach(), and rz_debug_qnx_reg_profile().
Definition at line 798 of file sys.c.
References arch, arch_bit_array, bit, and i.
Referenced by info(), and rz_egg_load_file().
RZ_API void rz_sys_backtrace | ( | void | ) |
Print the backtrace at the point this function is called from.
Definition at line 265 of file sys.c.
References eprintf.
Referenced by rz_assert_log(), rz_core_is_valid_offset(), rz_io_desc_add(), and winkd_wait_packet().
RZ_API bool rz_sys_chdir | ( | RZ_NONNULL const char * | s | ) |
Change current directory to s
, taking care of home expansion ~.
Definition at line 532 of file sys.c.
References chdir, free(), rz_path_home_expand(), rz_return_val_if_fail, and s.
Referenced by rz_cmd_shell_cd_handler(), rz_main_rizin(), and rz_test_chdir_fromtest().
Clean all environment variables in the calling process.
Please note that environment variables should not be used to store sensitive info as they might be kept elsewhere and there is no access control over that data.
Definition at line 346 of file sys.c.
References e, env, environ, eq, free(), L, len, NULL, RZ_NEWS0, rz_sys_env_init(), and v.
Referenced by rz_run_parseline(), and rz_sys_set_environ().
Definition at line 669 of file sys.c.
References cmd, free(), input(), len, NULL, output, and rz_sys_cmd_str_full().
Referenced by assemble(), getstr(), rz_core_cmd_command(), rz_sys_cmd_strf(), and socket_http_get_recursive().
RZ_API int rz_sys_cmd_str_full | ( | const char * | cmd, |
const char * | input, | ||
char ** | output, | ||
int * | len, | ||
char ** | sterr | ||
) |
Definition at line 590 of file sys.c.
References argv, cmd, rz_subprocess_opt_t::file, input(), len, NULL, output, RZ_LOG_ERROR, rz_str_argv(), rz_str_argv_free(), rz_subprocess_err(), rz_subprocess_fini(), rz_subprocess_free(), rz_subprocess_init(), rz_subprocess_out(), RZ_SUBPROCESS_PIPE_CREATE, RZ_SUBPROCESS_PIPE_NONE, rz_subprocess_start_opt(), rz_subprocess_stdin_write(), rz_subprocess_wait(), stdin_pipe, stdout_pipe, and UT64_MAX.
Referenced by rz_cons_flush(), rz_core_cmd_pipe_old(), and rz_sys_cmd_str().
Definition at line 644 of file sys.c.
References eprintf, test-lz4-list::exit, free(), NULL, pid, rz_file_binsh(), rz_sys_execl(), rz_sys_fork(), and cmd_descs_generate::str.
Referenced by rz_main_rz_agent().
Definition at line 457 of file sys.c.
References cmd, free(), rz_sys_sigaction(), SIGHUP, signal_handler(), and strdup().
Referenced by rz_main_rizin().
Definition at line 216 of file sys.c.
References fh, free(), HANDLE, INVALID_HANDLE_VALUE, list(), NULL, path, readdir, rz_list_append(), rz_list_new(), rz_list_newf(), strdup(), and sys_opendir().
Referenced by __clear_layout_cb(), __get_panels_config_file_from_dir(), __init_menu_saved_layout(), autocmplt_cmd_arg_file(), autocomplete_process_path(), cmd_print_format(), database_load(), is_cpu_valid(), list_themes_in_path(), load_scripts_for(), recursive_search_glob(), rtr_dir_files(), rz_cons_hud_path(), rz_core_loadlibs(), rz_core_parse_rizinrc(), rz_syscmd_ls(), rz_test_test_database_load_fuzz(), and rzfind_open_dir().
RZ_API void rz_sys_env_init | ( | void | ) |
Definition at line 1108 of file sys.c.
References env, and rz_sys_get_environ().
Referenced by rz_main_rizin(), and rz_sys_clearenv().
Definition at line 1575 of file sys.c.
Referenced by bochs_open(), rz_core_cmd_pipe_old(), rz_run_start(), and rz_sys_cmdbg().
Definition at line 1483 of file sys.c.
Referenced by rz_run_start(), and rz_socket_proc_open().
Definition at line 1525 of file sys.c.
Referenced by rz_subprocess_start_opt().
Definition at line 183 of file sys.c.
References test-lz4-list::exit, and status.
Referenced by lang_pipe_run(), and rz_subprocess_start_opt().
Definition at line 1815 of file sys.c.
References benchmark::FILE, free(), NULL, path, rz_file_is_regular(), rz_path_home_expand(), and rz_return_val_if_fail.
Referenced by __write(), DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), ihex_write(), load_1(), rz_cmd_cmp_file_handler(), rz_cons_flush(), rz_core_cmd_foreach(), rz_core_dump(), rz_file_dump(), rz_file_hexdump(), rz_file_slurp(), rz_file_slurp_hexpairs(), rz_file_slurp_range(), rz_line_hist_load(), rz_line_hist_save(), rz_run_parseline(), rz_save_panels_layout(), and rz_vlog().
Definition at line 1679 of file sys.c.
Referenced by lang_pipe_run(), redirect_socket_to_pty(), rz_core_cmd_pipe_old(), rz_main_rz_agent(), rz_main_rz_bin(), rz_run_config_env(), rz_run_start(), rz_socket_proc_open(), rz_socket_spawn(), rz_subprocess_start_opt(), rz_sys_cmdbg(), rz_sys_run(), rz_sys_run_rop(), rzpipe_open(), and wrap_fork().
RZ_API char** rz_sys_get_environ | ( | void | ) |
Definition at line 1115 of file sys.c.
References env, environ, NULL, and rz_lib_dl_sym().
Referenced by autocmplt_cmd_arg_env(), create_child_env(), rz_cmd_shell_env_handler(), rz_main_rizin(), rz_run_start(), and rz_sys_env_init().
RZ_API char* rz_sys_getdir | ( | void | ) |
Get current working directory.
Definition at line 521 of file sys.c.
References NULL.
Referenced by getcommapath(), rz_cmd_shell_cd_handler(), rz_cmd_shell_pwd_handler(), rz_file_abspath(), rz_test_chdir_fromtest(), rz_test_main(), and windbg_gcore().
Get the value of an environment variable named key
or NULL if none exists.
Definition at line 483 of file sys.c.
Referenced by rz_sys_getenv_asbool().
Return true if the environment variable has the value 1, false otherwise.
Definition at line 511 of file sys.c.
References env, free(), key, and rz_sys_getenv().
Referenced by rz_core_parse_rizinrc(), and rz_main_rizin().
Definition at line 1175 of file sys.c.
References DWORD, key, major, minor, NULL, RZ_NEW0, rz_str_newf(), rz_sys_info_free(), rz_sys_perror, si, strdup(), autogen_x86imm::tmp, type, and uname.
Referenced by __is_windows_ten(), and rz_cmd_shell_uname_handler().
Send signal sig
to process with pid pid
.
pid | PID of the process to send the signal to |
sig | Signal to send to the process. |
Definition at line 1850 of file sys.c.
References kill, pid, and rz_return_val_if_fail.
Referenced by rz_debug_signal_send(), rz_main_rz_agent(), and rz_sys_stop().
Definition at line 678 of file sys.c.
Referenced by rz_sys_mkdirp().
Definition at line 691 of file sys.c.
References eprintf, free(), p, path, RZ_SYS_DIR, rz_sys_mkdir(), rz_sys_mkdir_failed, and strdup().
Referenced by __create_panels_config_path(), download_and_write(), extract_binobj(), rz_line_hist_save(), rz_syscmd_mkdir(), and sdb_disk_create().
Definition at line 1740 of file sys.c.
References DWORD, flags, free(), h, HANDLE, INVALID_HANDLE_VALUE, NULL, O_APPEND, O_CREAT, O_EXCL, O_RDWR, O_TRUNC, O_WRONLY, path, rz_path_home_expand(), and rz_return_val_if_fail.
Referenced by apprentice_compile(), apprentice_map(), binutils_assemble(), buf_file_init(), langFromHashbang(), procfs_pid_slurp(), rz_cons_pipe_open(), rz_core_editor(), rz_file_mkstemp(), rz_file_mmap(), rz_file_mmap_resize(), rz_file_truncate(), rz_sys_aslr(), rz_sys_truncate(), and sp_open().
Convert rizin permissions (RZ_PERM_*) to posix permissions that can be passed to rz_sys_open .
rz_sys_open accepts posix permissions for now, not the arch-independent ones provided by RZ_PERM_*. This function is an helper to convert from rizin permissions to posix ones.
Definition at line 1718 of file sys.c.
References O_CREAT, O_RDONLY, O_RDWR, O_WRONLY, RZ_PERM_CREAT, RZ_PERM_R, and RZ_PERM_W.
Referenced by rz_io_ar_open(), rz_io_ar_open_many(), and rz_io_def_mmap_create_new_file().
Definition at line 737 of file sys.c.
References DWORD, eprintf, err, free(), NULL, and rz_str_endswith().
Definition at line 920 of file sys.c.
References argv, d, DWORD, eprintf, FALSE, free(), getenv(), HANDLE, L, len, length, malloc(), name, NULL, ok, p, path, pid, readlink, rz_str_ncpy(), rz_str_newf(), snprintf, sp, stat, strdup(), and autogen_x86imm::tmp.
Referenced by cmd_debug_pid(), and rz_debug_get_baddr().
Definition at line 1458 of file sys.c.
Referenced by bochs_open(), handle_redirection(), lang_pipe_run(), rz_core_cmd_pipe_old(), rz_run_config_env(), rz_socket_proc_open(), rz_subprocess_init(), rz_subprocess_start_opt(), and rzpipe_open().
Definition at line 1462 of file sys.c.
Referenced by bochs_open(), handle_redirection(), lang_pipe_run(), rz_core_cmd_pipe_old(), rz_run_config_env(), rz_subprocess_fini(), rz_subprocess_free(), rz_subprocess_init(), rz_subprocess_start_opt(), rz_subprocess_wait(), rzpipe_close(), and rzpipe_open().
Definition at line 809 of file sys.c.
References cb, eprintf, test-lz4-list::exit, free(), int, len, malloc(), memcpy(), num, p, pid, rz_mem_protect(), and rz_sys_fork().
Referenced by rz_egg_run().
Definition at line 861 of file sys.c.
References eprintf, test-lz4-list::exit, free(), len, malloc(), memcpy(), num, pid, RZ_SYS_ASM_START_ROP, and rz_sys_fork().
Referenced by rz_egg_run_rop().
RZ_API void rz_sys_set_environ | ( | char ** | e | ) |
Definition at line 1128 of file sys.c.
References e, env, environ, free(), NULL, rz_sys_clearenv(), rz_sys_setenv(), and val.
Referenced by rz_subprocess_start_opt().
Set an environment variable in the calling process.
Definition at line 405 of file sys.c.
Referenced by rz_sys_set_environ().
Definition at line 162 of file sys.c.
References EINVAL, eprintf, i, int, and signal.
Referenced by rz_sys_crash_handler(), and rz_sys_signal().
Definition at line 178 of file sys.c.
References rz_sys_sigaction(), and s.
Referenced by activateDieTime(), rz_cons_break_end(), rz_cons_context_break_pop(), rz_cons_context_break_push(), rz_cons_new(), rz_core_cmd_pipe_old(), rz_socket_connect(), rz_socket_listen(), rz_socket_new(), rz_socket_write(), rz_subprocess_fini(), rz_subprocess_init(), rz_subprocess_stdin_write(), and tcpme().
Sleep for secs
seconds.
Definition at line 300 of file sys.c.
References NULL, timespec::tv_nsec, and timespec::tv_sec.
Referenced by qnxr_attach(), rtr_visual(), rz_cmd_shell_sleep_handler(), rz_core_visual_esil(), rz_core_visual_show_char(), rz_core_visual_trackflags(), rz_main_rizin(), rz_run_config_env(), rz_socket_spawn(), and sdb_lock_wait().
Send SIGTSTP signal to every process in this process group.
Definition at line 1864 of file sys.c.
References rz_sys_kill().
Referenced by rz_cons_controlz().
Definition at line 1658 of file sys.c.
Referenced by binutils_assemble(), handle_redirection_proc(), rz_cmd_shell_mv_handler(), rz_egg_Cfile_parser(), rz_run_start(), rz_sys_cmdf(), rz_test_test_run_unit(), and rzpipe_open().
Definition at line 1692 of file sys.c.
References close, eprintf, fd, O_RDWR, r, rz_sys_open(), rz_sys_truncate_fd(), and truncate.
Referenced by rz_core_dump(), rz_file_dump(), rz_file_hexdump(), and rz_file_mmap_resize().
Definition at line 1684 of file sys.c.
References fd, ftruncate, and length.
Referenced by buf_file_resize(), and rz_sys_truncate().
Sleep for usecs
microseconds.
Definition at line 317 of file sys.c.
References NULL, timespec::tv_nsec, and timespec::tv_sec.
Referenced by basefind_thread_ui(), run_basic_block_analysis(), rz_cmd_debug(), rz_cons_flush(), rz_core_rtr_cmds_query(), rz_core_rtr_http_run(), rz_core_visual_esil(), rz_diff_draw_tui(), rz_socket_spawn(), rz_th_yield(), and visual_seek_animation().
RZ_API char* rz_sys_whoami | ( | char * | buf | ) |
|
static |
Definition at line 210 of file sys.c.
References NULL, path, and rz_return_val_if_fail.
Referenced by rz_sys_dir().
const { ... } arch_bit_array[] |
Referenced by rz_sys_arch_id(), and rz_sys_arch_str().
ut64 bit |
Definition at line 109 of file sys.c.
Referenced by rz_sys_arch_str().
|
static |
Definition at line 32 of file sys.c.
Referenced by autocmplt_cmd_arg_env(), binutils_assemble(), find_include(), find_path(), make_program_env(), nto_send_env(), parse_environment(), qnxr_run(), rz_assert_log(), rz_egg_lang_include_path(), rz_lib_path(), rz_main_rizin(), rz_run_get_environ_profile(), rz_sys_clearenv(), rz_sys_env_init(), rz_sys_get_environ(), rz_sys_getenv_asbool(), rz_sys_set_environ(), system_apply_env_var(), uv_os_environ(), and uv_spawn().
Definition at line 108 of file sys.c.
Referenced by rz_sys_pid_to_path().