Questions tagged [function-interposition]

Replacing a function in a dynamic library by providing an alternative definition

31 questions
12
votes
2 answers

How to hook system calls of my android app (non rooted device)

I am trying to intercept all system calls made by my Android app on a non rooted device. So every time my app writes/reads a file, I want to intercept the system call and encrypt/decrypt the stream for security purposes. The encryption part is no…
9
votes
3 answers

Why won't LD_PRELOAD work with Python?

Using function interposition for open() with Python doesn't seem to work after the first few calls. I suspect Python is doing some kind of initialization, or something is temporarily bypassing my function. Here the open call is clearly hooked: $ cat…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
8
votes
4 answers

Function interposition in Linux without dlsym

I'm currently working on a project where I need to track the usage of several system calls and low-level functions like mmap, brk, sbrk. So far, I've been doing this using function interposition: I write a wrapper function with the same name as the…
Jay Conrod
  • 28,943
  • 19
  • 98
  • 110
8
votes
3 answers

Interposing part of a shared object by soname

I’ve written a shared object that modifies the arguments to FreeType’s FT_Load_Glyph and FT_Render_Glyph functions, currently by interposing it with LD_PRELOAD and dlsym. This works fine, but I’m curious to know whether or not there’s a way to make…
Delan Azabani
  • 79,602
  • 28
  • 170
  • 210
6
votes
6 answers

How to catch unintentional function interpositioning?

Reading through my book Expert C Programming, I came across the chapter on function interpositioning and how it can lead to some serious hard to find bugs if done unintentionally. The example given in the book is the following: my_source.c mktemp()…
SiegeX
  • 135,741
  • 24
  • 144
  • 154
5
votes
2 answers

Interposition at compile time does not work

I am learning about interposition. The code below is taken from a course (CMU 15-213), however, when I compile, this warning "mymalloc.c:6:29: warning: all paths through this function will call itself [-Winfinite-recursion]" occurs. As I understand,…
4
votes
1 answer

malloc function interposition in the standard C and C++ libraries

I want to write a shared library in such a way that it is possible to isolate it’s memory usage from the application it is linked against. That is, if the shared library, let’s call it libmemory.so, calls malloc, I want to maintain that memory in a…
sholsapp
  • 15,542
  • 10
  • 50
  • 67
4
votes
1 answer

Interposing of OS X system calls

I need to interpose (get my functions called instead of the original functions) some OS X system calls to overcome a flaw in a piece of closed-source software. Preferably, the resulting solution would work under 10.5 (Leopard) and newer, but I might…
3
votes
3 answers

how do I interpose on Long/String compareTo()?

I have a class implementing a data structure storing Comparable objects. Some instances hold Longs and other Strings. I want to count the number of comparisons that occur, without changing the data structure class or the application too much. One…
2
votes
3 answers

Capturing Display / Monitor Images, Sending Keyboard Input on Linux

I need to process images sent to my laptop's video display, and I need to send keyboard input to my Linux system, using a C++ or shell program. My goal is to process images that are part of an FPS game, then taking action inside that game (hence the…
1
vote
1 answer

Hook statically linked "malloc" function family

I am using Detours to hook malloc/free of any target .exe without the access of its source code. I have succeeded in hooking malloc/free which are dynamically linked from the .exe. I'm wondering whether Detours can be used to hook statically linked…
Infinite
  • 3,198
  • 4
  • 27
  • 36
1
vote
1 answer

Override a CMake function twice

I have a CMake include file that overrides the built-in add_executable function, and I would like to figure out a way to do so transparently, so that if another file includes this file, but then also overrides add_executable, it will behave just as…
TallChuck
  • 1,725
  • 11
  • 28
1
vote
0 answers

Will using DYLD_INTERPOSE for a C function in one iOS static library interpose it for all other libraries in the bundle?

I have a static library objective c with some C functions that I need to modify the behavior of based on the callers. I looked at https://opensource.apple.com/source/dyld/dyld-210.2.3/include/mach-o/dyld-interposing.h and saw that it could be used…
gran_profaci
  • 8,087
  • 15
  • 66
  • 99
1
vote
1 answer

symbol lookup in shared libraries

I have tested such a simple program below /* a shared library */ dispatch_write_hello(void) { fprintf(stderr, "hello\n"); } extern void print_hello(void) { dispatch_write_hello(); } My main program is like this: extern…
HuangJie
  • 1,488
  • 1
  • 16
  • 33
1
vote
1 answer

Mach Injection: System call open is not getting interposed when injecting in Excel

I hooked system calls open, read, write, lstat etc. using osxinj project. Injected this into TextEdit application provided by apple and everything worked fine. When I opened new file using textedit, opencallback was called and messages were logged…
Premsagar
  • 21
  • 4
1
2 3