jmtd → software → examples
<p>
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.
</p>
<h4 id="libfaketime">libfaketime</h4>
<p>
libfaketime is a small, trivial library that lets you fake the
system time on a POSIX environment, via the gettimeofday() system call:
</p>
<pre class="code"
>$ 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.
</p><p>
If you want something more sophisticated, which also overrides
time/ftime, and allows you to set relative offsets, go to <a
href="http://www.code-wizards.com/projects/libfaketime/"
>http://www.code-wizards.com/projects/libfaketime/</a>, a
library which basically uses the same approach but wraps all
the time syscalls and is also called libfaketime.
</p><p>
Another useful LD_PRELOAD library is <a
href="http://freshmeat.net/projects/hidefile/" >hidefile</a>.
</p>
<h4 id="namekill">namekill</h4>
<p>
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 <a
href="http://www.mingw.org/">mingw</a>. Public Domain.
</p><p>
I wrote this in order to remove an annoying advert banner which
Durham University public computers would display when you logged in.
</p>
<ul>
<li><a href="namekill.exe.gz">namekill.exe.gz</a>, 34K</li>
<li><a href="namekill.c">namekill.c</a>, 1.3K</li>
</ul>
<h4 id="cpp">C++ Lecture</h4>
<p>
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.
</p>
<p>
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 <a href="c++_lecture.pdf"
>notes on delegation, adaptors and decorators in C++</a>
(c++_lecture.pdf).
</p>
This page was imported from my old site and is yet to be reviewed.