59 ret = dlopen(libname, RTLD_GLOBAL | RTLD_LAZY);
61 ret = dlopen(
NULL, RTLD_NOW);
64 RZ_LOG_ERROR(
"rz_lib_dl_open: error: %s (%s)\n", libname, dlerror());
68 if (libname && *libname) {
69 libname_ = rz_sys_conv_utf8_to_win(libname);
71 libname_ =
calloc(MAX_PATH,
sizeof(TCHAR));
73 RZ_LOG_ERROR(
"lib/rz_lib_dl_open: Failed to allocate memory.\n");
76 if (!GetModuleFileName(
NULL, libname_, MAX_PATH)) {
80 ret = LoadLibrary(libname_);
93 return dlsym(handler,
name);
95 return GetProcAddress(handler,
name);
106 return dlclose(handler);
108 return handler ? 0 : -1;
118 WCHAR *
name = rz_utf8_to_utf16(
tmp);
157 char *next, *path0 =
env;
159 next = strchr(path0,
':');
208 if (
h &&
h->constructor) {
210 return h->constructor(plugin,
h->user, symbol->
data);
220 if (
h->type ==
type) {
233 if (
p->handler &&
p->handler->destructor) {
234 ret =
p->handler->destructor(
p,
p->handler->user,
p->data);
251 if (strstr(
p->file,
file)) {
253 if (
p->handler &&
p->handler->destructor) {
254 ret =
p->handler->destructor(
p,
255 p->handler->user,
p->data);
273 if (pFileName && !strcmp(
fileName, pFileName)) {
289 RZ_LOG_INFO(
"Not loading library because it has already been loaded from somewhere else: '%s'\n",
file);
298 RZ_LOG_WARN(
"Loading plugins from '%s' is deprecated, please install plugin '%s' in '%s' instead.\n", oldhomeplugins,
basename, homeplugins);
300 free(oldhomeplugins);
318 RZ_LOG_INFO(
"Cannot find symbol '%s' in library '%s'\n",
333 char *
p = strchr(
a,
'.');
335 p = strchr(
p + 1,
'.');
348 bool mismatch = strcmp(mm0,
mm1);
352 RZ_LOG_WARN(
"Module version mismatch %s (%s) vs (%s)\n",
355 const char *dot = strchr(stru->
version,
'.');
357 int minor = dot ? atoi(dot + 1) : 0;
372 RZ_LOG_DEBUG(
"rz_lib_open_ptr: no handler was defined for %s with type %d\n",
file, stru->
type);
379 RZ_LOG_ERROR(
"rz_lib_open_ptr: Cannot allocate RzLibPlugin\n");
384 p->type = stru->
type;
385 p->data = stru->
data;
387 p->dl_handler = handler;
388 p->handler = lib_handler;
389 p->free = stru->
free;
427 WIN32_FIND_DATAW dir;
437 #ifdef RZ_LIBR_PLUGINS
439 path = RZ_LIBR_PLUGINS;
446 wcpath = rz_utf8_to_utf16(
path);
453 RZ_LOG_INFO(
"Cannot open directory %ls\n", wcpath);
458 swprintf(
file, _countof(
file),
L"%ls/%ls", wcpath, dir.cFileName);
459 wctocbuff = rz_utf16_to_utf8(
file);
468 }
while (FindNextFileW(
fh, &dir));
478 if (de->
d_name[0] ==
'.' || strstr(de->
d_name,
".dSYM")) {
506 if (
type ==
h->type) {
520 strncpy(handler->
desc,
desc,
sizeof(handler->
desc) - 1);
521 handler->
user = user;
534 if (
type ==
h->type) {
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
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 count
RZ_API void Ht_() free(HtName_(Ht) *ht)
#define INVALID_HANDLE_VALUE
RZ_API void rz_lib_free(RzLib *lib)
static RzLibTypeName rz_lib_types[]
RZ_API bool rz_lib_add_handler(RzLib *lib, int type, const char *desc, int(*cb)(RzLibPlugin *, void *, void *), int(*dt)(RzLibPlugin *, void *, void *), void *user)
RZ_API bool rz_lib_del_handler(RzLib *lib, int type)
RZ_API int rz_lib_run_handler(RzLib *lib, RzLibPlugin *plugin, RzLibStruct *symbol)
RZ_API int rz_lib_close(RzLib *lib, const char *file)
RZ_API int rz_lib_open_ptr(RzLib *lib, const char *file, void *handler, RzLibStruct *stru)
RZ_API RzLibHandler * rz_lib_get_handler(RzLib *lib, int type)
RZ_API int rz_lib_types_get_i(const char *str)
struct rz_lib_type_name_t RzLibTypeName
RZ_API void * rz_lib_dl_sym(void *handler, const char *name)
RZ_API void rz_lib_list(RzLib *lib)
RZ_API RzLib * rz_lib_new(const char *symname, const char *symnamefunc)
static const char * __lib_types_get(int id)
static bool __lib_dl_check_filename(const char *file)
RZ_API char * rz_lib_path(const char *libname)
RZ_API int rz_lib_open(RzLib *lib, const char *file)
static char * major_minor(const char *s)
RZ_API void * rz_lib_dl_open(const char *libname)
static bool __already_loaded(RzLib *lib, const char *file)
RZ_API bool rz_lib_opendir(RzLib *lib, const char *path, bool force)
Open all the libraries in the given directory, if it wasn't already opened.
RZ_API int rz_lib_dl_close(void *handler)
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
RZ_API void rz_list_delete(RZ_NONNULL RzList *list, RZ_NONNULL RzListIter *iter)
Removes an entry in the list by using the RzListIter pointer.
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
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 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
#define rz_return_val_if_fail(expr, val)
RZ_API const char * rz_file_basename(const char *path)
RZ_API bool rz_file_exists(const char *str)
RzLibStruct *(* RzLibStructFunc)(void)
#define RZ_LOG_INFO(fmtstr,...)
#define RZ_LOG_WARN(fmtstr,...)
#define RZ_LOG_DEBUG(fmtstr,...)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API RZ_OWN char * rz_path_home_prefix(RZ_NULLABLE const char *path)
Return path prefixed by the home prefix.
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_append(char *ptr, const char *string)
RZ_API const char * rz_str_rstr(const char *base, const char *p)
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 char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
#define RZ_HOME_OLD_PLUGINS
int(* constructor)(RzLibPlugin *, void *user, void *data)
int(* destructor)(RzLibPlugin *, void *user, void *data)
struct rz_lib_handler_t * handler
HtPU * opened_dirs
Hashtable to keep track of already opened directories.