Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nocache
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Danil Mikhailov
nocache
Commits
34f45b4a
Commit
34f45b4a
authored
Feb 03, 2012
by
Julius Plenz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simple open() and close() syscall interception via dlsym()
parent
f41e340f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
Makefile
Makefile
+3
-0
nocache.c
nocache.c
+31
-0
No files found.
Makefile
0 → 100644
View file @
34f45b4a
default
:
gcc
-Wall
-fPIC
-c
-o
nocache.o nocache.c
gcc
-Wall
-shared
-Wl
,-soname,nocache.so.1
-ldl
-o
nocache.so nocache.o
nocache.c
0 → 100644
View file @
34f45b4a
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include <stdio.h>
int
(
*
_original_open
)(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
(
*
_original_close
)(
int
fd
);
void
init
(
void
)
__attribute__
((
constructor
));
int
open
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
close
(
int
fd
);
void
init
(
void
)
{
_original_open
=
(
int
(
*
)(
const
char
*
,
int
,
mode_t
))
dlsym
(
RTLD_NEXT
,
"open"
);
_original_close
=
(
int
(
*
)(
int
))
dlsym
(
RTLD_NEXT
,
"close"
);
}
int
open
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
{
fprintf
(
stderr
,
"I intercepted the open() call!
\n
"
);
return
_original_open
(
pathname
,
flags
,
mode
);
}
int
close
(
int
fd
)
{
fprintf
(
stderr
,
"I intercepted the close() call!
\n
"
);
return
_original_close
(
fd
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment