Inside the Plutonium Bootstrapper: Four Themida VMs and a Silent Integrity Check
I took apart the Themida layer of Plutonium's bootstrapper offline, lifted the virtualized start of main back to C, and mapped the client protections behind it. The integrity check never shows an error. It quietly skips the game's TLS set-up.
On this page
Plutonium is a community project that keeps four old Call of Duty games
playable online on its own servers: World at War, Black Ops, Black Ops II and
Modern Warfare 3. All four start through the same file,
plutonium-bootstrapper-win32.exe, and that file is packed and virtualized
with Themida (it carries WinLicense registry strings; I never pinned the
version). I wanted to know two things: how this build of the Themida VM
actually works, and what the client checks once the VM is out of the way. For
the game side I stayed on Black Ops II.
I am not the first to take Themida apart. The Recon 2024 talk on its mutation engine and back.engineering's static devirtualization cover the protector from the static side. I found no public write-up of Plutonium's client protections, so most of the second half is new.
I never attached a debugger to the bootstrapper, and for the Themida work I
never ran it natively either. That part comes from static work in IDA and from
running the file inside an emulator. The only live runs were LAN sessions of the
real game on my own machine, to confirm a few behaviours the emulator could not
reach. By the end I had four VM machines mapped, the outer VM of
main decoded for every operation I could reach offline, the start of
main lifted back to C and checked against the emulator, and two start-up
integrity checks recovered. When those checks fail there is no message box, no
exit, nothing. The bootstrapper just skips setting up the game's TLS data.
The companion repository has three small C++ programs that reproduce the results. The first runs on your own copy of the file and needs nothing else.
View the PoC on GitHubWhat runs before main
The PE entry point sits in a section called .boot. It does a call/pop to find
its own address, unpacks .themida with aPLib, checks a guard dword and jumps
in. That first stage is plain native code, so I could reproduce it offline byte
for byte and get the real .themida contents without executing anything.
Stage 1 is the first VM. It resolves every API it needs by hashing export
names, and that hashing is most of what it executes. Around it, stage 1 runs the
usual anti-debug, monitor and VM checks and records the results as verdict
bytes. Under the emulator the file runs a little over two billion instructions
before it reaches the original entry point. I re-ran it while writing this and
got the same instruction count and the same system calls, with the same
arguments and results, as the first run a month earlier. That entry point has
been stolen: mainCRTStartup itself is virtualized on a second machine. Then
plutonium::main checks its .payload section, makes one import call and
enters a third machine. The application body, with authentication, the RCI
client and the anti-cheat worker, runs on a fourth.
One VM instruction at a time
Each of the four machines has its own handler table, its own context block and
its own bytecode. I counted handlers from the relocation pass Themida runs on
each table at first entry, because it rewrites exactly the table entries and
nothing else. The smallest machine has about 500 handlers, the largest about
1,500. Every entry is an E9 thunk to a distinct handler body. I call the
machines VM-A to VM-D; VM-A is the one that runs main.
There is no dispatch loop. A handler does its one job, then works out the next handler by itself and jumps to it. The opcode stored in a VM instruction is the index of the next handler, not the current one, and that index is encoded. In most handlers the handler reads an operand word, mixes it with a 16-bit key that lives in the context, runs it through a few mutated arithmetic steps that differ per handler, adds a signed offset to the VM instruction pointer and jumps through the table. Two decryptions from VM-C, as they come out once the junk is folded:
idx = (key16 + 0x214) & 0xFFFF; // vmc_038
idx = ((0x20B84 - ((((k ^ 0x7D4C) + k) << 2) & 0x2A698)) & 0x3EFFC) / 4; // vmc_27aBytecode is a linked list. Each instruction says where the next one is, and the
instructions are scattered through .themida between handler bodies. Operand
layouts are per handler. So there is no linear byte stream to disassemble, and
no single place to set a breakpoint and watch "the VM".
The register file is a set of context slots addressed by operand words, and permutation handlers rename those slots constantly. Each context has a handful of hot fields that the handlers keep mixing into their key chains; in VM-A one 16-bit key shows up in almost every handler.
What makes the four machines feel different is layout. The lock byte, the VM
instruction pointer, the table pointer, the VM stack pointer and the key fields
all sit at different offsets in each machine, and the handler code is mutated
with junk such as edi ^ (c ^ edi). A handler pattern learned on VM-A does not
match on VM-B. I stopped trying to match handlers early, for that reason.
Virtual conditional jumps
Each machine has its own set of 16 condition codes for conditional jumps. They
are random bytes, so 0x02 is je on one machine and means nothing on the
next. I recovered the full map for VM-D, the stage-1 machine, from its jump
handlers; the table is in the repository.
During one full emulated run, VM-D took about half a million conditional
jumps. For every one of them I compared the map's prediction with the "taken"
byte the handler writes into its own context: zero mismatches. Only the common
codes (je, jne, jb and two more) came up in that run. The rest come from
reading the handler.
Running it in an emulator
All of the dynamic work ran in Sogen, a Windows user-mode emulator, on its Unicorn backend, driven from Python, with Triton for symbolic replay and z3 to check the results. Themida is a good test of an emulator, because a gap in the emulator looks exactly like an analysis tool.
To show it for this write-up I rebuilt the emulator twice, once as it is and once with that two-line fix reverted, and compared the system call journals of the two runs:
first difference: syscall #1511 at instruction 328,869,633 fix applied NtAllocateVirtualMemory -> 0x0 fix reverted NtAllocateVirtualMemory -> 0xc00000a0 reverted run, ins 1,948,686,521 NtUserMessageBeep reverted run, ins 1,949,145,767 NtUserSetMsgBox fix applied: entry point reached fix reverted: no entry point, message box, message loop
One refused page commit, and 1.6 billion instructions later Themida beeps and draws its box.
That was one of about twenty fidelity fixes. Others covered anonymous pipes
(Windows 10 creates them with an empty name relative to \Device\NamedPipe\,
and the UCRT crashes if that fails), WoW64 exception and XSTATE handling, and
the debug-exception instruction pointer. Most are now
fixed upstream; the WoW64 context one is open as
momo5502/sogen#2056.
Every run used an instruction-count clock and a fixed start epoch, so two runs from process start behave the same down to the instruction.
The VM inside the VM
main is protected twice. VM-A runs a router with 44 slots and its own context.
Each slot is an outer handler, and each outer handler is written in VM-A
bytecode. The router context holds the outer instruction pointer. An outer
handler reads its operands there, works out the next slot and the next outer
instruction pointer, and returns to the router. One slot calls a native
function, another leaves the VM.
The outer bytecode is static: every outer instruction I sampled matched the bytes on disk. What changes is the router's decoding state, and it turned out to be small, 20 bytes. Given those 20 bytes and the static operands, every successor slot and every next outer instruction pointer follows.
My first approach was the classic one: derive a next-slot formula per outer handler. Some slots used a plain operand word. Others mixed several router bytes through multiplies, subtractions and an XOR. I had a dozen of these formulas when it became obvious they would never survive the next build.
Folding the protector away
What worked was to stop decoding handlers at all. I took one emulator snapshot at the router's first entry and replayed from it in Triton with a single rule: every byte inside the protector's own section (contexts, tables, bytecode, handler code) is concrete, and every other byte gets a fresh symbol the first time it is touched. Native calls are cut and resumed at their return thunk with fresh symbolic results. No per-slot formula, no hand-picked key bytes, nothing imported from a trace.
Under that rule the decoding machinery is just constant arithmetic on concrete
bytes, and the solver folds it away. What remains symbolic is exactly what the
program depends on: the clock, the tick count, the process ID, argv.
The replay predicted all 612 completed outer transitions on three independent recordings, including one made with the host clock instead of the fixed epoch, with zero mismatches. Not one successor and not one byte of decoding state depended on an input. I ran it again in one pass for this write-up, about an hour and a half of Triton:
symbolic successors 0, symbolic decoding bytes 0, input-dependent branches 0 corpus A (fixed clock) checked 612 successor_ok 612 projected_ok 612 corpus repeat checked 612 successor_ok 612 projected_ok 612 corpus T5 (host clock) checked 612 successor_ok 612 projected_ok 612
The router bytes that do differ between recordings are application data, such as a stack dword the clock call overwrote, never decoding state.
Two dead ends taught me something here. ESP first looked symbolic, through junk
like edi ^ (c ^ edi) that cancels out, so every dependence verdict now goes
through the solver: only an UNSAT proof counts as "constant". And one recording
disagreed at a single operation, because _time64 had overwritten a stack slot that the
replay still held from before the native call. Cutting a native call has to
invalidate the callee's stack region too.
The repetition explains why this is tractable. Over those operations VM-A dispatched more than a quarter of a million handlers, and 99% of them repeat a handler, instruction pointer and key state it had already seen.
What main actually does first
With decoding gone, I replayed main effect by effect: Triton on the VM-A code,
the emulator for native calls, and a comparison with the emulator's own state at
every router transfer. Every boundary matched on slot, stack pointer, live
stack and written VM pages. Expanding the stores into main's frame back to
their inputs gives this:
__time64_t t = _time64(NULL);
DWORD tick = GetTickCount();
DWORD pid = GetCurrentProcessId();
srand((uint32_t)t ^ ~(tick * pid)); // proved with z3
int q1 = rand() / 426315782; // always 0
int q2 = rand() / 412255378; // always 0
integrity_check_code(); // first check
integrity_check_status(); // second check
/* then the first read of argv */The two divisions are opaque predicates. rand() never returns more than
0x7FFF, so both quotients are zero on every run, and nothing uses them. My
guess for the seed is the integrity flags: Themida's SDK check macros take an
unpredictable value to start from, and nothing else in this stretch reads it.
The main_prefix program in the repository replays those lines with the
recorded native results and the MSVC rand() generator written out by hand:
srand seed 0x9B0F4539 recorded 0x9B0F4539 MATCH rand() #1 0x0D06 recorded 0x0D06 MATCH q1 = r1 / 426315782 = 0 rand() #2 0x0AEC recorded 0x0AEC MATCH q2 = r2 / 412255378 = 0 all 2^32 seeds: nonzero quotients 0, max rand() 0x7FFF
The check that never complains
The first check looks like a native call from the outer VM, but its target is a
protector routine. It allocates a buffer the size of .main, copies the whole
section into it, and folds it 32 bits at a time.
The loop is native code inside .themida, mutated like everything else. This
is the start of it in IDA's graph view. The first block builds esi in edx
through a constant it adds and removes, the second does the real work in one
line (add eax, [edx]), and the third is a long run of pushes, pops and
exchanges around the stack:
Pulled out of the unconditional jumps and the junk, these are the instructions that matter:
13DF7151 add eax, [edx] ; h += d
13E0D262 rol eax, 10h ; h = rol32(h, 16)
13DFEE93 xor eax, [edx] ; h ^= d (same dword, read again)
13DF83BF jno 13DF83CA ; always taken
13DF8446 jnb 13DF8451 ; always taken: OR clears CF
13DF845D xor edx, ecx ; edx = 4, built from constants
13DF8460 mov edi, edx / ... / add esi, edi ; esi += 4
13E00375 sub ecx, 6FFBAF00h / add ecx, eax / add ecx, 6FFBAF00h ; ecx -= 1Fold the constants and drop the branches that always go one way, and it is three lines:
uint32_t h = 0;
for (size_t i = 0; i < 0x623000 / 4; i++)
h = rol32(h + d[i], 16) ^ d[i];It runs for well over a hundred million emulated instructions, all inside
.themida, with no system call. The result is compared with a value Themida packed
into .themida at build time: 0x8A6116A2. Only the stage-0 unpacker ever
writes that dword, and only this check ever reads it.
The second check comes a few dozen outer operations later. It tests a dword in the protector's data that
is zero on a clean start. Nothing in stage 1 or in main writes it on any path I
emulated; my best guess is a start-up status word that the protector sets when
something goes wrong. When I poked it to 1, the check took the other branch and
returned early.
Neither check decides anything on the spot. Each one, on success, has a VM-C
handler store a magic value into a flag in .main. That is all.
Only one function reads those flags: native code in .main that sets up the
loaded game's TLS. It takes the TLS data directory of the game image, refuses a
template larger than the space it reserved, calls VirtualProtect and copies
the template into the thread's TLS slot. Before any of that, it checks that the
two flags hold the expected pair. If they do not, it returns without doing
anything.
So a modified .main does not produce an error. The bootstrapper carries on,
authenticates, maps the game, and hands it a thread with no TLS data. Whatever
breaks next breaks far from the check. I could not run past authentication
offline, so the exact symptom is inference. The decision is not: with the
checksum perturbed by one bit, the flag store disappears, and the TLS routine's test
fails on the dumped values.
This part does not need an emulator to check. integrity_hash unpacks stage 0
in C++ (byte-identical to my Python unpacker), reads the packed value out of the
unpacked .themida, and folds .main straight
from the file. The image has no relocations and .main's raw size is exactly
the copy length, so the file bytes are the bytes the protector hashes.
input sha256 6c405bec03a89b8d954d8ae5edea1bed89b4147f53e4dbe68ced6ef5a815a96b (r5354) stored checksum [0x13B949BB] = 0x8A6116A2 computed 0x8A6116A2 h = rol32(h + d, 16) ^ d over 1608704 dwords, h0 = 0 result MATCH
one-bit changes in a private copy of .main (file untouched): .main+0x000000 ^= 0x01 -> 0x145F4F30 MISMATCH .main+0x622FFF ^= 0x01 -> 0x8B6117A2 MISMATCH
The protections behind the VM
The application body, on VM-B, is where the anti-cheat lives. I mapped it by
calling every protected entry point in .main on its own, starting each game
component with its hooks, driving the authentication path with forced success
and ban responses, and running the first frame of the integrity worker.
A few things stood out.
Most of it is quiet. The start-up checks feed the TLS skip above. Once logged
in, a worker hashes the game's code every 30 seconds and sends the digest
encrypted. The memory guards on executable allocations and
VirtualProtect never block the call; they report it, with the caller and a
stack capture. The verdict for all of these is made on the server.
Login carries a machine fingerprint. The authentication request holds a
digest of the bootstrapper's own code, a hardware ID built from several hashed
machine identifiers, and a key protected with DPAPI, so it only decrypts under
the same Windows account. That lets the server recognize a machine, not only an
account. From that request on, the client also refuses to start new processes through
CreateProcess. I kept the identifiers and their filtering out of this post.
The game image is checked before it runs. The bootstrapper only maps game
executables whose whole-file SHA-1 is on a short allow-list, and DLLs the game
imports go through a hash list plus WinVerifyTrust. A DLL that fails is either
deleted or answered with a fake loader error.
Some of it is delayed on purpose. When the UI script checksum does not match,
the client does not react at once. It rolls rand() % 28, and on a hit it
disables the emulation of Steam's CEG decryption, so the next protected call
site in the game crashes inside Steam's original code path. I forced that path in
the real game in LAN mode: the result is a generic "The game ran into a problem"
dialog and a crash dump, with nothing that points back at the check.
I left the rest of the detail out on purpose: keys, flag values, the exact fingerprint inputs, which launch modes change what, and how any of it could be switched off.
Reproducing it
The repository has three programs, all in C++20 with CMake:
integrity_hashreads your ownplutonium-bootstrapper-win32.exer5354 (SHA-2566c405bec03a89b8d954d8ae5edea1bed89b4147f53e4dbe68ced6ef5a815a96b), unpacks stage 0, recomputes the.mainhash and compares it with the packed value.vjcc_vmdimplements VM-D's condition map and its jump handler, decodes every operand from your own unpacked.themida, and checks the result against the flags and outcomes recorded in the emulated run.main_prefixreplays the lifted start ofmainwith the recorded native results, and shows why bothrand()quotients are always zero.
A fourth, handler_stats, counts the handlers of the four machines straight
from the file. Each program's full output is in the repository. None of them
run Plutonium, touch the network or ship any of its code.
Conclusion
This build of Themida puts four separate VMs in front of Plutonium's code, each
with its own handler set, its own context layout and its own condition codes,
and runs main through a second VM on top of the first. None of that layering
survived a simple rule: treat the protector's own bytes as constants and let a
solver decide what depends on the outside world. The decoding is expensive to
run and cheap to remove. If I started again I would fix the emulator before
touching the VM: the fake debugger and a pipe the UCRT could not create cost me
more time than any handler.
The anti-cheat behind it makes a better choice than the VM does. Almost nothing
fails loudly. A modified .main costs the game its TLS data much later, a bad
UI checksum turns into a generic crash some time later, and the reports and the
login fingerprint go to a server that makes the call where the client cannot
see it. A cheat developer who gets a visible error knows which byte to look at.
One who gets a generic crash minutes later does not. For a community project,
that is the right trade.
What I could not see is the server. Everything here stops at the request the client sends; what Plutonium does with a digest that does not match, or with a fingerprint it has seen before, stays on their side. Three questions stay open on the client too: what sets the protector status word in a real failure, the condition-code maps of the three other VMs, and how much of this carries over to the clients for the other three games.


![IDA graph view of three blocks of the mutated checksum loop: a block that sets edx to esi through 533C5140h, a block with add eax, [edx], and a long block of push, pop and xchg junk.](/static/ida-checksum-loop-d32601.png)