I have some Python code that uses a library that implements virtual file systems. For the drivers for those virtual file systems to work a bunch of C functions (like readdir(), opendir(), fseek()) need to be overridden/replaced - with the replacements defined in a .so/.cpp file. Usually this could be done by setting LD_PRELOAD to that .so file. However, I need to be able to override these functions at runtime, and ideally revert back to the non-overridden functions once the Python functions that use those overridden functions have executed. Is this possible?
How can I override C functions (like with LD_PRELOAD) at runtime?
895 Views Asked by false_azure At
1
There are 1 best solutions below
Related Questions in PYTHON
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
- python how to write list of lists to file
- Removing URL features from tokens in NLTK
- Optimizing for Social Leaderboards
- Python : Get size of string in bytes
- What is the code of the sorted function?
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in C
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in DYNAMIC-LINKING
- CMake `link_directories` for libstdc++.so
- Contiki - Run-time linking of a loadable module containing reference to another loadable module is possible?
- Turning a statically linked library into a dynamic one
- Boost unit test dynamic linking on Ubuntu
- arm-linux libstdc++ difference in debug and release
- loading shared library into shared memory
- Can a UWP program load plugin?
- library not found although I use ldconfig and /etc/ld.so.conf.d/lib.conf
- How do I implement Android Firebase dynamic links without a website?
- g++ -fPIC not producing position independent code
- Finding virtual memory address of variable on osx
- How can I "register" my library libfoo.so to link it with `-lfoo`?
- Resolving symbols differently in different dynamically loaded objects
- g++ linking a static library into a dynamic library (without -fPIC)
- cmake linking shared libraries on ubuntu
Related Questions in LD-PRELOAD
- LD_PRELOADING dlopen on android
- Use LD_PRELOAD on ubuntu to intercept the network interaction of mysqld
- How can I override C functions (like with LD_PRELOAD) at runtime?
- Overriding getdirentries in C
- Switching Between More than Two Shared Libraries (LD_PRELOAD)
- Untar and load to LD_PRELOAD
- libfaketime and Mac OS, LD_PRELOAD
- LD_PRELOAD causing segmentation fault in dynamic library loader
- Why is LD_PRELOAD usage discouraged?
- Hooking into Linux executable with LD_PRELOAD not work
- Dynamic linked Go program when cross compile
- What does it mean for a shared object to be listed twice, both as found and not found, after setting LD_PRELOAD?
- export LD_PRELOAD for matlab MEX files
- How does the libhugetlbfs library replace the memory allocation process with huge pages?
- Override open function using LD_PRELOAD
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
I am guessing you want ctypes. Here is a discussion: https://docs.python.org/2/library/ctypes.html