void VM::Execute(RNPE_Header *header) { memset(®isters, 0, sizeof(registers)); //Clear all the registers ESP = mOpts->GetMemSize() - 1; EBP = ESP; unsigned int v; memcpy(&v, Memory, 4); if(header) EIP = header->entry_pos; //it's either initialized or zeroed out Instruction* curInst = 0; for(EVER) { log << "EIP: 0x" << std::hex << EIP << std::dec << std::endl; curInst = Instruction::ReadInstruction(EIP); if(!curInst) { log << "Instruction failed to be created" << std::endl; break; } if(!curInst->IsValid()) { log << "SIGILL: Invalid Instruction <" << curInst->GetError() << ">" << std::endl; break; } log << "Incrementing EIP by: " << curInst->GetEipOffset() << std::endl; EIP += curInst->GetEipOffset(); curInst->Execute(); if(mOpts->IsStepping()) { dump(); getchar(); } } }