Desassemblage depuis la mémoire, sans aucune borne, CRC pour vérification de changement

This commit is contained in:
Horde Nicolas 2021-07-09 09:39:59 +02:00
parent 6229019b75
commit 5e2288fcc2
4 changed files with 26 additions and 3 deletions

View File

@ -45,6 +45,8 @@ RUN git clone https://github.com/dahut87/finalcut.git
WORKDIR /usr/src/finalcut
RUN autoreconf --install --force && ./configure --prefix=/usr && make && make install
RUN apk --no-cache add zlib-dev
RUN adduser -D -H -u 502 utilisateur
RUN adduser -D -H -u 1000 utilisateurs
RUN mkdir /data

View File

@ -1,5 +1,5 @@
CC=g++ -O2
LFLAGS=-lfinal -lkeystone -lstdc++ -lm -lcapstone -lunicorn
LFLAGS=-lfinal -lkeystone -lstdc++ -lm -lcapstone -lunicorn -lz
OPTIONS=-std=c++17
DOCKER=docker run -it -e COLUMNS="$$(tput cols)" -e LINES="$$(tput lines)" --name maker --rm -v $$(pwd):/data maker
XTERM=terminator -f -e

View File

@ -10,6 +10,7 @@
#include <unicorn/unicorn.h>
#include <capstone/capstone.h>
#include <vector>
#include <zlib.h>
#include "ia86.h"
#include "struct_mapping/struct_mapping.h"
@ -495,7 +496,14 @@ std::string VMEngine::getFlags(int rights)
uint8_t *VMEngine::getRamRaw(uint32_t address, uint32_t size)
{
uint8_t *code=new uint8_t[512];
err = uc_mem_read(uc, address, code, size);
if (err)
{
log->append("Erreur de copie mémoire depuis la machine virtuelle");
return NULL;
}
return code;
}
std::string VMEngine::getRegs(int rights)
@ -1084,7 +1092,7 @@ void Menu::refresh()
{
regs.set(vm.getRegs(scenario.levels[scenar.getselected()].rights));
flags.set(vm.getFlags(scenario.levels[scenar.getselected()].rights));
//debug.setindex(vm.getEIP(code));
//debug.setindex(vm.getEIP(code));
}
if (!vm.isExecuted())
{
@ -1093,6 +1101,16 @@ void Menu::refresh()
else
{
finalcut::FApplication::setDefaultTheme();
eip=vm.getEIP()-256;
if (eip<0) eip=0x00000000;
code=vm.getRamRaw(eip, 512);
crc = crc32(0, code, 512);
if (crc != oldcrc || eip != oldeip)
{
debug.set(unasmer.Desassemble(code, eip,512));
oldcrc=crc;
oldeip=eip;
}
}
auto root_widget = getRootWidget();
root_widget->resetColors();

3
ia86.h
View File

@ -309,6 +309,9 @@ class Menu final : public finalcut::FDialog
void loadLevel();
TextWindow log{this};
private:
int eip,oldeip;
uint8_t *code;
uLong crc,oldcrc;
void onTimer (finalcut::FTimerEvent*) override;
void refresh();
void configureFileMenuItems();