jmtd → software → examples
Some of the smaller programs I have written are most useful as examples of techniques and approaches to problems in programming. Some were written with this purpose in mind, others were actually useful for something.
libfaketime
libfaketime is a small, trivial library that lets you fake the system time on a POSIX environment, via the gettimeofday() system call:
$ date Sat Nov 22 00:15:56 GMT 2003 $ LD_PRELOAD=./libfaketime.so.1.0.0 date Mon Nov 10 09:57:53 GMT 2003
It came about because a friend of mine wanted to circumvent a time-based check in a binary for which he didn't have the source code. I called it libfaketime since that seemed to be the most appropriate name for such a thing. It may prove a good reference for people interested in learning how to hijack a system library via LD_PRELOAD, or write a shared library. faketime.tar.gz, 920 bytes. Only tested on Linux, public domain.
If you want something more sophisticated, which also overrides time/ftime, and allows you to set relative offsets, go to http://www.code-wizards.com/projects/libfaketime/, a library which basically uses the same approach but wraps all the time syscalls and is also called libfaketime.
Another useful LD_PRELOAD library is hidefile.
namekill
Kills processes matching a name (case-insensitive) supplied on the command line. Designed for windows NT/2000/XP but may work with 9x too (uses psapi). Compiled with mingw. Public Domain.
I wrote this in order to remove an annoying advert banner which Durham University public computers would display when you logged in.
- namekill.exe.gz, 34K
- namekill.c, 1.3K
C++ Lecture
At some point in the second year of uni, I had a C++ tutorial with 4 other people (my Software Engineering group-mates). We managed to go to the wrong room, however- and since we didn't know where we should have been, we decided to revise the topic ourselves.
Basically, I lectured the material to my group-mates, and my friend (who has asked to remain nameless, due to his poor handwriting) wrote it up on his snazzy tablet PC. The results are these notes on delegation, adaptors and decorators in C++ (c++_lecture.pdf).