Search This Blog

Friday, November 2, 2007

library level system call hooking

We can use LD_PRELOAD to load our own library before any other libraries are loaded.


// myopen.c
#include
#include
#include
#include
#include

int open(const char *pathname, int flags)
{
void *handle;
char *error;
int ret;
static int (*orig_open)(const char *pathname, int flag) = NULL;

if (!orig_open) {
handle = dlopen("/lib/libc.so.6", RTLD_LAZY);
if (!handle) {
fputs(dlerror(), stderr);
exit(1);
}
orig_open = dlsym(handle, "open");
if ((error = dlerror()) != NULL) {
fprintf(stderr, "%s\n", error);
exit(1);
}
}
printf("calling open for %s\n", pathname);
ret = (*orig_open)(pathname, flags);

return ret;
}


// test.c
#include
#include
#include
#include

int main()
{
int fd;

fd = open("test.txt", O_CREAT);
write(fd, "cool", 4);
close(fd);
return 0;
}

# gcc -Wall -fpic -shared -ldl -o myopen.so myopen.c
# gcc -Wall -o test test.c
# LD_PRELOAD=/tmp/myopen.so ./test

Saturday, October 6, 2007

My sister's visit


My sister came to visit me last week and here is the picture I took with my baby and her baby.

Many people thought that they are twins and indeed they look alike. ;-)


Friday, October 5, 2007

prayer meeting

I write a short article for a prayer meeting each week and here is the one from this week.

Scripture reading
For I am convinced that neither death nor life, neither angels nor demons, neither the present nor the future, nor any powers, neither height nor depth, nor anything else in all creation, will be able to separate us from the love of God that is in Christ Jesus our Lord. (Romans 8:38-39)

For the past two weeks my sister’s family was here in America with me and we had a good time. Yet, the departure date finally came and we were sad that we had to say Good-bye. This reminded me of the well-known explanation of love. In Greek, there are various kinds of love depending on the type of relationship. First, there is a parental/familial love. This is love parents shows toward their children. Second, there is a platonic love between friends. Third, there is a romantic love between husband and wife. Although these loves are great in many senses, we also see the shortcomings. For instance, parental love has its own limitation in that the love is exclusive and temporary. When I was young, I thought that I would live with my parents and sisters forever. Yet, my sister’s visit shows that there is a physical distance gap that limits parental/familial love in one way or another. In addition, someday my parents will depart from this earth to be with the Lord. In other words, even parental love can be limited by distance or time. Therefore, this past two weeks was a good lesson for me because I could realize that human love cannot fill the void in our heart. So where can find we love that is eternal and permanent? Today’s verses show us that we can find that love in Christ Jesus. God first demonstrated His love by sending His one and only son when we still hated Him. No matter what we do to Him, God still loves us and He will not change his mind. Thus, today’s verses describe that His love is so strong that nothing can separate us from His love. So what is the love of God like? His love is limitless. His love is unconditional. His love is abounding. His love is eternal. His love is sacrificial. In conclusion, when I first came to see Manhattan, I was amazed at the number of dogs on the street. Whether it is true or not, someone told me that people are lonely in the city so they keep dogs to fill the void in their heart. I believe that people do this because God is love and we are made in his image so it is impossible to live without love. However, we cannot find the love that can fill their heart other than the love of God. So this morning I have good news for you. You have found the love big enough to fill your heart. Please be encouraged and share this good news. God bless you!

Wednesday, September 12, 2007

This is my first note

I got a blog for the first time. I am not sure if I can update this continually but let me try.

Ilho <><