Skip to main content
Filter by
Sorted by
Tagged with
1 vote
0 answers
76 views

I have a project written in C++ which consists in a main application which loads a few plugins. The overview of the problem is as follows: The plugins, which are shared objects (.so), load without any ...
southernKid33's user avatar
2 votes
1 answer
89 views

I'm trying to intercept dlsym calls using LD_PRELOAD. To debug the library, I am building it with AddressSanitizer. The resulting behavior is inconsistent, however: sometimes it works as expected, but ...
bmodel's user avatar
  • 33
1 vote
1 answer
71 views

I'm writing an application fooapp which can use one of several other, existing libraries for some part of its functionality. For the sake of discussion, let's say that its saving the program output. ...
einpoklum's user avatar
  • 137k
1 vote
1 answer
155 views

Below is a minimal reproducible example, where the goal is to call b_util() from a(). My question is whether it's possible to do this without explicitly passing a b_util() function pointer to a.c. I ...
MyNameIsTrez's user avatar
2 votes
1 answer
106 views

I was trying call a function dynamically in an executable file itself. The target function test_func was coded with the main function in the same source file. Here is the sample code: #include <...
uscq's user avatar
  • 128
3 votes
1 answer
81 views

I am trying to override "php_network_connect_socket_to_host" and cannot do it, although I am able to override "connect". Here is the source code of wrapper.c: #define _GNU_SOURCE 1 ...
N V's user avatar
  • 33
1 vote
1 answer
135 views

Say I have an application foo that is linked against bar.so. I have another library, buzz.so that the application does not directly link, but that I use when I run the application with LD_PRELOAD like ...
Joseph Garvin's user avatar
0 votes
0 answers
90 views

Assume there are shared libraries lib1, lib2, etc. each declaring and using one of its own global variable g_lib1, g_lib2, etc. I have the addresses of g_lib1, g_lib2, etc., as well as the names of ...
Hunter's user avatar
  • 11
0 votes
0 answers
213 views

Just trying debug what wrong with harness code, which was compiled with command: ┌──(kali㉿kali)-[~/…/experimment/research/PoCs/android-afl-qemu] └─$ export CC=/home/kali/Android/Sdk/ndk/22.1.7171670/...
Boom's user avatar
  • 25
4 votes
1 answer
132 views

I was reading the man page to dlopen(), and I stumbled on this block of code: cosine = (double (*)(double)) dlsym(handle, "cos"); /* According to the ISO C standard, casting ...
Danila Berezin's user avatar
0 votes
1 answer
93 views

Let's say I have a struct defined in MyType.h struct MyType { int x; int y; }; And I build a lib myLib.so which exposes a function that takes the above type as a parameter. #include "...
Ata-E-Rabbi's user avatar
0 votes
1 answer
255 views

Take for instance an application that needs to load several other shared libraries. Each with the same interface. How can I prevent that a crash in any of the loaded shared libraries to not crash the ...
Lucas Mülling's user avatar
1 vote
2 answers
84 views

Suppose I have an executable that dlopens libfirst.so with RTLD_LOCAL which then dlopens libsecond.so with RTLD_GLOBAL. Should the symbols from libsecond.so now be directly available (i.e., without ...
mallwright's user avatar
  • 2,023
0 votes
1 answer
174 views

Newbie question. Suppose there is a third party library ClassLibrary.so, which contains the class definition of a ClassTest and I don't have access to the source of ClassLibrary.so. Can I use ...
Umar Karim's user avatar
2 votes
3 answers
928 views

In C++ code, I would like to be able to include two headers for two different versions of a shared C library that I load at runtime (with dlopen/dlsym on linux, GetProcAddress on windows). For one ...
kingsjester's user avatar
2 votes
0 answers
54 views

I have a program that calls libc::memchr many times. When profiling my code I see that the function using the most time is DlsymWeak::initialize. initialize seem to be called by memchr, which is ...
nlta's user avatar
  • 1,948
1 vote
1 answer
158 views

I am trying to figure out to load the function shm_open dynamically at runtime and have hit a wall. My current code is as such: CMakeLists.txt project(dlsysm_stack_overflow_example) ...
Tom Hudson's user avatar
0 votes
1 answer
548 views

On MacOS Ventura, obtaining a handle to the dynamic loader using dlopen(NULL, 0) returns a handle containing the entire executable's symbol table. Using this handle, one can obtain pointers to symbol ...
jungon's user avatar
  • 49
2 votes
1 answer
78 views

In our code there is a function defined as: a.h extern int (*get_prof_action(void))(void); a.c static int (*ProfAction)(void) = NULL; int (*get_prof_action(void))(void) { return ProfAction; } ...
shenmufeng's user avatar
2 votes
1 answer
235 views

I want to call a function with dlsym and it is a member function of an object, I have the pointer, but it is not working. The function lives in the main executable, and I am loading it from a shared ...
Alvaro Hernandorena's user avatar
-1 votes
1 answer
657 views

I am trying to load library with dlopen(). But call to this dlopen() function sometimes (not always) damages my class variables and then app goes to segmentation fault. Below is not precise code (...
nckm's user avatar
  • 123
2 votes
1 answer
357 views

Assume a dynamic library exports a function, e.g. of type void(), named foo. A client code could then make use of it like in the following snippet (assuming foo is exposed via extern "C" ...
Enlico's user avatar
  • 30.3k
3 votes
1 answer
445 views

I recently added some dynamic plugin behavior in an OSX program which works as designed. However, trying the same on Linux (generic) fails as dlsym() library call fails to resolve symbol in the same ...
Johan's user avatar
  • 397
0 votes
1 answer
234 views

void* l = dlsym(lib,"_ZN11Environment9LibLogger14log_processingEiNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEjS6_z"); *(void **)&log_fcn = l; std::cout<<"Address&...
M N Adarsh Kumar's user avatar
3 votes
0 answers
218 views

I want to simulate loading symbols from a shared library for testing purposes. Is there a way to define a symbol at runtime programmatically such that dlsym will find it? For example: ...
Bruce Adams's user avatar
  • 5,819
0 votes
1 answer
911 views

OS Linux Ubuntu 18.04, gcc 7.4.0 A program should load one SO which is dependent on other SOs. All exported functions of all SOs should be called by the program. I found serveral related questions ...
CatMan's user avatar
  • 203
1 vote
1 answer
878 views

I installed pynput module (version 1.7.4) using this command: pip3 install pynput I tried to import the module in my Jupyter-lab, which always ended up a failure. The error message looks like this: ...
Jaecheol Lee's user avatar
1 vote
1 answer
348 views

Let's say I have a function foo in ./elf. I want to hook it with foo_hook which is located in my shared object. foo is not exported from ./elf. LD_PRELOAD is useful for hooking functions in shared ...
Amit Botzer's user avatar
2 votes
1 answer
296 views

Variatic functions such as printf can be wrapped using dlsym because it has a va_list version vprintf. So, int printf(const char *format, ...); //is equivalent to int vprintf(const char *format, ...
antrix's user avatar
  • 41
3 votes
2 answers
1k views

I'm faced a strange runtime behavior on Ubuntu 20.04 (gcc v 9.3.0) when using dlsym() call. Please, see below a simple example: file test.cpp: #include <iostream> #include <dlfcn.h> #...
drus's user avatar
  • 505
0 votes
1 answer
361 views

Application written in C, and runs on Ubuntu 18.04. This application links with couple of shared libraries, lets say shared_lib1_external.so, and shared_lib1_internal.so. I have this unique scenario ...
user3622275's user avatar
-1 votes
3 answers
161 views

Let's say I have a program (program.c) that uses rand function in standard C library. 1 #include <stdlib.h> 2 int main(){ 3 int rand_number = rand(); 4 } I also have a shared library (...
M.Soyturk's user avatar
  • 380
0 votes
0 answers
17 views

I have this assembly program that works fine: SECTION .text EXTERN dlopen ; loads a dynamic library EXTERN dlsym ; retrieves the address for a symbol in the dynamic library global _start ; "...
tuket's user avatar
  • 4,159
0 votes
1 answer
369 views

I have a small program in assembler that loads an .so file using dlopen, and then tries to load a function pointer using dlsym. Calling dlopen seems to be fine but it crashes when I call dlsym. ...
tuket's user avatar
  • 4,159
3 votes
2 answers
1k views

I have been trying to intercept calls to malloc and free, following our textbook (CSAPP book). I have followed their exact code, and nearly the same code that I found online and I keep getting a ...
juimdpp's user avatar
  • 47
2 votes
1 answer
1k views

I load a symbol from a shared library like this: void *sym = dlsym(RTLD_DEFAULT, "printf"); That will tell me whether the symbol printf exists in a loaded shared library, and if it does, ...
Simon Kissane's user avatar
1 vote
1 answer
811 views

First, the problem: Thread 2 "lexe.exe" received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff2c89700 (LWP 17367)] do_lookup_x (undef_name=undef_name@entry=0x7fffeb893ad9 &...
Bernd Elkemann's user avatar
1 vote
0 answers
817 views

I am getting issues with dlmopen, but I have successfully used dlopen and dlsym in my cpp program (in linux) void *lib_handle = dlopen(lib_path, RTLD_NOW); After this I used dlsym to get the function ...
Basant Pratap Singh's user avatar
2 votes
0 answers
499 views

I have been looking everywhere for this question, but I cannot seem to get the answer for this. So, every example I have been to is simply how to grab function pointers from SO file, which I have done....
Jacobson123's user avatar
2 votes
1 answer
1k views

I have a C++ program which I need to open a shared object (.so) and load a C++ class from it. I have seen this done on the internet and I have loaded many things using dlsym() in both C and C++, so I ...
Sophie's user avatar
  • 444
0 votes
0 answers
180 views

I have a liba.so. the a.h is: #pragma once #include <functional> extern "C" { void set_loop_func(std::function<void()> fn); int create_thread(); } the a.cpp is: #include &...
simulatorz's user avatar
0 votes
0 answers
301 views

I would like to dlopen() a dynamic library liba_new.so which was created by g++ ../include/a.cpp -fPIC -shared -o liba_new.so -std=c++11 -lpthread. But in the application loading it, i will hook the ...
simulatorz's user avatar
1 vote
1 answer
607 views

I started to dabble in unit testing C code (using check) and stubbing functions. I am trying to unit test a small library of data structures that I wrote and wanted to test how it would react to OOM. ...
BreadyX's user avatar
  • 57
1 vote
2 answers
83 views

Just want to understand the following code: Why we use option (1) other than option (2)? I don't know what's the use of (void**) here? really confused. Class Handle{ private: int unique_id; ...
Biao Cao's user avatar
  • 151
0 votes
1 answer
321 views

SO basically i dont know hu use this funciton "createLib" i can't seem to be able to use it: auto createLibFunc = dlsym(lib, symbol.c_str()); This works, i opened my dymacally loaded lib with dlopen, ...
freeinternet's user avatar
1 vote
0 answers
583 views

I have an executable (1) with two shared objects (2 and 3) opened using dlopen(..., RTLD_GLOBAL). All files include the symbol func(). If I use dlsym(RTLD_NEXT, ...) in 1 looking for the next func() ...
JVanDamme's user avatar
0 votes
1 answer
3k views

I have one C++ program which I want to load into my current running C++ program. Following are the snippet File : a.cpp #include<bits/stdc++.h> using namespace std; void abc() { ...
Pradeep Mahato's user avatar
2 votes
2 answers
989 views

I am trying to wrap function. To do that I thought about using dlsym to get the real function location in memory after having injected my dynamic library. I am running on MacOS Mojave (10.14.6) with ...
GrandChaman's user avatar
2 votes
2 answers
2k views

Suppose I have the following: // lib1.h struct S { int x; }; void f(S* s); // defined in .cpp and // lib2.h struct S { int x; int y; }; void f(S* s); // defined in .cpp Resulting in ...
Kiril Kirov's user avatar
  • 38.5k
7 votes
2 answers
3k views

My title may not be clear, so allow me to explain. I have a piece of code that goes like this: void* pluginFile = dlopen(fileName, RTLD_LAZY); auto function = dlsym(pluginFile, "ExpectedFunction"); ...
JigsawCorp's user avatar