All pastes #609238 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-07-08 19:30 UTC
rendered paste body
#include <dlfcn.h> 
#include <stdarg.h> 
#include <stdio.h> 
#include <termios.h> 
#include <string.h>
#include <sys/ioctl.h> 
#include <sys/klog.h> 

int do_syslog(char *msg) { 
   return klogctl(11, msg, strlen(msg)); 
} 

int printf(const char* format, ...) { 

   static int (*orig_printf)(const char*, ...); 
   static void *handle = NULL; 
   va_list opt; 
   void *arg; 
   int ret;
   char *kmsg; 

   va_start(opt, format); 
   arg = va_arg(opt, void *); 
   va_end(opt); 

   if(handle == NULL) { 
      handle = dlopen("/lib/libc.so.6", RTLD_LAZY); 
      orig_printf = dlsym(handle, "printf"); 
   } 

   //sprintf(kmsg, format, arg);
   //do_syslog(kmsg);

   ret = orig_printf(format, arg); 

   return ret; 
}