From d52a76a88e00b26b6d899f4229c9546ee72a15d5 Mon Sep 17 00:00:00 2001 From: Horde Nicolas Date: Sun, 11 Jul 2021 16:34:50 +0200 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20du=20code=20=C3=A0=20cha?= =?UTF-8?q?que=20it=C3=A9ration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ia86.cpp | 32 +++++++++++++++++--------------- ia86.h | 2 +- scenarios.json | 9 +++++++-- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ia86.cpp b/ia86.cpp index d224774..33fe622 100644 --- a/ia86.cpp +++ b/ia86.cpp @@ -679,26 +679,27 @@ uint32_t VMEngine::getNextInstr() std::vector> VMEngine::getInstr(int segment, int address,int size) { uint32_t realaddress=segment*16+address; - bool changed=false; if (realaddressbufferaddress+500) { - changed=true; - int begin=realaddress-30; - if (begin<0) begin=0x00000000; - err = uc_mem_read(uc, begin, code, 500); - if (err) - { - throw Error("VM IA86 - cache instructions......................[ERREUR]"); - } - bufferaddress=begin; + log->append("read"); + bufferaddress=realaddress-30; + if (bufferaddress<0) + bufferaddress=0x00000000; + address_old=address-30; + if (address_old<0) + address_old=0x00000000; } + err = uc_mem_read(uc, bufferaddress, code, 500); + if (err) + throw Error("VM IA86 - cache instructions......................[ERREUR]"); crc = crc32(0, code, 500); - if (crc != crc_old || changed) + if (crc != crc_old) { - unasmer.Desassemble(code, address, 500, &unasm); - if (unasm.src.size()==0) - throw Error("VM IA86 - cache instructions......................[ERREUR]"); - crc_old=crc; + log->append("unasm"); + unasmer.Desassemble(code, address_old, 500, &unasm); + if (unasm.src.size()==0) + throw Error("VM IA86 - cache instructions......................[ERREUR]"); + crc_old=crc; } int line=0; for(int pos: unasm.pos) @@ -739,6 +740,7 @@ void VMEngine::Configure(State *init, std::string code) return; Close(); Init(); + bufferaddress=-666; this->initialized=false; this->executed=false; //log->append("Mappage de la mémoire virtuelle"); diff --git a/ia86.h b/ia86.h index 38ad2f1..fb7e113 100644 --- a/ia86.h +++ b/ia86.h @@ -327,7 +327,7 @@ class VMEngine bool initialized=false; uc_engine *uc; uc_err err; - int bufferaddress=-555; + int bufferaddress; int address_old; uint8_t *code; uLong crc,crc_old; diff --git a/scenarios.json b/scenarios.json index e97db97..0ef29a7 100644 --- a/scenarios.json +++ b/scenarios.json @@ -8,8 +8,13 @@ "niveau_tutoriel" : "Ceci vous...", "niveau_code" : "mov ax,0x545 inc dx -mov esi,0x44441234 -hlt", +mov esi,0x44440234 +hlt +.org 0x8D +mov es,ax +.org 0x14D +mov es,ax +", "niveau_droits" : 10, "niveau_initial" : {