Embodiments of the present invention provide for platform independence,
low intrusiveness, and optimal memory usage of the binary instrumentation
process by means of employing one procedure (interceptor function)
implemented in a high-level programming language to intercept an
arbitrary number of functions or blocks of code. Each time a function or
code block needs to be intercepted a new copy of the procedure from a
provided memory region may be associated with the address of the function
or block of code by means of a memory region descriptor and an
intercepted function address table. Once activated, the interceptor
function may retrieve its current address and, by searching memory region
descriptors, determine the region the current address belongs to; the
region's base address may then be obtained. A reference to the
intercepted function address table may be fetched from the region
descriptor; and an index to the intercepted function address table may be
computed. Finally, the address of an intercepted function corresponding
to the active copy of the interceptor function may be read from the
intercepted function address table.