ITコンサルの日常

ITコンサル会社に勤務する普通のITエンジニアの日常です。

2008-03-12から1日間の記事一覧

LD_PRELOADで共有ライブラリを差し換える

BINARY HACKS p225やっぱり写経。 taka@ubuntu:~$ more gethostname.c #include #include int gethostname(char *name, size_t len) { char *p = getenv("FAKE_HOSTNAME"); if(p == NULL) { p = "localhost"; } strncpy(name, p, len - 1); name[len - 1] = …

CからC++の関数を呼び出す

BINARY HACKS p65今度は逆。 書籍中では、いきなりboostとか出てきてしまってツライので、さっきの例の逆をやってみる。 taka@ubuntu:~$ more dbg2.cpp // // dbg2.cpp // #include extern "C" { void dbg(const char *s) { std::cout ubuntu:~$ more sample…

C++からCの関数を呼び出す

BINARY HACKS p62とりあえずそのまま写経。 taka@ubuntu:~$ more dbg.c // // dbg.c // #include void dbg(const char *s) { printf("Log: %s\n", s); } taka@ubuntu:~$ more sample.cpp // // sample.cpp // extern "C" void dbg(const char *s); int main(…