An application program interface (API) replay tool and method is disclosed
for modeling and testing APIs. The replay tool receives as input a set of
API calls and associated context information and resources. A set of
components are called to map variables and a context into the replay tool
environment. An API builder translates the original API call (including
mapping memory references of parameters) into a sequence of assembly code
instructions, constituting the replayed API call, which is placed in an
execution buffer. The execution buffer is thereafter executed in a replay
environment including a set of resources extracted from a source binary
file associated with the replayed API. Thereafter, the operating system,
or other suitable consumer of API calls, executes the call in the context
recreated by the API replay tool prior to passing the call.