1. Introduction
Windows malware is routinely studied through
dynamic analysis: a sample is detonated inside an instrumented sandbox, and the sequence of API calls it makes—together with arguments, return values, and object handles—is recorded as a structured log. Public corpora of such logs now reach tens of thousands of samples, and a large body of work uses them as features for malware family classification and detection. All of this work rests on an implicit premise: that a recorded API-call sequence is a meaningful representation of the effects the malware produced—the files it created, the registry values it wrote, the connections it opened. The premise is intuitive, but to the best of our knowledge it has never been examined empirically for malware. As we discuss in
Section 2, recorded API calls have been re-issued before but only to test operating-system components; no prior study takes a
malware log and runs it, call by call, to observe what the recorded behavior does when carried out again.
This paper addresses that question directly, asking whether executing the file-related calls in a log creates the intended files, whether the registry calls reach the intended keys, whether a sequence that interleaves NT-native and Win32 calls reproduces as a chain—given that a handle minted by one layer is later consumed by the other—and what fraction of a real malware log reproduces, together with where and why reproduction fails. Answering this matters for two reasons. First, it supplies missing empirical footing for behavioral analysis: dynamic-analysis logs are widely trusted as behavior specifications, yet how much of a recorded log reproduces when carried out again had not been measured. Establishing this opens a third path between dynamic analysis, which is faithful but dangerous, and static analysis, which is safe but behavior blind. Second, and most concretely, the labeled endpoint telemetry that malware-classification and behavioral-detection research needs—for instance, Sysmon file and registry events, in live form, tagged by family—can today be obtained only by detonating real malware under a monitored host, which is dangerous, environment-dependent, and hard to reproduce. A method that regenerates such telemetry from a static log, without ever running the binary, would remove that barrier, turning existing log corpora into a safe source of labeled training data. Concretely, an analyst who holds a sample’s recorded API-call log but cannot—or must not—detonate the sample can use WinAPIReplay to re-execute that log inside an isolated virtual machine and obtain the file- and registry-events that the re-execution produces—captured by Sysmon and tagged with the sample’s family—turning a static log into labeled training data for malware-family classification, without the binary ever running. The same re-execution simultaneously yields the reproducibility measurement itself—a call-by-call account of which recorded operations carry over to a fresh environment and which do not.
Re-executing a recorded log is not trivial, which is why the question has remained open. Logged handle values are specific to the capture environment and invalid elsewhere; NT-native and Win32 calls interleave and must share one handle namespace; the re-execution must not damage or infect the host; and logged arguments—strings, structures, pointers—must be reconstructed into real call arguments. In this paper, we propose WinAPIReplay, which resolves these obstacles and, in doing so, turns a passive log into a controlled, repeatable re-execution.
Applying WinAPIReplay to 500 malware logs from five families, we find that 74.04% of modeled Layer-1 behavior-domain calls reproduce—the Layer-1 domain covering 57.98% of all recorded calls—that this reproduction is produced by the tool’s per-category executors rather than by a generic fallback, that the residual is dominated by intrinsic, environment-dependent behavior rather than by fixable tool gaps, that every side effect stays contained across all samples on the channels the tool models and monitors, and that the re-execution safely generates family-labeled endpoint telemetry from which malware families can be classified. This paper makes four contributions, none of which, to the best of our knowledge, appears in prior work.
C1—A behavior-reproduction tool (WinAPIReplay). A tool that re-executes both Win32 and NT-native API calls from a static log as real operating-system calls, using a unified handle map for cross-layer chains and a three-tier sandbox that contains all file, registry, and network side effects.
C2—The first quantitative measurement of dynamic-log reproducibility. Using WinAPIReplay, we measure how much of a real malware log reproduces in a fresh Windows environment, across 500 samples and five families.
C3—A four-way failure taxonomy. A method that separates fundamental, environment-dependent failure (true failure) from engineering-solvable barriers such as unresolved NT-to-Win32 handle dependencies, and quantifies each.
C4—Safe generation of labeled endpoint telemetry. A demonstration that running the re-execution under Sysmon synthesizes family-labeled file and registry events (Event ID 11/12/13/23) from static logs alone, without executing any malware binary—while the tool’s result record additionally recovers the original process arguments and network destinations that process suppression and network redirection remove from the corresponding Sysmon events—and that the generated file/registry telemetry is discriminative.
We organize the study around five research questions, which the experiments in
Section 5 address in turn.
RQ1. How much does the Layer-1 executor design improve behavior reproduction compared with a Layer-2-only (generic-dispatch) configuration?
RQ2. To what extent can WinAPIReplay reproduce Layer-1 API calls—as measured by the Layer-1 Behavior Reproduction Rate (L1 BRR)—and how does the rate vary across malware families and API categories?
RQ3. What are the principal causes of reproduction failure, and what fraction represents intrinsic, irreducible failure (true failure)?
RQ4. Is side-effect isolation complete across all samples, and how stable is the output—to what extent does an identical input under an identical initial state yield the same outcome sequence, and what accounts for the variation that remains?
RQ5. Can WinAPIReplay with Sysmon safely generate family-labeled endpoint telemetry, and is the generated data useful for machine-learning-based classification?
These questions map onto the four contributions: RQ1 and RQ4 establish that the tool (C1) reproduces behavior through its executor design and does so safely and stably; RQ2 delivers the reproducibility measurement (C2); RQ3 provides the failure taxonomy (C3); and RQ5 demonstrates safe telemetry generation and its utility (C4). Execution cost is reported alongside RQ4 as a measure of practicality.
The remainder of the paper is organized as follows.
Section 2 situates the work against prior recording, replay, emulation, and classification systems—as well as the one prior mechanism that re-issues recorded API calls and empirical studies of how malware behavior varies across environments—and states precisely what is new here.
Section 3 describes the design and implementation of WinAPIReplay—the two-layer executor model, the cross-layer handle map, and the three-tier sandbox.
Section 4 defines the corpus, the experimental environment and design, the reproduction metrics and their biases, the failure taxonomy, and the statistical methods.
Section 5 reports the eight experiments that answer the five research questions.
Section 6 discusses what the measurement means, why re-execution, rather than static transformation, is required to generate faithful telemetry, what this implies for detection-model training, the safety and stability that make the approach usable, and how the work stands in relation to prior art.
Section 7 sets out the limitations and threats to validity, and
Section 8 concludes.
3. Binary-Free Re-Execution of API-Call Logs: Executor Design
This section describes WinAPIReplay as a system, independently of any experiment. The tool takes one input—a recorded API-call log—and re-executes each recorded call as a real operating-system call, without the malware binary, inside a contained environment.
3.7. Side-Effect Containment: Three-Tier Sandbox and Dangerous-Call Blocking
Because WinAPIReplay issues real calls, containing their effects is a primary design concern rather than an afterthought. Three redirections confine every observable effect to disposable locations while still letting the operation genuinely occur—which is what makes later telemetry generation possible.
The
file tier rewrites every file-system path so that all file operations take place beneath a single disposable sandbox directory (
C:\Sandbox in our experiments), preserving the relative structure of the original path so that directory relationships are retained; local absolute paths, network share paths (of the form
\\server\share), and relative paths are each mapped into a dedicated area under that root. The
registry tier redirects every top-level registry root—including the machine-wide configuration root and the file-type/component registration root that malware often targets—into a dedicated sub-tree under the current user’s software key (
HKCU\Software\WinAPIReplaySandbox, where
HKCU abbreviates
HKEY_CURRENT_USER), and removes that sub-tree when the run ends; redirecting the machine-wide root into the user’s own area also sidesteps the need for administrative privileges. Before execution begins, the tool scans the log for the keys it will touch and creates them so that a recorded open of a key the malware had itself created earlier does not fail merely because the run starts from an empty sub-tree. The
network tier redirects address resolution and socket endpoints to the loopback address (
127.0.0.1, which always routes back to the same host and never reaches the network) and answers them with a benign local responder so that no packet leaves the host; the responder is “always ready”—on connection it offers a fixed 64 KiB block of data and then echoes whatever it receives—so that both client-initiated and server-initiated exchanges complete. The tool holds one Winsock reference of its own for the whole run so that recorded start-up and shutdown calls—which are themselves executed—can never tear down the session that later socket operations depend on. Data-carrying send-and-receive operations are satisfied with placeholder buffers of the recorded length, as are the input buffers of file and cryptographic calls elsewhere in the tool—zero-filled, except that the hashing call uses a constant non-zero byte. Registry values are an exception in the other direction: the log records the value data, so it is written as recorded.
Section 3.10 and
Section 4.5 treat this fidelity limitation.
Independently of these redirections, eight process- and thread-termination calls (for example
TerminateProcess and
NtTerminateProcess) are placed on a block-list and skipped before the layer decision is even made so that neither layer can execute them. This matters because, were such a call dispatched to Layer 2 and invoked, it would terminate the re-execution’s own process and truncate every remaining event; blocking it up front keeps the run intact at the cost of recording that single call as skipped. A second, disjoint block-list holds six calls that have no safe Layer-1 executor and would be hazardous if dispatched to the generic path with the log’s recorded arguments: an extended multi-object wait (
NtWaitForMultipleObjectsEx), a COM object-instantiation variant (
CoCreateInstanceEx), two low-level process-creation variants (
NtCreateProcessEx,
ZwCreateProcessEx), and two synchronization-object open variants (
ZwOpenSemaphore,
ZwOpenTimer). These are checked before the layer decision and, by design invariant, never overlap any executor’s supported set, so each such call is recorded as skipped and excluded from the reproduction rate. Process creation is contained by substitution rather than by blocking: the native and shell creation variants always report the success the caller expects without spawning anything, and for
CreateProcess and
WinExec an option—enabled in every run of
Section 5—does the same so that no child process is ever created while the intended command line and creation flags are still preserved as process events (
Section 3.9). The net intent is that real file, registry, and network effects occur but only inside designated, reversible locations, and never in a form that can terminate the run or escape the host.
A third form of containment applies to individual calls whose real execution would leave a persistent or system-wide side effect that no redirection can confine. Rather than being redirected or skipped, these calls are executed as safe substitutes that return the success value the caller expects while performing none of the dangerous action. A hook-installation call (SetWindowsHookEx) returns a non-null sentinel without installing any system-wide hook, which would otherwise burden every desktop thread on the machine. A privilege-adjustment call (AdjustTokenPrivileges) returns success without altering the process token, whose privileges the tool must keep intact for its own sandboxed operations. For a non-system library path supplied by the malware, a library-load call is issued with a data-file-only flag (LOAD_LIBRARY_AS_DATAFILE) so that the named library is mapped for inspection without executing its initialization routine (DllMain). A service-creation call returns a handle to an existing benign service instead of writing a new entry into the service-control database, which is persisted in the registry outside the sandbox. A debugger-attach call (DbgUiConnectToDbg), which malware uses as an anti-analysis probe and which would attach the tool’s own process to the kernel debug subsystem, returns success without connecting. In each case the call is reported as succeeding, so control flow proceeds, while its dangerous effect is never realized.
7. Limitations and Threats to Validity
Fidelity ceiling. Reproduction is bounded by intrinsic, environment-dependent behavior: 25.79% of Layer-1 calls are true failures, so the tool measures and generates a reproduced subset, not the whole of a sample’s behavior. Telemetry generation inherits this ceiling.
Dataset-specific handle gaps. A structural feature of the WinMET traces is that some object handles are created before capture begins and thus never appear as a producing call; such handles cannot be mapped, so calls that depend on them cannot reproduce. This is a property of the input corpus, not of the executor design; the failures it directly causes are captured by the handle-dependent category (recovered in the Projected L1 BRR), but the gap bounds what any re-execution of these logs can achieve.
Near-determinism, not determinism. Because the operating system assigns live handle values afresh on each run, output is generally not byte-identical across runs—the exceptions being samples that produce no live handle values; we demonstrate near-determinism (98.90% event stability, residual confined to handle calls, aggregate metrics within 0.41 percentage points) rather than strict determinism.
Telemetry scope. The faithful, malware-labeled Sysmon telemetry is limited to file and registry events (Event ID 11/12/13/23), whose sandbox paths the transforms correct back to the malware’s intended targets. The corresponding process-creation (Event ID 1) and network-connection (Event ID 3) events instead carry the tool’s own image and a loopback destination, because process creation is suppressed and traffic is redirected for safety; the malware’s intended process arguments and network destinations are preserved in the tool’s result record, so process-name- and C2-address-based detection must consume that record rather than the Sysmon stream directly.
Statistical power. The classification comparison uses 100 samples, and its McNemar test is both underpowered and, because leave-one-out folds are not independent, mildly anti-conservative; we therefore report the path-aware telemetry as statistically indistinguishable from the API-category-rate baseline, not as an improvement on it.
Environment scope. Side-effect operations execute against a sandbox on a single virtual-machine configuration, so both the reproduction measurement and the generated telemetry reflect that environment rather than the original victim’s state, and the disclosed measurement biases, together with the 39,177 calls answered without the recorded operation being carried out (
Table 7), make L1 BRR an upper-bound estimate of behavior reproduction. Containment is likewise scoped to the effect channels the tool models—file, registry, and network operations, together with the process- and thread-termination calls on the block-list—so an effect reaching the host through an unmodeled channel would fall outside its guarantee, even though none did across the 500 samples. It is worth stating which channels those are. Named kernel objects are the one case in which this corpus exercises an unsandboxed channel: the 6205 recorded mutant and event calls are re-executed with their original names, so the objects are created in the system-wide namespace rather than under a sandbox root, and although the operating system releases them when the re-execution process exits, they are visible to other processes while it runs. The remaining channels are either neutralized or absent. Process, thread, and shell launches (7444 calls) are suppressed by the no-spawn policy and are listed in
Table 7; the 125 service-control calls never reach the service database, because service start reports success without an attempt and no service is ever created; opens of device paths and named pipes are short-circuited, and registry operations are rewritten into the sandbox sub-tree, both of which the zero-escape measurement covers; of the 69 Winsock calls, the 20 that would open or address a connection are redirected to a loopback responder and the rest are library initialization and socket closure; and 3764 calls are refused outright, these being the two block-listed termination routines that the corpus actually invokes. COM activation is attempted against the real subsystem but never succeeded here (0 of the 38,549 calls actually executed); the attempt itself, however, initializes the COM subsystem, and the telemetry run recorded sixteen key-creation events under a WMI configuration key in eight samples—a subsystem side effect that the before-and-after comparison of
Section 5.4 does not register as a persistent change, but that a monitor watching the process does see. Device-control requests—the only route by which this corpus could reach symbolic links or junctions—are dispatched generically with zeroed arguments (3949 calls). Named pipes, scheduled tasks, symbolic-link creation, and alternate data streams do not occur in the corpus at all, so the zero-escape result says nothing about them.
Generality. The evaluation covers five families and one dataset; the specific rates should not be extrapolated to other families, corpora, or Windows versions without further study. The tool also presupposes that API-call logs are already available—it consumes logs, it does not acquire them.