Created
December 23, 2017 09:26
-
-
Save komang4130/61a6c5ad1df2331979603915b3ea78ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <linux/input.h> | |
/* Function pointers to hold the value of the glibc functions */ | |
static ssize_t (*real_write)(int fd, const void *buf, size_t count) = NULL; | |
/* wrapping write function call */ | |
ssize_t write(int fd, const void *buf, size_t count) | |
{ | |
FILE *file = fopen("/home/komang4130/Desktop/Viettel/challenge1/abc.txt","r"); | |
if ( file == NULL ) | |
{ | |
file = fopen("/home/komang4130/Desktop/Viettel/challenge1/abc.txt","w"); | |
fclose(file); | |
} | |
else | |
fclose(file); | |
real_write = dlsym(RTLD_NEXT, "write"); | |
real_write(fd, buf, count); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment