One key aspect of many modern programming languages is
that they are compiled into a portable intermediate form and executed
by a language runtime. Typically, the language runtime allows types to
be loaded at runtime from a binary source (e.g. from a file or from the
network) and executed. Two well known examples are the Java language,
which supports dynamic class loading, and the .NET framework which allows
assemblies to be dynamically loaded and executed.
One interesting side effect
of having dynamic code loading is that before actually loading the code
into a virtual machine, it is
possible to instrument
the code, introducing or removing specific instructions, changing the
use of classes, variables and constants. The key idea is that it is possible
to alter the code, performing some modifications, before the code is
actually executed. These transformations are either performed after compile
time, or at load time. This approach can be quite powerful. For instance,
it is possible to instrument the code so that proper resource control
takes place [1], change the code so that it is possible to serialize
and relocate executing threads in a cluster [2], perform program consistency
checks according to security policies [3], redirect method calls to proxies,
among others.
Two of the most important libraries in this area are
BCEL [4], which is now part of the Apache server, and provides a high-level
API for manipulating
Java byte code, and JOIE [5] that also allows java objects to be instrumented.
Together, these libraries have been used on more than 32 projects which
instrument Java code to perform the most various tasks. In [4] it is
presented a clear overview of many different types of projects that benefit
from this kind of technology. This kind of approach is even useful when
no dynamic class loading exists. For instance, EEL [6] is a C++ library
for instrument static executables.
It is our goal to study how this kind
of functionalities can be implemented in the .NET framework, and to actually
build a library
that provides that. Related to this, the Rotor code base will allow us
to understand the inner works of class resolution and loading, examine
the binary format of the assemblies and understand how the CLR manipulates
them. Rotor will also provide us with a platform where to experiment
with code rewriting, its interactions with the JIT, and learn how to
deal with pre compiled assemblies. We believe that by building such a library,
many important lessons will be learned that can be important to the research
community. At the same
time, after RAIL is built, a powerful tool will be available that can
help researchers to investigate into many different subjects like: security,
program verification, resource control, software fault injection, and
others.
|
[1] W. Binder, J. Hulaas, A. Villazón, and R.
Vidal: “Portable Resource Control in Java: The J SEAL2 Approach”,
in Proc. ACM Conference on Object-Oriented Programming, Systems, Languages,
and Applications (OOPSLA-2001), Florida, USA, 2001
[2] E. Truyen, B. Robben, B. Vanhaute, T. Coninx, W. Joosen, and P. Verbaeten: “Portable
support for transparent thread migration in Java”, in Proc. Joint
Symposium on Agent Systems and Applications/Mobile Agents (ASA/MA’2000),
Zürich, Switzerland, 2000
[3] A. Chander, J. Mitchell, and I. Shin: “Mobile code security through
java byte code modification”, available at: http://theory.stanford.edu/~vganesh/project.html
[4] “BCEL – The Byte Code Engineering Library”, available
at: http://jakarta.apache.org/bcel
[5] “JOIE – The Java Object Instrumentation Environment”,
available at: http://www.cs.duke.edu/ari/joie
[6] “EEL – An Executable Editing Library”, available
at: http://www.cs.wind.edu/~larus/eel.html
|