public void install(Program program) {
StatementSequence seq = new StatementSequence();
seq.addLast(new RTLVariableAssignment(1, ExpressionFactory.createVariable("%DF", 1), ExpressionFactory.FALSE));
AbsoluteAddress currentAddress = prologueAddress;
AbsoluteAddress fallthroughAddress = new AbsoluteAddress(currentAddress.getValue() + CALL_INSTR_DISTANCE);
// Call the entry point of the executable
push32(seq, ExpressionFactory.createNumber(fallthroughAddress.getValue(), 32));
seq.addLast(new RTLGoto(ExpressionFactory.createNumber(program.getStart().getAddress().getValue(), 32), RTLGoto.Type.CALL));
putSequence(program, seq, currentAddress);
program.setEntryAddress(currentAddress);
// Now call all procedures that were heuristically detected
for (Iterator<AbsoluteAddress> iter = entryPoints.iterator(); iter.hasNext();) {
AbsoluteAddress entryPoint = iter.next();
currentAddress = fallthroughAddress;
fallthroughAddress = iter.hasNext() ? new AbsoluteAddress(currentAddress.getValue() + 1) : prologueAddress;
seq = new StatementSequence();
for (RTLVariable v : program.getArchitecture().getRegisters()) {
if (!v.equals(esp))
clearReg(seq, v);
}
push32(seq, ExpressionFactory.createNumber(fallthroughAddress.getValue(), 32));
seq.addLast(new RTLGoto(ExpressionFactory.createNumber(entryPoint.getValue(), 32), RTLGoto.Type.CALL));
putSequence(program, seq, currentAddress);
}
lastAddress = currentAddress;